steam无法正确识别Python虚拟设备

2024-10-02 02:27:30 发布

您现在位置:Python中文网/ 问答频道 /正文

我正试图在Linux(特别是Manjaro)上创建一个虚拟操纵杆设备,用于steam游戏。我在这个项目中使用Python,并尝试了evdev和uinput库,结果是相同的:系统似乎可以识别设备(/dev/input/files正确创建,evdev和jscal都正确工作,等等),但steam不接受它作为有效的控制器。 这是我用来测试它的代码:

#!/bin/python

import uinput
import time

def main():
    events = (
        uinput.BTN_JOYSTICK,
        uinput.ABS_X + (0, 255, 0, 0),
        uinput.ABS_Y + (0, 255, 0, 0),
        )

    with uinput.Device(events) as device:
        for i in range(20):
            device.emit(uinput.ABS_X, 5, syn=False)
            device.emit(uinput.ABS_Y, 5)
            time.sleep(2)
        device.emit_click(uinput.BTN_JOYSTICK)

if __name__ == "__main__":
    main()

在控制台中运行steam,当连接物理控制器时,我得到以下输出:

Local Device Found
  type: 046d ca04
  path: sdl://0
  serial_number:  - 0
  Manufacturer: 
  Product:      dev:xb1:Logitech Logitech Racing Wheel
  Release:      110
  Interface:    -1

!! Steam controller device opened for index 0.
Steam Controller reserving XInput slot 0
Controller 0 connected, configuring it now...
Installing breakpad exception handler for appid(steam)/version(1576908998)
Controller has an Invalid or missing unit serial number, setting to '46d-ca04-655a04e'
!! Controller 0 attributes:
  Type: 32
  ProductID: 51716
  Serial: 46d-ca04-655a04e
  Capabilities: 0018414f
  Firmware Version: 0
  Firmware Build Time: 2147483647 (Tue, 19 Jan 2038 03:14:07 GMT)
  Bootloader Build Time: 2147483647 (Tue, 19 Jan 2038 03:14:07 GMT)

Opted-in Controller Mask for AppId 413080: f
Loaded Config for Local Selection Path for App ID 413080, Controller 0
[413080]Non-Steam Controller Configs Enabled: 1
!! Controller 0 attributes:
  Type: 32
  ProductID: 51716
  Serial: 46d-ca04-655a04e
  Capabilities: 0018414f
  Firmware Version: 0
  Firmware Build Time: 2147483647 (Tue, 19 Jan 2038 03:14:07 GMT)
  Bootloader Build Time: 2147483647 (Tue, 19 Jan 2038 03:14:07 GMT)
Fetching Config Sets 0

但是,当我创建虚拟设备时,我会得到以下输出:

Local Device Found
  type: 0001 0001
  path: sdl://2
  serial_number:  - 0
  Manufacturer: 
  Product:      python-uinput
  Release:      0
  Interface:    -1

Local Device Found
  type: 0001 0001
  path: sdl://2
  serial_number:  - 0
  Manufacturer: 
  Product:      python-uinput
  Release:      0
  Interface:    -1

因此steam似乎正确地检测到了该设备,但没有将其识别为有效的游戏控制器。我尝试更改设备的所有详细信息(名称、类型、产品等),以匹配现有的物理设备,但运气不佳。它确实为虚拟设备输出了两次“找到的本地设备”,而为物理设备只输出了一次,我不确定这是否相关,或者是什么原因造成的

提前谢谢


Tags: buildnumberfortimedevicelocalserialabs

热门问题