Commit bfe3799b authored by Thomas Conte's avatar Thomas Conte
Browse files

Auto-load setting + shift keys support

parent 3f2c831c
Pipeline #32278 passed with stages
in 5 minutes and 27 seconds
......@@ -5,6 +5,11 @@
#include <input.h>
#include <ui/ui.h>
enum keyb_states {
CAPS_SHIFT_PRESSED = 0x01,
SYMBOL_SHIFT_PRESSED = 0x02
};
static int64_t get_time_usec()
{
return (int64_t)( total_time_ms * 1000.0 );
......@@ -86,6 +91,15 @@ int ui_event(void)
{
keyb_event.type = INPUT_EVENT_KEYRELEASE;
input_event(&keyb_event);
// Also release shift keys
input_event_t shift_event;
shift_event.type = INPUT_EVENT_KEYRELEASE;
shift_event.types.key.native_key = INPUT_KEY_Shift_L;
shift_event.types.key.spectrum_key = INPUT_KEY_Shift_L;
input_event(&shift_event);
shift_event.types.key.native_key = INPUT_KEY_Control_R;
shift_event.types.key.spectrum_key = INPUT_KEY_Control_R;
input_event(&shift_event);
keyb_send = 0;
}
......@@ -276,14 +290,30 @@ int ui_event(void)
case RETRO_DEVICE_ID_JOYPAD_A:
if (keyb_send == 0)
{
keyb_overlay = false;
keyb_event.type = INPUT_EVENT_KEYPRESS;
keyb_event.types.key.native_key = keyb_layout[keyb_y][keyb_x];
keyb_event.types.key.spectrum_key = keyb_layout[keyb_y][keyb_x];
input_event(&keyb_event);
keyb_send = get_time_usec() + keyb_hold_time;
switch (keyb_event.types.key.spectrum_key)
{
case INPUT_KEY_Shift_L:
keyb_shift |= CAPS_SHIFT_PRESSED;
break;
case INPUT_KEY_Control_R:
keyb_shift |= SYMBOL_SHIFT_PRESSED;
break;
default:
keyb_shift = 0;
break;
}
if ((keyb_shift == (CAPS_SHIFT_PRESSED | SYMBOL_SHIFT_PRESSED)) || !keyb_shift)
{
keyb_send = get_time_usec() + keyb_hold_time;
keyb_overlay = false;
keyb_shift = 0;
}
}
return 0;
}
......
......@@ -39,6 +39,7 @@ extern unsigned input_devices[MAX_PADS];
extern int64_t keyb_send;
extern int64_t keyb_hold_time;
extern input_event_t keyb_event;
extern int8_t keyb_shift;
extern int select_pressed;
extern int keyb_overlay;
extern unsigned keyb_x;
......
......@@ -12,7 +12,6 @@ int settings_init(int *first_arg, int argc, char **argv)
{
int res = fuse_settings_init(first_arg, argc, argv);
settings_current.auto_load = 1;
settings_current.detect_loader = 1;
settings_current.printer = 0;
......
......@@ -104,6 +104,7 @@ unsigned input_devices[MAX_PADS];
int64_t keyb_send;
int64_t keyb_hold_time;
input_event_t keyb_event;
int8_t keyb_shift;
int select_pressed;
int keyb_overlay;
unsigned keyb_x;
......@@ -268,6 +269,7 @@ static const struct retro_variable core_vars[] =
{
{ "fuse_machine", "Model (needs content load); Spectrum 48K|Spectrum 48K (NTSC)|Spectrum 128K|Spectrum +2|Spectrum +2A|Spectrum +3|Spectrum +3e|Spectrum SE|Timex TC2048|Timex TC2068|Timex TS2068|Spectrum 16K|Pentagon 128K|Pentagon 512K|Pentagon 1024|Scorpion 256K" },
{ "fuse_hide_border", "Hide Video Border; disabled|enabled" },
{ "fuse_auto_load", "Tape Auto Load; enabled|disabled" },
{ "fuse_fast_load", "Tape Fast Load; enabled|disabled" },
{ "fuse_load_sound", "Tape Load Sound; enabled|disabled" },
{ "fuse_speaker_type", "Speaker Type; tv speaker|beeper|unfiltered" },
......@@ -375,8 +377,7 @@ int update_variables(int force)
}
}
settings_current.fastload = coreopt(env_cb, core_vars, "fuse_fast_load", NULL) != 1;
settings_current.accelerate_loader = settings_current.fastload;
settings_current.auto_load = coreopt(env_cb, core_vars, "fuse_auto_load", NULL) != 1;
if (coreopt(env_cb, core_vars, "fuse_fast_load", NULL) == 0)
{
......@@ -688,7 +689,7 @@ bool retro_load_game(const struct retro_game_info *info)
*/
// autoload is on by default
int autoload = 1;
int autoload = settings_current.auto_load;
// Disable autoload for tapes on Scorpion 256 (it doesn't work)
if (!strcmp(settings_current.start_machine, machine_get_id(LIBSPECTRUM_MACHINE_SCORP)) &&
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment