mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-09 07:39:26 +01:00
WiimoteEmu: Fix Drum Extension Velocity
This commit is contained in:
parent
1ba8541da9
commit
91abcd32dc
@ -101,7 +101,7 @@ void Drums::BuildDesiredExtensionState(DesiredExtensionState* target_state)
|
|||||||
state.drum_pads = 0;
|
state.drum_pads = 0;
|
||||||
m_pads->GetState(&state.drum_pads, drum_pad_bitmasks.data(), m_input_override_function);
|
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)
|
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.stick_y = STICK_CENTER;
|
||||||
desired_state.buttons = 0;
|
desired_state.buttons = 0;
|
||||||
desired_state.drum_pads = 0;
|
desired_state.drum_pads = 0;
|
||||||
desired_state.softness = 7;
|
desired_state.softness = 0x7F;
|
||||||
}
|
}
|
||||||
|
|
||||||
DataFormat drum_data = {};
|
DataFormat drum_data = {};
|
||||||
|
u8 velocity = 0x7F;
|
||||||
|
|
||||||
// The meaning of these bits are unknown but they are usually set.
|
// The meaning of these bits are unknown but they are usually set.
|
||||||
drum_data.unk1 = 0b11;
|
drum_data.unk1 = 0b11;
|
||||||
drum_data.unk2 = 0b11;
|
drum_data.unk2 = 0b11;
|
||||||
drum_data.unk3 = 0b1;
|
|
||||||
drum_data.unk4 = 0b1;
|
|
||||||
drum_data.unk5 = 0b11;
|
drum_data.unk5 = 0b11;
|
||||||
|
|
||||||
// Send no velocity data by default.
|
// Send no velocity data by default.
|
||||||
drum_data.velocity_id = u8(VelocityID::None);
|
drum_data.velocity_id = u8(VelocityID::None);
|
||||||
drum_data.no_velocity_data_1 = 1;
|
drum_data.no_velocity_data_1 = 1;
|
||||||
drum_data.no_velocity_data_2 = 1;
|
drum_data.no_velocity_data_2 = 1;
|
||||||
drum_data.softness = 7;
|
|
||||||
|
|
||||||
drum_data.stick_x = desired_state.stick_x;
|
drum_data.stick_x = desired_state.stick_x;
|
||||||
drum_data.stick_y = desired_state.stick_y;
|
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_1 = 0;
|
||||||
drum_data.no_velocity_data_2 = 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.
|
// A drum-pad hit causes the relevent bit to be triggered for the next 10 frames.
|
||||||
constexpr u8 HIT_FRAME_COUNT = 10;
|
constexpr u8 HIT_FRAME_COUNT = 10;
|
||||||
@ -174,6 +172,11 @@ void Drums::Update(const DesiredExtensionState& target_state)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
drum_data.velocity0 = velocity;
|
||||||
|
drum_data.velocity1 = velocity >> 1;
|
||||||
|
drum_data.velocity2 = velocity >> 2;
|
||||||
|
drum_data.velocity3 = velocity >> 3;
|
||||||
|
drum_data.velocity64 = velocity >> 4;
|
||||||
|
|
||||||
// Figure out which drum-pad bits to send.
|
// Figure out which drum-pad bits to send.
|
||||||
// Note: Relevent bits are not set until after velocity data has been sent.
|
// 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)
|
// Flip button and drum-pad bits. (0 == pressed)
|
||||||
drum_data.buttons ^= 0xff;
|
drum_data.buttons ^= 0x7e;
|
||||||
drum_data.drum_pads ^= 0xff;
|
drum_data.drum_pads ^= 0xff;
|
||||||
|
|
||||||
// Copy data to proper region in the "register".
|
// Copy data to proper region in the "register".
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
|
#include "Common/BitField.h"
|
||||||
#include "Core/HW/WiimoteEmu/Extension/Extension.h"
|
#include "Core/HW/WiimoteEmu/Extension/Extension.h"
|
||||||
#include "InputCommon/ControllerEmu/Setting/NumericSetting.h"
|
#include "InputCommon/ControllerEmu/Setting/NumericSetting.h"
|
||||||
|
|
||||||
@ -47,24 +48,28 @@ public:
|
|||||||
// Seemingly random.
|
// Seemingly random.
|
||||||
u8 unk2 : 2;
|
u8 unk2 : 2;
|
||||||
|
|
||||||
// Always 1 with no velocity data and seemingly random otherwise.
|
u8 velocity3 : 1;
|
||||||
u8 unk3 : 1;
|
|
||||||
// For which "pad" the velocity data is for.
|
// For which "pad" the velocity data is for.
|
||||||
u8 velocity_id : 7;
|
u8 velocity_id : 7;
|
||||||
|
|
||||||
// Always 1 with no velocity data and seemingly random otherwise.
|
u8 velocity2 : 1;
|
||||||
u8 unk4 : 1;
|
|
||||||
// 1 with no velocity data and 0 when velocity data is present.
|
// 1 with no velocity data and 0 when velocity data is present.
|
||||||
u8 no_velocity_data_1 : 1;
|
u8 no_velocity_data_1 : 1;
|
||||||
// These two bits seem to always be set. (0b11)
|
// These two bits seem to always be set. (0b11)
|
||||||
u8 unk5 : 2;
|
u8 unk5 : 2;
|
||||||
// 1 with no velocity data and 0 when velocity data is present.
|
// 1 with no velocity data and 0 when velocity data is present.
|
||||||
u8 no_velocity_data_2 : 1;
|
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 velocity64 : 3;
|
||||||
|
|
||||||
// Button bits.
|
// Button bits.
|
||||||
u8 buttons;
|
union
|
||||||
|
{
|
||||||
|
u8 buttons; // buttons
|
||||||
|
BitField<0, 1, u8> velocity0;
|
||||||
|
BitField<7, 1, u8> velocity1;
|
||||||
|
};
|
||||||
|
|
||||||
// Drum-pad bits.
|
// Drum-pad bits.
|
||||||
u8 drum_pads;
|
u8 drum_pads;
|
||||||
@ -94,8 +99,6 @@ public:
|
|||||||
|
|
||||||
void DoState(PointerWrap& p) override;
|
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_PLUS = 0x04;
|
||||||
static constexpr u8 BUTTON_MINUS = 0x10;
|
static constexpr u8 BUTTON_MINUS = 0x10;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user