diff options
author | Priyadi Iman Nurcahyo <priyadi@priyadi.net> | 2016-12-05 01:07:12 +0700 |
---|---|---|
committer | Priyadi Iman Nurcahyo <priyadi@priyadi.net> | 2016-12-05 01:21:17 +0700 |
commit | d059624bfb32e268ff0972609d7eadbb212fa2d2 (patch) | |
tree | 3d6079093aa4635367320e0f80b6ec924fa2c3e9 | |
parent | f39e1b5dfe7552f01dbc6eab95c268f41a9d98e2 (diff) | |
download | qmk_firmware-d059624bfb32e268ff0972609d7eadbb212fa2d2.tar.gz qmk_firmware-d059624bfb32e268ff0972609d7eadbb212fa2d2.zip |
Implemented weak ps2_mouse_init_user()
There are a lot of PS/2 commands, some are vendor/device specific, so we
provide a weak ps2_mouse_init_user() to be implemented in each keyboard
that need it.
-rw-r--r-- | tmk_core/protocol/ps2_mouse.c | 54 | ||||
-rw-r--r-- | tmk_core/protocol/ps2_mouse.h | 49 |
2 files changed, 56 insertions, 47 deletions
diff --git a/tmk_core/protocol/ps2_mouse.c b/tmk_core/protocol/ps2_mouse.c index af971dd49..e3c697444 100644 --- a/tmk_core/protocol/ps2_mouse.c +++ b/tmk_core/protocol/ps2_mouse.c | |||
@@ -28,53 +28,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
28 | 28 | ||
29 | /* ============================= MACROS ============================ */ | 29 | /* ============================= MACROS ============================ */ |
30 | 30 | ||
31 | #define PS2_MOUSE_SEND(command, message) \ | 31 | static report_mouse_t mouse_report = {};./ |
32 | do { \ | ||
33 | uint8_t rcv = ps2_host_send(command); \ | ||
34 | if (debug_mouse) { \ | ||
35 | print((message)); \ | ||
36 | xprintf(" command: %X, result: %X, error: %X \n", command, rcv, ps2_error); \ | ||
37 | } \ | ||
38 | } while(0) | ||
39 | |||
40 | #define PS2_MOUSE_SEND_SAFE(command, message) \ | ||
41 | do { \ | ||
42 | if (PS2_MOUSE_STREAM_MODE == ps2_mouse_mode) { \ | ||
43 | ps2_mouse_disable_data_reporting(); \ | ||
44 | } \ | ||
45 | PS2_MOUSE_SEND(command, message); \ | ||
46 | if (PS2_MOUSE_STREAM_MODE == ps2_mouse_mode) { \ | ||
47 | ps2_mouse_enable_data_reporting(); \ | ||
48 | } \ | ||
49 | } while(0) | ||
50 | |||
51 | #define PS2_MOUSE_SET_SAFE(command, value, message) \ | ||
52 | do { \ | ||
53 | if (PS2_MOUSE_STREAM_MODE == ps2_mouse_mode) { \ | ||
54 | ps2_mouse_disable_data_reporting(); \ | ||
55 | } \ | ||
56 | PS2_MOUSE_SEND(command, message); \ | ||
57 | PS2_MOUSE_SEND(value, "Sending value"); \ | ||
58 | if (PS2_MOUSE_STREAM_MODE == ps2_mouse_mode) { \ | ||
59 | ps2_mouse_enable_data_reporting(); \ | ||
60 | } \ | ||
61 | } while(0) | ||
62 | |||
63 | #define PS2_MOUSE_RECEIVE(message) \ | ||
64 | do { \ | ||
65 | uint8_t rcv = ps2_host_recv_response(); \ | ||
66 | if (debug_mouse) { \ | ||
67 | print((message)); \ | ||
68 | xprintf(" result: %X, error: %X \n", rcv, ps2_error); \ | ||
69 | } \ | ||
70 | } while(0) | ||
71 | |||
72 | static enum ps2_mouse_mode_e { | ||
73 | PS2_MOUSE_STREAM_MODE, | ||
74 | PS2_MOUSE_REMOTE_MODE, | ||
75 | } ps2_mouse_mode = PS2_MOUSE_STREAM_MODE; | ||
76 | |||
77 | static report_mouse_t mouse_report = {}; | ||
78 | 32 | ||
79 | static inline void ps2_mouse_print_report(report_mouse_t *mouse_report); | 33 | static inline void ps2_mouse_print_report(report_mouse_t *mouse_report); |
80 | static inline void ps2_mouse_convert_report_to_hid(report_mouse_t *mouse_report); | 34 | static inline void ps2_mouse_convert_report_to_hid(report_mouse_t *mouse_report); |
@@ -108,6 +62,12 @@ void ps2_mouse_init(void) { | |||
108 | #ifdef PS2_MOUSE_USE_2_1_SCALING | 62 | #ifdef PS2_MOUSE_USE_2_1_SCALING |
109 | ps2_mouse_set_scaling_2_1(); | 63 | ps2_mouse_set_scaling_2_1(); |
110 | #endif | 64 | #endif |
65 | |||
66 | ps2_mouse_init_user(); | ||
67 | } | ||
68 | |||
69 | __attribute__((weak)) | ||
70 | void ps2_mouse_init_user(void) { | ||
111 | } | 71 | } |
112 | 72 | ||
113 | void ps2_mouse_task(void) { | 73 | void ps2_mouse_task(void) { |
diff --git a/tmk_core/protocol/ps2_mouse.h b/tmk_core/protocol/ps2_mouse.h index e11c705fc..3c93a4634 100644 --- a/tmk_core/protocol/ps2_mouse.h +++ b/tmk_core/protocol/ps2_mouse.h | |||
@@ -19,6 +19,53 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
19 | #define PS2_MOUSE_H | 19 | #define PS2_MOUSE_H |
20 | 20 | ||
21 | #include <stdbool.h> | 21 | #include <stdbool.h> |
22 | #include "debug.h" | ||
23 | |||
24 | #define PS2_MOUSE_SEND(command, message) \ | ||
25 | do { \ | ||
26 | 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 | 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 | static enum ps2_mouse_mode_e { | ||
66 | PS2_MOUSE_STREAM_MODE, | ||
67 | PS2_MOUSE_REMOTE_MODE, | ||
68 | } ps2_mouse_mode = PS2_MOUSE_STREAM_MODE; | ||
22 | 69 | ||
23 | /* | 70 | /* |
24 | * Data format: | 71 | * Data format: |
@@ -107,6 +154,8 @@ typedef enum ps2_mouse_sample_rate_e { | |||
107 | 154 | ||
108 | void ps2_mouse_init(void); | 155 | void ps2_mouse_init(void); |
109 | 156 | ||
157 | void ps2_mouse_init_user(void); | ||
158 | |||
110 | void ps2_mouse_task(void); | 159 | void ps2_mouse_task(void); |
111 | 160 | ||
112 | void ps2_mouse_disable_data_reporting(void); | 161 | void ps2_mouse_disable_data_reporting(void); |