void GHOST_NDOFManager::updateButton(int button_number, bool press, GHOST_TUns64 time) { GHOST_IWindow* window = m_system.getWindowManager()->getActiveWindow(); #ifdef DEBUG_NDOF_BUTTONS if (m_deviceType != NDOF_UnknownDevice) printf("ndof: button %d -> ", button_number); #endif switch (m_deviceType) { case NDOF_SpaceNavigator: sendButtonEvent(SpaceNavigator_HID_map[button_number], press, time, window); break; case NDOF_SpaceExplorer: switch (button_number) { case 6: sendKeyEvent(GHOST_kKeyEsc, press, time, window); break; case 7: sendKeyEvent(GHOST_kKeyLeftAlt, press, time, window); break; case 8: sendKeyEvent(GHOST_kKeyLeftShift, press, time, window); break; case 9: sendKeyEvent(GHOST_kKeyLeftControl, press, time, window); break; default: sendButtonEvent(SpaceExplorer_HID_map[button_number], press, time, window); } break; case NDOF_SpacePilotPro: switch (button_number) { case 22: sendKeyEvent(GHOST_kKeyEsc, press, time, window); break; case 23: sendKeyEvent(GHOST_kKeyLeftAlt, press, time, window); break; case 24: sendKeyEvent(GHOST_kKeyLeftShift, press, time, window); break; case 25: sendKeyEvent(GHOST_kKeyLeftControl, press, time, window); break; default: sendButtonEvent(SpacePilotPro_HID_map[button_number], press, time, window); } break; case NDOF_SpacePilot: switch (button_number) { case 10: sendKeyEvent(GHOST_kKeyEsc, press, time, window); break; case 11: sendKeyEvent(GHOST_kKeyLeftAlt, press, time, window); break; case 12: sendKeyEvent(GHOST_kKeyLeftShift, press, time, window); break; case 13: sendKeyEvent(GHOST_kKeyLeftControl, press, time, window); break; case 20: puts("ndof: ignoring CONFIG button"); break; default: sendButtonEvent(SpacePilot_HID_map[button_number], press, time, window); } break; case NDOF_UnknownDevice: printf("ndof: button %d on unknown device (ignoring)\n", button_number); } int mask = 1 << button_number; if (press) { m_buttons |= mask; // set this button's bit } else { m_buttons &= ~mask; // clear this button's bit } }
void GHOST_NDOFManager::updateButton(int button_number, bool press, GHOST_TUns64 time) { GHOST_IWindow *window = m_system.getWindowManager()->getActiveWindow(); #ifdef DEBUG_NDOF_BUTTONS printf("ndof: button %d -> ", button_number); #endif NDOF_ButtonT button = (button_number < m_buttonCount) ? m_hidMap[button_number] : NDOF_BUTTON_NONE; switch (button) { case NDOF_BUTTON_NONE: #ifdef DEBUG_NDOF_BUTTONS printf("discarded\n"); #endif break; case NDOF_BUTTON_ESC: sendKeyEvent(GHOST_kKeyEsc, press, time, window); break; case NDOF_BUTTON_ALT: sendKeyEvent(GHOST_kKeyLeftAlt, press, time, window); break; case NDOF_BUTTON_SHIFT: sendKeyEvent(GHOST_kKeyLeftShift, press, time, window); break; case NDOF_BUTTON_CTRL: sendKeyEvent(GHOST_kKeyLeftControl, press, time, window); break; default: sendButtonEvent(button, press, time, window); } int mask = 1 << button_number; if (press) { m_buttons |= mask; // set this button's bit } else { m_buttons &= ~mask; // clear this button's bit } }