The WonderSwan SoC features a 4 by 3 keypad matrix. == I/O Ports == === Keypad Scan ($B5) === Scanning is done via writing to and reading from port $B5.
7 bit 0 ---- ---- .iii oooo ||| |||| ||| ++++- Output rows (0-3) +++------ Input rows (4-6)The standard procedure is to read rows controlled by bit 4, bit 5, then bit 6 in order, shifting their values into one twelve-bit mask like so:
15 bit 8 7 bit 0 ---- ---- ---- ---- .... 4444 5555 6666Typical keypad scanning implementations introduce a delay between writing to and reading from the matrix, allowing the scanned values to stabilize. For example, one can use the DAA opcode for doing so. == Keypad arrangement == === WonderSwan === ==== Layout ====
Y1
Y4 Y2
Y3
X1
X4 X2 A
X3 Sound Start Power B
(St)
Sound and Power buttons are not exposed directly to software.
==== Matrix ====
Bit O 3 2 1 0
I | | | |
| | | |
4--- Y4 - Y3 - Y2 - Y1 -
| | | |
5--- X4 - X3 - X2 - X1 -
| | | |
6--- B - A - St ---+--
| | | |
==== Bit mask ====
The following bit mask is the typical convention used by keypad scanning routines; it is not enforced by the hardware.
15 bit 8 7 bit 0
---- ---- ---- ----
.... yyyy xxxx bas.
|||| |||| |||
|||| |||| ||+- Start
|||| |||| |+-- A
|||| |||| +--- B
|||| ++++----- X4, X3, X2, X1
++++----------- Y4, Y3, Y2, Y1
=== Pocket Challenge V2 ===
==== Layout ====
Power
Esc
View
Up Clear
(Clr)
Lft Rgh Circle
(Crc)
Dwn Pass
(Pas)
The Power switch is not exposed directly to software.
==== Matrix ====
Bit O 3 2 1 0
I | | | |
| | | |
4--- Pas Crc --+-- Clr -
| | | |
5--- Rgh Esc --+- View -
| | | |
6--- Up - Dwn --+-- Lft -
| | | |
[1]
==== Bit mask ====
The following bit mask is the typical convention used by keypad scanning routines; it is not enforced by the hardware.
15 bit 8 7 bit 0
---- ---- ---- ----
.... pc1C re1v ud1l
|| | || | || |
|| | || | || +- Left
|| | || | |+--- Down
|| | || | +---- Up
|| | || +------ View
|| | |+-------- Esc
|| | +--------- Right
|| +----------- Clear
|+------------- Circle
+-------------- Pass