从/ dev / input获取实时信息 [英] Getting live info from /dev/input

查看:91
本文介绍了从/ dev / input获取实时信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不确定这是否是这个问题的正确地方。我正在尝试从系统上的操纵杆 / dev / input / js0 获取轴位置值。如果我运行 jstest / dev / input / js0 ,它将为我提供所有按钮和轴位置的实时反馈。

I am unsure if this is the correct place for this question. I am attempting to obtain the axis position values from a joystick /dev/input/js0 on my system. If I run jstest /dev/input/js0 it will give me live feedback on all buttons and axis positions.

我正在尝试将此信息输入到我的C程序中以控制伺服器。有这样做的功能吗?我在编程中没有对输入设备进行太多的工作,所以这对我来说是全新的。

I am trying to feed this information into my C program to control servos. Is there a function for doing this? I have not worked much with input devices in programming so this is all new to me.

推荐答案

此页: http://scaryreasoner.wordpress.com/2008/02/22/programming-joysticks-with-linux/ 有一个很好的关于如何阅读的文章/ dev / input / js0

This page: http://scaryreasoner.wordpress.com/2008/02/22/programming-joysticks-with-linux/ has a nice writeup on how to read the info from /dev/input/js0

从文件中读取的事件的格式记录在此处: https://www.kernel.org/doc/Documentation/input/input.txt 。这是一个简单的结构,其中包含时间戳,事件类型和标识符以及值:

The format of the events you read from the file are documented here: https://www.kernel.org/doc/Documentation/input/input.txt . It's a simple struct containing a timestamp, the event type and identifier and the value:

struct input_event {
    struct timeval time;
    unsigned short type;
    unsigned short code;
    unsigned int value;
};

这篇关于从/ dev / input获取实时信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