ReactOS 0.4.16-dev-297-gc569aee
config.c File Reference
#include "wine/unicode.h"
#include "objbase.h"
#include "dinput_private.h"
#include "device_private.h"
#include "resource.h"
#include "wine/heap.h"
Include dependency graph for config.c:

Go to the source code of this file.

Classes

struct  DeviceData
 
struct  DIDevicesData
 
struct  ConfigureDevicesData
 

Macros

#define NONAMELESSUNION
 

Functions

static BOOL CALLBACK collect_objects (LPCDIDEVICEOBJECTINSTANCEW lpddo, LPVOID pvRef)
 
static BOOL CALLBACK collect_devices (LPCDIDEVICEINSTANCEW lpddi, IDirectInputDevice8W *lpdid, DWORD dwFlags, DWORD dwRemaining, LPVOID pvRef)
 
static void init_listview_columns (HWND dialog)
 
static int lv_get_cur_item (HWND dialog)
 
static int lv_get_item_data (HWND dialog, int index)
 
static void lv_set_action (HWND dialog, int item, int action, LPDIACTIONFORMATW lpdiaf)
 
static DeviceDataget_cur_device (HWND dialog)
 
static DIACTIONFORMATWget_cur_lpdiaf (HWND dialog)
 
static DIACTIONFORMATWget_original_lpdiaf (HWND dialog)
 
static int dialog_display_only (HWND dialog)
 
static void init_devices (HWND dialog, ConfigureDevicesData *data)
 
static void destroy_data (HWND dialog)
 
static void fill_device_object_list (HWND dialog)
 
static void show_suitable_actions (HWND dialog)
 
static void assign_action (HWND dialog)
 
static void reset_actions (HWND dialog)
 
static void save_actions (HWND dialog)
 
