Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Caps in not always shift #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 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,27 @@ static void write_key(uint8_t key)
static void get_char(uint8_t ctrl, uint8_t keypos)
{
uint8_t ch;
int caps = 0;
//key position for latin letters
#define KEYP_LATIN_A 4
#define KEYP_LATIN_Z 29

#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 < KEYP_LATIN_A || keypos > KEYP_LATIN_Z))) {
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 +194,12 @@ static void check_key_code(uint8_t *buf)
set_leds ^= LED_CAPS_LOCK;
break;

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