📄 dinput_main.c
字号:
TRACE("(this=%p,%s,%p,%p)\n",This,debugstr_guid(rguid),pdev,punk);
/* Loop on all the devices to see if anyone matches the given GUID */
for (i = 0; i < NB_DINPUT_DEVICES; i++) {
HRESULT ret;
if (!dinput_devices[i]->create_deviceW) continue;
if ((ret = dinput_devices[i]->create_deviceW(This, rguid, NULL, pdev)) == DI_OK)
return DI_OK;
if (ret == DIERR_NOINTERFACE)
ret_value = DIERR_NOINTERFACE;
}
return ret_value;
}
static HRESULT WINAPI IDirectInputAImpl_Initialize(LPDIRECTINPUT7A iface, HINSTANCE hinst, DWORD x) {
return DIERR_ALREADYINITIALIZED;
}
static HRESULT WINAPI IDirectInputAImpl_GetDeviceStatus(LPDIRECTINPUT7A iface,
REFGUID rguid) {
IDirectInputImpl *This = (IDirectInputImpl *)iface;
FIXME("(%p)->(%s): stub\n",This,debugstr_guid(rguid));
return DI_OK;
}
static HRESULT WINAPI IDirectInputAImpl_RunControlPanel(LPDIRECTINPUT7A iface,
HWND hwndOwner,
DWORD dwFlags) {
IDirectInputImpl *This = (IDirectInputImpl *)iface;
FIXME("(%p)->(%p,%08lx): stub\n",This, hwndOwner, dwFlags);
return DI_OK;
}
static HRESULT WINAPI IDirectInput2AImpl_FindDevice(LPDIRECTINPUT7A iface, REFGUID rguid,
LPCSTR pszName, LPGUID pguidInstance) {
IDirectInputImpl *This = (IDirectInputImpl *)iface;
FIXME("(%p)->(%s, %s, %p): stub\n", This, debugstr_guid(rguid), pszName, pguidInstance);
return DI_OK;
}
static HRESULT WINAPI IDirectInput2WImpl_FindDevice(LPDIRECTINPUT7W iface, REFGUID rguid,
LPCWSTR pszName, LPGUID pguidInstance) {
IDirectInputImpl *This = (IDirectInputImpl *)iface;
FIXME("(%p)->(%s, %s, %p): stub\n", This, debugstr_guid(rguid), debugstr_w(pszName), pguidInstance);
return DI_OK;
}
static HRESULT WINAPI IDirectInput7AImpl_CreateDeviceEx(LPDIRECTINPUT7A iface, REFGUID rguid,
REFIID riid, LPVOID* pvOut, LPUNKNOWN lpUnknownOuter)
{
IDirectInputImpl *This = (IDirectInputImpl *)iface;
HRESULT ret_value = DIERR_DEVICENOTREG;
int i;
TRACE("(%p)->(%s, %s, %p, %p)\n", This, debugstr_guid(rguid), debugstr_guid(riid), pvOut, lpUnknownOuter);
/* Loop on all the devices to see if anyone matches the given GUID */
for (i = 0; i < NB_DINPUT_DEVICES; i++) {
HRESULT ret;
if (!dinput_devices[i]->create_deviceA) continue;
if ((ret = dinput_devices[i]->create_deviceA(This, rguid, riid, (LPDIRECTINPUTDEVICEA*) pvOut)) == DI_OK)
return DI_OK;
if (ret == DIERR_NOINTERFACE)
ret_value = DIERR_NOINTERFACE;
}
return ret_value;
}
static HRESULT WINAPI IDirectInput7WImpl_CreateDeviceEx(LPDIRECTINPUT7W iface, REFGUID rguid,
REFIID riid, LPVOID* pvOut, LPUNKNOWN lpUnknownOuter)
{
IDirectInputImpl *This = (IDirectInputImpl *)iface;
HRESULT ret_value = DIERR_DEVICENOTREG;
int i;
TRACE("(%p)->(%s, %s, %p, %p)\n", This, debugstr_guid(rguid), debugstr_guid(riid), pvOut, lpUnknownOuter);
/* Loop on all the devices to see if anyone matches the given GUID */
for (i = 0; i < NB_DINPUT_DEVICES; i++) {
HRESULT ret;
if (!dinput_devices[i]->create_deviceW) continue;
if ((ret = dinput_devices[i]->create_deviceW(This, rguid, riid, (LPDIRECTINPUTDEVICEW*) pvOut)) == DI_OK)
return DI_OK;
if (ret == DIERR_NOINTERFACE)
ret_value = DIERR_NOINTERFACE;
}
return ret_value;
}
static HRESULT WINAPI IDirectInput8AImpl_QueryInterface(LPDIRECTINPUT8A iface, REFIID riid, LPVOID *ppobj) {
IDirectInputImpl *This = (IDirectInputImpl *)iface;
TRACE("(this=%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
if (IsEqualGUID(&IID_IUnknown,riid) ||
IsEqualGUID(&IID_IDirectInput8A,riid)) {
IDirectInputAImpl_AddRef((LPDIRECTINPUT7A) iface);
*ppobj = This;
return 0;
}
TRACE("Unsupported interface !\n");
return E_NOINTERFACE;
}
static HRESULT WINAPI IDirectInput8WImpl_QueryInterface(LPDIRECTINPUT8W iface, REFIID riid, LPVOID *ppobj) {
IDirectInputImpl *This = (IDirectInputImpl *)iface;
TRACE("(this=%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
if (IsEqualGUID(&IID_IUnknown,riid) ||
IsEqualGUID(&IID_IDirectInput8W,riid)) {
IDirectInputAImpl_AddRef((LPDIRECTINPUT7A) iface);
*ppobj = This;
return 0;
}
TRACE("Unsupported interface !\n");
return E_NOINTERFACE;
}
static HRESULT WINAPI IDirectInput8AImpl_EnumDevicesBySemantics(
LPDIRECTINPUT8A iface, LPCSTR ptszUserName, LPDIACTIONFORMATA lpdiActionFormat,
LPDIENUMDEVICESBYSEMANTICSCBA lpCallback,
LPVOID pvRef, DWORD dwFlags
)
{
IDirectInputImpl *This = (IDirectInputImpl *)iface;
FIXME("(this=%p,%s,%p,%p,%p,%04lx): stub\n", This, ptszUserName, lpdiActionFormat,
lpCallback, pvRef, dwFlags);
return 0;
}
static HRESULT WINAPI IDirectInput8WImpl_EnumDevicesBySemantics(
LPDIRECTINPUT8W iface, LPCWSTR ptszUserName, LPDIACTIONFORMATW lpdiActionFormat,
LPDIENUMDEVICESBYSEMANTICSCBW lpCallback,
LPVOID pvRef, DWORD dwFlags
)
{
IDirectInputImpl *This = (IDirectInputImpl *)iface;
FIXME("(this=%p,%s,%p,%p,%p,%04lx): stub\n", This, debugstr_w(ptszUserName), lpdiActionFormat,
lpCallback, pvRef, dwFlags);
return 0;
}
static HRESULT WINAPI IDirectInput8AImpl_ConfigureDevices(
LPDIRECTINPUT8A iface, LPDICONFIGUREDEVICESCALLBACK lpdiCallback,
LPDICONFIGUREDEVICESPARAMSA lpdiCDParams, DWORD dwFlags, LPVOID pvRefData
)
{
IDirectInputImpl *This = (IDirectInputImpl *)iface;
FIXME("(this=%p,%p,%p,%04lx,%p): stub\n", This, lpdiCallback, lpdiCDParams,
dwFlags, pvRefData);
return 0;
}
static HRESULT WINAPI IDirectInput8WImpl_ConfigureDevices(
LPDIRECTINPUT8W iface, LPDICONFIGUREDEVICESCALLBACK lpdiCallback,
LPDICONFIGUREDEVICESPARAMSW lpdiCDParams, DWORD dwFlags, LPVOID pvRefData
)
{
IDirectInputImpl *This = (IDirectInputImpl *)iface;
FIXME("(this=%p,%p,%p,%04lx,%p): stub\n", This, lpdiCallback, lpdiCDParams,
dwFlags, pvRefData);
return 0;
}
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
# define XCAST(fun) (typeof(ddi7avt.fun))
#else
# define XCAST(fun) (void*)
#endif
static const IDirectInput7AVtbl ddi7avt = {
XCAST(QueryInterface)IDirectInputAImpl_QueryInterface,
XCAST(AddRef)IDirectInputAImpl_AddRef,
XCAST(Release)IDirectInputAImpl_Release,
XCAST(CreateDevice)IDirectInputAImpl_CreateDevice,
XCAST(EnumDevices)IDirectInputAImpl_EnumDevices,
XCAST(GetDeviceStatus)IDirectInputAImpl_GetDeviceStatus,
XCAST(RunControlPanel)IDirectInputAImpl_RunControlPanel,
XCAST(Initialize)IDirectInputAImpl_Initialize,
XCAST(FindDevice)IDirectInput2AImpl_FindDevice,
XCAST(CreateDeviceEx)IDirectInput7AImpl_CreateDeviceEx
};
#undef XCAST
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
# define XCAST(fun) (typeof(ddi7wvt.fun))
#else
# define XCAST(fun) (void*)
#endif
static const IDirectInput7WVtbl ddi7wvt = {
XCAST(QueryInterface)IDirectInputWImpl_QueryInterface,
XCAST(AddRef)IDirectInputAImpl_AddRef,
XCAST(Release)IDirectInputAImpl_Release,
XCAST(CreateDevice)IDirectInputWImpl_CreateDevice,
XCAST(EnumDevices)IDirectInputWImpl_EnumDevices,
XCAST(GetDeviceStatus)IDirectInputAImpl_GetDeviceStatus,
XCAST(RunControlPanel)IDirectInputAImpl_RunControlPanel,
XCAST(Initialize)IDirectInputAImpl_Initialize,
XCAST(FindDevice)IDirectInput2WImpl_FindDevice,
XCAST(CreateDeviceEx)IDirectInput7WImpl_CreateDeviceEx
};
#undef XCAST
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
# define XCAST(fun) (typeof(ddi8avt.fun))
#else
# define XCAST(fun) (void*)
#endif
static const IDirectInput8AVtbl ddi8avt = {
XCAST(QueryInterface)IDirectInput8AImpl_QueryInterface,
XCAST(AddRef)IDirectInputAImpl_AddRef,
XCAST(Release)IDirectInputAImpl_Release,
XCAST(CreateDevice)IDirectInputAImpl_CreateDevice,
XCAST(EnumDevices)IDirectInputAImpl_EnumDevices,
XCAST(GetDeviceStatus)IDirectInputAImpl_GetDeviceStatus,
XCAST(RunControlPanel)IDirectInputAImpl_RunControlPanel,
XCAST(Initialize)IDirectInputAImpl_Initialize,
XCAST(FindDevice)IDirectInput2AImpl_FindDevice,
XCAST(EnumDevicesBySemantics)IDirectInput8AImpl_EnumDevicesBySemantics,
XCAST(ConfigureDevices)IDirectInput8AImpl_ConfigureDevices
};
#undef XCAST
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
# define XCAST(fun) (typeof(ddi8wvt.fun))
#else
# define XCAST(fun) (void*)
#endif
static const IDirectInput8WVtbl ddi8wvt = {
XCAST(QueryInterface)IDirectInput8WImpl_QueryInterface,
XCAST(AddRef)IDirectInputAImpl_AddRef,
XCAST(Release)IDirectInputAImpl_Release,
XCAST(CreateDevice)IDirectInputWImpl_CreateDevice,
XCAST(EnumDevices)IDirectInputWImpl_EnumDevices,
XCAST(GetDeviceStatus)IDirectInputAImpl_GetDeviceStatus,
XCAST(RunControlPanel)IDirectInputAImpl_RunControlPanel,
XCAST(Initialize)IDirectInputAImpl_Initialize,
XCAST(FindDevice)IDirectInput2WImpl_FindDevice,
XCAST(EnumDevicesBySemantics)IDirectInput8WImpl_EnumDevicesBySemantics,
XCAST(ConfigureDevices)IDirectInput8WImpl_ConfigureDevices
};
#undef XCAST
/*******************************************************************************
* DirectInput ClassFactory
*/
typedef struct
{
/* IUnknown fields */
const IClassFactoryVtbl *lpVtbl;
LONG ref;
} IClassFactoryImpl;
static HRESULT WINAPI DICF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj);
return E_NOINTERFACE;
}
static ULONG WINAPI DICF_AddRef(LPCLASSFACTORY iface) {
IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
return InterlockedIncrement(&(This->ref));
}
static ULONG WINAPI DICF_Release(LPCLASSFACTORY iface) {
IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
/* static class, won't be freed */
return InterlockedDecrement(&(This->ref));
}
static HRESULT WINAPI DICF_CreateInstance(
LPCLASSFACTORY iface,LPUNKNOWN pOuter,REFIID riid,LPVOID *ppobj
) {
IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
if ( IsEqualGUID( &IID_IDirectInputA, riid ) ||
IsEqualGUID( &IID_IDirectInputW, riid ) ||
IsEqualGUID( &IID_IDirectInput2A, riid ) ||
IsEqualGUID( &IID_IDirectInput2W, riid ) ||
IsEqualGUID( &IID_IDirectInput7A, riid ) ||
IsEqualGUID( &IID_IDirectInput7W, riid ) ||
IsEqualGUID( &IID_IDirectInput8A, riid ) ||
IsEqualGUID( &IID_IDirectInput8W, riid ) ) {
/* FIXME: reuse already created dinput if present? */
return DirectInputCreateEx(0,0,riid,ppobj,pOuter);
}
FIXME("(%p,%p,%s,%p) Interface not found!\n",This,pOuter,debugstr_guid(riid),ppobj);
return E_NOINTERFACE;
}
static HRESULT WINAPI DICF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
FIXME("(%p)->(%d),stub!\n",This,dolock);
return S_OK;
}
static const IClassFactoryVtbl DICF_Vtbl = {
DICF_QueryInterface,
DICF_AddRef,
DICF_Release,
DICF_CreateInstance,
DICF_LockServer
};
static IClassFactoryImpl DINPUT_CF = {&DICF_Vtbl, 1 };
/***********************************************************************
* DllCanUnloadNow (DINPUT.@)
*/
HRESULT WINAPI DllCanUnloadNow(void)
{
FIXME("(void): stub\n");
return S_FALSE;
}
/***********************************************************************
* DllGetClassObject (DINPUT.@)
*/
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
{
TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
if ( IsEqualCLSID( &IID_IClassFactory, riid ) ) {
*ppv = (LPVOID)&DINPUT_CF;
IClassFactory_AddRef((IClassFactory*)*ppv);
return S_OK;
}
FIXME("(%s,%s,%p): no interface found.\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
return CLASS_E_CLASSNOTAVAILABLE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -