comparison io.c @ 1398:08116cb5ffaa

Fix absolute mouse mode when non-default overscan settings are used
author Michael Pavone <pavone@retrodev.com>
date Wed, 14 Jun 2017 20:46:11 -0700
parents aca496957999
children 6a0e3bb6981f
comparison
equal deleted inserted replaced
1397:89eb967fed72 1398:08116cb5ffaa
612 switch(current_io->mouse_mode) 612 switch(current_io->mouse_mode)
613 { 613 {
614 case MOUSE_NONE: 614 case MOUSE_NONE:
615 break; 615 break;
616 case MOUSE_ABSOLUTE: { 616 case MOUSE_ABSOLUTE: {
617 float scale_x = 640.0 / ((float)render_width()); 617 float scale_x = (render_emulated_width() * 2.0f) / ((float)render_width());
618 float scale_y = 480.0 / ((float)render_height()); 618 float scale_y = (render_emulated_height() * 2.0f) / ((float)render_height());
619 float scale = scale_x > scale_y ? scale_y : scale_x; 619 int32_t adj_x = x * scale_x + 2 * render_overscan_left() - 2 * BORDER_LEFT;
620 mice[mouse].motion_port->device.mouse.cur_x = x * scale_x; 620 int32_t adj_y = y * scale_y + 2 * render_overscan_top() - 4;
621 mice[mouse].motion_port->device.mouse.cur_y = y * scale_y; 621 if (adj_x >= 0 && adj_y >= 0) {
622 mice[mouse].motion_port->device.mouse.cur_x = adj_x;
623 mice[mouse].motion_port->device.mouse.cur_y = adj_y;
624 }
622 break; 625 break;
623 } 626 }
624 case MOUSE_RELATIVE: { 627 case MOUSE_RELATIVE: {
625 mice[mouse].motion_port->device.mouse.cur_x += deltax; 628 mice[mouse].motion_port->device.mouse.cur_x += deltax;
626 mice[mouse].motion_port->device.mouse.cur_y += deltay; 629 mice[mouse].motion_port->device.mouse.cur_y += deltay;