1 module win32.directx.dinput8; 2 version(Windows): 3 4 //import tango.sys.win32.Types; 5 //alias char CHAR; 6 7 import win32.windows; 8 9 enum { 10 CLASS_E_NOAGGREGATION = cast(int) 0x80040110, 11 } 12 13 interface IUnknown { 14 HRESULT QueryInterface(IID* riid, void** pvObject); 15 ULONG AddRef(); 16 ULONG Release(); 17 } 18 19 extern(C): 20 21 struct DIDEVICEINSTANCEA 22 { 23 DWORD dwSize; 24 GUID guidInstance; 25 GUID guidProduct; 26 DWORD dwDevType; 27 CHAR[MAX_PATH] tszInstanceName; 28 CHAR[MAX_PATH] tszProductName; 29 GUID guidFFDriver; 30 WORD wUsagePage; 31 WORD wUsage; 32 } 33 alias DIDEVICEINSTANCEA DIDEVICEINSTANCE; 34 35 struct DIDEVICEOBJECTINSTANCEA 36 { 37 DWORD dwSize; 38 GUID guidType; 39 DWORD dwOfs; 40 DWORD dwType; 41 DWORD dwFlags; 42 CHAR[MAX_PATH] tszName; 43 DWORD dwFFMaxForce; 44 DWORD dwFFForceResolution; 45 WORD wCollectionNumber; 46 WORD wDesignatorIndex; 47 WORD wUsagePage; 48 WORD wUsage; 49 DWORD dwDimension; 50 WORD wExponent; 51 WORD wReportId; 52 } 53 54 struct DIOBJECTDATAFORMAT 55 { 56 const GUID *pguid; 57 DWORD dwOfs; 58 DWORD dwType; 59 DWORD dwFlags; 60 } 61 62 struct DIDATAFORMAT 63 { 64 DWORD dwSize; 65 DWORD dwObjSize; 66 DWORD dwFlags; 67 DWORD dwDataSize; 68 DWORD dwNumObjs; 69 DIOBJECTDATAFORMAT* rgodf; 70 } 71 72 extern DIDATAFORMAT c_dfDIKeyboard; 73 extern DIDATAFORMAT c_dfDIMouse2; 74 extern DIDATAFORMAT c_dfDIJoystick; 75 76 struct DIACTIONA 77 { 78 UINT* uAppData; 79 DWORD dwSemantic; 80 DWORD dwFlags; 81 union 82 { 83 LPCSTR lptszActionName; 84 UINT uResIdString; 85 } 86 GUID guidInstance; 87 DWORD dwObjID; 88 DWORD dwHow; 89 } 90 91 struct DIACTIONFORMATA 92 { 93 DWORD dwSize; 94 DWORD dwActionSize; 95 DWORD dwDataSize; 96 DWORD dwNumActions; 97 DIACTIONA* rgoAction; 98 GUID guidActionMap; 99 DWORD dwGenre; 100 DWORD dwBufferSize; 101 LONG lAxisMin; 102 LONG lAxisMax; 103 HINSTANCE hInstString; 104 FILETIME ftTimeStamp; 105 DWORD dwCRC; 106 CHAR[MAX_PATH] tszActionMap; 107 } 108 109 struct DIDEVCAPS 110 { 111 DWORD dwSize; 112 DWORD dwFlags; 113 DWORD dwDevType; 114 DWORD dwAxes; 115 DWORD dwButtons; 116 DWORD dwPOVs; 117 DWORD dwFFSamplePeriod; 118 DWORD dwFFMinTimeResolution; 119 DWORD dwFirmwareRevision; 120 DWORD dwHardwareRevision; 121 DWORD dwFFDriverVersion; 122 } 123 124 struct DIPROPHEADER 125 { 126 DWORD dwSize; 127 DWORD dwHeaderSize; 128 DWORD dwObj; 129 DWORD dwHow; 130 } 131 132 struct DIDEVICEOBJECTDATA 133 { 134 DWORD dwOfs; 135 DWORD dwData; 136 DWORD dwTimeStamp; 137 DWORD dwSequence; 138 UINT* uAppData; 139 } 140 141 struct DIENVELOPE 142 { 143 DWORD dwSize = DIENVELOPE.sizeof; 144 DWORD dwAttackLevel; 145 DWORD dwAttackTime; // Microseconds 146 DWORD dwFadeLevel; 147 DWORD dwFadeTime; // Microseconds 148 } 149 150 struct DIEFFECT 151 { 152 DWORD dwSize = DIEFFECT.sizeof; 153 DWORD dwFlags; // DIEFF_* 154 DWORD dwDuration; // Microseconds 155 DWORD dwSamplePeriod; // Microseconds 156 DWORD dwGain; 157 DWORD dwTriggerButton; // or DIEB_NOTRIGGER 158 DWORD dwTriggerRepeatInterval; // Microseconds 159 DWORD cAxes; // Number of axes 160 LPDWORD rgdwAxes; // Array of axes 161 LPLONG rglDirection; // Array of directions 162 DIENVELOPE* lpEnvelope; // Optional 163 DWORD cbTypeSpecificParams; // Size of params 164 LPVOID lpvTypeSpecificParams; // Pointer to params 165 DWORD dwStartDelay; // Microseconds 166 } 167 168 struct DIEFFESCAPE 169 { 170 DWORD dwSize; 171 DWORD dwCommand; 172 LPVOID lpvInBuffer; 173 DWORD cbInBuffer; 174 LPVOID lpvOutBuffer; 175 DWORD cbOutBuffer; 176 } 177 178 struct DIEFFECTINFOA 179 { 180 DWORD dwSize; 181 GUID guid; 182 DWORD dwEffType; 183 DWORD dwStaticParams; 184 DWORD dwDynamicParams; 185 CHAR[MAX_PATH] tszName; 186 } 187 188 struct DIFILEEFFECT 189 { 190 DWORD dwSize; 191 GUID GuidEffect; 192 DIEFFECT* lpDiEffect; 193 CHAR[MAX_PATH] szFriendlyName; 194 } 195 196 struct DIDEVICEIMAGEINFOA 197 { 198 CHAR[MAX_PATH] tszImagePath; 199 DWORD dwFlags; 200 // These are valid if DIDIFT_OVERLAY is present in dwFlags. 201 DWORD dwViewID; 202 RECT rcOverlay; 203 DWORD dwObjID; 204 DWORD dwcValidPts; 205 POINT[5] rgptCalloutLine; 206 RECT rcCalloutRect; 207 DWORD dwTextAlign; 208 } 209 210 struct DIDEVICEIMAGEINFOHEADERA 211 { 212 DWORD dwSize; 213 DWORD dwSizeImageInfo; 214 DWORD dwcViews; 215 DWORD dwcButtons; 216 DWORD dwcAxes; 217 DWORD dwcPOVs; 218 DWORD dwBufferSize; 219 DWORD dwBufferUsed; 220 DIDEVICEIMAGEINFOA* lprgImageInfoArray; 221 } 222 223 struct DICONFIGUREDEVICESPARAMSA 224 { 225 DWORD dwSize; 226 DWORD dwcUsers; 227 LPSTR lptszUserNames; 228 DWORD dwcFormats; 229 DIACTIONFORMATA* lprgFormats; 230 HWND hwnd; 231 DICOLORSET dics; 232 IUnknown lpUnkDDSTarget; 233 } 234 235 struct DICOLORSET 236 { 237 DWORD dwSize; 238 DWORD cTextFore; 239 DWORD cTextHighlight; 240 DWORD cCalloutLine; 241 DWORD cCalloutHighlight; 242 DWORD cBorder; 243 DWORD cControlFill; 244 DWORD cHighlightFill; 245 DWORD cAreaFill; 246 } 247 248 struct DIMOUSESTATE2 249 { 250 LONG lX; 251 LONG lY; 252 LONG lZ; 253 BYTE[8] rgbButtons; 254 } 255 256 struct DIJOYSTATE 257 { 258 LONG lX; /* x-axis position */ 259 LONG lY; /* y-axis position */ 260 LONG lZ; /* z-axis position */ 261 LONG lRx; /* x-axis rotation */ 262 LONG lRy; /* y-axis rotation */ 263 LONG lRz; /* z-axis rotation */ 264 LONG[2] rglSlider; /* extra axes positions */ 265 DWORD[4] rgdwPOV; /* POV directions */ 266 BYTE[32] rgbButtons; /* 32 buttons */ 267 } 268 269 struct DIPROPRANGE 270 { 271 DIPROPHEADER diph; 272 LONG lMin; 273 LONG lMax; 274 } 275 276 interface IDirectInputEffect : IUnknown 277 { 278 HRESULT Initialize(HINSTANCE, DWORD, GUID*); 279 HRESULT GetEffectGuid(GUID*); 280 HRESULT GetParameters(DIEFFECT*, DWORD); 281 HRESULT SetParameters(DIEFFECT*, DWORD); 282 HRESULT Start(DWORD, DWORD); 283 HRESULT Stop(); 284 HRESULT GetEffectStatus(LPDWORD); 285 HRESULT Download(); 286 HRESULT Unload(); 287 HRESULT Escape(DIEFFESCAPE*); 288 } 289 290 extern(Windows) alias bool function(DIDEVICEINSTANCEA*, LPVOID) LPDIENUMDEVICESCALLBACKA; 291 extern(Windows) alias bool function(DIDEVICEINSTANCEA*, IDirectInputDevice8A*, DWORD, DWORD, LPVOID) LPDIENUMDEVICESBYSEMANTICSCBA; 292 293 extern(Windows) alias bool function(DIDEVICEOBJECTINSTANCEA *didoi, void* pContext) LPDIENUMDEVICEOBJECTSCALLBACKA; 294 295 extern(Windows) alias bool function(DIEFFECTINFOA*, LPVOID) LPDIENUMEFFECTSCALLBACKA; 296 extern(Windows) alias bool function(IDirectInputEffect, LPVOID) LPDIENUMCREATEDEFFECTOBJECTSCALLBACK; 297 extern(Windows) alias bool function(DIFILEEFFECT* , LPVOID) LPDIENUMEFFECTSINFILECALLBACK; 298 extern(Windows) alias bool function(IUnknown, LPVOID) LPDICONFIGUREDEVICESCALLBACK; 299 300 interface IDirectInputDevice8A : IUnknown 301 { 302 HRESULT GetCapabilities(DIDEVCAPS*); 303 HRESULT EnumObjects(LPDIENUMDEVICEOBJECTSCALLBACKA, VOID*, DWORD); 304 HRESULT GetProperty(GUID*, DIPROPHEADER*); 305 HRESULT SetProperty(GUID*, DIPROPHEADER*); 306 HRESULT Acquire(); 307 HRESULT Unacquire(); 308 HRESULT GetDeviceState(DWORD, LPVOID); 309 HRESULT GetDeviceData(DWORD, DIDEVICEOBJECTDATA*, LPDWORD, DWORD); 310 HRESULT SetDataFormat(DIDATAFORMAT*); 311 HRESULT SetEventNotification(HANDLE); 312 HRESULT SetCooperativeLevel(HWND, DWORD); 313 HRESULT GetObjectInfo(DIDEVICEOBJECTINSTANCEA*, DWORD, DWORD); 314 HRESULT GetDeviceInfo(DIDEVICEINSTANCEA*); 315 HRESULT RunControlPanel(HWND, DWORD); 316 HRESULT Initialize(HINSTANCE, DWORD, GUID*); 317 HRESULT CreateEffect(GUID*, DIEFFECT*, IDirectInputEffect*, IUnknown); 318 HRESULT EnumEffects(LPDIENUMEFFECTSCALLBACKA, LPVOID, DWORD); 319 HRESULT GetEffectInfo(DIEFFECTINFOA*, GUID*); 320 HRESULT GetForceFeedbackState(LPDWORD); 321 HRESULT SendForceFeedbackCommand(DWORD); 322 HRESULT EnumCreatedEffectObjects(LPDIENUMCREATEDEFFECTOBJECTSCALLBACK, LPVOID, DWORD); 323 HRESULT Escape(DIEFFESCAPE*); 324 HRESULT Poll(); 325 HRESULT SendDeviceData(DWORD, DIDEVICEOBJECTDATA*, LPDWORD, DWORD); 326 HRESULT EnumEffectsInFile(LPCSTR, LPDIENUMEFFECTSINFILECALLBACK, LPVOID, DWORD); 327 HRESULT WriteEffectToFile(LPCSTR, DWORD, DIFILEEFFECT*, DWORD); 328 HRESULT BuildActionMap(DIACTIONFORMATA*, LPCSTR, DWORD); 329 HRESULT SetActionMap(DIACTIONFORMATA*, LPCSTR, DWORD); 330 HRESULT GetImageInfo(DIDEVICEIMAGEINFOHEADERA*); 331 } 332 alias IDirectInputDevice8A IDirectInputDevice8; 333 334 interface IDirectInput8A : IUnknown 335 { 336 extern(Windows): 337 HRESULT CreateDevice(GUID*, IDirectInputDevice8A*, IUnknown); 338 HRESULT EnumDevices(DWORD, LPDIENUMDEVICESCALLBACKA, LPVOID, DWORD); 339 HRESULT GetDeviceStatus(GUID*); 340 HRESULT RunControlPanel(HWND, DWORD); 341 HRESULT Initialize(HINSTANCE, DWORD); 342 HRESULT FindDevice(GUID*, LPCSTR, GUID*); 343 HRESULT EnumDevicesBySemantics(LPCSTR, DIACTIONFORMATA*, LPDIENUMDEVICESBYSEMANTICSCBA, LPVOID, DWORD); 344 HRESULT ConfigureDevices(LPDICONFIGUREDEVICESCALLBACK, DICONFIGUREDEVICESPARAMSA*, DWORD, LPVOID); 345 } 346 alias IDirectInput8A IDirectInput8; 347 348 extern(Windows) HRESULT DirectInput8Create(HINSTANCE hinst, DWORD dwVersion, GUID* riidltf, void** ppvOut, IUnknown punkOuter); 349 350 const GUID IID_IDirectInput8A={0xBF798030, 0x483A, 0x4DA2, [0xAA, 0x99, 0x5D, 0x64, 0xED, 0x36, 0x97, 0x00]}; 351 alias IID_IDirectInput8A IID_IDirectInput8; 352 const GUID GUID_SysKeyboard = {0x6F1D2B61, 0xD5A0, 0x11CF, [0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]}; 353 const GUID GUID_SysMouse = {0x6F1D2B60, 0xD5A0, 0x11CF, [0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]}; 354 const GUID GUID_XAxis = {0xA36D02E0, 0xC9F3, 0x11CF, [0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]}; 355 const GUID GUID_YAxis = {0xA36D02E1, 0xC9F3, 0x11CF, [0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]}; 356 const GUID GUID_ZAxis = {0xA36D02E2, 0xC9F3, 0x11CF, [0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]}; 357 const GUID GUID_RxAxis = {0xA36D02F4, 0xC9F3, 0x11CF, [0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]}; 358 const GUID GUID_RyAxis = {0xA36D02F5, 0xC9F3, 0x11CF, [0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]}; 359 const GUID GUID_RzAxis = {0xA36D02E3, 0xC9F3, 0x11CF, [0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]}; 360 const GUID GUID_Slider = {0xA36D02E4, 0xC9F3, 0x11CF, [0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]}; 361 const GUID GUID_Key = {0x55728220, 0xD33C, 0x11CF, [0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]}; 362 const GUID GUID_POV = {0xA36D02F2, 0xC9F3, 0x11CF, [0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]}; 363 364 enum : uint 365 { 366 DISCL_EXCLUSIVE= 0x00000001, 367 DISCL_NONEXCLUSIVE= 0x00000002, 368 DISCL_FOREGROUND= 0x00000004, 369 DISCL_BACKGROUND= 0x00000008, 370 DISCL_NOWINKEY= 0x00000010, 371 372 DIPH_DEVICE=0, 373 DIPH_BYOFFSET=1, 374 375 DI8DEVCLASS_GAMECTRL=4, 376 DIEDFL_ATTACHEDONLY= 0x00000001, 377 DIDFT_AXIS= 0x00000003 378 } 379 380 enum 381 { 382 SEVERITY_SUCCESS= 0, 383 SEVERITY_ERROR= 1, 384 FACILITY_WIN32= 7, 385 ERROR_READ_FAULT= 30L, 386 DIENUM_CONTINUE= 1, 387 DIPH_BYID= 2 388 } 389 390 struct DIPROPDWORD 391 { 392 DIPROPHEADER diph; 393 DWORD dwData; 394 } 395 396 template MAKE_HRESULT(uint sev, uint fac, uint code) 397 { 398 const HRESULT MAKE_HRESULT = cast(HRESULT)((sev << 31) | (fac << 16) | code); 399 } 400 401 const HRESULT DIERR_OLDDIRECTINPUTVERSION = MAKE_HRESULT!(SEVERITY_ERROR, FACILITY_WIN32, 1150); 402 const HRESULT DIERR_BETADIRECTINPUTVERSION = MAKE_HRESULT!(SEVERITY_ERROR, FACILITY_WIN32, 1153); 403 const HRESULT DIERR_BADDRIVERVER = MAKE_HRESULT!(SEVERITY_ERROR, FACILITY_WIN32, 119); 404 const HRESULT DIERR_DEVICENOTREG = 0x80040154; 405 const HRESULT DIERR_NOTFOUND = MAKE_HRESULT!(SEVERITY_ERROR, FACILITY_WIN32, ERROR_FILE_NOT_FOUND); 406 const HRESULT DIERR_OBJECTNOTFOUND = MAKE_HRESULT!(SEVERITY_ERROR, FACILITY_WIN32, ERROR_FILE_NOT_FOUND); 407 const HRESULT DIERR_INVALIDPARAM = E_INVALIDARG; 408 const HRESULT DIERR_NOINTERFACE = E_NOINTERFACE; 409 const HRESULT DIERR_GENERIC = E_FAIL; 410 const HRESULT DIERR_OUTOFMEMORY = E_OUTOFMEMORY; 411 const HRESULT DIERR_UNSUPPORTED = E_NOTIMPL; 412 const HRESULT DIERR_NOTINITIALIZED = MAKE_HRESULT!(SEVERITY_ERROR, FACILITY_WIN32, 21); 413 const HRESULT DIERR_ALREADYINITIALIZED = MAKE_HRESULT!(SEVERITY_ERROR, FACILITY_WIN32, 1247); 414 const HRESULT DIERR_NOAGGREGATION = CLASS_E_NOAGGREGATION; 415 const HRESULT DIERR_OTHERAPPHASPRIO = 0x80070005; 416 const HRESULT DIERR_INPUTLOST = MAKE_HRESULT!(SEVERITY_ERROR, FACILITY_WIN32, ERROR_READ_FAULT); 417 const HRESULT DIERR_ACQUIRED = MAKE_HRESULT!(SEVERITY_ERROR, FACILITY_WIN32, 170); 418 const HRESULT DIERR_NOTACQUIRED = MAKE_HRESULT!(SEVERITY_ERROR, FACILITY_WIN32, 12); 419 const HRESULT DIERR_READONLY = 0x80070005; 420 const HRESULT DIERR_HANDLEEXISTS = 0x80070005; 421 const HRESULT DIERR_INSUFFICIENTPRIVS = 0x80040200; 422 const HRESULT DIERR_DEVICEFULL = 0x80040201; 423 const HRESULT DIERR_MOREDATA = 0x80040202; 424 const HRESULT DIERR_NOTDOWNLOADED = 0x80040203; 425 const HRESULT DIERR_HASEFFECTS = 0x80040204; 426 const HRESULT DIERR_NOTEXCLUSIVEACQUIRED = 0x80040205; 427 const HRESULT DIERR_INCOMPLETEEFFECT = 0x80040206; 428 const HRESULT DIERR_NOTBUFFERED = 0x80040207; 429 const HRESULT DIERR_EFFECTPLAYING = 0x80040208; 430 const HRESULT DIERR_UNPLUGGED = 0x80040209; 431 const HRESULT DIERR_REPORTFULL = 0x8004020A; 432 const HRESULT DIERR_MAPFILEFAIL = 0x8004020B;