summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorsnzgoo <snzgoo@gmail.com>2010-06-03 13:20:30 +0000
committersnzgoo <snzgoo@gmail.com>2010-06-03 13:20:30 +0000
commit3236aa9e73cf6d0bc798cce6f5224cff40eb6955 (patch)
treecbf0753ca7b30a4557ab0abe764fd09c40e1c4bd /Source
parentacd2b03afeab33ce4caf0046f0a760697619ede0 (diff)
Fixed pointer and nunchuk issues in new WiimotePlugin. Removed ir hack.
Details: Issue consisted of IR data overflowing extension data on IR report change e.g. mode 3 to 1, which happens for instance when changing data report mode from 0x33 to 0x37. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5588 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source')
-rw-r--r--Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/EmuSubroutines.cpp2
-rw-r--r--Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/WiimoteEmu.cpp46
2 files changed, 24 insertions, 24 deletions
diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/EmuSubroutines.cpp b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/EmuSubroutines.cpp
index 3aa672b772..0a11b0533b 100644
--- a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/EmuSubroutines.cpp
+++ b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/EmuSubroutines.cpp
@@ -66,7 +66,7 @@ void Wiimote::ReportMode(const u16 _channelID, wm_report_mode* dr)
m_reporting_channel = _channelID;
// reset IR camera
- memset(m_reg_ir, 0, sizeof(*m_reg_ir));
+ //memset(m_reg_ir, 0, sizeof(*m_reg_ir)); //ugly hack
if (0 == dr->all_the_time)
PanicAlert("Wiimote: Reporting Always is set to OFF! Everything should be fine, but games never do this.");
diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/WiimoteEmu.cpp b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/WiimoteEmu.cpp
index e682d9c870..424c205aa8 100644
--- a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/WiimoteEmu.cpp
+++ b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/WiimoteEmu.cpp
@@ -484,26 +484,8 @@ void Wiimote::Update()
}
- // ----extension----
- if (rpt.ext)
- {
- m_extension->GetState(data + rpt.ext, is_focus);
-
- // i dont think anything accesses the extension data like this, but ill support it
- // i think it should be unencrpyted in the register, encrypted when read
- memcpy(m_reg_ext->controller_data, data + rpt.ext, sizeof(wm_extension));
-
- // both of these ifs work
- //if (0x55 != m_reg_ext->encryption)
- if (0xAA == m_reg_ext->encryption)
- wiimote_encrypt(&m_ext_key, data + rpt.ext, 0x00, sizeof(wm_extension));
- }
-
// ----ir----
- // only if camera is fully enabled.
- // should send 0xFF if camera isn't enabled maybe,
- // 0x00 is working fine though
- if (rpt.ir && 0x08 == m_reg_ir->data[0x30])
+ if (rpt.ir)
{
float xx = 10000, yy = 0, zz = 0;
@@ -526,14 +508,21 @@ void Wiimote::Update()
x[1] = (unsigned int)(xx + distance);
x[2] = (unsigned int)(xx - 1.2f * distance);
x[3] = (unsigned int)(xx + 1.2f * distance);
-
+
+ //0xFF report
+ if (rpt.ext)
+ memset(data + rpt.ir, 0xFF, (rpt.ext - rpt.ir));
+ else
+ memset(data + rpt.ir, 0xFF, (46 - rpt.ir));
+
+ //Fill report with valid data when full handshake was done
+ if (m_reg_ir->data[0x30] || m_reg_ir->data[0x33])
// ir mode
switch (m_reg_ir->mode)
{
// basic
case 1 :
{
- memset(data + rpt.ir, 0xFF, 10);
wm_ir_basic* const irdata = (wm_ir_basic*)(data + rpt.ir);
if (y < 768)
{
@@ -562,7 +551,6 @@ void Wiimote::Update()
// extended
case 3 :
{
- memset(data + rpt.ir, 0xFF, 12);
wm_ir_extended* const irdata = (wm_ir_extended*)(data + rpt.ir);
if (y < 768)
{
@@ -584,10 +572,22 @@ void Wiimote::Update()
case 5 :
// UNSUPPORTED
break;
-
}
}
+ // ----extension----
+ if (rpt.ext)
+ {
+ m_extension->GetState(data + rpt.ext, is_focus);
+
+ // i dont think anything accesses the extension data like this, but ill support it. Indeed, commercial games don't do this.
+ // i think it should be unencrpyted in the register, encrypted when read.
+ memcpy(m_reg_ext->controller_data, data + rpt.ext, sizeof(wm_extension));
+
+ if (0xAA == m_reg_ext->encryption) {
+ wiimote_encrypt(&m_ext_key, data + rpt.ext, 0x00, sizeof(wm_extension));
+ }
+ }
// send data report
g_WiimoteInitialize.pWiimoteInput( m_index, m_reporting_channel, data, rpt.size );
}