qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] ui/cocoa.m: Give laptop users ability to scroll in


From: Programmingkid
Subject: [Qemu-devel] [PATCH] ui/cocoa.m: Give laptop users ability to scroll in monitor
Date: Fri, 13 Mar 2015 00:35:35 -0400

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 <address@hidden>

---
 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]