forked from mirrors/qmk_userspace
add mouse wheel function.
This commit is contained in:
parent
d3b1af9572
commit
7e3975e0ef
8 changed files with 256 additions and 59 deletions
68
usb.c
68
usb.c
|
@ -28,6 +28,7 @@
|
|||
#include "usb_keyboard.h"
|
||||
#include "usb_mouse.h"
|
||||
#include "usb_debug.h"
|
||||
#include "print.h"
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
|
@ -145,33 +146,36 @@ static uint8_t PROGMEM keyboard_hid_report_desc[] = {
|
|||
};
|
||||
|
||||
// Mouse Protocol 1, HID 1.11 spec, Appendix B, page 59-60, with wheel extension
|
||||
// http://www.microchip.com/forums/tm.aspx?high=&m=391435&mpage=1#391521
|
||||
// http://www.keil.com/forum/15671/
|
||||
// http://www.microsoft.com/whdc/device/input/wheel.mspx
|
||||
static uint8_t PROGMEM mouse_hid_report_desc[] = {
|
||||
0x05, 0x01, // Usage Page (Generic Desktop)
|
||||
0x09, 0x02, // Usage (Mouse)
|
||||
0xA1, 0x01, // Collection (Application)
|
||||
0x05, 0x09, // Usage Page (Button)
|
||||
0x19, 0x01, // Usage Minimum (Button #1)
|
||||
0x29, 0x03, // Usage Maximum (Button #3)
|
||||
0x15, 0x00, // Logical Minimum (0)
|
||||
0x25, 0x01, // Logical Maximum (1)
|
||||
0x95, 0x03, // Report Count (3)
|
||||
0x75, 0x01, // Report Size (1)
|
||||
0x81, 0x02, // Input (Data, Variable, Absolute)
|
||||
0x95, 0x01, // Report Count (1)
|
||||
0x75, 0x05, // Report Size (5)
|
||||
0x81, 0x03, // Input (Constant)
|
||||
0x05, 0x01, // Usage Page (Generic Desktop)
|
||||
0x09, 0x30, // Usage (X)
|
||||
0x09, 0x31, // Usage (Y)
|
||||
0x15, 0x81, // Logical Minimum (-127)
|
||||
0x25, 0x7F, // Logical Maximum (127)
|
||||
0x75, 0x08, // Report Size (8),
|
||||
0x95, 0x02, // Report Count (2),
|
||||
0x81, 0x06, // Input (Data, Variable, Relative)
|
||||
0x09, 0x38, // Usage (Wheel)
|
||||
0x95, 0x01, // Report Count (1),
|
||||
0x81, 0x06, // Input (Data, Variable, Relative)
|
||||
0xC0 // End Collection
|
||||
0x05, 0x01, // Usage Page (Generic Desktop)
|
||||
0x09, 0x02, // Usage (Mouse)
|
||||
0xA1, 0x01, // Collection (Application)
|
||||
0x05, 0x09, // Usage Page (Button)
|
||||
0x19, 0x01, // Usage Minimum (Button #1)
|
||||
0x29, 0x03, // Usage Maximum (Button #3)
|
||||
0x15, 0x00, // Logical Minimum (0)
|
||||
0x25, 0x01, // Logical Maximum (1)
|
||||
0x95, 0x03, // Report Count (3)
|
||||
0x75, 0x01, // Report Size (1)
|
||||
0x81, 0x02, // Input (Data, Variable, Absolute)
|
||||
0x95, 0x01, // Report Count (1)
|
||||
0x75, 0x05, // Report Size (5)
|
||||
0x81, 0x03, // Input (Constant)
|
||||
0x05, 0x01, // Usage Page (Generic Desktop)
|
||||
0x09, 0x30, // Usage (X)
|
||||
0x09, 0x31, // Usage (Y)
|
||||
0x15, 0x81, // Logical Minimum (-127)
|
||||
0x25, 0x7F, // Logical Maximum (127)
|
||||
0x75, 0x08, // Report Size (8),
|
||||
0x95, 0x02, // Report Count (2),
|
||||
0x81, 0x06, // Input (Data, Variable, Relative)
|
||||
0x09, 0x38, // Usage (Wheel)
|
||||
0x95, 0x01, // Report Count (1),
|
||||
0x81, 0x06, // Input (Data, Variable, Relative)
|
||||
0xC0 // End Collection
|
||||
};
|
||||
|
||||
static uint8_t PROGMEM debug_hid_report_desc[] = {
|
||||
|
@ -642,7 +646,10 @@ ISR(USB_COM_vect)
|
|||
}
|
||||
if (wIndex == MOUSE_INTERFACE) {
|
||||
if (bmRequestType == 0xA1) {
|
||||
print("mouse: 0xA1\n");
|
||||
if (bRequest == HID_GET_REPORT) {
|
||||
if (wValue == HID_REPORT_INPUT) {
|
||||
print("mouse: HID_GET_REPORT: input\n");
|
||||
usb_wait_in_ready();
|
||||
UEDATX = mouse_buttons;
|
||||
UEDATX = 0;
|
||||
|
@ -650,6 +657,14 @@ ISR(USB_COM_vect)
|
|||
UEDATX = 0;
|
||||
usb_send_in();
|
||||
return;
|
||||
}
|
||||
if (wValue == HID_REPORT_FEATURE) {
|
||||
print("mouse: HID_GET_REPORT: feature\n");
|
||||
usb_wait_in_ready();
|
||||
UEDATX = 0x05;
|
||||
usb_send_in();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (bRequest == HID_GET_PROTOCOL) {
|
||||
usb_wait_in_ready();
|
||||
|
@ -659,6 +674,7 @@ ISR(USB_COM_vect)
|
|||
}
|
||||
}
|
||||
if (bmRequestType == 0x21) {
|
||||
print("mouse: 0x21\n");
|
||||
if (bRequest == HID_SET_PROTOCOL) {
|
||||
mouse_protocol = wValue;
|
||||
usb_send_in();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue