Mailing List Archive

Sticky keys for FF/Rew [was: Re: MythTV Experiences]
john@churchdrama.org writes:

> >The other option would be that the forward and reverse buttons are
> >"sticky". When you press one it starts skipping forward until you
> >press it again. This is how my old video worked and is great for
> >programs where you want to only see a small part of the whole
> >recording.
> >
> >The reason that I would not want a different set of key presses to do
> >this is that my remote control only has a small number of
> >buttons. They are all used now, any more won't fit. I don't think
> >that MythTV should require the use of a keyboard.

> You make some good points about not wanting too many different key
> presses, although I suppose some "nonessential" key presses could
> simply be ignored, in terms of using with a remote. The "sticky"
> suggestion sounds like a good one to offer a way to quickly
> fastforward or rewind through several minutes of program.

Here is a patch that implements sticky keys for fast forward and
rewind.

You need to set StickyKeys=1 in settings.txt and I found that having
FastForwardAmount and RewindAmount set to 1 works well. Pressing the
same key again will stop the fast forward or rewind, pressing any
other key also does that.

The patch is against the CVS version from Saturday.

-------------------- mythtv patch --------------------
diff -ru ../cvs/MC/libs/libmythtv/settings.txt ./MC/libs/libmythtv/settings.txt
--- ../cvs2/MC/libs/libmythtv/settings.txt 2002-10-05 16:00:33.000000000 +0100
+++ ./MC/libs/libmythtv/settings.txt 2002-10-05 17:58:14.000000000 +0100
@@ -78,6 +78,8 @@
int FastForwardAmount=5
# How long to skip backwards on a rewind?
int RewindAmount=5
+# Are the fast forward and rewind buttons sticky (auto-repeat after letting go)?
+int StickyKeys=0
# How long should the OSD stay up for in seconds?
int OSDDisplayTime=3
# Theme to use for the OSD, if 'none' or otherwise doesn't exist, the normal
diff -ru ../cvs2/MC/libs/libmythtv/tv.cpp ./MC/libs/libmythtv/tv.cpp
--- ../cvs2/MC/libs/libmythtv/tv.cpp 2002-10-05 16:49:24.000000000 +0100
+++ ./MC/libs/libmythtv/tv.cpp 2002-10-05 17:56:42.000000000 +0100
@@ -887,10 +887,12 @@

void TV::RunTV(void)
{
- // frameRate = 29.97; // the default's not used, but give it a default anyway.
-
paused = false;
int keypressed;
+
+ stickykeys = settings->GetSetting("StickyKeys");
+ doing_ff = 0;
+ doing_rew = 0;

channelqueued = false;
channelKeys[0] = channelKeys[1] = channelKeys[2] = ' ';
@@ -906,9 +908,17 @@

usleep(1000);

- if (nvp && (keypressed = nvp->CheckEvents()))
+ if (nvp)
{
- ProcessKeypress(keypressed);
+ if ((keypressed = nvp->CheckEvents()))
+ ProcessKeypress(keypressed);
+ else if(stickykeys)
+ {
+ if (doing_ff)
+ DoFF();
+ else if (doing_rew)
+ DoRew();
+ }
}

if (StateIsRecording(internalState))
@@ -990,17 +1000,45 @@
switch (keypressed)
{
case 's': case 'S':
- case 'p': case 'P': DoPause(); break;
-
- case wsRight: case 'd': case 'D': DoFF(); break;
-
- case wsLeft: case 'a': case 'A': DoRew(); break;
+ case 'p': case 'P':
+ doing_ff = 0;
+ doing_rew = 0;
+ DoPause(); break;
+
+ case wsRight: case 'd': case 'D':
+ if (doing_ff && stickykeys)
+ {
+ doing_ff = 0;
+ }
+ else
+ {
+ doing_ff = 1;
+ doing_rew = 0;
+ DoFF();
+ }
+ break;
+
+ case wsLeft: case 'a': case 'A':
+ if (doing_rew && stickykeys)
+ {
+ doing_rew = 0;
+ }
+ else
+ {
+ doing_ff = 0;
+ doing_rew = 1;
+ DoRew();
+ }
+ break;

case wsEscape: exitPlayer = true; break;

// case 'e': case 'E': nvp->ToggleEdit(); break;
// case ' ': nvp->AdvanceOneFrame(); break;
- default: break;
+ default:
+ doing_ff = 0;
+ doing_rew = 0;
+ break;
}

if (internalState == kState_WatchingLiveTV)
diff -ru ../cvs2/MC/libs/libmythtv/tv.h ./MC/libs/libmythtv/tv.h
--- ../cvs2/MC/libs/libmythtv/tv.h 2002-10-05 14:41:25.000000000 +0100
+++ ./MC/libs/libmythtv/tv.h 2002-10-05 17:12:15.000000000 +0100
@@ -159,6 +159,9 @@

int fftime;
int rewtime;
+ int stickykeys;
+ int doing_ff;
+ int doing_rew;

OSD *osd;

-------------------- mythtv patch --------------------

--
Andrew.
----------------------------------------------------------------------
Andrew M. Bishop amb@gedanken.demon.co.uk
http://www.gedanken.demon.co.uk/
Re: Sticky keys for FF/Rew [was: Re: MythTV Experiences] [ In reply to ]
On Saturday 05 October 2002 01:06 pm, Andrew M. Bishop wrote:
> Here is a patch that implements sticky keys for fast forward and
> rewind.
>
> You need to set StickyKeys=1 in settings.txt and I found that having
> FastForwardAmount and RewindAmount set to 1 works well. Pressing the
> same key again will stop the fast forward or rewind, pressing any
> other key also does that.
>
> The patch is against the CVS version from Saturday.

Thanks, that works rather well. I also added in a small usleep() after the
seek, makes it a little smoother. It's in the tree now.

Isaac