Commit 730b35ba authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

windows.gaming.input: Import IAsyncOperation from windows.media.speech.

Adapting it for the IAsyncOperation_boolean interface and use it to implement IForceFeedbackMotor_Try(Enable|Disable|Reset)Async. Signed-off-by: 's avatarRémi Bernon <rbernon@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent a7d67c1c
...@@ -4482,7 +4482,7 @@ static void check_bool_async_( int line, IAsyncOperation_boolean *async, UINT32 ...@@ -4482,7 +4482,7 @@ static void check_bool_async_( int line, IAsyncOperation_boolean *async, UINT32
hr = IAsyncInfo_get_ErrorCode( async_info, &async_hr ); hr = IAsyncInfo_get_ErrorCode( async_info, &async_hr );
if (expect_status < 4) ok_(__FILE__, line)( hr == S_OK, "get_ErrorCode returned %#lx\n", hr ); if (expect_status < 4) ok_(__FILE__, line)( hr == S_OK, "get_ErrorCode returned %#lx\n", hr );
else ok_(__FILE__, line)( hr == E_ILLEGAL_METHOD_CALL, "get_ErrorCode returned %#lx\n", hr ); else ok_(__FILE__, line)( hr == E_ILLEGAL_METHOD_CALL, "get_ErrorCode returned %#lx\n", hr );
if (expect_status < 4) ok_(__FILE__, line)( async_hr == expect_hr, "got error %#lx\n", async_hr ); if (expect_status < 4) todo_wine_if(FAILED(expect_hr)) ok_(__FILE__, line)( async_hr == expect_hr, "got error %#lx\n", async_hr );
else ok_(__FILE__, line)( async_hr == E_ILLEGAL_METHOD_CALL, "got error %#lx\n", async_hr ); else ok_(__FILE__, line)( async_hr == E_ILLEGAL_METHOD_CALL, "got error %#lx\n", async_hr );
IAsyncInfo_Release( async_info ); IAsyncInfo_Release( async_info );
...@@ -4493,6 +4493,7 @@ static void check_bool_async_( int line, IAsyncOperation_boolean *async, UINT32 ...@@ -4493,6 +4493,7 @@ static void check_bool_async_( int line, IAsyncOperation_boolean *async, UINT32
{ {
case Completed: case Completed:
case Error: case Error:
todo_wine_if(FAILED(expect_hr))
ok_(__FILE__, line)( hr == expect_hr, "GetResults returned %#lx\n", hr ); ok_(__FILE__, line)( hr == expect_hr, "GetResults returned %#lx\n", hr );
ok_(__FILE__, line)( result == expect_result, "got result %u\n", result ); ok_(__FILE__, line)( result == expect_result, "got result %u\n", result );
break; break;
...@@ -5091,7 +5092,6 @@ static void test_windows_gaming_input(void) ...@@ -5091,7 +5092,6 @@ static void test_windows_gaming_input(void)
.report_id = 1, .report_id = 1,
.report_len = 2, .report_len = 2,
.report_buf = {1, 0x05}, .report_buf = {1, 0x05},
.todo = TRUE,
}; };
static struct hid_expect expect_enable = static struct hid_expect expect_enable =
{ {
...@@ -5099,7 +5099,6 @@ static void test_windows_gaming_input(void) ...@@ -5099,7 +5099,6 @@ static void test_windows_gaming_input(void)
.report_id = 1, .report_id = 1,
.report_len = 2, .report_len = 2,
.report_buf = {1, 0x04}, .report_buf = {1, 0x04},
.todo = TRUE,
}; };
static struct hid_expect expect_enable_fail = static struct hid_expect expect_enable_fail =
{ {
...@@ -5108,7 +5107,6 @@ static void test_windows_gaming_input(void) ...@@ -5108,7 +5107,6 @@ static void test_windows_gaming_input(void)
.report_id = 1, .report_id = 1,
.report_len = 2, .report_len = 2,
.report_buf = {1, 0x04}, .report_buf = {1, 0x04},
.todo = TRUE,
}; };
static struct hid_expect expect_reset_delay[] = static struct hid_expect expect_reset_delay[] =
{ {
...@@ -5119,7 +5117,6 @@ static void test_windows_gaming_input(void) ...@@ -5119,7 +5117,6 @@ static void test_windows_gaming_input(void)
.report_id = 1, .report_id = 1,
.report_len = 2, .report_len = 2,
.report_buf = {1, 0x01}, .report_buf = {1, 0x01},
.todo = TRUE,
}, },
/* device gain */ /* device gain */
{ {
...@@ -5127,7 +5124,6 @@ static void test_windows_gaming_input(void) ...@@ -5127,7 +5124,6 @@ static void test_windows_gaming_input(void)
.report_id = 6, .report_id = 6,
.report_len = 2, .report_len = 2,
.report_buf = {6, 0x7f}, .report_buf = {6, 0x7f},
.todo = TRUE,
}, },
}; };
struct hid_expect expect_reset[] = struct hid_expect expect_reset[] =
...@@ -5138,7 +5134,6 @@ static void test_windows_gaming_input(void) ...@@ -5138,7 +5134,6 @@ static void test_windows_gaming_input(void)
.report_id = 1, .report_id = 1,
.report_len = 2, .report_len = 2,
.report_buf = {1, 0x01}, .report_buf = {1, 0x01},
.todo = TRUE,
}, },
/* device gain */ /* device gain */
{ {
...@@ -5146,7 +5141,6 @@ static void test_windows_gaming_input(void) ...@@ -5146,7 +5141,6 @@ static void test_windows_gaming_input(void)
.report_id = 6, .report_id = 6,
.report_len = 2, .report_len = 2,
.report_buf = {6, 0x7f}, .report_buf = {6, 0x7f},
.todo = TRUE,
}, },
}; };
static const WCHAR *force_feedback_motor = RuntimeClass_Windows_Gaming_Input_ForceFeedback_ForceFeedbackMotor; static const WCHAR *force_feedback_motor = RuntimeClass_Windows_Gaming_Input_ForceFeedback_ForceFeedbackMotor;
...@@ -5309,9 +5303,7 @@ static void test_windows_gaming_input(void) ...@@ -5309,9 +5303,7 @@ static void test_windows_gaming_input(void)
enabled = FALSE; enabled = FALSE;
hr = IForceFeedbackMotor_get_IsEnabled( motor, &enabled ); hr = IForceFeedbackMotor_get_IsEnabled( motor, &enabled );
todo_wine
ok( hr == S_OK, "get_IsEnabled returned %#lx\n", hr ); ok( hr == S_OK, "get_IsEnabled returned %#lx\n", hr );
todo_wine
ok( enabled == TRUE, "got enabled %u\n", enabled ); ok( enabled == TRUE, "got enabled %u\n", enabled );
supported_axes = 0xdeadbeef; supported_axes = 0xdeadbeef;
...@@ -5335,10 +5327,8 @@ static void test_windows_gaming_input(void) ...@@ -5335,10 +5327,8 @@ static void test_windows_gaming_input(void)
set_hid_expect( file, &expect_disable, sizeof(expect_disable) ); set_hid_expect( file, &expect_disable, sizeof(expect_disable) );
hr = IForceFeedbackMotor_TryDisableAsync( motor, &bool_async ); hr = IForceFeedbackMotor_TryDisableAsync( motor, &bool_async );
todo_wine
ok( hr == S_OK, "TryDisableAsync returned %#lx\n", hr ); ok( hr == S_OK, "TryDisableAsync returned %#lx\n", hr );
wait_hid_expect_( __FILE__, __LINE__, file, 100, TRUE ); wait_hid_expect( file, 100 );
if (hr != S_OK) goto skip_tests;
check_bool_async( bool_async, 1, Completed, S_OK, TRUE ); check_bool_async( bool_async, 1, Completed, S_OK, TRUE );
check_interface( bool_async, &IID_IUnknown, TRUE ); check_interface( bool_async, &IID_IUnknown, TRUE );
...@@ -5382,9 +5372,8 @@ static void test_windows_gaming_input(void) ...@@ -5382,9 +5372,8 @@ static void test_windows_gaming_input(void)
set_hid_expect( file, &expect_enable_fail, sizeof(expect_enable_fail) ); set_hid_expect( file, &expect_enable_fail, sizeof(expect_enable_fail) );
hr = IForceFeedbackMotor_TryEnableAsync( motor, &bool_async ); hr = IForceFeedbackMotor_TryEnableAsync( motor, &bool_async );
todo_wine
ok( hr == S_OK, "TryEnableAsync returned %#lx\n", hr ); ok( hr == S_OK, "TryEnableAsync returned %#lx\n", hr );
wait_hid_expect_( __FILE__, __LINE__, file, 100, TRUE ); wait_hid_expect( file, 100 );
check_bool_async( bool_async, 1, Error, 0x8685400d, FALSE ); check_bool_async( bool_async, 1, Error, 0x8685400d, FALSE );
bool_async_handler = default_bool_async_handler; bool_async_handler = default_bool_async_handler;
...@@ -5411,7 +5400,6 @@ static void test_windows_gaming_input(void) ...@@ -5411,7 +5400,6 @@ static void test_windows_gaming_input(void)
set_hid_expect( file, expect_reset_delay, sizeof(expect_reset_delay) ); set_hid_expect( file, expect_reset_delay, sizeof(expect_reset_delay) );
hr = IForceFeedbackMotor_TryResetAsync( motor, &bool_async ); hr = IForceFeedbackMotor_TryResetAsync( motor, &bool_async );
todo_wine
ok( hr == S_OK, "TryResetAsync returned %#lx\n", hr ); ok( hr == S_OK, "TryResetAsync returned %#lx\n", hr );
check_bool_async( bool_async, 1, Started, S_OK, FALSE ); check_bool_async( bool_async, 1, Started, S_OK, FALSE );
...@@ -5435,7 +5423,7 @@ static void test_windows_gaming_input(void) ...@@ -5435,7 +5423,7 @@ static void test_windows_gaming_input(void)
ok( !bool_async_handler.invoked, "handler invoked\n" ); ok( !bool_async_handler.invoked, "handler invoked\n" );
IAsyncInfo_Release( async_info ); IAsyncInfo_Release( async_info );
wait_hid_expect_( __FILE__, __LINE__, file, 100, TRUE ); wait_hid_expect( file, 100 );
ret = WaitForSingleObject( bool_async_handler.event, 100 ); ret = WaitForSingleObject( bool_async_handler.event, 100 );
ok( ret == 0, "WaitForSingleObject returned %#lx\n", ret ); ok( ret == 0, "WaitForSingleObject returned %#lx\n", ret );
CloseHandle( bool_async_handler.event ); CloseHandle( bool_async_handler.event );
...@@ -5455,7 +5443,6 @@ static void test_windows_gaming_input(void) ...@@ -5455,7 +5443,6 @@ static void test_windows_gaming_input(void)
set_hid_expect( file, expect_reset_delay, sizeof(expect_reset_delay) ); set_hid_expect( file, expect_reset_delay, sizeof(expect_reset_delay) );
hr = IForceFeedbackMotor_TryResetAsync( motor, &bool_async ); hr = IForceFeedbackMotor_TryResetAsync( motor, &bool_async );
todo_wine
ok( hr == S_OK, "TryResetAsync returned %#lx\n", hr ); ok( hr == S_OK, "TryResetAsync returned %#lx\n", hr );
check_bool_async( bool_async, 1, Started, S_OK, FALSE ); check_bool_async( bool_async, 1, Started, S_OK, FALSE );
...@@ -5481,7 +5468,7 @@ static void test_windows_gaming_input(void) ...@@ -5481,7 +5468,7 @@ static void test_windows_gaming_input(void)
ok( !bool_async_handler.invoked, "handler invoked\n" ); ok( !bool_async_handler.invoked, "handler invoked\n" );
IAsyncInfo_Release( async_info ); IAsyncInfo_Release( async_info );
wait_hid_expect_( __FILE__, __LINE__, file, 100, TRUE ); wait_hid_expect( file, 100 );
ret = WaitForSingleObject( bool_async_handler.event, 100 ); ret = WaitForSingleObject( bool_async_handler.event, 100 );
ok( ret == 0, "WaitForSingleObject returned %#lx\n", ret ); ok( ret == 0, "WaitForSingleObject returned %#lx\n", ret );
CloseHandle( bool_async_handler.event ); CloseHandle( bool_async_handler.event );
...@@ -5498,21 +5485,18 @@ static void test_windows_gaming_input(void) ...@@ -5498,21 +5485,18 @@ static void test_windows_gaming_input(void)
set_hid_expect( file, &expect_enable, sizeof(expect_enable) ); set_hid_expect( file, &expect_enable, sizeof(expect_enable) );
hr = IForceFeedbackMotor_TryEnableAsync( motor, &bool_async ); hr = IForceFeedbackMotor_TryEnableAsync( motor, &bool_async );
todo_wine
ok( hr == S_OK, "TryEnableAsync returned %#lx\n", hr ); ok( hr == S_OK, "TryEnableAsync returned %#lx\n", hr );
wait_hid_expect_( __FILE__, __LINE__, file, 100, TRUE ); wait_hid_expect( file, 100 );
IAsyncOperation_boolean_Release( bool_async ); IAsyncOperation_boolean_Release( bool_async );
set_hid_expect( file, expect_reset, sizeof(expect_reset) ); set_hid_expect( file, expect_reset, sizeof(expect_reset) );
hr = IForceFeedbackMotor_TryResetAsync( motor, &bool_async ); hr = IForceFeedbackMotor_TryResetAsync( motor, &bool_async );
todo_wine
ok( hr == S_OK, "TryResetAsync returned %#lx\n", hr ); ok( hr == S_OK, "TryResetAsync returned %#lx\n", hr );
wait_hid_expect_( __FILE__, __LINE__, file, 100, TRUE ); wait_hid_expect( file, 100 );
IAsyncOperation_boolean_Release( bool_async ); IAsyncOperation_boolean_Release( bool_async );
skip_tests:
IForceFeedbackMotor_Release( motor ); IForceFeedbackMotor_Release( motor );
IRawGameController_Release( raw_controller ); IRawGameController_Release( raw_controller );
......
...@@ -2,6 +2,7 @@ MODULE = windows.gaming.input.dll ...@@ -2,6 +2,7 @@ MODULE = windows.gaming.input.dll
IMPORTS = combase uuid user32 dinput8 setupapi hid IMPORTS = combase uuid user32 dinput8 setupapi hid
C_SRCS = \ C_SRCS = \
async.c \
controller.c \ controller.c \
event_handlers.c \ event_handlers.c \
force_feedback.c \ force_feedback.c \
......
...@@ -161,8 +161,16 @@ static HRESULT WINAPI motor_put_MasterGain( IForceFeedbackMotor *iface, double v ...@@ -161,8 +161,16 @@ static HRESULT WINAPI motor_put_MasterGain( IForceFeedbackMotor *iface, double v
static HRESULT WINAPI motor_get_IsEnabled( IForceFeedbackMotor *iface, BOOLEAN *value ) static HRESULT WINAPI motor_get_IsEnabled( IForceFeedbackMotor *iface, BOOLEAN *value )
{ {
FIXME( "iface %p, value %p stub!\n", iface, value ); struct motor *impl = impl_from_IForceFeedbackMotor( iface );
return E_NOTIMPL; DWORD state;
HRESULT hr;
TRACE( "iface %p, value %p.\n", iface, value );
if (FAILED(hr = IDirectInputDevice8_GetForceFeedbackState( impl->device, &state ))) *value = FALSE;
else *value = !(state & DIGFFS_ACTUATORSOFF);
return hr;
} }
static HRESULT WINAPI motor_get_SupportedAxes( IForceFeedbackMotor *iface, enum ForceFeedbackEffectAxes *value ) static HRESULT WINAPI motor_get_SupportedAxes( IForceFeedbackMotor *iface, enum ForceFeedbackEffectAxes *value )
...@@ -205,22 +213,55 @@ static HRESULT WINAPI motor_StopAllEffects( IForceFeedbackMotor *iface ) ...@@ -205,22 +213,55 @@ static HRESULT WINAPI motor_StopAllEffects( IForceFeedbackMotor *iface )
return IDirectInputDevice8_SendForceFeedbackCommand( impl->device, DISFFC_STOPALL ); return IDirectInputDevice8_SendForceFeedbackCommand( impl->device, DISFFC_STOPALL );
} }
static HRESULT WINAPI motor_try_disable_async( IInspectable *iface, BOOLEAN *result )
{
struct motor *impl = impl_from_IForceFeedbackMotor( (IForceFeedbackMotor *)iface );
HRESULT hr;
hr = IDirectInputDevice8_SendForceFeedbackCommand( impl->device, DISFFC_SETACTUATORSOFF );
*result = SUCCEEDED(hr);
return hr;
}
static HRESULT WINAPI motor_TryDisableAsync( IForceFeedbackMotor *iface, IAsyncOperation_boolean **async_op ) static HRESULT WINAPI motor_TryDisableAsync( IForceFeedbackMotor *iface, IAsyncOperation_boolean **async_op )
{ {
FIXME( "iface %p, async_op %p stub!\n", iface, async_op ); TRACE( "iface %p, async_op %p.\n", iface, async_op );
return E_NOTIMPL; return async_operation_boolean_create( (IInspectable *)iface, motor_try_disable_async, async_op );
}
static HRESULT WINAPI motor_try_enable_async( IInspectable *iface, BOOLEAN *result )
{
struct motor *impl = impl_from_IForceFeedbackMotor( (IForceFeedbackMotor *)iface );
HRESULT hr;
hr = IDirectInputDevice8_SendForceFeedbackCommand( impl->device, DISFFC_SETACTUATORSON );
*result = SUCCEEDED(hr);
return hr;
} }
static HRESULT WINAPI motor_TryEnableAsync( IForceFeedbackMotor *iface, IAsyncOperation_boolean **async_op ) static HRESULT WINAPI motor_TryEnableAsync( IForceFeedbackMotor *iface, IAsyncOperation_boolean **async_op )
{ {
FIXME( "iface %p, async_op %p stub!\n", iface, async_op ); TRACE( "iface %p, async_op %p.\n", iface, async_op );
return E_NOTIMPL; return async_operation_boolean_create( (IInspectable *)iface, motor_try_enable_async, async_op );
}
static HRESULT WINAPI motor_try_reset_async( IInspectable *iface, BOOLEAN *result )
{
struct motor *impl = impl_from_IForceFeedbackMotor( (IForceFeedbackMotor *)iface );
HRESULT hr;
hr = IDirectInputDevice8_SendForceFeedbackCommand( impl->device, DISFFC_RESET );
*result = SUCCEEDED(hr);
return hr;
} }
static HRESULT WINAPI motor_TryResetAsync( IForceFeedbackMotor *iface, IAsyncOperation_boolean **async_op ) static HRESULT WINAPI motor_TryResetAsync( IForceFeedbackMotor *iface, IAsyncOperation_boolean **async_op )
{ {
FIXME( "iface %p, async_op %p stub!\n", iface, async_op ); TRACE( "iface %p, async_op %p.\n", iface, async_op );
return E_NOTIMPL; return async_operation_boolean_create( (IInspectable *)iface, motor_try_reset_async, async_op );
} }
static HRESULT WINAPI motor_TryUnloadEffectAsync( IForceFeedbackMotor *iface, IForceFeedbackEffect *effect, static HRESULT WINAPI motor_TryUnloadEffectAsync( IForceFeedbackMotor *iface, IForceFeedbackEffect *effect,
......
...@@ -67,6 +67,10 @@ extern void event_handlers_notify( struct list *list, IInspectable *element ); ...@@ -67,6 +67,10 @@ extern void event_handlers_notify( struct list *list, IInspectable *element );
extern HRESULT force_feedback_motor_create( IDirectInputDevice8W *device, IForceFeedbackMotor **out ); extern HRESULT force_feedback_motor_create( IDirectInputDevice8W *device, IForceFeedbackMotor **out );
typedef HRESULT (WINAPI *async_operation_boolean_callback)( IInspectable *invoker, BOOLEAN *result );
extern HRESULT async_operation_boolean_create( IInspectable *invoker, async_operation_boolean_callback callback,
IAsyncOperation_boolean **out );
#define DEFINE_IINSPECTABLE_( pfx, iface_type, impl_type, impl_from, iface_mem, expr ) \ #define DEFINE_IINSPECTABLE_( pfx, iface_type, impl_type, impl_from, iface_mem, expr ) \
static inline impl_type *impl_from( iface_type *iface ) \ static inline impl_type *impl_from( iface_type *iface ) \
{ \ { \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment