tolerate k_Repeat in cMenuEditStrItem::ProcessKey()

Message ID 444B6812.30900@cadsoft.de
State New
Headers

Commit Message

Klaus Schmidinger April 23, 2006, 11:42 a.m. UTC
  Marko Mäkelä wrote:
> On Sun, Apr 09, 2006 at 10:38:06PM +0300, Marko Mäkelä wrote:
> 
>>For instance, when I start editing the string "Euronews" by pressing the Right
>>button in the "Edit timer" menu, it will display as follows:
>>
>>Right->
>> [E]uronews
>>2->
>> [A]uronews
>>2->
>> Au[a]onews
>>
>>If I keep a longer pause between the two keypresses of the button "2",
>>the string will change to "Aaronews".
> 
> 
> This is because my RCU (the new Hauppauge RCU) erroneously will not flip
> the RC5 toggle bit when the button is pressed in rapid succession.
> Also, the unpatched cx88-input.c in Linux 2.6.x (where 12<=x<=16) would
> map rapidly arriving key-press events to key-repeat.
> 
> The fix is simple:
> 
> --- menuitems.c.orig    2006-04-22 18:51:36.000000000 +0300
> +++ menuitems.c 2006-04-22 19:04:00.000000000 +0300
> @@ -351,7 +351,7 @@ char cMenuEditStrItem::Inc(char c, bool
> 
>  eOSState cMenuEditStrItem::ProcessKey(eKeys Key)
>  {
> -  bool SameKey = Key == lastKey;
> +  bool SameKey = !((Key ^ lastKey) & ~k_Repeat);
>    if (Key != kNone)
>       lastKey = Key;
>    else if (!newchar && k0 <= NORMALKEY(lastKey) && NORMALKEY(lastKey) <= k9 && autoAdvanceTimeout.TimedOut()) {
> @@ -460,7 +460,7 @@ eOSState cMenuEditStrItem::ProcessKey(eK
>                         }
>                      if (!currentChar || !*currentChar || *currentChar == '\t') {
>                         // find the beginning of the character map entry for Key-                       int n = Key - k0;
> +                       int n = NORMALKEY(Key) - k0;
>                         currentChar = charMap;
>                         while (n > 0 && *currentChar) {
>                               if (*currentChar++ == '\t')
> 
> Without the second patch, the k0..k9|k_Repeat event would be ignored when
> *currentChar=='\t' is reached.

Can you please try the attached, slightly modified version of this patch?
It avoids the rather complex "xor" expression and also some extra NORMALKEY().

Klaus
  

Comments

Marko Mäkelä April 23, 2006, 12:51 p.m. UTC | #1
On Sun, Apr 23, 2006 at 01:42:10PM +0200, Klaus Schmidinger wrote:
> Can you please try the attached, slightly modified version of this patch?
> It avoids the rather complex "xor" expression and also some extra 
> NORMALKEY().

Done.  It works equally well.  Thank you!

	Marko
  

Patch

--- menuitems.c	2006/04/14 10:41:28	1.42
+++ menuitems.c	2006/04/23 11:39:48
@@ -351,10 +351,10 @@ 
 
 eOSState cMenuEditStrItem::ProcessKey(eKeys Key)
 {
-  bool SameKey = Key == lastKey;
+  bool SameKey = NORMALKEY(Key) == lastKey;
   if (Key != kNone)
-     lastKey = Key;
-  else if (!newchar && k0 <= NORMALKEY(lastKey) && NORMALKEY(lastKey) <= k9 && autoAdvanceTimeout.TimedOut()) {
+     lastKey = NORMALKEY(Key);
+  else if (!newchar && k0 <= lastKey && lastKey <= k9 && autoAdvanceTimeout.TimedOut()) {
      AdvancePos();
      newchar = true;
      currentChar = NULL;
@@ -460,7 +460,7 @@ 
                        }
                     if (!currentChar || !*currentChar || *currentChar == '\t') {
                        // find the beginning of the character map entry for Key
-                       int n = Key - k0;
+                       int n = NORMALKEY(Key) - k0;
                        currentChar = charMap;
                        while (n > 0 && *currentChar) {
                              if (*currentChar++ == '\t')