diff options
author | Michał Cichoń <michcic@gmail.com> | 2019-05-03 16:57:20 +0200 |
---|---|---|
committer | Michał Cichoń <michcic@gmail.com> | 2019-05-03 17:00:30 +0200 |
commit | 166056799c20ec66cdf94124e8c8cb3ef8114c84 (patch) | |
tree | f4709c48aae471993383832c82f37a75b9f5a109 /src/ui_readline.c | |
parent | 4d06dac5843651d755a4010691a60c68390e6ce0 (diff) | |
download | pianobar-windows-166056799c20ec66cdf94124e8c8cb3ef8114c84.tar.gz pianobar-windows-166056799c20ec66cdf94124e8c8cb3ef8114c84.tar.bz2 pianobar-windows-166056799c20ec66cdf94124e8c8cb3ef8114c84.zip |
Add support for hotkeys. #20
Hotkeys can be assigned to action in configuration file ex:
hk_<action_name> = g + shift + alt + ctrl
Diffstat (limited to 'src/ui_readline.c')
-rw-r--r-- | src/ui_readline.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/ui_readline.c b/src/ui_readline.c index 5d6b7a7..687258a 100644 --- a/src/ui_readline.c +++ b/src/ui_readline.c @@ -75,6 +75,8 @@ static inline int BarReadlineEncodeUtf8 (int codePoint, char* utf8) { struct _BarReadline_t { DWORD DefaultAttr; + BarVirtualKeyHandler VirtualKeyHandler; + void *VirtualKeyHandlerUserData; }; void BarReadlineInit(BarReadline_t* rl) { @@ -85,6 +87,11 @@ void BarReadlineInit(BarReadline_t* rl) { void BarReadlineDestroy(BarReadline_t rl) { } +void BarReadlineSetVirtualKeyHandler(BarReadline_t rl, BarVirtualKeyHandler handler, void *ud) { + rl->VirtualKeyHandler = handler; + rl->VirtualKeyHandlerUserData = ud; +} + /* return size of previous UTF-8 character */ static size_t BarReadlinePrevUtf8 (char *ptr) { @@ -248,16 +255,11 @@ size_t BarReadline (char *buf, const size_t bufSize, const char *mask, char encodedCodePoint[5]; int encodedCodePointLength; - /* - if (keyCode == VK_MEDIA_PLAY_PAUSE) { - codePoint = 'p'; - PlaySoundA("SystemNotification", NULL, SND_ASYNC); - } - else if (keyCode == VK_MEDIA_NEXT_TRACK) { - codePoint = 'n'; - PlaySoundA("SystemNotification", NULL, SND_ASYNC); + if (input->VirtualKeyHandler != NULL) { + int newCodePoint = input->VirtualKeyHandler(keyCode, input->VirtualKeyHandlerUserData); + if (newCodePoint != 0) + codePoint = newCodePoint; } - */ if (codePoint <= 0x1F) break; |