mouse.h File Reference

Mouse protocol implementation. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

union  _mouse_movt
 Mouse movement packet as sent in streaming mode. 3 bytes. More...
struct  _decoded_movt
 Decoded mouse movement: signed dx and dy, buttons state. More...

Defines

#define _MOUSE_H
#define YOVERFLOW   7
 These are the bits in 1st byte of 3-byte position packet.
#define XOVERFLOW   6
 X counter overflow.
#define YSIGN   5
 Y counter sign.
#define XSIGN   4
 X counter sign.
#define BUTTON3   2
 middle button
#define BUTTON2   1
 right button
#define BUTTON1   0
 left button

Typedefs

typedef union _mouse_movt MouseMovt
 Mouse movement packet as sent in streaming mode. 3 bytes.
typedef struct _decoded_movt DecodedMovt
 Decoded mouse movement: signed dx and dy, buttons state.

Enumerations

enum  _mouse_commands {
  MOUSE_RESET = 0xff, MOUSE_RESEND = 0xfe, MOUSE_SETDEFAULTS = 0xf6, MOUSE_DDR = 0xf5,
  MOUSE_EDR = 0xf4, MOUSE_SSR = 0xf3, MOUSE_GETID = 0xf2, MOUSE_SETREMOTE = 0xf0,
  MOUSE_SETWRAP = 0xee, MOUSE_RESETWRAP = 0xec, MOUSE_READDATA = 0xeb, MOUSE_SETSTREAM = 0xea,
  MOUSE_STATUSRQ = 0xe9, MOUSE_SETRES = 0xe8, MOUSE_SETSCALE21 = 0xe7, MOUSE_SETSCALE11 = 0xe6
}
 Mouse command codes. More...
enum  _mouse_response { MOUSE_ACK = 0xfa, MOUSE_NAK = 0xfe, MOUSE_ERROR = 0xfc, MOUSE_RESETOK = 0xaa }
 Mouse response codes. More...

Functions

uint8_t mouse_boot ()
 Boot mouse, check and return initial button state.
void mouse_setres (uint8_t res)
 Set mouse resolution.


Detailed Description

Mouse protocol implementation.


Define Documentation

#define _MOUSE_H

#define BUTTON1   0

left button

#define BUTTON2   1

right button

#define BUTTON3   2

middle button

#define XOVERFLOW   6

X counter overflow.

#define XSIGN   4

X counter sign.

#define YOVERFLOW   7

These are the bits in 1st byte of 3-byte position packet.

Y counter overflow

#define YSIGN   5

Y counter sign.


Typedef Documentation

typedef struct _decoded_movt DecodedMovt

Decoded mouse movement: signed dx and dy, buttons state.

typedef union _mouse_movt MouseMovt

Mouse movement packet as sent in streaming mode. 3 bytes.


Enumeration Type Documentation

Mouse command codes.

Enumerator:
MOUSE_RESET  reset mouse
MOUSE_RESEND  mouse, wtf?
MOUSE_SETDEFAULTS  set defaults
MOUSE_DDR  disable data reporting
MOUSE_EDR  enable data reporting
MOUSE_SSR  set sample rate: mouse responds ACK, then reads one byte arg
MOUSE_GETID  get device id
MOUSE_SETREMOTE  set remote mode
MOUSE_SETWRAP  set wrap mode
MOUSE_RESETWRAP  switch back to previous (remote or stream) mode
MOUSE_READDATA  request data in remote mode
MOUSE_SETSTREAM  set stream mode (continuous reporting)
MOUSE_STATUSRQ  status request
MOUSE_SETRES  set resolution
MOUSE_SETSCALE21  set scaling 2:1
MOUSE_SETSCALE11  set scaling 1:1
00009                      {
00010     MOUSE_RESET = 0xff,             
00011     MOUSE_RESEND = 0xfe,            
00012     MOUSE_SETDEFAULTS = 0xf6,       
00013     MOUSE_DDR = 0xf5,               
00014     MOUSE_EDR = 0xf4,               
00015     MOUSE_SSR = 0xf3,               
00016     MOUSE_GETID = 0xf2,             
00017     MOUSE_SETREMOTE = 0xf0,         
00018     MOUSE_SETWRAP = 0xee,           
00019     MOUSE_RESETWRAP = 0xec,         
00020     MOUSE_READDATA = 0xeb,          
00021     MOUSE_SETSTREAM = 0xea,         
00022     MOUSE_STATUSRQ = 0xe9,          
00023     MOUSE_SETRES = 0xe8,            
00024     MOUSE_SETSCALE21 = 0xe7,        
00025     MOUSE_SETSCALE11 = 0xe6,        
00026 };

Mouse response codes.

Enumerator:
MOUSE_ACK  agreeable mouse
MOUSE_NAK  disagreeable mouse
MOUSE_ERROR  mouse error
MOUSE_RESETOK  post-reset self test passed
00029                      {
00030     MOUSE_ACK = 0xfa,               
00031     MOUSE_NAK = 0xfe,               
00032     MOUSE_ERROR = 0xfc,             
00033     MOUSE_RESETOK = 0xaa,           
00034 };


Function Documentation

uint8_t mouse_boot (  ) 

Boot mouse, check and return initial button state.

Returns:
initial button status (bits 2,1,0 == left,middle,right)
00086                      {
00087     uint8_t buttons = 0;
00088     
00089     ps2_enable_recv(1);
00090 
00091     for(;;) {
00092         printf_P(PSTR("\nRESET: "));
00093         if (mouse_reset() == 0) {
00094             puts_P(PSTR_OK);
00095             break;
00096         } else {
00097             puts_P(PSTR_ERROR);
00098         }
00099     }
00100 
00101     mouse_command(MOUSE_DDR, 1);
00102     mouse_command(MOUSE_SETSCALE21, 1);
00103     
00104     mouse_command(MOUSE_SETRES, 1);
00105     mouse_command(1,1);             // 0 = 1, 1 = 2, 2 = 4, 3 = 8 counts/mm
00106 
00107     mouse_command(MOUSE_STATUSRQ, 1);
00108     tdelay(22);
00109     if (ps2_avail()) buttons = ps2_getbyte() & 7;
00110     
00111     mouse_flush(22);
00112     
00113     printf_P(PSTR("B:%x\n"), buttons);
00114 
00115     mouse_command(MOUSE_EDR, 1);
00116 
00117     mouse_flush(100);
00118 
00119     printf_P(PSTR("\n"));
00120     
00121     return buttons;    
00122 }

Here is the call graph for this function:

void mouse_setres ( uint8_t  res  ) 

Set mouse resolution.

Parameters:
res resolution code 0: 1 count per mm 1: 2 counts per mm 2: 4 counts per mm 3: 8 counts per mm
00077                                {
00078     mouse_command(MOUSE_DDR,1);
00079     
00080     mouse_command(MOUSE_SETRES, 1);
00081     mouse_command(res, 1);             // 0 = 1, 1 = 2, 2 = 4, 3 = 8 counts/mm
00082     
00083     mouse_command(MOUSE_EDR,1);
00084 }

Here is the call graph for this function:


Generated on Fri Nov 13 04:21:23 2009 for [M]ouse by  doxygen 1.5.9