From patchwork Fri Jul 1 15:59:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Programmingkid X-Patchwork-Id: 643116 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 3rh1qP3c4Zz9t0Z for ; Sat, 2 Jul 2016 02:20:49 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=v9qTqkKN; dkim-atps=neutral Received: from localhost ([::1]:34379 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bJ1BP-0006bb-Er for incoming@patchwork.ozlabs.org; Fri, 01 Jul 2016 12:20:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38572) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bJ0rl-0000ui-3Z for qemu-devel@nongnu.org; Fri, 01 Jul 2016 12:00:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bJ0ri-0006gD-Vk for qemu-devel@nongnu.org; Fri, 01 Jul 2016 12:00:28 -0400 Received: from mail-io0-x241.google.com ([2607:f8b0:4001:c06::241]:36746) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bJ0ri-0006g7-Qz for qemu-devel@nongnu.org; Fri, 01 Jul 2016 12:00:26 -0400 Received: by mail-io0-x241.google.com with SMTP id s63so11931414ioi.3 for ; Fri, 01 Jul 2016 09:00:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zRpUAmVF+fd0gpMjlgE8SMpQMkm6H6WiJCzVTNXXRUA=; b=v9qTqkKNpmPP92RLBrZYaogfUN76EJL+8papo+OqQz+EWp6d9iGtjhjlaKbmiMt0EJ 9Yu5E0hx9ij45jtdRpZjkIEp4/oYIvF83v2ELuCtsf4AJGt6GYTSZZg8VVS0PFW83HOQ iZQdW7XKgktE9V6isaSGOcjDTUH1Lqgtr/OqNcgOh+Q4WED8fFIjb7w3jE46pwMT2qdS RXpoou2i1UAhGeAazlAXlomTnq9OEUHyawtpnwphNLuoU54Js32Db9H+3C8zrsr+Rsx3 sbWHMnoxndErr9DgXuBbhOXQxqcy2oeWztJkK+r3+tg2s1ypW902IoOK3eyxZmi/WGPn o5Rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zRpUAmVF+fd0gpMjlgE8SMpQMkm6H6WiJCzVTNXXRUA=; b=LDQfusfM3L0/v9ESjdpYRMOwGtfe9Aab9Ed3hqE2vS7RjqXuEYAJD0uyz73sfZfMAG efKDuJOmzLp0YwMBvyk2xIjrLTX1/QmCwq3GLg2GKe7urI5gWG927pEo2SljHZzeKUGS mTdX1raPStnX07yEx84Se0D32Z2eUXgNdN2MwZ2u/O3Zcku9Cg4mWnZFC72965A5IbOO bhVkZefymyhiprvuBiRIxI//NEBWynLGt5wEP5A2xwvadlEY/PBhefytYv/YGWSWwxHD 1TsIrCEGikznQCltt2Qh0cqitvL14R+GYb0ZqtjadGqDlaZZnBYOe57mr9GR1nkTaFMn wj8A== X-Gm-Message-State: ALyK8tKB9Naua7fKWcjEcC1sgnl3c1z13S/wLXnybOsHrxbVxJnVGM3JY1dil9p2v3nFBQ== X-Received: by 10.107.63.198 with SMTP id m189mr21580971ioa.60.1467388826296; Fri, 01 Jul 2016 09:00:26 -0700 (PDT) Received: from localhost.localdomain (d199-74-164-53.col.wideopenwest.com. [74.199.53.164]) by smtp.gmail.com with ESMTPSA id a17sm1692663ioa.27.2016.07.01.09.00.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 01 Jul 2016 09:00:25 -0700 (PDT) From: John Arbuckle To: eblake@redhat.com, qemu-devel@nongnu.org Date: Fri, 1 Jul 2016 11:59:51 -0400 Message-Id: <1467388791-1657-4-git-send-email-programmingkidx@gmail.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1467388791-1657-1-git-send-email-programmingkidx@gmail.com> References: <1467388791-1657-1-git-send-email-programmingkidx@gmail.com> 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 3/3] hid.c: Add debug support X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Arbuckle Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Add debug macros to the code for easier debugging. Signed-off-by: John Arbuckle --- v2 changes: - Made DEBUG_HID() always defined hw/input/hid.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/hw/input/hid.c b/hw/input/hid.c index 3e1b46e..b5558cd 100644 --- a/hw/input/hid.c +++ b/hw/input/hid.c @@ -37,6 +37,19 @@ #define RELEASED -1 #define PUSHED -2 +/* #define DEBUG_HID_CODE */ +#ifdef DEBUG_HID_CODE + #define DEBUG_HID_PRINT 1 +#else + #define DEBUG_HID_PRINT 0 +#endif +#define DEBUG_HID(fmt, ...) \ + do { \ + if (DEBUG_HID_PRINT) { \ + fprintf(stderr, fmt, ## __VA_ARGS__); \ + } \ + } while (0) \ + /* Translates a QKeyCode to USB HID value */ static const uint8_t qcode_to_usb_hid[] = { [Q_KEY_CODE_SHIFT] = USB_HID_LEFT_SHIFT, @@ -331,6 +344,7 @@ static void hid_keyboard_event(DeviceState *dev, QemuConsole *src, return; } keycode = qcode_to_usb_hid[qcode]; + DEBUG_HID("keycode = 0x%x qcode:%d\n", keycode, qcode); count = 2; if (evt->u.key.data->down == false) { /* if key up event */ @@ -381,6 +395,9 @@ static void hid_keyboard_process_keycode(HIDState *hs) slot = hs->head & QUEUE_MASK; QUEUE_INCR(hs->head); hs->n--; keycode = hs->kbd.keycodes[slot]; + DEBUG_HID("keycode:0x%x status:%s\n", keycode, (status == PUSHED ? "Pushed" + : "Released")); + /* handle Control, Option, GUI/Windows/Command, and Shift keys */ if (keycode >= 0xe0) { process_modifier_key(status, keycode, &(hs->kbd.modifiers));