2

I am currently working on a program that acts as a USB game controller but I am having trouble finding a way to simulate keypress and stick movement...

I am hoping to work with python but anything will work.

martineau
  • 119,623
  • 25
  • 170
  • 301
  • 2
    Two hints to help us help you: Post the code you currently have, and also be more specific about the problem you're having (For example, if you've made it as far as having an error, post the error) – Robert Townley Nov 03 '17 at 21:32

1 Answers1

0

Have a look into pyvjoy, it allows you to simulate controllers when the emulator x360ce is installed.

Have a look at this rocket league bot framework where the code allows you to simulate input.

Example:

import pyvjoy

class PlayHelper:

    def __init__(self, player_index):
        self.device = pyvjoy.VJoyDevice(player_index + 1)

    def update_controller(self, output):
        self.device.data.wAxisX = output[0]
        self.device.data.wAxisY = output[1]
        self.device.data.wAxisZRot = output[2]
        self.device.data.wAxisZ = output[3]
        self.device.data.lButtons = (1 * output[4]) + (2 * output[5]) + (4 * output[6])

        self.device.data.wAxisXRot = 16383
        self.device.data.wAxisYRot = 16383

        self.device.update() # Send data to vJoy device

Source: https://github.com/drssoccer55/RLBot

Tom Cupis
  • 316
  • 3
  • 24