From 9596af4ac4d0c8dcde83334889f60d6687940b12 Mon Sep 17 00:00:00 2001 From: Michael Pavone Date: Mon, 14 Dec 2015 19:36:01 -0800 Subject: Scale mouse data based on window size --- io.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'io.c') 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) -- cgit v1.2.3