Skip to content

Commit

Permalink
add shell_command to event_queue
Browse files Browse the repository at this point in the history
  • Loading branch information
tekezo committed Jul 11, 2017
1 parent 3796ab1 commit b113792
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions appendix/dump_hid_value/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ class dump_hid_value final {
}
break;

case krbn::event_queue::queued_event::event::type::shell_command:
std::cout << "shell_command" << std::endl;
break;

case krbn::event_queue::queued_event::event::type::device_keys_are_released:
std::cout << "device_keys_are_released for " << device.get_name_for_log() << " (" << device.get_device_id() << ")" << std::endl;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class manipulator_manager final {
case event_queue::queued_event::event::type::pointing_y:
case event_queue::queued_event::event::type::pointing_vertical_wheel:
case event_queue::queued_event::event::type::pointing_horizontal_wheel:
case event_queue::queued_event::event::type::shell_command:
for (auto&& m : manipulators_) {
m->manipulate(front_input_event,
input_event_queue,
Expand Down
16 changes: 16 additions & 0 deletions src/share/event_queue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class event_queue final {
pointing_vertical_wheel,
pointing_horizontal_wheel,
// virtual events
shell_command,
device_keys_are_released,
device_pointing_buttons_are_released,
device_ungrabbed,
Expand All @@ -46,6 +47,13 @@ class event_queue final {
value_(integer_value) {
}

static event make_shell_command_event(const std::string& shell_command) {
event e;
e.type_ = type::shell_command;
e.value_ = shell_command;
return e;
}

static event make_device_keys_are_released_event(void) {
return make_virtual_event(type::device_keys_are_released);
}
Expand Down Expand Up @@ -99,6 +107,13 @@ class event_queue final {
return boost::none;
}

boost::optional<std::string> get_shell_command(void) const {
if (type_ == type::shell_command) {
return boost::get<std::string>(value_);
}
return boost::none;
}

boost::optional<std::string> get_frontmost_application_bundle_identifier(void) const {
if (type_ == type::frontmost_application_changed) {
const auto& v = boost::get<frontmost_application>(value_);
Expand Down Expand Up @@ -161,6 +176,7 @@ class event_queue final {
boost::variant<key_code, // For type::key_code
pointing_button, // For type::pointing_button
int64_t, // For type::pointing_x, type::pointing_y, type::pointing_vertical_wheel, type::pointing_horizontal_wheel
std::string, // For shell_command
boost::blank, // For virtual events
frontmost_application>
value_;
Expand Down

0 comments on commit b113792

Please sign in to comment.