Skip to content

Commit

Permalink
Bug 4576: remove touch/mouse duplication for IOS
Browse files Browse the repository at this point in the history
  • Loading branch information
1bsyl committed Apr 2, 2019
1 parent 42de5f9 commit 9d28156
Showing 1 changed file with 2 additions and 27 deletions.
29 changes: 2 additions & 27 deletions src/video/uikit/SDL_uikitview.m
Expand Up @@ -41,8 +41,6 @@ @implementation SDL_uikitview {

SDL_TouchID directTouchId;
SDL_TouchID indirectTouchId;

UITouch * __weak firstFingerDown;
}

- (instancetype)initWithFrame:(CGRect)frame
Expand Down Expand Up @@ -218,18 +216,7 @@ - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
continue;
}

if (!firstFingerDown) {
CGPoint locationInView = [self touchLocation:touch shouldNormalize:NO];
int clicks = (int) touch.tapCount;

/* send mouse moved event */
SDL_SendMouseMotion(sdlwindow, SDL_TOUCH_MOUSEID, 0, locationInView.x, locationInView.y);

/* send mouse down event */
SDL_SendMouseButtonClicks(sdlwindow, SDL_TOUCH_MOUSEID, SDL_PRESSED, SDL_BUTTON_LEFT, clicks);

firstFingerDown = touch;
}
/* FIXME, need to send: int clicks = (int) touch.tapCount; ? */

CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES];
SDL_SendTouch(touchId, (SDL_FingerID)((size_t)touch),
Expand All @@ -248,12 +235,7 @@ - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
continue;
}

if (touch == firstFingerDown) {
/* send mouse up */
int clicks = (int) touch.tapCount;
SDL_SendMouseButtonClicks(sdlwindow, SDL_TOUCH_MOUSEID, SDL_RELEASED, SDL_BUTTON_LEFT, clicks);
firstFingerDown = nil;
}
/* FIXME, need to send: int clicks = (int) touch.tapCount; ? */

CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES];
SDL_SendTouch(touchId, (SDL_FingerID)((size_t)touch),
Expand All @@ -277,13 +259,6 @@ - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
continue;
}

if (touch == firstFingerDown) {
CGPoint locationInView = [self touchLocation:touch shouldNormalize:NO];

/* send moved event */
SDL_SendMouseMotion(sdlwindow, SDL_TOUCH_MOUSEID, 0, locationInView.x, locationInView.y);
}

CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES];
SDL_SendTouchMotion(touchId, (SDL_FingerID)((size_t)touch),
locationInView.x, locationInView.y, pressure);
Expand Down

0 comments on commit 9d28156

Please sign in to comment.