summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorJordan Woyak <jordan.woyak@gmail.com>2018-12-15 10:26:51 -0600
committerJordan Woyak <jordan.woyak@gmail.com>2018-12-15 10:36:22 -0600
commit79eb065cf31e5cfc3280e6baadbb71bbd2d1ad33 (patch)
tree27ccba2a52cc2ba5ddd004d1061602fca53c0394 /Source/Core
parenta8a6bdcdd2b23573ac6ab913edf501f112a4c588 (diff)
Reduce emulated shaking frequency to 6hz. (something more humanly possible) (was ~13hz)
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Core/HW/Wiimote.h9
-rw-r--r--Source/Core/Core/HW/WiimoteEmu/Attachment/Nunchuk.h4
-rw-r--r--Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp33
-rw-r--r--Source/Core/Core/IOS/USB/Bluetooth/BTEmu.cpp3
4 files changed, 26 insertions, 23 deletions
diff --git a/Source/Core/Core/HW/Wiimote.h b/Source/Core/Core/HW/Wiimote.h
index 1e3e9c9c2a..a9e9405696 100644
--- a/Source/Core/Core/HW/Wiimote.h
+++ b/Source/Core/Core/HW/Wiimote.h
@@ -23,7 +23,7 @@ enum class ClassicGroup;
enum class GuitarGroup;
enum class DrumsGroup;
enum class TurntableGroup;
-}
+} // namespace WiimoteEmu
enum
{
@@ -55,6 +55,9 @@ enum class InitializeMode
DO_NOT_WAIT_FOR_WIIMOTES,
};
+// The Real Wii Remote sends report every ~5ms (200 Hz).
+constexpr int UPDATE_FREQ = 200;
+
void Shutdown();
void Initialize(InitializeMode init_mode);
void Connect(unsigned int index, bool connect);
@@ -78,7 +81,7 @@ void InterruptChannel(int number, u16 channel_id, const void* data, u32 size);
bool ButtonPressed(int number);
void Update(int number, bool connected);
bool NetPlay_GetButtonPress(int wiimote, bool pressed);
-}
+} // namespace Wiimote
namespace WiimoteReal
{
@@ -90,4 +93,4 @@ void Pause();
void Refresh();
void LoadSettings();
-}
+} // namespace WiimoteReal
diff --git a/Source/Core/Core/HW/WiimoteEmu/Attachment/Nunchuk.h b/Source/Core/Core/HW/WiimoteEmu/Attachment/Nunchuk.h
index 8a8f5d5d08..b16df713d7 100644
--- a/Source/Core/Core/HW/WiimoteEmu/Attachment/Nunchuk.h
+++ b/Source/Core/Core/HW/WiimoteEmu/Attachment/Nunchuk.h
@@ -14,7 +14,7 @@ class Buttons;
class ControlGroup;
class Force;
class Tilt;
-}
+} // namespace ControllerEmu
namespace WiimoteEmu
{
@@ -69,4 +69,4 @@ private:
std::array<u8, 3> m_shake_soft_step{};
std::array<u8, 3> m_shake_hard_step{};
};
-}
+} // namespace WiimoteEmu
diff --git a/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp b/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp
index 7e33d2492d..95896dcbb6 100644
--- a/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp
+++ b/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp
@@ -57,6 +57,11 @@ auto const PI = TAU / 2.0;
namespace WiimoteEmu
{
+constexpr int SHAKE_FREQ = 6;
+// Frame count of one up/down shake
+// < 9 no shake detection in "Wario Land: Shake It"
+constexpr int SHAKE_STEP_MAX = ::Wiimote::UPDATE_FREQ / SHAKE_FREQ;
+
// clang-format off
static const u8 eeprom_data_0[] = {
// IR, maybe more
@@ -114,10 +119,6 @@ void UpdateCalibrationDataChecksum(std::array<u8, 0x10>& data)
void EmulateShake(AccelData* const accel, ControllerEmu::Buttons* const buttons_group,
const double intensity, u8* const shake_step)
{
- // frame count of one up/down shake
- // < 9 no shake detection in "Wario Land: Shake It"
- auto const shake_step_max = 15;
-
// shake is a bitfield of X,Y,Z shake button states
static const unsigned int btns[] = {0x01, 0x02, 0x04};
unsigned int shake = 0;
@@ -127,8 +128,8 @@ void EmulateShake(AccelData* const accel, ControllerEmu::Buttons* const buttons_
{
if (shake & (1 << i))
{
- (&(accel->x))[i] = std::sin(TAU * shake_step[i] / shake_step_max) * intensity;
- shake_step[i] = (shake_step[i] + 1) % shake_step_max;
+ (&(accel->x))[i] = std::sin(TAU * shake_step[i] / SHAKE_STEP_MAX) * intensity;
+ shake_step[i] = (shake_step[i] + 1) % SHAKE_STEP_MAX;
}
else
shake_step[i] = 0;
@@ -139,10 +140,6 @@ void EmulateDynamicShake(AccelData* const accel, DynamicData& dynamic_data,
ControllerEmu::Buttons* const buttons_group,
const DynamicConfiguration& config, u8* const shake_step)
{
- // frame count of one up/down shake
- // < 9 no shake detection in "Wario Land: Shake It"
- auto const shake_step_max = 15;
-
// shake is a bitfield of X,Y,Z shake button states
static const unsigned int btns[] = {0x01, 0x02, 0x04};
unsigned int shake = 0;
@@ -156,8 +153,8 @@ void EmulateDynamicShake(AccelData* const accel, DynamicData& dynamic_data,
}
else if (dynamic_data.executing_frames_left[i] > 0)
{
- (&(accel->x))[i] = std::sin(TAU * shake_step[i] / shake_step_max) * dynamic_data.intensity[i];
- shake_step[i] = (shake_step[i] + 1) % shake_step_max;
+ (&(accel->x))[i] = std::sin(TAU * shake_step[i] / SHAKE_STEP_MAX) * dynamic_data.intensity[i];
+ shake_step[i] = (shake_step[i] + 1) % SHAKE_STEP_MAX;
dynamic_data.executing_frames_left[i]--;
}
else if (shake == 0 && dynamic_data.timing[i] > 0)
@@ -1035,11 +1032,15 @@ void Wiimote::LoadDefaults(const ControllerInterface& ciface)
// Buttons
#if defined HAVE_X11 && HAVE_X11
- m_buttons->SetControlExpression(0, "Click 1"); // A
- m_buttons->SetControlExpression(1, "Click 3"); // B
+ // A
+ m_buttons->SetControlExpression(0, "Click 1");
+ // B
+ m_buttons->SetControlExpression(1, "Click 3");
#else
- m_buttons->SetControlExpression(0, "Click 0"); // A
- m_buttons->SetControlExpression(1, "Click 1"); // B
+ // A
+ m_buttons->SetControlExpression(0, "Click 0");
+ // B
+ m_buttons->SetControlExpression(1, "Click 1");
#endif
m_buttons->SetControlExpression(2, "1"); // 1
m_buttons->SetControlExpression(3, "2"); // 2
diff --git a/Source/Core/Core/IOS/USB/Bluetooth/BTEmu.cpp b/Source/Core/Core/IOS/USB/Bluetooth/BTEmu.cpp
index 806151bbd4..02e8a7c79a 100644
--- a/Source/Core/Core/IOS/USB/Bluetooth/BTEmu.cpp
+++ b/Source/Core/Core/IOS/USB/Bluetooth/BTEmu.cpp
@@ -356,8 +356,7 @@ void BluetoothEmu::Update()
}
}
- // The Real Wii Remote sends report every ~5ms (200 Hz).
- const u64 interval = SystemTimers::GetTicksPerSecond() / 200;
+ const u64 interval = SystemTimers::GetTicksPerSecond() / Wiimote::UPDATE_FREQ;
const u64 now = CoreTiming::GetTicks();
if (now - m_last_ticks > interval)