Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!ucbvax!hoptoad!tim From: tim@hoptoad.uucp (Tim Maroney) Newsgroups: comp.sys.mac.programmer Subject: Re: Serial interface replacement for mouse Message-ID: <10865@hoptoad.uucp> Date: 20 Mar 90 10:25:50 GMT References: <1990Mar19.001639.28530@caen.engin.umich.edu> Reply-To: tim@hoptoad.UUCP (Tim Maroney) Organization: Eclectic Software, San Francisco Lines: 55 In article <1990Mar19.001639.28530@caen.engin.umich.edu> kleinow@caen.engin.umich.edu (leonard kleinow) writes: >Here's a tricky one. I have a pointing device (a glove) that sends about >a dozen bytes of data through its serial port to the mac indicating its >position in space and the positions of its fingers. I want to be able to >move the cursor with this and use one of its fingers as the mouse button. >I wrote a program to get the data from the modem port, and stuff the >x and y positions in the low-memory cursor positions. If I call this >before WaitNextEvent each time through my main loop, the cursor does in >fact follow the glove around quite nicely. (The routine SetMouse appeared >here some time ago.) Congratulations on finding the only valid use for the routine.... >This is inadequate, however. In order to be useful, I have to be able >to select from menus, hit buttons, etc. Things like ModalDialog, GrowWindow, >TrackControl, MenuSelect, etc., all need "fixing". Fight now, I have to >point the glove at the menubar, then press the mouse button and use the >mouse to select! > >This will require some patch to the system, I think. Is there some >place these above-mentioned traps have in common I can patch? Has >anyone done this already? Interesting project. It should be fairly simple. Presumably, you're using a driver now that either fields a positional interrupt from the glove or polls the glove for positional information. When you get the information, analyze it to see if the thumb is touching the forefinger or whatever you've set up for a mouse button. If it is, then set a flag, otherwise clear the flag (might as well make it your own flag -- there's a system one, but you can patch around it and get better compatibility). If the flag was set and the "button" is "down", then don't do anything else except for your usual position tracking. If the flag was clear and the button is down, post a mouse-down event using PostEvent. If the flag was set and the button is up, then post a mouse-up event. If the flag was clear and the button is up, then again there's nothing to do. The final piece of the solutions to patch Button so that it returns the state of your flag rather than the state of the system flag. The other routines, such as WaitMouseUp, call Button to test the state, so you shouldn't need to patch them as well. If this helps, send me a freebie. :-) -- Tim Maroney, Mac Software Consultant, sun!hoptoad!tim, tim@toad.com "Religion flourishes in greater purity without than with the aid of government." -- James Madison