[olpc-help] how can I redefine the game keys

dlang community-support at lists.laptop.org
Tue Jan 15 11:17:20 EST 2008


in the topic http://olpc.osuosl.org/forum/viewtopic.php?t=3104 there is a partial answer


braingram wrote:
> Here's a quit little 'hack' to remap the gamepad keys to zoom in and out in the Read activity.
> square = zoom in
> check  = zoom out
> open /usr/share/activities/Read.Activity/readactivity.py
> edit the _key_press_event_cb function (near the end of the file) to look like the following
> 
> Code:
> 
>     def _key_press_event_cb(self, widget, event):
>         keyname = gtk.gdk.keyval_name(event.keyval)
>         logging.debug("Keyname Press: %s, time: %s", keyname, event.time)
>         if keyname == 'KP_End'
>                 self._view_toolbar._zoom_in_cb(self._view_toolbar._zoom_in)
>                 return True
>         if keyname == 'KP_Home'
>                 self._view_toolbar._zoom_out_cb(self._view_toolbar._zoom_out)
>                 return True
>         if keyname == 'c' and event.state & gtk.gdk.CONTROL_MASK:
>             self._view.copy()
> 
> 
> 
> 
> Thanks a million to Ben James Ben over at the OLPC News Forum for helping me understand the callback return
> http://olpcnews.com/forum/index.php?topic=1437.0


I'm still trying to figure out how to just change a key to do something else. It may be as simple as 

Code:

        if keyname == 'KP_Home'
                keyname = 'd'




but I haven't had a chance to try it yet







More information about the community-support mailing list