Sugar devs,
I have provided a candidate patch to resolve trac ticket #5549
(http://dev.laptop.org/ticket/5549): "In rotated mode, game keys retain
original orientation". Please refer to the ticket for more details.
I have additionally attached the patch to this email.
-Erik
From ac3a34a911c3b11824981f9202a53cff6465f227 Mon Sep 17 00:00:00 2001
From: Erik Garrison <[EMAIL PROTECTED]>
Date: Wed, 28 May 2008 20:41:19 -0400
Subject: Modified sugar.view.keyhandler.handle_rotate() to rotate d-pad keys in concert with rotation of the display. Because of its explicit use of keycodes from an MP machine, this patch may be MP-specific.
---
src/view/keyhandler.py | 31 ++++++++++++++++++++++++++++---
1 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/src/view/keyhandler.py b/src/view/keyhandler.py
index 306bb21..2a2d539 100644
--- a/src/view/keyhandler.py
+++ b/src/view/keyhandler.py
@@ -186,14 +186,39 @@ class KeyHandler(object):
def handle_frame(self):
view.Shell.get_instance().get_frame().notify_key_press()
+
def handle_rotate(self):
+ """
+ Handles rotation of the display (using xrandr) and of the d-pad.
+
+ Notes: default mappings for keypad on MP
+ KP_Up 80
+ KP_Right 85
+ KP_Down 88
+ KP_Left 83
+ """
+
states = [ 'normal', 'left', 'inverted', 'right']
+ keycodes = (80, 85, 88, 83, 80, 85, 88, 83)
+ keysyms = ("KP_Up", "KP_Right", "KP_Down", "KP_Left")
self._screen_rotation += 1
- if self._screen_rotation == len(states):
- self._screen_rotation = 0
+ self._screen_rotation %= 4
+
+ actual_keycodes = keycodes[self._screen_rotation:self._screen_rotation+4]
+ code_pairs = zip(actual_keycodes, keysyms)
+ argv = ['xmodmap']
+ for arg in [('-e', 'keycode %i = %s' % p) for p in code_pairs]:
+ argv.extend(arg)
+
+ try:
+ subprocess.check_call(argv)
+ subprocess.check_call(['xrandr', '-o', states[self._screen_rotation]])
+ except OSError, e:
+ import errno
+ if e.errno != errno.EINTR:
+ raise
- subprocess.Popen(['xrandr', '-o', states[self._screen_rotation]])
def handle_quit_emulator(self):
if os.environ.has_key('SUGAR_EMULATOR_PID'):
--
1.5.4.3
_______________________________________________
Sugar mailing list
[email protected]
http://lists.laptop.org/listinfo/sugar