add horizontal mouse wheel

pull/12/head
tmk 14 years ago
parent 34a90769c9
commit 82637ded27

@ -1,141 +0,0 @@
/*
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x02, // USAGE (Mouse)
0xa1, 0x01, // COLLECTION (Application)
0x09, 0x02, // USAGE (Mouse)
0xa1, 0x02, // COLLECTION (Logical)
0x09, 0x01, // USAGE (Pointer)
0xa1, 0x00, // COLLECTION (Physical)
// ------------------------------ Buttons
0x05, 0x09, // USAGE_PAGE (Button)
0x19, 0x01, // USAGE_MINIMUM (Button 1)
0x29, 0x05, // USAGE_MAXIMUM (Button 5)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x25, 0x01, // LOGICAL_MAXIMUM (1)
0x75, 0x01, // REPORT_SIZE (1)
0x95, 0x05, // REPORT_COUNT (5)
0x81, 0x02, // INPUT (Data,Var,Abs)
// ------------------------------ Padding
0x75, 0x03, // REPORT_SIZE (3)
0x95, 0x01, // REPORT_COUNT (1)
0x81, 0x03, // INPUT (Cnst,Var,Abs)
// ------------------------------ X,Y position
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,Var,Rel)
0xa1, 0x02, // COLLECTION (Logical)
// ------------------------------ Vertical wheel res multiplier
0x09, 0x48, // USAGE (Resolution Multiplier)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x25, 0x01, // LOGICAL_MAXIMUM (1)
0x35, 0x01, // PHYSICAL_MINIMUM (1)
0x45, 0x04, // PHYSICAL_MAXIMUM (4)
0x75, 0x02, // REPORT_SIZE (2)
0x95, 0x01, // REPORT_COUNT (1)
0xa4, // PUSH
0xb1, 0x02, // FEATURE (Data,Var,Abs)
// ------------------------------ Vertical wheel
0x09, 0x38, // USAGE (Wheel)
0x15, 0x81, // LOGICAL_MINIMUM (-127)
0x25, 0x7f, // LOGICAL_MAXIMUM (127)
0x35, 0x00, // PHYSICAL_MINIMUM (0) - reset physical
0x45, 0x00, // PHYSICAL_MAXIMUM (0)
0x75, 0x08, // REPORT_SIZE (8)
0x81, 0x06, // INPUT (Data,Var,Rel)
0xc0, // END_COLLECTION
0xa1, 0x02, // COLLECTION (Logical)
// ------------------------------ Horizontal wheel res multiplier
0x09, 0x48, // USAGE (Resolution Multiplier)
0xb4, // POP
0xb1, 0x02, // FEATURE (Data,Var,Abs)
// ------------------------------ Padding for Feature report
0x35, 0x00, // PHYSICAL_MINIMUM (0) - reset physical
0x45, 0x00, // PHYSICAL_MAXIMUM (0)
0x75, 0x04, // REPORT_SIZE (4)
0xb1, 0x03, // FEATURE (Cnst,Var,Abs)
// ------------------------------ Horizontal wheel
0x05, 0x0c, // USAGE_PAGE (Consumer Devices)
0x0a, 0x38, 0x02, // USAGE (AC Pan)
0x15, 0x81, // LOGICAL_MINIMUM (-127)
0x25, 0x7f, // LOGICAL_MAXIMUM (127)
0x75, 0x08, // REPORT_SIZE (8)
0x81, 0x06, // INPUT (Data,Var,Rel)
0xc0, // END_COLLECTION
0xc0, // END_COLLECTION
0xc0, // END_COLLECTION
0xc0 // END_COLLECTION
*/
/*
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x02, // USAGE (Mouse)
0xa1, 0x01, // COLLECTION (Application)
0x09, 0x02, // USAGE (Mouse)
0xa1, 0x02, // COLLECTION (Logical)
0x09, 0x01, // USAGE (Pointer)
0xa1, 0x00, // COLLECTION (Physical)
0x05, 0x09, // USAGE_PAGE (Button)
0x19, 0x01, // USAGE_MINIMUM (Button 1)
0x29, 0x05, // USAGE_MAXIMUM (Button 5)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x25, 0x01, // LOGICAL_MAXIMUM (1)
0x75, 0x01, // REPORT_SIZE (1)
0x95, 0x05, // REPORT_COUNT (5)
0x81, 0x02, // INPUT (Data,Var,Abs)
0x75, 0x03, // REPORT_SIZE (3)
0x95, 0x01, // REPORT_COUNT (1)
0x81, 0x03, // INPUT (Cnst,Var,Abs)
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,Var,Rel)
0xa1, 0x02, // COLLECTION (Logical)
0x09, 0x48, // USAGE (Resolution Multiplier)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x25, 0x01, // LOGICAL_MAXIMUM (1)
0x35, 0x01, // PHYSICAL_MINIMUM (1)
0x45, 0x04, // PHYSICAL_MAXIMUM (4)
0x75, 0x02, // REPORT_SIZE (2)
0x95, 0x01, // REPORT_COUNT (1)
0xb1, 0x02, // FEATURE (Data,Var,Abs)
0x09, 0x38, // USAGE (Wheel)
0x15, 0x81, // LOGICAL_MINIMUM (-127)
0x25, 0x7f, // LOGICAL_MAXIMUM (127)
0x35, 0x00, // PHYSICAL_MINIMUM (0)
0x45, 0x00, // PHYSICAL_MAXIMUM (0)
0x75, 0x08, // REPORT_SIZE (8)
0x81, 0x06, // INPUT (Data,Var,Rel)
0xc0, // END_COLLECTION
0xa1, 0x02, // COLLECTION (Logical)
0x09, 0x48, // USAGE (Resolution Multiplier)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x25, 0x01, // LOGICAL_MAXIMUM (1)
0x35, 0x01, // PHYSICAL_MINIMUM (1)
0x45, 0x04, // PHYSICAL_MAXIMUM (4)
0x75, 0x02, // REPORT_SIZE (2)
0xb1, 0x02, // FEATURE (Data,Var,Abs)
0x35, 0x00, // PHYSICAL_MINIMUM (0)
0x45, 0x00, // PHYSICAL_MAXIMUM (0)
0x75, 0x04, // REPORT_SIZE (4)
0xb1, 0x03, // FEATURE (Cnst,Var,Abs)
0x05, 0x0c, // USAGE_PAGE (Consumer Devices)
0x0a, 0x38, 0x02, // USAGE (AC Pan)
0x15, 0x81, // LOGICAL_MINIMUM (-127)
0x25, 0x7f, // LOGICAL_MAXIMUM (127)
0x75, 0x08, // REPORT_SIZE (8)
0x81, 0x06, // INPUT (Data,Var,Rel)
0xc0, // END_COLLECTION
0xc0, // END_COLLECTION
0xc0, // END_COLLECTION
0xc0 // END_COLLECTION
*/

