IosO3DEApplication.mm 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <AzFramework/Input/Buses/Notifications/RawInputNotificationBus_ios.h>
  9. #import <UIKit/UIKit.h>
  10. //[GFX TODO][ATOM-449] - Remove this file once we switch to unified launcher
  11. ////////////////////////////////////////////////////////////////////////////////////////////////////
  12. @interface IosO3DEApplication : UIApplication
  13. {
  14. }
  15. @end // IosO3DEApplication Interface
  16. ////////////////////////////////////////////////////////////////////////////////////////////////////
  17. @implementation IosO3DEApplication
  18. ////////////////////////////////////////////////////////////////////////////////////////////////////
  19. - (void)touchesBegan: (NSSet<UITouch*>*)touches withEvent: (UIEvent*)event
  20. {
  21. for (const UITouch* touch in touches)
  22. {
  23. EBUS_EVENT(AzFramework::RawInputNotificationBusIos, OnRawTouchEventBegan, touch);
  24. }
  25. }
  26. ////////////////////////////////////////////////////////////////////////////////////////////////////
  27. - (void)touchesMoved: (NSSet<UITouch*>*)touches withEvent: (UIEvent*)event
  28. {
  29. for (const UITouch* touch in touches)
  30. {
  31. EBUS_EVENT(AzFramework::RawInputNotificationBusIos, OnRawTouchEventMoved, touch);
  32. }
  33. }
  34. ////////////////////////////////////////////////////////////////////////////////////////////////////
  35. - (void)touchesEnded: (NSSet<UITouch*>*)touches withEvent: (UIEvent*)event
  36. {
  37. for (const UITouch* touch in touches)
  38. {
  39. EBUS_EVENT(AzFramework::RawInputNotificationBusIos, OnRawTouchEventEnded, touch);
  40. }
  41. }
  42. ////////////////////////////////////////////////////////////////////////////////////////////////////
  43. - (void)touchesCancelled:(NSSet<UITouch*>*)touches withEvent: (UIEvent*)event
  44. {
  45. // Active touches can be cancelled (as opposed to ended) for a variety of reasons, including:
  46. // - The active view being rotated to match the device orientation.
  47. // - The application resigning it's active status (eg. when receiving a message or phone call).
  48. // - Exceeding the max number of active touches tracked by the system (which as explained above
  49. // is device dependent). For some reason this causes all active touches to be cancelled.
  50. // In any case, for the purposes of a game (or really any application that I can think of),
  51. // there really isn't any reason to distinguish between a touch ending or being cancelled.
  52. // They are mutually exclusive events, and both result in the touch being discarded by the
  53. // system.
  54. [self touchesEnded: touches withEvent: event];
  55. }
  56. @end