Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Allow emulated wiimote to be tilted 180 degrees in each direction. (w…
…as 90)

Fixes issue 3492.
  • Loading branch information
jordan-woyak committed Jan 20, 2013
1 parent 7f83418 commit 6ec95d3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
9 changes: 5 additions & 4 deletions Source/Core/Core/Src/HW/WiimoteEmu/WiimoteEmu.cpp
Expand Up @@ -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;

Expand Down Expand Up @@ -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")));

Expand All @@ -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"));
Expand Down
1 change: 1 addition & 0 deletions Source/Core/InputCommon/Src/ControllerEmu.cpp
Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions Source/Core/InputCommon/Src/ControllerEmu.h
Expand Up @@ -307,6 +307,7 @@ class ControllerEmu

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
Expand Down Expand Up @@ -363,8 +364,8 @@ class ControllerEmu
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];
Expand Down

0 comments on commit 6ec95d3

Please sign in to comment.