New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP - Wiimote emu motion plus #7589
WIP - Wiimote emu motion plus #7589
Conversation
…e the real thing. Transfer most of IR camera logic to the i2c bus. Temporarily break everything else.
…t's not a queue. New requests are ignored and input is suppressed while processing a request. This simplifies the save state code greatly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yay for cleanup!
// hybrid Wiimote stuff | ||
if (WIIMOTE_SRC_REAL & g_wiimote_sources[m_index] && (m_extension->switch_extension <= 0)) | ||
{ | ||
using namespace WiimoteReal; |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
@@ -202,53 +209,54 @@ void Wiimote::HandleExtensionSwap() | |||
|
|||
void Wiimote::RequestStatus(const wm_request_status* const rs) | |||
{ | |||
HandleExtensionSwap(); | |||
INFO_LOG(WIIMOTE, "Wiimote::RequestStatus"); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
|
||
// ignore the 0x010000 bit | ||
address &= ~0x010000; | ||
INFO_LOG(WIIMOTE, "Wiimote::WriteData: 0x%02x @ 0x%02x @ 0x%02x (%d)", wd->space, wd->slave_address, address, wd->size); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
@@ -620,4 +478,4 @@ void Wiimote::RealState() | |||
g_wiimotes[m_index]->EnableDataReporting(m_reporting_mode); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
@@ -135,21 +135,37 @@ void Pause() | |||
// An L2CAP packet is passed from the Core to the Wiimote on the HID CONTROL channel. | |||
void ControlChannel(int number, u16 channel_id, const void* data, u32 size) |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
class I2CBus | ||
{ | ||
public: | ||
void AddSlave(I2CSlave* slave) { m_slaves.emplace_back(slave); } |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
static const u8 c1[16] = {0x78, 0xd9, 0x78, 0x38, 0x77, 0x9d, 0x2f, 0x0c, | ||
0xcf, 0xf0, 0x31, 0xad, 0xc8, 0x0b, 0x5e, 0x39}; | ||
static const u8 c2[16] = {0x6f, 0x81, 0x7b, 0x89, 0x78, 0x51, 0x33, 0x60, | ||
0xc9, 0xf5, 0x37, 0xc1, 0x2d, 0xe9, 0x15, 0x8d}; |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
// Address 0x58 | ||
m_i2c_bus.AddSlave(&m_camera_logic); | ||
|
||
// TODO: only add to bus when enabled |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
{ | ||
++times_updated_since_activation; | ||
|
||
// TODO: wtf is this value actually.. |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
// For some reason the first read seems to have garbage data | ||
// is_mp_data and extension_connected are set, but the data is junk | ||
// it does seem to have some sort of pattern though, byte 5 is always 2 | ||
// something like: d5, b0, 4e, 6e, fc, 2 |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
return result; | ||
|
||
// It seems a write of any value triggers deactivation. | ||
if (0xf0 == addr) |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
auto const result = RawWrite(®_data, addr, count, data_in); | ||
|
||
// It seems a write of any value triggers activation. | ||
if (0xfe == addr) |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Reading through this code I am missing the handing of the read/write bit in i2c addressing. Am I missing the relevant code blocks or is the addressing handling wrong? If necessary, this document describes the i2c bus: https://www.nxp.com/docs/en/user-guide/UM10204.pdf |
The read/write bit (lsb of slave_address) is ignored by a real wiimote. I chop it off in Read/WriteData calls (>> 1) and the high level i2c bus simulation just makes use of the 7 bit address. |
Ah, that makes sense. Would it be meaningful to name the operation using a small constexpr function? |
…port handling with unusual values. Eliminated outdated comments.
da8e649
to
7369a84
Compare
Cleanup Wiimote emu code to more closely simulate the real thing.
Simulate Motion Plus attachment.
Eliminated some dead code.