当前位置:   article > 正文

使用F1C200S从零制作掌机之USB游戏手柄_hid 游戏手柄 键值

hid 游戏手柄 键值

一、USB手柄

COIORVIS PC游戏手柄电脑USB FC模拟器经典游戏手柄 安卓手机有线连接单打格斗对打拳皇 经典有线手柄【黄色】

https://item.jd.com/10046453175183.html

image-20240702210549757

插入USB即可自动识别。

# [ 1425.447643] usb 1-1: USB disconnect, device number 7
[ 1427.072155] usb 1-1: new full-speed USB device number 8 using musb-hdrc
[ 1427.275819] usb 1-1: USB disconnect, device number 8
[ 1427.912164] usb 1-1: new full-speed USB device number 9 using musb-hdrc
[ 1428.129207] input:   Android Gamepad as /devices/platform/soc/1c13000.usb/musb-hdrc.1.auto/usb1/1-1/1-1:1.0/0003:0079:181C.0005/input/input7
[ 1428.170743] hid-generic 0003:0079:181C.0005: input: USB HID v1.10 Gamepad [  Android Gamepad] on usb-musb-hdrc.1.auto-1/input0
[ 1428.225910] input:   Android Gamepad System Control as /devices/platform/soc/1c13000.usb/musb-hdrc.1.auto/usb1/1-1/1-1:1.1/0003:0079:181C.0006/input/input8
[ 1428.333248] input:   Android Gamepad Consumer Control as /devices/platform/soc/1c13000.usb/musb-hdrc.1.auto/usb1/1-1/1-1:1.1/0003:0079:181C.0006/input/input9
[ 1428.377856] hid-generic 0003:0079:181C.0006: input: USB HID v1.01 Device [  Android Gamepad] on usb-musb-hdrc.1.auto-1/input1
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

测试

hexdump /dev/input/event1
# hexdump /dev/input/event1
0000000 05f5 0000 8046 000e 0003 0000 0080 0000
0000010 05f5 0000 8046 000e 0003 0001 0080 0000
0000020 05f5 0000 8046 000e 0003 0002 0080 0000
0000030 05f5 0000 8046 000e 0003 0005 0080 0000
0000040 05f5 0000 8046 000e 0000 0000 0000 0000
0000050 05f7 0000 5fb3 0009 0003 0010 0001 0000
0000060 05f7 0000 5fb3 0009 0000 0000 0000 0000
0000070 05f7 0000 d0a1 000b 0003 0010 0000 0000
0000080 05f7 0000 d0a1 000b 0000 0000 0000 0000
0000090 05f8 0000 bc1f 0004 0003 0010 0001 0000
00000a0 05f8 0000 bc1f 0004 0000 0000 0000 0000
00000b0 05f8 0000 ee99 0006 0003 0010 0000 0000
00000c0 05f8 0000 ee99 0006 0000 0000 0000 0000
00000d0 05f9 0000 1fdd 0004 0003 0010 0001 0000
00000e0 05f9 0000 1fdd 0004 0000 0000 0000 0000
00000f0 05f9 0000 f49c 0005 0003 0010 0000 0000
0000100 05f9 0000 f49c 0005 0000 0000 0000 0000
0000110 05fa 0000 ed65 0001 0003 0010 ffff ffff
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20

按键键值定义和对应关系,使用以下程序测试。

#include <stdio.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <linux/input.h> 
 
 
#define _EV_KEY         0x01    /* button pressed/released */
#define _EV_ABS         0x03    
#define _EV_MSC         0x04   
 
int main() {
    printf("hello, usb hid joystick key test\n");
    int fd = open("/dev/input/event1", O_RDONLY);
    struct input_event e;
    while(1) {
        read(fd, &e, sizeof(e));
        switch(e.type) {
            case _EV_KEY:
                printf("type: %d, code: %d,value: %d, time: %ld\n", e.type, e.code, e.value, e.time);
                break;
            case _EV_ABS:
                printf("type: %d, code: %d,value: %d, time: %ld\n", e.type, e.code, e.value, e.time);
                break;
            case _EV_MSC:
            	printf("type: %d, code: %d,value: %d, time: %ld\n", e.type, e.code, e.value, e.time);
            	break;
            default:
                if(e.type != 0){
                    printf("type:%d, code: %d,value: %d, time: %ld\n",e.type, e.code, e.value, e.time);
                }
        }
    }
    close(fd);
    return 0;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36

#define ABS_HAT0X 0x10

#define ABS_HAT0Y 0x11

https://blog.51cto.com/u_16213568/7903431

二、无线手柄

同USB手柄

三、参考

https://blog.csdn.net/yyz_1987/article/details/132063201

https://www.cnblogs.com/twzy/p/15243838.html

https://whycan.com/t_5139.html

https://blog.csdn.net/yyz_1987/article/details/132063201

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/木道寻08/article/detail/815331
推荐阅读
相关标签
  

闽ICP备14008679号