VLCIRTVTapGestureRecognizer.m 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*****************************************************************************
  2. * VLC for iOS
  3. *****************************************************************************
  4. * Copyright (c) 2015 VideoLAN. All rights reserved.
  5. * $Id$
  6. *
  7. * Authors: Tobias Conradi <videolan # tobias-conradi.de>
  8. *
  9. * Refer to the COPYING file of the official project for license.
  10. *****************************************************************************/
  11. #import "VLCIRTVTapGestureRecognizer.h"
  12. #import <UIKit/UIGestureRecognizerSubclass.h>
  13. @interface UIPress (VLCSynthetic)
  14. // A press is synthetic if it is a tap on the Siri remote touchpad
  15. // which is synthesized to an arrow press.
  16. - (BOOL)vlc_isSynthetic;
  17. @end
  18. @implementation UIPress (VLCSynthetic)
  19. - (BOOL)vlc_isSynthetic
  20. {
  21. /*
  22. * !!! Attention: We are using private API !!!
  23. * !!! Might break in any future release !!!
  24. *
  25. * For internal name changes the press might wrongly detected as non-synthetic.
  26. * Since we us it to filter for only non-synthetic presses arrow taps
  27. * on the Siri remote might be additionally be detected.
  28. */
  29. NSString *key = [@"isSyn" stringByAppendingString:@"thetic"];
  30. NSNumber *value = [self valueForKey:key];
  31. if ([value isKindOfClass:[NSNumber class]]) {
  32. return [value boolValue];
  33. }
  34. return NO;
  35. }
  36. @end
  37. @implementation VLCIRTVTapGestureRecognizer
  38. - (void)pressesBegan:(NSSet<UIPress *> *)presses withEvent:(UIPressesEvent *)event
  39. {
  40. [presses enumerateObjectsUsingBlock:^(UIPress * _Nonnull obj, BOOL * _Nonnull stop) {
  41. if ([obj vlc_isSynthetic]) {
  42. [self ignorePress:obj forEvent:event];
  43. }
  44. }];
  45. [super pressesBegan:presses withEvent:event];
  46. }
  47. @end