Mercurial > repos > blastem
comparison io.c @ 1783:eda8df5bc74c
Minor cleanup
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 11 Mar 2019 00:04:48 -0700 |
parents | 7f42a93f18a4 |
children | 1843823f1e9b |
comparison
equal
deleted
inserted
replaced
1782:b2bffd98063d | 1783:eda8df5bc74c |
---|---|
217 { | 217 { |
218 return; | 218 return; |
219 } | 219 } |
220 | 220 |
221 const int gamepad_len = strlen("gamepad"); | 221 const int gamepad_len = strlen("gamepad"); |
222 const int mouse_len = strlen("mouse"); | 222 if (startswith(device_type, "gamepad")) |
223 if (!strncmp(device_type, "gamepad", gamepad_len)) | |
224 { | 223 { |
225 if ( | 224 if ( |
226 (device_type[gamepad_len] != '3' && device_type[gamepad_len] != '6' && device_type[gamepad_len] != '2') | 225 (device_type[gamepad_len] != '3' && device_type[gamepad_len] != '6' && device_type[gamepad_len] != '2') |
227 || device_type[gamepad_len+1] != '.' || device_type[gamepad_len+2] < '1' | 226 || device_type[gamepad_len+1] != '.' || device_type[gamepad_len+2] < '1' |
228 || device_type[gamepad_len+2] > '8' || device_type[gamepad_len+3] != 0 | 227 || device_type[gamepad_len+2] > '8' || device_type[gamepad_len+3] != 0 |
234 port->device_type = IO_GAMEPAD2; | 233 port->device_type = IO_GAMEPAD2; |
235 } else { | 234 } else { |
236 port->device_type = IO_GAMEPAD6; | 235 port->device_type = IO_GAMEPAD6; |
237 } | 236 } |
238 port->device.pad.gamepad_num = device_type[gamepad_len+2] - '0'; | 237 port->device.pad.gamepad_num = device_type[gamepad_len+2] - '0'; |
239 } else if(!strncmp(device_type, "mouse", mouse_len)) { | 238 } else if(startswith(device_type, "mouse")) { |
240 if (port->device_type != IO_MOUSE) { | 239 if (port->device_type != IO_MOUSE) { |
241 port->device_type = IO_MOUSE; | 240 port->device_type = IO_MOUSE; |
242 port->device.mouse.mouse_num = device_type[mouse_len+1] - '0'; | 241 port->device.mouse.mouse_num = device_type[strlen("mouse")+1] - '0'; |
243 port->device.mouse.last_read_x = 0; | 242 port->device.mouse.last_read_x = 0; |
244 port->device.mouse.last_read_y = 0; | 243 port->device.mouse.last_read_y = 0; |
245 port->device.mouse.cur_x = 0; | 244 port->device.mouse.cur_x = 0; |
246 port->device.mouse.cur_y = 0; | 245 port->device.mouse.cur_y = 0; |
247 port->device.mouse.latched_x = 0; | 246 port->device.mouse.latched_x = 0; |