Mercurial > repos > blastem
comparison io.c @ 1595:360d5bab199f
Update controller config when changed in UI without restart
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Fri, 06 Jul 2018 17:39:59 -0700 |
parents | 430dd12e4010 |
children | c206a422d466 |
comparison
equal
deleted
inserted
replaced
1594:137dbd05ceab | 1595:360d5bab199f |
---|---|
200 return find_keyboard(io) != NULL; | 200 return find_keyboard(io) != NULL; |
201 } | 201 } |
202 | 202 |
203 void process_device(char * device_type, io_port * port) | 203 void process_device(char * device_type, io_port * port) |
204 { | 204 { |
205 port->device_type = IO_NONE; | 205 //assuming that the io_port struct has been zeroed if this is the first time this has been called |
206 if (!device_type) | 206 if (!device_type) |
207 { | 207 { |
208 return; | 208 return; |
209 } | 209 } |
210 | 210 |
225 } else { | 225 } else { |
226 port->device_type = IO_GAMEPAD6; | 226 port->device_type = IO_GAMEPAD6; |
227 } | 227 } |
228 port->device.pad.gamepad_num = device_type[gamepad_len+2] - '0'; | 228 port->device.pad.gamepad_num = device_type[gamepad_len+2] - '0'; |
229 } else if(!strncmp(device_type, "mouse", mouse_len)) { | 229 } else if(!strncmp(device_type, "mouse", mouse_len)) { |
230 port->device_type = IO_MOUSE; | 230 if (port->device_type != IO_MOUSE) { |
231 port->device.mouse.mouse_num = device_type[mouse_len+1] - '0'; | 231 port->device_type = IO_MOUSE; |
232 port->device.mouse.last_read_x = 0; | 232 port->device.mouse.mouse_num = device_type[mouse_len+1] - '0'; |
233 port->device.mouse.last_read_y = 0; | 233 port->device.mouse.last_read_x = 0; |
234 port->device.mouse.cur_x = 0; | 234 port->device.mouse.last_read_y = 0; |
235 port->device.mouse.cur_y = 0; | 235 port->device.mouse.cur_x = 0; |
236 port->device.mouse.latched_x = 0; | 236 port->device.mouse.cur_y = 0; |
237 port->device.mouse.latched_y = 0; | 237 port->device.mouse.latched_x = 0; |
238 port->device.mouse.ready_cycle = CYCLE_NEVER; | 238 port->device.mouse.latched_y = 0; |
239 port->device.mouse.tr_counter = 0; | 239 port->device.mouse.ready_cycle = CYCLE_NEVER; |
240 port->device.mouse.tr_counter = 0; | |
241 } | |
240 } else if(!strcmp(device_type, "saturn keyboard")) { | 242 } else if(!strcmp(device_type, "saturn keyboard")) { |
241 port->device_type = IO_SATURN_KEYBOARD; | 243 if (port->device_type != IO_SATURN_KEYBOARD) { |
242 port->device.keyboard.read_pos = 0xFF; | 244 port->device_type = IO_SATURN_KEYBOARD; |
243 port->device.keyboard.write_pos = 0; | 245 port->device.keyboard.read_pos = 0xFF; |
246 port->device.keyboard.write_pos = 0; | |
247 } | |
244 } else if(!strcmp(device_type, "xband keyboard")) { | 248 } else if(!strcmp(device_type, "xband keyboard")) { |
245 port->device_type = IO_XBAND_KEYBOARD; | 249 if (port->device_type != IO_XBAND_KEYBOARD) { |
246 port->device.keyboard.read_pos = 0xFF; | 250 port->device_type = IO_XBAND_KEYBOARD; |
247 port->device.keyboard.write_pos = 0; | 251 port->device.keyboard.read_pos = 0xFF; |
252 port->device.keyboard.write_pos = 0; | |
253 } | |
248 } else if(!strcmp(device_type, "sega_parallel")) { | 254 } else if(!strcmp(device_type, "sega_parallel")) { |
249 port->device_type = IO_SEGA_PARALLEL; | 255 if (port->device_type != IO_SEGA_PARALLEL) { |
250 port->device.stream.data_fd = -1; | 256 port->device_type = IO_SEGA_PARALLEL; |
251 port->device.stream.listen_fd = -1; | 257 port->device.stream.data_fd = -1; |
258 port->device.stream.listen_fd = -1; | |
259 } | |
252 } else if(!strcmp(device_type, "generic")) { | 260 } else if(!strcmp(device_type, "generic")) { |
253 port->device_type = IO_GENERIC; | 261 if (port->device_type != IO_GENERIC) { |
254 port->device.stream.data_fd = -1; | 262 port->device_type = IO_GENERIC; |
255 port->device.stream.listen_fd = -1; | 263 port->device.stream.data_fd = -1; |
264 port->device.stream.listen_fd = -1; | |
265 } | |
256 } | 266 } |
257 } | 267 } |
258 | 268 |
259 char * io_name(int i) | 269 char * io_name(int i) |
260 { | 270 { |
306 bindings_set_mouse_mode(mouse_mode); | 316 bindings_set_mouse_mode(mouse_mode); |
307 | 317 |
308 for (int i = 0; i < 3; i++) | 318 for (int i = 0; i < 3; i++) |
309 { | 319 { |
310 #ifndef _WIN32 | 320 #ifndef _WIN32 |
311 if (ports[i].device_type == IO_SEGA_PARALLEL) | 321 if (ports[i].device_type == IO_SEGA_PARALLEL && ports[i].device.stream.data_fd == -1) |
312 { | 322 { |
313 char *pipe_name = tern_find_path(config, "io\0parallel_pipe\0", TVAL_PTR).ptrval; | 323 char *pipe_name = tern_find_path(config, "io\0parallel_pipe\0", TVAL_PTR).ptrval; |
314 if (!pipe_name) | 324 if (!pipe_name) |
315 { | 325 { |
316 warning("IO port %s is configured to use the sega parallel board, but no paralell_pipe is set!\n", io_name(i)); | 326 warning("IO port %s is configured to use the sega parallel board, but no paralell_pipe is set!\n", io_name(i)); |
333 ports[i].device_type = IO_NONE; | 343 ports[i].device_type = IO_NONE; |
334 } | 344 } |
335 } | 345 } |
336 } | 346 } |
337 } | 347 } |
338 } else if (ports[i].device_type == IO_GENERIC) { | 348 } else if (ports[i].device_type == IO_GENERIC && ports[i].device.stream.data_fd == -1) { |
339 char *sock_name = tern_find_path(config, "io\0socket\0", TVAL_PTR).ptrval; | 349 char *sock_name = tern_find_path(config, "io\0socket\0", TVAL_PTR).ptrval; |
340 if (!sock_name) | 350 if (!sock_name) |
341 { | 351 { |
342 warning("IO port %s is configured to use generic IO, but no socket is set!\n", io_name(i)); | 352 warning("IO port %s is configured to use generic IO, but no socket is set!\n", io_name(i)); |
343 ports[i].device_type = IO_NONE; | 353 ports[i].device_type = IO_NONE; |