ignore k_Repeat in cInterface::Wait()

Message ID 20050828213412.GC4047@localhost.localdomain
State New
Headers

Commit Message

Marko Mäkelä Aug. 28, 2005, 9:34 p.m. UTC
  While testing my suspend patch (see the previous message), I noticed somewhat
annoying behaviour of cInterface::Wait().  If I press the "Suspend" key
for a long time, so that it makes a normal keypress event as well as a
k_Repeat event, the "Press any key to cancel shutdown" prompt will be
cleared by the k_Repeat event.  I presume that the same would happen
with the "Power" key.

If I understood the loop termination condition in cInterface::Wait()
correctly, only k_Repeat of kOk would be filtered out.  I think it would
be better to ignore all k_Repeat keycodes.  Please see the attached patch.

	Marko
  

Comments

Reinhard Nissl Aug. 28, 2005, 9:48 p.m. UTC | #1
Hi,

Marko Mäkelä wrote:

> While testing my suspend patch (see the previous message), I noticed somewhat
> annoying behaviour of cInterface::Wait().  If I press the "Suspend" key
> for a long time, so that it makes a normal keypress event as well as a
> k_Repeat event, the "Press any key to cancel shutdown" prompt will be
> cleared by the k_Repeat event.  I presume that the same would happen
> with the "Power" key.

That's true. Most of the time, my mom seems to be not able to press the 
power key short enough to not trigger a k_Repeat event. As a result the 
VDR in the living room won't be powered off quite often (it's another 
question whether it is useful to switch of a VDR anyway ;-))

Maybe it would be a good idea to change the test in a way that it must 
be a different key, to abort the action, not the key that triggers the 
action. E. g. press power to initiate shutdown but back for example to 
abort it.

Bye.
  
Marko Mäkelä Aug. 29, 2005, 10:59 a.m. UTC | #2
On Sun, Aug 28, 2005 at 11:48:25PM +0200, Reinhard Nissl wrote:
> >While testing my suspend patch (see the previous message), I noticed 
> >somewhat
> >annoying behaviour of cInterface::Wait().  If I press the "Suspend" key
> >for a long time, so that it makes a normal keypress event as well as a
> >k_Repeat event, the "Press any key to cancel shutdown" prompt will be
> >cleared by the k_Repeat event.  I presume that the same would happen
> >with the "Power" key.
> 
> That's true. Most of the time, my mom seems to be not able to press the 
> power key short enough to not trigger a k_Repeat event. As a result the 
> VDR in the living room won't be powered off quite often (it's another 
> question whether it is useful to switch of a VDR anyway ;-))

Well, although my machine is quite silent and my house is equipped with
electric heating elements, I prefer to keep my computers shut down most
of the time and use the backup heating system when heating is needed.
About 10 years ago, the power supply of my PC caught fire when there
was a voltage spike on the mains network.  Luckily I was there.  Only
the filter capacitor on the mains input was blown.  So, nvram-wakeup is
my friend.

> Maybe it would be a good idea to change the test in a way that it must 
> be a different key, to abort the action, not the key that triggers the 
> action. E. g. press power to initiate shutdown but back for example to 
> abort it.

I don't think it is necessary, provided that your remote control driver
generates k_Repeat events properly.  (softdevice-dfb didn't until the patch
http://www.funet.fi/~msmakela/software/vdr/index.en.html#dfb-repeat
that I wrote yesterday.)

I tested the patch, and I can use the same key to confirm the message.
Did you try the patch out?  After applying it, you should still be able
to cancel the shutdown by pressing Power two times.  I don't think there
is any reason to require that the message must be confirmed by any other
key.  If you're in a dark room and have your thumb on the key already,
it's much easier to press the same key again.

	Marko
  

Patch

--- interface.c.orig    2004-11-01 16:23:28.000000000 +0200
+++ interface.c 2005-08-28 23:43:44.000000000 +0300
@@ -56,7 +56,7 @@ 
   time_t timeout = time(NULL) + Seconds;
   for (;;) {
       Key = GetKey();
-      if ((Key != kNone && (RAWKEY(Key) != kOk || RAWKEY(Key) == Key)) || time(NULL) > timeout || interrupted)
+      if (ISRAWKEY(Key) || time(NULL) > timeout || interrupted)
          break;
       }
   if (KeepChar && ISRAWKEY(Key))