WindowManager.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. #ifndef CORE_WINDOW_MANAGER_H
  2. #define CORE_WINDOW_MANAGER_H
  3. #include <core/Vector.h>
  4. typedef bool (*CoreWindowRunHandler)(void* data);
  5. typedef void (*CoreWindowTickHandler)(void* data);
  6. typedef void (*CoreWindowRenderHandler)(void* data, float lag);
  7. typedef struct {
  8. CoreIntVector2 size;
  9. bool fullscreen;
  10. const char* name;
  11. } CoreWindowOptions;
  12. bool coreOpenWindow(const CoreWindowOptions* options);
  13. void coreCloseWindow(void);
  14. void coreShowWindow(void);
  15. void coreTrapWindowCursor(void);
  16. void coreFreeWindowCursor(void);
  17. bool coreIsWindowCursorTrapped(void);
  18. const CoreIntVector2* coreGetWindowSize(void);
  19. bool coreHasWindowSizeChanged(void);
  20. bool coreShouldWindowClose(void);
  21. void coreSetWindowRunHandler(CoreWindowRunHandler wr, void* data);
  22. void coreSetWindowTickHandler(CoreWindowTickHandler t, void* data);
  23. void coreSetWindowRenderHandler(CoreWindowRenderHandler r, void* data);
  24. void coreSetWindowNanosPerTick(i64 nanos);
  25. void coreRunWindow(void);
  26. float coreGetWindowTicksPerSecond(void);
  27. float coreGetWindowFramesPerSecond(void);
  28. void coreSetInputLimit(size_t limit);
  29. void coreResetInput(void);
  30. void coreEnableInput(void);
  31. void coreDisableInput(void);
  32. bool coreIsInputEnabled(void);
  33. void coreFillInput(const char* s);
  34. size_t coreGetInputCursor(void);
  35. void coreSetInputCursor(size_t index);
  36. const char* coreGetInputString(void);
  37. typedef size_t CoreButton;
  38. CoreButton coreAddButton(const char* name);
  39. void coreBindKeyToButton(CoreButton b, int key);
  40. void coreBindGamepadToButton(CoreButton b, int gamepadButton);
  41. void coreBindMouseToButton(CoreButton b, int mouseButton);
  42. CoreVector2 coreGetLastMousePosition(void);
  43. CoreVector2 coreGetMousePosition(void);
  44. CoreVector2 coreGetLeftGamepadAxis(void);
  45. CoreVector2 coreGetRightGamepadAxis(void);
  46. float coreGetLeftGamepadTrigger(void);
  47. float coreGetRightGamepadTrigger(void);
  48. bool coreIsButtonDown(CoreButton b);
  49. int coreGetButtonDownTime(CoreButton b);
  50. bool coreWasButtonReleased(CoreButton b);
  51. const char* coreGetButtonName(CoreButton b);
  52. #ifdef IMPORT_CORE
  53. #define WindowRunHandler CoreWindowRunHandler
  54. #define WindowTickHandler CoreWindowTickHandler
  55. #define WindowRenderHandler CoreWindowRenderHandler
  56. #define WindowOptions CoreWindowOptions
  57. #define openWindow coreOpenWindow
  58. #define closeWindow coreCloseWindow
  59. #define showWindow coreShowWindow
  60. #define trapWindowCursor coreTrapWindowCursor
  61. #define freeWindowCursor coreFreeWindowCursor
  62. #define isWindowCursorTrapped coreIsWindowCursorTrapped
  63. #define getWindowSize coreGetWindowSize
  64. #define hasWindowSizeChanged coreHasWindowSizeChanged
  65. #define shouldWindowClose coreShouldWindowClose
  66. #define setWindowRunHandler coreSetWindowRunHandler
  67. #define setWindowTickHandler coreSetWindowTickHandler
  68. #define setWindowRenderHandler coreSetWindowRenderHandler
  69. #define setWindowNanosPerTick coreSetWindowNanosPerTick
  70. #define runWindow coreRunWindow
  71. #define getWindowTicksPerSecond coreGetWindowTicksPerSecond
  72. #define getWindowFramesPerSecond coreGetWindowFramesPerSecond
  73. #define setInputLimit coreSetInputLimit
  74. #define resetInput coreResetInput
  75. #define enableInput coreEnableInput
  76. #define disableInput coreDisableInput
  77. #define isInputEnabled coreIsInputEnabled
  78. #define fillInput coreFillInput
  79. #define getInputCursor coreGetInputCursor
  80. #define setInputCursor coreSetInputCursor
  81. #define getInputString coreGetInputString
  82. #define Button CoreButton
  83. #define addButton coreAddButton
  84. #define bindKeyToButton coreBindKeyToButton
  85. #define bindGamepadToButton coreBindGamepadToButton
  86. #define bindMouseToButton coreBindMouseToButton
  87. #define getLastMousePosition coreGetLastMousePosition
  88. #define getMousePosition coreGetMousePosition
  89. #define getLeftGamepadAxis coreGetLeftGamepadAxis
  90. #define getRightGamepadAxis coreGetRightGamepadAxis
  91. #define getLeftGamepadTrigger coreGetLeftGamepadTrigger
  92. #define getRightGamepadTrigger coreGetRightGamepadTrigger
  93. #define isButtonDown coreIsButtonDown
  94. #define getButtonDownTime coreGetButtonDownTime
  95. #define wasButtonReleased coreWasButtonReleased
  96. #define getButtonName coreGetButtonName
  97. #endif
  98. #endif