I found the problem… keycode is correct, but any volume key cannot be pressed with shift!
To deal with it, I tried release shift key before sending press volume up, and it worked.
Here is diff for my use case (volume key=volume down, Shift key+volume key=volume up, Fn key+volume key=mute)
I will make a fork of uconsole’s repo and make all these changes in it. If you like to merge it into official repo, I can make a PR.
diff --git a/Code/uconsole_keyboard/keymaps.ino b/Code/uconsole_keyboard/keymaps.ino
index 9a2a643..973658d 100644
--- a/Code/uconsole_keyboard/keymaps.ino
+++ b/Code/uconsole_keyboard/keymaps.ino
@@ -67,7 +67,7 @@ const uint16_t keyboard_maps[][MATRIX_KEYS] = {
},
[FN_LAYER] = {
- _PRINT_KEY, _PAUSE_KEY, _VOLUME_P, '`', '[', ']', KEY_F11, KEY_F12, \
+ _PRINT_KEY, _PAUSE_KEY, _VOLUME_MUTE, '`', '[', ']', KEY_F11, KEY_F12, \
KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6, KEY_F7, KEY_F8, \
KEY_F9, KEY_F10, _FN_LOCK_KEYBOARD, KEY_CAPS_LOCK, EMP, EMP, EMP, EMP, \
'q', 'w', 'e', 'r', 't', 'y', KEY_PAGE_UP, KEY_INSERT, \
@@ -251,18 +251,20 @@ void keyboard_action(DEVTERM*dv, uint8_t row, uint8_t col, uint8_t mode) {
case _VOLUME_P: {
if (mode == KEY_PRESSED) {
- if (dv->Keyboard_state.sf_on > 0) {
- dv->Consumer->press(HIDConsumer::MUTE);
- } else {
- dv->Consumer->press(HIDConsumer::VOLUME_UP);
- }
+ dv->Consumer->press(HIDConsumer::VOLUME_UP);
} else {
keyboard_release(dv, addr, k);
}
} break;
case _VOLUME_M: {
if (mode == KEY_PRESSED) {
- dv->Consumer->press(HIDConsumer::VOLUME_DOWN);
+ if (dv->Keyboard_state.sf_on > 0) {
+ dv->Keyboard->release(_LEFT_SHIFT_KEY);
+ dv->Keyboard->release(KEY_RIGHT_SHIFT);
+ dv->Consumer->press(HIDConsumer::VOLUME_UP);
+ } else {
+ dv->Consumer->press(HIDConsumer::VOLUME_DOWN);
+ }
} else {
keyboard_release(dv, addr, k);
}
@@ -319,7 +321,6 @@ void keypad_release_core(DEVTERM*dv, uint16_t k) {
switch (k) {
case _FN_SHIFT:
- dv->Keyboard_state.sf_on = 0;
break;
case _LEFT_SHIFT_KEY:
case KEY_RIGHT_SHIFT:
@@ -327,6 +328,7 @@ void keypad_release_core(DEVTERM*dv, uint16_t k) {
dv->Keyboard->release(k);
dv->Keyboard_state.shift.begin = 0;
dv->Keyboard_state.shift.time = 0;
+ dv->Keyboard_state.sf_on = 0;
}
break;
@@ -474,11 +476,7 @@ void keypad_action(DEVTERM*dv, uint8_t col, uint8_t mode) {
switch (k) {
case _FN_SHIFT:
- if (mode == KEY_PRESSED) {
- dv->Keyboard_state.sf_on = k;
- } else {
keypad_release(dv, col, k);
- }
break;
case _LEFT_SHIFT_KEY:
case KEY_RIGHT_SHIFT:
@@ -486,6 +484,7 @@ void keypad_action(DEVTERM*dv, uint8_t col, uint8_t mode) {
if (dv->Keyboard_state.shift.lock == 0) {
dv->Keyboard->press(k);
dv->Keyboard_state.shift.begin = k;
+ dv->Keyboard_state.sf_on = k;
}
} else if (mode == KEY_RELEASED) {
keypad_release(dv, col, k);