]> git.donarmstrong.com Git - qmk_firmware.git/blobdiff - tmk_core/protocol/ps2_mouse.h
Extended the hint of the programmer to link to the relevant README part instead of...
[qmk_firmware.git] / tmk_core / protocol / ps2_mouse.h
index 3b498059dcb71be845d0e883b90d2d1300c12c61..eeeffe4d80ca0fc62538ffb8681194b5be0fa3e4 100644 (file)
@@ -19,6 +19,54 @@ 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 { \
+   __attribute__ ((unused)) 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 { \
+   __attribute__ ((unused)) uint8_t rcv = ps2_host_recv_response(); \
+   if (debug_mouse) { \
+        print((message)); \
+        xprintf(" result: %X, error: %X \n", rcv, ps2_error); \
+    } \
+} while(0)
+
+__attribute__ ((unused))
+static enum ps2_mouse_mode_e {
+    PS2_MOUSE_STREAM_MODE,
+    PS2_MOUSE_REMOTE_MODE,
+} ps2_mouse_mode = PS2_MOUSE_STREAM_MODE;
 
 /*
  * Data format:
@@ -66,6 +114,9 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #ifndef PS2_MOUSE_SCROLL_MASK       
 #define PS2_MOUSE_SCROLL_MASK           0xFF 
 #endif
+#ifndef PS2_MOUSE_INIT_DELAY
+#define PS2_MOUSE_INIT_DELAY            1000
+#endif
 
 enum ps2_mouse_command_e {
     PS2_MOUSE_RESET = 0xFF,
@@ -104,6 +155,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);