forked from GloriousEggroll/proton-ge-custom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
proton-sdl_joy.patch
2604 lines (2536 loc) · 91.9 KB
/
proton-sdl_joy.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
From 881abc8ac09f7076cdd765c04d6c1d05600296d9 Mon Sep 17 00:00:00 2001
From: Aric Stewart <[email protected]>
Date: Thu, 28 Dec 2017 12:43:32 -0600
Subject: [PATCH] dinput: Add SDL support
v2: Include comments from Andrew including opening and closing devices more cleanly
Signed-off-by: Aric Stewart <[email protected]>
---
dlls/dinput/Makefile.in | 4 +-
dlls/dinput/dinput_main.c | 21 ++
dlls/dinput/dinput_private.h | 1 +
dlls/dinput/joystick_sdl.c | 707 +++++++++++++++++++++++++++++++++++
dlls/dinput8/Makefile.in | 5 +-
5 files changed, 736 insertions(+), 2 deletions(-)
create mode 100644 dlls/dinput/joystick_sdl.c
diff --git a/dlls/dinput/Makefile.in b/dlls/dinput/Makefile.in
index 3b046d61d44..f968dbbcc32 100644
--- a/dlls/dinput/Makefile.in
+++ b/dlls/dinput/Makefile.in
@@ -2,7 +2,8 @@ MODULE = dinput.dll
IMPORTLIB = dinput
IMPORTS = dxguid uuid comctl32 ole32 user32 advapi32
EXTRADEFS = -DDIRECTINPUT_VERSION=0x0700
-EXTRALIBS = $(IOKIT_LIBS) $(FORCEFEEDBACK_LIBS)
+EXTRALIBS = $(IOKIT_LIBS) $(FORCEFEEDBACK_LIBS) $(SDL2_LIBS)
+EXTRAINCL = $(SDL2_CFLAGS)
C_SRCS = \
config.c \
@@ -14,6 +15,7 @@ C_SRCS = \
joystick_linux.c \
joystick_linuxinput.c \
joystick_osx.c \
+ joystick_sdl.c \
keyboard.c \
mouse.c
diff --git a/dlls/dinput/dinput_main.c b/dlls/dinput/dinput_main.c
index 54777da2d96..ad3619abcaf 100644
--- a/dlls/dinput/dinput_main.c
+++ b/dlls/dinput/dinput_main.c
@@ -88,6 +88,7 @@ static const struct dinput_device *dinput_devices[] =
{
&mouse_device,
&keyboard_device,
+ &joystick_sdl_device,
&joystick_linuxinput_device,
&joystick_linux_device,
&joystick_osx_device
@@ -451,6 +452,7 @@ static HRESULT WINAPI IDirectInputAImpl_EnumDevices(
unsigned int i;
int j;
HRESULT r;
+ BOOL found_device = FALSE;
TRACE("(this=%p,0x%04x '%s',%p,%p,0x%04x)\n",
This, dwDevType, _dump_DIDEVTYPE_value(dwDevType, This->dwVersion),
@@ -472,9 +474,15 @@ static HRESULT WINAPI IDirectInputAImpl_EnumDevices(
TRACE(" - checking device %u ('%s')\n", i, dinput_devices[i]->name);
r = dinput_devices[i]->enum_deviceA(dwDevType, dwFlags, &devInstance, This->dwVersion, j);
if (r == S_OK)
+ {
+ found_device = TRUE;
if (enum_callback_wrapper(lpCallback, &devInstance, pvRef) == DIENUM_STOP)
return S_OK;
+ }
}
+ /* If we have found devices after SDL stop enumeration */
+ if (dinput_devices[i] == &joystick_sdl_device && found_device)
+ return S_OK;
}
return S_OK;
@@ -491,6 +499,7 @@ static HRESULT WINAPI IDirectInputWImpl_EnumDevices(
unsigned int i;
int j;
HRESULT r;
+ BOOL found_device = FALSE;
TRACE("(this=%p,0x%04x '%s',%p,%p,0x%04x)\n",
This, dwDevType, _dump_DIDEVTYPE_value(dwDevType, This->dwVersion),
@@ -512,9 +521,15 @@ static HRESULT WINAPI IDirectInputWImpl_EnumDevices(
TRACE(" - checking device %u ('%s')\n", i, dinput_devices[i]->name);
r = dinput_devices[i]->enum_deviceW(dwDevType, dwFlags, &devInstance, This->dwVersion, j);
if (r == S_OK)
+ {
+ found_device = TRUE;
if (enum_callback_wrapper(lpCallback, &devInstance, pvRef) == DIENUM_STOP)
return S_OK;
+ }
}
+ /* If we have found devices after SDL stop enumeration */
+ if (dinput_devices[i] == &joystick_sdl_device && found_device)
+ return S_OK;
}
return S_OK;
@@ -1084,6 +1099,9 @@ static HRESULT WINAPI IDirectInput8AImpl_EnumDevicesBySemantics(
didevis[device_count-1] = didevi;
}
}
+ /* If we have found devices after SDL stop enumeration */
+ if (dinput_devices[i] == &joystick_sdl_device && device_count)
+ return S_OK;
}
remain = device_count;
@@ -1189,6 +1207,9 @@ static HRESULT WINAPI IDirectInput8WImpl_EnumDevicesBySemantics(
didevis[device_count-1] = didevi;
}
}
+ /* If we have found devices after SDL stop enumeration */
+ if (dinput_devices[i] == &joystick_sdl_device && device_count)
+ return S_OK;
}
remain = device_count;
diff --git a/dlls/dinput/dinput_private.h b/dlls/dinput/dinput_private.h
index abdfbeb2531..1d87999ff50 100644
--- a/dlls/dinput/dinput_private.h
+++ b/dlls/dinput/dinput_private.h
@@ -70,6 +70,7 @@ extern const struct dinput_device keyboard_device DECLSPEC_HIDDEN;
extern const struct dinput_device joystick_linux_device DECLSPEC_HIDDEN;
extern const struct dinput_device joystick_linuxinput_device DECLSPEC_HIDDEN;
extern const struct dinput_device joystick_osx_device DECLSPEC_HIDDEN;
+extern const struct dinput_device joystick_sdl_device DECLSPEC_HIDDEN;
extern void check_dinput_hooks(LPDIRECTINPUTDEVICE8W) DECLSPEC_HIDDEN;
extern void check_dinput_events(void) DECLSPEC_HIDDEN;
diff --git a/dlls/dinput/joystick_sdl.c b/dlls/dinput/joystick_sdl.c
new file mode 100644
index 00000000000..de54add9b6e
--- /dev/null
+++ b/dlls/dinput/joystick_sdl.c
@@ -0,0 +1,707 @@
+/* DirectInput Joystick device from SDL
+ *
+ * Copyright 1998,2000 Marcus Meissner
+ * Copyright 1998,1999 Lionel Ulmer
+ * Copyright 2000-2001 TransGaming Technologies Inc.
+ * Copyright 2005 Daniel Remenak
+ * Copyright 2017 CodeWeavers, Aric Stewart
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include "config.h"
+#include "wine/port.h"
+
+#include <assert.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+#ifdef HAVE_SDL2_SDL_H
+# include <SDL2/SDL.h>
+#endif
+#include <errno.h>
+
+#include "wine/debug.h"
+#include "wine/unicode.h"
+#include "wine/list.h"
+#include "windef.h"
+#include "winbase.h"
+#include "winerror.h"
+#include "winreg.h"
+#include "dinput.h"
+
+#include "dinput_private.h"
+#include "device_private.h"
+#include "joystick_private.h"
+
+#ifdef HAVE_SDL2_SDL_H
+
+WINE_DEFAULT_DEBUG_CHANNEL(dinput);
+
+typedef struct JoystickImpl JoystickImpl;
+static const IDirectInputDevice8AVtbl JoystickAvt;
+static const IDirectInputDevice8WVtbl JoystickWvt;
+
+struct SDLDev {
+ int id;
+ WORD vendor_id;
+ WORD product_id;
+ CHAR *name;
+
+ BOOL has_ff;
+};
+
+struct JoystickImpl
+{
+ struct JoystickGenericImpl generic;
+ struct SDLDev *sdldev;
+
+ SDL_Joystick *device;
+};
+
+static inline JoystickImpl *impl_from_IDirectInputDevice8A(IDirectInputDevice8A *iface)
+{
+ return CONTAINING_RECORD(CONTAINING_RECORD(CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8A_iface),
+ JoystickGenericImpl, base), JoystickImpl, generic);
+}
+static inline JoystickImpl *impl_from_IDirectInputDevice8W(IDirectInputDevice8W *iface)
+{
+ return CONTAINING_RECORD(CONTAINING_RECORD(CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8W_iface),
+ JoystickGenericImpl, base), JoystickImpl, generic);
+}
+
+static inline IDirectInputDevice8W *IDirectInputDevice8W_from_impl(JoystickImpl *This)
+{
+ return &This->generic.base.IDirectInputDevice8W_iface;
+}
+
+static const GUID DInput_Wine_SDL_Joystick_GUID = { /* 001E36B7-5DBA-4C4F-A8C9-CFC8689DB403 */
+ 0x001E36B7, 0x5DBA, 0x4C4F, {0xA8, 0xC9, 0xCF, 0xC8, 0x68, 0x9D, 0xB4, 0x03}
+};
+
+static int have_sdldevs = -1;
+static struct SDLDev *sdldevs = NULL;
+
+static void find_sdldevs(void)
+{
+ int i;
+
+ if (InterlockedCompareExchange(&have_sdldevs, 0, -1) != -1)
+ /* Someone beat us to it */
+ return;
+
+ SDL_Init(SDL_INIT_JOYSTICK|SDL_INIT_HAPTIC);
+ SDL_JoystickEventState(SDL_ENABLE);
+
+ for (i = 0; i < SDL_NumJoysticks(); i++)
+ {
+ struct SDLDev sdldev = {0};
+ struct SDLDev *new_sdldevs;
+ SDL_Joystick *device;
+ const CHAR* name;
+
+ sdldev.id = i;
+ device = SDL_JoystickOpen(i);
+
+ name = SDL_JoystickName(device);
+ sdldev.name = HeapAlloc(GetProcessHeap(), 0, strlen(name) + 1);
+ strcpy(sdldev.name, name);
+
+ if (device_disabled_registry(sdldev.name)) {
+ SDL_JoystickClose(device);
+ continue;
+ }
+
+ TRACE("Found a joystick (%i) on %p: %s\n", have_sdldevs, device, sdldev.name);
+
+ sdldev.vendor_id = SDL_JoystickGetVendor(device);
+ sdldev.product_id = SDL_JoystickGetProduct(device);
+
+ if (!have_sdldevs)
+ new_sdldevs = HeapAlloc(GetProcessHeap(), 0, sizeof(struct SDLDev));
+ else
+ new_sdldevs = HeapReAlloc(GetProcessHeap(), 0, sdldevs, (1 + have_sdldevs) * sizeof(struct SDLDev));
+
+ SDL_JoystickClose(device);
+ if (!new_sdldevs)
+ {
+ continue;
+ }
+ sdldevs = new_sdldevs;
+ sdldevs[have_sdldevs] = sdldev;
+ have_sdldevs++;
+ }
+}
+
+static void fill_joystick_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, DWORD version, int id)
+{
+ DWORD dwSize = lpddi->dwSize;
+
+ TRACE("%d %p\n", dwSize, lpddi);
+ memset(lpddi, 0, dwSize);
+
+ lpddi->dwSize = dwSize;
+ lpddi->guidInstance = DInput_Wine_SDL_Joystick_GUID;
+ lpddi->guidInstance.Data3 = id;
+ lpddi->guidProduct = DInput_Wine_SDL_Joystick_GUID;
+ lpddi->guidFFDriver = GUID_NULL;
+
+ if (version >= 0x0800)
+ lpddi->dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8);
+ else
+ lpddi->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
+
+ /* Assume the joystick as HID if it is attached to USB bus and has a valid VID/PID */
+ if ( sdldevs[id].vendor_id && sdldevs[id].product_id)
+ {
+ lpddi->dwDevType |= DIDEVTYPE_HID;
+ lpddi->wUsagePage = 0x01; /* Desktop */
+ if (lpddi->dwDevType == DI8DEVTYPE_JOYSTICK || lpddi->dwDevType == DIDEVTYPE_JOYSTICK)
+ lpddi->wUsage = 0x04; /* Joystick */
+ else
+ lpddi->wUsage = 0x05; /* Game Pad */
+ }
+
+ MultiByteToWideChar(CP_ACP, 0, sdldevs[id].name, -1, lpddi->tszInstanceName, MAX_PATH);
+ MultiByteToWideChar(CP_ACP, 0, sdldevs[id].name, -1, lpddi->tszProductName, MAX_PATH);
+}
+
+static void fill_joystick_dideviceinstanceA(LPDIDEVICEINSTANCEA lpddi, DWORD version, int id)
+{
+ DIDEVICEINSTANCEW lpddiW;
+ DWORD dwSize = lpddi->dwSize;
+
+ lpddiW.dwSize = sizeof(lpddiW);
+ fill_joystick_dideviceinstanceW(&lpddiW, version, id);
+
+ TRACE("%d %p\n", dwSize, lpddi);
+ memset(lpddi, 0, dwSize);
+
+ /* Convert W->A */
+ lpddi->dwSize = dwSize;
+ lpddi->guidInstance = lpddiW.guidInstance;
+ lpddi->guidProduct = lpddiW.guidProduct;
+ lpddi->dwDevType = lpddiW.dwDevType;
+ strcpy(lpddi->tszInstanceName, sdldevs[id].name);
+ strcpy(lpddi->tszProductName, sdldevs[id].name);
+ lpddi->guidFFDriver = lpddiW.guidFFDriver;
+ lpddi->wUsagePage = lpddiW.wUsagePage;
+ lpddi->wUsage = lpddiW.wUsage;
+}
+
+static HRESULT sdl_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, DWORD version, int id)
+{
+ find_sdldevs();
+
+ if (id >= have_sdldevs) {
+ return E_FAIL;
+ }
+
+ if (!((dwDevType == 0) ||
+ ((dwDevType == DIDEVTYPE_JOYSTICK) && (version > 0x0300 && version < 0x0800)) ||
+ (((dwDevType == DI8DEVCLASS_GAMECTRL) || (dwDevType == DI8DEVTYPE_JOYSTICK)) && (version >= 0x0800))))
+ return S_FALSE;
+
+ if (!(dwFlags & DIEDFL_FORCEFEEDBACK) || sdldevs[id].has_ff) {
+ fill_joystick_dideviceinstanceA(lpddi, version, id);
+ return S_OK;
+ }
+ return S_FALSE;
+}
+
+static HRESULT sdl_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, DWORD version, int id)
+{
+ find_sdldevs();
+
+ if (id >= have_sdldevs) {
+ return E_FAIL;
+ }
+
+ if (!((dwDevType == 0) ||
+ ((dwDevType == DIDEVTYPE_JOYSTICK) && (version > 0x0300 && version < 0x0800)) ||
+ (((dwDevType == DI8DEVCLASS_GAMECTRL) || (dwDevType == DI8DEVTYPE_JOYSTICK)) && (version >= 0x0800))))
+ return S_FALSE;
+
+ if (!(dwFlags & DIEDFL_FORCEFEEDBACK) || sdldevs[id].has_ff) {
+ fill_joystick_dideviceinstanceW(lpddi, version, id);
+ return S_OK;
+ }
+ return S_FALSE;
+}
+
+static void poll_sdl_device_state(LPDIRECTINPUTDEVICE8A iface)
+{
+ JoystickImpl *This = impl_from_IDirectInputDevice8A(iface);
+ int i;
+ int inst_id = 0;
+ int newVal = 0;
+
+ SDL_JoystickUpdate();
+
+ for (i = 0; i < SDL_JoystickNumButtons(This->device); i++)
+ {
+ int val = SDL_JoystickGetButton(This->device, i);
+ int oldVal = This->generic.js.rgbButtons[i];
+ newVal = val ? 0x80 : 0x0;
+ This->generic.js.rgbButtons[i] = newVal;
+ if (oldVal != newVal)
+ {
+ TRACE("Button: %i val %d oldVal %d newVal %d\n", i, val, oldVal, newVal);
+ inst_id = DIDFT_MAKEINSTANCE(i) | DIDFT_PSHBUTTON;
+ queue_event(iface, inst_id, newVal, GetCurrentTime(), This->generic.base.dinput->evsequence++);
+ }
+ }
+ for (i = 0; i < SDL_JoystickNumAxes(This->device); i++)
+ {
+ int oldVal;
+ newVal = SDL_JoystickGetAxis(This->device, i);
+ newVal = joystick_map_axis(&This->generic.props[i], newVal);
+ switch (i)
+ {
+ case 0: oldVal = This->generic.js.lX;
+ This->generic.js.lX = newVal; break;
+ case 1: oldVal = This->generic.js.lY;
+ This->generic.js.lY = newVal; break;
+ case 2: oldVal = This->generic.js.lZ;
+ This->generic.js.lZ = newVal; break;
+ case 3: oldVal = This->generic.js.lRx;
+ This->generic.js.lRx = newVal; break;
+ case 4: oldVal = This->generic.js.lRy;
+ This->generic.js.lRy = newVal; break;
+ case 5: oldVal = This->generic.js.lRz;
+ This->generic.js.lRz = newVal; break;
+ case 6: oldVal = This->generic.js.rglSlider[0];
+ This->generic.js.rglSlider[0] = newVal; break;
+ case 7: oldVal = This->generic.js.rglSlider[1];
+ This->generic.js.rglSlider[1] = newVal; break;
+ }
+ if (oldVal != newVal)
+ {
+ TRACE("Axis: %i oldVal %d newVal %d\n", i, oldVal, newVal);
+ inst_id = DIDFT_MAKEINSTANCE(i) | DIDFT_ABSAXIS;
+ queue_event(iface, inst_id, newVal, GetCurrentTime(), This->generic.base.dinput->evsequence++);
+ }
+ }
+ for (i = 0; i < SDL_JoystickNumHats(This->device); i++)
+ {
+ int oldVal = This->generic.js.rgdwPOV[i];
+ newVal = SDL_JoystickGetHat(This->device, i);
+ switch (newVal)
+ {
+ case SDL_HAT_CENTERED: newVal = -1; break;
+ case SDL_HAT_UP: newVal = 0; break;
+ case SDL_HAT_RIGHTUP:newVal = 4500; break;
+ case SDL_HAT_RIGHT: newVal = 9000; break;
+ case SDL_HAT_RIGHTDOWN: newVal = 13500; break;
+ case SDL_HAT_DOWN: newVal = 18000; break;
+ case SDL_HAT_LEFTDOWN: newVal = 22500; break;
+ case SDL_HAT_LEFT: newVal = 27000; break;
+ case SDL_HAT_LEFTUP: newVal = 31500; break;
+ }
+ if (oldVal != newVal)
+ {
+ TRACE("Hat : %i oldVal %d newVal %d\n", i, oldVal, newVal);
+ This->generic.js.rgdwPOV[i] = newVal;
+ inst_id = DIDFT_MAKEINSTANCE(i) | DIDFT_POV;
+ queue_event(iface, inst_id, newVal, GetCurrentTime(), This->generic.base.dinput->evsequence++);
+ }
+ }
+}
+
+static JoystickImpl *alloc_device(REFGUID rguid, IDirectInputImpl *dinput, unsigned short index)
+{
+ JoystickImpl* newDevice;
+ LPDIDATAFORMAT df = NULL;
+ DIDEVICEINSTANCEW ddi;
+ int i,idx = 0;
+
+ newDevice = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(JoystickImpl));
+ if (!newDevice) return NULL;
+
+ newDevice->generic.guidInstance = DInput_Wine_SDL_Joystick_GUID;
+ newDevice->generic.guidInstance.Data3 = index;
+ newDevice->generic.guidProduct = DInput_Wine_SDL_Joystick_GUID;
+ newDevice->generic.joy_polldev = poll_sdl_device_state;
+
+ newDevice->generic.base.IDirectInputDevice8A_iface.lpVtbl = &JoystickAvt;
+ newDevice->generic.base.IDirectInputDevice8W_iface.lpVtbl = &JoystickWvt;
+ newDevice->generic.base.ref = 1;
+ newDevice->generic.base.guid = *rguid;
+ newDevice->generic.base.dinput = dinput;
+ newDevice->sdldev = &sdldevs[index];
+ newDevice->generic.name = (char*)newDevice->sdldev->name;
+
+ InitializeCriticalSection(&newDevice->generic.base.crit);
+ newDevice->generic.base.crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": JoystickImpl*->base.crit");
+
+ /* Open Device */
+ newDevice->device = SDL_JoystickOpen(newDevice->sdldev->id);
+
+ /* Count number of available axes - supported Axis & POVs */
+ newDevice->generic.devcaps.dwAxes = SDL_JoystickNumAxes(newDevice->device);
+
+ if (newDevice->generic.devcaps.dwAxes > 8 )
+ {
+ WARN("Can't support %d axis. Clamping down to 8\n", newDevice->generic.devcaps.dwAxes);
+ newDevice->generic.devcaps.dwAxes = 8;
+ }
+
+ for (i = 0; i < newDevice->generic.devcaps.dwAxes; i++)
+ {
+ newDevice->generic.props[i].lDevMin = -32768;
+ newDevice->generic.props[i].lDevMax = 32767;
+ newDevice->generic.props[i].lMin = 0;
+ newDevice->generic.props[i].lMax = 0xffff;
+ newDevice->generic.props[i].lDeadZone = 0;
+ newDevice->generic.props[i].lSaturation = 0;
+ }
+
+ newDevice->generic.devcaps.dwPOVs = SDL_JoystickNumHats(newDevice->device);
+ if (newDevice->generic.devcaps.dwPOVs > 4)
+ {
+ WARN("Can't support %d POV. Clamping down to 4\n", newDevice->generic.devcaps.dwPOVs);
+ newDevice->generic.devcaps.dwPOVs = 4;
+ }
+
+ newDevice->generic.devcaps.dwButtons = SDL_JoystickNumButtons(newDevice->device);
+ if (newDevice->generic.devcaps.dwButtons > 128)
+ {
+ WARN("Can't support %d buttons. Clamping down to 128\n", newDevice->generic.devcaps.dwButtons);
+ newDevice->generic.devcaps.dwButtons = 128;
+ }
+
+ TRACE("axes %u povs %u buttons %u\n", newDevice->generic.devcaps.dwAxes, newDevice->generic.devcaps.dwPOVs, newDevice->generic.devcaps.dwButtons);
+
+ /* Create copy of default data format */
+ if (!(df = HeapAlloc(GetProcessHeap(), 0, c_dfDIJoystick2.dwSize))) goto failed;
+ memcpy(df, &c_dfDIJoystick2, c_dfDIJoystick2.dwSize);
+
+ df->dwNumObjs = newDevice->generic.devcaps.dwAxes + newDevice->generic.devcaps.dwPOVs + newDevice->generic.devcaps.dwButtons;
+ if (!(df->rgodf = HeapAlloc(GetProcessHeap(), 0, df->dwNumObjs * df->dwObjSize))) goto failed;
+
+ for (i = 0; i < newDevice->generic.devcaps.dwAxes; i++)
+ {
+ memcpy(&df->rgodf[idx], &c_dfDIJoystick2.rgodf[idx], df->dwObjSize);
+ df->rgodf[idx].dwType = DIDFT_MAKEINSTANCE(idx) | DIDFT_ABSAXIS;
+ ++idx;
+ }
+
+ for (i = 0; i < newDevice->generic.devcaps.dwPOVs; i++)
+ {
+ memcpy(&df->rgodf[idx], &c_dfDIJoystick2.rgodf[i + 8], df->dwObjSize);
+ df->rgodf[idx++].dwType = DIDFT_MAKEINSTANCE(i) | DIDFT_POV;
+ }
+
+ for (i = 0; i < newDevice->generic.devcaps.dwButtons; i++)
+ {
+ memcpy(&df->rgodf[idx], &c_dfDIJoystick2.rgodf[i + 12], df->dwObjSize);
+ df->rgodf[idx].pguid = &GUID_Button;
+ df->rgodf[idx++].dwType = DIDFT_MAKEINSTANCE(i) | DIDFT_PSHBUTTON;
+ }
+ newDevice->generic.base.data_format.wine_df = df;
+
+ /* Fill the caps */
+ newDevice->generic.devcaps.dwSize = sizeof(newDevice->generic.devcaps);
+ newDevice->generic.devcaps.dwFlags = DIDC_ATTACHED;
+
+ ddi.dwSize = sizeof(ddi);
+ fill_joystick_dideviceinstanceW(&ddi, newDevice->generic.base.dinput->dwVersion, index);
+ newDevice->generic.devcaps.dwDevType = ddi.dwDevType;
+
+ if (newDevice->sdldev->has_ff)
+ newDevice->generic.devcaps.dwFlags |= DIDC_FORCEFEEDBACK;
+
+ IDirectInput_AddRef(&newDevice->generic.base.dinput->IDirectInput7A_iface);
+
+ EnterCriticalSection(&dinput->crit);
+ list_add_tail(&dinput->devices_list, &newDevice->generic.base.entry);
+ LeaveCriticalSection(&dinput->crit);
+
+ return newDevice;
+
+failed:
+ if (df) HeapFree(GetProcessHeap(), 0, df->rgodf);
+ HeapFree(GetProcessHeap(), 0, df);
+ HeapFree(GetProcessHeap(), 0, newDevice);
+ return NULL;
+}
+
+/******************************************************************************
+ * get_joystick_index : Get the joystick index from a given GUID
+ */
+static unsigned short get_joystick_index(REFGUID guid)
+{
+ GUID wine_joystick = DInput_Wine_SDL_Joystick_GUID;
+ GUID dev_guid = *guid;
+
+ wine_joystick.Data3 = 0;
+ dev_guid.Data3 = 0;
+
+ /* for the standard joystick GUID use index 0 */
+ if(IsEqualGUID(&GUID_Joystick,guid)) return 0;
+
+ /* for the wine joystick GUIDs use the index stored in Data3 */
+ if(IsEqualGUID(&wine_joystick, &dev_guid)) return guid->Data3;
+
+ return 0xffff;
+}
+
+static HRESULT sdl_create_device(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPVOID *pdev, int unicode)
+{
+ unsigned short index;
+
+ TRACE("%p %s %s %p %i\n", dinput, debugstr_guid(rguid), debugstr_guid(riid), pdev, unicode);
+
+ find_sdldevs();
+ *pdev = NULL;
+
+ if ((index = get_joystick_index(rguid)) < 0xffff &&
+ have_sdldevs && index < have_sdldevs)
+ {
+ JoystickImpl *This;
+
+ if (riid == NULL)
+ ;/* nothing */
+ else if (IsEqualGUID(&IID_IDirectInputDeviceA, riid) ||
+ IsEqualGUID(&IID_IDirectInputDevice2A, riid) ||
+ IsEqualGUID(&IID_IDirectInputDevice7A, riid) ||
+ IsEqualGUID(&IID_IDirectInputDevice8A, riid))
+ {
+ unicode = 0;
+ }
+ else if (IsEqualGUID(&IID_IDirectInputDeviceW, riid) ||
+ IsEqualGUID(&IID_IDirectInputDevice2W, riid) ||
+ IsEqualGUID(&IID_IDirectInputDevice7W, riid) ||
+ IsEqualGUID(&IID_IDirectInputDevice8W, riid))
+ {
+ unicode = 1;
+ }
+ else
+ {
+ WARN("no interface\n");
+ return DIERR_NOINTERFACE;
+ }
+
+ This = alloc_device(rguid, dinput, index);
+ TRACE("Created a Joystick device (%p)\n", This);
+
+ if (!This) return DIERR_OUTOFMEMORY;
+
+ if (unicode)
+ *pdev = &This->generic.base.IDirectInputDevice8W_iface;
+ else
+ *pdev = &This->generic.base.IDirectInputDevice8A_iface;
+
+ return DI_OK;
+ }
+
+ return DIERR_DEVICENOTREG;
+}
+
+const struct dinput_device joystick_sdl_device = {
+ "Wine SDL joystick driver",
+ sdl_enum_deviceA,
+ sdl_enum_deviceW,
+ sdl_create_device
+};
+
+static ULONG WINAPI JoystickWImpl_Release(LPDIRECTINPUTDEVICE8W iface)
+{
+ JoystickImpl *This = impl_from_IDirectInputDevice8W(iface);
+ TRACE("(this=%p)\n", iface);
+ if (This->generic.base.ref == 1 && This->device >= 0)
+ {
+ TRACE("Closing Joystick: %p\n",This);
+ SDL_JoystickClose(This->device);
+ This->device = NULL;
+ }
+ return IDirectInputDevice2WImpl_Release(iface);
+}
+
+static ULONG WINAPI JoystickAImpl_Release(LPDIRECTINPUTDEVICE8A iface)
+{
+ JoystickImpl *This = impl_from_IDirectInputDevice8A(iface);
+ return JoystickWImpl_Release(IDirectInputDevice8W_from_impl(This));
+}
+
+/******************************************************************************
+ * GetProperty : get input device properties
+ */
+static HRESULT WINAPI JoystickWImpl_GetProperty(LPDIRECTINPUTDEVICE8W iface, REFGUID rguid, LPDIPROPHEADER pdiph)
+{
+ JoystickImpl *This = impl_from_IDirectInputDevice8W(iface);
+
+ TRACE("(this=%p,%s,%p)\n", iface, debugstr_guid(rguid), pdiph);
+ _dump_DIPROPHEADER(pdiph);
+
+ if (!IS_DIPROP(rguid)) return DI_OK;
+
+ switch (LOWORD(rguid)) {
+
+ case (DWORD_PTR) DIPROP_VIDPID:
+ {
+ LPDIPROPDWORD pd = (LPDIPROPDWORD)pdiph;
+
+ if (!This->sdldev->product_id || !This->sdldev->vendor_id)
+ return DIERR_UNSUPPORTED;
+ pd->dwData = MAKELONG(This->sdldev->vendor_id, This->sdldev->product_id);
+ TRACE("DIPROP_VIDPID(%08x)\n", pd->dwData);
+ break;
+ }
+ case (DWORD_PTR) DIPROP_JOYSTICKID:
+ {
+ LPDIPROPDWORD pd = (LPDIPROPDWORD)pdiph;
+
+ pd->dwData = This->sdldev->id;
+ TRACE("DIPROP_JOYSTICKID(%d)\n", pd->dwData);
+ break;
+ }
+
+ default:
+ return JoystickWGenericImpl_GetProperty(iface, rguid, pdiph);
+ }
+
+ return DI_OK;
+}
+
+static HRESULT WINAPI JoystickAImpl_GetProperty(LPDIRECTINPUTDEVICE8A iface, REFGUID rguid, LPDIPROPHEADER pdiph)
+{
+ JoystickImpl *This = impl_from_IDirectInputDevice8A(iface);
+ return JoystickWImpl_GetProperty(IDirectInputDevice8W_from_impl(This), rguid, pdiph);
+}
+
+/******************************************************************************
+ * GetDeviceInfo : get information about a device's identity
+ */
+static HRESULT WINAPI JoystickAImpl_GetDeviceInfo(LPDIRECTINPUTDEVICE8A iface,
+ LPDIDEVICEINSTANCEA pdidi)
+{
+ JoystickImpl *This = impl_from_IDirectInputDevice8A(iface);
+
+ TRACE("(%p) %p\n", This, pdidi);
+
+ if (pdidi == NULL) return E_POINTER;
+ if ((pdidi->dwSize != sizeof(DIDEVICEINSTANCE_DX3A)) &&
+ (pdidi->dwSize != sizeof(DIDEVICEINSTANCEA)))
+ return DIERR_INVALIDPARAM;
+
+ fill_joystick_dideviceinstanceA(pdidi, This->generic.base.dinput->dwVersion,
+ get_joystick_index(&This->generic.base.guid));
+ return DI_OK;
+}
+
+static HRESULT WINAPI JoystickWImpl_GetDeviceInfo(LPDIRECTINPUTDEVICE8W iface,
+ LPDIDEVICEINSTANCEW pdidi)
+{
+ JoystickImpl *This = impl_from_IDirectInputDevice8W(iface);
+
+ TRACE("(%p) %p\n", This, pdidi);
+
+ if (pdidi == NULL) return E_POINTER;
+ if ((pdidi->dwSize != sizeof(DIDEVICEINSTANCE_DX3W)) &&
+ (pdidi->dwSize != sizeof(DIDEVICEINSTANCEW)))
+ return DIERR_INVALIDPARAM;
+
+ fill_joystick_dideviceinstanceW(pdidi, This->generic.base.dinput->dwVersion,
+ get_joystick_index(&This->generic.base.guid));
+ return DI_OK;
+}
+
+static const IDirectInputDevice8AVtbl JoystickAvt =
+{
+ IDirectInputDevice2AImpl_QueryInterface,
+ IDirectInputDevice2AImpl_AddRef,
+ JoystickAImpl_Release,
+ JoystickAGenericImpl_GetCapabilities,
+ IDirectInputDevice2AImpl_EnumObjects,
+ JoystickAImpl_GetProperty,
+ JoystickAGenericImpl_SetProperty,
+ IDirectInputDevice2AImpl_Acquire,
+ IDirectInputDevice2AImpl_Unacquire,
+ JoystickAGenericImpl_GetDeviceState,
+ IDirectInputDevice2AImpl_GetDeviceData,
+ IDirectInputDevice2AImpl_SetDataFormat,
+ IDirectInputDevice2AImpl_SetEventNotification,
+ IDirectInputDevice2AImpl_SetCooperativeLevel,
+ JoystickAGenericImpl_GetObjectInfo,
+ JoystickAImpl_GetDeviceInfo,
+ IDirectInputDevice2AImpl_RunControlPanel,
+ IDirectInputDevice2AImpl_Initialize,
+ IDirectInputDevice2AImpl_CreateEffect,
+ IDirectInputDevice2AImpl_EnumEffects,
+ IDirectInputDevice2AImpl_GetEffectInfo,
+ IDirectInputDevice2AImpl_GetForceFeedbackState,
+ IDirectInputDevice2AImpl_SendForceFeedbackCommand,
+ IDirectInputDevice2AImpl_EnumCreatedEffectObjects,
+ IDirectInputDevice2AImpl_Escape,
+ JoystickAGenericImpl_Poll,
+ IDirectInputDevice2AImpl_SendDeviceData,
+ IDirectInputDevice7AImpl_EnumEffectsInFile,
+ IDirectInputDevice7AImpl_WriteEffectToFile,
+ JoystickAGenericImpl_BuildActionMap,
+ JoystickAGenericImpl_SetActionMap,
+ IDirectInputDevice8AImpl_GetImageInfo
+};
+
+static const IDirectInputDevice8WVtbl JoystickWvt =
+{
+ IDirectInputDevice2WImpl_QueryInterface,
+ IDirectInputDevice2WImpl_AddRef,
+ JoystickWImpl_Release,
+ JoystickWGenericImpl_GetCapabilities,
+ IDirectInputDevice2WImpl_EnumObjects,
+ JoystickWImpl_GetProperty,
+ JoystickWGenericImpl_SetProperty,
+ IDirectInputDevice2WImpl_Acquire,
+ IDirectInputDevice2WImpl_Unacquire,
+ JoystickWGenericImpl_GetDeviceState,
+ IDirectInputDevice2WImpl_GetDeviceData,
+ IDirectInputDevice2WImpl_SetDataFormat,
+ IDirectInputDevice2WImpl_SetEventNotification,
+ IDirectInputDevice2WImpl_SetCooperativeLevel,
+ JoystickWGenericImpl_GetObjectInfo,
+ JoystickWImpl_GetDeviceInfo,
+ IDirectInputDevice2WImpl_RunControlPanel,
+ IDirectInputDevice2WImpl_Initialize,
+ IDirectInputDevice2WImpl_CreateEffect,
+ IDirectInputDevice2WImpl_EnumEffects,
+ IDirectInputDevice2WImpl_GetEffectInfo,
+ IDirectInputDevice2WImpl_GetForceFeedbackState,
+ IDirectInputDevice2WImpl_SendForceFeedbackCommand,
+ IDirectInputDevice2WImpl_EnumCreatedEffectObjects,
+ IDirectInputDevice2WImpl_Escape,
+ JoystickWGenericImpl_Poll,
+ IDirectInputDevice2WImpl_SendDeviceData,
+ IDirectInputDevice7WImpl_EnumEffectsInFile,
+ IDirectInputDevice7WImpl_WriteEffectToFile,
+ JoystickWGenericImpl_BuildActionMap,
+ JoystickWGenericImpl_SetActionMap,
+ IDirectInputDevice8WImpl_GetImageInfo
+};
+
+#else
+
+const struct dinput_device joystick_sdl_device = {
+ "Wine SDL joystick driver",
+ NULL,
+ NULL,
+ NULL
+};
+
+#endif
diff --git a/dlls/dinput8/Makefile.in b/dlls/dinput8/Makefile.in
index 0ede9f0fb16..9735fb55465 100644
--- a/dlls/dinput8/Makefile.in
+++ b/dlls/dinput8/Makefile.in
@@ -2,7 +2,8 @@ MODULE = dinput8.dll
IMPORTLIB = dinput8
IMPORTS = dxguid uuid comctl32 ole32 user32 advapi32
EXTRADEFS = -DDIRECTINPUT_VERSION=0x0800
-EXTRALIBS = $(IOKIT_LIBS) $(FORCEFEEDBACK_LIBS)
+EXTRALIBS = $(IOKIT_LIBS) $(FORCEFEEDBACK_LIBS) $(SDL2_LIBS)
+EXTRAINCL = $(SDL2_CFLAGS)
PARENTSRC = ../dinput
C_SRCS = \
@@ -11,9 +12,11 @@ C_SRCS = \
device.c \
dinput_main.c \
effect_linuxinput.c \
+ effect_sdl.c \
joystick.c \
joystick_linux.c \
joystick_linuxinput.c \
+ joystick_sdl.c \
joystick_osx.c \
keyboard.c \
mouse.c
From 69287b9bd2fb18738811fc2e4fa988ada69de10c Mon Sep 17 00:00:00 2001
From: Aric Stewart <[email protected]>
Date: Thu, 28 Dec 2017 13:44:29 -0600
Subject: [PATCH] dinput: Begin SDL haptic implemeting Get/SetProperty
Signed-off-by: Aric Stewart <[email protected]>
---
dlls/dinput/joystick_sdl.c | 106 ++++++++++++++++++++++++++++++++++++-
1 file changed, 104 insertions(+), 2 deletions(-)
diff --git a/dlls/dinput/joystick_sdl.c b/dlls/dinput/joystick_sdl.c
index de54add9b6e..48608015105 100644
--- a/dlls/dinput/joystick_sdl.c
+++ b/dlls/dinput/joystick_sdl.c
@@ -65,6 +65,8 @@ struct SDLDev {
CHAR *name;
BOOL has_ff;
+ int autocenter;
+ int gain;
};
struct JoystickImpl
@@ -73,6 +75,7 @@ struct JoystickImpl
struct SDLDev *sdldev;
SDL_Joystick *device;
+ SDL_Haptic *haptic;
};
static inline JoystickImpl *impl_from_IDirectInputDevice8A(IDirectInputDevice8A *iface)
@@ -130,6 +133,17 @@ static void find_sdldevs(void)
TRACE("Found a joystick (%i) on %p: %s\n", have_sdldevs, device, sdldev.name);
+ if (SDL_JoystickIsHaptic(device))
+ {
+ SDL_Haptic *haptic = SDL_HapticOpenFromJoystick(device);
+ if (haptic)
+ {
+ TRACE(" ... with force feedback\n");
+ sdldev.has_ff = TRUE;
+ SDL_HapticClose(haptic);
+ }
+ }
+
sdldev.vendor_id = SDL_JoystickGetVendor(device);
sdldev.product_id = SDL_JoystickGetProduct(device);
@@ -352,6 +366,7 @@ static JoystickImpl *alloc_device(REFGUID rguid, IDirectInputImpl *dinput, unsig
/* Open Device */
newDevice->device = SDL_JoystickOpen(newDevice->sdldev->id);
+ newDevice->haptic = SDL_HapticOpenFromJoystick(newDevice->device);
/* Count number of available axes - supported Axis & POVs */
newDevice->generic.devcaps.dwAxes = SDL_JoystickNumAxes(newDevice->device);
@@ -399,6 +414,8 @@ static JoystickImpl *alloc_device(REFGUID rguid, IDirectInputImpl *dinput, unsig
{
memcpy(&df->rgodf[idx], &c_dfDIJoystick2.rgodf[idx], df->dwObjSize);
df->rgodf[idx].dwType = DIDFT_MAKEINSTANCE(idx) | DIDFT_ABSAXIS;
+ if (newDevice->sdldev->has_ff && i < 2)
+ df->rgodf[idx].dwFlags |= DIDOI_FFACTUATOR;
++idx;
}
@@ -414,6 +431,10 @@ static JoystickImpl *alloc_device(REFGUID rguid, IDirectInputImpl *dinput, unsig
df->rgodf[idx].pguid = &GUID_Button;
df->rgodf[idx++].dwType = DIDFT_MAKEINSTANCE(i) | DIDFT_PSHBUTTON;
}
+
+ if (newDevice->sdldev->has_ff)
+ newDevice->generic.devcaps.dwFlags |= DIDC_FORCEFEEDBACK;
+
newDevice->generic.base.data_format.wine_df = df;
/* Fill the caps */
@@ -528,6 +549,8 @@ static ULONG WINAPI JoystickWImpl_Release(LPDIRECTINPUTDEVICE8W iface)
if (This->generic.base.ref == 1 && This->device >= 0)
{
TRACE("Closing Joystick: %p\n",This);
+ if (This->sdldev->has_ff)
+ SDL_HapticClose(This->haptic);
SDL_JoystickClose(This->device);
This->device = NULL;
}
@@ -553,7 +576,22 @@ static HRESULT WINAPI JoystickWImpl_GetProperty(LPDIRECTINPUTDEVICE8W iface, REF
if (!IS_DIPROP(rguid)) return DI_OK;
switch (LOWORD(rguid)) {
+ case (DWORD_PTR) DIPROP_AUTOCENTER:
+ {
+ LPDIPROPDWORD pd = (LPDIPROPDWORD)pdiph;
+ pd->dwData = This->sdldev->autocenter ? DIPROPAUTOCENTER_ON : DIPROPAUTOCENTER_OFF;
+ TRACE("autocenter(%d)\n", pd->dwData);
+ break;
+ }
+ case (DWORD_PTR) DIPROP_FFGAIN:
+ {
+ LPDIPROPDWORD pd = (LPDIPROPDWORD)pdiph;
+
+ pd->dwData = This->sdldev->gain;
+ TRACE("DIPROP_FFGAIN(%d)\n", pd->dwData);
+ break;
+ }
case (DWORD_PTR) DIPROP_VIDPID:
{
LPDIPROPDWORD pd = (LPDIPROPDWORD)pdiph;
@@ -586,6 +624,70 @@ static HRESULT WINAPI JoystickAImpl_GetProperty(LPDIRECTINPUTDEVICE8A iface, REF
return JoystickWImpl_GetProperty(IDirectInputDevice8W_from_impl(This), rguid, pdiph);
}
+static BOOL _SetProperty(JoystickImpl *This, const GUID *prop, const DIPROPHEADER *header)
+{
+ int rc;
+
+ switch(LOWORD(prop))
+ {
+ case (DWORD_PTR)DIPROP_AUTOCENTER:
+ {
+ LPCDIPROPDWORD pd = (LPCDIPROPDWORD)header;
+
+ This->sdldev->autocenter = pd->dwData == DIPROPAUTOCENTER_ON;
+
+ rc = SDL_HapticSetAutocenter(This->haptic, This->sdldev->autocenter * 100);
+ if (rc != 0)
+ ERR("SDL_HapticSetAutocenter failed: %s\n", SDL_GetError());
+ break;
+ }
+ case (DWORD_PTR)DIPROP_FFGAIN: