Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 122 additions & 0 deletions common/schemas/kvk/kvk.ksy
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
meta:
id: kvk
title: Keyman Visual Keyboard
file-extension: kvk
license: MIT
ks-version: 0.9
endian: le
bit-endian: le
doc: |
KVK is the binary file format for Keyman Visual Keyboard
files. KVKS is the equivalent XML source file format
doc-ref:
- https://github.com/keymanapp/keyman/
seq:
- id: header
type: header
- id: keys
type: keys
types:
header:
seq:
- id: identifier
contents: 'KVKF'
doc: Magic file identifier, always KVKF
- id: version
contents: [0, 6, 0, 0]
doc: Version number of KVK file format, always 0x00000600
- id: flag
type: header_flags
- id: associated_keyboard
type: string
- id: ansi_font
type: font
- id: unicode_font
type: font

header_flags:
seq:
- id: display_102
type: b1
doc: kvkh102, Keyboard should display 102nd key
- id: display_underlying
type: b1
doc: kvkhDisplayUnderlying, Keyboard should display underlying characters
- id: use_underlying
type: b1
doc: kvkhUseUnderlying,
- id: altgr
type: b1
doc: kvkhAltGr, Keyboard should treat left/right Ctrl and Alt separately

keys:
seq:
- id: count
type: u4
- id: key
type: key
repeat: expr
repeat-expr: count
key:
seq:
- id: flags
type: key_flags
- id: modifiers
type: key_modifiers
- id: vkey
type: u2
- id: text
type: string
- id: bitmap
type: u4

key_modifiers:
seq:
- id: shift
type: b1
- id: ctrl
type: b1
- id: alt
type: b1
- id: lctrl
type: b1
- id: rctrl
type: b1
- id: lalt
type: b1
- id: ralt
type: b1
- id: padding
type: b1
doc: reserved,
- id: zeropad
contents: [0]

key_flags:
seq:
- id: bitmap
type: b1
- id: unicode
type: b1
- id: padding
type: b6

font:
seq:
- id: name
type: string
- id: size
type: u4
- id: color
type: u4

string:
seq:
- id: len
type: u2
- id: str
type: str
size: len*2 - 2
encoding: utf-16
- id: zero_terminator
contents: [0,0]
14 changes: 14 additions & 0 deletions common/schemas/kvks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# .kvks schema

This schema validates .kvks files, according to the reference implementation
from VisualKeyboardLoaderXML.pas.

## Notes on conversion from xsd to json-schema

Converted using xsd2json. Following structural changes:

* kvk-version base type from km-version to string, copy km-version pattern in
* remove xs:all bracketing
* remove format:double from fontsize, change type to string
* encoding property changed type to array
* kvk-key added _ property for base text value
155 changes: 155 additions & 0 deletions common/schemas/kvks/kvks.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
{
"title": "kvks.xsd",
"$schema": "http://json-schema.org/schema#",
"type": "object",
"properties": {
"visualkeyboard": {
"properties": {
"header": {
"$ref": "#/definitions/kvk-header"
},
"encoding": {
"type": "array",
"items": {
"$ref": "#/definitions/kvk-encoding"
}
}
},
"required": [
"header"
],
"additionalProperties": false,
"type": "object"
}
},
"required": [
"visualkeyboard"
],
"additionalProperties": false,
"definitions": {
"kvk-header": {
"type": "object",
"properties": {
"version": {
"$ref": "#/definitions/kvk-version"
},
"kbdname": {
"type": "string"
},
"flags": {
"$ref": "#/definitions/kvk-header-flags"
},
"layout": {
"type": "string"
}
},
"required": [
"version"
],
"additionalProperties": false
},
"kvk-header-flags": {
"type": "object",
"properties": {
"key102": {
"$ref": "#/definitions/km-empty"
},
"displayunderlying": {
"$ref": "#/definitions/km-empty"
},
"usealtgr": {
"$ref": "#/definitions/km-empty"
},
"useunderlying": {
"$ref": "#/definitions/km-empty"
}
},
"additionalProperties": false
},
"kvk-encoding": {
"type": "object",
"properties": {
"layer": {
"type": "array",
"items": {
"$ref": "#/definitions/kvk-layer"
}
},
"name": {
"$ref": "#/definitions/kvk-encoding-name"
},
"fontname": {
"type": "string"
},
"fontsize": {
"type": "string"
}
},
"required": [
"name"
],
"additionalProperties": false
},
"kvk-layer": {
"type": "object",
"properties": {
"key": {
"type": "array",
"items": {
"$ref": "#/definitions/kvk-key"
}
},
"shift": {
"$ref": "#/definitions/kvk-layer-shift"
}
},
"required": [
"shift"
],
"additionalProperties": false
},
"kvk-key": {
"type": "object",
"properties": {
"bitmap": {
"type": "string"
},
"vkey": {
"type": "string"
},
"_": {
"type": "string"
}
},
"required": [
"vkey"
],
"additionalProperties": false
},
"km-empty": {
"type": "string"
},
"kvk-encoding-name": {
"type": "string",
"enum": [
"ansi",
"unicode"
]
},
"kvk-layer-shift": {
"type": "string",
"pattern": "S?(C|LC|RC)?(A|LA|RA)?"
},
"kvk-version": {
"type": "string",
"pattern": "(\\d+\\.)+(\\d+)",
"enum": [
"10.0"
]
},
"km-version": {
"type": "string",
"pattern": "(\\d+\\.)+(\\d+)"
}
}
}
92 changes: 92 additions & 0 deletions common/schemas/kvks/kvks.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
.kvks file schema, version 10.0

