Skip to content

Commit

Permalink
Caps in not always shift
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Dinar Valeev committed May 13, 2015
1 parent 7d766a3 commit 1c037c4
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions lib/libusb/usb-hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ uint8_t set_leds;
const uint8_t *key_std = NULL;
const uint8_t *key_std_shift = NULL;

uint8_t ctrl; /* modifiers */

/**
* read character from Keyboard-Buffer
*
Expand Down Expand Up @@ -120,22 +122,24 @@ static void write_key(uint8_t key)
static void get_char(uint8_t ctrl, uint8_t keypos)
{
uint8_t ch;
int caps = 0;

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

if (set_leds & LED_CAPS_LOCK) /* is CAPS Lock set ? */
ctrl |= MODIFIER_SHIFT; /* simulate shift */
caps = 1;

if (ctrl == 0) {
/* caps is a shift only for latin chars */
if ((caps == 0 && ctrl == 0) || (caps == 1 && (keypos < 4 || keypos > 29))) {
ch = key_std[keypos];
if (ch != 0)
write_key(ch);
return;
}

if (ctrl & MODIFIER_SHIFT) {
if ((ctrl & MODIFIER_SHIFT) || caps == 1) {
ch = key_std_shift[keypos];
if (ch != 0)
write_key(ch);
Expand Down Expand Up @@ -187,6 +191,12 @@ static void check_key_code(uint8_t *buf)
set_leds ^= LED_CAPS_LOCK;
break;

case 0x36:
ctrl |= MODIFIER_SHIFT;
break;
case 0xb6:
ctrl &= ~MODIFIER_SHIFT;
break;
case 0x3a: /* F1 */
write_key(0x1b);
write_key(0x5b);
Expand Down

0 comments on commit 1c037c4

Please sign in to comment.