summaryrefslogtreecommitdiff
path: root/hid
diff options
context:
space:
mode:
authorMaxim Devaev <[email protected]>2021-08-15 17:34:42 +0300
committerMaxim Devaev <[email protected]>2021-08-15 20:16:48 +0300
commitdf098bd075e26fb6ecc75b2f7be5923371741677 (patch)
tree663a4e6a4808ed267e985c5b5d3d18bc4cf1f915 /hid
parent9afa6efbe4b8ee3186c5d840233c96115363460f (diff)
win95 runtime switching
Diffstat (limited to 'hid')
-rw-r--r--hid/platformio.ini4
-rw-r--r--hid/src/main.cpp21
-rw-r--r--hid/src/proto.h18
-rw-r--r--hid/src/usb/hid.h10
4 files changed, 36 insertions, 17 deletions
diff --git a/hid/platformio.ini b/hid/platformio.ini
index fa42db0b..a6e27454 100644
--- a/hid/platformio.ini
+++ b/hid/platformio.ini
@@ -7,7 +7,7 @@ platform = atmelavr
board = micro
framework = arduino
lib_deps =
- git+https://github.com/mdevaev/HID#f12b7d633f7437552707d6ccd411204cf36601f2
+ git+https://github.com/mdevaev/HID#a8877bc878a1a2f39d993a3defa750b6ec1b2ee0
git+https://github.com/Harvie/ps2dev#v0.0.3
extra_scripts =
@@ -25,7 +25,7 @@ build_flags =
-DHID_SET_USB_KBD
-DHID_SET_USB_MOUSE_ABS
# ----- The USB ABS fix for Windows 98 (https://github.com/pikvm/pikvm/issues/159) -----
-# -DHID_USB_ABS_WIN98_FIX
+# -DHID_WITH_USB_WIN98
# ----- PS2 keyboard only -----
# -DHID_WITH_PS2
# -DHID_SET_PS2_KBD
diff --git a/hid/src/main.cpp b/hid/src/main.cpp
index ca00f7dc..10136d54 100644
--- a/hid/src/main.cpp
+++ b/hid/src/main.cpp
@@ -102,6 +102,8 @@ static void _initOutputs() {
outputs |= PROTO::OUTPUTS1::MOUSE::USB_REL;
# elif defined(HID_WITH_PS2) && defined(HID_SET_PS2_MOUSE)
outputs |= PROTO::OUTPUTS1::MOUSE::PS2;
+# elif defined(HID_WITH_USB) && defined(HID_WITH_USB_WIN98) && defined(HID_SET_USB_MOUSE_WIN98)
+ outputs |= PROTO::OUTPUTS1::MOUSE::USB_WIN98;
# endif
# ifdef HID_DYNAMIC
@@ -122,7 +124,8 @@ static void _initOutputs() {
uint8_t mouse = outputs & PROTO::OUTPUTS1::MOUSE::MASK;
switch (mouse) {
# ifdef HID_WITH_USB
- case PROTO::OUTPUTS1::MOUSE::USB_ABS: _usb_mouse_abs = new UsbMouseAbsolute(); break;
+ case PROTO::OUTPUTS1::MOUSE::USB_ABS:
+ case PROTO::OUTPUTS1::MOUSE::USB_WIN98: _usb_mouse_abs = new UsbMouseAbsolute(); break;
case PROTO::OUTPUTS1::MOUSE::USB_REL: _usb_mouse_rel = new UsbMouseRelative(); break;
# endif
}
@@ -140,7 +143,12 @@ static void _initOutputs() {
switch (mouse) {
# ifdef HID_WITH_USB
- case PROTO::OUTPUTS1::MOUSE::USB_ABS: _usb_mouse_abs->begin(); break;
+ case PROTO::OUTPUTS1::MOUSE::USB_ABS:
+# ifdef HID_WITH_USB_WIN98
+ case PROTO::OUTPUTS1::MOUSE::USB_WIN98:
+# endif
+ _usb_mouse_abs->begin(mouse == PROTO::OUTPUTS1::MOUSE::USB_WIN98);
+ break;
case PROTO::OUTPUTS1::MOUSE::USB_REL: _usb_mouse_rel->begin(); break;
# endif
}
@@ -286,7 +294,11 @@ static void _sendResponse(uint8_t code) {
}
if (_usb_mouse_abs) {
response[1] |= _usb_mouse_abs->getOfflineAs(PROTO::PONG::MOUSE_OFFLINE);
- response[2] |= PROTO::OUTPUTS1::MOUSE::USB_ABS;
+ if (_usb_mouse_abs->isWin98FixEnabled()) {
+ response[2] |= PROTO::OUTPUTS1::MOUSE::USB_WIN98;
+ } else {
+ response[2] |= PROTO::OUTPUTS1::MOUSE::USB_ABS;
+ }
} else if (_usb_mouse_rel) {
response[1] |= _usb_mouse_rel->getOfflineAs(PROTO::PONG::MOUSE_OFFLINE);
response[2] |= PROTO::OUTPUTS1::MOUSE::USB_REL;
@@ -299,6 +311,9 @@ static void _sendResponse(uint8_t code) {
# endif
# ifdef HID_WITH_USB
response[3] |= PROTO::OUTPUTS2::HAS_USB;
+# ifdef HID_WITH_USB_WIN98
+ response[3] |= PROTO::OUTPUTS2::HAS_USB_WIN98;
+# endif
# endif
# ifdef HID_WITH_PS2
response[3] |= PROTO::OUTPUTS2::HAS_PS2;
diff --git a/hid/src/proto.h b/hid/src/proto.h
index 7a273a30..18124d74 100644
--- a/hid/src/proto.h
+++ b/hid/src/proto.h
@@ -53,18 +53,20 @@ namespace PROTO {
const uint8_t PS2 = 0b00000011;
};
namespace MOUSE {
- const uint8_t MASK = 0b00111000;
- const uint8_t USB_ABS = 0b00001000;
- const uint8_t USB_REL = 0b00010000;
- const uint8_t PS2 = 0b00011000;
+ const uint8_t MASK = 0b00111000;
+ const uint8_t USB_ABS = 0b00001000;
+ const uint8_t USB_REL = 0b00010000;
+ const uint8_t PS2 = 0b00011000;
+ const uint8_t USB_WIN98 = 0b00100000;
};
};
namespace OUTPUTS2 { // Complex response
- const uint8_t CONNECTABLE = 0b10000000;
- const uint8_t CONNECTED = 0b01000000;
- const uint8_t HAS_USB = 0b00000001;
- const uint8_t HAS_PS2 = 0b00000010;
+ const uint8_t CONNECTABLE = 0b10000000;
+ const uint8_t CONNECTED = 0b01000000;
+ const uint8_t HAS_USB = 0b00000001;
+ const uint8_t HAS_PS2 = 0b00000010;
+ const uint8_t HAS_USB_WIN98 = 0b00000100;
}
namespace CMD {
diff --git a/hid/src/usb/hid.h b/hid/src/usb/hid.h
index 6c3772f2..13f68cf1 100644
--- a/hid/src/usb/hid.h
+++ b/hid/src/usb/hid.h
@@ -149,11 +149,13 @@ class UsbMouseAbsolute {
public:
UsbMouseAbsolute() {}
- void begin() {
+ void begin(bool win98_fix) {
_mouse.begin();
-#ifdef HID_USB_ABS_WIN98_FIX
- _mouse.setWin98Fix(true);
-#endif
+ _mouse.setWin98FixEnabled(win98_fix);
+ }
+
+ bool isWin98FixEnabled() {
+ return _mouse.isWin98FixEnabled();
}
void clear() {