Skip to content

48. The button mapping experiment, predicted before it is run

This section is written before the measurement, which is the point of it. A hardware result that confirms a number nobody committed to in advance is worth much less, and this experiment has failed three times upstream, so it is worth being explicit about what would count as a success.

The variable to watch

Section 13 read the arch 14 keypad scanner: a 14 by 4 matrix, rows active low, returning row * 4 + column as a linear index from 1 to 56, with 0 for no key. What it did not do is say where that index is kept, and that is what a live read needs.

The handler is 0x1937A on the Harmony 700 2.8 image. It calls the scanner, and:

  • stores the fresh code in a local, 0xD07;
  • returns immediately if it equals the code already held, which is the debounce;
  • on a change, writes the fresh code to 0x3A4 and then to 0x3A2;
  • raises the event by ORing the event type onto 0x3A2, at 0x193AC: MOVLW 0x40 ; MOVLB 3 ; IORWF 0x3A2,W. 0x40 is the release type of section 17.

So 0x3A2 holds the bare scan code with no event bits, which is exactly the number a config's key table indexes by.

The bench remote is a 600, not a 700, and the RAM layout is per build rather than per architecture. The same three instruction shape appears twice in the complete 600 0.2 image, at 0x179FA and 0x17A44, naming bank 7 offset 0x3D. Tracing 0x73D in the 600 and 0x3A2 in the 700 returns seventeen accesses each, of the same kinds in the same order, with a partner variable of three accesses each, 0x73F against 0x3A4. That correspondence is the reason for believing the port without a second measurement.

Arch 12 has no such helper section behind it, so it is a weaker prediction. The One 3.4 image carries the same shape at two places, naming 0x2FB and 0x202. 0x2FB traces like the arch 14 variable, fifteen accesses with the same clear, OR and store pattern and a fresh code arriving from 0xD04; 0x202 is read from inside the 0x2FB handler, so the two are related and which is the keypad is not settled. The One is the remote with a touch panel and section 45's hit map, so a second event source is expected to exist.

remote data address from
Harmony 600 0x073D 600 0.2, 0x179FA and 0x17A44
Harmony 700 0x03A2 700 2.8, 0x193AC
Harmony One 0x02FB, and 0x0202 as the other candidate One 3.4, 0x2BF00, 0x2BF6E, 0x25F24, 0x25F8A

The predictions

  1. At rest the variable reads 0, and it returns to 0 when the key is let go, so a press and a release are two observable transitions.
  2. A held key reads a value in 1 to 56 on the 600, from the scanner's own range, and the top two bits are clear, because the event type is ORed on somewhere else and never stored here.
  3. Every value observed appears in that unit's own key table. The 600's config carries 54 distinct scan codes in three event classes, section 17, and a pressed key that produced a code outside that set would falsify the whole chain rather than just this reading.
  4. The map is dense but not complete: 54 codes over 56 matrix positions, so at most two positions have no config entry, and the 600 has fewer than 54 physical buttons, so some codes belong to no button at all. A key that produces nothing is therefore not automatically a failure, and the codes that no key produces are as much of the result as the ones that do.
  5. 0x2FB on the One is the keypad and 0x0202 is not. This is the one prediction that is a guess rather than a reading, and it is written down so that being wrong costs something.

Why polling is enough

The read costs one USB exchange, so the loop runs at tens of hertz, and a key press held by a human lasts an order of magnitude longer than that. The debounce works in the remote's favour here too: the handler ignores a repeat of the same code, so the variable holds steady for as long as the key is down rather than flickering.

The tool is packages/usb/bin/watch-keys.ts, make watch-keys. It only reads, it prints one line per change, and it seeds itself from the resting value so the first read is not reported as a press.

The result goes in this section, below this line, and the predictions above are not edited.

The result: the experiment cannot be run this way, and it produced a quarter of the answer

Measured 7 August 2026 on the bench Harmony 600, firmware 0.2, every one of its 54 buttons pressed by hand while the host watched over USB.

Predictions 1 to 5 are all unresolved rather than confirmed or refuted, because the premise underneath them is wrong. A remote attached to USB shows a sync screen and does not run its application, so the keypad handler never runs, 0x73D and 0x73F never change, and no scan code is ever computed. The resting values are 0 and 6 and they stayed at 0 and 6 through every press of the session. Prediction 1 is technically true of 0x73D and means nothing.

The measurement stands and the wording above is too strong, section 111. USB mode is a mode of the application's own loop, section 99, and a connected Harmony One is demonstrably executing: its clock ticks, TMR1 runs, and its display light state machine holds values only its config states. What does not run is the keypad handler, which is what this section measured and what its conclusion rests on. The broad sentence had been copied into four summaries by the time it was checked, and each of them is corrected rather than deleted, because the narrow claim is still load bearing.

That is not a setup mistake, and it was checked three ways. The remote enters sync mode immediately on being plugged in, before the host sends anything, so it is not our traffic that puts it there. It stays there after the host closes the handle. And the row lines never move: 246 consecutive samples of PORTA, PORTD and PORTE at rest returned one constant value each, and across the whole session they never changed once, including during presses.

What the firmware does instead is legible and is the reason a quarter survives. It parks all fourteen row lines low at once and enables interrupt-on-change on the column port, so that any key pulls its own column down and wakes the part without a scan. That parked state is exactly what makes the row unobservable and the column observable:

PORTB  0xFE   at rest, top nibble all high, no key
PORTB  0xDA   Menu held, bit 5 low

Since the scan code is row * 4 + column, a press reports (code - 1) mod 4 and nothing else.

The census, and the closure it produces

All 54 buttons, every one of which reported a column, so there is no button on this remote wired outside the matrix. The table is in tests/test_keypad.py; the census is:

