add a --leave-shift-keys, remove DONT_SHADOW_SHIFTS. refine #13

This commit is contained in:
Gwenhael Le Moine 2023-11-01 17:46:01 +01:00
parent a79bbf5a38
commit 0a899ecdc5
No known key found for this signature in database
GPG key ID: FDFE3669426707A7
7 changed files with 69 additions and 50 deletions

View file

@ -33,11 +33,6 @@ ifeq ($(FULL_WARNINGS), yes)
CFLAGS += -Wall -Wextra -Wpedantic -Wno-unused-parameter -Wno-unused-function -Wconversion -Wdouble-promotion -Wno-sign-conversion -fsanitize=undefined -fsanitize-trap
endif
DONT_SHADOW_SHIFTS = no
ifeq ($(DONT_SHADOW_SHIFTS), yes)
CFLAGS += -DDONT_SHADOW_SHIFTS=1
endif
DOTOS = src/emu_serial.o \
src/emu_emulate.o \
src/emu_init.o \

1
dist/config.lua vendored
View file

@ -29,6 +29,7 @@ mono = false
gray = false
small = false
tiny = false
leave_shift_keys = false
x11_visual = "default"
netbook = false

3
dist/x48ng.man.1 vendored
View file

@ -114,6 +114,9 @@ where options include (depending on compiled front-ends):
\-\-small make the text UI small (2×2 pixels per character) (default: false)
.br
\-\-tiny make the text UI tiny (2×4 pixels per character) (default: false)
.br
\-\-leave\-shift\-keys _not_ mapping the shift keys to let them free for numbers (default: false)
.SH DESCRIPTION
.I x48ng

View file

@ -37,6 +37,8 @@ char* port2FileName = NULL;
int frontend_type = FRONTEND_TEXT;
bool leave_shift_keys = false;
bool mono = false;
bool gray = false;
@ -244,6 +246,7 @@ int parse_args( int argc, char* argv[] )
int clopt_gray = -1;
int clopt_small = -1;
int clopt_tiny = -1;
int clopt_leave_shift_keys = -1;
char* optstring = "c:hvVtsirT";
struct option long_options[] = {
@ -288,6 +291,7 @@ int parse_args( int argc, char* argv[] )
{ "gray", no_argument, &clopt_gray, true },
{ "small", no_argument, &clopt_small, true },
{ "tiny", no_argument, &clopt_tiny, true },
{ "leave-shift-keys", no_argument, &clopt_leave_shift_keys, true },
{ 0, 0, 0, 0 }
};
@ -348,6 +352,8 @@ int parse_args( int argc, char* argv[] )
" --small make the text UI small (2×2 pixels per character) (default: "
"false)\n"
" --tiny make the text UI tiny (2×4 pixels per character) (default: "
"false)\n"
" --leave-shift-keys _not_ mapping the shift keys to let them free for numbers (default: "
"false)\n";
while ( c != EOF ) {
c = getopt_long( argc, argv, optstring, long_options, &option_index );
@ -517,6 +523,9 @@ int parse_args( int argc, char* argv[] )
lua_getglobal( config_lua_values, "tiny" );
tiny = lua_toboolean( config_lua_values, -1 );
lua_getglobal( config_lua_values, "leave_shift_keys" );
leave_shift_keys = lua_toboolean( config_lua_values, -1 );
lua_getglobal( config_lua_values, "x11_visual" );
x11_visual = ( char* )luaL_optstring( config_lua_values, -1, "default" );
@ -586,6 +595,8 @@ int parse_args( int argc, char* argv[] )
small = clopt_small;
if ( clopt_tiny != -1 )
tiny = clopt_tiny;
if ( clopt_leave_shift_keys != -1 )
leave_shift_keys = clopt_leave_shift_keys;
/* After getting configs and params */
/* normalize config_dir again in case it's been modified */
@ -637,6 +648,7 @@ int parse_args( int argc, char* argv[] )
fprintf( stdout, "gray = %s\n", gray ? "true" : "false" );
fprintf( stdout, "small = %s\n", small ? "true" : "false" );
fprintf( stdout, "tiny = %s\n", tiny ? "true" : "false" );
fprintf( stdout, "leave_shift_keys = %s\n", leave_shift_keys ? "true" : "false" );
fprintf( stdout, "\n" );
fprintf( stdout, "x11_visual = \"%s\"\n", x11_visual );
fprintf( stdout, "netbook = %s\n", netbook ? "true" : "false" );

View file

@ -19,6 +19,8 @@ extern int frontend_type;
extern char* serialLine;
extern bool leave_shift_keys;
extern bool mono;
extern bool gray;

View file

@ -708,14 +708,14 @@ static int SDLKeyToKey( SDLKey k )
case SDLK_ESCAPE:
return HPKEY_ON;
break;
#ifndef DONT_SHADOW_SHIFTS
case SDLK_LSHIFT:
if ( !leave_shift_keys )
return HPKEY_SHL;
break;
case SDLK_RSHIFT:
if ( !leave_shift_keys )
return HPKEY_SHR;
break;
#endif
case SDLK_LCTRL:
return HPKEY_SHR;
break;

View file

@ -2700,16 +2700,22 @@ int decode_key( XEvent* xev, KeySym sym, char* buf, int buflen )
key_event( HPKEY_ON, xev );
wake = 1;
break;
#ifndef DONT_SHADOW_SHIFTS
case XK_Shift_L:
#endif
if ( !leave_shift_keys ) {
key_event( HPKEY_SHL, xev );
wake = 1;
}
break;
case XK_Control_R:
key_event( HPKEY_SHL, xev );
wake = 1;
break;
#ifndef DONT_SHADOW_SHIFTS
case XK_Shift_R:
#endif
if ( !leave_shift_keys ) {
key_event( HPKEY_SHR, xev );
wake = 1;
}
break;
case XK_Control_L:
key_event( HPKEY_SHR, xev );
wake = 1;