static INT_PTR CALLBACK ConfigureDevicesDlgProc (HWND dialog, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
HRESULT _configure_devices (IDirectInput8W *iface, LPDICONFIGUREDEVICESCALLBACK lpdiCallback, LPDICONFIGUREDEVICESPARAMSW lpdiCDParams, DWORD dwFlags, LPVOID pvRefData)
 

Macro Definition Documentation

◆ NONAMELESSUNION

#define NONAMELESSUNION

Definition at line 19 of file config.c.

Function Documentation

◆ _configure_devices()

HRESULT _configure_devices ( IDirectInput8W *  iface,
LPDICONFIGUREDEVICESCALLBACK  lpdiCallback,
LPDICONFIGUREDEVICESPARAMSW  lpdiCDParams,
DWORD  dwFlags,
LPVOID  pvRefData 
)

Definition at line 493 of file config.c.

499{
500 int i;
501 DWORD size;
504 data.lpDI = iface;
505 data.original_lpdiaf = lpdiCDParams->lprgFormats;
506 data.display_only = !(dwFlags & DICD_EDIT);
507 data.nusernames = lpdiCDParams->dwcUsers;
508 if (lpdiCDParams->lptszUserNames == NULL)
509 {
510 /* Get default user name */
512 username = heap_alloc(size * sizeof(WCHAR) );
514 data.nusernames = 1;
515 data.usernames = heap_alloc(sizeof(WCHAR *));
516 data.usernames[0] = username;
517 }
518 else
519 {
520 WCHAR *p = lpdiCDParams->lptszUserNames;
521 data.usernames = heap_alloc(sizeof(WCHAR *) * data.nusernames);
522 for (i = 0; i < data.nusernames; i++)
523 {
524 if (*p)
525 {
526 data.usernames[i] = p;
527 while (*(p++));
528 }
529 else
530 /* Return if there is an empty string */
531 return DIERR_INVALIDPARAM;
532 }
533 }
534
536
538 lpdiCDParams->hwnd, ConfigureDevicesDlgProc, (LPARAM)&data);
539
541 heap_free(data.usernames);
542
543 return DI_OK;
544}
static void * heap_alloc(size_t len)
Definition: appwiz.h:66
static BOOL heap_free(void *mem)
Definition: appwiz.h:76
VOID WINAPI InitCommonControls(void)
Definition: commctrl.c:870
#define DIERR_INVALIDPARAM
Definition: dinput.h:152
#define DICD_EDIT
Definition: dinput.h:1362
#define DI_OK
Definition: dinput.h:128
HINSTANCE DINPUT_instance
Definition: dinput_main.c:98
#define NULL
Definition: types.h:112
static INT_PTR CALLBACK ConfigureDevicesDlgProc(HWND dialog, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: config.c:401
#define IDD_CONFIGUREDEVICES
Definition: resource.h:23
BOOL WINAPI GetUserNameW(LPWSTR lpszName, LPDWORD lpSize)
Definition: misc.c:291
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLsizeiptr size
Definition: glext.h:5919
GLfloat GLfloat p
Definition: glext.h:8902
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static WCHAR username[]
Definition: url.c:32
LPDIACTIONFORMATW lprgFormats
Definition: dinput.h:1399
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
LONG_PTR LPARAM
Definition: windef.h:208
#define MAKEINTRESOURCE
Definition: winuser.h:591
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by IDirectInput8WImpl_ConfigureDevices().

◆ assign_action()

static void assign_action ( HWND  dialog)
static

Definition at line 327 of file config.c.

328{
331 LVFINDINFOW lvFind;
335 int old_action = lv_get_item_data(dialog, obj);
336 int used_obj;
337 DWORD type;
338
339 if (old_action == action) return;
340 if (obj < 0) return;
341 if (lpdiaf->rgoAction[old_action].dwFlags & DIA_APPFIXED) return;
342
343 type = device->ddo[obj].dwType;
344
345 /* Clear old action */
346 if (old_action != -1)
347 {
348 lpdiaf->rgoAction[old_action].dwObjID = 0;
349 lpdiaf->rgoAction[old_action].guidInstance = GUID_NULL;
350 lpdiaf->rgoAction[old_action].dwHow = DIAH_UNMAPPED;
351 }
352
353 /* Find if action text is already set for other object and unset it */
354 lvFind.flags = LVFI_PARAM;
355 lvFind.lParam = action;
356
358
359 lv_set_action(dialog, used_obj, -1, lpdiaf);
360
361 /* Set new action */
362 lpdiaf->rgoAction[action].dwObjID = type;
363 lpdiaf->rgoAction[action].guidInstance = device->ddi.guidInstance;
365
366 /* Set new action in the list */
367 lv_set_action(dialog, obj, action, lpdiaf);
368}
#define DIAH_UNMAPPED
Definition: dinput.h:1299
#define DIA_APPFIXED
Definition: dinput.h:1297
#define DIAH_USERCONFIG
Definition: dinput.h:1300
static DeviceData * get_cur_device(HWND dialog)
Definition: config.c:189
static int lv_get_item_data(HWND dialog, int index)
Definition: config.c:141
static DIACTIONFORMATW * get_cur_lpdiaf(HWND dialog)
Definition: config.c:196
static void lv_set_action(HWND dialog, int item, int action, LPDIACTIONFORMATW lpdiaf)
Definition: config.c:156
static int lv_get_cur_item(HWND dialog)
Definition: config.c:136
#define IDC_ACTIONLIST
Definition: resource.h:32
#define IDC_DEVICEOBJECTSLIST
Definition: resource.h:33
const WCHAR * action
Definition: action.c:7509
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define GUID_NULL
Definition: ks.h:106
static HWND dialog
Definition: gui.c:33
#define LVFI_PARAM
Definition: commctrl.h:2441
#define LVM_FINDITEMW
Definition: commctrl.h:2471
LPDIACTIONW rgoAction
Definition: dinput.h:1330
DWORD dwFlags
Definition: dinput.h:1278
GUID guidInstance
Definition: dinput.h:1283
DWORD dwHow
Definition: dinput.h:1285
DWORD dwObjID
Definition: dinput.h:1284
Definition: devices.h:37
LPARAM lParam
Definition: commctrl.h:2463
#define LB_GETITEMDATA
Definition: winuser.h:2044
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define LB_GETCURSEL
Definition: winuser.h:2042

Referenced by ConfigureDevicesDlgProc().

◆ collect_devices()

static BOOL CALLBACK collect_devices ( LPCDIDEVICEINSTANCEW  lpddi,
IDirectInputDevice8W *  lpdid,
DWORD  dwFlags,
DWORD  dwRemaining,
LPVOID  pvRef 
)
static

Definition at line 67 of file config.c.

68{
71 int i, j;
72
74
75 /* alloc array for devices if this is our first device */
76 if (!data->devices_data.ndevices)
77 data->devices_data.devices = HeapAlloc(GetProcessHeap(), 0, sizeof(DeviceData) * (dwRemaining + 1));
78 device = &data->devices_data.devices[data->devices_data.ndevices];
79 device->lpdid = lpdid;
80 device->ddi = *lpddi;
81
82 device->nobjects = 0;
84
85 device->user_afs = heap_alloc(sizeof(*device->user_afs) * data->nusernames);
86 memset(device->user_afs, 0, sizeof(*device->user_afs) * data->nusernames);
87 for (i = 0; i < data->nusernames; i++)
88 {
89 DIACTIONFORMATW *user_af = &device->user_afs[i];
90 user_af->dwNumActions = data->original_lpdiaf->dwNumActions;
91 user_af->guidActionMap = data->original_lpdiaf->guidActionMap;
92 user_af->rgoAction = heap_alloc(sizeof(DIACTIONW) * data->original_lpdiaf->dwNumActions);
93 memset(user_af->rgoAction, 0, sizeof(DIACTIONW) * data->original_lpdiaf->dwNumActions);
94 for (j = 0; j < user_af->dwNumActions; j++)
95 {
96 user_af->rgoAction[j].dwSemantic = data->original_lpdiaf->rgoAction[j].dwSemantic;
97 user_af->rgoAction[j].dwFlags = data->original_lpdiaf->rgoAction[j].dwFlags;
98 user_af->rgoAction[j].u.lptszActionName = data->original_lpdiaf->rgoAction[j].u.lptszActionName;
99 }
100 IDirectInputDevice8_BuildActionMap(lpdid, user_af, data->usernames[i], 0);
101 }
102
103 data->devices_data.ndevices++;
104 return DIENUM_CONTINUE;
105}
#define IDirectInputDevice_EnumObjects(p, a, b, c)
Definition: dinput.h:1605
#define IDirectInputDevice_AddRef(p)
Definition: dinput.h:1601
#define DIENUM_CONTINUE
Definition: dinput.h:188
#define DIDFT_ALL
Definition: dinput.h:750
#define IDirectInputDevice8_BuildActionMap(p, a, b, c)
Definition: dinput.h:2067
static BOOL CALLBACK collect_objects(LPCDIDEVICEOBJECTINSTANCEW lpddo, LPVOID pvRef)
Definition: config.c:57
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define memset(x, y, z)
Definition: compat.h:39
DWORD dwNumActions
Definition: dinput.h:1329
GUID guidActionMap
Definition: dinput.h:1331
LPCWSTR lptszActionName
Definition: dinput.h:1280
DWORD dwSemantic
Definition: dinput.h:1277

Referenced by init_devices().

◆ collect_objects()

static BOOL CALLBACK collect_objects ( LPCDIDEVICEOBJECTINSTANCEW  lpddo,
LPVOID  pvRef 
)
static

Definition at line 57 of file config.c.

58{
59 DeviceData *data = (DeviceData*) pvRef;
60
61 data->ddo[data->nobjects] = *lpddo;
62
63 data->nobjects++;
64 return DIENUM_CONTINUE;
65}
DIDEVICEOBJECTINSTANCEW ddo[256]
Definition: config.c:34

Referenced by collect_devices(), and release_script().

◆ ConfigureDevicesDlgProc()

static INT_PTR CALLBACK ConfigureDevicesDlgProc ( HWND  dialog,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 401 of file config.c.

402{
403 switch(uMsg)
404 {
405 case WM_INITDIALOG:
406 {
408
409 /* Initialize action format and enumerate devices */
411
412 /* Store information in the window */
414
416
417 /* Select the first device and show its actions */
421
423
424 break;
425 }
426
427 case WM_DESTROY:
429 break;
430
431 case WM_NOTIFY:
432
433 switch (((LPNMHDR)lParam)->code)
434 {
435 case LVN_ITEMCHANGED:
437 break;
438 }
439 break;
440
441
442 case WM_COMMAND:
443
444 switch(LOWORD(wParam))
445 {
446
447 case IDC_ACTIONLIST:
448
449 switch (HIWORD(wParam))
450 {
451 case LBN_DBLCLK:
452 /* Ignore this if app did not ask for editing */
453 if (dialog_display_only(dialog)) break;
454
456 break;
457 }
458 break;
459
461 case IDC_PLAYERCOMBO:
462
463 switch (HIWORD(wParam))
464 {
465 case CBN_SELCHANGE:
467 break;
468 }
469 break;
470
471 case IDOK:
473 EndDialog(dialog, 0);
475 break;
476
477 case IDCANCEL:
478 EndDialog(dialog, 0);
480 break;
481
482 case IDC_RESET:
485 break;
486 }
487 break;
488 }
489
490 return FALSE;
491}
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static void destroy_data(HWND dialog)
Definition: config.c:230
static void save_actions(HWND dialog)
Definition: config.c:384
static void fill_device_object_list(HWND dialog)
Definition: config.c:248
static void init_listview_columns(HWND dialog)
Definition: config.c:110
static void init_devices(HWND dialog, ConfigureDevicesData *data)
Definition: config.c:216
static void assign_action(HWND dialog)
Definition: config.c:327
static int dialog_display_only(HWND dialog)
Definition: config.c:210
static void show_suitable_actions(HWND dialog)
Definition: config.c:296
static void reset_actions(HWND dialog)
Definition: config.c:370
#define IDC_PLAYERCOMBO
Definition: resource.h:31
#define IDC_CONTROLLERCOMBO
Definition: resource.h:30
#define IDC_RESET
Definition: resource.h:26
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define LOWORD(l)
Definition: pedump.c:82
#define LVN_ITEMCHANGED
Definition: commctrl.h:3136
#define WM_NOTIFY
Definition: richedit.h:61
Definition: inflate.c:139
#define HIWORD(l)
Definition: typedefs.h:247
#define DWLP_USER
Definition: winuser.h:875
#define IDCANCEL
Definition: winuser.h:834
#define LBN_DBLCLK
Definition: winuser.h:2074
#define WM_COMMAND
Definition: winuser.h:1743
#define CB_SETCURSEL
Definition: winuser.h:1964
int WINAPI ShowCursor(_In_ BOOL)
Definition: cursoricon.c:2729
#define WM_INITDIALOG
Definition: winuser.h:1742
#define IDOK
Definition: winuser.h:833
#define CBN_SELCHANGE
Definition: winuser.h:1982
#define WM_DESTROY
Definition: winuser.h:1612
#define SetWindowLongPtrW
Definition: winuser.h:5358
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)

Referenced by _configure_devices().

◆ destroy_data()

static void destroy_data ( HWND  dialog)
static

Definition at line 230 of file config.c.

231{
232 int i, j;
234 DIDevicesData *devices_data = &data->devices_data;
235
236 /* Free the devices */
237 for (i=0; i < devices_data->ndevices; i++)
238 {
240 for (j=0; j < data->nusernames; j++)
241 heap_free(devices_data->devices[i].user_afs[j].rgoAction);
242 heap_free(devices_data->devices[i].user_afs);
243 }
244
245 HeapFree(GetProcessHeap(), 0, devices_data->devices);
246}
#define IDirectInputDevice8_Release(p)
Definition: dinput.h:2036
#define HeapFree(x, y, z)
Definition: compat.h:735
int ndevices
Definition: config.c:41
DeviceData * devices
Definition: config.c:42
IDirectInputDevice8W * lpdid
Definition: config.c:32
DIACTIONFORMATW * user_afs
Definition: config.c:37
#define GetWindowLongPtrW
Definition: winuser.h:4832

Referenced by ConfigureDevicesDlgProc().

◆ dialog_display_only()

static int dialog_display_only ( HWND  dialog)
static

Definition at line 210 of file config.c.

211{
213 return data->display_only;
214}

Referenced by ConfigureDevicesDlgProc().

◆ fill_device_object_list()

static void fill_device_object_list ( HWND  dialog)
static

Definition at line 248 of file config.c.

249{
253 int i, j;
254
255 /* Clean the listview */
257
258 /* Add each object */
259 for (i=0; i < device->nobjects; i++)
260 {
261 DWORD ddo_inst, ddo_type;
262 int action = -1;
263
264 item.mask = LVIF_TEXT | LVIF_PARAM;
265 item.iItem = i;
266 item.iSubItem = 0;
267 item.pszText = device->ddo[i].tszName;
268 item.cchTextMax = lstrlenW(item.pszText);
269
270 /* Add the item */
272 ddo_inst = DIDFT_GETINSTANCE(device->ddo[i].dwType);
273 ddo_type = DIDFT_GETTYPE(device->ddo[i].dwType);
274
275 /* Search for an assigned action for this device */
276 for (j=0; j < lpdiaf->dwNumActions; j++)
277 {
278 DWORD af_inst = DIDFT_GETINSTANCE(lpdiaf->rgoAction[j].dwObjID);
279 DWORD af_type = DIDFT_GETTYPE(lpdiaf->rgoAction[j].dwObjID);
280 if (af_type == DIDFT_PSHBUTTON) af_type = DIDFT_BUTTON;
281 if (af_type == DIDFT_RELAXIS) af_type = DIDFT_AXIS;
282 /* NOTE previously compared dwType == dwObjId but default buildActionMap actions
283 * were PSHBUTTON and RELAXS and didnt show up on config */
284 if (IsEqualGUID(&lpdiaf->rgoAction[j].guidInstance, &device->ddi.guidInstance) &&
285 ddo_inst == af_inst && ddo_type & af_type)
286 {
287 action = j;
288 break;
289 }
290 }
291
292 lv_set_action(dialog, i, action, lpdiaf);
293 }
294}
#define DIDFT_RELAXIS
Definition: dinput.h:751
#define DIDFT_GETTYPE(n)
Definition: dinput.h:763
#define DIDFT_PSHBUTTON
Definition: dinput.h:754
#define DIDFT_AXIS
Definition: dinput.h:753
#define DIDFT_GETINSTANCE(n)
Definition: dinput.h:764
#define DIDFT_BUTTON
Definition: dinput.h:756
#define lstrlenW
Definition: compat.h:750
static ATOM item
Definition: dde.c:856
#define LVM_DELETEALLITEMS
Definition: commctrl.h:2418
#define LVIF_PARAM
Definition: commctrl.h:2316
#define LVIF_TEXT
Definition: commctrl.h:2314
#define LVM_INSERTITEMW
Definition: commctrl.h:2409
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147

Referenced by ConfigureDevicesDlgProc().

◆ get_cur_device()

static DeviceData * get_cur_device ( HWND  dialog)
static

Definition at line 189 of file config.c.

190{
193 return &data->devices_data.devices[sel];
194}
#define CB_GETCURSEL
Definition: winuser.h:1946

Referenced by assign_action(), fill_device_object_list(), and show_suitable_actions().

◆ get_cur_lpdiaf()

static DIACTIONFORMATW * get_cur_lpdiaf ( HWND  dialog)
static

Definition at line 196 of file config.c.

197{
199 int controller_sel = SendDlgItemMessageW(dialog, IDC_CONTROLLERCOMBO, CB_GETCURSEL, 0, 0);
200 int player_sel = SendDlgItemMessageW(dialog, IDC_PLAYERCOMBO, CB_GETCURSEL, 0, 0);
201 return &data->devices_data.devices[controller_sel].user_afs[player_sel];
202}

Referenced by assign_action(), and fill_device_object_list().

◆ get_original_lpdiaf()

static DIACTIONFORMATW * get_original_lpdiaf ( HWND  dialog)
static

Definition at line 204 of file config.c.

205{
207 return data->original_lpdiaf;
208}

Referenced by show_suitable_actions().

◆ init_devices()

static void init_devices ( HWND  dialog,
ConfigureDevicesData data 
)
static

Definition at line 216 of file config.c.

217{
218 int i;
219
220 /* Collect and insert */
221 data->devices_data.ndevices = 0;
223
224 for (i = 0; i < data->devices_data.ndevices; i++)
225 SendDlgItemMessageW(dialog, IDC_CONTROLLERCOMBO, CB_ADDSTRING, 0, (LPARAM) data->devices_data.devices[i].ddi.tszProductName );
226 for (i = 0; i < data->nusernames; i++)
228}
#define IDirectInput8_EnumDevicesBySemantics(p, a, b, c, d, e)
Definition: dinput.h:2519
static BOOL CALLBACK collect_devices(LPCDIDEVICEINSTANCEW lpddi, IDirectInputDevice8W *lpdid, DWORD dwFlags, DWORD dwRemaining, LPVOID pvRef)
Definition: config.c:67
#define CB_ADDSTRING
Definition: winuser.h:1939

Referenced by ConfigureDevicesDlgProc().

◆ init_listview_columns()

static void init_listview_columns ( HWND  dialog)
static

Definition at line 110 of file config.c.

111{
112 LVCOLUMNW listColumn;
113 RECT viewRect;
114 int width;
116
118 width = (viewRect.right - viewRect.left)/2;
119
121 listColumn.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;
122 listColumn.pszText = column;
123 listColumn.cchTextMax = lstrlenW(listColumn.pszText);
124 listColumn.cx = width;
125
127
129 listColumn.cx = width;
130 listColumn.pszText = column;
131 listColumn.cchTextMax = lstrlenW(listColumn.pszText);
132
134}
#define ARRAY_SIZE(A)
Definition: main.h:20
#define IDS_OBJECTCOLUMN
Definition: resource.h:37
#define IDS_ACTIONCOLUMN
Definition: resource.h:36
#define MAX_PATH
Definition: compat.h:34
GLint GLint GLsizei width
Definition: gl.h:1546
#define LVCF_WIDTH
Definition: commctrl.h:2592
#define LVM_INSERTCOLUMNW
Definition: commctrl.h:2637
#define LVCF_SUBITEM
Definition: commctrl.h:2594
#define LVCF_TEXT
Definition: commctrl.h:2593
int cchTextMax
Definition: commctrl.h:2573
LPWSTR pszText
Definition: commctrl.h:2572
LONG right
Definition: windef.h:308
LONG left
Definition: windef.h:306
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)

