2
0

Platform.cpp 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. // Implementation of base platform-agnostic platform functionality.
  2. #include "Base.h"
  3. #include "Platform.h"
  4. #include "Game.h"
  5. #include "ScriptController.h"
  6. #include "Form.h"
  7. namespace gameplay
  8. {
  9. void Platform::touchEventInternal(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex, bool actuallyMouse)
  10. {
  11. if (actuallyMouse || !Form::touchEventInternal(evt, x, y, contactIndex))
  12. {
  13. Game::getInstance()->touchEventInternal(evt, x, y, contactIndex);
  14. }
  15. }
  16. void Platform::keyEventInternal(Keyboard::KeyEvent evt, int key)
  17. {
  18. if (!Form::keyEventInternal(evt, key))
  19. {
  20. Game::getInstance()->keyEventInternal(evt, key);
  21. }
  22. }
  23. bool Platform::mouseEventInternal(Mouse::MouseEvent evt, int x, int y, int wheelDelta)
  24. {
  25. if (Form::mouseEventInternal(evt, x, y, wheelDelta))
  26. return true;
  27. return Game::getInstance()->mouseEventInternal(evt, x, y, wheelDelta);
  28. }
  29. void Platform::gestureSwipeEventInternal(int x, int y, int direction)
  30. {
  31. // TODO: Add support to Form for gestures
  32. Game::getInstance()->gestureSwipeEventInternal(x, y, direction);
  33. }
  34. void Platform::gesturePinchEventInternal(int x, int y, float scale)
  35. {
  36. // TODO: Add support to Form for gestures
  37. Game::getInstance()->gesturePinchEventInternal(x, y, scale);
  38. }
  39. void Platform::gestureTapEventInternal(int x, int y)
  40. {
  41. // TODO: Add support to Form for gestures
  42. Game::getInstance()->gestureTapEventInternal(x, y);
  43. }
  44. void Platform::gestureLongTapEventInternal(int x, int y, float duration)
  45. {
  46. // TODO: Add support to Form for gestures
  47. Game::getInstance()->gestureLongTapEventInternal(x, y, duration);
  48. }
  49. void Platform::gestureDragEventInternal(int x, int y)
  50. {
  51. // TODO: Add support to Form for gestures
  52. Game::getInstance()->gestureDragEventInternal(x, y);
  53. }
  54. void Platform::gestureDropEventInternal(int x, int y)
  55. {
  56. // TODO: Add support to Form for gestures
  57. Game::getInstance()->gestureDropEventInternal(x, y);
  58. }
  59. void Platform::resizeEventInternal(unsigned int width, unsigned int height)
  60. {
  61. Game::getInstance()->resizeEventInternal(width, height);
  62. Form::resizeEventInternal(width, height);
  63. }
  64. void Platform::gamepadEventInternal(Gamepad::GamepadEvent evt, Gamepad* gamepad, unsigned int analogIndex)
  65. {
  66. if (!Form::gamepadEventInternal(evt, gamepad, analogIndex))
  67. {
  68. Game::getInstance()->gamepadEventInternal(evt, gamepad, analogIndex);
  69. }
  70. }
  71. void Platform::gamepadEventConnectedInternal(GamepadHandle handle, unsigned int buttonCount, unsigned int joystickCount, unsigned int triggerCount,
  72. unsigned int vendorId, unsigned int productId, const char* vendorString, const char* productString)
  73. {
  74. Gamepad::add(handle, buttonCount, joystickCount, triggerCount, vendorId, productId, vendorString, productString);
  75. }
  76. void Platform::gamepadEventDisconnectedInternal(GamepadHandle handle)
  77. {
  78. Gamepad::remove(handle);
  79. }
  80. }