Copyright (C) SIL International

Supports KVKS files for Keyman Developer 10+

Expects version 10.0
-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:element name="visualkeyboard">
<xs:complexType>
<xs:all>
<xs:element name="header" type="kvk-header" />
<xs:element minOccurs="0" name="encoding" type="kvk-encoding" />
</xs:all>
</xs:complexType>
</xs:element>

<xs:complexType name="kvk-header">
<xs:all>
<xs:element name="version" type="kvk-version" />
<xs:element minOccurs="0" name="kbdname" type="xs:string" />
<xs:element minOccurs="0" name="flags" type="kvk-header-flags" />
<xs:element minOccurs="0" name="layout" type="xs:string" />
</xs:all>
</xs:complexType>

<xs:complexType name="kvk-header-flags">
<xs:all>
<xs:element minOccurs="0" name="key102" type="km-empty" />
<xs:element minOccurs="0" name="displayunderlying" type="km-empty" />
<xs:element minOccurs="0" name="usealtgr" type="km-empty" />
<xs:element minOccurs="0" name="useunderlying" type="km-empty" />
</xs:all>
</xs:complexType>

<xs:complexType name="kvk-encoding">
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" name="layer" type="kvk-layer" />
</xs:sequence>
<xs:attribute name="name" type="kvk-encoding-name" use="required" />
<xs:attribute name="fontname" type="xs:string" />
<xs:attribute name="fontsize" type="xs:double" />
</xs:complexType>

<xs:simpleType name="kvk-encoding-name">
<xs:restriction base="xs:string">
<xs:enumeration value="ansi" />
<xs:enumeration value="unicode" />
</xs:restriction>
</xs:simpleType>

<xs:complexType name="kvk-layer">
<xs:sequence><xs:element minOccurs="0" maxOccurs="unbounded" name="key" type="kvk-key" /></xs:sequence>
<xs:attribute name="shift" use="required" type="kvk-layer-shift" />
</xs:complexType>

<xs:simpleType name="kvk-layer-shift">
<xs:restriction base="xs:string">
<xs:pattern value="S?(C|LC|RC)?(A|LA|RA)?" />
</xs:restriction>
</xs:simpleType>

<xs:complexType name="kvk-key" mixed="true">
<xs:sequence>
<xs:element minOccurs="0" name="bitmap" type="xs:string" />
</xs:sequence>
<xs:attribute name="vkey" type="xs:string" use="required" />
</xs:complexType>

<xs:simpleType name="kvk-version">
<xs:restriction base="km-version">
<xs:enumeration value="10.0" />
</xs:restriction>
</xs:simpleType>

<!-- Some base types -->

<xs:complexType name="km-empty">
<xs:sequence/>
</xs:complexType>

<xs:simpleType name="km-version">
<xs:restriction base="xs:string">
<xs:pattern value="(\d+\.)+(\d+)"/>
</xs:restriction>
</xs:simpleType>

</xs:schema>
1 change: 1 addition & 0 deletions developer/src/kmc-keyboard/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ else
# We need the schema file at runtime and bundled, so always copy it for all actions except `clean`
mkdir -p "$THIS_SCRIPT_PATH/build/src/"
cp "$KEYMAN_ROOT/resources/standards-data/ldml-keyboards/techpreview/ldml-keyboard.schema.json" "$THIS_SCRIPT_PATH/build/src/"
cp "$KEYMAN_ROOT/common/schemas/kvks/kvks.schema.json" "$THIS_SCRIPT_PATH/build/src/"
fi

#-------------------------------------------------------------------------------------------------------------------
Expand Down
Loading