summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authorMichael Pavone <pavone@retrodev.com>2015-12-14 19:36:01 -0800
committerMichael Pavone <pavone@retrodev.com>2015-12-14 19:36:01 -0800
commit9596af4ac4d0c8dcde83334889f60d6687940b12 (patch)
tree8050800ae911266f7fd95f29d3dc0df1e2fd4622 /io.c
parentff238c672d2f623363169f7ea6a3f292bbb24543 (diff)
Scale mouse data based on window size
Diffstat (limited to 'io.c')
-rw-r--r--io.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/io.c b/io.c
index b64da46..260ccb5 100644
--- a/io.c
+++ b/io.c
@@ -412,9 +412,11 @@ void handle_mouse_moved(int mouse, uint16_t x, uint16_t y)
return;
}
//TODO: relative mode
- //TODO: scale based on window size
- mice[mouse].motion_port->device.mouse.cur_x = x;
- mice[mouse].motion_port->device.mouse.cur_y = y;
+ 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;
}
int parse_binding_target(char * target, tern_node * padbuttons, tern_node *mousebuttons, int * ui_out, int * padnum_out, int * padbutton_out)