* Sync with Wine 1.5.26.
svn path=/trunk/; revision=58768
-
remove_definitions(-D_WIN32_WINNT=0x502)
add_definitions(-D_WIN32_WINNT=0x600)
+add_definitions(-D__WINESRC__)
include_directories(${REACTOS_SOURCE_DIR}/include/reactos/wine)
spec2def(dinput.dll dinput.spec ADD_IMPORTLIB)
add_library(dinput SHARED
+ config.c
data_formats.c
device.c
dinput_main.c
effect_linuxinput.c
+ joystick.c
joystick_linux.c
joystick_linuxinput.c
+ joystick_osx.c
keyboard.c
mouse.c
- regsvr.c
- version.rc
+ dinput.rc
${CMAKE_CURRENT_BINARY_DIR}/dinput.def)
+add_library(dinput_data_formats data_formats.c)
set_module_type(dinput win32dll UNICODE)
-
-target_link_libraries(dinput
- dxguid
- uuid
- wine)
-
-add_importlibs(dinput
- user32
- advapi32
- ole32
- winmm
- msvcrt
- kernel32
- ntdll)
-
+target_link_libraries(dinput dxguid uuid wine)
+add_importlibs(dinput comctl32 ole32 user32 advapi32 msvcrt kernel32 ntdll)
add_cd_file(TARGET dinput DESTINATION reactos/system32 FOR all)
-
--- /dev/null
+/*
+ * Copyright (c) 2011 Lucas Fialho Zawacki
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#define NONAMELESSUNION
+
+//#include "wine/unicode.h"
+//#include "objbase.h"
+#include "dinput_private.h"
+//#include "device_private.h"
+
+#include "resource.h"
+
+typedef struct {
+ int nobjects;
+ IDirectInputDevice8W *lpdid;
+ DIDEVICEINSTANCEW ddi;
+ DIDEVICEOBJECTINSTANCEW ddo[256];
+} DeviceData;
+
+typedef struct {
+ int ndevices;
+ DeviceData *devices;
+} DIDevicesData;
+
+typedef struct {
+ IDirectInput8W *lpDI;
+ LPDIACTIONFORMATW lpdiaf;
+ LPDIACTIONFORMATW original_lpdiaf;
+ DIDevicesData devices_data;
+ int display_only;
+} ConfigureDevicesData;
+
+/*
+ * Enumeration callback functions
+ */
+static BOOL CALLBACK collect_objects(LPCDIDEVICEOBJECTINSTANCEW lpddo, LPVOID pvRef)
+{
+ DeviceData *data = (DeviceData*) pvRef;
+
+ data->ddo[data->nobjects] = *lpddo;
+
+ data->nobjects++;
+ return DIENUM_CONTINUE;
+}
+
+static BOOL CALLBACK count_devices(LPCDIDEVICEINSTANCEW lpddi, IDirectInputDevice8W *lpdid, DWORD dwFlags, DWORD dwRemaining, LPVOID pvRef)
+{
+ DIDevicesData *data = (DIDevicesData*) pvRef;
+
+ data->ndevices++;
+ return DIENUM_CONTINUE;
+}
+
+static BOOL CALLBACK collect_devices(LPCDIDEVICEINSTANCEW lpddi, IDirectInputDevice8W *lpdid, DWORD dwFlags, DWORD dwRemaining, LPVOID pvRef)
+{
+ DIDevicesData *data = (DIDevicesData*) pvRef;
+ DeviceData *device = &data->devices[data->ndevices];
+ device->lpdid = lpdid;
+ device->ddi = *lpddi;
+
+ IDirectInputDevice_AddRef(lpdid);
+
+ device->nobjects = 0;
+ IDirectInputDevice_EnumObjects(lpdid, collect_objects, (LPVOID) device, DIDFT_ALL);
+
+ data->ndevices++;
+ return DIENUM_CONTINUE;
+}
+
+/*
+ * Listview utility functions
+ */
+static void init_listview_columns(HWND dialog)
+{
+ HINSTANCE hinstance = (HINSTANCE) GetWindowLongPtrW(dialog, GWLP_HINSTANCE);
+ LVCOLUMNW listColumn;
+ RECT viewRect;
+ int width;
+ WCHAR column[MAX_PATH];
+
+ GetClientRect(GetDlgItem(dialog, IDC_DEVICEOBJECTSLIST), &viewRect);
+ width = (viewRect.right - viewRect.left)/2;
+
+ LoadStringW(hinstance, IDS_OBJECTCOLUMN, column, sizeof(column)/sizeof(column[0]));
+ listColumn.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;
+ listColumn.pszText = column;
+ listColumn.cchTextMax = lstrlenW(listColumn.pszText);
+ listColumn.cx = width;
+
+ SendDlgItemMessageW (dialog, IDC_DEVICEOBJECTSLIST, LVM_INSERTCOLUMNW, 0, (LPARAM) &listColumn);
+
+ LoadStringW(hinstance, IDS_ACTIONCOLUMN, column, sizeof(column)/sizeof(column[0]));
+ listColumn.cx = width;
+ listColumn.pszText = column;
+ listColumn.cchTextMax = lstrlenW(listColumn.pszText);
+
+ SendDlgItemMessageW(dialog, IDC_DEVICEOBJECTSLIST, LVM_INSERTCOLUMNW, 1, (LPARAM) &listColumn);
+}
+
+static int lv_get_cur_item(HWND dialog)
+{
+ return SendDlgItemMessageW(dialog, IDC_DEVICEOBJECTSLIST, LVM_GETNEXTITEM, -1, LVNI_SELECTED);
+}
+
+static int lv_get_item_data(HWND dialog, int index)
+{
+ LVITEMW item;
+
+ if (index < 0) return -1;
+
+ item.mask = LVIF_PARAM;
+ item.iItem = index;
+ item.iSubItem = 0;
+
+ SendDlgItemMessageW(dialog, IDC_DEVICEOBJECTSLIST, LVM_GETITEMW , 0, (LPARAM)&item);
+
+ return item.lParam;
+}
+
+static void lv_set_action(HWND dialog, int item, int action, LPDIACTIONFORMATW lpdiaf)
+{
+ static const WCHAR no_action[] = {'-','\0'};
+ const WCHAR *action_text = no_action;
+ LVITEMW lvItem;
+
+ if (item < 0) return;
+
+ if (action != -1)
+ action_text = lpdiaf->rgoAction[action].u.lptszActionName;
+
+ /* Keep the action and text in the listview item */
+ lvItem.iItem = item;
+
+ lvItem.mask = LVIF_PARAM;
+ lvItem.iSubItem = 0;
+ lvItem.lParam = (LPARAM) action;
+
+ /* Action index */
+ SendDlgItemMessageW(dialog, IDC_DEVICEOBJECTSLIST, LVM_SETITEMW, 0, (LPARAM) &lvItem);
+
+ lvItem.mask = LVIF_TEXT;
+ lvItem.iSubItem = 1;
+ lvItem.pszText = (WCHAR *)action_text;
+ lvItem.cchTextMax = lstrlenW(lvItem.pszText);
+
+ /* Text */
+ SendDlgItemMessageW(dialog, IDC_DEVICEOBJECTSLIST, LVM_SETITEMW, 0, (LPARAM) &lvItem);
+}
+
+/*
+ * Utility functions
+ */
+static DeviceData* get_cur_device(HWND dialog)
+{
+ ConfigureDevicesData *data = (ConfigureDevicesData*) GetWindowLongPtrW(dialog, DWLP_USER);
+ int sel = SendDlgItemMessageW(dialog, IDC_CONTROLLERCOMBO, CB_GETCURSEL, 0, 0);
+ return &data->devices_data.devices[sel];
+}
+
+static LPDIACTIONFORMATW get_cur_lpdiaf(HWND dialog)
+{
+ ConfigureDevicesData *data = (ConfigureDevicesData*) GetWindowLongPtrW(dialog, DWLP_USER);
+ return data->lpdiaf;
+}
+
+static int dialog_display_only(HWND dialog)
+{
+ ConfigureDevicesData *data = (ConfigureDevicesData*) GetWindowLongPtrW(dialog, DWLP_USER);
+ return data->display_only;
+}
+
+static void init_devices(HWND dialog, IDirectInput8W *lpDI, DIDevicesData *data, LPDIACTIONFORMATW lpdiaf)
+{
+ int i;
+
+ /* Count devices */
+ data->ndevices = 0;
+ IDirectInput8_EnumDevicesBySemantics(lpDI, NULL, lpdiaf, count_devices, (LPVOID) data, 0);
+
+ /* Allocate devices */
+ data->devices = HeapAlloc(GetProcessHeap(), 0, sizeof(DeviceData) * data->ndevices);
+
+ /* Collect and insert */
+ data->ndevices = 0;
+ IDirectInput8_EnumDevicesBySemantics(lpDI, NULL, lpdiaf, collect_devices, (LPVOID) data, 0);
+
+ for (i=0; i < data->ndevices; i++)
+ SendDlgItemMessageW(dialog, IDC_CONTROLLERCOMBO, CB_ADDSTRING, 0, (LPARAM) data->devices[i].ddi.tszProductName );
+}
+
+static void destroy_data(HWND dialog)
+{
+ int i;
+ ConfigureDevicesData *data = (ConfigureDevicesData*) GetWindowLongPtrW(dialog, DWLP_USER);
+ DIDevicesData *devices_data = &data->devices_data;
+
+ /* Free the devices */
+ for (i=0; i < devices_data->ndevices; i++)
+ IDirectInputDevice8_Release(devices_data->devices[i].lpdid);
+
+ HeapFree(GetProcessHeap(), 0, devices_data->devices);
+
+ /* Free the backup LPDIACTIONFORMATW */
+ HeapFree(GetProcessHeap(), 0, data->original_lpdiaf->rgoAction);
+ HeapFree(GetProcessHeap(), 0, data->original_lpdiaf);
+}
+
+static void fill_device_object_list(HWND dialog)
+{
+ DeviceData *device = get_cur_device(dialog);
+ LPDIACTIONFORMATW lpdiaf = get_cur_lpdiaf(dialog);
+ LVITEMW item;
+ int i, j;
+
+ /* Clean the listview */
+ SendDlgItemMessageW(dialog, IDC_DEVICEOBJECTSLIST, LVM_DELETEALLITEMS, 0, 0);
+
+ /* Add each object */
+ for (i=0; i < device->nobjects; i++)
+ {
+ int action = -1;
+
+ item.mask = LVIF_TEXT | LVIF_PARAM;
+ item.iItem = i;
+ item.iSubItem = 0;
+ item.pszText = device->ddo[i].tszName;
+ item.cchTextMax = lstrlenW(item.pszText);
+
+ /* Add the item */
+ SendDlgItemMessageW(dialog, IDC_DEVICEOBJECTSLIST, LVM_INSERTITEMW, 0, (LPARAM) &item);
+
+ /* Search for an assigned action for this device */
+ for (j=0; j < lpdiaf->dwNumActions; j++)
+ {
+ if (IsEqualGUID(&lpdiaf->rgoAction[j].guidInstance, &device->ddi.guidInstance) &&
+ lpdiaf->rgoAction[j].dwObjID == device->ddo[i].dwType)
+ {
+ action = j;
+ break;
+ }
+ }
+
+ lv_set_action(dialog, i, action, lpdiaf);
+ }
+}
+
+static void show_suitable_actions(HWND dialog)
+{
+ DeviceData *device = get_cur_device(dialog);
+ LPDIACTIONFORMATW lpdiaf = get_cur_lpdiaf(dialog);
+ int i, added = 0;
+ int obj = lv_get_cur_item(dialog);
+
+ if (obj < 0) return;
+
+ SendDlgItemMessageW(dialog, IDC_ACTIONLIST, LB_RESETCONTENT, 0, 0);
+
+ for (i=0; i < lpdiaf->dwNumActions; i++)
+ {
+ /* Skip keyboard actions for non keyboards */
+ if (GET_DIDEVICE_TYPE(device->ddi.dwDevType) != DI8DEVTYPE_KEYBOARD &&
+ (lpdiaf->rgoAction[i].dwSemantic & DIKEYBOARD_MASK) == DIKEYBOARD_MASK) continue;
+
+ /* Skip mouse actions for non mouses */
+ if (GET_DIDEVICE_TYPE(device->ddi.dwDevType) != DI8DEVTYPE_MOUSE &&
+ (lpdiaf->rgoAction[i].dwSemantic & DIMOUSE_MASK) == DIMOUSE_MASK) continue;
+
+ /* Add action string and index in the action format to the list entry */
+ if (DIDFT_GETINSTANCE(lpdiaf->rgoAction[i].dwSemantic) & DIDFT_GETTYPE(device->ddo[obj].dwType))
+ {
+ SendDlgItemMessageW(dialog, IDC_ACTIONLIST, LB_ADDSTRING, 0, (LPARAM)lpdiaf->rgoAction[i].u.lptszActionName);
+ SendDlgItemMessageW(dialog, IDC_ACTIONLIST, LB_SETITEMDATA, added, (LPARAM) i);
+ added++;
+ }
+ }
+}
+
+static void assign_action(HWND dialog)
+{
+ DeviceData *device = get_cur_device(dialog);
+ LPDIACTIONFORMATW lpdiaf = get_cur_lpdiaf(dialog);
+ LVFINDINFOW lvFind;
+ int sel = SendDlgItemMessageW(dialog, IDC_ACTIONLIST, LB_GETCURSEL, 0, 0);
+ int action = SendDlgItemMessageW(dialog, IDC_ACTIONLIST, LB_GETITEMDATA, sel, 0);
+ int obj = lv_get_cur_item(dialog);
+ int old_action = lv_get_item_data(dialog, obj);
+ int used_obj;
+
+ DIDEVICEOBJECTINSTANCEW ddo = device->ddo[obj];
+
+ if (old_action == action) return;
+
+ /* Clear old action */
+ if (old_action != -1)
+ {
+ lpdiaf->rgoAction[old_action].dwObjID = 0;
+ lpdiaf->rgoAction[old_action].guidInstance = GUID_NULL;
+ lpdiaf->rgoAction[old_action].dwHow = DIAH_UNMAPPED;
+ }
+
+ /* Find if action text is already set for other object and unset it */
+ lvFind.flags = LVFI_PARAM;
+ lvFind.lParam = action;
+
+ used_obj = SendDlgItemMessageW(dialog, IDC_DEVICEOBJECTSLIST, LVM_FINDITEMW, -1, (LPARAM) &lvFind);
+
+ lv_set_action(dialog, used_obj, -1, lpdiaf);
+
+ /* Set new action */
+ lpdiaf->rgoAction[action].dwObjID = ddo.dwType;
+ lpdiaf->rgoAction[action].guidInstance = device->ddi.guidInstance;
+ lpdiaf->rgoAction[action].dwHow = DIAH_USERCONFIG;
+
+ /* Set new action in the list */
+ lv_set_action(dialog, obj, action, lpdiaf);
+}
+
+static void copy_actions(LPDIACTIONFORMATW to, LPDIACTIONFORMATW from)
+{
+ DWORD i;
+ for (i=0; i < from->dwNumActions; i++)
+ {
+ to->rgoAction[i].guidInstance = from->rgoAction[i].guidInstance;
+ to->rgoAction[i].dwObjID = from->rgoAction[i].dwObjID;
+ to->rgoAction[i].dwHow = from->rgoAction[i].dwHow;
+ to->rgoAction[i].u.lptszActionName = from->rgoAction[i].u.lptszActionName;
+ }
+}
+
+static void reset_actions(HWND dialog)
+{
+ ConfigureDevicesData *data = (ConfigureDevicesData*) GetWindowLongPtrW(dialog, DWLP_USER);
+ LPDIACTIONFORMATW to = data->lpdiaf, from = data->original_lpdiaf;
+
+ copy_actions(to, from);
+}
+
+static INT_PTR CALLBACK ConfigureDevicesDlgProc(HWND dialog, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ switch(uMsg)
+ {
+ case WM_INITDIALOG:
+ {
+ ConfigureDevicesData *data = (ConfigureDevicesData*) lParam;
+
+ /* Initialize action format and enumerate devices */
+ init_devices(dialog, data->lpDI, &data->devices_data, data->lpdiaf);
+
+ /* Store information in the window */
+ SetWindowLongPtrW(dialog, DWLP_USER, (LONG_PTR) data);
+
+ init_listview_columns(dialog);
+
+ /* Create a backup action format for CANCEL and RESET operations */
+ data->original_lpdiaf = HeapAlloc(GetProcessHeap(), 0, sizeof(*data->original_lpdiaf));
+ data->original_lpdiaf->dwNumActions = data->lpdiaf->dwNumActions;
+ data->original_lpdiaf->rgoAction = HeapAlloc(GetProcessHeap(), 0, sizeof(DIACTIONW)*data->lpdiaf->dwNumActions);
+ copy_actions(data->original_lpdiaf, data->lpdiaf);
+
+ /* Select the first device and show its actions */
+ SendDlgItemMessageW(dialog, IDC_CONTROLLERCOMBO, CB_SETCURSEL, 0, 0);
+ fill_device_object_list(dialog);
+
+ break;
+ }
+
+ case WM_NOTIFY:
+
+ switch (((LPNMHDR)lParam)->code)
+ {
+ case LVN_ITEMCHANGED:
+ show_suitable_actions(dialog);
+ break;
+ }
+ break;
+
+
+ case WM_COMMAND:
+
+ switch(LOWORD(wParam))
+ {
+
+ case IDC_ACTIONLIST:
+
+ switch (HIWORD(wParam))
+ {
+ case LBN_DBLCLK:
+ /* Ignore this if app did not ask for editing */
+ if (dialog_display_only(dialog)) break;
+
+ assign_action(dialog);
+ break;
+ }
+ break;
+
+ case IDC_CONTROLLERCOMBO:
+
+ switch (HIWORD(wParam))
+ {
+ case CBN_SELCHANGE:
+ fill_device_object_list(dialog);
+ break;
+ }
+ break;
+
+ case IDOK:
+ EndDialog(dialog, 0);
+ destroy_data(dialog);
+ break;
+
+ case IDCANCEL:
+ reset_actions(dialog);
+ EndDialog(dialog, 0);
+ destroy_data(dialog);
+ break;
+
+ case IDC_RESET:
+ reset_actions(dialog);
+ fill_device_object_list(dialog);
+ break;
+ }
+ break;
+ }
+
+ return FALSE;
+}
+
+HRESULT _configure_devices(IDirectInput8W *iface,
+ LPDICONFIGUREDEVICESCALLBACK lpdiCallback,
+ LPDICONFIGUREDEVICESPARAMSW lpdiCDParams,
+ DWORD dwFlags,
+ LPVOID pvRefData
+)
+{
+ ConfigureDevicesData data;
+ data.lpDI = iface;
+ data.lpdiaf = lpdiCDParams->lprgFormats;
+ data.display_only = !(dwFlags & DICD_EDIT);
+
+ InitCommonControls();
+
+ DialogBoxParamW(GetModuleHandleA("dinput.dll"), (LPCWSTR) MAKEINTRESOURCE(IDD_CONFIGUREDEVICES), lpdiCDParams->hwnd, ConfigureDevicesDlgProc, (LPARAM) &data);
+
+ return DI_OK;
+}
//#include <stdarg.h>
//#include <string.h>
#include <wine/debug.h>
-//#include "wine/unicode.h"
+#include <wine/unicode.h>
//#include "windef.h"
//#include "winbase.h"
-//#include "winreg.h"
-//#include "winuser.h"
+#include <winreg.h>
+#include <winuser.h>
//#include "winerror.h"
//#include "dinput.h"
#include "device_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(dinput);
+static inline IDirectInputDeviceImpl *impl_from_IDirectInputDevice8A(IDirectInputDevice8A *iface)
+{
+ return CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8A_iface);
+}
+static inline IDirectInputDeviceImpl *impl_from_IDirectInputDevice8W(IDirectInputDevice8W *iface)
+{
+ return CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8W_iface);
+}
+
+static inline IDirectInputDevice8A *IDirectInputDevice8A_from_impl(IDirectInputDeviceImpl *This)
+{
+ return &This->IDirectInputDevice8A_iface;
+}
+static inline IDirectInputDevice8W *IDirectInputDevice8W_from_impl(IDirectInputDeviceImpl *This)
+{
+ return &This->IDirectInputDevice8W_iface;
+}
+
/******************************************************************************
* Various debugging tools
*/
return (LPDIOBJECTDATAFORMAT)((LPBYTE)df->rgodf + idx * df->dwObjSize);
}
+/* dataformat_to_odf_by_type
+ * Find the Nth object of the selected type in the DataFormat
+ */
+LPDIOBJECTDATAFORMAT dataformat_to_odf_by_type(LPCDIDATAFORMAT df, int n, DWORD type)
+{
+ int i, nfound = 0;
+
+ for (i=0; i < df->dwNumObjs; i++)
+ {
+ LPDIOBJECTDATAFORMAT odf = dataformat_to_odf(df, i);
+
+ if (odf->dwType & type)
+ {
+ if (n == nfound)
+ return odf;
+
+ nfound++;
+ }
+ }
+
+ return NULL;
+}
+
static HRESULT create_DataFormat(LPCDIDATAFORMAT asked_format, DataFormat *format)
{
DataTransform *dt;
* instance id.
*/
((asked_format->rgodf[j].dwType & DIDFT_INSTANCEMASK) == DIDFT_ANYINSTANCE) ||
- (DIDFT_GETINSTANCE(asked_format->rgodf[j].dwType) == 0x00FF) || /* This is mentionned in no DX docs, but it works fine - tested on WinXP */
+ (DIDFT_GETINSTANCE(asked_format->rgodf[j].dwType) == 0x00FF) || /* This is mentioned in no DX docs, but it works fine - tested on WinXP */
(DIDFT_GETINSTANCE(asked_format->rgodf[j].dwType) == DIDFT_GETINSTANCE(format->wine_df->rgodf[i].dwType)))
&&
( /* Then if the asked type matches the one Wine provides */
return -1;
}
-int id_to_offset(const DataFormat *df, int id)
+static int id_to_offset(const DataFormat *df, int id)
{
int obj = id_to_object(df->wine_df, id);
return -1;
}
+static DWORD semantic_to_obj_id(IDirectInputDeviceImpl* This, DWORD dwSemantic)
+{
+ DWORD type = (0x0000ff00 & dwSemantic) >> 8;
+ DWORD offset = 0x000000ff & dwSemantic;
+ DWORD obj_instance = 0;
+ DWORD found = 0;
+ int i;
+
+ for (i = 0; i < This->data_format.wine_df->dwNumObjs; i++)
+ {
+ LPDIOBJECTDATAFORMAT odf = dataformat_to_odf(This->data_format.wine_df, i);
+
+ if (odf->dwOfs == offset)
+ {
+ obj_instance = DIDFT_GETINSTANCE(odf->dwType);
+ found = 1;
+ break;
+ }
+ }
+
+ if (!found) return 0;
+
+ if (type & DIDFT_AXIS) type = DIDFT_RELAXIS;
+ if (type & DIDFT_BUTTON) type = DIDFT_PSHBUTTON;
+
+ return type | (0x0000ff00 & (obj_instance << 8));
+}
+
+/*
+ * get_mapping_key
+ * Retrieves an open registry key to save the mapping, parametrized for an username,
+ * specific device and specific action mapping guid.
+ */
+static HKEY get_mapping_key(const WCHAR *device, const WCHAR *username, const WCHAR *guid)
+{
+ static const WCHAR subkey[] = {
+ 'S','o','f','t','w','a','r','e','\\',
+ 'W','i','n','e','\\',
+ 'D','i','r','e','c','t','I','n','p','u','t','\\',
+ 'M','a','p','p','i','n','g','s','\\','%','s','\\','%','s','\\','%','s','\0'};
+ HKEY hkey;
+ WCHAR *keyname;
+
+ keyname = HeapAlloc(GetProcessHeap(), 0,
+ sizeof(WCHAR) * (lstrlenW(subkey) + strlenW(username) + strlenW(device) + strlenW(guid)));
+ sprintfW(keyname, subkey, username, device, guid);
+
+ /* The key used is HKCU\Software\Wine\DirectInput\Mappings\[username]\[device]\[mapping_guid] */
+ if (RegCreateKeyW(HKEY_CURRENT_USER, keyname, &hkey))
+ hkey = 0;
+
+ HeapFree(GetProcessHeap(), 0, keyname);
+
+ return hkey;
+}
+
+static HRESULT save_mapping_settings(IDirectInputDevice8W *iface, LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUsername)
+{
+ WCHAR *guid_str = NULL;
+ DIDEVICEINSTANCEW didev;
+ HKEY hkey;
+ int i;
+
+ didev.dwSize = sizeof(didev);
+ IDirectInputDevice8_GetDeviceInfo(iface, &didev);
+
+ if (StringFromCLSID(&lpdiaf->guidActionMap, &guid_str) != S_OK)
+ return DI_SETTINGSNOTSAVED;
+
+ hkey = get_mapping_key(didev.tszInstanceName, lpszUsername, guid_str);
+
+ if (!hkey)
+ {
+ CoTaskMemFree(guid_str);
+ return DI_SETTINGSNOTSAVED;
+ }
+
+ /* Write each of the actions mapped for this device.
+ Format is "dwSemantic"="dwObjID" and key is of type REG_DWORD
+ */
+ for (i = 0; i < lpdiaf->dwNumActions; i++)
+ {
+ static const WCHAR format[] = {'%','x','\0'};
+ WCHAR label[9];
+
+ if (IsEqualGUID(&didev.guidInstance, &lpdiaf->rgoAction[i].guidInstance) &&
+ lpdiaf->rgoAction[i].dwHow != DIAH_UNMAPPED)
+ {
+ sprintfW(label, format, lpdiaf->rgoAction[i].dwSemantic);
+ RegSetValueExW(hkey, label, 0, REG_DWORD, (const BYTE*) &lpdiaf->rgoAction[i].dwObjID, sizeof(DWORD));
+ }
+ }
+
+ RegCloseKey(hkey);
+ CoTaskMemFree(guid_str);
+
+ return DI_OK;
+}
+
+static BOOL load_mapping_settings(IDirectInputDeviceImpl *This, LPDIACTIONFORMATW lpdiaf, const WCHAR *username)
+{
+ HKEY hkey;
+ WCHAR *guid_str;
+ DIDEVICEINSTANCEW didev;
+ int i, mapped = 0;
+
+ didev.dwSize = sizeof(didev);
+ IDirectInputDevice8_GetDeviceInfo(&This->IDirectInputDevice8W_iface, &didev);
+
+ if (StringFromCLSID(&lpdiaf->guidActionMap, &guid_str) != S_OK)
+ return FALSE;
+
+ hkey = get_mapping_key(didev.tszInstanceName, username, guid_str);
+
+ if (!hkey)
+ {
+ CoTaskMemFree(guid_str);
+ return FALSE;
+ }
+
+ /* Try to read each action in the DIACTIONFORMAT from registry */
+ for (i = 0; i < lpdiaf->dwNumActions; i++)
+ {
+ static const WCHAR format[] = {'%','x','\0'};
+ DWORD id, size = sizeof(DWORD);
+ WCHAR label[9];
+
+ sprintfW(label, format, lpdiaf->rgoAction[i].dwSemantic);
+
+ if (!RegQueryValueExW(hkey, label, 0, NULL, (LPBYTE) &id, &size))
+ {
+ lpdiaf->rgoAction[i].dwObjID = id;
+ lpdiaf->rgoAction[i].guidInstance = didev.guidInstance;
+ lpdiaf->rgoAction[i].dwHow = DIAH_DEFAULT;
+ mapped += 1;
+ }
+ }
+
+ RegCloseKey(hkey);
+ CoTaskMemFree(guid_str);
+
+ return mapped > 0;
+}
+
+HRESULT _build_action_map(LPDIRECTINPUTDEVICE8W iface, LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, DWORD dwFlags, DWORD devMask, LPCDIDATAFORMAT df)
+{
+ IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8W(iface);
+ WCHAR username[MAX_PATH];
+ DWORD username_size = MAX_PATH;
+ int i, has_actions = 0;
+ BOOL load_success = FALSE;
+
+ /* Unless asked the contrary by these flags, try to load a previous mapping */
+ if (!(dwFlags & DIDBAM_HWDEFAULTS))
+ {
+ /* Retrieve logged user name if necessary */
+ if (lpszUserName == NULL)
+ GetUserNameW(username, &username_size);
+ else
+ lstrcpynW(username, lpszUserName, MAX_PATH);
+
+ load_success = load_mapping_settings(This, lpdiaf, username);
+ }
+
+ if (load_success) return DI_OK;
+
+ for (i=0; i < lpdiaf->dwNumActions; i++)
+ {
+ /* Don't touch a user configured action */
+ if (lpdiaf->rgoAction[i].dwHow == DIAH_USERCONFIG) continue;
+
+ if ((lpdiaf->rgoAction[i].dwSemantic & devMask) == devMask)
+ {
+ DWORD obj_id = semantic_to_obj_id(This, lpdiaf->rgoAction[i].dwSemantic);
+ DWORD type = DIDFT_GETTYPE(obj_id);
+ DWORD inst = DIDFT_GETINSTANCE(obj_id);
+
+ LPDIOBJECTDATAFORMAT odf;
+
+ if (type == DIDFT_PSHBUTTON) type = DIDFT_BUTTON;
+ if (type == DIDFT_RELAXIS) type = DIDFT_AXIS;
+
+ /* Make sure the object exists */
+ odf = dataformat_to_odf_by_type(df, inst, type);
+
+ if (odf != NULL)
+ {
+ lpdiaf->rgoAction[i].dwObjID = obj_id;
+ lpdiaf->rgoAction[i].guidInstance = This->guid;
+ lpdiaf->rgoAction[i].dwHow = DIAH_DEFAULT;
+ has_actions = 1;
+ }
+ }
+ else if (!(dwFlags & DIDBAM_PRESERVE))
+ {
+ /* We must clear action data belonging to other devices */
+ memset(&lpdiaf->rgoAction[i].guidInstance, 0, sizeof(GUID));
+ lpdiaf->rgoAction[i].dwHow = DIAH_UNMAPPED;
+ }
+ }
+
+ if (!has_actions) return DI_NOEFFECT;
+
+ return IDirectInputDevice8WImpl_BuildActionMap(iface, lpdiaf, lpszUserName, dwFlags);
+}
+
+HRESULT _set_action_map(LPDIRECTINPUTDEVICE8W iface, LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, DWORD dwFlags, LPCDIDATAFORMAT df)
+{
+ IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8W(iface);
+ DIDATAFORMAT data_format;
+ DIOBJECTDATAFORMAT *obj_df = NULL;
+ DIPROPDWORD dp;
+ DIPROPRANGE dpr;
+ WCHAR username[MAX_PATH];
+ DWORD username_size = MAX_PATH;
+ int i, action = 0, num_actions = 0;
+ unsigned int offset = 0;
+
+ if (This->acquired) return DIERR_ACQUIRED;
+
+ data_format.dwSize = sizeof(data_format);
+ data_format.dwObjSize = sizeof(DIOBJECTDATAFORMAT);
+ data_format.dwFlags = DIDF_RELAXIS;
+ data_format.dwDataSize = lpdiaf->dwDataSize;
+
+ /* Count the actions */
+ for (i=0; i < lpdiaf->dwNumActions; i++)
+ if (IsEqualGUID(&This->guid, &lpdiaf->rgoAction[i].guidInstance))
+ num_actions++;
+
+ if (num_actions == 0) return DI_NOEFFECT;
+
+ This->num_actions = num_actions;
+
+ /* Construct the dataformat and actionmap */
+ obj_df = HeapAlloc(GetProcessHeap(), 0, sizeof(DIOBJECTDATAFORMAT)*num_actions);
+ data_format.rgodf = (LPDIOBJECTDATAFORMAT)obj_df;
+ data_format.dwNumObjs = num_actions;
+
+ HeapFree(GetProcessHeap(), 0, This->action_map);
+ This->action_map = HeapAlloc(GetProcessHeap(), 0, sizeof(ActionMap)*num_actions);
+
+ for (i = 0; i < lpdiaf->dwNumActions; i++)
+ {
+ if (IsEqualGUID(&This->guid, &lpdiaf->rgoAction[i].guidInstance))
+ {
+ DWORD inst = DIDFT_GETINSTANCE(lpdiaf->rgoAction[i].dwObjID);
+ DWORD type = DIDFT_GETTYPE(lpdiaf->rgoAction[i].dwObjID);
+ LPDIOBJECTDATAFORMAT obj;
+
+ if (type == DIDFT_PSHBUTTON) type = DIDFT_BUTTON;
+ if (type == DIDFT_RELAXIS) type = DIDFT_AXIS;
+
+ obj = dataformat_to_odf_by_type(df, inst, type);
+
+ memcpy(&obj_df[action], obj, df->dwObjSize);
+
+ This->action_map[action].uAppData = lpdiaf->rgoAction[i].uAppData;
+ This->action_map[action].offset = offset;
+ obj_df[action].dwOfs = offset;
+ offset += (type & DIDFT_BUTTON) ? 1 : 4;
+
+ action++;
+ }
+ }
+
+ IDirectInputDevice8_SetDataFormat(iface, &data_format);
+
+ HeapFree(GetProcessHeap(), 0, obj_df);
+
+ /* Set the device properties according to the action format */
+ dpr.diph.dwSize = sizeof(DIPROPRANGE);
+ dpr.lMin = lpdiaf->lAxisMin;
+ dpr.lMax = lpdiaf->lAxisMax;
+ dpr.diph.dwHeaderSize = sizeof(DIPROPHEADER);
+ dpr.diph.dwHow = DIPH_DEVICE;
+ IDirectInputDevice8_SetProperty(iface, DIPROP_RANGE, &dpr.diph);
+
+ if (lpdiaf->dwBufferSize > 0)
+ {
+ dp.diph.dwSize = sizeof(DIPROPDWORD);
+ dp.dwData = lpdiaf->dwBufferSize;
+ dp.diph.dwHeaderSize = sizeof(DIPROPHEADER);
+ dp.diph.dwHow = DIPH_DEVICE;
+ IDirectInputDevice8_SetProperty(iface, DIPROP_BUFFERSIZE, &dp.diph);
+ }
+
+ /* Retrieve logged user name if necessary */
+ if (lpszUserName == NULL)
+ GetUserNameW(username, &username_size);
+ else
+ lstrcpynW(username, lpszUserName, MAX_PATH);
+
+ /* Save the settings to disk */
+ save_mapping_settings(iface, lpdiaf, username);
+
+ return IDirectInputDevice8WImpl_SetActionMap(iface, lpdiaf, lpszUserName, dwFlags);
+}
+
/******************************************************************************
* queue_event - add new event to the ring queue
*/
-void queue_event(LPDIRECTINPUTDEVICE8A iface, int ofs, DWORD data, DWORD time, DWORD seq)
+void queue_event(LPDIRECTINPUTDEVICE8A iface, int inst_id, DWORD data, DWORD time, DWORD seq)
{
- IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
- int next_pos;
+ IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface);
+ int next_pos, ofs = id_to_offset(&This->data_format, inst_id);
/* Event is being set regardless of the queue state */
if (This->hEvent) SetEvent(This->hEvent);
This->data_queue[This->queue_head].dwData = data;
This->data_queue[This->queue_head].dwTimeStamp = time;
This->data_queue[This->queue_head].dwSequence = seq;
+
+ /* Set uAppData by means of action mapping */
+ if (This->num_actions > 0)
+ {
+ int i;
+ for (i=0; i < This->num_actions; i++)
+ {
+ if (This->action_map[i].offset == ofs)
+ {
+ TRACE("Offset %d mapped to uAppData %lu\n", ofs, This->action_map[i].uAppData);
+ This->data_queue[This->queue_head].uAppData = This->action_map[i].uAppData;
+ break;
+ }
+ }
+ }
+
This->queue_head = next_pos;
/* Send event if asked */
}
* Acquire
*/
-HRESULT WINAPI IDirectInputDevice2AImpl_Acquire(LPDIRECTINPUTDEVICE8A iface)
+HRESULT WINAPI IDirectInputDevice2WImpl_Acquire(LPDIRECTINPUTDEVICE8W iface)
{
- IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
+ IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8W(iface);
HRESULT res;
+ TRACE("(%p)\n", This);
+
if (!This->data_format.user_df) return DIERR_INVALIDPARAM;
if (This->dwCoopLevel & DISCL_FOREGROUND && This->win != GetForegroundWindow())
return DIERR_OTHERAPPHASPRIO;
res = This->acquired ? S_FALSE : DI_OK;
This->acquired = 1;
if (res == DI_OK)
- {
- This->queue_head = This->queue_tail = This->overflow = 0;
check_dinput_hooks(iface);
- }
LeaveCriticalSection(&This->crit);
return res;
}
+HRESULT WINAPI IDirectInputDevice2AImpl_Acquire(LPDIRECTINPUTDEVICE8A iface)
+{
+ IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface);
+ return IDirectInputDevice2WImpl_Acquire(IDirectInputDevice8W_from_impl(This));
+}
+
+
/******************************************************************************
* Unacquire
*/
-HRESULT WINAPI IDirectInputDevice2AImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface)
+HRESULT WINAPI IDirectInputDevice2WImpl_Unacquire(LPDIRECTINPUTDEVICE8W iface)
{
- IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
+ IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8W(iface);
HRESULT res;
+ TRACE("(%p)\n", This);
+
EnterCriticalSection(&This->crit);
res = !This->acquired ? DI_NOEFFECT : DI_OK;
This->acquired = 0;
return res;
}
+HRESULT WINAPI IDirectInputDevice2AImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface)
+{
+ IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface);
+ return IDirectInputDevice2WImpl_Unacquire(IDirectInputDevice8W_from_impl(This));
+}
+
/******************************************************************************
* IDirectInputDeviceA
*/
-HRESULT WINAPI IDirectInputDevice2AImpl_SetDataFormat(
- LPDIRECTINPUTDEVICE8A iface, LPCDIDATAFORMAT df)
+HRESULT WINAPI IDirectInputDevice2WImpl_SetDataFormat(LPDIRECTINPUTDEVICE8W iface, LPCDIDATAFORMAT df)
{
- IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
+ IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8W(iface);
HRESULT res = DI_OK;
if (!df) return E_POINTER;
return res;
}
+HRESULT WINAPI IDirectInputDevice2AImpl_SetDataFormat(LPDIRECTINPUTDEVICE8A iface, LPCDIDATAFORMAT df)
+{
+ IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface);
+ return IDirectInputDevice2WImpl_SetDataFormat(IDirectInputDevice8W_from_impl(This), df);
+}
+
/******************************************************************************
* SetCooperativeLevel
*
* Set cooperative level and the source window for the events.
*/
-HRESULT WINAPI IDirectInputDevice2AImpl_SetCooperativeLevel(
- LPDIRECTINPUTDEVICE8A iface, HWND hwnd, DWORD dwflags)
+HRESULT WINAPI IDirectInputDevice2WImpl_SetCooperativeLevel(LPDIRECTINPUTDEVICE8W iface, HWND hwnd, DWORD dwflags)
{
- IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
+ IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8W(iface);
TRACE("(%p) %p,0x%08x\n", This, hwnd, dwflags);
_dump_cooperativelevel_DI(dwflags);
(dwflags & (DISCL_FOREGROUND | DISCL_BACKGROUND)) == (DISCL_FOREGROUND | DISCL_BACKGROUND))
return DIERR_INVALIDPARAM;
+ if (hwnd && GetWindowLongW(hwnd, GWL_STYLE) & WS_CHILD) return E_HANDLE;
+
if (dwflags == (DISCL_NONEXCLUSIVE | DISCL_BACKGROUND))
hwnd = GetDesktopWindow();
return DI_OK;
}
+HRESULT WINAPI IDirectInputDevice2AImpl_SetCooperativeLevel(LPDIRECTINPUTDEVICE8A iface, HWND hwnd, DWORD dwflags)
+{
+ IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface);
+ return IDirectInputDevice2WImpl_SetCooperativeLevel(IDirectInputDevice8W_from_impl(This), hwnd, dwflags);
+}
+
/******************************************************************************
* SetEventNotification : specifies event to be sent on state change
*/
-HRESULT WINAPI IDirectInputDevice2AImpl_SetEventNotification(
- LPDIRECTINPUTDEVICE8A iface, HANDLE event)
+HRESULT WINAPI IDirectInputDevice2WImpl_SetEventNotification(LPDIRECTINPUTDEVICE8W iface, HANDLE event)
{
- IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
+ IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8W(iface);
TRACE("(%p) %p\n", This, event);
return DI_OK;
}
-ULONG WINAPI IDirectInputDevice2AImpl_Release(LPDIRECTINPUTDEVICE8A iface)
+HRESULT WINAPI IDirectInputDevice2AImpl_SetEventNotification(LPDIRECTINPUTDEVICE8A iface, HANDLE event)
+{
+ IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface);
+ return IDirectInputDevice2WImpl_SetEventNotification(IDirectInputDevice8W_from_impl(This), event);
+}
+
+
+ULONG WINAPI IDirectInputDevice2WImpl_Release(LPDIRECTINPUTDEVICE8W iface)
{
- IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
- ULONG ref;
+ IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8W(iface);
+ ULONG ref = InterlockedDecrement(&(This->ref));
+
+ TRACE("(%p) releasing from %d\n", This, ref + 1);
- ref = InterlockedDecrement(&(This->ref));
if (ref) return ref;
IDirectInputDevice_Unacquire(iface);
HeapFree(GetProcessHeap(), 0, This->data_format.wine_df);
release_DataFormat(&This->data_format);
+ /* Free action mapping */
+ HeapFree(GetProcessHeap(), 0, This->action_map);
+
EnterCriticalSection( &This->dinput->crit );
list_remove( &This->entry );
LeaveCriticalSection( &This->dinput->crit );
- IDirectInput_Release((LPDIRECTINPUTDEVICE8A)This->dinput);
+ IDirectInput_Release(&This->dinput->IDirectInput7A_iface);
This->crit.DebugInfo->Spare[0] = 0;
DeleteCriticalSection(&This->crit);
return DI_OK;
}
-HRESULT WINAPI IDirectInputDevice2AImpl_QueryInterface(
- LPDIRECTINPUTDEVICE8A iface,REFIID riid,LPVOID *ppobj
-)
+ULONG WINAPI IDirectInputDevice2AImpl_Release(LPDIRECTINPUTDEVICE8A iface)
{
- IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
-
- TRACE("(this=%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
- if (IsEqualGUID(&IID_IUnknown,riid)) {
- IDirectInputDevice2_AddRef(iface);
- *ppobj = This;
- return DI_OK;
- }
- if (IsEqualGUID(&IID_IDirectInputDeviceA,riid)) {
- IDirectInputDevice2_AddRef(iface);
- *ppobj = This;
- return DI_OK;
- }
- if (IsEqualGUID(&IID_IDirectInputDevice2A,riid)) {
- IDirectInputDevice2_AddRef(iface);
- *ppobj = This;
- return DI_OK;
- }
- if (IsEqualGUID(&IID_IDirectInputDevice7A,riid)) {
- IDirectInputDevice7_AddRef(iface);
- *ppobj = This;
- return DI_OK;
- }
- if (IsEqualGUID(&IID_IDirectInputDevice8A,riid)) {
- IDirectInputDevice8_AddRef(iface);
- *ppobj = This;
- return DI_OK;
- }
- TRACE("Unsupported interface !\n");
- return E_FAIL;
+ IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface);
+ return IDirectInputDevice2WImpl_Release(IDirectInputDevice8W_from_impl(This));
}
-HRESULT WINAPI IDirectInputDevice2WImpl_QueryInterface(
- LPDIRECTINPUTDEVICE8W iface,REFIID riid,LPVOID *ppobj
-)
+HRESULT WINAPI IDirectInputDevice2WImpl_QueryInterface(LPDIRECTINPUTDEVICE8W iface, REFIID riid, LPVOID *ppobj)
{
- IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
-
- TRACE("(this=%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
- if (IsEqualGUID(&IID_IUnknown,riid)) {
- IDirectInputDevice2_AddRef(iface);
- *ppobj = This;
- return DI_OK;
- }
- if (IsEqualGUID(&IID_IDirectInputDeviceW,riid)) {
- IDirectInputDevice2_AddRef(iface);
- *ppobj = This;
- return DI_OK;
- }
- if (IsEqualGUID(&IID_IDirectInputDevice2W,riid)) {
- IDirectInputDevice2_AddRef(iface);
- *ppobj = This;
- return DI_OK;
- }
- if (IsEqualGUID(&IID_IDirectInputDevice7W,riid)) {
- IDirectInputDevice7_AddRef(iface);
- *ppobj = This;
- return DI_OK;
+ IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8W(iface);
+
+ TRACE("(%p this=%p,%s,%p)\n", iface, This, debugstr_guid(riid), ppobj);
+ if (IsEqualGUID(&IID_IUnknown, riid) ||
+ IsEqualGUID(&IID_IDirectInputDeviceA, riid) ||
+ IsEqualGUID(&IID_IDirectInputDevice2A, riid) ||
+ IsEqualGUID(&IID_IDirectInputDevice7A, riid) ||
+ IsEqualGUID(&IID_IDirectInputDevice8A, riid))
+ {
+ IDirectInputDevice2_AddRef(iface);
+ *ppobj = IDirectInputDevice8A_from_impl(This);
+ return DI_OK;
}
- if (IsEqualGUID(&IID_IDirectInputDevice8W,riid)) {
- IDirectInputDevice8_AddRef(iface);
- *ppobj = This;
- return DI_OK;
+ if (IsEqualGUID(&IID_IDirectInputDeviceW, riid) ||
+ IsEqualGUID(&IID_IDirectInputDevice2W, riid) ||
+ IsEqualGUID(&IID_IDirectInputDevice7W, riid) ||
+ IsEqualGUID(&IID_IDirectInputDevice8W, riid))
+ {
+ IDirectInputDevice2_AddRef(iface);
+ *ppobj = IDirectInputDevice8W_from_impl(This);
+ return DI_OK;
}
- TRACE("Unsupported interface !\n");
+
+ WARN("Unsupported interface!\n");
return E_FAIL;
}
-ULONG WINAPI IDirectInputDevice2AImpl_AddRef(
- LPDIRECTINPUTDEVICE8A iface)
+HRESULT WINAPI IDirectInputDevice2AImpl_QueryInterface(LPDIRECTINPUTDEVICE8A iface, REFIID riid, LPVOID *ppobj)
+{
+ IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface);
+ return IDirectInputDevice2WImpl_QueryInterface(IDirectInputDevice8W_from_impl(This), riid, ppobj);
+}
+
+ULONG WINAPI IDirectInputDevice2WImpl_AddRef(LPDIRECTINPUTDEVICE8W iface)
{
- IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
- return InterlockedIncrement(&(This->ref));
+ IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8W(iface);
+ return InterlockedIncrement(&This->ref);
+}
+
+ULONG WINAPI IDirectInputDevice2AImpl_AddRef(LPDIRECTINPUTDEVICE8A iface)
+{
+ IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface);
+ return IDirectInputDevice2WImpl_AddRef(IDirectInputDevice8W_from_impl(This));
}
HRESULT WINAPI IDirectInputDevice2AImpl_EnumObjects(LPDIRECTINPUTDEVICE8A iface,
LPDIENUMDEVICEOBJECTSCALLBACKA lpCallback, LPVOID lpvRef, DWORD dwFlags)
{
- IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
+ IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface);
DIDEVICEOBJECTINSTANCEA ddoi;
int i;
{
LPDIOBJECTDATAFORMAT odf = dataformat_to_odf(This->data_format.wine_df, i);
- if (dwFlags != DIDFT_ALL && !(dwFlags & DIEFT_GETTYPE(odf->dwType))) continue;
+ if (dwFlags != DIDFT_ALL && !(dwFlags & DIDFT_GETTYPE(odf->dwType))) continue;
if (IDirectInputDevice_GetObjectInfo(iface, &ddoi, odf->dwType, DIPH_BYID) != DI_OK)
continue;
HRESULT WINAPI IDirectInputDevice2WImpl_EnumObjects(LPDIRECTINPUTDEVICE8W iface,
LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback, LPVOID lpvRef, DWORD dwFlags)
{
- IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
+ IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8W(iface);
DIDEVICEOBJECTINSTANCEW ddoi;
int i;
{
LPDIOBJECTDATAFORMAT odf = dataformat_to_odf(This->data_format.wine_df, i);
- if (dwFlags != DIDFT_ALL && !(dwFlags & DIEFT_GETTYPE(odf->dwType))) continue;
+ if (dwFlags != DIDFT_ALL && !(dwFlags & DIDFT_GETTYPE(odf->dwType))) continue;
if (IDirectInputDevice_GetObjectInfo(iface, &ddoi, odf->dwType, DIPH_BYID) != DI_OK)
continue;
* GetProperty
*/
-HRESULT WINAPI IDirectInputDevice2AImpl_GetProperty(
- LPDIRECTINPUTDEVICE8A iface, REFGUID rguid, LPDIPROPHEADER pdiph)
+HRESULT WINAPI IDirectInputDevice2WImpl_GetProperty(LPDIRECTINPUTDEVICE8W iface, REFGUID rguid, LPDIPROPHEADER pdiph)
{
- IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
+ IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8W(iface);
TRACE("(%p) %s,%p\n", iface, debugstr_guid(rguid), pdiph);
_dump_DIPROPHEADER(pdiph);
- if (HIWORD(rguid)) return DI_OK;
+ if (!IS_DIPROP(rguid)) return DI_OK;
switch (LOWORD(rguid))
{
TRACE("buffersize = %d\n", pd->dwData);
break;
}
+ case (DWORD_PTR) DIPROP_VIDPID:
+ FIXME("DIPROP_VIDPID not implemented\n");
+ return DIERR_UNSUPPORTED;
default:
- WARN("Unknown property %s\n", debugstr_guid(rguid));
- break;
+ FIXME("Unknown property %s\n", debugstr_guid(rguid));
+ return DIERR_INVALIDPARAM;
}
return DI_OK;
}
+HRESULT WINAPI IDirectInputDevice2AImpl_GetProperty(LPDIRECTINPUTDEVICE8A iface, REFGUID rguid, LPDIPROPHEADER pdiph)
+{
+ IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface);
+ return IDirectInputDevice2WImpl_GetProperty(IDirectInputDevice8W_from_impl(This), rguid, pdiph);
+}
+
/******************************************************************************
* SetProperty
*/
-HRESULT WINAPI IDirectInputDevice2AImpl_SetProperty(
- LPDIRECTINPUTDEVICE8A iface, REFGUID rguid, LPCDIPROPHEADER pdiph)
+HRESULT WINAPI IDirectInputDevice2WImpl_SetProperty(
+ LPDIRECTINPUTDEVICE8W iface, REFGUID rguid, LPCDIPROPHEADER pdiph)
{
- IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
+ IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8W(iface);
TRACE("(%p) %s,%p\n", iface, debugstr_guid(rguid), pdiph);
_dump_DIPROPHEADER(pdiph);
- if (HIWORD(rguid)) return DI_OK;
+ if (!IS_DIPROP(rguid)) return DI_OK;
switch (LOWORD(rguid))
{
return DI_OK;
}
+HRESULT WINAPI IDirectInputDevice2AImpl_SetProperty(
+ LPDIRECTINPUTDEVICE8A iface, REFGUID rguid, LPCDIPROPHEADER pdiph)
+{
+ IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface);
+ return IDirectInputDevice2WImpl_SetProperty(IDirectInputDevice8W_from_impl(This), rguid, pdiph);
+}
+
HRESULT WINAPI IDirectInputDevice2AImpl_GetObjectInfo(
LPDIRECTINPUTDEVICE8A iface,
LPDIDEVICEOBJECTINSTANCEA pdidoi,
DWORD dwObj,
DWORD dwHow)
{
+ IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface);
DIDEVICEOBJECTINSTANCEW didoiW;
HRESULT res;
return DIERR_INVALIDPARAM;
didoiW.dwSize = sizeof(didoiW);
- res = IDirectInputDevice2WImpl_GetObjectInfo((LPDIRECTINPUTDEVICE8W)iface, &didoiW, dwObj, dwHow);
+ res = IDirectInputDevice2WImpl_GetObjectInfo(IDirectInputDevice8W_from_impl(This), &didoiW, dwObj, dwHow);
if (res == DI_OK)
{
DWORD dwSize = pdidoi->dwSize;
DWORD dwObj,
DWORD dwHow)
{
- IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
+ IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8W(iface);
DWORD dwSize;
LPDIOBJECTDATAFORMAT odf;
int idx = -1;
return DI_OK;
}
-HRESULT WINAPI IDirectInputDevice2AImpl_GetDeviceData(
- LPDIRECTINPUTDEVICE8A iface, DWORD dodsize, LPDIDEVICEOBJECTDATA dod,
- LPDWORD entries, DWORD flags)
+HRESULT WINAPI IDirectInputDevice2WImpl_GetDeviceData(LPDIRECTINPUTDEVICE8W iface, DWORD dodsize,
+ LPDIDEVICEOBJECTDATA dod, LPDWORD entries, DWORD flags)
{
- IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
+ IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8W(iface);
HRESULT ret = DI_OK;
int len;
TRACE("(%p) %p -> %p(%d) x%d, 0x%08x\n",
This, dod, entries, entries ? *entries : 0, dodsize, flags);
- if (!This->acquired)
- return DIERR_NOTACQUIRED;
+ if (This->dinput->dwVersion == 0x0800 || dodsize == sizeof(DIDEVICEOBJECTDATA_DX3))
+ {
+ if (!This->queue_len) return DIERR_NOTBUFFERED;
+ if (!This->acquired) return DIERR_NOTACQUIRED;
+ }
+
if (!This->queue_len)
- return DIERR_NOTBUFFERED;
+ return DI_OK;
if (dodsize < sizeof(DIDEVICEOBJECTDATA_DX3))
return DIERR_INVALIDPARAM;
}
*entries = len;
- if (This->overflow)
+ if (This->overflow && This->dinput->dwVersion == 0x0800)
ret = DI_BUFFEROVERFLOW;
if (!(flags & DIGDD_PEEK))
return ret;
}
-HRESULT WINAPI IDirectInputDevice2AImpl_RunControlPanel(
- LPDIRECTINPUTDEVICE8A iface,
- HWND hwndOwner,
- DWORD dwFlags)
+HRESULT WINAPI IDirectInputDevice2AImpl_GetDeviceData(LPDIRECTINPUTDEVICE8A iface, DWORD dodsize,
+ LPDIDEVICEOBJECTDATA dod, LPDWORD entries, DWORD flags)
{
- FIXME("(this=%p,%p,0x%08x): stub!\n",
- iface, hwndOwner, dwFlags);
+ IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface);
+ return IDirectInputDevice2WImpl_GetDeviceData(IDirectInputDevice8W_from_impl(This), dodsize, dod, entries, flags);
+}
+
+HRESULT WINAPI IDirectInputDevice2WImpl_RunControlPanel(LPDIRECTINPUTDEVICE8W iface, HWND hwndOwner, DWORD dwFlags)
+{
+ FIXME("(this=%p,%p,0x%08x): stub!\n", iface, hwndOwner, dwFlags);
return DI_OK;
}
-HRESULT WINAPI IDirectInputDevice2AImpl_Initialize(
- LPDIRECTINPUTDEVICE8A iface,
- HINSTANCE hinst,
- DWORD dwVersion,
- REFGUID rguid)
+HRESULT WINAPI IDirectInputDevice2AImpl_RunControlPanel(LPDIRECTINPUTDEVICE8A iface, HWND hwndOwner, DWORD dwFlags)
{
- FIXME("(this=%p,%p,%d,%s): stub!\n",
- iface, hinst, dwVersion, debugstr_guid(rguid));
+ IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface);
+ return IDirectInputDevice2WImpl_RunControlPanel(IDirectInputDevice8W_from_impl(This), hwndOwner, dwFlags);
+}
+
+HRESULT WINAPI IDirectInputDevice2WImpl_Initialize(LPDIRECTINPUTDEVICE8W iface, HINSTANCE hinst, DWORD dwVersion,
+ REFGUID rguid)
+{
+ FIXME("(this=%p,%p,%d,%s): stub!\n", iface, hinst, dwVersion, debugstr_guid(rguid));
return DI_OK;
}
+HRESULT WINAPI IDirectInputDevice2AImpl_Initialize(LPDIRECTINPUTDEVICE8A iface, HINSTANCE hinst, DWORD dwVersion,
+ REFGUID rguid)
+{
+ IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface);
+ return IDirectInputDevice2WImpl_Initialize(IDirectInputDevice8W_from_impl(This), hinst, dwVersion, rguid);
+}
+
/******************************************************************************
* IDirectInputDevice2A
*/
-HRESULT WINAPI IDirectInputDevice2AImpl_CreateEffect(
- LPDIRECTINPUTDEVICE8A iface,
- REFGUID rguid,
- LPCDIEFFECT lpeff,
- LPDIRECTINPUTEFFECT *ppdef,
- LPUNKNOWN pUnkOuter)
+HRESULT WINAPI IDirectInputDevice2WImpl_CreateEffect(LPDIRECTINPUTDEVICE8W iface, REFGUID rguid, LPCDIEFFECT lpeff,
+ LPDIRECTINPUTEFFECT *ppdef, LPUNKNOWN pUnkOuter)
{
- FIXME("(this=%p,%s,%p,%p,%p): stub!\n",
- iface, debugstr_guid(rguid), lpeff, ppdef, pUnkOuter);
+ FIXME("(this=%p,%s,%p,%p,%p): stub!\n", iface, debugstr_guid(rguid), lpeff, ppdef, pUnkOuter);
return DI_OK;
}
+HRESULT WINAPI IDirectInputDevice2AImpl_CreateEffect(LPDIRECTINPUTDEVICE8A iface, REFGUID rguid, LPCDIEFFECT lpeff,
+ LPDIRECTINPUTEFFECT *ppdef, LPUNKNOWN pUnkOuter)
+{
+ IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface);
+ return IDirectInputDevice2WImpl_CreateEffect(IDirectInputDevice8W_from_impl(This), rguid, lpeff, ppdef, pUnkOuter);
+}
+
HRESULT WINAPI IDirectInputDevice2AImpl_EnumEffects(
LPDIRECTINPUTDEVICE8A iface,
LPDIENUMEFFECTSCALLBACKA lpCallback,
return DI_OK;
}
-HRESULT WINAPI IDirectInputDevice2AImpl_GetForceFeedbackState(
- LPDIRECTINPUTDEVICE8A iface,
- LPDWORD pdwOut)
+HRESULT WINAPI IDirectInputDevice2WImpl_GetForceFeedbackState(LPDIRECTINPUTDEVICE8W iface, LPDWORD pdwOut)
{
- FIXME("(this=%p,%p): stub!\n",
- iface, pdwOut);
+ FIXME("(this=%p,%p): stub!\n", iface, pdwOut);
return DI_OK;
}
-HRESULT WINAPI IDirectInputDevice2AImpl_SendForceFeedbackCommand(
- LPDIRECTINPUTDEVICE8A iface,
- DWORD dwFlags)
+HRESULT WINAPI IDirectInputDevice2AImpl_GetForceFeedbackState(LPDIRECTINPUTDEVICE8A iface, LPDWORD pdwOut)
+{
+ IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface);
+ return IDirectInputDevice2WImpl_GetForceFeedbackState(IDirectInputDevice8W_from_impl(This), pdwOut);
+}
+
+HRESULT WINAPI IDirectInputDevice2WImpl_SendForceFeedbackCommand(LPDIRECTINPUTDEVICE8W iface, DWORD dwFlags)
{
TRACE("(%p) 0x%08x:\n", iface, dwFlags);
return DI_NOEFFECT;
}
-HRESULT WINAPI IDirectInputDevice2AImpl_EnumCreatedEffectObjects(
- LPDIRECTINPUTDEVICE8A iface,
- LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback,
- LPVOID lpvRef,
- DWORD dwFlags)
+HRESULT WINAPI IDirectInputDevice2AImpl_SendForceFeedbackCommand(LPDIRECTINPUTDEVICE8A iface, DWORD dwFlags)
{
- FIXME("(this=%p,%p,%p,0x%08x): stub!\n",
- iface, lpCallback, lpvRef, dwFlags);
+ IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface);
+ return IDirectInputDevice2WImpl_SendForceFeedbackCommand(IDirectInputDevice8W_from_impl(This), dwFlags);
+}
+
+HRESULT WINAPI IDirectInputDevice2WImpl_EnumCreatedEffectObjects(LPDIRECTINPUTDEVICE8W iface,
+ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback, LPVOID lpvRef, DWORD dwFlags)
+{
+ FIXME("(this=%p,%p,%p,0x%08x): stub!\n", iface, lpCallback, lpvRef, dwFlags);
return DI_OK;
}
-HRESULT WINAPI IDirectInputDevice2AImpl_Escape(
- LPDIRECTINPUTDEVICE8A iface,
- LPDIEFFESCAPE lpDIEEsc)
+HRESULT WINAPI IDirectInputDevice2AImpl_EnumCreatedEffectObjects(LPDIRECTINPUTDEVICE8A iface,
+ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback, LPVOID lpvRef, DWORD dwFlags)
{
- FIXME("(this=%p,%p): stub!\n",
- iface, lpDIEEsc);
+ IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface);
+ return IDirectInputDevice2WImpl_EnumCreatedEffectObjects(IDirectInputDevice8W_from_impl(This), lpCallback, lpvRef, dwFlags);
+}
+
+HRESULT WINAPI IDirectInputDevice2WImpl_Escape(LPDIRECTINPUTDEVICE8W iface, LPDIEFFESCAPE lpDIEEsc)
+{
+ FIXME("(this=%p,%p): stub!\n", iface, lpDIEEsc);
return DI_OK;
}
-HRESULT WINAPI IDirectInputDevice2AImpl_Poll(
- LPDIRECTINPUTDEVICE8A iface)
+HRESULT WINAPI IDirectInputDevice2AImpl_Escape(LPDIRECTINPUTDEVICE8A iface, LPDIEFFESCAPE lpDIEEsc)
{
- IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
+ IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface);
+ return IDirectInputDevice2WImpl_Escape(IDirectInputDevice8W_from_impl(This), lpDIEEsc);
+}
+
+HRESULT WINAPI IDirectInputDevice2WImpl_Poll(LPDIRECTINPUTDEVICE8W iface)
+{
+ IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8W(iface);
if (!This->acquired) return DIERR_NOTACQUIRED;
/* Because wine devices do not need to be polled, just return DI_NOEFFECT */
return DI_NOEFFECT;
}
-HRESULT WINAPI IDirectInputDevice2AImpl_SendDeviceData(
- LPDIRECTINPUTDEVICE8A iface,
- DWORD cbObjectData,
- LPCDIDEVICEOBJECTDATA rgdod,
- LPDWORD pdwInOut,
- DWORD dwFlags)
+HRESULT WINAPI IDirectInputDevice2AImpl_Poll(LPDIRECTINPUTDEVICE8A iface)
{
- FIXME("(this=%p,0x%08x,%p,%p,0x%08x): stub!\n",
- iface, cbObjectData, rgdod, pdwInOut, dwFlags);
-
+ IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface);
+ return IDirectInputDevice2WImpl_Poll(IDirectInputDevice8W_from_impl(This));
+}
+
+HRESULT WINAPI IDirectInputDevice2WImpl_SendDeviceData(LPDIRECTINPUTDEVICE8W iface, DWORD cbObjectData,
+ LPCDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut,
+ DWORD dwFlags)
+{
+ FIXME("(this=%p,0x%08x,%p,%p,0x%08x): stub!\n", iface, cbObjectData, rgdod, pdwInOut, dwFlags);
+
return DI_OK;
}
+HRESULT WINAPI IDirectInputDevice2AImpl_SendDeviceData(LPDIRECTINPUTDEVICE8A iface, DWORD cbObjectData,
+ LPCDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut,
+ DWORD dwFlags)
+{
+ IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface);
+ return IDirectInputDevice2WImpl_SendDeviceData(IDirectInputDevice8W_from_impl(This), cbObjectData, rgdod,
+ pdwInOut, dwFlags);
+}
+
HRESULT WINAPI IDirectInputDevice7AImpl_EnumEffectsInFile(LPDIRECTINPUTDEVICE8A iface,
LPCSTR lpszFileName,
LPDIENUMEFFECTSINFILECALLBACK pec,
return DI_OK;
}
-HRESULT WINAPI IDirectInputDevice8AImpl_BuildActionMap(LPDIRECTINPUTDEVICE8A iface,
- LPDIACTIONFORMATA lpdiaf,
- LPCSTR lpszUserName,
- DWORD dwFlags)
-{
- FIXME("(%p)->(%p,%s,%08x): stub !\n", iface, lpdiaf, lpszUserName, dwFlags);
-#define X(x) if (dwFlags & x) FIXME("\tdwFlags =|"#x"\n");
- X(DIDBAM_DEFAULT)
- X(DIDBAM_PRESERVE)
- X(DIDBAM_INITIALIZE)
- X(DIDBAM_HWDEFAULTS)
-#undef X
- _dump_diactionformatA(lpdiaf);
- return DI_OK;
-}
-
HRESULT WINAPI IDirectInputDevice8WImpl_BuildActionMap(LPDIRECTINPUTDEVICE8W iface,
LPDIACTIONFORMATW lpdiaf,
LPCWSTR lpszUserName,
DWORD dwFlags)
{
- FIXME("(%p)->(%p,%s,%08x): stub !\n", iface, lpdiaf, debugstr_w(lpszUserName), dwFlags);
+ FIXME("(%p)->(%p,%s,%08x): semi-stub !\n", iface, lpdiaf, debugstr_w(lpszUserName), dwFlags);
#define X(x) if (dwFlags & x) FIXME("\tdwFlags =|"#x"\n");
X(DIDBAM_DEFAULT)
X(DIDBAM_PRESERVE)
return DI_OK;
}
-HRESULT WINAPI IDirectInputDevice8AImpl_SetActionMap(LPDIRECTINPUTDEVICE8A iface,
- LPDIACTIONFORMATA lpdiaf,
- LPCSTR lpszUserName,
- DWORD dwFlags)
-{
- FIXME("(%p)->(%p,%s,%08x): stub !\n", iface, lpdiaf, lpszUserName, dwFlags);
-
- return DI_OK;
-}
-
HRESULT WINAPI IDirectInputDevice8WImpl_SetActionMap(LPDIRECTINPUTDEVICE8W iface,
- LPDIACTIONFORMATW lpdiaf,
- LPCWSTR lpszUserName,
- DWORD dwFlags)
+ LPDIACTIONFORMATW lpdiaf,
+ LPCWSTR lpszUserName,
+ DWORD dwFlags)
{
- FIXME("(%p)->(%p,%s,%08x): stub !\n", iface, lpdiaf, debugstr_w(lpszUserName), dwFlags);
-
+ FIXME("(%p)->(%p,%s,%08x): semi-stub !\n", iface, lpdiaf, debugstr_w(lpszUserName), dwFlags);
+
return DI_OK;
}
LPDIDATAFORMAT user_df; /* user defined data format */
} DataFormat;
+typedef struct
+{
+ unsigned int offset;
+ UINT_PTR uAppData;
+} ActionMap;
+
/* Device implementation */
-typedef struct IDirectInputDevice2AImpl IDirectInputDevice2AImpl;
-struct IDirectInputDevice2AImpl
+typedef struct IDirectInputDeviceImpl IDirectInputDeviceImpl;
+struct IDirectInputDeviceImpl
{
- const void *lpVtbl;
+ IDirectInputDevice8A IDirectInputDevice8A_iface;
+ IDirectInputDevice8W IDirectInputDevice8W_iface;
LONG ref;
GUID guid;
CRITICAL_SECTION crit;
BOOL overflow; /* return DI_BUFFEROVERFLOW in 'GetDeviceData' */
DataFormat data_format; /* user data format and wine to user format converter */
+
+ /* Action mapping */
+ int num_actions; /* number of actions mapped */
+ ActionMap *action_map; /* array of mappings */
};
-extern BOOL get_app_key(HKEY*, HKEY*);
-extern DWORD get_config_key(HKEY, HKEY, const char*, char*, DWORD);
+extern BOOL get_app_key(HKEY*, HKEY*) DECLSPEC_HIDDEN;
+extern DWORD get_config_key(HKEY, HKEY, const char*, char*, DWORD) DECLSPEC_HIDDEN;
/* Routines to do DataFormat / WineFormat conversions */
-extern void fill_DataFormat(void *out, DWORD size, const void *in, const DataFormat *df) ;
-extern void release_DataFormat(DataFormat *df) ;
-extern void queue_event(LPDIRECTINPUTDEVICE8A iface, int ofs, DWORD data, DWORD time, DWORD seq);
+extern void fill_DataFormat(void *out, DWORD size, const void *in, const DataFormat *df) DECLSPEC_HIDDEN;
+extern void release_DataFormat(DataFormat *df) DECLSPEC_HIDDEN;
+extern void queue_event(LPDIRECTINPUTDEVICE8A iface, int inst_id, DWORD data, DWORD time, DWORD seq) DECLSPEC_HIDDEN;
/* Helper functions to work with data format */
-extern int id_to_object(LPCDIDATAFORMAT df, int id);
-extern int id_to_offset(const DataFormat *df, int id);
-extern int find_property(const DataFormat *df, LPCDIPROPHEADER ph);
+extern int id_to_object(LPCDIDATAFORMAT df, int id) DECLSPEC_HIDDEN;
+extern int find_property(const DataFormat *df, LPCDIPROPHEADER ph) DECLSPEC_HIDDEN;
/* Common joystick stuff */
typedef struct
LONG lSaturation;
} ObjProps;
-extern DWORD joystick_map_pov(POINTL *p);
-extern LONG joystick_map_axis(ObjProps *props, int val);
+extern DWORD joystick_map_pov(const POINTL *p) DECLSPEC_HIDDEN;
+extern LONG joystick_map_axis(ObjProps *props, int val) DECLSPEC_HIDDEN;
typedef struct
{
LPDIRECTINPUTEFFECT ref;
} effect_list_item;
-extern const GUID DInput_Wine_Keyboard_GUID;
-extern const GUID DInput_Wine_Mouse_GUID;
+extern const GUID DInput_Wine_Keyboard_GUID DECLSPEC_HIDDEN;
+extern const GUID DInput_Wine_Mouse_GUID DECLSPEC_HIDDEN;
/* Various debug tools */
-extern void _dump_DIPROPHEADER(LPCDIPROPHEADER diph) ;
-extern void _dump_OBJECTINSTANCEA(const DIDEVICEOBJECTINSTANCEA *ddoi) ;
-extern void _dump_OBJECTINSTANCEW(const DIDEVICEOBJECTINSTANCEW *ddoi) ;
-extern void _dump_DIDATAFORMAT(const DIDATAFORMAT *df) ;
-extern const char *_dump_dinput_GUID(const GUID *guid) ;
+extern void _dump_DIPROPHEADER(LPCDIPROPHEADER diph) DECLSPEC_HIDDEN;
+extern void _dump_OBJECTINSTANCEA(const DIDEVICEOBJECTINSTANCEA *ddoi) DECLSPEC_HIDDEN;
+extern void _dump_OBJECTINSTANCEW(const DIDEVICEOBJECTINSTANCEW *ddoi) DECLSPEC_HIDDEN;
+extern void _dump_DIDATAFORMAT(const DIDATAFORMAT *df) DECLSPEC_HIDDEN;
+extern const char *_dump_dinput_GUID(const GUID *guid) DECLSPEC_HIDDEN;
+
+extern LPDIOBJECTDATAFORMAT dataformat_to_odf_by_type(LPCDIDATAFORMAT df, int n, DWORD type) DECLSPEC_HIDDEN;
+
+extern HRESULT _build_action_map(LPDIRECTINPUTDEVICE8W iface, LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, DWORD dwFlags, DWORD devMask, LPCDIDATAFORMAT df) DECLSPEC_HIDDEN;
+extern HRESULT _set_action_map(LPDIRECTINPUTDEVICE8W iface, LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, DWORD dwFlags, LPCDIDATAFORMAT df) DECLSPEC_HIDDEN;
/* And the stubs */
-extern HRESULT WINAPI IDirectInputDevice2AImpl_Acquire(LPDIRECTINPUTDEVICE8A iface);
-extern HRESULT WINAPI IDirectInputDevice2AImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface);
-extern HRESULT WINAPI IDirectInputDevice2AImpl_SetDataFormat(
- LPDIRECTINPUTDEVICE8A iface,LPCDIDATAFORMAT df ) ;
-extern HRESULT WINAPI IDirectInputDevice2AImpl_SetCooperativeLevel(
- LPDIRECTINPUTDEVICE8A iface,HWND hwnd,DWORD dwflags ) ;
-extern HRESULT WINAPI IDirectInputDevice2AImpl_SetEventNotification(
- LPDIRECTINPUTDEVICE8A iface,HANDLE hnd ) ;
-extern ULONG WINAPI IDirectInputDevice2AImpl_Release(LPDIRECTINPUTDEVICE8A iface) ;
-extern HRESULT WINAPI IDirectInputDevice2AImpl_QueryInterface(LPDIRECTINPUTDEVICE8A iface,REFIID riid,LPVOID *ppobj);
-extern HRESULT WINAPI IDirectInputDevice2WImpl_QueryInterface(LPDIRECTINPUTDEVICE8W iface,REFIID riid,LPVOID *ppobj);
-extern ULONG WINAPI IDirectInputDevice2AImpl_AddRef(
- LPDIRECTINPUTDEVICE8A iface) ;
+extern HRESULT WINAPI IDirectInputDevice2AImpl_Acquire(LPDIRECTINPUTDEVICE8A iface) DECLSPEC_HIDDEN;
+extern HRESULT WINAPI IDirectInputDevice2WImpl_Acquire(LPDIRECTINPUTDEVICE8W iface) DECLSPEC_HIDDEN;
+extern HRESULT WINAPI IDirectInputDevice2AImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface) DECLSPEC_HIDDEN;
+extern HRESULT WINAPI IDirectInputDevice2WImpl_Unacquire(LPDIRECTINPUTDEVICE8W iface) DECLSPEC_HIDDEN;
+extern HRESULT WINAPI IDirectInputDevice2AImpl_SetDataFormat(LPDIRECTINPUTDEVICE8A iface, LPCDIDATAFORMAT df) DECLSPEC_HIDDEN;
+extern HRESULT WINAPI IDirectInputDevice2WImpl_SetDataFormat(LPDIRECTINPUTDEVICE8W iface, LPCDIDATAFORMAT df) DECLSPEC_HIDDEN;
+extern HRESULT WINAPI IDirectInputDevice2AImpl_SetCooperativeLevel(LPDIRECTINPUTDEVICE8A iface, HWND hwnd, DWORD dwflags) DECLSPEC_HIDDEN;
+extern HRESULT WINAPI IDirectInputDevice2WImpl_SetCooperativeLevel(LPDIRECTINPUTDEVICE8W iface, HWND hwnd, DWORD dwflags) DECLSPEC_HIDDEN;
+extern HRESULT WINAPI IDirectInputDevice2AImpl_SetEventNotification(LPDIRECTINPUTDEVICE8A iface, HANDLE hnd) DECLSPEC_HIDDEN;
+extern HRESULT WINAPI IDirectInputDevice2WImpl_SetEventNotification(LPDIRECTINPUTDEVICE8W iface, HANDLE hnd) DECLSPEC_HIDDEN;
+extern ULONG WINAPI IDirectInputDevice2AImpl_Release(LPDIRECTINPUTDEVICE8A iface) DECLSPEC_HIDDEN;
+extern ULONG WINAPI IDirectInputDevice2WImpl_Release(LPDIRECTINPUTDEVICE8W iface) DECLSPEC_HIDDEN;
+extern HRESULT WINAPI IDirectInputDevice2AImpl_QueryInterface(LPDIRECTINPUTDEVICE8A iface, REFIID riid, LPVOID *ppobj) DECLSPEC_HIDDEN;
+extern HRESULT WINAPI IDirectInputDevice2WImpl_QueryInterface(LPDIRECTINPUTDEVICE8W iface, REFIID riid, LPVOID *ppobj) DECLSPEC_HIDDEN;
+extern ULONG WINAPI IDirectInputDevice2AImpl_AddRef(LPDIRECTINPUTDEVICE8A iface) DECLSPEC_HIDDEN;
+extern ULONG WINAPI IDirectInputDevice2WImpl_AddRef(LPDIRECTINPUTDEVICE8W iface) DECLSPEC_HIDDEN;
extern HRESULT WINAPI IDirectInputDevice2AImpl_EnumObjects(
LPDIRECTINPUTDEVICE8A iface,
LPDIENUMDEVICEOBJECTSCALLBACKA lpCallback,
LPVOID lpvRef,
- DWORD dwFlags) ;
+ DWORD dwFlags) DECLSPEC_HIDDEN;
extern HRESULT WINAPI IDirectInputDevice2WImpl_EnumObjects(
LPDIRECTINPUTDEVICE8W iface,
LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback,
LPVOID lpvRef,
- DWORD dwFlags) ;
-extern HRESULT WINAPI IDirectInputDevice2AImpl_GetProperty(LPDIRECTINPUTDEVICE8A iface, REFGUID rguid, LPDIPROPHEADER pdiph);
-extern HRESULT WINAPI IDirectInputDevice2AImpl_SetProperty(LPDIRECTINPUTDEVICE8A iface, REFGUID rguid, LPCDIPROPHEADER pdiph);
+ DWORD dwFlags) DECLSPEC_HIDDEN;
+extern HRESULT WINAPI IDirectInputDevice2AImpl_GetProperty(LPDIRECTINPUTDEVICE8A iface, REFGUID rguid, LPDIPROPHEADER pdiph) DECLSPEC_HIDDEN;
+extern HRESULT WINAPI IDirectInputDevice2WImpl_GetProperty(LPDIRECTINPUTDEVICE8W iface, REFGUID rguid, LPDIPROPHEADER pdiph) DECLSPEC_HIDDEN;
+extern HRESULT WINAPI IDirectInputDevice2AImpl_SetProperty(LPDIRECTINPUTDEVICE8A iface, REFGUID rguid, LPCDIPROPHEADER pdiph) DECLSPEC_HIDDEN;
+extern HRESULT WINAPI IDirectInputDevice2WImpl_SetProperty(LPDIRECTINPUTDEVICE8W iface, REFGUID rguid, LPCDIPROPHEADER pdiph) DECLSPEC_HIDDEN;
extern HRESULT WINAPI IDirectInputDevice2AImpl_GetObjectInfo(
LPDIRECTINPUTDEVICE8A iface,
LPDIDEVICEOBJECTINSTANCEA pdidoi,
DWORD dwObj,
- DWORD dwHow) ;
+ DWORD dwHow) DECLSPEC_HIDDEN;
extern HRESULT WINAPI IDirectInputDevice2WImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface,
LPDIDEVICEOBJECTINSTANCEW pdidoi,
DWORD dwObj,
- DWORD dwHow);
-extern HRESULT WINAPI IDirectInputDevice2AImpl_GetDeviceData(LPDIRECTINPUTDEVICE8A iface,
- DWORD dodsize, LPDIDEVICEOBJECTDATA dod, LPDWORD entries, DWORD flags);
-extern HRESULT WINAPI IDirectInputDevice2AImpl_RunControlPanel(
- LPDIRECTINPUTDEVICE8A iface,
- HWND hwndOwner,
- DWORD dwFlags) ;
-extern HRESULT WINAPI IDirectInputDevice2AImpl_Initialize(
- LPDIRECTINPUTDEVICE8A iface,
- HINSTANCE hinst,
- DWORD dwVersion,
- REFGUID rguid) ;
-extern HRESULT WINAPI IDirectInputDevice2AImpl_CreateEffect(
- LPDIRECTINPUTDEVICE8A iface,
- REFGUID rguid,
- LPCDIEFFECT lpeff,
- LPDIRECTINPUTEFFECT *ppdef,
- LPUNKNOWN pUnkOuter) ;
+ DWORD dwHow) DECLSPEC_HIDDEN;
+extern HRESULT WINAPI IDirectInputDevice2AImpl_GetDeviceData(LPDIRECTINPUTDEVICE8A iface, DWORD dodsize, LPDIDEVICEOBJECTDATA dod,
+ LPDWORD entries, DWORD flags) DECLSPEC_HIDDEN;
+extern HRESULT WINAPI IDirectInputDevice2WImpl_GetDeviceData(LPDIRECTINPUTDEVICE8W iface, DWORD dodsize, LPDIDEVICEOBJECTDATA dod,
+ LPDWORD entries, DWORD flags) DECLSPEC_HIDDEN;
+extern HRESULT WINAPI IDirectInputDevice2AImpl_RunControlPanel(LPDIRECTINPUTDEVICE8A iface, HWND hwndOwner, DWORD dwFlags) DECLSPEC_HIDDEN;
+extern HRESULT WINAPI IDirectInputDevice2WImpl_RunControlPanel(LPDIRECTINPUTDEVICE8W iface, HWND hwndOwner, DWORD dwFlags) DECLSPEC_HIDDEN;
+extern HRESULT WINAPI IDirectInputDevice2AImpl_Initialize(LPDIRECTINPUTDEVICE8A iface, HINSTANCE hinst, DWORD dwVersion,
+ REFGUID rguid) DECLSPEC_HIDDEN;
+extern HRESULT WINAPI IDirectInputDevice2WImpl_Initialize(LPDIRECTINPUTDEVICE8W iface, HINSTANCE hinst, DWORD dwVersion,
+ REFGUID rguid) DECLSPEC_HIDDEN;
+extern HRESULT WINAPI IDirectInputDevice2AImpl_CreateEffect(LPDIRECTINPUTDEVICE8A iface, REFGUID rguid, LPCDIEFFECT lpeff,
+ LPDIRECTINPUTEFFECT *ppdef, LPUNKNOWN pUnkOuter) DECLSPEC_HIDDEN;
+extern HRESULT WINAPI IDirectInputDevice2WImpl_CreateEffect(LPDIRECTINPUTDEVICE8W iface, REFGUID rguid, LPCDIEFFECT lpeff,
+ LPDIRECTINPUTEFFECT *ppdef, LPUNKNOWN pUnkOuter) DECLSPEC_HIDDEN;
extern HRESULT WINAPI IDirectInputDevice2AImpl_EnumEffects(
LPDIRECTINPUTDEVICE8A iface,
LPDIENUMEFFECTSCALLBACKA lpCallback,
LPVOID lpvRef,
- DWORD dwFlags) ;
+ DWORD dwFlags) DECLSPEC_HIDDEN;
extern HRESULT WINAPI IDirectInputDevice2WImpl_EnumEffects(
LPDIRECTINPUTDEVICE8W iface,
LPDIENUMEFFECTSCALLBACKW lpCallback,
LPVOID lpvRef,
- DWORD dwFlags) ;
+ DWORD dwFlags) DECLSPEC_HIDDEN;
extern HRESULT WINAPI IDirectInputDevice2AImpl_GetEffectInfo(
LPDIRECTINPUTDEVICE8A iface,
LPDIEFFECTINFOA lpdei,
- REFGUID rguid) ;
+ REFGUID rguid) DECLSPEC_HIDDEN;
extern HRESULT WINAPI IDirectInputDevice2WImpl_GetEffectInfo(
LPDIRECTINPUTDEVICE8W iface,
LPDIEFFECTINFOW lpdei,
- REFGUID rguid) ;
-extern HRESULT WINAPI IDirectInputDevice2AImpl_GetForceFeedbackState(
- LPDIRECTINPUTDEVICE8A iface,
- LPDWORD pdwOut) ;
-extern HRESULT WINAPI IDirectInputDevice2AImpl_SendForceFeedbackCommand(
- LPDIRECTINPUTDEVICE8A iface,
- DWORD dwFlags) ;
-extern HRESULT WINAPI IDirectInputDevice2AImpl_EnumCreatedEffectObjects(
- LPDIRECTINPUTDEVICE8A iface,
- LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback,
- LPVOID lpvRef,
- DWORD dwFlags) ;
-extern HRESULT WINAPI IDirectInputDevice2AImpl_Escape(
- LPDIRECTINPUTDEVICE8A iface,
- LPDIEFFESCAPE lpDIEEsc) ;
-extern HRESULT WINAPI IDirectInputDevice2AImpl_Poll(
- LPDIRECTINPUTDEVICE8A iface) ;
-extern HRESULT WINAPI IDirectInputDevice2AImpl_SendDeviceData(
- LPDIRECTINPUTDEVICE8A iface,
- DWORD cbObjectData,
- LPCDIDEVICEOBJECTDATA rgdod,
- LPDWORD pdwInOut,
- DWORD dwFlags) ;
+ REFGUID rguid) DECLSPEC_HIDDEN;
+extern HRESULT WINAPI IDirectInputDevice2AImpl_GetForceFeedbackState(LPDIRECTINPUTDEVICE8A iface, LPDWORD pdwOut) DECLSPEC_HIDDEN;
+extern HRESULT WINAPI IDirectInputDevice2WImpl_GetForceFeedbackState(LPDIRECTINPUTDEVICE8W iface, LPDWORD pdwOut) DECLSPEC_HIDDEN;
+extern HRESULT WINAPI IDirectInputDevice2AImpl_SendForceFeedbackCommand(LPDIRECTINPUTDEVICE8A iface, DWORD dwFlags) DECLSPEC_HIDDEN;
+extern HRESULT WINAPI IDirectInputDevice2WImpl_SendForceFeedbackCommand(LPDIRECTINPUTDEVICE8W iface, DWORD dwFlags) DECLSPEC_HIDDEN;
+extern HRESULT WINAPI IDirectInputDevice2AImpl_EnumCreatedEffectObjects(LPDIRECTINPUTDEVICE8A iface,
+ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback,
+ LPVOID lpvRef, DWORD dwFlags) DECLSPEC_HIDDEN;
+extern HRESULT WINAPI IDirectInputDevice2WImpl_EnumCreatedEffectObjects(LPDIRECTINPUTDEVICE8W iface,
+ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback,
+ LPVOID lpvRef, DWORD dwFlags) DECLSPEC_HIDDEN;
+extern HRESULT WINAPI IDirectInputDevice2AImpl_Escape(LPDIRECTINPUTDEVICE8A iface, LPDIEFFESCAPE lpDIEEsc) DECLSPEC_HIDDEN;
+extern HRESULT WINAPI IDirectInputDevice2WImpl_Escape(LPDIRECTINPUTDEVICE8W iface, LPDIEFFESCAPE lpDIEEsc) DECLSPEC_HIDDEN;
+extern HRESULT WINAPI IDirectInputDevice2AImpl_Poll(LPDIRECTINPUTDEVICE8A iface) DECLSPEC_HIDDEN;
+extern HRESULT WINAPI IDirectInputDevice2WImpl_Poll(LPDIRECTINPUTDEVICE8W iface) DECLSPEC_HIDDEN;
+extern HRESULT WINAPI IDirectInputDevice2AImpl_SendDeviceData(LPDIRECTINPUTDEVICE8A iface, DWORD cbObjectData,
+ LPCDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD dwFlags) DECLSPEC_HIDDEN;
+extern HRESULT WINAPI IDirectInputDevice2WImpl_SendDeviceData(LPDIRECTINPUTDEVICE8W iface, DWORD cbObjectData,
+ LPCDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD dwFlags) DECLSPEC_HIDDEN;
extern HRESULT WINAPI IDirectInputDevice7AImpl_EnumEffectsInFile(LPDIRECTINPUTDEVICE8A iface,
LPCSTR lpszFileName,
LPDIENUMEFFECTSINFILECALLBACK pec,
LPVOID pvRef,
- DWORD dwFlags) ;
+ DWORD dwFlags) DECLSPEC_HIDDEN;
extern HRESULT WINAPI IDirectInputDevice7WImpl_EnumEffectsInFile(LPDIRECTINPUTDEVICE8W iface,
LPCWSTR lpszFileName,
LPDIENUMEFFECTSINFILECALLBACK pec,
LPVOID pvRef,
- DWORD dwFlags) ;
+ DWORD dwFlags) DECLSPEC_HIDDEN;
extern HRESULT WINAPI IDirectInputDevice7AImpl_WriteEffectToFile(LPDIRECTINPUTDEVICE8A iface,
LPCSTR lpszFileName,
DWORD dwEntries,
LPDIFILEEFFECT rgDiFileEft,
- DWORD dwFlags) ;
+ DWORD dwFlags) DECLSPEC_HIDDEN;
extern HRESULT WINAPI IDirectInputDevice7WImpl_WriteEffectToFile(LPDIRECTINPUTDEVICE8W iface,
LPCWSTR lpszFileName,
DWORD dwEntries,
LPDIFILEEFFECT rgDiFileEft,
- DWORD dwFlags) ;
-extern HRESULT WINAPI IDirectInputDevice8AImpl_BuildActionMap(LPDIRECTINPUTDEVICE8A iface,
- LPDIACTIONFORMATA lpdiaf,
- LPCSTR lpszUserName,
- DWORD dwFlags);
+ DWORD dwFlags) DECLSPEC_HIDDEN;
extern HRESULT WINAPI IDirectInputDevice8WImpl_BuildActionMap(LPDIRECTINPUTDEVICE8W iface,
LPDIACTIONFORMATW lpdiaf,
LPCWSTR lpszUserName,
- DWORD dwFlags);
-extern HRESULT WINAPI IDirectInputDevice8AImpl_SetActionMap(LPDIRECTINPUTDEVICE8A iface,
- LPDIACTIONFORMATA lpdiaf,
- LPCSTR lpszUserName,
- DWORD dwFlags);
+ DWORD dwFlags) DECLSPEC_HIDDEN;
extern HRESULT WINAPI IDirectInputDevice8WImpl_SetActionMap(LPDIRECTINPUTDEVICE8W iface,
LPDIACTIONFORMATW lpdiaf,
LPCWSTR lpszUserName,
- DWORD dwFlags);
+ DWORD dwFlags) DECLSPEC_HIDDEN;
extern HRESULT WINAPI IDirectInputDevice8AImpl_GetImageInfo(LPDIRECTINPUTDEVICE8A iface,
- LPDIDEVICEIMAGEINFOHEADERA lpdiDevImageInfoHeader);
+ LPDIDEVICEIMAGEINFOHEADERA lpdiDevImageInfoHeader) DECLSPEC_HIDDEN;
extern HRESULT WINAPI IDirectInputDevice8WImpl_GetImageInfo(LPDIRECTINPUTDEVICE8W iface,
- LPDIDEVICEIMAGEINFOHEADERW lpdiDevImageInfoHeader);
+ LPDIDEVICEIMAGEINFOHEADERW lpdiDevImageInfoHeader) DECLSPEC_HIDDEN;
#endif /* __WINE_DLLS_DINPUT_DINPUTDEVICE_PRIVATE_H */
--- /dev/null
+/*
+ * Copyright 2001 Ove Kaaven
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include "resource.h"
+
+1 WINE_REGISTRY dinput_classes.rgs
+
+#define WINE_FILEDESCRIPTION_STR "Wine DirectInput"
+#define WINE_FILENAME_STR "dinput.dll"
+#define WINE_FILEVERSION 5,1,2600,881
+#define WINE_FILEVERSION_STR "5.1.2600.881"
+#define WINE_PRODUCTVERSION 5,1,2600,881
+#define WINE_PRODUCTVERSION_STR "5.1"
+
+#include <wine/wine_common_ver.rc>
+
+LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT
+
+STRINGTABLE
+BEGIN
+ IDS_ACTIONCOLUMN "Action"
+ IDS_OBJECTCOLUMN "Object"
+END
+
+IDD_CONFIGUREDEVICES DIALOG 0, 0, 270, 260
+STYLE DS_CENTER | DS_MODALFRAME | DS_SHELLFONT | WS_CAPTION | WS_VISIBLE
+CAPTION "Configure Devices"
+FONT 8, "MS Shell Dlg"
+{
+ DEFPUSHBUTTON "OK", IDOK, 10, 236, 50, 14
+ PUSHBUTTON "Cancel", IDCANCEL, 65, 236, 50, 14
+ PUSHBUTTON "Reset", IDC_RESET, 210, 236, 50, 14
+ COMBOBOX IDC_PLAYERCOMBO, 10, 50, 90, 30, CBS_DROPDOWNLIST | CBS_HASSTRINGS
+ COMBOBOX IDC_CONTROLLERCOMBO, 10, 20, 90, 30, CBS_DROPDOWNLIST | CBS_HASSTRINGS
+ LTEXT "Player", IDC_PLAYERTEXT, 10, 40, 90, 8, SS_LEFT
+ LTEXT "Device", IDC_DEVICETEXT, 10, 10, 90, 8, SS_LEFT
+ LTEXT "Actions", IDC_ACTIONTEXT, 10, 70, 90, 8, SS_LEFT
+ LTEXT "Mapping", IDC_MAPPINGTEXT, 120, 8, 90, 8, SS_LEFT
+ LISTBOX IDC_ACTIONLIST, 10, 80, 90, 130, WS_TABSTOP | WS_VSCROLL | LBS_NOINTEGRALHEIGHT | LBS_NOTIFY
+ AUTOCHECKBOX "Show Assigned First", IDC_CHECKBOXSORT, 120, 215, 90, 8
+ CONTROL "", IDC_DEVICEOBJECTSLIST, "SysListView32", LVS_REPORT | LVS_AUTOARRANGE | LVS_ALIGNLEFT | LVS_SHOWSELALWAYS | LVS_SINGLESEL | WS_BORDER | WS_TABSTOP, 120, 20, 140, 190
+}
/*
- * Copyright 2001 Ove Kaaven
+ * COM Classes for dinput
+ *
+ * Copyright 2010 Alexandre Julliard
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
-#define WINE_FILEDESCRIPTION_STR "Wine DirectInput"
-#define WINE_FILENAME_STR "dinput.dll"
-#define WINE_FILEVERSION 5,1,2600,881
-#define WINE_FILEVERSION_STR "5.1.2600.881"
-#define WINE_PRODUCTVERSION 5,1,2600,881
-#define WINE_PRODUCTVERSION_STR "5.1"
+[
+ helpstring("DirectInput Object"),
+ threading(both),
+ uuid(25e609e0-b259-11cf-bfc7-444553540000)
+]
+coclass DirectInput { interface IDirectInput; }
-#include "wine/wine_common_ver.rc"
+[
+ helpstring("DirectInputDevice Object"),
+ threading(both),
+ uuid(25e609e1-b259-11cf-bfc7-444553540000)
+]
+coclass DirectInputDevice { interface IDirectInputDevice; }
--- /dev/null
+HKCR
+{
+ NoRemove Interface
+ {
+ }
+ NoRemove CLSID
+ {
+ '{25E609E0-B259-11CF-BFC7-444553540000}' = s 'DirectInput Object'
+ {
+ InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Both' }
+ }
+ '{25E609E1-B259-11CF-BFC7-444553540000}' = s 'DirectInputDevice Object'
+ {
+ InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Both' }
+ }
+ }
+}
//#include <stdarg.h>
//#include <string.h>
+#define WIN32_NO_STATUS
+#define _INC_WINDOWS
+#define COM_NO_WINDOWS_H
+
#define COBJMACROS
#define NONAMELESSUNION
#include <wine/debug.h>
//#include "wine/unicode.h"
//#include "windef.h"
-//#include "winbase.h"
-//#include "winuser.h"
+#include <winbase.h>
+#include <winuser.h>
+#include <winnls.h>
//#include "winerror.h"
+#include <objbase.h>
+#include <rpcproxy.h>
+//#include "initguid.h"
//#include "dinput_private.h"
#include "device_private.h"
+//#include "dinputd.h"
WINE_DEFAULT_DEBUG_CHANNEL(dinput);
static const IDirectInput7WVtbl ddi7wvt;
static const IDirectInput8AVtbl ddi8avt;
static const IDirectInput8WVtbl ddi8wvt;
+static const IDirectInputJoyConfig8Vtbl JoyConfig8vt;
+
+static inline IDirectInputImpl *impl_from_IDirectInput7A( IDirectInput7A *iface )
+{
+ return CONTAINING_RECORD( iface, IDirectInputImpl, IDirectInput7A_iface );
+}
static inline IDirectInputImpl *impl_from_IDirectInput7W( IDirectInput7W *iface )
{
- return CONTAINING_RECORD( iface, IDirectInputImpl, lpVtbl7w );
+ return CONTAINING_RECORD( iface, IDirectInputImpl, IDirectInput7W_iface );
}
static inline IDirectInputImpl *impl_from_IDirectInput8A( IDirectInput8A *iface )
{
- return CONTAINING_RECORD( iface, IDirectInputImpl, lpVtbl8a );
+ return CONTAINING_RECORD( iface, IDirectInputImpl, IDirectInput8A_iface );
}
static inline IDirectInputImpl *impl_from_IDirectInput8W( IDirectInput8W *iface )
{
- return CONTAINING_RECORD( iface, IDirectInputImpl, lpVtbl8w );
+ return CONTAINING_RECORD( iface, IDirectInputImpl, IDirectInput8W_iface );
}
-static inline IDirectInput7W *IDirectInput7W_from_impl( IDirectInputImpl *iface )
+static inline IDirectInputDeviceImpl *impl_from_IDirectInputDevice8A(IDirectInputDevice8A *iface)
+{
+ return CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8A_iface);
+}
+static inline IDirectInputDeviceImpl *impl_from_IDirectInputDevice8W(IDirectInputDevice8W *iface)
{
- return (IDirectInput7W *)(&iface->lpVtbl7w);
+ return CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8W_iface);
}
static const struct dinput_device *dinput_devices[] =
&mouse_device,
&keyboard_device,
&joystick_linuxinput_device,
- &joystick_linux_device
+ &joystick_linux_device,
+ &joystick_osx_device
};
#define NB_DINPUT_DEVICES (sizeof(dinput_devices)/sizeof(dinput_devices[0]))
static HINSTANCE DINPUT_instance = NULL;
-BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserv)
+static BOOL check_hook_thread(void);
+static CRITICAL_SECTION dinput_hook_crit;
+static struct list direct_input_list = LIST_INIT( direct_input_list );
+
+static HRESULT initialize_directinput_instance(IDirectInputImpl *This, DWORD dwVersion);
+static void uninitialize_directinput_instance(IDirectInputImpl *This);
+
+static HRESULT create_directinput_instance(REFIID riid, LPVOID *ppDI, IDirectInputImpl **out)
{
- switch(reason)
+ IDirectInputImpl *This = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectInputImpl) );
+ HRESULT hr;
+
+ if (!This)
+ return E_OUTOFMEMORY;
+
+ This->IDirectInput7A_iface.lpVtbl = &ddi7avt;
+ This->IDirectInput7W_iface.lpVtbl = &ddi7wvt;
+ This->IDirectInput8A_iface.lpVtbl = &ddi8avt;
+ This->IDirectInput8W_iface.lpVtbl = &ddi8wvt;
+ This->IDirectInputJoyConfig8_iface.lpVtbl = &JoyConfig8vt;
+
+ hr = IDirectInput_QueryInterface( &This->IDirectInput7A_iface, riid, ppDI );
+ if (FAILED(hr))
{
- case DLL_PROCESS_ATTACH:
- DisableThreadLibraryCalls(inst);
- DINPUT_instance = inst;
- break;
- case DLL_PROCESS_DETACH:
- break;
+ HeapFree( GetProcessHeap(), 0, This );
+ return hr;
}
- return TRUE;
-}
-static BOOL check_hook_thread(void);
-static CRITICAL_SECTION dinput_hook_crit;
-static struct list direct_input_list = LIST_INIT( direct_input_list );
+ if (out) *out = This;
+ return DI_OK;
+}
/******************************************************************************
* DirectInputCreateEx (DINPUT.@)
*/
HRESULT WINAPI DirectInputCreateEx(
HINSTANCE hinst, DWORD dwVersion, REFIID riid, LPVOID *ppDI,
- LPUNKNOWN punkOuter)
+ LPUNKNOWN punkOuter)
{
- IDirectInputImpl* This;
+ IDirectInputImpl *This;
+ HRESULT hr;
TRACE("(%p,%04x,%s,%p,%p)\n", hinst, dwVersion, debugstr_guid(riid), ppDI, punkOuter);
- if (IsEqualGUID( &IID_IUnknown, riid ) ||
- IsEqualGUID( &IID_IDirectInputA, riid ) ||
+ if (IsEqualGUID( &IID_IDirectInputA, riid ) ||
IsEqualGUID( &IID_IDirectInput2A, riid ) ||
IsEqualGUID( &IID_IDirectInput7A, riid ) ||
IsEqualGUID( &IID_IDirectInputW, riid ) ||
IsEqualGUID( &IID_IDirectInput2W, riid ) ||
- IsEqualGUID( &IID_IDirectInput7W, riid ) ||
- IsEqualGUID( &IID_IDirectInput8A, riid ) ||
- IsEqualGUID( &IID_IDirectInput8W, riid ))
+ IsEqualGUID( &IID_IDirectInput7W, riid ))
{
- if (!(This = HeapAlloc( GetProcessHeap(), 0, sizeof(IDirectInputImpl) )))
- return DIERR_OUTOFMEMORY;
+ hr = create_directinput_instance(riid, ppDI, &This);
+ if (FAILED(hr))
+ return hr;
}
else
- return DIERR_OLDDIRECTINPUTVERSION;
-
- This->lpVtbl = &ddi7avt;
- This->lpVtbl7w = &ddi7wvt;
- This->lpVtbl8a = &ddi8avt;
- This->lpVtbl8w = &ddi8wvt;
- This->ref = 0;
- This->dwVersion = dwVersion;
- This->evsequence = 1;
-
- InitializeCriticalSection(&This->crit);
- This->crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": IDirectInputImpl*->crit");
-
- list_init( &This->devices_list );
-
- /* Add self to the list of the IDirectInputs */
- EnterCriticalSection( &dinput_hook_crit );
- list_add_head( &direct_input_list, &This->entry );
- LeaveCriticalSection( &dinput_hook_crit );
+ return DIERR_NOINTERFACE;
- if (!check_hook_thread())
+ hr = IDirectInput_Initialize( &This->IDirectInput7A_iface, hinst, dwVersion );
+ if (FAILED(hr))
{
- IUnknown_Release( (LPDIRECTINPUT7A)This );
- return DIERR_GENERIC;
+ IDirectInput_Release( &This->IDirectInput7A_iface );
+ *ppDI = NULL;
+ return hr;
}
- IDirectInput_QueryInterface( (IDirectInput7A *)This, riid, ppDI );
return DI_OK;
}
/******************************************************************************
* DirectInputCreateA (DINPUT.@)
*/
-HRESULT WINAPI DirectInputCreateA(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUTA *ppDI, LPUNKNOWN punkOuter)
+HRESULT WINAPI DECLSPEC_HOTPATCH DirectInputCreateA(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUTA *ppDI, LPUNKNOWN punkOuter)
{
return DirectInputCreateEx(hinst, dwVersion, &IID_IDirectInput7A, (LPVOID *)ppDI, punkOuter);
}
/******************************************************************************
* DirectInputCreateW (DINPUT.@)
*/
-HRESULT WINAPI DirectInputCreateW(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUTW *ppDI, LPUNKNOWN punkOuter)
+HRESULT WINAPI DECLSPEC_HOTPATCH DirectInputCreateW(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUTW *ppDI, LPUNKNOWN punkOuter)
{
return DirectInputCreateEx(hinst, dwVersion, &IID_IDirectInput7W, (LPVOID *)ppDI, punkOuter);
}
-static const char *_dump_DIDEVTYPE_value(DWORD dwDevType) {
+static const char *_dump_DIDEVTYPE_value(DWORD dwDevType)
+{
switch (dwDevType) {
case 0: return "All devices";
case DIDEVTYPE_MOUSE: return "DIDEVTYPE_MOUSE";
}
}
-static void _dump_EnumDevices_dwFlags(DWORD dwFlags) {
+static void _dump_EnumDevices_dwFlags(DWORD dwFlags)
+{
if (TRACE_ON(dinput)) {
unsigned int i;
static const struct {
FE(DIEDFL_ATTACHEDONLY),
FE(DIEDFL_FORCEFEEDBACK),
FE(DIEDFL_INCLUDEALIASES),
- FE(DIEDFL_INCLUDEPHANTOMS)
+ FE(DIEDFL_INCLUDEPHANTOMS),
+ FE(DIEDFL_INCLUDEHIDDEN)
#undef FE
};
TRACE(" flags: ");
if (dwFlags == 0) {
- TRACE("DIEDFL_ALLDEVICES");
+ TRACE("DIEDFL_ALLDEVICES\n");
return;
}
for (i = 0; i < (sizeof(flags) / sizeof(flags[0])); i++)
TRACE("\n");
}
-void _dump_diactionformatA(LPDIACTIONFORMATA lpdiActionFormat) {
+static void _dump_diactionformatA(LPDIACTIONFORMATA lpdiActionFormat)
+{
unsigned int i;
- FIXME("diaf.dwSize = %d\n", lpdiActionFormat->dwSize);
- FIXME("diaf.dwActionSize = %d\n", lpdiActionFormat->dwActionSize);
- FIXME("diaf.dwDataSize = %d\n", lpdiActionFormat->dwDataSize);
- FIXME("diaf.dwNumActions = %d\n", lpdiActionFormat->dwNumActions);
- FIXME("diaf.rgoAction = %p\n", lpdiActionFormat->rgoAction);
- for (i=0;i<lpdiActionFormat->dwNumActions;i++) {
- FIXME("diaf.rgoAction[%u]:\n", i);
- FIXME("\tuAppData=%lx\n", lpdiActionFormat->rgoAction[i].uAppData);
- FIXME("\tdwSemantics=%x\n", lpdiActionFormat->rgoAction[i].dwSemantics);
- FIXME("\tdwFlags=%x\n", lpdiActionFormat->rgoAction[i].dwFlags);
- FIXME("\tszActionName=%s\n", debugstr_a(lpdiActionFormat->rgoAction[i].u.lptszActionName));
- FIXME("\tguidInstance=%s\n", debugstr_guid(&lpdiActionFormat->rgoAction[i].guidInstance));
- FIXME("\tdwObjID=%x\n", lpdiActionFormat->rgoAction[i].dwObjID);
- FIXME("\tdwHow=%x\n", lpdiActionFormat->rgoAction[i].dwHow);
+ TRACE("diaf.dwSize = %d\n", lpdiActionFormat->dwSize);
+ TRACE("diaf.dwActionSize = %d\n", lpdiActionFormat->dwActionSize);
+ TRACE("diaf.dwDataSize = %d\n", lpdiActionFormat->dwDataSize);
+ TRACE("diaf.dwNumActions = %d\n", lpdiActionFormat->dwNumActions);
+ TRACE("diaf.rgoAction = %p\n", lpdiActionFormat->rgoAction);
+ TRACE("diaf.guidActionMap = %s\n", debugstr_guid(&lpdiActionFormat->guidActionMap));
+ TRACE("diaf.dwGenre = 0x%08x\n", lpdiActionFormat->dwGenre);
+ TRACE("diaf.dwBufferSize = %d\n", lpdiActionFormat->dwBufferSize);
+ TRACE("diaf.lAxisMin = %d\n", lpdiActionFormat->lAxisMin);
+ TRACE("diaf.lAxisMax = %d\n", lpdiActionFormat->lAxisMax);
+ TRACE("diaf.hInstString = %p\n", lpdiActionFormat->hInstString);
+ TRACE("diaf.ftTimeStamp ...\n");
+ TRACE("diaf.dwCRC = 0x%x\n", lpdiActionFormat->dwCRC);
+ TRACE("diaf.tszActionMap = %s\n", debugstr_a(lpdiActionFormat->tszActionMap));
+ for (i = 0; i < lpdiActionFormat->dwNumActions; i++)
+ {
+ TRACE("diaf.rgoAction[%u]:\n", i);
+ TRACE("\tuAppData=0x%lx\n", lpdiActionFormat->rgoAction[i].uAppData);
+ TRACE("\tdwSemantic=0x%08x\n", lpdiActionFormat->rgoAction[i].dwSemantic);
+ TRACE("\tdwFlags=0x%x\n", lpdiActionFormat->rgoAction[i].dwFlags);
+ TRACE("\tszActionName=%s\n", debugstr_a(lpdiActionFormat->rgoAction[i].u.lptszActionName));
+ TRACE("\tguidInstance=%s\n", debugstr_guid(&lpdiActionFormat->rgoAction[i].guidInstance));
+ TRACE("\tdwObjID=0x%x\n", lpdiActionFormat->rgoAction[i].dwObjID);
+ TRACE("\tdwHow=0x%x\n", lpdiActionFormat->rgoAction[i].dwHow);
+ }
+}
+
+void _copy_diactionformatAtoW(LPDIACTIONFORMATW to, LPDIACTIONFORMATA from)
+{
+ int i;
+
+ to->dwSize = sizeof(DIACTIONFORMATW);
+ to->dwActionSize = sizeof(DIACTIONW);
+ to->dwDataSize = from->dwDataSize;
+ to->dwNumActions = from->dwNumActions;
+ to->guidActionMap = from->guidActionMap;
+ to->dwGenre = from->dwGenre;
+ to->dwBufferSize = from->dwBufferSize;
+ to->lAxisMin = from->lAxisMin;
+ to->lAxisMax = from->lAxisMax;
+ to->dwCRC = from->dwCRC;
+ to->ftTimeStamp = from->ftTimeStamp;
+
+ for (i=0; i < to->dwNumActions; i++)
+ {
+ to->rgoAction[i].uAppData = from->rgoAction[i].uAppData;
+ to->rgoAction[i].dwSemantic = from->rgoAction[i].dwSemantic;
+ to->rgoAction[i].dwFlags = from->rgoAction[i].dwFlags;
+ to->rgoAction[i].guidInstance = from->rgoAction[i].guidInstance;
+ to->rgoAction[i].dwObjID = from->rgoAction[i].dwObjID;
+ to->rgoAction[i].dwHow = from->rgoAction[i].dwHow;
+ }
+}
+
+void _copy_diactionformatWtoA(LPDIACTIONFORMATA to, LPDIACTIONFORMATW from)
+{
+ int i;
+
+ to->dwSize = sizeof(DIACTIONFORMATA);
+ to->dwActionSize = sizeof(DIACTIONA);
+ to->dwDataSize = from->dwDataSize;
+ to->dwNumActions = from->dwNumActions;
+ to->guidActionMap = from->guidActionMap;
+ to->dwGenre = from->dwGenre;
+ to->dwBufferSize = from->dwBufferSize;
+ to->lAxisMin = from->lAxisMin;
+ to->lAxisMax = from->lAxisMax;
+ to->dwCRC = from->dwCRC;
+ to->ftTimeStamp = from->ftTimeStamp;
+
+ for (i=0; i < to->dwNumActions; i++)
+ {
+ to->rgoAction[i].uAppData = from->rgoAction[i].uAppData;
+ to->rgoAction[i].dwSemantic = from->rgoAction[i].dwSemantic;
+ to->rgoAction[i].dwFlags = from->rgoAction[i].dwFlags;
+ to->rgoAction[i].guidInstance = from->rgoAction[i].guidInstance;
+ to->rgoAction[i].dwObjID = from->rgoAction[i].dwObjID;
+ to->rgoAction[i].dwHow = from->rgoAction[i].dwHow;
}
- FIXME("diaf.guidActionMap = %s\n", debugstr_guid(&lpdiActionFormat->guidActionMap));
- FIXME("diaf.dwGenre = %d\n", lpdiActionFormat->dwGenre);
- FIXME("diaf.dwBufferSize = %d\n", lpdiActionFormat->dwBufferSize);
- FIXME("diaf.lAxisMin = %d\n", lpdiActionFormat->lAxisMin);
- FIXME("diaf.lAxisMax = %d\n", lpdiActionFormat->lAxisMax);
- FIXME("diaf.hInstString = %p\n", lpdiActionFormat->hInstString);
- FIXME("diaf.ftTimeStamp ...\n");
- FIXME("diaf.dwCRC = %x\n", lpdiActionFormat->dwCRC);
- FIXME("diaf.tszActionMap = %s\n", debugstr_a(lpdiActionFormat->tszActionMap));
+}
+
+/* diactionformat_priority
+ *
+ * Given a DIACTIONFORMAT structure and a DI genre, returns the enumeration
+ * priority. Joysticks should pass the game genre, and mouse or keyboard their
+ * respective DI*_MASK
+ */
+static DWORD diactionformat_priorityA(LPDIACTIONFORMATA lpdiaf, DWORD genre)
+{
+ int i;
+ DWORD priorityFlags = 0;
+
+ /* If there's at least one action for the device it's priority 1 */
+ for(i=0; i < lpdiaf->dwNumActions; i++)
+ if ((lpdiaf->rgoAction[i].dwSemantic & genre) == genre)
+ priorityFlags |= DIEDBS_MAPPEDPRI1;
+
+ return priorityFlags;
+}
+
+static DWORD diactionformat_priorityW(LPDIACTIONFORMATW lpdiaf, DWORD genre)
+{
+ int i;
+ DWORD priorityFlags = 0;
+
+ /* If there's at least one action for the device it's priority 1 */
+ for(i=0; i < lpdiaf->dwNumActions; i++)
+ if ((lpdiaf->rgoAction[i].dwSemantic & genre) == genre)
+ priorityFlags |= DIEDBS_MAPPEDPRI1;
+
+ return priorityFlags;
}
/******************************************************************************
LPDIRECTINPUT7A iface, DWORD dwDevType, LPDIENUMDEVICESCALLBACKA lpCallback,
LPVOID pvRef, DWORD dwFlags)
{
- IDirectInputImpl *This = (IDirectInputImpl *)iface;
+ IDirectInputImpl *This = impl_from_IDirectInput7A(iface);
DIDEVICEINSTANCEA devInstance;
unsigned int i;
int j, r;
lpCallback, pvRef, dwFlags);
_dump_EnumDevices_dwFlags(dwFlags);
+ if (!lpCallback ||
+ dwFlags & ~(DIEDFL_ATTACHEDONLY | DIEDFL_FORCEFEEDBACK | DIEDFL_INCLUDEALIASES | DIEDFL_INCLUDEPHANTOMS | DIEDFL_INCLUDEHIDDEN) ||
+ (dwDevType > DI8DEVCLASS_GAMECTRL && dwDevType < DI8DEVTYPE_DEVICE) || dwDevType > DI8DEVTYPE_SUPPLEMENTAL)
+ return DIERR_INVALIDPARAM;
+
+ if (!This->initialized)
+ return DIERR_NOTINITIALIZED;
+
for (i = 0; i < NB_DINPUT_DEVICES; i++) {
if (!dinput_devices[i]->enum_deviceA) continue;
for (j = 0, r = -1; r != 0; j++) {
lpCallback, pvRef, dwFlags);
_dump_EnumDevices_dwFlags(dwFlags);
+ if (!lpCallback ||
+ dwFlags & ~(DIEDFL_ATTACHEDONLY | DIEDFL_FORCEFEEDBACK | DIEDFL_INCLUDEALIASES | DIEDFL_INCLUDEPHANTOMS | DIEDFL_INCLUDEHIDDEN) ||
+ (dwDevType > DI8DEVCLASS_GAMECTRL && dwDevType < DI8DEVTYPE_DEVICE) || dwDevType > DI8DEVTYPE_SUPPLEMENTAL)
+ return DIERR_INVALIDPARAM;
+
+ if (!This->initialized)
+ return DIERR_NOTINITIALIZED;
+
for (i = 0; i < NB_DINPUT_DEVICES; i++) {
if (!dinput_devices[i]->enum_deviceW) continue;
for (j = 0, r = -1; r != 0; j++) {
static ULONG WINAPI IDirectInputAImpl_AddRef(LPDIRECTINPUT7A iface)
{
- IDirectInputImpl *This = (IDirectInputImpl *)iface;
+ IDirectInputImpl *This = impl_from_IDirectInput7A( iface );
ULONG ref = InterlockedIncrement(&This->ref);
TRACE( "(%p) incrementing from %d\n", This, ref - 1);
static ULONG WINAPI IDirectInputWImpl_AddRef(LPDIRECTINPUT7W iface)
{
IDirectInputImpl *This = impl_from_IDirectInput7W( iface );
- return IDirectInputAImpl_AddRef( (IDirectInput7A *)This );
+ return IDirectInputAImpl_AddRef( &This->IDirectInput7A_iface );
}
static ULONG WINAPI IDirectInputAImpl_Release(LPDIRECTINPUT7A iface)
{
- IDirectInputImpl *This = (IDirectInputImpl *)iface;
+ IDirectInputImpl *This = impl_from_IDirectInput7A( iface );
ULONG ref = InterlockedDecrement( &This->ref );
TRACE( "(%p) releasing from %d\n", This, ref + 1 );
- if (ref) return ref;
-
- /* Remove self from the list of the IDirectInputs */
- EnterCriticalSection( &dinput_hook_crit );
- list_remove( &This->entry );
- LeaveCriticalSection( &dinput_hook_crit );
-
- check_hook_thread();
-
- This->crit.DebugInfo->Spare[0] = 0;
- DeleteCriticalSection( &This->crit );
- HeapFree( GetProcessHeap(), 0, This );
+ if (ref == 0)
+ {
+ uninitialize_directinput_instance( This );
+ HeapFree( GetProcessHeap(), 0, This );
+ }
- return 0;
+ return ref;
}
static ULONG WINAPI IDirectInputWImpl_Release(LPDIRECTINPUT7W iface)
{
IDirectInputImpl *This = impl_from_IDirectInput7W( iface );
- return IDirectInputAImpl_Release( (IDirectInput7A *)This );
+ return IDirectInputAImpl_Release( &This->IDirectInput7A_iface );
}
static HRESULT WINAPI IDirectInputAImpl_QueryInterface(LPDIRECTINPUT7A iface, REFIID riid, LPVOID *ppobj)
{
- IDirectInputImpl *This = (IDirectInputImpl *)iface;
+ IDirectInputImpl *This = impl_from_IDirectInput7A( iface );
TRACE( "(%p)->(%s,%p)\n", This, debugstr_guid(riid), ppobj );
+ if (!riid || !ppobj)
+ return E_POINTER;
+
if (IsEqualGUID( &IID_IUnknown, riid ) ||
IsEqualGUID( &IID_IDirectInputA, riid ) ||
IsEqualGUID( &IID_IDirectInput2A, riid ) ||
IsEqualGUID( &IID_IDirectInput7A, riid ))
{
- *ppobj = &This->lpVtbl;
+ *ppobj = &This->IDirectInput7A_iface;
IUnknown_AddRef( (IUnknown*)*ppobj );
return DI_OK;
IsEqualGUID( &IID_IDirectInput2W, riid ) ||
IsEqualGUID( &IID_IDirectInput7W, riid ))
{
- *ppobj = &This->lpVtbl7w;
+ *ppobj = &This->IDirectInput7W_iface;
IUnknown_AddRef( (IUnknown*)*ppobj );
return DI_OK;
if (IsEqualGUID( &IID_IDirectInput8A, riid ))
{
- *ppobj = &This->lpVtbl8a;
+ *ppobj = &This->IDirectInput8A_iface;
IUnknown_AddRef( (IUnknown*)*ppobj );
return DI_OK;
if (IsEqualGUID( &IID_IDirectInput8W, riid ))
{
- *ppobj = &This->lpVtbl8w;
+ *ppobj = &This->IDirectInput8W_iface;
+ IUnknown_AddRef( (IUnknown*)*ppobj );
+
+ return DI_OK;
+ }
+
+ if (IsEqualGUID( &IID_IDirectInputJoyConfig8, riid ))
+ {
+ *ppobj = &This->IDirectInputJoyConfig8_iface;
IUnknown_AddRef( (IUnknown*)*ppobj );
return DI_OK;
}
- FIXME( "Unsupported interface !\n" );
- return E_FAIL;
+ FIXME( "Unsupported interface: %s\n", debugstr_guid(riid));
+ *ppobj = NULL;
+ return E_NOINTERFACE;
}
static HRESULT WINAPI IDirectInputWImpl_QueryInterface(LPDIRECTINPUT7W iface, REFIID riid, LPVOID *ppobj)
{
IDirectInputImpl *This = impl_from_IDirectInput7W( iface );
- return IDirectInputAImpl_QueryInterface( (IDirectInput7A *)This, riid, ppobj );
+ return IDirectInputAImpl_QueryInterface( &This->IDirectInput7A_iface, riid, ppobj );
}
-static HRESULT WINAPI IDirectInputAImpl_Initialize(LPDIRECTINPUT7A iface, HINSTANCE hinst, DWORD x) {
- TRACE("(this=%p,%p,%x)\n",iface, hinst, x);
-
- /* Initialize can return: DIERR_BETADIRECTINPUTVERSION, DIERR_OLDDIRECTINPUTVERSION and DI_OK.
- * Since we already initialized the device, return DI_OK. In the past we returned DIERR_ALREADYINITIALIZED
- * which broke applications like Tomb Raider Legend because it isn't a legal return value.
- */
- return DI_OK;
+static HRESULT initialize_directinput_instance(IDirectInputImpl *This, DWORD dwVersion)
+{
+ if (!This->initialized)
+ {
+ This->dwVersion = dwVersion;
+ This->evsequence = 1;
+
+ InitializeCriticalSection( &This->crit );
+ This->crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": IDirectInputImpl*->crit");
+
+ list_init( &This->devices_list );
+
+ /* Add self to the list of the IDirectInputs */
+ EnterCriticalSection( &dinput_hook_crit );
+ list_add_head( &direct_input_list, &This->entry );
+ LeaveCriticalSection( &dinput_hook_crit );
+
+ This->initialized = TRUE;
+
+ if (!check_hook_thread())
+ {
+ uninitialize_directinput_instance( This );
+ return DIERR_GENERIC;
+ }
+ }
+
+ return DI_OK;
+}
+
+static void uninitialize_directinput_instance(IDirectInputImpl *This)
+{
+ if (This->initialized)
+ {
+ /* Remove self from the list of the IDirectInputs */
+ EnterCriticalSection( &dinput_hook_crit );
+ list_remove( &This->entry );
+ LeaveCriticalSection( &dinput_hook_crit );
+
+ check_hook_thread();
+
+ This->crit.DebugInfo->Spare[0] = 0;
+ DeleteCriticalSection( &This->crit );
+
+ This->initialized = FALSE;
+ }
+}
+
+enum directinput_versions
+{
+ DIRECTINPUT_VERSION_300 = 0x0300,
+ DIRECTINPUT_VERSION_500 = 0x0500,
+ DIRECTINPUT_VERSION_50A = 0x050A,
+ DIRECTINPUT_VERSION_5B2 = 0x05B2,
+ DIRECTINPUT_VERSION_602 = 0x0602,
+ DIRECTINPUT_VERSION_61A = 0x061A,
+ DIRECTINPUT_VERSION_700 = 0x0700,
+};
+
+static HRESULT WINAPI IDirectInputAImpl_Initialize(LPDIRECTINPUT7A iface, HINSTANCE hinst, DWORD version)
+{
+ IDirectInputImpl *This = impl_from_IDirectInput7A( iface );
+
+ TRACE("(%p)->(%p, 0x%04x)\n", iface, hinst, version);
+
+ if (!hinst)
+ return DIERR_INVALIDPARAM;
+ else if (version == 0)
+ return DIERR_NOTINITIALIZED;
+ else if (version > DIRECTINPUT_VERSION_700)
+ return DIERR_OLDDIRECTINPUTVERSION;
+ else if (version != DIRECTINPUT_VERSION_300 && version != DIRECTINPUT_VERSION_500 &&
+ version != DIRECTINPUT_VERSION_50A && version != DIRECTINPUT_VERSION_5B2 &&
+ version != DIRECTINPUT_VERSION_602 && version != DIRECTINPUT_VERSION_61A &&
+ version != DIRECTINPUT_VERSION_700 && version != DIRECTINPUT_VERSION)
+ return DIERR_BETADIRECTINPUTVERSION;
+
+ return initialize_directinput_instance(This, version);
}
static HRESULT WINAPI IDirectInputWImpl_Initialize(LPDIRECTINPUT7W iface, HINSTANCE hinst, DWORD x)
{
IDirectInputImpl *This = impl_from_IDirectInput7W( iface );
- return IDirectInputAImpl_Initialize( (IDirectInput7A *)This, hinst, x );
+ return IDirectInputAImpl_Initialize( &This->IDirectInput7A_iface, hinst, x );
}
static HRESULT WINAPI IDirectInputAImpl_GetDeviceStatus(LPDIRECTINPUT7A iface, REFGUID rguid)
{
- IDirectInputImpl *This = (IDirectInputImpl *)iface;
+ IDirectInputImpl *This = impl_from_IDirectInput7A( iface );
HRESULT hr;
LPDIRECTINPUTDEVICEA device;
TRACE( "(%p)->(%s)\n", This, debugstr_guid(rguid) );
+ if (!rguid) return E_POINTER;
+ if (!This->initialized)
+ return DIERR_NOTINITIALIZED;
+
hr = IDirectInput_CreateDevice( iface, rguid, &device, NULL );
if (hr != DI_OK) return DI_NOTATTACHED;
static HRESULT WINAPI IDirectInputWImpl_GetDeviceStatus(LPDIRECTINPUT7W iface, REFGUID rguid)
{
IDirectInputImpl *This = impl_from_IDirectInput7W( iface );
- return IDirectInputAImpl_GetDeviceStatus( (IDirectInput7A *)This, rguid );
+ return IDirectInputAImpl_GetDeviceStatus( &This->IDirectInput7A_iface, rguid );
}
static HRESULT WINAPI IDirectInputAImpl_RunControlPanel(LPDIRECTINPUT7A iface,
HWND hwndOwner,
DWORD dwFlags)
{
- IDirectInputImpl *This = (IDirectInputImpl *)iface;
+ WCHAR control_exeW[] = {'c','o','n','t','r','o','l','.','e','x','e',0};
+ STARTUPINFOW si = {0};
+ PROCESS_INFORMATION pi;
- FIXME( "(%p)->(%p,%08x): stub\n", This, hwndOwner, dwFlags );
+ IDirectInputImpl *This = impl_from_IDirectInput7A( iface );
+
+ TRACE( "(%p)->(%p, %08x)\n", This, hwndOwner, dwFlags );
+
+ if (hwndOwner && !IsWindow(hwndOwner))
+ return E_HANDLE;
+
+ if (dwFlags)
+ return DIERR_INVALIDPARAM;
+
+ if (!This->initialized)
+ return DIERR_NOTINITIALIZED;
+
+ if (!CreateProcessW(NULL, control_exeW, NULL, NULL, FALSE, DETACHED_PROCESS, NULL, NULL, &si, &pi))
+ return HRESULT_FROM_WIN32(GetLastError());
return DI_OK;
}
static HRESULT WINAPI IDirectInputWImpl_RunControlPanel(LPDIRECTINPUT7W iface, HWND hwndOwner, DWORD dwFlags)
{
IDirectInputImpl *This = impl_from_IDirectInput7W( iface );
- return IDirectInputAImpl_RunControlPanel( (IDirectInput7A *)This, hwndOwner, dwFlags );
+ return IDirectInputAImpl_RunControlPanel( &This->IDirectInput7A_iface, hwndOwner, dwFlags );
}
static HRESULT WINAPI IDirectInput2AImpl_FindDevice(LPDIRECTINPUT7A iface, REFGUID rguid,
LPCSTR pszName, LPGUID pguidInstance)
{
- IDirectInputImpl *This = (IDirectInputImpl *)iface;
+ IDirectInputImpl *This = impl_from_IDirectInput7A( iface );
FIXME( "(%p)->(%s, %s, %p): stub\n", This, debugstr_guid(rguid), pszName, pguidInstance );
return DI_OK;
}
-static HRESULT WINAPI IDirectInput7AImpl_CreateDeviceEx(LPDIRECTINPUT7A iface, REFGUID rguid,
- REFIID riid, LPVOID* pvOut, LPUNKNOWN lpUnknownOuter)
+static HRESULT create_device(IDirectInputImpl *This, REFGUID rguid, REFIID riid, LPVOID *pvOut, BOOL unicode)
{
- IDirectInputImpl *This = (IDirectInputImpl *)iface;
- HRESULT ret_value = DIERR_DEVICENOTREG;
- unsigned int i;
+ unsigned int i;
- TRACE("(%p)->(%s, %s, %p, %p)\n", This, debugstr_guid(rguid), debugstr_guid(riid), pvOut, lpUnknownOuter);
+ if (pvOut)
+ *pvOut = NULL;
- if (!rguid || !pvOut) return E_POINTER;
+ if (!rguid || !pvOut)
+ return E_POINTER;
- /* Loop on all the devices to see if anyone matches the given GUID */
- for (i = 0; i < NB_DINPUT_DEVICES; i++) {
- HRESULT ret;
+ if (!This->initialized)
+ return DIERR_NOTINITIALIZED;
- if (!dinput_devices[i]->create_deviceA) continue;
- if ((ret = dinput_devices[i]->create_deviceA(This, rguid, riid, (LPDIRECTINPUTDEVICEA*) pvOut)) == DI_OK)
+ /* Loop on all the devices to see if anyone matches the given GUID */
+ for (i = 0; i < NB_DINPUT_DEVICES; i++)
{
- EnterCriticalSection( &This->crit );
- list_add_tail( &This->devices_list, &(*(IDirectInputDevice2AImpl**)pvOut)->entry );
- LeaveCriticalSection( &This->crit );
- return DI_OK;
- }
+ HRESULT ret;
- if (ret == DIERR_NOINTERFACE)
- ret_value = DIERR_NOINTERFACE;
- }
+ if (!dinput_devices[i]->create_device) continue;
+ if ((ret = dinput_devices[i]->create_device(This, rguid, riid, pvOut, unicode)) == DI_OK)
+ return DI_OK;
+ }
- if (ret_value == DIERR_NOINTERFACE)
- {
WARN("invalid device GUID %s\n", debugstr_guid(rguid));
- }
-
- return ret_value;
+ return DIERR_DEVICENOTREG;
}
-static HRESULT WINAPI IDirectInput7WImpl_CreateDeviceEx(LPDIRECTINPUT7W iface, REFGUID rguid,
- REFIID riid, LPVOID* pvOut, LPUNKNOWN lpUnknownOuter)
+static HRESULT WINAPI IDirectInput7AImpl_CreateDeviceEx(LPDIRECTINPUT7A iface, REFGUID rguid,
+ REFIID riid, LPVOID* pvOut, LPUNKNOWN lpUnknownOuter)
{
- IDirectInputImpl *This = impl_from_IDirectInput7W( iface );
- HRESULT ret_value = DIERR_DEVICENOTREG;
- unsigned int i;
-
- TRACE("(%p)->(%s, %s, %p, %p)\n", This, debugstr_guid(rguid), debugstr_guid(riid), pvOut, lpUnknownOuter);
+ IDirectInputImpl *This = impl_from_IDirectInput7A( iface );
- if (!rguid || !pvOut) return E_POINTER;
+ 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;
+ return create_device(This, rguid, riid, pvOut, FALSE);
+}
- if (!dinput_devices[i]->create_deviceW) continue;
- if ((ret = dinput_devices[i]->create_deviceW(This, rguid, riid, (LPDIRECTINPUTDEVICEW*) pvOut)) == DI_OK)
- {
- EnterCriticalSection( &This->crit );
- list_add_tail( &This->devices_list, &(*(IDirectInputDevice2AImpl**)pvOut)->entry );
- LeaveCriticalSection( &This->crit );
- return DI_OK;
- }
+static HRESULT WINAPI IDirectInput7WImpl_CreateDeviceEx(LPDIRECTINPUT7W iface, REFGUID rguid,
+ REFIID riid, LPVOID* pvOut, LPUNKNOWN lpUnknownOuter)
+{
+ IDirectInputImpl *This = impl_from_IDirectInput7W( iface );
- if (ret == DIERR_NOINTERFACE)
- ret_value = DIERR_NOINTERFACE;
- }
+ TRACE("(%p)->(%s, %s, %p, %p)\n", This, debugstr_guid(rguid), debugstr_guid(riid), pvOut, lpUnknownOuter);
- return ret_value;
+ return create_device(This, rguid, riid, pvOut, TRUE);
}
static HRESULT WINAPI IDirectInputAImpl_CreateDevice(LPDIRECTINPUT7A iface, REFGUID rguid,
static ULONG WINAPI IDirectInput8AImpl_AddRef(LPDIRECTINPUT8A iface)
{
IDirectInputImpl *This = impl_from_IDirectInput8A( iface );
- return IDirectInputAImpl_AddRef( (IDirectInput7A *)This );
+ return IDirectInputAImpl_AddRef( &This->IDirectInput7A_iface );
}
static ULONG WINAPI IDirectInput8WImpl_AddRef(LPDIRECTINPUT8W iface)
{
IDirectInputImpl *This = impl_from_IDirectInput8W( iface );
- return IDirectInputAImpl_AddRef( (IDirectInput7A *)This );
+ return IDirectInputAImpl_AddRef( &This->IDirectInput7A_iface );
}
static HRESULT WINAPI IDirectInput8AImpl_QueryInterface(LPDIRECTINPUT8A iface, REFIID riid, LPVOID *ppobj)
{
IDirectInputImpl *This = impl_from_IDirectInput8A( iface );
- return IDirectInputAImpl_QueryInterface( (IDirectInput7A *)This, riid, ppobj );
+ return IDirectInputAImpl_QueryInterface( &This->IDirectInput7A_iface, riid, ppobj );
}
static HRESULT WINAPI IDirectInput8WImpl_QueryInterface(LPDIRECTINPUT8W iface, REFIID riid, LPVOID *ppobj)
{
IDirectInputImpl *This = impl_from_IDirectInput8W( iface );
- return IDirectInputAImpl_QueryInterface( (IDirectInput7A *)This, riid, ppobj );
+ return IDirectInputAImpl_QueryInterface( &This->IDirectInput7A_iface, riid, ppobj );
}
static ULONG WINAPI IDirectInput8AImpl_Release(LPDIRECTINPUT8A iface)
{
IDirectInputImpl *This = impl_from_IDirectInput8A( iface );
- return IDirectInputAImpl_Release( (IDirectInput7A *)This );
+ return IDirectInputAImpl_Release( &This->IDirectInput7A_iface );
}
static ULONG WINAPI IDirectInput8WImpl_Release(LPDIRECTINPUT8W iface)
{
IDirectInputImpl *This = impl_from_IDirectInput8W( iface );
- return IDirectInputAImpl_Release( (IDirectInput7A *)This );
+ return IDirectInputAImpl_Release( &This->IDirectInput7A_iface );
}
static HRESULT WINAPI IDirectInput8AImpl_CreateDevice(LPDIRECTINPUT8A iface, REFGUID rguid,
LPDIRECTINPUTDEVICE8A* pdev, LPUNKNOWN punk)
{
IDirectInputImpl *This = impl_from_IDirectInput8A( iface );
- return IDirectInput7AImpl_CreateDeviceEx( (IDirectInput7A *)This, rguid, NULL, (LPVOID*)pdev, punk );
+ return IDirectInput7AImpl_CreateDeviceEx( &This->IDirectInput7A_iface, rguid, NULL, (LPVOID*)pdev, punk );
}
static HRESULT WINAPI IDirectInput8WImpl_CreateDevice(LPDIRECTINPUT8W iface, REFGUID rguid,
LPDIRECTINPUTDEVICE8W* pdev, LPUNKNOWN punk)
{
IDirectInputImpl *This = impl_from_IDirectInput8W( iface );
- return IDirectInput7WImpl_CreateDeviceEx( IDirectInput7W_from_impl( This ), rguid, NULL, (LPVOID*)pdev, punk );
+ return IDirectInput7WImpl_CreateDeviceEx( &This->IDirectInput7W_iface, rguid, NULL, (LPVOID*)pdev, punk );
}
static HRESULT WINAPI IDirectInput8AImpl_EnumDevices(LPDIRECTINPUT8A iface, DWORD dwDevType, LPDIENUMDEVICESCALLBACKA lpCallback,
LPVOID pvRef, DWORD dwFlags)
{
IDirectInputImpl *This = impl_from_IDirectInput8A( iface );
- return IDirectInputAImpl_EnumDevices( (IDirectInput7A *)This, dwDevType, lpCallback, pvRef, dwFlags );
+ return IDirectInputAImpl_EnumDevices( &This->IDirectInput7A_iface, dwDevType, lpCallback, pvRef, dwFlags );
}
static HRESULT WINAPI IDirectInput8WImpl_EnumDevices(LPDIRECTINPUT8W iface, DWORD dwDevType, LPDIENUMDEVICESCALLBACKW lpCallback,
LPVOID pvRef, DWORD dwFlags)
{
IDirectInputImpl *This = impl_from_IDirectInput8W( iface );
- return IDirectInputWImpl_EnumDevices( IDirectInput7W_from_impl( This ), dwDevType, lpCallback, pvRef, dwFlags );
+ return IDirectInputWImpl_EnumDevices( &This->IDirectInput7W_iface, dwDevType, lpCallback, pvRef, dwFlags );
}
static HRESULT WINAPI IDirectInput8AImpl_GetDeviceStatus(LPDIRECTINPUT8A iface, REFGUID rguid)
{
IDirectInputImpl *This = impl_from_IDirectInput8A( iface );
- return IDirectInputAImpl_GetDeviceStatus( (IDirectInput7A *)This, rguid );
+ return IDirectInputAImpl_GetDeviceStatus( &This->IDirectInput7A_iface, rguid );
}
static HRESULT WINAPI IDirectInput8WImpl_GetDeviceStatus(LPDIRECTINPUT8W iface, REFGUID rguid)
{
IDirectInputImpl *This = impl_from_IDirectInput8W( iface );
- return IDirectInputAImpl_GetDeviceStatus( (IDirectInput7A *)This, rguid );
+ return IDirectInputAImpl_GetDeviceStatus( &This->IDirectInput7A_iface, rguid );
}
static HRESULT WINAPI IDirectInput8AImpl_RunControlPanel(LPDIRECTINPUT8A iface, HWND hwndOwner, DWORD dwFlags)
{
IDirectInputImpl *This = impl_from_IDirectInput8A( iface );
- return IDirectInputAImpl_RunControlPanel( (IDirectInput7A *)This, hwndOwner, dwFlags );
+ return IDirectInputAImpl_RunControlPanel( &This->IDirectInput7A_iface, hwndOwner, dwFlags );
}
static HRESULT WINAPI IDirectInput8WImpl_RunControlPanel(LPDIRECTINPUT8W iface, HWND hwndOwner, DWORD dwFlags)
{
IDirectInputImpl *This = impl_from_IDirectInput8W( iface );
- return IDirectInputAImpl_RunControlPanel( (IDirectInput7A *)This, hwndOwner, dwFlags );
+ return IDirectInputAImpl_RunControlPanel( &This->IDirectInput7A_iface, hwndOwner, dwFlags );
}
-static HRESULT WINAPI IDirectInput8AImpl_Initialize(LPDIRECTINPUT8A iface, HINSTANCE hinst, DWORD x)
+static HRESULT WINAPI IDirectInput8AImpl_Initialize(LPDIRECTINPUT8A iface, HINSTANCE hinst, DWORD version)
{
IDirectInputImpl *This = impl_from_IDirectInput8A( iface );
- return IDirectInputAImpl_Initialize( (IDirectInput7A *)This, hinst, x );
+
+ TRACE("(%p)->(%p, 0x%04x)\n", iface, hinst, version);
+
+ if (!hinst)
+ return DIERR_INVALIDPARAM;
+ else if (version == 0)
+ return DIERR_NOTINITIALIZED;
+ else if (version < DIRECTINPUT_VERSION)
+ return DIERR_BETADIRECTINPUTVERSION;
+ else if (version > DIRECTINPUT_VERSION)
+ return DIERR_OLDDIRECTINPUTVERSION;
+
+ return initialize_directinput_instance(This, version);
}
-static HRESULT WINAPI IDirectInput8WImpl_Initialize(LPDIRECTINPUT8W iface, HINSTANCE hinst, DWORD x)
+static HRESULT WINAPI IDirectInput8WImpl_Initialize(LPDIRECTINPUT8W iface, HINSTANCE hinst, DWORD version)
{
IDirectInputImpl *This = impl_from_IDirectInput8W( iface );
- return IDirectInputAImpl_Initialize( (IDirectInput7A *)This, hinst, x );
+ return IDirectInput8AImpl_Initialize( &This->IDirectInput8A_iface, hinst, version );
}
static HRESULT WINAPI IDirectInput8AImpl_FindDevice(LPDIRECTINPUT8A iface, REFGUID rguid, LPCSTR pszName, LPGUID pguidInstance)
{
IDirectInputImpl *This = impl_from_IDirectInput8A( iface );
- return IDirectInput2AImpl_FindDevice( (IDirectInput7A *)This, rguid, pszName, pguidInstance );
+ return IDirectInput2AImpl_FindDevice( &This->IDirectInput7A_iface, rguid, pszName, pguidInstance );
}
static HRESULT WINAPI IDirectInput8WImpl_FindDevice(LPDIRECTINPUT8W iface, REFGUID rguid, LPCWSTR pszName, LPGUID pguidInstance)
{
- IDirectInput7W *This = IDirectInput7W_from_impl( impl_from_IDirectInput8W( iface ) );
- return IDirectInput2WImpl_FindDevice( This, rguid, pszName, pguidInstance );
+ IDirectInputImpl *This = impl_from_IDirectInput8W( iface );
+ return IDirectInput2WImpl_FindDevice( &This->IDirectInput7W_iface, rguid, pszName, pguidInstance );
}
static HRESULT WINAPI IDirectInput8AImpl_EnumDevicesBySemantics(
LPVOID pvRef, DWORD dwFlags
)
{
+ static REFGUID guids[2] = { &GUID_SysKeyboard, &GUID_SysMouse };
+ static const DWORD actionMasks[] = { DIKEYBOARD_MASK, DIMOUSE_MASK };
IDirectInputImpl *This = impl_from_IDirectInput8A( iface );
+ DIDEVICEINSTANCEA didevi;
+ LPDIRECTINPUTDEVICE8A lpdid;
+ DWORD callbackFlags;
+ int i, j;
+
- FIXME("(this=%p,%s,%p,%p,%p,%04x): stub\n", This, ptszUserName, lpdiActionFormat,
+ FIXME("(this=%p,%s,%p,%p,%p,%04x): semi-stub\n", This, debugstr_a(ptszUserName), lpdiActionFormat,
lpCallback, pvRef, dwFlags);
#define X(x) if (dwFlags & x) FIXME("\tdwFlags |= "#x"\n");
X(DIEDBSFL_ATTACHEDONLY)
_dump_diactionformatA(lpdiActionFormat);
+ didevi.dwSize = sizeof(didevi);
+
+ /* Enumerate all the joysticks */
+ for (i = 0; i < NB_DINPUT_DEVICES; i++)
+ {
+ BOOL enumSuccess;
+
+ if (!dinput_devices[i]->enum_deviceA) continue;
+
+ for (j = 0, enumSuccess = -1; enumSuccess != 0; j++)
+ {
+ TRACE(" - checking device %u ('%s')\n", i, dinput_devices[i]->name);
+
+ callbackFlags = diactionformat_priorityA(lpdiActionFormat, lpdiActionFormat->dwGenre);
+ /* Default behavior is to enumerate attached game controllers */
+ enumSuccess = dinput_devices[i]->enum_deviceA(DI8DEVCLASS_GAMECTRL, DIEDFL_ATTACHEDONLY | dwFlags, &didevi, This->dwVersion, j);
+ if (enumSuccess)
+ {
+ IDirectInput_CreateDevice(iface, &didevi.guidInstance, &lpdid, NULL);
+
+ if (lpCallback(&didevi, lpdid, callbackFlags, 0, pvRef) == DIENUM_STOP)
+ return DI_OK;
+ }
+ }
+ }
+
+ if (dwFlags & DIEDBSFL_FORCEFEEDBACK) return DI_OK;
+
+ /* Enumerate keyboard and mouse */
+ for(i=0; i < sizeof(guids)/sizeof(guids[0]); i++)
+ {
+ callbackFlags = diactionformat_priorityA(lpdiActionFormat, actionMasks[i]);
+
+ IDirectInput_CreateDevice(iface, guids[i], &lpdid, NULL);
+ IDirectInputDevice_GetDeviceInfo(lpdid, &didevi);
+
+ if (lpCallback(&didevi, lpdid, callbackFlags, sizeof(guids)/sizeof(guids[0]) - (i+1), pvRef) == DIENUM_STOP)
+ return DI_OK;
+ }
+
return DI_OK;
}
LPVOID pvRef, DWORD dwFlags
)
{
- IDirectInputImpl *This = impl_from_IDirectInput8W( iface );
+ static REFGUID guids[2] = { &GUID_SysKeyboard, &GUID_SysMouse };
+ static const DWORD actionMasks[] = { DIKEYBOARD_MASK, DIMOUSE_MASK };
+ IDirectInputImpl *This = impl_from_IDirectInput8W(iface);
+ DIDEVICEINSTANCEW didevi;
+ LPDIRECTINPUTDEVICE8W lpdid;
+ DWORD callbackFlags;
+ int i, j;
+
+ FIXME("(this=%p,%s,%p,%p,%p,%04x): semi-stub\n", This, debugstr_w(ptszUserName), lpdiActionFormat,
+ lpCallback, pvRef, dwFlags);
+
+ didevi.dwSize = sizeof(didevi);
+
+ /* Enumerate all the joysticks */
+ for (i = 0; i < NB_DINPUT_DEVICES; i++)
+ {
+ BOOL enumSuccess;
+
+ if (!dinput_devices[i]->enum_deviceW) continue;
+
+ for (j = 0, enumSuccess = -1; enumSuccess != 0; j++)
+ {
+ TRACE(" - checking device %u ('%s')\n", i, dinput_devices[i]->name);
+
+ callbackFlags = diactionformat_priorityW(lpdiActionFormat, lpdiActionFormat->dwGenre);
+ /* Default behavior is to enumerate attached game controllers */
+ enumSuccess = dinput_devices[i]->enum_deviceW(DI8DEVCLASS_GAMECTRL, DIEDFL_ATTACHEDONLY | dwFlags, &didevi, This->dwVersion, j);
+ if (enumSuccess)
+ {
+ IDirectInput_CreateDevice(iface, &didevi.guidInstance, &lpdid, NULL);
+
+ if (lpCallback(&didevi, lpdid, callbackFlags, 0, pvRef) == DIENUM_STOP)
+ return DI_OK;
+ }
+ }
+ }
+
+ if (dwFlags & DIEDBSFL_FORCEFEEDBACK) return DI_OK;
- FIXME("(this=%p,%s,%p,%p,%p,%04x): stub\n", This, debugstr_w(ptszUserName), lpdiActionFormat,
- lpCallback, pvRef, dwFlags);
- return 0;
+ /* Enumerate keyboard and mouse */
+ for(i=0; i < sizeof(guids)/sizeof(guids[0]); i++)
+ {
+ callbackFlags = diactionformat_priorityW(lpdiActionFormat, actionMasks[i]);
+
+ IDirectInput_CreateDevice(iface, guids[i], &lpdid, NULL);
+ IDirectInputDevice_GetDeviceInfo(lpdid, &didevi);
+
+ if (lpCallback(&didevi, lpdid, callbackFlags, sizeof(guids)/sizeof(guids[0]) - (i+1), pvRef) == DIENUM_STOP)
+ return DI_OK;
+ }
+
+ return DI_OK;
+}
+
+static HRESULT WINAPI IDirectInput8WImpl_ConfigureDevices(
+ LPDIRECTINPUT8W iface, LPDICONFIGUREDEVICESCALLBACK lpdiCallback,
+ LPDICONFIGUREDEVICESPARAMSW lpdiCDParams, DWORD dwFlags, LPVOID pvRefData
+)
+{
+ IDirectInputImpl *This = impl_from_IDirectInput8W(iface);
+
+ FIXME("(this=%p,%p,%p,%04x,%p): stub\n", This, lpdiCallback, lpdiCDParams, dwFlags, pvRefData);
+
+ /* Call helper function in config.c to do the real work */
+ return _configure_devices(iface, lpdiCallback, lpdiCDParams, dwFlags, pvRefData);
}
static HRESULT WINAPI IDirectInput8AImpl_ConfigureDevices(
LPDICONFIGUREDEVICESPARAMSA lpdiCDParams, DWORD dwFlags, LPVOID pvRefData
)
{
- IDirectInputImpl *This = impl_from_IDirectInput8A( iface );
+ IDirectInputImpl *This = impl_from_IDirectInput8A(iface);
+ DIACTIONFORMATW diafW;
+ DICONFIGUREDEVICESPARAMSW diCDParamsW;
+ HRESULT hr;
+ int i;
+
+ FIXME("(this=%p,%p,%p,%04x,%p): stub\n", This, lpdiCallback, lpdiCDParams, dwFlags, pvRefData);
+
+ /* Copy parameters */
+ diCDParamsW.dwSize = sizeof(DICONFIGUREDEVICESPARAMSW);
+ diCDParamsW.dwcFormats = lpdiCDParams->dwcFormats;
+ diCDParamsW.lprgFormats = &diafW;
+ diCDParamsW.hwnd = lpdiCDParams->hwnd;
+
+ diafW.rgoAction = HeapAlloc(GetProcessHeap(), 0, sizeof(DIACTIONW)*lpdiCDParams->lprgFormats->dwNumActions);
+ _copy_diactionformatAtoW(&diafW, lpdiCDParams->lprgFormats);
+
+ /* Copy action names */
+ for (i=0; i < diafW.dwNumActions; i++)
+ {
+ const char* from = lpdiCDParams->lprgFormats->rgoAction[i].u.lptszActionName;
+ int len = MultiByteToWideChar(CP_ACP, 0, from , -1, NULL , 0);
+ WCHAR *to = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*len);
+
+ MultiByteToWideChar(CP_ACP, 0, from , -1, to , len);
+ diafW.rgoAction[i].u.lptszActionName = to;
+ }
+
+ hr = IDirectInput8WImpl_ConfigureDevices(&This->IDirectInput8W_iface, lpdiCallback, &diCDParamsW, dwFlags, pvRefData);
+
+ /* Copy back configuration */
+ if (SUCCEEDED(hr))
+ _copy_diactionformatWtoA(lpdiCDParams->lprgFormats, &diafW);
+
+ /* Free memory */
+ for (i=0; i < diafW.dwNumActions; i++)
+ HeapFree(GetProcessHeap(), 0, (void*) diafW.rgoAction[i].u.lptszActionName);
+
+ HeapFree(GetProcessHeap(), 0, diafW.rgoAction);
+
+ return hr;
+}
+
+/*****************************************************************************
+ * IDirectInputJoyConfig8 interface
+ */
+
+static inline IDirectInputImpl *impl_from_IDirectInputJoyConfig8(IDirectInputJoyConfig8 *iface)
+{
+ return CONTAINING_RECORD( iface, IDirectInputImpl, IDirectInputJoyConfig8_iface );
+}
- FIXME("(this=%p,%p,%p,%04x,%p): stub\n", This, lpdiCallback, lpdiCDParams,
- dwFlags, pvRefData);
- return 0;
+static HRESULT WINAPI JoyConfig8Impl_QueryInterface(IDirectInputJoyConfig8 *iface, REFIID riid, void** ppobj)
+{
+ IDirectInputImpl *This = impl_from_IDirectInputJoyConfig8( iface );
+ return IDirectInputAImpl_QueryInterface( &This->IDirectInput7A_iface, riid, ppobj );
}
-static HRESULT WINAPI IDirectInput8WImpl_ConfigureDevices(
- LPDIRECTINPUT8W iface, LPDICONFIGUREDEVICESCALLBACK lpdiCallback,
- LPDICONFIGUREDEVICESPARAMSW lpdiCDParams, DWORD dwFlags, LPVOID pvRefData
-)
+static ULONG WINAPI JoyConfig8Impl_AddRef(IDirectInputJoyConfig8 *iface)
+{
+ IDirectInputImpl *This = impl_from_IDirectInputJoyConfig8( iface );
+ return IDirectInputAImpl_AddRef( &This->IDirectInput7A_iface );
+}
+
+static ULONG WINAPI JoyConfig8Impl_Release(IDirectInputJoyConfig8 *iface)
+{
+ IDirectInputImpl *This = impl_from_IDirectInputJoyConfig8( iface );
+ return IDirectInputAImpl_Release( &This->IDirectInput7A_iface );
+}
+
+static HRESULT WINAPI JoyConfig8Impl_Acquire(IDirectInputJoyConfig8 *iface)
+{
+ FIXME( "(%p): stub!\n", iface );
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI JoyConfig8Impl_Unacquire(IDirectInputJoyConfig8 *iface)
+{
+ FIXME( "(%p): stub!\n", iface );
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI JoyConfig8Impl_SetCooperativeLevel(IDirectInputJoyConfig8 *iface, HWND hwnd, DWORD flags)
+{
+ FIXME( "(%p)->(%p, 0x%08x): stub!\n", iface, hwnd, flags );
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI JoyConfig8Impl_SendNotify(IDirectInputJoyConfig8 *iface)
+{
+ FIXME( "(%p): stub!\n", iface );
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI JoyConfig8Impl_EnumTypes(IDirectInputJoyConfig8 *iface, LPDIJOYTYPECALLBACK cb, void *ref)
+{
+ FIXME( "(%p)->(%p, %p): stub!\n", iface, cb, ref );
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI JoyConfig8Impl_GetTypeInfo(IDirectInputJoyConfig8 *iface, LPCWSTR name, LPDIJOYTYPEINFO info, DWORD flags)
+{
+ FIXME( "(%p)->(%s, %p, 0x%08x): stub!\n", iface, debugstr_w(name), info, flags );
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI JoyConfig8Impl_SetTypeInfo(IDirectInputJoyConfig8 *iface, LPCWSTR name, LPCDIJOYTYPEINFO info, DWORD flags,
+ LPWSTR new_name)
+{
+ FIXME( "(%p)->(%s, %p, 0x%08x, %s): stub!\n", iface, debugstr_w(name), info, flags, debugstr_w(new_name) );
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI JoyConfig8Impl_DeleteType(IDirectInputJoyConfig8 *iface, LPCWSTR name)
+{
+ FIXME( "(%p)->(%s): stub!\n", iface, debugstr_w(name) );
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI JoyConfig8Impl_GetConfig(IDirectInputJoyConfig8 *iface, UINT id, LPDIJOYCONFIG info, DWORD flags)
+{
+ IDirectInputImpl *di = impl_from_IDirectInputJoyConfig8(iface);
+ UINT found = 0;
+ int i, j, r;
+
+ FIXME("(%p)->(%d, %p, 0x%08x): semi-stub!\n", iface, id, info, flags);
+
+#define X(x) if (flags & x) FIXME("\tflags |= "#x"\n");
+ X(DIJC_GUIDINSTANCE)
+ X(DIJC_REGHWCONFIGTYPE)
+ X(DIJC_GAIN)
+ X(DIJC_CALLOUT)
+#undef X
+
+ /* Enumerate all joysticks in order */
+ for (i = 0; i < NB_DINPUT_DEVICES; i++)
+ {
+ if (!dinput_devices[i]->enum_deviceA) continue;
+
+ for (j = 0, r = -1; r != 0; j++)
+ {
+ DIDEVICEINSTANCEA dev;
+ dev.dwSize = sizeof(dev);
+ if ((r = dinput_devices[i]->enum_deviceA(DI8DEVCLASS_GAMECTRL, 0, &dev, di->dwVersion, j)))
+ {
+ /* Only take into account the chosen id */
+ if (found == id)
+ {
+ if (flags & DIJC_GUIDINSTANCE)
+ info->guidInstance = dev.guidInstance;
+
+ return DI_OK;
+ }
+ found += 1;
+ }
+ }
+ }
+
+ return DIERR_NOMOREITEMS;
+}
+
+static HRESULT WINAPI JoyConfig8Impl_SetConfig(IDirectInputJoyConfig8 *iface, UINT id, LPCDIJOYCONFIG info, DWORD flags)
+{
+ FIXME( "(%p)->(%d, %p, 0x%08x): stub!\n", iface, id, info, flags );
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI JoyConfig8Impl_DeleteConfig(IDirectInputJoyConfig8 *iface, UINT id)
+{
+ FIXME( "(%p)->(%d): stub!\n", iface, id );
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI JoyConfig8Impl_GetUserValues(IDirectInputJoyConfig8 *iface, LPDIJOYUSERVALUES info, DWORD flags)
+{
+ FIXME( "(%p)->(%p, 0x%08x): stub!\n", iface, info, flags );
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI JoyConfig8Impl_SetUserValues(IDirectInputJoyConfig8 *iface, LPCDIJOYUSERVALUES info, DWORD flags)
{
- IDirectInputImpl *This = impl_from_IDirectInput8W( iface );
+ FIXME( "(%p)->(%p, 0x%08x): stub!\n", iface, info, flags );
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI JoyConfig8Impl_AddNewHardware(IDirectInputJoyConfig8 *iface, HWND hwnd, REFGUID guid)
+{
+ FIXME( "(%p)->(%p, %s): stub!\n", iface, hwnd, debugstr_guid(guid) );
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI JoyConfig8Impl_OpenTypeKey(IDirectInputJoyConfig8 *iface, LPCWSTR name, DWORD security, PHKEY key)
+{
+ FIXME( "(%p)->(%s, 0x%08x, %p): stub!\n", iface, debugstr_w(name), security, key );
+ return E_NOTIMPL;
+}
- FIXME("(this=%p,%p,%p,%04x,%p): stub\n", This, lpdiCallback, lpdiCDParams,
- dwFlags, pvRefData);
- return 0;
+static HRESULT WINAPI JoyConfig8Impl_OpenAppStatusKey(IDirectInputJoyConfig8 *iface, PHKEY key)
+{
+ FIXME( "(%p)->(%p): stub!\n", iface, key );
+ return E_NOTIMPL;
}
static const IDirectInput7AVtbl ddi7avt = {
IDirectInput8WImpl_ConfigureDevices
};
+static const IDirectInputJoyConfig8Vtbl JoyConfig8vt =
+{
+ JoyConfig8Impl_QueryInterface,
+ JoyConfig8Impl_AddRef,
+ JoyConfig8Impl_Release,
+ JoyConfig8Impl_Acquire,
+ JoyConfig8Impl_Unacquire,
+ JoyConfig8Impl_SetCooperativeLevel,
+ JoyConfig8Impl_SendNotify,
+ JoyConfig8Impl_EnumTypes,
+ JoyConfig8Impl_GetTypeInfo,
+ JoyConfig8Impl_SetTypeInfo,
+ JoyConfig8Impl_DeleteType,
+ JoyConfig8Impl_GetConfig,
+ JoyConfig8Impl_SetConfig,
+ JoyConfig8Impl_DeleteConfig,
+ JoyConfig8Impl_GetUserValues,
+ JoyConfig8Impl_SetUserValues,
+ JoyConfig8Impl_AddNewHardware,
+ JoyConfig8Impl_OpenTypeKey,
+ JoyConfig8Impl_OpenAppStatusKey
+};
+
/*******************************************************************************
* DirectInput ClassFactory
*/
typedef struct
{
/* IUnknown fields */
- const IClassFactoryVtbl *lpVtbl;
- LONG ref;
+ IClassFactory IClassFactory_iface;
+ LONG ref;
} IClassFactoryImpl;
+static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
+{
+ return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
+}
+
static HRESULT WINAPI DICF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
- IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
+ IClassFactoryImpl *This = impl_from_IClassFactory(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;
+ IClassFactoryImpl *This = impl_from_IClassFactory(iface);
return InterlockedIncrement(&(This->ref));
}
static ULONG WINAPI DICF_Release(LPCLASSFACTORY iface) {
- IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
+ IClassFactoryImpl *This = impl_from_IClassFactory(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;
+ IClassFactoryImpl *This = impl_from_IClassFactory(iface);
TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
if ( IsEqualGUID( &IID_IUnknown, 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);
+ IsEqualGUID( &IID_IDirectInput7W, riid ) ) {
+ return create_directinput_instance(riid, ppobj, NULL);
}
FIXME("(%p,%p,%s,%p) Interface not found!\n",This,pOuter,debugstr_guid(riid),ppobj);
}
static HRESULT WINAPI DICF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
- IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
+ IClassFactoryImpl *This = impl_from_IClassFactory(iface);
FIXME("(%p)->(%d),stub!\n",This,dolock);
return S_OK;
}
DICF_CreateInstance,
DICF_LockServer
};
-static IClassFactoryImpl DINPUT_CF = {&DICF_Vtbl, 1 };
+static IClassFactoryImpl DINPUT_CF = {{&DICF_Vtbl}, 1 };
/***********************************************************************
* DllCanUnloadNow (DINPUT.@)
*/
HRESULT WINAPI DllCanUnloadNow(void)
{
- FIXME("(void): stub\n");
-
return S_FALSE;
}
return CLASS_E_CLASSNOTAVAILABLE;
}
+/***********************************************************************
+ * DllRegisterServer (DINPUT.@)
+ */
+HRESULT WINAPI DllRegisterServer(void)
+{
+ return __wine_register_resources( DINPUT_instance );
+}
+
+/***********************************************************************
+ * DllUnregisterServer (DINPUT.@)
+ */
+HRESULT WINAPI DllUnregisterServer(void)
+{
+ return __wine_unregister_resources( DINPUT_instance );
+}
+
/******************************************************************************
* DInput hook thread
*/
EnterCriticalSection( &dinput_hook_crit );
LIST_FOR_EACH_ENTRY( dinput, &direct_input_list, IDirectInputImpl, entry )
{
- IDirectInputDevice2AImpl *dev;
+ IDirectInputDeviceImpl *dev;
EnterCriticalSection( &dinput->crit );
- LIST_FOR_EACH_ENTRY( dev, &dinput->devices_list, IDirectInputDevice2AImpl, entry )
+ LIST_FOR_EACH_ENTRY( dev, &dinput->devices_list, IDirectInputDeviceImpl, entry )
if (dev->acquired && dev->event_proc)
{
TRACE("calling %p->%p (%lx %lx)\n", dev, dev->event_proc, wparam, lparam);
- dev->event_proc( (LPDIRECTINPUTDEVICE8A)dev, wparam, lparam );
- skip |= dev->dwCoopLevel & DISCL_EXCLUSIVE;
+ skip |= dev->event_proc( &dev->IDirectInputDevice8A_iface, wparam, lparam );
}
LeaveCriticalSection( &dinput->crit );
}
LIST_FOR_EACH_ENTRY( dinput, &direct_input_list, IDirectInputImpl, entry )
{
- IDirectInputDevice2AImpl *dev;
+ IDirectInputDeviceImpl *dev;
EnterCriticalSection( &dinput->crit );
- LIST_FOR_EACH_ENTRY( dev, &dinput->devices_list, IDirectInputDevice2AImpl, entry )
+ LIST_FOR_EACH_ENTRY( dev, &dinput->devices_list, IDirectInputDeviceImpl, entry )
{
if (!dev->acquired) continue;
if (msg->hwnd == dev->win && msg->hwnd != foreground)
{
TRACE( "%p window is not foreground - unacquiring %p\n", dev->win, dev );
- IDirectInputDevice_Unacquire( (LPDIRECTINPUTDEVICE8A)dev );
+ IDirectInputDevice_Unacquire( &dev->IDirectInputDevice8A_iface );
}
}
LeaveCriticalSection( &dinput->crit );
/* Count acquired keyboards and mice*/
LIST_FOR_EACH_ENTRY( dinput, &direct_input_list, IDirectInputImpl, entry )
{
- IDirectInputDevice2AImpl *dev;
+ IDirectInputDeviceImpl *dev;
EnterCriticalSection( &dinput->crit );
- LIST_FOR_EACH_ENTRY( dev, &dinput->devices_list, IDirectInputDevice2AImpl, entry )
+ LIST_FOR_EACH_ENTRY( dev, &dinput->devices_list, IDirectInputDeviceImpl, entry )
{
if (!dev->acquired || !dev->event_proc) continue;
return hook_thread_id != 0;
}
-void check_dinput_hooks(LPDIRECTINPUTDEVICE8A iface)
+void check_dinput_hooks(LPDIRECTINPUTDEVICE8W iface)
{
static HHOOK callwndproc_hook;
static ULONG foreground_cnt;
- IDirectInputDevice2AImpl *dev = (IDirectInputDevice2AImpl *)iface;
+ IDirectInputDeviceImpl *dev = impl_from_IDirectInputDevice8W(iface);
EnterCriticalSection(&dinput_hook_crit);
LeaveCriticalSection(&dinput_hook_crit);
}
+
+BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserv)
+{
+ switch(reason)
+ {
+ case DLL_PROCESS_ATTACH:
+ DisableThreadLibraryCalls(inst);
+ DINPUT_instance = inst;
+ break;
+ case DLL_PROCESS_DETACH:
+ DeleteCriticalSection(&dinput_hook_crit);
+ break;
+ }
+ return TRUE;
+}
#include <windef.h>
#include <winbase.h>
-#include <winreg.h>
-#include <winnls.h>
#include <dinput.h>
+#include <dinputd.h>
#include <wine/list.h>
/* Implementation specification */
typedef struct IDirectInputImpl IDirectInputImpl;
struct IDirectInputImpl
{
- const IDirectInput7AVtbl *lpVtbl;
- const IDirectInput7WVtbl *lpVtbl7w;
- const IDirectInput8AVtbl *lpVtbl8a;
- const IDirectInput8WVtbl *lpVtbl8w;
+ IDirectInput7A IDirectInput7A_iface;
+ IDirectInput7W IDirectInput7W_iface;
+ IDirectInput8A IDirectInput8A_iface;
+ IDirectInput8W IDirectInput8W_iface;
+ IDirectInputJoyConfig8 IDirectInputJoyConfig8_iface;
LONG ref;
+ BOOL initialized;
CRITICAL_SECTION crit;
struct list entry; /* entry into list of all IDirectInputs */
const char *name;
BOOL (*enum_deviceA)(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, DWORD version, int id);
BOOL (*enum_deviceW)(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, DWORD version, int id);
- HRESULT (*create_deviceA)(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEA* pdev);
- HRESULT (*create_deviceW)(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEW* pdev);
+ HRESULT (*create_device)(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPVOID *pdev, int unicode);
};
-extern const struct dinput_device mouse_device;
-extern const struct dinput_device keyboard_device;
-extern const struct dinput_device joystick_linux_device;
-extern const struct dinput_device joystick_linuxinput_device;
+extern const struct dinput_device mouse_device DECLSPEC_HIDDEN;
+extern const struct dinput_device keyboard_device DECLSPEC_HIDDEN;
+extern const struct dinput_device joystick_linux_device DECLSPEC_HIDDEN;
+extern const struct dinput_device joystick_linuxinput_device DECLSPEC_HIDDEN;
+extern const struct dinput_device joystick_osx_device DECLSPEC_HIDDEN;
-extern void check_dinput_hooks(LPDIRECTINPUTDEVICE8A);
-typedef void (*DI_EVENT_PROC)(LPDIRECTINPUTDEVICE8A, WPARAM, LPARAM);
+extern void check_dinput_hooks(LPDIRECTINPUTDEVICE8W) DECLSPEC_HIDDEN;
+typedef int (*DI_EVENT_PROC)(LPDIRECTINPUTDEVICE8A, WPARAM, LPARAM);
-extern void _dump_diactionformatA(LPDIACTIONFORMATA);
+extern void _copy_diactionformatAtoW(LPDIACTIONFORMATW, LPDIACTIONFORMATA) DECLSPEC_HIDDEN;
+extern void _copy_diactionformatWtoA(LPDIACTIONFORMATA, LPDIACTIONFORMATW) DECLSPEC_HIDDEN;
+
+extern HRESULT _configure_devices(IDirectInput8W *iface, LPDICONFIGUREDEVICESCALLBACK lpdiCallback, LPDICONFIGUREDEVICESPARAMSW lpdiCDParams, DWORD dwFlags, LPVOID pvRefData) DECLSPEC_HIDDEN;
+
+extern WCHAR* get_mapping_path(const WCHAR *device, const WCHAR *username) DECLSPEC_HIDDEN;
+
+#define IS_DIPROP(x) (((ULONG_PTR)(x) >> 16) == 0)
+
+#define DIKEYBOARD_MASK 0x81000000
+#define DIMOUSE_MASK 0x82000000
+#define DIGENRE_ANY 0xFF000000
#endif /* __WINE_DLLS_DINPUT_DINPUT_PRIVATE_H */
# include <linux/input.h>
# undef SW_MAX
#endif
+#include <limits.h>
#include <errno.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
typedef struct LinuxInputEffectImpl LinuxInputEffectImpl;
struct LinuxInputEffectImpl
{
- const void *lpVtbl;
- LONG ref;
- GUID guid;
+ IDirectInputEffect IDirectInputEffect_iface;
+ LONG ref;
+ GUID guid;
struct ff_effect effect; /* Effect data */
int gain; /* Effect gain */
struct list *entry; /* Entry into the parent's list of effects */
};
+static inline LinuxInputEffectImpl *impl_from_IDirectInputEffect(IDirectInputEffect *iface)
+{
+ return CONTAINING_RECORD(iface, LinuxInputEffectImpl, IDirectInputEffect_iface);
+}
/******************************************************************************
* DirectInputEffect Functional Helper
}
}
-static void _dump_DIEFFECT(LPCDIEFFECT eff, REFGUID guid)
+static void _dump_DIEFFECT(LPCDIEFFECT eff, REFGUID guid, DWORD dwFlags)
{
unsigned int i;
DWORD type = _typeFromGUID(guid);
_dump_DIEFFECT_flags(eff->dwFlags);
TRACE(" - dwDuration: %d\n", eff->dwDuration);
TRACE(" - dwGain: %d\n", eff->dwGain);
+
if (eff->dwGain > 10000)
- WARN("dwGain is out of range (>10,000)\n");
+ WARN("dwGain is out of range (>10,000)\n");
+
TRACE(" - dwTriggerButton: %d\n", eff->dwTriggerButton);
TRACE(" - dwTriggerRepeatInterval: %d\n", eff->dwTriggerRepeatInterval);
- TRACE(" - cAxes: %d\n", eff->cAxes);
- TRACE(" - rgdwAxes: %p\n", eff->rgdwAxes);
- if (TRACE_ON(dinput) && eff->rgdwAxes) {
- TRACE(" ");
- for (i = 0; i < eff->cAxes; ++i)
- TRACE("%d ", eff->rgdwAxes[i]);
- TRACE("\n");
- }
TRACE(" - rglDirection: %p\n", eff->rglDirection);
- TRACE(" - lpEnvelope: %p\n", eff->lpEnvelope);
TRACE(" - cbTypeSpecificParams: %d\n", eff->cbTypeSpecificParams);
TRACE(" - lpvTypeSpecificParams: %p\n", eff->lpvTypeSpecificParams);
+
+ /* Only trace some members if dwFlags indicates they have data */
+ if (dwFlags & DIEP_AXES) {
+ TRACE(" - cAxes: %d\n", eff->cAxes);
+ TRACE(" - rgdwAxes: %p\n", eff->rgdwAxes);
+
+ if (TRACE_ON(dinput) && eff->rgdwAxes) {
+ TRACE(" ");
+ for (i = 0; i < eff->cAxes; ++i)
+ TRACE("%d ", eff->rgdwAxes[i]);
+ TRACE("\n");
+ }
+ }
+
+ if (dwFlags & DIEP_ENVELOPE) {
+ TRACE(" - lpEnvelope: %p\n", eff->lpEnvelope);
+ if (eff->lpEnvelope != NULL)
+ _dump_DIENVELOPE(eff->lpEnvelope);
+ }
+
if (eff->dwSize > sizeof(DIEFFECT_DX5))
- TRACE(" - dwStartDelay: %d\n", eff->dwStartDelay);
- if (eff->lpEnvelope != NULL)
- _dump_DIENVELOPE(eff->lpEnvelope);
+ TRACE(" - dwStartDelay: %d\n", eff->dwStartDelay);
+
if (type == DIEFT_CONSTANTFORCE) {
if (eff->cbTypeSpecificParams != sizeof(DICONSTANTFORCE)) {
WARN("Effect claims to be a constant force but the type-specific params are the wrong size!\n");
static ULONG WINAPI LinuxInputEffectImpl_AddRef(
LPDIRECTINPUTEFFECT iface)
{
- LinuxInputEffectImpl *This = (LinuxInputEffectImpl *)iface;
+ LinuxInputEffectImpl *This = impl_from_IDirectInputEffect(iface);
return InterlockedIncrement(&(This->ref));
}
static HRESULT WINAPI LinuxInputEffectImpl_Download(
LPDIRECTINPUTEFFECT iface)
{
- LinuxInputEffectImpl *This = (LinuxInputEffectImpl *)iface;
+ LinuxInputEffectImpl *This = impl_from_IDirectInputEffect(iface);
TRACE("(this=%p)\n", This);
LPDIRECTINPUTEFFECT iface,
LPGUID pguid)
{
- LinuxInputEffectImpl *This = (LinuxInputEffectImpl*)iface;
+ LinuxInputEffectImpl *This = impl_from_IDirectInputEffect(iface);
TRACE("(this=%p,%p)\n", This, pguid);
- pguid = &This->guid;
-
+ *pguid = This->guid;
+
return DI_OK;
}
DWORD dwFlags)
{
HRESULT diErr = DI_OK;
- LinuxInputEffectImpl *This = (LinuxInputEffectImpl *)iface;
+ LinuxInputEffectImpl *This = impl_from_IDirectInputEffect(iface);
TRACE("(this=%p,%p,%d)\n", This, peff, dwFlags);
/* Major conversion factors are:
return diErr;
else {
if (peff->dwFlags & DIEFF_CARTESIAN) {
- peff->rglDirection[0] = (long)(sin(M_PI * 3 * This->effect.direction / 0x7FFF) * 1000);
- peff->rglDirection[1] = (long)(cos(M_PI * 3 * This->effect.direction / 0x7FFF) * 1000);
+ peff->rglDirection[0] = sin(M_PI * 3 * This->effect.direction / 0x7FFF) * 1000;
+ peff->rglDirection[1] = cos(M_PI * 3 * This->effect.direction / 0x7FFF) * 1000;
} else {
/* Polar and spherical coordinates are the same for two or less
* axes.
REFIID riid,
void **ppvObject)
{
- LinuxInputEffectImpl* This = (LinuxInputEffectImpl*)iface;
+ LinuxInputEffectImpl *This = impl_from_IDirectInputEffect(iface);
TRACE("(this=%p,%s,%p)\n", This, debugstr_guid(riid), ppvObject);
DWORD dwFlags)
{
struct input_event event;
- LinuxInputEffectImpl* This = (LinuxInputEffectImpl*)iface;
+ LinuxInputEffectImpl *This = impl_from_IDirectInputEffect(iface);
TRACE("(this=%p,%d,%d)\n", This, dwIterations, dwFlags);
event.type = EV_FF;
event.code = This->effect.id;
- event.value = dwIterations;
+ event.value = min( dwIterations, INT_MAX );
if (write(*(This->fd), &event, sizeof(event)) == -1) {
FIXME("Unable to write event. Assuming device disconnected.\n");
return DIERR_INPUTLOST;
LPDIRECTINPUTEFFECT iface,
LPCDIEFFECT peff,
DWORD dwFlags)
-{
- LinuxInputEffectImpl* This = (LinuxInputEffectImpl*)iface;
+{
+ LinuxInputEffectImpl *This = impl_from_IDirectInputEffect(iface);
DWORD type = _typeFromGUID(&This->guid);
HRESULT retval = DI_OK;
TRACE("(this=%p,%p,%d)\n", This, peff, dwFlags);
- _dump_DIEFFECT(peff, &This->guid);
+ _dump_DIEFFECT(peff, &This->guid, dwFlags);
if ((dwFlags & ~DIEP_NORESTART & ~DIEP_NODOWNLOAD & ~DIEP_START) == 0) {
/* set everything */
else env = NULL;
if (peff->lpEnvelope == NULL) {
- /* if this type had an envelope, reset it
- * note that length can never be zero, so we set it to something minuscule */
+ /* if this type had an envelope, reset it */
if (env) {
- env->attack_length = 0x10;
- env->attack_level = 0x7FFF;
- env->fade_length = 0x10;
- env->fade_level = 0x7FFF;
+ env->attack_length = 0;
+ env->attack_level = 0;
+ env->fade_length = 0;
+ env->fade_level = 0;
}
} else {
/* did we get passed an envelope for a type that doesn't even have one? */
return DIERR_INVALIDPARAM;
tsp = peff->lpvTypeSpecificParams;
This->effect.u.ramp.start_level = (tsp->lStart / 10) * 32;
- This->effect.u.ramp.end_level = (tsp->lStart / 10) * 32;
+ This->effect.u.ramp.end_level = (tsp->lEnd / 10) * 32;
} else if (type == DIEFT_CONDITION) {
LPCDICONDITION tsp = peff->lpvTypeSpecificParams;
if (peff->cbTypeSpecificParams == sizeof(DICONDITION)) {
LPDIRECTINPUTEFFECT iface)
{
struct input_event event;
- LinuxInputEffectImpl *This = (LinuxInputEffectImpl *)iface;
+ LinuxInputEffectImpl *This = impl_from_IDirectInputEffect(iface);
TRACE("(this=%p)\n", This);
static HRESULT WINAPI LinuxInputEffectImpl_Unload(
LPDIRECTINPUTEFFECT iface)
{
- LinuxInputEffectImpl *This = (LinuxInputEffectImpl *)iface;
+ LinuxInputEffectImpl *This = impl_from_IDirectInputEffect(iface);
TRACE("(this=%p)\n", This);
/* Erase the downloaded effect */
static ULONG WINAPI LinuxInputEffectImpl_Release(LPDIRECTINPUTEFFECT iface)
{
- LinuxInputEffectImpl *This = (LinuxInputEffectImpl *)iface;
+ LinuxInputEffectImpl *This = impl_from_IDirectInputEffect(iface);
ULONG ref = InterlockedDecrement(&(This->ref));
if (ref == 0)
* LinuxInputEffect
*/
-HRESULT linuxinput_create_effect(
+DECLSPEC_HIDDEN HRESULT linuxinput_create_effect(
int* fd,
REFGUID rguid,
struct list *parent_list_entry,
HEAP_ZERO_MEMORY, sizeof(LinuxInputEffectImpl));
DWORD type = _typeFromGUID(rguid);
- newEffect->lpVtbl = &LinuxInputEffectVtbl;
+ newEffect->IDirectInputEffect_iface.lpVtbl = &LinuxInputEffectVtbl;
newEffect->ref = 1;
newEffect->guid = *rguid;
newEffect->fd = fd;
newEffect->entry = parent_list_entry;
- *peff = (LPDIRECTINPUTEFFECT)newEffect;
+ *peff = &newEffect->IDirectInputEffect_iface;
TRACE("Creating linux input system effect (%p) with guid %s\n",
*peff, _dump_dinput_GUID(rguid));
return DI_OK;
}
-HRESULT linuxinput_get_info_A(
+DECLSPEC_HIDDEN HRESULT linuxinput_get_info_A(
int fd,
REFGUID rguid,
LPDIEFFECTINFOA info)
return DI_OK;
}
-HRESULT linuxinput_get_info_W(
+DECLSPEC_HIDDEN HRESULT linuxinput_get_info_W(
int fd,
REFGUID rguid,
LPDIEFFECTINFOW info)
--- /dev/null
+/* DirectInput Generic Joystick device
+ *
+ * Copyright 1998 Marcus Meissner
+ * Copyright 1998,1999 Lionel Ulmer
+ * Copyright 2000-2001 TransGaming Technologies Inc.
+ * Copyright 2009 Aric Stewart, CodeWeavers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+/*
+ * To Do:
+ * dead zone
+ * force feedback
+ */
+
+#include "joystick_private.h"
+#include <wine/debug.h>
+#include <winreg.h>
+
+WINE_DEFAULT_DEBUG_CHANNEL(dinput);
+
+static inline JoystickGenericImpl *impl_from_IDirectInputDevice8A(IDirectInputDevice8A *iface)
+{
+ return CONTAINING_RECORD(CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8A_iface), JoystickGenericImpl, base);
+}
+static inline JoystickGenericImpl *impl_from_IDirectInputDevice8W(IDirectInputDevice8W *iface)
+{
+ return CONTAINING_RECORD(CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8W_iface), JoystickGenericImpl, base);
+}
+static inline IDirectInputDevice8A *IDirectInputDevice8A_from_impl(JoystickGenericImpl *This)
+{
+ return &This->base.IDirectInputDevice8A_iface;
+}
+static inline IDirectInputDevice8W *IDirectInputDevice8W_from_impl(JoystickGenericImpl *This)
+{
+ return &This->base.IDirectInputDevice8W_iface;
+}
+
+BOOL device_disabled_registry(const char* name)
+{
+ static const char disabled_str[] = "disabled";
+ static const char joystick_key[] = "Joysticks";
+ char buffer[MAX_PATH];
+ HKEY hkey, appkey, temp;
+ BOOL do_disable = FALSE;
+
+ get_app_key(&hkey, &appkey);
+
+ /* Joystick settings are in the 'joysticks' subkey */
+ if (appkey)
+ {
+ if (RegOpenKeyA(appkey, joystick_key, &temp)) temp = 0;
+ RegCloseKey(appkey);
+ appkey = temp;
+ }
+ if (hkey)
+ {
+ if (RegOpenKeyA(hkey, joystick_key, &temp)) temp = 0;
+ RegCloseKey(hkey);
+ hkey = temp;
+ }
+
+ /* Look for the "controllername"="disabled" key */
+ if (!get_config_key(hkey, appkey, name, buffer, sizeof(buffer)))
+ if (!strcmp(disabled_str, buffer))
+ {
+ TRACE("Disabling joystick '%s' based on registry key.\n", name);
+ do_disable = TRUE;
+ }
+
+ if (appkey) RegCloseKey(appkey);
+ if (hkey) RegCloseKey(hkey);
+
+ return do_disable;
+}
+
+/******************************************************************************
+ * SetProperty : change input device properties
+ */
+HRESULT WINAPI JoystickWGenericImpl_SetProperty(LPDIRECTINPUTDEVICE8W iface, REFGUID rguid, LPCDIPROPHEADER ph)
+{
+ JoystickGenericImpl *This = impl_from_IDirectInputDevice8W(iface);
+ DWORD i;
+
+ TRACE("(%p,%s,%p)\n",This,debugstr_guid(rguid),ph);
+
+ if (ph == NULL) {
+ WARN("invalid parameter: ph == NULL\n");
+ return DIERR_INVALIDPARAM;
+ }
+
+ if (TRACE_ON(dinput))
+ _dump_DIPROPHEADER(ph);
+
+ if (IS_DIPROP(rguid)) {
+ switch (LOWORD(rguid)) {
+ case (DWORD_PTR)DIPROP_RANGE: {
+ LPCDIPROPRANGE pr = (LPCDIPROPRANGE)ph;
+ if (ph->dwHow == DIPH_DEVICE) {
+ TRACE("proprange(%d,%d) all\n", pr->lMin, pr->lMax);
+ for (i = 0; i < This->base.data_format.wine_df->dwNumObjs; i++) {
+ This->props[i].lMin = pr->lMin;
+ This->props[i].lMax = pr->lMax;
+ }
+ } else {
+ int obj = find_property(&This->base.data_format, ph);
+
+ TRACE("proprange(%d,%d) obj=%d\n", pr->lMin, pr->lMax, obj);
+ if (obj >= 0) {
+ This->props[obj].lMin = pr->lMin;
+ This->props[obj].lMax = pr->lMax;
+ return DI_OK;
+ }
+ }
+ break;
+ }
+ case (DWORD_PTR)DIPROP_DEADZONE: {
+ LPCDIPROPDWORD pd = (LPCDIPROPDWORD)ph;
+ if (ph->dwHow == DIPH_DEVICE) {
+ TRACE("deadzone(%d) all\n", pd->dwData);
+ for (i = 0; i < This->base.data_format.wine_df->dwNumObjs; i++)
+ This->props[i].lDeadZone = pd->dwData;
+ } else {
+ int obj = find_property(&This->base.data_format, ph);
+
+ TRACE("deadzone(%d) obj=%d\n", pd->dwData, obj);
+ if (obj >= 0) {
+ This->props[obj].lDeadZone = pd->dwData;
+ return DI_OK;
+ }
+ }
+ break;
+ }
+ case (DWORD_PTR)DIPROP_SATURATION: {
+ LPCDIPROPDWORD pd = (LPCDIPROPDWORD)ph;
+ if (ph->dwHow == DIPH_DEVICE) {
+ TRACE("saturation(%d) all\n", pd->dwData);
+ for (i = 0; i < This->base.data_format.wine_df->dwNumObjs; i++)
+ This->props[i].lSaturation = pd->dwData;
+ } else {
+ int obj = find_property(&This->base.data_format, ph);
+
+ TRACE("saturation(%d) obj=%d\n", pd->dwData, obj);
+ if (obj >= 0) {
+ This->props[obj].lSaturation = pd->dwData;
+ return DI_OK;
+ }
+ }
+ break;
+ }
+ default:
+ return IDirectInputDevice2WImpl_SetProperty(iface, rguid, ph);
+ }
+ }
+
+ return DI_OK;
+}
+
+HRESULT WINAPI JoystickAGenericImpl_SetProperty(LPDIRECTINPUTDEVICE8A iface, REFGUID rguid, LPCDIPROPHEADER ph)
+{
+ JoystickGenericImpl *This = impl_from_IDirectInputDevice8A(iface);
+ return JoystickWGenericImpl_SetProperty(IDirectInputDevice8W_from_impl(This), rguid, ph);
+}
+
+void _dump_DIDEVCAPS(const DIDEVCAPS *lpDIDevCaps)
+{
+ TRACE("dwSize: %d\n", lpDIDevCaps->dwSize);
+ TRACE("dwFlags: %08x\n", lpDIDevCaps->dwFlags);
+ TRACE("dwDevType: %08x %s\n", lpDIDevCaps->dwDevType,
+ lpDIDevCaps->dwDevType == DIDEVTYPE_DEVICE ? "DIDEVTYPE_DEVICE" :
+ lpDIDevCaps->dwDevType == DIDEVTYPE_DEVICE ? "DIDEVTYPE_DEVICE" :
+ lpDIDevCaps->dwDevType == DIDEVTYPE_MOUSE ? "DIDEVTYPE_MOUSE" :
+ lpDIDevCaps->dwDevType == DIDEVTYPE_KEYBOARD ? "DIDEVTYPE_KEYBOARD" :
+ lpDIDevCaps->dwDevType == DIDEVTYPE_JOYSTICK ? "DIDEVTYPE_JOYSTICK" :
+ lpDIDevCaps->dwDevType == DIDEVTYPE_HID ? "DIDEVTYPE_HID" : "UNKNOWN");
+ TRACE("dwAxes: %d\n", lpDIDevCaps->dwAxes);
+ TRACE("dwButtons: %d\n", lpDIDevCaps->dwButtons);
+ TRACE("dwPOVs: %d\n", lpDIDevCaps->dwPOVs);
+ if (lpDIDevCaps->dwSize > sizeof(DIDEVCAPS_DX3)) {
+ TRACE("dwFFSamplePeriod: %d\n", lpDIDevCaps->dwFFSamplePeriod);
+ TRACE("dwFFMinTimeResolution: %d\n", lpDIDevCaps->dwFFMinTimeResolution);
+ TRACE("dwFirmwareRevision: %d\n", lpDIDevCaps->dwFirmwareRevision);
+ TRACE("dwHardwareRevision: %d\n", lpDIDevCaps->dwHardwareRevision);
+ TRACE("dwFFDriverVersion: %d\n", lpDIDevCaps->dwFFDriverVersion);
+ }
+}
+
+HRESULT WINAPI JoystickWGenericImpl_GetCapabilities(LPDIRECTINPUTDEVICE8W iface, LPDIDEVCAPS lpDIDevCaps)
+{
+ JoystickGenericImpl *This = impl_from_IDirectInputDevice8W(iface);
+ int size;
+
+ TRACE("%p->(%p)\n",iface,lpDIDevCaps);
+
+ if (lpDIDevCaps == NULL) {
+ WARN("invalid pointer\n");
+ return E_POINTER;
+ }
+
+ size = lpDIDevCaps->dwSize;
+
+ if (!(size == sizeof(DIDEVCAPS) || size == sizeof(DIDEVCAPS_DX3))) {
+ WARN("invalid parameter\n");
+ return DIERR_INVALIDPARAM;
+ }
+
+ CopyMemory(lpDIDevCaps, &This->devcaps, size);
+ lpDIDevCaps->dwSize = size;
+
+ if (TRACE_ON(dinput))
+ _dump_DIDEVCAPS(lpDIDevCaps);
+
+ return DI_OK;
+}
+
+HRESULT WINAPI JoystickAGenericImpl_GetCapabilities(LPDIRECTINPUTDEVICE8A iface, LPDIDEVCAPS lpDIDevCaps)
+{
+ JoystickGenericImpl *This = impl_from_IDirectInputDevice8A(iface);
+ return JoystickWGenericImpl_GetCapabilities(IDirectInputDevice8W_from_impl(This), lpDIDevCaps);
+}
+
+/******************************************************************************
+ * GetObjectInfo : get object info
+ */
+HRESULT WINAPI JoystickWGenericImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface,
+ LPDIDEVICEOBJECTINSTANCEW pdidoi, DWORD dwObj, DWORD dwHow)
+{
+ static const WCHAR axisW[] = {'A','x','i','s',' ','%','d',0};
+ static const WCHAR povW[] = {'P','O','V',' ','%','d',0};
+ static const WCHAR buttonW[] = {'B','u','t','t','o','n',' ','%','d',0};
+ HRESULT res;
+
+ res = IDirectInputDevice2WImpl_GetObjectInfo(iface, pdidoi, dwObj, dwHow);
+ if (res != DI_OK) return res;
+
+ if (pdidoi->dwType & DIDFT_AXIS)
+ sprintfW(pdidoi->tszName, axisW, DIDFT_GETINSTANCE(pdidoi->dwType));
+ else if (pdidoi->dwType & DIDFT_POV)
+ sprintfW(pdidoi->tszName, povW, DIDFT_GETINSTANCE(pdidoi->dwType));
+ else if (pdidoi->dwType & DIDFT_BUTTON)
+ sprintfW(pdidoi->tszName, buttonW, DIDFT_GETINSTANCE(pdidoi->dwType));
+
+ _dump_OBJECTINSTANCEW(pdidoi);
+ return res;
+}
+
+HRESULT WINAPI JoystickAGenericImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8A iface,
+ LPDIDEVICEOBJECTINSTANCEA pdidoi, DWORD dwObj, DWORD dwHow)
+{
+ JoystickGenericImpl *This = impl_from_IDirectInputDevice8A(iface);
+ HRESULT res;
+ DIDEVICEOBJECTINSTANCEW didoiW;
+ DWORD dwSize = pdidoi->dwSize;
+
+ didoiW.dwSize = sizeof(didoiW);
+ res = JoystickWGenericImpl_GetObjectInfo(IDirectInputDevice8W_from_impl(This), &didoiW, dwObj, dwHow);
+ if (res != DI_OK) return res;
+
+ memset(pdidoi, 0, pdidoi->dwSize);
+ memcpy(pdidoi, &didoiW, FIELD_OFFSET(DIDEVICEOBJECTINSTANCEW, tszName));
+ pdidoi->dwSize = dwSize;
+ WideCharToMultiByte(CP_ACP, 0, didoiW.tszName, -1, pdidoi->tszName,
+ sizeof(pdidoi->tszName), NULL, NULL);
+
+ return res;
+}
+
+/******************************************************************************
+ * GetProperty : get input device properties
+ */
+HRESULT WINAPI JoystickWGenericImpl_GetProperty(LPDIRECTINPUTDEVICE8W iface, REFGUID rguid, LPDIPROPHEADER pdiph)
+{
+ JoystickGenericImpl *This = impl_from_IDirectInputDevice8W(iface);
+
+ TRACE("(%p,%s,%p)\n", iface, debugstr_guid(rguid), pdiph);
+
+ if (TRACE_ON(dinput))
+ _dump_DIPROPHEADER(pdiph);
+
+ if (IS_DIPROP(rguid)) {
+ switch (LOWORD(rguid)) {
+ case (DWORD_PTR) DIPROP_RANGE: {
+ LPDIPROPRANGE pr = (LPDIPROPRANGE)pdiph;
+ int obj = find_property(&This->base.data_format, pdiph);
+
+ /* The app is querying the current range of the axis
+ * return the lMin and lMax values */
+ if (obj >= 0) {
+ pr->lMin = This->props[obj].lMin;
+ pr->lMax = This->props[obj].lMax;
+ TRACE("range(%d, %d) obj=%d\n", pr->lMin, pr->lMax, obj);
+ return DI_OK;
+ }
+ break;
+ }
+ case (DWORD_PTR) DIPROP_DEADZONE: {
+ LPDIPROPDWORD pd = (LPDIPROPDWORD)pdiph;
+ int obj = find_property(&This->base.data_format, pdiph);
+
+ if (obj >= 0) {
+ pd->dwData = This->props[obj].lDeadZone;
+ TRACE("deadzone(%d) obj=%d\n", pd->dwData, obj);
+ return DI_OK;
+ }
+ break;
+ }
+ case (DWORD_PTR) DIPROP_SATURATION: {
+ LPDIPROPDWORD pd = (LPDIPROPDWORD)pdiph;
+ int obj = find_property(&This->base.data_format, pdiph);
+
+ if (obj >= 0) {
+ pd->dwData = This->props[obj].lSaturation;
+ TRACE("saturation(%d) obj=%d\n", pd->dwData, obj);
+ return DI_OK;
+ }
+ break;
+ }
+ case (DWORD_PTR) DIPROP_INSTANCENAME: {
+ DIPROPSTRING *ps = (DIPROPSTRING*) pdiph;
+ DIDEVICEINSTANCEW didev;
+
+ didev.dwSize = sizeof(didev);
+
+ IDirectInputDevice_GetDeviceInfo(iface, &didev);
+ lstrcpynW(ps->wsz, didev.tszInstanceName, MAX_PATH);
+
+ return DI_OK;
+ }
+ default:
+ return IDirectInputDevice2WImpl_GetProperty(iface, rguid, pdiph);
+ }
+ }
+
+ return DI_OK;
+}
+
+HRESULT WINAPI JoystickAGenericImpl_GetProperty(LPDIRECTINPUTDEVICE8A iface, REFGUID rguid, LPDIPROPHEADER pdiph)
+{
+ JoystickGenericImpl *This = impl_from_IDirectInputDevice8A(iface);
+ return JoystickWGenericImpl_GetProperty(IDirectInputDevice8W_from_impl(This), rguid, pdiph);
+}
+
+/******************************************************************************
+ * GetDeviceInfo : get information about a device's identity
+ */
+HRESULT WINAPI JoystickAGenericImpl_GetDeviceInfo(
+ LPDIRECTINPUTDEVICE8A iface,
+ LPDIDEVICEINSTANCEA pdidi)
+{
+ JoystickGenericImpl *This = impl_from_IDirectInputDevice8A(iface);
+
+ TRACE("(%p,%p)\n", iface, pdidi);
+
+ if (pdidi == NULL) {
+ WARN("invalid pointer\n");
+ return E_POINTER;
+ }
+
+ if ((pdidi->dwSize != sizeof(DIDEVICEINSTANCE_DX3A)) &&
+ (pdidi->dwSize != sizeof(DIDEVICEINSTANCEA))) {
+ WARN("invalid parameter: pdidi->dwSize = %d\n", pdidi->dwSize);
+ return DIERR_INVALIDPARAM;
+ }
+
+ /* Return joystick */
+ pdidi->guidInstance = This->guidInstance;
+ pdidi->guidProduct = This->guidProduct;
+ /* we only support traditional joysticks for now */
+ pdidi->dwDevType = This->devcaps.dwDevType;
+ strcpy(pdidi->tszInstanceName, "Joystick");
+ strcpy(pdidi->tszProductName, This->name);
+ if (pdidi->dwSize > sizeof(DIDEVICEINSTANCE_DX3A)) {
+ pdidi->guidFFDriver = GUID_NULL;
+ pdidi->wUsagePage = 0;
+ pdidi->wUsage = 0;
+ }
+
+ return DI_OK;
+}
+
+/******************************************************************************
+ * GetDeviceInfo : get information about a device's identity
+ */
+HRESULT WINAPI JoystickWGenericImpl_GetDeviceInfo(
+ LPDIRECTINPUTDEVICE8W iface,
+ LPDIDEVICEINSTANCEW pdidi)
+{
+ JoystickGenericImpl *This = impl_from_IDirectInputDevice8W(iface);
+
+ TRACE("(%p,%p)\n", iface, pdidi);
+
+ if ((pdidi->dwSize != sizeof(DIDEVICEINSTANCE_DX3W)) &&
+ (pdidi->dwSize != sizeof(DIDEVICEINSTANCEW))) {
+ WARN("invalid parameter: pdidi->dwSize = %d\n", pdidi->dwSize);
+ return DIERR_INVALIDPARAM;
+ }
+
+ /* Return joystick */
+ pdidi->guidInstance = This->guidInstance;
+ pdidi->guidProduct = This->guidProduct;
+ /* we only support traditional joysticks for now */
+ pdidi->dwDevType = This->devcaps.dwDevType;
+ MultiByteToWideChar(CP_ACP, 0, "Joystick", -1, pdidi->tszInstanceName, MAX_PATH);
+ MultiByteToWideChar(CP_ACP, 0, This->name, -1, pdidi->tszProductName, MAX_PATH);
+ if (pdidi->dwSize > sizeof(DIDEVICEINSTANCE_DX3W)) {
+ pdidi->guidFFDriver = GUID_NULL;
+ pdidi->wUsagePage = 0;
+ pdidi->wUsage = 0;
+ }
+
+ return DI_OK;
+}
+
+HRESULT WINAPI JoystickWGenericImpl_Poll(LPDIRECTINPUTDEVICE8W iface)
+{
+ JoystickGenericImpl *This = impl_from_IDirectInputDevice8W(iface);
+
+ TRACE("(%p)\n",This);
+
+ if (!This->base.acquired) {
+ WARN("not acquired\n");
+ return DIERR_NOTACQUIRED;
+ }
+
+ This->joy_polldev(IDirectInputDevice8A_from_impl(This));
+ return DI_OK;
+}
+
+HRESULT WINAPI JoystickAGenericImpl_Poll(LPDIRECTINPUTDEVICE8A iface)
+{
+ JoystickGenericImpl *This = impl_from_IDirectInputDevice8A(iface);
+ return JoystickWGenericImpl_Poll(IDirectInputDevice8W_from_impl(This));
+}
+
+/******************************************************************************
+ * GetDeviceState : returns the "state" of the joystick.
+ *
+ */
+HRESULT WINAPI JoystickWGenericImpl_GetDeviceState(LPDIRECTINPUTDEVICE8W iface, DWORD len, LPVOID ptr)
+{
+ JoystickGenericImpl *This = impl_from_IDirectInputDevice8W(iface);
+
+ TRACE("(%p,0x%08x,%p)\n", This, len, ptr);
+
+ if (!This->base.acquired) {
+ WARN("not acquired\n");
+ return DIERR_NOTACQUIRED;
+ }
+
+ /* update joystick state */
+ This->joy_polldev(IDirectInputDevice8A_from_impl(This));
+
+ /* convert and copy data to user supplied buffer */
+ fill_DataFormat(ptr, len, &This->js, &This->base.data_format);
+
+ return DI_OK;
+}
+
+HRESULT WINAPI JoystickAGenericImpl_GetDeviceState(LPDIRECTINPUTDEVICE8A iface, DWORD len, LPVOID ptr)
+{
+ JoystickGenericImpl *This = impl_from_IDirectInputDevice8A(iface);
+ return JoystickWGenericImpl_GetDeviceState(IDirectInputDevice8W_from_impl(This), len, ptr);
+}
+
+
+HRESULT WINAPI JoystickWGenericImpl_BuildActionMap(LPDIRECTINPUTDEVICE8W iface,
+ LPDIACTIONFORMATW lpdiaf,
+ LPCWSTR lpszUserName,
+ DWORD dwFlags)
+{
+ JoystickGenericImpl *This = impl_from_IDirectInputDevice8W(iface);
+ unsigned int i, j;
+ int has_actions = 0;
+ DWORD object_types[] = { DIDFT_AXIS, DIDFT_BUTTON };
+ DWORD type_map[] = { DIDFT_RELAXIS, DIDFT_PSHBUTTON };
+
+ FIXME("(%p)->(%p,%s,%08x): semi-stub !\n", iface, lpdiaf, debugstr_w(lpszUserName), dwFlags);
+
+ for (i=0; i < lpdiaf->dwNumActions; i++)
+ {
+ DWORD inst = (0x000000ff & (lpdiaf->rgoAction[i].dwSemantic)) - 1;
+ DWORD type = 0x000000ff & (lpdiaf->rgoAction[i].dwSemantic >> 8);
+ DWORD genre = 0xff000000 & lpdiaf->rgoAction[i].dwSemantic;
+
+ /* Don't touch an user configured action */
+ if (lpdiaf->rgoAction[i].dwHow == DIAH_USERCONFIG) continue;
+
+ /* Only consider actions of the right genre */
+ if (lpdiaf->dwGenre != genre && genre != DIGENRE_ANY) continue;
+
+ for (j=0; j < sizeof(object_types)/sizeof(object_types[0]); j++)
+ {
+ if (type & object_types[j])
+ {
+ /* Assure that the object exists */
+ LPDIOBJECTDATAFORMAT odf = dataformat_to_odf_by_type(This->base.data_format.wine_df, inst, object_types[j]);
+
+ if (odf != NULL)
+ {
+ lpdiaf->rgoAction[i].dwObjID = type_map[j] | (0x0000ff00 & (inst << 8));
+ lpdiaf->rgoAction[i].guidInstance = This->base.guid;
+ lpdiaf->rgoAction[i].dwHow = DIAH_DEFAULT;
+
+ has_actions = 1;
+
+ /* No need to try other types if the action was already mapped */
+ break;
+ }
+ }
+ }
+ }
+
+ if (!has_actions) return DI_NOEFFECT;
+
+ return IDirectInputDevice8WImpl_BuildActionMap(iface, lpdiaf, lpszUserName, dwFlags);
+}
+
+HRESULT WINAPI JoystickAGenericImpl_BuildActionMap(LPDIRECTINPUTDEVICE8A iface,
+ LPDIACTIONFORMATA lpdiaf,
+ LPCSTR lpszUserName,
+ DWORD dwFlags)
+{
+ JoystickGenericImpl *This = impl_from_IDirectInputDevice8A(iface);
+ DIACTIONFORMATW diafW;
+ HRESULT hr;
+ WCHAR *lpszUserNameW = NULL;
+ int username_size;
+
+ diafW.rgoAction = HeapAlloc(GetProcessHeap(), 0, sizeof(DIACTIONW)*lpdiaf->dwNumActions);
+ _copy_diactionformatAtoW(&diafW, lpdiaf);
+
+ if (lpszUserName != NULL)
+ {
+ username_size = MultiByteToWideChar(CP_ACP, 0, lpszUserName, -1, NULL, 0);
+ lpszUserNameW = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*username_size);
+ MultiByteToWideChar(CP_ACP, 0, lpszUserName, -1, lpszUserNameW, username_size);
+ }
+
+ hr = JoystickWGenericImpl_BuildActionMap(&This->base.IDirectInputDevice8W_iface, &diafW, lpszUserNameW, dwFlags);
+
+ _copy_diactionformatWtoA(lpdiaf, &diafW);
+ HeapFree(GetProcessHeap(), 0, diafW.rgoAction);
+ HeapFree(GetProcessHeap(), 0, lpszUserNameW);
+
+ return hr;
+}
+
+HRESULT WINAPI JoystickWGenericImpl_SetActionMap(LPDIRECTINPUTDEVICE8W iface,
+ LPDIACTIONFORMATW lpdiaf,
+ LPCWSTR lpszUserName,
+ DWORD dwFlags)
+{
+ JoystickGenericImpl *This = impl_from_IDirectInputDevice8W(iface);
+
+ FIXME("(%p)->(%p,%s,%08x): semi-stub !\n", iface, lpdiaf, debugstr_w(lpszUserName), dwFlags);
+
+ return _set_action_map(iface, lpdiaf, lpszUserName, dwFlags, This->base.data_format.wine_df);
+}
+
+HRESULT WINAPI JoystickAGenericImpl_SetActionMap(LPDIRECTINPUTDEVICE8A iface,
+ LPDIACTIONFORMATA lpdiaf,
+ LPCSTR lpszUserName,
+ DWORD dwFlags)
+{
+ JoystickGenericImpl *This = impl_from_IDirectInputDevice8A(iface);
+ DIACTIONFORMATW diafW;
+ HRESULT hr;
+ WCHAR *lpszUserNameW = NULL;
+ int username_size;
+
+ diafW.rgoAction = HeapAlloc(GetProcessHeap(), 0, sizeof(DIACTIONW)*lpdiaf->dwNumActions);
+ _copy_diactionformatAtoW(&diafW, lpdiaf);
+
+ if (lpszUserName != NULL)
+ {
+ username_size = MultiByteToWideChar(CP_ACP, 0, lpszUserName, -1, NULL, 0);
+ lpszUserNameW = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*username_size);
+ MultiByteToWideChar(CP_ACP, 0, lpszUserName, -1, lpszUserNameW, username_size);
+ }
+
+ hr = JoystickWGenericImpl_SetActionMap(&This->base.IDirectInputDevice8W_iface, &diafW, lpszUserNameW, dwFlags);
+
+ HeapFree(GetProcessHeap(), 0, diafW.rgoAction);
+ HeapFree(GetProcessHeap(), 0, lpszUserNameW);
+
+ return hr;
+}
+
+/*
+ * This maps the read value (from the input event) to a value in the
+ * 'wanted' range.
+ * Notes:
+ * Dead zone is in % multiplied by a 100 (range 0..10000)
+ */
+LONG joystick_map_axis(ObjProps *props, int val)
+{
+ LONG ret;
+ LONG dead_zone = MulDiv( props->lDeadZone, props->lDevMax - props->lDevMin, 10000 );
+ LONG dev_range = props->lDevMax - props->lDevMin - dead_zone;
+
+ /* Center input */
+ val -= (props->lDevMin + props->lDevMax) / 2;
+
+ /* Remove dead zone */
+ if (abs( val ) <= dead_zone / 2)
+ val = 0;
+ else
+ val = val < 0 ? val + dead_zone / 2 : val - dead_zone / 2;
+
+ /* Scale and map the value from the device range into the required range */
+ ret = MulDiv( val, props->lMax - props->lMin, dev_range ) +
+ (props->lMin + props->lMax) / 2;
+
+ /* Clamp in case or rounding errors */
+ if (ret > props->lMax) ret = props->lMax;
+ else if (ret < props->lMin) ret = props->lMin;
+
+ TRACE( "(%d <%d> %d) -> (%d <%d> %d): val=%d ret=%d\n",
+ props->lDevMin, dead_zone, props->lDevMax,
+ props->lMin, props->lDeadZone, props->lMax,
+ val, ret );
+
+ return ret;
+}
+
+/*
+ * Maps POV x & y event values to a DX "clock" position:
+ * 0
+ * 31500 4500
+ * 27000 -1 9000
+ * 22500 13500
+ * 18000
+ */
+DWORD joystick_map_pov(const POINTL *p)
+{
+ if (p->x > 0)
+ return p->y < 0 ? 4500 : !p->y ? 9000 : 13500;
+ else if (p->x < 0)
+ return p->y < 0 ? 31500 : !p->y ? 27000 : 22500;
+ else
+ return p->y < 0 ? 0 : !p->y ? -1 : 18000;
+}
+
+/*
+ * Setup the dinput options.
+ */
+
+HRESULT setup_dinput_options(JoystickGenericImpl *This, const int *default_axis_map)
+{
+ char buffer[MAX_PATH+16];
+ HKEY hkey, appkey;
+ int tokens = 0;
+ int axis = 0;
+ int pov = 0;
+
+ get_app_key(&hkey, &appkey);
+
+ /* get options */
+
+ if (!get_config_key(hkey, appkey, "DefaultDeadZone", buffer, sizeof(buffer)))
+ {
+ This->deadzone = atoi(buffer);
+ TRACE("setting default deadzone to: \"%s\" %d\n", buffer, This->deadzone);
+ }
+
+ This->axis_map = HeapAlloc(GetProcessHeap(), 0, This->device_axis_count * sizeof(int));
+ if (!This->axis_map) return DIERR_OUTOFMEMORY;
+
+ if (!get_config_key(hkey, appkey, This->name, buffer, sizeof(buffer)))
+ {
+ static const char *axis_names[] = {"X", "Y", "Z", "Rx", "Ry", "Rz",
+ "Slider1", "Slider2",
+ "POV1", "POV2", "POV3", "POV4"};
+ const char *delim = ",";
+ char * ptr;
+ TRACE("\"%s\" = \"%s\"\n", This->name, buffer);
+
+ if ((ptr = strtok(buffer, delim)) != NULL)
+ {
+ do
+ {
+ int i;
+
+ for (i = 0; i < sizeof(axis_names) / sizeof(axis_names[0]); i++)
+ {
+ if (!strcmp(ptr, axis_names[i]))
+ {
+ if (!strncmp(ptr, "POV", 3))
+ {
+ if (pov >= 4)
+ {
+ WARN("Only 4 POVs supported - ignoring extra\n");
+ i = -1;
+ }
+ else
+ {
+ /* Pov takes two axes */
+ This->axis_map[tokens++] = i;
+ pov++;
+ }
+ }
+ else
+ {
+ if (axis >= 8)
+ {
+ FIXME("Only 8 Axes supported - ignoring extra\n");
+ i = -1;
+ }
+ else
+ axis++;
+ }
+ break;
+ }
+ }
+
+ if (i == sizeof(axis_names) / sizeof(axis_names[0]))
+ {
+ ERR("invalid joystick axis type: \"%s\"\n", ptr);
+ i = -1;
+ }
+
+ This->axis_map[tokens] = i;
+ tokens++;
+ } while ((ptr = strtok(NULL, delim)) != NULL);
+
+ if (tokens != This->device_axis_count)
+ {
+ ERR("not all joystick axes mapped: %d axes(%d,%d), %d arguments\n",
+ This->device_axis_count, axis, pov, tokens);
+ while (tokens < This->device_axis_count)
+ {
+ This->axis_map[tokens] = -1;
+ tokens++;
+ }
+ }
+ }
+ }
+ else
+ {
+ int i;
+
+ if (default_axis_map)
+ {
+ /* Use default mapping from the driver */
+ for (i = 0; i < This->device_axis_count; i++)
+ {
+ This->axis_map[i] = default_axis_map[i];
+ tokens = default_axis_map[i];
+ if (tokens < 0)
+ continue;
+ if (tokens < 8)
+ axis++;
+ else if (tokens < 15)
+ {
+ i++;
+ pov++;
+ This->axis_map[i] = default_axis_map[i];
+ }
+ }
+ }
+ else
+ {
+ /* No config - set default mapping. */
+ for (i = 0; i < This->device_axis_count; i++)
+ {
+ if (i < 8)
+ This->axis_map[i] = axis++;
+ else if (i < 15)
+ {
+ This->axis_map[i++] = 8 + pov;
+ This->axis_map[i ] = 8 + pov++;
+ }
+ else
+ This->axis_map[i] = -1;
+ }
+ }
+ }
+ This->devcaps.dwAxes = axis;
+ This->devcaps.dwPOVs = pov;
+
+ if (appkey) RegCloseKey(appkey);
+ if (hkey) RegCloseKey(hkey);
+
+ return DI_OK;
+}
# include <sys/ioctl.h>
#endif
//#include <errno.h>
-#ifdef HAVE_SYS_ERRNO_H
-# include <sys/errno.h>
-#endif
#ifdef HAVE_LINUX_IOCTL_H
# include <linux/ioctl.h>
#endif
//#include "windef.h"
//#include "winbase.h"
//#include "winerror.h"
-//#include "winreg.h"
//#include "dinput.h"
//#include "dinput_private.h"
#include "device_private.h"
+//#include "joystick_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(dinput);
#define JOYDEV_NEW "/dev/input/js"
#define JOYDEV_OLD "/dev/js"
+#define JOYDEVDRIVER " (js)"
+
+struct JoyDev
+{
+ char device[MAX_PATH];
+ char name[MAX_PATH];
+
+ BYTE axis_count;
+ BYTE button_count;
+ int *dev_axes_map;
+};
typedef struct JoystickImpl JoystickImpl;
static const IDirectInputDevice8AVtbl JoystickAvt;
static const IDirectInputDevice8WVtbl JoystickWvt;
struct JoystickImpl
{
- struct IDirectInputDevice2AImpl base;
+ struct JoystickGenericImpl generic;
- char dev[32];
+ struct JoyDev *joydev;
/* joystick private */
int joyfd;
- DIJOYSTATE2 js; /* wine data */
- ObjProps *props;
- char *name;
- DIDEVCAPS devcaps;
- LONG deadzone;
- int *axis_map;
- int axes;
POINTL povs[4];
};
+static inline JoystickImpl *impl_from_IDirectInputDevice8A(IDirectInputDevice8A *iface)
+{
+ return CONTAINING_RECORD(CONTAINING_RECORD(CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8A_iface),
+ JoystickGenericImpl, base), JoystickImpl, generic);
+}
+static inline JoystickImpl *impl_from_IDirectInputDevice8W(IDirectInputDevice8W *iface)
+{
+ return CONTAINING_RECORD(CONTAINING_RECORD(CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8W_iface),
+ JoystickGenericImpl, base), JoystickImpl, generic);
+}
+static inline IDirectInputDevice8A *IDirectInputDevice8A_from_impl(JoystickImpl *This)
+{
+ return &This->generic.base.IDirectInputDevice8A_iface;
+}
+static inline IDirectInputDevice8W *IDirectInputDevice8W_from_impl(JoystickImpl *This)
+{
+ return &This->generic.base.IDirectInputDevice8W_iface;
+}
+
static const GUID DInput_Wine_Joystick_GUID = { /* 9e573ed9-7734-11d2-8d4a-23903fb6bdf7 */
0x9e573ed9,
0x7734,
{0x8d, 0x4a, 0x23, 0x90, 0x3f, 0xb6, 0xbd, 0xf7}
};
-static void _dump_DIDEVCAPS(const DIDEVCAPS *lpDIDevCaps)
-{
- TRACE("dwSize: %d\n", lpDIDevCaps->dwSize);
- TRACE("dwFlags: %08x\n", lpDIDevCaps->dwFlags);
- TRACE("dwDevType: %08x %s\n", lpDIDevCaps->dwDevType,
- lpDIDevCaps->dwDevType == DIDEVTYPE_DEVICE ? "DIDEVTYPE_DEVICE" :
- lpDIDevCaps->dwDevType == DIDEVTYPE_DEVICE ? "DIDEVTYPE_DEVICE" :
- lpDIDevCaps->dwDevType == DIDEVTYPE_MOUSE ? "DIDEVTYPE_MOUSE" :
- lpDIDevCaps->dwDevType == DIDEVTYPE_KEYBOARD ? "DIDEVTYPE_KEYBOARD" :
- lpDIDevCaps->dwDevType == DIDEVTYPE_JOYSTICK ? "DIDEVTYPE_JOYSTICK" :
- lpDIDevCaps->dwDevType == DIDEVTYPE_HID ? "DIDEVTYPE_HID" : "UNKNOWN");
- TRACE("dwAxes: %d\n", lpDIDevCaps->dwAxes);
- TRACE("dwButtons: %d\n", lpDIDevCaps->dwButtons);
- TRACE("dwPOVs: %d\n", lpDIDevCaps->dwPOVs);
- if (lpDIDevCaps->dwSize > sizeof(DIDEVCAPS_DX3)) {
- TRACE("dwFFSamplePeriod: %d\n", lpDIDevCaps->dwFFSamplePeriod);
- TRACE("dwFFMinTimeResolution: %d\n", lpDIDevCaps->dwFFMinTimeResolution);
- TRACE("dwFirmwareRevision: %d\n", lpDIDevCaps->dwFirmwareRevision);
- TRACE("dwHardwareRevision: %d\n", lpDIDevCaps->dwHardwareRevision);
- TRACE("dwFFDriverVersion: %d\n", lpDIDevCaps->dwFFDriverVersion);
- }
-}
-
#define MAX_JOYSTICKS 64
static INT joystick_devices_count = -1;
-static LPSTR joystick_devices[MAX_JOYSTICKS];
+static struct JoyDev *joystick_devices;
+
+static void joy_polldev(LPDIRECTINPUTDEVICE8A iface);
static INT find_joystick_devices(void)
{
joystick_devices_count = 0;
for (i = 0; i < MAX_JOYSTICKS; i++)
{
- CHAR device_name[MAX_PATH], *str;
- INT len;
int fd;
+ struct JoyDev joydev, *new_joydevs;
+ BYTE axes_map[ABS_MAX + 1];
+
+ snprintf(joydev.device, sizeof(joydev.device), "%s%d", JOYDEV_NEW, i);
+ if ((fd = open(joydev.device, O_RDONLY)) < 0)
+ {
+ snprintf(joydev.device, sizeof(joydev.device), "%s%d", JOYDEV_OLD, i);
+ if ((fd = open(joydev.device, O_RDONLY)) < 0) continue;
+ }
+
+ strcpy(joydev.name, "Wine Joystick");
+#if defined(JSIOCGNAME)
+ if (ioctl(fd, JSIOCGNAME(sizeof(joydev.name) - sizeof(JOYDEVDRIVER)), joydev.name) < 0)
+ WARN("ioctl(%s,JSIOCGNAME) failed: %s\n", joydev.device, strerror(errno));
+#endif
+
+ /* Append driver name */
+ strcat(joydev.name, JOYDEVDRIVER);
- len = sprintf(device_name, "%s%d", JOYDEV_NEW, i) + 1;
- if ((fd = open(device_name, O_RDONLY)) < 0)
+ if (device_disabled_registry(joydev.name)) {
+ close(fd);
+ continue;
+ }
+
+#ifdef JSIOCGAXES
+ if (ioctl(fd, JSIOCGAXES, &joydev.axis_count) < 0)
{
- len = sprintf(device_name, "%s%d", JOYDEV_OLD, i) + 1;
- if ((fd = open(device_name, O_RDONLY)) < 0) continue;
+ WARN("ioctl(%s,JSIOCGAXES) failed: %s, defauting to 2\n", joydev.device, strerror(errno));
+ joydev.axis_count = 2;
}
+#endif
+#ifdef JSIOCGBUTTONS
+ if (ioctl(fd, JSIOCGBUTTONS, &joydev.button_count) < 0)
+ {
+ WARN("ioctl(%s,JSIOCGBUTTONS) failed: %s, defauting to 2\n", joydev.device, strerror(errno));
+ joydev.button_count = 2;
+ }
+#endif
+
+ if (ioctl(fd, JSIOCGAXMAP, axes_map) < 0)
+ {
+ WARN("ioctl(%s,JSIOCGNAME) failed: %s\n", joydev.device, strerror(errno));
+ joydev.dev_axes_map = NULL;
+ }
+ else
+ if ((joydev.dev_axes_map = HeapAlloc(GetProcessHeap(), 0, joydev.axis_count * sizeof(int))))
+ {
+ INT j;
+
+ /* Remap to DI numbers */
+ for (j = 0; j < joydev.axis_count; j++)
+ if (axes_map[j] < 8)
+ /* Axis match 1-to-1 */
+ joydev.dev_axes_map[j] = j;
+ else if (axes_map[j] == 16 ||
+ axes_map[j] == 17)
+ /* POV axis */
+ joydev.dev_axes_map[j] = 8;
+ else
+ joydev.dev_axes_map[j] = -1;
+ }
close(fd);
- if (!(str = HeapAlloc(GetProcessHeap(), 0, len))) break;
- memcpy(str, device_name, len);
+ if (!joystick_devices_count)
+ new_joydevs = HeapAlloc(GetProcessHeap(), 0, sizeof(struct JoyDev));
+ else
+ new_joydevs = HeapReAlloc(GetProcessHeap(), 0, joystick_devices,
+ (joystick_devices_count + 1) * sizeof(struct JoyDev));
+ if (!new_joydevs) continue;
+
+ TRACE("Found a joystick on %s: %s\n with %d axes and %d buttons\n", joydev.device,
+ joydev.name, joydev.axis_count, joydev.button_count);
- joystick_devices[joystick_devices_count++] = str;
+ joystick_devices = new_joydevs;
+ joystick_devices[joystick_devices_count++] = joydev;
}
return joystick_devices_count;
((dwDevType == DIDEVTYPE_JOYSTICK) && (version > 0x0300 && version < 0x0800)) ||
(((dwDevType == DI8DEVCLASS_GAMECTRL) || (dwDevType == DI8DEVTYPE_JOYSTICK)) && (version >= 0x0800))) {
/* check whether we have a joystick */
- if ((fd = open(joystick_devices[id], O_RDONLY)) < 0)
+ if ((fd = open(joystick_devices[id].device, O_RDONLY)) < 0)
{
- WARN("open(%s, O_RDONLY) failed: %s\n", joystick_devices[id], strerror(errno));
+ WARN("open(%s, O_RDONLY) failed: %s\n", joystick_devices[id].name, strerror(errno));
return FALSE;
}
lpddi->dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8);
else
lpddi->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
- sprintf(lpddi->tszInstanceName, "Joystick %d", id);
-#if defined(JSIOCGNAME)
- if (ioctl(fd,JSIOCGNAME(sizeof(lpddi->tszProductName)),lpddi->tszProductName) < 0) {
- WARN("ioctl(%s,JSIOCGNAME) failed: %s\n", joystick_devices[id], strerror(errno));
- strcpy(lpddi->tszProductName, "Wine Joystick");
- }
-#else
- strcpy(lpddi->tszProductName, "Wine Joystick");
-#endif
+
+ strcpy(lpddi->tszInstanceName, joystick_devices[id].name);
+ strcpy(lpddi->tszProductName, joystick_devices[id].name);
lpddi->guidFFDriver = GUID_NULL;
close(fd);
- TRACE("Enumerating the linux Joystick device: %s (%s)\n", joystick_devices[id], lpddi->tszProductName);
+ TRACE("Enumerating the linux Joystick device: %s (%s)\n", joystick_devices[id].device, lpddi->tszProductName);
return TRUE;
}
static BOOL joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, DWORD version, int id)
{
int fd = -1;
- char name[MAX_PATH];
- char friendly[32];
if (id >= find_joystick_devices()) return FALSE;
((dwDevType == DIDEVTYPE_JOYSTICK) && (version > 0x0300 && version < 0x0800)) ||
(((dwDevType == DI8DEVCLASS_GAMECTRL) || (dwDevType == DI8DEVTYPE_JOYSTICK)) && (version >= 0x0800))) {
/* check whether we have a joystick */
- if ((fd = open(joystick_devices[id], O_RDONLY)) < 0)
+ if ((fd = open(joystick_devices[id].device, O_RDONLY)) < 0)
{
- WARN("open(%s,O_RDONLY) failed: %s\n", joystick_devices[id], strerror(errno));
+ WARN("open(%s,O_RDONLY) failed: %s\n", joystick_devices[id].device, strerror(errno));
return FALSE;
}
lpddi->dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8);
else
lpddi->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
- sprintf(friendly, "Joystick %d", id);
- MultiByteToWideChar(CP_ACP, 0, friendly, -1, lpddi->tszInstanceName, MAX_PATH);
-#if defined(JSIOCGNAME)
- if (ioctl(fd,JSIOCGNAME(sizeof(name)),name) < 0) {
- WARN("ioctl(%s, JSIOCGNAME) failed: %s\n", joystick_devices[id], strerror(errno));
- strcpy(name, "Wine Joystick");
- }
-#else
- strcpy(name, "Wine Joystick");
-#endif
- MultiByteToWideChar(CP_ACP, 0, name, -1, lpddi->tszProductName, MAX_PATH);
+
+ 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);
- TRACE("Enumerating the linux Joystick device: %s (%s)\n", joystick_devices[id], name);
+ TRACE("Enumerating the linux Joystick device: %s (%s)\n", joystick_devices[id].device, joystick_devices[id].name);
return TRUE;
}
return FALSE;
}
-/*
- * Setup the dinput options.
- */
-
-static HRESULT setup_dinput_options(JoystickImpl * device)
-{
- char buffer[MAX_PATH+16];
- HKEY hkey, appkey;
- int tokens = 0;
- int axis = 0;
- int pov = 0;
-
- buffer[MAX_PATH]='\0';
-
- get_app_key(&hkey, &appkey);
-
- /* get options */
-
- if (!get_config_key( hkey, appkey, "DefaultDeadZone", buffer, MAX_PATH )) {
- device->deadzone = atoi(buffer);
- TRACE("setting default deadzone to: \"%s\" %d\n", buffer, device->deadzone);
- }
-
- device->axis_map = HeapAlloc(GetProcessHeap(), 0, device->axes * sizeof(int));
- if (!device->axis_map) return DIERR_OUTOFMEMORY;
-
- if (!get_config_key( hkey, appkey, device->name, buffer, MAX_PATH )) {
- static const char *axis_names[] = {"X", "Y", "Z", "Rx", "Ry", "Rz",
- "Slider1", "Slider2",
- "POV1", "POV2", "POV3", "POV4"};
- const char *delim = ",";
- char * ptr;
- TRACE("\"%s\" = \"%s\"\n", device->name, buffer);
-
- if ((ptr = strtok(buffer, delim)) != NULL) {
- do {
- int i;
-
- for (i = 0; i < sizeof(axis_names) / sizeof(axis_names[0]); i++)
- if (!strcmp(ptr, axis_names[i]))
- {
- if (!strncmp(ptr, "POV", 3))
- {
- if (pov >= 4)
- {
- WARN("Only 4 POVs supported - ignoring extra\n");
- i = -1;
- }
- else
- {
- /* Pov takes two axes */
- device->axis_map[tokens++] = i;
- pov++;
- }
- }
- else
- {
- if (axis >= 8)
- {
- FIXME("Only 8 Axes supported - ignoring extra\n");
- i = -1;
- }
- else
- axis++;
- }
- break;
- }
-
- if (i == sizeof(axis_names) / sizeof(axis_names[0]))
- {
- ERR("invalid joystick axis type: \"%s\"\n", ptr);
- i = -1;
- }
-
- device->axis_map[tokens] = i;
- tokens++;
- } while ((ptr = strtok(NULL, delim)) != NULL);
-
- if (tokens != device->axes) {
- ERR("not all joystick axes mapped: %d axes(%d,%d), %d arguments\n", device->axes, axis, pov,tokens);
- while (tokens < device->axes) {
- device->axis_map[tokens] = -1;
- tokens++;
- }
- }
- }
- }
- else
- {
- for (tokens = 0; tokens < device->axes; tokens++)
- {
- if (tokens < 8)
- device->axis_map[tokens] = axis++;
- else if (tokens < 16)
- {
- device->axis_map[tokens++] = 8 + pov;
- device->axis_map[tokens ] = 8 + pov++;
- }
- else
- device->axis_map[tokens] = -1;
- }
- }
- device->devcaps.dwAxes = axis;
- device->devcaps.dwPOVs = pov;
-
- if (appkey)
- RegCloseKey( appkey );
-
- if (hkey)
- RegCloseKey( hkey );
-
- return DI_OK;
-}
-
-static HRESULT alloc_device(REFGUID rguid, const void *jvt, IDirectInputImpl *dinput,
- LPDIRECTINPUTDEVICEA* pdev, unsigned short index)
+static HRESULT alloc_device(REFGUID rguid, IDirectInputImpl *dinput,
+ JoystickImpl **pdev, unsigned short index)
{
DWORD i;
JoystickImpl* newDevice;
- char name[MAX_PATH];
HRESULT hr;
LPDIDATAFORMAT df = NULL;
int idx = 0;
- TRACE("%s %p %p %p %hu\n", debugstr_guid(rguid), jvt, dinput, pdev, index);
+ TRACE("%s %p %p %hu\n", debugstr_guid(rguid), dinput, pdev, index);
newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(JoystickImpl));
if (newDevice == 0) {
return DIERR_OUTOFMEMORY;
}
- if (!lstrcpynA(newDevice->dev, joystick_devices[index], sizeof(newDevice->dev)) ||
- (newDevice->joyfd = open(newDevice->dev, O_RDONLY)) < 0)
- {
- WARN("open(%s, O_RDONLY) failed: %s\n", newDevice->dev, strerror(errno));
- HeapFree(GetProcessHeap(), 0, newDevice);
- return DIERR_DEVICENOTREG;
- }
+ newDevice->joydev = &joystick_devices[index];
+ newDevice->joyfd = -1;
+ newDevice->generic.guidInstance = DInput_Wine_Joystick_GUID;
+ newDevice->generic.guidInstance.Data3 = index;
+ newDevice->generic.guidProduct = DInput_Wine_Joystick_GUID;
+ newDevice->generic.joy_polldev = joy_polldev;
+ newDevice->generic.name = newDevice->joydev->name;
+ newDevice->generic.device_axis_count = newDevice->joydev->axis_count;
+ newDevice->generic.devcaps.dwButtons = newDevice->joydev->button_count;
- /* get the device name */
-#if defined(JSIOCGNAME)
- if (ioctl(newDevice->joyfd,JSIOCGNAME(MAX_PATH),name) < 0) {
- WARN("ioctl(%s,JSIOCGNAME) failed: %s\n", newDevice->dev, strerror(errno));
- strcpy(name, "Wine Joystick");
- }
-#else
- strcpy(name, "Wine Joystick");
-#endif
-
- /* copy the device name */
- newDevice->name = HeapAlloc(GetProcessHeap(),0,strlen(name) + 1);
- strcpy(newDevice->name, name);
-
-#ifdef JSIOCGAXES
- if (ioctl(newDevice->joyfd,JSIOCGAXES,&newDevice->axes) < 0) {
- WARN("ioctl(%s,JSIOCGAXES) failed: %s, defauting to 2\n", newDevice->dev, strerror(errno));
- newDevice->axes = 2;
- }
-#endif
-#ifdef JSIOCGBUTTONS
- if (ioctl(newDevice->joyfd, JSIOCGBUTTONS, &newDevice->devcaps.dwButtons) < 0) {
- WARN("ioctl(%s,JSIOCGBUTTONS) failed: %s, defauting to 2\n", newDevice->dev, strerror(errno));
- newDevice->devcaps.dwButtons = 2;
- }
-#endif
-
- if (newDevice->devcaps.dwButtons > 128)
+ if (newDevice->generic.devcaps.dwButtons > 128)
{
- WARN("Can't support %d buttons. Clamping down to 128\n", newDevice->devcaps.dwButtons);
- newDevice->devcaps.dwButtons = 128;
+ WARN("Can't support %d buttons. Clamping down to 128\n", newDevice->generic.devcaps.dwButtons);
+ newDevice->generic.devcaps.dwButtons = 128;
}
- newDevice->base.lpVtbl = jvt;
- newDevice->base.ref = 1;
- newDevice->base.dinput = dinput;
- newDevice->base.guid = *rguid;
- InitializeCriticalSection(&newDevice->base.crit);
- newDevice->base.crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": JoystickImpl*->base.crit");
+ newDevice->generic.base.IDirectInputDevice8A_iface.lpVtbl = &JoystickAvt;
+ newDevice->generic.base.IDirectInputDevice8W_iface.lpVtbl = &JoystickWvt;
+ newDevice->generic.base.ref = 1;
+ newDevice->generic.base.dinput = dinput;
+ newDevice->generic.base.guid = *rguid;
+ InitializeCriticalSection(&newDevice->generic.base.crit);
+ newDevice->generic.base.crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": JoystickImpl*->generic.base.crit");
/* setup_dinput_options may change these */
- newDevice->deadzone = 0;
+ newDevice->generic.deadzone = 0;
/* do any user specified configuration */
- hr = setup_dinput_options(newDevice);
+ hr = setup_dinput_options(&newDevice->generic, newDevice->joydev->dev_axes_map);
if (hr != DI_OK)
goto FAILED1;
if (!(df = HeapAlloc(GetProcessHeap(), 0, c_dfDIJoystick2.dwSize))) goto FAILED;
memcpy(df, &c_dfDIJoystick2, c_dfDIJoystick2.dwSize);
- df->dwNumObjs = newDevice->devcaps.dwAxes + newDevice->devcaps.dwPOVs + newDevice->devcaps.dwButtons;
+ df->dwNumObjs = newDevice->generic.devcaps.dwAxes + newDevice->generic.devcaps.dwPOVs + newDevice->generic.devcaps.dwButtons;
if (!(df->rgodf = HeapAlloc(GetProcessHeap(), 0, df->dwNumObjs * df->dwObjSize))) goto FAILED;
- for (i = 0; i < newDevice->axes; i++)
+ for (i = 0; i < newDevice->generic.device_axis_count; i++)
{
- int wine_obj = newDevice->axis_map[i];
+ int wine_obj = newDevice->generic.axis_map[i];
if (wine_obj < 0) continue;
i++; /* POV takes 2 axes */
}
}
- for (i = 0; i < newDevice->devcaps.dwButtons; i++)
+ for (i = 0; i < newDevice->generic.devcaps.dwButtons; i++)
{
memcpy(&df->rgodf[idx], &c_dfDIJoystick2.rgodf[i + 12], df->dwObjSize);
df->rgodf[idx ].pguid = &GUID_Button;
df->rgodf[idx++].dwType = DIDFT_MAKEINSTANCE(i) | DIDFT_PSHBUTTON;
}
- newDevice->base.data_format.wine_df = df;
-
- /* create default properties */
- newDevice->props = HeapAlloc(GetProcessHeap(),0,c_dfDIJoystick2.dwNumObjs*sizeof(ObjProps));
- if (newDevice->props == 0)
- goto FAILED;
+ newDevice->generic.base.data_format.wine_df = df;
/* initialize default properties */
for (i = 0; i < c_dfDIJoystick2.dwNumObjs; i++) {
- newDevice->props[i].lDevMin = -32767;
- newDevice->props[i].lDevMax = +32767;
- newDevice->props[i].lMin = 0;
- newDevice->props[i].lMax = 0xffff;
- newDevice->props[i].lDeadZone = newDevice->deadzone; /* % * 1000 */
- newDevice->props[i].lSaturation = 0;
+ newDevice->generic.props[i].lDevMin = -32767;
+ newDevice->generic.props[i].lDevMax = +32767;
+ newDevice->generic.props[i].lMin = 0;
+ newDevice->generic.props[i].lMax = 0xffff;
+ newDevice->generic.props[i].lDeadZone = newDevice->generic.deadzone; /* % * 1000 */
+ newDevice->generic.props[i].lSaturation = 0;
}
- IDirectInput_AddRef((LPDIRECTINPUTDEVICE8A)newDevice->base.dinput);
+ IDirectInput_AddRef(&newDevice->generic.base.dinput->IDirectInput7A_iface);
- newDevice->devcaps.dwSize = sizeof(newDevice->devcaps);
- newDevice->devcaps.dwFlags = DIDC_ATTACHED;
- if (newDevice->base.dinput->dwVersion >= 0x0800)
- newDevice->devcaps.dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8);
+ EnterCriticalSection(&dinput->crit);
+ list_add_tail(&dinput->devices_list, &newDevice->generic.base.entry);
+ LeaveCriticalSection(&dinput->crit);
+
+ newDevice->generic.devcaps.dwSize = sizeof(newDevice->generic.devcaps);
+ newDevice->generic.devcaps.dwFlags = DIDC_ATTACHED;
+ if (newDevice->generic.base.dinput->dwVersion >= 0x0800)
+ newDevice->generic.devcaps.dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8);
else
- newDevice->devcaps.dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
- newDevice->devcaps.dwFFSamplePeriod = 0;
- newDevice->devcaps.dwFFMinTimeResolution = 0;
- newDevice->devcaps.dwFirmwareRevision = 0;
- newDevice->devcaps.dwHardwareRevision = 0;
- newDevice->devcaps.dwFFDriverVersion = 0;
+ newDevice->generic.devcaps.dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
+ newDevice->generic.devcaps.dwFFSamplePeriod = 0;
+ newDevice->generic.devcaps.dwFFMinTimeResolution = 0;
+ newDevice->generic.devcaps.dwFirmwareRevision = 0;
+ newDevice->generic.devcaps.dwHardwareRevision = 0;
+ newDevice->generic.devcaps.dwFFDriverVersion = 0;
if (TRACE_ON(dinput)) {
- _dump_DIDATAFORMAT(newDevice->base.data_format.wine_df);
- for (i = 0; i < (newDevice->axes); i++)
- TRACE("axis_map[%d] = %d\n", i, newDevice->axis_map[i]);
- _dump_DIDEVCAPS(&newDevice->devcaps);
+ _dump_DIDATAFORMAT(newDevice->generic.base.data_format.wine_df);
+ for (i = 0; i < (newDevice->generic.device_axis_count); i++)
+ TRACE("axis_map[%d] = %d\n", i, newDevice->generic.axis_map[i]);
+ _dump_DIDEVCAPS(&newDevice->generic.devcaps);
}
- *pdev = (LPDIRECTINPUTDEVICEA)newDevice;
+ *pdev = newDevice;
return DI_OK;
FAILED1:
if (df) HeapFree(GetProcessHeap(), 0, df->rgodf);
HeapFree(GetProcessHeap(), 0, df);
- release_DataFormat(&newDevice->base.data_format);
- HeapFree(GetProcessHeap(),0,newDevice->axis_map);
- HeapFree(GetProcessHeap(),0,newDevice->name);
- HeapFree(GetProcessHeap(),0,newDevice->props);
+ release_DataFormat(&newDevice->generic.base.data_format);
+ HeapFree(GetProcessHeap(),0,newDevice->generic.axis_map);
HeapFree(GetProcessHeap(),0,newDevice);
*pdev = 0;
return MAX_JOYSTICKS;
}
-static HRESULT joydev_create_deviceA(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEA* pdev)
+static HRESULT joydev_create_device(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPVOID *pdev, int unicode)
{
unsigned short index;
- TRACE("%p %s %p %p\n",dinput, debugstr_guid(rguid), riid, pdev);
+ TRACE("%p %s %s %p %i\n", dinput, debugstr_guid(rguid), debugstr_guid(riid), pdev, unicode);
find_joystick_devices();
*pdev = NULL;
if ((index = get_joystick_index(rguid)) < MAX_JOYSTICKS &&
joystick_devices_count && index < joystick_devices_count)
{
- if ((riid == NULL) ||
- IsEqualGUID(&IID_IDirectInputDeviceA, riid) ||
- IsEqualGUID(&IID_IDirectInputDevice2A, riid) ||
- IsEqualGUID(&IID_IDirectInputDevice7A, riid) ||
- IsEqualGUID(&IID_IDirectInputDevice8A, riid))
+ JoystickImpl *This;
+ HRESULT hr;
+
+ if (riid == NULL)
+ ;/* nothing */
+ else if (IsEqualGUID(&IID_IDirectInputDeviceA, riid) ||
+ IsEqualGUID(&IID_IDirectInputDevice2A, riid) ||
+ IsEqualGUID(&IID_IDirectInputDevice7A, riid) ||
+ IsEqualGUID(&IID_IDirectInputDevice8A, riid))
{
- return alloc_device(rguid, &JoystickAvt, dinput, pdev, index);
+ unicode = 0;
+ }
+ else if (IsEqualGUID(&IID_IDirectInputDeviceW, riid) ||
+ IsEqualGUID(&IID_IDirectInputDevice2W, riid) ||
+ IsEqualGUID(&IID_IDirectInputDevice7W, riid) ||
+ IsEqualGUID(&IID_IDirectInputDevice8W, riid))
+ {
+ unicode = 1;
+ }
+ else
+ {
+ WARN("no interface\n");
+ return DIERR_NOINTERFACE;
}
- WARN("no interface\n");
- return DIERR_NOINTERFACE;
- }
-
- return DIERR_DEVICENOTREG;
-}
-
-static HRESULT joydev_create_deviceW(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEW* pdev)
-{
- unsigned short index;
+ hr = alloc_device(rguid, dinput, &This, index);
+ if (!This) return hr;
- TRACE("%p %s %p %p\n",dinput, debugstr_guid(rguid), riid, pdev);
- find_joystick_devices();
- *pdev = NULL;
+ if (unicode)
+ *pdev = &This->generic.base.IDirectInputDevice8W_iface;
+ else
+ *pdev = &This->generic.base.IDirectInputDevice8A_iface;
- if ((index = get_joystick_index(rguid)) < MAX_JOYSTICKS &&
- joystick_devices_count && index < joystick_devices_count)
- {
- if ((riid == NULL) ||
- IsEqualGUID(&IID_IDirectInputDeviceW, riid) ||
- IsEqualGUID(&IID_IDirectInputDevice2W, riid) ||
- IsEqualGUID(&IID_IDirectInputDevice7W, riid) ||
- IsEqualGUID(&IID_IDirectInputDevice8W, riid))
- {
- return alloc_device(rguid, &JoystickWvt, dinput, (LPDIRECTINPUTDEVICEA *)pdev, index);
- }
- WARN("no interface\n");
- return DIERR_NOINTERFACE;
+ return hr;
}
- WARN("invalid device GUID %s\n",debugstr_guid(rguid));
return DIERR_DEVICENOTREG;
}
"Wine Linux joystick driver",
joydev_enum_deviceA,
joydev_enum_deviceW,
- joydev_create_deviceA,
- joydev_create_deviceW
+ joydev_create_device
};
/******************************************************************************
* Acquire : gets exclusive control of the joystick
*/
-static HRESULT WINAPI JoystickAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface)
+static HRESULT WINAPI JoystickLinuxWImpl_Acquire(LPDIRECTINPUTDEVICE8W iface)
{
- JoystickImpl *This = (JoystickImpl *)iface;
+ JoystickImpl *This = impl_from_IDirectInputDevice8W(iface);
+ HRESULT res;
TRACE("(%p)\n",This);
- if (This->base.acquired) {
- WARN("already acquired\n");
- return S_FALSE;
- }
+ res = IDirectInputDevice2WImpl_Acquire(iface);
+ if (res != DI_OK)
+ return res;
/* open the joystick device */
if (This->joyfd==-1) {
- TRACE("opening joystick device %s\n", This->dev);
+ TRACE("opening joystick device %s\n", This->joydev->device);
- This->joyfd=open(This->dev,O_RDONLY);
+ This->joyfd = open(This->joydev->device, O_RDONLY);
if (This->joyfd==-1) {
- ERR("open(%s) failed: %s\n", This->dev, strerror(errno));
+ ERR("open(%s) failed: %s\n", This->joydev->device, strerror(errno));
+ IDirectInputDevice2WImpl_Unacquire(iface);
return DIERR_NOTFOUND;
}
}
- This->base.acquired = 1;
+ return DI_OK;
+}
+
+static HRESULT WINAPI JoystickLinuxAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface)
+{
+ JoystickImpl *This = impl_from_IDirectInputDevice8A(iface);
+ return JoystickLinuxWImpl_Acquire(IDirectInputDevice8W_from_impl(This));
+}
+
+/******************************************************************************
+ * GetProperty : get input device properties
+ */
+static HRESULT WINAPI JoystickLinuxWImpl_GetProperty(LPDIRECTINPUTDEVICE8W iface, REFGUID rguid, LPDIPROPHEADER pdiph)
+{
+ JoystickImpl *This = impl_from_IDirectInputDevice8W(iface);
+
+ TRACE("(this=%p,%s,%p)\n", iface, debugstr_guid(rguid), pdiph);
+ _dump_DIPROPHEADER(pdiph);
+
+ if (!IS_DIPROP(rguid)) return DI_OK;
+
+ switch (LOWORD(rguid)) {
+
+ case (DWORD_PTR) DIPROP_JOYSTICKID:
+ {
+ LPDIPROPDWORD pd = (LPDIPROPDWORD)pdiph;
+
+ pd->dwData = get_joystick_index(&This->generic.base.guid);
+ TRACE("DIPROP_JOYSTICKID(%d)\n", pd->dwData);
+ break;
+ }
+
+ default:
+ return JoystickWGenericImpl_GetProperty(iface, rguid, pdiph);
+ }
return DI_OK;
}
+static HRESULT WINAPI JoystickLinuxAImpl_GetProperty(LPDIRECTINPUTDEVICE8A iface, REFGUID rguid, LPDIPROPHEADER pdiph)
+{
+ JoystickImpl *This = impl_from_IDirectInputDevice8A(iface);
+ return JoystickLinuxWImpl_GetProperty(IDirectInputDevice8W_from_impl(This), rguid, pdiph);
+}
+
/******************************************************************************
* Unacquire : frees the joystick
*/
-static HRESULT WINAPI JoystickAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface)
+static HRESULT WINAPI JoystickLinuxWImpl_Unacquire(LPDIRECTINPUTDEVICE8W iface)
{
- JoystickImpl *This = (JoystickImpl *)iface;
+ JoystickImpl *This = impl_from_IDirectInputDevice8W(iface);
HRESULT res;
TRACE("(%p)\n",This);
- if ((res = IDirectInputDevice2AImpl_Unacquire(iface)) != DI_OK) return res;
+ res = IDirectInputDevice2WImpl_Unacquire(iface);
+
+ if (res != DI_OK)
+ return res;
if (This->joyfd!=-1) {
TRACE("closing joystick device\n");
return DI_NOEFFECT;
}
-static void joy_polldev(JoystickImpl *This) {
+static HRESULT WINAPI JoystickLinuxAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface)
+{
+ JoystickImpl *This = impl_from_IDirectInputDevice8A(iface);
+ return JoystickLinuxWImpl_Unacquire(IDirectInputDevice8W_from_impl(This));
+}
+
+static void joy_polldev(LPDIRECTINPUTDEVICE8A iface)
+{
struct pollfd plfd;
- struct js_event jse;
+ struct js_event jse;
+ JoystickImpl *This = impl_from_IDirectInputDevice8A(iface);
+
TRACE("(%p)\n", This);
if (This->joyfd==-1) {
jse.type,jse.number,jse.value);
if (jse.type & JS_EVENT_BUTTON)
{
- if (jse.number >= This->devcaps.dwButtons) return;
+ if (jse.number >= This->generic.devcaps.dwButtons) return;
inst_id = DIDFT_MAKEINSTANCE(jse.number) | DIDFT_PSHBUTTON;
- This->js.rgbButtons[jse.number] = value = jse.value ? 0x80 : 0x00;
+ This->generic.js.rgbButtons[jse.number] = value = jse.value ? 0x80 : 0x00;
}
else if (jse.type & JS_EVENT_AXIS)
{
- int number = This->axis_map[jse.number]; /* wine format object index */
+ int number = This->generic.axis_map[jse.number]; /* wine format object index */
if (number < 0) return;
- inst_id = DIDFT_MAKEINSTANCE(number) | (number < 8 ? DIDFT_ABSAXIS : DIDFT_POV);
- value = joystick_map_axis(&This->props[id_to_object(This->base.data_format.wine_df, inst_id)], jse.value);
+ inst_id = number < 8 ? DIDFT_MAKEINSTANCE(number) | DIDFT_ABSAXIS :
+ DIDFT_MAKEINSTANCE(number - 8) | DIDFT_POV;
+ value = joystick_map_axis(&This->generic.props[id_to_object(This->generic.base.data_format.wine_df, inst_id)], jse.value);
TRACE("changing axis %d => %d\n", jse.number, number);
switch (number)
{
- case 0: This->js.lX = value; break;
- case 1: This->js.lY = value; break;
- case 2: This->js.lZ = value; break;
- case 3: This->js.lRx = value; break;
- case 4: This->js.lRy = value; break;
- case 5: This->js.lRz = value; break;
- case 6: This->js.rglSlider[0] = value; break;
- case 7: This->js.rglSlider[1] = value; break;
+ case 0: This->generic.js.lX = value; break;
+ case 1: This->generic.js.lY = value; break;
+ case 2: This->generic.js.lZ = value; break;
+ case 3: This->generic.js.lRx = value; break;
+ case 4: This->generic.js.lRy = value; break;
+ case 5: This->generic.js.lRz = value; break;
+ case 6: This->generic.js.rglSlider[0] = value; break;
+ case 7: This->generic.js.rglSlider[1] = value; break;
case 8: case 9: case 10: case 11:
{
int idx = number - 8;
else
This->povs[idx].x = jse.value;
- This->js.rgdwPOV[idx] = value = joystick_map_pov(&This->povs[idx]);
+ This->generic.js.rgdwPOV[idx] = value = joystick_map_pov(&This->povs[idx]);
break;
}
default:
}
}
if (inst_id >= 0)
- queue_event((LPDIRECTINPUTDEVICE8A)This,
- id_to_offset(&This->base.data_format, inst_id),
- value, jse.time, This->base.dinput->evsequence++);
- }
-}
-
-/******************************************************************************
- * GetDeviceState : returns the "state" of the joystick.
- *
- */
-static HRESULT WINAPI JoystickAImpl_GetDeviceState(
- LPDIRECTINPUTDEVICE8A iface,
- DWORD len,
- LPVOID ptr)
-{
- JoystickImpl *This = (JoystickImpl *)iface;
-
- TRACE("(%p,0x%08x,%p)\n", This, len, ptr);
-
- if (!This->base.acquired) {
- WARN("not acquired\n");
- return DIERR_NOTACQUIRED;
+ queue_event(iface, inst_id,
+ value, jse.time, This->generic.base.dinput->evsequence++);
}
-
- /* update joystick state */
- joy_polldev(This);
-
- /* convert and copy data to user supplied buffer */
- fill_DataFormat(ptr, len, &This->js, &This->base.data_format);
-
- return DI_OK;
-}
-
-/******************************************************************************
- * SetProperty : change input device properties
- */
-static HRESULT WINAPI JoystickAImpl_SetProperty(
- LPDIRECTINPUTDEVICE8A iface,
- REFGUID rguid,
- LPCDIPROPHEADER ph)
-{
- JoystickImpl *This = (JoystickImpl *)iface;
- DWORD i;
-
- TRACE("(%p,%s,%p)\n",This,debugstr_guid(rguid),ph);
-
- if (ph == NULL) {
- WARN("invalid parameter: ph == NULL\n");
- return DIERR_INVALIDPARAM;
- }
-
- if (TRACE_ON(dinput))
- _dump_DIPROPHEADER(ph);
-
- if (!HIWORD(rguid)) {
- switch (LOWORD(rguid)) {
- case (DWORD_PTR)DIPROP_RANGE: {
- LPCDIPROPRANGE pr = (LPCDIPROPRANGE)ph;
- if (ph->dwHow == DIPH_DEVICE) {
- TRACE("proprange(%d,%d) all\n", pr->lMin, pr->lMax);
- for (i = 0; i < This->base.data_format.wine_df->dwNumObjs; i++) {
- This->props[i].lMin = pr->lMin;
- This->props[i].lMax = pr->lMax;
- }
- } else {
- int obj = find_property(&This->base.data_format, ph);
-
- TRACE("proprange(%d,%d) obj=%d\n", pr->lMin, pr->lMax, obj);
- if (obj >= 0) {
- This->props[obj].lMin = pr->lMin;
- This->props[obj].lMax = pr->lMax;
- return DI_OK;
- }
- }
- break;
- }
- case (DWORD_PTR)DIPROP_DEADZONE: {
- LPCDIPROPDWORD pd = (LPCDIPROPDWORD)ph;
- if (ph->dwHow == DIPH_DEVICE) {
- TRACE("deadzone(%d) all\n", pd->dwData);
- for (i = 0; i < This->base.data_format.wine_df->dwNumObjs; i++)
- This->props[i].lDeadZone = pd->dwData;
- } else {
- int obj = find_property(&This->base.data_format, ph);
-
- TRACE("deadzone(%d) obj=%d\n", pd->dwData, obj);
- if (obj >= 0) {
- This->props[obj].lDeadZone = pd->dwData;
- return DI_OK;
- }
- }
- break;
- }
- case (DWORD_PTR)DIPROP_SATURATION: {
- LPCDIPROPDWORD pd = (LPCDIPROPDWORD)ph;
- if (ph->dwHow == DIPH_DEVICE) {
- TRACE("saturation(%d) all\n", pd->dwData);
- for (i = 0; i < This->base.data_format.wine_df->dwNumObjs; i++)
- This->props[i].lSaturation = pd->dwData;
- } else {
- int obj = find_property(&This->base.data_format, ph);
-
- TRACE("saturation(%d) obj=%d\n", pd->dwData, obj);
- if (obj >= 0) {
- This->props[obj].lSaturation = pd->dwData;
- return DI_OK;
- }
- }
- break;
- }
- default:
- return IDirectInputDevice2AImpl_SetProperty(iface, rguid, ph);
- }
- }
-
- return DI_OK;
-}
-
-static HRESULT WINAPI JoystickAImpl_GetCapabilities(
- LPDIRECTINPUTDEVICE8A iface,
- LPDIDEVCAPS lpDIDevCaps)
-{
- JoystickImpl *This = (JoystickImpl *)iface;
- int size;
-
- TRACE("%p->(%p)\n",iface,lpDIDevCaps);
-
- if (lpDIDevCaps == NULL) {
- WARN("invalid pointer\n");
- return E_POINTER;
- }
-
- size = lpDIDevCaps->dwSize;
-
- if (!(size == sizeof(DIDEVCAPS) || size == sizeof(DIDEVCAPS_DX3))) {
- WARN("invalid parameter\n");
- return DIERR_INVALIDPARAM;
- }
-
- CopyMemory(lpDIDevCaps, &This->devcaps, size);
- lpDIDevCaps->dwSize = size;
-
- if (TRACE_ON(dinput))
- _dump_DIDEVCAPS(lpDIDevCaps);
-
- return DI_OK;
-}
-
-static HRESULT WINAPI JoystickAImpl_Poll(LPDIRECTINPUTDEVICE8A iface)
-{
- JoystickImpl *This = (JoystickImpl *)iface;
-
- TRACE("(%p)\n",This);
-
- if (!This->base.acquired) {
- WARN("not acquired\n");
- return DIERR_NOTACQUIRED;
- }
-
- joy_polldev(This);
- return DI_OK;
-}
-
-/******************************************************************************
- * GetProperty : get input device properties
- */
-static HRESULT WINAPI JoystickAImpl_GetProperty(
- LPDIRECTINPUTDEVICE8A iface,
- REFGUID rguid,
- LPDIPROPHEADER pdiph)
-{
- JoystickImpl *This = (JoystickImpl *)iface;
-
- TRACE("(%p,%s,%p)\n", iface, debugstr_guid(rguid), pdiph);
-
- if (TRACE_ON(dinput))
- _dump_DIPROPHEADER(pdiph);
-
- if (!HIWORD(rguid)) {
- switch (LOWORD(rguid)) {
- case (DWORD_PTR) DIPROP_RANGE: {
- LPDIPROPRANGE pr = (LPDIPROPRANGE)pdiph;
- int obj = find_property(&This->base.data_format, pdiph);
-
- /* The app is querying the current range of the axis
- * return the lMin and lMax values */
- if (obj >= 0) {
- pr->lMin = This->props[obj].lMin;
- pr->lMax = This->props[obj].lMax;
- TRACE("range(%d, %d) obj=%d\n", pr->lMin, pr->lMax, obj);
- return DI_OK;
- }
- break;
- }
- case (DWORD_PTR) DIPROP_DEADZONE: {
- LPDIPROPDWORD pd = (LPDIPROPDWORD)pdiph;
- int obj = find_property(&This->base.data_format, pdiph);
-
- if (obj >= 0) {
- pd->dwData = This->props[obj].lDeadZone;
- TRACE("deadzone(%d) obj=%d\n", pd->dwData, obj);
- return DI_OK;
- }
- break;
- }
- case (DWORD_PTR) DIPROP_SATURATION: {
- LPDIPROPDWORD pd = (LPDIPROPDWORD)pdiph;
- int obj = find_property(&This->base.data_format, pdiph);
-
- if (obj >= 0) {
- pd->dwData = This->props[obj].lSaturation;
- TRACE("saturation(%d) obj=%d\n", pd->dwData, obj);
- return DI_OK;
- }
- break;
- }
- default:
- return IDirectInputDevice2AImpl_GetProperty(iface, rguid, pdiph);
- }
- }
-
- return DI_OK;
-}
-
-/******************************************************************************
- * GetObjectInfo : get object info
- */
-static HRESULT WINAPI JoystickWImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface,
- LPDIDEVICEOBJECTINSTANCEW pdidoi, DWORD dwObj, DWORD dwHow)
-{
- static const WCHAR axisW[] = {'A','x','i','s',' ','%','d',0};
- static const WCHAR povW[] = {'P','O','V',' ','%','d',0};
- static const WCHAR buttonW[] = {'B','u','t','t','o','n',' ','%','d',0};
- HRESULT res;
-
- res = IDirectInputDevice2WImpl_GetObjectInfo(iface, pdidoi, dwObj, dwHow);
- if (res != DI_OK) return res;
-
- if (pdidoi->dwType & DIDFT_AXIS)
- sprintfW(pdidoi->tszName, axisW, DIDFT_GETINSTANCE(pdidoi->dwType));
- else if (pdidoi->dwType & DIDFT_POV)
- sprintfW(pdidoi->tszName, povW, DIDFT_GETINSTANCE(pdidoi->dwType));
- else if (pdidoi->dwType & DIDFT_BUTTON)
- sprintfW(pdidoi->tszName, buttonW, DIDFT_GETINSTANCE(pdidoi->dwType));
-
- _dump_OBJECTINSTANCEW(pdidoi);
- return res;
-}
-
-static HRESULT WINAPI JoystickAImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8A iface,
- LPDIDEVICEOBJECTINSTANCEA pdidoi, DWORD dwObj, DWORD dwHow)
-{
- HRESULT res;
- DIDEVICEOBJECTINSTANCEW didoiW;
- DWORD dwSize = pdidoi->dwSize;
-
- didoiW.dwSize = sizeof(didoiW);
- res = JoystickWImpl_GetObjectInfo((LPDIRECTINPUTDEVICE8W)iface, &didoiW, dwObj, dwHow);
- if (res != DI_OK) return res;
-
- memset(pdidoi, 0, pdidoi->dwSize);
- memcpy(pdidoi, &didoiW, FIELD_OFFSET(DIDEVICEOBJECTINSTANCEW, tszName));
- pdidoi->dwSize = dwSize;
- WideCharToMultiByte(CP_ACP, 0, didoiW.tszName, -1, pdidoi->tszName,
- sizeof(pdidoi->tszName), NULL, NULL);
-
- return res;
-}
-
-/******************************************************************************
- * GetDeviceInfo : get information about a device's identity
- */
-static HRESULT WINAPI JoystickAImpl_GetDeviceInfo(
- LPDIRECTINPUTDEVICE8A iface,
- LPDIDEVICEINSTANCEA pdidi)
-{
- JoystickImpl *This = (JoystickImpl *)iface;
-
- TRACE("(%p,%p)\n", iface, pdidi);
-
- if (pdidi == NULL) {
- WARN("invalid pointer\n");
- return E_POINTER;
- }
-
- if ((pdidi->dwSize != sizeof(DIDEVICEINSTANCE_DX3A)) &&
- (pdidi->dwSize != sizeof(DIDEVICEINSTANCEA))) {
- WARN("invalid parameter: pdidi->dwSize = %d\n", pdidi->dwSize);
- return DIERR_INVALIDPARAM;
- }
-
- /* Return joystick */
- pdidi->guidInstance = GUID_Joystick;
- pdidi->guidProduct = DInput_Wine_Joystick_GUID;
- /* we only support traditional joysticks for now */
- pdidi->dwDevType = This->devcaps.dwDevType;
- strcpy(pdidi->tszInstanceName, "Joystick");
- strcpy(pdidi->tszProductName, This->name);
- if (pdidi->dwSize > sizeof(DIDEVICEINSTANCE_DX3A)) {
- pdidi->guidFFDriver = GUID_NULL;
- pdidi->wUsagePage = 0;
- pdidi->wUsage = 0;
- }
-
- return DI_OK;
-}
-
-/******************************************************************************
- * GetDeviceInfo : get information about a device's identity
- */
-static HRESULT WINAPI JoystickWImpl_GetDeviceInfo(
- LPDIRECTINPUTDEVICE8W iface,
- LPDIDEVICEINSTANCEW pdidi)
-{
- JoystickImpl *This = (JoystickImpl *)iface;
-
- TRACE("(%p,%p)\n", iface, pdidi);
-
- if ((pdidi->dwSize != sizeof(DIDEVICEINSTANCE_DX3W)) &&
- (pdidi->dwSize != sizeof(DIDEVICEINSTANCEW))) {
- WARN("invalid parameter: pdidi->dwSize = %d\n", pdidi->dwSize);
- return DIERR_INVALIDPARAM;
- }
-
- /* Return joystick */
- pdidi->guidInstance = GUID_Joystick;
- pdidi->guidProduct = DInput_Wine_Joystick_GUID;
- /* we only support traditional joysticks for now */
- pdidi->dwDevType = This->devcaps.dwDevType;
- MultiByteToWideChar(CP_ACP, 0, "Joystick", -1, pdidi->tszInstanceName, MAX_PATH);
- MultiByteToWideChar(CP_ACP, 0, This->name, -1, pdidi->tszProductName, MAX_PATH);
- if (pdidi->dwSize > sizeof(DIDEVICEINSTANCE_DX3W)) {
- pdidi->guidFFDriver = GUID_NULL;
- pdidi->wUsagePage = 0;
- pdidi->wUsage = 0;
- }
-
- return DI_OK;
}
static const IDirectInputDevice8AVtbl JoystickAvt =
IDirectInputDevice2AImpl_QueryInterface,
IDirectInputDevice2AImpl_AddRef,
IDirectInputDevice2AImpl_Release,
- JoystickAImpl_GetCapabilities,
+ JoystickAGenericImpl_GetCapabilities,
IDirectInputDevice2AImpl_EnumObjects,
- JoystickAImpl_GetProperty,
- JoystickAImpl_SetProperty,
- JoystickAImpl_Acquire,
- JoystickAImpl_Unacquire,
- JoystickAImpl_GetDeviceState,
+ JoystickLinuxAImpl_GetProperty,
+ JoystickAGenericImpl_SetProperty,
+ JoystickLinuxAImpl_Acquire,
+ JoystickLinuxAImpl_Unacquire,
+ JoystickAGenericImpl_GetDeviceState,
IDirectInputDevice2AImpl_GetDeviceData,
IDirectInputDevice2AImpl_SetDataFormat,
IDirectInputDevice2AImpl_SetEventNotification,
IDirectInputDevice2AImpl_SetCooperativeLevel,
- JoystickAImpl_GetObjectInfo,
- JoystickAImpl_GetDeviceInfo,
+ JoystickAGenericImpl_GetObjectInfo,
+ JoystickAGenericImpl_GetDeviceInfo,
IDirectInputDevice2AImpl_RunControlPanel,
IDirectInputDevice2AImpl_Initialize,
IDirectInputDevice2AImpl_CreateEffect,
IDirectInputDevice2AImpl_SendForceFeedbackCommand,
IDirectInputDevice2AImpl_EnumCreatedEffectObjects,
IDirectInputDevice2AImpl_Escape,
- JoystickAImpl_Poll,
+ JoystickAGenericImpl_Poll,
IDirectInputDevice2AImpl_SendDeviceData,
IDirectInputDevice7AImpl_EnumEffectsInFile,
IDirectInputDevice7AImpl_WriteEffectToFile,
- IDirectInputDevice8AImpl_BuildActionMap,
- IDirectInputDevice8AImpl_SetActionMap,
+ JoystickAGenericImpl_BuildActionMap,
+ JoystickAGenericImpl_SetActionMap,
IDirectInputDevice8AImpl_GetImageInfo
};
-#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
-# define XCAST(fun) (typeof(JoystickWvt.fun))
-#else
-# define XCAST(fun) (void*)
-#endif
-
static const IDirectInputDevice8WVtbl JoystickWvt =
{
- IDirectInputDevice2WImpl_QueryInterface,
- XCAST(AddRef)IDirectInputDevice2AImpl_AddRef,
- XCAST(Release)IDirectInputDevice2AImpl_Release,
- XCAST(GetCapabilities)JoystickAImpl_GetCapabilities,
- IDirectInputDevice2WImpl_EnumObjects,
- XCAST(GetProperty)JoystickAImpl_GetProperty,
- XCAST(SetProperty)JoystickAImpl_SetProperty,
- XCAST(Acquire)JoystickAImpl_Acquire,
- XCAST(Unacquire)JoystickAImpl_Unacquire,
- XCAST(GetDeviceState)JoystickAImpl_GetDeviceState,
- XCAST(GetDeviceData)IDirectInputDevice2AImpl_GetDeviceData,
- XCAST(SetDataFormat)IDirectInputDevice2AImpl_SetDataFormat,
- XCAST(SetEventNotification)IDirectInputDevice2AImpl_SetEventNotification,
- XCAST(SetCooperativeLevel)IDirectInputDevice2AImpl_SetCooperativeLevel,
- JoystickWImpl_GetObjectInfo,
- JoystickWImpl_GetDeviceInfo,
- XCAST(RunControlPanel)IDirectInputDevice2AImpl_RunControlPanel,
- XCAST(Initialize)IDirectInputDevice2AImpl_Initialize,
- XCAST(CreateEffect)IDirectInputDevice2AImpl_CreateEffect,
- IDirectInputDevice2WImpl_EnumEffects,
- IDirectInputDevice2WImpl_GetEffectInfo,
- XCAST(GetForceFeedbackState)IDirectInputDevice2AImpl_GetForceFeedbackState,
- XCAST(SendForceFeedbackCommand)IDirectInputDevice2AImpl_SendForceFeedbackCommand,
- XCAST(EnumCreatedEffectObjects)IDirectInputDevice2AImpl_EnumCreatedEffectObjects,
- XCAST(Escape)IDirectInputDevice2AImpl_Escape,
- XCAST(Poll)JoystickAImpl_Poll,
- XCAST(SendDeviceData)IDirectInputDevice2AImpl_SendDeviceData,
- IDirectInputDevice7WImpl_EnumEffectsInFile,
- IDirectInputDevice7WImpl_WriteEffectToFile,
- IDirectInputDevice8WImpl_BuildActionMap,
- IDirectInputDevice8WImpl_SetActionMap,
- IDirectInputDevice8WImpl_GetImageInfo
+ IDirectInputDevice2WImpl_QueryInterface,
+ IDirectInputDevice2WImpl_AddRef,
+ IDirectInputDevice2WImpl_Release,
+ JoystickWGenericImpl_GetCapabilities,
+ IDirectInputDevice2WImpl_EnumObjects,
+ JoystickLinuxWImpl_GetProperty,
+ JoystickWGenericImpl_SetProperty,
+ JoystickLinuxWImpl_Acquire,
+ JoystickLinuxWImpl_Unacquire,
+ JoystickWGenericImpl_GetDeviceState,
+ IDirectInputDevice2WImpl_GetDeviceData,
+ IDirectInputDevice2WImpl_SetDataFormat,
+ IDirectInputDevice2WImpl_SetEventNotification,
+ IDirectInputDevice2WImpl_SetCooperativeLevel,
+ JoystickWGenericImpl_GetObjectInfo,
+ JoystickWGenericImpl_GetDeviceInfo,
+ IDirectInputDevice2WImpl_RunControlPanel,
+ IDirectInputDevice2WImpl_Initialize,
+ IDirectInputDevice2WImpl_CreateEffect,
+ IDirectInputDevice2WImpl_EnumEffects,
+ IDirectInputDevice2WImpl_GetEffectInfo,
+ IDirectInputDevice2WImpl_GetForceFeedbackState,
+ IDirectInputDevice2WImpl_SendForceFeedbackCommand,
+ IDirectInputDevice2WImpl_EnumCreatedEffectObjects,
+ IDirectInputDevice2WImpl_Escape,
+ JoystickWGenericImpl_Poll,
+ IDirectInputDevice2WImpl_SendDeviceData,
+ IDirectInputDevice7WImpl_EnumEffectsInFile,
+ IDirectInputDevice7WImpl_WriteEffectToFile,
+ JoystickWGenericImpl_BuildActionMap,
+ JoystickWGenericImpl_SetActionMap,
+ IDirectInputDevice8WImpl_GetImageInfo
};
-#undef XCAST
#else /* HAVE_LINUX_22_JOYSTICK_API */
"Wine Linux joystick driver",
NULL,
NULL,
- NULL,
NULL
};
# include <sys/ioctl.h>
#endif
#include <errno.h>
-#ifdef HAVE_SYS_ERRNO_H
-# include <sys/errno.h>
-#endif
#ifdef HAVE_LINUX_INPUT_H
# include <linux/input.h>
# undef SW_MAX
//#include "dinput_private.h"
#include "device_private.h"
+//#include "joystick_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(dinput);
-
-/*
- * Maps POV x & y event values to a DX "clock" position:
- * 0
- * 31500 4500
- * 27000 -1 9000
- * 22500 13500
- * 18000
- */
-DWORD joystick_map_pov(POINTL *p)
-{
- if (p->x > 0)
- return p->y < 0 ? 4500 : !p->y ? 9000 : 13500;
- else if (p->x < 0)
- return p->y < 0 ? 31500 : !p->y ? 27000 : 22500;
- else
- return p->y < 0 ? 0 : !p->y ? -1 : 18000;
-}
-
-/*
- * This maps the read value (from the input event) to a value in the
- * 'wanted' range.
- * Notes:
- * Dead zone is in % multiplied by a 100 (range 0..10000)
- */
-LONG joystick_map_axis(ObjProps *props, int val)
-{
- LONG ret;
- LONG dead_zone = MulDiv( props->lDeadZone, props->lDevMax - props->lDevMin, 10000 );
- LONG dev_range = props->lDevMax - props->lDevMin - dead_zone;
-
- /* Center input */
- val -= (props->lDevMin + props->lDevMax) / 2;
-
- /* Remove dead zone */
- if (abs( val ) <= dead_zone / 2)
- val = 0;
- else
- val = val < 0 ? val + dead_zone / 2 : val - dead_zone / 2;
-
- /* Scale and map the value from the device range into the required range */
- ret = MulDiv( val, props->lMax - props->lMin, dev_range ) +
- (props->lMin + props->lMax) / 2;
-
- /* Clamp in case or rounding errors */
- if (ret > props->lMax) ret = props->lMax;
- else if (ret < props->lMin) ret = props->lMin;
-
- TRACE( "(%d <%d> %d) -> (%d <%d> %d): val=%d ret=%d\n",
- props->lDevMin, dead_zone, props->lDevMax,
- props->lMin, props->lDeadZone, props->lMax,
- val, ret );
-
- return ret;
-}
-
#ifdef HAVE_CORRECT_LINUXINPUT_H
-#define EVDEVPREFIX "/dev/input/event"
+#define EVDEVPREFIX "/dev/input/event"
+#define EVDEVDRIVER " (event)"
/* Wine joystick driver object instances */
#define WINE_JOYSTICK_MAX_AXES 8
/* data returned by the EVIOCGABS() ioctl */
struct wine_input_absinfo axes[ABS_MAX];
+
+ WORD vendor_id, product_id;
};
struct JoystickImpl
{
- struct IDirectInputDevice2AImpl base;
-
+ struct JoystickGenericImpl generic;
struct JoyDev *joydev;
/* joystick private */
int joyfd;
- DIJOYSTATE2 js;
-
- ObjProps props[ABS_MAX];
-
- int axes[ABS_MAX];
+ int dev_axes_to_di[ABS_MAX];
POINTL povs[4];
/* LUT for KEY_ to offset in rgbButtons */
BYTE buttons[KEY_MAX];
- DWORD numAxes;
- DWORD numPOVs;
- DWORD numButtons;
-
/* Force feedback variables */
struct list ff_effects;
int ff_state;
int ff_gain;
};
+static inline JoystickImpl *impl_from_IDirectInputDevice8A(IDirectInputDevice8A *iface)
+{
+ return CONTAINING_RECORD(CONTAINING_RECORD(CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8A_iface),
+ JoystickGenericImpl, base), JoystickImpl, generic);
+}
+static inline JoystickImpl *impl_from_IDirectInputDevice8W(IDirectInputDevice8W *iface)
+{
+ return CONTAINING_RECORD(CONTAINING_RECORD(CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8W_iface),
+ JoystickGenericImpl, base), JoystickImpl, generic);
+}
+static inline IDirectInputDevice8A *IDirectInputDevice8A_from_impl(JoystickImpl *This)
+{
+ return &This->generic.base.IDirectInputDevice8A_iface;
+}
+static inline IDirectInputDevice8W *IDirectInputDevice8W_from_impl(JoystickImpl *This)
+{
+ return &This->generic.base.IDirectInputDevice8W_iface;
+}
+
static void fake_current_js_state(JoystickImpl *ji);
static void find_joydevs(void);
+static void joy_polldev(LPDIRECTINPUTDEVICE8A iface);
/* This GUID is slightly different from the linux joystick one. Take note. */
static const GUID DInput_Wine_Joystick_Base_GUID = { /* 9e573eda-7734-11d2-8d4a-23903fb6bdf7 */
int no_ff_check = 0;
int j;
struct JoyDev *new_joydevs;
+ struct input_id device_id = {0};
snprintf(buf, sizeof(buf), EVDEVPREFIX"%d", i);
buf[MAX_PATH - 1] = 0;
if (ioctl(fd, EVIOCGNAME(MAX_PATH - 1), buf) != -1 &&
- (joydev.name = HeapAlloc(GetProcessHeap(), 0, strlen(buf) + 1)))
+ (joydev.name = HeapAlloc(GetProcessHeap(), 0, strlen(buf) + strlen(EVDEVDRIVER) + 1)))
+ {
strcpy(joydev.name, buf);
+ /* Append driver name */
+ strcat(joydev.name, EVDEVDRIVER);
+ }
else
joydev.name = joydev.device;
- joydev.guid = DInput_Wine_Joystick_Base_GUID;
- joydev.guid.Data3 += have_joydevs;
+ if (device_disabled_registry(joydev.name)) {
+ close(fd);
+ HeapFree(GetProcessHeap(), 0, joydev.name);
+ if (joydev.name != joydev.device)
+ HeapFree(GetProcessHeap(), 0, joydev.device);
+ continue;
+ }
+
+ joydev.guid = DInput_Wine_Joystick_Base_GUID;
+ joydev.guid.Data3 += have_joydevs;
- TRACE("Found a joystick on %s: %s (%s)\n",
+ TRACE("Found a joystick on %s: %s (%s)\n",
joydev.device, joydev.name,
debugstr_guid(&joydev.guid)
);
}
}
+ if (ioctl(fd, EVIOCGID, &device_id) == -1)
+ WARN("ioct(EVIOCGBIT, EV_ABS) failed: %d %s\n", errno, strerror(errno));
+ else
+ {
+ joydev.vendor_id = device_id.vendor;
+ joydev.product_id = device_id.product;
+ }
+
if (!have_joydevs)
new_joydevs = HeapAlloc(GetProcessHeap(), 0, sizeof(struct JoyDev));
else
continue;
}
joydevs = new_joydevs;
- memcpy(joydevs + have_joydevs, &joydev, sizeof(joydev));
+ joydevs[have_joydevs] = joydev;
have_joydevs++;
close(fd);
lpddi->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
strcpy(lpddi->tszInstanceName, joydevs[id].name);
- strcpy(lpddi->tszProductName, joydevs[id].device);
+ strcpy(lpddi->tszProductName, joydevs[id].name);
}
static void fill_joystick_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, DWORD version, int id)
lpddi->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
MultiByteToWideChar(CP_ACP, 0, joydevs[id].name, -1, lpddi->tszInstanceName, MAX_PATH);
- MultiByteToWideChar(CP_ACP, 0, joydevs[id].device, -1, lpddi->tszProductName, MAX_PATH);
+ MultiByteToWideChar(CP_ACP, 0, joydevs[id].name, -1, lpddi->tszProductName, MAX_PATH);
}
static BOOL joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, DWORD version, int id)
return FALSE;
}
-static JoystickImpl *alloc_device(REFGUID rguid, const void *jvt, IDirectInputImpl *dinput, unsigned short index)
+static JoystickImpl *alloc_device(REFGUID rguid, IDirectInputImpl *dinput, unsigned short index)
{
JoystickImpl* newDevice;
LPDIDATAFORMAT df = NULL;
int i, idx = 0;
- char buffer[MAX_PATH+16];
- HKEY hkey, appkey;
- LONG def_deadzone = 0;
+ int default_axis_map[WINE_JOYSTICK_MAX_AXES + WINE_JOYSTICK_MAX_POVS*2];
newDevice = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(JoystickImpl));
if (!newDevice) return NULL;
- newDevice->base.lpVtbl = jvt;
- newDevice->base.ref = 1;
- newDevice->base.guid = *rguid;
- newDevice->base.dinput = dinput;
+ newDevice->generic.base.IDirectInputDevice8A_iface.lpVtbl = &JoystickAvt;
+ newDevice->generic.base.IDirectInputDevice8W_iface.lpVtbl = &JoystickWvt;
+ newDevice->generic.base.ref = 1;
+ newDevice->generic.base.guid = *rguid;
+ newDevice->generic.base.dinput = dinput;
+ newDevice->generic.joy_polldev = joy_polldev;
newDevice->joyfd = -1;
newDevice->joydev = &joydevs[index];
+ newDevice->generic.name = newDevice->joydev->name;
list_init(&newDevice->ff_effects);
#ifdef HAVE_STRUCT_FF_EFFECT_DIRECTION
newDevice->ff_state = FF_STATUS_STOPPED;
#endif
/* There is no way in linux to query force feedback autocenter status.
- Instead, track it with ff_autocenter, and assume it's initialy
+ Instead, track it with ff_autocenter, and assume it's initially
enabled. */
newDevice->ff_autocenter = 1;
newDevice->ff_gain = 0xFFFF;
- InitializeCriticalSection(&newDevice->base.crit);
- newDevice->base.crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": JoystickImpl*->base.crit");
+ InitializeCriticalSection(&newDevice->generic.base.crit);
+ newDevice->generic.base.crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": JoystickImpl*->base.crit");
- /* get options */
- get_app_key(&hkey, &appkey);
+ /* Count number of available axes - supported Axis & POVs */
+ for (i = 0; i < WINE_JOYSTICK_MAX_AXES; i++)
+ {
+ if (test_bit(newDevice->joydev->absbits, i))
+ {
+ newDevice->generic.device_axis_count++;
+ newDevice->dev_axes_to_di[i] = idx;
+ newDevice->generic.props[idx].lDevMin = newDevice->joydev->axes[i].minimum;
+ newDevice->generic.props[idx].lDevMax = newDevice->joydev->axes[i].maximum;
+ default_axis_map[idx] = i;
+ idx++;
+ }
+ else
+ newDevice->dev_axes_to_di[i] = -1;
+ }
- if (!get_config_key(hkey, appkey, "DefaultDeadZone", buffer, MAX_PATH))
+ for (i = 0; i < WINE_JOYSTICK_MAX_POVS; i++)
{
- def_deadzone = atoi(buffer);
- TRACE("setting default deadzone to: %d\n", def_deadzone);
+ if (test_bit(newDevice->joydev->absbits, ABS_HAT0X + i * 2) &&
+ test_bit(newDevice->joydev->absbits, ABS_HAT0Y + i * 2))
+ {
+ newDevice->generic.device_axis_count += 2;
+ newDevice->generic.props[idx ].lDevMin = newDevice->joydev->axes[ABS_HAT0X + i * 2].minimum;
+ newDevice->generic.props[idx ].lDevMax = newDevice->joydev->axes[ABS_HAT0X + i * 2].maximum;
+ newDevice->dev_axes_to_di[ABS_HAT0X + i * 2] = idx;
+ newDevice->generic.props[idx+1].lDevMin = newDevice->joydev->axes[ABS_HAT0Y + i * 2].minimum;
+ newDevice->generic.props[idx+1].lDevMax = newDevice->joydev->axes[ABS_HAT0Y + i * 2].maximum;
+ newDevice->dev_axes_to_di[ABS_HAT0Y + i * 2] = idx + 1;
+
+ default_axis_map[idx] = default_axis_map[idx + 1] = WINE_JOYSTICK_MAX_AXES + i;
+ idx += 2;
+ }
+ else
+ newDevice->dev_axes_to_di[ABS_HAT0X + i * 2] = newDevice->dev_axes_to_di[ABS_HAT0Y + i * 2] = -1;
}
- if (appkey) RegCloseKey(appkey);
- if (hkey) RegCloseKey(hkey);
+
+ /* do any user specified configuration */
+ if (setup_dinput_options(&newDevice->generic, default_axis_map) != DI_OK) goto failed;
/* Create copy of default data format */
if (!(df = HeapAlloc(GetProcessHeap(), 0, c_dfDIJoystick2.dwSize))) goto failed;
memcpy(df, &c_dfDIJoystick2, c_dfDIJoystick2.dwSize);
if (!(df->rgodf = HeapAlloc(GetProcessHeap(), 0, df->dwNumObjs * df->dwObjSize))) goto failed;
- /* Supported Axis & POVs should map 1-to-1 */
- for (i = 0; i < WINE_JOYSTICK_MAX_AXES; i++)
+
+ /* Construct internal data format */
+
+ /* Supported Axis & POVs */
+ for (i = 0, idx = 0; i < newDevice->generic.device_axis_count; i++)
{
- if (!test_bit(newDevice->joydev->absbits, i)) {
- newDevice->axes[i] = -1;
- continue;
+ int wine_obj = newDevice->generic.axis_map[i];
+
+ if (wine_obj < 0) continue;
+
+ memcpy(&df->rgodf[idx], &c_dfDIJoystick2.rgodf[wine_obj], df->dwObjSize);
+ if (wine_obj < 8)
+ df->rgodf[idx].dwType = DIDFT_MAKEINSTANCE(wine_obj) | DIDFT_ABSAXIS;
+ else
+ {
+ df->rgodf[idx].dwType = DIDFT_MAKEINSTANCE(wine_obj - 8) | DIDFT_POV;
+ i++; /* POV takes 2 axes */
}
- memcpy(&df->rgodf[idx], &c_dfDIJoystick2.rgodf[i], df->dwObjSize);
- newDevice->axes[i] = idx;
- newDevice->props[idx].lDevMin = newDevice->joydev->axes[i].minimum;
- newDevice->props[idx].lDevMax = newDevice->joydev->axes[i].maximum;
- newDevice->props[idx].lMin = 0;
- newDevice->props[idx].lMax = 0xffff;
- newDevice->props[idx].lSaturation = 0;
- newDevice->props[idx].lDeadZone = def_deadzone;
+ newDevice->generic.props[idx].lMin = 0;
+ newDevice->generic.props[idx].lMax = 0xffff;
+ newDevice->generic.props[idx].lSaturation = 0;
+ newDevice->generic.props[idx].lDeadZone = newDevice->generic.deadzone;
/* Linux supports force-feedback on X & Y axes only */
if (newDevice->joydev->has_ff && (i == 0 || i == 1))
df->rgodf[idx].dwFlags |= DIDOI_FFACTUATOR;
- df->rgodf[idx++].dwType = DIDFT_MAKEINSTANCE(newDevice->numAxes++) | DIDFT_ABSAXIS;
- }
-
- for (i = 0; i < WINE_JOYSTICK_MAX_POVS; i++)
- {
- if (!test_bit(newDevice->joydev->absbits, ABS_HAT0X + i * 2) ||
- !test_bit(newDevice->joydev->absbits, ABS_HAT0Y + i * 2)) {
- newDevice->axes[ABS_HAT0X + i * 2] = newDevice->axes[ABS_HAT0Y + i * 2] = -1;
- continue;
- }
-
- memcpy(&df->rgodf[idx], &c_dfDIJoystick2.rgodf[i + WINE_JOYSTICK_MAX_AXES], df->dwObjSize);
- newDevice->axes[ABS_HAT0X + i * 2] = newDevice->axes[ABS_HAT0Y + i * 2] = i;
- df->rgodf[idx++].dwType = DIDFT_MAKEINSTANCE(newDevice->numPOVs++) | DIDFT_POV;
+ idx++;
}
/* Buttons can be anywhere, so check all */
- for (i = 0; i < KEY_MAX && newDevice->numButtons < WINE_JOYSTICK_MAX_BUTTONS; i++)
+ for (i = 0; i < KEY_MAX && newDevice->generic.devcaps.dwButtons < WINE_JOYSTICK_MAX_BUTTONS; i++)
{
if (!test_bit(newDevice->joydev->keybits, i)) continue;
- memcpy(&df->rgodf[idx], &c_dfDIJoystick2.rgodf[newDevice->numButtons + WINE_JOYSTICK_MAX_AXES + WINE_JOYSTICK_MAX_POVS], df->dwObjSize);
- newDevice->buttons[i] = 0x80 | newDevice->numButtons;
+ memcpy(&df->rgodf[idx], &c_dfDIJoystick2.rgodf[newDevice->generic.devcaps.dwButtons + 12], df->dwObjSize);
+ newDevice->buttons[i] = 0x80 | newDevice->generic.devcaps.dwButtons;
df->rgodf[idx ].pguid = &GUID_Button;
- df->rgodf[idx++].dwType = DIDFT_MAKEINSTANCE(newDevice->numButtons++) | DIDFT_PSHBUTTON;
+ df->rgodf[idx++].dwType = DIDFT_MAKEINSTANCE(newDevice->generic.devcaps.dwButtons++) | DIDFT_PSHBUTTON;
}
df->dwNumObjs = idx;
+ newDevice->generic.base.data_format.wine_df = df;
fake_current_js_state(newDevice);
- newDevice->base.data_format.wine_df = df;
- IDirectInput_AddRef((LPDIRECTINPUTDEVICE8A)newDevice->base.dinput);
+ /* Fill the caps */
+ newDevice->generic.devcaps.dwSize = sizeof(newDevice->generic.devcaps);
+ newDevice->generic.devcaps.dwFlags = DIDC_ATTACHED;
+ if (newDevice->generic.base.dinput->dwVersion >= 0x0800)
+ newDevice->generic.devcaps.dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8);
+ else
+ newDevice->generic.devcaps.dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
+
+ if (newDevice->joydev->has_ff)
+ newDevice->generic.devcaps.dwFlags |= DIDC_FORCEFEEDBACK;
+
+ IDirectInput_AddRef(&newDevice->generic.base.dinput->IDirectInput7A_iface);
+
+ EnterCriticalSection(&dinput->crit);
+ list_add_tail(&dinput->devices_list, &newDevice->generic.base.entry);
+ LeaveCriticalSection(&dinput->crit);
+
return newDevice;
failed:
if (df) HeapFree(GetProcessHeap(), 0, df->rgodf);
HeapFree(GetProcessHeap(), 0, df);
+ HeapFree(GetProcessHeap(), 0, newDevice->generic.axis_map);
HeapFree(GetProcessHeap(), 0, newDevice);
return NULL;
}
return MAX_JOYDEV;
}
-static HRESULT joydev_create_deviceA(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEA* pdev)
+static HRESULT joydev_create_device(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPVOID *pdev, int unicode)
{
unsigned short index;
+ TRACE("%p %s %s %p %i\n", dinput, debugstr_guid(rguid), debugstr_guid(riid), pdev, unicode);
find_joydevs();
+ *pdev = NULL;
if ((index = get_joystick_index(rguid)) < MAX_JOYDEV &&
have_joydevs && index < have_joydevs)
{
- if ((riid == NULL) ||
- IsEqualGUID(&IID_IDirectInputDeviceA, riid) ||
- IsEqualGUID(&IID_IDirectInputDevice2A, riid) ||
- IsEqualGUID(&IID_IDirectInputDevice7A, riid) ||
- IsEqualGUID(&IID_IDirectInputDevice8A, riid))
+ JoystickImpl *This;
+
+ if (riid == NULL)
+ ;/* nothing */
+ else if (IsEqualGUID(&IID_IDirectInputDeviceA, riid) ||
+ IsEqualGUID(&IID_IDirectInputDevice2A, riid) ||
+ IsEqualGUID(&IID_IDirectInputDevice7A, riid) ||
+ IsEqualGUID(&IID_IDirectInputDevice8A, riid))
{
- *pdev = (IDirectInputDeviceA*) alloc_device(rguid, &JoystickAvt, dinput, index);
- TRACE("Created a Joystick device (%p)\n", *pdev);
-
- if (*pdev == NULL)
- {
- ERR("out of memory\n");
- return DIERR_OUTOFMEMORY;
- }
- return DI_OK;
+ unicode = 0;
+ }
+ else if (IsEqualGUID(&IID_IDirectInputDeviceW, riid) ||
+ IsEqualGUID(&IID_IDirectInputDevice2W, riid) ||
+ IsEqualGUID(&IID_IDirectInputDevice7W, riid) ||
+ IsEqualGUID(&IID_IDirectInputDevice8W, riid))
+ {
+ unicode = 1;
+ }
+ else
+ {
+ WARN("no interface\n");
+ return DIERR_NOINTERFACE;
}
- WARN("no interface\n");
- return DIERR_NOINTERFACE;
- }
-
- return DIERR_DEVICENOTREG;
-}
-
-
-static HRESULT joydev_create_deviceW(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEW* pdev)
-{
- unsigned short index;
+ This = alloc_device(rguid, dinput, index);
+ TRACE("Created a Joystick device (%p)\n", This);
- find_joydevs();
+ if (!This) return DIERR_OUTOFMEMORY;
- if ((index = get_joystick_index(rguid)) < MAX_JOYDEV &&
- have_joydevs && index < have_joydevs)
- {
- if ((riid == NULL) ||
- IsEqualGUID(&IID_IDirectInputDeviceW, riid) ||
- IsEqualGUID(&IID_IDirectInputDevice2W, riid) ||
- IsEqualGUID(&IID_IDirectInputDevice7W, riid) ||
- IsEqualGUID(&IID_IDirectInputDevice8W, riid))
- {
- *pdev = (IDirectInputDeviceW*) alloc_device(rguid, &JoystickWvt, dinput, index);
- TRACE("Created a Joystick device (%p)\n", *pdev);
+ if (unicode)
+ *pdev = &This->generic.base.IDirectInputDevice8W_iface;
+ else
+ *pdev = &This->generic.base.IDirectInputDevice8A_iface;
- if (*pdev == NULL)
- {
- ERR("out of memory\n");
- return DIERR_OUTOFMEMORY;
- }
- return DI_OK;
- }
- WARN("no interface\n");
- return DIERR_NOINTERFACE;
+ return DI_OK;
}
- WARN("invalid device GUID\n");
return DIERR_DEVICENOTREG;
}
+
const struct dinput_device joystick_linuxinput_device = {
"Wine Linux-input joystick driver",
joydev_enum_deviceA,
joydev_enum_deviceW,
- joydev_create_deviceA,
- joydev_create_deviceW
+ joydev_create_device
};
/******************************************************************************
* Acquire : gets exclusive control of the joystick
*/
-static HRESULT WINAPI JoystickAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface)
+static HRESULT WINAPI JoystickWImpl_Acquire(LPDIRECTINPUTDEVICE8W iface)
{
- JoystickImpl *This = (JoystickImpl *)iface;
+ JoystickImpl *This = impl_from_IDirectInputDevice8W(iface);
HRESULT res;
TRACE("(this=%p)\n",This);
- if ((res = IDirectInputDevice2AImpl_Acquire(iface)) != DI_OK)
+ if ((res = IDirectInputDevice2WImpl_Acquire(iface)) != DI_OK)
{
WARN("Failed to acquire: %x\n", res);
return res;
{
/* Couldn't open the device at all */
ERR("Failed to open device %s: %d %s\n", This->joydev->device, errno, strerror(errno));
- IDirectInputDevice2AImpl_Unacquire(iface);
+ IDirectInputDevice2WImpl_Unacquire(iface);
return DIERR_NOTFOUND;
}
else
return DI_OK;
}
+static HRESULT WINAPI JoystickAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface)
+{
+ JoystickImpl *This = impl_from_IDirectInputDevice8A(iface);
+ return JoystickWImpl_Acquire(IDirectInputDevice8W_from_impl(This));
+}
+
/******************************************************************************
* Unacquire : frees the joystick
*/
-static HRESULT WINAPI JoystickAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface)
+static HRESULT WINAPI JoystickWImpl_Unacquire(LPDIRECTINPUTDEVICE8W iface)
{
- JoystickImpl *This = (JoystickImpl *)iface;
+ JoystickImpl *This = impl_from_IDirectInputDevice8W(iface);
HRESULT res;
TRACE("(this=%p)\n",This);
- res = IDirectInputDevice2AImpl_Unacquire(iface);
+ res = IDirectInputDevice2WImpl_Unacquire(iface);
if (res==DI_OK && This->joyfd!=-1) {
effect_list_item *itr;
struct input_event event;
/* Enable autocenter. */
event.type = EV_FF;
event.code = FF_AUTOCENTER;
- /* TODO: Read autocenter strengh before disabling it, and use it here
- * instead of 0xFFFF (maximum strengh).
+ /* TODO: Read autocenter strength before disabling it, and use it here
+ * instead of 0xFFFF (maximum strength).
*/
event.value = 0xFFFF;
if (write(This->joyfd, &event, sizeof(event)) == -1)
return res;
}
+static HRESULT WINAPI JoystickAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface)
+{
+ JoystickImpl *This = impl_from_IDirectInputDevice8A(iface);
+ return JoystickWImpl_Unacquire(IDirectInputDevice8W_from_impl(This));
+}
+
/*
* set the current state of the js device as it would be with the middle
* values on the axes
*/
#define CENTER_AXIS(a) \
- (ji->axes[a] == -1 ? 0 : joystick_map_axis( &ji->props[ji->axes[a]], \
- ji->joydev->axes[a].value ))
+ (ji->dev_axes_to_di[a] == -1 ? 0 : joystick_map_axis( &ji->generic.props[ji->dev_axes_to_di[a]], \
+ ji->joydev->axes[a].value ))
static void fake_current_js_state(JoystickImpl *ji)
{
int i;
/* center the axes */
- ji->js.lX = CENTER_AXIS(ABS_X);
- ji->js.lY = CENTER_AXIS(ABS_Y);
- ji->js.lZ = CENTER_AXIS(ABS_Z);
- ji->js.lRx = CENTER_AXIS(ABS_RX);
- ji->js.lRy = CENTER_AXIS(ABS_RY);
- ji->js.lRz = CENTER_AXIS(ABS_RZ);
- ji->js.rglSlider[0] = CENTER_AXIS(ABS_THROTTLE);
- ji->js.rglSlider[1] = CENTER_AXIS(ABS_RUDDER);
+ ji->generic.js.lX = CENTER_AXIS(ABS_X);
+ ji->generic.js.lY = CENTER_AXIS(ABS_Y);
+ ji->generic.js.lZ = CENTER_AXIS(ABS_Z);
+ ji->generic.js.lRx = CENTER_AXIS(ABS_RX);
+ ji->generic.js.lRy = CENTER_AXIS(ABS_RY);
+ ji->generic.js.lRz = CENTER_AXIS(ABS_RZ);
+ ji->generic.js.rglSlider[0] = CENTER_AXIS(ABS_THROTTLE);
+ ji->generic.js.rglSlider[1] = CENTER_AXIS(ABS_RUDDER);
/* POV center is -1 */
for (i = 0; i < 4; i++)
- ji->js.rgdwPOV[i] = -1;
+ ji->generic.js.rgdwPOV[i] = -1;
}
#undef CENTER_AXIS
/* convert wine format offset to user format object index */
-static void joy_polldev(JoystickImpl *This)
+static void joy_polldev(LPDIRECTINPUTDEVICE8A iface)
{
struct pollfd plfd;
struct input_event ie;
+ JoystickImpl *This = impl_from_IDirectInputDevice8A(iface);
if (This->joyfd==-1)
return;
{
btn &= 0x7F;
inst_id = DIDFT_MAKEINSTANCE(btn) | DIDFT_PSHBUTTON;
- This->js.rgbButtons[btn] = value = ie.value ? 0x80 : 0x00;
+ This->generic.js.rgbButtons[btn] = value = ie.value ? 0x80 : 0x00;
}
break;
}
case EV_ABS:
{
- int axis = This->axes[ie.code];
- if (axis==-1) {
- break;
- }
- inst_id = DIDFT_MAKEINSTANCE(axis) | (ie.code < ABS_HAT0X ? DIDFT_ABSAXIS : DIDFT_POV);
- value = joystick_map_axis(&This->props[id_to_object(This->base.data_format.wine_df, inst_id)], ie.value);
-
- switch (ie.code) {
- case ABS_X: This->js.lX = value; break;
- case ABS_Y: This->js.lY = value; break;
- case ABS_Z: This->js.lZ = value; break;
- case ABS_RX: This->js.lRx = value; break;
- case ABS_RY: This->js.lRy = value; break;
- case ABS_RZ: This->js.lRz = value; break;
- case ABS_THROTTLE: This->js.rglSlider[0] = value; break;
- case ABS_RUDDER: This->js.rglSlider[1] = value; break;
- case ABS_HAT0X: case ABS_HAT0Y: case ABS_HAT1X: case ABS_HAT1Y:
- case ABS_HAT2X: case ABS_HAT2Y: case ABS_HAT3X: case ABS_HAT3Y:
+ int axis = This->dev_axes_to_di[ie.code];
+
+ /* User axis remapping */
+ if (axis < 0) break;
+ axis = This->generic.axis_map[axis];
+ if (axis < 0) break;
+
+ inst_id = axis < 8 ? DIDFT_MAKEINSTANCE(axis) | DIDFT_ABSAXIS :
+ DIDFT_MAKEINSTANCE(axis - 8) | DIDFT_POV;
+ value = joystick_map_axis(&This->generic.props[id_to_object(This->generic.base.data_format.wine_df, inst_id)], ie.value);
+
+ switch (axis) {
+ case 0: This->generic.js.lX = value; break;
+ case 1: This->generic.js.lY = value; break;
+ case 2: This->generic.js.lZ = value; break;
+ case 3: This->generic.js.lRx = value; break;
+ case 4: This->generic.js.lRy = value; break;
+ case 5: This->generic.js.lRz = value; break;
+ case 6: This->generic.js.rglSlider[0] = value; break;
+ case 7: This->generic.js.rglSlider[1] = value; break;
+ case 8: case 9: case 10: case 11:
{
- int idx = (ie.code - ABS_HAT0X) / 2;
+ int idx = axis - 8;
if (ie.code % 2)
This->povs[idx].y = ie.value;
else
This->povs[idx].x = ie.value;
- This->js.rgdwPOV[idx] = value = joystick_map_pov(&This->povs[idx]);
+ This->generic.js.rgdwPOV[idx] = value = joystick_map_pov(&This->povs[idx]);
break;
}
default:
case EV_SYN:
/* there is nothing to do */
break;
+#endif
+#ifdef EV_MSC
+ case EV_MSC:
+ /* Ignore */
+ break;
#endif
default:
FIXME("joystick cannot handle type %d event (code %d)\n",ie.type,ie.code);
break;
}
if (inst_id >= 0)
- queue_event((LPDIRECTINPUTDEVICE8A)This,
- id_to_offset(&This->base.data_format, inst_id),
- value, ie.time.tv_usec, This->base.dinput->evsequence++);
- }
-}
-
-/******************************************************************************
- * GetDeviceState : returns the "state" of the joystick.
- *
- */
-static HRESULT WINAPI JoystickAImpl_GetDeviceState(
- LPDIRECTINPUTDEVICE8A iface,DWORD len,LPVOID ptr
-) {
- JoystickImpl *This = (JoystickImpl *)iface;
-
- TRACE("(this=%p,0x%08x,%p)\n", This, len, ptr);
-
- if (!This->base.acquired)
- {
- WARN("not acquired\n");
- return DIERR_NOTACQUIRED;
+ queue_event(iface, inst_id,
+ value, ie.time.tv_usec, This->generic.base.dinput->evsequence++);
}
-
- joy_polldev(This);
-
- /* convert and copy data to user supplied buffer */
- fill_DataFormat(ptr, len, &This->js, &This->base.data_format);
-
- return DI_OK;
}
/******************************************************************************
* SetProperty : change input device properties
*/
-static HRESULT WINAPI JoystickAImpl_SetProperty(LPDIRECTINPUTDEVICE8A iface,
- REFGUID rguid,
- LPCDIPROPHEADER ph)
+static HRESULT WINAPI JoystickWImpl_SetProperty(LPDIRECTINPUTDEVICE8W iface, REFGUID rguid, LPCDIPROPHEADER ph)
{
- JoystickImpl *This = (JoystickImpl *)iface;
+ JoystickImpl *This = impl_from_IDirectInputDevice8W(iface);
if (!ph) {
WARN("invalid argument\n");
TRACE("ph.dwSize = %d, ph.dwHeaderSize =%d, ph.dwObj = %d, ph.dwHow= %d\n",
ph->dwSize, ph->dwHeaderSize, ph->dwObj, ph->dwHow);
- if (!HIWORD(rguid)) {
+ if (IS_DIPROP(rguid)) {
switch (LOWORD(rguid)) {
- case (DWORD_PTR)DIPROP_RANGE: {
- LPCDIPROPRANGE pr = (LPCDIPROPRANGE)ph;
-
- if (ph->dwHow == DIPH_DEVICE) {
- DWORD i;
- TRACE("proprange(%d,%d) all\n", pr->lMin, pr->lMax);
- for (i = 0; i < This->base.data_format.wine_df->dwNumObjs; i++) {
- /* Scale dead-zone */
- This->props[i].lDeadZone = MulDiv(This->props[i].lDeadZone, pr->lMax - pr->lMin,
- This->props[i].lMax - This->props[i].lMin);
- This->props[i].lMin = pr->lMin;
- This->props[i].lMax = pr->lMax;
- }
- } else {
- int obj = find_property(&This->base.data_format, ph);
-
- TRACE("proprange(%d,%d) obj=%d\n", pr->lMin, pr->lMax, obj);
- if (obj >= 0) {
- /* Scale dead-zone */
- This->props[obj].lDeadZone = MulDiv(This->props[obj].lDeadZone, pr->lMax - pr->lMin,
- This->props[obj].lMax - This->props[obj].lMin);
- This->props[obj].lMin = pr->lMin;
- This->props[obj].lMax = pr->lMax;
- }
- }
- fake_current_js_state(This);
- break;
- }
- case (DWORD_PTR)DIPROP_DEADZONE: {
- LPCDIPROPDWORD pd = (LPCDIPROPDWORD)ph;
- if (ph->dwHow == DIPH_DEVICE) {
- DWORD i;
- TRACE("deadzone(%d) all\n", pd->dwData);
- for (i = 0; i < This->base.data_format.wine_df->dwNumObjs; i++) {
- This->props[i].lDeadZone = pd->dwData;
- }
- } else {
- int obj = find_property(&This->base.data_format, ph);
-
- TRACE("deadzone(%d) obj=%d\n", pd->dwData, obj);
- if (obj >= 0) {
- This->props[obj].lDeadZone = pd->dwData;
- }
- }
- fake_current_js_state(This);
- break;
- }
case (DWORD_PTR)DIPROP_CALIBRATIONMODE: {
LPCDIPROPDWORD pd = (LPCDIPROPDWORD)ph;
FIXME("DIPROP_CALIBRATIONMODE(%d)\n", pd->dwData);
break;
}
- case (DWORD_PTR)DIPROP_SATURATION: {
- LPCDIPROPDWORD pd = (LPCDIPROPDWORD)ph;
-
- if (ph->dwHow == DIPH_DEVICE) {
- DWORD i;
-
- TRACE("saturation(%d) all\n", pd->dwData);
- for (i = 0; i < This->base.data_format.wine_df->dwNumObjs; i++)
- This->props[i].lSaturation = pd->dwData;
- } else {
- int obj = find_property(&This->base.data_format, ph);
-
- if (obj < 0) return DIERR_OBJECTNOTFOUND;
-
- TRACE("saturation(%d) obj=%d\n", pd->dwData, obj);
- This->props[obj].lSaturation = pd->dwData;
- }
- fake_current_js_state(This);
- break;
- }
case (DWORD_PTR)DIPROP_FFGAIN: {
LPCDIPROPDWORD pd = (LPCDIPROPDWORD)ph;
TRACE("DIPROP_FFGAIN(%d)\n", pd->dwData);
This->ff_gain = MulDiv(pd->dwData, 0xFFFF, 10000);
- if (This->base.acquired) {
+ if (This->generic.base.acquired) {
/* Update immediately. */
struct input_event event;
break;
}
default:
- return IDirectInputDevice2AImpl_SetProperty(iface, rguid, ph);
+ return JoystickWGenericImpl_SetProperty(iface, rguid, ph);
}
}
return DI_OK;
}
-static HRESULT WINAPI JoystickAImpl_GetCapabilities(
- LPDIRECTINPUTDEVICE8A iface,
- LPDIDEVCAPS lpDIDevCaps)
+static HRESULT WINAPI JoystickAImpl_SetProperty(LPDIRECTINPUTDEVICE8A iface, REFGUID rguid, LPCDIPROPHEADER ph)
{
- JoystickImpl *This = (JoystickImpl *)iface;
-
- TRACE("%p->(%p)\n",iface,lpDIDevCaps);
-
- if (!lpDIDevCaps) {
- WARN("invalid pointer\n");
- return E_POINTER;
- }
-
- if (lpDIDevCaps->dwSize != sizeof(DIDEVCAPS)) {
- WARN("invalid argument\n");
- return DIERR_INVALIDPARAM;
- }
-
- lpDIDevCaps->dwFlags = DIDC_ATTACHED;
- if (This->base.dinput->dwVersion >= 0x0800)
- lpDIDevCaps->dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8);
- else
- lpDIDevCaps->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
-
- if (This->joydev->has_ff)
- lpDIDevCaps->dwFlags |= DIDC_FORCEFEEDBACK;
-
- lpDIDevCaps->dwAxes = This->numAxes;
- lpDIDevCaps->dwButtons = This->numButtons;
- lpDIDevCaps->dwPOVs = This->numPOVs;
-
- return DI_OK;
-}
-
-static HRESULT WINAPI JoystickAImpl_Poll(LPDIRECTINPUTDEVICE8A iface)
-{
- JoystickImpl *This = (JoystickImpl *)iface;
-
- TRACE("(%p)\n",This);
-
- if (!This->base.acquired)
- return DIERR_NOTACQUIRED;
-
- joy_polldev(This);
- return DI_OK;
+ JoystickImpl *This = impl_from_IDirectInputDevice8A(iface);
+ return JoystickWImpl_SetProperty(IDirectInputDevice8W_from_impl(This), rguid, ph);
}
/******************************************************************************
* GetProperty : get input device properties
*/
-static HRESULT WINAPI JoystickAImpl_GetProperty(LPDIRECTINPUTDEVICE8A iface,
- REFGUID rguid,
- LPDIPROPHEADER pdiph)
+static HRESULT WINAPI JoystickWImpl_GetProperty(LPDIRECTINPUTDEVICE8W iface, REFGUID rguid, LPDIPROPHEADER pdiph)
{
- JoystickImpl *This = (JoystickImpl *)iface;
+ JoystickImpl *This = impl_from_IDirectInputDevice8W(iface);
TRACE("(this=%p,%s,%p)\n", iface, debugstr_guid(rguid), pdiph);
_dump_DIPROPHEADER(pdiph);
- if (HIWORD(rguid)) return DI_OK;
+ if (!IS_DIPROP(rguid)) return DI_OK;
switch (LOWORD(rguid)) {
- case (DWORD_PTR) DIPROP_RANGE:
- {
- LPDIPROPRANGE pr = (LPDIPROPRANGE) pdiph;
- int obj = find_property(&This->base.data_format, pdiph);
-
- if (obj < 0) return DIERR_OBJECTNOTFOUND;
-
- pr->lMin = This->props[obj].lMin;
- pr->lMax = This->props[obj].lMax;
- TRACE("range(%d, %d) obj=%d\n", pr->lMin, pr->lMax, obj);
- break;
- }
- case (DWORD_PTR) DIPROP_DEADZONE:
+ case (DWORD_PTR) DIPROP_AUTOCENTER:
{
LPDIPROPDWORD pd = (LPDIPROPDWORD)pdiph;
- int obj = find_property(&This->base.data_format, pdiph);
-
- if (obj < 0) return DIERR_OBJECTNOTFOUND;
- pd->dwData = This->props[obj].lDeadZone;
- TRACE("deadzone(%d) obj=%d\n", pd->dwData, obj);
+ pd->dwData = This->ff_autocenter ? DIPROPAUTOCENTER_ON : DIPROPAUTOCENTER_OFF;
+ TRACE("autocenter(%d)\n", pd->dwData);
break;
}
- case (DWORD_PTR) DIPROP_SATURATION:
+ case (DWORD_PTR) DIPROP_FFGAIN:
{
LPDIPROPDWORD pd = (LPDIPROPDWORD)pdiph;
- int obj = find_property(&This->base.data_format, pdiph);
-
- if (obj < 0) return DIERR_OBJECTNOTFOUND;
- pd->dwData = This->props[obj].lSaturation;
- TRACE("saturation(%d) obj=%d\n", pd->dwData, obj);
+ pd->dwData = MulDiv(This->ff_gain, 10000, 0xFFFF);
+ TRACE("DIPROP_FFGAIN(%d)\n", pd->dwData);
break;
}
- case (DWORD_PTR) DIPROP_AUTOCENTER:
+
+ case (DWORD_PTR) DIPROP_VIDPID:
{
LPDIPROPDWORD pd = (LPDIPROPDWORD)pdiph;
- pd->dwData = This->ff_autocenter ? DIPROPAUTOCENTER_ON : DIPROPAUTOCENTER_OFF;
- TRACE("autocenter(%d)\n", pd->dwData);
+ if (!This->joydev->product_id || !This->joydev->vendor_id)
+ return DIERR_UNSUPPORTED;
+ pd->dwData = MAKELONG(This->joydev->vendor_id, This->joydev->product_id);
+ TRACE("DIPROP_VIDPID(%08x)\n", pd->dwData);
break;
}
- case (DWORD_PTR) DIPROP_FFGAIN:
+
+ case (DWORD_PTR) DIPROP_JOYSTICKID:
{
LPDIPROPDWORD pd = (LPDIPROPDWORD)pdiph;
- pd->dwData = MulDiv(This->ff_gain, 10000, 0xFFFF);
- TRACE("DIPROP_FFGAIN(%d)\n", pd->dwData);
+ pd->dwData = get_joystick_index(&This->generic.base.guid);
+ TRACE("DIPROP_JOYSTICKID(%d)\n", pd->dwData);
break;
}
default:
- return IDirectInputDevice2AImpl_GetProperty(iface, rguid, pdiph);
+ return JoystickWGenericImpl_GetProperty(iface, rguid, pdiph);
}
return DI_OK;
}
-/******************************************************************************
- * GetObjectInfo : get information about a device object such as a button
- * or axis
- */
-static HRESULT WINAPI JoystickWImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface,
- LPDIDEVICEOBJECTINSTANCEW pdidoi, DWORD dwObj, DWORD dwHow)
+static HRESULT WINAPI JoystickAImpl_GetProperty(LPDIRECTINPUTDEVICE8A iface, REFGUID rguid, LPDIPROPHEADER pdiph)
{
- static const WCHAR axisW[] = {'A','x','i','s',' ','%','d',0};
- static const WCHAR povW[] = {'P','O','V',' ','%','d',0};
- static const WCHAR buttonW[] = {'B','u','t','t','o','n',' ','%','d',0};
- HRESULT res;
-
- res = IDirectInputDevice2WImpl_GetObjectInfo(iface, pdidoi, dwObj, dwHow);
- if (res != DI_OK) return res;
-
- if (pdidoi->dwType & DIDFT_AXIS)
- sprintfW(pdidoi->tszName, axisW, DIDFT_GETINSTANCE(pdidoi->dwType));
- else if (pdidoi->dwType & DIDFT_POV)
- sprintfW(pdidoi->tszName, povW, DIDFT_GETINSTANCE(pdidoi->dwType));
- else if (pdidoi->dwType & DIDFT_BUTTON)
- sprintfW(pdidoi->tszName, buttonW, DIDFT_GETINSTANCE(pdidoi->dwType));
-
- _dump_OBJECTINSTANCEW(pdidoi);
- return res;
-}
-
-static HRESULT WINAPI JoystickAImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8A iface,
- LPDIDEVICEOBJECTINSTANCEA pdidoi, DWORD dwObj, DWORD dwHow)
-{
- HRESULT res;
- DIDEVICEOBJECTINSTANCEW didoiW;
- DWORD dwSize = pdidoi->dwSize;
-
- didoiW.dwSize = sizeof(didoiW);
- res = JoystickWImpl_GetObjectInfo((LPDIRECTINPUTDEVICE8W)iface, &didoiW, dwObj, dwHow);
- if (res != DI_OK) return res;
-
- memset(pdidoi, 0, pdidoi->dwSize);
- memcpy(pdidoi, &didoiW, FIELD_OFFSET(DIDEVICEOBJECTINSTANCEW, tszName));
- pdidoi->dwSize = dwSize;
- WideCharToMultiByte(CP_ACP, 0, didoiW.tszName, -1, pdidoi->tszName,
- sizeof(pdidoi->tszName), NULL, NULL);
-
- return res;
+ JoystickImpl *This = impl_from_IDirectInputDevice8A(iface);
+ return JoystickWImpl_GetProperty(IDirectInputDevice8W_from_impl(This), rguid, pdiph);
}
/******************************************************************************
* CreateEffect - Create a new FF effect with the specified params
*/
-static HRESULT WINAPI JoystickAImpl_CreateEffect(LPDIRECTINPUTDEVICE8A iface,
- REFGUID rguid,
- LPCDIEFFECT lpeff,
- LPDIRECTINPUTEFFECT *ppdef,
- LPUNKNOWN pUnkOuter)
+static HRESULT WINAPI JoystickWImpl_CreateEffect(LPDIRECTINPUTDEVICE8W iface, REFGUID rguid,
+ LPCDIEFFECT lpeff, LPDIRECTINPUTEFFECT *ppdef,
+ LPUNKNOWN pUnkOuter)
{
#ifdef HAVE_STRUCT_FF_EFFECT_DIRECTION
effect_list_item* new_effect = NULL;
HRESULT retval = DI_OK;
#endif
- JoystickImpl* This = (JoystickImpl*)iface;
+ JoystickImpl* This = impl_from_IDirectInputDevice8W(iface);
TRACE("(this=%p,%p,%p,%p,%p)\n", This, rguid, lpeff, ppdef, pUnkOuter);
#ifndef HAVE_STRUCT_FF_EFFECT_DIRECTION
return DI_OK;
#endif /* HAVE_STRUCT_FF_EFFECT_DIRECTION */
-}
+}
+
+static HRESULT WINAPI JoystickAImpl_CreateEffect(LPDIRECTINPUTDEVICE8A iface, REFGUID rguid,
+ LPCDIEFFECT lpeff, LPDIRECTINPUTEFFECT *ppdef,
+ LPUNKNOWN pUnkOuter)
+{
+ JoystickImpl *This = impl_from_IDirectInputDevice8A(iface);
+ return JoystickWImpl_CreateEffect(IDirectInputDevice8W_from_impl(This), rguid, lpeff, ppdef, pUnkOuter);
+}
/*******************************************************************************
* EnumEffects - Enumerate available FF effects
#ifdef HAVE_STRUCT_FF_EFFECT_DIRECTION
DIEFFECTINFOA dei; /* feif */
DWORD type = DIEFT_GETTYPE(dwEffType);
- JoystickImpl* This = (JoystickImpl*)iface;
+ JoystickImpl* This = impl_from_IDirectInputDevice8A(iface);
TRACE("(this=%p,%p,%d) type=%d\n", This, pvRef, dwEffType, type);
* are actually different (A/W) */
DIEFFECTINFOW dei; /* feif */
DWORD type = DIEFT_GETTYPE(dwEffType);
- JoystickImpl* This = (JoystickImpl*)iface;
+ JoystickImpl* This = impl_from_IDirectInputDevice8W(iface);
int xfd = This->joyfd;
TRACE("(this=%p,%p,%d) type=%d fd=%d\n", This, pvRef, dwEffType, type, xfd);
LPDIEFFECTINFOA pdei,
REFGUID guid)
{
- JoystickImpl* This = (JoystickImpl*)iface;
+ JoystickImpl* This = impl_from_IDirectInputDevice8A(iface);
TRACE("(this=%p,%p,%s)\n", This, pdei, _dump_dinput_GUID(guid));
LPDIEFFECTINFOW pdei,
REFGUID guid)
{
- JoystickImpl* This = (JoystickImpl*)iface;
-
+ JoystickImpl* This = impl_from_IDirectInputDevice8W(iface);
+
TRACE("(this=%p,%p,%s)\n", This, pdei, _dump_dinput_GUID(guid));
-
+
#ifdef HAVE_STRUCT_FF_EFFECT_DIRECTION
return linuxinput_get_info_W(This->joyfd, guid, pdei);
#else
/*******************************************************************************
* GetForceFeedbackState - Get information about the device's FF state
*/
-static HRESULT WINAPI JoystickAImpl_GetForceFeedbackState(
- LPDIRECTINPUTDEVICE8A iface,
- LPDWORD pdwOut)
+static HRESULT WINAPI JoystickWImpl_GetForceFeedbackState(LPDIRECTINPUTDEVICE8W iface, LPDWORD pdwOut)
{
- JoystickImpl* This = (JoystickImpl*)iface;
+ JoystickImpl* This = impl_from_IDirectInputDevice8W(iface);
TRACE("(this=%p,%p)\n", This, pdwOut);
return DI_OK;
}
+static HRESULT WINAPI JoystickAImpl_GetForceFeedbackState(LPDIRECTINPUTDEVICE8A iface, LPDWORD pdwOut)
+{
+ JoystickImpl *This = impl_from_IDirectInputDevice8A(iface);
+ return JoystickWImpl_GetForceFeedbackState(IDirectInputDevice8W_from_impl(This), pdwOut);
+}
+
/*******************************************************************************
* SendForceFeedbackCommand - Send a command to the device's FF system
*/
-static HRESULT WINAPI JoystickAImpl_SendForceFeedbackCommand(
- LPDIRECTINPUTDEVICE8A iface,
- DWORD dwFlags)
+static HRESULT WINAPI JoystickWImpl_SendForceFeedbackCommand(LPDIRECTINPUTDEVICE8W iface, DWORD dwFlags)
{
- JoystickImpl* This = (JoystickImpl*)iface;
+ JoystickImpl* This = impl_from_IDirectInputDevice8W(iface);
TRACE("(this=%p,%d)\n", This, dwFlags);
#ifdef HAVE_STRUCT_FF_EFFECT_DIRECTION
#endif
}
+static HRESULT WINAPI JoystickAImpl_SendForceFeedbackCommand(LPDIRECTINPUTDEVICE8A iface, DWORD dwFlags)
+{
+ JoystickImpl *This = impl_from_IDirectInputDevice8A(iface);
+ return JoystickWImpl_SendForceFeedbackCommand(IDirectInputDevice8W_from_impl(This), dwFlags);
+}
+
/*******************************************************************************
* EnumCreatedEffectObjects - Enumerate all the effects that have been
* created for this device.
*/
-static HRESULT WINAPI JoystickAImpl_EnumCreatedEffectObjects(
- LPDIRECTINPUTDEVICE8A iface,
- LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback,
- LPVOID pvRef,
- DWORD dwFlags)
+static HRESULT WINAPI JoystickWImpl_EnumCreatedEffectObjects(LPDIRECTINPUTDEVICE8W iface,
+ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback,
+ LPVOID pvRef, DWORD dwFlags)
{
/* this function is safe to call on non-ff-enabled builds */
- JoystickImpl* This = (JoystickImpl*)iface;
+ JoystickImpl* This = impl_from_IDirectInputDevice8W(iface);
effect_list_item *itr, *ptr;
TRACE("(this=%p,%p,%p,%d)\n", This, lpCallback, pvRef, dwFlags);
return DI_OK;
}
+static HRESULT WINAPI JoystickAImpl_EnumCreatedEffectObjects(LPDIRECTINPUTDEVICE8A iface,
+ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback,
+ LPVOID pvRef, DWORD dwFlags)
+{
+ JoystickImpl *This = impl_from_IDirectInputDevice8A(iface);
+ return JoystickWImpl_EnumCreatedEffectObjects(IDirectInputDevice8W_from_impl(This), lpCallback, pvRef, dwFlags);
+}
+
/******************************************************************************
* GetDeviceInfo : get information about a device's identity
*/
static HRESULT WINAPI JoystickAImpl_GetDeviceInfo(LPDIRECTINPUTDEVICE8A iface,
LPDIDEVICEINSTANCEA pdidi)
{
- JoystickImpl *This = (JoystickImpl *)iface;
+ JoystickImpl *This = impl_from_IDirectInputDevice8A(iface);
TRACE("(%p) %p\n", This, pdidi);
(pdidi->dwSize != sizeof(DIDEVICEINSTANCEA)))
return DIERR_INVALIDPARAM;
- fill_joystick_dideviceinstanceA(pdidi, This->base.dinput->dwVersion,
- get_joystick_index(&This->base.guid));
+ fill_joystick_dideviceinstanceA(pdidi, This->generic.base.dinput->dwVersion,
+ get_joystick_index(&This->generic.base.guid));
return DI_OK;
}
static HRESULT WINAPI JoystickWImpl_GetDeviceInfo(LPDIRECTINPUTDEVICE8W iface,
LPDIDEVICEINSTANCEW pdidi)
{
- JoystickImpl *This = (JoystickImpl *)iface;
+ JoystickImpl *This = impl_from_IDirectInputDevice8W(iface);
TRACE("(%p) %p\n", This, pdidi);
(pdidi->dwSize != sizeof(DIDEVICEINSTANCEW)))
return DIERR_INVALIDPARAM;
- fill_joystick_dideviceinstanceW(pdidi, This->base.dinput->dwVersion,
- get_joystick_index(&This->base.guid));
+ fill_joystick_dideviceinstanceW(pdidi, This->generic.base.dinput->dwVersion,
+ get_joystick_index(&This->generic.base.guid));
return DI_OK;
}
IDirectInputDevice2AImpl_QueryInterface,
IDirectInputDevice2AImpl_AddRef,
IDirectInputDevice2AImpl_Release,
- JoystickAImpl_GetCapabilities,
+ JoystickAGenericImpl_GetCapabilities,
IDirectInputDevice2AImpl_EnumObjects,
JoystickAImpl_GetProperty,
JoystickAImpl_SetProperty,
JoystickAImpl_Acquire,
JoystickAImpl_Unacquire,
- JoystickAImpl_GetDeviceState,
+ JoystickAGenericImpl_GetDeviceState,
IDirectInputDevice2AImpl_GetDeviceData,
IDirectInputDevice2AImpl_SetDataFormat,
IDirectInputDevice2AImpl_SetEventNotification,
IDirectInputDevice2AImpl_SetCooperativeLevel,
- JoystickAImpl_GetObjectInfo,
+ JoystickAGenericImpl_GetObjectInfo,
JoystickAImpl_GetDeviceInfo,
IDirectInputDevice2AImpl_RunControlPanel,
IDirectInputDevice2AImpl_Initialize,
JoystickAImpl_SendForceFeedbackCommand,
JoystickAImpl_EnumCreatedEffectObjects,
IDirectInputDevice2AImpl_Escape,
- JoystickAImpl_Poll,
+ JoystickAGenericImpl_Poll,
IDirectInputDevice2AImpl_SendDeviceData,
IDirectInputDevice7AImpl_EnumEffectsInFile,
IDirectInputDevice7AImpl_WriteEffectToFile,
- IDirectInputDevice8AImpl_BuildActionMap,
- IDirectInputDevice8AImpl_SetActionMap,
+ JoystickAGenericImpl_BuildActionMap,
+ JoystickAGenericImpl_SetActionMap,
IDirectInputDevice8AImpl_GetImageInfo
};
-#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
-# define XCAST(fun) (typeof(JoystickWvt.fun))
-#else
-# define XCAST(fun) (void*)
-#endif
-
static const IDirectInputDevice8WVtbl JoystickWvt =
{
- IDirectInputDevice2WImpl_QueryInterface,
- XCAST(AddRef)IDirectInputDevice2AImpl_AddRef,
- XCAST(Release)IDirectInputDevice2AImpl_Release,
- XCAST(GetCapabilities)JoystickAImpl_GetCapabilities,
- IDirectInputDevice2WImpl_EnumObjects,
- XCAST(GetProperty)JoystickAImpl_GetProperty,
- XCAST(SetProperty)JoystickAImpl_SetProperty,
- XCAST(Acquire)JoystickAImpl_Acquire,
- XCAST(Unacquire)JoystickAImpl_Unacquire,
- XCAST(GetDeviceState)JoystickAImpl_GetDeviceState,
- XCAST(GetDeviceData)IDirectInputDevice2AImpl_GetDeviceData,
- XCAST(SetDataFormat)IDirectInputDevice2AImpl_SetDataFormat,
- XCAST(SetEventNotification)IDirectInputDevice2AImpl_SetEventNotification,
- XCAST(SetCooperativeLevel)IDirectInputDevice2AImpl_SetCooperativeLevel,
- JoystickWImpl_GetObjectInfo,
- JoystickWImpl_GetDeviceInfo,
- XCAST(RunControlPanel)IDirectInputDevice2AImpl_RunControlPanel,
- XCAST(Initialize)IDirectInputDevice2AImpl_Initialize,
- XCAST(CreateEffect)JoystickAImpl_CreateEffect,
- JoystickWImpl_EnumEffects,
- JoystickWImpl_GetEffectInfo,
- XCAST(GetForceFeedbackState)JoystickAImpl_GetForceFeedbackState,
- XCAST(SendForceFeedbackCommand)JoystickAImpl_SendForceFeedbackCommand,
- XCAST(EnumCreatedEffectObjects)JoystickAImpl_EnumCreatedEffectObjects,
- XCAST(Escape)IDirectInputDevice2AImpl_Escape,
- XCAST(Poll)JoystickAImpl_Poll,
- XCAST(SendDeviceData)IDirectInputDevice2AImpl_SendDeviceData,
- IDirectInputDevice7WImpl_EnumEffectsInFile,
- IDirectInputDevice7WImpl_WriteEffectToFile,
- IDirectInputDevice8WImpl_BuildActionMap,
- IDirectInputDevice8WImpl_SetActionMap,
- IDirectInputDevice8WImpl_GetImageInfo
+ IDirectInputDevice2WImpl_QueryInterface,
+ IDirectInputDevice2WImpl_AddRef,
+ IDirectInputDevice2WImpl_Release,
+ JoystickWGenericImpl_GetCapabilities,
+ IDirectInputDevice2WImpl_EnumObjects,
+ JoystickWImpl_GetProperty,
+ JoystickWImpl_SetProperty,
+ JoystickWImpl_Acquire,
+ JoystickWImpl_Unacquire,
+ JoystickWGenericImpl_GetDeviceState,
+ IDirectInputDevice2WImpl_GetDeviceData,
+ IDirectInputDevice2WImpl_SetDataFormat,
+ IDirectInputDevice2WImpl_SetEventNotification,
+ IDirectInputDevice2WImpl_SetCooperativeLevel,
+ JoystickWGenericImpl_GetObjectInfo,
+ JoystickWImpl_GetDeviceInfo,
+ IDirectInputDevice2WImpl_RunControlPanel,
+ IDirectInputDevice2WImpl_Initialize,
+ JoystickWImpl_CreateEffect,
+ JoystickWImpl_EnumEffects,
+ JoystickWImpl_GetEffectInfo,
+ JoystickWImpl_GetForceFeedbackState,
+ JoystickWImpl_SendForceFeedbackCommand,
+ JoystickWImpl_EnumCreatedEffectObjects,
+ IDirectInputDevice2WImpl_Escape,
+ JoystickWGenericImpl_Poll,
+ IDirectInputDevice2WImpl_SendDeviceData,
+ IDirectInputDevice7WImpl_EnumEffectsInFile,
+ IDirectInputDevice7WImpl_WriteEffectToFile,
+ JoystickWGenericImpl_BuildActionMap,
+ JoystickWGenericImpl_SetActionMap,
+ IDirectInputDevice8WImpl_GetImageInfo
};
-#undef XCAST
#else /* HAVE_CORRECT_LINUXINPUT_H */
"Wine Linux-input joystick driver",
NULL,
NULL,
- NULL,
NULL
};
--- /dev/null
+/* DirectInput Joystick device for Mac OS/X
+ *
+ * Copyright 1998 Marcus Meissner
+ * Copyright 1998,1999 Lionel Ulmer
+ * Copyright 2000-2001 TransGaming Technologies Inc.
+ * Copyright 2009 CodeWeavers, Aric Stewart
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include <config.h>
+//#include "wine/port.h"
+
+#if defined(HAVE_IOKIT_HID_IOHIDLIB_H)
+#define ULONG __carbon_ULONG
+#define E_INVALIDARG __carbon_E_INVALIDARG
+#define E_OUTOFMEMORY __carbon_E_OUTOFMEMORY
+#define E_HANDLE __carbon_E_HANDLE
+#define E_ACCESSDENIED __carbon_E_ACCESSDENIED
+#define E_UNEXPECTED __carbon_E_UNEXPECTED
+#define E_FAIL __carbon_E_FAIL
+#define E_ABORT __carbon_E_ABORT
+#define E_POINTER __carbon_E_POINTER
+#define E_NOINTERFACE __carbon_E_NOINTERFACE
+#define E_NOTIMPL __carbon_E_NOTIMPL
+#define S_FALSE __carbon_S_FALSE
+#define S_OK __carbon_S_OK
+#define HRESULT_FACILITY __carbon_HRESULT_FACILITY
+#define IS_ERROR __carbon_IS_ERROR
+#define FAILED __carbon_FAILED
+#define SUCCEEDED __carbon_SUCCEEDED
+#define MAKE_HRESULT __carbon_MAKE_HRESULT
+#define HRESULT __carbon_HRESULT
+#define STDMETHODCALLTYPE __carbon_STDMETHODCALLTYPE
+#include <IOKit/hid/IOHIDLib.h>
+#undef ULONG
+#undef E_INVALIDARG
+#undef E_OUTOFMEMORY
+#undef E_HANDLE
+#undef E_ACCESSDENIED
+#undef E_UNEXPECTED
+#undef E_FAIL
+#undef E_ABORT
+#undef E_POINTER
+#undef E_NOINTERFACE
+#undef E_NOTIMPL
+#undef S_FALSE
+#undef S_OK
+#undef HRESULT_FACILITY
+#undef IS_ERROR
+#undef FAILED
+#undef SUCCEEDED
+#undef MAKE_HRESULT
+#undef HRESULT
+#undef STDMETHODCALLTYPE
+#endif /* HAVE_IOKIT_HID_IOHIDLIB_H */
+
+//#include "wine/debug.h"
+//#include "wine/unicode.h"
+//#include "windef.h"
+//#include "winbase.h"
+//#include "winerror.h"
+//#include "winreg.h"
+//#include "dinput.h"
+
+#include "dinput_private.h"
+//#include "device_private.h"
+//#include "joystick_private.h"
+
+#ifdef HAVE_IOHIDMANAGERCREATE
+
+WINE_DEFAULT_DEBUG_CHANNEL(dinput);
+
+static IOHIDManagerRef gIOHIDManagerRef = NULL;
+static CFArrayRef gCollections = NULL;
+
+typedef struct JoystickImpl JoystickImpl;
+static const IDirectInputDevice8AVtbl JoystickAvt;
+static const IDirectInputDevice8WVtbl JoystickWvt;
+
+struct JoystickImpl
+{
+ struct JoystickGenericImpl generic;
+
+ /* osx private */
+ int id;
+ CFMutableArrayRef elementCFArrayRef;
+ ObjProps **propmap;
+};
+
+static inline JoystickImpl *impl_from_IDirectInputDevice8A(IDirectInputDevice8A *iface)
+{
+ return CONTAINING_RECORD(CONTAINING_RECORD(CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8A_iface),
+ JoystickGenericImpl, base), JoystickImpl, generic);
+}
+static inline JoystickImpl *impl_from_IDirectInputDevice8W(IDirectInputDevice8W *iface)
+{
+ return CONTAINING_RECORD(CONTAINING_RECORD(CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8W_iface),
+ JoystickGenericImpl, base), JoystickImpl, generic);
+}
+
+static const GUID DInput_Wine_OsX_Joystick_GUID = { /* 59CAD8F6-E617-41E2-8EB7-47B23EEEDC5A */
+ 0x59CAD8F6, 0xE617, 0x41E2, {0x8E, 0xB7, 0x47, 0xB2, 0x3E, 0xEE, 0xDC, 0x5A}
+};
+
+static void CFSetApplierFunctionCopyToCFArray(const void *value, void *context)
+{
+ CFArrayAppendValue( ( CFMutableArrayRef ) context, value );
+}
+
+static CFMutableDictionaryRef creates_osx_device_match(int usage)
+{
+ CFMutableDictionaryRef result;
+
+ result = CFDictionaryCreateMutable( kCFAllocatorDefault, 0,
+ &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks );
+
+ if ( result )
+ {
+ int number = kHIDPage_GenericDesktop;
+ CFNumberRef pageCFNumberRef = CFNumberCreate( kCFAllocatorDefault,
+ kCFNumberIntType, &number);
+
+ if ( pageCFNumberRef )
+ {
+ CFNumberRef usageCFNumberRef;
+
+ CFDictionarySetValue( result, CFSTR( kIOHIDDeviceUsagePageKey ),
+ pageCFNumberRef );
+ CFRelease( pageCFNumberRef );
+
+ usageCFNumberRef = CFNumberCreate( kCFAllocatorDefault,
+ kCFNumberIntType, &usage);
+ if ( usageCFNumberRef )
+ {
+ CFDictionarySetValue( result, CFSTR( kIOHIDDeviceUsageKey ),
+ usageCFNumberRef );
+ CFRelease( usageCFNumberRef );
+ }
+ else
+ {
+ ERR("CFNumberCreate() failed.\n");
+ return NULL;
+ }
+ }
+ else
+ {
+ ERR("CFNumberCreate failed.\n");
+ return NULL;
+ }
+ }
+ else
+ {
+ ERR("CFDictionaryCreateMutable failed.\n");
+ return NULL;
+ }
+
+ return result;
+}
+
+static CFIndex find_top_level(IOHIDDeviceRef tIOHIDDeviceRef, CFArrayRef topLevels)
+{
+ CFArrayRef gElementCFArrayRef;
+ CFIndex numTops = 0;
+
+ if (!tIOHIDDeviceRef)
+ return 0;
+
+ gElementCFArrayRef = IOHIDDeviceCopyMatchingElements(tIOHIDDeviceRef, NULL, 0);
+
+ if (gElementCFArrayRef)
+ {
+ CFIndex idx, cnt = CFArrayGetCount(gElementCFArrayRef);
+ for (idx=0; idx<cnt; idx++)
+ {
+ IOHIDElementRef tIOHIDElementRef = (IOHIDElementRef)CFArrayGetValueAtIndex(gElementCFArrayRef, idx);
+ int eleType = IOHIDElementGetType(tIOHIDElementRef);
+
+ /* Check for top-level gaming device collections */
+ if (eleType == kIOHIDElementTypeCollection && IOHIDElementGetParent(tIOHIDElementRef) == 0)
+ {
+ int tUsagePage = IOHIDElementGetUsagePage(tIOHIDElementRef);
+ int tUsage = IOHIDElementGetUsage(tIOHIDElementRef);
+
+ if (tUsagePage == kHIDPage_GenericDesktop &&
+ (tUsage == kHIDUsage_GD_Joystick || tUsage == kHIDUsage_GD_GamePad))
+ {
+ CFArrayAppendValue((CFMutableArrayRef)topLevels, tIOHIDElementRef);
+ numTops++;
+ }
+ }
+ }
+ }
+ return numTops;
+}
+
+static void get_element_children(IOHIDElementRef tElement, CFArrayRef childElements)
+{
+ CFIndex idx, cnt;
+ CFArrayRef tElementChildrenArray = IOHIDElementGetChildren(tElement);
+
+ cnt = CFArrayGetCount(tElementChildrenArray);
+ if (cnt < 1)
+ return;
+
+ /* Either add the element to the array or grab its children */
+ for (idx=0; idx<cnt; idx++)
+ {
+ IOHIDElementRef tChildElementRef;
+
+ tChildElementRef = (IOHIDElementRef)CFArrayGetValueAtIndex(tElementChildrenArray, idx);
+ if (IOHIDElementGetType(tChildElementRef) == kIOHIDElementTypeCollection)
+ get_element_children(tChildElementRef, childElements);
+ else
+ CFArrayAppendValue((CFMutableArrayRef)childElements, tChildElementRef);
+ }
+}
+
+static int find_osx_devices(void)
+{
+ IOReturn tIOReturn;
+ CFMutableDictionaryRef result;
+ CFSetRef devset;
+ CFArrayRef matching;
+
+ gIOHIDManagerRef = IOHIDManagerCreate( kCFAllocatorDefault, 0L );
+ tIOReturn = IOHIDManagerOpen( gIOHIDManagerRef, 0L);
+ if ( kIOReturnSuccess != tIOReturn )
+ {
+ ERR("Couldn't open IOHIDManager.\n");
+ return 0;
+ }
+
+ matching = CFArrayCreateMutable( kCFAllocatorDefault, 0,
+ &kCFTypeArrayCallBacks );
+
+ /* build matching dictionary */
+ result = creates_osx_device_match(kHIDUsage_GD_Joystick);
+ if (!result)
+ {
+ CFRelease(matching);
+ return 0;
+ }
+ CFArrayAppendValue( ( CFMutableArrayRef )matching, result );
+ result = creates_osx_device_match(kHIDUsage_GD_GamePad);
+ if (!result)
+ {
+ CFRelease(matching);
+ return 0;
+ }
+ CFArrayAppendValue( ( CFMutableArrayRef )matching, result );
+
+ IOHIDManagerSetDeviceMatchingMultiple( gIOHIDManagerRef, matching);
+ devset = IOHIDManagerCopyDevices( gIOHIDManagerRef );
+ if (devset)
+ {
+ CFIndex countDevices, countCollections, idx;
+ CFArrayRef gDevices = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks);
+ CFSetApplyFunction(devset, CFSetApplierFunctionCopyToCFArray, (void*)gDevices);
+ CFRelease( devset);
+ countDevices = CFArrayGetCount(gDevices);
+
+ gCollections = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks);
+ if (!gCollections)
+ return 0;
+
+ countCollections = 0;
+ for (idx = 0; idx < countDevices; idx++)
+ {
+ CFIndex tTop;
+ IOHIDDeviceRef tDevice;
+
+ tDevice = (IOHIDDeviceRef) CFArrayGetValueAtIndex(gDevices, idx);
+ tTop = find_top_level(tDevice, gCollections);
+ countCollections += tTop;
+ }
+
+ CFRelease(gDevices);
+
+ TRACE("found %i device(s), %i collection(s)\n",(int)countDevices,(int)countCollections);
+ return (int)countCollections;
+ }
+ return 0;
+}
+
+static int get_osx_device_name(int id, char *name, int length)
+{
+ CFStringRef str;
+ IOHIDElementRef tIOHIDElementRef;
+ IOHIDDeviceRef tIOHIDDeviceRef;
+
+ if (!gCollections)
+ return 0;
+
+ tIOHIDElementRef = (IOHIDElementRef)CFArrayGetValueAtIndex(gCollections, id);
+
+ if (!tIOHIDElementRef)
+ {
+ ERR("Invalid Element requested %i\n",id);
+ return 0;
+ }
+
+ tIOHIDDeviceRef = IOHIDElementGetDevice(tIOHIDElementRef);
+
+ if (name)
+ name[0] = 0;
+
+ if (!tIOHIDDeviceRef)
+ {
+ ERR("Invalid Device requested %i\n",id);
+ return 0;
+ }
+
+ str = IOHIDDeviceGetProperty(tIOHIDDeviceRef, CFSTR( kIOHIDProductKey ));
+ if (str)
+ {
+ CFIndex len = CFStringGetLength(str);
+ if (length >= len)
+ {
+ CFStringGetCString(str,name,length,kCFStringEncodingASCII);
+ return len;
+ }
+ else
+ return (len+1);
+ }
+ return 0;
+}
+
+static void insert_sort_button(int header, IOHIDElementRef tIOHIDElementRef,
+ CFMutableArrayRef elementCFArrayRef, int index,
+ int target)
+{
+ IOHIDElementRef targetElement;
+ int usage;
+
+ CFArraySetValueAtIndex(elementCFArrayRef, header+index, NULL);
+ targetElement = ( IOHIDElementRef ) CFArrayGetValueAtIndex( elementCFArrayRef, header+target);
+ if (targetElement == NULL)
+ {
+ CFArraySetValueAtIndex(elementCFArrayRef, header+target,tIOHIDElementRef);
+ return;
+ }
+ usage = IOHIDElementGetUsage( targetElement );
+ usage --; /* usage 1 based index */
+
+ insert_sort_button(header, targetElement, elementCFArrayRef, target, usage);
+ CFArraySetValueAtIndex(elementCFArrayRef, header+target,tIOHIDElementRef);
+}
+
+static void get_osx_device_elements(JoystickImpl *device, int axis_map[8])
+{
+ IOHIDElementRef tIOHIDElementRef;
+ CFArrayRef gElementCFArrayRef;
+ DWORD axes = 0;
+ DWORD sliders = 0;
+ DWORD buttons = 0;
+ DWORD povs = 0;
+
+ device->elementCFArrayRef = NULL;
+
+ if (!gCollections)
+ return;
+
+ tIOHIDElementRef = (IOHIDElementRef)CFArrayGetValueAtIndex(gCollections, device->id);
+
+ if (!tIOHIDElementRef)
+ return;
+
+ gElementCFArrayRef = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks);
+ get_element_children(tIOHIDElementRef, gElementCFArrayRef);
+
+ if (gElementCFArrayRef)
+ {
+ CFIndex idx, cnt = CFArrayGetCount( gElementCFArrayRef );
+ /* build our element array in the order that dinput expects */
+ device->elementCFArrayRef = CFArrayCreateMutable(NULL,0,NULL);
+
+ for ( idx = 0; idx < cnt; idx++ )
+ {
+ IOHIDElementRef tIOHIDElementRef = ( IOHIDElementRef ) CFArrayGetValueAtIndex( gElementCFArrayRef, idx );
+ int eleType = IOHIDElementGetType( tIOHIDElementRef );
+ switch(eleType)
+ {
+ case kIOHIDElementTypeInput_Button:
+ {
+ int usagePage = IOHIDElementGetUsagePage( tIOHIDElementRef );
+ if (usagePage != kHIDPage_Button)
+ {
+ /* avoid strange elements found on the 360 controller */
+ continue;
+ }
+
+ if (buttons < 128)
+ {
+ CFArrayInsertValueAtIndex(device->elementCFArrayRef, (axes+povs+buttons), tIOHIDElementRef);
+ buttons++;
+ }
+ break;
+ }
+ case kIOHIDElementTypeInput_Axis:
+ {
+ CFArrayInsertValueAtIndex(device->elementCFArrayRef, axes, tIOHIDElementRef);
+ axes++;
+ break;
+ }
+ case kIOHIDElementTypeInput_Misc:
+ {
+ uint32_t usage = IOHIDElementGetUsage( tIOHIDElementRef );
+ switch(usage)
+ {
+ case kHIDUsage_GD_Hatswitch:
+ {
+ CFArrayInsertValueAtIndex(device->elementCFArrayRef, (axes+povs), tIOHIDElementRef);
+ povs++;
+ break;
+ }
+ case kHIDUsage_GD_Slider:
+ sliders ++;
+ if (sliders > 2)
+ break;
+ /* fallthrough, sliders are axis */
+ case kHIDUsage_GD_X:
+ case kHIDUsage_GD_Y:
+ case kHIDUsage_GD_Z:
+ case kHIDUsage_GD_Rx:
+ case kHIDUsage_GD_Ry:
+ case kHIDUsage_GD_Rz:
+ {
+ CFArrayInsertValueAtIndex(device->elementCFArrayRef, axes, tIOHIDElementRef);
+ axis_map[axes]=usage;
+ axes++;
+ break;
+ }
+ default:
+ FIXME("Unhandled usage %i\n",usage);
+ }
+ break;
+ }
+ default:
+ FIXME("Unhandled type %i\n",eleType);
+ }
+ }
+ }
+
+ device->generic.devcaps.dwAxes = axes;
+ device->generic.devcaps.dwButtons = buttons;
+ device->generic.devcaps.dwPOVs = povs;
+
+ /* Sort buttons into correct order */
+ for (buttons = 0; buttons < device->generic.devcaps.dwButtons; buttons++)
+ {
+ IOHIDElementRef tIOHIDElementRef = ( IOHIDElementRef ) CFArrayGetValueAtIndex( device->elementCFArrayRef, axes+povs+buttons);
+ uint32_t usage = IOHIDElementGetUsage( tIOHIDElementRef );
+ usage --; /* usage is 1 indexed we need 0 indexed */
+ if (usage == buttons)
+ continue;
+
+ insert_sort_button(axes+povs, tIOHIDElementRef, device->elementCFArrayRef,buttons,usage);
+ }
+}
+
+static void get_osx_device_elements_props(JoystickImpl *device)
+{
+ CFArrayRef gElementCFArrayRef = device->elementCFArrayRef;
+
+ if (gElementCFArrayRef)
+ {
+ CFIndex idx, cnt = CFArrayGetCount( gElementCFArrayRef );
+
+ for ( idx = 0; idx < cnt; idx++ )
+ {
+ IOHIDElementRef tIOHIDElementRef = ( IOHIDElementRef ) CFArrayGetValueAtIndex( gElementCFArrayRef, idx );
+
+ device->generic.props[idx].lDevMin = IOHIDElementGetLogicalMin(tIOHIDElementRef);
+ device->generic.props[idx].lDevMax = IOHIDElementGetLogicalMax(tIOHIDElementRef);
+ device->generic.props[idx].lMin = 0;
+ device->generic.props[idx].lMax = 0xffff;
+ device->generic.props[idx].lDeadZone = 0;
+ device->generic.props[idx].lSaturation = 0;
+ }
+ }
+}
+
+static void poll_osx_device_state(LPDIRECTINPUTDEVICE8A iface)
+{
+ JoystickImpl *device = impl_from_IDirectInputDevice8A(iface);
+ IOHIDElementRef tIOHIDTopElementRef;
+ IOHIDDeviceRef tIOHIDDeviceRef;
+ CFArrayRef gElementCFArrayRef = device->elementCFArrayRef;
+
+ TRACE("polling device %i\n",device->id);
+
+ if (!gCollections)
+ return;
+
+ tIOHIDTopElementRef = (IOHIDElementRef) CFArrayGetValueAtIndex(gCollections, device->id);
+ tIOHIDDeviceRef = IOHIDElementGetDevice(tIOHIDTopElementRef);
+
+ if (!tIOHIDDeviceRef)
+ return;
+
+ if (gElementCFArrayRef)
+ {
+ int button_idx = 0;
+ int pov_idx = 0;
+ int slider_idx = 0;
+ int inst_id;
+ CFIndex idx, cnt = CFArrayGetCount( gElementCFArrayRef );
+
+ for ( idx = 0; idx < cnt; idx++ )
+ {
+ IOHIDValueRef valueRef;
+ int val, oldVal, newVal;
+ IOHIDElementRef tIOHIDElementRef = ( IOHIDElementRef ) CFArrayGetValueAtIndex( gElementCFArrayRef, idx );
+ int eleType = IOHIDElementGetType( tIOHIDElementRef );
+
+ switch(eleType)
+ {
+ case kIOHIDElementTypeInput_Button:
+ if(button_idx < 128)
+ {
+ IOHIDDeviceGetValue(tIOHIDDeviceRef, tIOHIDElementRef, &valueRef);
+ val = IOHIDValueGetIntegerValue(valueRef);
+ newVal = val ? 0x80 : 0x0;
+ oldVal = device->generic.js.rgbButtons[button_idx];
+ device->generic.js.rgbButtons[button_idx] = newVal;
+ if (oldVal != newVal)
+ {
+ inst_id = DIDFT_MAKEINSTANCE(button_idx) | DIDFT_PSHBUTTON;
+ queue_event(iface,inst_id,newVal,GetCurrentTime(),device->generic.base.dinput->evsequence++);
+ }
+ button_idx ++;
+ }
+ break;
+ case kIOHIDElementTypeInput_Misc:
+ {
+ uint32_t usage = IOHIDElementGetUsage( tIOHIDElementRef );
+ switch(usage)
+ {
+ case kHIDUsage_GD_Hatswitch:
+ {
+ IOHIDDeviceGetValue(tIOHIDDeviceRef, tIOHIDElementRef, &valueRef);
+ val = IOHIDValueGetIntegerValue(valueRef);
+ oldVal = device->generic.js.rgdwPOV[pov_idx];
+ if (val >= 8)
+ newVal = -1;
+ else
+ newVal = val * 4500;
+ device->generic.js.rgdwPOV[pov_idx] = newVal;
+ if (oldVal != newVal)
+ {
+ inst_id = DIDFT_MAKEINSTANCE(pov_idx) | DIDFT_POV;
+ queue_event(iface,inst_id,newVal,GetCurrentTime(),device->generic.base.dinput->evsequence++);
+ }
+ pov_idx ++;
+ break;
+ }
+ case kHIDUsage_GD_X:
+ case kHIDUsage_GD_Y:
+ case kHIDUsage_GD_Z:
+ case kHIDUsage_GD_Rx:
+ case kHIDUsage_GD_Ry:
+ case kHIDUsage_GD_Rz:
+ case kHIDUsage_GD_Slider:
+ {
+ int wine_obj = -1;
+
+ IOHIDDeviceGetValue(tIOHIDDeviceRef, tIOHIDElementRef, &valueRef);
+ val = IOHIDValueGetIntegerValue(valueRef);
+ newVal = joystick_map_axis(&device->generic.props[idx], val);
+ switch (usage)
+ {
+ case kHIDUsage_GD_X:
+ wine_obj = 0;
+ oldVal = device->generic.js.lX;
+ device->generic.js.lX = newVal;
+ break;
+ case kHIDUsage_GD_Y:
+ wine_obj = 1;
+ oldVal = device->generic.js.lY;
+ device->generic.js.lY = newVal;
+ break;
+ case kHIDUsage_GD_Z:
+ wine_obj = 2;
+ oldVal = device->generic.js.lZ;
+ device->generic.js.lZ = newVal;
+ break;
+ case kHIDUsage_GD_Rx:
+ wine_obj = 3;
+ oldVal = device->generic.js.lRx;
+ device->generic.js.lRx = newVal;
+ break;
+ case kHIDUsage_GD_Ry:
+ wine_obj = 4;
+ oldVal = device->generic.js.lRy;
+ device->generic.js.lRy = newVal;
+ break;
+ case kHIDUsage_GD_Rz:
+ wine_obj = 5;
+ oldVal = device->generic.js.lRz;
+ device->generic.js.lRz = newVal;
+ break;
+ case kHIDUsage_GD_Slider:
+ wine_obj = 6 + slider_idx;
+ oldVal = device->generic.js.rglSlider[slider_idx];
+ device->generic.js.rglSlider[slider_idx] = newVal;
+ slider_idx ++;
+ break;
+ }
+ if ((wine_obj != -1) &&
+ (oldVal != newVal))
+ {
+ inst_id = DIDFT_MAKEINSTANCE(wine_obj) | DIDFT_ABSAXIS;
+ queue_event(iface,inst_id,newVal,GetCurrentTime(),device->generic.base.dinput->evsequence++);
+ }
+
+ break;
+ }
+ default:
+ FIXME("unhandled usage %i\n",usage);
+ }
+ break;
+ }
+ default:
+ FIXME("Unhandled type %i\n",eleType);
+ }
+ }
+ }
+}
+
+static INT find_joystick_devices(void)
+{
+ static INT joystick_devices_count = -1;
+
+ if (joystick_devices_count != -1) return joystick_devices_count;
+
+ joystick_devices_count = find_osx_devices();
+
+ return joystick_devices_count;
+}
+
+static BOOL joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, DWORD version, int id)
+{
+ if (id >= find_joystick_devices()) return FALSE;
+
+ if (dwFlags & DIEDFL_FORCEFEEDBACK) {
+ WARN("force feedback not supported\n");
+ return FALSE;
+ }
+
+ if ((dwDevType == 0) ||
+ ((dwDevType == DIDEVTYPE_JOYSTICK) && (version > 0x0300 && version < 0x0800)) ||
+ (((dwDevType == DI8DEVCLASS_GAMECTRL) || (dwDevType == DI8DEVTYPE_JOYSTICK)) && (version >= 0x0800)))
+ {
+ /* Return joystick */
+ lpddi->guidInstance = DInput_Wine_OsX_Joystick_GUID;
+ lpddi->guidInstance.Data3 = id;
+ lpddi->guidProduct = DInput_Wine_OsX_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);
+ sprintf(lpddi->tszInstanceName, "Joystick %d", id);
+
+ /* get the device name */
+ get_osx_device_name(id, lpddi->tszProductName, MAX_PATH);
+
+ lpddi->guidFFDriver = GUID_NULL;
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static BOOL joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, DWORD version, int id)
+{
+ char name[MAX_PATH];
+ char friendly[32];
+
+ if (id >= find_joystick_devices()) return FALSE;
+
+ if (dwFlags & DIEDFL_FORCEFEEDBACK) {
+ WARN("force feedback not supported\n");
+ return FALSE;
+ }
+
+ if ((dwDevType == 0) ||
+ ((dwDevType == DIDEVTYPE_JOYSTICK) && (version > 0x0300 && version < 0x0800)) ||
+ (((dwDevType == DI8DEVCLASS_GAMECTRL) || (dwDevType == DI8DEVTYPE_JOYSTICK)) && (version >= 0x0800))) {
+ /* Return joystick */
+ lpddi->guidInstance = DInput_Wine_OsX_Joystick_GUID;
+ lpddi->guidInstance.Data3 = id;
+ lpddi->guidProduct = DInput_Wine_OsX_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);
+ sprintf(friendly, "Joystick %d", id);
+ MultiByteToWideChar(CP_ACP, 0, friendly, -1, lpddi->tszInstanceName, MAX_PATH);
+ /* get the device name */
+ get_osx_device_name(id, name, MAX_PATH);
+
+ MultiByteToWideChar(CP_ACP, 0, name, -1, lpddi->tszProductName, MAX_PATH);
+ lpddi->guidFFDriver = GUID_NULL;
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static HRESULT alloc_device(REFGUID rguid, IDirectInputImpl *dinput,
+ JoystickImpl **pdev, unsigned short index)
+{
+ DWORD i;
+ JoystickImpl* newDevice;
+ char name[MAX_PATH];
+ HRESULT hr;
+ LPDIDATAFORMAT df = NULL;
+ int idx = 0;
+ int axis_map[8]; /* max axes */
+ int slider_count = 0;
+
+ TRACE("%s %p %p %hu\n", debugstr_guid(rguid), dinput, pdev, index);
+
+ newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(JoystickImpl));
+ if (newDevice == 0) {
+ WARN("out of memory\n");
+ *pdev = 0;
+ return DIERR_OUTOFMEMORY;
+ }
+
+ newDevice->id = index;
+
+ newDevice->generic.guidInstance = DInput_Wine_OsX_Joystick_GUID;
+ newDevice->generic.guidInstance.Data3 = index;
+ newDevice->generic.guidProduct = DInput_Wine_OsX_Joystick_GUID;
+ newDevice->generic.joy_polldev = poll_osx_device_state;
+
+ /* get the device name */
+ get_osx_device_name(index, name, MAX_PATH);
+ TRACE("Name %s\n",name);
+
+ /* copy the device name */
+ newDevice->generic.name = HeapAlloc(GetProcessHeap(),0,strlen(name) + 1);
+ strcpy(newDevice->generic.name, name);
+
+ memset(axis_map, 0, sizeof(axis_map));
+ get_osx_device_elements(newDevice, axis_map);
+
+ TRACE("%i axes %i buttons %i povs\n",newDevice->generic.devcaps.dwAxes,newDevice->generic.devcaps.dwButtons,newDevice->generic.devcaps.dwPOVs);
+
+ if (newDevice->generic.devcaps.dwButtons > 128)
+ {
+ WARN("Can't support %d buttons. Clamping down to 128\n", newDevice->generic.devcaps.dwButtons);
+ newDevice->generic.devcaps.dwButtons = 128;
+ }
+
+ newDevice->generic.base.IDirectInputDevice8A_iface.lpVtbl = &JoystickAvt;
+ newDevice->generic.base.IDirectInputDevice8W_iface.lpVtbl = &JoystickWvt;
+ newDevice->generic.base.ref = 1;
+ newDevice->generic.base.dinput = dinput;
+ newDevice->generic.base.guid = *rguid;
+ InitializeCriticalSection(&newDevice->generic.base.crit);
+ newDevice->generic.base.crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": JoystickImpl*->generic.base.crit");
+
+ /* Create copy of default data format */
+ if (!(df = HeapAlloc(GetProcessHeap(), 0, c_dfDIJoystick2.dwSize))) goto FAILED;
+ memcpy(df, &c_dfDIJoystick2, c_dfDIJoystick2.dwSize);
+
+ df->dwNumObjs = newDevice->generic.devcaps.dwAxes + newDevice->generic.devcaps.dwPOVs + newDevice->generic.devcaps.dwButtons;
+ if (!(df->rgodf = HeapAlloc(GetProcessHeap(), 0, df->dwNumObjs * df->dwObjSize))) goto FAILED;
+
+ for (i = 0; i < newDevice->generic.devcaps.dwAxes; i++)
+ {
+ int wine_obj = -1;
+ switch (axis_map[i])
+ {
+ case kHIDUsage_GD_X: wine_obj = 0; break;
+ case kHIDUsage_GD_Y: wine_obj = 1; break;
+ case kHIDUsage_GD_Z: wine_obj = 2; break;
+ case kHIDUsage_GD_Rx: wine_obj = 3; break;
+ case kHIDUsage_GD_Ry: wine_obj = 4; break;
+ case kHIDUsage_GD_Rz: wine_obj = 5; break;
+ case kHIDUsage_GD_Slider:
+ wine_obj = 6 + slider_count;
+ slider_count++;
+ break;
+ }
+ if (wine_obj < 0 ) continue;
+
+ memcpy(&df->rgodf[idx], &c_dfDIJoystick2.rgodf[wine_obj], df->dwObjSize);
+ df->rgodf[idx++].dwType = DIDFT_MAKEINSTANCE(wine_obj) | DIDFT_ABSAXIS;
+ }
+
+ for (i = 0; i < newDevice->generic.devcaps.dwPOVs; i++)
+ {
+ memcpy(&df->rgodf[idx], &c_dfDIJoystick2.rgodf[i + 8], df->dwObjSize);
+ df->rgodf[idx++].dwType = DIDFT_MAKEINSTANCE(i) | DIDFT_POV;
+ }
+
+ for (i = 0; i < newDevice->generic.devcaps.dwButtons; i++)
+ {
+ memcpy(&df->rgodf[idx], &c_dfDIJoystick2.rgodf[i + 12], df->dwObjSize);
+ df->rgodf[idx ].pguid = &GUID_Button;
+ df->rgodf[idx++].dwType = DIDFT_MAKEINSTANCE(i) | DIDFT_PSHBUTTON;
+ }
+ newDevice->generic.base.data_format.wine_df = df;
+
+ /* initialize default properties */
+ get_osx_device_elements_props(newDevice);
+
+ IDirectInput_AddRef(&newDevice->generic.base.dinput->IDirectInput7A_iface);
+
+ EnterCriticalSection(&dinput->crit);
+ list_add_tail(&dinput->devices_list, &newDevice->generic.base.entry);
+ LeaveCriticalSection(&dinput->crit);
+
+ newDevice->generic.devcaps.dwSize = sizeof(newDevice->generic.devcaps);
+ newDevice->generic.devcaps.dwFlags = DIDC_ATTACHED;
+ if (newDevice->generic.base.dinput->dwVersion >= 0x0800)
+ newDevice->generic.devcaps.dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8);
+ else
+ newDevice->generic.devcaps.dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
+ newDevice->generic.devcaps.dwFFSamplePeriod = 0;
+ newDevice->generic.devcaps.dwFFMinTimeResolution = 0;
+ newDevice->generic.devcaps.dwFirmwareRevision = 0;
+ newDevice->generic.devcaps.dwHardwareRevision = 0;
+ newDevice->generic.devcaps.dwFFDriverVersion = 0;
+
+ if (TRACE_ON(dinput)) {
+ _dump_DIDATAFORMAT(newDevice->generic.base.data_format.wine_df);
+ _dump_DIDEVCAPS(&newDevice->generic.devcaps);
+ }
+
+ *pdev = newDevice;
+
+ return DI_OK;
+
+FAILED:
+ hr = DIERR_OUTOFMEMORY;
+ if (df) HeapFree(GetProcessHeap(), 0, df->rgodf);
+ HeapFree(GetProcessHeap(), 0, df);
+ release_DataFormat(&newDevice->generic.base.data_format);
+ HeapFree(GetProcessHeap(),0,newDevice->generic.name);
+ HeapFree(GetProcessHeap(),0,newDevice);
+ *pdev = 0;
+
+ return hr;
+}
+
+/******************************************************************************
+ * get_joystick_index : Get the joystick index from a given GUID
+ */
+static unsigned short get_joystick_index(REFGUID guid)
+{
+ GUID wine_joystick = DInput_Wine_OsX_Joystick_GUID;
+ GUID dev_guid = *guid;
+
+ wine_joystick.Data3 = 0;
+ dev_guid.Data3 = 0;
+
+ /* for the standard joystick GUID use index 0 */
+ if(IsEqualGUID(&GUID_Joystick,guid)) return 0;
+
+ /* for the wine joystick GUIDs use the index stored in Data3 */
+ if(IsEqualGUID(&wine_joystick, &dev_guid)) return guid->Data3;
+
+ return 0xffff;
+}
+
+static HRESULT joydev_create_device(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPVOID *pdev, int unicode)
+{
+ unsigned short index;
+ int joystick_devices_count;
+
+ TRACE("%p %s %s %p %i\n", dinput, debugstr_guid(rguid), debugstr_guid(riid), pdev, unicode);
+ *pdev = NULL;
+
+ if ((joystick_devices_count = find_joystick_devices()) == 0)
+ return DIERR_DEVICENOTREG;
+
+ if ((index = get_joystick_index(rguid)) < 0xffff &&
+ joystick_devices_count && index < joystick_devices_count)
+ {
+ JoystickImpl *This;
+ HRESULT hr;
+
+ if (riid == NULL)
+ ;/* nothing */
+ else if (IsEqualGUID(&IID_IDirectInputDeviceA, riid) ||
+ IsEqualGUID(&IID_IDirectInputDevice2A, riid) ||
+ IsEqualGUID(&IID_IDirectInputDevice7A, riid) ||
+ IsEqualGUID(&IID_IDirectInputDevice8A, riid))
+ {
+ unicode = 0;
+ }
+ else if (IsEqualGUID(&IID_IDirectInputDeviceW, riid) ||
+ IsEqualGUID(&IID_IDirectInputDevice2W, riid) ||
+ IsEqualGUID(&IID_IDirectInputDevice7W, riid) ||
+ IsEqualGUID(&IID_IDirectInputDevice8W, riid))
+ {
+ unicode = 1;
+ }
+ else
+ {
+ WARN("no interface\n");
+ return DIERR_NOINTERFACE;
+ }
+
+ hr = alloc_device(rguid, dinput, &This, index);
+ if (!This) return hr;
+
+ if (unicode)
+ *pdev = &This->generic.base.IDirectInputDevice8W_iface;
+ else
+ *pdev = &This->generic.base.IDirectInputDevice8A_iface;
+ return hr;
+ }
+
+ return DIERR_DEVICENOTREG;
+}
+
+const struct dinput_device joystick_osx_device = {
+ "Wine OS X joystick driver",
+ joydev_enum_deviceA,
+ joydev_enum_deviceW,
+ joydev_create_device
+};
+
+static const IDirectInputDevice8AVtbl JoystickAvt =
+{
+ IDirectInputDevice2AImpl_QueryInterface,
+ IDirectInputDevice2AImpl_AddRef,
+ IDirectInputDevice2AImpl_Release,
+ JoystickAGenericImpl_GetCapabilities,
+ IDirectInputDevice2AImpl_EnumObjects,
+ JoystickAGenericImpl_GetProperty,
+ JoystickAGenericImpl_SetProperty,
+ IDirectInputDevice2AImpl_Acquire,
+ IDirectInputDevice2AImpl_Unacquire,
+ JoystickAGenericImpl_GetDeviceState,
+ IDirectInputDevice2AImpl_GetDeviceData,
+ IDirectInputDevice2AImpl_SetDataFormat,
+ IDirectInputDevice2AImpl_SetEventNotification,
+ IDirectInputDevice2AImpl_SetCooperativeLevel,
+ JoystickAGenericImpl_GetObjectInfo,
+ JoystickAGenericImpl_GetDeviceInfo,
+ IDirectInputDevice2AImpl_RunControlPanel,
+ IDirectInputDevice2AImpl_Initialize,
+ IDirectInputDevice2AImpl_CreateEffect,
+ IDirectInputDevice2AImpl_EnumEffects,
+ IDirectInputDevice2AImpl_GetEffectInfo,
+ IDirectInputDevice2AImpl_GetForceFeedbackState,
+ IDirectInputDevice2AImpl_SendForceFeedbackCommand,
+ IDirectInputDevice2AImpl_EnumCreatedEffectObjects,
+ IDirectInputDevice2AImpl_Escape,
+ JoystickAGenericImpl_Poll,
+ IDirectInputDevice2AImpl_SendDeviceData,
+ IDirectInputDevice7AImpl_EnumEffectsInFile,
+ IDirectInputDevice7AImpl_WriteEffectToFile,
+ JoystickAGenericImpl_BuildActionMap,
+ JoystickAGenericImpl_SetActionMap,
+ IDirectInputDevice8AImpl_GetImageInfo
+};
+
+static const IDirectInputDevice8WVtbl JoystickWvt =
+{
+ IDirectInputDevice2WImpl_QueryInterface,
+ IDirectInputDevice2WImpl_AddRef,
+ IDirectInputDevice2WImpl_Release,
+ JoystickWGenericImpl_GetCapabilities,
+ IDirectInputDevice2WImpl_EnumObjects,
+ JoystickWGenericImpl_GetProperty,
+ JoystickWGenericImpl_SetProperty,
+ IDirectInputDevice2WImpl_Acquire,
+ IDirectInputDevice2WImpl_Unacquire,
+ JoystickWGenericImpl_GetDeviceState,
+ IDirectInputDevice2WImpl_GetDeviceData,
+ IDirectInputDevice2WImpl_SetDataFormat,
+ IDirectInputDevice2WImpl_SetEventNotification,
+ IDirectInputDevice2WImpl_SetCooperativeLevel,
+ JoystickWGenericImpl_GetObjectInfo,
+ JoystickWGenericImpl_GetDeviceInfo,
+ IDirectInputDevice2WImpl_RunControlPanel,
+ IDirectInputDevice2WImpl_Initialize,
+ IDirectInputDevice2WImpl_CreateEffect,
+ IDirectInputDevice2WImpl_EnumEffects,
+ IDirectInputDevice2WImpl_GetEffectInfo,
+ IDirectInputDevice2WImpl_GetForceFeedbackState,
+ IDirectInputDevice2WImpl_SendForceFeedbackCommand,
+ IDirectInputDevice2WImpl_EnumCreatedEffectObjects,
+ IDirectInputDevice2WImpl_Escape,
+ JoystickWGenericImpl_Poll,
+ IDirectInputDevice2WImpl_SendDeviceData,
+ IDirectInputDevice7WImpl_EnumEffectsInFile,
+ IDirectInputDevice7WImpl_WriteEffectToFile,
+ JoystickWGenericImpl_BuildActionMap,
+ JoystickWGenericImpl_SetActionMap,
+ IDirectInputDevice8WImpl_GetImageInfo
+};
+
+#else /* HAVE_IOHIDMANAGERCREATE */
+
+const struct dinput_device joystick_osx_device = {
+ "Wine OS X joystick driver",
+ NULL,
+ NULL,
+ NULL
+};
+
+#endif /* HAVE_IOHIDMANAGERCREATE */
--- /dev/null
+/*
+ * Copyright 2009, Aric Stewart, CodeWeavers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#ifndef __WINE_DLLS_DINPUT_JOYSTICK_PRIVATE_H
+#define __WINE_DLLS_DINPUT_JOYSTICK_PRIVATE_H
+
+#include <stdarg.h>
+
+#define WIN32_NO_STATUS
+#define _INC_WINDOWS
+#define COM_NO_WINDOWS_H
+
+#include "windef.h"
+#include "winbase.h"
+#include "dinput.h"
+#include "wine/list.h"
+#include "wine/unicode.h"
+#include "dinput_private.h"
+#include "device_private.h"
+
+/* Number of objects in the default data format */
+#define MAX_PROPS 164
+struct JoystickGenericImpl;
+
+typedef void joy_polldev_handler(LPDIRECTINPUTDEVICE8A iface);
+
+typedef struct JoystickGenericImpl
+{
+ struct IDirectInputDeviceImpl base;
+
+ ObjProps props[MAX_PROPS];
+ DIDEVCAPS devcaps;
+ DIJOYSTATE2 js; /* wine data */
+ GUID guidProduct;
+ GUID guidInstance;
+ char *name;
+ int device_axis_count; /* Total number of axes in the device */
+ int *axis_map; /* User axes remapping */
+ LONG deadzone; /* Default dead-zone */
+
+ joy_polldev_handler *joy_polldev;
+} JoystickGenericImpl;
+
+LONG joystick_map_axis(ObjProps *props, int val) DECLSPEC_HIDDEN;
+HRESULT setup_dinput_options(JoystickGenericImpl *This, const int *default_axis_map) DECLSPEC_HIDDEN;
+
+DWORD joystick_map_pov(const POINTL *p) DECLSPEC_HIDDEN;
+
+BOOL device_disabled_registry(const char* name) DECLSPEC_HIDDEN;
+
+HRESULT WINAPI JoystickWGenericImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface,
+ LPDIDEVICEOBJECTINSTANCEW pdidoi, DWORD dwObj, DWORD dwHow) DECLSPEC_HIDDEN;
+
+HRESULT WINAPI JoystickAGenericImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8A iface,
+ LPDIDEVICEOBJECTINSTANCEA pdidoi, DWORD dwObj, DWORD dwHow) DECLSPEC_HIDDEN;
+
+HRESULT WINAPI JoystickAGenericImpl_GetProperty(LPDIRECTINPUTDEVICE8A iface, REFGUID rguid, LPDIPROPHEADER pdiph) DECLSPEC_HIDDEN;
+HRESULT WINAPI JoystickWGenericImpl_GetProperty(LPDIRECTINPUTDEVICE8W iface, REFGUID rguid, LPDIPROPHEADER pdiph) DECLSPEC_HIDDEN;
+
+HRESULT WINAPI JoystickAGenericImpl_GetCapabilities(LPDIRECTINPUTDEVICE8A iface, LPDIDEVCAPS lpDIDevCaps) DECLSPEC_HIDDEN;
+HRESULT WINAPI JoystickWGenericImpl_GetCapabilities(LPDIRECTINPUTDEVICE8W iface, LPDIDEVCAPS lpDIDevCaps) DECLSPEC_HIDDEN;
+
+void _dump_DIDEVCAPS(const DIDEVCAPS *lpDIDevCaps) DECLSPEC_HIDDEN;
+
+HRESULT WINAPI JoystickAGenericImpl_SetProperty(LPDIRECTINPUTDEVICE8A iface, REFGUID rguid, LPCDIPROPHEADER ph) DECLSPEC_HIDDEN;
+HRESULT WINAPI JoystickWGenericImpl_SetProperty(LPDIRECTINPUTDEVICE8W iface, REFGUID rguid, LPCDIPROPHEADER ph) DECLSPEC_HIDDEN;
+
+HRESULT WINAPI JoystickAGenericImpl_GetDeviceInfo( LPDIRECTINPUTDEVICE8A iface,
+ LPDIDEVICEINSTANCEA pdidi) DECLSPEC_HIDDEN;
+
+HRESULT WINAPI JoystickWGenericImpl_GetDeviceInfo( LPDIRECTINPUTDEVICE8W iface,
+ LPDIDEVICEINSTANCEW pdidi) DECLSPEC_HIDDEN;
+
+HRESULT WINAPI JoystickAGenericImpl_Poll(LPDIRECTINPUTDEVICE8A iface) DECLSPEC_HIDDEN;
+HRESULT WINAPI JoystickWGenericImpl_Poll(LPDIRECTINPUTDEVICE8W iface) DECLSPEC_HIDDEN;
+
+HRESULT WINAPI JoystickAGenericImpl_GetDeviceState(LPDIRECTINPUTDEVICE8A iface, DWORD len, LPVOID ptr) DECLSPEC_HIDDEN;
+HRESULT WINAPI JoystickWGenericImpl_GetDeviceState(LPDIRECTINPUTDEVICE8W iface, DWORD len, LPVOID ptr) DECLSPEC_HIDDEN;
+
+HRESULT WINAPI JoystickAGenericImpl_BuildActionMap(LPDIRECTINPUTDEVICE8A iface, LPDIACTIONFORMATA lpdiaf, LPCSTR lpszUserName, DWORD dwFlags) DECLSPEC_HIDDEN;
+HRESULT WINAPI JoystickWGenericImpl_BuildActionMap(LPDIRECTINPUTDEVICE8W iface, LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, DWORD dwFlags) DECLSPEC_HIDDEN;
+
+HRESULT WINAPI JoystickAGenericImpl_SetActionMap(LPDIRECTINPUTDEVICE8A iface, LPDIACTIONFORMATA lpdiaf, LPCSTR lpszUserName, DWORD dwFlags) DECLSPEC_HIDDEN;
+HRESULT WINAPI JoystickWGenericImpl_SetActionMap(LPDIRECTINPUTDEVICE8W iface, LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, DWORD dwFlags) DECLSPEC_HIDDEN;
+
+#endif /* __WINE_DLLS_DINPUT_JOYSTICK_PRIVATE_H */
#include <config.h>
//#include "wine/port.h"
-//#include <stdarg.h>
+#include <stdarg.h>
//#include <string.h>
-//#include "windef.h"
-//#include "winbase.h"
-//#include "winuser.h"
+#include <windef.h>
+#include <winbase.h>
+#include <winuser.h>
+#include <winnls.h>
//#include "winerror.h"
//#include "dinput.h"
typedef struct SysKeyboardImpl SysKeyboardImpl;
struct SysKeyboardImpl
{
- struct IDirectInputDevice2AImpl base;
+ struct IDirectInputDeviceImpl base;
BYTE DInputKeyState[WINE_DINPUT_KEYBOARD_MAX_KEYS];
};
+static inline SysKeyboardImpl *impl_from_IDirectInputDevice8A(IDirectInputDevice8A *iface)
+{
+ return CONTAINING_RECORD(CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8A_iface), SysKeyboardImpl, base);
+}
+static inline SysKeyboardImpl *impl_from_IDirectInputDevice8W(IDirectInputDevice8W *iface)
+{
+ return CONTAINING_RECORD(CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8W_iface), SysKeyboardImpl, base);
+}
+static inline IDirectInputDevice8A *IDirectInputDevice8A_from_impl(SysKeyboardImpl *This)
+{
+ return &This->base.IDirectInputDevice8A_iface;
+}
+static inline IDirectInputDevice8W *IDirectInputDevice8W_from_impl(SysKeyboardImpl *This)
+{
+ return &This->base.IDirectInputDevice8W_iface;
+}
+
static BYTE map_dik_code(DWORD scanCode, DWORD vkCode)
{
static const BYTE asciiCodes[] =
return out_code;
}
-static void KeyboardCallback( LPDIRECTINPUTDEVICE8A iface, WPARAM wparam, LPARAM lparam )
+static int KeyboardCallback( LPDIRECTINPUTDEVICE8A iface, WPARAM wparam, LPARAM lparam )
{
- SysKeyboardImpl *This = (SysKeyboardImpl *)iface;
- int dik_code;
+ SysKeyboardImpl *This = impl_from_IDirectInputDevice8A(iface);
+ int dik_code, ret = This->base.dwCoopLevel & DISCL_EXCLUSIVE;
KBDLLHOOKSTRUCT *hook = (KBDLLHOOKSTRUCT *)lparam;
BYTE new_diks;
if (wparam != WM_KEYDOWN && wparam != WM_KEYUP &&
wparam != WM_SYSKEYDOWN && wparam != WM_SYSKEYUP)
- return;
+ return 0;
TRACE("(%p) %ld,%ld\n", iface, wparam, lparam);
- dik_code = map_dik_code(hook->scanCode & 0xff,hook->vkCode);
- /* R-Shift is special - it is an extended key with separate scan code */
- if (hook->flags & LLKHF_EXTENDED && dik_code != 0x36)
- dik_code |= 0x80;
-
+ switch (hook->vkCode)
+ {
+ /* R-Shift is special - it is an extended key with separate scan code */
+ case VK_RSHIFT : dik_code = DIK_RSHIFT; break;
+ case VK_PAUSE : dik_code = DIK_PAUSE; break;
+ case VK_NUMLOCK : dik_code = DIK_NUMLOCK; break;
+ case VK_SUBTRACT: dik_code = DIK_SUBTRACT; break;
+ default:
+ dik_code = map_dik_code(hook->scanCode & 0xff, hook->vkCode);
+ if (hook->flags & LLKHF_EXTENDED) dik_code |= 0x80;
+ }
new_diks = hook->flags & LLKHF_UP ? 0 : 0x80;
/* returns now if key event already known */
if (new_diks == This->DInputKeyState[dik_code])
- return;
+ return ret;
This->DInputKeyState[dik_code] = new_diks;
TRACE(" setting %02X to %02X\n", dik_code, This->DInputKeyState[dik_code]);
-
- dik_code = id_to_offset(&This->base.data_format, DIDFT_MAKEINSTANCE(dik_code) | DIDFT_PSHBUTTON);
+
EnterCriticalSection(&This->base.crit);
- queue_event((LPDIRECTINPUTDEVICE8A)This, dik_code, new_diks, hook->time, This->base.dinput->evsequence++);
+ queue_event(iface, DIDFT_MAKEINSTANCE(dik_code) | DIDFT_PSHBUTTON,
+ new_diks, hook->time, This->base.dinput->evsequence++);
LeaveCriticalSection(&This->base.crit);
+
+ return ret;
}
const GUID DInput_Wine_Keyboard_GUID = { /* 0ab8648a-7735-11d2-8c73-71df54a96441 */
return FALSE;
}
-static SysKeyboardImpl *alloc_device(REFGUID rguid, const void *kvt, IDirectInputImpl *dinput)
+static SysKeyboardImpl *alloc_device(REFGUID rguid, IDirectInputImpl *dinput)
{
SysKeyboardImpl* newDevice;
LPDIDATAFORMAT df = NULL;
int i, idx = 0;
newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(SysKeyboardImpl));
- newDevice->base.lpVtbl = kvt;
+ newDevice->base.IDirectInputDevice8A_iface.lpVtbl = &SysKeyboardAvt;
+ newDevice->base.IDirectInputDevice8W_iface.lpVtbl = &SysKeyboardWvt;
newDevice->base.ref = 1;
memcpy(&newDevice->base.guid, rguid, sizeof(*rguid));
newDevice->base.dinput = dinput;
df->dwNumObjs = idx;
newDevice->base.data_format.wine_df = df;
- IDirectInput_AddRef((LPDIRECTINPUTDEVICE8A)newDevice->base.dinput);
+ IDirectInput_AddRef(&newDevice->base.dinput->IDirectInput7A_iface);
+
+ EnterCriticalSection(&dinput->crit);
+ list_add_tail(&dinput->devices_list, &newDevice->base.entry);
+ LeaveCriticalSection(&dinput->crit);
+
return newDevice;
failed:
}
-static HRESULT keyboarddev_create_deviceA(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEA* pdev)
+static HRESULT keyboarddev_create_device(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPVOID *pdev, int unicode)
{
- if ((IsEqualGUID(&GUID_SysKeyboard,rguid)) || /* Generic Keyboard */
- (IsEqualGUID(&DInput_Wine_Keyboard_GUID,rguid))) { /* Wine Keyboard */
- if ((riid == NULL) ||
- IsEqualGUID(&IID_IDirectInputDeviceA,riid) ||
- IsEqualGUID(&IID_IDirectInputDevice2A,riid) ||
- IsEqualGUID(&IID_IDirectInputDevice7A,riid) ||
- IsEqualGUID(&IID_IDirectInputDevice8A,riid)) {
- *pdev = (IDirectInputDeviceA*) alloc_device(rguid, &SysKeyboardAvt, dinput);
- TRACE("Creating a Keyboard device (%p)\n", *pdev);
- if (!*pdev) return DIERR_OUTOFMEMORY;
- return DI_OK;
- } else
- return DIERR_NOINTERFACE;
- }
- return DIERR_DEVICENOTREG;
-}
+ TRACE("%p %s %s %p %i\n", dinput, debugstr_guid(rguid), debugstr_guid(riid), pdev, unicode);
+ *pdev = NULL;
-static HRESULT keyboarddev_create_deviceW(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEW* pdev)
-{
- if ((IsEqualGUID(&GUID_SysKeyboard,rguid)) || /* Generic Keyboard */
- (IsEqualGUID(&DInput_Wine_Keyboard_GUID,rguid))) { /* Wine Keyboard */
- if ((riid == NULL) ||
- IsEqualGUID(&IID_IDirectInputDeviceW,riid) ||
- IsEqualGUID(&IID_IDirectInputDevice2W,riid) ||
- IsEqualGUID(&IID_IDirectInputDevice7W,riid) ||
- IsEqualGUID(&IID_IDirectInputDevice8W,riid)) {
- *pdev = (IDirectInputDeviceW*) alloc_device(rguid, &SysKeyboardWvt, dinput);
- TRACE("Creating a Keyboard device (%p)\n", *pdev);
- if (!*pdev) return DIERR_OUTOFMEMORY;
- return DI_OK;
- } else
- return DIERR_NOINTERFACE;
- }
- return DIERR_DEVICENOTREG;
+ if (IsEqualGUID(&GUID_SysKeyboard, rguid) || /* Generic Keyboard */
+ IsEqualGUID(&DInput_Wine_Keyboard_GUID, rguid)) /* Wine Keyboard */
+ {
+ SysKeyboardImpl *This;
+
+ if (riid == NULL)
+ ;/* nothing */
+ else if (IsEqualGUID(&IID_IDirectInputDeviceA, riid) ||
+ IsEqualGUID(&IID_IDirectInputDevice2A, riid) ||
+ IsEqualGUID(&IID_IDirectInputDevice7A, riid) ||
+ IsEqualGUID(&IID_IDirectInputDevice8A, riid))
+ {
+ unicode = 0;
+ }
+ else if (IsEqualGUID(&IID_IDirectInputDeviceW, riid) ||
+ IsEqualGUID(&IID_IDirectInputDevice2W, riid) ||
+ IsEqualGUID(&IID_IDirectInputDevice7W, riid) ||
+ IsEqualGUID(&IID_IDirectInputDevice8W, riid))
+ {
+ unicode = 1;
+ }
+ else
+ {
+ WARN("no interface\n");
+ return DIERR_NOINTERFACE;
+ }
+
+ This = alloc_device(rguid, dinput);
+ TRACE("Created a Keyboard device (%p)\n", This);
+
+ if (!This) return DIERR_OUTOFMEMORY;
+
+ if (unicode)
+ *pdev = &This->base.IDirectInputDevice8W_iface;
+ else
+ *pdev = &This->base.IDirectInputDevice8A_iface;
+
+ return DI_OK;
+ }
+
+ return DIERR_DEVICENOTREG;
}
const struct dinput_device keyboard_device = {
"Wine keyboard driver",
keyboarddev_enum_deviceA,
keyboarddev_enum_deviceW,
- keyboarddev_create_deviceA,
- keyboarddev_create_deviceW
+ keyboarddev_create_device
};
-static HRESULT WINAPI SysKeyboardAImpl_GetDeviceState(
- LPDIRECTINPUTDEVICE8A iface,DWORD len,LPVOID ptr
-)
+static HRESULT WINAPI SysKeyboardWImpl_GetDeviceState(LPDIRECTINPUTDEVICE8W iface, DWORD len, LPVOID ptr)
{
- SysKeyboardImpl *This = (SysKeyboardImpl *)iface;
+ SysKeyboardImpl *This = impl_from_IDirectInputDevice8W(iface);
TRACE("(%p)->(%d,%p)\n", This, len, ptr);
if (!This->base.acquired) return DIERR_NOTACQUIRED;
return DI_OK;
}
+static HRESULT WINAPI SysKeyboardAImpl_GetDeviceState(LPDIRECTINPUTDEVICE8A iface, DWORD len, LPVOID ptr)
+{
+ SysKeyboardImpl *This = impl_from_IDirectInputDevice8A(iface);
+ return SysKeyboardWImpl_GetDeviceState(IDirectInputDevice8W_from_impl(This), len, ptr);
+}
+
/******************************************************************************
* GetCapabilities : get the device capabilities
*/
-static HRESULT WINAPI SysKeyboardAImpl_GetCapabilities(
- LPDIRECTINPUTDEVICE8A iface,
- LPDIDEVCAPS lpDIDevCaps)
+static HRESULT WINAPI SysKeyboardWImpl_GetCapabilities(LPDIRECTINPUTDEVICE8W iface, LPDIDEVCAPS lpDIDevCaps)
{
- SysKeyboardImpl *This = (SysKeyboardImpl *)iface;
+ SysKeyboardImpl *This = impl_from_IDirectInputDevice8W(iface);
DIDEVCAPS devcaps;
TRACE("(this=%p,%p)\n",This,lpDIDevCaps);
WARN("invalid parameter\n");
return DIERR_INVALIDPARAM;
}
-
+
devcaps.dwSize = lpDIDevCaps->dwSize;
- devcaps.dwFlags = DIDC_ATTACHED;
+ devcaps.dwFlags = DIDC_ATTACHED | DIDC_EMULATED;
if (This->base.dinput->dwVersion >= 0x0800)
- devcaps.dwDevType = DI8DEVTYPE_KEYBOARD | (DI8DEVTYPEKEYBOARD_UNKNOWN << 8);
+ devcaps.dwDevType = DI8DEVTYPE_KEYBOARD | (DI8DEVTYPEKEYBOARD_PCENH << 8);
else
- devcaps.dwDevType = DIDEVTYPE_KEYBOARD | (DIDEVTYPEKEYBOARD_UNKNOWN << 8);
+ devcaps.dwDevType = DIDEVTYPE_KEYBOARD | (DIDEVTYPEKEYBOARD_PCENH << 8);
devcaps.dwAxes = 0;
devcaps.dwButtons = This->base.data_format.wine_df->dwNumObjs;
devcaps.dwPOVs = 0;
devcaps.dwFFDriverVersion = 0;
memcpy(lpDIDevCaps, &devcaps, lpDIDevCaps->dwSize);
-
+
return DI_OK;
}
+static HRESULT WINAPI SysKeyboardAImpl_GetCapabilities(LPDIRECTINPUTDEVICE8A iface, LPDIDEVCAPS lpDIDevCaps)
+{
+ SysKeyboardImpl *This = impl_from_IDirectInputDevice8A(iface);
+ return SysKeyboardWImpl_GetCapabilities(IDirectInputDevice8W_from_impl(This), lpDIDevCaps);
+}
+
/******************************************************************************
* GetObjectInfo : get information about a device object such as a button
* or axis
DWORD dwHow)
{
HRESULT res;
+ LONG scan;
res = IDirectInputDevice2AImpl_GetObjectInfo(iface, pdidoi, dwObj, dwHow);
if (res != DI_OK) return res;
- if (!GetKeyNameTextA((DIDFT_GETINSTANCE(pdidoi->dwType) & 0x80) << 17 |
- (DIDFT_GETINSTANCE(pdidoi->dwType) & 0x7f) << 16,
+ scan = DIDFT_GETINSTANCE(pdidoi->dwType);
+ if (scan == DIK_PAUSE || scan == DIK_NUMLOCK) scan ^= 0x80;
+ if (!GetKeyNameTextA((scan & 0x80) << 17 | (scan & 0x7f) << 16,
pdidoi->tszName, sizeof(pdidoi->tszName)))
return DIERR_OBJECTNOTFOUND;
DWORD dwHow)
{
HRESULT res;
+ LONG scan;
res = IDirectInputDevice2WImpl_GetObjectInfo(iface, pdidoi, dwObj, dwHow);
if (res != DI_OK) return res;
- if (!GetKeyNameTextW((DIDFT_GETINSTANCE(pdidoi->dwType) & 0x80) << 17 |
- (DIDFT_GETINSTANCE(pdidoi->dwType) & 0x7f) << 16,
- pdidoi->tszName,
- sizeof(pdidoi->tszName)/sizeof(pdidoi->tszName[0])))
+ scan = DIDFT_GETINSTANCE(pdidoi->dwType);
+ if (scan == DIK_PAUSE || scan == DIK_NUMLOCK) scan ^= 0x80;
+ if (!GetKeyNameTextW((scan & 0x80) << 17 | (scan & 0x7f) << 16,
+ pdidoi->tszName, sizeof(pdidoi->tszName)))
return DIERR_OBJECTNOTFOUND;
_dump_OBJECTINSTANCEW(pdidoi);
LPDIRECTINPUTDEVICE8A iface,
LPDIDEVICEINSTANCEA pdidi)
{
- SysKeyboardImpl *This = (SysKeyboardImpl *)iface;
+ SysKeyboardImpl *This = impl_from_IDirectInputDevice8A(iface);
TRACE("(this=%p,%p)\n", This, pdidi);
if (pdidi->dwSize != sizeof(DIDEVICEINSTANCEA)) {
return DI_OK;
}
-static HRESULT WINAPI SysKeyboardWImpl_GetDeviceInfo(LPDIRECTINPUTDEVICE8W iface, LPDIDEVICEINSTANCEW pdidi)
+static HRESULT WINAPI SysKeyboardWImpl_GetDeviceInfo(LPDIRECTINPUTDEVICE8W iface, LPDIDEVICEINSTANCEW pdidi)
{
- SysKeyboardImpl *This = (SysKeyboardImpl *)iface;
+ SysKeyboardImpl *This = impl_from_IDirectInputDevice8W(iface);
TRACE("(this=%p,%p)\n", This, pdidi);
if (pdidi->dwSize != sizeof(DIDEVICEINSTANCEW)) {
/******************************************************************************
* GetProperty : Retrieves information about the input device.
*/
-static HRESULT WINAPI SysKeyboardAImpl_GetProperty(LPDIRECTINPUTDEVICE8A iface,
- REFGUID rguid, LPDIPROPHEADER pdiph)
+static HRESULT WINAPI SysKeyboardWImpl_GetProperty(LPDIRECTINPUTDEVICE8W iface,
+ REFGUID rguid, LPDIPROPHEADER pdiph)
{
+ SysKeyboardImpl *This = impl_from_IDirectInputDevice8W(iface);
+
TRACE("(%p) %s,%p\n", iface, debugstr_guid(rguid), pdiph);
_dump_DIPROPHEADER(pdiph);
- if (HIWORD(rguid)) return DI_OK;
+ if (!IS_DIPROP(rguid)) return DI_OK;
switch (LOWORD(rguid))
{
didoi.dwSize = sizeof(DIDEVICEOBJECTINSTANCEW);
- hr = SysKeyboardWImpl_GetObjectInfo((LPDIRECTINPUTDEVICE8W)iface , &didoi,
- ps->diph.dwObj, ps->diph.dwHow);
+ hr = SysKeyboardWImpl_GetObjectInfo(iface, &didoi, ps->diph.dwObj, ps->diph.dwHow);
if (hr == DI_OK)
memcpy(ps->wsz, didoi.tszName, sizeof(ps->wsz));
return hr;
}
+ case (DWORD_PTR) DIPROP_RANGE:
+ return DIERR_UNSUPPORTED;
default:
- return IDirectInputDevice2AImpl_GetProperty( iface, rguid, pdiph );
+ return IDirectInputDevice2AImpl_GetProperty( IDirectInputDevice8A_from_impl(This), rguid, pdiph );
}
return DI_OK;
}
+static HRESULT WINAPI SysKeyboardAImpl_GetProperty(LPDIRECTINPUTDEVICE8A iface,
+ REFGUID rguid, LPDIPROPHEADER pdiph)
+{
+ SysKeyboardImpl *This = impl_from_IDirectInputDevice8A(iface);
+ return SysKeyboardWImpl_GetProperty(IDirectInputDevice8W_from_impl(This), rguid, pdiph);
+}
+
+static HRESULT WINAPI SysKeyboardWImpl_BuildActionMap(LPDIRECTINPUTDEVICE8W iface,
+ LPDIACTIONFORMATW lpdiaf,
+ LPCWSTR lpszUserName,
+ DWORD dwFlags)
+{
+ FIXME("(%p)->(%p,%s,%08x): semi-stub !\n", iface, lpdiaf, debugstr_w(lpszUserName), dwFlags);
+
+ return _build_action_map(iface, lpdiaf, lpszUserName, dwFlags, DIKEYBOARD_MASK, &c_dfDIKeyboard);
+}
+
+static HRESULT WINAPI SysKeyboardAImpl_BuildActionMap(LPDIRECTINPUTDEVICE8A iface,
+ LPDIACTIONFORMATA lpdiaf,
+ LPCSTR lpszUserName,
+ DWORD dwFlags)
+{
+ SysKeyboardImpl *This = impl_from_IDirectInputDevice8A(iface);
+ DIACTIONFORMATW diafW;
+ HRESULT hr;
+ WCHAR *lpszUserNameW = NULL;
+ int username_size;
+
+ diafW.rgoAction = HeapAlloc(GetProcessHeap(), 0, sizeof(DIACTIONW)*lpdiaf->dwNumActions);
+ _copy_diactionformatAtoW(&diafW, lpdiaf);
+
+ if (lpszUserName != NULL)
+ {
+ username_size = MultiByteToWideChar(CP_ACP, 0, lpszUserName, -1, NULL, 0);
+ lpszUserNameW = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*username_size);
+ MultiByteToWideChar(CP_ACP, 0, lpszUserName, -1, lpszUserNameW, username_size);
+ }
+
+ hr = SysKeyboardWImpl_BuildActionMap(&This->base.IDirectInputDevice8W_iface, &diafW, lpszUserNameW, dwFlags);
+
+ _copy_diactionformatWtoA(lpdiaf, &diafW);
+ HeapFree(GetProcessHeap(), 0, diafW.rgoAction);
+ HeapFree(GetProcessHeap(), 0, lpszUserNameW);
+
+ return hr;
+}
+
+static HRESULT WINAPI SysKeyboardWImpl_SetActionMap(LPDIRECTINPUTDEVICE8W iface,
+ LPDIACTIONFORMATW lpdiaf,
+ LPCWSTR lpszUserName,
+ DWORD dwFlags)
+{
+ FIXME("(%p)->(%p,%s,%08x): semi-stub !\n", iface, lpdiaf, debugstr_w(lpszUserName), dwFlags);
+
+ return _set_action_map(iface, lpdiaf, lpszUserName, dwFlags, &c_dfDIKeyboard);
+}
+
+static HRESULT WINAPI SysKeyboardAImpl_SetActionMap(LPDIRECTINPUTDEVICE8A iface,
+ LPDIACTIONFORMATA lpdiaf,
+ LPCSTR lpszUserName,
+ DWORD dwFlags)
+{
+ SysKeyboardImpl *This = impl_from_IDirectInputDevice8A(iface);
+ DIACTIONFORMATW diafW;
+ HRESULT hr;
+ WCHAR *lpszUserNameW = NULL;
+ int username_size;
+
+ diafW.rgoAction = HeapAlloc(GetProcessHeap(), 0, sizeof(DIACTIONW)*lpdiaf->dwNumActions);
+ _copy_diactionformatAtoW(&diafW, lpdiaf);
+
+ if (lpszUserName != NULL)
+ {
+ username_size = MultiByteToWideChar(CP_ACP, 0, lpszUserName, -1, NULL, 0);
+ lpszUserNameW = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*username_size);
+ MultiByteToWideChar(CP_ACP, 0, lpszUserName, -1, lpszUserNameW, username_size);
+ }
+
+ hr = SysKeyboardWImpl_SetActionMap(&This->base.IDirectInputDevice8W_iface, &diafW, lpszUserNameW, dwFlags);
+
+ HeapFree(GetProcessHeap(), 0, diafW.rgoAction);
+ HeapFree(GetProcessHeap(), 0, lpszUserNameW);
+
+ return hr;
+}
+
static const IDirectInputDevice8AVtbl SysKeyboardAvt =
{
- IDirectInputDevice2AImpl_QueryInterface,
- IDirectInputDevice2AImpl_AddRef,
- IDirectInputDevice2AImpl_Release,
- SysKeyboardAImpl_GetCapabilities,
- IDirectInputDevice2AImpl_EnumObjects,
- SysKeyboardAImpl_GetProperty,
- IDirectInputDevice2AImpl_SetProperty,
- IDirectInputDevice2AImpl_Acquire,
- IDirectInputDevice2AImpl_Unacquire,
- SysKeyboardAImpl_GetDeviceState,
- IDirectInputDevice2AImpl_GetDeviceData,
- IDirectInputDevice2AImpl_SetDataFormat,
- IDirectInputDevice2AImpl_SetEventNotification,
- IDirectInputDevice2AImpl_SetCooperativeLevel,
- SysKeyboardAImpl_GetObjectInfo,
- SysKeyboardAImpl_GetDeviceInfo,
- IDirectInputDevice2AImpl_RunControlPanel,
- IDirectInputDevice2AImpl_Initialize,
- IDirectInputDevice2AImpl_CreateEffect,
- IDirectInputDevice2AImpl_EnumEffects,
- IDirectInputDevice2AImpl_GetEffectInfo,
- IDirectInputDevice2AImpl_GetForceFeedbackState,
- IDirectInputDevice2AImpl_SendForceFeedbackCommand,
- IDirectInputDevice2AImpl_EnumCreatedEffectObjects,
- IDirectInputDevice2AImpl_Escape,
- IDirectInputDevice2AImpl_Poll,
- IDirectInputDevice2AImpl_SendDeviceData,
- IDirectInputDevice7AImpl_EnumEffectsInFile,
- IDirectInputDevice7AImpl_WriteEffectToFile,
- IDirectInputDevice8AImpl_BuildActionMap,
- IDirectInputDevice8AImpl_SetActionMap,
- IDirectInputDevice8AImpl_GetImageInfo
+ IDirectInputDevice2AImpl_QueryInterface,
+ IDirectInputDevice2AImpl_AddRef,
+ IDirectInputDevice2AImpl_Release,
+ SysKeyboardAImpl_GetCapabilities,
+ IDirectInputDevice2AImpl_EnumObjects,
+ SysKeyboardAImpl_GetProperty,
+ IDirectInputDevice2AImpl_SetProperty,
+ IDirectInputDevice2AImpl_Acquire,
+ IDirectInputDevice2AImpl_Unacquire,
+ SysKeyboardAImpl_GetDeviceState,
+ IDirectInputDevice2AImpl_GetDeviceData,
+ IDirectInputDevice2AImpl_SetDataFormat,
+ IDirectInputDevice2AImpl_SetEventNotification,
+ IDirectInputDevice2AImpl_SetCooperativeLevel,
+ SysKeyboardAImpl_GetObjectInfo,
+ SysKeyboardAImpl_GetDeviceInfo,
+ IDirectInputDevice2AImpl_RunControlPanel,
+ IDirectInputDevice2AImpl_Initialize,
+ IDirectInputDevice2AImpl_CreateEffect,
+ IDirectInputDevice2AImpl_EnumEffects,
+ IDirectInputDevice2AImpl_GetEffectInfo,
+ IDirectInputDevice2AImpl_GetForceFeedbackState,
+ IDirectInputDevice2AImpl_SendForceFeedbackCommand,
+ IDirectInputDevice2AImpl_EnumCreatedEffectObjects,
+ IDirectInputDevice2AImpl_Escape,
+ IDirectInputDevice2AImpl_Poll,
+ IDirectInputDevice2AImpl_SendDeviceData,
+ IDirectInputDevice7AImpl_EnumEffectsInFile,
+ IDirectInputDevice7AImpl_WriteEffectToFile,
+ SysKeyboardAImpl_BuildActionMap,
+ SysKeyboardAImpl_SetActionMap,
+ IDirectInputDevice8AImpl_GetImageInfo
};
-#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
-# define XCAST(fun) (typeof(SysKeyboardWvt.fun))
-#else
-# define XCAST(fun) (void*)
-#endif
-
static const IDirectInputDevice8WVtbl SysKeyboardWvt =
{
- IDirectInputDevice2WImpl_QueryInterface,
- XCAST(AddRef)IDirectInputDevice2AImpl_AddRef,
- XCAST(Release)IDirectInputDevice2AImpl_Release,
- XCAST(GetCapabilities)SysKeyboardAImpl_GetCapabilities,
- IDirectInputDevice2WImpl_EnumObjects,
- XCAST(GetProperty)SysKeyboardAImpl_GetProperty,
- XCAST(SetProperty)IDirectInputDevice2AImpl_SetProperty,
- XCAST(Acquire)IDirectInputDevice2AImpl_Acquire,
- XCAST(Unacquire)IDirectInputDevice2AImpl_Unacquire,
- XCAST(GetDeviceState)SysKeyboardAImpl_GetDeviceState,
- XCAST(GetDeviceData)IDirectInputDevice2AImpl_GetDeviceData,
- XCAST(SetDataFormat)IDirectInputDevice2AImpl_SetDataFormat,
- XCAST(SetEventNotification)IDirectInputDevice2AImpl_SetEventNotification,
- XCAST(SetCooperativeLevel)IDirectInputDevice2AImpl_SetCooperativeLevel,
- SysKeyboardWImpl_GetObjectInfo,
- SysKeyboardWImpl_GetDeviceInfo,
- XCAST(RunControlPanel)IDirectInputDevice2AImpl_RunControlPanel,
- XCAST(Initialize)IDirectInputDevice2AImpl_Initialize,
- XCAST(CreateEffect)IDirectInputDevice2AImpl_CreateEffect,
- IDirectInputDevice2WImpl_EnumEffects,
- IDirectInputDevice2WImpl_GetEffectInfo,
- XCAST(GetForceFeedbackState)IDirectInputDevice2AImpl_GetForceFeedbackState,
- XCAST(SendForceFeedbackCommand)IDirectInputDevice2AImpl_SendForceFeedbackCommand,
- XCAST(EnumCreatedEffectObjects)IDirectInputDevice2AImpl_EnumCreatedEffectObjects,
- XCAST(Escape)IDirectInputDevice2AImpl_Escape,
- XCAST(Poll)IDirectInputDevice2AImpl_Poll,
- XCAST(SendDeviceData)IDirectInputDevice2AImpl_SendDeviceData,
- IDirectInputDevice7WImpl_EnumEffectsInFile,
- IDirectInputDevice7WImpl_WriteEffectToFile,
- IDirectInputDevice8WImpl_BuildActionMap,
- IDirectInputDevice8WImpl_SetActionMap,
- IDirectInputDevice8WImpl_GetImageInfo
+ IDirectInputDevice2WImpl_QueryInterface,
+ IDirectInputDevice2WImpl_AddRef,
+ IDirectInputDevice2WImpl_Release,
+ SysKeyboardWImpl_GetCapabilities,
+ IDirectInputDevice2WImpl_EnumObjects,
+ SysKeyboardWImpl_GetProperty,
+ IDirectInputDevice2WImpl_SetProperty,
+ IDirectInputDevice2WImpl_Acquire,
+ IDirectInputDevice2WImpl_Unacquire,
+ SysKeyboardWImpl_GetDeviceState,
+ IDirectInputDevice2WImpl_GetDeviceData,
+ IDirectInputDevice2WImpl_SetDataFormat,
+ IDirectInputDevice2WImpl_SetEventNotification,
+ IDirectInputDevice2WImpl_SetCooperativeLevel,
+ SysKeyboardWImpl_GetObjectInfo,
+ SysKeyboardWImpl_GetDeviceInfo,
+ IDirectInputDevice2WImpl_RunControlPanel,
+ IDirectInputDevice2WImpl_Initialize,
+ IDirectInputDevice2WImpl_CreateEffect,
+ IDirectInputDevice2WImpl_EnumEffects,
+ IDirectInputDevice2WImpl_GetEffectInfo,
+ IDirectInputDevice2WImpl_GetForceFeedbackState,
+ IDirectInputDevice2WImpl_SendForceFeedbackCommand,
+ IDirectInputDevice2WImpl_EnumCreatedEffectObjects,
+ IDirectInputDevice2WImpl_Escape,
+ IDirectInputDevice2WImpl_Poll,
+ IDirectInputDevice2WImpl_SendDeviceData,
+ IDirectInputDevice7WImpl_EnumEffectsInFile,
+ IDirectInputDevice7WImpl_WriteEffectToFile,
+ SysKeyboardWImpl_BuildActionMap,
+ SysKeyboardWImpl_SetActionMap,
+ IDirectInputDevice8WImpl_GetImageInfo
};
-#undef XCAST
#include <config.h>
//#include "wine/port.h"
-//#include <stdarg.h>
+#include <stdarg.h>
//#include <string.h>
-//#include "windef.h"
+#include <windef.h>
//#include "winbase.h"
//#include "wingdi.h"
-//#include "winuser.h"
+#include <winuser.h>
//#include "winerror.h"
-//#include "winreg.h"
+#include <winreg.h>
//#include "dinput.h"
//#include "dinput_private.h"
struct SysMouseImpl
{
- struct IDirectInputDevice2AImpl base;
-
+ struct IDirectInputDeviceImpl base;
+
/* SysMouseAImpl */
/* These are used in case of relative -> absolute transitions */
POINT org_coords;
- POINT mapped_center;
- DWORD win_centerX, win_centerY;
+ BOOL clipped;
/* warping: whether we need to move mouse back to middle once we
* reach window borders (for e.g. shooters, "surface movement" games) */
BOOL need_warp;
WARP_MOUSE warp_override;
};
-static void dinput_mouse_hook( LPDIRECTINPUTDEVICE8A iface, WPARAM wparam, LPARAM lparam );
+static inline SysMouseImpl *impl_from_IDirectInputDevice8A(IDirectInputDevice8A *iface)
+{
+ return CONTAINING_RECORD(CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8A_iface), SysMouseImpl, base);
+}
+static inline SysMouseImpl *impl_from_IDirectInputDevice8W(IDirectInputDevice8W *iface)
+{
+ return CONTAINING_RECORD(CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8W_iface), SysMouseImpl, base);
+}
+static inline IDirectInputDevice8A *IDirectInputDevice8A_from_impl(SysMouseImpl *This)
+{
+ return &This->base.IDirectInputDevice8A_iface;
+}
+static inline IDirectInputDevice8W *IDirectInputDevice8W_from_impl(SysMouseImpl *This)
+{
+ return &This->base.IDirectInputDevice8W_iface;
+}
+
+static int dinput_mouse_hook( LPDIRECTINPUTDEVICE8A iface, WPARAM wparam, LPARAM lparam );
const GUID DInput_Wine_Mouse_GUID = { /* 9e573ed8-7734-11d2-8d4a-23903fb6bdf7 */
0x9e573ed8, 0x7734, 0x11d2, {0x8d, 0x4a, 0x23, 0x90, 0x3f, 0xb6, 0xbd, 0xf7}
};
-static void _dump_mouse_state(DIMOUSESTATE2 *m_state)
+static void _dump_mouse_state(const DIMOUSESTATE2 *m_state)
{
int i;
return FALSE;
}
-static SysMouseImpl *alloc_device(REFGUID rguid, const void *mvt, IDirectInputImpl *dinput)
+static SysMouseImpl *alloc_device(REFGUID rguid, IDirectInputImpl *dinput)
{
SysMouseImpl* newDevice;
LPDIDATAFORMAT df = NULL;
newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(SysMouseImpl));
if (!newDevice) return NULL;
- newDevice->base.lpVtbl = mvt;
+ newDevice->base.IDirectInputDevice8A_iface.lpVtbl = &SysMouseAvt;
+ newDevice->base.IDirectInputDevice8W_iface.lpVtbl = &SysMouseWvt;
newDevice->base.ref = 1;
newDevice->base.dwCoopLevel = DISCL_NONEXCLUSIVE | DISCL_BACKGROUND;
newDevice->base.guid = *rguid;
df->rgodf[i].dwType = DIDFT_MAKEINSTANCE(i) | DIDFT_PSHBUTTON;
newDevice->base.data_format.wine_df = df;
- IDirectInput_AddRef((LPDIRECTINPUTDEVICE8A)newDevice->base.dinput);
+ IDirectInput_AddRef(&newDevice->base.dinput->IDirectInput7A_iface);
+
+ EnterCriticalSection(&dinput->crit);
+ list_add_tail(&dinput->devices_list, &newDevice->base.entry);
+ LeaveCriticalSection(&dinput->crit);
+
return newDevice;
failed:
return NULL;
}
-static HRESULT mousedev_create_deviceA(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEA* pdev)
-{
- if ((IsEqualGUID(&GUID_SysMouse,rguid)) || /* Generic Mouse */
- (IsEqualGUID(&DInput_Wine_Mouse_GUID,rguid))) { /* Wine Mouse */
- if ((riid == NULL) ||
- IsEqualGUID(&IID_IDirectInputDeviceA,riid) ||
- IsEqualGUID(&IID_IDirectInputDevice2A,riid) ||
- IsEqualGUID(&IID_IDirectInputDevice7A,riid) ||
- IsEqualGUID(&IID_IDirectInputDevice8A,riid)) {
- *pdev = (IDirectInputDeviceA*) alloc_device(rguid, &SysMouseAvt, dinput);
- TRACE("Creating a Mouse device (%p)\n", *pdev);
- if (!*pdev) return DIERR_OUTOFMEMORY;
- return DI_OK;
- } else
- return DIERR_NOINTERFACE;
- }
-
- return DIERR_DEVICENOTREG;
-}
+static HRESULT mousedev_create_device(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPVOID *pdev, int unicode)
+{
+ TRACE("%p %s %s %p %i\n", dinput, debugstr_guid(rguid), debugstr_guid(riid), pdev, unicode);
+ *pdev = NULL;
+
+ if (IsEqualGUID(&GUID_SysMouse, rguid) || /* Generic Mouse */
+ IsEqualGUID(&DInput_Wine_Mouse_GUID, rguid)) /* Wine Mouse */
+ {
+ SysMouseImpl *This;
+
+ if (riid == NULL)
+ ;/* nothing */
+ else if (IsEqualGUID(&IID_IDirectInputDeviceA, riid) ||
+ IsEqualGUID(&IID_IDirectInputDevice2A, riid) ||
+ IsEqualGUID(&IID_IDirectInputDevice7A, riid) ||
+ IsEqualGUID(&IID_IDirectInputDevice8A, riid))
+ {
+ unicode = 0;
+ }
+ else if (IsEqualGUID(&IID_IDirectInputDeviceW, riid) ||
+ IsEqualGUID(&IID_IDirectInputDevice2W, riid) ||
+ IsEqualGUID(&IID_IDirectInputDevice7W, riid) ||
+ IsEqualGUID(&IID_IDirectInputDevice8W, riid))
+ {
+ unicode = 1;
+ }
+ else
+ {
+ WARN("no interface\n");
+ return DIERR_NOINTERFACE;
+ }
+
+ This = alloc_device(rguid, dinput);
+ TRACE("Created a Mouse device (%p)\n", This);
+
+ if (!This) return DIERR_OUTOFMEMORY;
-static HRESULT mousedev_create_deviceW(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEW* pdev)
-{
- if ((IsEqualGUID(&GUID_SysMouse,rguid)) || /* Generic Mouse */
- (IsEqualGUID(&DInput_Wine_Mouse_GUID,rguid))) { /* Wine Mouse */
- if ((riid == NULL) ||
- IsEqualGUID(&IID_IDirectInputDeviceW,riid) ||
- IsEqualGUID(&IID_IDirectInputDevice2W,riid) ||
- IsEqualGUID(&IID_IDirectInputDevice7W,riid) ||
- IsEqualGUID(&IID_IDirectInputDevice8W,riid)) {
- *pdev = (IDirectInputDeviceW*) alloc_device(rguid, &SysMouseWvt, dinput);
- TRACE("Creating a Mouse device (%p)\n", *pdev);
- if (!*pdev) return DIERR_OUTOFMEMORY;
- return DI_OK;
- } else
- return DIERR_NOINTERFACE;
+ if (unicode)
+ *pdev = &This->base.IDirectInputDevice8W_iface;
+ else
+ *pdev = &This->base.IDirectInputDevice8A_iface;
+
+ return DI_OK;
}
-
+
return DIERR_DEVICENOTREG;
}
"Wine mouse driver",
mousedev_enum_deviceA,
mousedev_enum_deviceW,
- mousedev_create_deviceA,
- mousedev_create_deviceW
+ mousedev_create_device
};
/******************************************************************************
*/
/* low-level mouse hook */
-static void dinput_mouse_hook( LPDIRECTINPUTDEVICE8A iface, WPARAM wparam, LPARAM lparam )
+static int dinput_mouse_hook( LPDIRECTINPUTDEVICE8A iface, WPARAM wparam, LPARAM lparam )
{
MSLLHOOKSTRUCT *hook = (MSLLHOOKSTRUCT *)lparam;
- SysMouseImpl* This = (SysMouseImpl*) iface;
- DWORD dwCoop;
- int wdata = 0, inst_id = -1;
+ SysMouseImpl* This = impl_from_IDirectInputDevice8A(iface);
+ int wdata = 0, inst_id = -1, ret = 0;
TRACE("msg %lx @ (%d %d)\n", wparam, hook->pt.x, hook->pt.y);
EnterCriticalSection(&This->base.crit);
- dwCoop = This->base.dwCoopLevel;
switch(wparam) {
case WM_MOUSEMOVE:
{
/* Already have X, need to queue it */
if (inst_id != -1)
- queue_event((LPDIRECTINPUTDEVICE8A)This, id_to_offset(&This->base.data_format, inst_id),
+ queue_event(iface, inst_id,
wdata, GetCurrentTime(), This->base.dinput->evsequence);
inst_id = DIDFT_MAKEINSTANCE(WINE_MOUSE_Y_AXIS_INSTANCE) | DIDFT_RELAXIS;
wdata = pt1.y;
}
- This->need_warp = This->warp_override != WARP_DISABLE &&
- (pt.x || pt.y) &&
- (dwCoop & DISCL_EXCLUSIVE || This->warp_override == WARP_FORCE_ON);
+ if (pt.x || pt.y)
+ {
+ if ((This->warp_override == WARP_FORCE_ON) ||
+ (This->warp_override != WARP_DISABLE && (This->base.dwCoopLevel & DISCL_EXCLUSIVE)))
+ This->need_warp = TRUE;
+ }
break;
}
case WM_MOUSEWHEEL:
inst_id = DIDFT_MAKEINSTANCE(WINE_MOUSE_Z_AXIS_INSTANCE) | DIDFT_RELAXIS;
This->m_state.lZ += wdata = (short)HIWORD(hook->mouseData);
+ /* FarCry crashes if it gets a mouse wheel message */
+ /* FIXME: should probably filter out other messages too */
+ ret = This->clipped;
break;
case WM_LBUTTONDOWN:
inst_id = DIDFT_MAKEINSTANCE(WINE_MOUSE_BUTTONS_INSTANCE + 0) | DIDFT_PSHBUTTON;
if (inst_id != -1)
{
_dump_mouse_state(&This->m_state);
- queue_event((LPDIRECTINPUTDEVICE8A)This, id_to_offset(&This->base.data_format, inst_id),
+ queue_event(iface, inst_id,
wdata, GetCurrentTime(), This->base.dinput->evsequence++);
}
LeaveCriticalSection(&This->base.crit);
+ return ret;
}
-static BOOL dinput_window_check(SysMouseImpl* This) {
- RECT rect;
- DWORD centerX, centerY;
+static void warp_check( SysMouseImpl* This, BOOL force )
+{
+ DWORD now = GetCurrentTime();
+ const DWORD interval = This->clipped ? 500 : 10;
- /* make sure the window hasn't moved */
- if(!GetWindowRect(This->base.win, &rect))
- return FALSE;
- centerX = (rect.right - rect.left) / 2;
- centerY = (rect.bottom - rect.top ) / 2;
- if (This->win_centerX != centerX || This->win_centerY != centerY) {
- This->win_centerX = centerX;
- This->win_centerY = centerY;
+ if (force || (This->need_warp && (now - This->last_warped > interval)))
+ {
+ RECT rect, new_rect;
+ POINT mapped_center;
+
+ This->last_warped = now;
+ This->need_warp = FALSE;
+ if (!GetClientRect(This->base.win, &rect)) return;
+ MapWindowPoints( This->base.win, 0, (POINT *)&rect, 2 );
+ if (!This->clipped)
+ {
+ mapped_center.x = (rect.left + rect.right) / 2;
+ mapped_center.y = (rect.top + rect.bottom) / 2;
+ TRACE("Warping mouse to %d - %d\n", mapped_center.x, mapped_center.y);
+ SetCursorPos( mapped_center.x, mapped_center.y );
+ }
+ if (This->base.dwCoopLevel & DISCL_EXCLUSIVE)
+ {
+ /* make sure we clip even if the window covers the whole screen */
+ rect.left = max( rect.left, GetSystemMetrics( SM_XVIRTUALSCREEN ) + 1 );
+ rect.top = max( rect.top, GetSystemMetrics( SM_YVIRTUALSCREEN ) + 1 );
+ rect.right = min( rect.right, rect.left + GetSystemMetrics( SM_CXVIRTUALSCREEN ) - 2 );
+ rect.bottom = min( rect.bottom, rect.top + GetSystemMetrics( SM_CYVIRTUALSCREEN ) - 2 );
+ TRACE("Clipping mouse to %s\n", wine_dbgstr_rect( &rect ));
+ ClipCursor( &rect );
+ This->clipped = GetClipCursor( &new_rect ) && EqualRect( &rect, &new_rect );
+ }
}
- This->mapped_center.x = This->win_centerX;
- This->mapped_center.y = This->win_centerY;
- MapWindowPoints(This->base.win, HWND_DESKTOP, &This->mapped_center, 1);
- return TRUE;
}
/******************************************************************************
* Acquire : gets exclusive control of the mouse
*/
-static HRESULT WINAPI SysMouseAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface)
+static HRESULT WINAPI SysMouseWImpl_Acquire(LPDIRECTINPUTDEVICE8W iface)
{
- SysMouseImpl *This = (SysMouseImpl *)iface;
- RECT rect;
+ SysMouseImpl *This = impl_from_IDirectInputDevice8W(iface);
POINT point;
HRESULT res;
-
+
TRACE("(this=%p)\n",This);
- if ((res = IDirectInputDevice2AImpl_Acquire(iface)) != DI_OK) return res;
+ if ((res = IDirectInputDevice2WImpl_Acquire(iface)) != DI_OK) return res;
/* Init the mouse state */
GetCursorPos( &point );
This->m_state.rgbButtons[0] = GetKeyState(VK_LBUTTON) & 0x80;
This->m_state.rgbButtons[1] = GetKeyState(VK_RBUTTON) & 0x80;
This->m_state.rgbButtons[2] = GetKeyState(VK_MBUTTON) & 0x80;
-
- /* Install our mouse hook */
+
if (This->base.dwCoopLevel & DISCL_EXCLUSIVE)
{
- RECT rc;
-
- ShowCursor(FALSE); /* hide cursor */
- if (GetWindowRect(This->base.win, &rc))
- {
- FIXME("Clipping cursor to %s\n", wine_dbgstr_rect( &rc ));
- ClipCursor(&rc);
- }
- else
- ERR("Failed to get RECT: %d\n", GetLastError());
+ ShowCursor(FALSE); /* hide cursor */
+ warp_check( This, TRUE );
}
-
- /* Need a window to warp mouse in. */
- if (This->warp_override == WARP_FORCE_ON && !This->base.win)
- This->base.win = GetDesktopWindow();
-
- /* Get the window dimension and find the center */
- GetWindowRect(This->base.win, &rect);
- This->win_centerX = (rect.right - rect.left) / 2;
- This->win_centerY = (rect.bottom - rect.top ) / 2;
-
- /* Warp the mouse to the center of the window */
- if (This->base.dwCoopLevel & DISCL_EXCLUSIVE || This->warp_override == WARP_FORCE_ON)
+ else if (This->warp_override == WARP_FORCE_ON)
+ {
+ /* Need a window to warp mouse in. */
+ if (!This->base.win) This->base.win = GetDesktopWindow();
+ warp_check( This, TRUE );
+ }
+ else if (This->clipped)
{
- This->mapped_center.x = This->win_centerX;
- This->mapped_center.y = This->win_centerY;
- MapWindowPoints(This->base.win, HWND_DESKTOP, &This->mapped_center, 1);
- TRACE("Warping mouse to %d - %d\n", This->mapped_center.x, This->mapped_center.y);
- SetCursorPos( This->mapped_center.x, This->mapped_center.y );
- This->last_warped = GetCurrentTime();
-
- This->need_warp = FALSE;
+ ClipCursor( NULL );
+ This->clipped = FALSE;
}
return DI_OK;
}
+static HRESULT WINAPI SysMouseAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface)
+{
+ SysMouseImpl *This = impl_from_IDirectInputDevice8A(iface);
+ return SysMouseWImpl_Acquire(IDirectInputDevice8W_from_impl(This));
+}
+
/******************************************************************************
* Unacquire : frees the mouse
*/
-static HRESULT WINAPI SysMouseAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface)
+static HRESULT WINAPI SysMouseWImpl_Unacquire(LPDIRECTINPUTDEVICE8W iface)
{
- SysMouseImpl *This = (SysMouseImpl *)iface;
+ SysMouseImpl *This = impl_from_IDirectInputDevice8W(iface);
HRESULT res;
-
+
TRACE("(this=%p)\n",This);
- if ((res = IDirectInputDevice2AImpl_Unacquire(iface)) != DI_OK) return res;
+ if ((res = IDirectInputDevice2WImpl_Unacquire(iface)) != DI_OK) return res;
if (This->base.dwCoopLevel & DISCL_EXCLUSIVE)
{
ClipCursor(NULL);
ShowCursor(TRUE); /* show cursor */
+ This->clipped = FALSE;
}
/* And put the mouse cursor back where it was at acquire time */
if (This->base.dwCoopLevel & DISCL_EXCLUSIVE || This->warp_override == WARP_FORCE_ON)
{
- TRACE(" warping mouse back to (%d , %d)\n", This->org_coords.x, This->org_coords.y);
- SetCursorPos(This->org_coords.x, This->org_coords.y);
+ TRACE("warping mouse back to %s\n", wine_dbgstr_point(&This->org_coords));
+ SetCursorPos(This->org_coords.x, This->org_coords.y);
}
-
+
return DI_OK;
}
+static HRESULT WINAPI SysMouseAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface)
+{
+ SysMouseImpl *This = impl_from_IDirectInputDevice8A(iface);
+ return SysMouseWImpl_Unacquire(IDirectInputDevice8W_from_impl(This));
+}
+
/******************************************************************************
* GetDeviceState : returns the "state" of the mouse.
*
* For the moment, only the "standard" return structure (DIMOUSESTATE) is
* supported.
*/
-static HRESULT WINAPI SysMouseAImpl_GetDeviceState(
- LPDIRECTINPUTDEVICE8A iface,DWORD len,LPVOID ptr
-) {
- SysMouseImpl *This = (SysMouseImpl *)iface;
+static HRESULT WINAPI SysMouseWImpl_GetDeviceState(LPDIRECTINPUTDEVICE8W iface, DWORD len, LPVOID ptr)
+{
+ SysMouseImpl *This = impl_from_IDirectInputDevice8W(iface);
if(This->base.acquired == 0) return DIERR_NOTACQUIRED;
}
LeaveCriticalSection(&This->base.crit);
- /* Check if we need to do a mouse warping */
- if (This->need_warp && (GetCurrentTime() - This->last_warped > 10))
- {
- if(!dinput_window_check(This))
- return DIERR_GENERIC;
- TRACE("Warping mouse to %d - %d\n", This->mapped_center.x, This->mapped_center.y);
- SetCursorPos( This->mapped_center.x, This->mapped_center.y );
- This->last_warped = GetCurrentTime();
-
- This->need_warp = FALSE;
- }
-
+ warp_check( This, FALSE );
return DI_OK;
}
+static HRESULT WINAPI SysMouseAImpl_GetDeviceState(LPDIRECTINPUTDEVICE8A iface, DWORD len, LPVOID ptr)
+{
+ SysMouseImpl *This = impl_from_IDirectInputDevice8A(iface);
+ return SysMouseWImpl_GetDeviceState(IDirectInputDevice8W_from_impl(This), len, ptr);
+}
+
/******************************************************************************
* GetDeviceData : gets buffered input data.
*/
-static HRESULT WINAPI SysMouseAImpl_GetDeviceData(LPDIRECTINPUTDEVICE8A iface,
+static HRESULT WINAPI SysMouseWImpl_GetDeviceData(LPDIRECTINPUTDEVICE8W iface,
DWORD dodsize, LPDIDEVICEOBJECTDATA dod, LPDWORD entries, DWORD flags)
{
- SysMouseImpl *This = (SysMouseImpl *)iface;
+ SysMouseImpl *This = impl_from_IDirectInputDevice8W(iface);
HRESULT res;
- res = IDirectInputDevice2AImpl_GetDeviceData(iface, dodsize, dod, entries, flags);
- if (FAILED(res)) return res;
-
- /* Check if we need to do a mouse warping */
- if (This->need_warp && (GetCurrentTime() - This->last_warped > 10))
- {
- if(!dinput_window_check(This))
- return DIERR_GENERIC;
- TRACE("Warping mouse to %d - %d\n", This->mapped_center.x, This->mapped_center.y);
- SetCursorPos( This->mapped_center.x, This->mapped_center.y );
- This->last_warped = GetCurrentTime();
-
- This->need_warp = FALSE;
- }
+ res = IDirectInputDevice2WImpl_GetDeviceData(iface, dodsize, dod, entries, flags);
+ if (SUCCEEDED(res)) warp_check( This, FALSE );
return res;
}
+static HRESULT WINAPI SysMouseAImpl_GetDeviceData(LPDIRECTINPUTDEVICE8A iface,
+ DWORD dodsize, LPDIDEVICEOBJECTDATA dod, LPDWORD entries, DWORD flags)
+{
+ SysMouseImpl *This = impl_from_IDirectInputDevice8A(iface);
+ return SysMouseWImpl_GetDeviceData(IDirectInputDevice8W_from_impl(This), dodsize, dod, entries, flags);
+}
+
/******************************************************************************
* GetProperty : get input device properties
*/
-static HRESULT WINAPI SysMouseAImpl_GetProperty(LPDIRECTINPUTDEVICE8A iface,
- REFGUID rguid,
- LPDIPROPHEADER pdiph)
+static HRESULT WINAPI SysMouseWImpl_GetProperty(LPDIRECTINPUTDEVICE8W iface, REFGUID rguid, LPDIPROPHEADER pdiph)
{
- SysMouseImpl *This = (SysMouseImpl *)iface;
-
+ SysMouseImpl *This = impl_from_IDirectInputDevice8W(iface);
+
TRACE("(%p) %s,%p\n", This, debugstr_guid(rguid), pdiph);
_dump_DIPROPHEADER(pdiph);
-
- if (!HIWORD(rguid)) {
+
+ if (IS_DIPROP(rguid)) {
switch (LOWORD(rguid)) {
case (DWORD_PTR) DIPROP_GRANULARITY: {
LPDIPROPDWORD pr = (LPDIPROPDWORD) pdiph;
}
default:
- return IDirectInputDevice2AImpl_GetProperty(iface, rguid, pdiph);
+ return IDirectInputDevice2WImpl_GetProperty(iface, rguid, pdiph);
}
}
-
+
return DI_OK;
}
+static HRESULT WINAPI SysMouseAImpl_GetProperty(LPDIRECTINPUTDEVICE8A iface, REFGUID rguid, LPDIPROPHEADER pdiph)
+{
+ SysMouseImpl *This = impl_from_IDirectInputDevice8A(iface);
+ return SysMouseWImpl_GetProperty(IDirectInputDevice8W_from_impl(This), rguid, pdiph);
+}
+
/******************************************************************************
* GetCapabilities : get the device capabilities
*/
-static HRESULT WINAPI SysMouseAImpl_GetCapabilities(
- LPDIRECTINPUTDEVICE8A iface,
- LPDIDEVCAPS lpDIDevCaps)
+static HRESULT WINAPI SysMouseWImpl_GetCapabilities(LPDIRECTINPUTDEVICE8W iface, LPDIDEVCAPS lpDIDevCaps)
{
- SysMouseImpl *This = (SysMouseImpl *)iface;
+ SysMouseImpl *This = impl_from_IDirectInputDevice8W(iface);
DIDEVCAPS devcaps;
TRACE("(this=%p,%p)\n",This,lpDIDevCaps);
}
devcaps.dwSize = lpDIDevCaps->dwSize;
- devcaps.dwFlags = DIDC_ATTACHED;
+ devcaps.dwFlags = DIDC_ATTACHED | DIDC_EMULATED;
if (This->base.dinput->dwVersion >= 0x0800)
devcaps.dwDevType = DI8DEVTYPE_MOUSE | (DI8DEVTYPEMOUSE_TRADITIONAL << 8);
else
devcaps.dwFFDriverVersion = 0;
memcpy(lpDIDevCaps, &devcaps, lpDIDevCaps->dwSize);
-
+
return DI_OK;
}
+static HRESULT WINAPI SysMouseAImpl_GetCapabilities(LPDIRECTINPUTDEVICE8A iface, LPDIDEVCAPS lpDIDevCaps)
+{
+ SysMouseImpl *This = impl_from_IDirectInputDevice8A(iface);
+ return SysMouseWImpl_GetCapabilities(IDirectInputDevice8W_from_impl(This), lpDIDevCaps);
+}
+
/******************************************************************************
* GetObjectInfo : get information about a device object such as a button
* or axis
static HRESULT WINAPI SysMouseAImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8A iface,
LPDIDEVICEOBJECTINSTANCEA pdidoi, DWORD dwObj, DWORD dwHow)
{
+ SysMouseImpl *This = impl_from_IDirectInputDevice8A(iface);
HRESULT res;
DIDEVICEOBJECTINSTANCEW didoiW;
DWORD dwSize = pdidoi->dwSize;
didoiW.dwSize = sizeof(didoiW);
- res = SysMouseWImpl_GetObjectInfo((LPDIRECTINPUTDEVICE8W)iface, &didoiW, dwObj, dwHow);
+ res = SysMouseWImpl_GetObjectInfo(IDirectInputDevice8W_from_impl(This), &didoiW, dwObj, dwHow);
if (res != DI_OK) return res;
memset(pdidoi, 0, pdidoi->dwSize);
LPDIRECTINPUTDEVICE8A iface,
LPDIDEVICEINSTANCEA pdidi)
{
- SysMouseImpl *This = (SysMouseImpl *)iface;
+ SysMouseImpl *This = impl_from_IDirectInputDevice8A(iface);
TRACE("(this=%p,%p)\n", This, pdidi);
if (pdidi->dwSize != sizeof(DIDEVICEINSTANCEA)) {
- WARN(" dinput3 not supporte yet...\n");
+ WARN(" dinput3 not supported yet...\n");
return DI_OK;
}
static HRESULT WINAPI SysMouseWImpl_GetDeviceInfo(LPDIRECTINPUTDEVICE8W iface, LPDIDEVICEINSTANCEW pdidi)
{
- SysMouseImpl *This = (SysMouseImpl *)iface;
+ SysMouseImpl *This = impl_from_IDirectInputDevice8W(iface);
TRACE("(this=%p,%p)\n", This, pdidi);
if (pdidi->dwSize != sizeof(DIDEVICEINSTANCEW)) {
- WARN(" dinput3 not supporte yet...\n");
+ WARN(" dinput3 not supported yet...\n");
return DI_OK;
}
return DI_OK;
}
+static HRESULT WINAPI SysMouseWImpl_BuildActionMap(LPDIRECTINPUTDEVICE8W iface,
+ LPDIACTIONFORMATW lpdiaf,
+ LPCWSTR lpszUserName,
+ DWORD dwFlags)
+{
+ FIXME("(%p)->(%p,%s,%08x): semi-stub !\n", iface, lpdiaf, debugstr_w(lpszUserName), dwFlags);
+
+ return _build_action_map(iface, lpdiaf, lpszUserName, dwFlags, DIMOUSE_MASK, &c_dfDIMouse2);
+}
+
+static HRESULT WINAPI SysMouseAImpl_BuildActionMap(LPDIRECTINPUTDEVICE8A iface,
+ LPDIACTIONFORMATA lpdiaf,
+ LPCSTR lpszUserName,
+ DWORD dwFlags)
+{
+ SysMouseImpl *This = impl_from_IDirectInputDevice8A(iface);
+ DIACTIONFORMATW diafW;
+ HRESULT hr;
+ WCHAR *lpszUserNameW = NULL;
+ int username_size;
+
+ diafW.rgoAction = HeapAlloc(GetProcessHeap(), 0, sizeof(DIACTIONW)*lpdiaf->dwNumActions);
+ _copy_diactionformatAtoW(&diafW, lpdiaf);
+
+ if (lpszUserName != NULL)
+ {
+ username_size = MultiByteToWideChar(CP_ACP, 0, lpszUserName, -1, NULL, 0);
+ lpszUserNameW = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*username_size);
+ MultiByteToWideChar(CP_ACP, 0, lpszUserName, -1, lpszUserNameW, username_size);
+ }
+
+ hr = SysMouseWImpl_BuildActionMap(&This->base.IDirectInputDevice8W_iface, &diafW, lpszUserNameW, dwFlags);
+
+ _copy_diactionformatWtoA(lpdiaf, &diafW);
+ HeapFree(GetProcessHeap(), 0, diafW.rgoAction);
+ HeapFree(GetProcessHeap(), 0, lpszUserNameW);
+
+ return hr;
+}
+
+static HRESULT WINAPI SysMouseWImpl_SetActionMap(LPDIRECTINPUTDEVICE8W iface,
+ LPDIACTIONFORMATW lpdiaf,
+ LPCWSTR lpszUserName,
+ DWORD dwFlags)
+{
+ FIXME("(%p)->(%p,%s,%08x): semi-stub !\n", iface, lpdiaf, debugstr_w(lpszUserName), dwFlags);
+
+ return _set_action_map(iface, lpdiaf, lpszUserName, dwFlags, &c_dfDIMouse2);
+}
+
+static HRESULT WINAPI SysMouseAImpl_SetActionMap(LPDIRECTINPUTDEVICE8A iface,
+ LPDIACTIONFORMATA lpdiaf,
+ LPCSTR lpszUserName,
+ DWORD dwFlags)
+{
+ SysMouseImpl *This = impl_from_IDirectInputDevice8A(iface);
+ DIACTIONFORMATW diafW;
+ HRESULT hr;
+ WCHAR *lpszUserNameW = NULL;
+ int username_size;
+
+ diafW.rgoAction = HeapAlloc(GetProcessHeap(), 0, sizeof(DIACTIONW)*lpdiaf->dwNumActions);
+ _copy_diactionformatAtoW(&diafW, lpdiaf);
+
+ if (lpszUserName != NULL)
+ {
+ username_size = MultiByteToWideChar(CP_ACP, 0, lpszUserName, -1, NULL, 0);
+ lpszUserNameW = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*username_size);
+ MultiByteToWideChar(CP_ACP, 0, lpszUserName, -1, lpszUserNameW, username_size);
+ }
+
+ hr = SysMouseWImpl_SetActionMap(&This->base.IDirectInputDevice8W_iface, &diafW, lpszUserNameW, dwFlags);
+
+ HeapFree(GetProcessHeap(), 0, diafW.rgoAction);
+ HeapFree(GetProcessHeap(), 0, lpszUserNameW);
+
+ return hr;
+}
static const IDirectInputDevice8AVtbl SysMouseAvt =
{
IDirectInputDevice2AImpl_SendDeviceData,
IDirectInputDevice7AImpl_EnumEffectsInFile,
IDirectInputDevice7AImpl_WriteEffectToFile,
- IDirectInputDevice8AImpl_BuildActionMap,
- IDirectInputDevice8AImpl_SetActionMap,
+ SysMouseAImpl_BuildActionMap,
+ SysMouseAImpl_SetActionMap,
IDirectInputDevice8AImpl_GetImageInfo
};
-#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
-# define XCAST(fun) (typeof(SysMouseWvt.fun))
-#else
-# define XCAST(fun) (void*)
-#endif
-
static const IDirectInputDevice8WVtbl SysMouseWvt =
{
IDirectInputDevice2WImpl_QueryInterface,
- XCAST(AddRef)IDirectInputDevice2AImpl_AddRef,
- XCAST(Release)IDirectInputDevice2AImpl_Release,
- XCAST(GetCapabilities)SysMouseAImpl_GetCapabilities,
+ IDirectInputDevice2WImpl_AddRef,
+ IDirectInputDevice2WImpl_Release,
+ SysMouseWImpl_GetCapabilities,
IDirectInputDevice2WImpl_EnumObjects,
- XCAST(GetProperty)SysMouseAImpl_GetProperty,
- XCAST(SetProperty)IDirectInputDevice2AImpl_SetProperty,
- XCAST(Acquire)SysMouseAImpl_Acquire,
- XCAST(Unacquire)SysMouseAImpl_Unacquire,
- XCAST(GetDeviceState)SysMouseAImpl_GetDeviceState,
- XCAST(GetDeviceData)SysMouseAImpl_GetDeviceData,
- XCAST(SetDataFormat)IDirectInputDevice2AImpl_SetDataFormat,
- XCAST(SetEventNotification)IDirectInputDevice2AImpl_SetEventNotification,
- XCAST(SetCooperativeLevel)IDirectInputDevice2AImpl_SetCooperativeLevel,
+ SysMouseWImpl_GetProperty,
+ IDirectInputDevice2WImpl_SetProperty,
+ SysMouseWImpl_Acquire,
+ SysMouseWImpl_Unacquire,
+ SysMouseWImpl_GetDeviceState,
+ SysMouseWImpl_GetDeviceData,
+ IDirectInputDevice2WImpl_SetDataFormat,
+ IDirectInputDevice2WImpl_SetEventNotification,
+ IDirectInputDevice2WImpl_SetCooperativeLevel,
SysMouseWImpl_GetObjectInfo,
SysMouseWImpl_GetDeviceInfo,
- XCAST(RunControlPanel)IDirectInputDevice2AImpl_RunControlPanel,
- XCAST(Initialize)IDirectInputDevice2AImpl_Initialize,
- XCAST(CreateEffect)IDirectInputDevice2AImpl_CreateEffect,
+ IDirectInputDevice2WImpl_RunControlPanel,
+ IDirectInputDevice2WImpl_Initialize,
+ IDirectInputDevice2WImpl_CreateEffect,
IDirectInputDevice2WImpl_EnumEffects,
IDirectInputDevice2WImpl_GetEffectInfo,
- XCAST(GetForceFeedbackState)IDirectInputDevice2AImpl_GetForceFeedbackState,
- XCAST(SendForceFeedbackCommand)IDirectInputDevice2AImpl_SendForceFeedbackCommand,
- XCAST(EnumCreatedEffectObjects)IDirectInputDevice2AImpl_EnumCreatedEffectObjects,
- XCAST(Escape)IDirectInputDevice2AImpl_Escape,
- XCAST(Poll)IDirectInputDevice2AImpl_Poll,
- XCAST(SendDeviceData)IDirectInputDevice2AImpl_SendDeviceData,
+ IDirectInputDevice2WImpl_GetForceFeedbackState,
+ IDirectInputDevice2WImpl_SendForceFeedbackCommand,
+ IDirectInputDevice2WImpl_EnumCreatedEffectObjects,
+ IDirectInputDevice2WImpl_Escape,
+ IDirectInputDevice2WImpl_Poll,
+ IDirectInputDevice2WImpl_SendDeviceData,
IDirectInputDevice7WImpl_EnumEffectsInFile,
IDirectInputDevice7WImpl_WriteEffectToFile,
- IDirectInputDevice8WImpl_BuildActionMap,
- IDirectInputDevice8WImpl_SetActionMap,
+ SysMouseWImpl_BuildActionMap,
+ SysMouseWImpl_SetActionMap,
IDirectInputDevice8WImpl_GetImageInfo
};
-#undef XCAST
+++ /dev/null
-/*
- * self-registerable dll functions for dinput.dll
- *
- * Copyright (C) 2003 John K. Hohm
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
- */
-
-#define WIN32_NO_STATUS
-#define _INC_WINDOWS
-#define COM_NO_WINDOWS_H
-
-#include <stdarg.h>
-//#include <string.h>
-
-#include <windef.h>
-#include <winbase.h>
-//#include "wingdi.h"
-//#include "winuser.h"
-#include <winreg.h>
-//#include "winerror.h"
-
-#include <dinput.h>
-
-#include <wine/debug.h>
-#include <wine/unicode.h>
-
-WINE_DEFAULT_DEBUG_CHANNEL(dinput);
-
-/*
- * Near the bottom of this file are the exported DllRegisterServer and
- * DllUnregisterServer, which make all this worthwhile.
- */
-
-/***********************************************************************
- * interface for self-registering
- */
-struct regsvr_interface
-{
- IID const *iid; /* NULL for end of list */
- LPCSTR name; /* can be NULL to omit */
- IID const *base_iid; /* can be NULL to omit */
- int num_methods; /* can be <0 to omit */
- CLSID const *ps_clsid; /* can be NULL to omit */
- CLSID const *ps_clsid32; /* can be NULL to omit */
-};
-
-static HRESULT register_interfaces(struct regsvr_interface const *list);
-static HRESULT unregister_interfaces(struct regsvr_interface const *list);
-
-struct regsvr_coclass
-{
- CLSID const *clsid; /* NULL for end of list */
- LPCSTR name; /* can be NULL to omit */
- LPCSTR ips; /* can be NULL to omit */
- LPCSTR ips32; /* can be NULL to omit */
- LPCSTR ips32_tmodel; /* can be NULL to omit */
- LPCSTR progid; /* can be NULL to omit */
- LPCSTR viprogid; /* can be NULL to omit */
- LPCSTR progid_extra; /* can be NULL to omit */
-};
-
-static HRESULT register_coclasses(struct regsvr_coclass const *list);
-static HRESULT unregister_coclasses(struct regsvr_coclass const *list);
-
-/***********************************************************************
- * static string constants
- */
-static WCHAR const interface_keyname[10] = {
- 'I', 'n', 't', 'e', 'r', 'f', 'a', 'c', 'e', 0 };
-static WCHAR const base_ifa_keyname[14] = {
- 'B', 'a', 's', 'e', 'I', 'n', 't', 'e', 'r', 'f', 'a', 'c',
- 'e', 0 };
-static WCHAR const num_methods_keyname[11] = {
- 'N', 'u', 'm', 'M', 'e', 't', 'h', 'o', 'd', 's', 0 };
-static WCHAR const ps_clsid_keyname[15] = {
- 'P', 'r', 'o', 'x', 'y', 'S', 't', 'u', 'b', 'C', 'l', 's',
- 'i', 'd', 0 };
-static WCHAR const ps_clsid32_keyname[17] = {
- 'P', 'r', 'o', 'x', 'y', 'S', 't', 'u', 'b', 'C', 'l', 's',
- 'i', 'd', '3', '2', 0 };
-static WCHAR const clsid_keyname[6] = {
- 'C', 'L', 'S', 'I', 'D', 0 };
-static WCHAR const curver_keyname[7] = {
- 'C', 'u', 'r', 'V', 'e', 'r', 0 };
-static WCHAR const ips_keyname[13] = {
- 'I', 'n', 'P', 'r', 'o', 'c', 'S', 'e', 'r', 'v', 'e', 'r',
- 0 };
-static WCHAR const ips32_keyname[15] = {
- 'I', 'n', 'P', 'r', 'o', 'c', 'S', 'e', 'r', 'v', 'e', 'r',
- '3', '2', 0 };
-static WCHAR const progid_keyname[7] = {
- 'P', 'r', 'o', 'g', 'I', 'D', 0 };
-static WCHAR const viprogid_keyname[25] = {
- 'V', 'e', 'r', 's', 'i', 'o', 'n', 'I', 'n', 'd', 'e', 'p',
- 'e', 'n', 'd', 'e', 'n', 't', 'P', 'r', 'o', 'g', 'I', 'D',
- 0 };
-static char const tmodel_valuename[] = "ThreadingModel";
-
-/***********************************************************************
- * static helper functions
- */
-static LONG register_key_guid(HKEY base, WCHAR const *name, GUID const *guid);
-static LONG register_key_defvalueW(HKEY base, WCHAR const *name,
- WCHAR const *value);
-static LONG register_key_defvalueA(HKEY base, WCHAR const *name,
- char const *value);
-static LONG register_progid(WCHAR const *clsid,
- char const *progid, char const *curver_progid,
- char const *name, char const *extra);
-
-/***********************************************************************
- * register_interfaces
- */
-static HRESULT register_interfaces(struct regsvr_interface const *list)
-{
- LONG res = ERROR_SUCCESS;
- HKEY interface_key;
-
- res = RegCreateKeyExW(HKEY_CLASSES_ROOT, interface_keyname, 0, NULL, 0,
- KEY_READ | KEY_WRITE, NULL, &interface_key, NULL);
- if (res != ERROR_SUCCESS) goto error_return;
-
- for (; res == ERROR_SUCCESS && list->iid; ++list) {
- WCHAR buf[39];
- HKEY iid_key;
-
- StringFromGUID2(list->iid, buf, 39);
- res = RegCreateKeyExW(interface_key, buf, 0, NULL, 0,
- KEY_READ | KEY_WRITE, NULL, &iid_key, NULL);
- if (res != ERROR_SUCCESS) goto error_close_interface_key;
-
- if (list->name) {
- res = RegSetValueExA(iid_key, NULL, 0, REG_SZ,
- (CONST BYTE*)(list->name),
- strlen(list->name) + 1);
- if (res != ERROR_SUCCESS) goto error_close_iid_key;
- }
-
- if (list->base_iid) {
- res = register_key_guid(iid_key, base_ifa_keyname, list->base_iid);
- if (res != ERROR_SUCCESS) goto error_close_iid_key;
- }
-
- if (0 <= list->num_methods) {
- static WCHAR const fmt[3] = { '%', 'd', 0 };
- HKEY key;
-
- res = RegCreateKeyExW(iid_key, num_methods_keyname, 0, NULL, 0,
- KEY_READ | KEY_WRITE, NULL, &key, NULL);
- if (res != ERROR_SUCCESS) goto error_close_iid_key;
-
- sprintfW(buf, fmt, list->num_methods);
- res = RegSetValueExW(key, NULL, 0, REG_SZ,
- (CONST BYTE*)buf,
- (lstrlenW(buf) + 1) * sizeof(WCHAR));
- RegCloseKey(key);
-
- if (res != ERROR_SUCCESS) goto error_close_iid_key;
- }
-
- if (list->ps_clsid) {
- res = register_key_guid(iid_key, ps_clsid_keyname, list->ps_clsid);
- if (res != ERROR_SUCCESS) goto error_close_iid_key;
- }
-
- if (list->ps_clsid32) {
- res = register_key_guid(iid_key, ps_clsid32_keyname, list->ps_clsid32);
- if (res != ERROR_SUCCESS) goto error_close_iid_key;
- }
-
- error_close_iid_key:
- RegCloseKey(iid_key);
- }
-
-error_close_interface_key:
- RegCloseKey(interface_key);
-error_return:
- return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
-}
-
-/***********************************************************************
- * unregister_interfaces
- */
-static HRESULT unregister_interfaces(struct regsvr_interface const *list)
-{
- LONG res = ERROR_SUCCESS;
- HKEY interface_key;
-
- res = RegOpenKeyExW(HKEY_CLASSES_ROOT, interface_keyname, 0,
- KEY_READ | KEY_WRITE, &interface_key);
- if (res == ERROR_FILE_NOT_FOUND) return S_OK;
- if (res != ERROR_SUCCESS) goto error_return;
-
- for (; res == ERROR_SUCCESS && list->iid; ++list) {
- WCHAR buf[39];
-
- StringFromGUID2(list->iid, buf, 39);
- res = RegDeleteTreeW(interface_key, buf);
- if (res == ERROR_FILE_NOT_FOUND) res = ERROR_SUCCESS;
- }
-
- RegCloseKey(interface_key);
-error_return:
- return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
-}
-
-/***********************************************************************
- * register_coclasses
- */
-static HRESULT register_coclasses(struct regsvr_coclass const *list)
-{
- LONG res = ERROR_SUCCESS;
- HKEY coclass_key;
-
- res = RegCreateKeyExW(HKEY_CLASSES_ROOT, clsid_keyname, 0, NULL, 0,
- KEY_READ | KEY_WRITE, NULL, &coclass_key, NULL);
- if (res != ERROR_SUCCESS) goto error_return;
-
- for (; res == ERROR_SUCCESS && list->clsid; ++list) {
- WCHAR buf[39];
- HKEY clsid_key;
-
- StringFromGUID2(list->clsid, buf, 39);
- res = RegCreateKeyExW(coclass_key, buf, 0, NULL, 0,
- KEY_READ | KEY_WRITE, NULL, &clsid_key, NULL);
- if (res != ERROR_SUCCESS) goto error_close_coclass_key;
-
- if (list->name) {
- res = RegSetValueExA(clsid_key, NULL, 0, REG_SZ,
- (CONST BYTE*)(list->name),
- strlen(list->name) + 1);
- if (res != ERROR_SUCCESS) goto error_close_clsid_key;
- }
-
- if (list->ips) {
- res = register_key_defvalueA(clsid_key, ips_keyname, list->ips);
- if (res != ERROR_SUCCESS) goto error_close_clsid_key;
- }
-
- if (list->ips32) {
- HKEY ips32_key;
-
- res = RegCreateKeyExW(clsid_key, ips32_keyname, 0, NULL, 0,
- KEY_READ | KEY_WRITE, NULL,
- &ips32_key, NULL);
- if (res != ERROR_SUCCESS) goto error_close_clsid_key;
-
- res = RegSetValueExA(ips32_key, NULL, 0, REG_SZ,
- (CONST BYTE*)list->ips32,
- lstrlenA(list->ips32) + 1);
- if (res == ERROR_SUCCESS && list->ips32_tmodel)
- res = RegSetValueExA(ips32_key, tmodel_valuename, 0, REG_SZ,
- (CONST BYTE*)list->ips32_tmodel,
- strlen(list->ips32_tmodel) + 1);
- RegCloseKey(ips32_key);
- if (res != ERROR_SUCCESS) goto error_close_clsid_key;
- }
-
- if (list->progid) {
- res = register_key_defvalueA(clsid_key, progid_keyname,
- list->progid);
- if (res != ERROR_SUCCESS) goto error_close_clsid_key;
-
- res = register_progid(buf, list->progid, NULL,
- list->name, list->progid_extra);
- if (res != ERROR_SUCCESS) goto error_close_clsid_key;
- }
-
- if (list->viprogid) {
- res = register_key_defvalueA(clsid_key, viprogid_keyname,
- list->viprogid);
- if (res != ERROR_SUCCESS) goto error_close_clsid_key;
-
- res = register_progid(buf, list->viprogid, list->progid,
- list->name, list->progid_extra);
- if (res != ERROR_SUCCESS) goto error_close_clsid_key;
- }
-
- error_close_clsid_key:
- RegCloseKey(clsid_key);
- }
-
-error_close_coclass_key:
- RegCloseKey(coclass_key);
-error_return:
- return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
-}
-
-/***********************************************************************
- * unregister_coclasses
- */
-static HRESULT unregister_coclasses(struct regsvr_coclass const *list)
-{
- LONG res = ERROR_SUCCESS;
- HKEY coclass_key;
-
- res = RegOpenKeyExW(HKEY_CLASSES_ROOT, clsid_keyname, 0,
- KEY_READ | KEY_WRITE, &coclass_key);
- if (res == ERROR_FILE_NOT_FOUND) return S_OK;
- if (res != ERROR_SUCCESS) goto error_return;
-
- for (; res == ERROR_SUCCESS && list->clsid; ++list) {
- WCHAR buf[39];
-
- StringFromGUID2(list->clsid, buf, 39);
- res = RegDeleteTreeW(coclass_key, buf);
- if (res == ERROR_FILE_NOT_FOUND) res = ERROR_SUCCESS;
- if (res != ERROR_SUCCESS) goto error_close_coclass_key;
-
- if (list->progid) {
- res = RegDeleteTreeA(HKEY_CLASSES_ROOT, list->progid);
- if (res == ERROR_FILE_NOT_FOUND) res = ERROR_SUCCESS;
- if (res != ERROR_SUCCESS) goto error_close_coclass_key;
- }
-
- if (list->viprogid) {
- res = RegDeleteTreeA(HKEY_CLASSES_ROOT, list->viprogid);
- if (res == ERROR_FILE_NOT_FOUND) res = ERROR_SUCCESS;
- if (res != ERROR_SUCCESS) goto error_close_coclass_key;
- }
- }
-
-error_close_coclass_key:
- RegCloseKey(coclass_key);
-error_return:
- return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
-}
-
-/***********************************************************************
- * regsvr_key_guid
- */
-static LONG register_key_guid(HKEY base, WCHAR const *name, GUID const *guid)
-{
- WCHAR buf[39];
-
- StringFromGUID2(guid, buf, 39);
- return register_key_defvalueW(base, name, buf);
-}
-
-/***********************************************************************
- * regsvr_key_defvalueW
- */
-static LONG register_key_defvalueW(
- HKEY base,
- WCHAR const *name,
- WCHAR const *value)
-{
- LONG res;
- HKEY key;
-
- res = RegCreateKeyExW(base, name, 0, NULL, 0,
- KEY_READ | KEY_WRITE, NULL, &key, NULL);
- if (res != ERROR_SUCCESS) return res;
- res = RegSetValueExW(key, NULL, 0, REG_SZ, (CONST BYTE*)value,
- (lstrlenW(value) + 1) * sizeof(WCHAR));
- RegCloseKey(key);
- return res;
-}
-
-/***********************************************************************
- * regsvr_key_defvalueA
- */
-static LONG register_key_defvalueA(
- HKEY base,
- WCHAR const *name,
- char const *value)
-{
- LONG res;
- HKEY key;
-
- res = RegCreateKeyExW(base, name, 0, NULL, 0,
- KEY_READ | KEY_WRITE, NULL, &key, NULL);
- if (res != ERROR_SUCCESS) return res;
- res = RegSetValueExA(key, NULL, 0, REG_SZ, (CONST BYTE*)value,
- lstrlenA(value) + 1);
- RegCloseKey(key);
- return res;
-}
-
-/***********************************************************************
- * regsvr_progid
- */
-static LONG register_progid(
- WCHAR const *clsid,
- char const *progid,
- char const *curver_progid,
- char const *name,
- char const *extra)
-{
- LONG res;
- HKEY progid_key;
-
- res = RegCreateKeyExA(HKEY_CLASSES_ROOT, progid, 0,
- NULL, 0, KEY_READ | KEY_WRITE, NULL,
- &progid_key, NULL);
- if (res != ERROR_SUCCESS) return res;
-
- if (name) {
- res = RegSetValueExA(progid_key, NULL, 0, REG_SZ,
- (CONST BYTE*)name, strlen(name) + 1);
- if (res != ERROR_SUCCESS) goto error_close_progid_key;
- }
-
- if (clsid) {
- res = register_key_defvalueW(progid_key, clsid_keyname, clsid);
- if (res != ERROR_SUCCESS) goto error_close_progid_key;
- }
-
- if (curver_progid) {
- res = register_key_defvalueA(progid_key, curver_keyname,
- curver_progid);
- if (res != ERROR_SUCCESS) goto error_close_progid_key;
- }
-
- if (extra) {
- HKEY extra_key;
-
- res = RegCreateKeyExA(progid_key, extra, 0,
- NULL, 0, KEY_READ | KEY_WRITE, NULL,
- &extra_key, NULL);
- if (res == ERROR_SUCCESS)
- RegCloseKey(extra_key);
- }
-
-error_close_progid_key:
- RegCloseKey(progid_key);
- return res;
-}
-
-/***********************************************************************
- * coclass list
- */
-static struct regsvr_coclass const coclass_list[] = {
- {
- &CLSID_DirectInput,
- "DirectInput Object",
- NULL,
- "dinput.dll",
- "Both"
- },
- {
- &CLSID_DirectInputDevice,
- "DirectInputDevice Object",
- NULL,
- "dinput.dll",
- "Both"
- },
- { NULL } /* list terminator */
-};
-
-/***********************************************************************
- * interface list
- */
-
-static struct regsvr_interface const interface_list[] = {
- { NULL } /* list terminator */
-};
-
-/***********************************************************************
- * DllRegisterServer (DINPUT.@)
- */
-HRESULT WINAPI DllRegisterServer(void)
-{
- HRESULT hr;
-
- TRACE("\n");
-
- hr = register_coclasses(coclass_list);
- if (SUCCEEDED(hr))
- hr = register_interfaces(interface_list);
- return hr;
-}
-
-/***********************************************************************
- * DllUnregisterServer (DINPUT.@)
- */
-HRESULT WINAPI DllUnregisterServer(void)
-{
- HRESULT hr;
-
- TRACE("\n");
-
- hr = unregister_coclasses(coclass_list);
- if (SUCCEEDED(hr))
- hr = unregister_interfaces(interface_list);
- return hr;
-}
--- /dev/null
+/*
+ * Copyright (c) 2011 Lucas Fialho Zawacki
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+//#include "shlobj.h"
+
+#include <windef.h>
+#include <winuser.h>
+#include <commctrl.h>
+
+#define IDD_CONFIGUREDEVICES 1
+
+#define IDC_DEVICETEXT 20
+#define IDC_RESET 21
+#define IDC_ACTIONTEXT 22
+#define IDC_PLAYERTEXT 23
+#define IDC_DEVICEOBJECTSTEXT 24
+#define IDC_CONTROLLERCOMBO 25
+#define IDC_PLAYERCOMBO 26
+#define IDC_ACTIONLIST 27
+#define IDC_DEVICEOBJECTSLIST 28
+#define IDC_CHECKBOXSORT 29
+#define IDC_MAPPINGTEXT 30
+#define IDS_ACTIONCOLUMN 31
+#define IDS_OBJECTCOLUMN 32
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
-#ifndef __WINE_DINPUT_H
-#define __WINE_DINPUT_H
+#ifndef __DINPUT_INCLUDED__
+#define __DINPUT_INCLUDED__
+#define COM_NO_WINDOWS_H
#include <objbase.h>
#ifndef DIRECTINPUT_VERSION
DECL_WINELIB_TYPE_AW(LPDIRECTINPUT2)
#define IID_IDirectInput7 WINELIB_NAME_AW(IID_IDirectInput7)
DECL_WINELIB_TYPE_AW(LPDIRECTINPUT7)
+#define IID_IDirectInput8 WINELIB_NAME_AW(IID_IDirectInput8)
+DECL_WINELIB_TYPE_AW(LPDIRECTINPUT8)
#define IID_IDirectInputDevice WINELIB_NAME_AW(IID_IDirectInputDevice)
DECL_WINELIB_TYPE_AW(LPDIRECTINPUTDEVICE)
#define IID_IDirectInputDevice2 WINELIB_NAME_AW(IID_IDirectInputDevice2)
#define DI_BUFFEROVERFLOW S_FALSE
#define DI_PROPNOEFFECT S_FALSE
#define DI_NOEFFECT S_FALSE
-#define DI_POLLEDDEVICE ((HRESULT)0x00000002L)
-#define DI_DOWNLOADSKIPPED ((HRESULT)0x00000003L)
-#define DI_EFFECTRESTARTED ((HRESULT)0x00000004L)
-#define DI_TRUNCATED ((HRESULT)0x00000008L)
-#define DI_TRUNCATEDANDRESTARTED ((HRESULT)0x0000000CL)
+#define DI_POLLEDDEVICE ((HRESULT)0x00000002)
+#define DI_DOWNLOADSKIPPED ((HRESULT)0x00000003)
+#define DI_EFFECTRESTARTED ((HRESULT)0x00000004)
+#define DI_TRUNCATED ((HRESULT)0x00000008)
+#define DI_SETTINGSNOTSAVED ((HRESULT)0x0000000B)
+#define DI_TRUNCATEDANDRESTARTED ((HRESULT)0x0000000C)
#define DIERR_OLDDIRECTINPUTVERSION \
MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_OLD_WIN_VERSION)
#define DIERR_EFFECTPLAYING 0x80040208L
#define DIERR_UNPLUGGED 0x80040209L
#define DIERR_REPORTFULL 0x8004020AL
+#define DIERR_MAPFILEFAIL 0x8004020BL
#define DIENUM_STOP 0
#define DIENUM_CONTINUE 1
#define DIEDFL_ALLDEVICES 0x00000000
-#define DIEDFL_ATTACHEDONLY 0x00000000
+#define DIEDFL_ATTACHEDONLY 0x00000001
#define DIEDFL_FORCEFEEDBACK 0x00000100
#define DIEDFL_INCLUDEALIASES 0x00010000
#define DIEDFL_INCLUDEPHANTOMS 0x00020000
#define DI8DEVTYPE_SCREENPOINTER 0x1A
#define DI8DEVTYPE_REMOTE 0x1B
#define DI8DEVTYPE_SUPPLEMENTAL 0x1C
-
+
#define DIDEVTYPEMOUSE_UNKNOWN 1
#define DIDEVTYPEMOUSE_TRADITIONAL 2
#define DIDEVTYPEMOUSE_FINGERSTICK 3
#define DI8DEVTYPESUPPLEMENTAL_DUALPEDALS 11
#define DI8DEVTYPESUPPLEMENTAL_THREEPEDALS 12
#define DI8DEVTYPESUPPLEMENTAL_RUDDERPEDALS 13
-
+
#define GET_DIDEVICE_TYPE(dwDevType) LOBYTE(dwDevType)
#define GET_DIDEVICE_SUBTYPE(dwDevType) HIBYTE(dwDevType)
DWORD dwType;
DWORD dwFlags;
CHAR tszName[MAX_PATH];
-#if(DIRECTINPUT_VERSION >= 0x0500)
DWORD dwFFMaxForce;
DWORD dwFFForceResolution;
WORD wCollectionNumber;
DWORD dwDimension;
WORD wExponent;
WORD wReserved;
-#endif /* DIRECTINPUT_VERSION >= 0x0500 */
} DIDEVICEOBJECTINSTANCEA, *LPDIDEVICEOBJECTINSTANCEA;
typedef const DIDEVICEOBJECTINSTANCEA *LPCDIDEVICEOBJECTINSTANCEA;
DWORD dwType;
DWORD dwFlags;
WCHAR tszName[MAX_PATH];
-#if(DIRECTINPUT_VERSION >= 0x0500)
DWORD dwFFMaxForce;
DWORD dwFFForceResolution;
WORD wCollectionNumber;
DWORD dwDimension;
WORD wExponent;
WORD wReserved;
-#endif /* DIRECTINPUT_VERSION >= 0x0500 */
} DIDEVICEOBJECTINSTANCEW, *LPDIDEVICEOBJECTINSTANCEW;
typedef const DIDEVICEOBJECTINSTANCEW *LPCDIDEVICEOBJECTINSTANCEW;
DWORD dwDevType;
CHAR tszInstanceName[MAX_PATH];
CHAR tszProductName[MAX_PATH];
-#if(DIRECTINPUT_VERSION >= 0x0500)
GUID guidFFDriver;
WORD wUsagePage;
WORD wUsage;
-#endif /* DIRECTINPUT_VERSION >= 0x0500 */
} DIDEVICEINSTANCEA, *LPDIDEVICEINSTANCEA;
typedef const DIDEVICEINSTANCEA *LPCDIDEVICEINSTANCEA;
DWORD dwDevType;
WCHAR tszInstanceName[MAX_PATH];
WCHAR tszProductName[MAX_PATH];
-#if(DIRECTINPUT_VERSION >= 0x0500)
GUID guidFFDriver;
WORD wUsagePage;
WORD wUsage;
-#endif /* DIRECTINPUT_VERSION >= 0x0500 */
} DIDEVICEINSTANCEW, *LPDIDEVICEINSTANCEW;
typedef const DIDEVICEINSTANCEW *LPCDIDEVICEINSTANCEW;
DECL_WINELIB_TYPE_AW(LPDIDEVICEINSTANCE)
DECL_WINELIB_TYPE_AW(LPCDIDEVICEINSTANCE)
+typedef BOOL (CALLBACK *LPDIENUMDEVICESCALLBACKA)(LPCDIDEVICEINSTANCEA,LPVOID);
+typedef BOOL (CALLBACK *LPDIENUMDEVICESCALLBACKW)(LPCDIDEVICEINSTANCEW,LPVOID);
+DECL_WINELIB_TYPE_AW(LPDIENUMDEVICESCALLBACK)
+
+#define DIEDBS_MAPPEDPRI1 0x00000001
+#define DIEDBS_MAPPEDPRI2 0x00000002
+#define DIEDBS_RECENTDEVICE 0x00000010
+#define DIEDBS_NEWDEVICE 0x00000020
+
#define DIEDBSFL_ATTACHEDONLY 0x00000000
-#define DIEDBSFL_THISUSER 0x00000010
+#define DIEDBSFL_THISUSER 0x00000010
#define DIEDBSFL_FORCEFEEDBACK DIEDFL_FORCEFEEDBACK
#define DIEDBSFL_AVAILABLEDEVICES 0x00001000
#define DIEDBSFL_MULTIMICEKEYBOARDS 0x00002000
#define DIEDBSFL_NONGAMINGDEVICES 0x00004000
-#define DIEDBSFL_VALID 0x00007110
-
-typedef BOOL (CALLBACK *LPDIENUMDEVICESCALLBACKA)(LPCDIDEVICEINSTANCEA,LPVOID);
-typedef BOOL (CALLBACK *LPDIENUMDEVICESCALLBACKW)(LPCDIDEVICEINSTANCEW,LPVOID);
-DECL_WINELIB_TYPE_AW(LPDIENUMDEVICESCALLBACK)
+#define DIEDBSFL_VALID 0x00007110
-#if DIRECTINPUT_VERSION >= 0x0800
typedef BOOL (CALLBACK *LPDIENUMDEVICESBYSEMANTICSCBA)(LPCDIDEVICEINSTANCEA,LPDIRECTINPUTDEVICE8A,DWORD,DWORD,LPVOID);
typedef BOOL (CALLBACK *LPDIENUMDEVICESBYSEMANTICSCBW)(LPCDIDEVICEINSTANCEW,LPDIRECTINPUTDEVICE8W,DWORD,DWORD,LPVOID);
DECL_WINELIB_TYPE_AW(LPDIENUMDEVICESBYSEMANTICSCB)
-#endif
typedef BOOL (CALLBACK *LPDICONFIGUREDEVICESCALLBACK)(LPUNKNOWN,LPVOID);
#define DIK_DOWNARROW DIK_DOWN /* DownArrow on arrow keypad */
#define DIK_PGDN DIK_NEXT /* PgDn on arrow keypad */
+/* New DirectInput8 style keyboard constants */
+
+#define DIKEYBOARD_ESCAPE (DIK_ESCAPE | 0x81000400)
+#define DIKEYBOARD_1 (DIK_1 | 0x81000400)
+#define DIKEYBOARD_2 (DIK_2 | 0x81000400)
+#define DIKEYBOARD_3 (DIK_3 | 0x81000400)
+#define DIKEYBOARD_4 (DIK_4 | 0x81000400)
+#define DIKEYBOARD_5 (DIK_5 | 0x81000400)
+#define DIKEYBOARD_6 (DIK_6 | 0x81000400)
+#define DIKEYBOARD_7 (DIK_7 | 0x81000400)
+#define DIKEYBOARD_8 (DIK_8 | 0x81000400)
+#define DIKEYBOARD_9 (DIK_9 | 0x81000400)
+#define DIKEYBOARD_0 (DIK_0 | 0x81000400)
+#define DIKEYBOARD_MINUS (DIK_MINUS | 0x81000400)
+#define DIKEYBOARD_EQUALS (DIK_EQUALS | 0x81000400)
+#define DIKEYBOARD_BACK (DIK_BACK | 0x81000400)
+#define DIKEYBOARD_TAB (DIK_TAB | 0x81000400)
+#define DIKEYBOARD_Q (DIK_Q | 0x81000400)
+#define DIKEYBOARD_W (DIK_W | 0x81000400)
+#define DIKEYBOARD_E (DIK_E | 0x81000400)
+#define DIKEYBOARD_R (DIK_R | 0x81000400)
+#define DIKEYBOARD_T (DIK_T | 0x81000400)
+#define DIKEYBOARD_Y (DIK_Y | 0x81000400)
+#define DIKEYBOARD_U (DIK_U | 0x81000400)
+#define DIKEYBOARD_I (DIK_I | 0x81000400)
+#define DIKEYBOARD_O (DIK_O | 0x81000400)
+#define DIKEYBOARD_P (DIK_P | 0x81000400)
+#define DIKEYBOARD_LBRACKET (DIK_LBRACKET | 0x81000400)
+#define DIKEYBOARD_RBRACKET (DIK_RBRACKET | 0x81000400)
+#define DIKEYBOARD_RETURN (DIK_RETURN | 0x81000400)
+#define DIKEYBOARD_LCONTROL (DIK_LCONTROL | 0x81000400)
+#define DIKEYBOARD_A (DIK_A | 0x81000400)
+#define DIKEYBOARD_S (DIK_S | 0x81000400)
+#define DIKEYBOARD_D (DIK_D | 0x81000400)
+#define DIKEYBOARD_F (DIK_F | 0x81000400)
+#define DIKEYBOARD_G (DIK_G | 0x81000400)
+#define DIKEYBOARD_H (DIK_H | 0x81000400)
+#define DIKEYBOARD_J (DIK_J | 0x81000400)
+#define DIKEYBOARD_K (DIK_K | 0x81000400)
+#define DIKEYBOARD_L (DIK_L | 0x81000400)
+#define DIKEYBOARD_SEMICOLON (DIK_SEMICOLON | 0x81000400)
+#define DIKEYBOARD_APOSTROPHE (DIK_APOSTROPHE | 0x81000400)
+#define DIKEYBOARD_GRAVE (DIK_GRAVE | 0x81000400)
+#define DIKEYBOARD_LSHIFT (DIK_LSHIFT | 0x81000400)
+#define DIKEYBOARD_BACKSLASH (DIK_BACKSLASH | 0x81000400)
+#define DIKEYBOARD_Z (DIK_Z | 0x81000400)
+#define DIKEYBOARD_X (DIK_X | 0x81000400)
+#define DIKEYBOARD_C (DIK_C | 0x81000400)
+#define DIKEYBOARD_V (DIK_V | 0x81000400)
+#define DIKEYBOARD_B (DIK_B | 0x81000400)
+#define DIKEYBOARD_N (DIK_N | 0x81000400)
+#define DIKEYBOARD_M (DIK_M | 0x81000400)
+#define DIKEYBOARD_COMMA (DIK_COMMA | 0x81000400)
+#define DIKEYBOARD_PERIOD (DIK_PERIOD | 0x81000400)
+#define DIKEYBOARD_SLASH (DIK_SLASH | 0x81000400)
+#define DIKEYBOARD_RSHIFT (DIK_RSHIFT | 0x81000400)
+#define DIKEYBOARD_MULTIPLY (DIK_MULTIPLY | 0x81000400)
+#define DIKEYBOARD_LMENU (DIK_LMENU | 0x81000400)
+#define DIKEYBOARD_SPACE (DIK_SPACE | 0x81000400)
+#define DIKEYBOARD_CAPITAL (DIK_CAPITAL | 0x81000400)
+#define DIKEYBOARD_F1 (DIK_F1 | 0x81000400)
+#define DIKEYBOARD_F2 (DIK_F2 | 0x81000400)
+#define DIKEYBOARD_F3 (DIK_F3 | 0x81000400)
+#define DIKEYBOARD_F4 (DIK_F4 | 0x81000400)
+#define DIKEYBOARD_F5 (DIK_F5 | 0x81000400)
+#define DIKEYBOARD_F6 (DIK_F6 | 0x81000400)
+#define DIKEYBOARD_F7 (DIK_F7 | 0x81000400)
+#define DIKEYBOARD_F8 (DIK_F8 | 0x81000400)
+#define DIKEYBOARD_F9 (DIK_F9 | 0x81000400)
+#define DIKEYBOARD_F10 (DIK_F10 | 0x81000400)
+#define DIKEYBOARD_NUMLOCK (DIK_NUMLOCK | 0x81000400)
+#define DIKEYBOARD_SCROLL (DIK_SCROLL | 0x81000400)
+#define DIKEYBOARD_NUMPAD7 (DIK_NUMPAD7 | 0x81000400)
+#define DIKEYBOARD_NUMPAD8 (DIK_NUMPAD8 | 0x81000400)
+#define DIKEYBOARD_NUMPAD9 (DIK_NUMPAD9 | 0x81000400)
+#define DIKEYBOARD_SUBTRACT (DIK_SUBTRACT | 0x81000400)
+#define DIKEYBOARD_NUMPAD4 (DIK_NUMPAD4 | 0x81000400)
+#define DIKEYBOARD_NUMPAD5 (DIK_NUMPAD5 | 0x81000400)
+#define DIKEYBOARD_NUMPAD6 (DIK_NUMPAD6 | 0x81000400)
+#define DIKEYBOARD_ADD (DIK_ADD | 0x81000400)
+#define DIKEYBOARD_NUMPAD1 (DIK_NUMPAD1 | 0x81000400)
+#define DIKEYBOARD_NUMPAD2 (DIK_NUMPAD2 | 0x81000400)
+#define DIKEYBOARD_NUMPAD3 (DIK_NUMPAD3 | 0x81000400)
+#define DIKEYBOARD_NUMPAD0 (DIK_NUMPAD0 | 0x81000400)
+#define DIKEYBOARD_DECIMAL (DIK_DECIMAL | 0x81000400)
+#define DIKEYBOARD_F11 (DIK_F11 | 0x81000400)
+#define DIKEYBOARD_F12 (DIK_F12 | 0x81000400)
+#define DIKEYBOARD_F13 (DIK_F13 | 0x81000400)
+#define DIKEYBOARD_F14 (DIK_F14 | 0x81000400)
+#define DIKEYBOARD_F15 (DIK_F15 | 0x81000400)
+#define DIKEYBOARD_KANA (DIK_KANA | 0x81000400)
+#define DIKEYBOARD_CONVERT (DIK_CONVERT | 0x81000400)
+#define DIKEYBOARD_NOCONVERT (DIK_NOCONVERT | 0x81000400)
+#define DIKEYBOARD_YEN (DIK_YEN | 0x81000400)
+#define DIKEYBOARD_NUMPADEQUALS (DIK_NUMPADEQUALS | 0x81000400)
+#define DIKEYBOARD_CIRCUMFLEX (DIK_CIRCUMFLEX | 0x81000400)
+#define DIKEYBOARD_AT (DIK_AT | 0x81000400)
+#define DIKEYBOARD_COLON (DIK_COLON | 0x81000400)
+#define DIKEYBOARD_UNDERLINE (DIK_UNDERLINE | 0x81000400)
+#define DIKEYBOARD_KANJI (DIK_KANJI | 0x81000400)
+#define DIKEYBOARD_STOP (DIK_STOP | 0x81000400)
+#define DIKEYBOARD_AX (DIK_AX | 0x81000400)
+#define DIKEYBOARD_UNLABELED (DIK_UNLABELED | 0x81000400)
+#define DIKEYBOARD_NUMPADENTER (DIK_NUMPADENTER | 0x81000400)
+#define DIKEYBOARD_RCONTROL (DIK_RCONTROL | 0x81000400)
+#define DIKEYBOARD_NUMPADCOMMA (DIK_NUMPADCOMMA | 0x81000400)
+#define DIKEYBOARD_DIVIDE (DIK_DIVIDE | 0x81000400)
+#define DIKEYBOARD_SYSRQ (DIK_SYSRQ | 0x81000400)
+#define DIKEYBOARD_RMENU (DIK_RMENU | 0x81000400)
+#define DIKEYBOARD_PAUSE (DIK_PAUSE | 0x81000400)
+#define DIKEYBOARD_HOME (DIK_HOME | 0x81000400)
+#define DIKEYBOARD_UP (DIK_UP | 0x81000400)
+#define DIKEYBOARD_PRIOR (DIK_PRIOR | 0x81000400)
+#define DIKEYBOARD_LEFT (DIK_LEFT | 0x81000400)
+#define DIKEYBOARD_RIGHT (DIK_RIGHT | 0x81000400)
+#define DIKEYBOARD_END (DIK_END | 0x81000400)
+#define DIKEYBOARD_DOWN (DIK_DOWN | 0x81000400)
+#define DIKEYBOARD_NEXT (DIK_NEXT | 0x81000400)
+#define DIKEYBOARD_INSERT (DIK_INSERT | 0x81000400)
+#define DIKEYBOARD_DELETE (DIK_DELETE | 0x81000400)
+#define DIKEYBOARD_LWIN (DIK_LWIN | 0x81000400)
+#define DIKEYBOARD_RWIN (DIK_RWIN | 0x81000400)
+#define DIKEYBOARD_APPS (DIK_APPS | 0x81000400)
+#define DIKEYBOARD_POWER (DIK_POWER | 0x81000400)
+#define DIKEYBOARD_SLEEP (DIK_SLEEP | 0x81000400)
+#define DIKEYBOARD_BACKSPACE (DIK_BACKSPACE | 0x81000400)
+#define DIKEYBOARD_NUMPADSTAR (DIK_NUMPADSTAR | 0x81000400)
+#define DIKEYBOARD_LALT (DIK_LALT | 0x81000400)
+#define DIKEYBOARD_CAPSLOCK (DIK_CAPSLOCK | 0x81000400)
+#define DIKEYBOARD_NUMPADMINUS (DIK_NUMPADMINUS | 0x81000400)
+#define DIKEYBOARD_NUMPADPLUS (DIK_NUMPADPLUS | 0x81000400)
+#define DIKEYBOARD_NUMPADPERIOD (DIK_NUMPADPERIOD | 0x81000400)
+#define DIKEYBOARD_NUMPADSLASH (DIK_NUMPADSLASH | 0x81000400)
+#define DIKEYBOARD_RALT (DIK_RALT | 0x81000400)
+#define DIKEYBOARD_UPARROW (DIK_UPARROW | 0x81000400)
+#define DIKEYBOARD_PGUP (DIK_PGUP | 0x81000400)
+#define DIKEYBOARD_LEFTARROW (DIK_LEFTARROW | 0x81000400)
+#define DIKEYBOARD_RIGHTARROW (DIK_RIGHTARROW | 0x81000400)
+#define DIKEYBOARD_DOWNARROW (DIK_DOWNARROW | 0x81000400)
+#define DIKEYBOARD_PGDN (DIK_PGDN | 0x81000400)
+
#define DIDFT_ALL 0x00000000
#define DIDFT_RELAXIS 0x00000001
#define DIDFT_ABSAXIS 0x00000002
#define DIGDD_PEEK 0x00000001
+#define DISEQUENCE_COMPARE(dwSq1,cmp,dwSq2) ((int)((dwSq1) - (dwSq2)) cmp 0)
+
typedef struct DIDEVICEOBJECTDATA_DX3 {
DWORD dwOfs;
DWORD dwData;
typedef const DIPROPGUIDANDPATH *LPCDIPROPGUIDANDPATH;
typedef struct DIPROPSTRING {
- DIPROPHEADER diph;
- WCHAR wsz[MAX_PATH];
+ DIPROPHEADER diph;
+ WCHAR wsz[MAX_PATH];
} DIPROPSTRING, *LPDIPROPSTRING;
typedef const DIPROPSTRING *LPCDIPROPSTRING;
#define DIPROPCALIBRATIONMODE_COOKED 0
#define DIPROPCALIBRATIONMODE_RAW 1
-#if DIRECTINPUT_VERSION >= 0x050a
#define DIPROP_CALIBRATION MAKEDIPROP(11)
#define DIPROP_GUIDANDPATH MAKEDIPROP(12)
-#define DIPROP_INSTANCENAME MAKEDIPROP(13)
-#define DIPROP_PRODUCTNAME MAKEDIPROP(14)
-#endif
-#if DIRECTINPUT_VERSION >= 0x5B2
-#define DIPROP_JOYSTICKID MAKEDIPROP(15)
-#define DIPROP_GETPORTDISPLAYNAME MAKEDIPROP(16)
-#endif
-
-#if DIRECTINPUT_VERSION >= 0x0700
-#define DIPROP_PHYSICALRANGE MAKEDIPROP(18)
-#define DIPROP_LOGICALRANGE MAKEDIPROP(19)
-#endif
-
-#if(DIRECTINPUT_VERSION >= 0x0800)
-#define DIPROP_KEYNAME MAKEDIPROP(20)
-#define DIPROP_CPOINTS MAKEDIPROP(21)
-#define DIPROP_APPDATA MAKEDIPROP(22)
-#define DIPROP_SCANCODE MAKEDIPROP(23)
-#define DIPROP_VIDPID MAKEDIPROP(24)
-#define DIPROP_USERNAME MAKEDIPROP(25)
-#define DIPROP_TYPENAME MAKEDIPROP(26)
-#endif
+#define DIPROP_INSTANCENAME MAKEDIPROP(13)
+#define DIPROP_JOYSTICKID MAKEDIPROP(15)
+#define DIPROP_KEYNAME MAKEDIPROP(20)
+#define DIPROP_VIDPID MAKEDIPROP(24)
+#define DIPROP_KEYNAME MAKEDIPROP(20)
+#define DIPROP_CPOINTS MAKEDIPROP(21)
+#define DIPROP_APPDATA MAKEDIPROP(22)
+#define DIPROP_SCANCODE MAKEDIPROP(23)
+#define DIPROP_VIDPID MAKEDIPROP(24)
+#define DIPROP_USERNAME MAKEDIPROP(25)
+#define DIPROP_TYPENAME MAKEDIPROP(26)
typedef struct DIDEVCAPS_DX3 {
DWORD dwSize;
DWORD dwAxes;
DWORD dwButtons;
DWORD dwPOVs;
-#if(DIRECTINPUT_VERSION >= 0x0500)
DWORD dwFFSamplePeriod;
DWORD dwFFMinTimeResolution;
DWORD dwFirmwareRevision;
DWORD dwHardwareRevision;
DWORD dwFFDriverVersion;
-#endif /* DIRECTINPUT_VERSION >= 0x0500 */
} DIDEVCAPS,*LPDIDEVCAPS;
#define DIDC_ATTACHED 0x00000001
#define DISCL_NONEXCLUSIVE 0x00000002
#define DISCL_FOREGROUND 0x00000004
#define DISCL_BACKGROUND 0x00000008
-#define DISCL_NOWINKEY 0x00000010
+#define DISCL_NOWINKEY 0x00000010
/* Device FF flags */
-#define DISFFC_RESET 0x00000001
-
+#define DISFFC_RESET 0x00000001
+#define DISFFC_STOPALL 0x00000002
+#define DISFFC_PAUSE 0x00000004
+#define DISFFC_CONTINUE 0x00000008
+#define DISFFC_SETACTUATORSON 0x00000010
+#define DISFFC_SETACTUATORSOFF 0x00000020
+
+#define DIGFFS_EMPTY 0x00000001
+#define DIGFFS_STOPPED 0x00000002
+#define DIGFFS_PAUSED 0x00000004
+#define DIGFFS_ACTUATORSON 0x00000010
+#define DIGFFS_ACTUATORSOFF 0x00000020
+#define DIGFFS_POWERON 0x00000040
+#define DIGFFS_POWEROFF 0x00000080
+#define DIGFFS_SAFETYSWITCHON 0x00000100
+#define DIGFFS_SAFETYSWITCHOFF 0x00000200
+#define DIGFFS_USERFFSWITCHON 0x00000400
+#define DIGFFS_USERFFSWITCHOFF 0x00000800
+#define DIGFFS_DEVICELOST 0x80000000
+
+/* Effect flags */
#define DIEFT_ALL 0x00000000
-
+
#define DIEFT_CONSTANTFORCE 0x00000001
#define DIEFT_RAMPFORCE 0x00000002
#define DIEFT_PERIODIC 0x00000003
#define DIEFT_DEADBAND 0x00004000
#define DIEFT_STARTDELAY 0x00008000
#define DIEFT_GETTYPE(n) LOBYTE(n)
+
+#define DIEFF_OBJECTIDS 0x00000001
+#define DIEFF_OBJECTOFFSETS 0x00000002
+#define DIEFF_CARTESIAN 0x00000010
+#define DIEFF_POLAR 0x00000020
+#define DIEFF_SPHERICAL 0x00000040
+
+#define DIEP_DURATION 0x00000001
+#define DIEP_SAMPLEPERIOD 0x00000002
+#define DIEP_GAIN 0x00000004
+#define DIEP_TRIGGERBUTTON 0x00000008
+#define DIEP_TRIGGERREPEATINTERVAL 0x00000010
+#define DIEP_AXES 0x00000020
+#define DIEP_DIRECTION 0x00000040
+#define DIEP_ENVELOPE 0x00000080
+#define DIEP_TYPESPECIFICPARAMS 0x00000100
+#define DIEP_STARTDELAY 0x00000200
+#define DIEP_ALLPARAMS_DX5 0x000001FF
+#define DIEP_ALLPARAMS 0x000003FF
+#define DIEP_START 0x20000000
+#define DIEP_NORESTART 0x40000000
+#define DIEP_NODOWNLOAD 0x80000000
+#define DIEB_NOTRIGGER 0xFFFFFFFF
+
+#define DIES_SOLO 0x00000001
+#define DIES_NODOWNLOAD 0x80000000
+
+#define DIEGES_PLAYING 0x00000001
+#define DIEGES_EMULATED 0x00000002
#define DI_DEGREES 100
#define DI_FFNOMINALMAX 10000
typedef BOOL (CALLBACK *LPDIENUMEFFECTSINFILECALLBACK)(LPCDIFILEEFFECT , LPVOID);
/* DInput 8 structures and types */
-#if DIRECTINPUT_VERSION >= 0x0800
typedef struct _DIACTIONA {
UINT_PTR uAppData;
- DWORD dwSemantics;
+ DWORD dwSemantic;
DWORD dwFlags;
union {
LPCSTR lptszActionName;
typedef struct _DIACTIONW {
UINT_PTR uAppData;
- DWORD dwSemantics;
+ DWORD dwSemantic;
DWORD dwFlags;
union {
LPCWSTR lptszActionName;
DECL_WINELIB_TYPE_AW(LPDIDEVICEIMAGEINFOHEADER)
DECL_WINELIB_TYPE_AW(LPCDIDEVICEIMAGEINFOHEADER)
-#endif /* DI8 */
-
/*****************************************************************************
* IDirectInputEffect interface
#define IDirectInputEffect_SetParameters(p,a,b) (p)->lpVtbl->SetParameters(p,a,b)
#define IDirectInputEffect_Start(p,a,b) (p)->lpVtbl->Start(p,a,b)
#define IDirectInputEffect_Stop(p) (p)->lpVtbl->Stop(p)
-#define IDirectInputEffect_GetEffectStatus(p,a,b) (p)->lpVtbl->GetEffectStatus(p,a)
+#define IDirectInputEffect_GetEffectStatus(p,a) (p)->lpVtbl->GetEffectStatus(p,a)
#define IDirectInputEffect_Download(p) (p)->lpVtbl->Download(p)
#define IDirectInputEffect_Unload(p) (p)->lpVtbl->Unload(p)
#define IDirectInputEffect_Escape(p,a) (p)->lpVtbl->Escape(p,a)
#define IDirectInputEffect_SetParameters(p,a,b) (p)->SetParameters(a,b)
#define IDirectInputEffect_Start(p,a,b) (p)->Start(a,b)
#define IDirectInputEffect_Stop(p) (p)->Stop()
-#define IDirectInputEffect_GetEffectStatus(p,a,b) (p)->GetEffectStatus(a)
+#define IDirectInputEffect_GetEffectStatus(p,a) (p)->GetEffectStatus(a)
#define IDirectInputEffect_Download(p) (p)->Download()
#define IDirectInputEffect_Unload(p) (p)->Unload()
#define IDirectInputEffect_Escape(p,a) (p)->Escape(a)
#define IDirectInputDevice2_SendDeviceData(p,a,b,c,d) (p)->SendDeviceData(a,b,c,d)
#endif
-#if DIRECTINPUT_VERSION >= 0x0700
/*****************************************************************************
* IDirectInputDevice7A interface
*/
#define IDirectInputDevice7_WriteEffectToFile(p,a,b,c,d) (p)->WriteEffectToFile(a,b,c,d)
#endif
-#endif /* DI7 */
-#if DIRECTINPUT_VERSION >= 0x0800
/*****************************************************************************
* IDirectInputDevice8A interface
*/
#define IDirectInputDevice8_GetImageInfo(p,a) (p)->GetImageInfo(a)
#endif
-#endif /* DI8 */
-
/* "Standard" Mouse report... */
typedef struct DIMOUSESTATE {
LONG lX;
#define DIMOFS_BUTTON6 (FIELD_OFFSET(DIMOUSESTATE2, rgbButtons) + 6)
#define DIMOFS_BUTTON7 (FIELD_OFFSET(DIMOUSESTATE2, rgbButtons) + 7)
+/* New DirectInput8 mouse definitions */
+
+#define DIMOUSE_XAXISAB (0x82000200 | DIMOFS_X)
+#define DIMOUSE_YAXISAB (0x82000200 | DIMOFS_Y)
+#define DIMOUSE_XAXIS (0x82000300 | DIMOFS_X)
+#define DIMOUSE_YAXIS (0x82000300 | DIMOFS_Y)
+#define DIMOUSE_WHEEL (0x82000300 | DIMOFS_Z)
+#define DIMOUSE_BUTTON0 (0x82000400 | DIMOFS_BUTTON0)
+#define DIMOUSE_BUTTON1 (0x82000400 | DIMOFS_BUTTON1)
+#define DIMOUSE_BUTTON2 (0x82000400 | DIMOFS_BUTTON2)
+#define DIMOUSE_BUTTON3 (0x82000400 | DIMOFS_BUTTON3)
+#define DIMOUSE_BUTTON4 (0x82000400 | DIMOFS_BUTTON4)
+#define DIMOUSE_BUTTON5 (0x82000400 | DIMOFS_BUTTON5)
+#define DIMOUSE_BUTTON6 (0x82000400 | DIMOFS_BUTTON6)
+#define DIMOUSE_BUTTON7 (0x82000400 | DIMOFS_BUTTON7)
+
#ifdef __cplusplus
extern "C" {
#endif
extern const DIDATAFORMAT c_dfDIJoystick;
extern const DIDATAFORMAT c_dfDIJoystick2;
#ifdef __cplusplus
-}
+};
#endif
+#define DIAXIS_ANY_X_1 0xFF00C201
+#define DIAXIS_ANY_X_2 0xFF00C202
+#define DIAXIS_ANY_Y_1 0xFF014201
+#define DIAXIS_ANY_Y_2 0xFF014202
+#define DIAXIS_ANY_Z_1 0xFF01C201
+#define DIAXIS_ANY_Z_2 0xFF01C202
+#define DIAXIS_ANY_R_1 0xFF024201
+#define DIAXIS_ANY_R_2 0xFF024202
+#define DIAXIS_ANY_U_1 0xFF02C201
+#define DIAXIS_ANY_U_2 0xFF02C202
+#define DIAXIS_ANY_V_1 0xFF034201
+#define DIAXIS_ANY_V_2 0xFF034202
+#define DIAXIS_ANY_A_1 0xFF03C201
+#define DIAXIS_ANY_A_2 0xFF03C202
+#define DIAXIS_ANY_B_1 0xFF044201
+#define DIAXIS_ANY_B_2 0xFF044202
+#define DIAXIS_ANY_C_1 0xFF04C201
+#define DIAXIS_ANY_C_2 0xFF04C202
+#define DIAXIS_ANY_S_1 0xFF054201
+#define DIAXIS_ANY_S_2 0xFF054202
+#define DIAXIS_ANY_1 0xFF004201
+#define DIAXIS_ANY_2 0xFF004202
+#define DIAXIS_ANY_3 0xFF004203
+#define DIAXIS_ANY_4 0xFF004204
+#define DIPOV_ANY_1 0xFF004601
+#define DIPOV_ANY_2 0xFF004602
+#define DIPOV_ANY_3 0xFF004603
+#define DIPOV_ANY_4 0xFF004604
+#define DIBUTTON_ANY(instance) (0xFF004400 | (instance))
+
+
/*****************************************************************************
* IDirectInputA interface
*/
#define IDirectInput2_FindDevice(p,a,b,c) (p)->FindDevice(a,b,c)
#endif
-#if DIRECTINPUT_VERSION >= 0x0700
/*****************************************************************************
* IDirectInput7A interface
*/
#define IDirectInput7_CreateDeviceEx(p,a,b,c,d) (p)->CreateDeviceEx(a,b,c,d)
#endif
-#endif /* DI7 */
-#if DIRECTINPUT_VERSION >= 0x0800
/*****************************************************************************
* IDirectInput8A interface
*/
#define IDirectInput8_ConfigureDevices(p,a,b,c,d) (p)->ConfigureDevices(a,b,c,d)
#endif
-#endif /* DI8 */
/* Export functions */
extern "C" {
#endif
-#if DIRECTINPUT_VERSION >= 0x0800
HRESULT WINAPI DirectInput8Create(HINSTANCE,DWORD,REFIID,LPVOID *,LPUNKNOWN);
-#endif
HRESULT WINAPI DirectInputCreateA(HINSTANCE,DWORD,LPDIRECTINPUTA *,LPUNKNOWN);
HRESULT WINAPI DirectInputCreateW(HINSTANCE,DWORD,LPDIRECTINPUTW *,LPUNKNOWN);
HRESULT WINAPI DirectInputCreateEx(HINSTANCE,DWORD,REFIID,LPVOID *,LPUNKNOWN);
#ifdef __cplusplus
-}
+};
#endif
-#endif /* __WINE_DINPUT_H */
+#endif /* __DINPUT_INCLUDED__ */
--- /dev/null
+/*
+ * Copyright (C) the Wine project
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#ifndef __DINPUTD_INCLUDED__
+#define __DINPUTD_INCLUDED__
+
+#define COM_NO_WINDOWS_H
+#include <objbase.h>
+
+#ifndef DIRECTINPUT_VERSION
+#define DIRECTINPUT_VERSION 0x0800
+#endif
+
+DEFINE_GUID(IID_IDirectInputJoyConfig8, 0xEB0D7DFA,0x1990,0x4F27,0xB4,0xD6,0xED,0xF2,0xEE,0xC4,0xA4,0x4C);
+
+typedef struct IDirectInputJoyConfig8 *LPDIRECTINPUTJOYCONFIG8;
+
+
+typedef BOOL (CALLBACK *LPDIJOYTYPECALLBACK)(LPCWSTR, LPVOID);
+
+#define MAX_JOYSTRING 256
+#ifndef MAX_JOYSTICKOEMVXDNAME
+#define MAX_JOYSTICKOEMVXDNAME 260
+#endif
+
+#define JOY_POV_NUMDIRS 4
+#define JOY_POVVAL_FORWARD 0
+#define JOY_POVVAL_BACKWARD 1
+#define JOY_POVVAL_LEFT 2
+#define JOY_POVVAL_RIGHT 3
+
+#define DIERR_NOMOREITEMS MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_NO_MORE_ITEMS)
+
+typedef struct joypos_tag
+{
+ DWORD dwX;
+ DWORD dwY;
+ DWORD dwZ;
+ DWORD dwR;
+ DWORD dwU;
+ DWORD dwV;
+} JOYPOS, *LPJOYPOS;
+
+typedef struct joyrange_tag
+{
+ JOYPOS jpMin;
+ JOYPOS jpMax;
+ JOYPOS jpCenter;
+} JOYRANGE, *LPJOYRANGE;
+
+typedef struct joyreguservalues_tag
+{
+ DWORD dwTimeOut;
+ JOYRANGE jrvRanges;
+ JOYPOS jpDeadZone;
+} JOYREGUSERVALUES, *LPJOYREGUSERVALUES;
+
+typedef struct joyreghwsettings_tag
+{
+ DWORD dwFlags;
+ DWORD dwNumButtons;
+} JOYREGHWSETTINGS, *LPJOYHWSETTINGS;
+
+typedef struct joyreghwvalues_tag
+{
+ JOYRANGE jrvHardware;
+ DWORD dwPOVValues[JOY_POV_NUMDIRS];
+ DWORD dwCalFlags;
+} JOYREGHWVALUES, *LPJOYREGHWVALUES;
+
+typedef struct joyreghwconfig_tag
+{
+ JOYREGHWSETTINGS hws;
+ DWORD dwUsageSettings;
+ JOYREGHWVALUES hwv;
+ DWORD dwType;
+ DWORD dwReserved;
+} JOYREGHWCONFIG, *LPJOYREGHWCONFIG;
+
+typedef struct DIJOYTYPEINFO_DX5
+{
+ DWORD dwSize;
+ JOYREGHWSETTINGS hws;
+ CLSID clsidConfig;
+ WCHAR wszDisplayName[MAX_JOYSTRING];
+ WCHAR wszCallout[MAX_JOYSTICKOEMVXDNAME];
+} DIJOYTYPEINFO_DX5, *LPDIJOYTYPEINFO_DX5;
+typedef const DIJOYTYPEINFO_DX5 *LPCDIJOYTYPEINFO_DX5;
+
+typedef struct DIJOYTYPEINFO_DX6
+{
+ DWORD dwSize;
+ JOYREGHWSETTINGS hws;
+ CLSID clsidConfig;
+ WCHAR wszDisplayName[MAX_JOYSTRING];
+ WCHAR wszCallout[MAX_JOYSTICKOEMVXDNAME];
+ WCHAR wszHardwareId[MAX_JOYSTRING];
+ DWORD dwFlags1;
+} DIJOYTYPEINFO_DX6, *LPDIJOYTYPEINFO_DX6;
+typedef const DIJOYTYPEINFO_DX6 *LPCDIJOYTYPEINFO_DX6;
+
+typedef struct DIJOYTYPEINFO
+{
+ DWORD dwSize;
+ JOYREGHWSETTINGS hws;
+ CLSID clsidConfig;
+ WCHAR wszDisplayName[MAX_JOYSTRING];
+ WCHAR wszCallout[MAX_JOYSTICKOEMVXDNAME];
+ WCHAR wszHardwareId[MAX_JOYSTRING];
+ DWORD dwFlags1;
+ DWORD dwFlags2;
+ WCHAR wszMapFile[MAX_JOYSTRING];
+} DIJOYTYPEINFO, *LPDIJOYTYPEINFO;
+typedef const DIJOYTYPEINFO *LPCDIJOYTYPEINFO;
+#define DIJC_GUIDINSTANCE 0x00000001
+#define DIJC_REGHWCONFIGTYPE 0x00000002
+#define DIJC_GAIN 0x00000004
+#define DIJC_CALLOUT 0x00000008
+#define DIJC_WDMGAMEPORT 0x00000010
+
+typedef struct DIJOYCONFIG_DX5
+{
+ DWORD dwSize;
+ GUID guidInstance;
+ JOYREGHWCONFIG hwc;
+ DWORD dwGain;
+ WCHAR wszType[MAX_JOYSTRING];
+ WCHAR wszCallout[MAX_JOYSTRING];
+} DIJOYCONFIG_DX5, *LPDIJOYCONFIG_DX5;
+typedef const DIJOYCONFIG_DX5 *LPCDIJOYCONFIG_DX5;
+
+typedef struct DIJOYCONFIG
+{
+ DWORD dwSize;
+ GUID guidInstance;
+ JOYREGHWCONFIG hwc;
+ DWORD dwGain;
+ WCHAR wszType[MAX_JOYSTRING];
+ WCHAR wszCallout[MAX_JOYSTRING];
+ GUID guidGameport;
+} DIJOYCONFIG, *LPDIJOYCONFIG;
+typedef const DIJOYCONFIG *LPCDIJOYCONFIG;
+
+typedef struct DIJOYUSERVALUES
+{
+ DWORD dwSize;
+ JOYREGUSERVALUES ruv;
+ WCHAR wszGlobalDriver[MAX_JOYSTRING];
+ WCHAR wszGameportEmulator[MAX_JOYSTRING];
+} DIJOYUSERVALUES, *LPDIJOYUSERVALUES;
+typedef const DIJOYUSERVALUES *LPCDIJOYUSERVALUES;
+
+
+/*****************************************************************************
+ * IDirectInputJoyConfig8 interface
+ */
+#define INTERFACE IDirectInputJoyConfig8
+DECLARE_INTERFACE_(IDirectInputJoyConfig8, IUnknown)
+{
+ /*** IUnknown methods ***/
+ STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
+ STDMETHOD_(ULONG,AddRef)(THIS) PURE;
+ STDMETHOD_(ULONG,Release)(THIS) PURE;
+ /*** IDirectInputJoyConfig8 methods ***/
+ STDMETHOD(Acquire)(THIS) PURE;
+ STDMETHOD(Unacquire)(THIS) PURE;
+ STDMETHOD(SetCooperativeLevel)(THIS_ HWND, DWORD) PURE;
+ STDMETHOD(SendNotify)(THIS) PURE;
+ STDMETHOD(EnumTypes)(THIS_ LPDIJOYTYPECALLBACK, LPVOID) PURE;
+ STDMETHOD(GetTypeInfo)(THIS_ LPCWSTR, LPDIJOYTYPEINFO, DWORD) PURE;
+ STDMETHOD(SetTypeInfo)(THIS_ LPCWSTR, LPCDIJOYTYPEINFO, DWORD, LPWSTR) PURE;
+ STDMETHOD(DeleteType)(THIS_ LPCWSTR) PURE;
+ STDMETHOD(GetConfig)(THIS_ UINT, LPDIJOYCONFIG, DWORD) PURE;
+ STDMETHOD(SetConfig)(THIS_ UINT, LPCDIJOYCONFIG, DWORD) PURE;
+ STDMETHOD(DeleteConfig)(THIS_ UINT) PURE;
+ STDMETHOD(GetUserValues)(THIS_ LPDIJOYUSERVALUES, DWORD) PURE;
+ STDMETHOD(SetUserValues)(THIS_ LPCDIJOYUSERVALUES, DWORD) PURE;
+ STDMETHOD(AddNewHardware)(THIS_ HWND, REFGUID) PURE;
+ STDMETHOD(OpenTypeKey)(THIS_ LPCWSTR, DWORD, PHKEY) PURE;
+ STDMETHOD(OpenAppStatusKey)(THIS_ PHKEY) PURE;
+};
+#undef INTERFACE
+
+#if !defined(__cplusplus) || defined(CINTERFACE)
+/*** IUnknown methods ***/
+#define IDirectInputJoyConfig8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
+#define IDirectInputJoyConfig8_AddRef(p) (p)->lpVtbl->AddRef(p)
+#define IDirectInputJoyConfig8_Release(p) (p)->lpVtbl->Release(p)
+/*** IDirectInputJoyConfig8 methods ***/
+#define IDirectInputJoyConfig8_Acquire(p) (p)->lpVtbl->Acquire(p)
+#define IDirectInputJoyConfig8_Unacquire(p) (p)->lpVtbl->Unacquire(p)
+#define IDirectInputJoyConfig8_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b)
+#define IDirectInputJoyConfig8_SendNotify(p) (p)->lpVtbl->SendNotify(p)
+#define IDirectInputJoyConfig8_EnumTypes(p,a,b) (p)->lpVtbl->EnumTypes(p,a,b)
+#define IDirectInputJoyConfig8_GetTypeInfo(p,a,b,c) (p)->lpVtbl->GetTypeInfo(p,a,b,c)
+#define IDirectInputJoyConfig8_SetTypeInfo(p,a,b,c,d) (p)->lpVtbl->SetTypeInfo(p,a,b,c,d)
+#define IDirectInputJoyConfig8_DeleteType(p,a) (p)->lpVtbl->DeleteType(p,a)
+#define IDirectInputJoyConfig8_GetConfig(p,a,b,c) (p)->lpVtbl->GetConfig(p,a,b,c)
+#define IDirectInputJoyConfig8_SetConfig(p,a,b,c) (p)->lpVtbl->SetConfig(p,a,b,c)
+#define IDirectInputJoyConfig8_DeleteConfig(p,a) (p)->lpVtbl->DeleteConfig(p,a)
+#define IDirectInputJoyConfig8_GetUserValues(p,a,b) (p)->lpVtbl->GetUserValues(p,a,b)
+#define IDirectInputJoyConfig8_SetUserValues(p,a,b) (p)->lpVtbl->SetUserValues(p,a,b)
+#define IDirectInputJoyConfig8_AddNewHardware(p,a,b) (p)->lpVtbl->AddNewHardware(p,a,b)
+#define IDirectInputJoyConfig8_OpenTypeKey(p,a,b,c) (p)->lpVtbl->OpenTypeKey(p,a,b,c)
+#define IDirectInputJoyConfig8_OpenAppStatusKey(p,a) (p)->lpVtbl->OpenAppStatusKey(p,a)
+#else
+/*** IUnknown methods ***/
+#define IDirectInputJoyConfig8_QueryInterface(p,a,b) (p)->QueryInterface(a,b)
+#define IDirectInputJoyConfig8_AddRef(p) (p)->AddRef()
+#define IDirectInputJoyConfig8_Release(p) (p)->Release()
+/*** IDirectInputJoyConfig8 methods ***/
+#define IDirectInputJoyConfig8_Acquire(p) (p)->Acquire()
+#define IDirectInputJoyConfig8_Unacquire(p) (p)->Unacquire()
+#define IDirectInputJoyConfig8_SetCooperativeLevel(p,a,b) (p)->SetCooperativeLevel(a,b)
+#define IDirectInputJoyConfig8_SendNotify(p) (p)->SendNotify()
+#define IDirectInputJoyConfig8_EnumTypes(p,a,b) (p)->EnumTypes(a,b)
+#define IDirectInputJoyConfig8_GetTypeInfo(p,a,b,c) (p)->GetTypeInfo(a,b,c)
+#define IDirectInputJoyConfig8_SetTypeInfo(p,a,b,c,d) (p)->SetTypeInfo(a,b,c,d)
+#define IDirectInputJoyConfig8_DeleteType(p,a) (p)->DeleteType(a)
+#define IDirectInputJoyConfig8_GetConfig(p,a,b,c) (p)->GetConfig(a,b,c)
+#define IDirectInputJoyConfig8_SetConfig(p,a,b,c) (p)->SetConfig(a,b,c)
+#define IDirectInputJoyConfig8_DeleteConfig(p,a) (p)->DeleteConfig(a)
+#define IDirectInputJoyConfig8_GetUserValues(p,a,b) (p)->GetUserValues(a,b)
+#define IDirectInputJoyConfig8_SetUserValues(p,a,b) (p)->SetUserValues(a,b)
+#define IDirectInputJoyConfig8_AddNewHardware(p,a,b) (p)->AddNewHardware(a,b)
+#define IDirectInputJoyConfig8_OpenTypeKey(p,a,b,c) (p)->OpenTypeKey(a,b,c)
+#define IDirectInputJoyConfig8_OpenAppStatusKey(p,a) (p)->OpenAppStatusKey(a)
+#endif
+
+#endif /* __DINPUTD_INCLUDED__ */
The following libraries are shared with Wine.
reactos/dll/directx/amstream # Synced to Wine-1.3.37
-reactos/dll/directx/dinput # Synced to Wine-20090208
+reactos/dll/directx/dinput # Synced to Wine-1.5.26
reactos/dll/directx/dinput8 # Synced to Wine-20090208
reactos/dll/directx/dmusic # Synced to Wine-1.5.26
reactos/dll/directx/dplay # Synced to Wine-1.5.26