fixed poll events for Windows;

Canoi dbe8ce52 a54ddc98

Changed files
+23 -3
+8 -3
bite.c
··· 19 19 void bite_poll_events(void) { 20 20 #if defined(_WIN32) 21 21 MSG message; 22 - while (GetMessage(&message, NULL, 0, 0)) { 22 + if (GetMessage(&message, NULL, 0, 0)) { 23 23 TranslateMessage(&message); 24 24 DispatchMessage(&message); 25 25 } ··· 92 92 } 93 93 break; 94 94 case WM_DESTROY: PostQuitMessage(0); break; 95 - default: return DefWindowProc(hwnd, msg, wParam, lParam); 95 + case WM_SYSKEYDOWN: 96 + case WM_KEYDOWN: { 97 + e.type = BITE_KEY_PRESSED; 98 + e.key.keycode = (int)wParam; 99 + } 100 + break; 96 101 } 97 102 be_EventCallback fn = _callbacks[e.type]; 98 103 if (fn) fn(&e); 99 - return 0; 104 + return DefWindowProc(hwnd, msg, wParam, lParam); 100 105 } 101 106 #else 102 107 #endif
+10
bite.h
··· 57 57 BITE_EVENTS 58 58 }; 59 59 60 + enum { 61 + BITEK_NONE = 0, 62 + BITEK_ESCAPE, 63 + BITEK_RETURN, 64 + BITEK_UP, 65 + BITEK_RIGHT, 66 + BITEK_DOWN, 67 + BITEK_LEFT 68 + }; 69 + 60 70 struct be_Window { 61 71 int x, y; 62 72 int width, height;
+5
main.c
··· 5 5 static int running = 1; 6 6 7 7 void key_pressed(be_Event* ev) { 8 + printf("Pressed: %x\n", ev->key.keycode); 9 + #if defined(_WIN32) 10 + if (ev->key.keycode == VK_ESCAPE) running = 0; 11 + #else 8 12 if (ev->key.keycode == 0x09) running = 0; 13 + #endif 9 14 } 10 15 11 16 void quit_callback(be_Event* ev) {