Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!zaphod.mps.ohio-state.edu!swrinde!elroy.jpl.nasa.gov!decwrl!pa.dec.com!nntpd.lkg.dec.com!engage!3d.enet.dec.com!davis From: davis@3d.enet.dec.com (Peter Davis) Newsgroups: comp.windows.x Subject: Re: How to simulate mouse events from a data tablet Message-ID: <1991May29.150652.20665@engage.pko.dec.com> Date: 29 May 91 14:57:02 GMT Sender: newsdaemon@engage.pko.dec.com (USENET News Daemon) Distribution: usa Organization: Digital Equipment Corporation Lines: 49 In article <64370@bbn.BBN.COM>, schroder@bbn.com (Ken Schroder) writes... >I'm trying to integrate a data tablet with the mouse using X11R4. >I'd like the cursor to move whenever I move either the mouse of the >cursor/pen on the tablet. I'd like X clients to receive a button >event whenever a button on either the mouse or tablet is pressed >or released. Has anyone already done this? > >I've found that using XWarpPointer works fine to drive the pointer >from the tablet. The problem is getting a suitable value for the >window pointer passed in the event structure to XSendEvent. Does >anyone know the correct value so the server will map screen (x,y) >to window and window relative (x,y)? > Gee, I'm trying to do almost this exact thing. I'm looking at a whole bunch of input devices, and I want to be able to simulate mouse movements by sending events, and then send any additional data that the devices can input via the ClientMessage mechanism. To do motion, I found I had to: 1 XQueryPointer to get the current position, 2 find the lowest offspring of the pointer window which still contains the pointer position, 3 XTranslateCoordinates to get the coordinates relative to that offspring, 4 XSendEvent to send a motion event to that window, 5 XGrabPointer 6 XWarpPointer 7 XUngrabPointer 8 XQueryPointer to see if the pointer window has changed. If it has, repeat steps 2, 3, and 4 for the new window. To do button transitions, I had to: 1 XQueryPointer to get the current position, window, etc. 2 find the lowest offspring of the pointer window which still contains the pointer position, 3 XTranslateCoordinates to get the x, y in the coordinates of that offspring window, 4 Figure out what the button/key mask should be, and 5 XSendEvent to send the button event to that window. I still don't have this completely working, so I won't vouch for the completeness of the above procedures. If anyone has any improvements or suggestions, I'd be glad to hear 'em. Thanks. -pd