Adding support for the "media" play/pause/stop/next/prev buttons
authorJoshua Leung <aligorith@gmail.com>
Fri, 18 Feb 2011 22:42:03 +0000 (22:42 +0000)
committerJoshua Leung <aligorith@gmail.com>
Fri, 18 Feb 2011 22:42:03 +0000 (22:42 +0000)
available on many keyboards these days, so that they can be used for
animation playback (giving more options over alt-a and alt-a ad-
infinitum).

Currently, this is Windows only as I don't have a Linux/Mac system to
test on (it should compile with both mingw and msvc, at least using
scons). Maintainers for those systems can probably easily add this in
once they find out the relevant mappings for those systems.

intern/ghost/GHOST_Types.h
intern/ghost/intern/GHOST_EventPrinter.cpp
intern/ghost/intern/GHOST_SystemWin32.cpp
source/blender/makesrna/intern/rna_object_api.c
source/blender/makesrna/intern/rna_wm.c
source/blender/windowmanager/intern/wm_event_system.c
source/blender/windowmanager/wm_event_types.h

index af17b10bf00e5d427282288d137cb2e53d677279..c3bc8d17b65ed7a12bc43a61e812466591434eb0 100644 (file)
@@ -353,7 +353,13 @@ typedef enum {
        GHOST_kKeyF21,
        GHOST_kKeyF22,
        GHOST_kKeyF23,
-       GHOST_kKeyF24
+       GHOST_kKeyF24,
+       
+       // Multimedia keypad buttons
+       GHOST_kKeyMediaPlay,
+       GHOST_kKeyMediaStop,
+       GHOST_kKeyMediaFirst,
+       GHOST_kKeyMediaLast
 } GHOST_TKey;
 
 typedef enum {
index 697ced64a70bde0e8cc3d2f3d2c59d8fad6c687f..b3d936aedbe8b4f02020b4df87dccefbbafef11e 100644 (file)
@@ -325,6 +325,18 @@ void GHOST_EventPrinter::getKeyString(GHOST_TKey key, STR_String& str) const
                case GHOST_kKeyNumpadSlash:
                        str = "NumpadSlash";
                        break;
+               case GHOST_kKeyMediaPlay:
+                       str = "MediaPlayPause";
+                       break;
+               case GHOST_kKeyMediaStop:
+                       str = "MediaStop";
+                       break;
+               case GHOST_kKeyMediaFirst:
+                       str = "MediaFirst";
+                       break;
+               case GHOST_kKeyMediaLast:
+                       str = "MediaLast";
+                       break;
                default:
                        str = "unknown";
                        break;
index 24f9e96b109e1e290d064440bbe53712911a8fc7..64a1c20922696c9894b5c8234f9fba6b21e85b84 100644 (file)
 #define VK_GR_LESS 0xE2
 #endif // VK_GR_LESS
 
+#ifndef VK_MEDIA_NEXT_TRACK
+#define VK_MEDIA_NEXT_TRACK    0xB0
+#endif // VK_MEDIA_NEXT_TRACK
+#ifndef VK_MEDIA_PREV_TRACK
+#define VK_MEDIA_PREV_TRACK    0xB1
+#endif // VK_MEDIA_PREV_TRACK
+#ifndef VK_MEDIA_STOP
+#define VK_MEDIA_STOP  0xB2
+#endif // VK_MEDIA_STOP
+#ifndef VK_MEDIA_PLAY_PAUSE
+#define VK_MEDIA_PLAY_PAUSE    0xB3
+#endif // VK_MEDIA_PLAY_PAUSE
+
 
 GHOST_SystemWin32::GHOST_SystemWin32()
 : m_hasPerformanceCounter(false), m_freq(0), m_start(0)
@@ -640,6 +653,10 @@ GHOST_TKey GHOST_SystemWin32::convertKey(GHOST_IWindow *window, WPARAM wParam, L
                case VK_OEM_8:
                        key = ((GHOST_SystemWin32*)getSystem())->processSpecialKey(window, wParam, lParam);
                        break;
+               case VK_MEDIA_PLAY_PAUSE: key = GHOST_kKeyMediaPlay; break;
+               case VK_MEDIA_STOP: key = GHOST_kKeyMediaStop; break;
+               case VK_MEDIA_PREV_TRACK: key = GHOST_kKeyMediaFirst; break;
+               case VK_MEDIA_NEXT_TRACK: key = GHOST_kKeyMediaLast; break;
                default:
                        key = GHOST_kKeyUnknown;
                        break;
index ac4b86b40367aa65859fbe61a73cbc7fdb6b5ebc..9f1ef7396c0833d26e17f4a8fe0e5f55b4628dea 100644 (file)
@@ -331,7 +331,7 @@ static PointerRNA rna_Object_shape_key_add(Object *ob, bContext *C, ReportList *
 
 int rna_Object_is_visible(Object *ob, Scene *sce)
 {
-       return !(ob->restrictflag & OB_RESTRICT_VIEW) && ob->lay & sce->lay;
+       return !(ob->restrictflag & OB_RESTRICT_VIEW) && (ob->lay & sce->lay);
 }
 
 /*
index b4500a77f8469e160afb75ada784cd6b52c4b500..fd328a1545b788a404d83147417c9945cf42965e 100644 (file)
@@ -241,6 +241,11 @@ EnumPropertyItem event_type_items[] = {
        {PAGEDOWNKEY, "PAGE_DOWN", 0, "Page Down", ""},
        {ENDKEY, "END", 0, "End", ""},
        {0, "", 0, NULL, NULL},
+       {MEDIAPLAY, "MEDIA_PLAY", 0, "Media Play/Pause", ""},
+       {MEDIASTOP, "MEDIA_STOP", 0, "Media Stop", ""},
+       {MEDIAFIRST, "MEDIA_FIRST", 0, "Media First", ""},
+       {MEDIALAST, "MEDIA_LAST", 0, "Media Last", ""},
+       {0, "", 0, NULL, NULL},
        {WINDEACTIVATE, "WINDOW_DEACTIVATE", 0, "Window Deactivate", ""},
        {TIMER, "TIMER", 0, "Timer", ""},
        {TIMER0, "TIMER0", 0, "Timer 0", ""},
index af78e7113f7a40d8acc6cb57a3db4126c270b259..39a6e5b27b52e8e130f5012fbc462e6b0b5481e1 100644 (file)
@@ -2196,7 +2196,12 @@ static int convert_key(GHOST_TKey key)
                        case GHOST_kKeyNumpadSlash:             return PADSLASHKEY;
                                
                        case GHOST_kKeyGrLess:              return GRLESSKEY; 
-                               
+                       
+                       case GHOST_kKeyMediaPlay:               return MEDIAPLAY;
+                       case GHOST_kKeyMediaStop:               return MEDIASTOP;
+                       case GHOST_kKeyMediaFirst:              return MEDIAFIRST;
+                       case GHOST_kKeyMediaLast:               return MEDIALAST;
+                       
                        default:
                                return UNKNOWNKEY;      /* GHOST_kKeyUnknown */
                }
index 5d7eb625f7877e43e41bf4aee0881f1b36a95e79..c3573f86c6d2d42d2a2a8c54f48b9c20dcdc28e4 100644 (file)
 #define OSKEY          172
 #define GRLESSKEY      173
 
+// XXX: are these codes ok?
+#define MEDIAPLAY      174
+#define MEDIASTOP      175
+#define MEDIAFIRST     176
+#define MEDIALAST      177
+
 /* for event checks */
        /* only used for KM_TEXTINPUT, so assume that we want all user-inputtable ascii codes included */
 #define ISTEXTINPUT(event)     (event >=' ' && event <=255)