Allow emulated wiimote to be tilted 180 degrees in each direction. (was 90)

Fixes issue 3492.
This commit is contained in:
Jordan Woyak 2013-01-19 19:16:01 -06:00
parent 7f8341825b
commit 6ec95d30af
3 changed files with 9 additions and 6 deletions

View File

@ -124,7 +124,8 @@ void EmulateTilt(AccelData* const accel
, const bool focus, const bool sideways, const bool upright)
{
float roll, pitch;
tilt_group->GetState( &roll, &pitch, 0, focus ? (PI / 2) : 0 ); // 90 degrees
// 180 degrees
tilt_group->GetState(&roll, &pitch, 0, focus ? PI : 0);
unsigned int ud = 0, lr = 0, fb = 0;
@ -267,6 +268,9 @@ Wiimote::Wiimote( const unsigned int index )
for (unsigned int i=0; i < sizeof(named_buttons)/sizeof(*named_buttons); ++i)
m_buttons->controls.push_back(new ControlGroup::Input( named_buttons[i]));
// udp
groups.push_back(m_udp = new UDPWrapper(m_index, _trans("UDP Wiimote")));
// ir
groups.push_back(m_ir = new Cursor(_trans("IR")));
@ -276,9 +280,6 @@ Wiimote::Wiimote( const unsigned int index )
// tilt
groups.push_back(m_tilt = new Tilt(_trans("Tilt")));
// udp
groups.push_back(m_udp = new UDPWrapper(m_index, _trans("UDP Wiimote")));
// shake
groups.push_back(m_shake = new Buttons(_trans("Shake")));
m_shake->controls.push_back(new ControlGroup::Input("X"));

View File

@ -295,6 +295,7 @@ ControllerEmu::Tilt::Tilt(const char* const _name)
settings.push_back(new Setting(_trans("Dead Zone"), 0, 0, 50));
settings.push_back(new Setting(_trans("Circle Stick"), 0));
settings.push_back(new Setting(_trans("Angle"), 0.9f, 0, 180));
}
ControllerEmu::Cursor::Cursor(const char* const _name)

View File

@ -307,6 +307,7 @@ public:
ControlState deadzone = settings[0]->value;
ControlState circle = settings[1]->value;
auto const angle = settings[2]->value / 1.8f;
ControlState m = controls[4]->control_ref->State();
// modifier code
@ -363,8 +364,8 @@ public:
m_tilt[1] = std::max(m_tilt[1] - 0.1f, yy);
}
*y = C(m_tilt[1] * range + base);
*x = C(m_tilt[0] * range + base);
*y = C(m_tilt[1] * angle * range + base);
*x = C(m_tilt[0] * angle * range + base);
}
private:
float m_tilt[2];