Skip to content

Commit f21bd82

Browse files
authored
Merge branch 'master' into feat/core/9119-marker-core-epic-ldml
2 parents f1c7452 + add9a43 commit f21bd82

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+442
-108
lines changed

common/schemas/keyman-touch-layout/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,17 @@ and `width`.
399399
: Number. Defines the width of the key. Not currently supported for longpress
400400
keys. See `key` object for details.
401401

402+
* `default`
403+
404+
: Boolean. Defaults to `false`. If true, this will be the default key when the
405+
user longpresses the base key without moving their finger. Only one subkey
406+
should be default; if multiple subkeys have the default field set, then
407+
behaviour is undefined. Given that cancel is not the preferred default
408+
action for a longpress, the user can cancel the longpress default by
409+
sliding outside the 'acceptance' area -- e.g. south of the key cap,
410+
which would then unhighlight the default and indicate visually that
411+
no output would occur when they release their finger.
412+
402413
## `flick` object
403414

404415
A object with a set of properties that define flick keys for given directions.
@@ -445,6 +456,9 @@ string") into the appropriate spec format.
445456

446457
# .keyman-touch-layout version history
447458

459+
## 2023-08-08 2.1 stable
460+
* Add support for default on longpress (sk) keys. Aligns with Keyman 17.0.
461+
448462
## 2022-06-30 2.0 stable
449463
* Add support for flick, multitap, hint, defaultHint. Aligns with Keyman 16.0.
450464

common/schemas/keyman-touch-layout/keyman-touch-layout.spec.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@
131131
"width": { "$ref" : "#/definitions/numeric" },
132132
"fontsize": { "$ref": "#/definitions/fontsize-spec" },
133133
"font": { "$ref": "#/definitions/font-spec" },
134-
"dk": { "type": "string" }
134+
"dk": { "type": "string" },
135+
"default": { "type": "boolean" }
135136
},
136137
"required": ["id"],
137138
"additionalProperties": false

common/web/types/src/keyman-touch-layout/keyman-touch-layout-file-writer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ export class TouchLayoutFileWriter {
7777
if(Object.hasOwn(key, 'text') && key.text === '') delete key.text;
7878
if(Object.hasOwn(key, 'id') && <string>key.id === '') delete key.id;
7979
if(Object.hasOwn(key, 'hint') && (<any>key).hint === '') delete (<any>key).hint;
80+
if(Object.hasOwn(key, 'default') && (<any>key).default === false) delete (<any>key).default;
8081
};
8182

