*

Welcome, Guest. Please login or register.

Get your own OLPC - Buy an XO laptop on eBay!
Pages: [1] 2 3 4
Print
Author Topic: Pseudo-mouse & keyboard in tablet mode  (Read 58230 times)

Pseudo-mouse & keyboard in tablet mode

scrub
Commenter

Posts: 19


February 08, 2008, 02:30:32 AM

OK, I finally have a configuration I like for tablet mode. By default, the gamepad keys (up/down/left/right, Circle/Check/X/Square) all have their default functions. By pressing the "screen rotate" button the directional arrows move the mouse cursor, three of the other keys emulate three mouse buttons, and the fourth key binds to alt+control. By hitting alt+control+mouse1, I toggle an on-screen keyboard to allow text entry.  I can still add functions for alt+control+mouse2 and alt+control+mouse3.

I'll try to go through all the steps it took, but I might forget some of what I did...let me know if you run into problems!

For the virtual keyboard, I installed xvkbd, described at  http://homepage3.nifty.com/tsato/xvkbd/   I installed a package from  http://dag.wieers.com/rpm/packages/xvkbd/
I needed to install the Xaw package first, so do this as root:

yum install Xaw3d
rpm -i  http://dag.wieers.com/rpm/packages/xvkbd/xvkbd-2.8-1.rh9.rf.i386.rpm

To control the mousekeys functionality, I compiled and installed the xkbset utility from  http://www.math.missouri.edu/~stephen/software/ If you're running Xfce you might be able to work with the built-in functionality there, but I don't think fluxbox has anything built in to control the accessibility features in the same way that xfce does. If anyone wants to just download the compiled xkbset executable, you can get it at  http://corrupt.net/~scrub/olpc/xkbset Save it into /usr/bin and do a "chmod 755 /usr/bin/xkbset" to allow all users to execute it. For anyone who wants to compile it themselves, I had to do (as root):

yum install gcc glibc-devel libX11-devel
wget  http://www.math.missouri.edu/~stephen/software/xkbset/xkbset-0.5.tar.gz
gunzip xkbset-0.5.tar.gz
tar -xvf xkbset-0.5.tar.gz
cd xkbset-0.5
make
cp xkbset /usr/bin

Now you can run xkbset with various command line options to turn accessibility features on and off.

Next you have to mess around with the xkb/compat files.  I don't totally understand how these work, but I got what I wanted by doing the following:

cd /usr/share/X11/xkb/compat
mv olpc olpc.backup
vi mousekeys (or use whatever text editor you prefer) to change this text:

    interpret Pointer_Button1 {
        action= PointerButton(button=1);
    };
    interpret Pointer_Button2 {
        action= PointerButton(button=2);
    };
    interpret Pointer_Button3 {
        action= PointerButton(button=3);
    };

to instead say:

    interpret KP_Home{
        action= PointerButton(button=1);
    };
    interpret KP_Prior {
        action= PointerButton(button=2);
    };
    interpret KP_End {
        action= PointerButton(button=3);
    };
    interpret KP_Next {
        action= SetMods(modifiers=Alt+Control);
    };

That just bound the mouse click actions to Square, Circle, and Check, and made it so that pressing the X is like pressing Control and Alt.

Next I made two scripts:

/usr/bin/togglemousekeys.sh which contains:

current=`xkbset q | grep "Mouse-Keys =" | awk '{print $3}'`
if [ $current == "Off" };
then
  xkbset m -r ma 60 20 25 30 500
else
  xkbset -m r
fi

