Skip to content

Commit 1c037c4

Browse files
author
Dinar Valeev
committed
Caps in not always shift
Caps behaves like shift only for latin characters. In case we're typing - for example with caps enabled, SLOF picks _ char from shifted table. Threat caps as shift only for letters. Signed-off-by: Dinar Valeev <dvaleev@suse.com>
1 parent 7d766a3 commit 1c037c4

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

lib/libusb/usb-hid.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ uint8_t set_leds;
8383
const uint8_t *key_std = NULL;
8484
const uint8_t *key_std_shift = NULL;
8585

86+
uint8_t ctrl; /* modifiers */
87+
8688
/**
8789
* read character from Keyboard-Buffer
8890
*
@@ -120,22 +122,24 @@ static void write_key(uint8_t key)
120122
static void get_char(uint8_t ctrl, uint8_t keypos)
121123
{
122124
uint8_t ch;
125+
int caps = 0;
123126

124127
#ifdef KEY_DEBUG
125128
printf("pos %02X\n", keypos);
126129
#endif
127130

128131
if (set_leds & LED_CAPS_LOCK) /* is CAPS Lock set ? */
129-
ctrl |= MODIFIER_SHIFT; /* simulate shift */
132+
caps = 1;
130133

131-
if (ctrl == 0) {
134+
/* caps is a shift only for latin chars */
135+
if ((caps == 0 && ctrl == 0) || (caps == 1 && (keypos < 4 || keypos > 29))) {
132136
ch = key_std[keypos];
133137
if (ch != 0)
134138
write_key(ch);
135139
return;
136140
}
137141

138-
if (ctrl & MODIFIER_SHIFT) {
142+
if ((ctrl & MODIFIER_SHIFT) || caps == 1) {
139143
ch = key_std_shift[keypos];
140144
if (ch != 0)
141145
write_key(ch);
@@ -187,6 +191,12 @@ static void check_key_code(uint8_t *buf)
187191
set_leds ^= LED_CAPS_LOCK;
188192
break;
189193

194+
case 0x36:
195+
ctrl |= MODIFIER_SHIFT;
196+
break;
197+
case 0xb6:
198+
ctrl &= ~MODIFIER_SHIFT;
199+
break;
190200
case 0x3a: /* F1 */
191201
write_key(0x1b);
192202
write_key(0x5b);

0 commit comments

Comments
 (0)