Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!helios!bcm!dimacs.rutgers.edu!rutgers!modus!simm!yachaya!oliver!newsuser From: newsuser@oliver.SUBLINK.ORG (Ugo Cei) Newsgroups: comp.windows.x Subject: Re: Using tablets in X (Was: Re: Moving pointer in software ?) Message-ID: <919@oliver.SUBLINK.ORG> Date: 21 Mar 91 21:38:45 GMT References: <9103131557.AA10051@devnull.Eng.Sun.COM> <1165@dandelion.CI.COM> <1991Mar18.170530.13580@dsd.es.com> <1276@attc.UUCP> Organization: Oliver, Pavia, Italy Lines: 51 marbru@attc.UUCP (Martin Brunecky) writes: >In article <1991Mar18.170530.13580@dsd.es.com> rthomson@dsd.es.com (Rich Thomson) writes: >>In article <1165@dandelion.CI.COM> >> dale@jack.ci.com (Dale Gallaher) writes: >>> Has anyone implemented applications which use tablet input instead >>> of the mouse. We have a CAD package where many uses prefer using >>> a tablet but I have never seen anyone discuss using tablets in X. >> >>The X input extension allows input from a wide variety of devices. >>However, the support for the input extension must be built into the >>server (including driving the devices). It is not plug-and-play in >>that respect. >> > We have taken a slightly different approach. Since we want to treate > the digitizer suface similarly to the screen, i.e. lay windows on the > top of it, get enter/leave/button/motion events etc., we decided > to strip-down (lobotomize) the MIT X Server. You could also use a much more simple-minded approach: warp the pointer when the stylus or the mouse on the digitizer moves. You could create a program which reads the stylus position and outputs a couple of coordinates whenever the position changes. Your application has to open a connection to this program (e.g. using popen) and make the server listen to it (via XtAddInput). I've tried this and it worked, even though movement of the pointer either lagged behind the actual movement of the stylus (too many coordinates being input) or the movement wasn't smooth enough when I tried to output them less frequently. Eventually, I obtained satisfying performance by disposing entirely of XtAddInput and warping the pointer from the program connected to the digitizer, like this: while(forever) { read coordinates from digitizer if(they have changed) warp pointer to the new location } You also need to generate fake ButtonPress/Release events (via XSendEvent) when the user presses/releases the stylus or mouse button(s). If you send these events to the root window instead of your application's main window, you can control the entire X session using the digitizer, but beware that many applications require a three button mouse to work properly and even some key+button combinations. Also, when you stop moving the digitizer, you regain control of the pointer through the mouse. -- **************** | Ugo Cei | SUBLINK: newsuser@oliver.sublink.org * OLIVER * | Via Colombo 7 | INTERNET: cei@ipvvis.unipv.it **************** | 27100 Pavia ITALY | "Real Programs Dump Core"