📄 2410_keyboard.c
字号:
/*** $Id: 2410.c,v 1.6 2004/04/01 08:57:13 weiym Exp $**** 2410.c: Low Level Input Engine for SMDK2410 Dev Board.** ** Copyright (C) 2003 Feynman Software.*//*** This program is free software; you can redistribute it and/or modify** it under the terms of the GNU General Public License as published by** the Free Software Foundation; either version 2 of the License, or** (at your option) any later version.**** This program is distributed in the hope that it will be useful,** but WITHOUT ANY WARRANTY; without even the implied warranty of** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the** GNU General Public License for more details.**** You should have received a copy of the GNU General Public License** along with this program; if not, write to the Free Software** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA*/#include <stdio.h>#include <stdlib.h>#include <string.h>#include "common.h"#ifdef _SMDK2410_IAL#include <unistd.h>#include <fcntl.h>#include <sys/ioctl.h>#include <sys/poll.h>#include <sys/types.h>#include <sys/stat.h>#include <linux/kd.h>#define KBD_DEVICE "/dev/input/tty0"#include "ial.h"#include "2410.h"/* for data reading from /dev/ts *//*typedef struct { unsigned char pressure; signed char x; signed char y;} TS_EVENT;*/typedef unsigned char TS_EVENT;static int ts = -1;static TS_EVENT ts_event;#undef _DEBUG/************************ Low Level Input Operations **********************/#ifdef _LITE_VERSION static int wait_event (int which, int maxfd, fd_set *in, fd_set *out, fd_set *except, struct timeval *timeout)#elsestatic int wait_event (int which, fd_set *in, fd_set *out, fd_set *except, struct timeval *timeout)#endif{ fd_set rfds; int retvalue = 0; int e; if (!in) { in = &rfds; FD_ZERO (in); } if ((which & IAL_KEYEVENT) && ts >= 0){ FD_SET (ts, in);#ifdef _LITE_VERSION if(ts > maxfd) maxfd = ts;#endif }#ifdef _LITE_VERSION e = select (maxfd + 1, in, out, except, timeout) ;#else e = select (FD_SETSIZE, in, out, except, timeout) ;#endif if (e > 0) { if (ts >= 0 && FD_ISSET (ts, in)) { int rs; FD_CLR (ts, in); printf ("begin to read\n"); rs = read (ts, &ts_event, sizeof (TS_EVENT)); printf ("get char is %c\n", ts_event); retvalue |= IAL_KEYEVENT; } } else if (e < 0) { return -1; } return retvalue;}BOOL Init2410Input (INPUT* input, const char* mdev, const char* mtype){ /* mdev should be /dev/ts */ mdev="/dev/input/keybdev0"; ts = open (mdev, O_RDONLY); if (ts < 0) { printf ("2410: Can not open keydev: %s!\n", mdev); return FALSE; } printf ("In 2410 engine\n"); input->wait_event = wait_event; return TRUE;}void Term2410Input(void) { if (ts >= 0) close(ts); }#endif /* _SMDK2410_IAL */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -