https://bugs.winehq.org/show_bug.cgi?id=45688
Bug ID: 45688 Summary: Gamepad appears both as dinput and xinput (eg. Valkyria Chronicles) Product: Wine Version: 3.11 Hardware: x86 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: directx-dinput Assignee: wine-bugs@winehq.org Reporter: gabriel.corona@enst-bretagne.fr Distribution: ---
AFAIU, on Windows a gamepad appears either on DirectInput or on XInput.
Some games are helpful and automatically work with both. For example, Valkyria Chronicles apparently automatically switches between DirectInput and Xinput based on the latests input.
On Wine >= 3.3, every gamepad appears both on DirecrInput and XInput. This is useful because the gamepad can work both on DirectInput and XInput gamed.
However, on Valkyria Chronicles (for example) the effect is that the game switches randomly between the two modes because it apparently sees the same gamepad from both APIs. This can be seen because the buttons displayes on screen change from numbered key labels ("1", "2", "3", etc.) and XInput based key labels ("A", "B", "C", "D").
In order to sucessfully run the game, I has to disable the gamepad from DirectInput (using "wine control"). This works, but prevents running DirectInput only games without reconfiguration.
A possible workaround would be to have an option to disable DirectInput gamepads if both libraries are mapped in the same process.
https://bugs.winehq.org/show_bug.cgi?id=45688
--- Comment #1 from Vincent Povirk madewokherd@gmail.com --- xinput controls can be accessed through dinput on Windows, but not all controllers support xinput.
MS has published sample code which uses WMI to test whether a dinput controller supports xinput, and ignore it if so: https://docs.microsoft.com/en-us/windows/desktop/xinput/xinput-and-directinp...
I don't think that approach works correctly on Wine.
https://bugs.winehq.org/show_bug.cgi?id=45688
--- Comment #2 from Hans Leidekker hans@meelstraat.net --- (In reply to Vincent Povirk from comment #1)
xinput controls can be accessed through dinput on Windows, but not all controllers support xinput.
MS has published sample code which uses WMI to test whether a dinput controller supports xinput, and ignore it if so: https://docs.microsoft.com/en-us/windows/desktop/xinput/xinput-and- directinput
I don't think that approach works correctly on Wine.
Support for Win32_PnPEntity has been added recently, so the query should succeed at least. It may not yield any results if your joystick is somehow not detected as a plug and play device.
If I plug in the Xbox 360 controller I have here and run that WMI query I get three results. Two of them identify as a joystick and contain IG_. One is a HID device and the other a Linux event device.
Reporter, can you attach a WINEDEBUG=+wbemprox,+hid,+plugplay,+setupapi trace?
https://bugs.winehq.org/show_bug.cgi?id=45688
--- Comment #3 from Gabriel Corona gabriel.corona@enst-bretagne.fr --- Created attachment 62168 --> https://bugs.winehq.org/attachment.cgi?id=62168 Logs
https://bugs.winehq.org/show_bug.cgi?id=45688
--- Comment #4 from Gabriel Corona gabriel.corona@enst-bretagne.fr --- I tried using the code from https://docs.microsoft.com/en-us/windows/desktop/xinput/xinput-and-directinp... like this :
BOOL CALLBACK enumCallback(const DIDEVICEINSTANCE* instance, VOID* context) { LPDIRECTINPUTDEVICE8 joystick; HRESULT hr = di->CreateDevice(instance->guidInstance, &joystick, NULL); if (FAILED(hr)) return DIENUM_CONTINUE;
OLECHAR* bstrGuid; StringFromCLSID(instance->guidInstance, &bstrGuid);
BOOL xinput = IsXInputDevice(&(instance->guidInstance)); printf("%ls\t%i\n", bstrGuid, xinput ? 1 : 0);
if (joystick) { joystick->Unacquire(); } return DIENUM_CONTINUE; }
int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { HRESULT hr;
if (FAILED(hr = DirectInput8Create(GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, (VOID**)&di, NULL))) { return hr; }
LPDIRECTINPUTDEVICE8 joystick; if (FAILED(hr = di->EnumDevices(DI8DEVCLASS_GAMECTRL, enumCallback, NULL, DIEDFL_ATTACHEDONLY))) { return hr; } return 0; }
Currently this routine seems to tell my dinput gamepad is not a xinput device: pEnumDevices->Next() is not retuning any result.
https://bugs.winehq.org/show_bug.cgi?id=45688
--- Comment #5 from Hans Leidekker hans@meelstraat.net --- I would expect to see setupapi traces related to the WMI query. Your version of Wine is probably too old. Win32_PnPEntity was added on August 6 so you need something newer than that.
https://bugs.winehq.org/show_bug.cgi?id=45688
zzzzzyzz@hacari.org changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |zzzzzyzz@hacari.org
https://bugs.winehq.org/show_bug.cgi?id=45688
Rémi Bernon rbernon@codeweavers.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |rbernon@codeweavers.com
--- Comment #6 from Rémi Bernon rbernon@codeweavers.com --- AFAIK this should be properly implemented now, although there's possibly some case issues that still need to be addressed (we report the "&IG_" suffix but I believe dinput properties / setupapi paths should instead maybe be lowercase).
https://bugs.winehq.org/show_bug.cgi?id=45688
Neko-san nekoNexus@protonmail.ch changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |nekoNexus@protonmail.ch