Avoiding an extra key press event if the repeat function kicks in when controlling VDR via the PC keyboard

This commit is contained in:
Klaus Schmidinger 2013-02-02 12:44:33 +01:00
parent bb7d8b3b5b
commit 1bad5d1e6f
3 changed files with 47 additions and 14 deletions

View File

@ -7534,7 +7534,7 @@ Video Disk Recorder Revision History
- Reduced the number of retries in cTransfer::Receive() to avoid blocking recordings - Reduced the number of retries in cTransfer::Receive() to avoid blocking recordings
in case the primary device can't handle the current live signal. in case the primary device can't handle the current live signal.
2013-02-01: Version 1.7.37 2013-02-03: Version 1.7.37
- Now also using FindHeader() in cMpeg2Fixer::AdjTref() (pointed out by Sören Moch). - Now also using FindHeader() in cMpeg2Fixer::AdjTref() (pointed out by Sören Moch).
- Added missing template for DVBDIR to Make.config.template (reported by Derek Kelly). - Added missing template for DVBDIR to Make.config.template (reported by Derek Kelly).
@ -7560,3 +7560,5 @@ Video Disk Recorder Revision History
- Improved LIRC timing for repeat function. - Improved LIRC timing for repeat function.
- When pausing live video, the current audio and subtitle tracks are now retained. - When pausing live video, the current audio and subtitle tracks are now retained.
- Added some notes about plugin Makefiles to PLUGINS.html. - Added some notes about plugin Makefiles to PLUGINS.html.
- Avoiding an extra key press event if the repeat function kicks in when controlling
VDR via the PC keyboard.

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: remote.c 2.6 2013/01/13 12:01:52 kls Exp $ * $Id: remote.c 2.7 2013/02/02 12:44:33 kls Exp $
*/ */
#include "remote.h" #include "remote.h"
@ -295,6 +295,14 @@ int cKbdRemote::MapCodeToFunc(uint64_t Code)
return kfNone; return kfNone;
} }
void cKbdRemote::PutKey(uint64_t Code, bool Repeat, bool Release)
{
if (rawMode || !Put(Code, Repeat, Release)) {
if (int func = MapCodeToFunc(Code))
Put(KBDKEY(func), Repeat, Release);
}
}
int cKbdRemote::ReadKey(void) int cKbdRemote::ReadKey(void)
{ {
cPoller Poller(STDIN_FILENO); cPoller Poller(STDIN_FILENO);
@ -356,24 +364,46 @@ uint64_t cKbdRemote::ReadKeySequence(void)
void cKbdRemote::Action(void) void cKbdRemote::Action(void)
{ {
uint64_t FirstCommand = 0;
uint64_t LastCommand = 0; uint64_t LastCommand = 0;
bool Delayed = false;
bool Repeat = false; bool Repeat = false;
while (Running()) { while (Running()) {
uint64_t Command = ReadKeySequence(); uint64_t Command = ReadKeySequence();
if (LastCommand && Command != LastCommand && Repeat) { if (Command) {
if (!rawMode) if (Command == LastCommand) {
Put(LastCommand, false, true); // If two keyboard events with the same command come in without an intermediate
// timeout, this is a long key press that caused the repeat function to kick in:
Delayed = false;
FirstCommand = 0;
PutKey(Command, true);
Repeat = true;
}
else if (Command == FirstCommand) {
// If the same command comes in twice with an intermediate timeout, we
// need to delay the second command to see whether it is going to be
// a repeat function or a separate key press:
Delayed = true;
}
else {
// This is a totally new key press, so we accept it immediately:
PutKey(Command);
Delayed = false;
FirstCommand = Command;
}
}
else if (Repeat) {
// Timeout after a repeat function, so we generate a 'release':
PutKey(LastCommand, false, true);
Repeat = false; Repeat = false;
} }
if (Command) { else if (Delayed && FirstCommand) {
if (Command == LastCommand) // Timeout after two normal key presses of the same key, so accept the
Repeat = true; // delayed key:
if (rawMode || !Put(Command, Repeat)) { PutKey(FirstCommand);
int func = MapCodeToFunc(Command); Delayed = false;
if (func) FirstCommand = 0;
Put(KBDKEY(func));
}
} }
LastCommand = Command; LastCommand = Command;
} }

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: remote.h 1.41 2008/02/23 14:38:47 kls Exp $ * $Id: remote.h 2.1 2013/02/02 12:44:33 kls Exp $
*/ */
#ifndef __REMOTE_H #ifndef __REMOTE_H
@ -111,6 +111,7 @@ private:
int ReadKey(void); int ReadKey(void);
uint64_t ReadKeySequence(void); uint64_t ReadKeySequence(void);
int MapCodeToFunc(uint64_t Code); int MapCodeToFunc(uint64_t Code);
void PutKey(uint64_t Code, bool Repeat = false, bool Release = false);
public: public:
cKbdRemote(void); cKbdRemote(void);
virtual ~cKbdRemote(); virtual ~cKbdRemote();