Skip to content

Commit

Permalink
Finish the StickyKeys settings removal started in [23112]. Due to Act…
Browse files Browse the repository at this point in the history
…ion overloading, the initial change resulted in absolute, rather than incremental, seeks when Left/Right were used with queued input (numerical seek amounts).

After this change, users wanting the original StickyKeys behavior should ensure that Left and Right keys are not mapped to any of SEEKRWND/SEEKFFWD or RWNDSTICKY/FFWDSTICKY (resulting in the Global LEFT/RIGHT bindings being used).  A DB update modifies the key bindings for those who have not modified them since [23112].

Rather than adding 2 new redundant sections of code to the key handling, this change pulls seek/rew/ffwd handling into a separate function where the code is shared for all the action processing and all the overloaded functionality for those actions.


git-svn-id: http://svn.mythtv.org/svn/trunk@23362 7dbf422c-18fa-0310-86e9-fd20926502f2
  • Loading branch information
sphery committed Jan 29, 2010
1 parent 2dcf14d commit 005a437
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 58 deletions.
2 changes: 1 addition & 1 deletion mythtv/bindings/python/MythTV/MythStatic.py
Expand Up @@ -4,7 +4,7 @@
Contains any static and global variables for MythTV Python Bindings
"""

SCHEMA_VERSION = 1252
SCHEMA_VERSION = 1253
MVSCHEMA_VERSION = 1032
NVSCHEMA_VERSION = 1004
PROTO_VERSION = 56
Expand Down
65 changes: 63 additions & 2 deletions mythtv/libs/libmythtv/dbcheck.cpp
Expand Up @@ -17,10 +17,10 @@ using namespace std;
#define MINIMUM_DBMS_VERSION 5,0,15

/* If currentDatabaseVersion gets updated, the following files need updated:
mythtv/bindings/python/MythTV/MythDB.py
mythtv/bindings/python/MythTV/MythStatic.py
*/
/// This is the DB schema version expected by the running MythTV instance.
const QString currentDatabaseVersion = "1252";
const QString currentDatabaseVersion = "1253";

static bool UpdateDBVersionNumber(const QString &newnumber);
static bool performActualUpdate(
Expand Down Expand Up @@ -5098,6 +5098,67 @@ NULL
dbver = "1252";
}

if (dbver == "1252")
{
MSqlQuery select(MSqlQuery::InitCon());
select.prepare("SELECT hostname, data FROM settings "
" WHERE value = 'StickyKeys'");

if (!select.exec())
{
MythDB::DBError("Unable to retrieve StickyKeys values.", select);
}
else
{
MSqlQuery update(MSqlQuery::InitCon());
while (select.next())
{
QString hostname = select.value(0).toString();
QString sticky_keys = select.value(1).toString();

if ("1" == sticky_keys)
{
// Only remap the keys if they're currently set to defaults
update.prepare("UPDATE keybindings "
" SET keylist = :KEYS "
" WHERE context = 'TV Playback' AND "
" action = :ACTION AND "
" hostname = :HOSTNAME AND "
" keylist = :DEFAULT_KEYS");

QString keylist = ">,.";
QString action = "FFWDSTICKY";
QString default_keys = ">,.,Right";

update.bindValue(":KEYS", keylist);
update.bindValue(":ACTION", action);
update.bindValue(":HOSTNAME", hostname);
update.bindValue(":DEFAULT_KEYS", default_keys);
if (!update.exec())
MythDB::DBError("Unable to update keybindings",
update);

keylist = ",,<";
action = "RWNDSTICKY";
default_keys = ",,<,Left";

update.bindValue(":KEYS", keylist);
update.bindValue(":ACTION", action);
update.bindValue(":HOSTNAME", hostname);
update.bindValue(":DEFAULT_KEYS", default_keys);
if (!update.exec())
MythDB::DBError("Unable to update keybindings",
update);
}
}
}

if (!UpdateDBVersionNumber("1253"))
return false;

dbver = "1253";
}

return true;
}

Expand Down
113 changes: 58 additions & 55 deletions mythtv/libs/libmythtv/tv_play.cpp
Expand Up @@ -4242,62 +4242,8 @@ bool TV::ActiveHandleAction(PlayerContext *ctx,
}
}
}
else if (has_action("SEEKFFWD",actions) && !isDVDStill)
else if (!isDVDStill && SeekHandleAction(ctx, actions, isDVD))
{
if (HasQueuedInput())
DoArbSeek(ctx, ARBSEEK_FORWARD);
else if (ctx->paused)
{
if (!isDVD)
DoSeek(ctx, 1.001 / ctx->last_framerate, tr("Forward"));
}
else
{
if (smartForward && doSmartForward)
DoSeek(ctx, ctx->rewtime, tr("Skip Ahead"));
else
DoSeek(ctx, ctx->fftime, tr("Skip Ahead"));
}
}
else if (has_action("FFWDSTICKY", actions) && !isDVDStill)
{
if (HasQueuedInput())
DoArbSeek(ctx, ARBSEEK_END);
else if (ctx->paused)
{
if (!isDVD)
DoSeek(ctx, 1.0, tr("Forward"));
}
else
ChangeFFRew(ctx, 1);
}
else if (has_action("SEEKRWND", actions) && !isDVDStill)
{
if (HasQueuedInput())
DoArbSeek(ctx, ARBSEEK_REWIND);
else if (ctx->paused)
{
if (!isDVD)
DoSeek(ctx, -1.001 / ctx->last_framerate, tr("Rewind"));
}
else
{
if (smartForward)
doSmartForward = true;
DoSeek(ctx, -ctx->rewtime, tr("Skip Back"));
}
}
else if (has_action("RWNDSTICKY", actions) && !isDVDStill)
{
if (HasQueuedInput())
DoArbSeek(ctx, ARBSEEK_SET);
else if (ctx->paused)
{
if (!isDVD)
DoSeek(ctx, -1.0, tr("Rewind"));
}
else
ChangeFFRew(ctx, -1);
}
else if (has_action("JUMPRWND", actions))
{
Expand Down Expand Up @@ -5934,6 +5880,63 @@ bool TV::DoNVPSeek(PlayerContext *ctx, float time)
return res;
}

bool TV::SeekHandleAction(PlayerContext *actx, const QStringList &actions,
const bool isDVD)
{
int REWIND = 4, FORWARD = 8, STICKY = 16, SLIPPERY = 32,
INCREMENTAL = 64, ABSOLUTE = 128, WHENCE = 3;
int flags = 0;
if (has_action("SEEKFFWD", actions))
flags = ARBSEEK_FORWARD | FORWARD | SLIPPERY | INCREMENTAL;
else if (has_action("FFWDSTICKY", actions))
flags = ARBSEEK_END | FORWARD | STICKY | ABSOLUTE;
else if (has_action("RIGHT", actions))
flags = ARBSEEK_FORWARD | FORWARD | STICKY | INCREMENTAL;
else if (has_action("SEEKRWND", actions))
flags = ARBSEEK_REWIND | REWIND | SLIPPERY | INCREMENTAL;
else if (has_action("RWNDSTICKY", actions))
flags = ARBSEEK_SET | REWIND | STICKY | ABSOLUTE;
else if (has_action("LEFT", actions))
flags = ARBSEEK_REWIND | REWIND | STICKY | INCREMENTAL;
else
return false;

int direction = (flags & REWIND) ? -1 : 1;
if (HasQueuedInput())
{
DoArbSeek(actx, (ArbSeekWhence)(flags & WHENCE));
}
else if (actx->paused)
{
if (!isDVD)
{
float time = (flags & ABSOLUTE) ? direction :
direction * (1.001 / actx->last_framerate);
QString message = (flags & REWIND) ? QString(tr("Rewind")) :
QString(tr("Forward"));
DoSeek(actx, time, message);
}
}
else if (flags & STICKY)
{
ChangeFFRew(actx, direction);
}
else if (flags & REWIND)
{
if (smartForward)
doSmartForward = true;
DoSeek(actx, -actx->rewtime, tr("Skip Back"));
}
else
{
if (smartForward & doSmartForward)
DoSeek(actx, actx->rewtime, tr("Skip Ahead"));
else
DoSeek(actx, actx->fftime, tr("Skip Ahead"));
}
return true;
}

void TV::DoSeek(PlayerContext *ctx, float time, const QString &mesg)
{
bool limitkeys = false;
Expand Down
2 changes: 2 additions & 0 deletions mythtv/libs/libmythtv/tv_play.h
Expand Up @@ -419,6 +419,8 @@ class MPUBLIC TV : public QThread
void DoTogglePause(PlayerContext*, bool showOSD);
vector<bool> DoSetPauseState(PlayerContext *lctx, const vector<bool>&);

bool SeekHandleAction(PlayerContext *actx, const QStringList &actions,
const bool isDVD);
void DoSeek(PlayerContext*, float time, const QString &mesg);
bool DoNVPSeek(PlayerContext*, float time);
enum ArbSeekWhence {
Expand Down

0 comments on commit 005a437

Please sign in to comment.