mirror of
https://github.com/ioacademy-jikim/device_driver.git
synced 2026-08-22 05:42:54 +00:00
first sample
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_CFLAGS := -fPIE
|
||||
LOCAL_LDFLAGS := -fPIE -pie
|
||||
LOCAL_MODULE := myapp
|
||||
LOCAL_SRC_FILES := input_app.c
|
||||
include $(BUILD_EXECUTABLE)
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
#if 1
|
||||
#include <stdio.h>
|
||||
#include <poll.h>
|
||||
#include <fcntl.h>
|
||||
#include <linux/input.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int i;
|
||||
int fd, ret;
|
||||
struct input_event events[64];
|
||||
fd = open( "/dev/input/event4", O_RDONLY );
|
||||
while (ret = read( fd, events, sizeof events ))
|
||||
{
|
||||
for( i=0 ; i<(ret/(int)sizeof(struct input_event)); i++ )
|
||||
printf("type=%d, code=%d, value=%d\n",
|
||||
events[i].type, events[i].code, events[i].value);
|
||||
}
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
#if 1
|
||||
#include <stdio.h>
|
||||
#include <poll.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int i;
|
||||
int fd, ret;
|
||||
int temp[64];
|
||||
fd = open( "/dev/mydev", O_RDONLY );
|
||||
while (ret = read( fd, temp, sizeof temp ))
|
||||
{
|
||||
for( i=0 ; i<(ret/(int)sizeof(int)); i++ )
|
||||
printf("temp[%d] = %d\n", i, temp[i] );
|
||||
}
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user