LRESULT CALLBACK keyboard_hook_event_proc(int nCode, WPARAM wParam, LPARAM lParam) { // Calculate Unix epoch from native time source. uint64_t timestamp = get_event_timestamp(); KBDLLHOOKSTRUCT *kbhook = (KBDLLHOOKSTRUCT *) lParam; switch (wParam) { case WM_KEYDOWN: case WM_SYSKEYDOWN: process_key_pressed(timestamp, kbhook); break; case WM_KEYUP: case WM_SYSKEYUP: process_key_released(timestamp, kbhook); break; } LRESULT hook_result = -1; if (nCode < 0 || event.reserved ^ 0x01) { hook_result = CallNextHookEx(keyboard_event_hhook, nCode, wParam, lParam); } else { logger(LOG_LEVEL_DEBUG, "%s [%u]: Consuming the current event. (%li)\n", __FUNCTION__, __LINE__, (long) hook_result); } return hook_result; }
LRESULT CALLBACK keyboard_hook_event_proc(int nCode, WPARAM wParam, LPARAM lParam) { KBDLLHOOKSTRUCT *kbhook = (KBDLLHOOKSTRUCT *) lParam; switch (wParam) { case WM_KEYDOWN: case WM_SYSKEYDOWN: process_key_pressed(kbhook); break; case WM_KEYUP: case WM_SYSKEYUP: process_key_released(kbhook); break; default: // In theory this *should* never execute. logger(LOG_LEVEL_INFO, "%s [%u]: Unhandled Windows keyboard event: %#X.\n", __FUNCTION__, __LINE__, (unsigned int) wParam); break; } LRESULT hook_result = -1; if (nCode < 0 || event.reserved ^ 0x01) { hook_result = CallNextHookEx(keyboard_event_hhook, nCode, wParam, lParam); } else { logger(LOG_LEVEL_DEBUG, "%s [%u]: Consuming the current event. (%li)\n", __FUNCTION__, __LINE__, (long) hook_result); } return hook_result; }
ACTION kbd_interface_routine(PLAYER *player, int edit_mode) { int key; ACTION act=ACT_NONE; key = get_kbd_press(); if (key != 0) act = edit_mode ? process_key_pressed_edit(player, key) : process_key_pressed(player, key); #ifdef USE_MOUSE if (act == ACT_NONE) { int shift_state = get_kbd_shift() & 9; act = mouse_interface_routine(player, shift_state, edit_mode); } #endif return act; }