Referenced by ConfigureDevicesDlgProc().

◆ lv_get_cur_item()

static int lv_get_cur_item ( HWND  dialog)
static

Definition at line 136 of file config.c.

137{
139}
#define LVNI_SELECTED
Definition: commctrl.h:2429
#define LVM_GETNEXTITEM
Definition: commctrl.h:2438

Referenced by assign_action(), and show_suitable_actions().

◆ lv_get_item_data()

static int lv_get_item_data ( HWND  dialog,
int  index 
)
static

Definition at line 141 of file config.c.

142{
144
145 if (index < 0) return -1;
146
147 item.mask = LVIF_PARAM;
148 item.iItem = index;
149 item.iSubItem = 0;
150
152
153 return item.lParam;
154}
#define index(s, c)
Definition: various.h:29
GLuint index
Definition: glext.h:6031
#define LVM_GETITEMW
Definition: commctrl.h:2395

Referenced by assign_action().

◆ lv_set_action()

static void lv_set_action ( HWND  dialog,
int  item,
int  action,
LPDIACTIONFORMATW  lpdiaf 
)
static

Definition at line 156 of file config.c.

157{
158 static const WCHAR no_action[] = {'-','\0'};
159 const WCHAR *action_text = no_action;
160 LVITEMW lvItem;
161
162 if (item < 0) return;
163
164 if (action != -1)
165 action_text = lpdiaf->rgoAction[action].u.lptszActionName;
166
167 /* Keep the action and text in the listview item */
168 lvItem.iItem = item;
169
170 lvItem.mask = LVIF_PARAM;
171 lvItem.iSubItem = 0;
172 lvItem.lParam = (LPARAM) action;
173
174 /* Action index */
176
177 lvItem.mask = LVIF_TEXT;
178 lvItem.iSubItem = 1;
179 lvItem.pszText = (WCHAR *)action_text;
180 lvItem.cchTextMax = lstrlenW(lvItem.pszText);
181
182 /* Text */
184}
#define LVM_SETITEMW
Definition: commctrl.h:2402
LPWSTR pszText
Definition: commctrl.h:2370
int iSubItem
Definition: commctrl.h:2367
int cchTextMax
Definition: commctrl.h:2371
UINT mask
Definition: commctrl.h:2365
LPARAM lParam
Definition: commctrl.h:2373

