Revision: 23579
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=23579
Author:   damien78
Date:     2009-10-01 10:58:09 +0200 (Thu, 01 Oct 2009)

Log Message:
-----------
Cocoa port, events WIP:
- Fix keyboard keymap
- NSAutoReleasePool now drained at every cycle
- Tablet events combined with mouse events now handled

Modified Paths:
--------------
    trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.h
    trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.mm

Modified: trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.h
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.h       2009-10-01 
04:14:43 UTC (rev 23578)
+++ trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.h       2009-10-01 
08:58:09 UTC (rev 23579)
@@ -252,7 +252,7 @@
     //static void s_timerCallback(TMTaskPtr tmTask);
     
        /** Cocoa autoReleasePool (void*) used for enablign standard C++ 
compilation */
-       void* autoReleasePool;
+       void* m_autoReleasePool;
        
     /** Event handler reference. */
     //EventHandlerRef m_handler;

Modified: trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.mm
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.mm      2009-10-01 
04:14:43 UTC (rev 23578)
+++ trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.mm      2009-10-01 
08:58:09 UTC (rev 23579)
@@ -49,27 +49,17 @@
 #include "GHOST_NDOFManager.h"
 #include "AssertMacros.h"
 
-#define GHOST_KEY_SWITCH(mac, ghost) { case (mac): ghostKey = (ghost); break; }
-
-/* blender class and types events */
-enum {
-  kEventClassBlender              = 'blnd'
-};
-
-enum {
-       kEventBlenderNdofAxis                   = 1,
-       kEventBlenderNdofButtons                = 2
-};
-
 #pragma mark KeyMap, mouse converters
 
+//TODO: remove (kept as reminder to implement window events)
+/*
 const EventTypeSpec    kEvents[] =
 {
        { kEventClassAppleEvent, kEventAppleEvent },
-/*
-       { kEventClassApplication, kEventAppActivated },
-       { kEventClassApplication, kEventAppDeactivated },
-*/     
+
+//     { kEventClassApplication, kEventAppActivated },
+//     { kEventClassApplication, kEventAppDeactivated },
+       
        { kEventClassKeyboard, kEventRawKeyDown },
        { kEventClassKeyboard, kEventRawKeyRepeat },
        { kEventClassKeyboard, kEventRawKeyUp },
@@ -81,10 +71,10 @@
        { kEventClassMouse, kEventMouseDragged },
        { kEventClassMouse, kEventMouseWheelMoved },
        
-       { kEventClassWindow, kEventWindowClickZoomRgn } ,  /* for new zoom 
behaviour */ 
-       { kEventClassWindow, kEventWindowZoom },  /* for new zoom behaviour */ 
-       { kEventClassWindow, kEventWindowExpand } ,  /* for new zoom behaviour 
*/ 
-       { kEventClassWindow, kEventWindowExpandAll },  /* for new zoom 
behaviour */ 
+       { kEventClassWindow, kEventWindowClickZoomRgn } ,  // for new zoom 
behaviour  
+       { kEventClassWindow, kEventWindowZoom },  // for new zoom behaviour  
+       { kEventClassWindow, kEventWindowExpand } ,  // for new zoom behaviour 
+       { kEventClassWindow, kEventWindowExpandAll },  // for new zoom 
behaviour 
 
        { kEventClassWindow, kEventWindowClose },
        { kEventClassWindow, kEventWindowActivated },
@@ -97,7 +87,7 @@
        
        
        
-};
+};*/
 
 static GHOST_TButtonMask convertButton(EventMouseButton button)
 {
@@ -117,103 +107,155 @@
        }
 }
 
