summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorSanjay Govind <sanjay.govind9@gmail.com>2024-12-22 23:55:13 +1300
committerSanjay Govind <sanjay.govind9@gmail.com>2025-01-24 10:06:09 +1300
commitef97185854a055da119eaafc0a685dbf25f0d67c (patch)
treea5ca58d5f4234d88cbc3448956777e3853f98564 /Source/Core
parent1ba8541da95128c784d03f9fe5cd53a227de1f89 (diff)
WiimoteEmu: Fix Drum Extension Velocity
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Core/HW/WiimoteEmu/Extension/Drums.cpp17
-rw-r--r--Source/Core/Core/HW/WiimoteEmu/Extension/Drums.h23
2 files changed, 23 insertions, 17 deletions
diff --git a/Source/Core/Core/HW/WiimoteEmu/Extension/Drums.cpp b/Source/Core/Core/HW/WiimoteEmu/Extension/Drums.cpp
index 24ceda4029..bec40343b9 100644
--- a/Source/Core/Core/HW/WiimoteEmu/Extension/Drums.cpp
+++ b/Source/Core/Core/HW/WiimoteEmu/Extension/Drums.cpp
@@ -101,7 +101,7 @@ void Drums::BuildDesiredExtensionState(DesiredExtensionState* target_state)
state.drum_pads = 0;
m_pads->GetState(&state.drum_pads, drum_pad_bitmasks.data(), m_input_override_function);
- state.softness = u8(7 - std::lround(m_hit_strength_setting.GetValue() * 7 / 100));
+ state.softness = u8(0x7F - std::lround(m_hit_strength_setting.GetValue() * 0x7F / 100));
}
void Drums::Update(const DesiredExtensionState& target_state)
@@ -118,23 +118,21 @@ void Drums::Update(const DesiredExtensionState& target_state)
desired_state.stick_y = STICK_CENTER;
desired_state.buttons = 0;
desired_state.drum_pads = 0;
- desired_state.softness = 7;
+ desired_state.softness = 0x7F;
}
DataFormat drum_data = {};
+ u8 velocity = 0x7F;
// The meaning of these bits are unknown but they are usually set.
drum_data.unk1 = 0b11;
drum_data.unk2 = 0b11;
- drum_data.unk3 = 0b1;
- drum_data.unk4 = 0b1;
drum_data.unk5 = 0b11;
// Send no velocity data by default.
drum_data.velocity_id = u8(VelocityID::None);
drum_data.no_velocity_data_1 = 1;
drum_data.no_velocity_data_2 = 1;
- drum_data.softness = 7;
drum_data.stick_x = desired_state.stick_x;
drum_data.stick_y = desired_state.stick_y;
@@ -164,7 +162,7 @@ void Drums::Update(const DesiredExtensionState& target_state)
drum_data.no_velocity_data_1 = 0;
drum_data.no_velocity_data_2 = 0;
- drum_data.softness = desired_state.softness;
+ velocity = desired_state.softness;
// A drum-pad hit causes the relevent bit to be triggered for the next 10 frames.
constexpr u8 HIT_FRAME_COUNT = 10;
@@ -174,6 +172,11 @@ void Drums::Update(const DesiredExtensionState& target_state)
break;
}
}
+ drum_data.velocity0 = velocity;
+ drum_data.velocity1 = velocity >> 1;
+ drum_data.velocity2 = velocity >> 2;
+ drum_data.velocity3 = velocity >> 3;
+ drum_data.velocity4 = velocity >> 4;
// Figure out which drum-pad bits to send.
// Note: Relevent bits are not set until after velocity data has been sent.
@@ -190,7 +193,7 @@ void Drums::Update(const DesiredExtensionState& target_state)
}
// Flip button and drum-pad bits. (0 == pressed)
- drum_data.buttons ^= 0xff;
+ drum_data.buttons ^= 0x7e;
drum_data.drum_pads ^= 0xff;
// Copy data to proper region in the "register".
diff --git a/Source/Core/Core/HW/WiimoteEmu/Extension/Drums.h b/Source/Core/Core/HW/WiimoteEmu/Extension/Drums.h
index ba65e48877..86d5cb243d 100644
--- a/Source/Core/Core/HW/WiimoteEmu/Extension/Drums.h
+++ b/Source/Core/Core/HW/WiimoteEmu/Extension/Drums.h
@@ -5,6 +5,7 @@
#include <array>
+#include "Common/BitField.h"
#include "Core/HW/WiimoteEmu/Extension/Extension.h"
#include "InputCommon/ControllerEmu/Setting/NumericSetting.h"
@@ -34,7 +35,7 @@ public:
u8 stick_y; // 6 bits
u8 buttons; // 2 bits
u8 drum_pads; // 6 bits
- u8 softness; // 3 bits
+ u8 softness; // 7 bits
};
struct DataFormat
@@ -47,24 +48,28 @@ public:
// Seemingly random.
u8 unk2 : 2;
- // Always 1 with no velocity data and seemingly random otherwise.
- u8 unk3 : 1;
+ u8 velocity3 : 1;
+
// For which "pad" the velocity data is for.
u8 velocity_id : 7;
- // Always 1 with no velocity data and seemingly random otherwise.
- u8 unk4 : 1;
+ u8 velocity2 : 1;
// 1 with no velocity data and 0 when velocity data is present.
u8 no_velocity_data_1 : 1;
// These two bits seem to always be set. (0b11)
u8 unk5 : 2;
// 1 with no velocity data and 0 when velocity data is present.
u8 no_velocity_data_2 : 1;
- // How "soft" a drum pad has been hit as a range from 0:very-hard to 7:very-soft.
- u8 softness : 3;
+
+ u8 velocity4 : 3;
// Button bits.
- u8 buttons;
+ union
+ {
+ u8 buttons; // buttons
+ BitField<0, 1, u8> velocity0;
+ BitField<7, 1, u8> velocity1;
+ };
// Drum-pad bits.
u8 drum_pads;
@@ -94,8 +99,6 @@ public:
void DoState(PointerWrap& p) override;
- // FYI: The low/high bits of the button byte are "random" when velocity data is present.
- // static constexpr u8 HAVE_VELOCITY_DATA = 0b10000001;
static constexpr u8 BUTTON_PLUS = 0x04;
static constexpr u8 BUTTON_MINUS = 0x10;