/src/app/app.h

https://bitbucket.org/vivkin/gam3b00bs/ · C Header · 59 lines · 28 code · 15 blank · 16 comment · 0 complexity · 3d9a7db9c2ad79d2cf37ae1406148cd9 MD5 · raw file

  1. #pragma once
  2. //
  3. // app.h - application interface: global initialization and teardown, etc.
  4. //
  5. #include "common.h"
  6. #define INPUT_KEYS_MAX 256
  7. #define INPUT_BUTTONS_MAX 5
  8. namespace app
  9. {
  10. struct timings
  11. {
  12. double T;
  13. float dt;
  14. };
  15. namespace input
  16. {
  17. // PRESSED - key or button is held down more than one tick
  18. enum state { UP = 0, DOWN, PRESSED };
  19. bool init();
  20. void term();
  21. // reset input relative
  22. bool tick();
  23. // get keyboard key state
  24. state get_key_state(uint16 key);
  25. // get mouse button state
  26. // 0 - left, 1 - right, 2 - middle, 3 - xbutton1, 4 - xbutton2
  27. state get_button_state(uint16 button);
  28. // get mouse wheel relative
  29. int16 get_wheel_rel();
  30. // get current cursor position
  31. void get_cursor_pos(int16 *x, int16 *y);
  32. // get relative to last query position
  33. void get_cursor_rel(int16 *xr, int16 *yr);
  34. }
  35. // initializes the C++ part of the program: renderer, sound, network
  36. // return false on error
  37. bool init();
  38. void term();
  39. // moves the frame time,
  40. // returns false if the program wants to terminate
  41. bool tick();
  42. // returns timings for the last tick
  43. struct timings time();
  44. }