From patchwork Thu Feb 25 08:39:20 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [3/4] kbd leds: usb kbd Date: Wed, 24 Feb 2010 22:39:20 -0000 From: Gerd Hoffmann X-Patchwork-Id: 46220 Message-Id: <1267087161-15204-4-git-send-email-kraxel@redhat.com> To: qemu-devel@nongnu.org Cc: Gerd Hoffmann Add led status notification support to the usb kbd driver. Signed-off-by: Gerd Hoffmann --- hw/usb-hid.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/hw/usb-hid.c b/hw/usb-hid.c index bf456bb..2e4e647 100644 --- a/hw/usb-hid.c +++ b/hw/usb-hid.c @@ -600,12 +600,20 @@ static int usb_keyboard_poll(USBKeyboardState *s, uint8_t *buf, int len) static int usb_keyboard_write(USBKeyboardState *s, uint8_t *buf, int len) { if (len > 0) { + int ledstate = 0; /* 0x01: Num Lock LED * 0x02: Caps Lock LED * 0x04: Scroll Lock LED * 0x08: Compose LED * 0x10: Kana LED */ s->leds = buf[0]; + if (s->leds & 0x04) + ledstate |= QEMU_SCROLL_LOCK_LED; + if (s->leds & 0x01) + ledstate |= QEMU_NUM_LOCK_LED; + if (s->leds & 0x02) + ledstate |= QEMU_CAPS_LOCK_LED; + kbd_put_ledstate(ledstate); } return 0; }