- commit
- 68b1d7b4898d308ddee7baf4e5269e4c93e8c8b7
- parent
- 9ed422188d81541280efae4565815703c55bf20a
- author
- Dami <dami.etoile@gmail.com>
| M | crates/ | 2 | ++ |
| M | docs/ | 14 | +++++++++----- |
| M | portal/ | 5 | +++-- |
| M | portal/ | 16 | +++++++++++----- |
@@ -495,6 +495,8 @@ mod tests {
495495 );496496 assert!(InputEvent::MouseDown { b: 9 }.validate().is_err());497497 assert!(InputEvent::KeyUp { k: String::new() }.validate().is_err());498+ // This exercises the UTF-8 byte bound only; protocol validation does499+ // not imply that arbitrary Unicode is an operational keyboard input.498500 assert!(499501 InputEvent::KeyDown {500502 k: "é".repeat(MAX_KEY_IDENTIFIER_UTF8_BYTES / 2)@@ -1318,11 +1318,15 @@ separate `gamepad` input capability and rejects gamepad snapshots unless that
13181318 capability was negotiated.13191319 13201320 It releases every held keyboard/mouse transition and sends a fully neutral1321-gamepad snapshot when an input session ends. The client currently sends a Text1322-event in addition to physical printable-key events; the host explicitly treats1323-Text as a content-free no-op, acknowledges it when ACKs were negotiated, and1324-does not advertise Text support. No key, text, or gamepad payload is logged.1325-The Linux button/axis assignments follow the kernel's1321+gamepad snapshot when an input session ends. Portal sends a bounded subset of1322+W3C `KeyboardEvent.code` physical-position tokens for keyboard input. This1323+keeps game and Steam bindings independent of the client's active keyboard1324+layout. The current uinput backend advertises keyboard input but does not1325+advertise Text; Unicode text and IME composition are therefore unsupported.1326+For protocol compatibility, any legacy Text event received by Sigil remains a1327+content-free no-op and is acknowledged when ACKs were negotiated. No key,1328+text, or gamepad payload is logged. The Linux button/axis assignments follow1329+the kernel's13261330 [gamepad protocol](https://docs.kernel.org/input/gamepad.html) and Xbox `xpad`13271331 layout.13281332 @@ -98,8 +98,9 @@ export function mapKey(event) {
9898 }9999 100100 // Resolve each keydown to exactly one protocol class. Physical keyboard input101-// wins whenever it is available; text is a fallback for virtual keyboards or102-// unsupported physical codes and is never emitted alongside a key transition.101+// wins whenever it is available. Text is considered only if the host separately102+// advertises an operational Text capability, and is never emitted alongside a103+// key transition.103104 export function keyboardInputForEvent(event, capabilities = {}) {104105 if (capabilities.keyboard === true) {105106 const key = mapKey(event);@@ -32,7 +32,7 @@ test('forwards the bounded physical code contract including extended keys', () =
3232 }3333 });3434 35-test('physical codes preserve non-ASCII and alternate-layout key positions', () => {35+test('physical codes preserve client key positions across keyboard layouts', () => {3636 assert.equal(mapKey({ code: 'KeyE', key: 'é' }), 'KeyE');3737 assert.equal(mapKey({ code: 'Digit2', key: 'é' }), 'Digit2');3838 assert.equal(mapKey({ code: 'KeyQ', key: 'a' }), 'KeyQ');@@ -71,12 +71,18 @@ test('rejects unsupported physical and logical keys without guessing', () => {
7171 }7272 });7373 74-test('chooses one physical key transition before any text fallback', () => {75- const both = { keyboard: true, text: true };74+test('production keyboard capability forwards a physical code without Text', () => {7675 assert.deepEqual(77- keyboardInputForEvent({ code: 'KeyE', key: 'é' }, both),76+ keyboardInputForEvent(77+ { code: 'KeyE', key: 'é' },78+ { keyboard: true, text: false },79+ ),7880 { type: 'key', key: 'KeyE' },7981 );82+});83+84+test('hypothetical operational Text capability remains exclusive with keyboard', () => {85+ const both = { keyboard: true, text: true };8086 assert.deepEqual(8187 keyboardInputForEvent({ code: 'F5', key: 'F5' }, both),8288 { type: 'key', key: 'F5' },@@ -87,7 +93,7 @@ test('chooses one physical key transition before any text fallback', () => {
8793 );8894 });8995 90-test('text-only fallback accepts one Unicode scalar and rejects modified or composing input', () => {96+test('hypothetical Text-only capability accepts one scalar and rejects unsafe input', () => {9197 const textOnly = { keyboard: false, text: true };9298 assert.deepEqual(9399 keyboardInputForEvent({ code: '', key: 'é' }, textOnly),