Commit 93f40b2e authored by Alexandre Julliard's avatar Alexandre Julliard

dinput: Implement GetDeviceInfo for Linux joystick.

parent 5a6cda45
...@@ -223,6 +223,52 @@ static INT find_joystick_devices(void) ...@@ -223,6 +223,52 @@ static INT find_joystick_devices(void)
return joystick_devices_count; return joystick_devices_count;
} }
static void fill_joystick_dideviceinstanceA(LPDIDEVICEINSTANCEA lpddi, DWORD version, int id)
{
DWORD dwSize = lpddi->dwSize;
TRACE("%d %p\n", dwSize, lpddi);
memset(lpddi, 0, dwSize);
/* Return joystick */
lpddi->dwSize = dwSize;
lpddi->guidInstance = DInput_Wine_Joystick_GUID;
lpddi->guidInstance.Data3 = id;
lpddi->guidProduct = DInput_Wine_Joystick_GUID;
/* we only support traditional joysticks for now */
if (version >= 0x0800)
lpddi->dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8);
else
lpddi->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
strcpy(lpddi->tszInstanceName, joystick_devices[id].name);
strcpy(lpddi->tszProductName, joystick_devices[id].name);
lpddi->guidFFDriver = GUID_NULL;
}
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);
/* Return joystick */
lpddi->dwSize = dwSize;
lpddi->guidInstance = DInput_Wine_Joystick_GUID;
lpddi->guidInstance.Data3 = id;
lpddi->guidProduct = DInput_Wine_Joystick_GUID;
/* we only support traditional joysticks for now */
if (version >= 0x0800)
lpddi->dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8);
else
lpddi->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
MultiByteToWideChar(CP_ACP, 0, joystick_devices[id].name, -1, lpddi->tszInstanceName, MAX_PATH);
MultiByteToWideChar(CP_ACP, 0, joystick_devices[id].name, -1, lpddi->tszProductName, MAX_PATH);
lpddi->guidFFDriver = GUID_NULL;
}
static HRESULT joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, DWORD version, int id) static HRESULT joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, DWORD version, int id)
{ {
int fd = -1; int fd = -1;
...@@ -243,21 +289,7 @@ static HRESULT joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINS ...@@ -243,21 +289,7 @@ static HRESULT joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINS
WARN("open(%s, O_RDONLY) failed: %s\n", joystick_devices[id].name, strerror(errno)); WARN("open(%s, O_RDONLY) failed: %s\n", joystick_devices[id].name, strerror(errno));
return S_FALSE; return S_FALSE;
} }
fill_joystick_dideviceinstanceA( lpddi, version, id );
/* Return joystick */
lpddi->guidInstance = DInput_Wine_Joystick_GUID;
lpddi->guidInstance.Data3 = id;
lpddi->guidProduct = DInput_Wine_Joystick_GUID;
/* we only support traditional joysticks for now */
if (version >= 0x0800)
lpddi->dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8);
else
lpddi->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
strcpy(lpddi->tszInstanceName, joystick_devices[id].name);
strcpy(lpddi->tszProductName, joystick_devices[id].name);
lpddi->guidFFDriver = GUID_NULL;
close(fd); close(fd);
TRACE("Enumerating the linux Joystick device: %s (%s)\n", joystick_devices[id].device, lpddi->tszProductName); TRACE("Enumerating the linux Joystick device: %s (%s)\n", joystick_devices[id].device, lpddi->tszProductName);
return S_OK; return S_OK;
...@@ -286,20 +318,7 @@ static HRESULT joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINS ...@@ -286,20 +318,7 @@ static HRESULT joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINS
WARN("open(%s,O_RDONLY) failed: %s\n", joystick_devices[id].device, strerror(errno)); WARN("open(%s,O_RDONLY) failed: %s\n", joystick_devices[id].device, strerror(errno));
return S_FALSE; return S_FALSE;
} }
fill_joystick_dideviceinstanceW( lpddi, version, id );
/* Return joystick */
lpddi->guidInstance = DInput_Wine_Joystick_GUID;
lpddi->guidInstance.Data3 = id;
lpddi->guidProduct = DInput_Wine_Joystick_GUID;
/* we only support traditional joysticks for now */
if (version >= 0x0800)
lpddi->dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8);
else
lpddi->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
MultiByteToWideChar(CP_ACP, 0, joystick_devices[id].name, -1, lpddi->tszInstanceName, MAX_PATH);
MultiByteToWideChar(CP_ACP, 0, joystick_devices[id].name, -1, lpddi->tszProductName, MAX_PATH);
lpddi->guidFFDriver = GUID_NULL;
close(fd); close(fd);
TRACE("Enumerating the linux Joystick device: %s (%s)\n", joystick_devices[id].device, joystick_devices[id].name); TRACE("Enumerating the linux Joystick device: %s (%s)\n", joystick_devices[id].device, joystick_devices[id].name);
return S_OK; return S_OK;
...@@ -591,6 +610,41 @@ static HRESULT WINAPI JoystickLinuxAImpl_GetProperty(LPDIRECTINPUTDEVICE8A iface ...@@ -591,6 +610,41 @@ static HRESULT WINAPI JoystickLinuxAImpl_GetProperty(LPDIRECTINPUTDEVICE8A iface
} }
/****************************************************************************** /******************************************************************************
* GetDeviceInfo : get information about a device's identity
*/
static HRESULT WINAPI JoystickLinuxAImpl_GetDeviceInfo(LPDIRECTINPUTDEVICE8A iface, LPDIDEVICEINSTANCEA ddi)
{
JoystickImpl *This = impl_from_IDirectInputDevice8A(iface);
TRACE("(%p) %p\n", This, ddi);
if (ddi == NULL) return E_POINTER;
if ((ddi->dwSize != sizeof(DIDEVICEINSTANCE_DX3A)) &&
(ddi->dwSize != sizeof(DIDEVICEINSTANCEA)))
return DIERR_INVALIDPARAM;
fill_joystick_dideviceinstanceA( ddi, This->generic.base.dinput->dwVersion,
get_joystick_index(&This->generic.base.guid) );
return DI_OK;
}
static HRESULT WINAPI JoystickLinuxWImpl_GetDeviceInfo(LPDIRECTINPUTDEVICE8W iface, LPDIDEVICEINSTANCEW ddi)
{
JoystickImpl *This = impl_from_IDirectInputDevice8W(iface);
TRACE("(%p) %p\n", This, ddi);
if (ddi == NULL) return E_POINTER;
if ((ddi->dwSize != sizeof(DIDEVICEINSTANCE_DX3W)) &&
(ddi->dwSize != sizeof(DIDEVICEINSTANCEW)))
return DIERR_INVALIDPARAM;
fill_joystick_dideviceinstanceW( ddi, This->generic.base.dinput->dwVersion,
get_joystick_index(&This->generic.base.guid) );
return DI_OK;
}
/******************************************************************************
* Unacquire : frees the joystick * Unacquire : frees the joystick
*/ */
static HRESULT WINAPI JoystickLinuxWImpl_Unacquire(LPDIRECTINPUTDEVICE8W iface) static HRESULT WINAPI JoystickLinuxWImpl_Unacquire(LPDIRECTINPUTDEVICE8W iface)
...@@ -713,7 +767,7 @@ static const IDirectInputDevice8AVtbl JoystickAvt = ...@@ -713,7 +767,7 @@ static const IDirectInputDevice8AVtbl JoystickAvt =
IDirectInputDevice2AImpl_SetEventNotification, IDirectInputDevice2AImpl_SetEventNotification,
IDirectInputDevice2AImpl_SetCooperativeLevel, IDirectInputDevice2AImpl_SetCooperativeLevel,
JoystickAGenericImpl_GetObjectInfo, JoystickAGenericImpl_GetObjectInfo,
JoystickAGenericImpl_GetDeviceInfo, JoystickLinuxAImpl_GetDeviceInfo,
IDirectInputDevice2AImpl_RunControlPanel, IDirectInputDevice2AImpl_RunControlPanel,
IDirectInputDevice2AImpl_Initialize, IDirectInputDevice2AImpl_Initialize,
IDirectInputDevice2AImpl_CreateEffect, IDirectInputDevice2AImpl_CreateEffect,
...@@ -749,7 +803,7 @@ static const IDirectInputDevice8WVtbl JoystickWvt = ...@@ -749,7 +803,7 @@ static const IDirectInputDevice8WVtbl JoystickWvt =
IDirectInputDevice2WImpl_SetEventNotification, IDirectInputDevice2WImpl_SetEventNotification,
IDirectInputDevice2WImpl_SetCooperativeLevel, IDirectInputDevice2WImpl_SetCooperativeLevel,
JoystickWGenericImpl_GetObjectInfo, JoystickWGenericImpl_GetObjectInfo,
JoystickWGenericImpl_GetDeviceInfo, JoystickLinuxWImpl_GetDeviceInfo,
IDirectInputDevice2WImpl_RunControlPanel, IDirectInputDevice2WImpl_RunControlPanel,
IDirectInputDevice2WImpl_Initialize, IDirectInputDevice2WImpl_Initialize,
IDirectInputDevice2WImpl_CreateEffect, IDirectInputDevice2WImpl_CreateEffect,
......
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