ReactOS  0.4.11-dev-946-g431643b
input.c File Reference
#include "precomp.h"
#include <dinput.h>
Include dependency graph for input.c:

Go to the source code of this file.

Classes

struct  INPUT_DIALOG_CONTEXT
 

Typedefs

typedef struct INPUT_DIALOG_CONTEXTPINPUT_DIALOG_CONTEXT
 

Functions

BOOL CALLBACK DirectInputEnumDevCb (LPCDIDEVICEINSTANCEW lpddi, LPVOID pvRef)
 
VOID InputPageInitListViewColumns (PINPUT_DIALOG_CONTEXT pContext)
 
static void InitializeDirectInputDialog (HWND hwndDlg)
 
INT_PTR CALLBACK InputPageWndProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
 

Typedef Documentation

◆ PINPUT_DIALOG_CONTEXT

Function Documentation

◆ DirectInputEnumDevCb()

BOOL CALLBACK DirectInputEnumDevCb ( LPCDIDEVICEINSTANCEW  lpddi,
LPVOID  pvRef 
)

Definition at line 24 of file input.c.

Referenced by InitializeDirectInputDialog().

28 {
29  HRESULT hResult;
30  WCHAR szText[100];
31  IDirectInputDevice8W * pDev = NULL;
32  //DIPROPGUIDANDPATH GuidPath;
33  //DIPROPSTRING TypeName;
34  DIPROPDWORD VendorID;
35  DIDEVCAPS DevCaps;
36  DWORD dwProductID;
37  DWORD dwManufacturerID;
38  LVITEMW Item;
39  LRESULT lResult;
40 
42 
43  if (!pContext)
44  return DIENUM_STOP;
45 
46  ZeroMemory(&Item, sizeof(LVITEMW));
47  Item.mask = LVIF_TEXT;
48  Item.pszText = (LPWSTR)lpddi->tszProductName;
49  Item.iItem = pContext->Count;
50  /* insert device item */
51  lResult = SendMessageW(pContext->hDevList, LVM_INSERTITEM, 0, (LPARAM)&Item);
52  if (lResult == -1)
53  return DIENUM_CONTINUE;
54 
55  /* is the device attached */
56  szText[0] = L'\0';
57  hResult = pContext->pObj->lpVtbl->GetDeviceStatus(pContext->pObj, &lpddi->guidInstance);
58  if (hResult == DI_OK)
59  LoadStringW(hInst, IDS_DEVICE_STATUS_ATTACHED, szText, sizeof(szText) / sizeof(WCHAR));
60  else if (hResult == DI_NOTATTACHED)
61  LoadStringW(hInst, IDS_DEVICE_STATUS_MISSING, szText, sizeof(szText) / sizeof(WCHAR));
62  else
63  LoadStringW(hInst, IDS_DEVICE_STATUS_UNKNOWN, szText, sizeof(szText) / sizeof(WCHAR));
64 
65  if (szText[0])
66  {
67  szText[(sizeof(szText) / sizeof(WCHAR))-1] = L'\0';
68  Item.iSubItem = 1;
69  Item.pszText = szText;
70  SendMessageW(pContext->hDevList, LVM_SETITEM, lResult, (LPARAM)&Item);
71  }
72 
73  hResult = pContext->pObj->lpVtbl->CreateDevice(pContext->pObj, &lpddi->guidInstance, &pDev, NULL);
74 
75  if (hResult != DI_OK)
76  return DIENUM_STOP;
77 
78  ZeroMemory(&VendorID, sizeof(DIPROPDWORD));
79  VendorID.diph.dwSize = sizeof(DIPROPDWORD);
80  VendorID.diph.dwHeaderSize = sizeof(DIPROPHEADER);
81 
82  hResult = pDev->lpVtbl->GetProperty(pDev, DIPROP_VIDPID, (LPDIPROPHEADER)&VendorID);
83  if (hResult == DI_OK)
84  {
85  /* set manufacturer id */
86  dwManufacturerID = LOWORD(VendorID.dwData);
87  wsprintfW(szText, L"0x%04X", dwManufacturerID);
88  Item.iSubItem = 3;
89  SendMessageW(pContext->hDevList, LVM_SETITEM, lResult, (LPARAM)&Item);
90  /* set product id */
91  dwProductID = HIWORD(VendorID.dwData);
92  wsprintfW(szText, L"0x%04X", dwProductID);
93  Item.iSubItem = 4;
94  SendMessageW(pContext->hDevList, LVM_SETITEM, lResult, (LPARAM)&Item);
95  }
96  else
97  {
98  szText[0] = L'\0';
99  LoadStringW(hInst, IDS_NOT_APPLICABLE, szText, sizeof(szText) / sizeof(WCHAR));
100  szText[(sizeof(szText)/sizeof(WCHAR))-1] = L'\0';
101  /* set manufacturer id */
102  Item.iSubItem = 3;
103  SendMessageW(pContext->hDevList, LVM_SETITEM, lResult, (LPARAM)&Item);
104  /* set product id */
105  Item.iSubItem = 4;
106  SendMessageW(pContext->hDevList, LVM_SETITEM, lResult, (LPARAM)&Item);
107  }
108 
109  /* check for force feedback support */
110  DevCaps.dwSize = sizeof(DIDEVCAPS); // use DIDEVCAPS_DX3 for DX3 support
111  hResult = pDev->lpVtbl->GetCapabilities(pDev, &DevCaps);
112  szText[0] = L'\0';
113  if (hResult == DI_OK)
114  {
115  if (DevCaps.dwFlags & DIDC_FORCEFEEDBACK)
116  LoadStringW(hInst, IDS_OPTION_YES, szText, sizeof(szText)/sizeof(WCHAR));
117  else
118  LoadStringW(hInst, IDS_NOT_APPLICABLE, szText, sizeof(szText)/sizeof(WCHAR));
119  }
120  else
121  {
122  LoadStringW(hInst, IDS_NOT_APPLICABLE, szText, sizeof(szText)/sizeof(WCHAR));
123  }
124 
125  Item.iSubItem = 5;
126  SendMessageW(pContext->hDevList, LVM_SETITEM, lResult, (LPARAM)&Item);
127 
128 
129 #if 0
130  ZeroMemory(&GuidPath, sizeof(DIPROPGUIDANDPATH));
131  GuidPath.diph.dwSize = sizeof(DIPROPGUIDANDPATH);
132  GuidPath.diph.dwHeaderSize = sizeof(DIPROPHEADER);
133  GuidPath.diph.dwHow = DIPH_DEVICE;
134  hResult = pDev->lpVtbl->GetProperty(pDev, DIPROP_GUIDANDPATH, (LPDIPROPHEADER)&GuidPath);
135 
136  ZeroMemory(&TypeName, sizeof(TypeName));
137  TypeName.diph.dwSize = sizeof(TypeName);
138  TypeName.diph.dwHeaderSize = sizeof(DIPROPHEADER);
139  TypeName.diph.dwHow = DIPH_DEVICE;
140  hResult = pDev->lpVtbl->GetProperty(pDev, DIPROP_GETPORTDISPLAYNAME, (LPDIPROPHEADER)&TypeName);
141 
142 
143 #endif
144 
145 
146  pDev->lpVtbl->Release(pDev);
147  pContext->Count++;
148 
149 
150  return DIENUM_CONTINUE;
151 }
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)
DWORD dwSize
Definition: dinput.h:828
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define IDS_DEVICE_STATUS_MISSING
Definition: resource.h:117
struct DIPROPGUIDANDPATH DIPROPGUIDANDPATH
#define DI_NOTATTACHED
Definition: dinput.h:129
#define ZeroMemory
Definition: winbase.h:1635
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define DIPH_DEVICE
Definition: dinput.h:835
#define IDS_NOT_APPLICABLE
Definition: resource.h:125
#define LVIF_TEXT
Definition: commctrl.h:2279
DIPROPHEADER diph
Definition: dinput.h:843
static const WCHAR szText[]
Definition: dialog.c:139
LONG_PTR LPARAM
Definition: windef.h:208
#define LVM_INSERTITEM
Definition: commctrl.h:2376
int iSubItem
Definition: commctrl.h:2332
#define IDS_DEVICE_STATUS_ATTACHED
Definition: resource.h:116
DWORD dwFlags
Definition: dinput.h:935
#define DIENUM_STOP
Definition: dinput.h:187
smooth NULL
Definition: ftsmooth.c:416
struct DIDEVCAPS DIDEVCAPS
DWORD dwSize
Definition: dinput.h:934
LONG HRESULT
Definition: typedefs.h:77
LPWSTR pszText
Definition: commctrl.h:2335
#define IDS_OPTION_YES
Definition: resource.h:126
unsigned long DWORD
Definition: ntddk_ex.h:95
UINT mask
Definition: commctrl.h:2330
WCHAR tszProductName[MAX_PATH]
Definition: dinput.h:430
static const WCHAR L[]
Definition: oid.c:1087
#define IDS_DEVICE_STATUS_UNKNOWN
Definition: resource.h:118
#define DIPROP_GUIDANDPATH
Definition: dinput.h:908
struct INPUT_DIALOG_CONTEXT * PINPUT_DIALOG_CONTEXT
IDirectInput8W * pObj
Definition: input.c:17
struct DIPROPHEADER DIPROPHEADER
HINSTANCE hInst
Definition: dxdiag.c:13
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define LVM_SETITEM
Definition: commctrl.h:2369
GUID guidInstance
Definition: dinput.h:426
#define DI_OK
Definition: dinput.h:128
#define DIENUM_CONTINUE
Definition: dinput.h:188
DWORD dwHeaderSize
Definition: dinput.h:829
#define HIWORD(l)
Definition: typedefs.h:246
WCHAR * LPWSTR
Definition: xmlstorage.h:184
LONG_PTR LRESULT
Definition: windef.h:209
struct DIPROPDWORD DIPROPDWORD
#define DIPROP_VIDPID
Definition: dinput.h:920
#define DIDC_FORCEFEEDBACK
Definition: dinput.h:951
#define LOWORD(l)
Definition: pedump.c:82

