summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2017-05-30 11:05:00 +0200
committerKlaus Schmidinger <vdr@tvdr.de>2017-05-30 11:05:00 +0200
commit6edfcda43a365cfd94ed6649d66a0adcbb965480 (patch)
treef96eb4bb4160f1c126efaf07da6554ee005aa653
parentc9c15a727d7fe1b2bea360ec1126cd1dc2d8e4cd (diff)
downloadvdr-6edfcda43a365cfd94ed6649d66a0adcbb965480.tar.gz
vdr-6edfcda43a365cfd94ed6649d66a0adcbb965480.tar.bz2
Fixed generating k_Release key events for LIRC remote controls
-rw-r--r--HISTORY5
-rw-r--r--lirc.c21
2 files changed, 12 insertions, 14 deletions
diff --git a/HISTORY b/HISTORY
index 97c5986c..8ea3ebfc 100644
--- a/HISTORY
+++ b/HISTORY
@@ -9056,7 +9056,7 @@ Video Disk Recorder Revision History
- Fixed detecting the inclusion of STL header files in tools.h (thanks to Jasmin
Jessich).
-2017-05-29: Version 2.3.6
+2017-05-30: Version 2.3.6
- Added debug output for checking the correct sequence of locking global lists
(with help and suggestions from Jasmin Jessich). To activate this, define the
@@ -9081,3 +9081,6 @@ Video Disk Recorder Revision History
- Added clearing CiResourceHandlers before shutting down the plugin manager.
- Fixed a double channel switch when pressing the Channel+/- keys while no menu
or channel display is open.
+- Fixed generating k_Release key events for LIRC remote controls (due to the short
+ timeout another normal key was sometimes put into the queue after the generated
+ release). Also removed some code redundancy and added some buffer checks.
diff --git a/lirc.c b/lirc.c
index 2b0c07b1..d02ae11e 100644
--- a/lirc.c
+++ b/lirc.c
@@ -6,7 +6,7 @@
*
* LIRC support added by Carsten Koch <Carsten.Koch@icem.de> 2000-06-16.
*
- * $Id: lirc.c 3.2 2013/10/29 12:32:12 kls Exp $
+ * $Id: lirc.c 4.1 2017/05/30 11:02:17 kls Exp $
*/
#include "lirc.h"
@@ -20,7 +20,7 @@ cLircRemote::cLircRemote(const char *DeviceName)
,cThread("LIRC remote control")
{
addr.sun_family = AF_UNIX;
- strcpy(addr.sun_path, DeviceName);
+ strn0cpy(addr.sun_path, DeviceName, sizeof(addr.sun_path));
if (!Connect())
f = -1;
Start();
@@ -94,12 +94,12 @@ void cLircRemote::Action(void)
}
int Delta = ThisTime.Elapsed(); // the time between two subsequent LIRC events
ThisTime.Set();
- if (count == 0) {
+ if (count == 0) { // new key pressed
if (strcmp(KeyName, LastKeyName) == 0 && FirstTime.Elapsed() < (uint)Setup.RcRepeatDelay)
continue; // skip keys coming in too fast
if (repeat)
- Put(LastKeyName, false, true);
- strcpy(LastKeyName, KeyName);
+ Put(LastKeyName, false, true); // generated release for previous repeated key
+ strn0cpy(LastKeyName, KeyName, sizeof(LastKeyName));
pressed = true;
repeat = false;
FirstTime.Set();
@@ -112,21 +112,16 @@ void cLircRemote::Action(void)
else {
pressed = true;
repeat = true;
- timeout = Delta * 10 / 9;
+ timeout = Delta * 3 / 2;
}
if (pressed) {
LastTime.Set();
Put(KeyName, repeat);
}
}
- else if (pressed && repeat) { // the last one was a repeat, so let's generate a release
- Put(LastKeyName, false, true);
- pressed = false;
- repeat = false;
- *LastKeyName = 0;
- timeout = -1;
- }
else {
+ if (pressed && repeat) // the last one was a repeat, so let's generate a release
+ Put(LastKeyName, false, true);
pressed = false;
repeat = false;
*LastKeyName = 0;