1
## Description: add some description
2
## Origin/Author: add some origin or author
4
Index: lirc/daemons/hw_hiddev.c
5
===================================================================
6
--- lirc.orig/daemons/hw_hiddev.c 2010-03-27 23:49:25.207227120 -0500
7
+++ lirc/daemons/hw_hiddev.c 2010-03-27 23:49:21.755255839 -0500
9
static unsigned int pre_code;
10
static signed int main_code = 0;
12
-static int repeat_flag = 0;
13
+static struct timeval start,end,last;
22
+static int repeat_state = RPT_UNKNOWN;
24
/* Remotec Mediamaster specific */
25
struct hardware hw_bw6130=
28
LOGPRINTF(1, "lirc code: 0x%X", *codep);
30
- *repeat_flagp = repeat_flag;
31
- *min_remaining_gapp = 0;
32
- *max_remaining_gapp = 0;
33
+ map_gap(remote, &start, &last, 0, repeat_flagp,
34
+ min_remaining_gapp, max_remaining_gapp);
35
+ /* override repeat */
36
+ switch( repeat_state )
53
LOGPRINTF(1, "hiddev_rec");
57
+ gettimeofday(&start,NULL);
58
rd = read(hw.fd, &event, sizeof event);
59
if (rd != sizeof event) {
60
logprintf(LOG_ERR, "error reading '%s'", hw.device);
63
main_code = event.value;
65
+ gettimeofday(&end,NULL);
67
if (event.hid == 0x10046) {
69
- repeat_flag = (main_code & dvico_repeat_mask);
70
+ repeat_state = (main_code & dvico_repeat_mask) ? RPT_YES : RPT_NO;
71
main_code = (main_code & ~dvico_repeat_mask);
73
gettimeofday (&now, NULL);
75
/* previous valid code because it is likely that they are */
79
+ if(repeat_state == RPT_YES)
81
if(time_elapsed(&time_of_last_code, &now) > 500000)
85
time_of_last_code = now;
87
- LOGPRINTF(1, "main 0x%X repeat flag 0x%X", main_code, repeat_flag);
88
+ LOGPRINTF(1, "main 0x%X repeat state 0x%X", main_code, repeat_state);
89
return decode_all(remotes);
91
/* the following code could be used to recreate the
93
pre = event.value&0xff;
94
pre_code = reverse(~pre, 8)<<8 | reverse(pre, 8);
96
- repeat_flag = (event.value & dvico_repeat_mask);
97
+ repeat_state = (event.value & dvico_repeat_mask) ? RPT_YES : RPT_NO;
99
main = (event.value&0x7f00) >> 8;
100
main_code = reverse(main, 8)<<8 | reverse(~main, 8);
102
(event.value != 0xFFFFFFFF) &&
103
(event.value != 0xFFFFFFAA))
105
- if (old_main_code == main_code) repeat_flag = 1;
106
+ if (old_main_code == main_code) repeat_state = RPT_YES;
107
old_main_code = main_code;
108
if (main_code==0x40) { /* the mousedial has been touched */
111
return decode_all(remotes);
113
else if ((event.hid == 0xFFA10003) && (event.value == 0xFFFFFFAA)) {
115
+ repeat_state = RPT_NO;
120
pre_code_length = 16;
121
main_code_length = 16;
124
+ repeat_state = RPT_NO;
127
+ gettimeofday(&start,NULL);
129
rd = read(hw.fd, &uref, sizeof(uref));
135
+ gettimeofday(&end,NULL);
137
if (uref.field_index == HID_FIELD_INDEX_NONE) {
139
* we get this when the new report has been send from
142
LOGPRINTF(1, "macmini_rec");
145
+ gettimeofday(&start,NULL);
148
if(i>0 && !waitfordata(TIMEOUT))
149
@@ -563,18 +593,18 @@
153
+ gettimeofday(&end,NULL);
155
- gettimeofday (&now, NULL);
156
/* Record the code */
159
main_code = (ev[0].value << 24) + (ev[1].value << 16) +
160
(ev[2].value << 8) + (ev[3].value << 0);
162
+ repeat_state = RPT_UNKNOWN;
165
/* some variants seem to send 0 to indicate repeats */
166
- if(time_elapsed(&time_of_last_code, &now) > 500000)
167
+ if(time_elapsed(&time_of_last_code, &end) > 500000)
169
/* but some send 0 if they receive codes from
170
a different remote, so only send repeats if
171
@@ -582,13 +612,10 @@
174
main_code = old_main_code;
176
- if (old_main_code == main_code)
179
+ repeat_state = RPT_YES;
181
old_main_code = main_code;
182
- time_of_last_code = now;
183
+ time_of_last_code = end;
185
return decode_all(remotes);
189
main_code_length = 32;
192
+ repeat_state = RPT_NO;
195
+ gettimeofday(&start,NULL);
196
rd = read(hw.fd, &uref, sizeof(uref));
198
logprintf(LOG_ERR, "error reading '%s'", hw.device);
203
+ gettimeofday(&end,NULL);
205
if (uref.field_index == HID_FIELD_INDEX_NONE) {