Merge commit '2ebaafa6c9334071b664b15d045656250690dd96' into main

main
Sam Lantinga 2022-10-23 16:35:18 -07:00
commit 5373ad6ffb
1 changed files with 24 additions and 13 deletions

View File

@ -455,25 +455,36 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
#endif /* TARGET_OS_TV || defined(__IPHONE_9_1) */ #endif /* TARGET_OS_TV || defined(__IPHONE_9_1) */
static CGPoint translation_old = (CGPoint){ 0.0, 0.0 };
-(void)mouseWheelGesture:(UIPanGestureRecognizer *)gesture -(void)mouseWheelGesture:(UIPanGestureRecognizer *)gesture
{ {
if (gesture.state == UIGestureRecognizerStateBegan || if (gesture.state == UIGestureRecognizerStateBegan ||
gesture.state == UIGestureRecognizerStateChanged || gesture.state == UIGestureRecognizerStateChanged) {
gesture.state == UIGestureRecognizerStateEnded) {
CGPoint velocity = [gesture velocityInView:self];
if (velocity.x > 0.0f) { CGPoint translation = [gesture translationInView:self];
velocity.x = -1.0; CGPoint mouse_wheel = translation;
} else if (velocity.x < 0.0f) {
velocity.x = 1.0f; if (gesture.state == UIGestureRecognizerStateChanged) {
mouse_wheel.x -= translation_old.x;
mouse_wheel.y -= translation_old.y;
} }
if (velocity.y > 0.0f) {
velocity.y = -1.0; translation_old = translation;
} else if (velocity.y < 0.0f) {
velocity.y = 1.0f; if (mouse_wheel.x > 0.0f) {
mouse_wheel.x = 1.0;
} else if (mouse_wheel.x < 0.0f) {
mouse_wheel.x = -1.0f;
} }
if (velocity.x != 0.0f || velocity.y != 0.0f) { if (mouse_wheel.y > 0.0f) {
SDL_SendMouseWheel(sdlwindow, 0, velocity.x, velocity.y, SDL_MOUSEWHEEL_NORMAL); mouse_wheel.y = 1.0;
} else if (mouse_wheel.y < 0.0f) {
mouse_wheel.y = -1.0f;
}
if (mouse_wheel.x != 0.0f || mouse_wheel.y != 0.0f) {
SDL_SendMouseWheel(sdlwindow, 0, mouse_wheel.x, mouse_wheel.y, SDL_MOUSEWHEEL_NORMAL);
} }
} }
} }