Page 1 of 1

Logging And Controlling XboxOne With Python

Posted: Fri Feb 15, 2019 11:51 am
by deep_learning_nerd
Dear all,
I've got my GIMX adapter working where I can run the launcher and see all of the live output going to the text option and see the controls on the screen.

My goal right now is to first log ALL of my controller outputs in real-time, ideally in a format that makes it easy for me to play with them in python.

When I launch from the command line:

Code: Select all

gimx -c XOnePadUsb.xml --status --nograb --force-updates -t XboxPad --src 127.0.0.1:51914
I get this:

Code: Select all

global option -c with value `XOnePadUsb.xml'
controller #1: option -t with value `XboxPad'
controller #1: option -s with value `127.0.0.1:51914'
grab flag is unset
status flag is set
force_updates flag is set
using default refresh period: 8.00ms
Warning: joystick not found: Microsoft X-Box One pad 0
Everything seems to be working, I can control the xbox and move around, but I don't see live output like I do when I run the gimx-launcher. I've looked around on the site, forum, and google and i think I'm kind of stuck here. I would be thrilled if someone could help point me to where I could get live outputs for ALL controllers in real-time like I see with the gimx-launcher and then the next step would be injecting controls with python to auto play.

The project I'm working on is training a deep-learner to play COD on the xbox using video to predict live controller output.

Re: Logging And Controlling XboxOne With Python

Posted: Fri Feb 15, 2019 11:59 am
by deep_learning_nerd
Ok, rubber ducking it, I played more with the launcher and noticed I wasn't setting the subpos flag:

Code: Select all

gimx -c XOnePadUsb.xml -p /dev/ttyUSB0 --status --nograb --force-updates --subpos -t XboxPad --src 127.0.0.1:51914
This is now doing what I want, now I just need to wrap it in python to handle/log the subprocess

Re: Logging And Controlling XboxOne With Python

Posted: Fri Feb 15, 2019 1:01 pm
by deep_learning_nerd
So for the python lovers out there, I'm getting logging lines in real-time to play with like this:

Code: Select all

from subprocess import Popen, PIPE

def run(command):
    process = Popen(command, stdout=PIPE, shell=True)
    while True:
        line = process.stdout.readline().rstrip()
        if not line:
            break
        yield line


if __name__ == "__main__":
    command = 'gimx -c XOnePadUsb.xml -p /dev/ttyUSB0 --status --nograb --force-updates --subpos -t XboxPad --src 127.0.0.1:51914'
    for path in run(command):
        print(path)
Now I can align them with the frame buffers and start training my deep networks to learn to auto play

Re: Logging And Controlling XboxOne With Python

Posted: Fri Feb 15, 2019 8:37 pm
by Matlo
Thanks for sharing :)

Re: Logging And Controlling XboxOne With Python

Posted: Thu Feb 28, 2019 9:47 pm
by Forbidden Era
Agreed thanks for sharing.