Menu

#101 UI key remapping

future
open
nobody
5
2016-08-06
2016-08-06
No

When I try to play with Wizard of Wor (http://www.worldofspectrum.org/infoseekid.cgi?id=0018543) with my son a (couple of) two player game, I realized two things:
1. there is no any support for two keyboard-joystick in Fuse
2. we cannot use any "extra" key (control pad, numpad, etc) for keyboard-joystick

So, I think the best solution is to providing a general UI key remapping feature.
My aim was to make a simple, but flexible implementation. Now it works with GTK+ (at least GTK3), SDL and X11 UI.

We can determine key mapping with '--remapkeys' option. The format: key_from:key_to key_from:key_to ... e.g.: "KP_Left:1 KP_Right:2 1:0"
We can use '>' instead of ':', so "KP_Left>1 KP_Right>2 1:0" is the same as above. With this mapping, if we press keypad left (or keypad 4) it mapped to '1', if we press '1' a '0' appears.
Note: with this UIs we get "unmodified" keysyms. e.g. we never get a KP_4 key, even NumLock is "On", or a 'Q' (capital Q), alway get 'q' even Shift pressed or CapsLock is On.
With this key remapping we can easily workaround the problems with AZERTY keyboard layouts, where the number keys are 'shifted' see [feature-requests:#59] (numeric keys not working in fuse 0.10.0.2 for Czech keyboard). With --remapkeys "plus:1 ecaron:2 scaron:3 ccaron:4 rcaron:5 zcaron:6 yacute:7 aacute:8 iacute:9 eacute:0" we can use fuse with Czech layout. Note: with SDL UI we need some extra work, because SDL hasn't got unique keysyms for different "code tables"...

Back to two player games, there are some option for Sinclair 1&2 joysticks ;)
--remapjoy-enable enable or disable the Sinclair joystick related keymappings. It can be toggle from the UI. So during the gameplay we can switch on or off these mappings as we need ...
--remapjoy-custom1 user defined key mapping for Sinclair joy 1 (or 2)
--remapjoy-custom2 user defined key mapping for Sinclair joy 2 (or 1)
--remapjoy1 and --remapjoy2 we can select predefined or custom maps for Sinclair 1&2 joys. Available options: None, Numpad23470, OPAQspc, WEQ1Z, Ctrlpad, Numpad46285, Custom1 and Custom2. We can select this values through the UI (too).
This predefined and "custom" maps are simple keymaps, so OPAQspc is equal with "o>1 p>2 a>3 q>4 space>5". (So with custom maps we can define another, not joystick related keymaps...)

The patch:
configure.ac:
- add "--disable-remapkeys" option to build Fuse without this feature
- add UI_REMAPKEYS macro and AM condition
menu.h:
- add "menu_options_joysticks_sinclair()" declaration
menu_data.dat:
- add new menuitem to "Options/Joysticks"
menu_data.pl:
- add ode to replace '&' with '&' for "menu_data.ui" generation (GTK)
periph.c:
- add code to reparse keymaps after close options if needed
settings.dat:
- add new options
ui/{,gtk/,sdl/,xlib/}Makefile.am
- add new source files and rules to generate keymap parsing tables
ui/gtk/gtkinternals.h:
- add gtkkeyboard_init() declaration
ui/{gtk/gtk,sdl/sdl,xlib/x}keyboard.c:
- add code to initialize ui_remapkeys with GTK/SDL/X key table (in sdlkeyboard.c we have ..._init() and ..._end() functions)
- add code to do key remapping
ui/{gtk/gtk,xlib/x}ui.c:
- add code to call {x,gtk}keyboard_init() at startup
- add code to destroy keymap hash (ui_remapkeys_end()) at finish
ui/{gtk,sdl,xlib}/remapkeys.dat:
- keysyms data for building remapkeys.c (which included as "remapkeys_tab[]" data)
- in GTK/X11 data, the capital letters commented out, because the parsing of keysyms is case insenitive now (we never get "modified", "shifted" keysyms!), so capital letters (e.g. A or Aacute) make some trouble... Fuse find Aacute instead of aacute if Aacute is defined in "remapkeys_tab[]"...
ui/options.dat:
- add a new option dialog for Sinclair joysticks
ui/remapkeys.pl:
- new script to generate "remapkeys_tab[]" data for keymap string parsing
- the GTK and the X11 keysyms are quite similar, but we have to "fix" some SDL keysyms to looks like X11's/GTK's...
ui/ui.h:
- add "remapkeys_t" struct definition
- add "ui_remapkeys_xxx()" function definitions
ui/uiremapkeys.c:
- new functions for keymap parsing, hash generation, lookup...
ui/widget/menu.c, ui/widget/widget.{h,c}:
- add code for new sinclair joystick option widget

1 Attachments

Related

Feature Requests: #59
Patches: #358

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.