# HG changeset patch # User Sam Lantinga # Date 1280634933 25200 # Node ID 22952969328912568f793872c4d5d0d0bdd347d4 # Parent 5ee96ba0c01e367475ff5d71628839db3fe30feb Fixed sending motion and finger up events diff -r 5ee96ba0c01e -r 229529693289 src/video/cocoa/SDL_cocoawindow.m --- a/src/video/cocoa/SDL_cocoawindow.m Sat Jul 31 20:38:37 2010 -0700 +++ b/src/video/cocoa/SDL_cocoawindow.m Sat Jul 31 20:55:33 2010 -0700 @@ -291,14 +291,28 @@ - (void)handleTouches:(cocoaTouchType)type withEvent:(NSEvent *)event { - NSSet *touches = [event touchesMatchingPhase:NSTouchPhaseBegan inView:nil]; + NSSet *touches = 0; + NSEnumerator *enumerator; + NSTouch *touch; - NSEnumerator *enumerator = [touches objectEnumerator]; - NSTouch *touch = (NSTouch*)[enumerator nextObject]; + switch (type) { + case COCOA_TOUCH_DOWN: + touches = [event touchesMatchingPhase:NSTouchPhaseBegan inView:nil]; + break; + case COCOA_TOUCH_UP: + case COCOA_TOUCH_CANCELLED: + touches = [event touchesMatchingPhase:NSTouchPhaseEnded inView:nil]; + break; + case COCOA_TOUCH_MOVE: + touches = [event touchesMatchingPhase:NSTouchPhaseMoved inView:nil]; + break; + } + + enumerator = [touches objectEnumerator]; + touch = (NSTouch*)[enumerator nextObject]; while (touch) { - long touchId = (long)[touch device]; + SDL_TouchID touchId = (SDL_TouchID)[touch device]; if (!SDL_GetTouch(touchId)) { - printf("Adding touch: %li\n",touchId); SDL_Touch touch; touch.id = touchId; @@ -313,13 +327,12 @@ touch.native_pressureres = touch.pressure_max - touch.pressure_min; if (SDL_AddTouch(&touch, "") < 0) { - continue; + return; } - printf("Success, added touch: %li\n",touchId); } float x = [touch normalizedPosition].x; float y = [touch normalizedPosition].y; - long fingerId = (long)[touch identity]; + SDL_FingerID fingerId = (SDL_FingerID)[touch identity]; switch (type) { case COCOA_TOUCH_DOWN: SDL_SendFingerDown(touchId, fingerId, SDL_TRUE, x, y, 1);