diff options
Diffstat (limited to 'tmk_core/protocol/ps2_mouse.h')
-rw-r--r-- | tmk_core/protocol/ps2_mouse.h | 177 |
1 files changed, 0 insertions, 177 deletions
diff --git a/tmk_core/protocol/ps2_mouse.h b/tmk_core/protocol/ps2_mouse.h deleted file mode 100644 index c97c6c893..000000000 --- a/tmk_core/protocol/ps2_mouse.h +++ /dev/null | |||
@@ -1,177 +0,0 @@ | |||
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 | #pragma once | ||
19 | |||
20 | #include <stdbool.h> | ||
21 | #include "debug.h" | ||
22 | #include "report.h" | ||
23 | |||
24 | #define PS2_MOUSE_SEND(command, message) \ | ||
25 | do { \ | ||
26 | __attribute__((unused)) uint8_t rcv = ps2_host_send(command); \ | ||
27 | if (debug_mouse) { \ | ||
28 | print((message)); \ | ||
29 | xprintf(" command: %X, result: %X, error: %X \n", command, rcv, ps2_error); \ | ||
30 | } \ | ||
31 | } while (0) | ||
32 | |||
33 | #define PS2_MOUSE_SEND_SAFE(command, message) \ | ||
34 | do { \ | ||
35 | if (PS2_MOUSE_STREAM_MODE == ps2_mouse_mode) { \ | ||
36 | ps2_mouse_disable_data_reporting(); \ | ||
37 | } \ | ||
38 | PS2_MOUSE_SEND(command, message); \ | ||
39 | if (PS2_MOUSE_STREAM_MODE == ps2_mouse_mode) { \ | ||
40 | ps2_mouse_enable_data_reporting(); \ | ||
41 | } \ | ||
42 | } while (0) | ||
43 | |||
44 | #define PS2_MOUSE_SET_SAFE(command, value, message) \ | ||
45 | do { \ | ||
46 | if (PS2_MOUSE_STREAM_MODE == ps2_mouse_mode) { \ | ||
47 | ps2_mouse_disable_data_reporting(); \ | ||
48 | } \ | ||
49 | PS2_MOUSE_SEND(command, message); \ | ||
50 | PS2_MOUSE_SEND(value, "Sending value"); \ | ||
51 | if (PS2_MOUSE_STREAM_MODE == ps2_mouse_mode) { \ | ||
52 | ps2_mouse_enable_data_reporting(); \ | ||
53 | } \ | ||
54 | } while (0) | ||
55 | |||
56 | #define PS2_MOUSE_RECEIVE(message) \ | ||
57 | do { \ | ||
58 | __attribute__((unused)) uint8_t rcv = ps2_host_recv_response(); \ | ||
59 | if (debug_mouse) { \ | ||
60 | print((message)); \ | ||
61 | xprintf(" result: %X, error: %X \n", rcv, ps2_error); \ | ||
62 | } \ | ||
63 | } while (0) | ||
64 | |||
65 | __attribute__((unused)) static enum ps2_mouse_mode_e { | ||
66 | PS2_MOUSE_STREAM_MODE, | ||
67 | PS2_MOUSE_REMOTE_MODE, | ||
68 | } ps2_mouse_mode = PS2_MOUSE_STREAM_MODE; | ||
69 | |||
70 | /* | ||
71 | * Data format: | ||
72 | * byte|7 6 5 4 3 2 1 0 | ||
73 | * ----+---------------------------------------------------------------- | ||
74 | * 0|[Yovflw][Xovflw][Ysign ][Xsign ][ 1 ][Middle][Right ][Left ] | ||
75 | * 1|[ X movement(0-255) ] | ||
76 | * 2|[ Y movement(0-255) ] | ||
77 | */ | ||
78 | #define PS2_MOUSE_BTN_MASK 0x07 | ||
79 | #define PS2_MOUSE_BTN_LEFT 0 | ||
80 | #define PS2_MOUSE_BTN_RIGHT 1 | ||
81 | #define PS2_MOUSE_BTN_MIDDLE 2 | ||
82 | #define PS2_MOUSE_X_SIGN 4 | ||
83 | #define PS2_MOUSE_Y_SIGN 5 | ||
84 | #define PS2_MOUSE_X_OVFLW 6 | ||
85 | #define PS2_MOUSE_Y_OVFLW 7 | ||
86 | |||
87 | /* mouse button to start scrolling; set 0 to disable scroll */ | ||
88 | #ifndef PS2_MOUSE_SCROLL_BTN_MASK | ||
89 | # define PS2_MOUSE_SCROLL_BTN_MASK (1 << PS2_MOUSE_BTN_MIDDLE) | ||
90 | #endif | ||
91 | /* send button event when button is released within this value(ms); set 0 to disable */ | ||
92 | #ifndef PS2_MOUSE_SCROLL_BTN_SEND | ||
93 | # define PS2_MOUSE_SCROLL_BTN_SEND 300 | ||
94 | #endif | ||
95 | /* divide virtical and horizontal mouse move by this to convert to scroll move */ | ||
96 | #ifndef PS2_MOUSE_SCROLL_DIVISOR_V | ||
97 | # define PS2_MOUSE_SCROLL_DIVISOR_V 2 | ||
98 | #endif | ||
99 | #ifndef PS2_MOUSE_SCROLL_DIVISOR_H | ||
100 | # define PS2_MOUSE_SCROLL_DIVISOR_H 2 | ||
101 | #endif | ||
102 | /* multiply reported mouse values by these */ | ||
103 | #ifndef PS2_MOUSE_X_MULTIPLIER | ||
104 | # define PS2_MOUSE_X_MULTIPLIER 1 | ||
105 | #endif | ||
106 | #ifndef PS2_MOUSE_Y_MULTIPLIER | ||
107 | # define PS2_MOUSE_Y_MULTIPLIER 1 | ||
108 | #endif | ||
109 | #ifndef PS2_MOUSE_V_MULTIPLIER | ||
110 | # define PS2_MOUSE_V_MULTIPLIER 1 | ||
111 | #endif | ||
112 | /* For some mice this will need to be 0x0F */ | ||
113 | #ifndef PS2_MOUSE_SCROLL_MASK | ||
114 | # define PS2_MOUSE_SCROLL_MASK 0xFF | ||
115 | #endif | ||
116 | #ifndef PS2_MOUSE_INIT_DELAY | ||
117 | # define PS2_MOUSE_INIT_DELAY 1000 | ||
118 | #endif | ||
119 | |||
120 | enum ps2_mouse_command_e { | ||
121 | PS2_MOUSE_RESET = 0xFF, | ||
122 | PS2_MOUSE_RESEND = 0xFE, | ||
123 | PS2_MOSUE_SET_DEFAULTS = 0xF6, | ||
124 | PS2_MOUSE_DISABLE_DATA_REPORTING = 0xF5, | ||
125 | PS2_MOUSE_ENABLE_DATA_REPORTING = 0xF4, | ||
126 | PS2_MOUSE_SET_SAMPLE_RATE = 0xF3, | ||
127 | PS2_MOUSE_GET_DEVICE_ID = 0xF2, | ||
128 | PS2_MOUSE_SET_REMOTE_MODE = 0xF0, | ||
129 | PS2_MOUSE_SET_WRAP_MODE = 0xEC, | ||
130 | PS2_MOUSE_READ_DATA = 0xEB, | ||
131 | PS2_MOUSE_SET_STREAM_MODE = 0xEA, | ||
132 | PS2_MOUSE_STATUS_REQUEST = 0xE9, | ||
133 | PS2_MOUSE_SET_RESOLUTION = 0xE8, | ||
134 | PS2_MOUSE_SET_SCALING_2_1 = 0xE7, | ||
135 | PS2_MOUSE_SET_SCALING_1_1 = 0xE6, | ||
136 | }; | ||
137 | |||
138 | typedef enum ps2_mouse_resolution_e { | ||
139 | PS2_MOUSE_1_COUNT_MM, | ||
140 | PS2_MOUSE_2_COUNT_MM, | ||
141 | PS2_MOUSE_4_COUNT_MM, | ||
142 | PS2_MOUSE_8_COUNT_MM, | ||
143 | } ps2_mouse_resolution_t; | ||
144 | |||
145 | typedef enum ps2_mouse_sample_rate_e { | ||
146 | PS2_MOUSE_10_SAMPLES_SEC = 10, | ||
147 | PS2_MOUSE_20_SAMPLES_SEC = 20, | ||
148 | PS2_MOUSE_40_SAMPLES_SEC = 40, | ||
149 | PS2_MOUSE_60_SAMPLES_SEC = 60, | ||
150 | PS2_MOUSE_80_SAMPLES_SEC = 80, | ||
151 | PS2_MOUSE_100_SAMPLES_SEC = 100, | ||
152 | PS2_MOUSE_200_SAMPLES_SEC = 200, | ||
153 | } ps2_mouse_sample_rate_t; | ||
154 | |||
155 | void ps2_mouse_init(void); | ||
156 | |||
157 | void ps2_mouse_init_user(void); | ||
158 | |||
159 | void ps2_mouse_task(void); | ||
160 | |||
161 | void ps2_mouse_disable_data_reporting(void); | ||
162 | |||
163 | void ps2_mouse_enable_data_reporting(void); | ||
164 | |||
165 | void ps2_mouse_set_remote_mode(void); | ||
166 | |||
167 | void ps2_mouse_set_stream_mode(void); | ||
168 | |||
169 | void ps2_mouse_set_scaling_2_1(void); | ||
170 | |||
171 | void ps2_mouse_set_scaling_1_1(void); | ||
172 | |||
173 | void ps2_mouse_set_resolution(ps2_mouse_resolution_t resolution); | ||
174 | |||
175 | void ps2_mouse_set_sample_rate(ps2_mouse_sample_rate_t sample_rate); | ||
176 | |||
177 | void ps2_mouse_moved_user(report_mouse_t *mouse_report); | ||