SkellySoul Posted August 12, 2011 Share Posted August 12, 2011 Hello I just bought a Xbox Controller for the PC and been playing around with it and have just about everything functional except I don't know how to call this Dll to get the battery life. http://msdn.microsoft.com/en-us/library/microsoft.directx_sdk.reference.xinputgetbatteryinformation Also is it possible to make the Xbox Guide button functional and may be any code to mess with the lights Thanks Link to comment Share on other sites More sharing options...
monoscout999 Posted August 12, 2011 Share Posted August 12, 2011 (edited) what dll? EDIT: Are you talking about autoIt? because as far i can see there is no DLL only a C++ Library, but my knowldege is few maybe someone else can point you to the right direction. more EDIT: Usually MSDN put you as requirements the DLL you need, when this is not there it means that there`s no dll at all. more and more EDIT: ...the mouse ate your tonge? jijiji and more of that EDIT: ...i don`t know to much but maybe AutoItObject can help you with this quest. Edited August 12, 2011 by monoscout999 Link to comment Share on other sites More sharing options...
SkellySoul Posted August 12, 2011 Author Share Posted August 12, 2011 what dll?EDIT: Are you talking about autoIt? because as far i can see there is no DLL only a C++ Library, but my knowldege is few maybe someone else can point you to the right direction.more EDIT: Usually MSDN put you as requirements the DLL you need, when this is not there it means that there`s no dll at all.more and more EDIT: ...the mouse ate your tonge? jijijiand more of that EDIT: ...i don`t know to much but maybe AutoItObject can help you with this quest.xinput9_1_0.dll Link to comment Share on other sites More sharing options...
monoscout999 Posted August 12, 2011 Share Posted August 12, 2011 (edited) i didn`t find it, please point me to the documentation of that dll, because MSDN doesn`t say anything about that... Only guessing, thrusting in that the dll might work this way. and also thrusting that you know what means every parameter of this function. DllCall("xinput9_1_0.dll","dword","XInputGetBatteryInformation","dword",$UserIndex,"byte",$devType,"ptr",DllStructGetPtr($tXINPUT_BATTERY_INFORMATION)) Mainly something like this. After that $BatteryType = DllStructGetData($tXINPUT_BATTERY_INFORMATION,1) $BatteryLevel = DllStructGetData($tXINPUT_BATTERY_INFORMATION,2) Edited August 12, 2011 by monoscout999 Link to comment Share on other sites More sharing options...
smashly Posted August 12, 2011 Share Posted August 12, 2011 Hi, have you actually tried calling any of the Xinput functions? I've been calling xinput1_3.dll and the XInputGetBatteryInformation works for me in xp x86, not tried it in win 7 yet. It's a pretty straight forward api call. Link to comment Share on other sites More sharing options...
JohnOne Posted August 12, 2011 Share Posted August 12, 2011 (edited) I'm usually wrong with dll witchcraft but imagine it would look something like this. $type = "?" ; Dont know where you get this from, I assume you do. $Index = "?" ; same $OutStruct = DllStructCreate("byte;byte") $dwUserIndex = DllStructCreate("dword dwUserIndex") $devType = DllStructCreate("byte[" & BinaryLen($type) & "] devType") DllStructSetData($dwUserIndex,"dwUserIndex",$type) DllStructSetData($devType,"devType",$Index) $pointer = DllStructGetPtr($OutStruct) $sDll = "Some.dll") $Rtn = DllCall($sDll,"dword","XInputGetBatteryInformation","dword",$dwUserIndex,"byte",$devType,"ptr",$pointer) Edited August 12, 2011 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
smashly Posted August 12, 2011 Share Posted August 12, 2011 (edited) These are the constants I'm using ;// User index definitions Global Const $XUSER_MAX_COUNT = 4 ; Can be a value in the range 0 to XUSER_MAX_COUNT − 1 ;// Device types available in XINPUT_CAPABILITIES Global Const $XINPUT_DEVTYPE_GAMEPAD = 0x01 Global Const $tag_XINPUT_BATTERY_INFORMATION = "BYTE BatteryType;BYTE BatteryLevel" ;// Flags for battery status level ;// Battery Type Global Const $BATTERY_TYPE_DISCONNECTED = 0x00 ;// This device is not connected Global Const $BATTERY_TYPE_WIRED = 0x01 ;// Wired device, no battery Global Const $BATTERY_TYPE_ALKALINE = 0x02 ;// Alkaline battery source Global Const $BATTERY_TYPE_NIMH = 0x03 ;// Nickel Metal Hydride battery source Global Const $BATTERY_TYPE_UNKNOWN = 0xFF ;// Cannot determine the battery type ;// These are only valid for wireless, connected devices, with known battery types ;// The amount of use time remaining depends on the type of device. ;// Battery Level Global Const $BATTERY_LEVEL_EMPTY = 0x00 Global Const $BATTERY_LEVEL_LOW = 0x01 Global Const $BATTERY_LEVEL_MEDIUM = 0x02 Global Const $BATTERY_LEVEL_FULL = 0x03Basically a copy and paste from XInput.h from DX SDK Aug 09 Edited August 12, 2011 by smashly Link to comment Share on other sites More sharing options...
SkellySoul Posted August 12, 2011 Author Share Posted August 12, 2011 (edited) expandcollapse popup;Xbox Controller ;Button[1] = Up ;Button[2] = Down ;Button[3] = Left ;Button[4] = Right ;Button[5] = Start ;Button[6] = Back ;Button[7] = Left Joy ;Button[8] = Right Joy ;Button[9] = Left Button ;Button[10] = Right Button ;Button[11] = A ;Button[12] = B ;Button[13] = X ;Button[14] = Y $X_Dll = X_Start() While 1 $Idle = 100 $X_Input = _X_Input($X_Dll) $X_Button = _X_Button($X_Input[2]) Sleep($Idle) If $X_Button[1] Then ; Up ;;; ElseIf $X_Button[2] Then ; Down ;;; ElseIf $X_Button[3] Then ; Left ;;; ElseIf $X_Button[4] Then ; Right ;;; ElseIf $X_Button[5] Then ; Start ;;; ElseIf $X_Button[6] Then ; Back ;;; ElseIf $X_Button[7] Then ; Left Joy ;;; ElseIf $X_Button[8] Then ; Right Joy ;;; ElseIf $X_Button[9] Then ; Left Button ;;; ElseIf $X_Button[10] Then ; Right Button ;;; ElseIf $X_Button[11] Then ; A ;;; ElseIf $X_Button[12] Then ; B ;;; ElseIf $X_Button[13] Then ; X ;;; ElseIf $X_Button[14] Then ; Y ;;; EndIf _X_Vibrate($X_Dll, Round(($X_Input[3] / 255) * 100), Round(($X_Input[4] / 255) * 100)) WEnd Func X_Start() Local $Box $Box = DllOpen(@ScriptDir & "\Controller.dll") If $Box = -1 Then MsgBox(16, "Error" , "Exiting...") DllClose($Box) Else Return $Box EndIf EndFunc Func _X_Input($X_Dll) Local $Input[9] $Pad = DllStructCreate("dword;short;ubyte;ubyte;short;short;short;short") If DllCall($X_Dll, "long", "XInputGetState", "long", 0, "ptr", DllStructGetPtr($Pad)) = 0 Then Return For $i = 1 to 8 $Input[$i] = DllStructGetData($Pad, $i) Next Return $Input EndFunc Func _X_Button($X_Button) Local $Pressed[15] If $X_Button < 0 Then $X_Button = $X_Button + 32768 $Pressed[14] = 1 EndIf For $i = 14 to 12 Step -1 If $X_Button >= (2 ^ $i) Then $X_Button = $X_Button - (2 ^ $i) $Pressed[($i-1)] = 1 EndIf Next For $i = 9 to 0 Step -1 If $X_Button >= (2 ^ $i) Then $X_Button = $X_Button - (2 ^ $i) $Pressed[($i + 1)] = 1 EndIf Next Return $Pressed EndFunc Func _X_Vibrate($X_Dll, $L_Motor, $R_Motor) $X_Vibration = DllStructCreate("short;short") DllStructSetData($X_Vibration, 1, Round(($L_Motor / 100) * 32767)) DllStructSetData($X_Vibration, 2, Round(($R_Motor / 100) * 32767)) DllCall($X_Dll, "long", "XInputSetState", "long", 0, "ptr", DllStructGetPtr($X_Vibration)) EndFunc Edited August 12, 2011 by SkellySoul Link to comment Share on other sites More sharing options...
JohnOne Posted August 12, 2011 Share Posted August 12, 2011 "ubyte" Is that a valid type in autoit? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
SkellySoul Posted August 12, 2011 Author Share Posted August 12, 2011 "ubyte"Is that a valid type in autoit?24th August, 2007 - v3.2.6.0Added: byte and ubyte type to DllCall(). Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now