From f50ffc067222c998bd6db1c7907aeec6ec23c867 Mon Sep 17 00:00:00 2001 From: gephilipp <> Date: Tue, 17 Jul 2007 20:16:16 +0000 Subject: [PATCH] Mouse look handling change --- panda/src/osxdisplay/osxGraphicsWindow.mm | 93 +++++++++++++---------- 1 file changed, 53 insertions(+), 40 deletions(-) diff --git a/panda/src/osxdisplay/osxGraphicsWindow.mm b/panda/src/osxdisplay/osxGraphicsWindow.mm index 0bf8275822..351fc81ddb 100644 --- a/panda/src/osxdisplay/osxGraphicsWindow.mm +++ b/panda/src/osxdisplay/osxGraphicsWindow.mm @@ -379,7 +379,7 @@ static pascal OSStatus appEvtHndlr (EventHandlerCallRef myHandler, EventRef even case kEventClassKeyboard: { switch (kind) { - case kEventRawKeyRepeat: + case kEventRawKeyRepeat: case kEventRawKeyDown: result = osx_win->handleKeyInput (myHandler, event, true); break; @@ -1223,30 +1223,31 @@ OSStatus osxGraphicsWindow::handleKeyInput (EventHandlerCallRef myHandler, Event // are already mapped in the desktop seem to not even come into this // function in the first place. UInt32 newModifiers = 0; - OSStatus error = GetEventParameter(event, kEventParamKeyModifiers, - typeUInt32, NULL, sizeof(UInt32), - NULL, &newModifiers); - if(error == noErr) { - HandleModifireDeleta(newModifiers); - } + OSStatus error = GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &newModifiers); + if(error == noErr) + HandleModifireDeleta(newModifiers); UInt32 keyCode; - GetEventParameter(event, kEventParamKeyCode, typeUInt32, NULL, - sizeof(UInt32), NULL, &keyCode); + GetEventParameter(event, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode); ButtonHandle button = OSX_TranslateKey(keyCode, event); - if (keyDown) { - if ((newModifiers & cmdKey) != 0) { - if (button == KeyboardButton::ascii_key("q") || - button == KeyboardButton::ascii_key("w")) { + if (keyDown) + { + if ((newModifiers & cmdKey) != 0) + { + if (button == KeyboardButton::ascii_key("q") || button == KeyboardButton::ascii_key("w")) + { // Command-Q or Command-W: quit the application or close the // window, respectively. For now, we treat them both the // same: close the window. user_close_request(); } } + SendKeyEvent(button, true); - } else { + } + else + { SendKeyEvent(button, false); } @@ -1295,7 +1296,7 @@ void osxGraphicsWindow::SystemSetWindowForground(bool forground) WindowRef window = NULL; OSStatus result = eventNotHandledErr; UInt32 kind = GetEventKind (event); - EventMouseButton button = 0; +// EventMouseButton button = 0; Point qdGlobalPoint = {0, 0}; UInt32 modifiers = 0; Rect rectPort; @@ -1318,7 +1319,7 @@ void osxGraphicsWindow::SystemSetWindowForground(bool forground) // start trackball, pan, or dolly case kEventMouseDown: { - GetEventParameter(event, kEventParamMouseButton, typeMouseButton, NULL, sizeof(EventMouseButton), NULL, &button); +// GetEventParameter(event, kEventParamMouseButton, typeMouseButton, NULL, sizeof(EventMouseButton), NULL, &button); GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers); if(_properties.get_mouse_mode()==WindowProperties::M_relative) { @@ -1332,11 +1333,17 @@ void osxGraphicsWindow::SystemSetWindowForground(bool forground) GetEventParameter(event, kEventParamMouseLocation,typeQDPoint, NULL, sizeof(Point),NULL , (void*) &qdGlobalPoint); SystemPointToLocalPoint(qdGlobalPoint); } - ButtonHandle button_h = MouseButton::one(); - if(kEventMouseButtonSecondary == button) + + ButtonHandle button_h = MouseButton::one(); + UInt32 buttons = GetCurrentEventButtonState(); + + if (buttons & (1 << 1)) +// if(kEventMouseButtonSecondary == button) button_h = MouseButton::three(); - if(kEventMouseButtonTertiary == button) + if (buttons & (1 << 2)) +// if(kEventMouseButtonTertiary == button) button_h = MouseButton::two(); + _input_devices[0].set_pointer_in_window((int)qdGlobalPoint.h, (int)qdGlobalPoint.v); _input_devices[0].button_down(button_h); result = noErr; @@ -1345,7 +1352,7 @@ void osxGraphicsWindow::SystemSetWindowForground(bool forground) // stop trackball, pan, or dolly case kEventMouseUp: { - GetEventParameter(event, kEventParamMouseButton, typeMouseButton, NULL, sizeof(EventMouseButton), NULL, &button); +// GetEventParameter(event, kEventParamMouseButton, typeMouseButton, NULL, sizeof(EventMouseButton), NULL, &button); // GetEventParameter(event, kEventParamWindowMouseLocation, typeHIPoint, NULL, sizeof(HIPoint), NULL, &location); // Mac OS X v10.1 and later if(_properties.get_mouse_mode()==WindowProperties::M_relative) { @@ -1359,11 +1366,17 @@ void osxGraphicsWindow::SystemSetWindowForground(bool forground) GetEventParameter(event, kEventParamMouseLocation,typeQDPoint, NULL, sizeof(Point),NULL , (void*) &qdGlobalPoint); SystemPointToLocalPoint(qdGlobalPoint); } - ButtonHandle button_h = MouseButton::one(); - if(kEventMouseButtonSecondary == button) + + ButtonHandle button_h = MouseButton::one(); + UInt32 buttons = GetCurrentEventButtonState(); + +// if(kEventMouseButtonSecondary == button) + if (buttons & (1 << 1)) button_h = MouseButton::three(); - if(kEventMouseButtonTertiary == button) +// if(kEventMouseButtonTertiary == button) + if (buttons & (1 << 2)) button_h = MouseButton::two(); + _input_devices[0].set_pointer_in_window((int)qdGlobalPoint.h, (int)qdGlobalPoint.v); _input_devices[0].button_up(button_h); result = noErr; @@ -1475,16 +1488,16 @@ void osxGraphicsWindow::SystemSetWindowForground(bool forground) case 76: nk = KeyboardButton::enter(); break; case 36: nk = KeyboardButton::enter(); break; - case 123: nk = KeyboardButton::left(); break; + case 123: nk = KeyboardButton::left(); break; case 124: nk = KeyboardButton::right(); break; - case 125: nk = KeyboardButton::down(); break; + case 125: nk = KeyboardButton::down(); break; case 126: nk = KeyboardButton::up(); break; - case 116: nk = KeyboardButton::page_up(); break; - case 121: nk = KeyboardButton::page_down(); break; - case 115: nk = KeyboardButton::home(); break; + case 116: nk = KeyboardButton::page_up(); break; + case 121: nk = KeyboardButton::page_down(); break; + case 115: nk = KeyboardButton::home(); break; case 119: nk = KeyboardButton::end(); break; case 114: nk = KeyboardButton::help(); break; - case 117: nk = KeyboardButton::del(); break; + case 117: nk = KeyboardButton::del(); break; // case 71: nk = KeyboardButton::num_lock() break; @@ -1507,17 +1520,17 @@ void osxGraphicsWindow::SystemSetWindowForground(bool forground) case 106: nk = KeyboardButton::f16(); break; // shiftable chartablet - case 50: nk = KeyboardButton::ascii_key('`'); break; - case 27: nk = KeyboardButton::ascii_key('-'); break; - case 24: nk = KeyboardButton::ascii_key('='); break; - case 33: nk = KeyboardButton::ascii_key('['); break; - case 30: nk = KeyboardButton::ascii_key(']'); break; - case 42: nk = KeyboardButton::ascii_key('\\'); break; - case 41: nk = KeyboardButton::ascii_key(';'); break; - case 39: nk = KeyboardButton::ascii_key('\''); break; - case 43: nk = KeyboardButton::ascii_key(','); break; - case 47: nk = KeyboardButton::ascii_key('.'); break; - case 44: nk = KeyboardButton::ascii_key('/'); break; + case 50: nk = KeyboardButton::ascii_key('`'); break; + case 27: nk = KeyboardButton::ascii_key('-'); break; + case 24: nk = KeyboardButton::ascii_key('='); break; + case 33: nk = KeyboardButton::ascii_key('['); break; + case 30: nk = KeyboardButton::ascii_key(']'); break; + case 42: nk = KeyboardButton::ascii_key('\\'); break; + case 41: nk = KeyboardButton::ascii_key(';'); break; + case 39: nk = KeyboardButton::ascii_key('\''); break; + case 43: nk = KeyboardButton::ascii_key(','); break; + case 47: nk = KeyboardButton::ascii_key('.'); break; + case 44: nk = KeyboardButton::ascii_key('/'); break; default: if (osxdisplay_cat.is_debug()) {