Skip to content

The click wheel and the buttons

On the iPod classic the buttons are the wheel. One controller reports the five keys, the finger's position on the ring and whether a finger touches it at all, in a single packet. The firmware turns that packet into rows, covers, volume steps and held-key gestures through four separate pieces. Chikuma reproduces each piece with the firmware's own numbers, in chikuma/drivers/hw/wheel.zig and the screen tasks above it.

The packet

The controller raises an interrupt and the driver reads a 32-bit packet. It carries the buttons, the position and a touch bit. The position runs from 0 to 95, so a full turn of the ring is 96 units. The driver acknowledges every packet, valid or not, because the controller holds its line until it does.

A press always carries the touch bit, since a thumb on a key is a thumb on the wheel. The firmware tests the touch bit on both the new packet and the previous one and rejects a button with no finger down before anything else looks at it. It acts on the release packet of a tap, not on the press.

From units to rows

The deadband

When the finger lifts, the interrupt handler re-arms a deadband of six units. Small movements after that only accumulate. Once they add up past the gap, the deadband clears and every unit counts. A delta larger than about a third of a turn between two packets is thrown away as noise. The six is a constant in the handler, not a setting.

The divider

A unit is not a row. Each consumer builds a small object of its own that divides the units it receives and keeps the remainder for next time. That carry is why the same turn gives different row counts from different starting points.

The divisor depends on who asks:

Consumer Units per step
a plain list: menus, settings, the contextual menu 5
a media list with rows under 31 pixels 4
a media list with taller rows 6
Cover Flow 4 per cover

Only the media list re-derives its divisor from the row height, on every event, so finger travel per row stays roughly the same across the row heights it uses. A plain list keeps its 5 whatever its rows measure.

The acceleration

The multiplier on the units doubles while the wheel turns fast. Speed is the mean of the last sixteen intervals between packets, kept in a ring. Below 20 ms per packet, the multiplier doubles every 350 ms, up to a cap of 16 for most lists and 32 for the media lists. A change of direction, or 400 ms idle, puts it back to 1.

A ring that is only partly filled reads as fast, because its empty slots count as zero. So the multiplier can climb for a moment at the start of a turn, then fall back once the real mean shows. The original does this too, and Chikuma keeps it.

Cover Flow never accelerates. It steps its divider with a speed of zero, which resets the multiplier on every step, so a cover always costs four units however hard the wheel is flicked. On the same scripted flick, the original and Chikuma land on the same cover.

Held keys

A key press arms a repeat timer, and the release cancels it. What the timer does depends on a per-key hold mode:

Mode At 500 ms Release afterwards
repeat auto-repeat delivered
hold pressandhold delivered
hold, swallow release pressandhold dropped

A key still down 1000 ms later also gets longpressandhold. MENU, SELECT and Play use the third mode, so the release after a hold is never a tap. NEXT and PREV use the second: the release comes, and it stops a scan instead of skipping.

What no screen binds falls to the application's own event table, which lives in the resource archive with the other bindings. Status lists the gestures and what each one does.

The hold switch

The hold switch sits behind the PMU, on the same I2C bus as the audio codec and the battery gauge. Before delivering a button event, the firmware reads one PMU register and drops the event if the switch is on. The read is two bus transactions under the bus mutex, with no retry. A read that never lands leaves an undefined value behind, so the bus driver has to be exact for keys to arrive at all.

During light sleep, a wake with the hold switch on goes straight back to sleep. Games read the switch through the games API.

The clicker

The tick that follows the wheel does not come from the wheel driver. The driver posts a message, and a task of its own drives a piezo with two hardware timers, a gate and a tone. The Clicker setting stops the message, so it silences the tick without touching input.

Which two timers it uses depends on the board revision in SysInfo. One revision uses a different tone timer from the others, and a model that watched only one pair would hear nothing. In the emulator the original clicks once per scroll step and never at rest. Chikuma does not drive the piezo yet, so for the moment its Clicker setting has nothing to gate.

Tests

The host tests pin the deadband, the divider and its carry, and every rule of the ramp. Both firmwares were then run on the same machine, through the same instrument. With the wheel turned slowly they deliver the same rows for the same gesture. Turned fast, both show the multiplier doubling through 1, 2, 4, 8, 16 and stopping at 32.