TY Moros
| 7810 | |
| 7811 | //TY Moros |
| 7812 | static EM_BOOL keyboard_callback(int eventType, const EmscriptenKeyboardEvent* e, void* userData) |
| 7813 | { |
| 7814 | // we maintain our own state for teh number pad, default true |
| 7815 | static bool numPadActive = true; |
| 7816 | |
| 7817 | // THANK GOD!! for this compute function. And thanks Dandistine for pointing it out! |
| 7818 | int pk_code = emscripten_compute_dom_pk_code(e->code); |
| 7819 | |
| 7820 | if(!numPadActive) |
| 7821 | { |
| 7822 | /** |
| 7823 | * we need to react differently if the numlock is not |
| 7824 | * active. this block ensures uniform behavior with |
| 7825 | * windows and linux, MacOS is a lost cause due to GLUT. |
| 7826 | */ |
| 7827 | switch(pk_code) |
| 7828 | { |
| 7829 | case DOM_PK_NUMPAD_7: pk_code = DOM_PK_HOME; break; |
| 7830 | case DOM_PK_NUMPAD_8: pk_code = DOM_PK_ARROW_UP; break; |
| 7831 | case DOM_PK_NUMPAD_9: pk_code = DOM_PK_PAGE_UP; break; |
| 7832 | case DOM_PK_NUMPAD_4: pk_code = DOM_PK_ARROW_LEFT; break; |
| 7833 | case DOM_PK_NUMPAD_5: pk_code = DOM_PK_UNKNOWN; break; |
| 7834 | case DOM_PK_NUMPAD_6: pk_code = DOM_PK_ARROW_RIGHT; break; |
| 7835 | case DOM_PK_NUMPAD_1: pk_code = DOM_PK_END; break; |
| 7836 | case DOM_PK_NUMPAD_2: pk_code = DOM_PK_ARROW_DOWN; break; |
| 7837 | case DOM_PK_NUMPAD_3: pk_code = DOM_PK_PAGE_DOWN; break; |
| 7838 | case DOM_PK_NUMPAD_0: pk_code = DOM_PK_INSERT; break; |
| 7839 | case DOM_PK_NUMPAD_DECIMAL: pk_code = DOM_PK_DELETE; break; |
| 7840 | default: |
| 7841 | break; |
| 7842 | } |
| 7843 | } |
| 7844 | |
| 7845 | // check for keydown + numlock and act appropriately |
| 7846 | if (eventType == EMSCRIPTEN_EVENT_KEYDOWN && pk_code == DOM_PK_NUM_LOCK) |
| 7847 | { |
| 7848 | numPadActive = !numPadActive; |
| 7849 | } |
| 7850 | |
| 7851 | if (eventType == EMSCRIPTEN_EVENT_KEYDOWN) |
| 7852 | ptrPGE->olc_UpdateKeyState(pk_code, true); |
| 7853 | |
| 7854 | if (eventType == EMSCRIPTEN_EVENT_KEYUP) |
| 7855 | ptrPGE->olc_UpdateKeyState(pk_code, false); |
| 7856 | |
| 7857 | //Consume keyboard events so that keys like F1 and F5 don't do weird things |
| 7858 | return EM_TRUE; |
| 7859 | } |
| 7860 | |
| 7861 | //TY Moros |
| 7862 | static EM_BOOL wheel_callback(int eventType, const EmscriptenWheelEvent* e, void* userData) |
nothing calls this directly
no test coverage detected