LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (https://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   Java - Reading /dev/mouse - appears to be empty (https://www.linuxquestions.org/questions/linux-hardware-18/java-reading-dev-mouse-appears-to-be-empty-219917/)

chakkerz 08-19-2004 07:23 PM

Java - Reading /dev/mouse - appears to be empty
 
Hi

i'm running a little piping thing:

/dev/mouse > /home/chakkerz/mousetest

which gives me stacks of data :) ... short of sitting down and trying to interpret all of it ... is there a table / listing of what the data (interpreted atm into int by a java program) means?

What i actually need to find are left and right clicks (and double left clicks, but i figure that should be two left clicks in quick succession).

Also i've observed that clicks appear to be tabs and enters by looking at the dumb (cat /dev/mouse) but when i spew out what the java program finds, it looks like it's more complex which implies to me that it records down and up for each button. (seems logical, how else would the puter know the state of the buttons) and i've seen something similar on the console (backspace for release??)

If anyone could point me in the right direction or tell me the four values i seek (or more if more are related to the button states) i'd be grateful.

PS mousewheel as well so that's 8 signals i think need

Thanks

chakkerz 08-19-2004 07:48 PM

OK

Make that "anyone know how to interpret the mouse wheel scrolling direction?"

here are the ways i got the clicks and so forth, as well as below that the actual identified values:


first clear the mouse stream (ie delete the file you've been piping /dev/mouse to)
cat /dev/mouse > /home/chakkerz/mousetest

(obviously /home/chakkerz/mousetest would be replaced by what you've got)
permissions for access to /dev/mouse and the subsequent /dev/psaux (or whatever) are also important, but i haven't solidified the reqs for that for myself yet.

//code *save as MouseClicker.java*

import java.io.*;

public class MouseClicker
{
public static void main(String args[])
{
String MOUSE_STREAM = "/home/chakkerz/mousetest";
BufferedInputStream bis;

try
{
bis = new BufferedInputStream(new FileInputStream(new File (MOUSE_STREAM)));

while (true)
{
try
{
int input = bis.read();
if (input != -1)
System.out.println("" + input);
}
catch (IOException iox)
{
iox.printStackTrace();
}
}
}
catch (FileNotFoundException fnfx)
{
fnfx.printStackTrace();
}
}
}

recorded values:

9 0 0 = left button down
10 0 0 = right button down
12 0 0 = center / mousewheel button down

800 = button up and scrolling

NOW
if left is released while right is held, left release = 10 0 0
if right is release while left is held, right release = 9 0 0
if scrolling while one or more button is depressed the scroll indicator is the same as the button's depress signal:
if left is held (a 9 0 0 signal) scrolling = 9 0 0
if right is held (a 10 0 0 signal) scrolling = 10 0 0
if left then right are held, scrolling = 11 0 0

the reason i feel like a dunce is - i had written that program already, and instead of looking the generic output and trying it (which i did just now), i made the mental leap of "i can't do anything with the output because the program doesn't interpret it yet". the brain can process ... think boy think :P

OK thanks anyway, i hope this helps someone else if they want to interpret the /dev/mouse or /dev/psaux stream ... should be google able :) later this week anyway

Incidentally if anyone knows how to get the actually scrolling direction out of this, that'd be grand.


All times are GMT -5. The time now is 11:20 PM.