Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Keyboard.h
- *
- * Created on: 18 jun. 2019
- * Author: Gebruiker
- */
- #include <windows.h>
- #include <stdio.h>
- #include <conio.h>
- typedef struct KeyboardState {
- int quit;
- int left;
- int right;
- int up;
- int down;
- int no;
- } KeyboardState;
- KeyboardState getKeyboardState() {
- KeyboardState state = { 0 };
- int ch;
- int add;
- state.quit = ((ch = _getch()) == 27) /* 27 = Esc key */;
- if (ch == 0 || ch == 224) {
- add = _getch();
- state.up = ((add == 72));
- state.left = ((add == 75));
- state.right = ((add == 77));
- state.down = ((add == 80));
- }
- state.no = 1;
- return state;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement