User avatar
stolk
Posts: 16
Joined: Tue Jan 22, 2013 3:32 am

/dev/input/mouse0 and the scrollwheel

Tue Jan 22, 2013 10:23 pm

Hi,

I've got the reading of mouse buttons and mouse position working, by reading the /dev/input/mouse0 device three bytes at a time (but,dx,dy).

My mouse has a scroll wheel.
How can I read the scroll wheel using /dev/input/mouse0 device?
I am not running X btw, just straight from the console.

Thanks,

Bram Stolk

bbond007
Posts: 73
Joined: Sun Nov 04, 2012 6:10 pm

Re: /dev/input/mouse0 and the scrollwheel

Wed Jan 23, 2013 3:52 am

stolk wrote:Hi,

I've got the reading of mouse buttons and mouse position working, by reading the /dev/input/mouse0 device three bytes at a time (but,dx,dy).

My mouse has a scroll wheel.
How can I read the scroll wheel using /dev/input/mouse0 device?
I am not running X btw, just straight from the console.

Thanks,

Bram Stolk
look at function "handle_mouse"
https://github.com/bbond007/raspytube/b ... bjs.c#L245

here...
https://github.com/bbond007/raspytube/b ... bjs.c#L309

also if you want to see how to get wheel events in Xwindows look at "x_window_loop"

https://github.com/bbond007/raspytube/b ... bjs.c#L547

User avatar
stolk
Posts: 16
Joined: Tue Jan 22, 2013 3:32 am

Re: /dev/input/mouse0 and the scrollwheel

Wed Jan 23, 2013 4:02 am

Thank you,

Reading the source, I understand that I should be using /dev/input/eventX and not /dev/input/mouse0.
And when reading the event, the scrollwheel is under type 2, code 8.

Bram

bbond007
Posts: 73
Joined: Sun Nov 04, 2012 6:10 pm

Re: /dev/input/mouse0 and the scrollwheel

Wed Jan 23, 2013 4:12 am

stolk wrote:Thank you,

Reading the source, I understand that I should be using /dev/input/eventX and not /dev/input/mouse0.
And when reading the event, the scrollwheel is under type 2, code 8.

Bram
yes,

I just realized that you were asking for help with /dev/input/mouse0... and my example uses eventX

my bad :(

I do believe I wrote a program to dump /dev/input/mice and did not see any sort of wheel events at all.

Yes. you can use eventX, but they do move around... event1 might be a keyboard, might be a mouse, might be a gamepad... etc.. that is the challenge, the mouse can move around.

User avatar
jojopi
Posts: 3816
Joined: Tue Oct 11, 2011 8:38 pm

Re: /dev/input/mouse0 and the scrollwheel

Wed Jan 23, 2013 4:36 am

stolk wrote:How can I read the scroll wheel using /dev/input/mouse0 device?
/dev/input/mice emulates a PS/2 mouse. It opens in three-byte mode. To switch it into four-byte intellimouse or intellimouse explorer mode you write the same magic command sequences you would to the real thing:

Code: Select all

static unsigned char mousedev_imps_seq[] = { 0xf3, 200, 0xf3, 100, 0xf3, 80 };
static unsigned char mousedev_imex_seq[] = { 0xf3, 200, 0xf3, 200, 0xf3, 80 };

Return to “C/C++”