297{
300 IDirectInputDeviceA *pJoystick;
314 char oldstate[248], curstate[248];
316 LONG direction[2] = {0, 0};
323
324 ok(
data->version >= 0x0300,
"Joysticks not supported in version 0x%04x\n",
data->version);
325
327 ok(
hr==
E_POINTER,
"IDirectInput_CreateDevice() should have returned "
328 "E_POINTER, returned: %08x\n",
hr);
329
331 ok(
hr==
E_POINTER,
"IDirectInput_CreateDevice() should have returned "
332 "E_POINTER, returned: %08x\n",
hr);
333
335 ok(
hr==
E_POINTER,
"IDirectInput_CreateDevice() should have returned "
336 "E_POINTER, returned: %08x\n",
hr);
337
340 ok(
hr==
DI_OK,
"IDirectInput_CreateDevice() failed: %08x\n",
hr);
343
344 trace(
"---- Controller Information ----\n"
345 "Product Name : %s\n"
346 "Instance Name : %s\n"
347 "devType : 0x%08x\n"
348 "GUID Product : %s\n"
349 "GUID Instance : %s\n"
350 "HID Page : 0x%04x\n"
351 "HID Usage : 0x%04x\n",
359
360
363 "Expected a game controller HID UsagePage and Usage, got page 0x%x usage 0x%x\n",
365
366
372
374 ok(
SUCCEEDED(
hr),
"IDirectInputDevice_GetProperty() for DIPROP_JOYSTICKID failed\n");
375
376
377 memset(&dps, 0,
sizeof(dps));
381
383 ok(
SUCCEEDED(
hr),
"IDirectInput_GetProperty() for DIPROP_INSTANCENAME failed: %08x\n",
hr);
384
385
387 ok(!
lstrcmpW(nameBuffer, dps.
wsz),
"DIPROP_INSTANCENAME returned is wrong. Expected: %s Got: %s\n",
389
391 ok(
SUCCEEDED(
hr),
"IDirectInput_GetProperty() for DIPROP_PRODUCTNAME failed: %08x\n",
hr);
392
393
395 ok(!
lstrcmpW(nameBuffer, dps.
wsz),
"DIPROP_PRODUCTNAME returned is wrong. Expected: %s Got: %s\n",
397
398
399 memset(&dpg, 0,
sizeof(dpg));
403
405 ok(
SUCCEEDED(
hr),
"IDirectInput_GetProperty() for DIPROP_GUIDANDPATH failed: %08x\n",
hr);
406
407 {
408 static const WCHAR formatW[] = {
'\\',
'\\',
'?',
'\\',
'%',
'*',
'[',
'^',
'#',
']',
'#',
'v',
'i',
'd',
'_',
409 '%','0','4','x','&','p','i','d','_','%','0','4','x',0};
410 static const WCHAR miW[] = {
'm',
'i',
'_',0};
411 static const WCHAR igW[] = {
'i',
'g',
'_',0};
413
416 ok(
count == 2,
"DIPROP_GUIDANDPATH path has wrong format. Expected count: 2 Got: %i Path: %s\n",
419 "DIPROP_GUIDANDPATH path should contain either 'ig_' or 'mi_' substring. Path: %s\n",
421 }
422
424 ok(
hr==
E_POINTER,
"IDirectInputDevice_SetDataFormat() should have returned "
425 "E_POINTER, returned: %08x\n",
hr);
426
430 "returned DIERR_INVALIDPARAM, returned: %08x\n",
hr);
431
432
434 ok(
hr==
DI_OK,
"IDirectInputDevice_SetDataFormat() failed: %08x\n",
hr);
435
437 ok(
hr==
DI_OK,
"IDirectInputDevice_SetDataFormat() failed: %08x\n",
hr);
438
439
441 ok(
hr==
DI_OK,
"IDirectInputDevice_SetDataFormat() failed: %08x\n",
hr);
442
444 ok(
hr==
DI_OK,
"IDirectInputDevice_SetDataFormat() failed: %08x\n",
hr);
447
449 {
452 }
454 {
457 }
458
461 ok(
hr==
DI_OK,
"IDirectInputDevice_SetCooperativeLevel() failed: %08x\n",
hr);
462
463
466 "should have returned E_POINTER, returned: %08x\n",
hr);
467
471 "should have returned DIERR_INVALIDPARAM, returned: %08x\n",
hr);
472
473 caps.
dwSize =
sizeof(caps);
475 ok(
hr==
DI_OK,
"IDirectInputDevice_GetCapabilities() failed: %08x\n",
hr);
476
478 info.pJoystick = pJoystick;
479
480
483
485 ok(
hr==
DI_OK,
"IDirectInputDevice_EnumObjects() failed: %08x\n",
hr);
486
487 ok(caps.
dwAxes ==
info.axis,
"Number of enumerated axes (%d) doesn't match capabilities (%d)\n",
info.axis, caps.
dwAxes);
489 ok(caps.
dwPOVs ==
info.pov,
"Number of enumerated POVs (%d) doesn't match capabilities (%d)\n",
info.pov, caps.
dwPOVs);
490
491
493 ok(
hr==
DI_OK,
"IDirectInputDevice_SetDataFormat() failed: %08x\n",
hr);
498 ok(
hr==
DI_OK,
"IDirectInputDevice_EnumObjects() failed: %08x\n",
hr);
499
502 "should have returned E_POINTER, returned: %08x\n",
hr);
503
506
509 "should have returned DIERR_INVALIDPARAM, returned: %08x\n",
hr);
510
511 inst.
dwSize =
sizeof(inst);
513 ok(
hr==
DI_OK,
"IDirectInputDevice_GetDeviceInfo() failed: %08x\n",
hr);
514
515 inst3.
dwSize =
sizeof(inst3);
517 ok(
hr==
DI_OK,
"IDirectInputDevice_GetDeviceInfo() failed: %08x\n",
hr);
518
520 ok(
hr ==
S_FALSE,
"IDirectInputDevice_Unacquire() should have returned S_FALSE, got: %08x\n",
hr);
521
523 ok(
hr==
DI_OK,
"IDirectInputDevice_Acquire() failed: %08x\n",
hr);
526
528 ok(
hr ==
S_FALSE,
"IDirectInputDevice_Acquire() should have returned S_FALSE, got: %08x\n",
hr);
529
531 {
533 ok(
hr ==
DI_OK,
"IDirectInputDevice_GetDeviceState() failed: %08x\n",
hr);
534 ok(js.
rgdwPOV[3] == -1,
"Default for unassigned POV should be -1 not: %d\n", js.
rgdwPOV[3]);
535 }
536
537 trace(
"Testing force feedback\n");
538 ZeroMemory(&effect_data,
sizeof(effect_data));
539 effect_data.eff.dwSize = sizeof(effect_data.eff);
541 effect_data.eff.dwDuration =
INFINITE;
545 effect_data.eff.rgdwAxes = axes;
546 effect_data.eff.rglDirection = direction;
547
548
549
550
551
552
553
554
555 real_hWnd =
CreateWindowExA(0,
"EDIT",
"Test text", 0, 10, 10, 300, 300,
NULL,
NULL,
557 ok(real_hWnd!=0,
"CreateWindowExA failed: %p\n", real_hWnd);
560 ok(
hr==
DI_OK,
"IDirectInputDevice_Unacquire() failed: %08x\n",
hr);
563 ok(
hr==
DI_OK,
"IDirectInputDevice_SetCooperativeLevel() failed: %08x\n",
hr);
565 ok(
hr==
DI_OK,
"IDirectInputDevice_Acquire() failed: %08x\n",
hr);
566
568
570 ok(
hr==
DI_OK,
"IDirectInputDevice2_EnumEffects() failed: %08x\n",
hr);
571
572
573
574 if (!effect_data.effect_count)
575 {
577 effect_data.guid = GUID_ConstantForce;
578 effect_data.eff.cbTypeSpecificParams =
sizeof(
constant);
579 effect_data.eff.lpvTypeSpecificParams = &
constant;
580 effect_data.effect_name = "Constant";
582
584 }
585
586 effect = (void *)0xdeadbeef;
588 &effect_data.eff, &effect,
NULL);
590 {
591 trace(
"force feedback supported with %d effects, using '%s' for test\n",
592 effect_data.effect_count, effect_data.effect_name);
593 ok(
hr ==
DI_OK,
"IDirectInputDevice_CreateEffect() failed: %08x\n",
hr);
595 ok(cnt1 == cnt2,
"Ref count is wrong %d != %d\n", cnt1, cnt2);
596
597 if (effect)
598 {
602
604 &effect_data.guid);
605 ok(
hr==
DI_OK,
"IDirectInputEffect_Initialize failed: %08x\n",
hr);
608 ok(
hr==
DI_OK,
"IDirectInputEffect_SetParameters failed: %08x\n",
hr);
610
611
613 ok(
hr==
DI_OK,
"IDirectInputDevice_Unacquire() failed: %08x\n",
hr);
615 ok(
hr==
DI_OK,
"IDirectInputDevice_Acquire() failed: %08x\n",
hr);
617 ok(
hr==
DI_OK,
"IDirectInputEffect_SetParameters failed: %08x\n",
hr);
618 }
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
635 ok(
hr==
E_POINTER,
"IDirectInputEffect_GetEffectStatus() must fail with E_POINTER, got: %08x\n",
hr);
636 effect_status = 0xdeadbeef;
638 ok(
hr==
DI_OK,
"IDirectInputEffect_GetEffectStatus() failed: %08x\n",
hr);
639 ok(effect_status==0,
"IDirectInputEffect_GetEffectStatus() reported effect as started\n");
641 ok(
hr==
DI_OK,
"IDirectInputEffect_SetParameters failed: %08x\n",
hr);
643 ok(
hr==
DI_OK,
"IDirectInputEffect_GetEffectStatus() failed: %08x\n",
hr);
644 todo_wine ok(effect_status!=0,
"IDirectInputEffect_GetEffectStatus() reported effect as stopped\n");
646 ok(
hr==
DI_OK,
"IDirectInputDevice_Unacquire() failed: %08x\n",
hr);
648 ok(
hr==
DI_OK,
"IDirectInputDevice_Acquire() failed: %08x\n",
hr);
650 ok(
hr==
DI_OK,
"IDirectInputEffect_Download() failed: %08x\n",
hr);
652 ok(
hr==
DI_OK,
"IDirectInputEffect_GetEffectStatus() failed: %08x\n",
hr);
653 ok(effect_status==0,
"IDirectInputEffect_GetEffectStatus() reported effect as started\n");
655 ok(
hr==
DI_OK,
"IDirectInputEffect_Start() failed: %08x\n",
hr);
657 ok(
hr==
DI_OK,
"IDirectInputEffect_GetEffectStatus() failed: %08x\n",
hr);
659 todo_wine ok(effect_status!=0,
"IDirectInputEffect_GetEffectStatus() reported effect as stopped\n");
661 ok(
hr==
DI_OK,
"IDirectInputEffect_GetEffectGuid() failed: %08x\n",
hr);
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679 diprop_word.diph.dwSize = sizeof(diprop_word);
680 diprop_word.diph.dwHeaderSize = sizeof(diprop_word.diph);
681 diprop_word.diph.dwObj = 0;
684 ok(
hr==
DI_OK,
"IDirectInputDevice_Unacquire() failed: %08x\n",
hr);
686 ok(
hr==
DI_OK,
"IDirectInputDevice2_GetProperty() failed: %08x\n",
hr);
687 ok(diprop_word.dwData==
DIPROPAUTOCENTER_ON,
"IDirectInputDevice2_GetProperty() reported autocenter as disabled\n");
690 ok(
hr==
DI_OK,
"IDirectInputDevice2_SetProperty() failed: %08x\n",
hr);
692 ok(
hr==
DI_OK,
"IDirectInputDevice2_GetProperty() failed: %08x\n",
hr);
693 ok(diprop_word.dwData==
DIPROPAUTOCENTER_OFF,
"IDirectInputDevice2_GetProperty() reported autocenter as enabled\n");
695 trace(
"Acquiring in 2s, autocenter will be disabled.\n");
697 }
699 ok(
hr==
DI_OK,
"IDirectInputDevice_Acquire() failed: %08x\n",
hr);
701 trace(
"Acquired.\n");
703 ok(
hr==
DI_OK,
"IDirectInputDevice2_GetProperty() failed: %08x\n",
hr);
704 ok(diprop_word.dwData==
DIPROPAUTOCENTER_OFF,
"IDirectInputDevice2_GetProperty() reported autocenter as enabled\n");
706 trace(
"Releasing in 2s, autocenter will be re-enabled.\n");
708 }
710 ok(
hr==
DI_OK,
"IDirectInputDevice_Unacquire() failed: %08x\n",
hr);
714 ok(
hr==
DI_OK,
"IDirectInputDevice2_GetProperty() failed: %08x\n",
hr);
715 ok(diprop_word.dwData==
DIPROPAUTOCENTER_OFF,
"IDirectInputDevice2_GetProperty() reported autocenter as enabled\n");
717 ok(
hr==
DI_OK,
"IDirectInputDevice_Acquire() failed: %08x\n",
hr);
719 ok(
hr==
DI_OK,
"IDirectInputDevice2_GetProperty() failed: %08x\n",
hr);
720
721
722
723
724
725
726
727
737
738
740 ok(
hr ==
DI_OK,
"IDirectInputDevice_Unacquire() should have returned S_FALSE, got: %08x\n",
hr);
743 ok(
hr==
DI_OK,
"IDirectInputDevice_SetProperty() failed: %08x\n",
hr);
745 ok(
hr==
DI_OK,
"IDirectInputDevice_GetProperty() failed: %08x\n",
hr);
748 ok(
hr==
DI_OK,
"IDirectInputDevice_Acquire() failed: %08x\n",
hr);
751 ok(
hr==
DI_OK,
"IDirectInputDevice_SetProperty() failed: %08x\n",
hr);
753 ok(
hr==
DI_OK,
"IDirectInputDevice_GetProperty() failed: %08x\n",
hr);
755
761 ok(
hr==
DI_OK,
"IDirectInputDevice_SetProperty() failed: %08x\n",
hr);
763 ok(
hr==
DI_OK,
"IDirectInputDevice_GetProperty() failed: %08x\n",
hr);
765 dip_gain_set.
dwData = 10000;
767 ok(
hr==
DI_OK,
"IDirectInputDevice_SetProperty() failed: %08x\n",
hr);
769 ok(
hr==
DI_OK,
"IDirectInputDevice_GetProperty() failed: %08x\n",
hr);
771
772 dip_gain_set.
dwData = 10001;
774 ok(
hr==
DI_OK,
"IDirectInputDevice_SetProperty() failed: %08x\n",
hr);
776 ok(
hr==
DI_OK,
"IDirectInputDevice_GetProperty() failed: %08x\n",
hr);
778
779
780
781
782
787
789 ok(
hr==
DI_OK,
"IDirectInputEffect_Download() failed: %08x\n",
hr);
790
791
793 ok(
hr==
DI_OK,
"IDirectInputDevice_SendForceFeedbackCommand() failed: %08x\n",
hr);
795 ok(
hr==
DI_OK,
"IDirectInputEffect_GetEffectStatus() failed: %08x\n",
hr);
796 ok(effect_status==0,
"IDirectInputEffect_GetEffectStatus() reported effect as started\n");
798 ok(
hr==
DI_OK,
"IDirectInputEffect_Start() failed: %08x\n",
hr);
800 ok(
hr==
DI_OK,
"IDirectInputEffect_GetEffectGuid() failed: %08x\n",
hr);
802
803
805 ok(
hr==
DI_OK,
"IDirectInputDevice_SendForceFeedbackCommand() failed: %08x\n",
hr);
809 ok(
hr==
DI_OK,
"IDirectInputEffect_Download() failed: %08x\n",
hr);
811 ok(
hr==
DI_OK,
"IDirectInputEffect_GetEffectStatus() failed: %08x\n",
hr);
812 ok(effect_status==0,
"IDirectInputEffect_GetEffectStatus() reported effect as started\n");
814 ok(
hr==
DI_OK,
"IDirectInputEffect_Start() failed: %08x\n",
hr);
816 ok(
hr==
DI_OK,
"IDirectInputEffect_GetEffectGuid() failed: %08x\n",
hr);
818
819 ref = IUnknown_Release(effect);
820 ok(
ref == 0,
"IDirectInputDevice_Release() reference count = %d\n",
ref);
821 }
823 ok(cnt1 == cnt2,
"Ref count is wrong %d != %d\n", cnt1, cnt2);
824 }
825
826
827
828 else
829 {
830 trace(
"No force feedback support\n");
831 ok(
hr==
DIERR_UNSUPPORTED,
"IDirectInputDevice_CreateEffect() must fail with DIERR_UNSUPPORTED, got: %08x\n",
hr);
832 ok(effect ==
NULL,
"effect must be NULL, got %p\n", effect);
833 }
834
835
836
838 ok(
hr==
DI_OK,
"IDirectInputDevice_Unacquire() failed: %08x\n",
hr);
841 ok(
hr==
DI_OK,
"IDirectInputDevice_SetCooperativeLevel() failed: %08x\n",
hr);
844 ok(
hr==
DI_OK,
"IDirectInputDevice_Acquire() failed: %08x\n",
hr);
845
847 trace(
"You have 30 seconds to test all axes, sliders, POVs and buttons\n");
849 } else
851
853 oldstate[0]='\0';
856 ok(
hr==
DI_OK,
"IDirectInputDevice_GetDeviceState() failed: %08x\n",
hr);
858 break;
859 sprintf(curstate,
"X%5d Y%5d Z%5d Rx%5d Ry%5d Rz%5d "
860 "S0%5d S1%5d POV0%5d POV1%5d POV2%5d POV3%5d "
861 "B %d %d %d %d %d %d %d %d %d %d %d %d\n",
869 if (
strcmp(oldstate, curstate) != 0)
870 {
871 trace(
"%s\n", curstate);
872 strcpy(oldstate, curstate);
873 }
875 }
877
879 ok(
hr==
DI_OK,
"IDirectInputDevice_Unacquire() failed: %08x\n",
hr);
880
883 ok(
ref==0,
"IDirectInputDevice_Release() reference count = %d\n",
ref);
884
887}
int strcmp(const char *String1, const char *String2)
char * strcpy(char *DstString, const char *SrcString)
#define MultiByteToWideChar
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
GLuint GLuint GLsizei count
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
_Check_return_ _CRTIMP int __cdecl swscanf(_In_z_ const wchar_t *_Src, _In_z_ _Scanf_format_string_ const wchar_t *_Format,...)
_CONST_RETURN wchar_t *__cdecl wcsstr(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_SubStr)
#define sprintf(buf, format,...)
_CRTIMP wchar_t *__cdecl _wcslwr(_Inout_z_ wchar_t *_String)
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
_In_ ULONG_PTR _In_ ULONG _Out_ ULONG_PTR * pid
HWND WINAPI CreateWindowExA(_In_ DWORD dwExStyle, _In_opt_ LPCSTR lpClassName, _In_opt_ LPCSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
BOOL WINAPI DestroyWindow(_In_ HWND)