8283
const fixupPlatform = (platform: TouchLayoutPlatform) => {

common/web/types/src/keyman-touch-layout/keyman-touch-layout-file.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ export interface TouchLayoutSubKey {
7373
sp?: TouchLayoutKeySp;
7474
pad?: TouchLayoutKeyPad;
7575
width?: TouchLayoutKeyWidth;
76+
default?: boolean; // Only used for longpress currently
7677
};
7778

7879
export interface TouchLayoutFlick {

common/web/types/src/util/compiler-interfaces.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ export interface CompilerEvent {
66
line?: number;
77
code: number;
88
message: string;
9+
/**
10+
* an internal error occurred that should be captured with a stack trace
11+
* e.g. to the Keyman sentry instance by kmc
12+
*/
13+
exceptionVar?: any;
914
};
1015

1116
export enum CompilerErrorSeverity {
@@ -399,7 +404,13 @@ export const defaultCompilerOptions: CompilerOptions = {
399404
* @param message
400405
* @returns
401406
*/
402-
export const CompilerMessageSpec = (code: number, message: string) : CompilerEvent => { return { code, message } };
407+
export const CompilerMessageSpec = (code: number, message: string, exceptionVar?: any) : CompilerEvent => ({
408+
code,
409+
message: exceptionVar
410+
? (message ?? `Unexpected exception`) + `: ${exceptionVar.toString()}\n\nCall stack:\n${(exceptionVar instanceof Error ? exceptionVar.stack : (new Error()).stack)}` :
411+
message,
412+
exceptionVar
413+
});
403414

404415
/**
405416
* @deprecated use `CompilerError.exceptionToString` instead

core/src/km_kbp_processevent_api.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ km_kbp_event(
2828
switch(event) {
2929
case KM_KBP_EVENT_KEYBOARD_ACTIVATED:
3030
assert(data == nullptr);
31-
if(data == nullptr) {
31+
if(data != nullptr) {
3232
return KM_KBP_STATUS_INVALID_ARGUMENT;
3333
}
3434
break;

core/src/kmx/kmx_processevent.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ class KMX_ProcessEvent {
8686
/* Caps Lock and modifier management */
8787

8888
KMX_BOOL IsCapsLockOn(KMX_DWORD modifiers);
89-
void SetCapsLock(KMX_DWORD &modifiers, KMX_BOOL capsLockOn, KMX_BOOL force = FALSE);
9089
void ResetCapsLock(KMX_DWORD &modifiers, KMX_BOOL isKeyDown);
9190
KMX_BOOL KeyCapsLockPress(KMX_DWORD &modifiers, KMX_BOOL isKeyDown);
9291
void KeyShiftPress(KMX_DWORD &modifiers, KMX_BOOL isKeyDown);
@@ -107,6 +106,7 @@ class KMX_ProcessEvent {
107106
KMX_Environment *GetEnvironment();
108107
KMX_Environment const *GetEnvironment() const;
109108
INTKEYBOARDINFO const *GetKeyboard() const;
109+
void SetCapsLock(KMX_DWORD &modifiers, KMX_BOOL capsLockOn, KMX_BOOL force = FALSE);
110110

111111
// Utility function
112112
public:

core/src/kmx/kmx_processor.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,30 @@ kmx_processor::update_option(
103103
return option(scope, key, value);
104104
}
105105

106+
km_kbp_status
107+
kmx_processor::external_event(
108+
km_kbp_state* state,
109+
uint32_t event,
110+
void* _kmn_unused(data)
111+
) {
112+
113+
switch (event) {
114+
case KM_KBP_EVENT_KEYBOARD_ACTIVATED:
115+
// reset any current actions in the queue as a new keyboard
116+
// has been activated
117+
_kmx.GetActions()->ResetQueue();
118+
state->actions().clear();
119+
if (_kmx.GetKeyboard()->Keyboard->dwFlags & KF_CAPSALWAYSOFF) {
120+
KMX_DWORD dummy_modifiers = 0;
121+
_kmx.SetCapsLock(dummy_modifiers, FALSE, TRUE);
122+
}
123+
break;
124+
default:
125+
return KM_KBP_STATUS_INVALID_ARGUMENT;
126+
}
127+
return internal_process_queued_actions(state);
128+
}
129+
106130
bool
107131
kmx_processor::queue_action(
108132
km_kbp_state * state,

core/src/kmx/kmx_processor.hpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,14 @@ namespace kbp
5959
km_kbp_status
6060
process_queued_actions(
6161
km_kbp_state *state
62-
) override;
62+
) override;
63+
64+
km_kbp_status
65+
external_event(
66+
km_kbp_state* state,
67+
uint32_t event,
68+
void* data
69+
) override;
6370

6471
bool
6572
queue_action(

core/tests/unit/kmnkbd/action_items.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const char *action_item_types[] = {
2323
"KM_KBP_IT_PERSIST_OPT", // = 5, // The indicated option needs to be stored.
2424
"KM_KBP_IT_EMIT_KEYSTROKE", // = 6, // Emit the current keystroke to the application
2525
"KM_KBP_IT_INVALIDATE_CONTEXT", // = 7,
26+
"KM_KBP_IT_CAPSLOCK",// = 8, Enable or disable capsLock
2627
};
2728

2829
void print_action_item(const char *title, km_kbp_action_item const & item) {
@@ -50,6 +51,13 @@ void print_action_item(const char *title, km_kbp_action_item const & item) {
5051
<< " value: " << item.option->value << std::endl
5152
<< " scope: " << item.option->scope << std::endl;
5253
break;
54+
case KM_KBP_IT_CAPSLOCK:
55+
std::cout << " caps lock: " <<
56+
(item.capsLock == 0 ? "off" :
57+
item.capsLock == 1 ? "on" :
58+
"invalid value") << " (" <<
59+
item.capsLock << ")" << std::endl;
60+
break;
5361
}
5462
}
5563

@@ -68,6 +76,7 @@ bool operator==(
6876
lhs.backspace.expected_value == rhs.backspace.expected_value; break;
6977
case KM_KBP_IT_PERSIST_OPT: result = *lhs.option == *rhs.option; break;
7078
case KM_KBP_IT_EMIT_KEYSTROKE: break;
79+
case KM_KBP_IT_CAPSLOCK: result = lhs.capsLock == rhs.capsLock; break;
7180
case KM_KBP_IT_INVALIDATE_CONTEXT: break;
7281
default: std::cout << "unexpected type" << std::endl; return false; //
7382
}

0 commit comments

Comments
 (0)