2

我目前正在开发一个充当 USB 游戏控制器的程序,但我无法找到模拟按键和摇杆移动的方法......

我希望与 python 一起工作,但任何事情都会奏效。

4

1 回答 1

0

看看 pyvjoy,它允许您在安装模拟器x360ce时模拟控制器。

看看这个火箭联盟机器人框架,其中的代码允许您模拟输入。

例子:

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

来源:https ://github.com/drssoccer55/RLBot

于 2017-11-03T21:38:05.920 回答