Input.pkg 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. $#include "Input.h"
  2. $#include "UIElement.h"
  3. struct TouchState
  4. {
  5. int touchID_ @ touchID;
  6. IntVector2 position_ @ position;
  7. IntVector2 lastPosition_ @ lastPosition;
  8. IntVector2 delta_ @ delta;
  9. float pressure_ @ pressure;
  10. };
  11. struct JoystickState
  12. {
  13. unsigned GetNumButtons() const;
  14. unsigned GetNumAxes() const;
  15. unsigned GetNumHats() const;
  16. bool GetButtonDown(unsigned index) const;
  17. bool GetButtonPress(unsigned index) const;
  18. float GetAxisPosition(unsigned index) const;
  19. int GetHatPosition(unsigned index) const;
  20. tolua_readonly tolua_property__get_set unsigned numButtons;
  21. tolua_readonly tolua_property__get_set unsigned numAxes;
  22. tolua_readonly tolua_property__get_set unsigned numHats;
  23. };
  24. class Input : public Object
  25. {
  26. void SetToggleFullscreen(bool enable);
  27. void SetMouseVisible(bool enable);
  28. bool OpenJoystick(unsigned index);
  29. void CloseJoystick(unsigned index);
  30. bool DetectJoysticks();
  31. unsigned AddScreenJoystick(bool injectAsKeyEvents = false, XMLFile* layoutFile = 0, XMLFile* styleFile = 0);
  32. void SetScreenKeyboardVisible(bool enable);
  33. int GetKeyFromName(const String name) const;
  34. int GetKeyFromScancode(int scancode) const;
  35. String GetKeyName(int key) const;
  36. int GetScancodeFromKey(int key) const;
  37. int GetScancodeFromName(const String name) const;
  38. String GetScancodeName(int scancode) const;
  39. bool GetKeyDown(int key) const;
  40. bool GetKeyPress(int key) const;
  41. bool GetScancodeDown(int scancode) const;
  42. bool GetScancodePress(int scancode) const;
  43. bool GetMouseButtonDown(int button) const;
  44. bool GetMouseButtonPress(int button) const;
  45. bool GetQualifierDown(int qualifier) const;
  46. bool GetQualifierPress(int qualifier) const;
  47. int GetQualifiers() const;
  48. IntVector2 GetMousePosition() const;
  49. const IntVector2& GetMouseMove() const;
  50. int GetMouseMoveX() const;
  51. int GetMouseMoveY() const;
  52. int GetMouseMoveWheel() const;
  53. unsigned GetNumTouches() const;
  54. TouchState* GetTouch(unsigned index) const;
  55. unsigned GetNumJoysticks() const;
  56. const String GetJoystickName(unsigned index) const;
  57. JoystickState* GetJoystick(unsigned index);
  58. bool GetToggleFullscreen() const;
  59. bool GetScreenKeyboardSupport() const;
  60. bool IsScreenKeyboardVisible() const;
  61. bool IsMouseVisible() const;
  62. bool HasFocus();
  63. bool IsMinimized() const;
  64. tolua_readonly tolua_property__get_set int qualifiers;
  65. tolua_readonly tolua_property__get_set IntVector2 mousePosition;
  66. tolua_readonly tolua_property__get_set IntVector2& mouseMove;
  67. tolua_readonly tolua_property__get_set int mouseMoveX;
  68. tolua_readonly tolua_property__get_set int mouseMoveY;
  69. tolua_readonly tolua_property__get_set int mouseMoveWheel;
  70. tolua_readonly tolua_property__get_set unsigned numTouches;
  71. tolua_readonly tolua_property__get_set unsigned numJoysticks;
  72. tolua_readonly tolua_property__get_set bool toggleFullscreen;
  73. tolua_readonly tolua_property__get_set bool screenKeyboardSupport;
  74. tolua_property__is_set bool screenKeyboardVisible;
  75. tolua_property__is_set bool mouseVisible;
  76. tolua_readonly tolua_property__has_set bool focus;
  77. tolua_readonly tolua_property__is_set bool minimized;
  78. };
  79. Input* GetInput();
  80. tolua_readonly tolua_property__get_set Input* input;
  81. ${
  82. #define TOLUA_DISABLE_tolua_InputLuaAPI_GetInput00
  83. static int tolua_InputLuaAPI_GetInput00(lua_State* tolua_S)
  84. {
  85. return ToluaGetSubsystem<Input>(tolua_S);
  86. }
  87. #define TOLUA_DISABLE_tolua_get_input_ptr
  88. #define tolua_get_input_ptr tolua_InputLuaAPI_GetInput00
  89. $}