feat(common/core/desktop): Allow preserved key support#5850
Conversation
User Test ResultsTest specification and instructions
Test Artifacts |
|
|
||
|
|
||
| void km_kbp_keyboard_key_list_dispose(km_kbp_keyboard_key *key_list); |
There was a problem hiding this comment.
Need to document this function too 😉
| km_kbp_keyboard_key *key_rule_it = kb_key_list; | ||
| auto n = 0; | ||
| for (; key_rule_it->key; ++key_rule_it) { | ||
| ++n; | ||
| } |
There was a problem hiding this comment.
Can we assert the values returned as well? I would also like to see a test for a more complex keyboard with multiple groups and with the same keys referred in multiple groups (to validate that we don't list keys more than once). We cannot assume the list order so will need to be careful on testing results!
| } else { | ||
| if (!_td->lpActiveKeyboard->Keyboard) { | ||
| return FALSE; | ||
| } | ||
| return pkm.MapKeyboard(_td->lpActiveKeyboard->Keyboard, pPreservedKeys, cPreservedKeys); | ||
| } |
There was a problem hiding this comment.
Do we want to add the issue number for future removal of this code and related functions?
|
Jenkins failure: |
| @@ -0,0 +1,28 @@ | |||
| c Description: Tests multiple groups. Purpose here is to interleave output and backspaces from kmx processor to consumer | |||
There was a problem hiding this comment.
Looks like this test doesn't run (because it's not listed in meson.build). I see that it's used in kmx_key_list.cpp. If it's intended to be used only from that test than IMO it would be better and less confusing to rename it to kmx_key_list.kmn or something like that.
There was a problem hiding this comment.
Yes, when I was first setting it up I as going to create a new expected key list comment to go in the header of the kmn so that it would test with kmx.cpp. I ended up with having it all testested from kmx_key_list.cpp I will rename this to the suggested name.
There was a problem hiding this comment.
@ermshiperete I fixed the what I thought where the issues with kmx_key_list and the meson.build, but the jenkins build is still failing. Can you also add my user to the build so I can view it in Jenkins?
ermshiperete
left a comment
There was a problem hiding this comment.
Looks like 049 - groups ctrlalt.kmx is still present!?
| return 1; | ||
| } | ||
|
|
||
| km_kbp_keyboard_key kb_key_expected_list[] = {{49,16384},{50,16384},{66,16416},{67,16384},{67,16448},{97,0},{98,0}}; |
There was a problem hiding this comment.
The test might be easier to understand if we'd use the KM_KBP_VKEY_* and KM_KBP_MODIFIER_* consts here, especially when looking at the .kmn file and trying to understand the expected list here.
| return TRUE; | ||
| } | ||
|
|
||
| if (*cPreservedKeys < cKeys) { |
There was a problem hiding this comment.
Shouldn't we set *cPreservedKeys = cKeys here as well?
There was a problem hiding this comment.
If we get to this if statement it means the size of the array of PreservedKeys pPreservedKeys is going to be big enough to store all the keys. So it returns False.
When ::MapKeyboardCore is called if pPreservedKeys is NULL, we set *cPreservedKeys to the size pPreservedKeys needs to be.
So in the other cases we don't set cPreservedKeys
| ++cRules; | ||
| } | ||
| cKeys = cRules; | ||
| if (cKeys == 0) { |
There was a problem hiding this comment.
Shouldn't we set *cPreservedKeys = cKeys here as well?
There was a problem hiding this comment.
I guess we could check if pPreservedKeys == NULL and set *cPreservedKeys = cKeys basically setting it to zero. but in this case we are returning FALSE anyway. So if the function is returning FALSE for failure, I don't think the *cPreservedKeys should be trusted.
This also mimics the behaviour of the current ::MapCore
|
@mcdurdin The comment @ermshiperete made about using constants instead of magic numbers in the |
Two possible solutions. I lean towards the first. Translate the characters to US vkeys before returning from kmx processorThis is probably the cleanest way to solve the issue. v_key = p_group->dpKeyArray[j].Key;
modifier_flag = p_group->dpKeyArray[j].ShiftFlags;
if(modifier_flag == 0) {
if(!MapUSCharToVK(&v_key, &modifier_flag)) continue;
}
map_rules[std::make_pair(v_key,modifier_flag)] = modifier_flag;Live with itThis alternative is also okay, although not great. We have many kmx processor details that inform the design of the Keyman Core API. The fact that the kmx processor can report chars as well as vkeys should be documented, not ignored :-). However, let's split out the char pattern as a separate bit property rather than encoding it into the (Noted also, use That hides the worst of the implementation details (a |
|
Per discussion, moving back to draft to eliminate use of characters in place of virtual keys outside the boundaries of kmx processor. |
This work has now been done and ready for re-review. |
|
Jenkins error: This suggests kmx_conversion.cpp needs to be added to linux\ibus-keyman\tests\Makefile.am. (It's a shame we are not using meson here!) |
The pkeys was using the wrong counter as a index in the map check therefore matching the incorrect key
Co-authored-by: Marc Durdin <marc@durdin.net>
Also update issue comment for future removal of winows processor code
Co-authored-by: Eberhard Beilharz <ermshiperete@users.noreply.github.com>
c154681 to
cfed6f1
Compare
Indeed. I have it on my to-do list though 😄 - probably should create an issue for it: #5981 |
|
Changes in this pull request will be available for download in Keyman version 15.0.157-alpha |

Fixes: #5777
Add
km_kbp_keyboard_get_key_rulesto get a list of virtual keys and the shift modifiers that are used in the keyboard rules.The data structure for each item in the list is
There is more information in the
kmxprocessor implmentation for a key.Line;dpOutput;dpContext;. These seemed to be processor specific, and they are coupled toGroupagain which is akmxspecific rule layout. I wasn't sure what would be useful to have in a list of "keys". So if I am after guidance if this data structure should contain more information in this public api call to make it a more useful API call. The other option would be to make this an encode/decode pair with the structured data type which would then allow more info to be added tokm_kbp_keyboard_key_ruleswithout breaking previous implementations. That is it would be backward compatible.User Testing
All tests are for keyman for windows.
TEST_PRESERVEDKEYS
This is to test the key rules which contain AltGr or Shift + AltGr work correctly.
Load a keyboard
khmer_angkorOpen LibreOffice or Notepad
Type a AltGr + o
Observere output of ឱ
Type a Shift + AltGr + o
Observere output of ᧨