Skip to content

feat(windows): Change caps to work with common core processor#5803

Merged
rc-swag merged 9 commits intomasterfrom
feat/windows/keyman-caps-lock-stores
Oct 15, 2021
Merged

feat(windows): Change caps to work with common core processor#5803
rc-swag merged 9 commits intomasterfrom
feat/windows/keyman-caps-lock-stores

Conversation

@rc-swag
Copy link
Copy Markdown
Contributor

@rc-swag rc-swag commented Oct 6, 2021

The Keyman for Windows engine now sends through the Modifier key presses to the core processor so it could evaluate the key press against the keyboard rules for Caps. The Windows engine now to process the KM_KBP_IT_CAPSLOCK action and synthesizes key presses accordingly.
Fixes #5652

@keymanapp-test-bot keymanapp-test-bot bot added the user-test-missing User tests have not yet been defined for the PR label Oct 6, 2021
@keymanapp-test-bot
Copy link
Copy Markdown

keymanapp-test-bot bot commented Oct 6, 2021

User Test Results

Test specification and instructions

✅ SUITE_CL: Caps Lock

  • TEST_CAPSLOCK-1 (PASSED): pass. does get output when a is pressed and released with the CapsLock on.
  • TEST_CAPSLOCK-2 (PASSED): pass. does get output when shift b are pressed and released with the CapsLock on.
  • TEST_CAPSLOCK-3 (PASSED): pass. does get output when shift 3 are pressed and released with the CapsLock on.
  • TEST_CAPSLOCK-4 (PASSED): pass. does get output when c is pressed and released with the CapsLock on.
  • TEST_CAPSLOCK-5 (PASSED): pass. does get output when shift d are pressed with the CapsLock on.

✅ SUITE_OFF: CapsAlwaysOff

  • TEST_CAPSOFF-1 (PASSED): ncaps_little_a does get output when a is pressed and released on the MV's soft keyboard with the CapsLock off.
  • TEST_CAPSOFF-2 (PASSED): ncaps_little_a does get output and the CapsLock stays turned off when CapsLock is pressed and released on the MV's soft keyboard with the CapsLock off.
  • TEST_CAPSOFF-3 (PASSED): ncaps_little_a does get output when CapsLock is pressed and held on the hardware keyboard and a is pressed and relased with the CapsLock off.
  • TEST_CAPSOFF-4 (PASSED): ncaps_shift_A does get output when CapsLock and shift are pressed and held on the hardware keyboard with the CapsLock off.
  • TEST_CAPSOFF-5 (PASSED): ncaps_little_a does get output and the CapsLock turned off when a is pressed and released on the MV's soft keyboard with the CapsLock on.

🟥 SUITE_SHIFT: CapsOnOnly/ShiftFreesCaps

  • TEST_CAPSONLY-1 (PASSED): pass. does get output when 1 is pressed and released on the VM's soft keyboard with the CapsLock off.
  • TEST_CAPSONLY-2 (PASSED): pass. does get output and CapsLock key indicator turned on when CapsLock is pressed and released and then 2 is pressed and released on the VM's soft keyboard with the CapsLock initially off.
  • TEST_CAPSONLY-3 (PASSED): pass. does get output and CapsLock key indicator turned on when CapsLock is pressed and released twice and then 6 is pressed and released on the VM's soft keyboard with the CapsLock initially off.
  • TEST_CAPSONLY-4 (PASSED): pass. does get output and CapsLock key indicator turned off when CapsLock is pressed and released and shift is pressed and held and then 3 is pressed and released on the VM's soft keyboard with the CapsLock initially off.
  • 🟥 TEST_CAPSONLY-5 (FAILED): The CapsLock and Shift key indicators are all stay on. (notes)

@rc-swag
Copy link
Copy Markdown
Contributor Author

rc-swag commented Oct 7, 2021

User Testing

SUITE_CL: Caps Lock

The test keyboard layouts are found in the keyman repo at app/windows/src/test/manual-tests/caps-lock-stores. There is a project file for the 3 keyboards used in this test. The project file can be used to build the keyboard packages required for the following tests.

