From patchwork Thu Nov 28 14:30:00 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 294914 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 1644E2C0098 for ; Fri, 29 Nov 2013 01:31:26 +1100 (EST) Received: from localhost ([::1]:42277 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vm2cl-0001nb-Dp for incoming@patchwork.ozlabs.org; Thu, 28 Nov 2013 09:31:23 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57947) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vm2c5-0001er-4m for qemu-devel@nongnu.org; Thu, 28 Nov 2013 09:30:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vm2bw-0006lB-MI for qemu-devel@nongnu.org; Thu, 28 Nov 2013 09:30:40 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50451) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vm2bw-0006ki-AJ for qemu-devel@nongnu.org; Thu, 28 Nov 2013 09:30:32 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rASEUUIU008775 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 28 Nov 2013 09:30:30 -0500 Received: from nilsson.home.kraxel.org (vpn1-4-184.ams2.redhat.com [10.36.4.184]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id rASEUTnb011325; Thu, 28 Nov 2013 09:30:29 -0500 Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id 989D180875; Thu, 28 Nov 2013 15:30:27 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 28 Nov 2013 15:30:00 +0100 Message-Id: <1385649010-7034-6-git-send-email-kraxel@redhat.com> In-Reply-To: <1385649010-7034-1-git-send-email-kraxel@redhat.com> References: <1385649010-7034-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Dave Airlie , Gerd Hoffmann , Anthony Liguori Subject: [Qemu-devel] [RFC PATCH 05/15] input: keyboard: add helper functions to core X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org A bunch of helper functions to manage keyboard events, to make life simpler for the ui code when submitting keyboard events. Signed-off-by: Gerd Hoffmann --- include/ui/input.h | 3 +++ ui/input.c | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/include/ui/input.h b/include/ui/input.h index 3cf3641..12a964c 100644 --- a/include/ui/input.h +++ b/include/ui/input.h @@ -29,4 +29,7 @@ void qemu_input_handler_unregister(QemuInputHandlerState *s); void qemu_input_event_send(QemuConsole *src, InputEvent *evt); void qemu_input_event_sync(void); +InputEvent *qemu_input_event_new_key(int keycode, bool down); +void qemu_input_event_send_key(QemuConsole *src, int keycode, bool down); + #endif /* INPUT_H */ diff --git a/ui/input.c b/ui/input.c index 23c84f7..284bd1f 100644 --- a/ui/input.c +++ b/ui/input.c @@ -81,3 +81,22 @@ void qemu_input_event_sync(void) s->events = 0; } } + +InputEvent *qemu_input_event_new_key(int keycode, bool down) +{ + InputEvent *evt = g_new0(InputEvent, 1); + evt->key = g_new0(InputKeyEvent, 1); + evt->kind = INPUT_EVENT_KIND_KEY; + evt->key->keycode = keycode; + evt->key->down = down; + return evt; +} + +void qemu_input_event_send_key(QemuConsole *src, int keycode, bool down) +{ + InputEvent *evt; + evt = qemu_input_event_new_key(keycode, down); + qemu_input_event_send(src, evt); + qemu_input_event_sync(); + qapi_free_InputEvent(evt); +}