mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-02-03 19:41:52 +08:00
moved arduino hid to hid/arduino
This commit is contained in:
11
hid/arduino/patches/arduino-get-plugged-endpoint.patch
Normal file
11
hid/arduino/patches/arduino-get-plugged-endpoint.patch
Normal file
@@ -0,0 +1,11 @@
|
||||
--- a/cores/arduino/PluggableUSB.h 2019-05-16 15:52:01.000000000 +0300
|
||||
+++ b/cores/arduino/PluggableUSB.h 2020-11-14 20:57:30.942432544 +0300
|
||||
@@ -31,6 +31,8 @@
|
||||
numEndpoints(numEps), numInterfaces(numIfs), endpointType(epType)
|
||||
{ }
|
||||
|
||||
+ uint8_t getPluggedEndpoint() { return pluggedEndpoint; }
|
||||
+
|
||||
protected:
|
||||
virtual bool setup(USBSetup& setup) = 0;
|
||||
virtual int getInterface(uint8_t* interfaceCount) = 0;
|
||||
24
hid/arduino/patches/arduino-main-no-usb.patch
Normal file
24
hid/arduino/patches/arduino-main-no-usb.patch
Normal file
@@ -0,0 +1,24 @@
|
||||
diff --git a/cores/arduino/main.cpp b/cores/arduino/main.cpp
|
||||
index 434cd40..7aba76f 100644
|
||||
--- a/cores/arduino/main.cpp
|
||||
+++ b/cores/arduino/main.cpp
|
||||
@@ -36,15 +36,15 @@ int main(void)
|
||||
|
||||
initVariant();
|
||||
|
||||
-#if defined(USBCON)
|
||||
- USBDevice.attach();
|
||||
-#endif
|
||||
+// #if defined(USBCON)
|
||||
+// USBDevice.attach();
|
||||
+// #endif
|
||||
|
||||
setup();
|
||||
|
||||
for (;;) {
|
||||
loop();
|
||||
- if (serialEventRun) serialEventRun();
|
||||
+ // if (serialEventRun) serialEventRun();
|
||||
}
|
||||
|
||||
return 0;
|
||||
141
hid/arduino/patches/arduino-optional-cdc.patch
Normal file
141
hid/arduino/patches/arduino-optional-cdc.patch
Normal file
@@ -0,0 +1,141 @@
|
||||
From 8e823d276f939d79b2d323fad675fb8442a718c2 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Gibson <metalcaedes@gmail.com>
|
||||
Date: Tue, 5 Jan 2021 13:48:43 +0100
|
||||
Subject: [PATCH] Allow disabling CDC with -DCDC_DISABLED
|
||||
|
||||
https://github.com/arduino/ArduinoCore-avr/pull/383
|
||||
|
||||
Sometimes Arduino-based USB devices don't work because some hardware
|
||||
(like KVM switches) gets confused by the CDC sub-devices.
|
||||
This change makes it relatively easy to disable CDC at compiletime.
|
||||
Disabling it of course means that the serial console won't work anymore,
|
||||
so you need to use the reset button when flashing.
|
||||
|
||||
CDC_DISABLED is also used in ArduinoCore-samd for the same purpose.
|
||||
|
||||
based on
|
||||
https://github.com/gdsports/usb-metamorph/tree/master/USBSerPassThruLine
|
||||
|
||||
See also https://github.com/NicoHood/HID/issues/225 and
|
||||
https://github.com/arduino/Arduino/issues/6387 and
|
||||
https://forum.arduino.cc/index.php?topic=545288.msg3717028#msg3717028
|
||||
---
|
||||
cores/arduino/CDC.cpp | 8 ++++++++
|
||||
cores/arduino/USBCore.cpp | 18 +++++++++++++++++-
|
||||
cores/arduino/USBDesc.h | 17 +++++++++++++++++
|
||||
3 files changed, 42 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/cores/arduino/CDC.cpp b/cores/arduino/CDC.cpp
|
||||
index 4ff6b9b4..7d5afaab 100644
|
||||
--- a/cores/arduino/CDC.cpp
|
||||
+++ b/cores/arduino/CDC.cpp
|
||||
@@ -22,6 +22,13 @@
|
||||
|
||||
#if defined(USBCON)
|
||||
|
||||
+#ifndef CDC_ENABLED
|
||||
+
|
||||
+#warning "! Disabled serial console via USB (CDC)!"
|
||||
+#warning "! With this change you'll have to use the Arduino's reset button/pin to flash (upload)!"
|
||||
+
|
||||
+#else // CDC not disabled
|
||||
+
|
||||
typedef struct
|
||||
{
|
||||
u32 dwDTERate;
|
||||
@@ -299,4 +306,5 @@ int32_t Serial_::readBreak() {
|
||||
|
||||
Serial_ Serial;
|
||||
|
||||
+#endif /* if defined(CDC_ENABLED) */
|
||||
#endif /* if defined(USBCON) */
|
||||
diff --git a/cores/arduino/USBCore.cpp b/cores/arduino/USBCore.cpp
|
||||
index dc6bc387..93352387 100644
|
||||
--- a/cores/arduino/USBCore.cpp
|
||||
+++ b/cores/arduino/USBCore.cpp
|
||||
@@ -69,8 +69,18 @@ const u8 STRING_MANUFACTURER[] PROGMEM = USB_MANUFACTURER;
|
||||
#define DEVICE_CLASS 0x02
|
||||
|
||||
// DEVICE DESCRIPTOR
|
||||
+
|
||||
+#ifdef CDC_ENABLED
|
||||
const DeviceDescriptor USB_DeviceDescriptorIAD =
|
||||
D_DEVICE(0xEF,0x02,0x01,64,USB_VID,USB_PID,0x100,IMANUFACTURER,IPRODUCT,ISERIAL,1);
|
||||
+#else // CDC_DISABLED
|
||||
+// The default descriptor uses USB class OxEF, subclass 0x02 with protocol 1
|
||||
+// which means "Interface Association Descriptor" - that's needed for the CDC,
|
||||
+// but doesn't make much sense as a default for custom devices when CDC is disabled.
|
||||
+// (0x00 means "Use class information in the Interface Descriptors" which should be generally ok)
|
||||
+const DeviceDescriptor USB_DeviceDescriptorIAD =
|
||||
+ D_DEVICE(0x00,0x00,0x00,64,USB_VID,USB_PID,0x100,IMANUFACTURER,IPRODUCT,ISERIAL,1);
|
||||
+#endif
|
||||
|
||||
//==================================================================
|
||||
//==================================================================
|
||||
@@ -328,10 +338,12 @@ int USB_Send(u8 ep, const void* d, int len)
|
||||
u8 _initEndpoints[USB_ENDPOINTS] =
|
||||
{
|
||||
0, // Control Endpoint
|
||||
-
|
||||
+
|
||||
+#ifdef CDC_ENABLED
|
||||
EP_TYPE_INTERRUPT_IN, // CDC_ENDPOINT_ACM
|
||||
EP_TYPE_BULK_OUT, // CDC_ENDPOINT_OUT
|
||||
EP_TYPE_BULK_IN, // CDC_ENDPOINT_IN
|
||||
+#endif
|
||||
|
||||
// Following endpoints are automatically initialized to 0
|
||||
};
|
||||
@@ -373,10 +385,12 @@ void InitEndpoints()
|
||||
static
|
||||
bool ClassInterfaceRequest(USBSetup& setup)
|
||||
{
|
||||
+#ifdef CDC_ENABLED
|
||||
u8 i = setup.wIndex;
|
||||
|
||||
if (CDC_ACM_INTERFACE == i)
|
||||
return CDC_Setup(setup);
|
||||
+#endif
|
||||
|
||||
#ifdef PLUGGABLE_USB_ENABLED
|
||||
return PluggableUSB().setup(setup);
|
||||
@@ -466,7 +480,9 @@ static u8 SendInterfaces()
|
||||
{
|
||||
u8 interfaces = 0;
|
||||
|
||||
+#ifdef CDC_ENABLED
|
||||
CDC_GetInterface(&interfaces);
|
||||
+#endif
|
||||
|
||||
#ifdef PLUGGABLE_USB_ENABLED
|
||||
PluggableUSB().getInterface(&interfaces);
|
||||
diff --git a/cores/arduino/USBDesc.h b/cores/arduino/USBDesc.h
|
||||
index c0dce079..b55ac20b 100644
|
||||
--- a/cores/arduino/USBDesc.h
|
||||
+++ b/cores/arduino/USBDesc.h
|
||||
@@ -26,8 +26,25 @@
|
||||
|
||||
#define ISERIAL_MAX_LEN 20
|
||||
|
||||
+// Uncomment the following line or pass -DCDC_DISABLED to the compiler
|
||||
+// to disable CDC (serial console via USB).
|
||||
+// That's useful if you want to create an USB device (like an USB Boot Keyboard)
|
||||
+// that works even with problematic devices (like KVM switches).
|
||||
+// Keep in mind that with this change you'll have to use the Arduino's
|
||||
+// reset button to be able to flash it.
|
||||
+//#define CDC_DISABLED
|
||||
+
|
||||
+#ifndef CDC_DISABLED
|
||||
+#define CDC_ENABLED
|
||||
+#endif
|
||||
+
|
||||
+#ifdef CDC_ENABLED
|
||||
#define CDC_INTERFACE_COUNT 2
|
||||
#define CDC_ENPOINT_COUNT 3
|
||||
+#else // CDC_DISABLED
|
||||
+#define CDC_INTERFACE_COUNT 0
|
||||
+#define CDC_ENPOINT_COUNT 0
|
||||
+#endif
|
||||
|
||||
#define CDC_ACM_INTERFACE 0 // CDC ACM
|
||||
#define CDC_DATA_INTERFACE 1 // CDC Data
|
||||
66
hid/arduino/patches/hid-no-singletones.patch
Normal file
66
hid/arduino/patches/hid-no-singletones.patch
Normal file
@@ -0,0 +1,66 @@
|
||||
diff -u -r a/src/SingleReport/BootKeyboard.cpp b/src/SingleReport/BootKeyboard.cpp
|
||||
--- a/src/SingleReport/BootKeyboard.cpp 2019-07-13 21:16:23.000000000 +0300
|
||||
+++ b/src/SingleReport/BootKeyboard.cpp 2020-11-17 18:59:36.618815374 +0300
|
||||
@@ -206,6 +206,6 @@
|
||||
}
|
||||
|
||||
|
||||
-BootKeyboard_ BootKeyboard;
|
||||
+//BootKeyboard_ BootKeyboard;
|
||||
|
||||
|
||||
diff -u -r a/src/SingleReport/BootKeyboard.h b/src/SingleReport/BootKeyboard.h
|
||||
--- a/src/SingleReport/BootKeyboard.h 2019-07-13 21:16:23.000000000 +0300
|
||||
+++ b/src/SingleReport/BootKeyboard.h 2020-11-17 19:00:54.967113649 +0300
|
||||
@@ -80,6 +80,6 @@
|
||||
uint8_t* featureReport;
|
||||
int featureLength;
|
||||
};
|
||||
-extern BootKeyboard_ BootKeyboard;
|
||||
+//extern BootKeyboard_ BootKeyboard;
|
||||
|
||||
|
||||
diff -u -r a/src/SingleReport/BootMouse.cpp b/src/SingleReport/BootMouse.cpp
|
||||
--- a/src/SingleReport/BootMouse.cpp 2019-07-13 21:16:23.000000000 +0300
|
||||
+++ b/src/SingleReport/BootMouse.cpp 2020-11-17 18:59:22.859113905 +0300
|
||||
@@ -139,6 +139,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
-BootMouse_ BootMouse;
|
||||
+//BootMouse_ BootMouse;
|
||||
|
||||
|
||||
diff -u -r a/src/SingleReport/BootMouse.h b/src/SingleReport/BootMouse.h
|
||||
--- a/src/SingleReport/BootMouse.h 2019-07-13 21:16:23.000000000 +0300
|
||||
+++ b/src/SingleReport/BootMouse.h 2020-11-17 19:01:04.076915591 +0300
|
||||
@@ -48,6 +48,6 @@
|
||||
|
||||
virtual void SendReport(void* data, int length) override;
|
||||
};
|
||||
-extern BootMouse_ BootMouse;
|
||||
+//extern BootMouse_ BootMouse;
|
||||
|
||||
|
||||
diff -u -r a/src/SingleReport/SingleAbsoluteMouse.cpp b/src/SingleReport/SingleAbsoluteMouse.cpp
|
||||
--- a/src/SingleReport/SingleAbsoluteMouse.cpp 2020-11-17 18:39:35.314843889 +0300
|
||||
+++ b/src/SingleReport/SingleAbsoluteMouse.cpp 2020-11-17 18:59:12.189345326 +0300
|
||||
@@ -139,6 +139,6 @@
|
||||
USB_Send(pluggedEndpoint | TRANSFER_RELEASE, data, length);
|
||||
}
|
||||
|
||||
-SingleAbsoluteMouse_ SingleAbsoluteMouse;
|
||||
+//SingleAbsoluteMouse_ SingleAbsoluteMouse;
|
||||
|
||||
|
||||
diff -u -r a/src/SingleReport/SingleAbsoluteMouse.h b/src/SingleReport/SingleAbsoluteMouse.h
|
||||
--- a/src/SingleReport/SingleAbsoluteMouse.h 2019-07-13 21:16:23.000000000 +0300
|
||||
+++ b/src/SingleReport/SingleAbsoluteMouse.h 2020-11-17 19:01:21.356539808 +0300
|
||||
@@ -49,6 +49,6 @@
|
||||
|
||||
virtual inline void SendReport(void* data, int length) override;
|
||||
};
|
||||
-extern SingleAbsoluteMouse_ SingleAbsoluteMouse;
|
||||
+//extern SingleAbsoluteMouse_ SingleAbsoluteMouse;
|
||||
|
||||
|
||||
16
hid/arduino/patches/hid-shut-up.patch
Normal file
16
hid/arduino/patches/hid-shut-up.patch
Normal file
@@ -0,0 +1,16 @@
|
||||
diff --git a/src/KeyboardLayouts/ImprovedKeylayouts.h b/src/KeyboardLayouts/ImprovedKeylayouts.h
|
||||
index 03b92a0..ee0bab4 100644
|
||||
--- a/src/KeyboardLayouts/ImprovedKeylayouts.h
|
||||
+++ b/src/KeyboardLayouts/ImprovedKeylayouts.h
|
||||
@@ -51,9 +51,9 @@ enum KeyboardLeds : uint8_t {
|
||||
#ifndef HID_CUSTOM_LAYOUT
|
||||
#define HID_CUSTOM_LAYOUT
|
||||
#define LAYOUT_US_ENGLISH
|
||||
- #pragma message "Using default ASCII layout for keyboard modules"
|
||||
+ //#pragma message "Using default ASCII layout for keyboard modules"
|
||||
#else
|
||||
- #pragma message "Using custom layout for keyboard modules"
|
||||
+ //#pragma message "Using custom layout for keyboard modules"
|
||||
#endif
|
||||
|
||||
// Hut1_12v2.pdf
|
||||
82
hid/arduino/patches/hid-win98.patch
Normal file
82
hid/arduino/patches/hid-win98.patch
Normal file
@@ -0,0 +1,82 @@
|
||||
From 82c8aee0ae3739eb22ae11b8f527d0c50b0ced31 Mon Sep 17 00:00:00 2001
|
||||
From: Maxim Devaev <mdevaev@gmail.com>
|
||||
Date: Sat, 14 Aug 2021 10:10:06 +0300
|
||||
Subject: [PATCH] Fixed absolute mouse positioning in Windows 98
|
||||
|
||||
Windows 98 contains a buggy HID driver. It allows you to move only
|
||||
on the upper right quarter of the screen. Yes, this is indeed exceeding
|
||||
the maximum value from the HID report. Yes, it really should work that way.
|
||||
|
||||
VirtualBox has a similar fix, but with a shift in the other direction
|
||||
(I didn't dig the details). I suppose it can be fixed somehow with a special
|
||||
HID descriptor, but the proposed fix is simpler and really works.
|
||||
|
||||
Related: https://github.com/pikvm/pikvm/issues/159
|
||||
---
|
||||
src/HID-APIs/AbsoluteMouseAPI.h | 3 +++
|
||||
src/HID-APIs/AbsoluteMouseAPI.hpp | 17 ++++++++++++++++-
|
||||
2 files changed, 19 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/HID-APIs/AbsoluteMouseAPI.h b/src/HID-APIs/AbsoluteMouseAPI.h
|
||||
index 66dbe42..c99e6a5 100644
|
||||
--- a/src/HID-APIs/AbsoluteMouseAPI.h
|
||||
+++ b/src/HID-APIs/AbsoluteMouseAPI.h
|
||||
@@ -57,6 +57,7 @@ class AbsoluteMouseAPI
|
||||
int16_t xAxis;
|
||||
int16_t yAxis;
|
||||
uint8_t _buttons;
|
||||
+ bool win98_fix;
|
||||
inline void buttons(uint8_t b);
|
||||
|
||||
inline int16_t qadd16(int16_t base, int16_t increment);
|
||||
@@ -65,6 +66,8 @@ class AbsoluteMouseAPI
|
||||
inline AbsoluteMouseAPI(void);
|
||||
inline void begin(void);
|
||||
inline void end(void);
|
||||
+ inline void setWin98FixEnabled(bool enabled);
|
||||
+ inline bool isWin98FixEnabled(void);
|
||||
|
||||
inline void click(uint8_t b = MOUSE_LEFT);
|
||||
inline void moveTo(int x, int y, signed char wheel = 0);
|
||||
diff --git a/src/HID-APIs/AbsoluteMouseAPI.hpp b/src/HID-APIs/AbsoluteMouseAPI.hpp
|
||||
index 0913c8a..0b9aaa2 100644
|
||||
--- a/src/HID-APIs/AbsoluteMouseAPI.hpp
|
||||
+++ b/src/HID-APIs/AbsoluteMouseAPI.hpp
|
||||
@@ -51,7 +51,7 @@ int16_t AbsoluteMouseAPI::qadd16(int16_t base, int16_t increment) {
|
||||
}
|
||||
|
||||
AbsoluteMouseAPI::AbsoluteMouseAPI(void):
|
||||
-xAxis(0), yAxis(0), _buttons(0)
|
||||
+xAxis(0), yAxis(0), _buttons(0), win98_fix(false)
|
||||
{
|
||||
// Empty
|
||||
}
|
||||
@@ -66,6 +66,14 @@ void AbsoluteMouseAPI::end(void){
|
||||
moveTo(xAxis, yAxis, 0);
|
||||
}
|
||||
|
||||
+void AbsoluteMouseAPI::setWin98FixEnabled(bool enabled){
|
||||
+ win98_fix = enabled;
|
||||
+}
|
||||
+
|
||||
+bool AbsoluteMouseAPI::isWin98FixEnabled(void){
|
||||
+ return win98_fix;
|
||||
+}
|
||||
+
|
||||
void AbsoluteMouseAPI::click(uint8_t b){
|
||||
_buttons = b;
|
||||
moveTo(xAxis, yAxis, 0);
|
||||
@@ -84,6 +92,13 @@ void AbsoluteMouseAPI::moveTo(int x, int y, signed char wheel){
|
||||
// See detauls in AbsoluteMouse sources and here: https://github.com/NicoHood/HID/pull/306
|
||||
report.xAxis = ((int32_t)x + 32768) / 2;
|
||||
report.yAxis = ((int32_t)y + 32768) / 2;
|
||||
+ if (win98_fix) {
|
||||
+ // Windows 98 contains a buggy driver.
|
||||
+ // Yes, this is indeed exceeding the maximum value from the HID report.
|
||||
+ // Yes, it really should work that way.
|
||||
+ report.xAxis <<= 1;
|
||||
+ report.yAxis <<= 1;
|
||||
+ }
|
||||
report.wheel = wheel;
|
||||
SendReport(&report, sizeof(report));
|
||||
}
|
||||
11
hid/arduino/patches/platformio-stm32f1-no-serial-usb.patch
Normal file
11
hid/arduino/patches/platformio-stm32f1-no-serial-usb.patch
Normal file
@@ -0,0 +1,11 @@
|
||||
--- aaa/tools/platformio-build-stm32f1.py 2022-07-16 18:54:42.536695468 +0200
|
||||
+++ bbb/tools/platformio-build-stm32f1.py 2022-07-16 19:03:10.988056751 +0200
|
||||
@@ -121,7 +121,7 @@
|
||||
env.Append(
|
||||
|
||||
CPPDEFINES=[
|
||||
|
||||
("CONFIG_MAPLE_MINI_NO_DISABLE_DEBUG", 1),
|
||||
|
||||
- "SERIAL_USB"
|
||||
|
||||
Reference in New Issue
Block a user