Mercurial > repos > blastem
comparison io.c @ 1256:ccf5c02610c6
Only allow keyboard capture if the emulated system has a keyboard attached
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Wed, 01 Mar 2017 00:00:04 -0800 |
parents | d966298442d4 |
children | db28178bd2a1 |
comparison
equal
deleted
inserted
replaced
1255:6370b80491c7 | 1256:ccf5c02610c6 |
---|---|
390 | 390 |
391 int current_speed = 0; | 391 int current_speed = 0; |
392 int num_speeds = 1; | 392 int num_speeds = 1; |
393 uint32_t * speeds = NULL; | 393 uint32_t * speeds = NULL; |
394 | 394 |
395 uint8_t is_keyboard(io_port *port) | |
396 { | |
397 return port->device_type == IO_SATURN_KEYBOARD || port->device_type == IO_XBAND_KEYBOARD; | |
398 } | |
399 | |
400 uint8_t keyboard_connected(sega_io *io) | |
401 { | |
402 return is_keyboard(io->ports) || is_keyboard(io->ports+1) || is_keyboard(io->ports+2); | |
403 } | |
404 | |
395 void handle_binding_up(keybinding * binding) | 405 void handle_binding_up(keybinding * binding) |
396 { | 406 { |
397 switch(binding->bind_type) | 407 switch(binding->bind_type) |
398 { | 408 { |
399 case BIND_GAMEPAD1: | 409 case BIND_GAMEPAD1: |
469 current_io->mouse_captured = 0; | 479 current_io->mouse_captured = 0; |
470 render_relative_mouse(0); | 480 render_relative_mouse(0); |
471 } | 481 } |
472 break; | 482 break; |
473 case UI_TOGGLE_KEYBOARD_CAPTURE: | 483 case UI_TOGGLE_KEYBOARD_CAPTURE: |
474 current_io->keyboard_captured = !current_io->keyboard_captured; | 484 if (keyboard_connected(current_io)) { |
485 current_io->keyboard_captured = !current_io->keyboard_captured; | |
486 } | |
475 break; | 487 break; |
476 case UI_TOGGLE_FULLSCREEN: | 488 case UI_TOGGLE_FULLSCREEN: |
477 render_toggle_fullscreen(); | 489 render_toggle_fullscreen(); |
478 break; | 490 break; |
479 case UI_SOFT_RESET: | 491 case UI_SOFT_RESET: |