2015-07-01, 23:30
(2015-07-01, 23:00)garbear Wrote:Yeah it works fine during the next scan so not really a problem. BTW this is a bluetooth controller I'm trying to get to work so rescanning on new USB devices isn't gonna help.(2015-07-01, 21:13)Montellese Wrote: Looking a bit at the joystick code is it possible that the following log message from CJoystickInterfaceDirectInput::EnumJoysticksCallback() is the reason why this (or any other) controller might not be detected with DirectInput:
Code:AddOnLog: Joystick Support: ********** HWND: 00000000
Because the code then returns early even though pdidInstance contains information that looks correct like the name being "Bluetooth Wireless Controller" (which is what I see in win7's game controller window.
NVM: That only happens at the beginning (probably because the window doesn't exist yet during boot). The next scan works but it then throws an exception when trying to initialize the discovered joystick. Will investigate further.
I remember running into this problem now. The window isn't created yet so GetMainWindowHandle() returns NULL. Peripheral buses are re-scanned every 5 seconds so it should work once the window is created. I'll probably also do this to force a scan when a USB device is attached.
(2015-07-01, 23:00)garbear Wrote:I have no idea about XInput or DirectInput so I'm just throwing ideas out there but isn't there some kind of unique identifier for each device. You have to have a way to know from which device a button press came from right?(2015-07-01, 21:13)Montellese Wrote: EDIT: OK I think I found the issue. At https://github.com/kodi-game/peripheral....ut.cpp#L84 you first copy all the detected CJoystickDirectInput pointers from m_scanResults into the joysticks output parameter (see https://github.com/kodi-game/peripheral....ck.cpp#L32) and then you clean up m_scanResult by deleting every CJoystick pointer it contains but since you previously copied those pointers to another vector you just destroyed the objects that you are later trying to initialize.
Removing the logic that deletes the pointers in m_scanResults gets me further and the joystick is successfully initialized but during the next scan it is recognized again and initialized again and then Kodi freezes.
I pushed a fix for this: https://github.com/kodi-game/peripheral....it/7643538 .
The next crash is probably due to logic here, which I copied from Kodi's peripherals subsystem. It breaks down when we can't differentiate between joysticks. The problem is, if two identical joysticks are attached and one is detached, how do we know which one?