Gamepad Receiver PS4/PS5 × MATRIX Mini R4
Back to Gamepad Receiver PS4/PS5
The MATRIX edition of the Gamepad Receiver PS4/PS5 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 | R = 方向鍵 | 形狀鍵<<4(上 1 右 2 下 4 左 8、▲16 ●32 ✕64 ■128) |
| G | shoulder buttons | G = 肩鍵 | 功能鍵<<4(L2 1 R2 2 L1 4 R1 8、SELECT(SHARE) 16 L3 32 R3 64 START(OPTIONS) 128) |
| K | connected | K = 1/0 |
| B | stick axis 1~4 1~2 | B C M Y = LX LY RX RY,0~99,50 = 中間 |
| C | stick axis 1~4 3~4 | B C M Y = LX LY RX RY,0~99,50 = 中間 |
| M | stick axis 1~4 5~6 | B C M Y = LX LY RX RY,0~99,50 = 中間 |
| Y | stick axis 1~4 7~8 | B C M Y = LX LY RX RY,0~99,50 = 中間 |
// MATRIXblock → Arduino:stock library
int r = MiniR4.I2C1.MXColor.getColor(R); // D-padSources and assumptions
Generated by _build/gen-reference.mjs from _build/protocol/ps4.json (single source of truth, transcribed from the 2026-10-21 protocol decisions).
- 值表、命令、旗標與 PS2 完全相同(mBlock 定案「兩款相同」+I2C 定案 §3/§4);只有 hw0 = 2、model = PS4、E5/E6 有作用。
- D3:SPIKE 模式 0 教育版 byte 6~7、模式 6 v[2]、模式 9 v[6] 的 button16 都是 PSX 排列(#65 已把 PS4 改成 PSX,盤點檔寫的 Bluepad32 排列已過時)。
- 0x22 命令 4 同時裝方向鍵(低 nibble)與形狀鍵(高 nibble)、命令 5 裝肩鍵(低)與功能鍵(高);JSON 只能把一個命令掛在一個值上,所以掛在 02/04,03/05 的 ch22 = null(內容寫在 02/04 的 note)。SPIKE 模式 0/1/2/9 的 nibble 也用同樣方式在 note 說明。
- 搖桿:I2C/mBlock 送 ±100;EV3/0x22送 0
99(50 = 中間)、SPIKE 送 19(5 = 中間),不是線性 offset,主機端各自換算(網站範例已是這樣)。 - EV3 模式 3 = 方向鍵 | 形狀鍵<<4 | 已連線<<8(#67 新增 bit8);模式 4 內容不變([方向鍵, LX, 形狀鍵, LY]);模式 5 改送裝置 ID 格式 B [0x42 | 2<<8, 韌體版]。
- SPIKE 模式 3 改 [已連線, 電量, 0](3×int8)、模式 8 改 [0x42 | 2<<8, 協議版 2, 韌體版, 更新序號];其餘空模式 1、2、4、6 維持現狀。
- ESP32 從機不能時脈延展:I2C v2 在 onReceive 就預載從該編號起 32 B;0x22照 MATRIX 定案 §5 #2 預載最新一包,待上機。
- I2C 0A 系統鍵 b1 = 擷取鍵(v1 0x15 放在 b3,v2 改 b1,照 I2C 定案 §4)。