Mercurial > repos > blastem
comparison io.c @ 910:c030e4af32b7
Mouse X and Y are 9-bit 2's complement not 8-bit magnitude + sign bit like I thought. Fixed mouse Y direction.
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sat, 05 Dec 2015 18:40:34 -0800 |
parents | b5d35222047e |
children | 73732ae76fa8 |
comparison
equal
deleted
inserted
replaced
909:e60eb88d7b09 | 910:c030e4af32b7 |
---|---|
1227 case 3: | 1227 case 3: |
1228 input = 0; | 1228 input = 0; |
1229 //it would be unfortunate if our event handler updated cur_x or cur_y in the middle | 1229 //it would be unfortunate if our event handler updated cur_x or cur_y in the middle |
1230 //of the mouse poll sequence, so we save the delta here | 1230 //of the mouse poll sequence, so we save the delta here |
1231 port->device.mouse.delta_x = port->device.mouse.cur_x - port->device.mouse.last_read_x; | 1231 port->device.mouse.delta_x = port->device.mouse.cur_x - port->device.mouse.last_read_x; |
1232 port->device.mouse.delta_y = port->device.mouse.cur_y - port->device.mouse.last_read_y; | 1232 port->device.mouse.delta_y = port->device.mouse.last_read_y - port->device.mouse.cur_y; |
1233 if (port->device.mouse.delta_y > 255 || port->device.mouse.delta_y < -255) { | 1233 if (port->device.mouse.delta_y > 255 || port->device.mouse.delta_y < -255) { |
1234 input |= 8; | 1234 input |= 8; |
1235 } | 1235 } |
1236 if (port->device.mouse.delta_x > 255 || port->device.mouse.delta_x < -255) { | 1236 if (port->device.mouse.delta_x > 255 || port->device.mouse.delta_x < -255) { |
1237 input |= 4; | 1237 input |= 4; |
1245 break; | 1245 break; |
1246 case 4: | 1246 case 4: |
1247 input = port->input[0]; | 1247 input = port->input[0]; |
1248 break; | 1248 break; |
1249 case 5: | 1249 case 5: |
1250 input = abs(port->device.mouse.delta_x) >> 4 & 0xF; | 1250 input = port->device.mouse.delta_x >> 4 & 0xF; |
1251 break; | 1251 break; |
1252 case 6: | 1252 case 6: |
1253 input = abs(port->device.mouse.delta_x) & 0xF; | 1253 input = port->device.mouse.delta_x & 0xF; |
1254 break; | 1254 break; |
1255 case 7: | 1255 case 7: |
1256 input = abs(port->device.mouse.delta_y) >> 4 & 0xF; | 1256 input = port->device.mouse.delta_y >> 4 & 0xF; |
1257 break; | 1257 break; |
1258 case 8: | 1258 case 8: |
1259 input = abs(port->device.mouse.delta_y) & 0xF; | 1259 input = port->device.mouse.delta_y & 0xF; |
1260 //need to figure out when this actually happens | 1260 //need to figure out when this actually happens |
1261 port->device.mouse.last_read_x = port->device.mouse.cur_x; | 1261 port->device.mouse.last_read_x = port->device.mouse.cur_x; |
1262 port->device.mouse.last_read_y = port->device.mouse.cur_y; | 1262 port->device.mouse.last_read_y = port->device.mouse.cur_y; |
1263 break; | 1263 break; |
1264 default: | 1264 default: |