Skip to content

Commit

Permalink
Fixed bug 4347 - Keyboard LEDs don't work on linux console
Browse files Browse the repository at this point in the history
Rainer Sabelka

When using SLD2 on a Linux console with the KMS/DRM video backend and Linux evdev keyboard support, the caps lock, scroll lock, and num lock leds do not work.

The attached patch adds ioctls for setting the LED state in SDL_evdev_kbd.c
  • Loading branch information
slouken committed Oct 31, 2018
1 parent 6c029f1 commit 9af581b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/core/linux/SDL_evdev_kbd.c
Expand Up @@ -510,17 +510,19 @@ static unsigned int handle_diacr(SDL_EVDEV_keyboard_state *kbd, unsigned int ch)

static int vc_kbd_led(SDL_EVDEV_keyboard_state *kbd, int flag)
{
return ((kbd->ledflagstate >> flag) & 1);
return (kbd->ledflagstate & flag) != 0;
}

static void set_vc_kbd_led(SDL_EVDEV_keyboard_state *kbd, int flag)
{
kbd->ledflagstate |= 1 << flag;
kbd->ledflagstate |= flag;
ioctl(kbd->console_fd, KDSETLED, (unsigned long)(kbd->ledflagstate));
}

static void clr_vc_kbd_led(SDL_EVDEV_keyboard_state *kbd, int flag)
{
kbd->ledflagstate &= ~(1 << flag);
kbd->ledflagstate &= ~flag;
ioctl(kbd->console_fd, KDSETLED, (unsigned long)(kbd->ledflagstate));
}

static void chg_vc_kbd_lock(SDL_EVDEV_keyboard_state *kbd, int flag)
Expand All @@ -535,7 +537,8 @@ static void chg_vc_kbd_slock(SDL_EVDEV_keyboard_state *kbd, int flag)

static void chg_vc_kbd_led(SDL_EVDEV_keyboard_state *kbd, int flag)
{
kbd->ledflagstate ^= 1 << flag;
kbd->ledflagstate ^= flag;
ioctl(kbd->console_fd, KDSETLED, (unsigned long)(kbd->ledflagstate));
}

/*
Expand Down

0 comments on commit 9af581b

Please sign in to comment.