From 390995bf03dde6757b2fe54e4097a090b0ed8381 Mon Sep 17 00:00:00 2001 From: June Tate-Gans Date: Sun, 25 Apr 2021 22:28:22 -0500 Subject: [PATCH] action: Revert my unsigned vs. signed "fix" Totally misread the code in the Action_keys::act method -- the code actually reverse sends events in an up condition. Still, keeping the C++11 iteration and improving by using boost::adaptors::reverse. --- g13d/action.cc | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/g13d/action.cc b/g13d/action.cc index 84a082b..32192ab 100644 --- a/g13d/action.cc +++ b/g13d/action.cc @@ -1,5 +1,6 @@ #include "action.h" +#include #include #include #include @@ -35,9 +36,16 @@ Action_Keys::~Action_Keys() { } void Action_Keys::act(Device &g13, bool is_down) { - for (auto key : _keys) { - g13.send_event(EV_KEY, key, is_down); - G13_LOG(trace, "sending KEY " << (is_down ? "DOWN " : "UP ") << key); + if (is_down) { + for (auto key : _keys) { + g13.send_event(EV_KEY, key, is_down); + G13_LOG(trace, "sending KEY DOWN " << key); + } + } else { + for (auto key : boost::adaptors::reverse(_keys)) { + g13.send_event(EV_KEY, key, is_down); + G13_LOG(trace, "sending KEY UP " << key); + } } }