Skip to content

Commit

Permalink
switch: fix right click drag scrolling with physical mouse
Browse files Browse the repository at this point in the history
  • Loading branch information
rsn8887 committed May 16, 2019
1 parent 6fd80c9 commit b1f77ec
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
21 changes: 15 additions & 6 deletions src/video/sdl_vita_v.cpp
Expand Up @@ -38,6 +38,7 @@ int _last_mouse_y = 0;
int _hires_dx = 0; // sub-pixel-precision counters to allow slow pointer motion of <1 pixel per frame
int _hires_dy = 0;
int _pressed_right_stick_dirs[4] = { 0, 0, 0, 0 };
int _using_physical_mouse = 1; // need to distinguish virtual mousemotion from physical
static int _pressed_cursor_keys[4] = { 0, 0, 0, 0 };
static int _fast_mouse = 0;
static int _slow_mouse = 0;
Expand Down Expand Up @@ -309,6 +310,7 @@ static void GetVideoModes()

static void HandleAnalogSticks(void)
{
_using_physical_mouse = 1;
int left_x = SDL_JoystickGetAxis(_sdl_joystick, 0);
int left_y = SDL_JoystickGetAxis(_sdl_joystick, 1);
RescaleAnalog(&left_x, &left_y, 2000);
Expand Down Expand Up @@ -348,6 +350,7 @@ static void HandleAnalogSticks(void)
y = VITA_DISPLAY_HEIGHT;
yrel = VITA_DISPLAY_HEIGHT - _last_mouse_y;
}
_using_physical_mouse = 0;
SDL_Event event;
event.type = SDL_MOUSEMOTION;
event.motion.x = x;
Expand Down Expand Up @@ -687,14 +690,20 @@ int VideoDriver_SDL::PollEvent()
// state, and generate corresponding mouse events there
break;
case SDL_MOUSEMOTION:
if (_cursor.UpdateCursorPosition(ev.motion.x, ev.motion.y, false)) {
//SDL_CALL SDL_WarpMouseInWindow(_sdl_window, _cursor.pos.x, _cursor.pos.y);
// update joystick / touch mouse coords
_last_mouse_x = _cursor.pos.x;
_last_mouse_y = _cursor.pos.y;
} else {
if (_using_physical_mouse) {
if (_cursor.UpdateCursorPosition(ev.motion.x, ev.motion.y, true)) {
SDL_CALL SDL_WarpMouseInWindow(_sdl_window, _cursor.pos.x, _cursor.pos.y);
}
_last_mouse_x = ev.motion.x;
_last_mouse_y = ev.motion.y;
} else {
if (_cursor.UpdateCursorPosition(ev.motion.x, ev.motion.y, false)) {
_last_mouse_x = _cursor.pos.x;
_last_mouse_y = _cursor.pos.y;
} else {
_last_mouse_x = ev.motion.x;
_last_mouse_y = ev.motion.y;
}
}
HandleMouseEvents();
break;
Expand Down
3 changes: 2 additions & 1 deletion src/video/vita_touch.cpp
Expand Up @@ -24,6 +24,7 @@ static void set_mouse_button_event(SDL_Event *event, uint32_t type, uint8_t butt
static int _vita_rear_touch = 0; // always disable rear_touch for now
extern int _last_mouse_x;
extern int _last_mouse_y;
extern int _using_physical_mouse;

static int _touch_initialized = 0;
static unsigned int _simulated_click_start_time[SCE_TOUCH_PORT_MAX_NUM][2]; // initiation time of last simulated left or right click (zero if no click)
Expand Down Expand Up @@ -109,6 +110,7 @@ static void preprocess_events(SDL_Event *event)
break;
case SDL_FINGERMOTION:
preprocess_finger_motion(event);
_using_physical_mouse = 0;
break;
}
}
Expand Down Expand Up @@ -320,7 +322,6 @@ void FinishSimulatedMouseClicks()
SDL_Event ev;
set_mouse_button_event(&ev, SDL_MOUSEBUTTONUP, simulated_button, _last_mouse_x, _last_mouse_y);
SDL_PushEvent(&ev);

_simulated_click_start_time[port][i] = 0;
}
}
Expand Down

0 comments on commit b1f77ec

Please sign in to comment.