From patchwork Fri Feb 28 14:06:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 325238 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id E6E0C2C0089 for ; Sat, 1 Mar 2014 02:00:24 +1100 (EST) Received: from localhost ([::1]:51273 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WJO85-0004On-Ac for incoming@patchwork.ozlabs.org; Fri, 28 Feb 2014 09:09:33 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49538) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WJO5i-0001co-QQ for qemu-devel@nongnu.org; Fri, 28 Feb 2014 09:07:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WJO5b-0003hQ-Cm for qemu-devel@nongnu.org; Fri, 28 Feb 2014 09:07:06 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57053) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WJO5b-0003gt-3K for qemu-devel@nongnu.org; Fri, 28 Feb 2014 09:06:59 -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.14.4/8.14.4) with ESMTP id s1SE6vUd028555 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 28 Feb 2014 09:06:57 -0500 Received: from nilsson.home.kraxel.org (vpn1-5-124.ams2.redhat.com [10.36.5.124]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s1SE6unw029417; Fri, 28 Feb 2014 09:06:56 -0500 Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id B27D58060D; Fri, 28 Feb 2014 15:06:53 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 28 Feb 2014 15:06:27 +0100 Message-Id: <1393596409-28934-17-git-send-email-kraxel@redhat.com> In-Reply-To: <1393596409-28934-1-git-send-email-kraxel@redhat.com> References: <1393596409-28934-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Gerd Hoffmann , Anthony Liguori Subject: [Qemu-devel] [PULL 16/38] input: mouse: add graphic_rotate support 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 Transform absolute mouse events according to graphic_rotate. Legacy input code does it for both absolute and relative events, but the logic is broken for relative coordinates, so this is most likely not used anyway. Signed-off-by: Gerd Hoffmann --- ui/input.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/ui/input.c b/ui/input.c index a02172e..2c4d4d6 100644 --- a/ui/input.c +++ b/ui/input.c @@ -50,6 +50,33 @@ qemu_input_find_handler(uint32_t mask) return NULL; } +static void qemu_input_transform_abs_rotate(InputEvent *evt) +{ + switch (graphic_rotate) { + case 90: + if (evt->abs->axis == INPUT_AXIS_X) { + evt->abs->axis = INPUT_AXIS_Y; + } + if (evt->abs->axis == INPUT_AXIS_Y) { + evt->abs->axis = INPUT_AXIS_X; + evt->abs->axis = INPUT_EVENT_ABS_SIZE - 1 - evt->abs->axis; + } + break; + case 180: + evt->abs->axis = INPUT_EVENT_ABS_SIZE - 1 - evt->abs->axis; + break; + case 270: + if (evt->abs->axis == INPUT_AXIS_X) { + evt->abs->axis = INPUT_AXIS_Y; + evt->abs->axis = INPUT_EVENT_ABS_SIZE - 1 - evt->abs->axis; + } + if (evt->abs->axis == INPUT_AXIS_Y) { + evt->abs->axis = INPUT_AXIS_X; + } + break; + } +} + void qemu_input_event_send(QemuConsole *src, InputEvent *evt) { QemuInputHandlerState *s; @@ -58,6 +85,12 @@ void qemu_input_event_send(QemuConsole *src, InputEvent *evt) return; } + /* pre processing */ + if (graphic_rotate && (evt->kind == INPUT_EVENT_KIND_ABS)) { + qemu_input_transform_abs_rotate(evt); + } + + /* send event */ s = qemu_input_find_handler(1 << evt->kind); s->handler->event(s->dev, src, evt); s->events++;