Modern-Apps.git
Publicgit clone https://git.maproj.org/Modern-Apps.gitModern-Apps.git / auto / protocol / src / main / proto / gal / input.proto
input.proto130 lines · 5.0 KiBRaw
| 1 | // Google Automotive Link input channel (service 8): touch, keys and scroll. |
| 2 | // |
| 3 | // Field numbers, wire types and cardinality were recovered from the protobuf-lite |
| 4 | // RawMessageInfo descriptors in the Android Auto APK (analysis/maauto/dump_protos.py) and are |
| 5 | // exact. Message and field NAMES are not in the APK -- they follow the public aasdk/openauto |
| 6 | // naming where it matches, and are plain descriptions elsewhere. See gal/control.proto for |
| 7 | // the provenance note and auto/docs/FINDINGS.md for the endpoint teardown. |
| 8 | // |
| 9 | // Direction: the head unit OWNS the input hardware, so it SENDS InputReport (0x8001) and |
| 10 | // the phone only answers with KeyBindingRequest (0x8002, supported keycodes echoed back |
| 11 | // on channel open) and InputFeedback (0x8004). The phone never builds an InputReport. |
| 12 | // The dispatch compares raw wire ids (`jar.a()` overrides the base and never calls |
| 13 | // `wub.o`, so there is no off-by-one here): 0x8001 report, 0x8003 binding response. |
| 14 | // |
| 15 | // Touch mapping, from `ikb.i` + `iye.a` + `wox.A`: |
| 16 | // - TouchPointer is (x, y, pointer_id): `iyd` prints "ProjectionPointer(x,y,id)" and |
| 17 | // `iye.a` assigns `props.id = pointer_id`, `coords.x/y = x/y` (+ a zero offset). |
| 18 | // - The action enum IS the MotionEvent action: `wox.A` maps 0->1, 1->2, 2->3, 5->6, |
| 19 | // 6->7 and `ikb.i` subtracts one, so 0/1/2/5/6 become DOWN/UP/MOVE/POINTER_DOWN/ |
| 20 | // POINTER_UP. Anything else maps to 0 and then defaults back to DOWN -- mirrored |
| 21 | // in InputCodec.motionAction rather than fixed, because the head unit decides. |
| 22 | // - `action_index` indexes the pointers list for the POINTER_DOWN/UP actions. |
| 23 | // - Coordinates arrive in head-unit touchscreen pixels (discovery `TouchConfig` |
| 24 | // width/height, DHU default 800x480) and are scaled to car-display pixels by |
| 25 | // the receiver; see InputCodec.scaleCoordinate. |
| 26 | // |
| 27 | // Key mapping, from `ikb.h`: KeyEvent(code=field1, down=field2, meta=field3) -- |
| 28 | // field3 sits in the KeyEvent metaState position. Field4 is observed but its exact |
| 29 | // HU intent is undecoded: a key-UP carrying it makes gearhead synthesize a full |
| 30 | // down+up pair (`jar.java` fallback branch), so it is kept as `field4` rather |
| 31 | // than given a confident wrong name. |
| 32 | // |
| 33 | // Scroll, from `jar.java` relative handling: RelativeEvent{keycode=65536, delta} |
| 34 | // with a non-zero delta becomes an ACTION_SCROLL MotionEvent with AXIS_VSCROLL set |
| 35 | // to the delta and SOURCE_MOUSE. AbsoluteEvent{keycode=65541, value} is the |
| 36 | // touchpad tap-as-select: value 1 presses KEYCODE_DPAD_CENTER, 0 releases it. |
| 37 | |
| 38 | syntax = "proto2"; |
| 39 | |
| 40 | package gal; |
| 41 | |
| 42 | option java_package = "com.vayunmathur.auto.protocol.gal"; |
| 43 | option java_multiple_files = true; |
| 44 | |
| 45 | // `xom.e` via `wox.A`, minus one: these already ARE the MotionEvent actions. |
| 46 | enum TouchAction { |
| 47 | TOUCH_DOWN = 0; |
| 48 | TOUCH_UP = 1; |
| 49 | TOUCH_MOVE = 2; |
| 50 | TOUCH_POINTER_DOWN = 5; |
| 51 | TOUCH_POINTER_UP = 6; |
| 52 | } |
| 53 | |
| 54 | // One finger: `xol` (`iyd`), fields in order x, y, pointer id. |
| 55 | message TouchPointer { |
| 56 | required uint32 x = 1; |
| 57 | required uint32 y = 2; |
| 58 | required uint32 pointer_id = 3; |
| 59 | } |
| 60 | |
| 61 | // One touch frame: `xom`. Field 3 is the touchscreen, field 7 the touchpad. |
| 62 | message TouchEvent { |
| 63 | repeated TouchPointer pointers = 1; |
| 64 | optional uint32 action_index = 2; |
| 65 | optional TouchAction action = 3; |
| 66 | } |
| 67 | |
| 68 | // One key press or release: `xke`. |
| 69 | message KeyEvent { |
| 70 | required uint32 keycode = 1; |
| 71 | required bool key_down = 2; |
| 72 | required uint32 meta_state = 3; |
| 73 | optional bool field4 = 4; |
| 74 | } |
| 75 | |
| 76 | // One rotary/scroll tick: `xno`. Scroll is keycode 65536 with a non-zero delta. |
| 77 | message RelativeEvent { |
| 78 | required uint32 keycode = 1; |
| 79 | required int32 delta = 2; |
| 80 | } |
| 81 | |
| 82 | message RelativeEvents { |
| 83 | repeated RelativeEvent event = 1; |
| 84 | } |
| 85 | |
| 86 | // One absolute input value: `xgw`. Keycode 65541 is tap-as-select. |
| 87 | message AbsoluteEvent { |
| 88 | required uint32 keycode = 1; |
| 89 | required int32 value = 2; |
| 90 | } |
| 91 | |
| 92 | message AbsoluteEvents { |
| 93 | repeated AbsoluteEvent event = 1; |
| 94 | } |
| 95 | |
| 96 | // The key-event list inside a report: `xkf`. |
| 97 | message KeyEvents { |
| 98 | repeated KeyEvent events = 1; |
| 99 | } |
| 100 | |
| 101 | // The head-unit-to-phone report: `xjt`. Field 1 is the report timestamp; |
| 102 | // every section is optional and the phone handles whichever are present. |
| 103 | message InputReport { |
| 104 | required uint64 timestamp = 1; |
| 105 | optional TouchEvent touchscreen = 3; |
| 106 | optional KeyEvents key_events = 4; |
| 107 | optional AbsoluteEvents abs_events = 5; |
| 108 | optional RelativeEvents relative_events = 6; |
| 109 | optional TouchEvent touchpad = 7; |
| 110 | // Field 2 is absent from this build. |
| 111 | } |
| 112 | |
| 113 | // Phone-to-head-unit, sent on channel open: `xkb`. The phone echoes the keycode |
| 114 | // list the head unit advertised in discovery (`ikb.r` sends `this.c`, which came |
| 115 | // from `xjw` field 1 via `wub.ay`). |
| 116 | message KeyBindingRequest { |
| 117 | repeated int32 keycodes = 1 [packed = true]; |
| 118 | } |
| 119 | |
| 120 | // Head-unit-to-phone answer: `xkc`, a single status (field 1). |
| 121 | message KeyBindingResponse { |
| 122 | required int32 status = 1; |
| 123 | } |
| 124 | |
| 125 | // Phone-to-head-unit feedback event: `xjs` (`ikb.n` sends one per `xji` event |
| 126 | // from the discovery-advertised set). The field carries the feedback event id; |
| 127 | // like `xjw` field 4 it is enum-typed on the wire and int32 here. |
| 128 | message InputFeedback { |
| 129 | optional int32 feedback_event = 1; |
| 130 | } |