-
-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(web): prototype KMX+ TouchLayout generator (in TS) #12305
Conversation
User Test ResultsTest specification and instructions ERROR: user tests have not yet been defined Test Artifacts
|
|
||
const keyNames = Object.keys(Codes.keyCodes); | ||
|
||
export function convertLayerList(layerList: LayerList, keys: Keys) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function converts one layer list (one pre-parsed entry of the layr.lists
subtable) into the OSK-friendly TouchLayout
format.
this.layerLists = layerLists; | ||
} | ||
|
||
private processLayers(layerTableOffset: number, strs: Strs, keys: Keys) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method may include some "heavy lifting" to assist the convertLayerList
method.
* - strs | ||
* - list - needs strs | ||
* - keys - needs lsts | ||
* - layr - needs keys, others. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
disp
could probably go after strs
or list
- it only really needs to reference strs
, I believe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct
return [...data.slice(start, start+4)].map((x) => String.fromCharCode(x)).join(''); | ||
} | ||
|
||
export function decodeString(data: Uint8Array, start: number, len: number) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the UTF-16LE strs
table.
|
||
const layout = convertLayerList(kbdObj.layr.layerLists[0], kbdObj.keys); | ||
|
||
console.log(JSON.stringify(layout, null, 2)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is the source of the example touch-layout I placed in the PR's description.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reasonable though should be able to reuse constants from the compiler side?
@@ -173,8 +173,8 @@ Then for each string: | |||
|
|||
| ∆ | Bits | Name | Description | | |||
|---|------|---------------|-----------------------------------------------| | |||
|16+| 32 | offset | off: Offset to string | | |||
|20+| 32 | length | int: Length of string in UTF-16LE code units | | |||
|12+| 32 | offset | off: Offset to string | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops, good catch!
} | ||
} | ||
|
||
// TODO: no good current fixture available with data for this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unit tests only
const keyCount = decodeNumber(rawData, 8); | ||
const flicksCount = decodeNumber(rawData, 12); | ||
|
||
const FLICK_GROUP_LEN = 12; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now, shouldn't this file be able to use https://github.com/keymanapp/keyman/blob/master/core/include/ldml/keyman_core_ldml.ts ?
so:
const FLICK_GROUP_LEN = 12; | |
const FLICK_GROUP_LEN = Constants.length_keys_flick_list; |
* - strs | ||
* - list - needs strs | ||
* - keys - needs lsts | ||
* - layr - needs keys, others. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct
We are approaching this from a different direction and keeping kmx+ interpretation entirely within Core |
without sharing constants? |
A few constants are helpful, e.g. VKs and modifiers but those are not kmx+-specific. |
I think you are saying "a different direction from this PR". - my comment above is that https://github.com/keymanapp/keyman/blob/master/core/include/ldml/keyman_core_ldml.ts contains the offsets and KMX+ specific constants from the spec and could be shared here. Speaking of spec, perhaps the spec corrections should be split out from this PR? |
Good point, will do. |
Closing this. We will parse kmx+ layout data in Keyman Core and pass it to Keyman Engine for Web through a new Core API. |
In order to build the touch-layout required for OSK construction for KMX+ keyboards, we either need that layout to be pre-compiled... or we need the ability to parse a KMX+ file in order to find the data we need. This PR represents initial efforts toward the latter - parsing the KMX+ format in order to construct a viable TouchLayout that the OSK may consume.
Actual converted layout!
Using the KMX+ keyboard
imperial_aramaic.kmx
, as output for keymanapp/keyboards#2993...Known limitations:
K_
key, we handle that perfectly fine.