Buttons¶
Guide 7 · E-M5 III firmware 1.7 · draft 1. New to these guides? Read Before you start and Operating system first. Open questions: research gaps.
Key points¶
- A key press goes from an interrupt to the UI_IN task, then through the app event queue to the HLS_EVENT task and the application.
- The interrupt only records the new key state and wakes UI_IN, which turns every changed bit into an app event.
- If a full press of the shutter button arrives without a half-press, the decoder sends the half-press first.
- A stock shell command can press keys over Wi-Fi by setting the same key image the interrupt sets.
This guide follows a button from the moment its contact closes to the moment the camera's application code hears about it. It covers the interrupt, the key image, the task that decodes it into an event, and the queue that carries the event to the application. It ends with a stock way to press buttons over Wi-Fi, which we use for testing.
The path up to the application's event queue is traced in the code. What happens after that depends on the screen you're on, and the step from "half-press event" to the shooting sequencer is still open.
Overview¶
- The key contact closes and the key-line interrupt fires.
- A callback updates the key image and wakes the UI_IN task.
- UI_IN compares the old and the new image.
- It sends an app event, such as "key 0x100 pressed" for a half-press.
- The event goes into the app event queue.
- The HLS_EVENT task reads it and hands it to the application, such as a menu, playback or shooting.
1. Key lines and groups¶
The buttons are not scanned one at a time. They are wired to several kinds of inputs, and the firmware treats each kind as a group with its own bit image, one bit per key.
| group | what it covers |
|---|---|
| gio | most push buttons, on general-purpose input lines (three bytes of bits) |
| adc | keys read through an analogue input (several keys share a line, told apart by voltage) |
| dial | the mode dial position |
| ext | keys on an external input chip |
| power | the power switch, read through the always-on power block (wake input 0) |
The key groups and what each covers.
Each key has a 4-letter name and a number in a table. Some examples: Trg1 (0x100) is the shutter button half-pressed,
Trg2 (0x101) fully pressed, Ok (0x4), Menu (0x89), Play (0x87), Info (0x1205). Cables, card doors and the
lens show up as "keys" too (UsbC, Hdmi, LnsC), which is why the same module also reports a lens change.
Where in the firmware
| what | where | known from |
|---|---|---|
| group table | 0x601b8320, 12-byte records | [code] |
| bit images | power 0xa2652f38, gio 0xa2652f34, adc 0xa2652f2c, dial 0xa2652f2d, ext 0xa2652f30 | [code] |
| key names and codes | 0x60251248 | [code] |
which physical button each Cut code is |
needs ui key debug on the camera |
open |
The group table, the bit images and the key names.
2. The interrupt¶
When a key line changes, the hardware raises an interrupt. The handler reads which channel fired, clears it, and calls the function that was registered for that channel. For the push buttons, that function belongs to the key module (called UI_IN). It updates the group's bit image and sets a bit in UI_IN's event flag.
That is all it does. The interrupt doesn't decide what the key means, doesn't log, and doesn't wait for anything. It records the new state and wakes the task that will deal with it (see interrupt context).
The analogue keys and the power switch use their own drivers, but they end the same way. A callback updates the group's image and sets UI_IN's flag. Registering the power-switch callback takes one of the cross-core lock bits, so that driver is shared between cores.
Where in the firmware
| what | where | known from |
|---|---|---|
| key-line interrupt block | 0x9bd00000 (channels at +0x00 and +0x80, status +0x08 / +0x88) | [code]; GPIO edge block [inferred] |
| interrupt handler | 0x601231e0, callbacks from table 0x620b2860 | [code] |
| register a callback | 0x601230ab | [code] |
| UI_IN's push-button callback | 0x60120011 (registered at 0x6011faf1) | [code] |
| analogue key callbacks | 0x60121305 / 0x601213bd | [code]; "adc" [inferred] |
| power key callback | 0x60121f0d (via 0x60063d13, lock 8) | [code] |
| UI_IN event flag | u16 at 0x60040dd4, bit 0 | [code] |
The key-line interrupt, its callbacks and UI_IN's event flag.
3. The UI_IN task¶
UI_IN is an ordinary task that spends its life waiting on its event flag. When the interrupt sets the bit, the task wakes, clears the flag, and runs the key decoder. Then it handles the dials, and goes back to waiting.
The decoder compares each group's new image with the previous one. Every bit that changed becomes an app event, a 32-bit number made of a kind and the key code:
| event | meaning |
|---|---|
| 0x2000000 + code | key pressed |
| 0x2010000 + code | key released |
| 0x2020000 + code | value changed (the mode dial: the code plus its new position) |
The three kinds of app event the key decoder sends.
One rule is built in here. If a full press of the shutter button (Trg2) arrives without a half-press before it, the
decoder sends the half-press (Trg1) first. So the rest of the camera can assume a full press always comes after a
half-press, however quickly the button was pushed.
Where in the firmware
| what | where | known from |
|---|---|---|
| UI_IN task loop | 0x6011f9d8 (wait, clear, decoder 0x6012092f, jog 0x6011fb2d) | [code] |
| key dispatcher (events, half-press first) | 0x60120ad3 | [code] |
| event kinds | 0x2000000 / 0x2010000 / 0x2020000 + code | [code] |
The UI_IN task loop and the key decoder.
Sources: Wi-Fi debug shell.
4. Dials¶
The front and rear dials don't have on/off contacts. They produce pulses as they turn. A separate jog driver counts the pulses and sends an app event of a fourth kind (0x2030000 + dial code, with the step count). UI_IN's loop services the jog driver after the keys.
Where in the firmware
| what | where | known from |
|---|---|---|
| send a dial event | JOG_SendEvent 0x6011fe86 (0x2030000 + 0x1902 / 0x1903) |
[code] |
| how the pulses are counted (timer, interrupt) | not traced | open |
The jog driver.
Sources: Wi-Fi debug shell.
5. The app event queue¶
Every app event, from keys, dials or elsewhere, goes out through one function. It packs the event into a small 12-byte message and writes it to the app event queue, an operating-system queue. A task called HLS_EVENT reads that queue and hands each event to the application layer.
From here the meaning depends on what the camera is doing. In a menu, Up moves the cursor. In playback, it may step
through images. In shooting mode, a half-press starts focusing and metering.
pseudocode in our own words, summarised from the disassembly (0x60046008, 0x602e39b9)
post_app_event(event, argument):
(a few events are dropped in one special mode; meaning open)
message = allocate 12 bytes: {source, event, argument}
write the message to the app event queue, no timeout
The same queue is used by many of the application's service modules (recording, playback, display), so a key event waits its turn among other kinds of events.
Where in the firmware
| what | where | known from |
|---|---|---|
| post an app event | 0x60046008 → 0x602e39b9 (OlyQeWrCpu) |
[code] |
| app event queue | queue id u16 at 0x60040f24 | [code] |
| reader | appevent::Wait_Event 0x602e2f49, Wait_ExecuteEvent 0x602e32f6 (HLS_EVENT task) |
[code] |
| dropped events | 0x40d00b5 / 0x40d00b6 while byte 0xa25b897e = 119 | [code]; meaning open |
Posting to the app event queue and reading from it.
Sources: Wi-Fi debug shell.
6. After a half-press¶
In shooting mode, the half-press is where Taking a photo begins. The shooting sequencer leaves Idle, runs the focus and exposure states, and then waits in RdyTrig2Wait for the full press, which moves it on to the capture.
The route from the generated C++ layer to the sequencer is known for a take-picture request. The C++ code calls a C interface, which puts a message into the sequencer's own queue. See C++ shooting layer. Whether the half-press takes the same route, and which component sends it, hasn't been checked yet.
Where in the firmware
| what | where | known from |
|---|---|---|
| sequencer waits for the full press | state RdyTrig2Wait (5); the take request arrives as queue event 11 (2026-11-25) | [code] |
| release seen during capture prep | byte 0x62110640 | [code] |
| app event → sequencer route | take request: API message type 11 to queue 0x60 (2026-11-25); half-press not checked | [code] / open |
The sequencer's wait for the full press and the route a take request follows.
Sources: shooting sequencer, Live ND.
7. Simulated key presses¶
The user shell has a ui key command that works at the key-image level. ui key skey <code> 1 sets the key's bit in
its group image and wakes UI_IN, exactly as the interrupt would. ui key skey <code> 0 releases it. Everything from
section 3 onwards then runs as for a real press. ui key debug 1 prints every app event as it is sent, which is the
easiest way to find out which code a physical button makes.
Since the shell is reachable over Wi-Fi from a stock card file, this gives a way to press buttons remotely for testing. Always send the release. Never send the codes for power, cables, the card or the lens, which would fake those events.
Where in the firmware
| what | where | known from |
|---|---|---|
ui command / key sub-commands |
0x61408cf3 / 0x61408f79 | [code] |
| set a key | 0x60120327(code, state) | [code] |
| tried on the camera | not yet | open |
The shell's key commands.
Sources: Wi-Fi debug shell, remote test rig.
Our features¶
- Live ND quick tap. An armed Live ND shot that was released too early hung in the capture-prep state. The release arrived before the "full press seen" event the port expected. The fix handles the release events in that state. Lesson: any feature that hooks the shutter path must handle a press that ends sooner than expected.
- Loading on the first half-press. The planned looks feature loads its card file on the first half-press after power-on, in the HLS_EVENT task's event loop, where blocking on a file is allowed.
- Our own settings page receives the menu key events through the screen's handlers, the same way a stock menu page does.
Other cameras¶
Each step checked against the firmware of other bodies. Nothing is assumed. "Not checked" means we don't know.
| step | E-M5 III 1.7 | OM-5 1.2 | E-M1 III 1.6 | OM-5 II 1.1 | OM-1 1.9 | PEN-F 3.1 | other projects |
|---|---|---|---|---|---|---|---|
key names (Trg1, Trg2, ...) |
yes | confirmed | confirmed | confirmed | confirmed | confirmed | fenykl: same key codes on E-M10 II |
| key-line interrupt block 0x9bd00000 | yes | confirmed (address used) | confirmed (address used) | confirmed (address used) | different: not used | confirmed (address used) | — |
jog driver (JOG_SendEvent) |
yes | confirmed | confirmed | confirmed | confirmed | different: name not found | — |
HLS_EVENT task, appevent::Wait_Event |
yes | confirmed | confirmed | confirmed | confirmed | confirmed | OM-5 II (Atlas-linked project): first-half-press work done in the HLS_EVENT task |
| half-press sent before a lone full press | yes | not checked | not checked | not checked | not checked | not checked | — |
Each step on other bodies. The last column holds what other projects report.
"Confirmed" here means the names or the address are present. The code around them wasn't checked. Wi-Fi debug shell, fenykl notes, Atlas-linked projects.
Further reading¶
- Wi-Fi debug shell: technical notes, the detailed reference for this guide.
- Operating system, tasks, event flags, queues and interrupt context.
- Taking a photo, what the half-press starts in shooting mode.
Research by the Oly Firmware Notes and Mods contributors, shared under CC BY 4.0. If you use or summarise it, please credit and link "Buttons".
Spotted a mistake, or know something we don't? Additions and corrections are welcome. Open an issue on the notes repository.