WindowManager.hpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #ifndef GAMINGCORE_WINDOW_MANAGER_HPP
  2. #define GAMINGCORE_WINDOW_MANAGER_HPP
  3. #include <core/Types.hpp>
  4. #include <core/Vector.hpp>
  5. namespace Core::Window {
  6. using RunHandler = bool (*)(void* data);
  7. using TickHandler = void (*)(void* data);
  8. using RenderHandler = void (*)(void* data, float lag);
  9. struct Options {
  10. IntVector2 size{};
  11. bool fullscreen = false;
  12. const char* name = "Unknown";
  13. };
  14. bool open(const Options* options);
  15. void close();
  16. void show();
  17. void trapCursor();
  18. void freeCursor();
  19. bool isCursorTrapped();
  20. const IntVector2* getSize();
  21. bool hasSizeChanged();
  22. bool shouldClose();
  23. void setRunHandler(RunHandler wr, void* data);
  24. void setTickHandler(TickHandler t, void* data);
  25. void setRenderHandler(RenderHandler r, void* data);
  26. void setNanosPerTick(i64 nanos);
  27. void run();
  28. float getTicksPerSecond();
  29. float getFramesPerSecond();
  30. void setInputLimit(size_t limit);
  31. void resetInput();
  32. void enableInput();
  33. void disableInput();
  34. bool isInputEnabled();
  35. void fillInput(const char* s);
  36. size_t getInputCursor();
  37. void setInputCursor(size_t index);
  38. const char* getInputString();
  39. using Button = size_t;
  40. Button addButton(const char* name);
  41. void bindKeyToButton(Button b, Button key);
  42. void bindGamepadToButton(Button b, Button gamepadButton);
  43. void bindMouseToButton(Button b, Button mouseButton);
  44. Vector2 getLastMousePosition();
  45. Vector2 getMousePosition();
  46. Vector2 getLeftGamepadAxis();
  47. Vector2 getRightGamepadAxis();
  48. float getLeftGamepadTrigger();
  49. float getRightGamepadTrigger();
  50. bool isButtonDown(Button b);
  51. int getButtonDownTime(Button b);
  52. bool wasButtonReleased(Button b);
  53. const char* getButtonName(Button b);
  54. }
  55. #endif