The test cases below expect the usage of the capslock.kmp keyboard. That keyboard outputs pass or fail if following the test cases.

Prerequisites before each test

  • System keyboard layout is en-US
  • Install a keyboard that doesn't use any of the caps lock stores, e.g. capslock.kmp.
  • CapsLock is currently on
  • Currently active keyboard is the capslock.kmp keyboard

Test cases

  • TEST_CAPSLOCK-1: uppercase with virtual key

    • press and release a

    Expected result:

    • pass. (with other keyboards uppercase A)
  • TEST_CAPSLOCK-2: lowercase with virtual key

    • press and hold 'Shift'
    • press and release b
    • release Shift

    Expected result:

    • pass. (with other keyboards lowercase b)
  • TEST_CAPSLOCK-3: capslock ignored for numbers

    • press and hold 'Shift'
    • press and release 3
    • release Shift

    Expected result:

    • pass. (with other keyboards #)
  • TEST_CAPSLOCK-4: uppercase

    • press and release c

    Expected result:

    • pass. (with other keyboards uppercase C)
  • TEST_CAPSLOCK-5: lowercase

    • press and hold 'Shift'
    • press and release d
    • release Shift

    Expected result:

    • pass. (with other keyboards lowercase d)

SUITE_OFF: CapsAlwaysOff

For these tests, use a keyboard with the CapsAlwaysOff store set. We call this keyboard capsalwaysoff below.

Any keyboard with that store set will work; if you don't have one at hand you can use the caps_always_off.kmp keyboard. The caps_always_off.kmp keyboard will prevent switching caps lock on. As a sanity check to verify that Keyman is actually active, pressing the key a will output ncaps_little_a, and Shift+a will output ncaps_shift_A.

Note: When testing in a virtual machine, use an on-screen keyboard (in VirtualBox: Input/Keyboard/Soft Keyboard) and observe the caps lock indicator of the on-screen keyboard. Using the hardware keyboard might show side effects with caps lock.

Prerequisites before each test

  • Install a keyboard that has CapsAlwaysOff store set, e.g. caps_always_off.kmp.
  • CapsLock is currently off
  • Currently active keyboard is a non-Keyman keyboard

Test cases

  • TEST_CAPSOFF-1: sanity check

    • switch to capsalwaysoff keyboard
    • press and release a

    Expected result:

    • output: ncaps_little_a
  • TEST_CAPSOFF-2: caps lock stays off

    • switch to capsalwaysoff keyboard
    • press and release CapsLock key
    • press and release a

    Expected result:

    • caps lock indicator stays turned off
    • output: ncaps_little_a
  • TEST_CAPSOFF-3: no caps lock while holding capslock key

    • switch to capsalwaysoff keyboard
    • press and hold CapsLock key
    • press and release a
    • release CapsLock key

    Expected result:

    • output: ncaps_little_a
  • TEST_CAPSOFF-4: no caps lock while holding capslock key

    • switch to capsalwaysoff keyboard
    • press and hold CapsLock key
    • press and hold Shift key
    • press and release a
    • release CapsLock and Shift keys

    Expected result:

    • output: ncaps_shift_A
  • TEST_CAPSOFF-5: switching turns off caps lock

    • turn on caps lock
    • switch to capsalwaysoff keyboard
    • press and release a

    Expected result:

    • caps lock indicator turned off
    • output: ncaps_little_a

SUITE_SHIFT: CapsOnOnly/ShiftFreesCaps

For these tests, use a keyboard with the CapsOnOnly and ShiftFreesCaps stores set. We call this keyboard shift_frees_caps below.

Any keyboard with these stores set will work; if you don't have one at hand you can use the shift_frees_caps.kmp keyboard.

The shift_frees_caps.kmp keyboard will enable caps lock by pressing the CapsLock key, and will turn capslock off by pressing the Shift key. The keyboard outputs pass or fail if following the test cases.

Note: When testing in a virtual machine, use an on-screen keyboard (in VirtualBox: Input/Keyboard/Soft Keyboard) and observe the caps lock indicator of the on-screen keyboard. Using the hardware keyboard might show side effects with caps lock.

Prerequisites before each test

  • Install a keyboard that has the CapsOnOnly and ShiftFreesCaps stores set, e.g.
    shift_frees_caps.kmp.
  • CapsLock is currently off
  • Currently active keyboard is shift_frees_caps keyboard

Test cases

  • TEST_CAPSONLY-1: no caps

    • press and release 1

    Expected result:

    • output: pass.
  • TEST_CAPSONLY-2: caps

    • press and release CapsLock
    • press and release 2

    Expected result:

    • caps lock indicator turned on
    • output: pass.
  • TEST_CAPSONLY-3: caps doesn't toggle

    • press and release CapsLock
    • press and release CapsLock
    • press and release 6

    Expected result:

    • caps lock indicator turned on
    • output: pass.
  • TEST_CAPSONLY-4: shift turns off

    • press and release CapsLock
    • press and hold Shift
    • press and release 3
    • release Shift

    Expected result:

    • caps lock indicator turned off
    • output: pass.
  • TEST_CAPSONLY-5: shift by itself turns off

    • press and release CapsLock
    • press and release Shift

    Expected result:

    • caps lock indicator turned off
    • (no output)

@keymanapp-test-bot keymanapp-test-bot bot added user-test-required User tests have not been completed and removed user-test-missing User tests have not yet been defined for the PR labels Oct 7, 2021
@rc-swag rc-swag marked this pull request as ready for review October 7, 2021 06:08
Copy link
Copy Markdown
Member

@mcdurdin mcdurdin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really clean. There's one functional change I think we need to make (!Updateable) which may have side-effects so will need testing. Apart from that LGTM.

Comment on lines +83 to +87
// We only want to process the Caps Lock key event once --
// in the first pass (!Updateable).
if (Updateable){
return TRUE;
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't be processing in the !Updateable pass -- this is essentially read-only.

@rc-swag
Copy link
Copy Markdown
Contributor Author

rc-swag commented Oct 8, 2021

This looks really clean. There's one functional change I think we need to make (!Updateable) which may have side-effects so will need testing. Apart from that LGTM.

I have done some testing this morning. Processing only on the Updatable pass doesn't work for CapsOnly && ShiftFressCaps. It also makes CapsAlwaysOff a bit flakey it will always produce lower case letters but with mashing the caps lock key you can get the caps lock indicator to stay on until the next key press.
I am looking into it more to see if I can get it to work.

Copy link
Copy Markdown
Member

@mcdurdin mcdurdin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh my bad. I just looked at the code comment in the old Windows core and it was exactly the same -- doing this in the !Updateable pass. So clearly that works and has been the One True Method for all this time, so let's go with it!

LGTM

…caps-tests

feat(windows): manual keyboard caps tests
@MakaraSok
Copy link
Copy Markdown

The test keyboard layouts are found in the keyman repo at app/windows/src/test/caps_lock_stores.

The path to the keyboard packages for testing this PR doesn't exist, but there is something like this keyman\windows\src\test\manual-tests\caps-lock-stores. Please confirm. Thanks.

@rc-swag
Copy link
Copy Markdown
Contributor Author

rc-swag commented Oct 12, 2021

The test keyboard layouts are found in the keyman repo at app/windows/src/test/caps_lock_stores.

The path to the keyboard packages for testing this PR doesn't exist, but there is something like this keyman\windows\src\test\manual-tests\caps-lock-stores. Please confirm. Thanks.

Yes this is correct and I have updated the test instructions

@MakaraSok
Copy link
Copy Markdown

SUITE_CL: Caps Lock

  • TEST_CAPSLOCK-1: PASSED pass. does get output when a is pressed and released with the CapsLock on.
  • TEST_CAPSLOCK-2: PASSED pass. does get output when shift b are pressed and released with the CapsLock on.
  • TEST_CAPSLOCK-3: PASSED pass. does get output when shift 3 are pressed and released with the CapsLock on.
  • TEST_CAPSLOCK-4: PASSED pass. does get output when c is pressed and released with the CapsLock on.
  • TEST_CAPSLOCK-5: PASSED pass. does get output when shift d are pressed with the CapsLock on.

SUITE_OFF: CapsAlwaysOff

  • TEST_CAPSOFF-1: PASSED ncaps_little_a does get output when a is pressed and released on the MV's soft keyboard with the CapsLock off.
  • TEST_CAPSOFF-2: PASSED ncaps_little_a does get output and the CapsLock stays turned off when CapsLock is pressed and released on the MV's soft keyboard with the CapsLock off.
  • TEST_CAPSOFF-3: PASSED ncaps_little_a does get output when CapsLock is pressed and held on the hardware keyboard and a is pressed and relased with the CapsLock off.
  • TEST_CAPSOFF-4: PASSED ncaps_shift_A does get output when CapsLock and shift are pressed and held on the hardware keyboard with the CapsLock off.
  • TEST_CAPSOFF-5: PASSED ncaps_little_a does get output and the CapsLock turned off when a is pressed and released on the MV's soft keyboard with the CapsLock on.

@MakaraSok
Copy link
Copy Markdown

SUITE_SHIFT: CapsOnOnly/ShiftFreesCaps

  • TEST_CAPSONLY-1: PASSED pass. does get output when 1 is pressed and released on the VM's soft keyboard with the CapsLock off.
  • TEST_CAPSONLY-2: PASSED pass. does get output and CapsLock key indicator turned on when CapsLock is pressed and released and then 2 is pressed and released on the VM's soft keyboard with the CapsLock initially off.
  • TEST_CAPSONLY-3: PASSED pass. does get output and CapsLock key indicator turned on when CapsLock is pressed and released twice and then 6 is pressed and released on the VM's soft keyboard with the CapsLock initially off.
  • TEST_CAPSONLY-4: PASSED pass. does get output and CapsLock key indicator turned off when CapsLock is pressed and released and shift is pressed and held and then 3 is pressed and released on the VM's soft keyboard with the CapsLock initially off.
  • TEST_CAPSONLY-5: FAILED The CapsLock and Shift key indicators are all stay on.

@keymanapp-test-bot keymanapp-test-bot bot removed the user-test-required User tests have not been completed label Oct 12, 2021
@rc-swag
Copy link
Copy Markdown
Contributor Author

rc-swag commented Oct 12, 2021

For TEST_CAPSONLY-5: FAILED I tested the team city build for this PR on windows "on the metal" machine (not a VM) and this test passes. The way the on-screen keyboard sends the shift events seems different. Visually you click shift once and an indicator goes on(green) then you press it again and the indicator goes amber, you have to press it a 3rd time to go off.
@ermshiperete I know you had something similar on the linux side when using a linux VM. In your case though I think at least the VM virtual keyboard worked, even though the hardware keyboard didn't?

@MakaraSok I just thought can check this with the old windows keyboard processor as a reference. To do this go into keyman configuration, select options on the left-hand side, down the bottom is keyman system settings select that it will bring up a list of settings you can modify. Change the use common core to 0, apply and restart keyman. You should notice that the keyman core icon is no longer in the task bar icons. Now try TEST_CAPONLY-5 in the VM again and see if it works.
image

@MakaraSok
Copy link
Copy Markdown

Now try TEST_CAPONLY-5 in the VM again and see if it works.

The same behavior. The CapsLock won't go off after pressing the Shift key on the VM soft keyboard.

image

@rc-swag
Copy link
Copy Markdown
Contributor Author

rc-swag commented Oct 14, 2021

Talking with @ermshiperete using the VM soft keyboard it does NOT actually send the Shift Shift Key Stroke through but rather will change the keys pressed for example if an a is pressed the soft keyboard itself will change that key to a A. This means we can't do Test TEST_CAPONLY-5 on a soft keyboard. I will still merge this PR as it passes when an actual shift stroke is sent through.
And the current windows processor gives the same result when using the soft VM keyboard.

@rc-swag rc-swag merged commit ab0f50d into master Oct 15, 2021
@rc-swag rc-swag deleted the feat/windows/keyman-caps-lock-stores branch October 15, 2021 06:03
@rc-swag rc-swag self-assigned this Jun 2, 2023
@rc-swag rc-swag added this to the A15S15 milestone Jun 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(windows): Keyman Core Integration - Full support for Caps Lock system stores 🥑

3 participants