Ubuntu 16.04环境中读取XBOX 360手柄信息
2021/5/2 7:29:34
本文主要是介绍Ubuntu 16.04环境中读取XBOX 360手柄信息,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
目录- 获取设备的端口
- 读取设备数据
- 查看端口号:
- 查看端口输出
- 参考
获取设备的端口
在插入设备时,在/dev/input目录下 ,操作系统会为每一个设备分配event号,先插上的为event0,后插上的为event1。
查找设备的设备号用如下指令:
cat /proc/bus/input/devices
获得如下输出
I: Bus=0003 Vendor=80ee Product=0021 Version=0110 N: Name="VirtualBox USB Tablet" P: Phys=usb-0000:00:06.0-1/input0 S: Sysfs=/devices/pci0000:00/0000:00:06.0/usb1/1-1/1-1:1.0/0003:80EE:0021.0001/input/input6 U: Uniq= H: Handlers=mouse1 event5 js0 B: PROP=0 B: EV=1f B: KEY=1f0000 0 0 0 0 B: REL=1940 B: ABS=3 B: MSC=10 I: Bus=0001 Vendor=80ee Product=cafe Version=0601 N: Name="VirtualBox mouse integration" P: Phys= S: Sysfs=/devices/pci0000:00/0000:00:04.0/input/input7 U: Uniq= H: Handlers=event6 js1 B: PROP=0 B: EV=b B: KEY=10000 0 0 0 0 B: ABS=3 I: Bus=0003 Vendor=045e Product=028e Version=0110 N: Name="Microsoft X-Box 360 pad" P: Phys=usb-0000:00:06.0-2/input0 S: Sysfs=/devices/pci0000:00/0000:00:06.0/usb1/1-2/1-2:1.0/input/input8 U: Uniq= H: Handlers=event7 js2 B: PROP=0 B: EV=20000b B: KEY=7cdb000000000000 0 0 0 0 B: ABS=3003f B: FF=107030000 0
在端口处找到设备名字“Microsoft X-Box 360 pad”,event7/js2是手柄的设备号。
如果找不到,可能是手柄中的版本不对,根据产品说明书需要由X-input转换到D-input模式。(长按home键3秒)X -input适用于XBOX360移植到PC上的即插即玩的游戏,D-input适用于早期单机游戏如极品飞车1-12等。
读取设备数据
查看端口号:
ls /dev/input
查看端口输出
cat /dev/input/js2 | hexdump
或者
cat /dev/input/enent7 | hexdump
得到一些16进制的数字,当手柄按下的时候会有数字变化
ke@ubnt20:/dev/input$ ls /dev/input/ by-id event0 event2 event4 event6 js0 js2 mouse0 by-path event1 event3 event5 event7 js1 mice mouse1 ke@ubnt20:/dev/input$ cat /dev/input/js2 | hexdump 0000000 c6d8 0003 0000 0081 c6d8 0003 0000 0181 0000010 c6d8 0003 0000 0281 c6d8 0003 0000 0381 0000020 c6d8 0003 0000 0481 c6d8 0003 0000 0581 0000030 c6d8 0003 0000 0681 c6d8 0003 0000 0781 0000040 c6d8 0003 0000 0881 c6d8 0003 0000 0981 0000050 c6d8 0003 0000 0a81 c6d8 0003 0000 0082 0000060 c6d8 0003 0000 0182 c6d8 0003 8001 0282 0000070 c6d8 0003 0000 0382 c6d8 0003 0000 0482 0000080 c6d8 0003 8001 0582 c6d8 0003 0000 0682 0000090 c6d8 0003 0000 0782 d274 0003 0001 0501 00000a0 d2e4 0003 0000 0501 d5c0 0003 8efa 0102 00000b0 d5e8 0003 8001 0102 d718 0003 0000 0102 00000c0 d820 0003 8001 0102 d8c4 0003 0000 0102 00000d0 d960 0003 7fff 0002 da4c 0003 0000 0002 00000e0 dbe4 0003 7fff 0602 dce4 0003 0000 0602 00000f0 ddb8 0003 7fff 0602 de90 0003 0000 0602 0000100 df84 0003 8001 0602 e034 0003 0000 0602 0000110 ead0 0003 8001 0602 ebb4 0003 0000 0602 0000120 ec64 0003 7fff 0702 ec9c 0003 7fff 0602 0000130 ecc4 0003 0000 0702 ed68 0003 0000 0602 0000140 f0c0 0003 8001 0602 f1b8 0003 0000 0602 0000150 f258 0003 7fff 0602 f364 0003 0000 0602 0000160 f3f4 0003 8001 0602 f504 0003 0000 0602 0000170 f568 0003 7fff 0602 f684 0003 0000 0602 0000180 f958 0003 7fff 0602 fa44 0003 0000 0602 0000190 fa5c 0003 8001 0702 fa70 0003 8001 0602 00001a0 fa80 0003 0000 0702 fb9c 0003 0000 0602 00001b0 fdf8 0003 7fff 0702 fee0 0003 0000 0702 00001c0 ffbc 0003 8001 0702 0094 0004 0000 0702 00001d0 0178 0004 7fff 0602 0278 0004 0000 0602 00001e0 02e0 0004 8001 0602 03d4 0004 0000 0602 00001f0 0444 0004 7fff 0702 0490 0004 0000 0702
参考
Ubuntu16.04环境下读取USB手柄/方向盘信息
这篇关于Ubuntu 16.04环境中读取XBOX 360手柄信息的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-07-02springboot项目无法注册到nacos-icode9专业技术文章分享
- 2024-06-26结对编程到底难不难?答案在这里
- 2024-06-19《2023版Java工程师》课程升级公告
- 2024-06-15matplotlib作图不显示3D图,怎么办?
- 2024-06-1503-Loki 日志监控
- 2024-06-1504-让LLM理解知识 -Prompt
- 2024-06-05做软件测试需要懂代码吗?
- 2024-06-0514-ShardingSphere的分布式主键实现
- 2024-06-03为什么以及如何要进行架构设计权衡?
- 2024-05-31全网首发第二弹!软考2024年5月《软件设计师》真题+解析+答案!(11-20题)