From patchwork Thu Mar 24 14:07:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Programmingkid X-Patchwork-Id: 8661161 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4AF049FBEE for ; Thu, 24 Mar 2016 14:08:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9D1DC201E4 for ; Thu, 24 Mar 2016 14:08:52 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EC2A020254 for ; Thu, 24 Mar 2016 14:08:51 +0000 (UTC) Received: from localhost ([::1]:50570 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aj5wR-0001Jg-9i for patchwork-qemu-devel@patchwork.kernel.org; Thu, 24 Mar 2016 10:08:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45552) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aj5vI-0000C2-J9 for qemu-devel@nongnu.org; Thu, 24 Mar 2016 10:07:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aj5vE-0001wW-MJ for qemu-devel@nongnu.org; Thu, 24 Mar 2016 10:07:40 -0400 Received: from mail-io0-x241.google.com ([2607:f8b0:4001:c06::241]:33061) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aj5vE-0001wS-Hr for qemu-devel@nongnu.org; Thu, 24 Mar 2016 10:07:36 -0400 Received: by mail-io0-x241.google.com with SMTP id v187so9445378ioe.0 for ; Thu, 24 Mar 2016 07:07:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:content-transfer-encoding:subject:date:message-id:to :mime-version; bh=oPLk+26CYinDSfWExBRn9j22kpSMj7LAovZNGCq076A=; b=lxIlV+ZAlv4X0qbBvomoO17wXx7NkoraFJbyG0zv+3U/Exo5XMNcY8dlk0Q16cflhj MVbvKJwN+6k0aA1TDN4N8jjXlS0Quo4fHtudN9KMvtnR9BSTR+Fp0GOllQk42qptTV47 SaeWo0VdMxz3Cd4ZIxtQNN6tn5Wx5bljUWaCFUuX21w4vn/CJJuO7OOXjEHgroff4Q9h VUQzdXonWeKtCKQskJLK2VJKlYyLI8KwN1DblwmueJk4DQPlv/gBBnGmaeBpmHzRrYyV I09DKMok2kDw4Yo60q1QPzg9/ERwhzOpF1LqzH2PQfrpkIH3CMYb6TcmmV0mEwuK7Fsc T32A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:content-transfer-encoding:subject:date :message-id:to:mime-version; bh=oPLk+26CYinDSfWExBRn9j22kpSMj7LAovZNGCq076A=; b=mcQit4Dgai85zcOX9mYF1k6JxwLD+1CmPSziO0ja33hPCnV72R0jv9kUf5KOW5ck6X S877jTjBgA+0lrIODTJ1IvWQSy9Y1jCMrPKYnZcDCn4PezlMw03SxuvpSa26J3wITXRN wvfyKJUOu8H9STzVje2e/Dn7zQt944CeWcV5LntLWNYY9o6Csgw8n8jkA33OLa1lspN6 jWBHWj3foE3SiLSMGXdC/AGDo5isYoVD5AoiQcNbiLuPNNnJPeEx5a9L32swa8MDQ0TX sFeDMwB1UUFrupyXlUPG6aaxrScodoNBnebSD8AmEXWNvLZDJA5aMGd2/41genMAc251 l+7A== X-Gm-Message-State: AD7BkJILVUpN8T47bIFCgrV6i0HTktB8PhyAxE+QMxB21CQGGi5S2H5e2ZpjKZ3rLJNNxQ== X-Received: by 10.107.18.214 with SMTP id 83mr8742726ios.130.1458828456136; Thu, 24 Mar 2016 07:07:36 -0700 (PDT) Received: from [192.168.0.5] (d199-74-164-53.col.wideopenwest.com. [74.199.53.164]) by smtp.gmail.com with ESMTPSA id a126sm3161111ioe.7.2016.03.24.07.07.35 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 24 Mar 2016 07:07:35 -0700 (PDT) From: Programmingkid Date: Thu, 24 Mar 2016 10:07:35 -0400 Message-Id: To: Peter Maydell , Gerd Hoffmann , qemu-devel qemu-devel Mime-Version: 1.0 (Apple Message framework v1084) X-Mailer: Apple Mail (2.1084) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:4001:c06::241 Subject: [Qemu-devel] [PATCH v2 4/4] adb.c: add power key 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add support for the power key. It has to be handled differently from the other keys because it is the only 16-bit value key. Signed-off-by: John Arbuckle --- hw/input/adb.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/hw/input/adb.c b/hw/input/adb.c index 8413db9..fab241b 100644 --- a/hw/input/adb.c +++ b/hw/input/adb.c @@ -358,10 +358,17 @@ static int adb_kbd_poll(ADBDevice *d, uint8_t *obuf) s->rptr = 0; } s->count--; - obuf[0] = keycode; - /* NOTE: could put a second keycode if needed */ - obuf[1] = 0xff; - olen = 2; + /* The power key is the only two byte value key, so it is a special case. */ + if (keycode == 0x7f) { + obuf[0] = 0x7f; + obuf[1] = 0x7f; + olen = 2; + } else { + obuf[0] = keycode; + /* NOTE: could put a second keycode if needed */ + obuf[1] = 0xff; + olen = 2; + } return olen; } @@ -440,11 +447,22 @@ static void adb_keyboard_event(DeviceState *dev, QemuConsole *src, } keycode = qcode_to_adb_keycode[qcode]; - if (evt->u.key.data->down == false) { /* if key release event */ - keycode = keycode | 0x80; /* create keyboard break code */ + /* The power button is a special case because it is a 16-bit value */ + if (qcode == Q_KEY_CODE_POWER) { + if (evt->u.key.data->down == true) { /* Power button pushed keycode */ + adb_kbd_put_keycode(s, 0x7f); + } else { /* Power button released keycode */ + adb_kbd_put_keycode(s, 0xff); + } } - adb_kbd_put_keycode(s, keycode); + /* For all non-power keys - safe for 8-bit keycodes */ + else { + if (evt->u.key.data->down == false) { /* if key release event */ + keycode = keycode | 0x80; /* create keyboard break code */ + } + adb_kbd_put_keycode(s, keycode); + } } static const VMStateDescription vmstate_adb_kbd = {