WiimoteEmu: Fix usage of ReportFeatures in TAS related code.
This commit is contained in:
parent
4dc0aa6f8e
commit
84d32f6645
|
@ -849,15 +849,16 @@ void Wiimote::Update()
|
||||||
|
|
||||||
Movie::SetPolledDevice();
|
Movie::SetPolledDevice();
|
||||||
|
|
||||||
|
// TODO: Is max battery really 100 and not 0xff?
|
||||||
m_status.battery = (u8)(m_battery_setting->GetValue() * 100);
|
m_status.battery = (u8)(m_battery_setting->GetValue() * 100);
|
||||||
|
|
||||||
const ReportFeatures& rptf = reporting_mode_features[m_reporting_mode - RT_REPORT_CORE];
|
const ReportFeatures& rptf = reporting_mode_features[m_reporting_mode - RT_REPORT_CORE];
|
||||||
s8 rptf_size = rptf.size;
|
s8 rptf_size = rptf.total_size;
|
||||||
if (Movie::IsPlayingInput() &&
|
if (Movie::IsPlayingInput() &&
|
||||||
Movie::PlayWiimote(m_index, data, rptf, m_extension->active_extension, m_ext_logic.ext_key))
|
Movie::PlayWiimote(m_index, data, rptf, m_extension->active_extension, m_ext_logic.ext_key))
|
||||||
{
|
{
|
||||||
if (rptf.core)
|
if (rptf.core_size)
|
||||||
m_status.buttons = *reinterpret_cast<wm_buttons*>(data + rptf.core);
|
m_status.buttons = *reinterpret_cast<wm_buttons*>(data + 2);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -873,38 +874,43 @@ void Wiimote::Update()
|
||||||
u8* feature_ptr = data + 2;
|
u8* feature_ptr = data + 2;
|
||||||
|
|
||||||
// core buttons
|
// core buttons
|
||||||
if (rptf.core)
|
if (rptf.core_size)
|
||||||
{
|
{
|
||||||
GetButtonData(feature_ptr);
|
GetButtonData(feature_ptr);
|
||||||
feature_ptr += rptf.core;
|
feature_ptr += rptf.core_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
// acceleration
|
// acceleration
|
||||||
if (rptf.accel)
|
if (rptf.accel_size)
|
||||||
{
|
{
|
||||||
// TODO: GetAccelData has hardcoded payload offsets..
|
// TODO: GetAccelData has hardcoded payload offsets..
|
||||||
GetAccelData(data);
|
GetAccelData(data);
|
||||||
feature_ptr += rptf.accel;
|
feature_ptr += rptf.accel_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
// IR Camera
|
// IR Camera
|
||||||
// TODO: kill use_accel param
|
// TODO: kill use_accel param
|
||||||
// TODO: call only if camera logic is enabled?
|
// TODO: call only if camera logic is enabled?
|
||||||
UpdateIRData(rptf.accel != 0);
|
UpdateIRData(rptf.accel_size != 0);
|
||||||
if (rptf.ir)
|
if (rptf.ir_size)
|
||||||
{
|
{
|
||||||
// TODO: kill magic numbers
|
// TODO: kill magic numbers
|
||||||
m_i2c_bus.BusRead(0x58, 0x37, rptf.ir, feature_ptr);
|
m_i2c_bus.BusRead(0x58, 0x37, rptf.ir_size, feature_ptr);
|
||||||
feature_ptr += rptf.ir;
|
feature_ptr += rptf.ir_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
// extension
|
// extension
|
||||||
UpdateExtData();
|
UpdateExtData();
|
||||||
if (rptf.ext)
|
if (rptf.ext_size)
|
||||||
{
|
{
|
||||||
// TODO: kill magic numbers
|
// TODO: kill magic numbers
|
||||||
m_i2c_bus.BusRead(0x52, 0x00, rptf.ext, feature_ptr);
|
m_i2c_bus.BusRead(0x52, 0x00, rptf.ext_size, feature_ptr);
|
||||||
feature_ptr += rptf.ext;
|
feature_ptr += rptf.ext_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (feature_ptr != data + rptf_size)
|
||||||
|
{
|
||||||
|
PanicAlert("Wiimote input report is the wrong size!");
|
||||||
}
|
}
|
||||||
|
|
||||||
Movie::CallWiiInputManip(data, rptf, m_index, m_extension->active_extension,
|
Movie::CallWiiInputManip(data, rptf, m_index, m_extension->active_extension,
|
||||||
|
@ -912,9 +918,9 @@ void Wiimote::Update()
|
||||||
}
|
}
|
||||||
if (NetPlay::IsNetPlayRunning())
|
if (NetPlay::IsNetPlayRunning())
|
||||||
{
|
{
|
||||||
NetPlay_GetWiimoteData(m_index, data, rptf.size, m_reporting_mode);
|
NetPlay_GetWiimoteData(m_index, data, rptf.total_size, m_reporting_mode);
|
||||||
if (rptf.core)
|
if (rptf.core_size)
|
||||||
m_status.buttons = *reinterpret_cast<wm_buttons*>(data + rptf.core);
|
m_status.buttons = *reinterpret_cast<wm_buttons*>(data + rptf.core_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: need to fix usage of rptf probably
|
// TODO: need to fix usage of rptf probably
|
||||||
|
|
|
@ -16,9 +16,6 @@
|
||||||
// Registry sizes
|
// Registry sizes
|
||||||
#define WIIMOTE_EEPROM_SIZE (16 * 1024)
|
#define WIIMOTE_EEPROM_SIZE (16 * 1024)
|
||||||
#define WIIMOTE_EEPROM_FREE_SIZE 0x1700
|
#define WIIMOTE_EEPROM_FREE_SIZE 0x1700
|
||||||
#define WIIMOTE_REG_SPEAKER_SIZE 10
|
|
||||||
#define WIIMOTE_REG_EXT_SIZE 0x100
|
|
||||||
#define WIIMOTE_REG_IR_SIZE 0x34
|
|
||||||
|
|
||||||
class PointerWrap;
|
class PointerWrap;
|
||||||
|
|
||||||
|
@ -116,7 +113,14 @@ enum class TurntableGroup
|
||||||
|
|
||||||
struct ReportFeatures
|
struct ReportFeatures
|
||||||
{
|
{
|
||||||
u8 core, accel, ir, ext, size;
|
// Byte counts:
|
||||||
|
// Features are always in the following order in an input report:
|
||||||
|
u8 core_size, accel_size, ir_size, ext_size, total_size;
|
||||||
|
|
||||||
|
int GetCoreOffset() const { return 2; }
|
||||||
|
int GetAccelOffset() const { return GetCoreOffset() + core_size; }
|
||||||
|
int GetIROffset() const { return GetAccelOffset() + accel_size; }
|
||||||
|
int GetExtOffset() const { return GetIROffset() + ir_size; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct AccelData
|
struct AccelData
|
||||||
|
|
|
@ -648,10 +648,10 @@ static void SetWiiInputDisplayString(int remoteID, const u8* const data,
|
||||||
|
|
||||||
std::string display_str = StringFromFormat("R%d:", remoteID + 1);
|
std::string display_str = StringFromFormat("R%d:", remoteID + 1);
|
||||||
|
|
||||||
const u8* const coreData = rptf.core ? (data + rptf.core) : nullptr;
|
const u8* const coreData = rptf.core_size ? (data + rptf.GetCoreOffset()) : nullptr;
|
||||||
const u8* const accelData = rptf.accel ? (data + rptf.accel) : nullptr;
|
const u8* const accelData = rptf.accel_size ? (data + rptf.GetAccelOffset()) : nullptr;
|
||||||
const u8* const irData = rptf.ir ? (data + rptf.ir) : nullptr;
|
const u8* const irData = rptf.ir_size ? (data + rptf.GetIROffset()) : nullptr;
|
||||||
const u8* const extData = rptf.ext ? (data + rptf.ext) : nullptr;
|
const u8* const extData = rptf.ext_size ? (data + rptf.GetExtOffset()) : nullptr;
|
||||||
|
|
||||||
if (coreData)
|
if (coreData)
|
||||||
{
|
{
|
||||||
|
@ -821,7 +821,7 @@ void CheckWiimoteStatus(int wiimote, const u8* data, const WiimoteEmu::ReportFea
|
||||||
SetWiiInputDisplayString(wiimote, data, rptf, ext, key);
|
SetWiiInputDisplayString(wiimote, data, rptf, ext, key);
|
||||||
|
|
||||||
if (IsRecordingInput())
|
if (IsRecordingInput())
|
||||||
RecordWiimote(wiimote, data, rptf.size);
|
RecordWiimote(wiimote, data, rptf.total_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RecordWiimote(int wiimote, const u8* data, u8 size)
|
void RecordWiimote(int wiimote, const u8* data, u8 size)
|
||||||
|
@ -1204,7 +1204,7 @@ bool PlayWiimote(int wiimote, u8* data, const WiimoteEmu::ReportFeatures& rptf,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
u8 size = rptf.size;
|
u8 size = rptf.total_size;
|
||||||
|
|
||||||
u8 sizeInMovie = s_temp_input[s_currentByte];
|
u8 sizeInMovie = s_temp_input[s_currentByte];
|
||||||
|
|
||||||
|
|
|
@ -326,10 +326,10 @@ void WiiTASInputWindow::GetValues(u8* report_data, WiimoteEmu::ReportFeatures rp
|
||||||
|
|
||||||
UpdateExt(ext);
|
UpdateExt(ext);
|
||||||
|
|
||||||
u8* const buttons_data = rptf.core ? (report_data + rptf.core) : nullptr;
|
u8* const buttons_data = rptf.core_size ? (report_data + rptf.GetCoreOffset()) : nullptr;
|
||||||
u8* const accel_data = rptf.accel ? (report_data + rptf.accel) : nullptr;
|
u8* const accel_data = rptf.accel_size ? (report_data + rptf.GetAccelOffset()) : nullptr;
|
||||||
u8* const ir_data = rptf.ir ? (report_data + rptf.ir) : nullptr;
|
u8* const ir_data = rptf.ir_size ? (report_data + rptf.GetIROffset()) : nullptr;
|
||||||
u8* const ext_data = rptf.ext ? (report_data + rptf.ext) : nullptr;
|
u8* const ext_data = rptf.ext_size ? (report_data + rptf.GetExtOffset()) : nullptr;
|
||||||
|
|
||||||
if (m_remote_buttons_box->isVisible() && buttons_data)
|
if (m_remote_buttons_box->isVisible() && buttons_data)
|
||||||
{
|
{
|
||||||
|
@ -380,10 +380,11 @@ void WiiTASInputWindow::GetValues(u8* report_data, WiimoteEmu::ReportFeatures rp
|
||||||
|
|
||||||
u8 mode;
|
u8 mode;
|
||||||
// Mode 5 not supported in core anyway.
|
// Mode 5 not supported in core anyway.
|
||||||
if (rptf.ext)
|
// TODO: Can just use ir_size to determine mode
|
||||||
mode = (rptf.ext - rptf.ir) == 10 ? 1 : 3;
|
if (rptf.ext_size)
|
||||||
|
mode = (rptf.GetExtOffset() - rptf.GetIROffset()) == 10 ? 1 : 3;
|
||||||
else
|
else
|
||||||
mode = (rptf.size - rptf.ir) == 10 ? 1 : 3;
|
mode = (rptf.total_size - rptf.GetIROffset()) == 10 ? 1 : 3;
|
||||||
|
|
||||||
if (mode == 1)
|
if (mode == 1)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue