]> git.donarmstrong.com Git - qmk_firmware.git/blob - tmk_core/protocol/ps2_mouse.h
Added back PS2_MOUSE_INIT_DELAY define
[qmk_firmware.git] / tmk_core / protocol / ps2_mouse.h
1 /*
2 Copyright 2011 Jun Wako <wakojun@gmail.com>
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #ifndef PS2_MOUSE_H
19 #define  PS2_MOUSE_H
20
21 #include <stdbool.h>
22
23 /*
24  * Data format:
25  * byte|7       6       5       4       3       2       1       0
26  * ----+----------------------------------------------------------------
27  *    0|[Yovflw][Xovflw][Ysign ][Xsign ][ 1    ][Middle][Right ][Left  ]
28  *    1|[                    X movement(0-255)                         ]
29  *    2|[                    Y movement(0-255)                         ]
30  */
31 #define PS2_MOUSE_BTN_MASK      0x07
32 #define PS2_MOUSE_BTN_LEFT      0
33 #define PS2_MOUSE_BTN_RIGHT     1
34 #define PS2_MOUSE_BTN_MIDDLE    2
35 #define PS2_MOUSE_X_SIGN        4
36 #define PS2_MOUSE_Y_SIGN        5
37 #define PS2_MOUSE_X_OVFLW       6
38 #define PS2_MOUSE_Y_OVFLW       7
39
40 /* mouse button to start scrolling; set 0 to disable scroll */
41 #ifndef PS2_MOUSE_SCROLL_BTN_MASK
42 #define PS2_MOUSE_SCROLL_BTN_MASK       (1<<PS2_MOUSE_BTN_MIDDLE)
43 #endif
44 /* send button event when button is released within this value(ms); set 0 to disable  */
45 #ifndef PS2_MOUSE_SCROLL_BTN_SEND
46 #define PS2_MOUSE_SCROLL_BTN_SEND       300
47 #endif
48 /* divide virtical and horizontal mouse move by this to convert to scroll move */
49 #ifndef PS2_MOUSE_SCROLL_DIVISOR_V
50 #define PS2_MOUSE_SCROLL_DIVISOR_V      2
51 #endif
52 #ifndef PS2_MOUSE_SCROLL_DIVISOR_H
53 #define PS2_MOUSE_SCROLL_DIVISOR_H      2
54 #endif
55 /* multiply reported mouse values by these */
56 #ifndef PS2_MOUSE_X_MULTIPLIER
57 #define PS2_MOUSE_X_MULTIPLIER          1
58 #endif
59 #ifndef PS2_MOUSE_Y_MULTIPLIER
60 #define PS2_MOUSE_Y_MULTIPLIER          1
61 #endif
62 #ifndef PS2_MOUSE_V_MULTIPLIER
63 #define PS2_MOUSE_V_MULTIPLIER          1
64 #endif
65 /* For some mice this will need to be 0x0F */
66 #ifndef PS2_MOUSE_SCROLL_MASK       
67 #define PS2_MOUSE_SCROLL_MASK           0xFF 
68 #endif
69 #ifndef PS2_MOUSE_INIT_DELAY
70 #define PS2_MOUSE_INIT_DELAY            1000
71 #endif
72
73 enum ps2_mouse_command_e {
74     PS2_MOUSE_RESET = 0xFF,
75     PS2_MOUSE_RESEND = 0xFE,
76     PS2_MOSUE_SET_DEFAULTS = 0xF6,
77     PS2_MOUSE_DISABLE_DATA_REPORTING = 0xF5,
78     PS2_MOUSE_ENABLE_DATA_REPORTING = 0xF4,
79     PS2_MOUSE_SET_SAMPLE_RATE = 0xF3,
80     PS2_MOUSE_GET_DEVICE_ID = 0xF2,
81     PS2_MOUSE_SET_REMOTE_MODE = 0xF0,
82     PS2_MOUSE_SET_WRAP_MODE = 0xEC,
83     PS2_MOUSE_READ_DATA = 0xEB,
84     PS2_MOUSE_SET_STREAM_MODE = 0xEA,
85     PS2_MOUSE_STATUS_REQUEST = 0xE9,
86     PS2_MOUSE_SET_RESOLUTION = 0xE8,
87     PS2_MOUSE_SET_SCALING_2_1 = 0xE7,
88     PS2_MOUSE_SET_SCALING_1_1 = 0xE6,
89 };
90
91 typedef enum ps2_mouse_resolution_e {
92     PS2_MOUSE_1_COUNT_MM,
93     PS2_MOUSE_2_COUNT_MM,
94     PS2_MOUSE_4_COUNT_MM,
95     PS2_MOUSE_8_COUNT_MM,   
96 } ps2_mouse_resolution_t;
97
98 typedef enum ps2_mouse_sample_rate_e {
99     PS2_MOUSE_10_SAMPLES_SEC = 10,
100     PS2_MOUSE_20_SAMPLES_SEC = 20,
101     PS2_MOUSE_40_SAMPLES_SEC = 40,
102     PS2_MOUSE_60_SAMPLES_SEC = 60,
103     PS2_MOUSE_80_SAMPLES_SEC = 80,
104     PS2_MOUSE_100_SAMPLES_SEC = 100,
105     PS2_MOUSE_200_SAMPLES_SEC = 200,
106 } ps2_mouse_sample_rate_t;
107
108 void ps2_mouse_init(void);
109
110 void ps2_mouse_task(void);
111
112 void ps2_mouse_disable_data_reporting(void);
113
114 void ps2_mouse_enable_data_reporting(void);
115
116 void ps2_mouse_set_remote_mode(void);
117
118 void ps2_mouse_set_stream_mode(void);
119
120 void ps2_mouse_set_scaling_2_1(void);
121
122 void ps2_mouse_set_scaling_1_1(void);
123
124 void ps2_mouse_set_resolution(ps2_mouse_resolution_t resolution);
125
126 void ps2_mouse_set_sample_rate(ps2_mouse_sample_rate_t sample_rate);
127
128 #endif