From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56986) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YWHK3-0000m8-QR for qemu-devel@nongnu.org; Fri, 13 Mar 2015 00:35:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YWHJy-0002rz-Kt for qemu-devel@nongnu.org; Fri, 13 Mar 2015 00:35:43 -0400 Received: from mail-qg0-x234.google.com ([2607:f8b0:400d:c04::234]:46454) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YWHJy-0002rj-Ff for qemu-devel@nongnu.org; Fri, 13 Mar 2015 00:35:38 -0400 Received: by qgfh3 with SMTP id h3so23358135qgf.13 for ; Thu, 12 Mar 2015 21:35:38 -0700 (PDT) From: Programmingkid Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Date: Fri, 13 Mar 2015 00:35:35 -0400 Message-Id: <9D0D12D4-476B-4EF4-80EB-0A61F0BED115@gmail.com> Mime-Version: 1.0 (Apple Message framework v1084) Subject: [Qemu-devel] [PATCH] ui/cocoa.m: Give laptop users ability to scroll in monitor List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: qemu-devel qemu-devel Laptop users usually have keyboards that are missing the page up and = page down keys. This means they cannot scroll in the monitor. This patch = gives laptop users the ability to scroll in the monitor by having the = user push the Control + Up/Down arrow keys to scroll one line at a time. = Use ALT/Option in place of Control to be able to scroll at 10 lines at a = time.=20 Signed-off-by: John Arbuckle --- ui/cocoa.m | 82 = ++++++++++++++++++++++++++++++++++++++++------------------- 1 files changed, 55 insertions(+), 27 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index d37c29b..3ac847f 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -593,35 +593,63 @@ QemuCocoaView *cocoaView; // handlekeys for Monitor } else { int keysym =3D 0; - switch([event keyCode]) { - case 115: - keysym =3D QEMU_KEY_HOME; - break; - case 117: - keysym =3D QEMU_KEY_DELETE; - break; - case 119: - keysym =3D QEMU_KEY_END; - break; - case 123: - keysym =3D QEMU_KEY_LEFT; - break; - case 124: - keysym =3D QEMU_KEY_RIGHT; - break; - case 125: - keysym =3D QEMU_KEY_DOWN; - break; - case 126: - keysym =3D QEMU_KEY_UP; - break; - default: - { - NSString *ks =3D [event characters]; - if ([ks length] > 0) - keysym =3D [ks characterAtIndex:0]; + + /* + Holding down the up or down arrow key with the Control = key scrolls the console one line. + Using the ALT/Option key with the up or down key = scrolls the console 10 lines. + Had to do this because laptops don't have page up or = page down keys. + */ + + // if the CONTROL key is held down + if([event modifierFlags] & NSControlKeyMask) { + if([event keyCode] =3D=3D 126) { // up = arrow key + keysym =3D QEMU_KEY_CTRL_UP; + } else if([event keyCode] =3D=3D 125) { // down = arrow key + keysym =3D QEMU_KEY_CTRL_DOWN; + } + } + + // if the ALT/OPTION key is held down + else if ([event modifierFlags] & NSAlternateKeyMask) { + if ([event keyCode] =3D=3D 126) { // up = arrow key + keysym =3D QEMU_KEY_CTRL_PAGEUP; + } else if ([event keyCode] =3D=3D 125) { // down = arrow key + keysym =3D QEMU_KEY_CTRL_PAGEDOWN; } } + + else { + switch([event keyCode]) { + case 115: + keysym =3D QEMU_KEY_HOME; + break; + case 117: + keysym =3D QEMU_KEY_DELETE; + break; + case 119: + keysym =3D QEMU_KEY_END; + break; + case 123: + keysym =3D QEMU_KEY_LEFT; + break; + case 124: + keysym =3D QEMU_KEY_RIGHT; + break; + case 125: + keysym =3D QEMU_KEY_DOWN; + break; + case 126: + keysym =3D QEMU_KEY_UP; + break; + default: + { + NSString *ks =3D [event characters]; + if ([ks length] > 0) + keysym =3D [ks characterAtIndex:0]; + } + } + } + if (keysym) kbd_put_keysym(keysym); } --=20 1.7.5.4