Skip to content

Commit 0376d7c

Browse files
Wiimote to GunCon3 apply (https://wiibrew.org/wiki/Wiimote#IR_Camera) suggestions (Experimental)
1 parent 17b72ae commit 0376d7c

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

rpcs3/Emu/Io/WiimoteManager.cpp

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,37 +55,40 @@ bool wiimote_device::initialize_ir()
5555
auto write_reg = [&](u32 addr, const std::vector<u8>& data) {
5656
u8 buf[22] = {0};
5757
buf[0] = 0x16; // Write register
58-
buf[1] = 0x04;
58+
buf[1] = 0x06; // Register Space + Request Acknowledgement
5959
buf[2] = (addr >> 16) & 0xFF;
6060
buf[3] = (addr >> 8) & 0xFF;
6161
buf[4] = addr & 0xFF;
6262
buf[5] = static_cast<u8>(data.size());
6363
std::copy(data.begin(), data.end(), &buf[6]);
6464
if (hid_write(m_handle, buf, sizeof(buf)) < 0) return false;
65-
std::this_thread::sleep_for(std::chrono::milliseconds(20));
65+
std::this_thread::sleep_for(std::chrono::milliseconds(50));
6666
return true;
6767
};
6868

69-
// 1. Enable IR logic / Pixel Clock
70-
u8 ir_on1[] = { 0x13, 0x04 };
69+
// 1. Enable IR logic / Pixel Clock (Requesting Acknowledgement for stability)
70+
u8 ir_on1[] = { 0x13, 0x06 };
7171
hid_write(m_handle, ir_on1, 2);
72-
std::this_thread::sleep_for(std::chrono::milliseconds(20));
73-
u8 ir_on2[] = { 0x1a, 0x04 };
72+
std::this_thread::sleep_for(std::chrono::milliseconds(50));
73+
u8 ir_on2[] = { 0x1a, 0x06 };
7474
hid_write(m_handle, ir_on2, 2);
7575
std::this_thread::sleep_for(std::chrono::milliseconds(50));
7676

77-
// 2. Enable IR Camera (Matching wiimote_test order)
78-
if (!write_reg(0xb00030, {0x08})) return false;
77+
// 2. Enable IR Camera (Wii-style sequence)
78+
if (!write_reg(0xb00030, {0x01})) return false;
7979

80-
// 3. Sensitivity Level 3 (Exactly matching wiimote_test)
80+
// 3. Sensitivity Level 3 (Exactly matching wiimote_test / official levels)
8181
if (!write_reg(0xb00000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, 0x00, 0x41})) return false;
8282
if (!write_reg(0xb0001a, {0x40, 0x00})) return false;
8383

8484
// 4. IR Mode: Extended (3 bytes per point)
8585
if (!write_reg(0xb00033, {0x03})) return false;
8686

87-
// 5. Reporting mode: Buttons + Accel + IR
88-
u8 mode[] = { 0x12, 0x00, 0x33 };
87+
// 5. Finalize IR Enable
88+
if (!write_reg(0xb00030, {0x08})) return false;
89+
90+
// 6. Reporting mode: Buttons + Accel + IR (Continuous)
91+
u8 mode[] = { 0x12, 0x04, 0x33 };
8992
if (hid_write(m_handle, mode, sizeof(mode)) < 0) return false;
9093
std::this_thread::sleep_for(std::chrono::milliseconds(100));
9194

0 commit comments

Comments
 (0)