old-www/LDP/LG/issue33/gm-xinput.html

326 lines
19 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="GENERATOR" CONTENT="Mozilla/4.06 [en] (X11; I; Linux 2.0.30 i486) [Netscape]">
<TITLE>Graphics Muse
</TITLE>
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000FA" VLINK="#FA3333" ALINK="#33CC33">
<!-- =============================================================
This Page Designed by Michael J. Hammel.
Permission to use all graphics and other content for private,
non-commerical use is granted provided you give me (or the
original authors/artists) credit for the work.
CD-ROM distributors and commercial ventures interested in
providing the Graphics Muse for a fee must contact me,
Michael J. Hammel (mjhammel@csn.net), for permission.
============================================================= !--><A NAME="musings"></A>
<TABLE>
<TR>
<TD>
<H2>
More...</H2>
<IMG SRC="../gx/hammel/musings.gif" ALT="Musings" HEIGHT=52 WIDTH=247 ALIGN=LEFT></TD>
</TR>
</TABLE>
<TABLE>
<TR>
<TD>
<H2>
X Input ...</H2>
</TD>
</TR>
</TABLE>
<TABLE WIDTH="100%" >
<TR>
<TD ALIGN=RIGHT WIDTH="100%"><FONT SIZE=-2>&copy; 1998 <A HREF="mailto:mjhammel@csn.net">Michael
J. Hammel</A></FONT></TD>
</TR>
<TR>
<TD VALIGN=TOP BGCOLOR="#000000" cellpadding="0" cellspacing="0"><IMG SRC="../gx/hammel/cleardot.gif" ALT="indent" ALIGN=LEFT></TD>
</TR>
</TABLE>
The configuration line <B>AlwaysCore</B> for the SubSections WacomCore
and EraserCore will essentially set this configuration to allow both the
pen and eraser on the Wacom pen to act as your core pointer at the same
time as your mouse.&nbsp; In other words, this configuration lets you use
either the pen or the mouse to move the pointer around the screen.&nbsp;
The pen can be used to post menus from your window manager or click on
buttons in applications just like the mouse, although the raw coordinate
system of the tablet makes it a bit strange to use as the core pointer
initially.&nbsp; Where you might move the mouse, pick it up and the roll
it again, with the pen and tablet you always need to place the pen exactly
in the right coordinate on the tablet to get the right coordinate on the
screen.&nbsp; For example, to move to the upper left corner of the display
you must place the pen in the upper left corner of the tablet.&nbsp; Once
you have your tablet configured you'll see what I mean.&nbsp; I found the
use of the pen as my core pointing device a little difficult to get used
to but you may not.
<P>After the <B>SubSection</B> line is the line defining the device port
to use.&nbsp; My tablet uses a serial port and I suspect most of the other
tablets do as well.&nbsp; In this case, /dev/ttyS1 is my second serial
port.&nbsp; Although you may be able to use the /dev/cua1 device here as
well, I've read that it is recommended to use the cua devices only for
modems.&nbsp; If you use a multiport serial card, such as the <A HREF="http://ftp.leidenuniv.nl/linux/tsx-11/packages/comtrol/">Comtrol
RocketPort</A>, and have the device connected to one of those ports then
the device name will be different.&nbsp; The Comtrol controller sets up
ports with names running from /dev/ttyR0 to /dev/ttyR15 (depending on how
many cards and ports you have installed).
<P>The <B>Mode Absolute</B> line is required.&nbsp; Unfortunately I don't
really have any information as to what would happen if you didn't include
this line.&nbsp; The last line, <B>Suppress</B>, is used to set the movement
sensitivity of the pen.&nbsp; Higher values mean that the pointer on the
screen won't move as quickly as you move the pen around the tablet.&nbsp;
I experimented with the default value (from the X Input Howto) of 9 and
found the pointer jumped too quickly for my taste.&nbsp; A value of 17
seemed to work more to my liking.
<P>These are the only changes you'll need to make to the XF86Config file.&nbsp;
We'll test this configuration in a moment but first lets make sure you
have the hardware connected properly.&nbsp; The PenPartner, at least, has
two connectors that have to be connected to your system.&nbsp; One plugs
into your keyboard connector and allows your keyboard to be connected to
it.&nbsp; This is used to get power to the tablet.&nbsp; The other connector
is a typical serial connector and should be plugged into the port specified
by your Port line in the XF86Config file.&nbsp; Be certain you don't have
the power on when you attach the plug that goes to the keyboard connector.&nbsp;
If you do you can cause damage to the tablet.&nbsp; After the keyboard
and serial connectors are in place you can power up your computer.
<P>In my setup I have only two serial ports, with one of those dedicated
to the mouse.&nbsp; The other port is shared between a modem, a PalmPilot
cradle and the Wacom PenPartner.&nbsp; I have each of these connected to
an AB switch box.&nbsp; This configuration works just fine but be certain
that the switch box is set to the tablet port before starting your X session.&nbsp;
If you don't then the X server won't see the tablet during initialization
and you won't be able to use it.
<P><B><I>Testing the configuration:&nbsp; xsetpointer and gsumi</I></B>
<P>Ok, you've got your server up and the tablets connected.&nbsp; The first
thing we want to do is make sure the tablet is being seen by the server.&nbsp;
To verify this, run the following command:
<BLOCKQUOTE><TT><FONT SIZE=-1>xsetpointer -l</FONT></TT></BLOCKQUOTE>
The output, if you're configuration is like the one I gave earlier, should
look like this:
<BLOCKQUOTE><TT><FONT SIZE=-1>"pointer"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
[XPointer]</FONT></TT>
<BR><TT><FONT SIZE=-1>"keyboard"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [XKeyboard]</FONT></TT>
<BR><TT><FONT SIZE=-1>"Wacom"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
[XExtensionDevice]</FONT></TT>
<BR><TT><FONT SIZE=-1>"WacomCore"&nbsp;&nbsp;&nbsp;&nbsp; [XExtensionDevice]</FONT></TT>
<BR><TT><FONT SIZE=-1>"ERASER"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
[XExtensionDevice]</FONT></TT>
<BR><TT><FONT SIZE=-1>"EraserCore"&nbsp;&nbsp;&nbsp; [XExtensionDevice]</FONT></TT></BLOCKQUOTE>
If you see the Wacom and Eraser entries then you're all set.&nbsp; If not,
you need to double check that you have your XF86Config file properly set
up and that you have a 3.3.1 or 3.3.2 XFree86 server running and you have
the proper modules loaded (from the XF86Config file).
<P>If all this is in place and looks correct, try moving the pen around
on the tablet.&nbsp; Does the pointer on the screen move too?&nbsp; If
so, you're all set!&nbsp; If not, well, reread the first part of this article
and then check the X Input Howto to see if you might have missed something.
<P>Next we want to try an application with X Input support.&nbsp; The easiest
one to try is gsumi, a simple black and white drawing program from Owen
Taylor.&nbsp; In order to use gsumi you need to first have a version of
the GTK+ libraries installed that include X Input support.&nbsp; If you
don't have these, you can <A HREF="ftp://ftp.gtk.org">grab the source code</A>,
build and install them.&nbsp; This is fairly easy to do so don't let it
frighten you.&nbsp; The INSTALL document that come with the source code
does a decent job of describing the build process, including the one additional
option argument to the configure script that you need:&nbsp; <TT><FONT SIZE=-2>--with-xinput</FONT></TT>.&nbsp;
So, taking the INSTALL information from GTK+ and modifying it, you would
do the following:
<BLOCKQUOTE><TT><FONT SIZE=-1>% gzip -cd gtk+-1.0.5.tar.gz | tar xvf -
# unpack the sources</FONT></TT>
<BR><TT><FONT SIZE=-1>% cd gtk+-1.0.5&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
# change to the toplevel directory</FONT></TT>
<BR><TT><FONT SIZE=-1>% ./configure&nbsp; --with-xinput=xfree&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
# run the `configure' script</FONT></TT>
<BR><TT><FONT SIZE=-1>% make&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
# build GTK</FONT></TT>
<BR><TT><FONT SIZE=-1>[ Become root if necessary ]</FONT></TT>
<BR><TT><FONT SIZE=-1>% make install&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
# install GTK</FONT></TT></BLOCKQUOTE>
After this completes you're ready to build <A HREF="http://www.gimp.org/~otaylor/gsumi/index.html">gsumi</A>.&nbsp;
This is easier to do that GTK+.&nbsp; Just unpack the software and run
the following commands:
<BLOCKQUOTE><TT><FONT SIZE=-1>% configure</FONT></TT>
<BR><TT><FONT SIZE=-1>% make</FONT></TT>
<BR><TT><FONT SIZE=-1>[ Become root if necessary ]</FONT></TT>
<BR><TT><FONT SIZE=-1>% make install</FONT></TT></BLOCKQUOTE>
Now you can actually try an application that uses X Input.&nbsp; Start
gsumi with the command
<BLOCKQUOTE><TT><FONT SIZE=-1>% gsumi</FONT></TT></BLOCKQUOTE>
Figure 1 shows the gsumi interface.
<BR>&nbsp;
<CENTER><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=5 COLS=1 WIDTH="100%" NOSAVE >
<TR NOSAVE>
<TD ALIGN=CENTER NOSAVE><A HREF="./gx/hammel/gsumi-large.jpg"><IMG SRC="./gx/hammel/gsumi-small.jpg" BORDER=0 HEIGHT=320 WIDTH=464></A>
<P><B>Figure 1</B>:&nbsp; The gsumi interface - note the ...</TD>
</TR>
</TABLE></CENTER>
<P>Setting the buttons on the pen to map to mouse buttons is done using
the <B><I><FONT COLOR="#CC6600">xinput</FONT></I></B> program.&nbsp; With
the PenPartner, try
<BLOCKQUOTE><TT><FONT SIZE=-1>% xinput set-button-map Wacom 1 3 2</FONT></TT></BLOCKQUOTE>
This sets the pen button as your right mouse click (assuming a 2 button
mouse) and the eraser as button 3. Making changes like this may affect
how your pen interacts with your applications so you may need to expermiment
with the xinput program till you find a configuration you like.
<P><B><I>Building the Gimp with X Input support</I></B>
<P>Everything seems to be working now, so lets get the Gimp running with
X Input support too.&nbsp; The first you thing you need to know is that,
like gsumi, the Gimp needs to be compiled with a version of the GTK+ libraries
that has X Input enabled.&nbsp; You've already installed an X Input enabled
GTK+ earlier in this article.&nbsp; Now you just need to <A HREF="ftp://ftp.gimp.org">grab
the Gimp sources</A> and recompile them.&nbsp; All of the Gimp plug-ins
also need recompiling.&nbsp; If you downloaded any of the plug-ins on their
own, for example from the <A HREF="http://registry.gimp.org/">Plug-In Registry</A>,
and built them outside of the core Gimp source tree then you'll need to
recompile them individually.&nbsp; If you do end up recompiling any of
the plug-ins by themselves then you need to be certain that their Makefiles
are updated to link with the X Input library using the -lXi option.&nbsp;
Add this right before the -lX11 option (which all plug-in Makefiles are
likely to have).&nbsp; For example, the Curtain plug-in has the following
line in its Makefile:
<BLOCKQUOTE><TT><FONT SIZE=-1>LDADD=-L/usr/X11R6/lib -lgimp -lglib -lm
-lgtk -lgdk -lXext -lX11</FONT></TT></BLOCKQUOTE>
You should modify this to look like the following:
<BLOCKQUOTE><TT><FONT SIZE=-1>LDADD=-L/usr/X11R6/lib -lgimp -lglib -lm
-lgtk -lgdk -lXi -lXext -lX11</FONT></TT></BLOCKQUOTE>
If you don't rebuild the plug-ins they'll crash when you start the Gimp.&nbsp;
All of the plug-ins that are part of the core source distribution will
be rebuilt when you rebuild the core Gimp source.
<P>Once you've rebuilt the Gimp with X Input support you can use the mouse
or tablet to perform the same functions you're probably now very familiar
with in the Gimp.&nbsp; There is one additional feature to the Gimp that
can be added, however.&nbsp; This feature requires <A HREF="http://www.gtk.org/~otaylor/xinput/patch-gimp-xinput.10.gz">an
additional patch</A> and will allow you to make use of an Input Devices
dialog from the Gimp.&nbsp; I wasn't able to get this properly working
before this article had to be submitted so all I can do here is pass on
the information provided by Owen.&nbsp; This information is also provided
by Owen's <A HREF="http://www.gtk.org/~otaylor/xinput/step-by-step.html">step-by-step
instructions</A> for using the Gimp with X Input.
<P>To apply the patch you need to first start with a clean source tree.&nbsp;
Change directories to your Gimp sources and type
<BLOCKQUOTE><TT><FONT SIZE=-1>% make distclean</FONT></TT></BLOCKQUOTE>
Now apply the patch.&nbsp; Here we assume the patch has been saved to your
/tmp directory:
<BLOCKQUOTE><TT><FONT SIZE=-1>% gzip -cd /tmp/patch-gimp-xinput.10.gz |
patch -p1</FONT></TT>
<BR><TT><FONT SIZE=-1>% automake app/Makefile</FONT></TT></BLOCKQUOTE>
If when you downloaded the file using a Netscape browser the file name
was changed to remove the .gz extension, you may still have a gzipped file.&nbsp;
To check this type:
<BLOCKQUOTE><TT><FONT SIZE=-1>% file /tmp/patch-gimp-xinput.10</FONT></TT></BLOCKQUOTE>
If it tells you its a gzipped file then you can still use the two preceeding
lines but leave off the .gz suffix from the patch filename.&nbsp;&nbsp;
If its not a gzipped file anymore then use the following lines instead:
<BLOCKQUOTE><TT><FONT SIZE=-1>% cat /tmp/patch-gimp-xinput.10 | patch -p1</FONT></TT>
<BR><TT><FONT SIZE=-1>% automake app/Makefile</FONT></TT></BLOCKQUOTE>
Then build the Gimp:
<BLOCKQUOTE><TT><FONT SIZE=-1>% make clean</FONT></TT>
<BR><TT><FONT SIZE=-1>% make distclean</FONT></TT>
<BR><TT><FONT SIZE=-1>% configure</FONT></TT>
<BR><TT><FONT SIZE=-1>% make</FONT></TT>
<BR><TT><FONT SIZE=-1>% make install</FONT></TT></BLOCKQUOTE>
Aside from the Input Devices dialog there isn't anything to show you here
in the way of screen shots.&nbsp; The effect of having done all this work
is that you now have a version of both gsumi and Gimp that will respond
to either the mouse or the drawing tablet as input devices.&nbsp; It turns
out this isn't very hard to get working, but it can be a little time sonsuming,
especially if you're not familiar with what should be happening when you've
finished making your XF86Config configuration changes.
<P>You can also apply another optional patch,&nbsp; patch-gimp-nopaintbrush,
but only if the Gimp appears to run very slow after having applied the
first patch, or you don't like the effect you get with the pressure-sensitive
brushes.&nbsp; The pressure-sensitive paintbrush has been improved in the
1.1 version of the Gimp (the developers branch of the source code which
is not meant for public use at this time) but the patch-gimp-xinput.10
file, meant for the 1.0 version of the Gimp, can produce a rather "dotty"
output.
<BR>In general, patch-gimp-nopaintbrush is not a recommended patch - it
just reverses some portions of the main patch for those people who might
need it.
<P>For those of you with either the XFree86 source code or&nbsp; who have
the glibc library installed on your system, Owen has a patch for the Wacom
driver which you can pick up at&nbsp; <A HREF="ftp://ftp.gtk.org/pub/users/otaylor/xf86Wacom-owt-patch">ftp://ftp.gtk.org/pub/users/otaylor/xf86Wacom-owt-patch</A>
(source code) or <A HREF="ftp://ftp.gtk.org/pub/users/otaylor/xf86Wacom-owt-linux-glibc.so.gz">ftp://ftp.gtk.org/pub/users/otaylor/xf86Wacom-owt-linux-glibc.so.gz</A>.&nbsp;&nbsp;&nbsp;
The later file is a binary that just replaces the xf86Wacom.so in the /usr/X11R6/lib/modules/
directory.&nbsp; Make a backup of the old one, as always.&nbsp; It fixes
a number of problems related to button presses and the eraser.&nbsp; For
tablets with two side switches it also modifies the button mapping to,
more sanely, have the second side switch mapped to button 3, not button
4.
<P>Thats about it.&nbsp; The only thing left is to fill you in on a few
of the caveats I ran into while using my tablet with the Gimp.
<P><B><I>Tips on using X Input with the Gimp</I></B>
<P>Using the Gimp with an XFree86 server configured as in this article
doesn't required the use of the gxid daemon.&nbsp; However, you may need
to manually set the pointer with xsetpointer if the server doesn't allow
you to automatically switch between the mouse and tablet.&nbsp; I had this
problem until I got both my XF86Config file and my AB switch box synced
up correctly.
<P>The Suppress option can be increased or decreased to adjust how sensitive
the pointer will be to pen movements.&nbsp; I set mine to 17 and have just
about the same response as my mouse.
<P>Pressing hard on the tablet will get the PenPartner pen to act like
a button 1 mouse click.&nbsp; I don't know if this is the same on other
tablets.&nbsp; This means that when I move the pointer around I can post
menus by pressing hard on the tablet.&nbsp; On the other hand, this doesn't
work all that well in the Image Window to post the Image Window menu when
I have a drawing tool selected.&nbsp; Sometimes the pointer gets stuck
drawing and I have to tap it once to get it to stop.&nbsp; I don't know
if this is an intentional feature or a possible bug, but I couldn't find
a simple way to repeat it at will.
<P>Wacom does not include tilt support in their 4"x5" tablets, including
the PenPartner. Wacom's new Intuos line does include tilt support on the
low end models, but it is not yet clear what the driver situation will
be for those tablets.
<P>When you use the pen to make selections you have to tap or press hard
with the pen to clear the current selection.&nbsp; This doesn't always
work and sometimes you get extremely small, almost pointlike, selections
left in the window.&nbsp; You may have to use CTRL-Shift-Alt to clear the
selection manually.
<P>Be careful about having the pen too close to the pad when you try to
use the mouse.&nbsp; It can confuse the server a bit and make it look like
the mouse is not working properly.
<P>For those who wish to try, the gxid daemon is supposed to allow other
servers to work with gsumi at a minimum.&nbsp; If you use this option you
have to compile GTK+ again, this time setting the with-xinput argument
to "gxi" instead of "xfree".&nbsp; If you do manage to get this working,
drop me a line with the details and I'll post it here in the Muse.
<P><B><I>Where to get help:&nbsp; X Input Resources</I></B>
<P>The first place to start when attempting to configure a tablet with
X Input is the X Input Howto:
<BLOCKQUOTE><A HREF="http://www.gtk.org/~otaylor/xinput/howto/XInput-HOWTO.html">http://www.gtk.org/~otaylor/xinput/howto/XInput-HOWTO.html</A></BLOCKQUOTE>
Owen Taylor maintains this Howto document, along with the gsumi application
and Web site:
<BLOCKQUOTE><A HREF="http://www.gimp.org/~otaylor/gsumi/index.html">http://www.gimp.org/~otaylor/gsumi/index.html
</A>-
GSUMI, an XInput example program</BLOCKQUOTE>
There is an&nbsp; XInput page at XFree86 - <A HREF="http://www.xfree86.org/3.3.2/xinput.html">http://www.xfree86.org/3.3.2/xinput.html</A>,
but its not very helpful.
<P>And of course, the Wacom and Summagraphics Web sites:&nbsp; <A HREF="http://www.wacom.com">www.wacom.com</A>
and <A HREF="http://www.summagraphics.com">www.summagraphics.com</A>, respectively.
<BR>&nbsp;
<BR>&nbsp;
<TABLE WIDTH="100%" >
<TR>
<TD VALIGN=TOP COLSPAN="4" BGCOLOR="#000000" cellpadding="0" cellspacing="0"><IMG SRC="../gx/hammel/cleardot.gif" ALT="indent" ALIGN=LEFT></TD>
</TR>
</TABLE>
<TABLE WIDTH="100%" >
<TR>
<TD ALIGN=RIGHT><FONT SIZE=-2>&copy; 1998 by <A HREF="mailto:mjhammel@csn.net">Michael
J. Hammel</A></FONT></TD>
</TR>
</TABLE>
</BODY>
</HTML>