remap Fx keys in tui and standardize them across all 3 UIs (x11, sdl and tui)

This commit is contained in:
Gwenhael Le Moine 2023-11-02 10:04:40 +01:00
parent f96d7da619
commit 2ecd7d5386
No known key found for this signature in database
GPG key ID: FDFE3669426707A7
4 changed files with 53 additions and 35 deletions

View file

@ -43,12 +43,14 @@ You can use the script `setup-x48ng-home.sh` or simply run `x48ng --rom=<romfile
I had to be a bit 'creative' mapping keys there:
- `On` is either `F4` or `Esc` or `Home` or `\`
- `Left Shift` is either `F5` or `PgUp` or `[`
- `Right Shift` is either `F6` or `PgDn` or `]`
- `Alpha` is either `F8` or `Ins` or `;`
- _Enter_ is either `Return` or `Ctrl-J` or `F1`
- _Left Shift_ is either `PgUp` or `[` or `F2`
- _Right Shift_ is either `PgDn` or `]` or `F3`
- _Alpha_ is either `Ins` or `;` or `F4`
- _On_ is either `Esc` or `Home` or `\` or `F5`
- finally `|` or `Shift+End` or `F10` or `F7` **quits** x48ng
_To quit `x48ng --tui` use `F10` or `Shift+End` or `|`_
These keybindings have been standardized across all 3 UIs (x11, sdl and tui)
## What have I done:

View file

@ -663,9 +663,8 @@ static int SDLKeyToKey( SDLKey k )
case SDLK_SPACE:
return HPKEY_SPC;
break;
case SDLK_F1:
case SDLK_RETURN:
return HPKEY_ENTER;
break;
case SDLK_KP_ENTER:
return HPKEY_ENTER;
break;
@ -705,6 +704,7 @@ static int SDLKeyToKey( SDLKey k )
case SDLK_KP_DIVIDE:
return HPKEY_DIV;
break;
case SDLK_F5:
case SDLK_ESCAPE:
return HPKEY_ON;
break;
@ -716,18 +716,24 @@ static int SDLKeyToKey( SDLKey k )
if ( !leave_shift_keys )
return HPKEY_SHR;
break;
case SDLK_LCTRL:
return HPKEY_SHR;
break;
case SDLK_F2:
case SDLK_RCTRL:
return HPKEY_SHL;
break;
case SDLK_LALT:
return HPKEY_ALPHA;
case SDLK_F3:
case SDLK_LCTRL:
return HPKEY_SHR;
break;
case SDLK_F4:
case SDLK_LALT:
case SDLK_RALT:
return HPKEY_ALPHA;
break;
case SDLK_F7:
case SDLK_F10:
exit_emulator();
exit( 0 );
break;
default:
return -1;
}

View file

@ -385,16 +385,6 @@ static inline int ncurses_get_event( void )
case ' ':
hpkey = HPKEY_SPC;
break;
case KEY_ENTER:
case '\n':
case ',':
hpkey = HPKEY_ENTER;
break;
case KEY_BACKSPACE:
case 127:
case '\b':
hpkey = HPKEY_BS;
break;
case KEY_DC:
hpkey = HPKEY_DEL;
break;
@ -414,33 +404,42 @@ static inline int ncurses_get_event( void )
hpkey = HPKEY_DIV;
break;
case KEY_F( 1 ):
case KEY_ENTER:
case '\n':
case ',':
hpkey = HPKEY_ENTER;
break;
case KEY_BACKSPACE:
case 127:
case '\b':
hpkey = HPKEY_BS;
break;
case KEY_F( 2 ):
case '[':
case 339: /* PgUp */
case KEY_F( 5 ):
hpkey = HPKEY_SHL;
break;
case KEY_F( 3 ):
case ']':
case 338: /* PgDn */
case KEY_F( 6 ):
hpkey = HPKEY_SHR;
break;
case KEY_F( 4 ):
case ';':
case KEY_IC: /* Ins */
case KEY_F( 7 ):
case KEY_F( 8 ):
hpkey = HPKEY_ALPHA;
break;
case KEY_F( 5 ):
case '\\':
/* case KEY_ESC: */
case 27: /* Esc */
case 262: /* Home */
case KEY_F( 4 ):
hpkey = HPKEY_ON;
break;
case KEY_F( 7 ):
case '|': /* Shift+\ */
case KEY_SEND: /* Shift+End */
case KEY_F( 1 ):
case KEY_F( 10 ):
nodelay( stdscr, FALSE );
echo();

View file

@ -2673,6 +2673,7 @@ int decode_key( XEvent* xev, KeySym sym, char* buf, int buflen )
key_event( HPKEY_MUL, xev );
wake = 1;
break;
case XK_F1:
case XK_KP_Enter:
case XK_Return:
key_event( HPKEY_ENTER, xev );
@ -2696,6 +2697,7 @@ int decode_key( XEvent* xev, KeySym sym, char* buf, int buflen )
key_event( HPKEY_BS, xev );
wake = 1;
break;
case XK_F5:
case XK_Escape:
key_event( HPKEY_ON, xev );
wake = 1;
@ -2706,6 +2708,7 @@ int decode_key( XEvent* xev, KeySym sym, char* buf, int buflen )
wake = 1;
}
break;
case XK_F2:
case XK_Control_R:
key_event( HPKEY_SHL, xev );
wake = 1;
@ -2716,10 +2719,12 @@ int decode_key( XEvent* xev, KeySym sym, char* buf, int buflen )
wake = 1;
}
break;
case XK_F3:
case XK_Control_L:
key_event( HPKEY_SHR, xev );
wake = 1;
break;
case XK_F4:
case XK_Alt_L:
case XK_Alt_R:
case XK_Meta_L:
@ -2729,37 +2734,37 @@ int decode_key( XEvent* xev, KeySym sym, char* buf, int buflen )
break;
case XK_a:
case XK_A:
case XK_F1:
/* case XK_F1: */
key_event( HPKEY_A, xev );
wake = 1;
break;
case XK_b:
case XK_B:
case XK_F2:
/* case XK_F2: */
key_event( HPKEY_B, xev );
wake = 1;
break;
case XK_c:
case XK_C:
case XK_F3:
/* case XK_F3: */
key_event( HPKEY_C, xev );
wake = 1;
break;
case XK_d:
case XK_D:
case XK_F4:
/* case XK_F4: */
key_event( HPKEY_D, xev );
wake = 1;
break;
case XK_e:
case XK_E:
case XK_F5:
/* case XK_F5: */
key_event( HPKEY_E, xev );
wake = 1;
break;
case XK_f:
case XK_F:
case XK_F6:
/* case XK_F6: */
key_event( HPKEY_F, xev );
wake = 1;
break;
@ -2867,6 +2872,12 @@ int decode_key( XEvent* xev, KeySym sym, char* buf, int buflen )
key_event( HPKEY_EEX, xev );
wake = 1;
break;
case XK_F7:
case XK_F10:
exit_emulator();
XCloseDisplay( dpy );
exit( 0 );
break;
default:
break;
}