iOSEvents.mm 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2013 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #include "platformiOS/platformiOS.h"
  23. #include "platform/event.h"
  24. #include "platform/platformInput.h"
  25. #include "game/gameInterface.h"
  26. #include "platform/threads/thread.h"
  27. #include "platform/platformVideo.h"
  28. #include <pthread.h>
  29. #include "platformiOS/iOSUtil.h"
  30. #include "platformiOS/iOSEvents.h"
  31. #include "platformiOS/iOSAlerts.h"
  32. #include "gui/guiCanvas.h"
  33. /*
  34. EventHandlerRef gWinMouseEventHandlerRef = NULL;
  35. EventHandlerRef gAppMouseEventHandlerRef = NULL;
  36. */
  37. //-----------------------------------------------------------------------------
  38. static void _OnActivate(bool activating)
  39. {
  40. if(activating)
  41. {
  42. Input::activate();
  43. Game->refreshWindow();
  44. platState.backgrounded = false;
  45. pthread_kill((pthread_t)platState.torqueThreadId, SIGALRM);
  46. }
  47. else
  48. {
  49. Input::deactivate();
  50. platState.backgrounded = true;
  51. }
  52. }
  53. //-----------------------------------------------------------------------------
  54. // here we manually poll for events, and send them to the dispatcher.
  55. // we only use this in single-threaded mode.
  56. static void _iOSPollEvents()
  57. {
  58. }
  59. //-----------------------------------------------------------------------------
  60. void Platform::enableKeyboardTranslation(void)
  61. {
  62. platState.tsmActive=true;
  63. }
  64. //-----------------------------------------------------------------------------
  65. void Platform::disableKeyboardTranslation(void)
  66. {
  67. platState.tsmActive=false;
  68. }
  69. void Platform::setMouseLock(bool locked)
  70. {
  71. }
  72. //-----------------------------------------------------------------------------
  73. void Platform::process()
  74. {
  75. // TODO: HID input
  76. // ProcessMessages() manually polls for events when we are single threaded
  77. // if(ThreadManager::isCurrentThread(platState.firstThreadId))
  78. // _iOSPollEvents();
  79. // Some things do not get carbon events, we must always poll for them.
  80. // HID ( usb gamepad et al ) input, for instance.
  81. Input::process();
  82. if(platState.ctxNeedsUpdate)
  83. {
  84. //aglUpdateContext(platState.ctx);
  85. platState.ctxNeedsUpdate=false;
  86. }
  87. }