diff io.c @ 914:28ec32e720b2

Scale mouse data based on window size
author Michael Pavone <pavone@retrodev.com>
date Mon, 14 Dec 2015 19:36:01 -0800
parents a5a51465f8b0
children 9e882eca717e
line wrap: on
line diff
--- a/io.c	Tue Dec 08 19:33:58 2015 -0800
+++ b/io.c	Mon Dec 14 19:36:01 2015 -0800
@@ -412,9 +412,11 @@
 		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)