From dbc3e3f7ffecadd7417773322414cf62641a55b8 Mon Sep 17 00:00:00 2001 From: meancoot Date: Tue, 5 Mar 2013 20:28:59 -0500 Subject: [PATCH] (iOS) Fix broken multi-touch code. --- ios/RetroArch/input/RAInputResponder.h | 1 - ios/RetroArch/input/RAInputResponder.m | 15 +++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/ios/RetroArch/input/RAInputResponder.h b/ios/RetroArch/input/RAInputResponder.h index 3ad909f25f..b02b07fed3 100644 --- a/ios/RetroArch/input/RAInputResponder.h +++ b/ios/RetroArch/input/RAInputResponder.h @@ -19,7 +19,6 @@ typedef struct touch_data { - bool is_down; int16_t screen_x, screen_y; int16_t fixed_x, fixed_y; int16_t full_x, full_y; diff --git a/ios/RetroArch/input/RAInputResponder.m b/ios/RetroArch/input/RAInputResponder.m index 5951a17813..98af742500 100644 --- a/ios/RetroArch/input/RAInputResponder.m +++ b/ios/RetroArch/input/RAInputResponder.m @@ -57,7 +57,7 @@ extern NSString* const RATouchNotification; - (const touch_data_t*)getTouchDataAtIndex:(unsigned)index { - return (index < MAX_TOUCHES && _touches[index].is_down) ? &_touches[index] : 0; + return (index < _touchCount) ? &_touches[index] : 0; } // Response handlers @@ -77,18 +77,21 @@ extern NSString* const RATouchNotification; { UIEvent* event = [notification.userInfo objectForKey:@"event"]; NSArray* touches = [[event allTouches] allObjects]; + const int numTouches = [touches count]; - _touchCount = [touches count]; + _touchCount = 0; - for(int i = 0; i != _touchCount; i ++) + for(int i = 0; i != numTouches && _touchCount != MAX_TOUCHES; i ++) { UITouch *touch = [touches objectAtIndex:i]; CGPoint coord = [touch locationInView:touch.view]; float scale = [[UIScreen mainScreen] scale]; - _touches[i].is_down = (touch.phase != UITouchPhaseEnded) && (touch.phase != UITouchPhaseCancelled); - _touches[i].screen_x = coord.x * scale; - _touches[i].screen_y = coord.y * scale; + if (touch.phase != UITouchPhaseEnded && touch.phase != UITouchPhaseCancelled) + { + _touches[_touchCount ].screen_x = coord.x * scale; + _touches[_touchCount ++].screen_y = coord.y * scale; + } } } @end