Skip to content

Commit

Permalink
Support profile.device.mouse_flip_* in simple_modifications_manipulat…
Browse files Browse the repository at this point in the history
…or_manager
  • Loading branch information
tekezo committed Sep 21, 2023
1 parent 4c4acb3 commit ec986af
Showing 1 changed file with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ class simple_modifications_manipulator_manager final {
manipulator_manager_->invalidate_manipulators();

for (const auto& device : profile.get_devices()) {
//
// Add profile.device.simple_modifications
//

for (const auto& pair : device.get_simple_modifications().get_pairs()) {
try {
if (auto m = make_manipulator(pair)) {
Expand All @@ -38,6 +42,40 @@ class simple_modifications_manipulator_manager final {
logger::get_logger()->error(e.what());
}
}

//
// Add profile.device.mouse_flip_*
//

auto flip = nlohmann::json::array();
if (device.get_mouse_flip_x()) {
flip.push_back("x");
}
if (device.get_mouse_flip_y()) {
flip.push_back("y");
}
if (device.get_mouse_flip_vertical_wheel()) {
flip.push_back("vertical_wheel");
}
if (device.get_mouse_flip_horizontal_wheel()) {
flip.push_back("horizontal_wheel");
}
if (flip.size() > 0) {
try {
auto json = nlohmann::json::object({
{"type", "mouse_basic"},
{"flip", flip},
});
auto parameters = krbn::core_configuration::details::complex_modifications_parameters();
auto m = std::make_shared<manipulator::manipulators::mouse_basic::mouse_basic>(json,
parameters);
auto c = manipulator::manipulator_factory::make_device_if_condition(device);
m->push_back_condition(c);
manipulator_manager_->push_back_manipulator(m);
} catch (const std::exception& e) {
logger::get_logger()->error(e.what());
}
}
}

for (const auto& pair : profile.get_simple_modifications().get_pairs()) {
Expand Down

0 comments on commit ec986af

Please sign in to comment.