@ -149,8 +149,8 @@ int main(void)
if (code == MS_BTN5) mouse_btn |= 1<<4; if (code == MS_BTN5) mouse_btn |= 1<<4;
if (code == MS_WH_UP) mouse_wheel += 1; if (code == MS_WH_UP) mouse_wheel += 1;
if (code == MS_WH_DOWN) mouse_wheel -= 1; if (code == MS_WH_DOWN) mouse_wheel -= 1;
if (code == MS_WH_LEFT) mouse_hwheel += 1; if (code == MS_WH_LEFT) mouse_hwheel -= 1;
if (code == MS_WH_RIGHT) mouse_hwheel -= 1; if (code == MS_WH_RIGHT) mouse_hwheel += 1;
} else { } else {
// normal keys // normal keys
if (key_index < 6) if (key_index < 6)

104
usb.c

@ -150,32 +150,76 @@ static uint8_t PROGMEM keyboard_hid_report_desc[] = {
// http://www.keil.com/forum/15671/ // http://www.keil.com/forum/15671/
// http://www.microsoft.com/whdc/device/input/wheel.mspx // http://www.microsoft.com/whdc/device/input/wheel.mspx
static uint8_t PROGMEM mouse_hid_report_desc[] = { static uint8_t PROGMEM mouse_hid_report_desc[] = {
0x05, 0x01, // Usage Page (Generic Desktop) 0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x02, // Usage (Mouse) 0x09, 0x02, // USAGE (Mouse)
0xA1, 0x01, // Collection (Application) 0xa1, 0x01, // COLLECTION (Application)
0x05, 0x09, // Usage Page (Button) 0x09, 0x02, // USAGE (Mouse)
0x19, 0x01, // Usage Minimum (Button #1) 0xa1, 0x02, // COLLECTION (Logical)
0x29, 0x03, // Usage Maximum (Button #3) 0x09, 0x01, // USAGE (Pointer)
0x15, 0x00, // Logical Minimum (0) 0xa1, 0x00, // COLLECTION (Physical)
0x25, 0x01, // Logical Maximum (1) // ------------------------------ Buttons
0x95, 0x03, // Report Count (3) 0x05, 0x09, // USAGE_PAGE (Button)
0x75, 0x01, // Report Size (1) 0x19, 0x01, // USAGE_MINIMUM (Button 1)
0x81, 0x02, // Input (Data, Variable, Absolute) 0x29, 0x05, // USAGE_MAXIMUM (Button 5)
0x95, 0x01, // Report Count (1) 0x15, 0x00, // LOGICAL_MINIMUM (0)
0x75, 0x05, // Report Size (5) 0x25, 0x01, // LOGICAL_MAXIMUM (1)
0x81, 0x03, // Input (Constant) 0x75, 0x01, // REPORT_SIZE (1)
0x05, 0x01, // Usage Page (Generic Desktop) 0x95, 0x05, // REPORT_COUNT (5)
0x09, 0x30, // Usage (X) 0x81, 0x02, // INPUT (Data,Var,Abs)
0x09, 0x31, // Usage (Y) // ------------------------------ Padding
0x15, 0x81, // Logical Minimum (-127) 0x75, 0x03, // REPORT_SIZE (3)
0x25, 0x7F, // Logical Maximum (127) 0x95, 0x01, // REPORT_COUNT (1)
0x75, 0x08, // Report Size (8), 0x81, 0x03, // INPUT (Cnst,Var,Abs)
0x95, 0x02, // Report Count (2), // ------------------------------ X,Y position
0x81, 0x06, // Input (Data, Variable, Relative) 0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x38, // Usage (Wheel) 0x09, 0x30, // USAGE (X)
0x95, 0x01, // Report Count (1), 0x09, 0x31, // USAGE (Y)
0x81, 0x06, // Input (Data, Variable, Relative) 0x15, 0x81, // LOGICAL_MINIMUM (-127)
0xC0 // End Collection 0x25, 0x7f, // LOGICAL_MAXIMUM (127)
0x75, 0x08, // REPORT_SIZE (8)
0x95, 0x02, // REPORT_COUNT (2)
0x81, 0x06, // INPUT (Data,Var,Rel)
0xa1, 0x02, // COLLECTION (Logical)
// ------------------------------ Vertical wheel res multiplier
0x09, 0x48, // USAGE (Resolution Multiplier)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x25, 0x01, // LOGICAL_MAXIMUM (1)
0x35, 0x01, // PHYSICAL_MINIMUM (1)
0x45, 0x04, // PHYSICAL_MAXIMUM (4)
0x75, 0x02, // REPORT_SIZE (2)
0x95, 0x01, // REPORT_COUNT (1)
0xa4, // PUSH
0xb1, 0x02, // FEATURE (Data,Var,Abs)
// ------------------------------ Vertical wheel
0x09, 0x38, // USAGE (Wheel)
0x15, 0x81, // LOGICAL_MINIMUM (-127)
0x25, 0x7f, // LOGICAL_MAXIMUM (127)
0x35, 0x00, // PHYSICAL_MINIMUM (0) - reset physical
0x45, 0x00, // PHYSICAL_MAXIMUM (0)
0x75, 0x08, // REPORT_SIZE (8)
0x81, 0x06, // INPUT (Data,Var,Rel)
0xc0, // END_COLLECTION
0xa1, 0x02, // COLLECTION (Logical)
// ------------------------------ Horizontal wheel res multiplier
0x09, 0x48, // USAGE (Resolution Multiplier)
0xb4, // POP
0xb1, 0x02, // FEATURE (Data,Var,Abs)
// ------------------------------ Padding for Feature report
0x35, 0x00, // PHYSICAL_MINIMUM (0) - reset physical
0x45, 0x00, // PHYSICAL_MAXIMUM (0)
0x75, 0x04, // REPORT_SIZE (4)
0xb1, 0x03, // FEATURE (Cnst,Var,Abs)
// ------------------------------ Horizontal wheel
0x05, 0x0c, // USAGE_PAGE (Consumer Devices)
0x0a, 0x38, 0x02, // USAGE (AC Pan)
0x15, 0x81, // LOGICAL_MINIMUM (-127)
0x25, 0x7f, // LOGICAL_MAXIMUM (127)
0x75, 0x08, // REPORT_SIZE (8)
0x81, 0x06, // INPUT (Data,Var,Rel)
0xc0, // END_COLLECTION
0xc0, // END_COLLECTION
0xc0, // END_COLLECTION
0xc0 // END_COLLECTION
}; };
static uint8_t PROGMEM debug_hid_report_desc[] = { static uint8_t PROGMEM debug_hid_report_desc[] = {
@ -258,7 +302,7 @@ static uint8_t PROGMEM config1_descriptor[CONFIG1_DESC_SIZE] = {
5, // bDescriptorType 5, // bDescriptorType
MOUSE_ENDPOINT | 0x80, // bEndpointAddress MOUSE_ENDPOINT | 0x80, // bEndpointAddress
0x03, // bmAttributes (0x03=intr) 0x03, // bmAttributes (0x03=intr)
4, 0, // wMaxPacketSize MOUSE_SIZE, 0, // wMaxPacketSize
1, // bInterval 1, // bInterval
// interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12 // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
@ -646,10 +690,8 @@ ISR(USB_COM_vect)
} }
if (wIndex == MOUSE_INTERFACE) { if (wIndex == MOUSE_INTERFACE) {
if (bmRequestType == 0xA1) { if (bmRequestType == 0xA1) {
print("mouse: 0xA1\n");
if (bRequest == HID_GET_REPORT) { if (bRequest == HID_GET_REPORT) {
if (wValue == HID_REPORT_INPUT) { if (wValue == HID_REPORT_INPUT) {
print("mouse: HID_GET_REPORT: input\n");
usb_wait_in_ready(); usb_wait_in_ready();
UEDATX = mouse_buttons; UEDATX = mouse_buttons;
UEDATX = 0; UEDATX = 0;
@ -659,7 +701,6 @@ print("mouse: HID_GET_REPORT: input\n");
return; return;
} }
if (wValue == HID_REPORT_FEATURE) { if (wValue == HID_REPORT_FEATURE) {
print("mouse: HID_GET_REPORT: feature\n");
usb_wait_in_ready(); usb_wait_in_ready();
UEDATX = 0x05; UEDATX = 0x05;
usb_send_in(); usb_send_in();
@ -674,7 +715,6 @@ print("mouse: HID_GET_REPORT: feature\n");
} }
} }
if (bmRequestType == 0x21) { if (bmRequestType == 0x21) {
print("mouse: 0x21\n");
if (bRequest == HID_SET_PROTOCOL) { if (bRequest == HID_SET_PROTOCOL) {
mouse_protocol = wValue; mouse_protocol = wValue;
usb_send_in(); usb_send_in();
@ -705,5 +745,3 @@ print("mouse: 0x21\n");
} }
UECONX = (1<<STALLRQ) | (1<<EPEN); // stall UECONX = (1<<STALLRQ) | (1<<EPEN); // stall
} }

@ -56,7 +56,8 @@ int8_t usb_mouse_move(int8_t x, int8_t y, int8_t wheel, int8_t hwheel)
UEDATX = x; UEDATX = x;
UEDATX = y; UEDATX = y;
UEDATX = wheel; UEDATX = wheel;
//UEDATX = hwheel; UEDATX = hwheel;
UEINTX = 0x3A; UEINTX = 0x3A;
SREG = intr_state; SREG = intr_state;
return 0; return 0;

Loading…
Cancel
Save