1 //----------------------------------------------------------------------------- 2 // File: XBInput.h 3 // 4 // Desc: Input helper functions for the XBox samples 5 // 6 // Hist: 12.15.00 - Separated from XBUtil.h for December XDK release 7 // 01.03.00 - Made changes for real Xbox controller 8 // 9 // Copyright (c) Microsoft Corporation. All rights reserved. 10 //----------------------------------------------------------------------------- 11 #ifndef XBINPUT_H 12 #define XBINPUT_H 13 14 15 16 17 //----------------------------------------------------------------------------- 18 // Name: struct XBGAMEPAD 19 // Desc: structure for holding Game pad data 20 //----------------------------------------------------------------------------- 21 struct XBGAMEPAD : public XINPUT_GAMEPAD 22 { 23 // The following members are inherited from XINPUT_GAMEPAD: 24 // WORD wButtons; 25 // BYTE bAnalogButtons[8]; 26 // SHORT sThumbLX; 27 // SHORT sThumbLY; 28 // SHORT sThumbRX; 29 // SHORT sThumbRY; 30 31 // Thumb stick values converted to range [-1,+1] 32 FLOAT fX1; 33 FLOAT fY1; 34 FLOAT fX2; 35 FLOAT fY2; 36 37 // State of buttons tracked since last poll 38 WORD wLastButtons; 39 BOOL bLastAnalogButtons[8]; 40 WORD wPressedButtons; 41 BOOL bPressedAnalogButtons[8]; 42 43 // Rumble properties 44 XINPUT_RUMBLE Rumble; 45 XINPUT_FEEDBACK Feedback; 46 47 // Device properties 48 XINPUT_CAPABILITIES caps; 49 HANDLE hDevice; 50 51 // Flags for whether game pad was just inserted or removed 52 BOOL bInserted; 53 BOOL bRemoved; 54 }; 55 56 57 58 59 //----------------------------------------------------------------------------- 60 // Global access to input states 61 //----------------------------------------------------------------------------- 62 extern XINPUT_STATE g_InputStates[4]; 63 64 65 66 67 //----------------------------------------------------------------------------- 68 // Global access to gamepad devices 69 //----------------------------------------------------------------------------- 70 extern XBGAMEPAD g_Gamepads[4]; 71 72 73 74 75 //----------------------------------------------------------------------------- 76 // Name: XBInput_CreateGamepads() 77 // Desc: Creates the game pad devices 78 //----------------------------------------------------------------------------- 79 HRESULT XBInput_CreateGamepads( XBGAMEPAD** ppGamepads = NULL ); 80 81 82 83 84 //----------------------------------------------------------------------------- 85 // Name: XBInput_GetInput() 86 // Desc: Processes input from the game pad 87 //----------------------------------------------------------------------------- 88 VOID XBInput_GetInput( XBGAMEPAD* pGamepads = NULL ); 89 90 91 92 93 #endif // XBINPUT_H 94