diff --git a/YAOCMouse.ino b/YAOCMouse.ino index 9524c55..a6f36e4 100644 --- a/YAOCMouse.ino +++ b/YAOCMouse.ino @@ -5,6 +5,23 @@ #include +#define PIN_MOUSE_V 19 // LAN_TX0 +#define PIN_MOUSE_VQ 26 // LAN_RX1 +#define PIN_MOUSE_H 27 // LAN_CRS +#define PIN_MOUSE_HQ 23 // LAN_MDC +#define PIN_MOUSE_LBTN 21 // LAN_TXEN +#define PIN_MOUSE_MBTN 25 // LAN_RX0 +#define PIN_MOUSE_RBTN 17 // LAN_CLK + +#define MOUSE_SCALE_MAX 63 + +const byte mouseStates[4][2] = { + {0, 0}, + {0, 1}, + {1, 1}, + {1, 0} +}; + class MouseRptParser : public MouseReportParser { protected: @@ -14,41 +31,41 @@ class MouseRptParser : public MouseReportParser void OnLeftButtonDown (MOUSEINFO *mi); void OnLeftButtonUp (MOUSEINFO *mi); void OnMiddleButtonDown (MOUSEINFO *mi); + void OnMiddleButtonUp (MOUSEINFO *mi); }; void MouseRptParser::OnRightButtonUp (MOUSEINFO *mi) { - + digitalWrite(PIN_MOUSE_RBTN, HIGH); }; void MouseRptParser::OnRightButtonDown (MOUSEINFO *mi) { - + digitalWrite(PIN_MOUSE_RBTN, LOW); }; void MouseRptParser::OnLeftButtonDown (MOUSEINFO *mi) { - digitalWrite(16, LOW); + digitalWrite(PIN_MOUSE_LBTN, LOW); }; void MouseRptParser::OnLeftButtonUp (MOUSEINFO *mi) { - digitalWrite(16, HIGH); + digitalWrite(PIN_MOUSE_LBTN, HIGH); }; void MouseRptParser::OnMiddleButtonDown (MOUSEINFO *mi) { - + digitalWrite(PIN_MOUSE_MBTN, LOW); }; -byte mouseStates[4][2] = { - {0, 0}, - {0, 1}, - {1, 1}, - {1, 0} +void MouseRptParser::OnMiddleButtonUp (MOUSEINFO *mi) +{ + digitalWrite(PIN_MOUSE_MBTN, HIGH); }; + bool mouseYworking = false; int mouseYTableIndex = 0; void amigaYpulse(int8_t count) { @@ -59,7 +76,7 @@ void amigaYpulse(int8_t count) { return; mouseYworking = true; - byte mapped = map(abs(count), 0, 127, 1, 63); + byte mapped = map(abs(count), 0, 127, 1, MOUSE_SCALE_MAX); for (byte i = 0; i < mapped; i++) { if (count < 0) { @@ -90,7 +107,7 @@ void amigaXpulse(int8_t count) { if (count == 0) return; - for (byte i = 0; i < map(abs(count), 0, 127, 1, 63); i++) + for (byte i = 0; i < map(abs(count), 0, 127, 1, MOUSE_SCALE_MAX); i++) { if (count < 0) { mouseXTableIndex++;