NES Controller problems!?!?

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Post Reply
hootentoot
Posts: 4
Joined: Tue Jan 17, 2012 7:12 pm

NES Controller problems!?!?

Post by hootentoot » Tue Jan 17, 2012 7:21 pm

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

ulao
Rank 4
Rank 4
Posts: 480
Joined: Mon Aug 25, 2008 8:45 pm

Re: NES Controller problems!?!?

Post by ulao » Wed Jan 18, 2012 6:14 am

Then you goofed the descriptor, joystick is what you want
0x09, 0x04, // USAGE (Joystick)

If you still have issues post your descriptor.

hootentoot
Posts: 4
Joined: Tue Jan 17, 2012 7:12 pm

Re: NES Controller problems!?!?

Post by hootentoot » Wed Jan 18, 2012 10:00 am

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
};

hootentoot
Posts: 4
Joined: Tue Jan 17, 2012 7:12 pm

Re: NES Controller problems!?!?

Post by hootentoot » Thu Jan 19, 2012 6:35 pm

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

Daid
Rank 2
Rank 2
Posts: 55
Joined: Mon Apr 18, 2011 12:19 pm

Re: NES Controller problems!?!?

Post by Daid » Fri Jan 20, 2012 11:41 am

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.

hootentoot
Posts: 4
Joined: Tue Jan 17, 2012 7:12 pm

Re: NES Controller problems!?!?

Post by hootentoot » Fri Jan 20, 2012 3:02 pm

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!

ulao
Rank 4
Rank 4
Posts: 480
Joined: Mon Aug 25, 2008 8:45 pm

Re: NES Controller problems!?!?

Post by ulao » Mon Jan 23, 2012 4:08 am

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.

Post Reply