From f1a8681050aa28f78b5c03ad40f1683f154a67bf Mon Sep 17 00:00:00 2001 From: danij Date: Sat, 8 Nov 2014 19:14:59 +0000 Subject: [PATCH] Fixed|BindContext|PlayerImpulse: PlayerImpulse double-click binding activation Symbolic events have no device identifier, they are referenced by name and context only. Also fixed a recent refactoring oversight when passing the generated name via ddevent_t to InputSystem::postEvent() --- doomsday/client/src/ui/bindcontext.cpp | 5 +++-- doomsday/client/src/ui/playerimpulse.cpp | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/doomsday/client/src/ui/bindcontext.cpp b/doomsday/client/src/ui/bindcontext.cpp index 0391e49839..e3346e758d 100644 --- a/doomsday/client/src/ui/bindcontext.cpp +++ b/doomsday/client/src/ui/bindcontext.cpp @@ -450,12 +450,13 @@ static void substituteInCommand(String const &command, ddevent_t const &event, d static Action *commandActionFor(BindContext const &context, CommandBinding const &bind, ddevent_t const &event, bool respectHigherContexts) { - if(bind.deviceId != event.device) return nullptr; - if(bind.type != event.type) return nullptr; + if(bind.type != event.type) return nullptr; InputDevice const *dev = nullptr; if(event.type != E_SYMBOLIC) { + if(bind.deviceId != event.device) return nullptr; + dev = inputSys().devicePtr(bind.deviceId); if(!dev || !dev->isActive()) { diff --git a/doomsday/client/src/ui/playerimpulse.cpp b/doomsday/client/src/ui/playerimpulse.cpp index 6ce4b3649c..44d3d83502 100644 --- a/doomsday/client/src/ui/playerimpulse.cpp +++ b/doomsday/client/src/ui/playerimpulse.cpp @@ -136,7 +136,7 @@ DENG2_PIMPL_NOREF(PlayerImpulse) db.triggered = true; // Compose the name of the symbolic event. - String symbolicName = "sym-"; + String symbolicName; switch(newState) { case DoubleClick::Positive: symbolicName += "control-doubleclick-positive-"; break; @@ -152,13 +152,14 @@ DENG2_PIMPL_NOREF(PlayerImpulse) << name << (localPlayer + 1) << newState << (nowTime - db.previousClickTime) << symbolicName; + Block symbolicNameUtf8 = symbolicName.toUtf8(); ddevent_t ev; de::zap(ev); ev.device = uint(-1); ev.type = E_SYMBOLIC; ev.symbolic.id = playerNum; - ev.symbolic.name = symbolicName.toUtf8().constData(); + ev.symbolic.name = symbolicNameUtf8.constData(); - inputSys().postEvent(&ev); + inputSys().postEvent(&ev); // makes a copy. } db.previousClickTime = nowTime;