src/video/cocoa/SDL_cocoawindow.m
changeset 9236 a845edf98a80
parent 9086 c5e33f9a0d03
child 9237 2cc90bb31777
     1.1 --- a/src/video/cocoa/SDL_cocoawindow.m	Sun Nov 23 15:39:28 2014 -0500
     1.2 +++ b/src/video/cocoa/SDL_cocoawindow.m	Sun Nov 23 15:48:52 2014 -0500
     1.3 @@ -856,6 +856,25 @@
     1.4  
     1.5  - (void)touchesBeganWithEvent:(NSEvent *) theEvent
     1.6  {
     1.7 +    NSSet *touches = [theEvent touchesMatchingPhase:NSTouchPhaseAny inView:nil];
     1.8 +    int existingTouchCount = 0;
     1.9 +
    1.10 +    for (NSTouch* touch in touches) {
    1.11 +        if ([touch phase] != NSTouchPhaseBegan) {
    1.12 +            existingTouchCount++;
    1.13 +        }
    1.14 +    }
    1.15 +    if (existingTouchCount == 0) {
    1.16 +        SDL_TouchID touchID = (SDL_TouchID)(intptr_t)[[touches anyObject] device];
    1.17 +        int numFingers = SDL_GetNumTouchFingers(touchID);
    1.18 +        DLog("Reset Lost Fingers: %d", numFingers);
    1.19 +        for (--numFingers; numFingers >= 0; --numFingers) {
    1.20 +            SDL_Finger* finger = SDL_GetTouchFinger(touchID, numFingers);
    1.21 +            SDL_SendTouch(touchID, finger->id, SDL_FALSE, 0, 0, 0);
    1.22 +        }
    1.23 +    }
    1.24 +
    1.25 +    DLog("Began Fingers: %lu .. existing: %d", (unsigned long)[touches count], existingTouchCount);
    1.26      [self handleTouches:NSTouchPhaseBegan withEvent:theEvent];
    1.27  }
    1.28