Commit 5e5dd844 authored by Andre Leiradella's avatar Andre Leiradella
Browse files

fixes to the input system, to the embedded keyboard, and to the LOAD "" command

parent 263b262f
......@@ -8,6 +8,7 @@ static int timer; // milliseconds counter to release the key
static uint32_t joystate = 0; // joystick button states
static uint32_t keystate[ ( RETROK_LAST + 31 ) / 32 ] = { 0 }; // key states
#define TOGGLE 1
#define PRESSED 2
#define SELECTED 4
......@@ -295,7 +296,7 @@ static void update( retro_input_state_t input_cb, unsigned* devices, int ms )
}
}
}
else
else if ( timer <= 0 )
{
// virtual keyboard navigation
......@@ -315,15 +316,15 @@ static void update( retro_input_state_t input_cb, unsigned* devices, int ms )
case RETRO_DEVICE_ID_JOYPAD_A:
case RETRO_DEVICE_ID_JOYPAD_B:
{
if ( key->meta & 1 )
if ( key->meta & TOGGLE )
{
key->meta ^= PRESSED;
}
else if ( timer <= 0 )
else
{
for ( k = ovl->keys; k->id != 0xffff; k++ )
{
if ( ( k->meta & ( PRESSED | 1 ) ) == ( PRESSED | 1 ) )
if ( ( k->meta & ( PRESSED | TOGGLE ) ) == ( PRESSED | TOGGLE ) )
{
ovl->keypress( ovl, k->mapped );
}
......@@ -346,33 +347,36 @@ static void update( retro_input_state_t input_cb, unsigned* devices, int ms )
// Process the keyboard
for ( p = 0; p < 2; p++ )
if ( !visible )
{
if ( ( devices[ p ] & RETRO_DEVICE_MASK ) != RETRO_DEVICE_KEYBOARD )
{
continue;
}
for ( k = ovl->keys; k->id != 0xffff; k++ )
for ( p = 0; p < 2; p++ )
{
int16_t is_down = input_cb( p, devices[ p ], 0, k->retro );
int index = k->retro / 32;
uint32_t bit = 1 << ( k->retro & 31 );
if ( is_down )
if ( ( devices[ p ] & RETRO_DEVICE_MASK ) != RETRO_DEVICE_KEYBOARD )
{
if ( ( keystate[ index ] & bit ) == 0 )
{
keystate[ index ] |= bit;
ovl->keypress( ovl, k->mapped );
}
continue;
}
else
for ( k = ovl->keys; k->id != 0xffff; k++ )
{
if ( keystate[ index ] & bit )
int16_t is_down = input_cb( p, devices[ p ], 0, k->retro );
int index = k->retro / 32;
uint32_t bit = 1 << ( k->retro & 31 );
if ( is_down )
{
keystate[ index ] &= ~bit;
ovl->keyrelease( ovl, k->mapped );
if ( ( keystate[ index ] & bit ) == 0 )
{
keystate[ index ] |= bit;
ovl->keypress( ovl, k->mapped );
}
}
else
{
if ( keystate[ index ] & bit )
{
keystate[ index ] &= ~bit;
ovl->keyrelease( ovl, k->mapped );
}
}
}
}
......
......@@ -12,8 +12,8 @@
#include <zx81.h>
#include <tzx/TZXFILE.h>
#define RETRO_DEVICE_SINCLAIR_KEYBOARD RETRO_DEVICE_KEYBOARD
#define RETRO_DEVICE_CURSOR_JOYSTICK RETRO_DEVICE_JOYPAD
#define RETRO_DEVICE_SINCLAIR_KEYBOARD RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_KEYBOARD, 0)
#define RETRO_DEVICE_CURSOR_JOYSTICK RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 0)
#ifdef LOG_PERFORMANCE
#define RETRO_PERFORMANCE_INIT( name ) do { static struct retro_perf_counter name = { #name }; if ( !name.registered ) perf_cb.perf_register( &( name ) ) } while ( 0 )
......@@ -67,6 +67,8 @@ extern TTZXFile TZXFile;
static state_t state;
#define ZX81KEYS "default|new line|shift|space|.|0|1|2|3|4|5|6|7|8|9|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z"
static const struct retro_variable core_vars[] =
{
{ "81_fast_load", "Tape Fast Load; enabled|disabled" },
......@@ -75,20 +77,20 @@ static const struct retro_variable core_vars[] =
{ "81_chroma_81", "Emulate Chroma 81; disabled|enabled" },
{ "81_video_presets", "Video Presets; clean|tv|noisy" },
{ "81_sound", "Sound emulation; none|Zon X-81" },
{ "81_joypad_up", "Joypad Up mapping; default|new line|shift|space|.|0|1|2|3|4|5|6|7|8|9|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z" },
{ "81_joypad_down", "Joypad Down mapping; default|new line|shift|space|.|0|1|2|3|4|5|6|7|8|9|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z" },
{ "81_joypad_left", "Joypad Left mapping; default|new line|shift|space|.|0|1|2|3|4|5|6|7|8|9|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z" },
{ "81_joypad_right", "Joypad Right mapping; default|new line|shift|space|.|0|1|2|3|4|5|6|7|8|9|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z" },
{ "81_joypad_fire", "Joypad Fire mapping; default|new line|shift|space|.|0|1|2|3|4|5|6|7|8|9|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z" },
{ "81_joypad_up", "Joypad Up mapping; " ZX81KEYS },
{ "81_joypad_down", "Joypad Down mapping; " ZX81KEYS },
{ "81_joypad_left", "Joypad Left mapping; " ZX81KEYS },
{ "81_joypad_right", "Joypad Right mapping; " ZX81KEYS },
{ "81_joypad_fire", "Joypad Fire mapping; " ZX81KEYS },
{ "81_keybovl_transp", "Transparent Keyboard Overlay; enabled|disabled" },
{ "81_key_hold_time", "Time to Release Key in ms; 500|1000|100|300" },
{ "81_key_hold_time", "Time to Release Key in ms; 100|300|500|1000" },
{ NULL, NULL },
};
#define UPDATE_RESET 1
#define UPDATE_AV 2
static int update_variables( void )
static int update_variables()
{
int reset = 0;
int old_scaled = state.scaled;
......@@ -325,9 +327,6 @@ bool retro_load_game( const struct retro_game_info* info )
memcpy( state.data, info->data, state.size );
state.devices[ 0 ] = RETRO_DEVICE_CURSOR_JOYSTICK;
state.devices[ 1 ] = RETRO_DEVICE_SINCLAIR_KEYBOARD;
state.cfg.machine = MACHINEZX81;
state.cfg.LambdaColour = COLOURDISABLED;
state.cfg.LowRAMContents = LOWRAM_ROMSHADOW;
......@@ -343,6 +342,7 @@ bool retro_load_game( const struct retro_game_info* info )
state.cfg.Chroma81 = 0;
state.scaled = -1;
TZXFile.AddTextBlock( "" ); // prevent a crash if the user does a LOAD ""
TZXFile.FlashLoad = true;
update_variables();
......
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