All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] ui/cocoa.m: Give laptop users ability to scroll in monitor
@ 2015-03-13  4:35 Programmingkid
  2015-03-13  9:51 ` Peter Maydell
  0 siblings, 1 reply; 25+ messages in thread
From: Programmingkid @ 2015-03-13  4:35 UTC (permalink / raw)
  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. 

Signed-off-by: John Arbuckle <programmingkidx@gmail.com>

---
 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 = 0;
-                switch([event keyCode]) {
-                case 115:
-                    keysym = QEMU_KEY_HOME;
-                    break;
-                case 117:
-                    keysym = QEMU_KEY_DELETE;
-                    break;
-                case 119:
-                    keysym = QEMU_KEY_END;
-                    break;
-                case 123:
-                    keysym = QEMU_KEY_LEFT;
-                    break;
-                case 124:
-                    keysym = QEMU_KEY_RIGHT;
-                    break;
-                case 125:
-                    keysym = QEMU_KEY_DOWN;
-                    break;
-                case 126:
-                    keysym = QEMU_KEY_UP;
-                    break;
-                default:
-                    {
-                        NSString *ks = [event characters];
-                        if ([ks length] > 0)
-                            keysym = [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] == 126) {         // up arrow key
+                        keysym = QEMU_KEY_CTRL_UP;
+                    } else if([event keyCode] == 125) {  // down arrow key
+                        keysym = QEMU_KEY_CTRL_DOWN;
+                    }
+                }
+
+                // if the ALT/OPTION key is held down
+                else if ([event modifierFlags] & NSAlternateKeyMask) {
+                    if ([event keyCode] == 126) {         // up arrow key
+                        keysym = QEMU_KEY_CTRL_PAGEUP;
+                    } else if ([event keyCode] == 125) {  // down arrow key
+                        keysym = QEMU_KEY_CTRL_PAGEDOWN;
                     }
                 }
+
+                else {
+                    switch([event keyCode]) {
+                    case 115:
+                        keysym = QEMU_KEY_HOME;
+                        break;
+                    case 117:
+                        keysym = QEMU_KEY_DELETE;
+                        break;
+                    case 119:
+                        keysym = QEMU_KEY_END;
+                        break;
+                    case 123:
+                        keysym = QEMU_KEY_LEFT;
+                        break;
+                    case 124:
+                        keysym = QEMU_KEY_RIGHT;
+                        break;
+                    case 125:
+                        keysym = QEMU_KEY_DOWN;
+                        break;
+                    case 126:
+                        keysym = QEMU_KEY_UP;
+                        break;
+                    default:
+                        {
+                            NSString *ks = [event characters];
+                            if ([ks length] > 0)
+                                keysym = [ks characterAtIndex:0];
+                        }
+                    }
+                }
+
                 if (keysym)
                     kbd_put_keysym(keysym);
             }
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2015-06-11 14:24 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-13  4:35 [Qemu-devel] [PATCH] ui/cocoa.m: Give laptop users ability to scroll in monitor Programmingkid
2015-03-13  9:51 ` Peter Maydell
2015-03-13 14:48   ` Programmingkid
2015-03-13 17:31     ` Paolo Bonzini
2015-03-13 20:43       ` Programmingkid
2015-03-16 12:19         ` Paolo Bonzini
2015-03-16 13:35           ` Programmingkid
2015-03-16 13:36             ` Paolo Bonzini
2015-03-16 13:39               ` Programmingkid
2015-03-16 13:48         ` Daniel P. Berrange
2015-03-16 14:00           ` Peter Maydell
2015-03-16 14:38             ` Programmingkid
2015-03-16 14:43               ` Peter Maydell
2015-03-16 14:45                 ` Programmingkid
2015-03-16 14:47                   ` Paolo Bonzini
2015-03-16 14:49                     ` Programmingkid
2015-03-16 14:52                       ` Paolo Bonzini
2015-03-16 14:59                         ` Peter Maydell
2015-03-16 15:06                           ` Programmingkid
2015-03-16 15:01                         ` Programmingkid
2015-05-10 22:34                   ` Peter Maydell
2015-05-10 22:51                     ` Peter Maydell
2015-05-11  6:53                       ` Gerd Hoffmann
2015-06-11 14:23                         ` Peter Maydell
2015-03-16 14:33           ` Programmingkid

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.