◆ InitializeDirectInputDialog()

static void InitializeDirectInputDialog ( HWND  hwndDlg)
static

Definition at line 185 of file input.c.

Referenced by InputPageWndProc().

186 {
188  HRESULT hResult;
189  IDirectInput8W * pObj;
190 
191  hResult = DirectInput8Create(hInst, DIRECTINPUT_VERSION, &IID_IDirectInput8W, (LPVOID*)&pObj, NULL);
192  if (hResult != DI_OK)
193  return;
194 
195  ZeroMemory(&Context, sizeof(Context));
196  Context.pObj = pObj;
197  Context.hwndDlg = hwndDlg;
199  pObj->lpVtbl->EnumDevices(pObj, DI8DEVCLASS_ALL, DirectInputEnumDevCb, (PVOID)&Context, DIEDFL_ALLDEVICES);
200 
201  pObj->lpVtbl->Release(pObj);
202 }
VOID InputPageInitListViewColumns(PINPUT_DIALOG_CONTEXT pContext)
Definition: input.c:154
#define ZeroMemory
Definition: winbase.h:1635
HRESULT WINAPI DECLSPEC_HOTPATCH DirectInput8Create(HINSTANCE hinst, DWORD version, REFIID iid, void **out, IUnknown *outer)
Definition: dinput_main.c:170
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:77
#define DI8DEVCLASS_ALL
Definition: dinput.h:203
#define DIRECTINPUT_VERSION
Definition: precomp.h:4
BOOL CALLBACK DirectInputEnumDevCb(LPCDIDEVICEINSTANCEW lpddi, LPVOID pvRef)
Definition: input.c:24
#define DIEDFL_ALLDEVICES
Definition: dinput.h:190
IDirectInput8W * pObj
Definition: input.c:17
HINSTANCE hInst
Definition: dxdiag.c:13
#define DI_OK
Definition: dinput.h:128
struct tagContext Context
Definition: acpixf.h:1027

