LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices



Reply
 
Search this Thread
Old 08-19-2004, 08:23 PM   #1
chakkerz
Member
 
Registered: Dec 2002
Location: Brisbane, Australia
Distribution: RedHat (RHEL, FC, CentOS), openSuSE, Mac OS X
Posts: 653

Rep: Reputation: 32
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
 
Old 08-19-2004, 08:48 PM   #2
chakkerz
Member
 
Registered: Dec 2002
Location: Brisbane, Australia
Distribution: RedHat (RHEL, FC, CentOS), openSuSE, Mac OS X
Posts: 653

Original Poster
Rep: Reputation: 32
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.

Last edited by chakkerz; 08-19-2004 at 08:58 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
/dev is a bit empty dive Slackware 11 07-09-2005 01:49 PM
baldurs gate with wine X mouse still appears? breadbin Linux - Software 3 01-21-2005 04:54 PM
HPFS / NTFS problem C: partition appears to be empty thk33 Linux - Software 2 08-11-2004 11:22 AM
Hardrive "appears" empty patske Linux - General 6 04-11-2004 11:29 AM
/dev/ =empty corbintechboy Arch 2 04-06-2004 03:06 PM


All times are GMT -5. The time now is 12:27 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration