133. A scan code gets a button name, read only, by decoding the code it sends¶
Section 48 measured how far a connected remote can be pushed towards the keypad map and stopped in the
right place: a remote on USB never runs its keypad handler, arch 14 yields the electrical column only
and arch 12 yields nothing at all, and finishing the census needs a write into the running remote's
memory to drive the matrix rows. That write is forbidden here and this section does not propose it.
keyCodes has therefore always returned a number for a hard key, and its own docstring said so: a code
has no name, and a label comes from the screen where a screen draws one and from nowhere otherwise.
Thirty two buttons of a Harmony One and thirty six of a Harmony 600 now have their names, and nothing
was written to either remote or asked of either remote. The tables are in reference/button-maps.md.
The chain, and why it is content rather than order¶
Three things are joined, and the join is by what a code is rather than by where it sits:
- The container binds a scan code to a base slot 9 handler set, whose action list sends an infrared
code as a group and an index,
keyCodes. Sections 39, 67 and 128. - That record's duration stream is decoded back into the bit frame a device sees,
packages/codec/src/irframe.ts, new here. - The frame is looked up in the catalogue of named commands held by the account that generated the config, and the button map held by the same account says which button sends that command.
Step 2 is what was missing, and it is the whole content of the new module. A duration stream can be
compared to another duration stream and to nothing else, so before this two codes were either byte
identical or unrelated. A frame is a number that can be compared to a number written down somewhere
else, and Logitech's own catalogue writes one down per command: G:Sony 12 Bit:()(0x910)():3, section
132.
The decoder, which is deliberately protocol agnostic¶
Consumer infrared encodes a bit in the length of one half of a mark and space pair. Which half is a property of the protocol family: Sony varies the mark, and the two forty eight bit families in the calibration account vary the space. The decoder tries both, skips one header pair, splits the measured durations at the midpoint between their shortest and longest, and returns the bits most significant first. It does not name the protocol, decode an address or a command, or check a parity bit.
The convention selects itself, and that closure is what makes the module usable. Under the wrong
convention every measured duration is the constant half of the pair, so there is nothing to split and
the reading is refused: a pulse width protocol read as pulse distance yields a train of identical
spaces. Across the corpus 3502 records read under exactly one convention, none under both and 1128 under
none, corrected here on 23 August 2026 from 4029 under one and 936 under none, which
partitions 4965 records where the population is 4630 and predates a change to the container list, and
again on 24 August 2026 from 3547, 148 and 935: section 163 emptied the "both" column and section 164 took
45 records out of the "one" column. The records that used to read under both are the ones section 134 is
about, and they are biphase, which is now the property that identifies them. So a caller never has to know the family,
and irFrames returns every reading so that an ambiguous record is visible rather than silently
resolved.
Two mistakes are recorded because both produced a decoder that matched nothing at all while looking correct, and both are one line:
- The terminator is not a bit. A forty eight bit frame ends with a pair whose space is 32767, and counting that pair gave forty nine bits, which matched no catalogue entry.
- The trailing gap arrives with the last bit, not instead of it. A Sony frame's final bit is a mark followed by that gap, so testing the other half of the pair before taking the bit dropped the last one and made every twelve bit frame read as eleven.
The two tests look redundant and are the opposite: one guards the measured half of the pair and one the other half.
What it produced¶
Every record of every device in both calibration containers decodes and matches the catalogue: 241 of 241 on the Harmony One and 241 of 242 on the Harmony 600. Each group's records identify their own device, by majority vote over the catalogue, and the answer agrees with section 126's pairing through base slot 13 on six of six groups across the two architectures. That is a third route to which group is which device, and the first that reads no name at all.
For the button names the join has to be made inside the map of the activity the binding belongs to, and getting that scope wrong is what the instructive part of this section is about. Thirty two of the Harmony One's forty four buttons and thirty six of the Harmony 600's fifty four are named, with no button claimed by two scans and no activity contradicting another.
The first version had eight ambiguous scans per remote and it argued the ambiguity was inherent, on
the grounds that two buttons sending the same infrared code cannot be told apart by a route that reads the
code. That argument is sound and it mostly did not apply, because the premise was wrong: the two buttons
were not sending the same code, the same key was sending two codes. Scan 19 of a Harmony One sends the
television's ChannelUp in one activity and the Blu-ray player's SkipForward in the other, both names
exist as buttons, and a vote over every map at once therefore saw one key as two. The frame column records
the evidence, since that scan lists both codes.
Three rules take it from eight to four, and none of them is visible in the data:
- A scan's command is per activity and its button is not, so a vote is scoped to the map of the activity whose set holds the binding.
- Only an
ActivityButtonMapmay name an activity's set. ADeviceButtonMapis the layout for driving one device directly and aRootButtonMapis neither. Choosing the map by how well it overlaps picked device maps for the Harmony One, which is what left two of its scans disagreeing with themselves; the kind is stated in the map and is read rather than inferred. - The assignment is globally injective, because a
ButtonKeynames one physical key and a physical key has one scan code, so a button another scan has taken in any activity is unavailable. A per activity constraint pass cannot see that, and this is what namesNumberPlus: its pair's other scan resolves toPrevChannelin the other activity, and the two send the same code from the second device.
Four scans per remote remain genuinely undecided, and the honest statement of what is left took two attempts. The revision that added the three rules above claimed "what remains unnamed is unbound rather than undecided", which is true of every key except these four: a remote's two up keys send one command and so do its two down keys, in both activities of both configs, so four scans face four buttons in two symmetric pairs. Elimination cannot break a symmetry and neither can any amount of decoding. Splitting them needs a config where the two members of a pair carry different commands, which means a device with its own page or channel pair beside a directional pad. Everything else unnamed is unbound: these configs drive three devices in two activities, so a key neither activity binds to a decodable code is never reached.
Two closures, one of which reads nothing¶
The two models agree. Every one of the thirty two button names in both tables carries an identical frame, and the four the Harmony 600 has on top are exactly the teletext colour keys a Harmony One does not have. Two containers, two architectures, two separate runs of Logitech's generator, and the same command decodes to the same bits.
The frames are checked against the bytes. packages/codec/test/irframe.test.ts parses the tables out
of reference/button-maps.md and asserts that each scan still sends exactly the listed frames in the
container the table was measured on. One copy of the derivation, in the document, because a table of
sixty numbers duplicated into a test is two copies until one of them moves.
The geometry does not follow, and that is the useful negative¶
The expectation going in was that a named keypad would fall into rows. It does not. Section 48 derived
the electrical column on arch 14 as (scan - 1) mod 4, and under it the digits 1, 2 and 3 of a Harmony
600 sit in columns 3, 2 and 2, which is not a row of three keys. Every divisor from 2 to 19 was tried,
with and without an offset, taking the row from the quotient and then from the remainder, and none
puts each of the three digit rows on one line. A matrix position is a wiring decision on a board.
So a scan code carries a name and no place, this route is the only source for the name, and
reference/silhouettes/ was going to get no data-scan: the two remotes here have twenty eight and
thirty two of their forty four and fifty four buttons named, and filling in a drawing would mean
guessing the rest. A test asserts the geometry cannot be recovered, so nobody has to re-derive that.
(Corrected 25 August 2026: the maps grew to 32 and 36 buttons, and the traced geometry of 21 August
put data-scan on exactly the measured keys and on nothing else, the 600's 36 plus, on the One, the
two touch arrows section 125 placed beside its 32. So the rule that survived is "never a guess"
rather than "never an attribute". Found by an audit rather than by a failure: no test read this
sentence, which is what a summary is.)
What this is, and what it is not¶
A calibration instrument, not a reader. It works for a config generated through an account we control, which is what the two calibration samples are, and it cannot name a button in a contributed config, because that config's own catalogue and button maps are not ours to have. What it yields is a per model table, once, which afterwards is a fact about the model.
It is also not in packages/usb/src/models.ts beside the other per model hardware facts, deliberately,
and for two reasons now: four scans per remote are still undecided, and the tables cover thirty two of
forty four and thirty six of fifty four buttons, so a library answering for a scan these configs never
bound would be answering from nothing.
What would falsify it¶
A scan code in the tables that a container binds to a different code. A button name in both tables with different frames on the two architectures. A third config for either model, with more devices on it, naming one of these scans differently. A remote whose digits do fall into rows under some modulus, which would mean the column formula and the layout do coincide and the negative above is wrong. And an independent naming of any of these keys, from a photograph or from another host, disagreeing with the table.
Where it lands¶
reference/button-maps.md: the two tables, the unresolved sets, and the provenance.packages/codec/src/irframe.ts:irFrame,irFrames,frameKey.packages/codec/test/irframe.test.ts: the corpus census, the tables against the containers, the agreement between the two models, and the geometry negative.docs/config-format.md: base slot 5, that a record's frame is recoverable and what it is not.
Section 132 | the archive | section 134. Section 133 of the findings archive, which is frozen; the reference holds the current answer. The archive on GitHub.