[PATCH 4/4] dinput: Restore effect ID on error due to kernel < 3.14 bug

Bruno Jesus 00cpxxx at gmail.com
Mon Aug 22 20:06:58 CDT 2016


Based on ideas by Elias Vanderstuyft

Full discussion:
http://www.mail-archive.com/linux-input@vger.kernel.org/msg08513.html

Signed-off-by: Bruno Jesus <00cpxxx at gmail.com>
---
 dlls/dinput/effect_linuxinput.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/dlls/dinput/effect_linuxinput.c b/dlls/dinput/effect_linuxinput.c
index 642dfc0..bbcadf5 100644
--- a/dlls/dinput/effect_linuxinput.c
+++ b/dlls/dinput/effect_linuxinput.c
@@ -173,14 +173,19 @@ static HRESULT WINAPI LinuxInputEffectImpl_Download(
 	LPDIRECTINPUTEFFECT iface)
 {
     LinuxInputEffectImpl *This = impl_from_IDirectInputEffect(iface);
-    int ret;
+    int ret, old_effect_id;
 
     TRACE("(this=%p)\n", This);
     ff_dump_effect(&This->effect);
 
+    old_effect_id = This->effect.id;
     if (ioctl(*(This->fd), EVIOCSFF, &This->effect) != -1)
         return DI_OK;
 
+    /* Linux kernel < 3.14 has a bug that incorrectly assigns an effect ID even
+     * on error, restore it here if that is the case. */
+    This->effect.id = old_effect_id;
+
     switch (errno)
     {
         case EINVAL:
-- 
2.9.3




More information about the wine-patches mailing list