From bc55a51cf7629b035de77f09fef094da38c003df Mon Sep 17 00:00:00 2001 From: Raphael Assenat Date: Tue, 18 Aug 2015 23:24:23 -0400 Subject: [PATCH] Cleanup report descriptor a bit. - No longer an extra button 0 in linux --- Makefile.stk525 | 3 +++ main.c | 8 ++++++ n64.c | 4 +-- reportdesc.c | 65 ++++++++++++++++++++----------------------------- 4 files changed, 40 insertions(+), 40 deletions(-) diff --git a/Makefile.stk525 b/Makefile.stk525 index 8cad8c4..e4ae50a 100644 --- a/Makefile.stk525 +++ b/Makefile.stk525 @@ -16,6 +16,9 @@ all: $(HEXFILE) clean: rm -f $(PROGNAME).elf $(PROGNAME).hex $(PROGNAME).map $(OBJS) +main.o: main.c reportdesc.c dataHidReport.c + $(CC) $(CFLAGS) -c $< -o $@ + %.o: %.S $(CC) $(CFLAGS) -c $< -o $@ diff --git a/main.c b/main.c index 38c217d..b21c0b1 100644 --- a/main.c +++ b/main.c @@ -215,9 +215,11 @@ static unsigned char gamepad_report0[32]; // Output Report IDs for various functions #define REPORT_SET_EFFECT 0x01 +#define REPORT_SET_STATUS 0x02 #define REPORT_SET_PERIODIC 0x04 #define REPORT_SET_CONSTANT_FORCE 0x05 #define REPORT_EFFECT_OPERATION 0x0A +#define REPORT_EFFECT_BLOCK_IDX 0x0B #define REPORT_DISABLE_ACTUATORS 0x0C #define REPORT_PID_POOL 0x0D @@ -350,6 +352,12 @@ uint8_t hid_set_report_main(const struct usb_request *rq, const uint8_t *data, u switch(data[0]) { + case REPORT_SET_STATUS: + printf_P(PSTR("eff. set stat\r\n")); + break; + case REPORT_EFFECT_BLOCK_IDX: + printf_P(PSTR("eff. blk. idx\r\n")); + break; case REPORT_DISABLE_ACTUATORS: printf_P(PSTR("disable actuators\r\n")); break; diff --git a/n64.c b/n64.c index 54eaaf9..95ebbca 100644 --- a/n64.c +++ b/n64.c @@ -132,8 +132,10 @@ static char n64Update(void) } #ifdef BUTTON_A_RUMBLE_TEST must_rumble = force_rumble; + //printf("Caps: %02x %02x %02x\r\n", caps[0], caps[1], caps[2]); #endif + switch (n64_rumble_state) { case RSTATE_INIT: @@ -257,8 +259,6 @@ static char n64Update(void) xval += 16000; yval += 16000; - printf("x: 0x%04x -> ", xval, yval); - last_built_report[1] = ((uint8_t*)&xval)[0]; last_built_report[2] = ((uint8_t*)&xval)[1]; diff --git a/reportdesc.c b/reportdesc.c index 7bac34c..82d7126 100644 --- a/reportdesc.c +++ b/reportdesc.c @@ -30,22 +30,17 @@ const uint8_t gcn64_usbHidReportDescriptor[] PROGMEM = { 0x09,0x05, // Usage Joystick 0xA1,0x01, // Collection Application //axis - 0x85,0x01, // Report ID 1 - // not sure how this is to work? -// 0x05, 0x02, //USAGE_PAGE (Simulation Controls) - //0x09, 0xBB, //USAGE (Throttle) +// 0x09, 0x01, // usage pointer 0xA1, 0x00, // COLLECTION (phys) - 0x05, 0x01, // USAGE_PAGE (Generic desktop) + 0x85,0x01, // Report ID 1 + 0x05, 0x01, // USAGE_PAGE (Generic desktop) 0x75, 0x10, // REPORT_SIZE (16) 0x95, 0x06, // REPORT_COUNT (6) 0x15, 0x00, // LOGICAL_MINIMUM (0) 0x26, 0x00, 0x7D, // LOGICAL_MAXIMUM (32000) -// 0x16, 0x00, // Physical Minimum (0) -// 0x46, 0x00, 0x7D, // Physical Maximum (32000) - 0x09, 0x30, // USAGE (X) 0x09, 0x31, // USAGE (Y) 0x09, 0x33, // USAGE (Rx) @@ -53,32 +48,23 @@ const uint8_t gcn64_usbHidReportDescriptor[] PROGMEM = { 0x09, 0x35, // USAGE (Rz) 0x09, 0x36, // USAGE (Slider) 0x81, 0x02, // INPUT + 0xc0, // END COLLECTION #define NUM_BUTTONS 16 //buttons - 0x05, 0x09, // USAGE_PAGE (Button) - 0x15, 0x00, // LOGICAL_MINIMUM (0) - 0x25, 0x01, // LOGICAL_MAXIMUM (1) - 0x75, 0x01, // REPORT_SIZE (1) - 0x95, NUM_BUTTONS, // REPORT_COUNT (14) - 0x19, 0x01, // USAGE_MINIMUM (Button 1) - 0x29, NUM_BUTTONS, // USAGE_MAXIMUM (Button 14) - 0x75, 0x01, // REPORT_SIZE (1) - 0x95, NUM_BUTTONS, // REPORT_COUNT (16) - 0x81, 0x02, // INPUT - + 0xA1, 0x00, // COLLECTION (phys) + 0x05, 0x09, // USAGE_PAGE (Button) + 0x15, 0x00, // LOGICAL_MINIMUM (0) + 0x25, 0x01, // LOGICAL_MAXIMUM (1) + 0x75, 0x01, // REPORT_SIZE (1) + 0x95, NUM_BUTTONS, // REPORT_COUNT (14) + 0x19, 0x01, // USAGE_MINIMUM (Button 1) + 0x29, NUM_BUTTONS, // USAGE_MAXIMUM (Button 14) + 0x75, 0x01, // REPORT_SIZE (1) + 0x95, NUM_BUTTONS, // REPORT_COUNT (16) + 0x81, 0x02, // INPUT 0xc0, // END COLLECTION -#if 0 -//??? - 0x06,0x01,0xFF, // Usage Page Generic Desktop - 0x09,0x49, // Usage Undefined - 0x75,0x01, // Report Size 1 - 0x95,0x01, // Report Count 1 - 0x81,0x02, // Input (Variable) - 0x75,0x07, // Report Size 7 - 0x81,0x03, // Input (Constant, Variable) - #endif 0x05,0x0F, // Usage Page Physical Interface @@ -87,7 +73,11 @@ const uint8_t gcn64_usbHidReportDescriptor[] PROGMEM = { 0x85,0x02, // Report ID 2 0x09,0x9F, // Usage DS Device is Reset 0x09,0xA0, // Usage DS Device is Pause - 0x09,0xA4, // Usage Actuator Power + // RA: 2015-08-18: Removed this bit since it gets + // mapped to BTN_DEAD in linux's hid-input.c and this + // makes the adapter appear to have 17 buttons. + // +// 0x09,0xA4, // Usage Actuator Power 0x09,0xA5, // Usage Undefined 0x09,0xA6, // Usage Undefined 0x15,0x00, // Logical Minimum 0 @@ -95,19 +85,19 @@ const uint8_t gcn64_usbHidReportDescriptor[] PROGMEM = { 0x35,0x00, // Physical Minimum 0 0x45,0x01, // Physical Maximum 1 0x75,0x01, // Report Size 1 - 0x95,0x05, // Report Count 5 - 0x81,0x02, // Input (Variable) - 0x95,0x03, // Report Count 3 + 0x95,0x04, // Report Count 4 + 0x81,0x02, // Input (Variable) + 0x95,0x04, // Report Count 4 0x75,0x01, // Report Size 1 - 0x81,0x03, // Input (Constant, Variable) - 0x09,0x94, // Usage PID Device Control + 0x81,0x03, // Input (Constant, Variable) + 0x09,0x94, // Usage PID Device Control 0x15,0x00, // Logical Minimum 0 0x25,0x01, // Logical Maximum 1 0x35,0x00, // Physical Minimum 0 0x45,0x01, // Physical Maximum 1 0x75,0x01, // Report Size 1 0x95,0x01, // Report Count 1 - 0x81,0x02, // Input (Variable) + 0x81,0x02, // Input (Variable) 0x09,0x22, // Usage Effect Block Index 0x15,0x01, // Logical Minimum 1 0x25,0x28, // Logical Maximum 28h (40d) @@ -115,10 +105,9 @@ const uint8_t gcn64_usbHidReportDescriptor[] PROGMEM = { 0x45,0x28, // Physical Maximum 28h (40d) 0x75,0x07, // Report Size 7 0x95,0x01, // Report Count 1 - 0x81,0x02, // Input (Variable) + 0x81,0x02, // Input (Variable) 0xC0 , // End Collection - 0x09,0x21, // Usage Set Effect Report 0xA1,0x02, // Collection Datalink 0x85,0x01, // Report ID 1