Commit 5fa86231 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

windows.gaming.input: Return object counts and VID/PID for RawGameController.

parent 1e9b83a4
...@@ -65,6 +65,7 @@ struct controller ...@@ -65,6 +65,7 @@ struct controller
LONG ref; LONG ref;
IGameControllerProvider *provider; IGameControllerProvider *provider;
IWineGameControllerProvider *wine_provider;
}; };
static inline struct controller *impl_from_IGameControllerImpl( IGameControllerImpl *iface ) static inline struct controller *impl_from_IGameControllerImpl( IGameControllerImpl *iface )
...@@ -120,6 +121,8 @@ static ULONG WINAPI controller_Release( IGameControllerImpl *iface ) ...@@ -120,6 +121,8 @@ static ULONG WINAPI controller_Release( IGameControllerImpl *iface )
if (!ref) if (!ref)
{ {
if (impl->wine_provider)
IWineGameControllerProvider_Release( impl->wine_provider );
IGameControllerProvider_Release( impl->provider ); IGameControllerProvider_Release( impl->provider );
free( impl ); free( impl );
} }
...@@ -157,6 +160,10 @@ static HRESULT WINAPI controller_Initialize( IGameControllerImpl *iface, IGameCo ...@@ -157,6 +160,10 @@ static HRESULT WINAPI controller_Initialize( IGameControllerImpl *iface, IGameCo
impl->IGameController_outer = outer; impl->IGameController_outer = outer;
IGameControllerProvider_AddRef( (impl->provider = provider) ); IGameControllerProvider_AddRef( (impl->provider = provider) );
hr = IGameControllerProvider_QueryInterface( provider, &IID_IWineGameControllerProvider,
(void **)&impl->wine_provider );
if (FAILED(hr)) return hr;
EnterCriticalSection( &controller_cs ); EnterCriticalSection( &controller_cs );
if (SUCCEEDED(hr = init_controllers())) if (SUCCEEDED(hr = init_controllers()))
hr = IVector_RawGameController_Append( controllers, &impl->IRawGameController_iface ); hr = IVector_RawGameController_Append( controllers, &impl->IRawGameController_iface );
...@@ -210,14 +217,14 @@ DEFINE_IINSPECTABLE_OUTER( raw_controller, IRawGameController, struct controller ...@@ -210,14 +217,14 @@ DEFINE_IINSPECTABLE_OUTER( raw_controller, IRawGameController, struct controller
static HRESULT WINAPI raw_controller_get_AxisCount( IRawGameController *iface, INT32 *value ) static HRESULT WINAPI raw_controller_get_AxisCount( IRawGameController *iface, INT32 *value )
{ {
FIXME( "iface %p, value %p stub!\n", iface, value ); struct controller *impl = impl_from_IRawGameController( iface );
return E_NOTIMPL; return IWineGameControllerProvider_get_AxisCount( impl->wine_provider, value );
} }
static HRESULT WINAPI raw_controller_get_ButtonCount( IRawGameController *iface, INT32 *value ) static HRESULT WINAPI raw_controller_get_ButtonCount( IRawGameController *iface, INT32 *value )
{ {
FIXME( "iface %p, value %p stub!\n", iface, value ); struct controller *impl = impl_from_IRawGameController( iface );
return E_NOTIMPL; return IWineGameControllerProvider_get_ButtonCount( impl->wine_provider, value );
} }
static HRESULT WINAPI raw_controller_get_ForceFeedbackMotors( IRawGameController *iface, IVectorView_ForceFeedbackMotor **value ) static HRESULT WINAPI raw_controller_get_ForceFeedbackMotors( IRawGameController *iface, IVectorView_ForceFeedbackMotor **value )
...@@ -228,20 +235,20 @@ static HRESULT WINAPI raw_controller_get_ForceFeedbackMotors( IRawGameController ...@@ -228,20 +235,20 @@ static HRESULT WINAPI raw_controller_get_ForceFeedbackMotors( IRawGameController
static HRESULT WINAPI raw_controller_get_HardwareProductId( IRawGameController *iface, UINT16 *value ) static HRESULT WINAPI raw_controller_get_HardwareProductId( IRawGameController *iface, UINT16 *value )
{ {
FIXME( "iface %p, value %p stub!\n", iface, value ); struct controller *impl = impl_from_IRawGameController( iface );
return E_NOTIMPL; return IGameControllerProvider_get_HardwareProductId( impl->provider, value );
} }
static HRESULT WINAPI raw_controller_get_HardwareVendorId( IRawGameController *iface, UINT16 *value ) static HRESULT WINAPI raw_controller_get_HardwareVendorId( IRawGameController *iface, UINT16 *value )
{ {
FIXME( "iface %p, value %p stub!\n", iface, value ); struct controller *impl = impl_from_IRawGameController( iface );
return E_NOTIMPL; return IGameControllerProvider_get_HardwareVendorId( impl->provider, value );
} }
static HRESULT WINAPI raw_controller_get_SwitchCount( IRawGameController *iface, INT32 *value ) static HRESULT WINAPI raw_controller_get_SwitchCount( IRawGameController *iface, INT32 *value )
{ {
FIXME( "iface %p, value %p stub!\n", iface, value ); struct controller *impl = impl_from_IRawGameController( iface );
return E_NOTIMPL; return IWineGameControllerProvider_get_SwitchCount( impl->wine_provider, value );
} }
static HRESULT WINAPI raw_controller_GetButtonLabel( IRawGameController *iface, INT32 index, static HRESULT WINAPI raw_controller_GetButtonLabel( IRawGameController *iface, INT32 index,
......
...@@ -143,6 +143,45 @@ static HRESULT WINAPI wine_provider_get_Type( IWineGameControllerProvider *iface ...@@ -143,6 +143,45 @@ static HRESULT WINAPI wine_provider_get_Type( IWineGameControllerProvider *iface
return S_OK; return S_OK;
} }
static HRESULT WINAPI wine_provider_get_AxisCount( IWineGameControllerProvider *iface, INT32 *value )
{
struct provider *impl = impl_from_IWineGameControllerProvider( iface );
DIDEVCAPS caps = {.dwSize = sizeof(DIDEVCAPS)};
HRESULT hr;
TRACE( "iface %p, value %p.\n", iface, value );
if (SUCCEEDED(hr = IDirectInputDevice8_GetCapabilities( impl->dinput_device, &caps )))
*value = caps.dwAxes;
return hr;
}
static HRESULT WINAPI wine_provider_get_ButtonCount( IWineGameControllerProvider *iface, INT32 *value )
{
struct provider *impl = impl_from_IWineGameControllerProvider( iface );
DIDEVCAPS caps = {.dwSize = sizeof(DIDEVCAPS)};
HRESULT hr;
TRACE( "iface %p, value %p.\n", iface, value );
if (SUCCEEDED(hr = IDirectInputDevice8_GetCapabilities( impl->dinput_device, &caps )))
*value = caps.dwButtons;
return hr;
}
static HRESULT WINAPI wine_provider_get_SwitchCount( IWineGameControllerProvider *iface, INT32 *value )
{
struct provider *impl = impl_from_IWineGameControllerProvider( iface );
DIDEVCAPS caps = {.dwSize = sizeof(DIDEVCAPS)};
HRESULT hr;
TRACE( "iface %p, value %p.\n", iface, value );
if (SUCCEEDED(hr = IDirectInputDevice8_GetCapabilities( impl->dinput_device, &caps )))
*value = caps.dwPOVs;
return hr;
}
static const struct IWineGameControllerProviderVtbl wine_provider_vtbl = static const struct IWineGameControllerProviderVtbl wine_provider_vtbl =
{ {
wine_provider_QueryInterface, wine_provider_QueryInterface,
...@@ -154,6 +193,9 @@ static const struct IWineGameControllerProviderVtbl wine_provider_vtbl = ...@@ -154,6 +193,9 @@ static const struct IWineGameControllerProviderVtbl wine_provider_vtbl =
wine_provider_GetTrustLevel, wine_provider_GetTrustLevel,
/* IWineGameControllerProvider methods */ /* IWineGameControllerProvider methods */
wine_provider_get_Type, wine_provider_get_Type,
wine_provider_get_AxisCount,
wine_provider_get_ButtonCount,
wine_provider_get_SwitchCount,
}; };
DEFINE_IINSPECTABLE( game_provider, IGameControllerProvider, struct provider, IWineGameControllerProvider_iface ) DEFINE_IINSPECTABLE( game_provider, IGameControllerProvider, struct provider, IWineGameControllerProvider_iface )
...@@ -166,14 +208,28 @@ static HRESULT WINAPI game_provider_get_FirmwareVersionInfo( IGameControllerProv ...@@ -166,14 +208,28 @@ static HRESULT WINAPI game_provider_get_FirmwareVersionInfo( IGameControllerProv
static HRESULT WINAPI game_provider_get_HardwareProductId( IGameControllerProvider *iface, UINT16 *value ) static HRESULT WINAPI game_provider_get_HardwareProductId( IGameControllerProvider *iface, UINT16 *value )
{ {
FIXME( "iface %p, value %p stub!\n", iface, value ); DIPROPDWORD vid_pid = {.diph = {.dwHeaderSize = sizeof(DIPROPHEADER), .dwSize = sizeof(DIPROPDWORD)}};
return E_NOTIMPL; struct provider *impl = impl_from_IGameControllerProvider( iface );
HRESULT hr;
TRACE( "iface %p, value %p.\n", iface, value );
if (SUCCEEDED(hr = IDirectInputDevice8_GetProperty( impl->dinput_device, DIPROP_VIDPID, &vid_pid.diph )))
*value = HIWORD(vid_pid.dwData);
return hr;
} }
static HRESULT WINAPI game_provider_get_HardwareVendorId( IGameControllerProvider *iface, UINT16 *value ) static HRESULT WINAPI game_provider_get_HardwareVendorId( IGameControllerProvider *iface, UINT16 *value )
{ {
FIXME( "iface %p, value %p stub!\n", iface, value ); DIPROPDWORD vid_pid = {.diph = {.dwHeaderSize = sizeof(DIPROPHEADER), .dwSize = sizeof(DIPROPDWORD)}};
return E_NOTIMPL; struct provider *impl = impl_from_IGameControllerProvider( iface );
HRESULT hr;
TRACE( "iface %p, value %p.\n", iface, value );
if (SUCCEEDED(hr = IDirectInputDevice8_GetProperty( impl->dinput_device, DIPROP_VIDPID, &vid_pid.diph )))
*value = LOWORD(vid_pid.dwData);
return hr;
} }
static HRESULT WINAPI game_provider_get_HardwareVersionInfo( IGameControllerProvider *iface, GameControllerVersionInfo *value ) static HRESULT WINAPI game_provider_get_HardwareVersionInfo( IGameControllerProvider *iface, GameControllerVersionInfo *value )
......
...@@ -59,6 +59,9 @@ namespace Windows.Gaming.Input.Custom { ...@@ -59,6 +59,9 @@ namespace Windows.Gaming.Input.Custom {
requires Windows.Gaming.Input.Custom.IGameControllerProvider requires Windows.Gaming.Input.Custom.IGameControllerProvider
{ {
[propget] HRESULT Type([out, retval] WineGameControllerType *value); [propget] HRESULT Type([out, retval] WineGameControllerType *value);
[propget] HRESULT AxisCount([out, retval] INT32 *value);
[propget] HRESULT ButtonCount([out, retval] INT32 *value);
[propget] HRESULT SwitchCount([out, retval] INT32 *value);
} }
[ [
......
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