Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

408 lines
14 KiB

  1. //===========================================================================
  2. // dimaptst.h
  3. //
  4. // History:
  5. // 08/19/1999 - davidkl - created
  6. //===========================================================================
  7. #ifndef _DIMAPTST_H
  8. #define _DIMAPTST_H
  9. //---------------------------------------------------------------------------
  10. #include <windows.h>
  11. #include <commctrl.h>
  12. #include <dinput.h>
  13. #include "dmterror.h"
  14. #include "debug.h"
  15. #include "resource.h"
  16. //---------------------------------------------------------------------------
  17. // app global variables
  18. extern HINSTANCE ghinst;
  19. extern HANDLE ghEvent;
  20. extern CRITICAL_SECTION gcritsect;
  21. //JJ FIX
  22. extern UINT_PTR g_NumSubGenres;
  23. //---------------------------------------------------------------------------
  24. // custom window messages
  25. #define WM_DMT_UPDATE_LISTS WM_USER+1
  26. #define WM_DMT_FILE_SAVE WM_USER+3
  27. //---------------------------------------------------------------------------
  28. #define GENRES_INI ".\\genre.ini"
  29. //---------------------------------------------------------------------------
  30. #define DMT_DI_STRING_VER "0x800"
  31. //---------------------------------------------------------------------------
  32. #define ID_POLL_TIMER 97
  33. #define DMT_POLL_TIMEOUT 100
  34. //---------------------------------------------------------------------------
  35. #define NUM_DISPBTNS 32
  36. //---------------------------------------------------------------------------
  37. #ifndef COUNT_ARRAY_ELEMENTS
  38. #define COUNT_ARRAY_ELEMENTS(a) (sizeof(a) / sizeof(a[0]))
  39. #endif
  40. //---------------------------------------------------------------------------
  41. #define MAX_ACTION_ID_STRING MAX_PATH
  42. //---------------------------------------------------------------------------
  43. #define DMT_GENRE_MASK 0xFF000000
  44. #define DMT_ACTION_MASK 0x000000FF
  45. //---------------------------------------------------------------------------
  46. // control type IDs
  47. #define DMTA_TYPE_AXIS 0
  48. #define DMTA_TYPE_BUTTON 1
  49. #define DMTA_TYPE_POV 2
  50. #define DMTA_TYPE_UNKNOWN 0xFFFFFFFF
  51. //---------------------------------------------------------------------------
  52. typedef struct _actionname
  53. {
  54. DWORD dw;
  55. char sz[MAX_PATH];
  56. } ACTIONNAME, *PACTIONNAME;
  57. //---------------------------------------------------------------------------
  58. //===========================================================================
  59. // GUID_DIMapTst
  60. //
  61. // GUID uniquely identifying our application
  62. //
  63. // DDK App:
  64. // {87480CC9-C186-4270-914B-CF9EC33839CA}
  65. // SDK App:
  66. // {87480CCA-C186-4270-914B-CF9EC33839CA}
  67. // Internal App:
  68. // {87480CCB-C186-4270-914B-CF9EC33839CA}
  69. //===========================================================================
  70. #ifdef DDKAPP
  71. DEFINE_GUID(GUID_DIMapTst,
  72. 0x87480cc9, 0xc186, 0x4270, 0x91, 0x4b, 0xcf, 0x9e, 0xc3, 0x38, 0x39, 0xca);
  73. #else
  74. DEFINE_GUID(GUID_DIMapTst,
  75. 0x87480ccb, 0xc186, 0x4270, 0x91, 0x4b, 0xcf, 0x9e, 0xc3, 0x38, 0x39, 0xca);
  76. #endif
  77. //===========================================================================
  78. // GUID_DIConfigAppEditLayout
  79. //
  80. // Make IDirectInput8::ConfigureDevices() launch in "edit mode"
  81. //
  82. // {FD4ACE13-7044-4204-8B15-095286B12EAD}
  83. //===========================================================================
  84. DEFINE_GUID(GUID_DIConfigAppEditLayout,
  85. 0xfd4ace13, 0x7044, 0x4204, 0x8b, 0x15, 0x09, 0x52, 0x86, 0xb1, 0x2e, 0xad);
  86. //---------------------------------------------------------------------------
  87. #ifdef DDKAPP
  88. #define DMT_APP_CAPTION "DirectInput Mapper Device Configuration Tool"
  89. #else
  90. #define DMT_APP_CAPTION "DirectInput Mapper Test Tool - MICROSOFT INTERNAL BUILD"
  91. #endif
  92. //---------------------------------------------------------------------------
  93. //===========================================================================
  94. // DMTDEVICEOBJECT_NODE
  95. // PDMTDEVICEOBJECT_NODE
  96. //
  97. // Linked list node for DirectInput device objects (buttons, axes, povs)
  98. //
  99. // Struct contents:
  100. // DMTDEVICEOBJECT_NODE *pNext - next device object in the
  101. // list
  102. // char szName - display name of the device
  103. // object (ANSI string)
  104. // DWORD dwObjectType - type (axis, button, pov)
  105. // DWORD dwObjectOffset - offset into the device data
  106. // format
  107. // WORD wUsagePage - HID usage page
  108. // WORD wUsage - HID usage
  109. // GUID guidDeviceInstance - parent device's instance
  110. // GUID
  111. // WORD wCtrlId - "identifier" for integrated
  112. // test UI control
  113. //
  114. //===========================================================================
  115. typedef struct _dmtdeviceobject_node
  116. {
  117. struct _dmtdeviceobject_node *pNext;
  118. char szName[MAX_PATH];
  119. DWORD dwObjectType;
  120. DWORD dwObjectOffset;
  121. WORD wUsagePage;
  122. WORD wUsage;
  123. GUID guidDeviceInstance;
  124. WORD wCtrlId;
  125. } DMTDEVICEOBJECT_NODE, *PDMTDEVICEOBJECT_NODE;
  126. //===========================================================================
  127. // DMTDEVICE_NODE
  128. // PDMTDEVICE_NODE
  129. //
  130. // Linked list node for DirectInput devices
  131. //
  132. // Struct contents:
  133. // DMTDEVICE_NODE *pNext - next device in the list
  134. // char szName - display name of the device
  135. // (ANSI string)
  136. // char szShorthandName -
  137. // WORD wVendorId - vendor id
  138. // WORD wProductId - product id
  139. // DMTDEVICEOBJECT_NODE *pObjectList - list of device controls
  140. // char szFileTitle -
  141. //
  142. //===========================================================================
  143. typedef struct _dmtdevice_node
  144. {
  145. struct _dmtdevice_node *pNext;
  146. IDirectInputDevice8A *pdid;
  147. char szName[MAX_PATH];
  148. char szShorthandName[MAX_PATH];
  149. WORD wVendorId;
  150. WORD wProductId;
  151. GUID guidInstance;
  152. DWORD dwDeviceType;
  153. BOOL fPolled;
  154. char szProductName[MAX_PATH];
  155. DWORD dwAxes;
  156. DWORD dwButtons;
  157. DWORD dwPovs;
  158. DMTDEVICEOBJECT_NODE *pObjectList;
  159. char szFilename[MAX_PATH];
  160. } DMTDEVICE_NODE, *PDMTDEVICE_NODE;
  161. //===========================================================================
  162. // DMTMAPPING_NODE
  163. // PDMTMAPPING_NODE
  164. //
  165. // Linked list node for action maps
  166. //
  167. // Struct contents:
  168. // DMTMAPPING_NODE *pNext - next mapping in the list
  169. // GUID guidInstance - device's instance guid
  170. // BOOL fChanged - has this data changed?
  171. // (this gets set to FALSE on load & save)
  172. // DIACTIONA *pdia - array of DIACTIONA structures
  173. // UINT uActions - number of actions referenced by pdia
  174. //
  175. //===========================================================================
  176. typedef struct _dmtmapping_node
  177. {
  178. struct _dmtmapping_node *pNext;
  179. GUID guidInstance;
  180. BOOL fChanged;
  181. DIACTIONA *pdia;
  182. UINT uActions;
  183. } DMTMAPPING_NODE, *PDMTMAPPING_NODE;
  184. //===========================================================================
  185. // DMTACTION_NODE
  186. // PDMTACTION_NODE
  187. //
  188. // Linked list node for DirectInput Mapper actions
  189. //
  190. // Struct contents:
  191. // DMTACTION_NODE *pNext - next action in the list
  192. // char szName - name of the action (ANSI string)
  193. // DWORD dwType - action type (button, axis, pov)
  194. // DWORD dwPriority - priority level of control mapping
  195. // DWORD dwActionId - ID as defined by DirectInput
  196. // char szActionId - text representation of action ID (ANSI
  197. // string)
  198. //
  199. //===========================================================================
  200. typedef struct _dmtaction_node
  201. {
  202. struct _dmtaction_node *pNext;
  203. char szName[MAX_PATH];
  204. DWORD dwType;
  205. DWORD dwPriority;
  206. DWORD dwActionId;
  207. char szActionId[MAX_ACTION_ID_STRING];
  208. } DMTACTION_NODE, *PDMTACTION_NODE;
  209. //===========================================================================
  210. // DMTSUBGENRE_NODE
  211. // PDMTSUBGENRE_NODE
  212. //
  213. // Linked list node for DirectInput Mapper subgenres
  214. //
  215. // Struct contents:
  216. // DMTSUBGENRE_NODE *pNext - next subgenre in the list
  217. // char szName - name of the subgenre (ANSI string)
  218. // char szDescription - brief description text (ANSI string)
  219. // DWORD dwGenreId - genre identifier
  220. // DMTACTION_NODE *pActionList - linked list of available actions
  221. // DMTMAPPING_NODE *pMappingList - linked list of mapping information
  222. //
  223. //===========================================================================
  224. typedef struct _dmtsubgenre_node
  225. {
  226. struct _dmtsubgenre_node *pNext;
  227. char szName[MAX_PATH];
  228. char szDescription[MAX_PATH];
  229. DWORD dwGenreId;
  230. DMTACTION_NODE *pActionList;
  231. DMTMAPPING_NODE *pMappingList;
  232. } DMTSUBGENRE_NODE, *PDMTSUBGENRE_NODE;
  233. //===========================================================================
  234. // DMTGENRE_NODE
  235. // PDMTGENRE_NODE
  236. //
  237. // Linked list node for DirectInput Mapper genres
  238. //
  239. // Struct contents:
  240. // DMTGENRE_NODE *pNext - next genre in the list
  241. // char szName - name of the genre (ANSI string)
  242. // DMTSUBGENRE_NODE *pSubGenreList - linked list of subgenres
  243. //
  244. //===========================================================================
  245. typedef struct _dmtgenre_node
  246. {
  247. struct _dmtgenre_node *pNext;
  248. char szName[MAX_PATH];
  249. DMTSUBGENRE_NODE *pSubGenreList;
  250. } DMTGENRE_NODE, *PDMTGENRE_NODE;
  251. //===========================================================================
  252. // DMT_APPINFO
  253. // PDMT_APPINFO
  254. //
  255. // Structure for data needed by main application dialog
  256. //
  257. // Struct contents:
  258. // DMTGENRE_NODE *pGenreList - linked list of device genres
  259. // DMTSUBGENRE_NODE *pSubGenre
  260. // DMTDEVICE_NODE *pDeviceList - linked list of gaming devices
  261. // BOOL fStartWithDefaults - initially provide DirectInput's
  262. // "default" object mappings
  263. // BOOL fLaunchCplEditMode - launch the mapper cpl in edit
  264. // mode so object offsets, etc can
  265. // be added to the device map file
  266. //
  267. //===========================================================================
  268. typedef struct _dmt_appinfo
  269. {
  270. DMTGENRE_NODE *pGenreList;
  271. DMTSUBGENRE_NODE *pSubGenre;
  272. DMTDEVICE_NODE *pDeviceList;
  273. BOOL fStartWithDefaults;
  274. BOOL fLaunchCplEditMode;
  275. ACTIONNAME *pan;
  276. DWORD dwActions;
  277. } DMT_APPINFO, *PDMTAPPINFO;
  278. //---------------------------------------------------------------------------
  279. #ifndef COUNT_ARRAY_ELEMENTS
  280. #define COUNT_ARRAY_ELEMENTS (sizeof(a)/sizeof(a[0])
  281. #endif
  282. #ifndef SAFE_RELEASE
  283. #define SAFE_RELEASE(o) if(o) \
  284. { \
  285. o->Release(); \
  286. o = NULL; \
  287. }
  288. #endif
  289. //---------------------------------------------------------------------------
  290. #include "dmtxlat.h"
  291. //---------------------------------------------------------------------------
  292. INT_PTR CALLBACK dimaptstMainDlgProc(HWND hwnd,
  293. UINT uMsg,
  294. WPARAM wparam,
  295. LPARAM lparam);
  296. BOOL dimaptstOnInitDialog(HWND hwnd,
  297. HWND hwndFocus,
  298. LPARAM lparam);
  299. BOOL dimaptstOnClose(HWND hwnd);
  300. BOOL dimaptstOnCommand(HWND hwnd,
  301. WORD wId,
  302. HWND hwndCtrl,
  303. WORD wNotifyCode);
  304. BOOL dimaptstOnTimer(HWND hwnd,
  305. WPARAM wparamTimerId);
  306. BOOL dimaptstOnUpdateLists(HWND hwnd);
  307. UINT dmtGetCheckedRadioButton(HWND hWnd,
  308. UINT uCtrlStart,
  309. UINT uCtrlStop);
  310. void dimaptstPostEnumEnable(HWND hwnd,
  311. BOOL fEnable);
  312. // ini file reading helper functions
  313. DWORD BigFileGetPrivateProfileStringA(LPCSTR lpAppName,
  314. LPCSTR lpKeyName,
  315. LPCSTR lpDefault,
  316. LPSTR lpReturnedString,
  317. DWORD nSize,
  318. LPCSTR lpFileName);
  319. UINT BigFileGetPrivateProfileIntA(LPCSTR lpAppName,
  320. LPCSTR lpKeyName,
  321. UINT nDefault,
  322. LPCSTR lpFileName);
  323. HRESULT dmtGetListItemData(HWND hwnd,
  324. WORD wCtrlId,
  325. BOOL fCombo,
  326. void *pvData,
  327. DWORD cbSize);
  328. //---------------------------------------------------------------------------
  329. #endif // _DIMAPTST_H