USB Joystick driver

Discuss development specific to the Pi version of ADFFS
richw
Posts: 95
Joined: Sat Sep 14, 2013 9:05 pm

Re: USB Joystick driver

Post by richw » Mon Oct 08, 2018 11:06 pm

Odd. If you use the read *command, does it look like the correct axes and buttons respond?

The raw data might be misleading. I need to enhance the output to show the last 20 reads or something, as the data formats are not always the same.

I was reading up on bytev earlier. Looks reasonable!

JonAbbott
Posts: 2061
Joined: Thu Apr 11, 2013 12:13 pm
Location: Essex

Re: USB Joystick driver

Post by JonAbbott » Tue Oct 09, 2018 11:25 am

richw wrote:
Mon Oct 08, 2018 11:06 pm
If you use the read *command, does it look like the correct axes and buttons respond?
No it doesn't show any changes, but USBJoystick_Debug only ever shows the padding value which also explains why the first four buttons are always shown as being down.
richw wrote:
Mon Oct 08, 2018 11:06 pm
The raw data might be misleading. I need to enhance the output to show the last 20 reads or something, as the data formats are not always the same.
I read the raw data directly from the endpoint, so you could compare it to values from your clone.

I'll modify the source later to ignore the padding and see if that gets it working.

JonAbbott
Posts: 2061
Joined: Thu Apr 11, 2013 12:13 pm
Location: Essex

Re: USB Joystick driver

Post by JonAbbott » Tue Oct 09, 2018 2:48 pm

JonAbbott wrote:
Tue Oct 09, 2018 11:25 am
I'll modify the source later to ignore the padding and see if that gets it working.
By dropping the padding and the first 4 bytes of the USB data, the XB360 controller works correctly, so either the HID descriptor is different for an official XB360 wireless, or its not being parsed correctly. If you dump the raw USB data on your clone, does it match mine? I'm guessing everything is 4 bytes to the left? Unfortunately, I don't have a wired controller to see if wireless is adding 4 extra bytes on the front.

Here's the hack I added to upcallv_hook_handler after the buffer_read() call:

Code: Select all

  if (joy_data[i].vendor_id==0x45e && joy_data[i].product_id==0x719) {
    unsigned int zz2 = 0;
    for (unsigned int zz = 0; zz<joy_data[i].dlen; zz++) {
      if (zz!=3) {
        zz2+=buffer[zz];
      }
    }
    if (zz2==0 && buffer[3]==0xf0) {
      read = 0;
    }
    else {
      if (read == joy_data[i].dlen) {
        joy_data[i].good_reads++;
        joy_data[i].good_reads_delta++;
        memcpy(joy_data[i].data_buf, buffer+4, joy_data[i].dlen-4);
        joystick_decode(i);
      }
      else {
        joy_data[i].bad_reads++;
        joy_data[i].bad_reads_delta++;
      }
      return VECTOR_PASSON;
    }
  }
This also fixed the 8/16bit weirdness, which I guess was down to combination of the data being shifted and the D-Pad being mapped instead of the left thumbstick.

richw
Posts: 95
Joined: Sat Sep 14, 2013 9:05 pm

Re: USB Joystick driver

Post by richw » Tue Oct 09, 2018 5:04 pm

I have been doing some reading of the drivers for other platforms: the wireless one uses the same HID report descriptor format (as the wired), BUT in the received data packet, there is additional information. The first few bytes indicate something else, then the rest is identical, as you've found. I thought that there would be a touch more to it, which is why I was distracting myself by looking at ByteV, and hoping you'd spot the craziness in the 8/16-bit Acorn SWI handler. :)

I think I'll add in a proper 'device type', so I can cleanly differentiate between standard/xb360/xb360wireless (+ others as they appear) in the code.

So... the bit I don't understand... why does your SideWinder FF not work? Surely it doesn't work with the above hack?!

JonAbbott
Posts: 2061
Joined: Thu Apr 11, 2013 12:13 pm
Location: Essex

Re: USB Joystick driver

Post by JonAbbott » Wed Oct 10, 2018 9:51 am

richw wrote:
Tue Oct 09, 2018 5:04 pm
So... the bit I don't understand... why does your SideWinder FF not work? Surely it doesn't work with the above hack?!
I've just retested and its now working correctly :?

richw
Posts: 95
Joined: Sat Sep 14, 2013 9:05 pm

Re: USB Joystick driver

Post by richw » Wed Oct 10, 2018 5:41 pm

Phew - glad to hear it!

I've got my basic first draft of the I/O podule ADC emulation up-and-running, but I need to throw together a BASIC test utility, as I have nothing else to test it with. I think covering the official OSByte calls and BASIC's ADVAL command should be enough, but until we try it with some real software, we don't know for sure.

Post Reply