Open GAELYNX opened 1 year ago
The reading of the input seems to be actually done in kernel/HID.c (HIDIRQRead).
I printed the 24 first packets at every call of HIDIRQRead and based on the information in the linux steam controller driver implementation (https://github.com/torvalds/linux/blob/master/drivers/hid/hid-steam.c) I see that the first set of packets is giving battery status, then the subsequent calls it's input data. But there is no data past the sequence number (offset 4-7). So, the buttons (offset 8-10) for example are always zero even when I press the buttons.
I did notice that with the Steam Controller connected in wired mode, by default we have both HIDKeyboardConnected and HIDControllerConnected that's because the wired mode creates 3 interfaces:
Again strangely the HID Test shows non-zero input data when I connect the Steam Controller with the same controller.ini config file so the implementation must be a bit different and I'd really like to see the source code for the HID Test to compare.
I didn't mean to close this, it was closed by mistake, it's still not resolved.
I did the setup of the controller.ini config file for the Steam Controller (in wired mode) and it works fine in the HID Test. But in game it doesn't work: the controller is detected but none of the inputs are responsive. So I downloaded the Nintendont source code to investigate.
I confirmed that the buttons mask & offset are correctly read from the config file and accessible through HID_CTRL. All the buttons are at offset 0x8 and 0x9 but the analog joystick and the two track-pads are s16 so they use two bytes: the Left-Pad / joystick X's values are at offset 0x11 (X) and 0x13 (Y) and the Right-Pad X at offset 0x15 (X) and 0x17 (Y).
From what I can see in the PADReadGC.c implementation I will need to add a special case of the Steam Controller to support two bytes per axis X or Y. There is also some additional (identifiable) value changes that happens when the trackpads are touched which overlap with the offset for one of the analog triggers, I would have to add some code to ignore these value changes so the trigger doesn't get false-positive input. I would also try and figure out how to use the Steam Controller haptics to support rumble.
But before I can do these changes, I have to figure out why it doesn't work even though the HID_CTRL has correct values. HID_Packet[0x0] == 0x01, HID_Packet[0x2] == 0x04, HID_Packet[0x3] == 0x0B these are the constant values that I observed in the default values shown in the HID Test when no input is received. The default values seems to be read from memory but when the input is given it seems that the HID packets aren't re-read from the memory: it's still the default values.
I see that the hid packets are read at 0x930050F0 and the memory is invalidated with the PowerPC assembly instruction dcbi which allows re-reading the input, but assembly code is not my forte and I can't tell for sure if the current code does support up to 64 byte of packets. The weird thing is that the buttons input is in the first 10 bytes which should be re-read from what I can tell in the code.
I can't find the source code of the HID Test to compare and see if anything was done differently. Any help would be appreciated! Thanks.