Andrew Geissler | 4fc9e43 | 2020-06-27 00:13:56 -0500 | [diff] [blame] | 1 | diff -ruN lirc-0.10.1.orig/lib/config_file.c lirc-0.10.1/lib/config_file.c |
| 2 | --- lirc-0.10.1.orig/lib/config_file.c 2017-09-10 17:52:19.000000000 +0900 |
| 3 | +++ lirc-0.10.1/lib/config_file.c 2019-06-26 00:39:45.734320696 +0900 |
| 4 | @@ -71,7 +71,7 @@ |
| 5 | typedef void* (*array_guest_func)(void* item, void* arg); |
| 6 | |
| 7 | |
| 8 | -#define LINE_LEN 1024 |
| 9 | +#define LINE_LEN 4096 |
| 10 | #define MAX_INCLUDES 10 |
| 11 | |
| 12 | const char* whitespace = " \t"; |
| 13 | diff -ruN lirc-0.10.1.orig/lib/ir_remote.h lirc-0.10.1/lib/ir_remote.h |
| 14 | --- lirc-0.10.1.orig/lib/ir_remote.h 2017-09-10 17:52:19.000000000 +0900 |
| 15 | +++ lirc-0.10.1/lib/ir_remote.h 2019-06-26 00:39:45.714321224 +0900 |
| 16 | @@ -110,12 +110,17 @@ |
| 17 | |
| 18 | static inline int is_pulse(lirc_t data) |
| 19 | { |
| 20 | - return data & PULSE_BIT ? 1 : 0; |
| 21 | + return ((data & LIRC_MODE2_MASK)==LIRC_MODE2_PULSE) ? 1 : 0; |
| 22 | } |
| 23 | |
| 24 | static inline int is_space(lirc_t data) |
| 25 | { |
| 26 | - return !is_pulse(data); |
| 27 | + return ((data & LIRC_MODE2_MASK)==LIRC_MODE2_SPACE) ? 1 : 0; |
| 28 | +} |
| 29 | + |
| 30 | +static inline int is_timeout(lirc_t data) |
| 31 | +{ |
| 32 | + return ((data & LIRC_MODE2_MASK)==LIRC_MODE2_TIMEOUT) ? 1 : 0; |
| 33 | } |
| 34 | |
| 35 | static inline int has_repeat(const struct ir_remote* remote) |
| 36 | diff -ruN lirc-0.10.1.orig/lib/irrecord.c lirc-0.10.1/lib/irrecord.c |
| 37 | --- lirc-0.10.1.orig/lib/irrecord.c 2017-09-10 17:52:19.000000000 +0900 |
| 38 | +++ lirc-0.10.1/lib/irrecord.c 2019-06-26 00:39:45.724320960 +0900 |
| 39 | @@ -1398,9 +1398,16 @@ |
| 40 | state->retval = 0; |
| 41 | return STS_LEN_TIMEOUT; |
| 42 | } |
| 43 | + if (is_timeout(state->data)) { |
| 44 | + return STS_LEN_AGAIN; |
| 45 | + } |
| 46 | state->count++; |
| 47 | if (state->mode == MODE_GET_GAP) { |
| 48 | - state->sum += state->data & PULSE_MASK; |
| 49 | + if (state->sum != 0 || is_pulse(state->data)) { |
| 50 | + state->sum += state->data & PULSE_MASK; |
| 51 | + }else{ |
| 52 | + return STS_LEN_AGAIN; |
| 53 | + } |
| 54 | if (state->average == 0 && is_space(state->data)) { |
| 55 | if (state->data > 100000) { |
| 56 | state->sum = 0; |
| 57 | @@ -1472,6 +1479,10 @@ |
| 58 | state->keypresses = lastmaxcount; |
| 59 | return STS_LEN_AGAIN; |
| 60 | } else if (state->mode == MODE_HAVE_GAP) { |
| 61 | + if (state->count==1 && is_space(state->data)) { |
| 62 | + state->count = 0; |
| 63 | + return STS_LEN_AGAIN; |
| 64 | + } |
| 65 | if (state->count <= MAX_SIGNALS) { |
| 66 | signals[state->count - 1] = state->data & PULSE_MASK; |
| 67 | } else { |
| 68 | @@ -1510,7 +1521,7 @@ |
| 69 | /* such long pulses may appear with |
| 70 | * crappy hardware (receiver? / remote?) |
| 71 | */ |
| 72 | - else { |
| 73 | + else if(is_pulse(state->data)) { |
| 74 | remote->gap = 0; |
| 75 | return STS_LEN_NO_GAP_FOUND; |
| 76 | } |
| 77 | @@ -1811,22 +1822,24 @@ |
| 78 | |
| 79 | static int raw_data_ok(struct button_state* btn_state) |
| 80 | { |
| 81 | - int r; |
| 82 | + int r = 0; |
| 83 | int ref; |
| 84 | |
| 85 | - if (!is_space(btn_state->data)) { |
| 86 | + if (is_pulse(btn_state->data)) { |
| 87 | r = 0; |
| 88 | - } else if (is_const(&remote)) { |
| 89 | - if (remote.gap > btn_state->sum) { |
| 90 | - ref = (remote.gap - btn_state->sum); |
| 91 | - ref *= (100 - remote.eps); |
| 92 | - ref /= 100; |
| 93 | + } else if (is_space(btn_state->data)) { |
| 94 | + if (is_const(&remote)) { |
| 95 | + if (remote.gap > btn_state->sum) { |
| 96 | + ref = (remote.gap - btn_state->sum); |
| 97 | + ref *= (100 - remote.eps); |
| 98 | + ref /= 100; |
| 99 | + } else { |
| 100 | + ref = 0; |
| 101 | + } |
| 102 | + r = btn_state->data > ref; |
| 103 | } else { |
| 104 | - ref = 0; |
| 105 | + r = btn_state->data > (remote.gap * (100 - remote.eps)) / 100; |
| 106 | } |
| 107 | - r = btn_state->data > ref; |
| 108 | - } else { |
| 109 | - r = btn_state->data > (remote.gap * (100 - remote.eps)) / 100; |
| 110 | } |
| 111 | return r; |
| 112 | } |
| 113 | @@ -1970,7 +1983,7 @@ |
| 114 | btn_state->data = remote.gap; |
| 115 | } |
| 116 | if (btn_state->count == 0) { |
| 117 | - if (!is_space(btn_state->data) |
| 118 | + if (is_pulse(btn_state->data) |
| 119 | || btn_state->data < |
| 120 | remote.gap - remote.gap * remote.eps / |
| 121 | 100) { |
| 122 | diff -ruN lirc-0.10.1.orig/lib/lirc/ir_remote.h lirc-0.10.1/lib/lirc/ir_remote.h |
| 123 | --- lirc-0.10.1.orig/lib/lirc/ir_remote.h 2017-09-10 17:52:58.000000000 +0900 |
| 124 | +++ lirc-0.10.1/lib/lirc/ir_remote.h 2019-06-26 00:39:45.724320960 +0900 |
| 125 | @@ -110,12 +110,17 @@ |
| 126 | |
| 127 | static inline int is_pulse(lirc_t data) |
| 128 | { |
| 129 | - return data & PULSE_BIT ? 1 : 0; |
| 130 | + return ((data & LIRC_MODE2_MASK)==LIRC_MODE2_PULSE) ? 1 : 0; |
| 131 | } |
| 132 | |
| 133 | static inline int is_space(lirc_t data) |
| 134 | { |
| 135 | - return !is_pulse(data); |
| 136 | + return ((data & LIRC_MODE2_MASK)==LIRC_MODE2_SPACE) ? 1 : 0; |
| 137 | +} |
| 138 | + |
| 139 | +static inline int is_timeout(lirc_t data) |
| 140 | +{ |
| 141 | + return ((data & LIRC_MODE2_MASK)==LIRC_MODE2_TIMEOUT) ? 1 : 0; |
| 142 | } |
| 143 | |
| 144 | static inline int has_repeat(const struct ir_remote* remote) |
| 145 | diff -ruN lirc-0.10.1.orig/tools/mode2.cpp lirc-0.10.1/tools/mode2.cpp |
| 146 | --- lirc-0.10.1.orig/tools/mode2.cpp 2017-09-10 17:52:19.000000000 +0900 |
| 147 | +++ lirc-0.10.1/tools/mode2.cpp 2019-06-26 00:45:38.840404976 +0900 |
| 148 | @@ -326,12 +326,24 @@ |
| 149 | void print_mode2_data(unsigned int data) |
| 150 | { |
| 151 | static int bitno = 1; |
| 152 | + static bool leading_space = true; |
| 153 | + unsigned int msg = data & LIRC_MODE2_MASK; |
| 154 | |
| 155 | switch (opt_dmode) { |
| 156 | case 0: |
| 157 | - printf("%s %u\n", ( |
| 158 | - data & PULSE_BIT) ? "pulse" : "space", |
| 159 | - (uint32_t)(data & PULSE_MASK)); |
| 160 | + if (leading_space && msg == LIRC_MODE2_SPACE ) { |
| 161 | + break; |
| 162 | + } else { |
| 163 | + leading_space = false; |
| 164 | + } |
| 165 | + if (msg == LIRC_MODE2_PULSE) { |
| 166 | + printf("pulse %u\n", (__u32)(data & PULSE_MASK)); |
| 167 | + } else if (msg == LIRC_MODE2_SPACE) { |
| 168 | + printf("space %u\n", (__u32)(data & PULSE_MASK)); |
| 169 | + } else if (msg == LIRC_MODE2_TIMEOUT) { |
| 170 | + printf("timeout %u\n", (__u32)(data & PULSE_MASK)); |
| 171 | + leading_space = true; |
| 172 | + } |
| 173 | break; |
| 174 | case 1: { |
| 175 | /* print output like irrecord raw config file data */ |