diff options
author | Michael Pavone <pavone@retrodev.com> | 2015-12-14 19:36:01 -0800 |
---|---|---|
committer | Michael Pavone <pavone@retrodev.com> | 2015-12-14 19:36:01 -0800 |
commit | 9596af4ac4d0c8dcde83334889f60d6687940b12 (patch) | |
tree | 8050800ae911266f7fd95f29d3dc0df1e2fd4622 /io.c | |
parent | ff238c672d2f623363169f7ea6a3f292bbb24543 (diff) |
Scale mouse data based on window size
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -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) |