column buttons
1 14
2 14
3 13
4 13

A column has exactly 14 positions, so two of those numbers are at the hard ceiling and the other two are one short. Now the independent artefact. The 600's own config, read off that same unit, carries 54 keypad scan codes, contiguous 1 to 54, so of the 56 matrix positions exactly 55 and 56 are unoccupied. column_of(55) is 3 and column_of(56) is 4.

The measured deficit is one in column 3 and one in column 4. It agrees exactly.

Nothing was fitted to make that happen. The buttons were counted off a photograph and pressed in a written order; the scan codes come out of a config generated by Logitech's software years ago. The weakest link in the chain, section 17's claim that a key code is an event type plus a scan code and that the 600's 162 records are 54 codes in three classes, has now been checked against the hardware for the first time, and so has the scanner's row * 4 + column arithmetic from section 13.

What is now known, and what is not

Known: the Harmony 600 has 54 matrix buttons and 56 matrix positions; scan codes 55 and 56 belong to no button, so a config that binds them binds a key nobody can press; and for each of the 54 buttons, the scan code modulo 4.

Not known: the row, which is 14 candidates per button. The offline route through the config was checked and does not exist: slot 0's named tree holds state variable names (TV_Power, CurrentActivityState) and no button or command names.

Three leads for the row, none of them run:

  • The four bound scan codes. Base slot 8 names exactly four in every arch 14 config, the same four in the 600 and both 700s: 2, 8, 9 and 34, in columns 2, 4, 1 and 2. Being identical across three configs of two models makes them firmware level buttons rather than user bindings. Three of the four columns match power, more activities and devices, which is suggestive and is not evidence.
  • Their rows are low, 0, 1, 2 and 8, and the top of the remote is where the special buttons are. If the matrix is wired roughly top to bottom the ordering constrains a lot.
  • The Harmony One. Written here as "worth more, because its matrix is 7 by 8, so a press is worth (code - 1) mod 8". Both halves of that are wrong and the next subsection is the measurement that says so. The 7 by 8 came from an upstream matrix encoding that section 17 already discarded, and it was never established for arch 12 by anything in this project.

The route that would finish it is blocked on purpose. WRITE_MISC selector 0x07 writes a byte into the data memory of a running remote, so a host could drive the row lines itself and read the matrix out completely, which is precisely what the parked firmware will not do. That is a write to a live device, on arch 14, where packages/usb/src/rails.ts allowed no write target at all when this was written; since section 281 it allows the Harmony 650 a flash block and no RAM write, so the answer is the same. It is recorded here as the shape of the answer, not as a plan.

Arch 12 gives nothing at all, and that is the interesting half

The spare Harmony One was attached the same evening. It enters sync mode on being plugged in exactly as the 600 does, so that behaviour is a property of the family rather than of one model. Then the same measurement, and the result is a clean negative.

Sixteen distinct buttons, spread over the whole remote, every one of them pulled the same single bit. Four in a first pass, twelve chosen for maximum physical separation in a second: power, activities, help, menu, exit, guide, channel up, mute, fast forward, record, 3, enter. Every press is PORTB bit 5 and only bit 5. No other bit on any of the seven ports moved once in the whole session, and 0x2FB, the arch 12 equivalent of the variable the 600 would not update, did not move either.

Bit 5 is therefore not a column line, and that is a proof rather than an impression. A column holds at most as many buttons as the matrix has rows. The One has 40 physical matrix buttons, so for sixteen of them to share one column the matrix would need at least sixteen rows and at most three columns, and then the other two column lines would have shown up among sixteen presses drawn from every region of the remote. They never did.

The firmware agrees. A search of the One 3.4 image for the shape the arch 14 column reader has, a run of BTFSS port,bit ; RETLW n, finds nothing at all, where both arch 14 images have exactly one. What arch 12 has instead is the pattern upstream describes for arch 9: a binary search for the key over a single sense line, driven by a table of masks. A single sense line is precisely what sixteen buttons on one bit looks like.

So the ceiling is not the same on the two architectures:

wake mechanism observed what USB yields
arch 14, Harmony 600 interrupt-on-change per column, four lines the column, (code - 1) mod 4
arch 12, Harmony One one shared sense line that a key is down, and nothing else

One incidental observation, recorded because it was not looked for. A single tap on the touch panel pulled PORTB bit 4 low and it stayed low for the rest of the session, where a keypress releases within a fifth of a second. So the panel is a separate input on its own line with its own latching behaviour, which is consistent with section 45: its codes are the 43 to 53 block and they do not come out of the matrix.

A prediction, written before anything tests it. The One has 44 buttons, four of which are touch areas on the panel, two flanking the screen and two directly below it, leaving 40 in the matrix. This said "42 buttons in the photograph", with only the two flanking areas as touch, until 9 October 2026. The count missed the two touch points under the screen, which section 125 later found in the hit map as codes 43 and 44 and which the drawing in packages/silhouettes carries as SoftLeft and SoftRight. The matrix figure came out right anyway, because both missing buttons are touch areas rather than matrix keys. Its config carries scan codes 1 to 40, then 43 to 53, then 55. So the 40 matrix buttons should be codes 1 to 40, the 43 to 53 block is the touch panel, and 55 is not a button. Nothing here tests that.

Where it lands

packages/usb/bin/watch-columns.ts, make watch-columns, which reads PORTB and reports a column per press, and watch-keys.ts --address --mask for watching a port with unrelated traffic in it. tests/test_keypad.py pins the 54 measurements and the closure against the config.


Section 47 | the archive | section 49. Section 48 of the findings archive, which is frozen; the reference holds the current answer. The archive on GitHub.