/* * Copyright (c) 2019 TOYOTA MOTOR CORPORATION * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include #include #include #include #include #include #include static int eventFd = -1; static FILE* pfile; struct input_event ev0[64]; static int screenWidth = 0; static int screenHeight = 0; extern char* getTouchScreenInfo(); static int handle_event() { int i, rd; char str[256]; float x = 0, y = 0; rd = read(eventFd, ev0, sizeof(struct input_event)* 64); if(rd < sizeof(struct input_event)) return 0; for(i=0;i\n \ -f : file name for recording event\n", myName); } int main(int argc,char *argv[]) { int done = 1; int index = 0; char* fName = NULL; char eventNode[50]; const char* tsInfo; if (argc < 3) { printUsage(argv[0]); return -1; } for (index = 1; index < argc; index++) { if (strcmp(argv[index], "-f") == 0) { fName = argv[++index]; } else { printUsage(argv[0]); return -1; } } tsInfo = getTouchScreenInfo(); if (NULL == tsInfo) { printf("Failed to get touch screen info.\n"); return -1; } memset(eventNode, 0, sizeof(eventNode)); sscanf(tsInfo, "%s %d %d", eventNode, &screenWidth, &screenHeight); eventFd = open(eventNode, O_RDWR); if(eventFd <0) { printf("open input device error\n"); return -1; } pfile = fopen(fName, "wb+"); if(pfile == NULL) { printf("Failed to create file!\n"); return -1; } while (done) { printf("begin %s...\n", eventNode); done = handle_event(); printf("end %s...\n", eventNode); } fclose(pfile); if(eventFd > 0) { close(eventFd); eventFd = -1; } return 0; }