1 /*************************************************************************** 2 * 3 * Copyright (c) 2015 Advanced Driver Information Technology. 4 * This code is developed by Advanced Driver Information Technology. 5 * Copyright of Advanced Driver Information Technology, Bosch, and DENSO. 6 * All rights reserved. 7 * 8 * 9 * Licensed under the Apache License, Version 2.0 (the "License"); 10 * you may not use this file except in compliance with the License. 11 * You may obtain a copy of the License at 12 * 13 * http://www.apache.org/licenses/LICENSE-2.0 14 * 15 * Unless required by applicable law or agreed to in writing, software 16 * distributed under the License is distributed on an "AS IS" BASIS, 17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 * See the License for the specific language governing permissions and 19 * limitations under the License. 20 * 21 ****************************************************************************/ 22 #ifndef UTIL_H 23 #define UTIL_H 24 25 #include <stdint.h> 26 27 /* Log Macro */ 28 #ifndef LOG_ERROR 29 #define LOG_ERROR(...) { \ 30 fprintf(stderr, "ERROR : " __VA_ARGS__); \ 31 } 32 #endif 33 34 #ifndef LOG_INFO 35 #define LOG_INFO(...) { \ 36 fprintf(stderr, "INFO : " __VA_ARGS__); \ 37 } 38 #endif 39 40 #ifndef LOG_WARNING 41 #define LOG_WARNING(...) { \ 42 fprintf(stderr, "WARN : " __VA_ARGS__); \ 43 } 44 #endif 45 46 enum 47 { 48 TOUCH_DOWN = (1 << 0), 49 TOUCH_MOTION = (1 << 1), 50 TOUCH_UP = (1 << 2), 51 TOUCH_FRAME = (1 << 3), 52 TOUCH_CANCEL = (1 << 4) 53 }; 54 55 struct event_log 56 { 57 uint32_t event; 58 int32_t id; 59 float x; 60 float y; 61 uint32_t time; 62 char dmy[4]; 63 }; 64 65 struct event_log_array 66 { 67 size_t n_log; 68 size_t n_alloc; 69 struct event_log *p_logs; 70 }; 71 72 void* allocate(uint32_t alloc_size, int clear); 73 void log_array_init(struct event_log_array *p_array, int n_alloc); 74 void log_array_release(struct event_log_array *p_array); 75 void log_array_add(struct event_log_array *p_array, struct event_log *p_log); 76 77 #endif /* UTIL_H */ 78