Referenced by assign_action(), and fill_device_object_list().

◆ reset_actions()

static void reset_actions ( HWND  dialog)
static

Definition at line 370 of file config.c.

371{
373 DIDevicesData *ddata = (DIDevicesData*) &data->devices_data;
374 unsigned i, j;
375
376 for (i = 0; i < data->devices_data.ndevices; i++)
377 {
378 DeviceData *device = &ddata->devices[i];
379 for (j = 0; j < data->nusernames; j++)
380 IDirectInputDevice8_BuildActionMap(device->lpdid, &device->user_afs[j], data->usernames[j], DIDBAM_HWDEFAULTS);
381 }
382}
#define DIDBAM_HWDEFAULTS
Definition: dinput.h:1355
#define for
Definition: utility.h:88

Referenced by ConfigureDevicesDlgProc().

◆ save_actions()

static void save_actions ( HWND  dialog)
static

Definition at line 384 of file config.c.

384 {
386 DIDevicesData *ddata = (DIDevicesData*) &data->devices_data;
387 unsigned i, j;
388 if (!data->display_only) {
389 for (i = 0; i < ddata->ndevices; i++)
390 {
391 DeviceData *device = &ddata->devices[i];
392 for (j = 0; j < data->nusernames; j++)
393 {
394 if (save_mapping_settings(device->lpdid, &device->user_afs[j], data->usernames[j]) != DI_OK)
395 MessageBoxA(dialog, "Could not save settings", 0, MB_ICONERROR);
396 }
397 }
398 }
399}
HRESULT save_mapping_settings(IDirectInputDevice8W *iface, LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUsername)
Definition: device.c:695
if(dx< 0)
Definition: linetemp.h:194
int WINAPI MessageBoxA(_In_opt_ HWND hWnd, _In_opt_ LPCSTR lpText, _In_opt_ LPCSTR lpCaption, _In_ UINT uType)
#define MB_ICONERROR
Definition: winuser.h:790

