mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-09 03:10:22 +00:00
IOS7: Update logic for touch events for Apple TV remote
The Apple TV remote sends touch events of type UITouchTypeIndirect since it's not touches made on the screen. In iOS touchpads might send UITouchTypeIndirect touch events as well as mouse move events. So in iOS we want to block touches of type UITouchTypeIndirect while in TV OS we want them to be handled. Touchpad mode for touch events is also required for the Apple TV remote to work properly. Make sure to disable the possibility to disable touchpad mode in TV OS.
This commit is contained in:
parent
d8bc349b37
commit
3ee048d922
@ -180,7 +180,11 @@ void IOS7OptionsWidget::setEnabled(bool e) {
|
||||
#else
|
||||
_onscreenCheckbox->setEnabled(false);
|
||||
#endif
|
||||
#if TARGET_OS_IOS
|
||||
_touchpadCheckbox->setEnabled(e);
|
||||
#else
|
||||
_touchpadCheckbox->setEnabled(false);
|
||||
#endif
|
||||
_clickAndDragCheckbox->setEnabled(e);
|
||||
_keyboardFnBarCheckbox->setEnabled(e);
|
||||
}
|
||||
|
@ -45,6 +45,19 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)shouldHandleTouch:(UITouch *)touch {
|
||||
// In iOS touchpads will trigger UITouchTypeIndirect events
|
||||
// However, they will also send mose events. Make sure to
|
||||
// block the UITouchTypeIndirect but not in Apple TV OS where
|
||||
// they are required as the Apple TV remote sends touh events
|
||||
// but no mouse events.
|
||||
#if TARGET_OS_IOS
|
||||
return touch.type == UITouchTypeDirect;
|
||||
#else
|
||||
return YES;
|
||||
#endif
|
||||
}
|
||||
|
||||
- (UITouch *)secondTouchOtherTouchThan:(UITouch *)touch in:(NSSet *)set {
|
||||
NSArray *all = [set allObjects];
|
||||
for (UITouch *t in all) {
|
||||
@ -60,7 +73,7 @@
|
||||
switch (allTouches.count) {
|
||||
case 1: {
|
||||
_firstTouch = [allTouches anyObject];
|
||||
if (_firstTouch.type == UITouchTypeDirect) {
|
||||
if ([self shouldHandleTouch:_firstTouch]) {
|
||||
CGPoint p = [self getLocationInView:_firstTouch];
|
||||
[[self view] addEvent:InternalEvent(kInputTouchFirstDown, p.x, p.y)];
|
||||
}
|
||||
@ -68,7 +81,7 @@
|
||||
}
|
||||
case 2: {
|
||||
_secondTouch = [self secondTouchOtherTouchThan:_firstTouch in:allTouches];
|
||||
if (_secondTouch && _secondTouch.type == UITouchTypeDirect) {
|
||||
if (_secondTouch && [self shouldHandleTouch:_secondTouch]) {
|
||||
CGPoint p = [self getLocationInView:_firstTouch];
|
||||
[[self view] addEvent:InternalEvent(kInputTouchSecondDown, p.x, p.y)];
|
||||
}
|
||||
@ -82,7 +95,7 @@
|
||||
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
|
||||
NSSet *allTouches = [event allTouches];
|
||||
for (UITouch *touch in allTouches) {
|
||||
if (touch.type == UITouchTypeDirect) {
|
||||
if ([self shouldHandleTouch:touch]) {
|
||||
if (touch == _firstTouch) {
|
||||
CGPoint p = [self getLocationInView:touch];
|
||||
[[self view] addEvent:InternalEvent(kInputTouchFirstDragged , p.x, p.y)];
|
||||
@ -99,7 +112,7 @@
|
||||
switch (allTouches.count) {
|
||||
case 1: {
|
||||
_firstTouch = [allTouches anyObject];
|
||||
if (_firstTouch.type == UITouchTypeDirect) {
|
||||
if ([self shouldHandleTouch:_firstTouch]) {
|
||||
CGPoint p = [self getLocationInView:_firstTouch];
|
||||
[[self view] addEvent:InternalEvent(kInputTouchFirstUp, p.x, p.y)];
|
||||
}
|
||||
@ -107,7 +120,7 @@
|
||||
}
|
||||
case 2: {
|
||||
_secondTouch = [self secondTouchOtherTouchThan:_firstTouch in:allTouches];
|
||||
if (_secondTouch && _secondTouch.type == UITouchTypeDirect) {
|
||||
if (_secondTouch && [self shouldHandleTouch:_secondTouch]) {
|
||||
CGPoint p = [self getLocationInView:_firstTouch];
|
||||
[[self view] addEvent:InternalEvent(kInputTouchSecondUp, p.x, p.y)];
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ bool iOS7_isBigDevice() {
|
||||
#if TARGET_OS_IOS
|
||||
return UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad;
|
||||
#elif TARGET_OS_TV
|
||||
return true;
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user