Wiimote: Extend emulated Wiimote reconnect-on-button-press to attachments.
This commit is contained in:
parent
ab2e68aa16
commit
244e5224a7
|
@ -50,3 +50,15 @@ void ControllerEmu::Extension::GetState(u8* const data)
|
||||||
{
|
{
|
||||||
((WiimoteEmu::Attachment*)attachments[active_extension].get())->GetState(data);
|
((WiimoteEmu::Attachment*)attachments[active_extension].get())->GetState(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ControllerEmu::Extension::IsButtonPressed() const
|
||||||
|
{
|
||||||
|
// Extension == 0 means no Extension, > 0 means one is connected
|
||||||
|
// Since we want to use this to know if disconnected Wiimotes want to be connected, and disconnected
|
||||||
|
// Wiimotes (can? always?) have their active_extension set to -1, we also have to check the switch_extension
|
||||||
|
if (active_extension > 0)
|
||||||
|
return ((WiimoteEmu::Attachment*)attachments[active_extension].get())->IsButtonPressed();
|
||||||
|
if (switch_extension > 0)
|
||||||
|
return ((WiimoteEmu::Attachment*)attachments[switch_extension].get())->IsButtonPressed();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ public:
|
||||||
Attachment(const char* const _name, WiimoteEmu::ExtensionReg& _reg);
|
Attachment(const char* const _name, WiimoteEmu::ExtensionReg& _reg);
|
||||||
|
|
||||||
virtual void GetState(u8* const data) {}
|
virtual void GetState(u8* const data) {}
|
||||||
|
virtual bool IsButtonPressed() const { return false; }
|
||||||
void Reset();
|
void Reset();
|
||||||
std::string GetName() const override;
|
std::string GetName() const override;
|
||||||
|
|
||||||
|
|
|
@ -135,5 +135,14 @@ void Classic::GetState(u8* const data)
|
||||||
ccdata->bt.hex ^= 0xFFFF;
|
ccdata->bt.hex ^= 0xFFFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Classic::IsButtonPressed() const
|
||||||
|
{
|
||||||
|
u16 buttons = 0;
|
||||||
|
ControlState trigs[2] = { 0, 0 };
|
||||||
|
m_buttons->GetState(&buttons, classic_button_bitmasks);
|
||||||
|
m_dpad->GetState(&buttons, classic_dpad_bitmasks);
|
||||||
|
m_triggers->GetState(&buttons, classic_trigger_bitmasks, trigs);
|
||||||
|
return buttons != 0;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ class Classic : public Attachment
|
||||||
public:
|
public:
|
||||||
Classic(WiimoteEmu::ExtensionReg& _reg);
|
Classic(WiimoteEmu::ExtensionReg& _reg);
|
||||||
void GetState(u8* const data) override;
|
void GetState(u8* const data) override;
|
||||||
|
bool IsButtonPressed() const override;
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
|
|
@ -81,4 +81,12 @@ void Drums::GetState(u8* const data)
|
||||||
ddata->bt ^= 0xFFFF;
|
ddata->bt ^= 0xFFFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Drums::IsButtonPressed() const
|
||||||
|
{
|
||||||
|
u16 buttons = 0;
|
||||||
|
m_buttons->GetState(&buttons, drum_button_bitmasks);
|
||||||
|
m_pads->GetState(&buttons, drum_pad_bitmasks);
|
||||||
|
return buttons != 0;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ class Drums : public Attachment
|
||||||
public:
|
public:
|
||||||
Drums(WiimoteEmu::ExtensionReg& _reg);
|
Drums(WiimoteEmu::ExtensionReg& _reg);
|
||||||
void GetState(u8* const data) override;
|
void GetState(u8* const data) override;
|
||||||
|
bool IsButtonPressed() const override;
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
|
|
@ -100,4 +100,13 @@ void Guitar::GetState(u8* const data)
|
||||||
gdata->bt ^= 0xFFFF;
|
gdata->bt ^= 0xFFFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Guitar::IsButtonPressed() const
|
||||||
|
{
|
||||||
|
u16 buttons = 0;
|
||||||
|
m_buttons->GetState(&buttons, guitar_button_bitmasks);
|
||||||
|
m_frets->GetState(&buttons, guitar_fret_bitmasks);
|
||||||
|
m_strum->GetState(&buttons, guitar_strum_bitmasks);
|
||||||
|
return buttons != 0;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ class Guitar : public Attachment
|
||||||
public:
|
public:
|
||||||
Guitar(WiimoteEmu::ExtensionReg& _reg);
|
Guitar(WiimoteEmu::ExtensionReg& _reg);
|
||||||
void GetState(u8* const data) override;
|
void GetState(u8* const data) override;
|
||||||
|
bool IsButtonPressed() const override;
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
|
|
@ -106,6 +106,13 @@ void Nunchuk::GetState(u8* const data)
|
||||||
ncdata->bt.acc_z_lsb = accel_z & 0x3;
|
ncdata->bt.acc_z_lsb = accel_z & 0x3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Nunchuk::IsButtonPressed() const
|
||||||
|
{
|
||||||
|
u8 buttons = 0;
|
||||||
|
m_buttons->GetState(&buttons, nunchuk_button_bitmasks);
|
||||||
|
return buttons != 0;
|
||||||
|
}
|
||||||
|
|
||||||
void Nunchuk::LoadDefaults(const ControllerInterface& ciface)
|
void Nunchuk::LoadDefaults(const ControllerInterface& ciface)
|
||||||
{
|
{
|
||||||
// ugly macroooo
|
// ugly macroooo
|
||||||
|
|
|
@ -17,6 +17,7 @@ public:
|
||||||
Nunchuk(WiimoteEmu::ExtensionReg& _reg);
|
Nunchuk(WiimoteEmu::ExtensionReg& _reg);
|
||||||
|
|
||||||
void GetState(u8* const data) override;
|
void GetState(u8* const data) override;
|
||||||
|
bool IsButtonPressed() const override;
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
|
|
@ -127,5 +127,11 @@ void Turntable::GetState(u8* const data)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Turntable::IsButtonPressed() const
|
||||||
|
{
|
||||||
|
u16 buttons = 0;
|
||||||
|
m_buttons->GetState(&buttons, turntable_button_bitmasks);
|
||||||
|
return buttons != 0;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ class Turntable : public Attachment
|
||||||
public:
|
public:
|
||||||
Turntable(WiimoteEmu::ExtensionReg& _reg);
|
Turntable(WiimoteEmu::ExtensionReg& _reg);
|
||||||
void GetState(u8* const data) override;
|
void GetState(u8* const data) override;
|
||||||
|
bool IsButtonPressed() const override;
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
|
|
@ -881,7 +881,7 @@ void Wiimote::ConnectOnInput()
|
||||||
m_buttons->GetState(&buttons, button_bitmasks);
|
m_buttons->GetState(&buttons, button_bitmasks);
|
||||||
m_dpad->GetState(&buttons, dpad_bitmasks);
|
m_dpad->GetState(&buttons, dpad_bitmasks);
|
||||||
|
|
||||||
if (buttons != 0)
|
if (buttons != 0 || m_extension->IsButtonPressed())
|
||||||
{
|
{
|
||||||
Host_ConnectWiimote(m_index, true);
|
Host_ConnectWiimote(m_index, true);
|
||||||
// arbitrary value so it doesn't try to send multiple requests before Dolphin can react
|
// arbitrary value so it doesn't try to send multiple requests before Dolphin can react
|
||||||
|
|
|
@ -424,6 +424,7 @@ public:
|
||||||
~Extension() {}
|
~Extension() {}
|
||||||
|
|
||||||
void GetState(u8* const data);
|
void GetState(u8* const data);
|
||||||
|
bool IsButtonPressed() const;
|
||||||
|
|
||||||
std::vector<std::unique_ptr<ControllerEmu>> attachments;
|
std::vector<std::unique_ptr<ControllerEmu>> attachments;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue