From 956ddf3688954a2a5717dbcf6132c42251a35ca4 Mon Sep 17 00:00:00 2001 From: Tony Wang Date: Sun, 1 Jan 2017 15:30:55 +0800 Subject: [PATCH] hyper key --- .../Resources/simple_modifications.json | 3 +++ .../include/manipulator/event_manipulator.hpp | 15 +++++++++++++++ src/share/types.hpp | 2 ++ 3 files changed, 20 insertions(+) diff --git a/src/apps/PreferencesWindow/PreferencesWindow/Resources/simple_modifications.json b/src/apps/PreferencesWindow/PreferencesWindow/Resources/simple_modifications.json index 9da128c1b..da0784280 100644 --- a/src/apps/PreferencesWindow/PreferencesWindow/Resources/simple_modifications.json +++ b/src/apps/PreferencesWindow/PreferencesWindow/Resources/simple_modifications.json @@ -32,6 +32,9 @@ { "name": "fn" }, + { + "name": "hyper" + }, { "category": "Controls and symbols" }, diff --git a/src/core/grabber/include/manipulator/event_manipulator.hpp b/src/core/grabber/include/manipulator/event_manipulator.hpp index 9112715a0..72864a2ae 100644 --- a/src/core/grabber/include/manipulator/event_manipulator.hpp +++ b/src/core/grabber/include/manipulator/event_manipulator.hpp @@ -203,6 +203,10 @@ class event_manipulator final { return; } + if (post_hyper_key(to_key_code, pressed)) { + return; + } + if (post_modifier_flag_event(to_key_code, pressed)) { return; } @@ -406,6 +410,17 @@ class event_manipulator final { return false; } + bool post_hyper_key(krbn::key_code key_code, bool pressed) { + if (key_code == krbn::key_code::hyper) { + post_modifier_flag_event(krbn::key_code(kHIDUsage_KeyboardLeftControl), pressed); + post_modifier_flag_event(krbn::key_code(kHIDUsage_KeyboardLeftShift), pressed); + post_modifier_flag_event(krbn::key_code(kHIDUsage_KeyboardLeftAlt), pressed); + post_modifier_flag_event(krbn::key_code(kHIDUsage_KeyboardLeftGUI), pressed); + return true; + } + return false; + } + bool post_modifier_flag_event(krbn::key_code key_code, bool pressed) { auto operation = pressed ? manipulator::modifier_flag_manager::operation::increase : manipulator::modifier_flag_manager::operation::decrease; diff --git a/src/share/types.hpp b/src/share/types.hpp index 290261523..697d0b164 100644 --- a/src/share/types.hpp +++ b/src/share/types.hpp @@ -115,6 +115,7 @@ enum class key_code : uint32_t { // Keys that are not in generic keyboard_or_keypad usage_page. fn, + hyper, display_brightness_decrement, display_brightness_increment, dashboard, @@ -442,6 +443,7 @@ class types final { {"vk_none", key_code::vk_none}, {"fn", key_code::fn}, + {"hyper", key_code::hyper}, {"display_brightness_decrement", key_code::display_brightness_decrement}, {"display_brightness_increment", key_code::display_brightness_increment}, {"mission_control", key_code::mission_control},