Skip to content

Commit

Permalink
Add virtualHIDKeyboardStrictFnArrows
Browse files Browse the repository at this point in the history
  • Loading branch information
tekezo committed Aug 24, 2024
1 parent 35b6d05 commit a815ca5
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/apps/SettingsWindow/src/View/VirtualKeyboardView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,19 @@ struct VirtualKeyboardView: View {
.background(Color(NSColor.textBackgroundColor))
}

GroupBox(label: Text("Flags")) {
VStack(alignment: .leading, spacing: 12.0) {
Toggle(isOn: $settings.virtualHIDKeyboardStrictFnArrows) {
Text(
"Change fn+arrows to home, end, page up, page down only when no other modifiers are pressed (Default: on)"
)
.frame(maxWidth: .infinity, alignment: .leading)
}
.switchToggleStyle()
}
.padding(6.0)
}

GroupBox(label: Text("Mouse key")) {
VStack(alignment: .leading, spacing: 12.0) {
HStack {
Expand Down
13 changes: 13 additions & 0 deletions src/apps/share/swift/LibKrbn/Settings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ extension LibKrbn {

virtualHIDKeyboardCountryCode = Int(
libkrbn_core_configuration_get_selected_profile_virtual_hid_keyboard_country_code())
virtualHIDKeyboardStrictFnArrows =
libkrbn_core_configuration_get_selected_profile_virtual_hid_keyboard_strict_fn_arrows()
virtualHIDKeyboardMouseKeyXYScale = Int(
libkrbn_core_configuration_get_selected_profile_virtual_hid_keyboard_mouse_key_xy_scale())
virtualHIDKeyboardIndicateStickyModifierKeysState =
Expand Down Expand Up @@ -557,6 +559,17 @@ extension LibKrbn {
}
}

@Published var virtualHIDKeyboardStrictFnArrows = true {
didSet {
if didSetEnabled {
libkrbn_core_configuration_set_selected_profile_virtual_hid_keyboard_strict_fn_arrows(
virtualHIDKeyboardStrictFnArrows
)
save()
}
}
}

@Published var virtualHIDKeyboardMouseKeyXYScale: Int = 0 {
didSet {
if didSetEnabled {
Expand Down
3 changes: 3 additions & 0 deletions src/lib/libkrbn/include/libkrbn/libkrbn.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ void libkrbn_core_configuration_get_new_complex_modifications_rule_json_string(c
uint8_t libkrbn_core_configuration_get_selected_profile_virtual_hid_keyboard_country_code(void);
void libkrbn_core_configuration_set_selected_profile_virtual_hid_keyboard_country_code(uint8_t value);

bool libkrbn_core_configuration_get_selected_profile_virtual_hid_keyboard_strict_fn_arrows(void);
void libkrbn_core_configuration_set_selected_profile_virtual_hid_keyboard_strict_fn_arrows(bool value);

int libkrbn_core_configuration_get_selected_profile_virtual_hid_keyboard_mouse_key_xy_scale(void);
void libkrbn_core_configuration_set_selected_profile_virtual_hid_keyboard_mouse_key_xy_scale(int value);

Expand Down
14 changes: 14 additions & 0 deletions src/lib/libkrbn/src/libkrbn_configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,20 @@ void libkrbn_core_configuration_set_selected_profile_virtual_hid_keyboard_countr
->set_country_code(pqrs::hid::country_code::value_t(value));
}

bool libkrbn_core_configuration_get_selected_profile_virtual_hid_keyboard_strict_fn_arrows(void) {
auto c = get_current_core_configuration();
return c->get_selected_profile()
.get_virtual_hid_keyboard()
->get_strict_fn_arrows();
}

void libkrbn_core_configuration_set_selected_profile_virtual_hid_keyboard_strict_fn_arrows(bool value) {
auto c = get_current_core_configuration();
c->get_selected_profile()
.get_virtual_hid_keyboard()
->set_strict_fn_arrows(value);
}

int libkrbn_core_configuration_get_selected_profile_virtual_hid_keyboard_mouse_key_xy_scale(void) {
auto c = get_current_core_configuration();
return c->get_selected_profile()
Expand Down

0 comments on commit a815ca5

Please sign in to comment.