How to control the mouse in Linux

This forum is for users of Microchip MPUs and who are interested in using Linux OS.

Moderator: nferre

MWeston
Posts: 45
Joined: Sun Jun 13, 2004 4:20 am

How to control the mouse in Linux

Thu Jan 05, 2006 10:53 pm

I can't seem to find specific information on how to control the mouse (PS2, not serial) in an embedded Linux system. I am using a 2.4.20 kernel on a small system and I want to write a program that runs from the console. The program needs to control the frame buffer and the mouse so the user can click on things on the screen. The frame buffer stuff is easy, of course, but I am not sure how I can control the mouse/buttons (and probably the keyboard too, later on).

I think /dev/mouse will return raw data from the mouse? Or is it packetized in some easy to parse format? Anyone have some basic code they can share or weblinks they can post? Thanks!


Michael
klama
Posts: 14
Joined: Wed Mar 02, 2005 3:21 pm

Re: How to control the mouse in Linux

Wed Jan 11, 2006 9:16 am

Hi Michael,

the /dev/mouse node usually is a link which points to the actual mouse device. The data you get is in raw format. I would suggest you write a simple mini program which hex dumps the input from /dev/mouse to your console. To help interpret the bytes you receive, you might start looking here:

http://www.microsoft.com/whdc/device/in ... wheel.mspx

or download this:

http://innovexpo.itee.uq.edu.au/1999/th ... thesis.PDF

These are just 2 of 298000 hits you will get when you search for "ps2 mouse data format" using http://www.hotbot.com

Best regards,

Markus.
liftboy
Posts: 17
Joined: Sun Dec 11, 2005 1:17 am

Re: How to control the mouse in Linux

Wed Jan 11, 2006 9:52 pm

MWeston wrote:I can't seem to find specific information on how to control the mouse (PS2, not serial) in an embedded Linux system.
i think the best you can do is use gpm. if your kernel has ps/2 driver it's device node is /dev/psaux or /dev/misc/psaux (it's character device with major/minor 10/1)
MWeston
Posts: 45
Joined: Sun Jun 13, 2004 4:20 am

Re: How to control the mouse in Linux

Wed Jan 11, 2006 11:49 pm

klama wrote:Hi Michael,

the /dev/mouse node usually is a link which points to the actual mouse device. The data you get is in raw format. I would suggest you write a simple mini program which hex dumps the input from /dev/mouse to your console. To help interpret the bytes you receive, you might start looking here:

http://www.microsoft.com/whdc/device/in ... wheel.mspx

or download this:

http://innovexpo.itee.uq.edu.au/1999/th ... thesis.PDF

These are just 2 of 298000 hits you will get when you search for "ps2 mouse data format" using http://www.hotbot.com

Best regards,

Markus.
Hi Klama, I have been checking out what comes out of the mouse and I have seen the PS2 format documentation, but the beauty of Linux, and the reason people use it, is for its vast list of drivers that save us from all that hassle! My mouse is /dev/psaux and I can dump its output to the terminal and see the cursor moving back and forth and writing characters so I can see that it does output what looks like nice little packets of information. :)

I have since found info and source for gpm, but I am still trying to figure out how I can use it. I need the most basic of features (Xdiff,Ydiff and button presses). It looks like you can run it from the console, but I need to access it from my program. I'm sure that is possible, I just don't know what it takes yet. I'm not afraid to admit that I am a Linux novice and that is why I welcome any help anyone can give.
liftboy
Posts: 17
Joined: Sun Dec 11, 2005 1:17 am

Thu Jan 12, 2006 12:16 am

c'mon. don't tell me you were so lazy you didn't follow link from gpm page pointing to http://users.tkk.fi/~then/mytexts/mouse.html
MWeston
Posts: 45
Joined: Sun Jun 13, 2004 4:20 am

Thu Jan 12, 2006 3:28 am

Actually, I downloaded the gpm source from somewhere else and had no idea that link existed until today.

My problem is still concerned with missing information by not polling often enough (and I have never used interrupts) and I don't know if there is a buffering scheme with the /dev/psaux char device. That is why I was hoping Linux had some great way of managing all of this.

Thanks for the link, by the way. I appreciate it greatly.
liftboy
Posts: 17
Joined: Sun Dec 11, 2005 1:17 am

Thu Jan 12, 2006 10:46 pm

but what do you want interrupts for? just frequently read /dev/psaux in the main loop of your program. leave interrupts and other nasty ;) things to kernel.

Return to “LINUX”

Who is online

Users browsing this forum: No registered users and 3 guests