Thread: Need to read mouse movement in program

  1. #1
    Unregistered
    Guest

    Need to read mouse movement in program

    I'm working on an interface that uses a mouse board tied into a vehicle speed sensor(VSS) in order to gather data about a car's movement, and need to read this info in my program. I chose the circuitry from a mouse because of its simplicity, my problem is that I need to watch for a change in x or y(depending on where I hook it up) and record the time between the two. I've see several mouse examples, but most only report between 0-79(for each character of an 80-line display) and I need the most precise number I can get(I'm hoping for each individual trigger of the beam) If anyone can point me in the right direction, or can help me out, I'd really appreciate it.

    BTW, in case some of what I'm trying to accomplish seems unclear, the mouse circuitry i'm using is from a serial type that has two large toothed wheels inside that follow the ball, with sensors at the teeth that detect light passing through each tooth. What I'm going to be doing is hooking the VSS in place of that sensor so that each trigger of the VSS would sount as one tooth passing the sensor.


    Thanks for any help!

  2. #2
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    You seem to be getting a little beyond the scope of just plain programming here. You're doing some actually hardare design! Good for you. Java sounds like it would be better suited to this. Inside a function that implements one of Java's Event handling interfaces, use e() to get the coordinates of the mouse.

  3. #3
    Unregistered
    Guest
    Ok, now I've figured out the mouse part, but I need a little data help. The program's collecting the amount of mouse movement and storing it every 1mS, it's so small because it needs to be VERY accurate. The problem is that I'm affraid an array growing that large is going to cause problems. I'm looking at a max of 30 seconds so is an array of 30,000 structs going to cause any problems? I haven't developed it enough to test to see. If not, I might be able to write it to a file, but that's another fear because I want to make sure the writing to disk isn't going to cause any innacuracy. If it were to be writing to disk, they'd be very small entries, most likely a one or two digit number per mS.
    Does this seem like the best method, or is there a better one?

  4. #4
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Depends on how large your structs are. If they are only tracking two values - x,y then this should not be a problem.

    The only way that I know of to save space introduces some inaccuracies into the mix. You could only sample the rate at certain intervals and linear interpolate between the two values to find the interim values. But, again, you would only be detecting the values that should have been there, not the ones that really are or were. If your board has enough onboard RAM to hold the structs in memory then that is what you will probably have to do. This method would not conserve any space, either.

    To save space though, dump the struct. Depending on what the min and max for each value are, you could compress each value into a single WORD or DWORD. For instance you could place x high and y low or vice versa. Then you would only be storing WORDS (or DWORDS - depending on what you need) in memory, but those WORDs would represent two values.


    DWORD value=(x<<16)+y

    or

    WORD value=(x<<8)+y

  5. #5
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Sorry for the contradiction. The first method does not save space. It would merely change the sampling rate. But when you interpolated to get the interim values you would have just as much data as your method. Probably not a good idea.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. (Windows) Send keyboard and mouse to another program?
    By Chrisname in forum Windows Programming
    Replies: 4
    Last Post: 06-13-2009, 06:13 PM
  2. Simulating mouse movement in other windows
    By Wiretron in forum Windows Programming
    Replies: 11
    Last Post: 10-13-2007, 08:11 AM
  3. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  4. my program wont read vector array
    By MKashlev in forum C++ Programming
    Replies: 5
    Last Post: 08-10-2002, 03:51 PM