From patchwork Fri Feb 26 16:17:36 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 46357 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 2B119B7D03 for ; Sat, 27 Feb 2010 03:44:41 +1100 (EST) Received: from localhost ([127.0.0.1]:33078 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nl3Is-0000ZA-2s for incoming@patchwork.ozlabs.org; Fri, 26 Feb 2010 11:44:38 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nl2sy-0001gc-RS for qemu-devel@nongnu.org; Fri, 26 Feb 2010 11:17:53 -0500 Received: from [199.232.76.173] (port=52143 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nl2sx-0001eV-2b for qemu-devel@nongnu.org; Fri, 26 Feb 2010 11:17:51 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1Nl2st-0004qY-7c for qemu-devel@nongnu.org; Fri, 26 Feb 2010 11:17:50 -0500 Received: from mx1.redhat.com ([209.132.183.28]:2772) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Nl2ss-0004ps-JC for qemu-devel@nongnu.org; Fri, 26 Feb 2010 11:17:46 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o1QGHii7012773 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 26 Feb 2010 11:17:44 -0500 Received: from zweiblum.home.kraxel.org (vpn1-4-31.ams2.redhat.com [10.36.4.31]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o1QGHfet003073; Fri, 26 Feb 2010 11:17:41 -0500 Received: by zweiblum.home.kraxel.org (Postfix, from userid 500) id 121B67010D; Fri, 26 Feb 2010 17:17:39 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 26 Feb 2010 17:17:36 +0100 Message-Id: <1267201059-24145-2-git-send-email-kraxel@redhat.com> In-Reply-To: <1267201059-24145-1-git-send-email-kraxel@redhat.com> References: <1267201059-24145-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Gerd Hoffmann Subject: [Qemu-devel] [PATCH v2 1/4] kbd leds: infrastructure X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Adds infrastructure for keyboard led status tracking to qemu. Signed-off-by: Gerd Hoffmann --- console.h | 15 +++++++++++++++ input.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 0 deletions(-) diff --git a/console.h b/console.h index 916859d..71e8ff2 100644 --- a/console.h +++ b/console.h @@ -10,10 +10,16 @@ #define MOUSE_EVENT_RBUTTON 0x02 #define MOUSE_EVENT_MBUTTON 0x04 +/* identical to the ps/2 keyboard bits */ +#define QEMU_SCROLL_LOCK_LED (1 << 0) +#define QEMU_NUM_LOCK_LED (1 << 1) +#define QEMU_CAPS_LOCK_LED (1 << 2) + /* in ms */ #define GUI_REFRESH_INTERVAL 30 typedef void QEMUPutKBDEvent(void *opaque, int keycode); +typedef void QEMUPutLEDEvent(void *opaque, int ledstate); typedef void QEMUPutMouseEvent(void *opaque, int dx, int dy, int dz, int buttons_state); typedef struct QEMUPutMouseEntry { @@ -26,13 +32,22 @@ typedef struct QEMUPutMouseEntry { struct QEMUPutMouseEntry *next; } QEMUPutMouseEntry; +typedef struct QEMUPutLEDEntry { + QEMUPutLEDEvent *put_led; + void *opaque; + QTAILQ_ENTRY(QEMUPutLEDEntry) next; +} QEMUPutLEDEntry; + void qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque); QEMUPutMouseEntry *qemu_add_mouse_event_handler(QEMUPutMouseEvent *func, void *opaque, int absolute, const char *name); void qemu_remove_mouse_event_handler(QEMUPutMouseEntry *entry); +QEMUPutLEDEntry *qemu_add_led_event_handler(QEMUPutLEDEvent *func, void *opaque); +void qemu_remove_led_event_handler(QEMUPutLEDEntry *entry); void kbd_put_keycode(int keycode); +void kbd_put_ledstate(int ledstate); void kbd_mouse_event(int dx, int dy, int dz, int buttons_state); int kbd_mouse_is_absolute(void); diff --git a/input.c b/input.c index 955b9ab..baaa4c6 100644 --- a/input.c +++ b/input.c @@ -33,6 +33,7 @@ static QEMUPutKBDEvent *qemu_put_kbd_event; static void *qemu_put_kbd_event_opaque; static QEMUPutMouseEntry *qemu_put_mouse_event_head; static QEMUPutMouseEntry *qemu_put_mouse_event_current; +static QTAILQ_HEAD(, QEMUPutLEDEntry) led_handlers = QTAILQ_HEAD_INITIALIZER(led_handlers); void qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque) { @@ -102,6 +103,27 @@ void qemu_remove_mouse_event_handler(QEMUPutMouseEntry *entry) qemu_free(entry); } +QEMUPutLEDEntry *qemu_add_led_event_handler(QEMUPutLEDEvent *func, + void *opaque) +{ + QEMUPutLEDEntry *s; + + s = qemu_mallocz(sizeof(QEMUPutLEDEntry)); + + s->put_led = func; + s->opaque = opaque; + QTAILQ_INSERT_TAIL(&led_handlers, s, next); + return s; +} + +void qemu_remove_led_event_handler(QEMUPutLEDEntry *entry) +{ + if (entry == NULL) + return; + QTAILQ_REMOVE(&led_handlers, entry, next); + qemu_free(entry); +} + void kbd_put_keycode(int keycode) { if (qemu_put_kbd_event) { @@ -109,6 +131,15 @@ void kbd_put_keycode(int keycode) } } +void kbd_put_ledstate(int ledstate) +{ + QEMUPutLEDEntry *cursor; + + QTAILQ_FOREACH(cursor, &led_handlers, next) { + cursor->put_led(cursor->opaque, ledstate); + } +} + void kbd_mouse_event(int dx, int dy, int dz, int buttons_state) { QEMUPutMouseEvent *mouse_event;