Jump to content

Simulating Xbox One controller inputs to computer


Recommended Posts

So, I've had this problem for a couple of days now, because I'm trying to automate a feature in my Xbox (currently running through streaming in my computer (Xbox App)) and I can't find any solution.

I have managed to run the program where you can read which button is pressed in a game controller from the following post: https://www.autoitscript.com/forum/topic/10953-joystick-udf/. But thats not what I actually need. I need to be able to press "B" (like if I was pressing the "B" button in my controller) in my computer without actually need to press it.

What I'm trying to do is detecting by PixelGetColor() if a certain menu was open on the Xbox, and if that's the case, virtually press the "B" button to close it, leaving the user unable to open that certain menu.

I would appreciate any solutions, because this will allow me to solve many problems I have with my Xbox automation script. :)

(If any doubts, I actually have a Xbox One controller connected to the computer)

Link to comment
Share on other sites

Good morning @Joel_, and welcome to the AutoIt forum :)

I don't know if this kind of request could be taken as game automation. If so, you won't have any answer from here.

If it's not ( and I am not the one who can decide for that ), it is possible to do it, but yoi have to post the code you are working on, or a working reproducer of your script, in order to see what you did, and help you from what you did :)

 

Best Regards.

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

It's not for game automation purposes. See, I am renting (I don't know if thats the appropiate verb) my Xbox, like a personal bussiness, and I'm not able to control the kids from entering some menus I don't want like the "turning off Xbox" menu and "change session" menu. I just want to detect if any of those menus was open so I can send a "B" button and take them out of there.

Like I said, I was only able to run the code from the posted link: 

;____________________________________________________________________
;       Original program by Ejoc                                    ;
;       Improved by Adam1213 (autoit 3.2 compatiblity + improved labels         ;
;____________________________________________________________________

#include <GUIConstants.au3>

;_________________ SETUP_____________________________________
Local $joy,$coor,$h,$s,$msg

$joy    = _JoyInit()

dim $labels_text[8]=['X', 'Y', 'Z', 'R', 'U', 'V', 'POV', 'Buttons']
dim $labels_no=UBound($labels_text)
dim $labels[$labels_no]
dim $labels_value[$labels_no]
;__________ CONFIG ____________________________________________
;---------- Find the max length of the longest label --------------
$label_len=0
for $text in $labels_text
    $len=stringlen($text)
    if $len>$label_len then
        $label_len=$len
    endif
next
$label_len*=6
;_____________ GUI _______________________________________________
GUICreate('Joystick Test', 200, 200)
GUICtrlCreateLabel('Joystick', 40, 20, 100, 20)
    
for $i=0 to $labels_no-1
    GuiCtrlCreatelabel($labels_text[$i]&':', 10, 60+$i*12, $label_len, 12)
    $labels[$i]=GuiCtrlCreatelabel('', 10+$label_len, 60+$i*12, 70, 12)
    $labels_value[$i]=''
next
GUISetState()
;_____________________________________________________________________

while 1
    $coord=_GetJoy($joy,0)
    for $i=0 to UBound($coord)-1
        if $coord[$i]<>$labels_value[$i] then
            GUICtrlSetData($labels[$i], $coord[$i])
            $labels_value[$i]=$coord[$i]
        endif
    next
    sleep(10)
    $msg =GUIGetMSG()
    if $msg = $GUI_EVENT_CLOSE Then Exitloop
    
    ;*********************************************************
    ;Here I would like to detect If (Menu was open) Then  (With PixelGetColor(), that I have used)
    ;                                Send(A virtual "B" press)
    ;                            EndIf
    ;*********************************************************
    
WEnd

$lpJoy=0 ; Joyclose

;======================================
;   _JoyInit()
;======================================
Func _JoyInit()
    Local $joy
    Global $JOYINFOEX_struct    = "dword[13]"

    $joy=DllStructCreate($JOYINFOEX_struct)
    if @error Then Return 0
    DllStructSetData($joy, 1, DllStructGetSize($joy), 1);dwSize = sizeof(struct)
    DllStructSetData($joy, 1, 255, 2)              ;dwFlags = GetAll
    return $joy
EndFunc

;======================================
;   _GetJoy($lpJoy,$iJoy)
;   $lpJoy  Return from _JoyInit()
;   $iJoy   Joystick # 0-15
;   Return  Array containing X-Pos, Y-Pos, Z-Pos, R-Pos, U-Pos, V-Pos,POV
;           Buttons down
;
;           *POV This is a digital game pad, not analog joystick
;           65535   = Not pressed
;           0       = U
;           4500    = UR
;           9000    = R
;           Goes around clockwise increasing 4500 for each position
;======================================
Func _GetJoy($lpJoy,$iJoy)
    Local $coor,$ret

    Dim $coor[8]
    DllCall("Winmm.dll","int","joyGetPosEx", _
            "int",$iJoy, _
            "ptr",DllStructGetPtr($lpJoy))

    if Not @error Then
        $coor[0]    = DllStructGetData($lpJoy,1,3)
        $coor[1]    = DllStructGetData($lpJoy,1,4)
        $coor[2]    = DllStructGetData($lpJoy,1,5)
        $coor[3]    = DllStructGetData($lpJoy,1,6)
        $coor[4]    = DllStructGetData($lpJoy,1,7)
        $coor[5]    = DllStructGetData($lpJoy,1,8)
        $coor[6]    = DllStructGetData($lpJoy,1,11)
        $coor[7]    = DllStructGetData($lpJoy,1,9)
    EndIf

    return $coor
EndFunc

 

I'm not very familiar with DLL's (if they end to be part of the solution), so I need help figuring out what code I need to be able to just send one "B" pulse.

 

Thanks in advance.

Link to comment
Share on other sites

  • 5 weeks later...

Im very interested in this too. Did you ever managed to find a solution?

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...