织梦CMS - 轻松建站从此开始!

欧博ABG官网-欧博官方网址-会员登入

Simulate XBox Controller Inp欧博ut with Python

时间:2025-08-22 12:27来源: 作者:admin 点击: 2 次
In case someone with the same problems will find this thread: I solved the issue with vJoy, pyVJoy and x360ce. vJoy provides an SDK and driver to si

In case someone with the same problems will find this thread:

I solved the issue with vJoy, pyVJoy and x360ce.

vJoy provides an SDK and driver to simulate input devices. You can have joysticks, gamepads etc.. PyvJoy allows you to access these drivers and simulate the input inside python. https://github.com/tidzo/pyvjoy pyvJoy uses values between 0 and 32767 for the "analog" sticks. For example, to get the left thumb-stick of an xbox controller in a neutral position you put the XAxis and YAxis in 1/2 of 32767.

So for me having input values between 0 and 1 I multiply them with this values. In my code it looks kinda like this:

MAX_VJOY = 32767 self.j = pyvjoy.VJoyDevice(1) def play_function(self,X,Y,Z,XRot): self.j.data.wAxisX = int(X * self.MAX_VJOY) self.j.data.wAxisY = int(Y * self.MAX_VJOY) self.j.data.wAxisZ = int(Z * self.MAX_VJOY) self.j.data.wAxisXRot = int(XRot * self.MAX_VJOY) j.update()

You can also update "binary"/"digital" buttons this way, the pyvjoy github page has a few more examples. Try using this Joystick app for calibration:

The final part is using X360CE, what is does is turn the vJoy "DigitalInput" Devide into a XInput device. So the PC/game thinks its an actual Xbox 360 or Xbox One Controller. This last part is only needed for some games that only allow official Xbox controllers, like GTA 5. You can get X360CE from here:

All this combined allows me to play those games through python. I learned that using WASD to train a neural network doesnt work too well because it always acts to extreme because it only allows 1 or 0 for the button presses. With these controls you can get smoother game controls.

(责任编辑:)
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 验证码:
发布者资料
查看详细资料 发送留言 加为好友 用户等级: 注册时间:2025-08-23 16:08 最后登录:2025-08-23 16:08
栏目列表
推荐内容