That script checks whether mousekeys is enabled or not, and switches to the other state.  It also toggles repeat keys since you need to disable them for mousekeys to work properly ,but reenable them for keyboard things like holding down the down arrow to scroll through a file.  (Anyone know how to enable repeatkeys for individual keys?  I'd love to regain the ability to hold down k and j and l and so on to move through files in vi, instead of having to move over to the arrow keys.)

I also made:

/usr/bin/togglevkbd.sh  which contains:

if ps ax | grep -v grep | grep xvkbd > /dev/null
then
  /usr/bin/pkill xvkbd
else
  /usr/bin/xvkbd -secure -always-on-top -compact -geometry 300x80-0-100
fi

This script chceks whether the on-screen keyboard is running.  If so, it kills it.  If not, it runs it as a small keyboard in the bottom right corner.

Make sure to change permissions:

chmod 755 /usr/bin/toggle*

To bind the mousekeys toggle to the screen rotate button, and to bind the X key + Square key (Control+Alt+Mouse1) to toggle the on-screen keyboard, I added these lines to my fluxbox keys file in /home/olpc/.fluxbox/keys

235 :ExecCommand /usr/bin/togglemousekeys.sh
Control Mod1 Mouse1 :ExecCommand /usr/bin/togglevkbd.sh

I want the gamepad keys to rotate with the screen, so that whenever I look at the screen from 90, 180, o r270 degrees rotation, the buttons still work intuitively.  So I made two more scripts (remember to chmod 755 these):

/usr/bin/xrandr_rotate.sh which contains:

current=`xrandr | grep connected | awk '{print $4}'`
if [ $current == "(normal" ]; then val=1
 elif [ $current == "left" ]; then val=2
 elif [ $current == "inverted" ]; then val=3
 elif [ $current == "right" ]; then val=0
fi

xrandr -o $val
xmodmap /home/olpc/rotate$val


and /usr/bin/xrandr_reverse.sh which contains:

current=`xrandr | grep connected | awk '{print $4}'`
if [ $current == "(normal" ]; then val=3
 elif [ $current == "left" ]; then val=0
 elif [ $current == "inverted" ]; then val=1
 elif [ $current == "right" ]; then val=2
fi

xrandr -o $val
xmodmap /home/olpc/rotate$val


I bound them to control-screen rotate and shift-screen rotate in fluxbox by editing my /home/olpc/.fluxbox/keys file again to add:

Control 235 :ExecCommand xrandr_rotate.sh
Shift 235 :ExecCommand xrandr_reverse.sh

I created four files to dynamically remap the gamepad keys as the screen rotates:

/home/olpc/rotate0 contains:

keycode 80 = KP_Up
keycode 85 = KP_Right
keycode 88 = KP_Down
keycode 83 = KP_Left
keycode 81 = KP_Prior
keycode 79 = KP_Home
keycode 89 = KP_Next
keycode 87 = KP_End

/home/olpc/rotate1 contains:

keycode 85 = KP_Up
keycode 88 = KP_Right
keycode 83 = KP_Down
keycode 80 = KP_Left
keycode 87 = KP_Prior
keycode 81 = KP_Home
keycode 79 = KP_Next
keycode 89 = KP_End

/home/olpc/rotate2 contains:

keycode 88 = KP_Up
keycode 83 = KP_Right
keycode 80 = KP_Down
keycode 85 = KP_Left
keycode 89 = KP_Prior
keycode 87 = KP_Home
keycode 81 = KP_Next
keycode 79 = KP_End

/home/olpc/rotate3 contains:

keycode 83 = KP_Up
keycode 80 = KP_Right
keycode 85 = KP_Down
keycode 88 = KP_Left
keycode 79 = KP_Prior
keycode 89 = KP_Home
keycode 87 = KP_Next
keycode 81 = KP_End

You don't need to set any special permissions on those, since they aren't scripts...they're just input files for xmodmap

I haven't yet decided what to bind alt-control mouse2 and alt-control mouse3 to; when I do decide I'll add those to /home/olpc/.fluxbox/keys the same as above.  For those of you not running fluxbox, you'll need to figure out how to do the key bindings under your own window manager, but everything else should work the same.

Annoyingly, using the X button in mousekeys mode, when it's bound to alt-control, still sends the "page down" signal.  I spent a lot of time banging my head against the /usr/share/X11/xkb/compat/mousekeys file trying to find a better solution, but I couldn't.  If you don't expect to use a mouse with scroll-wheel, then you could use mouse button 4 or 5.  I also found an action to Redirect the key within the mousekeys, but then it rebound the key whether or not mousekeys was enabled...I only want the mousekeys binding in effect when mousekeys is enabled.  Anyway, please let me know if you see a better way to handle the X key or any of the rest of this!

Scrub
Logged

#1 Re: Pseudo-mouse & keyboard in tablet mode

mattd
Senior Contributor
**
Posts: 111


February 08, 2008, 06:01:22 AM

I think scrub just defined the word hack.
Logged

#2 Re: Pseudo-mouse & keyboard in tablet mode

unrequited
Senior Contributor
**
Posts: 120



February 08, 2008, 03:55:55 PM

WOW, that's wonderful. Would you mind tar'ing it all up (at least your custom scripts) so they're easy to install? Also perhaps the custom config files so we could just mv them to their correct locations?
Logged

-Unrequited

#3 Re: Pseudo-mouse & keyboard in tablet mode

scrub
Commenter

Posts: 19


February 08, 2008, 05:15:40 PM

matt, lol! Smiley

unrequited,

Good idea...I'll work on bundling things, but I won't get to it for several days.  I'll post it when I have it, though!



Scrub
Logged

#4 Re: Pseudo-mouse & keyboard in tablet mode

LesleyT
Master Contributor
***
Posts: 281



WWW
February 08, 2008, 05:32:28 PM

Damn....


*stands in quiet awe*

You. Rock.
Like totally.......
Logged

#5 Re: Pseudo-mouse & keyboard in tablet mode

scrub
Commenter

Posts: 19


February 12, 2008, 04:15:25 PM

I uploaded a bundle which should have all the scripts and executables you need:

http://corrupt.net/~scrub/tablet/olpctablet-0.1.tar.gz

As root, run the command:

gunzip < olpctablet-0.1.tar.gz | tar -xv
cd olpctablet-0.1
./install.sh

That will copy all the bin files into your /usr/bin and set the permissions to 755

It will create a /home/olpc/.tablet directory and copy 8 xmodmap keybinding files into it.

It will back up your mousekeys file and copy a new one into the /usr/share/X11/xkb/compat directory.  It renames your olpc file so it isn't found by the systme.  NOTE: if you run the script a second time, it will copy the tablet version of mousekeys into the backed-up version, so you'll have to manually backup your original mousekeys to be safe.

It adds a couple of xmodmap bindings to your /home/olpc/.Xmodmap file

It runs yum install Xaw3d  (if this fails or you don't have internet connection when you run the install script, you can manually run the yum install later)

I've never put together a bundle like this, so let me know if I missed anything!

Some changes vs what I described in my last post:

I mentioned the annoyance of "page down" passing through even in mousekeys mode.  I fixed that by binding the key to Scroll_Lock instead of KP_Next.  But if you have an application that uses Scroll Lock for anything and you have problems, you'll have to try something else for the binding.

I set it up so that in "mousekeys" mode, hitting the bottom game key plus left game key opens the virtual keyboard and jumps the mouse cursor to it.  Hitting bottom game key plus top game key sends "enter" to your application.  Bottom game key plus right game key sends "control-l", which in opera goes to the address bar.  You can easily change those bindings in .fluxbox/keys or in whatever you use for key bindings in your window manager.

Note that the install script does *NOT* automatically set any keybindings. If you use fluxbox, you can copy the bindings from the end of the fluxbox/keys file included in the bundle.  Otherwise you can use the fluxbox/keys file as a gude, but you'll have to figure out the details for your own window manager.

I will probably take this a step further by adding a third "mode" to the current "normal" and "mousekeys" mode.  The 3rd mode would allow bindings for zoom in/out, with plenty more keybinding possibilities to do whatever else seems most valuable in tablet mode.

Enjoy, and let me know how it works or if you have ideas for improvements!
Logged

#6 Re: Pseudo-mouse & keyboard in tablet mode

newbie
Senior Contributor
**
Posts: 126

Don't know much about computers but LOVE my Olpc.


February 23, 2008, 05:51:10 AM

I've been looking for this kind of thing for a while now, since I'd really like to surf on the net in tablet mode.

Just one question - does this change the gamepad-keys permanently? Or can I just start this every time I need it?
Logged

#7 Re: Pseudo-mouse & keyboard in tablet mode

scrub
Commenter

Posts: 19


February 28, 2008, 09:37:51 AM

Hi newbie,

I set it up so that hitting the "screen rotate" button toggles between normal gamepad functions vs mouse & keyboard functions.  By default, when I boot up, the gamepad keys function normally, until I hit the screen rotate button.

To rotate the screen, I instead use control-screen rotate and shift-screen rotate to go clockwise or counter-clockwise.  If you want to preserve the screen rotate button's original function, you would just have to set up a different trigger to switch gamepad button modes.

I hope that helps!

Scrub
Logged

#8 Re: Pseudo-mouse & keyboard in tablet mode

newbie
Senior Contributor
**
Posts: 126

Don't know much about computers but LOVE my Olpc.


February 28, 2008, 01:11:17 PM

Thanks! I will definitely give this a try now!
Logged

#9 Re: Pseudo-mouse & keyboard in tablet mode

LesleyT
Master Contributor
***
Posts: 281



WWW
March 04, 2008, 01:58:20 PM

arg
It's downloaded.  But I can't run the gunzip.  I have to find where it downloaded, I guess.
Logged

#10 Re: Pseudo-mouse & keyboard in tablet mode

mattd
Senior Contributor
**
Posts: 111


March 05, 2008, 07:42:21 AM

I saw this over on the GPS thread and thought it might be helpful.

They call it the ergonomic touchpad. It's essentially a regular laptop mouse pad, just not in a laptop. It's USB and has some velcro on the back so you could stick it on the handle area when in tablet mode.

Though, Gabey8 bought one and said it didn't work out of the box on the XO (but did on her WinXP box). I've got one on the way, but no XO yet...

I figured this might be helpful for someone looking for a mouse in tablet mode.
Logged

#11 Re: Pseudo-mouse & keyboard in tablet mode

Ben
Contributor
*
Posts: 68


March 18, 2008, 10:04:27 PM

I uploaded a bundle which should have all the scripts and executables you need:

...

Note that the install script does *NOT* automatically set any keybindings. If you use fluxbox, you can copy the bindings from the end of the fluxbox/keys file included in the bundle.  Otherwise you can use the fluxbox/keys file as a gude, but you'll have to figure out the details for your own window manager.

Thanks for the tar file.

If I just want the gamepad buttons to rotate, do I need to install Xaw3d and the togglemouse scripts?

With a "virgin" XO, anyone know how to add the keybindings for the rotate button to the default windows manager?
Logged

#12 Re: Pseudo-mouse & keyboard in tablet mode

samphilomath
Senior Contributor
**
Posts: 214


Let GO my XO


WWW
March 27, 2008, 11:33:08 PM

This is great stuff. We need to keep working on this.
http://laptop.org/en/laptop/start/features.shtml

- Give the Game pad complete function of the touch pad mouse censor movement when on tablet mode.  Game pad is the button on top of the Screen rotation button.

- Reverse the screen upside down by clicking twice the Screen rotation button.

 For the Game controller buttons, circle, a square, a check, and a ×, the buttons on top of the Power button

- Use X to scroll up, circle to scroll down, Circle + Square to scroll to the right, and Check + Circle to scroll to the left.
- Check  for Right click

- Square  for Left click

- Circle + Square + Check + X to open and close on screen Keyboard. 



Those are easy stuff any talented OLPC's developers or a couple of smart XO users can do in less then a week.

You end up with a complete multi functional table PC. No stylus or touch screen needed. Simply amazing.

   
This function will be available soon. Very soon Smiley
« Last Edit: March 29, 2008, 09:45:00 PM by samphilomath » Logged

#13 Re: Pseudo-mouse & keyboard in tablet mode

scrub
Commenter

Posts: 19


March 28, 2008, 12:13:39 AM

Hey mattd,

Sweet, thanks for the link to the ergonomic touchpad!  Their website talks about Windows and Macintosh, but I don't see anything about linux, so maybe we need to wait for drivers before it'll work with the XO? :/  I'd love to hear if anyone gets it working!

Ben: you only need the Xaw3d to run the virtual keyboard.  And you only need the togglemousekeys scripts to turn the mouse emulator on and off.  If you just want to rotate the gamepad keys, you don't need either of those. 

The file for modifying key bindings under the default Sugar window manager is /usr/share/sugar/shell/view/keyhandler.py  I don't know off the top of my head what modifications you need to make there, but it would basically entail binding the xrandr scripts to the screen rotate button, which has key value 235 (as I mentioned below, I use control-235 and shift-235).  You just need to figure out the syntax for the keyhandler.py file.

philomath: I feel a little confused, since my setup allows you to use the gamepad and rocker keys to either move the mouse cursor over the screen, or use the keys in their normal default way.  This set up gives you complete use of the mouse (movement and three mouse buttons simulated) without needing a stylist or touch screen or touch pad.

Are you saying you want to move the mouse cursor with the game pad keys, rather than with the "rocker" keys (up/down/left/right) like I set it up?  If so, I think you would have to bind the square/circle/x/check buttons to be up/down/left/right, using xmodmap.  (Using the same syntax as I use below in the rotate0 rotate1 rotate2 and rotate3 scripts.)  Out of curiousity, what would you use the rocker keys for instead?

I don't think you could use the circle/square/check/x buttons to move the mouse cursor, *and* use them to send left and right clicks without winding up sending an awful lot of accidental clicks whenever you hit the wrong two at once while trying to move the mouse around.

Let me know if I totally misunderstood you!

Scrub
Logged

#14 Re: Pseudo-mouse & keyboard in tablet mode

samphilomath
Senior Contributor
**
Posts: 214


Let GO my XO


WWW
March 28, 2008, 12:46:07 AM

sorry scrub, I did mean the "rocker" key, the on the left side on top of the screen rotation button. i will edit my post.

Base on
http://laptop.org/en/laptop/start/features.shtml
« Last Edit: March 28, 2008, 09:56:42 AM by philomath » Logged

Pages: [1] 2 3 4
Print
Jump to:  

Members
Total Members: 2405
Latest: sembik
Stats
Total Posts: 31943
Total Topics: 3843
Online Today: 25
Online Ever: 238
(April 18, 2011, 09:48:50 PM)
Users Online
Users: 0
Guests: 13
Total: 13