Page 1 of 1

NES Controller problems!?!?

Posted: Tue Jan 17, 2012 7:21 pm
by hootentoot
Hi everyone,

I built the "NES Gamepad on ATTiny45" project and encountered some problems.
The PC-AVR communication works so far, but the device is recognized as an HID keyboard rather than a gamepad.
I'm not able to configure it in Windows and no key events are sent to the PC (at least no key events I can see anywhere...).
I built the circuit with 2 diodes in series for power supply instead of the zener diodes at the data lines and my operating system is Windows 7 x64.

I hope anyone can help me, because I really want to play with this retro NES controller ;-)

Greetings,
Christoph

Re: NES Controller problems!?!?

Posted: Wed Jan 18, 2012 6:14 am
by ulao
Then you goofed the descriptor, joystick is what you want
0x09, 0x04, // USAGE (Joystick)

If you still have issues post your descriptor.

Re: NES Controller problems!?!?

Posted: Wed Jan 18, 2012 10:00 am
by hootentoot
I used the predefined descriptor of the project:

Code: Select all

 PROGMEM char usbHidReportDescriptor[USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH] = { /* USB report descriptor */       0x05, 0x01,                    // USAGE_PAGE (Generic Desktop)
    0x09, 0x05,                    // USAGE (Game Pad)
    0xa1, 0x01,                    //   COLLECTION (Application)
    0x09, 0x01,                    //     USAGE (Pointer)
    0xa1, 0x00,                    //     COLLECTION (Physical)
    0x09, 0x30,                    //       USAGE (X)
    0x09, 0x31,                    //       USAGE (Y)
    0x15, 0x00,                    //       LOGICAL_MINIMUM (0)
    0x26, 0xff, 0x00,            //      LOGICAL_MAXIMUM (255)
    0x75, 0x08,                    //       REPORT_SIZE (8)
    0x95, 0x02,                    //       REPORT_COUNT (2)
    0x81, 0x02,                    //       INPUT (Data,Var,Abs)
    0xc0,                          //     END_COLLECTION
    0x05, 0x09,                    //     USAGE_PAGE (Button)
    0x19, 0x01,                    //     USAGE_MINIMUM (Button 1)
    0x29, 0x04,                    //     USAGE_MAXIMUM (Button 4)
    0x15, 0x00,                    //     LOGICAL_MINIMUM (0)
    0x25, 0x01,                    //     LOGICAL_MAXIMUM (1)
    0x75, 0x01,                    //     REPORT_SIZE (1)
    0x95, 0x04,                    //     REPORT_COUNT (4)
    0x81, 0x02,                    //     INPUT (Data,Var,Abs)

    /* Padding.*/
    0x75, 0x01,                    //     REPORT_SIZE (1)
    0x95, 0x04,                    //     REPORT_COUNT (4)
    0x81, 0x03,                    //     INPUT (Constant,Var,Abs)
    0xc0,                          //   END_COLLECTION
};

Re: NES Controller problems!?!?

Posted: Thu Jan 19, 2012 6:35 pm
by hootentoot
I now tried some different HID descriptors for joysticks and even a standard mouse, but USBlyzr always shows me the device as an HID keyboard.
I'm a bit frustrated at the moment because I thought the device type only depends on the descriptor, but it seems to be different somehow...

I hope someone can tell me a reason for this phenomenon.

Greetings,
Christoph

Re: NES Controller problems!?!?

Posted: Fri Jan 20, 2012 11:41 am
by Daid
I've used almost the same descriptor for a gamepad without problems for WinXP and WinVista.
But maybe the PID/VID pair has something to do with it. Or the silly caching that windows does.

Re: NES Controller problems!?!?

Posted: Fri Jan 20, 2012 3:02 pm
by hootentoot
I now used the following selfmade descriptor:

Code: Select all

PROGMEM char usbHidReportDescriptor[USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH] = { /* USB report descriptor */
    0x05, 0x01,                    // USAGE_PAGE (Generic Desktop)
    0x09, 0x05,                    // USAGE (Game Pad)
    0xa1, 0x01,                    // COLLECTION (Application)
    0xa1, 0x00,                    //   COLLECTION (Physical)
    0x05, 0x01,                    //     USAGE_PAGE (Generic Desktop)
    0x09, 0x30,                    //     USAGE (X)
    0x09, 0x31,                    //     USAGE (Y)
    0x15, 0x00,                    //     LOGICAL_MINIMUM (0)
    0x26, 0xff, 0x00,              //     LOGICAL_MAXIMUM (255)
    0x75, 0x08,                    //     REPORT_SIZE (8)
    0x95, 0x02,                    //     REPORT_COUNT (2)
    0x81, 0x02,                    //     INPUT (Data,Var,Abs)
    0x05, 0x09,                    //     USAGE_PAGE (Button)
    0x19, 0x01,                    //     USAGE_MINIMUM (Button 1)
    0x29, 0x04,                    //     USAGE_MAXIMUM (Button 4)
    0x15, 0x00,                    //     LOGICAL_MINIMUM (0)
    0x25, 0x01,                    //     LOGICAL_MAXIMUM (1)
    0x95, 0x08,                    //     REPORT_COUNT (8)
    0x75, 0x01,                    //     REPORT_SIZE (1)
    0x81, 0x02,                    //     INPUT (Data,Var,Abs)
    0xc0,                          //   END_COLLECTION
    0xc0                           // END_COLLECTION
};


and it works now. I have no idea why, but it works like it should work.

Greetings!

Re: NES Controller problems!?!?

Posted: Mon Jan 23, 2012 4:08 am
by ulao
I bet because the report size was wrong, you need to calculate the report size when changing it. You proly just happened to find one that matched.