summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorLéo Lam <leo@leolam.fr>2019-11-17 10:39:18 +0100
committerGitHub <noreply@github.com>2019-11-17 10:39:18 +0100
commit97f9f252ccae53ce8abd766a0fb22209b1b47bc6 (patch)
tree989f1e3450aa064fdfdda27b65304dbb690d2867 /Source/Core
parentbc1aa3640b02e75e9079a1f6aa06f3f0d7fe7840 (diff)
parent4d24f160e300adadc94ad9491f24f43d82ee3847 (diff)
Merge pull request #8464 from jordan-woyak/wm-emu-errorcode
WiimoteEmu: Minor accuracy fixes.
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Core/HW/WiimoteCommon/WiimoteConstants.h12
-rw-r--r--Source/Core/Core/HW/WiimoteEmu/EmuSubroutines.cpp17
2 files changed, 21 insertions, 8 deletions
diff --git a/Source/Core/Core/HW/WiimoteCommon/WiimoteConstants.h b/Source/Core/Core/HW/WiimoteCommon/WiimoteConstants.h
index 02313ac048..99cf0e04e7 100644
--- a/Source/Core/Core/HW/WiimoteCommon/WiimoteConstants.h
+++ b/Source/Core/Core/HW/WiimoteCommon/WiimoteConstants.h
@@ -62,16 +62,22 @@ enum class AddressSpace : u8
// FYI: The EEPROM address space is offset 0x0070 on i2c slave 0x50.
// However attempting to access this device directly results in an error.
EEPROM = 0x00,
- // 0x01 is never used but it does function on a real wiimote:
- I2CBusAlt = 0x01,
- I2CBus = 0x02,
+ // I2CBusAlt is never used by games but it does function on a real wiimote.
+ I2CBus = 0x01,
+ I2CBusAlt = 0x02,
};
enum class ErrorCode : u8
{
+ // Normal result.
Success = 0,
+ // Produced by read/write attempts during an active read.
+ Busy = 4,
+ // Produced by using something other than the above AddressSpace values.
InvalidSpace = 6,
+ // Produced by an i2c read/write with a non-responding slave address.
Nack = 7,
+ // Produced by accessing invalid regions of EEPROM or the EEPROM directly over i2c.
InvalidAddress = 8,
};
diff --git a/Source/Core/Core/HW/WiimoteEmu/EmuSubroutines.cpp b/Source/Core/Core/HW/WiimoteEmu/EmuSubroutines.cpp
index 5a11782d63..76d5848336 100644
--- a/Source/Core/Core/HW/WiimoteEmu/EmuSubroutines.cpp
+++ b/Source/Core/Core/HW/WiimoteEmu/EmuSubroutines.cpp
@@ -258,7 +258,12 @@ void Wiimote::HandleRequestStatus(const OutputReportRequestStatus&)
void Wiimote::HandleWriteData(const OutputReportWriteData& wd)
{
- // TODO: Are writes ignored during an active read request?
+ if (m_read_request.size)
+ {
+ // FYI: Writes during an active read will occasionally produce a "busy" (0x4) ack.
+ // We won't simulate that as it often does work. Poorly programmed games may rely on it.
+ WARN_LOG(WIIMOTE, "WriteData: write during active read request.");
+ }
u16 address = Common::swap16(wd.address);
@@ -416,9 +421,11 @@ void Wiimote::HandleReadData(const OutputReportReadData& rd)
{
if (m_read_request.size)
{
- // There is already an active read request.
- // A real wiimote ignores the new one.
- WARN_LOG(WIIMOTE, "ReadData: ignoring read during active request.");
+ // There is already an active read being processed.
+ WARN_LOG(WIIMOTE, "ReadData: attempting read during active request.");
+
+ // A real wm+ sends a busy ack in this situation.
+ SendAck(OutputReportID::ReadData, ErrorCode::Busy);
return;
}
@@ -437,7 +444,7 @@ void Wiimote::HandleReadData(const OutputReportReadData& rd)
// TODO: should this be removed and let Update() take care of it?
ProcessReadDataRequest();
- // FYI: No "ACK" is sent.
+ // FYI: No "ACK" is sent under normal situations.
}
bool Wiimote::ProcessReadDataRequest()