Pen Tablet Support/GTK Widget: Difference between revisions

From OLPC
Jump to navigation Jump to search
No edit summary
No edit summary
Line 34: Line 34:
or on [http://dev.laptop.org/git?p=users/pdubroy/TabletAreaTest gitweb]. Alternatively, you can just grab the bundle: [http://dev.laptop.org/~pdubroy/TabletAreaTest-1.xo TabletAreaTest-1.xo].
or on [http://dev.laptop.org/git?p=users/pdubroy/TabletAreaTest gitweb]. Alternatively, you can just grab the bundle: [http://dev.laptop.org/~pdubroy/TabletAreaTest-1.xo TabletAreaTest-1.xo].


'''NB:''' because the driver support for the Pen Tablet is still in flux, this activity forks an evtest process to read input from the tablet. This will not be necessary in the future. So in order for the activity to work, you will either need to run it as root, or make the evtest executable setuid. This can be done from a terminal window using the following commands:
'''NB:''' because the driver support for the Pen Tablet is still in flux, this activity forks an evtest process to read input from the tablet. It assumes that /dev/input/event5 is the tablet, which may not be the case on every XO. This hack will not be necessary in the future. So in order for the activity to work, you will either need to run it as root, or make the evtest executable setuid. This can be done from a terminal window using the following commands:


su -
su -

Revision as of 00:58, 13 April 2008

This GTK widget is intended for applications that want to map tablet input to an on-screen widget that is the same shape and aspect ratio as the physical tablet. At its largest size, this would take up the full width of the screen and approximately 1/3 of the height of the screen.

Note: As of April 12, 2008, this is being developed in Patrick Dubroy's git branch at

 git://dev.laptop.org/users/pdubroy/sugar-toolkit 

or on gitweb. Comments are welcome -- please leave them on the Talk page.

Usage

Using this widget is as simple as:

 from sugar.graphics.tabletarea import TabletArea
 
 tablet_area = TabletArea()

This will create a gtk.DrawingArea on-screen. Whenever a stroke is detected on the tablet, a corresponding stroke will appear inside the widget. Some useful API:

 # Returns a list of strokes that have been made inside the tablet area
 tablet_area.get_strokes() 
 
 # Returns a copy of the gtk.gdk.Pixmap displayed on the tablet area
 tablet_area.get_pixmap() 
 
 # Clears the tablet area -- both the pixmap and the list of strokes.
 tablet_area.clear()

Full API documentation (subject to change) can be found here.

Sample Activity

For more information, please see the sample activity: source is in

 git://dev.laptop.org/users/pdubroy/TabletAreaTest 

or on gitweb. Alternatively, you can just grab the bundle: TabletAreaTest-1.xo.

NB: because the driver support for the Pen Tablet is still in flux, this activity forks an evtest process to read input from the tablet. It assumes that /dev/input/event5 is the tablet, which may not be the case on every XO. This hack will not be necessary in the future. So in order for the activity to work, you will either need to run it as root, or make the evtest executable setuid. This can be done from a terminal window using the following commands:

 su -
 cd <activity_dir>
 chown root:olpc evtest
 chmod 4775 evtest

In addition, it can sometimes leave zombie processes lying around, which can be cured like so:

 killall evtest

If anyone has a system where the tablet driver works properly (which I've heard is the case in the latest joyride builds), I welcome a patch to get this activity working with that.