Skip to content

Commit

Permalink
Add strict_fn_arrows_
Browse files Browse the repository at this point in the history
  • Loading branch information
tekezo committed Aug 23, 2024
1 parent 6d01c8c commit 37f56b6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ class virtual_hid_keyboard final {
country_code_,
pqrs::hid::country_code::value_t(0));

helper_values_.push_back_value<bool>("strict_fn_arrows",
strict_fn_arrows_,
true);

helper_values_.push_back_value<int>("mouse_key_xy_scale",
mouse_key_xy_scale_,
100);
Expand Down Expand Up @@ -52,6 +56,14 @@ class virtual_hid_keyboard final {
country_code_ = value;
}

const bool& get_strict_fn_arrows(void) const {
return strict_fn_arrows_;
}

void set_strict_fn_arrows(bool value) {
strict_fn_arrows_ = value;
}

const int& get_mouse_key_xy_scale(void) const {
return mouse_key_xy_scale_;
}
Expand Down Expand Up @@ -81,6 +93,7 @@ class virtual_hid_keyboard final {
private:
nlohmann::json json_;
pqrs::hid::country_code::value_t country_code_;
bool strict_fn_arrows_;
int mouse_key_xy_scale_;
bool indicate_sticky_modifier_keys_state_;
configuration_json_helper::helper_values helper_values_;
Expand Down
11 changes: 8 additions & 3 deletions tests/src/core_configuration/src/core_configuration_test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1640,17 +1640,20 @@ void run_core_configuration_test(void) {
auto json = nlohmann::json::object();
krbn::core_configuration::details::virtual_hid_keyboard virtual_hid_keyboard(json,
krbn::core_configuration::error_handling::strict);
expect(virtual_hid_keyboard.get_country_code() == pqrs::hid::country_code::value_t(0));
expect(pqrs::hid::country_code::value_t(0) == virtual_hid_keyboard.get_country_code());
expect(true == virtual_hid_keyboard.get_strict_fn_arrows());
}

// load values from json
{
nlohmann::json json({
{"country_code", 10},
{"strict_fn_arrows", false},
});
krbn::core_configuration::details::virtual_hid_keyboard virtual_hid_keyboard(json,
krbn::core_configuration::error_handling::strict);
expect(virtual_hid_keyboard.get_country_code() == pqrs::hid::country_code::value_t(10));
expect(pqrs::hid::country_code::value_t(10) == virtual_hid_keyboard.get_country_code());
expect(false == virtual_hid_keyboard.get_strict_fn_arrows());
}

// invalid values in json
Expand Down Expand Up @@ -1682,6 +1685,7 @@ void run_core_configuration_test(void) {
krbn::core_configuration::details::virtual_hid_keyboard virtual_hid_keyboard(json,
krbn::core_configuration::error_handling::strict);
virtual_hid_keyboard.set_country_code(pqrs::hid::country_code::value_t(10));
virtual_hid_keyboard.set_strict_fn_arrows(false);
virtual_hid_keyboard.set_mouse_key_xy_scale(50);

auto expected = R"(
Expand All @@ -1691,7 +1695,8 @@ void run_core_configuration_test(void) {
"dummy": {
"keep_me": true
},
"mouse_key_xy_scale": 50
"mouse_key_xy_scale": 50,
"strict_fn_arrows": false
}
)"_json;
Expand Down

0 comments on commit 37f56b6

Please sign in to comment.