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); + } } }