diff options
author | Devaev Maxim <[email protected]> | 2019-10-05 02:42:06 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2019-10-05 02:42:06 +0300 |
commit | da660d02cd9184f31f47bec3edb3a600608b45d5 (patch) | |
tree | e079c5a144259a04ac7ea53aaf69861c640bbf6c | |
parent | f5bbfeb8b523ddb9fe1277f2b06deb3970e51105 (diff) |
arduino hid: fixed mouse movement on windows
-rw-r--r-- | hid/Makefile | 2 | ||||
-rw-r--r-- | hid/patch.py | 18 | ||||
-rw-r--r-- | hid/patches/absmouse.patch | 12 | ||||
-rw-r--r-- | hid/platformio.ini | 2 | ||||
-rw-r--r-- | hid/src/main.cpp | 2 |
5 files changed, 35 insertions, 1 deletions
diff --git a/hid/Makefile b/hid/Makefile index 62fde0fe..2aa886a1 100644 --- a/hid/Makefile +++ b/hid/Makefile @@ -10,7 +10,7 @@ upload: clean-all: clean clean: - rm -rf .pioenvs .piolibdeps + rm -rf .pio help: @ cat Makefile diff --git a/hid/patch.py b/hid/patch.py new file mode 100644 index 00000000..24ba2123 --- /dev/null +++ b/hid/patch.py @@ -0,0 +1,18 @@ +from os.path import join +from os.path import exists + +Import("env") + + +# ===== +env_path = join(env["PROJECTLIBDEPS_DIR"], env["PIOENV"]) +flag_path = join(env_path, ".patched") + +if not exists(flag_path): + env.Execute(f"patch -p1 -d {join(env_path, 'HID-Project_ID523')} < {join('patches', 'absmouse.patch')}") + + def touch_flag(*_, **__) -> None: + with open(flag_path, "w") as flag_file: + pass + + env.Execute(touch_flag) diff --git a/hid/patches/absmouse.patch b/hid/patches/absmouse.patch new file mode 100644 index 00000000..ac2226a1 --- /dev/null +++ b/hid/patches/absmouse.patch @@ -0,0 +1,12 @@ +See /kvmd/apps/otg/hid/keyboard.py for details +--- a/src/SingleReport/SingleAbsoluteMouse.cpp 2019-07-13 21:16:23.000000000 +0300 ++++ b/src/SingleReport/SingleAbsoluteMouse.cpp 2019-10-05 00:58:34.592003332 +0300 +@@ -43,7 +43,7 @@ + 0x05, 0x01, /* USAGE_PAGE (Generic Desktop) */ + 0x09, 0x30, /* USAGE (X) */ + 0x09, 0x31, /* USAGE (Y) */ +- 0x16, 0x00, 0x80, /* Logical Minimum (-32768) */ ++ 0x16, 0x00, 0x00, /* Logical Minimum (0) */ + 0x26, 0xFF, 0x7F, /* Logical Maximum (32767) */ + 0x75, 0x10, /* Report Size (16), */ + 0x95, 0x02, /* Report Count (2), */ diff --git a/hid/platformio.ini b/hid/platformio.ini index 86fd8f7b..e1952afa 100644 --- a/hid/platformio.ini +++ b/hid/platformio.ini @@ -20,6 +20,7 @@ framework = arduino upload_port = /dev/ttyACM0 lib_deps = ${common.lib_deps} build_flags = -DCMD_SERIAL=Serial1 +extra_scripts = post:patch.py [env:serial_test] platform = atmelavr @@ -28,3 +29,4 @@ framework = arduino upload_port = /dev/ttyACM0 lib_deps = ${common.lib_deps} build_flags = -DCMD_SERIAL=Serial +extra_scripts = post:patch.py diff --git a/hid/src/main.cpp b/hid/src/main.cpp index 27520f97..fe5e0210 100644 --- a/hid/src/main.cpp +++ b/hid/src/main.cpp @@ -98,9 +98,11 @@ INLINE void cmdMouseButtonEvent(const uint8_t *buffer) { // 1 byte INLINE void cmdMouseMoveEvent(const uint8_t *buffer) { // 4 bytes int x = (int)buffer[0] << 8; x |= (int)buffer[1]; + x = (x + 32768) / 2; // See /kvmd/apps/otg/hid/keyboard.py for details int y = (int)buffer[2] << 8; y |= (int)buffer[3]; + y = (y + 32768) / 2; // See /kvmd/apps/otg/hid/keyboard.py for details SingleAbsoluteMouse.moveTo(x, y); } |