資源簡介
在linux下 將游戲手柄的按鍵 映射到 鍵盤 發(fā)送到系統(tǒng)消息中,
可以用游戲手柄玩本來只能鍵盤玩的游戲

代碼片段和文件信息
#include???
#include???
#include???
#include???
#include???
#include???
#include???
#include???
#include?
static?int?fd;
int?openjoy(const?char?*dev)
{
????printf(“open:%s\r\n“dev);
????fd?=?open(dev?O_RDONLY);
????if?(fd?0)????return?-1;
????return?fd;
}
int?readjoy(int?*keyint?*value)
{
????int?len;
????struct?js_event?js;
????len?=?read(fd?&js?sizeof(struct?js_event));
????if?(len?0)????return?-1;
????*key=js.type*10+js.number;
????*value=js.value;
????return?0;
}
void?closejoy(void)
{
????close(fd);
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????????113??2018-08-14?12:32??joy.h
?????文件????????2983??2018-08-14?12:25??main.c
?????文件?????????249??2018-08-14?12:33??makefile
?????文件????????1783??2018-08-14?12:31??vkey.c
?????文件?????????155??2018-08-14?12:29??vkey.h
?????文件?????????660??2018-08-14?12:31??joy.c
評論
共有 條評論