◆ InputPageInitListViewColumns()

VOID InputPageInitListViewColumns ( PINPUT_DIALOG_CONTEXT  pContext)

Definition at line 154 of file input.c.

Referenced by InitializeDirectInputDialog().

155 {
156  WCHAR szText[256];
157  LVCOLUMNW lvcolumn;
158  INT Index;
159 
160 
161  pContext->hDevList = GetDlgItem(pContext->hwndDlg, IDC_LIST_DEVICE);
162 
163  /* Highlights the entire row instead of just the selected item in the first column.
164  This increases readability on the selected item in the list. */
166 
167  ZeroMemory(&lvcolumn, sizeof(LVCOLUMNW));
168  lvcolumn.pszText = szText;
169  lvcolumn.mask = LVCF_FMT | LVCF_TEXT | LVCF_SUBITEM | LVCF_WIDTH;
170  lvcolumn.fmt = LVCFMT_LEFT;
171  lvcolumn.cx = 100;
172 
173  for(Index = 0; Index < 6; Index++)
174  {
175  szText[0] = L'\0';
176  LoadStringW(hInst, IDS_DEVICE_NAME + Index, szText, sizeof(szText) / sizeof(WCHAR));
177  szText[(sizeof(szText) / sizeof(WCHAR))-1] = L'\0';
178  if (SendMessageW(pContext->hDevList, LVM_INSERTCOLUMNW, Index, (LPARAM)&lvcolumn) == -1)
179  return;
180  }
181 }
#define LVCF_WIDTH
Definition: commctrl.h:2557
#define IDC_LIST_DEVICE
Definition: resource.h:90
#define LVCF_TEXT
Definition: commctrl.h:2558
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define LVS_EX_FULLROWSELECT
Definition: commctrl.h:2704
#define LVCFMT_LEFT
Definition: commctrl.h:2568
#define ZeroMemory
Definition: winbase.h:1635
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
int32_t INT
Definition: typedefs.h:56
#define IDS_DEVICE_NAME
Definition: resource.h:119
#define LVCF_SUBITEM
Definition: commctrl.h:2559
static const WCHAR szText[]
Definition: dialog.c:139
#define LVM_INSERTCOLUMNW
Definition: commctrl.h:2602
LONG_PTR LPARAM
Definition: windef.h:208
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
static const UCHAR Index[8]
Definition: usbohci.c:18
LPWSTR pszText
Definition: commctrl.h:2537
#define LVM_SETEXTENDEDLISTVIEWSTYLE
Definition: commctrl.h:2694
static const WCHAR L[]
Definition: oid.c:1087
#define LVCF_FMT
Definition: commctrl.h:2556
HINSTANCE hInst
Definition: dxdiag.c:13
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define SendMessage
Definition: winuser.h:5709

◆ InputPageWndProc()

INT_PTR CALLBACK InputPageWndProc ( HWND  hDlg,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 207 of file input.c.

Referenced by InitializeTabCtrl().

208 {
211  switch (message) {
212  case WM_INITDIALOG:
213  {
216  return TRUE;
217  }
218  }
219 
220  return FALSE;
221 }
Definition: tftpd.h:59
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define SWP_NOZORDER
Definition: winuser.h:1232
static void InitializeDirectInputDialog(HWND hwndDlg)
Definition: input.c:185
WPARAM wParam
Definition: combotst.c:138
smooth NULL
Definition: ftsmooth.c:416
#define SWP_NOACTIVATE
Definition: winuser.h:1227
#define SWP_NOSIZE
Definition: winuser.h:1230
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define WM_INITDIALOG
Definition: winuser.h:1715
LPARAM lParam
Definition: combotst.c:139
#define SWP_NOOWNERZORDER
Definition: winuser.h:1234