From a16b320c17fc38bfd4d50fe8a31d4f0210f91e3f Mon Sep 17 00:00:00 2001 From: Eberhard Beilharz Date: Thu, 1 Jul 2021 17:20:57 +0200 Subject: [PATCH 1/3] chore(common/core/desktop): Update readme --- common/core/desktop/src/kmx/kmx_processevent.cpp | 10 +++------- common/core/desktop/tests/unit/kmx/README.md | 11 +++++++++-- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/common/core/desktop/src/kmx/kmx_processevent.cpp b/common/core/desktop/src/kmx/kmx_processevent.cpp index 3e4f39f5ed..6d4bd8cbb3 100644 --- a/common/core/desktop/src/kmx/kmx_processevent.cpp +++ b/common/core/desktop/src/kmx/kmx_processevent.cpp @@ -71,7 +71,6 @@ char VKeyToChar(KMX_UINT modifiers, KMX_UINT vk) { * ProcessEvent organizes the messages and gives them to the appropriate routines to * process, and checks the state of Windows for the keyboard handling. */ - KMX_BOOL KMX_ProcessEvent::ProcessEvent(km_kbp_state *state, KMX_UINT vkey, KMX_DWORD modifiers) { LPKEYBOARD kbd = m_keyboard.Keyboard; @@ -142,10 +141,9 @@ KMX_BOOL KMX_ProcessEvent::ProcessEvent(km_kbp_state *state, KMX_UINT vkey, KMX_ * * Called by: ProcessEvent, recursive inside groups * -* ProcessKey is where the keystroke conversion and output takes place. This routine +* ProcessGroup is where the keystroke conversion and output takes place. This routine * has a lot of crucial code in it! */ - KMX_BOOL KMX_ProcessEvent::ProcessGroup(LPGROUP gp, KMX_BOOL *pOutputKeystroke) { KMX_DWORD i; @@ -381,12 +379,11 @@ KMX_BOOL KMX_ProcessEvent::ProcessGroup(LPGROUP gp, KMX_BOOL *pOutputKeystroke) * * Returns: 0 to continue, 1 and 2 to return. * -* Called by: ProcessKey +* Called by: ProcessGroup * * PostString posts a string of "context", "index", "beep", characters and virtual keys * to the active application, via the Keyman PostKey buffer. */ - int KMX_ProcessEvent::PostString(PKMX_WCHAR str, LPKEYBOARD lpkb, PKMX_WCHAR endstr, KMX_BOOL *pOutputKeystroke) { PKMX_WCHAR p, q, temp; @@ -561,11 +558,10 @@ KMX_BOOL KMX_ProcessEvent::IsMatchingPlatform(LPSTORE s) // I3432 * * Returns: 0 on OK, 1 on not equal * -* Called by: ProcessKey +* Called by: ProcessGroup * * ContextMatch compares the context of a rule with the current context. */ - KMX_BOOL KMX_ProcessEvent::ContextMatch(LPKEY kkp) { KMX_WORD /*i,*/ n; diff --git a/common/core/desktop/tests/unit/kmx/README.md b/common/core/desktop/tests/unit/kmx/README.md index 39de91f403..c73656b973 100644 --- a/common/core/desktop/tests/unit/kmx/README.md +++ b/common/core/desktop/tests/unit/kmx/README.md @@ -52,11 +52,18 @@ c expected: pass.pass.pass.pass.pass.pass. ## Running the tests -All tests can be run at once with `meson test`. +All tests can be run at once with `./build.sh --debug tests`. Alternatively it's possible to run a single test with: ```bash cd common/core/desktop -build/tests/unit/kmx/kmx 'tests/unit/kmx/038 - punctkeys.kmn' 'tests/unit/kmx/038 - punctkeys.kmx' +build/arch/debug/tests/unit/kmx/kmx 'tests/unit/kmx/038 - punctkeys.kmn' 'tests/unit/kmx/038 - punctkeys.kmx' +``` + +or shorter: + +```bash +cd common/core/desktop +build/arch/debug/tests/unit/kmx/kmx 'tests/unit/kmx/038 - punctkeys'.km{n,x} ``` From 84aa50b82fca5d590e18dbc5ef4095be5f50f648 Mon Sep 17 00:00:00 2001 From: Eberhard Beilharz Date: Tue, 6 Jul 2021 18:46:11 +0200 Subject: [PATCH 2/3] chore(linux): Update sample vscode settings for Linux --- docs/settings/linux/c_cpp_properties.json | 30 +++-- docs/settings/linux/extensions.json | 1 + docs/settings/linux/launch.json | 71 ++++++++++++ docs/settings/linux/settings.json | 83 +++++++++++++- docs/settings/linux/tasks.json | 133 ++++++++++++++++++++++ linux/.editorconfig | 8 +- 6 files changed, 304 insertions(+), 22 deletions(-) create mode 100644 docs/settings/linux/tasks.json diff --git a/docs/settings/linux/c_cpp_properties.json b/docs/settings/linux/c_cpp_properties.json index 13ff111c62..267484e4e3 100644 --- a/docs/settings/linux/c_cpp_properties.json +++ b/docs/settings/linux/c_cpp_properties.json @@ -1,17 +1,15 @@ { - "configurations": [ - { - "name": "Linux", - "includePath": [ - "${workspaceFolder}/**" - ], - "defines": [], - "compilerPath": "/usr/lib/ccache/clang", - "cStandard": "c11", - "cppStandard": "c++14", - "intelliSenseMode": "clang-x64", - "compileCommands": "${workspaceFolder}/linux/keyboardprocessor/compile_commands.json" - } - ], - "version": 4 -} \ No newline at end of file + "configurations": [ + { + "name": "linux", + "includePath": ["${workspaceFolder}/common/core/desktop/include/**"], + "defines": [], + "compilerPath": "/usr/lib/ccache/clang", + "cStandard": "c11", + "cppStandard": "c++14", + "intelliSenseMode": "clang-x64", + "compileCommands": "${workspaceFolder}/common/core/desktop/build/arch/debug/compile_commands.json" + } + ], + "version": 4 +} diff --git a/docs/settings/linux/extensions.json b/docs/settings/linux/extensions.json index c03958b519..88b037ee83 100644 --- a/docs/settings/linux/extensions.json +++ b/docs/settings/linux/extensions.json @@ -5,5 +5,6 @@ "asabil.meson", "EditorConfig.editorconfig", "ms-python.python", + "rust-lang.rust", ] } diff --git a/docs/settings/linux/launch.json b/docs/settings/linux/launch.json index e3fcde5bba..dfbaa420eb 100644 --- a/docs/settings/linux/launch.json +++ b/docs/settings/linux/launch.json @@ -4,6 +4,38 @@ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ + { + "name": "Launch fixupHistory", + "program": "${workspaceFolder}/resources/build/version/dist/index.js", + "request": "launch", + "skipFiles": [ + "/**" + ], + "args": ["history", "version"], + "type": "node" + }, + { + "type": "gdb", + "request": "launch", + "name": "Launch kmx unit tests", + "target": "build/arch/debug/tests/unit/kmx/kmx", + "cwd": "${workspaceRoot}/common/core/desktop/", + "arguments": "tests/unit/kmx/033\\ -\\ caps\\ always\\ off.km{n,x}", + "valuesFormatting": "parseText" + }, + { + // kill ibus-engine-keyman, if running + // start: gdbserver 10.3.0.53:2345 /media/sf_Develop/keyman/keyman/linux/ibus-keyman/src/ibus-engine-keyman + // then attach debugger in vscode + "type": "gdb", + "request": "attach", + "name": "Attach to gdbserver", + "executable": "./linux/ibus-keyman/src/ibus-engine-keyman", + "target": "10.3.0.53:2345", + "remote": true, + "cwd": "${workspaceFolder}/linux/ibus-keyman", + "valuesFormatting": "parseText" + }, { "name": "Python: Current File", "type": "python", @@ -17,7 +49,46 @@ "request": "launch", "program": "linux/keyman-config/km-config", "cwd": "${workspaceFolder}", + "console": "integratedTerminal", + "env": { + "KEYMAN_NOSENTRY": "1" + } + }, + { + "name": "km-package-install", + "type": "python", + "request": "launch", + "program": "linux/keyman-config/km-package-install", + "cwd": "${workspaceFolder}", + "console": "integratedTerminal", + "env": { + "KEYMAN_NOSENTRY": "1" + } + }, + { + "name": "Python: ibus-keyman unit tests", + "type": "python", + "request": "launch", + "program": "${workspaceFolder}/linux/ibus-keyman/test/test_ibus_keyman.py", + "args": [ + "001 - basic input UnicodeI" + ], + "cwd": "${workspaceFolder}/linux/ibus-keyman/test/", "console": "integratedTerminal" + }, + { + "type": "perl", + "name": "help2md", + "request": "launch", + "program": "${workspaceFolder}/linux/keyman-config/buildtools/help2md", + "args": ["${workspaceFolder}/linux/keyman-config/km-package-install", "--output=${workspaceFolder}/linux/keyman-config/debian/man/km-package-install.md", "--name=Keyman keyboards installation and information", "--opt-include=${workspaceFolder}/linux/keyman-config/maninc/km-package-install.inc"], + "cwd": "${workspaceFolder}/linux/keyman-config", + "stopOnEntry": true, + "reloadModules": true, + "env": { + "KEYMAN_NOSENTRY": "1", + "PERL5LIB": "${HOME}/perl5/lib/perl5:${PERL5LIB}" + } } ] } diff --git a/docs/settings/linux/settings.json b/docs/settings/linux/settings.json index 1476b35a91..59d9c57304 100644 --- a/docs/settings/linux/settings.json +++ b/docs/settings/linux/settings.json @@ -13,5 +13,86 @@ "python.linting.enabled": true, // We use flake8 for Python linting - install with `pip3 install flake8` "python.linting.flake8Enabled": true, - "python.pythonPath": "/usr/bin/python3" + "python.pythonPath": "/usr/bin/python3", + "files.associations": { + "*.tcc": "cpp", + "keyboardprocessor.h": "c", + "engine.h": "c", + "keyman-service.h": "c", + "keymanutil.h": "c", + "cctype": "cpp", + "clocale": "cpp", + "cmath": "cpp", + "csetjmp": "cpp", + "csignal": "cpp", + "cstdarg": "cpp", + "cstddef": "cpp", + "cstdio": "cpp", + "cstdlib": "cpp", + "cstring": "cpp", + "ctime": "cpp", + "cwchar": "cpp", + "cwctype": "cpp", + "array": "cpp", + "atomic": "cpp", + "strstream": "cpp", + "bitset": "cpp", + "chrono": "cpp", + "cinttypes": "cpp", + "codecvt": "cpp", + "complex": "cpp", + "condition_variable": "cpp", + "cstdint": "cpp", + "deque": "cpp", + "forward_list": "cpp", + "list": "cpp", + "unordered_map": "cpp", + "vector": "cpp", + "exception": "cpp", + "algorithm": "cpp", + "functional": "cpp", + "iterator": "cpp", + "map": "cpp", + "memory": "cpp", + "memory_resource": "cpp", + "numeric": "cpp", + "optional": "cpp", + "random": "cpp", + "ratio": "cpp", + "regex": "cpp", + "set": "cpp", + "string": "cpp", + "string_view": "cpp", + "system_error": "cpp", + "tuple": "cpp", + "type_traits": "cpp", + "utility": "cpp", + "fstream": "cpp", + "future": "cpp", + "initializer_list": "cpp", + "iomanip": "cpp", + "iosfwd": "cpp", + "iostream": "cpp", + "istream": "cpp", + "limits": "cpp", + "mutex": "cpp", + "new": "cpp", + "ostream": "cpp", + "shared_mutex": "cpp", + "sstream": "cpp", + "stdexcept": "cpp", + "streambuf": "cpp", + "thread": "cpp", + "cfenv": "cpp", + "typeindex": "cpp", + "typeinfo": "cpp", + "valarray": "cpp", + "variant": "cpp", + "bit": "cpp", + "*.ipp": "cpp", + "ibus.h": "c", + "*.in": "cpp" + }, + "C_Cpp.clang_format_fallbackStyle": "Google", + "rust.target_dir": "../../../build/rust/rls", } diff --git a/docs/settings/linux/tasks.json b/docs/settings/linux/tasks.json new file mode 100644 index 0000000000..3f69492cd6 --- /dev/null +++ b/docs/settings/linux/tasks.json @@ -0,0 +1,133 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "type": "shell", + "label": "core: build", + "command": "${workspaceFolder}/common/core/desktop/build.sh", + "args": [ + "--debug" + ], + "options": { + "cwd": "${workspaceFolder}/common/core/desktop" + }, + "problemMatcher": [ + { + "owner": "cpp", + "source": "compiler", + "fileLocation": [ + "relative", + "${workspaceFolder}/common/core/desktop/" + ], + "pattern": [ + { + "regexp": "^../../../(.*):(\\d+):(\\d+):\\s+(warning|error|note):\\s+(.*)(\\s+\\[.*\\])?$", + "file": 1, + "line": 2, + "column": 3, + "severity": 4, + "message": 5 + } + ] + }, + { + "owner": "cpp", + "source": "linker", + "fileLocation": "absolute", + "pattern": [ + { + "regexp": "^(/usr/bin/ld:\\s+)?(.*):(\\d+):\\s+(.*)$", + "file": 2, + "location": 3, + "message": 4 + } + ] + }, + { + "base": "$rustc", + "source": "rust compiler", + "fileLocation": "absolute" + } + ], + "group": "build", + "detail": "build common/core/desktop" + }, + { + "type": "shell", + "label": "core: build Rust", + "command": "${workspaceFolder}/common/core/desktop/build.sh", + "args": [ + "--debug", + "build-rust" + ], + "options": { + "cwd": "${workspaceFolder}/common/core/desktop" + }, + "problemMatcher": [ + { + "base": "$rustc", + "fileLocation": "absolute" + } + ], + "group": "build", + "detail": "Rust build of common/core/desktop" + }, + { + "type": "shell", + "label": "core: test", + "command": "${workspaceFolder}/common/core/desktop/build.sh", + "args": [ + "--debug", + "tests" + ], + "problemMatcher": [ + "$gcc" + ], + "group": "test", + "detail": "run tests for common/core/desktop" + }, + { + "type": "shell", + "label": "ibus-keyman: configure", + "command": "./configure", + "args": [ + "CPPFLAGS=\"-DG_MESSAGES_DEBUG -I${workspaceFolder}/common/core/desktop/build/arch/debug/include/ -I${workspaceFolder}/common/core/desktop/include/\"", + "CFLAGS=\"-g -O0\"", + "CXXFLAGS=\"-g -O0\"" + ], + "options": { + "cwd": "${workspaceFolder}/linux/ibus-keyman" + }, + "problemMatcher": [ + { + "base": "$gcc", + "fileLocation": [ + "relative", + "${workspaceFolder}/linux/ibus-keyman/src/" + ], + } + ], + "group": "build", + "detail": "configure ibus-keyman" + }, + { + "type": "shell", + "label": "ibus-keyman: build", + "command": "make", + "options": { + "cwd": "${workspaceFolder}/linux/ibus-keyman", + }, + "problemMatcher": [ + { + "base": "$gcc", + "fileLocation": [ + "relative", + "${workspaceFolder}/linux/ibus-keyman/src/" + ], + } + ], + "group": "build", + "detail": "build ibus-keyman" + }, + ] +} diff --git a/linux/.editorconfig b/linux/.editorconfig index 0d465fe281..565810a97e 100644 --- a/linux/.editorconfig +++ b/linux/.editorconfig @@ -1,7 +1,5 @@ -root = true - -[*.py] +[*] trim_trailing_whitespace = true -intent_stype = space -intent_size = 4 +indent_style = space +indent_size = 4 From 0eca43d4eadfcd28d147b2817c6fef2a495c3743 Mon Sep 17 00:00:00 2001 From: Eberhard Beilharz Date: Tue, 6 Jul 2021 18:54:59 +0200 Subject: [PATCH 3/3] feat(common/core): Implement capsAlwaysOff system store This change implements the core part in a way that makes the tests pass. This still needs corresponding changes in the engine. --- common/core/desktop/.gitignore | 2 + .../include/keyman/keyboardprocessor.h.in | 5 +- .../desktop/src/km_kbp_processevent_api.cpp | 12 +- common/core/desktop/src/kmx/kmx_capslock.cpp | 105 +++--- .../core/desktop/src/kmx/kmx_environment.cpp | 8 - common/core/desktop/src/kmx/kmx_environment.h | 2 - .../core/desktop/src/kmx/kmx_processevent.cpp | 48 ++- .../core/desktop/src/kmx/kmx_processevent.h | 14 +- common/core/desktop/src/kmx/kmx_processor.cpp | 343 +++++++++--------- common/core/desktop/src/kmx/kmx_processor.hpp | 29 +- .../core/desktop/src/mock/mock_processor.cpp | 25 +- .../core/desktop/src/mock/mock_processor.hpp | 26 +- common/core/desktop/src/processor.hpp | 27 +- .../rust/keyman_keyboard_processor/src/lib.rs | 4 +- .../core/desktop/src/rust/native/src/lib.rs | 4 +- .../desktop/src/rust/rust_mock_processor.cpp | 12 +- .../desktop/src/rust/rust_mock_processor.hpp | 27 +- common/core/desktop/src/rust/wasm/src/lib.rs | 4 +- common/core/desktop/src/state.cpp | 10 +- common/core/desktop/src/state.hpp | 2 +- .../desktop/tests/unit/kmnkbd/debug_api.cpp | 20 +- .../desktop/tests/unit/kmnkbd/state_api.cpp | 12 +- .../tests/unit/kmx/031 - caps lock.kmn | 4 +- .../tests/unit/kmx/032 - caps control.kmn | 4 +- .../tests/unit/kmx/033 - caps always off.kmn | 4 +- .../tests/unit/kmx/033 - caps always off.kmx | Bin 0 -> 516 bytes .../047 - caps always off initially on.kmn | 23 ++ .../047 - caps always off initially on.kmx | Bin 0 -> 516 bytes common/core/desktop/tests/unit/kmx/README.md | 13 +- common/core/desktop/tests/unit/kmx/kmx.cpp | 113 +++--- .../core/desktop/tests/unit/kmx/meson.build | 5 +- .../tests/unit/rust_mock/state_api.cpp | 4 +- linux/.editorconfig | 5 - linux/ibus-keyman/src/engine.c | 69 ++-- 34 files changed, 566 insertions(+), 419 deletions(-) create mode 100644 common/core/desktop/tests/unit/kmx/033 - caps always off.kmx create mode 100644 common/core/desktop/tests/unit/kmx/047 - caps always off initially on.kmn create mode 100644 common/core/desktop/tests/unit/kmx/047 - caps always off initially on.kmx delete mode 100644 linux/.editorconfig diff --git a/common/core/desktop/.gitignore b/common/core/desktop/.gitignore index 40a3439fe8..90ca8c2bb1 100644 --- a/common/core/desktop/.gitignore +++ b/common/core/desktop/.gitignore @@ -9,3 +9,5 @@ wasm.build TIER.md VERSION.md shellHelperFunctions.sh + +src/rust/keyman_keyboard_processor/target/ diff --git a/common/core/desktop/include/keyman/keyboardprocessor.h.in b/common/core/desktop/include/keyman/keyboardprocessor.h.in index 430dc0b455..6bb681f672 100644 --- a/common/core/desktop/include/keyman/keyboardprocessor.h.in +++ b/common/core/desktop/include/keyman/keyboardprocessor.h.in @@ -478,6 +478,7 @@ typedef struct { uintptr_t marker; // MARKER type km_kbp_option_item const * option; // OPT types km_kbp_usv character; // CHAR type + uint8_t capsLock; // CAPSLOCK type, 1 to turn on, 0 to turn off }; } km_kbp_action_item; @@ -494,6 +495,7 @@ enum km_kbp_action_type { // for applications where context is cached, this clears the context; // for applications where context is read from the focused text store, // the context is just re-read and markers flushed. + KM_KBP_IT_CAPSLOCK = 8, // Enable or disable capsLock KM_KBP_IT_MAX_TYPE_ID }; @@ -940,7 +942,8 @@ KMN_API km_kbp_status km_kbp_process_event(km_kbp_state *state, km_kbp_virtual_key vk, - uint16_t modifier_state); + uint16_t modifier_state, + uint8_t is_key_down); #if defined(__cplusplus) } // extern "C" diff --git a/common/core/desktop/src/km_kbp_processevent_api.cpp b/common/core/desktop/src/km_kbp_processevent_api.cpp index 698ae7b2f2..747ee2858c 100644 --- a/common/core/desktop/src/km_kbp_processevent_api.cpp +++ b/common/core/desktop/src/km_kbp_processevent_api.cpp @@ -12,15 +12,15 @@ #include "processor.hpp" #include "state.hpp" -km_kbp_status +km_kbp_status km_kbp_process_event(km_kbp_state *state, - km_kbp_virtual_key vk, uint16_t modifier_state) -{ - return state->processor().process_event(state, vk, modifier_state); + km_kbp_virtual_key vk, + uint16_t modifier_state, + uint8_t is_key_down) { + return state->processor().process_event(state, vk, modifier_state, is_key_down); } - -km_kbp_attr const * +km_kbp_attr const * km_kbp_get_engine_attrs(km_kbp_state const *state) { return &state->processor().attributes(); diff --git a/common/core/desktop/src/kmx/kmx_capslock.cpp b/common/core/desktop/src/kmx/kmx_capslock.cpp index cd11290af7..9db0fab0a0 100644 --- a/common/core/desktop/src/kmx/kmx_capslock.cpp +++ b/common/core/desktop/src/kmx/kmx_capslock.cpp @@ -2,57 +2,80 @@ Copyright: Copyright (C) 2003-2018 SIL International. Authors: mcdurdin */ +#include #include using namespace km::kbp; using namespace kmx; -void KMX_ProcessEvent::ResetCapsLock(void) -{ - DebugLog("ResetCapsLock: enter"); +/** + * Set caps lock state. + * Called by ProcessEvent. + * May update `modifiers` to add or remove `CAPITALFLAG` according to capsLockOn + * parameter. May queue actions to set caps lock state. + * + * @param[in,out] modifiers The modifier key bitmap + * @param capsLockOn The desired caps lock state + */ +void KMX_ProcessEvent::SetCapsLock(KMX_DWORD &modifiers, KMX_BOOL capsLockOn) { + KMX_BOOL capsLockCurrentlyOn = IsCapsLockOn(modifiers); + if (capsLockCurrentlyOn == capsLockOn) { + return; + } - if (m_keyboard.Keyboard->dwFlags & KF_CAPSALWAYSOFF) - { + DebugLog("Caps lock is %s, switching %s", capsLockCurrentlyOn ? "on" : "off", capsLockOn ? "on" : "off"); + + m_actions.QueueAction(QIT_CAPSLOCK, capsLockOn); + if (capsLockOn) { + modifiers |= CAPITALFLAG; + } else { + modifiers &= ~CAPITALFLAG; + } +} + +/** + * Deal with CapsAlwaysOff store option and turns caps lock off if necessary. + * Called by ProcessEvent. + * May update `modifiers` to add or remove `CAPITALFLAG` according to keyboard + * requirements. May queue actions to set caps lock state. + * + * @param[in,out] modifiers The modifier key bitmap + */ +void KMX_ProcessEvent::ResetCapsLock(KMX_DWORD &modifiers) { + if (m_keyboard.Keyboard->dwFlags & KF_CAPSALWAYSOFF) { DebugLog("ResetCapsLock: caps lock should be always off"); - if (m_environment.capsLock()) - { - DebugLog("ResetCapsLock: caps lock is on, switching off caps lock"); - m_actions.QueueAction(QIT_CAPSLOCK, 0); - } - } - DebugLog("ResetCapsLock: exit"); -} - - -void KMX_ProcessEvent::KeyCapsLockPress(KMX_BOOL FIsUp) -{ - if (m_keyboard.Keyboard->dwFlags & KF_CAPSONONLY) - { - if(FIsUp && !m_environment.capsLock()) - { - m_actions.QueueAction(QIT_CAPSLOCK, 1); - } - } - else if (m_keyboard.Keyboard->dwFlags & KF_CAPSALWAYSOFF) - { - if(!FIsUp && m_environment.capsLock()) - { - m_actions.QueueAction(QIT_CAPSLOCK, 0); - } + SetCapsLock(modifiers, FALSE); } } - -void KMX_ProcessEvent::KeyShiftPress(KMX_BOOL FIsUp) -{ - if(!m_environment.capsLock()) return; - - if (m_keyboard.Keyboard->dwFlags & KF_SHIFTFREESCAPS) - { - if(!FIsUp) - { - m_actions.QueueAction(QIT_CAPSLOCK, 0); - } +/** + * Deal with CapsLock store options on CapsLock key press. Called by ProcessEvent. + * May update `modifiers` to add or remove `CAPITALFLAG` according to keyboard + * requirements. May queue actions to set caps lock state. + * + * @param[in,out] modifiers The modifier key bitmap + * @param isKeyDown TRUE if this is called on KeyDown event, FALSE if + * called on KeyUp event + */ +void KMX_ProcessEvent::KeyCapsLockPress(KMX_DWORD &modifiers, KMX_BOOL isKeyDown) { + if (m_keyboard.Keyboard->dwFlags & KF_CAPSONONLY && !isKeyDown) { + SetCapsLock(modifiers, TRUE); + } else if (m_keyboard.Keyboard->dwFlags & KF_CAPSALWAYSOFF && isKeyDown) { + SetCapsLock(modifiers, FALSE); } } +/** + * Deal with CapsLock store options on Shift key press. Called by ProcessEvent. + * May update `modifiers` to remove `CAPITALFLAG` according to keyboard + * requirements. May queue actions to reset caps lock state. + * + * @param[in,out] modifiers The modifier key bitmap + * @param isKeyDown TRUE if this is called on KeyDown event, FALSE if + * called on KeyUp event + */ +void KMX_ProcessEvent::KeyShiftPress(KMX_DWORD &modifiers, KMX_BOOL isKeyDown) { + if (m_keyboard.Keyboard->dwFlags & KF_SHIFTFREESCAPS && isKeyDown) { + SetCapsLock(modifiers, FALSE); + } +} diff --git a/common/core/desktop/src/kmx/kmx_environment.cpp b/common/core/desktop/src/kmx/kmx_environment.cpp index 1e166225c1..4d3d3c5490 100644 --- a/common/core/desktop/src/kmx/kmx_environment.cpp +++ b/common/core/desktop/src/kmx/kmx_environment.cpp @@ -16,7 +16,6 @@ namespace { *DEFAULT_BASELAYOUT = u"kbdus.dll", *DEFAULT_BASELAYOUTALT = u"en-US", *DEFAULT_SIMULATEALTGR = u"0", - *DEFAULT_CAPSLOCK = u"0", *DEFAULT_BASELAYOUTGIVESCTRLRALTFORRALT = u"0"; } @@ -25,7 +24,6 @@ KMX_Environment::KMX_Environment() { Set(KM_KBP_KMX_ENV_BASELAYOUT, DEFAULT_BASELAYOUT); Set(KM_KBP_KMX_ENV_BASELAYOUTALT, DEFAULT_BASELAYOUTALT); Set(KM_KBP_KMX_ENV_SIMULATEALTGR, DEFAULT_SIMULATEALTGR); - Set(KM_KBP_KMX_ENV_CAPSLOCK, DEFAULT_CAPSLOCK); Set(KM_KBP_KMX_ENV_BASELAYOUTGIVESCTRLRALTFORRALT, DEFAULT_BASELAYOUTGIVESCTRLRALTFORRALT); } @@ -46,9 +44,6 @@ char16_t const * KMX_Environment::LookUp(std::u16string const & key) const { else if (!u16icmp(key.c_str(), KM_KBP_KMX_ENV_SIMULATEALTGR)) { return _simulateAltGr ? u"1" : u"0"; } - else if (!u16icmp(key.c_str(), KM_KBP_KMX_ENV_CAPSLOCK)) { - return _capsLock ? u"1" : u"0"; - } else if (!u16icmp(key.c_str(), KM_KBP_KMX_ENV_BASELAYOUTGIVESCTRLRALTFORRALT)) { return _baseLayoutGivesCtrlRAltForRAlt ? u"1" : u"0"; } @@ -74,9 +69,6 @@ void KMX_Environment::Set(std::u16string const & key, std::u16string const & val else if (!u16icmp(key.c_str(), KM_KBP_KMX_ENV_SIMULATEALTGR)) { _simulateAltGr = value == u"1"; } - else if (!u16icmp(key.c_str(), KM_KBP_KMX_ENV_CAPSLOCK)) { - _capsLock = value == u"1"; - } else if (!u16icmp(key.c_str(), KM_KBP_KMX_ENV_BASELAYOUTGIVESCTRLRALTFORRALT)) { _baseLayoutGivesCtrlRAltForRAlt = value == u"1"; } diff --git a/common/core/desktop/src/kmx/kmx_environment.h b/common/core/desktop/src/kmx/kmx_environment.h index f1ee70faf6..4d934e0d10 100644 --- a/common/core/desktop/src/kmx/kmx_environment.h +++ b/common/core/desktop/src/kmx/kmx_environment.h @@ -12,7 +12,6 @@ class KMX_Environment { private: KMX_BOOL _simulateAltGr, _baseLayoutGivesCtrlRAltForRAlt; std::u16string _baseLayout, _baseLayoutAlt; - KMX_BOOL _capsLock; std::u16string _platform; void InitOption( std::vector