summaryrefslogtreecommitdiffstats
path: root/tmk_core/protocol/ps2_mouse.h
diff options
context:
space:
mode:
authorPriyadi Iman Nurcahyo <priyadi@priyadi.net>2016-12-04 19:07:12 +0100
committerPriyadi Iman Nurcahyo <priyadi@priyadi.net>2016-12-04 19:21:17 +0100
commitd059624bfb32e268ff0972609d7eadbb212fa2d2 (patch)
tree3d6079093aa4635367320e0f80b6ec924fa2c3e9 /tmk_core/protocol/ps2_mouse.h
parentf39e1b5dfe7552f01dbc6eab95c268f41a9d98e2 (diff)
downloadqmk_firmware-d059624bfb32e268ff0972609d7eadbb212fa2d2.tar.gz
qmk_firmware-d059624bfb32e268ff0972609d7eadbb212fa2d2.tar.xz
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.
Diffstat (limited to 'tmk_core/protocol/ps2_mouse.h')
-rw-r--r--tmk_core/protocol/ps2_mouse.h49
1 files changed, 49 insertions, 0 deletions
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/>.
#define PS2_MOUSE_H
#include <stdbool.h>
+#include "debug.h"
+
+#define PS2_MOUSE_SEND(command, message) \
+do { \
+ uint8_t rcv = ps2_host_send(command); \
+ if (debug_mouse) { \
+ print((message)); \
+ xprintf(" command: %X, result: %X, error: %X \n", command, rcv, ps2_error); \
+ } \
+} while(0)
+
+#define PS2_MOUSE_SEND_SAFE(command, message) \
+do { \
+ if (PS2_MOUSE_STREAM_MODE == ps2_mouse_mode) { \
+ ps2_mouse_disable_data_reporting(); \
+ } \
+ PS2_MOUSE_SEND(command, message); \
+ if (PS2_MOUSE_STREAM_MODE == ps2_mouse_mode) { \
+ ps2_mouse_enable_data_reporting(); \
+ } \
+} while(0)
+
+#define PS2_MOUSE_SET_SAFE(command, value, message) \
+do { \
+ if (PS2_MOUSE_STREAM_MODE == ps2_mouse_mode) { \
+ ps2_mouse_disable_data_reporting(); \
+ } \
+ PS2_MOUSE_SEND(command, message); \
+ PS2_MOUSE_SEND(value, "Sending value"); \
+ if (PS2_MOUSE_STREAM_MODE == ps2_mouse_mode) { \
+ ps2_mouse_enable_data_reporting(); \
+ } \
+} while(0)
+
+#define PS2_MOUSE_RECEIVE(message) \
+do { \
+ uint8_t rcv = ps2_host_recv_response(); \
+ if (debug_mouse) { \
+ print((message)); \
+ xprintf(" result: %X, error: %X \n", rcv, ps2_error); \
+ } \
+} while(0)
+
+static enum ps2_mouse_mode_e {
+ PS2_MOUSE_STREAM_MODE,
+ PS2_MOUSE_REMOTE_MODE,
+} ps2_mouse_mode = PS2_MOUSE_STREAM_MODE;
/*
* Data format:
@@ -107,6 +154,8 @@ typedef enum ps2_mouse_sample_rate_e {
void ps2_mouse_init(void);
+void ps2_mouse_init_user(void);
+
void ps2_mouse_task(void);
void ps2_mouse_disable_data_reporting(void);