Referenced by ConfigureDevicesDlgProc().

◆ show_suitable_actions()

static void show_suitable_actions ( HWND  dialog)
static

Definition at line 296 of file config.c.

297{
300 int i, added = 0;
302
303 if (obj < 0) return;
304
306
307 for (i=0; i < lpdiaf->dwNumActions; i++)
308 {
309 /* Skip keyboard actions for non keyboards */
310 if (GET_DIDEVICE_TYPE(device->ddi.dwDevType) != DI8DEVTYPE_KEYBOARD &&
311 (lpdiaf->rgoAction[i].dwSemantic & DIKEYBOARD_MASK) == DIKEYBOARD_MASK) continue;
312
313 /* Skip mouse actions for non mouses */
314 if (GET_DIDEVICE_TYPE(device->ddi.dwDevType) != DI8DEVTYPE_MOUSE &&
315 (lpdiaf->rgoAction[i].dwSemantic & DIMOUSE_MASK) == DIMOUSE_MASK) continue;
316
317 /* Add action string and index in the action format to the list entry */
318 if (DIDFT_GETINSTANCE(lpdiaf->rgoAction[i].dwSemantic) & DIDFT_GETTYPE(device->ddo[obj].dwType))
319 {
322 added++;
323 }
324 }
325}
#define GET_DIDEVICE_TYPE(dwDevType)
Definition: dinput.h:320
#define DI8DEVTYPE_MOUSE
Definition: dinput.h:210
#define DI8DEVTYPE_KEYBOARD
Definition: dinput.h:211
#define DIMOUSE_MASK
#define DIKEYBOARD_MASK
static DIACTIONFORMATW * get_original_lpdiaf(HWND dialog)
Definition: config.c:204
#define LB_ADDSTRING
Definition: winuser.h:2034
#define LB_RESETCONTENT
Definition: winuser.h:2058
#define LB_SETITEMDATA
Definition: winuser.h:2068

Referenced by ConfigureDevicesDlgProc().