O3DEApplication_iOS.mm 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. #import <UIKit/UIKit.h>
  9. #include <AzFramework/Input/Buses/Notifications/RawInputNotificationBus_Platform.h>
  10. @interface O3DEApplication_iOS : UIApplication
  11. {
  12. }
  13. @end // O3DEApplication_iOS Interface
  14. @implementation O3DEApplication_iOS
  15. - (void)touchesBegan: (NSSet<UITouch*>*)touches withEvent: (UIEvent*)event
  16. {
  17. for (const UITouch* touch in touches)
  18. {
  19. AzFramework::RawInputNotificationBusIos::Broadcast(
  20. &AzFramework::RawInputNotificationBusIos::Events::OnRawTouchEventBegan, touch);
  21. }
  22. }
  23. - (void)touchesMoved: (NSSet<UITouch*>*)touches withEvent: (UIEvent*)event
  24. {
  25. for (const UITouch* touch in touches)
  26. {
  27. AzFramework::RawInputNotificationBusIos::Broadcast(
  28. &AzFramework::RawInputNotificationBusIos::Events::OnRawTouchEventMoved, touch);
  29. }
  30. }
  31. - (void)touchesEnded: (NSSet<UITouch*>*)touches withEvent: (UIEvent*)event
  32. {
  33. for (const UITouch* touch in touches)
  34. {
  35. AzFramework::RawInputNotificationBusIos::Broadcast(
  36. &AzFramework::RawInputNotificationBusIos::Events::OnRawTouchEventEnded, touch);
  37. }
  38. }
  39. - (void)touchesCancelled:(NSSet<UITouch*>*)touches withEvent: (UIEvent*)event
  40. {
  41. // Active touches can be cancelled (as opposed to ended) for a variety of reasons, including:
  42. // - The active view being rotated to match the device orientation.
  43. // - The application resigning it's active status (eg. when receiving a message or phone call).
  44. // - Exceeding the max number of active touches tracked by the system (which as explained above
  45. // is device dependent). For some reason this causes all active touches to be cancelled.
  46. // In any case, for the purposes of a game (or really any application that I can think of),
  47. // there really isn't any reason to distinguish between a touch ending or being cancelled.
  48. // They are mutually exclusive events, and both result in the touch being discarded by the
  49. // system.
  50. [self touchesEnded: touches withEvent: event];
  51. }
  52. @end // O3DEApplication_iOS Implementation