diff options
author | Michael Pavone <pavone@retrodev.com> | 2017-06-14 20:46:11 -0700 |
---|---|---|
committer | Michael Pavone <pavone@retrodev.com> | 2017-06-14 20:46:11 -0700 |
commit | f1fca3e3dc8d77ccc740bab5084cf4bbc715b48f (patch) | |
tree | 67fd5901b7523e2151f6c9bfd9e1b68291b34388 /io.c | |
parent | ee59b3c6b69e9b5cfb0f5135dfb5fe3ce9a1a8c9 (diff) |
Fix absolute mouse mode when non-default overscan settings are used
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 13 |
1 files changed, 8 insertions, 5 deletions
@@ -614,11 +614,14 @@ void handle_mouse_moved(int mouse, uint16_t x, uint16_t y, int16_t deltax, int16 case MOUSE_NONE: break; case MOUSE_ABSOLUTE: { - float scale_x = 640.0 / ((float)render_width()); - float scale_y = 480.0 / ((float)render_height()); - float scale = scale_x > scale_y ? scale_y : scale_x; - mice[mouse].motion_port->device.mouse.cur_x = x * scale_x; - mice[mouse].motion_port->device.mouse.cur_y = y * scale_y; + float scale_x = (render_emulated_width() * 2.0f) / ((float)render_width()); + float scale_y = (render_emulated_height() * 2.0f) / ((float)render_height()); + int32_t adj_x = x * scale_x + 2 * render_overscan_left() - 2 * BORDER_LEFT; + int32_t adj_y = y * scale_y + 2 * render_overscan_top() - 4; + if (adj_x >= 0 && adj_y >= 0) { + mice[mouse].motion_port->device.mouse.cur_x = adj_x; + mice[mouse].motion_port->device.mouse.cur_y = adj_y; + } break; } case MOUSE_RELATIVE: { |