mirror of
https://gitlab.winehq.org/wine/wine-staging.git
synced 2024-09-13 09:17:20 -07:00
Remove re-implemented dinput patchsets
The HID code for handling devices, make it possible to remove some of the existing patchset.
This commit is contained in:
parent
56a387bf1d
commit
f3fd4a3903
@ -1,214 +0,0 @@
|
||||
From 24829b2ba6d5efd950f178b8282dda826c4d1df0 Mon Sep 17 00:00:00 2001
|
||||
From: Bruno Jesus <bjesus@codeweavers.com>
|
||||
Date: Thu, 28 Feb 2019 15:56:18 +1100
|
||||
Subject: [PATCH] dinput: Recalculated Axis after deadzone change.
|
||||
|
||||
Wine-bugs: https://bugs.winehq.org/show_bug.cgi?id=41317
|
||||
---
|
||||
dlls/dinput/joystick.c | 149 ++++++++++++++++++++++-------------------
|
||||
1 file changed, 80 insertions(+), 69 deletions(-)
|
||||
|
||||
diff --git a/dlls/dinput/joystick.c b/dlls/dinput/joystick.c
|
||||
index 433348cd04..c150528e3d 100644
|
||||
--- a/dlls/dinput/joystick.c
|
||||
+++ b/dlls/dinput/joystick.c
|
||||
@@ -312,6 +312,76 @@ BOOL is_xinput_device(const DIDEVCAPS *devcaps, WORD vid, WORD pid)
|
||||
return (devcaps->dwAxes == 6 && devcaps->dwButtons >= 14);
|
||||
}
|
||||
|
||||
+static void remap_init(JoystickGenericImpl *This, int obj, ObjProps *remap_props)
|
||||
+{
|
||||
+ /* Configure as if nothing changed so the helper functions can only change
|
||||
+ * what they need, thus reducing code duplication. */
|
||||
+ remap_props->lDevMin = remap_props->lMin = This->props[obj].lMin;
|
||||
+ remap_props->lDevMax = remap_props->lMax = This->props[obj].lMax;
|
||||
+
|
||||
+ remap_props->lDeadZone = This->props[obj].lDeadZone;
|
||||
+ remap_props->lSaturation = This->props[obj].lSaturation;
|
||||
+}
|
||||
+
|
||||
+static void remap_apply(JoystickGenericImpl *This, int obj, ObjProps *remap_props)
|
||||
+{
|
||||
+ /* Many games poll the joystick immediately after setting the range
|
||||
+ * for calibration purposes, so the old values need to be remapped
|
||||
+ * to the new range before it does so */
|
||||
+ switch (This->base.data_format.wine_df->rgodf[obj].dwOfs){
|
||||
+ case DIJOFS_X : This->js.lX = joystick_map_axis(remap_props, This->js.lX); break;
|
||||
+ case DIJOFS_Y : This->js.lY = joystick_map_axis(remap_props, This->js.lY); break;
|
||||
+ case DIJOFS_Z : This->js.lZ = joystick_map_axis(remap_props, This->js.lZ); break;
|
||||
+ case DIJOFS_RX : This->js.lRx = joystick_map_axis(remap_props, This->js.lRx); break;
|
||||
+ case DIJOFS_RY : This->js.lRy = joystick_map_axis(remap_props, This->js.lRy); break;
|
||||
+ case DIJOFS_RZ : This->js.lRz = joystick_map_axis(remap_props, This->js.lRz); break;
|
||||
+ case DIJOFS_SLIDER(0): This->js.rglSlider[0] = joystick_map_axis(remap_props, This->js.rglSlider[0]); break;
|
||||
+ case DIJOFS_SLIDER(1): This->js.rglSlider[1] = joystick_map_axis(remap_props, This->js.rglSlider[1]); break;
|
||||
+ default: break;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static void remap_range(JoystickGenericImpl *This, int obj, LPCDIPROPRANGE pr)
|
||||
+{
|
||||
+ ObjProps remap_props;
|
||||
+ remap_init(This, obj, &remap_props);
|
||||
+
|
||||
+ remap_props.lMin = pr->lMin;
|
||||
+ remap_props.lMax = pr->lMax;
|
||||
+
|
||||
+ remap_apply(This, obj, &remap_props);
|
||||
+
|
||||
+ /* Store new values */
|
||||
+ This->props[obj].lMin = pr->lMin;
|
||||
+ This->props[obj].lMax = pr->lMax;
|
||||
+}
|
||||
+
|
||||
+static void remap_deadzone(JoystickGenericImpl *This, int obj, LPCDIPROPDWORD pd)
|
||||
+{
|
||||
+ ObjProps remap_props;
|
||||
+ remap_init(This, obj, &remap_props);
|
||||
+
|
||||
+ remap_props.lDeadZone = pd->dwData;
|
||||
+
|
||||
+ remap_apply(This, obj, &remap_props);
|
||||
+
|
||||
+ /* Store new value */
|
||||
+ This->props[obj].lDeadZone = pd->dwData;
|
||||
+}
|
||||
+
|
||||
+static void remap_saturation(JoystickGenericImpl *This, int obj, LPCDIPROPDWORD pd)
|
||||
+{
|
||||
+ ObjProps remap_props;
|
||||
+ remap_init(This, obj, &remap_props);
|
||||
+
|
||||
+ remap_props.lSaturation = pd->dwData;
|
||||
+
|
||||
+ remap_apply(This, obj, &remap_props);
|
||||
+
|
||||
+ /* Store new value */
|
||||
+ This->props[obj].lSaturation = pd->dwData;
|
||||
+}
|
||||
+
|
||||
/******************************************************************************
|
||||
* SetProperty : change input device properties
|
||||
*/
|
||||
@@ -319,7 +389,6 @@ HRESULT WINAPI JoystickWGenericImpl_SetProperty(LPDIRECTINPUTDEVICE8W iface, REF
|
||||
{
|
||||
JoystickGenericImpl *This = impl_from_IDirectInputDevice8W(iface);
|
||||
DWORD i;
|
||||
- ObjProps remap_props;
|
||||
|
||||
TRACE("(%p,%s,%p)\n",This,debugstr_guid(rguid),ph);
|
||||
|
||||
@@ -336,69 +405,15 @@ HRESULT WINAPI JoystickWGenericImpl_SetProperty(LPDIRECTINPUTDEVICE8W iface, REF
|
||||
case (DWORD_PTR)DIPROP_RANGE: {
|
||||
LPCDIPROPRANGE pr = (LPCDIPROPRANGE)ph;
|
||||
if (ph->dwHow == DIPH_DEVICE) {
|
||||
-
|
||||
- /* Many games poll the joystick immediately after setting the range
|
||||
- * for calibration purposes, so the old values need to be remapped
|
||||
- * to the new range before it does so */
|
||||
-
|
||||
TRACE("proprange(%d,%d) all\n", pr->lMin, pr->lMax);
|
||||
- for (i = 0; i < This->base.data_format.wine_df->dwNumObjs; i++) {
|
||||
-
|
||||
- remap_props.lDevMin = This->props[i].lMin;
|
||||
- remap_props.lDevMax = This->props[i].lMax;
|
||||
-
|
||||
- remap_props.lDeadZone = This->props[i].lDeadZone;
|
||||
- remap_props.lSaturation = This->props[i].lSaturation;
|
||||
-
|
||||
- remap_props.lMin = pr->lMin;
|
||||
- remap_props.lMax = pr->lMax;
|
||||
-
|
||||
- switch (This->base.data_format.wine_df->rgodf[i].dwOfs) {
|
||||
- case DIJOFS_X : This->js.lX = joystick_map_axis(&remap_props, This->js.lX); break;
|
||||
- case DIJOFS_Y : This->js.lY = joystick_map_axis(&remap_props, This->js.lY); break;
|
||||
- case DIJOFS_Z : This->js.lZ = joystick_map_axis(&remap_props, This->js.lZ); break;
|
||||
- case DIJOFS_RX : This->js.lRx = joystick_map_axis(&remap_props, This->js.lRx); break;
|
||||
- case DIJOFS_RY : This->js.lRy = joystick_map_axis(&remap_props, This->js.lRy); break;
|
||||
- case DIJOFS_RZ : This->js.lRz = joystick_map_axis(&remap_props, This->js.lRz); break;
|
||||
- case DIJOFS_SLIDER(0): This->js.rglSlider[0] = joystick_map_axis(&remap_props, This->js.rglSlider[0]); break;
|
||||
- case DIJOFS_SLIDER(1): This->js.rglSlider[1] = joystick_map_axis(&remap_props, This->js.rglSlider[1]); break;
|
||||
- default: break;
|
||||
- }
|
||||
-
|
||||
- This->props[i].lMin = pr->lMin;
|
||||
- This->props[i].lMax = pr->lMax;
|
||||
- }
|
||||
+ for (i = 0; i < This->base.data_format.wine_df->dwNumObjs; i++)
|
||||
+ remap_range(This, i, pr);
|
||||
} else {
|
||||
int obj = find_property(&This->base.data_format, ph);
|
||||
|
||||
TRACE("proprange(%d,%d) obj=%d\n", pr->lMin, pr->lMax, obj);
|
||||
- if (obj >= 0) {
|
||||
-
|
||||
- remap_props.lDevMin = This->props[obj].lMin;
|
||||
- remap_props.lDevMax = This->props[obj].lMax;
|
||||
-
|
||||
- remap_props.lDeadZone = This->props[obj].lDeadZone;
|
||||
- remap_props.lSaturation = This->props[obj].lSaturation;
|
||||
-
|
||||
- remap_props.lMin = pr->lMin;
|
||||
- remap_props.lMax = pr->lMax;
|
||||
-
|
||||
- switch (This->base.data_format.wine_df->rgodf[obj].dwOfs) {
|
||||
- case DIJOFS_X : This->js.lX = joystick_map_axis(&remap_props, This->js.lX); break;
|
||||
- case DIJOFS_Y : This->js.lY = joystick_map_axis(&remap_props, This->js.lY); break;
|
||||
- case DIJOFS_Z : This->js.lZ = joystick_map_axis(&remap_props, This->js.lZ); break;
|
||||
- case DIJOFS_RX : This->js.lRx = joystick_map_axis(&remap_props, This->js.lRx); break;
|
||||
- case DIJOFS_RY : This->js.lRy = joystick_map_axis(&remap_props, This->js.lRy); break;
|
||||
- case DIJOFS_RZ : This->js.lRz = joystick_map_axis(&remap_props, This->js.lRz); break;
|
||||
- case DIJOFS_SLIDER(0): This->js.rglSlider[0] = joystick_map_axis(&remap_props, This->js.rglSlider[0]); break;
|
||||
- case DIJOFS_SLIDER(1): This->js.rglSlider[1] = joystick_map_axis(&remap_props, This->js.rglSlider[1]); break;
|
||||
- default: break;
|
||||
- }
|
||||
-
|
||||
- This->props[obj].lMin = pr->lMin;
|
||||
- This->props[obj].lMax = pr->lMax;
|
||||
- return DI_OK;
|
||||
- }
|
||||
+ if (obj >= 0)
|
||||
+ remap_range(This, obj, pr);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -407,15 +422,13 @@ HRESULT WINAPI JoystickWGenericImpl_SetProperty(LPDIRECTINPUTDEVICE8W iface, REF
|
||||
if (ph->dwHow == DIPH_DEVICE) {
|
||||
TRACE("deadzone(%d) all\n", pd->dwData);
|
||||
for (i = 0; i < This->base.data_format.wine_df->dwNumObjs; i++)
|
||||
- This->props[i].lDeadZone = pd->dwData;
|
||||
+ remap_deadzone(This, i, pd);
|
||||
} else {
|
||||
int obj = find_property(&This->base.data_format, ph);
|
||||
|
||||
TRACE("deadzone(%d) obj=%d\n", pd->dwData, obj);
|
||||
- if (obj >= 0) {
|
||||
- This->props[obj].lDeadZone = pd->dwData;
|
||||
- return DI_OK;
|
||||
- }
|
||||
+ if (obj >= 0)
|
||||
+ remap_deadzone(This, obj, pd);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -424,15 +437,13 @@ HRESULT WINAPI JoystickWGenericImpl_SetProperty(LPDIRECTINPUTDEVICE8W iface, REF
|
||||
if (ph->dwHow == DIPH_DEVICE) {
|
||||
TRACE("saturation(%d) all\n", pd->dwData);
|
||||
for (i = 0; i < This->base.data_format.wine_df->dwNumObjs; i++)
|
||||
- This->props[i].lSaturation = pd->dwData;
|
||||
+ remap_saturation(This, i, pd);
|
||||
} else {
|
||||
int obj = find_property(&This->base.data_format, ph);
|
||||
|
||||
TRACE("saturation(%d) obj=%d\n", pd->dwData, obj);
|
||||
- if (obj >= 0) {
|
||||
- This->props[obj].lSaturation = pd->dwData;
|
||||
- return DI_OK;
|
||||
- }
|
||||
+ if (obj >= 0)
|
||||
+ remap_saturation(This, obj, pd);
|
||||
}
|
||||
break;
|
||||
}
|
||||
--
|
||||
2.17.1
|
||||
|
@ -1,2 +0,0 @@
|
||||
Fixes: [41317] dinput: Recalculated Axis after deadzone change.
|
||||
Disabled: True
|
@ -1,88 +0,0 @@
|
||||
From 290d6b2b773e9729c38495ec8c1291b40678bc31 Mon Sep 17 00:00:00 2001
|
||||
From: Jetro Jormalainen <jje-wine@jv.jetro.fi>
|
||||
Date: Tue, 30 Apr 2019 09:20:20 +1000
|
||||
Subject: [PATCH 1/3] dinput: Load users Joystick mappings.
|
||||
|
||||
---
|
||||
dlls/dinput/device.c | 2 +-
|
||||
dlls/dinput/device_private.h | 2 ++
|
||||
dlls/dinput/joystick.c | 25 +++++++++++++++++++++++++
|
||||
3 files changed, 28 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c
|
||||
index 28329d03b5..d1bf934a82 100644
|
||||
--- a/dlls/dinput/device.c
|
||||
+++ b/dlls/dinput/device.c
|
||||
@@ -714,7 +714,7 @@ static HRESULT save_mapping_settings(IDirectInputDevice8W *iface, LPDIACTIONFORM
|
||||
return DI_OK;
|
||||
}
|
||||
|
||||
-static BOOL load_mapping_settings(IDirectInputDeviceImpl *This, LPDIACTIONFORMATW lpdiaf, const WCHAR *username)
|
||||
+BOOL load_mapping_settings(IDirectInputDeviceImpl *This, LPDIACTIONFORMATW lpdiaf, const WCHAR *username)
|
||||
{
|
||||
HKEY hkey;
|
||||
WCHAR *guid_str;
|
||||
diff --git a/dlls/dinput/device_private.h b/dlls/dinput/device_private.h
|
||||
index 27e9c26286..ea794d7396 100644
|
||||
--- a/dlls/dinput/device_private.h
|
||||
+++ b/dlls/dinput/device_private.h
|
||||
@@ -125,6 +125,8 @@ extern const char *_dump_dinput_GUID(const GUID *guid) DECLSPEC_HIDDEN;
|
||||
|
||||
extern LPDIOBJECTDATAFORMAT dataformat_to_odf_by_type(LPCDIDATAFORMAT df, int n, DWORD type) DECLSPEC_HIDDEN;
|
||||
|
||||
+extern BOOL load_mapping_settings(IDirectInputDeviceImpl *This, LPDIACTIONFORMATW lpdiaf, const WCHAR *username) DECLSPEC_HIDDEN;
|
||||
+
|
||||
extern HRESULT _build_action_map(LPDIRECTINPUTDEVICE8W iface, LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, DWORD dwFlags, DWORD devMask, LPCDIDATAFORMAT df) DECLSPEC_HIDDEN;
|
||||
extern HRESULT _set_action_map(LPDIRECTINPUTDEVICE8W iface, LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, DWORD dwFlags, LPCDIDATAFORMAT df) DECLSPEC_HIDDEN;
|
||||
|
||||
diff --git a/dlls/dinput/joystick.c b/dlls/dinput/joystick.c
|
||||
index 2220b5d576..8341e0313a 100644
|
||||
--- a/dlls/dinput/joystick.c
|
||||
+++ b/dlls/dinput/joystick.c
|
||||
@@ -28,8 +28,10 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
+#include "device_private.h"
|
||||
#include "joystick_private.h"
|
||||
#include "wine/debug.h"
|
||||
+#include "wine/heap.h"
|
||||
#include "winreg.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(dinput);
|
||||
@@ -825,9 +827,32 @@ HRESULT WINAPI JoystickWGenericImpl_BuildActionMap(LPDIRECTINPUTDEVICE8W iface,
|
||||
JoystickGenericImpl *This = impl_from_IDirectInputDevice8W(iface);
|
||||
unsigned int i, j;
|
||||
BOOL has_actions = FALSE;
|
||||
+ WCHAR *username;
|
||||
+ DWORD size;
|
||||
+ BOOL load_success = FALSE;
|
||||
|
||||
FIXME("(%p)->(%p,%s,%08x): semi-stub !\n", This, lpdiaf, debugstr_w(lpszUserName), dwFlags);
|
||||
|
||||
+ /* Unless asked the contrary by these flags, try to load a previous mapping */
|
||||
+ if (!(dwFlags & DIDBAM_HWDEFAULTS))
|
||||
+ {
|
||||
+ if (!lpszUserName)
|
||||
+ GetUserNameW(NULL, &size);
|
||||
+ else
|
||||
+ size = lstrlenW(lpszUserName) + 1;
|
||||
+
|
||||
+ username = heap_alloc(size * sizeof(WCHAR));
|
||||
+ if (!lpszUserName)
|
||||
+ GetUserNameW(username, &size);
|
||||
+ else
|
||||
+ lstrcpynW(username, lpszUserName, size);
|
||||
+
|
||||
+ load_success = load_mapping_settings((IDirectInputDeviceImpl *) This, lpdiaf, username);
|
||||
+ heap_free(username);
|
||||
+ }
|
||||
+
|
||||
+ if (load_success) return DI_OK;
|
||||
+
|
||||
for (i=0; i < lpdiaf->dwNumActions; i++)
|
||||
{
|
||||
DWORD inst = (0x000000ff & (lpdiaf->rgoAction[i].dwSemantic)) - 1;
|
||||
--
|
||||
2.17.1
|
||||
|
@ -1,232 +0,0 @@
|
||||
From 5a3007325917b8818493fc2193019e829916b733 Mon Sep 17 00:00:00 2001
|
||||
From: Andrew Church <achurch@achurch.org>
|
||||
Date: Mon, 25 Feb 2019 11:23:12 +1100
|
||||
Subject: [PATCH] dinput: Allow reconnecting to disconnected joysticks
|
||||
|
||||
Wine-bug: https://bugs.winehq.org/show_bug.cgi?id=34297
|
||||
---
|
||||
dlls/dinput/joystick_linuxinput.c | 152 ++++++++++++++++++++++--------
|
||||
1 file changed, 115 insertions(+), 37 deletions(-)
|
||||
|
||||
diff --git a/dlls/dinput/joystick_linuxinput.c b/dlls/dinput/joystick_linuxinput.c
|
||||
index 2b970271ec3..8e292904f78 100644
|
||||
--- a/dlls/dinput/joystick_linuxinput.c
|
||||
+++ b/dlls/dinput/joystick_linuxinput.c
|
||||
@@ -84,6 +84,13 @@ struct wine_input_absinfo {
|
||||
LONG flat;
|
||||
};
|
||||
|
||||
+enum wine_joystick_linuxinput_fd_state {
|
||||
+ WINE_FD_STATE_CLOSED = 0, /* No device has been opened yet */
|
||||
+ WINE_FD_STATE_OK, /* File descriptor is open and ready for reading */
|
||||
+ WINE_FD_STATE_DISCONNECTED, /* Read error occurred; might be able to reopen later */
|
||||
+ WINE_FD_STATE_INVALID, /* Device is no longer available at original pathname */
|
||||
+};
|
||||
+
|
||||
/* implemented in effect_linuxinput.c */
|
||||
HRESULT linuxinput_create_effect(int* fd, REFGUID rguid, struct list *parent_list_entry, LPDIRECTINPUTEFFECT* peff);
|
||||
HRESULT linuxinput_get_info_A(int fd, REFGUID rguid, LPDIEFFECTINFOA info);
|
||||
@@ -122,6 +129,7 @@ struct JoystickImpl
|
||||
|
||||
/* joystick private */
|
||||
int joyfd;
|
||||
+ enum wine_joystick_linuxinput_fd_state joyfd_state;
|
||||
|
||||
int dev_axes_to_di[ABS_MAX];
|
||||
POINTL povs[4];
|
||||
@@ -411,6 +419,7 @@ static HRESULT alloc_device( REFGUID rguid, IDirectInputImpl *dinput, JoystickIm
|
||||
|
||||
newDevice->generic.joy_polldev = joy_polldev;
|
||||
newDevice->joyfd = -1;
|
||||
+ newDevice->joyfd_state = WINE_FD_STATE_CLOSED;
|
||||
newDevice->joydev = &joydevs[index];
|
||||
newDevice->generic.name = newDevice->joydev->name;
|
||||
list_init(&newDevice->ff_effects);
|
||||
@@ -589,6 +598,44 @@ static HRESULT joydev_create_device( IDirectInputImpl *dinput, REFGUID rguid, ID
|
||||
return DIERR_DEVICENOTREG;
|
||||
}
|
||||
|
||||
+static int joydev_open_evdev(JoystickImpl *This)
|
||||
+{
|
||||
+ int fd;
|
||||
+
|
||||
+ if ((fd = open(This->joydev->device, O_RDWR)) == -1)
|
||||
+ {
|
||||
+ if ((fd = open(This->joydev->device, O_RDONLY)) == -1)
|
||||
+ {
|
||||
+ /* Couldn't open the device at all */
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ /* Couldn't open in r/w but opened in read-only. */
|
||||
+ WARN("Could not open %s in read-write mode. Force feedback will be disabled.\n", This->joydev->device);
|
||||
+ }
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ struct input_event event;
|
||||
+
|
||||
+ event.type = EV_FF;
|
||||
+ event.code = FF_GAIN;
|
||||
+ event.value = This->ff_gain;
|
||||
+ if (write(fd, &event, sizeof(event)) == -1)
|
||||
+ ERR("Failed to set gain (%i): %d %s\n", This->ff_gain, errno, strerror(errno));
|
||||
+ if (!This->ff_autocenter)
|
||||
+ {
|
||||
+ /* Disable autocenter. */
|
||||
+ event.code = FF_AUTOCENTER;
|
||||
+ event.value = 0;
|
||||
+ if (write(fd, &event, sizeof(event)) == -1)
|
||||
+ ERR("Failed disabling autocenter: %d %s\n", errno, strerror(errno));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return fd;
|
||||
+}
|
||||
+
|
||||
|
||||
const struct dinput_device joystick_linuxinput_device = {
|
||||
"Wine Linux-input joystick driver",
|
||||
@@ -612,40 +659,14 @@ static HRESULT WINAPI JoystickWImpl_Acquire(LPDIRECTINPUTDEVICE8W iface)
|
||||
return res;
|
||||
}
|
||||
|
||||
- if ((This->joyfd = open(This->joydev->device, O_RDWR)) == -1)
|
||||
+ if ((This->joyfd = joydev_open_evdev(This)) == -1)
|
||||
{
|
||||
- if ((This->joyfd = open(This->joydev->device, O_RDONLY)) == -1)
|
||||
- {
|
||||
- /* Couldn't open the device at all */
|
||||
- ERR("Failed to open device %s: %d %s\n", This->joydev->device, errno, strerror(errno));
|
||||
- IDirectInputDevice2WImpl_Unacquire(iface);
|
||||
- return DIERR_NOTFOUND;
|
||||
- }
|
||||
- else
|
||||
- {
|
||||
- /* Couldn't open in r/w but opened in read-only. */
|
||||
- WARN("Could not open %s in read-write mode. Force feedback will be disabled.\n", This->joydev->device);
|
||||
- }
|
||||
- }
|
||||
- else
|
||||
- {
|
||||
- struct input_event event;
|
||||
-
|
||||
- event.type = EV_FF;
|
||||
- event.code = FF_GAIN;
|
||||
- event.value = This->ff_gain;
|
||||
- if (write(This->joyfd, &event, sizeof(event)) == -1)
|
||||
- ERR("Failed to set gain (%i): %d %s\n", This->ff_gain, errno, strerror(errno));
|
||||
- if (!This->ff_autocenter)
|
||||
- {
|
||||
- /* Disable autocenter. */
|
||||
- event.code = FF_AUTOCENTER;
|
||||
- event.value = 0;
|
||||
- if (write(This->joyfd, &event, sizeof(event)) == -1)
|
||||
- ERR("Failed disabling autocenter: %d %s\n", errno, strerror(errno));
|
||||
- }
|
||||
+ ERR("Failed to open device %s: %d %s\n", This->joydev->device, errno, strerror(errno));
|
||||
+ IDirectInputDevice2WImpl_Unacquire(iface);
|
||||
+ return DIERR_NOTFOUND;
|
||||
}
|
||||
|
||||
+ This->joyfd_state = WINE_FD_STATE_OK;
|
||||
return DI_OK;
|
||||
}
|
||||
|
||||
@@ -677,6 +698,7 @@ static HRESULT WINAPI JoystickWImpl_Unacquire(LPDIRECTINPUTDEVICE8W iface)
|
||||
|
||||
close(This->joyfd);
|
||||
This->joyfd = -1;
|
||||
+ This->joyfd_state = WINE_FD_STATE_CLOSED;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@@ -715,23 +737,79 @@ static void joy_polldev( IDirectInputDevice8W *iface )
|
||||
struct input_event ie;
|
||||
JoystickImpl *This = impl_from_IDirectInputDevice8W( iface );
|
||||
|
||||
- if (This->joyfd==-1)
|
||||
- return;
|
||||
+ if (This->joyfd == -1)
|
||||
+ {
|
||||
+ int fd;
|
||||
+ char namebuf[MAX_PATH + 8]; /* 8 == strlen(EVDEVDRIVER) */
|
||||
+
|
||||
+ if (This->joyfd_state != WINE_FD_STATE_DISCONNECTED)
|
||||
+ return;
|
||||
+ /* Try to reconnect to the device. */
|
||||
+ fd = joydev_open_evdev(This);
|
||||
+ if (fd == -1)
|
||||
+ return;
|
||||
+ namebuf[sizeof(namebuf) - strlen(EVDEVDRIVER) - 1] = 0;
|
||||
+ if (ioctl(fd, EVIOCGNAME(sizeof(namebuf) - strlen(EVDEVDRIVER) - 1), namebuf) == -1)
|
||||
+ {
|
||||
+ /* Couldn't get the name; assume it's a different device. */
|
||||
+ ERR("EVIOCGNAME(%s) failed: %d %s", This->joydev->device, errno, strerror(errno));
|
||||
+ This->joyfd_state = WINE_FD_STATE_INVALID;
|
||||
+ return;
|
||||
+ }
|
||||
+ strcat(namebuf, EVDEVDRIVER); /* Guaranteed to be safe. */
|
||||
+ if (strcmp(namebuf, This->joydev->name) != 0)
|
||||
+ {
|
||||
+ ERR("Device %s changed from \"%s\" to \"%s\"! Can't reconnect.\n", This->joydev->device, This->joydev->name, namebuf);
|
||||
+ This->joyfd_state = WINE_FD_STATE_INVALID;
|
||||
+ return;
|
||||
+ }
|
||||
+ if (InterlockedCompareExchange(&This->joyfd, fd, -1) == -1)
|
||||
+ {
|
||||
+ This->joyfd_state = WINE_FD_STATE_OK;
|
||||
+ TRACE("Reconnected to \"%s\" on %s", This->joydev->name, This->joydev->device);
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ /* Somebody beat us to it! Throw away our fd and use theirs. */
|
||||
+ close(fd);
|
||||
+ }
|
||||
+ }
|
||||
|
||||
while (1)
|
||||
{
|
||||
LONG value = 0;
|
||||
int inst_id = -1;
|
||||
+ int result;
|
||||
|
||||
plfd.fd = This->joyfd;
|
||||
plfd.events = POLLIN;
|
||||
|
||||
- if (poll(&plfd,1,0) != 1)
|
||||
- return;
|
||||
+ result = poll(&plfd,1,0);
|
||||
+ if (result != 1)
|
||||
+ {
|
||||
+ if (result == -1)
|
||||
+ {
|
||||
+ ERR("poll failed: %d %s\n", errno, strerror(errno));
|
||||
+ close(This->joyfd);
|
||||
+ This->joyfd = -1;
|
||||
+ This->joyfd_state = WINE_FD_STATE_DISCONNECTED;
|
||||
+ }
|
||||
+ return;
|
||||
+ }
|
||||
|
||||
/* we have one event, so we can read */
|
||||
- if (sizeof(ie)!=read(This->joyfd,&ie,sizeof(ie)))
|
||||
- return;
|
||||
+ result = read(This->joyfd,&ie,sizeof(ie));
|
||||
+ if (result != sizeof(ie))
|
||||
+ {
|
||||
+ if (result == -1)
|
||||
+ {
|
||||
+ ERR("read failed: %d %s\n", errno, strerror(errno));
|
||||
+ close(This->joyfd);
|
||||
+ This->joyfd = -1;
|
||||
+ This->joyfd_state = WINE_FD_STATE_DISCONNECTED;
|
||||
+ }
|
||||
+ return;
|
||||
+ }
|
||||
|
||||
TRACE("input_event: type %d, code %d, value %d\n",ie.type,ie.code,ie.value);
|
||||
switch (ie.type) {
|
||||
--
|
||||
2.30.2
|
||||
|
@ -1,2 +0,0 @@
|
||||
Fixes: [34297] dinput: Allow reconnecting to disconnected joysticks
|
||||
Disabled: True
|
Loading…
Reference in New Issue
Block a user