-static GHOST_TKey convertKey(int rawCode, unsigned char asciiCharacter) 
+/**
+ * Converts Mac rawkey codes (same for Cocoa & Carbon)
+ * into GHOST key codes
+ * @param rawCode The raw physical key code
+ * @param recvChar the character ignoring modifiers (except for shift)
+ * @return Ghost key code
+ */
+static GHOST_TKey convertKey(int rawCode, unichar recvChar) 
 {      
-               /* This bit of magic converts the rawCode into a virtual
-                * Mac key based on the current keyboard mapping, but
-                * without regard to the modifiers (so we don't get 'a' 
-                * and 'A' for example.
-                */
-               /* Map numpad based on rawcodes first, otherwise they
-                * look like non-numpad events.
-                * Added too: mapping the number keys, for french keyboards etc 
(ton)
-                */
-       // printf("GHOST: vk: %d %c raw: %d\n", asciiCharacter, asciiCharacter, 
rawCode);
-       //FIXME : check rawcodes         
+       
+       //printf("\nrecvchar %c 0x%x",recvChar,recvChar);
        switch (rawCode) {
-       case 18:        return GHOST_kKey1;
-       case 19:        return GHOST_kKey2;
-       case 20:        return GHOST_kKey3;
-       case 21:        return GHOST_kKey4;
-       case 23:        return GHOST_kKey5;
-       case 22:        return GHOST_kKey6;
-       case 26:        return GHOST_kKey7;
-       case 28:        return GHOST_kKey8;
-       case 25:        return GHOST_kKey9;
-       case 29:        return GHOST_kKey0;
+               /*Physical keycodes not used due to map changes in int'l 
keyboards
+               case kVK_ANSI_A:        return GHOST_kKeyA;
+               case kVK_ANSI_B:        return GHOST_kKeyB;
+               case kVK_ANSI_C:        return GHOST_kKeyC;
+               case kVK_ANSI_D:        return GHOST_kKeyD;
+               case kVK_ANSI_E:        return GHOST_kKeyE;
+               case kVK_ANSI_F:        return GHOST_kKeyF;
+               case kVK_ANSI_G:        return GHOST_kKeyG;
+               case kVK_ANSI_H:        return GHOST_kKeyH;
+               case kVK_ANSI_I:        return GHOST_kKeyI;
+               case kVK_ANSI_J:        return GHOST_kKeyJ;
+               case kVK_ANSI_K:        return GHOST_kKeyK;
+               case kVK_ANSI_L:        return GHOST_kKeyL;
+               case kVK_ANSI_M:        return GHOST_kKeyM;
+               case kVK_ANSI_N:        return GHOST_kKeyN;
+               case kVK_ANSI_O:        return GHOST_kKeyO;
+               case kVK_ANSI_P:        return GHOST_kKeyP;
+               case kVK_ANSI_Q:        return GHOST_kKeyQ;
+               case kVK_ANSI_R:        return GHOST_kKeyR;
+               case kVK_ANSI_S:        return GHOST_kKeyS;
+               case kVK_ANSI_T:        return GHOST_kKeyT;
+               case kVK_ANSI_U:        return GHOST_kKeyU;
+               case kVK_ANSI_V:        return GHOST_kKeyV;
+               case kVK_ANSI_W:        return GHOST_kKeyW;
+               case kVK_ANSI_X:        return GHOST_kKeyX;
+               case kVK_ANSI_Y:        return GHOST_kKeyY;
+               case kVK_ANSI_Z:        return GHOST_kKeyZ;*/
+               
+               /* Numbers keys mapped to handle some int'l keyboard (e.g. 
French)*/
+               case kVK_ISO_Section: return    GHOST_kKeyUnknown;
+               case kVK_ANSI_1:        return GHOST_kKey1;
+               case kVK_ANSI_2:        return GHOST_kKey2;
+               case kVK_ANSI_3:        return GHOST_kKey3;
+               case kVK_ANSI_4:        return GHOST_kKey4;
+               case kVK_ANSI_5:        return GHOST_kKey5;
+               case kVK_ANSI_6:        return GHOST_kKey6;
+               case kVK_ANSI_7:        return GHOST_kKey7;
+               case kVK_ANSI_8:        return GHOST_kKey8;
+               case kVK_ANSI_9:        return GHOST_kKey9;
+               case kVK_ANSI_0:        return GHOST_kKey0;
        
-       case 82:        return GHOST_kKeyNumpad0;
-       case 83:        return GHOST_kKeyNumpad1;
-       case 84:        return GHOST_kKeyNumpad2;
-       case 85:        return GHOST_kKeyNumpad3;
-       case 86:        return GHOST_kKeyNumpad4;
-       case 87:        return GHOST_kKeyNumpad5;
-       case 88:        return GHOST_kKeyNumpad6;
-       case 89:        return GHOST_kKeyNumpad7;
-       case 91:        return GHOST_kKeyNumpad8;
-       case 92:        return GHOST_kKeyNumpad9;
-       case 65:        return GHOST_kKeyNumpadPeriod;
-       case 76:        return GHOST_kKeyNumpadEnter;
-       case 69:        return GHOST_kKeyNumpadPlus;
-       case 78:        return GHOST_kKeyNumpadMinus;
-       case 67:        return GHOST_kKeyNumpadAsterisk;
-       case 75:        return GHOST_kKeyNumpadSlash;
-       }
-       
-       if ((asciiCharacter >= 'a') && (asciiCharacter <= 'z')) {
-               return (GHOST_TKey) (asciiCharacter - 'a' + GHOST_kKeyA);
-       } else if ((asciiCharacter >= '0') && (asciiCharacter <= '9')) {
-               return (GHOST_TKey) (asciiCharacter - '0' + GHOST_kKey0);
-       } else if (asciiCharacter==16) {
-               switch (rawCode) {
-               case 122:       return GHOST_kKeyF1;
-               case 120:       return GHOST_kKeyF2;
-               case 99:        return GHOST_kKeyF3;
-               case 118:       return GHOST_kKeyF4;
-               case 96:        return GHOST_kKeyF5;
-               case 97:        return GHOST_kKeyF6;
-               case 98:        return GHOST_kKeyF7;
-               case 100:       return GHOST_kKeyF8;
-               case 101:       return GHOST_kKeyF9;
-               case 109:       return GHOST_kKeyF10;
-               case 103:       return GHOST_kKeyF11;
-               case 111:       return GHOST_kKeyF12;  // FIXME : Never get, is 
used for ejecting the CD! 
-               }
-       } else {
-               switch (asciiCharacter) {
-               case kUpArrowCharCode:          return GHOST_kKeyUpArrow;
-               case kDownArrowCharCode:        return GHOST_kKeyDownArrow;
-               case kLeftArrowCharCode:        return GHOST_kKeyLeftArrow;
-               case kRightArrowCharCode:       return GHOST_kKeyRightArrow;
+               case kVK_ANSI_Keypad0:                  return 
GHOST_kKeyNumpad0;
+               case kVK_ANSI_Keypad1:                  return 
GHOST_kKeyNumpad1;
+               case kVK_ANSI_Keypad2:                  return 
GHOST_kKeyNumpad2;
+               case kVK_ANSI_Keypad3:                  return 
GHOST_kKeyNumpad3;
+               case kVK_ANSI_Keypad4:                  return 
GHOST_kKeyNumpad4;
+               case kVK_ANSI_Keypad5:                  return 
GHOST_kKeyNumpad5;
+               case kVK_ANSI_Keypad6:                  return 
GHOST_kKeyNumpad6;
+               case kVK_ANSI_Keypad7:                  return 
GHOST_kKeyNumpad7;
+               case kVK_ANSI_Keypad8:                  return 
GHOST_kKeyNumpad8;
+               case kVK_ANSI_Keypad9:                  return 
GHOST_kKeyNumpad9;
+               case kVK_ANSI_KeypadDecimal:    return GHOST_kKeyNumpadPeriod;
+               case kVK_ANSI_KeypadEnter:              return 
GHOST_kKeyNumpadEnter;
+               case kVK_ANSI_KeypadPlus:               return 
GHOST_kKeyNumpadPlus;
+               case kVK_ANSI_KeypadMinus:              return 
GHOST_kKeyNumpadMinus;
+               case kVK_ANSI_KeypadMultiply:   return GHOST_kKeyNumpadAsterisk;
+               case kVK_ANSI_KeypadDivide:     return GHOST_kKeyNumpadSlash;
+               case kVK_ANSI_KeypadClear:              return 
GHOST_kKeyUnknown;
 
-               case kReturnCharCode:           return GHOST_kKeyEnter;
-               case kBackspaceCharCode:        return GHOST_kKeyBackSpace;
-               case kDeleteCharCode:           return GHOST_kKeyDelete;
-               case kEscapeCharCode:           return GHOST_kKeyEsc;
-               case kTabCharCode:                      return GHOST_kKeyTab;
-               case kSpaceCharCode:            return GHOST_kKeySpace;
-
-               case kHomeCharCode:             return GHOST_kKeyHome;
-               case kEndCharCode:                      return GHOST_kKeyEnd;
-               case kPageUpCharCode:           return GHOST_kKeyUpPage;
-               case kPageDownCharCode:         return GHOST_kKeyDownPage;
-
-               case '-':       return GHOST_kKeyMinus;
-               case '=':       return GHOST_kKeyEqual;
-               case ',':       return GHOST_kKeyComma;
-               case '.':       return GHOST_kKeyPeriod;
-               case '/':       return GHOST_kKeySlash;
-               case ';':       return GHOST_kKeySemicolon;
-               case '\'':      return GHOST_kKeyQuote;
-               case '\\':      return GHOST_kKeyBackslash;
-               case '[':       return GHOST_kKeyLeftBracket;
-               case ']':       return GHOST_kKeyRightBracket;
-               case '`':       return GHOST_kKeyAccentGrave;
-               }
+               case kVK_F1:                            return GHOST_kKeyF1;
+               case kVK_F2:                            return GHOST_kKeyF2;
+               case kVK_F3:                            return GHOST_kKeyF3;
+               case kVK_F4:                            return GHOST_kKeyF4;
+               case kVK_F5:                            return GHOST_kKeyF5;
+               case kVK_F6:                            return GHOST_kKeyF6;
+               case kVK_F7:                            return GHOST_kKeyF7;
+               case kVK_F8:                            return GHOST_kKeyF8;
+               case kVK_F9:                            return GHOST_kKeyF9;
+               case kVK_F10:                           return GHOST_kKeyF10;
+               case kVK_F11:                           return GHOST_kKeyF11;
+               case kVK_F12:                           return GHOST_kKeyF12;
+               case kVK_F13:                           return GHOST_kKeyF13;
+               case kVK_F14:                           return GHOST_kKeyF14;
+               case kVK_F15:                           return GHOST_kKeyF15;
+               case kVK_F16:                           return GHOST_kKeyF16;
+               case kVK_F17:                           return GHOST_kKeyF17;
+               case kVK_F18:                           return GHOST_kKeyF18;
+               case kVK_F19:                           return GHOST_kKeyF19;
+               case kVK_F20:                           return GHOST_kKeyF20;
+                       
+               case kVK_UpArrow:                       return 
GHOST_kKeyUpArrow;
+               case kVK_DownArrow:                     return 
GHOST_kKeyDownArrow;
+               case kVK_LeftArrow:                     return 
GHOST_kKeyLeftArrow;
+               case kVK_RightArrow:            return GHOST_kKeyRightArrow;
+                       
+               case kVK_Return:                        return GHOST_kKeyEnter;
+               case kVK_Delete:                        return 
GHOST_kKeyBackSpace;
+               case kVK_ForwardDelete:         return GHOST_kKeyDelete;

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to