ReactOS 0.4.15-dev-7681-g776c3a3
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.

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;
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}
struct INPUT_DIALOG_CONTEXT * PINPUT_DIALOG_CONTEXT
#define IDS_DEVICE_STATUS_ATTACHED
Definition: resource.h:116
#define IDS_OPTION_YES
Definition: resource.h:126
#define IDS_DEVICE_STATUS_MISSING
Definition: resource.h:117
#define IDS_NOT_APPLICABLE
Definition: resource.h:125
#define IDS_DEVICE_STATUS_UNKNOWN
Definition: resource.h:118
#define DIPROP_GUIDANDPATH
Definition: dinput.h:908
#define DIENUM_STOP
Definition: dinput.h:187
#define DIENUM_CONTINUE
Definition: dinput.h:188
#define DIDC_FORCEFEEDBACK
Definition: dinput.h:949
#define DI_NOTATTACHED
Definition: dinput.h:129
#define DI_OK
Definition: dinput.h:128
#define DIPROP_VIDPID
Definition: dinput.h:918
#define DIPH_DEVICE
Definition: dinput.h:835
#define NULL
Definition: types.h:112
HINSTANCE hInst
Definition: dxdiag.c:13
unsigned long DWORD
Definition: ntddk_ex.h:95
ULONG Release()
#define L(x)
Definition: ntvdm.h:50
#define LOWORD(l)
Definition: pedump.c:82
#define LVM_SETITEM
Definition: commctrl.h:2399
#define LVM_INSERTITEM
Definition: commctrl.h:2406
#define LVIF_TEXT
Definition: commctrl.h:2309
DWORD dwSize
Definition: dinput.h:932
DWORD dwFlags
Definition: dinput.h:933
WCHAR tszProductName[MAX_PATH]
Definition: dinput.h:430
GUID guidInstance
Definition: dinput.h:426
DIPROPHEADER diph
Definition: dinput.h:843
DWORD dwData
Definition: dinput.h:844
DWORD dwSize
Definition: dinput.h:828
DWORD dwHeaderSize
Definition: dinput.h:829
IDirectInput8W * pObj
Definition: input.c:17
#define HIWORD(l)
Definition: typedefs.h:247
_In_ WDFCOLLECTION _In_ WDFOBJECT Item
#define ZeroMemory
Definition: winbase.h:1712
LONG_PTR LPARAM
Definition: windef.h:208
LONG_PTR LRESULT
Definition: windef.h:209
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by InitializeDirectInputDialog().

◆ InitializeDirectInputDialog()

static void InitializeDirectInputDialog ( HWND  hwndDlg)
static

Definition at line 185 of file input.c.

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}
BOOL CALLBACK DirectInputEnumDevCb(LPCDIDEVICEINSTANCEW lpddi, LPVOID pvRef)
Definition: input.c:24
VOID InputPageInitListViewColumns(PINPUT_DIALOG_CONTEXT pContext)
Definition: input.c:154
#define DIRECTINPUT_VERSION
Definition: precomp.h:4
#define DI8DEVCLASS_ALL
Definition: dinput.h:203
#define DIEDFL_ALLDEVICES
Definition: dinput.h:190
HRESULT WINAPI DECLSPEC_HOTPATCH DirectInput8Create(HINSTANCE hinst, DWORD version, REFIID iid, void **out, IUnknown *outer)
Definition: dinput_main.c:172

Referenced by InputPageWndProc().

◆ InputPageInitListViewColumns()

VOID InputPageInitListViewColumns ( PINPUT_DIALOG_CONTEXT  pContext)

Definition at line 154 of file input.c.

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;
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 IDC_LIST_DEVICE
Definition: resource.h:90
#define IDS_DEVICE_NAME
Definition: resource.h:119
#define LVCF_WIDTH
Definition: commctrl.h:2587
#define LVS_EX_FULLROWSELECT
Definition: commctrl.h:2734
#define LVM_INSERTCOLUMNW
Definition: commctrl.h:2632
#define LVCF_FMT
Definition: commctrl.h:2586
#define LVCF_SUBITEM
Definition: commctrl.h:2589
#define LVCFMT_LEFT
Definition: commctrl.h:2598
#define LVCF_TEXT
Definition: commctrl.h:2588
#define LVM_SETEXTENDEDLISTVIEWSTYLE
Definition: commctrl.h:2724
LPWSTR pszText
Definition: commctrl.h:2567
int32_t INT
Definition: typedefs.h:58
_In_ WDFCOLLECTION _In_ ULONG Index
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define SendMessage
Definition: winuser.h:5842

Referenced by InitializeDirectInputDialog().

◆ InputPageWndProc()

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

Definition at line 207 of file input.c.

208{
211 switch (message) {
212 case WM_INITDIALOG:
213 {
216 return TRUE;
217 }
218 }
219
220 return FALSE;
221}
static void InitializeDirectInputDialog(HWND hwndDlg)
Definition: input.c:185
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
Definition: tftpd.h:60
#define SWP_NOACTIVATE
Definition: winuser.h:1241
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define SWP_NOSIZE
Definition: winuser.h:1244
#define WM_INITDIALOG
Definition: winuser.h:1738
#define SWP_NOOWNERZORDER
Definition: winuser.h:1248
#define SWP_NOZORDER
Definition: winuser.h:1246

Referenced by InitializeTabCtrl().