From patchwork Sun Feb 13 10:07:36 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roy Tam X-Patchwork-Id: 82976 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 E298AB7122 for ; Sun, 13 Feb 2011 21:09:08 +1100 (EST) Received: from localhost ([127.0.0.1]:58981 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PoYt7-000367-Js for incoming@patchwork.ozlabs.org; Sun, 13 Feb 2011 05:09:05 -0500 Received: from [140.186.70.92] (port=41072 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PoYs3-00032A-9l for qemu-devel@nongnu.org; Sun, 13 Feb 2011 05:08:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PoYs2-0006xM-3F for qemu-devel@nongnu.org; Sun, 13 Feb 2011 05:07:59 -0500 Received: from mail-wy0-f173.google.com ([74.125.82.173]:49247) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PoYs1-0006x5-UM for qemu-devel@nongnu.org; Sun, 13 Feb 2011 05:07:58 -0500 Received: by wyg36 with SMTP id 36so3924792wyg.4 for ; Sun, 13 Feb 2011 02:07:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:from:date:message-id:subject:to :content-type; bh=O58L3mnn7SCdJrDLB6OWDuRvGSKIQFT5ahZunIIYLsI=; b=LA8TsS9UrK89NQqBjUlb47bOQV7AaWpRnVSM5slm190jMBtxMAQEGLx9o6e+Dm5t4/ 8rJvNDnJ3wV+jJE6/A1xAg1UmdcmEjk/E/jhkfkZiP3aifMJ2OOT/gksYPK/lyDwaPl/ abx0XYvSs6h7+daBgs0mpoVFTAHe6KCMtVNJg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type; b=qVTY9fvwVVK6oJH9rOPOfmWBg2QQNQ4qss6ydOdbZ/7Xj5WAR/SQvT6kEVGk6vuFJH KwoRt9u8n9S5doztFxx+9AxBFqwET/wSsdD/WhI/iRZHNxPrzvosTwJ2kznmFmqzPezp XW9z+oCKsKAAx11fbj9NkBteoChdiJrcXGOpI= Received: by 10.227.133.15 with SMTP id d15mr1523967wbt.76.1297591676677; Sun, 13 Feb 2011 02:07:56 -0800 (PST) MIME-Version: 1.0 Received: by 10.227.133.7 with HTTP; Sun, 13 Feb 2011 02:07:36 -0800 (PST) From: Roy Tam Date: Sun, 13 Feb 2011 18:07:36 +0800 Message-ID: To: qemu-devel X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 74.125.82.173 Subject: [Qemu-devel] [PATCH v2] PS/2 keyboard Scancode Set 3 support 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 The following patch adds PS/2 keyboard Scancode Set 3 support. Sign-off-by: Roy Tam --- v2: checkpatch.pl style fixes diff --git a/hw/ps2.c b/hw/ps2.c index 762bb00..6bea0ef 100644 --- a/hw/ps2.c +++ b/hw/ps2.c @@ -143,13 +143,85 @@ static void ps2_put_keycode(void *opaque, int keycode) { PS2KbdState *s = opaque; - /* XXX: add support for scancode sets 1 and 3 */ - if (!s->translate && keycode < 0xe0 && s->scancode_set == 2) - { + /* XXX: add support for scancode sets 1 */ + if (!s->translate && keycode < 0xe0 && s->scancode_set > 1) { if (keycode & 0x80) ps2_queue(&s->common, 0xf0); keycode = ps2_raw_keycode[keycode & 0x7f]; - } + if (s->scancode_set == 3) { + switch (keycode) { + case 0x1: + keycode = 0x47; + break; + case 0x3: + keycode = 0x27; + break; + case 0x4: + keycode = 0x17; + break; + case 0x5: + keycode = 0x7; + break; + case 0x6: + keycode = 0xf; + break; + case 0x7: + keycode = 0x5e; + break; + case 0x9: + keycode = 0x4f; + break; + case 0xa: + keycode = 0x3f; + break; + case 0xb: + keycode = 0x2f; + break; + case 0xc: + keycode = 0x1f; + break; + case 0x11: + keycode = 0x19; + break; + case 0x14: + keycode = 0x11; + break; + case 0x58: + keycode = 0x14; + break; + case 0x5d: + keycode = 0x5c; + break; + case 0x76: + keycode = 0x8; + break; + case 0x77: + keycode = 0x76; + break; + case 0x78: + keycode = 0x56; + break; + case 0x79: + keycode = 0x7c; + break; + case 0x7b: + keycode = 0x84; + break; + case 0x7c: + keycode = 0x7e; + break; + case 0x7e: + keycode = 0x5f; + break; + case 0x83: + keycode = 0x37; + break; + case 0x84: + keycode = 0x57; + break; + } + } + } ps2_queue(&s->common, keycode); }