File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ struct Config {
88 std::string configPath;
99 std::string keymapPath;
1010 int altcmkp = 0 ;
11+ bool hwsc = false ;
1112 char keymap[256 ]; // idx is midi key code (0-127, typically), value is vk code (1-254)
1213
1314 void use (std::string configPath, std::string keymapPath) {
@@ -18,6 +19,7 @@ struct Config {
1819 void save () {
1920 ini::IniFile storage;
2021 storage[" Compatibility" ][" altcmkp" ] = altcmkp;
22+ storage[" Compatibility" ][" hwsc" ] = hwsc;
2123 storage.save (configPath);
2224
2325 std::ofstream out;
@@ -30,6 +32,7 @@ struct Config {
3032 ini::IniFile storage;
3133 storage.load (configPath);
3234 if (storage[" Compatibility" ][" altcmkp" ].as <std::string>() != " " ) altcmkp = storage[" Compatibility" ][" altcmkp" ].as <int >();
35+ if (storage[" Compatibility" ][" hwsc" ].as <std::string>() != " " ) hwsc = storage[" Compatibility" ][" hwsc" ].as <bool >();
3336
3437 for (size_t i = 0 ; i < 255 ; i++) {
3538 keymap[i] = 0 ;
@@ -43,6 +46,7 @@ struct Config {
4346 auto repr () {
4447 std::map<std::string, std::string> entries = {
4548 { " altcmkp" , std::to_string (altcmkp) },
49+ { " hwsc" , std::to_string (hwsc) },
4650 };
4751 return entries;
4852 }
Original file line number Diff line number Diff line change @@ -85,6 +85,7 @@ class Keymapper {
8585
8686 void changeSettings () {
8787 config.altcmkp = question (ui, " Use alternative key release detection? (y/n)" );
88+ config.hwsc = question (ui, " Use hardware scan codes? (y/n)" );
8889 config.save ();
8990 }
9091
@@ -137,11 +138,16 @@ class Keymapper {
137138 }
138139 INPUT input;
139140 input.type = INPUT_KEYBOARD;
140- input.ki .wScan = 0 ;
141141 input.ki .time = 0 ;
142142 input.ki .dwExtraInfo = 0 ;
143143 input.ki .wVk = config.keymap [+cmkc];
144- input.ki .dwFlags = cmkp ? 0 : KEYEVENTF_KEYUP;
144+ if (config.hwsc ) {
145+ input.ki .wScan = MapVirtualKey (input.ki .wVk , MAPVK_VK_TO_VSC);
146+ input.ki .dwFlags = cmkp ? KEYEVENTF_SCANCODE : KEYEVENTF_SCANCODE | KEYEVENTF_KEYUP;
147+ } else {
148+ input.ki .wScan = 0 ;
149+ input.ki .dwFlags = cmkp ? 0 : KEYEVENTF_KEYUP;
150+ }
145151 SendInput (1 , &input, sizeof (INPUT));
146152 }
147153
You can’t perform that action at this time.
0 commit comments