From patchwork Fri Mar 19 10:58:43 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shahar Havivi X-Patchwork-Id: 48136 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 D5F8AB7C67 for ; Fri, 19 Mar 2010 22:31:30 +1100 (EST) Received: from localhost ([127.0.0.1]:54541 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NsaPn-000185-MY for incoming@patchwork.ozlabs.org; Fri, 19 Mar 2010 07:30:55 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NsZuo-0000wH-E6 for qemu-devel@nongnu.org; Fri, 19 Mar 2010 06:58:54 -0400 Received: from [199.232.76.173] (port=39156 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NsZun-0000vv-HT for qemu-devel@nongnu.org; Fri, 19 Mar 2010 06:58:53 -0400 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NsZul-0000P4-Jx for qemu-devel@nongnu.org; Fri, 19 Mar 2010 06:58:53 -0400 Received: from mx20.gnu.org ([199.232.41.8]:33539) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NsZuk-0000Ox-DZ for qemu-devel@nongnu.org; Fri, 19 Mar 2010 06:58:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NsZuj-0005d2-5N for qemu-devel@nongnu.org; Fri, 19 Mar 2010 06:58:49 -0400 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o2JAwm8h024032 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 19 Mar 2010 06:58:48 -0400 Received: from localhost (dhcp-1-229.tlv.redhat.com [10.35.1.229]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o2JAwl7H015839; Fri, 19 Mar 2010 06:58:47 -0400 Date: Fri, 19 Mar 2010 12:58:43 +0200 From: Shahar Havivi To: qemu-devel@nongnu.org Message-ID: <2dcacefd7562e5785174f1e167fe76fd8f077a48.1268994938.git.shaharh@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-08-17) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.18 X-detected-operating-system: by mx20.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) Cc: Dor Laor Subject: [Qemu-devel] [PATCH 2/2] Added monitor commands: 'keyboard_set' and 'info keybaord' 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 This new monitor command adding ability to handle which keyboard qemu will use and to see which keyboard are currently available. Signed-off-by: Shahar Havivi --- input.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ monitor.c | 8 ++++++ qemu-monitor.hx | 17 +++++++++++++ 3 files changed, 98 insertions(+), 0 deletions(-) diff --git a/input.c b/input.c index 4b86f48..c883b5b 100644 --- a/input.c +++ b/input.c @@ -337,3 +337,76 @@ void do_mouse_set(Monitor *mon, const QDict *qdict) else monitor_printf(mon, "Mouse at given index not found\n"); } + +static void info_keyboard_iter(QObject *data, void *opaque) +{ + QDict *kbd; + Monitor *mon = opaque; + + kbd = qobject_to_qdict(data); + monitor_printf(mon, "%c Keyboard #%" PRId64 ": %s\n", + (qdict_get_bool(kbd, "current") ? '*' : ' '), + qdict_get_int(kbd, "index"), qdict_get_str(kbd, "name")); +} + +void do_info_keyboard_print(Monitor *mon, const QObject *data) +{ + QList *kbd_list; + + kbd_list = qobject_to_qlist(data); + if (qlist_empty(kbd_list)) { + monitor_printf(mon, "No keyboard devices connected\n"); + return; + } + + qlist_iter(kbd_list, info_keyboard_iter, mon); +} + +void do_info_keyboard(Monitor *mon, QObject **ret_data) +{ + QEMUPutKbdEntry *cursor; + QList *kbd_list; + int index = 0; + + kbd_list = qlist_new(); + + if (!qemu_put_kbd_event_head) { + goto out; + } + + cursor = qemu_put_kbd_event_head; + while (cursor != NULL) { + QObject *obj; + obj = qobject_from_jsonf("{ 'name': %s, 'index': %d, 'current': %i }", + cursor->qemu_put_kbd_name, + index, cursor == qemu_put_kbd_event_current); + qlist_append_obj(kbd_list, obj); + index++; + cursor = cursor->next; + } +out: + *ret_data = QOBJECT(kbd_list); +} + +void do_keyboard_set(Monitor *mon, const QDict *qdict) +{ + QEMUPutKbdEntry *cursor; + int i = 0; + int index = qdict_get_int(qdict, "index"); + + if (!qemu_put_kbd_event_head) { + monitor_printf(mon, "No keyboard devices connected\n"); + return; + } + + cursor = qemu_put_kbd_event_head; + while (cursor != NULL && index != i) { + i++; + cursor = cursor->next; + } + + if (cursor != NULL) + qemu_put_kbd_event_current = cursor; + else + monitor_printf(mon, "Keyboard at given index not found\n"); +} diff --git a/monitor.c b/monitor.c index 0448a70..cc95b3d 100644 --- a/monitor.c +++ b/monitor.c @@ -2783,6 +2783,14 @@ static const mon_cmd_t info_cmds[] = { .mhandler.info_new = do_info_mice, }, { + .name = "keyboard", + .args_type = "", + .params = "", + .help = "show which guest keyboard is receiving events", + .user_print = do_info_keyboard_print, + .mhandler.info_new = do_info_keyboard, + }, + { .name = "vnc", .args_type = "", .params = "", diff --git a/qemu-monitor.hx b/qemu-monitor.hx index 5308f36..d86be17 100644 --- a/qemu-monitor.hx +++ b/qemu-monitor.hx @@ -659,6 +659,23 @@ info mice @end example ETEXI + { + .name = "keyboard_set", + .args_type = "index:i", + .params = "index", + .help = "set which keyboard device receives events", + .mhandler.cmd = do_keyboard_set, + }, + +STEXI +@item keyboard_set @var{index} +@findex keyboard_set +Set which keyboard device receives events at given @var{index}, index +can be obtained with +@example +info keyboard +@end example +ETEXI #ifdef HAS_AUDIO { .name = "wavcapture",