SDL
SDL copied to clipboard
Add support for Joy-Con 2
This might be tricky.
On Windows, they show up as an 'Unknown device' whilst pairing, and immediately disconnect when Windows attempts to pair.
From what I understand, these devices are LE only. This is all I know for now.
btmon output for scanning of Joy-Con 2 (Right)
> HCI Event: LE Meta Event (0x3e) plen 57 #21 [hci0] 7.932117
LE Extended Advertising Report (0x0d)
Num reports: 1
Entry 0
Event type: 0x0013
Props: 0x0013
Connectable
Scannable
Use legacy advertising PDUs
Data status: [0;32mComplete[0m
Legacy PDU Type: ADV_IND (0x0013)
Address type: Public (0x00)
Address: 98:E2:55:A1:A5:FE (Nintendo Co.,Ltd)
Primary PHY: LE 1M
Secondary PHY: No packets
SID: no ADI field (0xff)
TX power: 127 dBm
RSSI: -44 dBm (0xd4)
Periodic advertising interval: 0.00 msec (0x0000)
Direct address type: Public (0x00)
Direct address: 00:00:00:00:00:00 (OUI 00-00-00)
Data length: 0x1f
02 01 06 1b ff 53 05 01 00 03 7e 05 66 20 00 01 .....S....~.f ..
00 00 00 00 00 00 00 0f 00 00 00 00 00 00 00 ...............
Flags: 0x06
LE General Discoverable Mode
BR/EDR Not Supported
Company: Nintendo Co., Ltd. (1363)
Data[24]: 0100037e0566200001000000000000000f00000000000000
> HCI Event: LE Meta Event (0x3e) plen 26 #22 [hci0] 7.932487
LE Extended Advertising Report (0x0d)
Num reports: 1
Entry 0
Event type: 0x001b
Props: 0x001b
Connectable
Scannable
Scan response
Use legacy advertising PDUs
Data status: [0;32mComplete[0m
Legacy PDU Type: SCAN_RSP to an ADV_SCAN_IND (0x001b)
Address type: Public (0x00)
Address: 98:E2:55:A1:A5:FE (Nintendo Co.,Ltd)
Primary PHY: LE 1M
Secondary PHY: No packets
SID: no ADI field (0xff)
TX power: 127 dBm
RSSI: -44 dBm (0xd4)
Periodic advertising interval: 0.00 msec (0x0000)
Direct address type: Public (0x00)
Direct address: 00:00:00:00:00:00 (OUI 00-00-00)
Data length: 0x00
@ MGMT Event: Device Found (0x0012) plen 45 {0x0001} [hci0] 7.932504
LE Address: 98:E2:55:A1:A5:FE (Nintendo Co.,Ltd)
RSSI: -44 dBm (0xd4)
Flags: 0x00000000
Data length: 31
Flags: 0x06
LE General Discoverable Mode
BR/EDR Not Supported
Company: Nintendo Co., Ltd. (1363)
Data[24]: 0100037e0566200001000000000000000f00000000000000
btmon output of attempting to pair Joy-Con 2 (Right)
@ MGMT Command: Pair Device (0x0019) plen 8 {0x0001} [hci0] 21.480930
LE Address: 98:E2:55:A1:A5:FE (Nintendo Co.,Ltd)
Capability: KeyboardDisplay (0x04)
> HCI Event: Command Complete (0x0e) plen 4 #96 [hci0] 21.484774
LE Set Address Resolution Enable (0x08|0x002d) ncmd 1
Status: Success (0x00)
HCI Event: Command Complete (0x0e) plen 4 #98 [hci0] 21.487769
LE Set Extended Scan Parameters (0x08|0x0041) ncmd 1
Status: Success (0x00)
HCI Event: Command Complete (0x0e) plen 4 #100 [hci0] 21.490772
LE Set Extended Scan Enable (0x08|0x0042) ncmd 1
Status: Success (0x00)
HCI Event: Command Complete (0x0e) plen 4 #102 [hci0] 21.493025
LE Set Extended Scan Enable (0x08|0x0042) ncmd 1
Status: Success (0x00)
HCI Event: Command Complete (0x0e) plen 4 #104 [hci0] 21.496776
LE Set Address Resolution Enable (0x08|0x002d) ncmd 1
Status: Success (0x00)
HCI Event: Command Complete (0x0e) plen 4 #106 [hci0] 21.499895
LE Add Device To Accept List (0x08|0x0011) ncmd 1
Status: Success (0x00)
HCI Event: Command Complete (0x0e) plen 4 #108 [hci0] 21.502770
LE Set Address Resolution Enable (0x08|0x002d) ncmd 1
Status: Success (0x00)
HCI Event: Command Complete (0x0e) plen 4 #110 [hci0] 21.505900
LE Set Extended Scan Parameters (0x08|0x0041) ncmd 1
Status: Success (0x00)
HCI Event: Command Complete (0x0e) plen 4 #112 [hci0] 21.508523
LE Set Extended Scan Enable (0x08|0x0042) ncmd 1
Status: Success (0x00)
> HCI Event: LE Meta Event (0x3e) plen 57 #113 [hci0] 21.531400
LE Extended Advertising Report (0x0d)
Num reports: 1
Entry 0
Event type: 0x0013
Props: 0x0013
Connectable
Scannable
Use legacy advertising PDUs
Data status: [0;32mComplete[0m
Legacy PDU Type: ADV_IND (0x0013)
Address type: Public (0x00)
Address: 98:E2:55:A1:A5:FE (Nintendo Co.,Ltd)
Primary PHY: LE 1M
Secondary PHY: No packets
SID: no ADI field (0xff)
TX power: 127 dBm
RSSI: -37 dBm (0xdb)
Periodic advertising interval: 0.00 msec (0x0000)
Direct address type: Public (0x00)
Direct address: 00:00:00:00:00:00 (OUI 00-00-00)
Data length: 0x1f
02 01 06 1b ff 53 05 01 00 03 7e 05 66 20 00 01 .....S....~.f ..
00 00 00 00 00 00 00 0f 00 00 00 00 00 00 00 ...............
Flags: 0x06
LE General Discoverable Mode
BR/EDR Not Supported
Company: Nintendo Co., Ltd. (1363)
Data[24]: 0100037e0566200001000000000000000f00000000000000
HCI Event: Command Complete (0x0e) plen 4 #115 [hci0] 21.533021
LE Set Extended Scan Enable (0x08|0x0042) ncmd 1
Status: Success (0x00)
HCI Event: Command Status (0x0f) plen 4 #117 [hci0] 21.537027
LE Extended Create Connection (0x08|0x0043) ncmd 1
Status: Success (0x00)
> HCI Event: LE Meta Event (0x3e) plen 31 #118 [hci0] 21.598399
LE Enhanced Connection Complete (0x0a)
Status: Success (0x00)
Handle: 512
Role: Central (0x00)
Peer address type: Public (0x00)
Peer address: 98:E2:55:A1:A5:FE (Nintendo Co.,Ltd)
Local resolvable private address: 00:00:00:00:00:00 (Non-Resolvable)
Peer resolvable private address: 00:00:00:00:00:00 (Non-Resolvable)
Connection interval: 48.75 msec (0x0027)
Connection latency: 0 (0x0000)
Supervision timeout: 420 msec (0x002a)
Central clock accuracy: 0x00
@ MGMT Event: Device Connected (0x000b) plen 44 {0x0001} [hci0] 21.598417
LE Address: 98:E2:55:A1:A5:FE (Nintendo Co.,Ltd)
Flags: 0x00000008
Connection Locally Initiated
Data length: 31
Flags: 0x06
LE General Discoverable Mode
BR/EDR Not Supported
Company: Nintendo Co., Ltd. (1363)
Data[24]: 0100037e0566200001000000000000000f00000000000000
@ RAW Open: btmon (privileged) version 2.22 {0x0003} 21.598538
@ RAW Close: btmon {0x0003} 21.598541
> HCI Event: LE Meta Event (0x3e) plen 4 #119 [hci0] 21.598523
LE Channel Selection Algorithm (0x14)
Handle: 512 Address: 98:E2:55:A1:A5:FE (Nintendo Co.,Ltd)
Algorithm: #2 (0x01)
> HCI Event: LE Meta Event (0x3e) plen 11 #120 [hci0] 21.598648
LE Data Length Change (0x07)
Handle: 512 Address: 98:E2:55:A1:A5:FE (Nintendo Co.,Ltd)
Max TX octets: 251
Max TX time: 2120
Max RX octets: 251
Max RX time: 2120
HCI Event: Command Status (0x0f) plen 4 #122 [hci0] 21.608525
LE Read Remote Used Features (0x08|0x0016) ncmd 1
Status: Success (0x00)
HCI Event: Command Complete (0x0e) plen 4 #124 [hci0] 21.611524
LE Set Address Resolution Enable (0x08|0x002d) ncmd 1
Status: Success (0x00)
HCI Event: Command Complete (0x0e) plen 4 #126 [hci0] 21.614526
LE Set Address Resolution Enable (0x08|0x002d) ncmd 1
Status: Success (0x00)
HCI Event: Command Complete (0x0e) plen 4 #128 [hci0] 21.617526
LE Set Extended Scan Parameters (0x08|0x0041) ncmd 1
Status: Success (0x00)
HCI Event: Command Complete (0x0e) plen 4 #130 [hci0] 21.620649
LE Set Extended Scan Enable (0x08|0x0042) ncmd 1
Status: Success (0x00)
> HCI Event: LE Meta Event (0x3e) plen 12 #131 [hci0] 21.695650
LE Read Remote Used Features (0x04)
Status: Success (0x00)
Handle: 512 Address: 98:E2:55:A1:A5:FE (Nintendo Co.,Ltd)
Features: 0xfd 0xfd 0xff 0xf7 0x00 0x00 0x00 0x00
LE Encryption
Extended Reject Indication
Peripheral-initiated Features Exchange
LE Ping
LE Data Packet Length Extension
LL Privacy
Extended Scanner Filter Policies
LE 2M PHY
Stable Modulation Index - Receiver
LE Coded PHY
LE Extended Advertising
LE Periodic Advertising
Channel Selection Algorithm #2
LE Power Class 1
Minimum Number of Used Channels Procedure
Connection CTE Request
Connection CTE Response
Connectionless CTE Transmitter
Connectionless CTE Receiver
Antenna Switching During CTE Transmission (AoD)
Antenna Switching During CTE Reception (AoA)
Receiving Constant Tone Extensions
Periodic Advertising Sync Transfer - Sender
Periodic Advertising Sync Transfer - Recipient
Sleep Clock Accuracy Updates
Connected Isochronous Stream - Central
Connected Isochronous Stream - Peripheral
Isochronous Broadcaster
Synchronized Receiver
HCI Event: Number of Completed Packets (0x13) plen 5 #133 [hci0] 21.744400
Num handles: 1
Handle: 512 Address: 98:E2:55:A1:A5:FE (Nintendo Co.,Ltd)
Count: 1
#132: len 11 (1 Kb/s)
Latency: 48 msec (48-48 msec ~48 msec)
> ACL Data RX: Handle 512 flags 0x02 dlen 6 #134 [hci0] 21.794577
SMP: Pairing Failed (0x05) len 1
Reason: Pairing not supported (0x05)
@ MGMT Event: Command Complete (0x0001) plen 10 {0x0001} [hci0] 21.794807
Pair Device (0x0019) plen 7
Status: Authentication Failed (0x05)
LE Address: 98:E2:55:A1:A5:FE (Nintendo Co.,Ltd)
> ACL Data RX: Handle 512 flags 0x02 dlen 11 #135 [hci0] 21.794578
SMP: Pairing Response (0x02) len 6
IO capability: NoInputNoOutput (0x03)
OOB data: Authentication data not present (0x00)
Authentication requirement: No bonding, No MITM, Legacy, No Keypresses (0x00)
Max encryption key size: 16
Initiator key distribution: (0x00)
Responder key distribution: (0x00)
HCI Event: Command Status (0x0f) plen 4 #137 [hci0] 21.797400
Disconnect (0x01|0x0006) ncmd 1
Status: Success (0x00)
> HCI Event: Disconnect Complete (0x05) plen 4 #138 [hci0] 21.842153
Status: Success (0x00)
Handle: 512 Address: 98:E2:55:A1:A5:FE (Nintendo Co.,Ltd)
Reason: Authentication Failure (0x05)
@ MGMT Event: Device Disconnected (0x000c) plen 8 {0x0001} [hci0] 21.842161
LE Address: 98:E2:55:A1:A5:FE (Nintendo Co.,Ltd)
Reason: Unspecified (0x00)
Part of #13178
I wonder how the maintainers of SDL will treat the new mouse sensor in these devices? Will it be exposed as some sort of sensor like gyro and accelerometer (e.g. position delta) or will it be left to the OS to expose it as a regular pointing device?
My guess is the mouse data will have to be a new sensor type (SDL_SENSOR_OPTICAL?) and it will be relative x/y only. It may be possible to optionally expose mouse motion events via hints but it depends on what the best experience would be for multi-mouse scenarios. I don't know if I would expose the buttons since the clash between left/right controllers and left/right mouse would be difficult to fake; the optimal setup would either detect or assume optical motion from a physical device and interpret the device's buttons accordingly. Beyond that, it would have to be something #4464 addresses.
I'm pretty sure SDL already supports multiple mice. IIRC that was added in 2.0.