diff options
author | zheng_wenlong <wenlong_zheng@nexty-ele.com> | 2019-04-04 09:03:27 +0900 |
---|---|---|
committer | zheng_wenlong <wenlong_zheng@nexty-ele.com> | 2019-04-04 09:04:27 +0900 |
commit | c404f25dcaa4e622a0fe9179bc79393a468093d1 (patch) | |
tree | cb53edb66a21a4463cdea12082fbd5b77a057035 /src/js_raw.c | |
parent | 1fed2c5a38fed8bc91bb6b8a08982303eb9c2e82 (diff) |
Revert "Change steering to systemd service for ces2019"
This reverts commit 1fed2c5a38fed8bc91bb6b8a08982303eb9c2e82.
Change-Id: Id83b437eef556b8d3fcd95503b9ff5b4d94bc7a5
Signed-off-by: zheng_wenlong <wenlong_zheng@nexty-ele.com>
Diffstat (limited to 'src/js_raw.c')
-rw-r--r-- | src/js_raw.c | 77 |
1 files changed, 9 insertions, 68 deletions
diff --git a/src/js_raw.c b/src/js_raw.c index 9cdc168..5541162 100644 --- a/src/js_raw.c +++ b/src/js_raw.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2019 TOYOTA MOTOR CORPORATION + * Copyright (c) 2017 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. @@ -26,7 +26,7 @@ #include <linux/input.h> #include <linux/joystick.h> -#include "wheel-service.h" +#include "af-steering-wheel-binding.h" #include "js_raw.h" #include "js_signal_event.h" @@ -34,8 +34,6 @@ static int *axis; static char *button; -static timer_t tid; -static struct sigaction oldact; int js_signal_read(int fd) { @@ -46,22 +44,16 @@ int js_signal_read(int fd) size = read(fd, &jsEvent, sizeof(struct js_event)); if(size != 0) { - switch (jsEvent.type) //& ~JS_EVENT_INIT don't deal with init state. + switch (jsEvent.type & ~JS_EVENT_INIT) { - case JS_EVENT_BUTTON | JS_EVENT_INIT: - DBG_NOTICE("This is JS_EVENT_BUTTON init state [%d] : %d.", jsEvent.number, button[jsEvent.number]); - break; - case JS_EVENT_AXIS | JS_EVENT_INIT: - DBG_NOTICE("This is JS_EVENT_AXIS init state [%d] : %d.", jsEvent.number, axis[jsEvent.number]); - break; case JS_EVENT_BUTTON: button[jsEvent.number] = (char)jsEvent.value; - DBG_NOTICE("JS_EVENT_BUTTON [%d] : %d.", jsEvent.number, button[jsEvent.number]); + //NOTICEMSG("JS_EVENT_BUTTON %d\n", button[jsEvent.number]); newButtonValue(jsEvent.number, jsEvent.value); break; case JS_EVENT_AXIS: axis[jsEvent.number] = jsEvent.value; - DBG_NOTICE("JS_EVENT_AXIS [%d] : %d.", jsEvent.number, axis[jsEvent.number]); + //NOTICEMSG("JS_EVENT_AXIS %d\n", axis[jsEvent.number]); newAxisValue(jsEvent.number, jsEvent.value); break; default: @@ -88,7 +80,7 @@ int on_event(sd_event_source *s, int fd, uint32_t revents, void *userdata) rc = js_signal_read(fd); if(rc == -1) { - DBG_ERROR("JS Frame Read failed"); + ERRMSG("JS Frame Read failed"); return -1; } @@ -97,20 +89,19 @@ int on_event(sd_event_source *s, int fd, uint32_t revents, void *userdata) { /* T.B.D * if error or hungup */ - DBG_ERROR("Error or Hunup: rvent=%08x", revents); + ERRMSG("Error or Hunup: rvent=%08x", revents); } return 0; } -int js_open(const char *devname) +int js_open(const char *devname) { unsigned char numAxes = 0; unsigned char numButtons = 0; int version = 0; int fd; char name[JSNAMELEN] = "Unknown"; - char steering_name[JSNAMELEN] = "Logitech G29 Driving Force Racing Wheel"; struct js_corr cal[6]; int i, j; @@ -134,17 +125,6 @@ int js_open(const char *devname) ioctl(fd, JSIOCGBUTTONS, &numButtons); ioctl(fd, JSIOCGNAME(JSNAMELEN), name); - if (strcmp(name, steering_name) == 0) - { - setJsType(JS_TYPE_STEERING); - DBG_NOTICE("JS_TYPE_STEERING type!"); - } - else - { - setJsType(JS_TYPE_GAME_CTL); - DBG_NOTICE("JS_TYPE_GAME_CTL type!"); - } - for (i = 0; i < 6; i++) { int k = 0; @@ -171,7 +151,7 @@ int js_open(const char *devname) gis = g_unix_input_stream_new(fd, TRUE); if(gis == NULL) { - DBG_ERROR("g_unix_input_stream_new() failed!"); + ERRMSG("g_unix_input_stream_new() failed!"); } else { @@ -192,42 +172,3 @@ void js_close(int js) close(js); } - -int init_timer() -{ - struct sigaction act; - struct itimerspec itval; - - memset(&act, 0, sizeof(struct sigaction)); - memset(&oldact, 0, sizeof(struct sigaction)); - - act.sa_handler = updateTimerHandler; - act.sa_flags = SA_RESTART; - if(sigaction(SIGALRM, &act, &oldact) < 0) { - DBG_ERROR("sigaction failed."); - return -1; - } - - itval.it_value.tv_sec = 0; - itval.it_value.tv_nsec = 200000000; - itval.it_interval.tv_sec = 0; - itval.it_interval.tv_nsec = 200000000; - - if(timer_create(CLOCK_REALTIME, NULL, &tid) < 0) { - DBG_ERROR("timer_create failed."); - return -1; - } - - if(timer_settime(tid, 0, &itval, NULL) < 0) { - DBG_ERROR("timer_settime failed."); - return -1; - } - - return 0; -} - -void deinit_timer() -{ - timer_delete(tid); - sigaction(SIGALRM, &oldact, NULL); -}
\ No newline at end of file |