URN Logo
UNIX Resources » Linux » Linux Forum » Linux Discussions » Page.88 » function to read /dev/input/mouse0 ?
announcement The content of this page is collected from Linux Forum, All copyrights and other associated rights are reserved by the original authors of the articles.
Resources
China Linux Forum(finished)
Linux Forum(finished)
FreeBSD China(finished)
linuxforum.com
  LinuxForum General Chat
  Linux Advocacy
  LinuxForum Polls
  Introductions
  Linux Kernel Support
  Patch Management
  Development Release
  Linux Programming
  Linux Security
  Linux Software
  Linux Hardware Problems
    Linux Video Problems
    Linux Sound Problems
  Linux Networking Support
  Linux Printing Support
  Linux Human Interface Devices Support
  Linux Data Storage Support
  Linux Applications Support
  Linux Installation Support
  Linux Laptops Support
  Linux Motherboard, Chipsets, CPU, Memory
  Miscellaneous
  Debian Linux Support
  Ubuntu Linux Support
  LiveCD Discussions
  Gentoo Linux Support
  Mandrake Linux Support
  Redhat / Fedora Linux Support
  Slackware Linux Support
  SuSE Linux Support
  CentOS Linux Support
  Linux Web Servers
  Linux DNS Servers
  Linux Database Servers
  Linux Email Servers
  Linux FTP Servers
  Linux Squid Proxy Server
  Linux Samba Help
  Linux cPanel Help
  Linux Ensim Help
  Linux Plesk Help
  Linux Webmin / Usermin Help
  Qmail Toaster Help
  Linux Games
  Windows Game Emulation
  Linux Discussions
  General Linux Discussions
  Red Hat Linux Discussions
  More Red Hat Linux Discussions
  Mandrake Linux Discussions
  Slackware Linux Discussions
  SuSE Linux Discussions
  Debian Discussions
  Samba Help
  Linux Security
  Linux Networking
  Gentoo Help
  Operating System Rant Forum
  Hardware Rants
   
function to read /dev/input/mouse0 ?
Subject: function to read /dev/input/mouse0 ?
Author: Dennis G    Posted: 2004-08-16 06:48:56    Length: 358 byte(s)
[Original] [Print] [Top]
Hi,

I would like to read in the bits of /dev/input/mouse0 with a function
under c++. Any Ideas ?

I already tried to search in the gpm-source, but yet I didn't find the
answer for my problem...

I am using Fedora Core 1, but I think the problem is
distribution-independent.

TIA, Dennis !

[Original] [Print] [Top]
Subject: function to read /dev/input/mouse0 ?
Author: Lew Pitcher    Posted: 2004-08-16 07:23:22    Length: 1,342 byte(s)
[Original] [Print] [Top]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Dennis G wrote:
QUOTE
Hi,

I would like to read in the bits of /dev/input/mouse0 with a function
under c++. Any Ideas ?

In general, you would open and read /dev/input/mouse0 just like you would open
and read /etc/fstab or /var/log/messages. As far as your program is concerned,
/dev/input/mouse0 is just another file.

You will likely need to interpret the data you read from the file. It's going to
be in binary byte values (rather than printable characters), and will need some
programmatic interpretation to determine the mouse activities, but that's a
different question.


- --
Lew Pitcher
IT Consultant, Enterprise Application Architecture,
Enterprise Technology Solutions, TD Bank Financial Group

(Opinions expressed are my own, not my employers')
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)

iD8DBQFBILVIagVFX4UWr64RAhVaAKCkRwbUtio26G0iHAI318WBVhLKgQCgpCeA
Bj8sVfHV86y1yEJzngliCJU=
=Dn83
-----END PGP SIGNATURE-----

[Original] [Print] [Top]
Subject: function to read /dev/input/mouse0 ?
Author: Peter Jensen    Posted: 2004-08-16 09:31:34    Length: 2,245 byte(s)
[Original] [Print] [Top]
Lew Pitcher wrote:

QUOTE
You will likely need to interpret the data you read from the file.
It's going to be in binary byte values (rather than printable
characters), and will need some programmatic interpretation to
determine the mouse activities, but that's a different question.

It also depends on the mouse protocol used ... Take for instance the
IMPS/2 protocol in its most basic form.  It uses three bytes pr sample
and it is fairly trivial to reverse-engineer it from a 'xxd -c 3 -g 3
/dev/input/mouse0'.  Here's a quick run-down:

High 4 bits of first byte describes the movement direction.  These can
be OR'ed to describe movement in both directions over one sample:

0000 No movement, movement up, or movement right
0001 Movement left
0010 Movement down

The low 4 bits describe the button that is pressed:

1000 No button pressed (also when button released)
1001 Left mouse button pressed
1010 Right button pressed
1100 Middle button pressed

These can be OR'ed to describe pressing multiple buttons.

The second byte describes the sideways movement over the last sample.
When moving right it's the direct number of mouse tics moved, when
moving left it's the negative number of mouse tics moved in twos
complement format.

The third byte describes the vertical movement over the last sample.
When moving up it's the direct number of mouse tics moved, when moving
down it's the negative number of mouse tics moved in twos complement
format.

And this was from just studying the output for 5 minutes :-)

There may also be some communication going the other way to configure
the mouse, I don't know ... For that you need to dig up some official
specifications ...

--
PeKaJe

I hope you millionaires are having fun!  I just invested half your life
savings in yeast!!

[Original] [Print] [Top]
« Previous thread
Trying to open port 2121
Linux Discussions
Page. 88
Next thread »
survey: runlevel 3 or 5?
     

Copyright © 2007 UNIX Resources Network, All Rights Reserved.      About URN | Privacy & Legal | Help | Contact us
Powered by FreeBSD    webmaster: webmaster@unixresources.net
This page created on 2007-08-01 12:11:50, cost 0.023191213607788 ms.