Skip to content

Commit

Permalink
Complete list of keycodes that can be remapped (Fixes #142) (#143)
Browse files Browse the repository at this point in the history
* Complete list of keycodes that can be remapped (Fixes #142)

* Added warning about renamed num keycodes to README (#142)

* Removed type from README (#142)
  • Loading branch information
micheldebree committed Nov 19, 2021
1 parent 3b30d93 commit 2b03a4d
Show file tree
Hide file tree
Showing 4 changed files with 238 additions and 45 deletions.
3 changes: 3 additions & 0 deletions README.md
Expand Up @@ -18,6 +18,9 @@ binaries](https://github.com/Chordian/sidfactory2/workflows/Build%20macOS%20bina

## Changelog

- Changed: [#142](https://github.com/Chordian/sidfactory2/issues/142) the
list of keys that can be remapped is complete now. Please note: the names for
keycodes starting with `num` are renamed to start with `kp_`.
- Added: Documentation on how to customize configuration using a `user.ini`
file. Including a default template `/documentation/user.default.ini`.
- Added: Configuration option `Window.Scaling` to scale the contents of the
Expand Down
13 changes: 8 additions & 5 deletions SIDFactoryII/config.ini
Expand Up @@ -116,6 +116,9 @@ ColorScheme.Filename += "classic.ini"
// multiple key definitions for an action by separating the definitions with a comma on the same line. If you want this to
// be sticky, create the user.ini file and copy the changed key definition lines to it.
//
// The possible values for the keycodes can be found at https://wiki.libsdl.org/SDL_Keycode in the column 'SDL_Keycode Value'.
// Remove the SDLK_ part and make lowercase. For example SDLK_KP_PLUS becomes the code @kp_plus.

Key.ScreenEdit.Stop = @escape
Key.ScreenEdit.Play = @f1
Key.ScreenEdit.PlayFromMarker = @f2
Expand Down Expand Up @@ -150,10 +153,10 @@ Key.ScreenEdit.IncrementEventHighlightInterval = @down:alt
Key.ScreenEdit.IncrementEventHighlightOffset = @down:alt:shift
Key.ScreenEdit.ToggleFollowPlay = @p::control
Key.ScreenEdit.ToggleDisplayHexUppercase = @u:control
Key.ScreenEdit.IncrementInstrumentIndex = @numplus, @down:alt:control
Key.ScreenEdit.DecrementInstrumentIndex = @numminus, @up:alt:control
Key.ScreenEdit.IncrementCommandIndex = @numplus:control, @down:alt:control:shift
Key.ScreenEdit.DecrementCommandIndex = @numminus:control, @up:alt:control:shift
Key.ScreenEdit.IncrementInstrumentIndex = @kp_plus, @down:alt:control
Key.ScreenEdit.DecrementInstrumentIndex = @kp_minus, @up:alt:control
Key.ScreenEdit.IncrementCommandIndex = @kp_plus:control, @down:alt:control:shift
Key.ScreenEdit.DecrementCommandIndex = @kp_minus:control, @up:alt:control:shift
Key.ScreenEdit.SetOrderlistLoopPointAll = @l:control
Key.ScreenEdit.FastForward = @half
Key.ScreenEdit.FasterForward = @half:shift
Expand Down Expand Up @@ -285,4 +288,4 @@ Key.OrderListOverview.Paste = @v:cmd
[debug] // Applies to debug builds only

Sound.Emulation.Resample = 0 // If this is set to 1, the SID emulation will use resampling, otherwise it will only use linear
// interpolation. Resampling is the best quality possible but also requires more CPU power.
// interpolation. Resampling is the best quality possible but also requires more CPU power.
27 changes: 22 additions & 5 deletions SIDFactoryII/config/config.ini
Expand Up @@ -44,6 +44,9 @@ Editor.Follow.Play = 0 // If you set this to 1, follow
Editor.Sequence.Highlights = 0 // If you set this to 1, sequence highlights are on by default.
Editor.Confirm.QuickSave = 1 // If you set this to 1, a confirmation dialog pops up when quick saving
// If set to 0, the quick save is performed without asking for confirmation
Editor.Driver.ConvertLegacyColors = 1 // DEPRECATED - this will be deleted soon.
//
Expand Down Expand Up @@ -113,6 +116,9 @@ ColorScheme.Filename += "classic.ini"
// multiple key definitions for an action by separating the definitions with a comma on the same line. If you want this to
// be sticky, create the user.ini file and copy the changed key definition lines to it.
//
// The possible values for the keycodes can be found at https://wiki.libsdl.org/SDL_Keycode in the column 'SDL_Keycode Value'.
// Remove the SDLK_ part and make lowercase. For example SDLK_KP_PLUS becomes the code @kp_plus.

Key.ScreenEdit.Stop = @escape
Key.ScreenEdit.Play = @f1
Key.ScreenEdit.PlayFromMarker = @f2
Expand Down Expand Up @@ -147,10 +153,10 @@ Key.ScreenEdit.IncrementEventHighlightInterval = @down:alt
Key.ScreenEdit.IncrementEventHighlightOffset = @down:alt:shift
Key.ScreenEdit.ToggleFollowPlay = @p::control
Key.ScreenEdit.ToggleDisplayHexUppercase = @u:control
Key.ScreenEdit.IncrementInstrumentIndex = @numplus, @down:alt:control
Key.ScreenEdit.DecrementInstrumentIndex = @numminus, @up:alt:control
Key.ScreenEdit.IncrementCommandIndex = @numplus:control, @down:alt:control:shift
Key.ScreenEdit.DecrementCommandIndex = @numminus:control, @up:alt:control:shift
Key.ScreenEdit.IncrementInstrumentIndex = @kp_plus, @down:alt:control
Key.ScreenEdit.DecrementInstrumentIndex = @kp_minus, @up:alt:control
Key.ScreenEdit.IncrementCommandIndex = @kp_plus:control, @down:alt:control:shift
Key.ScreenEdit.DecrementCommandIndex = @kp_minus:control, @up:alt:control:shift
Key.ScreenEdit.SetOrderlistLoopPointAll = @l:control
Key.ScreenEdit.FastForward = @half
Key.ScreenEdit.FasterForward = @half:shift
Expand Down Expand Up @@ -196,13 +202,20 @@ Key.Track.SplitSequenceAtEventPosition = @b:control
Key.Track.SetSelectedInstrumentIndexValue = @i:control
Key.Track.SetSelectedCommandIndexValue = @o:control
Key.Track.SetOrderlistLoopPoint = @l:shift:control
Key.OrderListOverview.Copy = @c:control
Key.OrderListOverview.Paste = @v:control

[windows] // Applies to the windows platform only

// Disk.Startup.Folder = "" // Uncomment and enter the absolute path to the folder that should
// open by default in the file browser.

#include "user.ini"

[macos] // Applies to the macos platform only

Disk.Startup.Folder = "~" // The folder that should open by default in the file browser.

// Favorite folders to show in the file browser.
// There are two lists;
// Disk.UserFolders for the folders
Expand All @@ -223,6 +236,8 @@ Disk.UserFolders.Aliases += "External Volumes"



Disk.Startup.Folder = "~" // The folder that should open by default in the file browser.

// Favorite folders to show in the file browser.
// There are two lists;
// Disk.UserFolders for the folders
Expand Down Expand Up @@ -260,6 +275,8 @@ Key.Track.Copy = @c:cmd
Key.Track.Paste = @v:cmd
Key.ScreenEdit.Undo = @z:cmd
Key.ScreenEdit.Redo = @z:shift:cmd
Key.OrderListOverview.Copy = @c:cmd
Key.OrderListOverview.Paste = @v:cmd

#include "~/.config/sidfactory2/user.ini"

Expand All @@ -271,4 +288,4 @@ Key.ScreenEdit.Redo = @z:shift:cmd
[debug] // Applies to debug builds only

Sound.Emulation.Resample = 0 // If this is set to 1, the SID emulation will use resampling, otherwise it will only use linear
// interpolation. Resampling is the best quality possible but also requires more CPU power.
// interpolation. Resampling is the best quality possible but also requires more CPU power.
240 changes: 205 additions & 35 deletions SIDFactoryII/source/utils/config/configutils.cpp
@@ -1,7 +1,6 @@
#include "configutils.h"



namespace Utility
{
namespace Config
Expand All @@ -16,8 +15,53 @@ namespace Utility
SDL_Keycode m_SDLKeyCode;
};

static KeyNameSDLKeycodePair pair[] =
{
static KeyNameSDLKeycodePair pair[] = {

// taken from SDL_keycode.h

{ "return", SDLK_RETURN },
{ "escape", SDLK_ESCAPE },
{ "backspace", SDLK_BACKSPACE },
{ "tab", SDLK_TAB },
{ "space", SDLK_SPACE },
{ "exclaim", SDLK_EXCLAIM },
{ "quotedbl", SDLK_QUOTEDBL },
{ "hash", SDLK_HASH },
{ "percent", SDLK_PERCENT },
{ "dollar", SDLK_DOLLAR },
{ "ampersand", SDLK_AMPERSAND },
{ "quote", SDLK_QUOTE },
{ "leftparen", SDLK_LEFTPAREN },
{ "rightparen", SDLK_RIGHTPAREN },
{ "asterisk", SDLK_ASTERISK },
{ "plus", SDLK_PLUS },
{ "comma", SDLK_COMMA },
{ "minus", SDLK_MINUS },
{ "period", SDLK_PERIOD },
{ "slash", SDLK_SLASH },
{ "0", SDLK_0 },
{ "1", SDLK_1 },
{ "2", SDLK_2 },
{ "3", SDLK_3 },
{ "4", SDLK_4 },
{ "5", SDLK_5 },
{ "6", SDLK_6 },
{ "7", SDLK_7 },
{ "8", SDLK_8 },
{ "9", SDLK_9 },
{ "colon", SDLK_COLON },
{ "semicolon", SDLK_SEMICOLON },
{ "less", SDLK_LESS },
{ "equals", SDLK_EQUALS },
{ "greater", SDLK_GREATER },
{ "question", SDLK_QUESTION },
{ "at", SDLK_AT },
{ "leftbracket", SDLK_LEFTBRACKET },
{ "backslash", SDLK_BACKSLASH },
{ "rightbracket", SDLK_RIGHTBRACKET },
{ "caret", SDLK_CARET },
{ "underscore", SDLK_UNDERSCORE },
{ "backquote", SDLK_BACKQUOTE },
{ "a", SDLK_a },
{ "b", SDLK_b },
{ "c", SDLK_c },
Expand All @@ -44,16 +88,7 @@ namespace Utility
{ "x", SDLK_x },
{ "y", SDLK_y },
{ "z", SDLK_z },
{ "0", SDLK_0 },
{ "1", SDLK_1 },
{ "2", SDLK_2 },
{ "3", SDLK_3 },
{ "4", SDLK_4 },
{ "5", SDLK_5 },
{ "6", SDLK_6 },
{ "7", SDLK_7 },
{ "8", SDLK_8 },
{ "9", SDLK_9 },
{ "capslock", SDLK_CAPSLOCK },
{ "f1", SDLK_F1 },
{ "f2", SDLK_F2 },
{ "f3", SDLK_F3 },
Expand All @@ -66,36 +101,171 @@ namespace Utility
{ "f10", SDLK_F10 },
{ "f11", SDLK_F11 },
{ "f12", SDLK_F12 },
{ "return", SDLK_RETURN },
{ "space", SDLK_SPACE },
{ "up", SDLK_UP },
{ "down", SDLK_DOWN },
{ "left", SDLK_LEFT },
{ "right", SDLK_RIGHT },
{ "printscreen", SDLK_PRINTSCREEN },
{ "scrolllock", SDLK_SCROLLLOCK },
{ "pause", SDLK_PAUSE },
{ "insert", SDLK_INSERT },
{ "home", SDLK_HOME },
{ "end", SDLK_END },
{ "pageup", SDLK_PAGEUP },
{ "pagedown", SDLK_PAGEDOWN },
{ "insert", SDLK_INSERT },
{ "delete", SDLK_DELETE },
{ "backspace", SDLK_BACKSPACE },
{ "escape", SDLK_ESCAPE },
{ "numplus", SDLK_KP_PLUS },
{ "numminus", SDLK_KP_MINUS },
{ "numcomma", SDLK_KP_COMMA },
{ "nummul", SDLK_KP_MULTIPLY },
{ "numdiv", SDLK_KP_DIVIDE },
{ "minus", SDLK_MINUS },
{ "plus", SDLK_PLUS },
{ "slash", SDLK_SLASH },
{ "backslash", SDLK_BACKSLASH },
{ "end", SDLK_END },
{ "pagedown", SDLK_PAGEDOWN },
{ "right", SDLK_RIGHT },
{ "left", SDLK_LEFT },
{ "down", SDLK_DOWN },
{ "up", SDLK_UP },
{ "numlockclear", SDLK_NUMLOCKCLEAR },
{ "kp_divide", SDLK_KP_DIVIDE },
{ "kp_multiply", SDLK_KP_MULTIPLY },
{ "kp_minus", SDLK_KP_MINUS },
{ "kp_plus", SDLK_KP_PLUS },
{ "kp_enter", SDLK_KP_ENTER },
{ "kp_1", SDLK_KP_1 },
{ "kp_2", SDLK_KP_2 },
{ "kp_3", SDLK_KP_3 },
{ "kp_4", SDLK_KP_4 },
{ "kp_5", SDLK_KP_5 },
{ "kp_6", SDLK_KP_6 },
{ "kp_7", SDLK_KP_7 },
{ "kp_8", SDLK_KP_8 },
{ "kp_9", SDLK_KP_9 },
{ "kp_0", SDLK_KP_0 },
{ "kp_period", SDLK_KP_PERIOD },
{ "application", SDLK_APPLICATION },
{ "power", SDLK_POWER },
{ "kp_equals", SDLK_KP_EQUALS },
{ "f13", SDLK_F13 },
{ "f14", SDLK_F14 },
{ "f15", SDLK_F15 },
{ "f16", SDLK_F16 },
{ "f17", SDLK_F17 },
{ "f18", SDLK_F18 },
{ "f19", SDLK_F19 },
{ "f20", SDLK_F20 },
{ "f21", SDLK_F21 },
{ "f22", SDLK_F22 },
{ "f23", SDLK_F23 },
{ "f24", SDLK_F24 },
{ "execute", SDLK_EXECUTE },
{ "help", SDLK_HELP },
{ "menu", SDLK_MENU },
{ "select", SDLK_SELECT },
{ "stop", SDLK_STOP },
{ "again", SDLK_AGAIN },
{ "undo", SDLK_UNDO },
{ "cut", SDLK_CUT },
{ "copy", SDLK_COPY },
{ "paste", SDLK_PASTE },
{ "find", SDLK_FIND },
{ "mute", SDLK_MUTE },
{ "volumeup", SDLK_VOLUMEUP },
{ "volumedown", SDLK_VOLUMEDOWN },
{ "kp_comma", SDLK_KP_COMMA },
{ "kp_equalsas400", SDLK_KP_EQUALSAS400 },
{ "alterase", SDLK_ALTERASE },
{ "sysreq", SDLK_SYSREQ },
{ "cancel", SDLK_CANCEL },
{ "clear", SDLK_CLEAR },
{ "prior", SDLK_PRIOR },
{ "return2", SDLK_RETURN2 },
{ "separator", SDLK_SEPARATOR },
{ "out", SDLK_OUT },
{ "oper", SDLK_OPER },
{ "clearagain", SDLK_CLEARAGAIN },
{ "crsel", SDLK_CRSEL },
{ "exsel", SDLK_EXSEL },
{ "kp_00", SDLK_KP_00 },
{ "kp_000", SDLK_KP_000 },
{ "thousandsseparator", SDLK_THOUSANDSSEPARATOR },
{ "decimalseparator", SDLK_DECIMALSEPARATOR },
{ "currencyunit", SDLK_CURRENCYUNIT },
{ "currencysubunit", SDLK_CURRENCYSUBUNIT },
{ "kp_leftparen", SDLK_KP_LEFTPAREN },
{ "kp_rightparen", SDLK_KP_RIGHTPAREN },
{ "kp_leftbrace", SDLK_KP_LEFTBRACE },
{ "kp_rightbrace", SDLK_KP_RIGHTBRACE },
{ "kp_tab", SDLK_KP_TAB },
{ "kp_backspace", SDLK_KP_BACKSPACE },
{ "kp_a", SDLK_KP_A },
{ "kp_b", SDLK_KP_B },
{ "kp_c", SDLK_KP_C },
{ "kp_d", SDLK_KP_D },
{ "kp_e", SDLK_KP_E },
{ "kp_f", SDLK_KP_F },
{ "kp_xor", SDLK_KP_XOR },
{ "kp_power", SDLK_KP_POWER },
{ "kp_percent", SDLK_KP_PERCENT },
{ "kp_less", SDLK_KP_LESS },
{ "kp_greater", SDLK_KP_GREATER },
{ "kp_ampersand", SDLK_KP_AMPERSAND },
{ "kp_dblampersand", SDLK_KP_DBLAMPERSAND },
{ "kp_verticalbar", SDLK_KP_VERTICALBAR },
{ "kp_dblverticalbar", SDLK_KP_DBLVERTICALBAR },
{ "kp_colon", SDLK_KP_COLON },
{ "kp_hash", SDLK_KP_HASH },
{ "kp_space", SDLK_KP_SPACE },
{ "kp_at", SDLK_KP_AT },
{ "kp_exclam", SDLK_KP_EXCLAM },
{ "kp_memstore", SDLK_KP_MEMSTORE },
{ "kp_memrecall", SDLK_KP_MEMRECALL },
{ "kp_memclear", SDLK_KP_MEMCLEAR },
{ "kp_memadd", SDLK_KP_MEMADD },
{ "kp_memsubtract", SDLK_KP_MEMSUBTRACT },
{ "kp_memmultiply", SDLK_KP_MEMMULTIPLY },
{ "kp_memdivide", SDLK_KP_MEMDIVIDE },
{ "kp_plusminus", SDLK_KP_PLUSMINUS },
{ "kp_clear", SDLK_KP_CLEAR },
{ "kp_clearentry", SDLK_KP_CLEARENTRY },
{ "kp_binary", SDLK_KP_BINARY },
{ "kp_octal", SDLK_KP_OCTAL },
{ "kp_decimal", SDLK_KP_DECIMAL },
{ "kp_hexadecimal", SDLK_KP_HEXADECIMAL },
{ "lctrl", SDLK_LCTRL },
{ "lshift", SDLK_LSHIFT },
{ "lalt", SDLK_LALT },
{ "lgui", SDLK_LGUI },
{ "rctrl", SDLK_RCTRL },
{ "rshift", SDLK_RSHIFT },
{ "ralt", SDLK_RALT },
{ "rgui", SDLK_RGUI },
{ "mode", SDLK_MODE },
{ "audionext", SDLK_AUDIONEXT },
{ "audioprev", SDLK_AUDIOPREV },
{ "audiostop", SDLK_AUDIOSTOP },
{ "audioplay", SDLK_AUDIOPLAY },
{ "audiomute", SDLK_AUDIOMUTE },
{ "mediaselect", SDLK_MEDIASELECT },
{ "www", SDLK_WWW },
{ "mail", SDLK_MAIL },
{ "calculator", SDLK_CALCULATOR },
{ "computer", SDLK_COMPUTER },
{ "ac_search", SDLK_AC_SEARCH },
{ "ac_home", SDLK_AC_HOME },
{ "ac_back", SDLK_AC_BACK },
{ "ac_forward", SDLK_AC_FORWARD },
{ "ac_stop", SDLK_AC_STOP },
{ "ac_refresh", SDLK_AC_REFRESH },
{ "ac_bookmarks", SDLK_AC_BOOKMARKS },
{ "brightnessdown", SDLK_BRIGHTNESSDOWN },
{ "brightnessup", SDLK_BRIGHTNESSUP },
{ "displayswitch", SDLK_DISPLAYSWITCH },
{ "kbdillumtoggle", SDLK_KBDILLUMTOGGLE },
{ "kbdillumdown", SDLK_KBDILLUMDOWN },
{ "kbdillumup", SDLK_KBDILLUMUP },
{ "eject", SDLK_EJECT },
{ "sleep", SDLK_SLEEP },
{ "app1", SDLK_APP1 },
{ "app2", SDLK_APP2 },
{ "audiorewind", SDLK_AUDIOREWIND },
{ "audiofastforward", SDLK_AUDIOFASTFORWARD },

{ "half", 189 },
// not available in SDL_keycode.h

{ "half", 189 },
{ nullptr, 0 }
};

for (int i=0; pair[i].m_KeyName != nullptr; ++i)
for (int i = 0; pair[i].m_KeyName != nullptr; ++i)
{
if (inKeyValue.compare(pair[i].m_KeyName) == 0)
return pair[i].m_SDLKeyCode;
Expand Down

0 comments on commit 2b03a4d

Please sign in to comment.