Skip to content

Commit

Permalink
update: not broken... but not working either
Browse files Browse the repository at this point in the history
  • Loading branch information
Alabastard-64 committed Jan 21, 2023
1 parent 7a0769b commit a6d5417
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 59 deletions.
13 changes: 5 additions & 8 deletions tmk_core/protocol/lufa/lufa.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,7 @@ static uint8_t keyboard_led_state = 0;
static report_keyboard_t keyboard_report_sent;

#ifdef MOUSE_WHEEL_HIRES_ENABLE
static report_resolution_multiplier_t resolution_multiplier_report = {
REPORT_ID_MULTIPLIER,
0x00,
};
static uint8_t resolution_multiplier;
#endif

/* Host driver */
Expand All @@ -95,7 +92,7 @@ static void send_extra(report_extra_t *report);
host_driver_t lufa_driver = {keyboard_leds, send_keyboard, send_mouse, send_extra};

void send_report(uint8_t endpoint, void *report, size_t size) {
uint8_t timeout = 255;
uint8_t timeout = 255;

if (USB_DeviceState != DEVICE_STATE_Configured) return;

Expand Down Expand Up @@ -465,8 +462,8 @@ void EVENT_USB_Device_ControlRequest(void) {
#endif
# ifdef MOUSE_WHEEL_HIRES_ENABLE
if (USB_ControlRequest.wValue == (0x0300 | REPORT_ID_MULTIPLIER)) {
ReportData = (uint8_t *)&resolution_multiplier_report;
ReportSize = sizeof(resolution_multiplier_report);
ReportData = (uint8_t *)&resolution_multiplier;
ReportSize = sizeof(resolution_multiplier);
}
# endif
break;
Expand Down Expand Up @@ -503,7 +500,7 @@ void EVENT_USB_Device_ControlRequest(void) {
break;
#ifdef MOUSE_WHEEL_HIRES_ENABLE
case REPORT_ID_MULTIPLIER:
resolution_multiplier_report.multiplier = Endpoint_Read_8();
resolution_multiplier = Endpoint_Read_8();
break;
#endif
}
Expand Down
4 changes: 0 additions & 4 deletions tmk_core/protocol/lufa/lufa.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ extern "C" {

extern host_driver_t lufa_driver;

//#ifdef MOUSE_WHEEL_HIRES_ENABLE
//extern report_resolution_multiplier_t resolution_multiplier_report;
//#endif

#ifdef __cplusplus
}
#endif
20 changes: 6 additions & 14 deletions tmk_core/protocol/report.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,12 @@ typedef int16_t mouse_hv_report_t;
typedef int8_t mouse_hv_report_t;
#endif

#ifdef MOUSE_WHEEL_HIRES_ENABLE
# ifndef MOUSE_WHEEL_MULTIPLIER
# define MOUSE_WHEEL_MULTIPLIER 120
# endif
#endif

typedef struct {
#ifdef MOUSE_SHARED_EP
uint8_t report_id;
Expand All @@ -229,20 +235,6 @@ typedef struct {
mouse_hv_report_t h;
} __attribute__((packed)) report_mouse_t;

#ifdef MOUSE_WHEEL_HIRES_ENABLE
# ifndef MOUSE_WHEEL_MULTIPLIER
# define MOUSE_WHEEL_MULTIPLER 120
# endif
typedef struct {
uint8_t report_id;
struct {
uint8_t v : 2;
uint8_t h : 2;
uint8_t reserved : 4;
} multiplier;
} __attribute__((packed)) report_resolution_multiplier_t;
#endif

typedef struct {
#ifdef DIGITIZER_SHARED_EP
uint8_t report_id;
Expand Down
17 changes: 9 additions & 8 deletions tmk_core/protocol/usb_descriptor.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM SharedReport[] = {
# endif
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE),

// Vertical/Horizontal Wheel (2, 4, or 5 bytes)
// Vertical/Horizontal Wheel (2 or 4 bytes)
# ifdef MOUSE_WHEEL_HIRES_ENABLE
HID_RI_COLLECTION(8, 0x02), // Logical collection
// Resolution Multiplier (2 bits)
Expand All @@ -171,7 +171,7 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM SharedReport[] = {
# else
HID_RI_REPORT_ID(8, 0x00), // reset report ID
# endif
# endif
# endif // MOUSE_WHEEL_HIRES_ENABLE
// Vertical wheel (1-2 bytes)
HID_RI_USAGE(8, 0x38), // Wheel (V)
# ifdef MOUSE_WHEEL_EXTENDED_REPORT
Expand All @@ -187,14 +187,14 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM SharedReport[] = {
# endif
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE),
# ifdef MOUSE_WHEEL_HIRES_ENABLE
HID_RI_END_COLLECTION(0),
HID_RI_END_COLLECTION(0), // Logical
# endif

// Horizontal Wheel (1 or 2 bytes)
# ifdef MOUSE_WHEEL_HIRES_ENABLE
HID_RI_COLLECTION(8, 0x02), // Logical collection
// Resolution Multiplier (2 bits)
HID_RI_REPORT(8, REPORT_ID_MULTIPLIER),
HID_RI_REPORT_ID(8, REPORT_ID_MULTIPLIER),
HID_RI_USAGE(8, 0x48), // Resolution Multiplier
HID_RI_REPORT_COUNT(8, 0x01),
HID_RI_REPORT_SIZE(8, 0x02),
Expand All @@ -209,9 +209,9 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM SharedReport[] = {
# ifdef MOUSE_SHARED_EP
HID_RI_REPORT_ID(8, REPORT_ID_MOUSE),
# else
HID_RI_REPORT_ID(8, 0x00), // reset report ID
HID_RI_REPORT_ID(8, 0x00), // reset report ID
# endif
# endif
# endif // MOUSE_WHEEL_HIRES_ENABLE
HID_RI_USAGE_PAGE(8, 0x0C), // Consumer
HID_RI_USAGE(16, 0x0238), // AC Pan (Horizontal Wheel)
# ifdef MOUSE_WHEEL_EXTENDED_REPORT
Expand All @@ -227,9 +227,10 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM SharedReport[] = {
# endif
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE),
# ifdef MOUSE_WHEEL_HIRES_ENABLE
HID_RI_END_COLLECTION(0),
HID_RI_END_COLLECTION(0), // Logical
# endif
HID_RI_END_COLLECTION(0),
HID_RI_END_COLLECTION(0), // Physical
HID_RI_END_COLLECTION(0), // Application
# ifndef MOUSE_SHARED_EP
};
# endif
Expand Down
55 changes: 30 additions & 25 deletions tmk_core/protocol/vusb/vusb.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ enum usb_interfaces {
static uint8_t keyboard_led_state = 0;
static uint8_t vusb_idle_rate = 0;

#ifdef MOUSE_WHEEL_HIRES_ENABLE
static uint8_t resolution_multiplier;
#endif

/* Keyboard report send buffer */
#define KBUF_SIZE 16
static report_keyboard_t kbuf[KBUF_SIZE];
Expand Down Expand Up @@ -384,15 +388,16 @@ uchar usbFunctionWrite(uchar *data, uchar len) {
keyboard_led_state = data[0];
last_req.len = 0;
return 1;

#ifdef MOUSE_WHEEL_HIRES_ENABLE
case SET_RES_MULT:
if (len == 2 && resolution_multiplier_report.report_id == data[0]) {
if (len == 2 && data[0] == REPORT_ID_MULTIPLIER) {
dprintf("SET_RES_MULT: %02X\n", data[1]);
resolution_multiplier_report.multiplier = data[1];
last_req.len = 0;
resolution_multiplier = data[1];
last_req.len = 0;
return 1;
}
break;
#endif
case NONE:
default:
return -1;
Expand Down Expand Up @@ -439,18 +444,18 @@ const PROGMEM uchar keyboard_hid_report[] = {
0x85, REPORT_ID_KEYBOARD, // Report ID
#endif
// Modifiers (8 bits)
0x05, 0x07, // Usage Page (Keyboard/Keypad)
0x19, 0xE0, // Usage Minimum (Keyboard Left Control)
0x29, 0xE7, // Usage Maximum (Keyboard Right GUI)
0x15, 0x00, // Logical Minimum (0)
0x25, 0x01, // Logical Maximum (1)
0x95, 0x08, // Report Count (8)
0x75, 0x01, // Report Size (1)
0x81, 0x02, // Input (Data, Variable, Absolute)
0x05, 0x07, // Usage Page (Keyboard/Keypad)
0x19, 0xE0, // Usage Minimum (Keyboard Left Control)
0x29, 0xE7, // Usage Maximum (Keyboard Right GUI)
0x15, 0x00, // Logical Minimum (0)
0x25, 0x01, // Logical Maximum (1)
0x95, 0x08, // Report Count (8)
0x75, 0x01, // Report Size (1)
0x81, 0x02, // Input (Data, Variable, Absolute)
// Reserved (1 byte)
0x95, 0x01, // Report Count (1)
0x75, 0x08, // Report Size (8)
0x81, 0x03, // Input (Constant)
0x95, 0x01, // Report Count (1)
0x75, 0x08, // Report Size (8)
0x81, 0x03, // Input (Constant)
// Keycodes (6 bytes)
0x05, 0x07, // Usage Page (Keyboard/Keypad)
0x19, 0x00, // Usage Minimum (0)
Expand All @@ -462,17 +467,17 @@ const PROGMEM uchar keyboard_hid_report[] = {
0x81, 0x00, // Input (Data, Array, Absolute)

// Status LEDs (5 bits)
0x05, 0x08, // Usage Page (LED)
0x19, 0x01, // Usage Minimum (Num Lock)
0x29, 0x05, // Usage Maximum (Kana)
0x95, 0x05, // Report Count (5)
0x75, 0x01, // Report Size (1)
0x91, 0x02, // Output (Data, Variable, Absolute)
0x05, 0x08, // Usage Page (LED)
0x19, 0x01, // Usage Minimum (Num Lock)
0x29, 0x05, // Usage Maximum (Kana)
0x95, 0x05, // Report Count (5)
0x75, 0x01, // Report Size (1)
0x91, 0x02, // Output (Data, Variable, Absolute)
// LED padding (3 bits)
0x95, 0x01, // Report Count (1)
0x75, 0x03, // Report Size (3)
0x91, 0x03, // Output (Constant)
0xC0, // End Collection
0x95, 0x01, // Report Count (1)
0x75, 0x03, // Report Size (3)
0x91, 0x03, // Output (Constant)
0xC0, // End Collection
#ifndef KEYBOARD_SHARED_EP
};
#endif
Expand Down

0 comments on commit a6d5417

Please sign in to comment.