PS2 Gamepad Receiver × MATRIX Mini R4
The MATRIX edition of the PS2 Gamepad Receiver plugs into a Mini R4 I2C port at address 0x22 and is read with the stock colour-sensor blocks: no library change, RK = seven 0255 numbers.
SPIKEEV3Arduino I2CmBlockMATRIXmicro:bit
Wiring
Use the stock MATRIX 4-pin sensor cable on I2C1 or I2C2 and pick that port in the block.
A. Stock blocks (0x22)
The "colour sensor → R / G / B / C / M / Y / K" blocks each return one 0~255 number. ⚠️ Do not use the stock H / S / V or colour-ID blocks (the host computes them from R, G, B; meaningless here); the grayscale and colour-number blocks were removed by MATRIX.
| Block | Content | Decode |
|---|---|---|
| R | d-pad | #67 新增:R = 方向鍵 | 形狀鍵<<4(上 1、右 2、下 4、左 8、▲16、●32、✕64、■128) |
| G | shoulder buttons | #67 新增:G = 肩鍵 | 功能鍵<<4(L2 1、R2 2、L1 4、R1 8、SELECT 16、L3 32、R3 64、START 128) |
| K | connected | #67 新增:K = 已連線 1/0 |
| B | stick LX / LY / RX / RY 1~2 | #67 新增:B、C、M、Y = LX、LY、RX、RY |
| C | stick LX / LY / RX / RY 3~4 | #67 新增:B、C、M、Y = LX、LY、RX、RY |
| M | stick LX / LY / RX / RY 5~6 | #67 新增:B、C、M、Y = LX、LY、RX、RY |
| Y | stick LX / LY / RX / RY 7~8 | #67 新增:B、C、M、Y = LX、LY、RX、RY |
// MATRIXblock → Arduino:stock library
int r = MiniR4.I2C1.MXColor.getColor(R); // d-padSources and assumptions
Generated by _build/gen-reference.mjs from _build/protocol/ps2.json (single source of truth, transcribed from the 2026-10-21 protocol decisions).
- hw[0] = 1(PS2)、電量 07 恆 0、系統鍵 0A 恆 0、手把類型 0B 只會出現 0/1/2(I2C 定案 §2、§4)。
- 08/09 L2/R2 類比照定案寫 0~255:DS2 類比模式有壓力值;沒有壓力值時按下 = 255、放開 = 0(沿用 v1 0x14 的做法,盤點 .ino:598-603)。
- E5 震動、E6 燈條照 I2C 定案 §3 列在 PS2/PS4 共用命令表;PS2 收到回 ACK 後忽略(跟 v1 0x10/0x23 一樣)。
- 搖桿 10
13 在 I2C/mBlock 是 ±100(由 raw (v−128)×100/128、Y 上為正);EV3/0x22 維持 099(50 中間)、SPIKE 維持 1~9(5 中間)照盤點,不改鎖住模式。 - EV3:模式 0、1、2、4 鎖住(照盤點);模式 3 改 方向|形狀<<4|已連線<<8(原本沒有 bit8);模式 5 改成 ID 格式 B(原本 = 按鍵/搖桿合併版)。
- SPIKE:0/5/7/9 鎖住,1、2、4、6 維持不動;模式 3 改 [已連線, 電量(0), 0](原本 = 4 組按鍵);模式 8 改 v[0] = ID|hw[0]<<8(原本 = 搖桿)。模式 9 v[6] button16 = PSX 排列(D3)。
- SPIKE 模式 5 只容得下 11 鍵(L2、R2、L3、R3、START 讀不到),鎖住不改。