VMDisplayMetalViewController+Private.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. //
  2. // Copyright © 2023 osy. All rights reserved.
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. //
  16. #import "VMDisplayMetalViewController.h"
  17. #import <TargetConditionals.h>
  18. @class VMCursor;
  19. @class VMScroll;
  20. @class GCController;
  21. NS_ASSUME_NONNULL_BEGIN
  22. @interface VMDisplayMetalViewController ()
  23. // cursor handling
  24. @property (nonatomic) CGPoint lastTwoPanOrigin;
  25. @property (nonatomic) BOOL mouseLeftDown;
  26. @property (nonatomic) BOOL mouseRightDown;
  27. @property (nonatomic) BOOL mouseMiddleDown;
  28. @property (nonatomic) BOOL mouseSideDown;
  29. @property (nonatomic) BOOL mouseExtraDown;
  30. @property (nonatomic) BOOL pencilForceRightClickOnce;
  31. @property (nonatomic, nullable) VMCursor *cursor;
  32. @property (nonatomic, nullable) VMScroll *scroll;
  33. // Gestures
  34. @property (nonatomic, nullable) UISwipeGestureRecognizer *swipeUp;
  35. @property (nonatomic, nullable) UISwipeGestureRecognizer *swipeDown;
  36. @property (nonatomic, nullable) UISwipeGestureRecognizer *swipeScrollUp;
  37. @property (nonatomic, nullable) UISwipeGestureRecognizer *swipeScrollDown;
  38. @property (nonatomic, nullable) UIPanGestureRecognizer *pan;
  39. @property (nonatomic, nullable) UIPanGestureRecognizer *twoPan;
  40. @property (nonatomic, nullable) UIPanGestureRecognizer *threePan;
  41. @property (nonatomic, nullable) UITapGestureRecognizer *tap;
  42. @property (nonatomic, nullable) UITapGestureRecognizer *tapPencil;
  43. @property (nonatomic, nullable) UITapGestureRecognizer *twoTap;
  44. @property (nonatomic, nullable) UILongPressGestureRecognizer *longPress;
  45. @property (nonatomic, nullable) UIPinchGestureRecognizer *pinch;
  46. //Gamepad
  47. @property (nonatomic, nullable) GCController *controller;
  48. #if !defined(TARGET_OS_VISION) || !TARGET_OS_VISION
  49. // Feedback generators
  50. @property (nonatomic, nullable) UISelectionFeedbackGenerator *clickFeedbackGenerator;
  51. #endif
  52. @end
  53. NS_ASSUME_NONNULL_END
  54. static inline CGFloat CGPointToPixel(CGFloat point) {
  55. #if defined(TARGET_OS_VISION) && TARGET_OS_VISION
  56. return point * 2.0;
  57. #else
  58. return point * [UIScreen mainScreen].nativeScale; // FIXME: multiple screens?
  59. #endif
  60. }
  61. static inline CGFloat CGPixelToPoint(CGFloat pixel) {
  62. #if defined(TARGET_OS_VISION) && TARGET_OS_VISION
  63. return pixel / 2.0;
  64. #else
  65. return pixel / [UIScreen mainScreen].nativeScale; // FIXME: multiple screens?
  66. #endif
  67. }