Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

UDF: _IsPressed360.au3 (Xbox360 controller)


  • Please log in to reply
2 replies to this topic

#1 Carlo84

Carlo84

    Adventurer

  • Active Members
  • PipPip
  • 127 posts

Posted 06 October 2011 - 09:16 PM

Hey all i found this old script by Oxin8 for the X-box controller, but i just needed something more simple, so i decided to make a UDF simmilair to the _IsPressed function by ezzetabi and Jon.
Hope its helpfull to someone :-)

Functions:

Spoiler

Example:
Spoiler

UDF:
Spoiler

Edited by Carlo84, 25 August 2014 - 09:37 PM.








#2 Carlo84

Carlo84

    Adventurer

  • Active Members
  • PipPip
  • 127 posts

Posted 07 October 2011 - 12:37 AM

Heres a better example.
Script uses Controller as mouse.
Press Escape to exit script.
Check here for button layout

Posted Image


AutoIt         
#include "_IsPressed360.au3" HotKeySet('{ESC}', '_Exit') Global Const $hDll = DllOpen("xinput9_1_0.dll") Global $iAdown = 0, $iBdown = 0, $iYDown = 0 Global $iLeftJoyDown = 0 Global $iLeftDown = 0, $iRightDown = 0, $iUpDown = 0, $iDownDown = 0 Global $iRightJoyRightDown = 0, $iRightJoyLeftDown = 0, $iRightJoyDown = 0, $iRightJoyUpDown = 0, $iRightJoyDownDown = 0 While 1     If _IsPressed360(131072, $hDll) Or _IsPressed360(262144) Then _MouseMove() ; Left Joystick moved     _MouseUpDown(64, 'middle', $iLeftJoyDown, $hDll) ; Left Joystick pressed     _MouseUpDown(4096, 'primary', $iAdown, $hDll) ;A button     _MouseUpDown(8192, 'secondary', $iBdown, $hDll) ;B button     _KeyUpDown(-32768, '{LAUNCH_MEDIA down}', $iYDown, $hDll) ;Y button     If _IsPressed360(16, $hDll) Then ; Start button pressed         Send('#d')         Sleep(1000)     EndIf     If _IsPressed360(32768, $hDll) Then MouseWheel('down') ; Left trigger pressed     If _IsPressed360(65536, $hDll) Then MouseWheel('up') ; Right trigger pressed     If _IsPressed360(256, $hDll) Then Send('{VOLUME_DOWN}') ; LB pressed     If _IsPressed360(512, $hDll) Then Send('{VOLUME_UP}') ; RB pressed     _KeyUpDown(1, '{MEDIA_PLAY_PAUSE down}', $iUpDown, $hDll) ;D-Pad Up button     _KeyUpDown(2, '{MEDIA_STOP down}', $iDownDown, $hDll) ;D-Pad Down button     _KeyUpDown(4, '{MEDIA_PREV down}', $iLeftDown, $hDll) ;D-Pad Left button     _KeyUpDown(8, '{MEDIA_NEXT down}', $iRightDown, $hDll) ;D-Pad Right button     If _IsPressed360(524288, $hDll) And @extended > 0 Then         _KeyUpDown(524288, '{BROWSER_FORWARD down}', $iRightJoyRightDown, $hDll) ;Right Joystick moved to right     ElseIf _IsPressed360(524288, $hDll) And @extended < 0 Then         _KeyUpDown(524288, '{BROWSER_BACK down}', $iRightJoyLeftDown, $hDll) ;Right Joystick moved to left     Else         _KeyUpDown(524288, '{BROWSER_BACK down}', $iRightJoyLeftDown, $hDll) ;Right Joystick moved to left         _KeyUpDown(524288, '{BROWSER_FORWARD down}', $iRightJoyRightDown, $hDll) ;Right Joystick moved to right     EndIf     _KeyUpDown(128, '{BROWSER_HOME down}', $iRightJoyDown, $hDll) ;Right Joystick pressed     If _IsPressed360(1048576, $hDll) And @extended > 0 Then         _KeyUpDown(1048576, '{BROWSER_FAVORITES down}', $iRightJoyUpDown, $hDll) ;Right Joystick moved up     ElseIf _IsPressed360(1048576, $hDll) And @extended < 0 Then         _KeyUpDown(1048576, '{BROWSER_REFRESH down}', $iRightJoyDownDown, $hDll) ;Right Joystick moved down     Else         _KeyUpDown(1048576, '{BROWSER_FAVORITES down}', $iRightJoyUpDown, $hDll) ;Right Joystick moved up         _KeyUpDown(1048576, '{BROWSER_REFRESH down}', $iRightJoyDownDown, $hDll) ;Right Joystick moved down     EndIf     If _IsPressed360(32, $hDll) Then _Hibernate(32, 5000, $hDll) ; Back button pressed     Sleep(25) WEnd Func _Hibernate($iKey360, $iTime = 5000, $vDll = "xinput9_1_0.dll")     Local $iTimer = TimerInit()     While 1         If Not _IsPressed360($iKey360, $vDll) Then Return 0         If TimerDiff($iTimer) > $iTime Then ExitLoop     WEnd     If _IsPressed360($iKey360, $vDll) Then         Shutdown(64)         Return 0     EndIf EndFunc   ;==>_Hibernate Func _MouseUpDown($iKey360, $sPressKey, ByRef $iVar, $vDll = "xinput9_1_0.dll")     If _IsPressed360($iKey360, $vDll) And $iVar = 0 Then         MouseDown($sPressKey)         $iVar = 1     ElseIf Not _IsPressed360($iKey360, $vDll) And $iVar = 1 Then         MouseUp($sPressKey)         $iVar = 0     EndIf EndFunc   ;==>_MouseUpDown Func _KeyUpDown($iKey360, $sPressKey, ByRef $iVar, $vDll = "xinput9_1_0.dll")     If _IsPressed360($iKey360, $vDll) And $iVar = 0 Then         Send($sPressKey)         $iVar = 1     ElseIf Not _IsPressed360($iKey360, $vDll) And $iVar = 1 Then         Send(StringRegExpReplace($sPressKey, '(\ down\})', ' up}'))         $iVar = 0     EndIf EndFunc   ;==>_KeyUpDown Func _MouseMove()     Local $iX = MouseGetPos(0)     Local $iY = MouseGetPos(1)     If _IsPressed360(131072, $hDll) Then $iX += (@extended / 1000)     If _IsPressed360(262144, $hDll) Then $iY -= (@extended / 1000)     MouseMove($iX, $iY) EndFunc   ;==>_MouseMove Func _Exit()     DllClose($hDll)     Exit EndFunc   ;==>_Exit

Edited by Djarlo, 07 October 2011 - 12:30 PM.


#3 Carlo84

Carlo84

    Adventurer

  • Active Members
  • PipPip
  • 127 posts

Posted 07 October 2011 - 12:28 PM

Updated second sample for completion, think it shows plenty of diffrent examples of possibilities now, and its actually useful :-)
I stop working on this now ;-)

Edited by Djarlo, 07 October 2011 - 12:32 PM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users