mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2026-10-04 13:24:19 +00:00
[common] rework BitField and BitUtil, use concepts whenever possible (#4076)
test no regressions especially on Liiinux Signed-off-by: lizzie <lizzie@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4076 Reviewed-by: CamilleLaVey <camillelavey99@gmail.com> Reviewed-by: MaranBr <maranbr@eden-emu.dev>
This commit is contained in:
@@ -1662,17 +1662,17 @@ bool EmulatedController::IsControllerFullkey(bool use_temporary_value) const {
|
||||
bool EmulatedController::IsControllerSupported(bool use_temporary_value) const {
|
||||
const auto type = is_configuring.load() && use_temporary_value ? tmp_npad_type.load() : npad_type.load();
|
||||
switch (type) {
|
||||
case NpadStyleIndex::Fullkey: return supported_style_tag.fullkey.As<bool>();
|
||||
case NpadStyleIndex::Handheld: return supported_style_tag.handheld.As<bool>();
|
||||
case NpadStyleIndex::JoyconDual: return supported_style_tag.joycon_dual.As<bool>();
|
||||
case NpadStyleIndex::JoyconLeft: return supported_style_tag.joycon_left.As<bool>();
|
||||
case NpadStyleIndex::JoyconRight: return supported_style_tag.joycon_right.As<bool>();
|
||||
case NpadStyleIndex::GameCube: return supported_style_tag.gamecube.As<bool>();
|
||||
case NpadStyleIndex::Pokeball: return supported_style_tag.palma.As<bool>();
|
||||
case NpadStyleIndex::NES: return supported_style_tag.lark.As<bool>();
|
||||
case NpadStyleIndex::SNES: return supported_style_tag.lucia.As<bool>();
|
||||
case NpadStyleIndex::N64: return supported_style_tag.lagoon.As<bool>();
|
||||
case NpadStyleIndex::SegaGenesis: return supported_style_tag.lager.As<bool>();
|
||||
case NpadStyleIndex::Fullkey: return supported_style_tag.fullkey;
|
||||
case NpadStyleIndex::Handheld: return supported_style_tag.handheld;
|
||||
case NpadStyleIndex::JoyconDual: return supported_style_tag.joycon_dual;
|
||||
case NpadStyleIndex::JoyconLeft: return supported_style_tag.joycon_left;
|
||||
case NpadStyleIndex::JoyconRight: return supported_style_tag.joycon_right;
|
||||
case NpadStyleIndex::GameCube: return supported_style_tag.gamecube;
|
||||
case NpadStyleIndex::Pokeball: return supported_style_tag.palma;
|
||||
case NpadStyleIndex::NES: return supported_style_tag.lark;
|
||||
case NpadStyleIndex::SNES: return supported_style_tag.lucia;
|
||||
case NpadStyleIndex::N64: return supported_style_tag.lagoon;
|
||||
case NpadStyleIndex::SegaGenesis: return supported_style_tag.lager;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -284,9 +284,9 @@ u8 RingController::GetCrcValue(const std::vector<u8>& data) const {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
requires std::is_trivially_copyable_v<T>
|
||||
u64 RingController::GetData(const T& reply, std::span<u8> out_data) const {
|
||||
static_assert(std::is_trivially_copyable_v<T>);
|
||||
const auto data_size = static_cast<u64>((std::min)(sizeof(reply), out_data.size()));
|
||||
const auto data_size = u64((std::min)(sizeof(reply), out_data.size()));
|
||||
std::memcpy(out_data.data(), &reply, data_size);
|
||||
return data_size;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
@@ -221,6 +224,7 @@ private:
|
||||
|
||||
// Converts structs to an u8 vector equivalent
|
||||
template <typename T>
|
||||
requires std::is_trivially_copyable_v<T>
|
||||
u64 GetData(const T& reply, std::span<u8> out_data) const;
|
||||
|
||||
RingConCommands command{RingConCommands::Error};
|
||||
|
||||
@@ -66,8 +66,7 @@ Result NpadAbstractSixAxisHandler::UpdateSixAxisState() {
|
||||
continue;
|
||||
}
|
||||
auto& npad_entry = data->shared_memory_format->npad.npad_entry[NpadIdTypeToIndex(npad_id)];
|
||||
UpdateSixaxisInternalState(npad_entry, data->aruid,
|
||||
data->flag.enable_six_axis_sensor.As<bool>());
|
||||
UpdateSixaxisInternalState(npad_entry, data->aruid, data->flag.enable_six_axis_sensor);
|
||||
}
|
||||
return ResultSuccess;
|
||||
}
|
||||
@@ -79,8 +78,7 @@ Result NpadAbstractSixAxisHandler::UpdateSixAxisState(u64 aruid) {
|
||||
return ResultSuccess;
|
||||
}
|
||||
auto& npad_entry = data->shared_memory_format->npad.npad_entry[NpadIdTypeToIndex(npad_id)];
|
||||
UpdateSixaxisInternalState(npad_entry, data->aruid,
|
||||
data->flag.enable_six_axis_sensor.As<bool>());
|
||||
UpdateSixaxisInternalState(npad_entry, data->aruid, data->flag.enable_six_axis_sensor);
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
@@ -91,8 +89,7 @@ Result NpadAbstractSixAxisHandler::UpdateSixAxisState2(u64 aruid) {
|
||||
return ResultSuccess;
|
||||
}
|
||||
auto& npad_internal_state = aruid_data->shared_memory_format->npad.npad_entry[npad_index];
|
||||
UpdateSixaxisInternalState(npad_internal_state, aruid,
|
||||
aruid_data->flag.enable_six_axis_sensor.As<bool>());
|
||||
UpdateSixaxisInternalState(npad_internal_state, aruid, aruid_data->flag.enable_six_axis_sensor);
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
||||
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
||||
@@ -24,7 +24,7 @@ void NPadData::SetNpadAnalogStickUseCenterClamp(bool is_enabled) {
|
||||
}
|
||||
|
||||
bool NPadData::GetNpadAnalogStickUseCenterClamp() const {
|
||||
return status.use_center_clamp.As<bool>();
|
||||
return status.use_center_clamp;
|
||||
}
|
||||
|
||||
void NPadData::SetNpadSystemExtStateEnabled(bool is_enabled) {
|
||||
@@ -32,7 +32,7 @@ void NPadData::SetNpadSystemExtStateEnabled(bool is_enabled) {
|
||||
}
|
||||
|
||||
bool NPadData::GetNpadSystemExtState() const {
|
||||
return status.system_ext_state.As<bool>();
|
||||
return status.system_ext_state;
|
||||
}
|
||||
|
||||
Result NPadData::SetSupportedNpadIdType(std::span<const Core::HID::NpadIdType> list) {
|
||||
@@ -154,27 +154,27 @@ bool NPadData::IsNpadStyleIndexSupported(Core::HID::NpadStyleIndex style_index)
|
||||
Core::HID::NpadStyleTag style = {supported_npad_style_set};
|
||||
switch (style_index) {
|
||||
case Core::HID::NpadStyleIndex::Fullkey:
|
||||
return style.fullkey.As<bool>();
|
||||
return style.fullkey;
|
||||
case Core::HID::NpadStyleIndex::Handheld:
|
||||
return style.handheld.As<bool>();
|
||||
return style.handheld;
|
||||
case Core::HID::NpadStyleIndex::JoyconDual:
|
||||
return style.joycon_dual.As<bool>();
|
||||
return style.joycon_dual;
|
||||
case Core::HID::NpadStyleIndex::JoyconLeft:
|
||||
return style.joycon_left.As<bool>();
|
||||
return style.joycon_left;
|
||||
case Core::HID::NpadStyleIndex::JoyconRight:
|
||||
return style.joycon_right.As<bool>();
|
||||
return style.joycon_right;
|
||||
case Core::HID::NpadStyleIndex::GameCube:
|
||||
return style.gamecube.As<bool>();
|
||||
return style.gamecube;
|
||||
case Core::HID::NpadStyleIndex::Pokeball:
|
||||
return style.palma.As<bool>();
|
||||
return style.palma;
|
||||
case Core::HID::NpadStyleIndex::NES:
|
||||
return style.lark.As<bool>();
|
||||
return style.lark;
|
||||
case Core::HID::NpadStyleIndex::SNES:
|
||||
return style.lucia.As<bool>();
|
||||
return style.lucia;
|
||||
case Core::HID::NpadStyleIndex::N64:
|
||||
return style.lagoon.As<bool>();
|
||||
return style.lagoon;
|
||||
case Core::HID::NpadStyleIndex::SegaGenesis:
|
||||
return style.lager.As<bool>();
|
||||
return style.lager;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@@ -185,7 +185,7 @@ void NPadData::SetLrAssignmentMode(bool is_enabled) {
|
||||
}
|
||||
|
||||
bool NPadData::GetLrAssignmentMode() const {
|
||||
return status.lr_assignment_mode.As<bool>();
|
||||
return status.lr_assignment_mode;
|
||||
}
|
||||
|
||||
void NPadData::SetAssigningSingleOnSlSrPress(bool is_enabled) {
|
||||
@@ -193,7 +193,7 @@ void NPadData::SetAssigningSingleOnSlSrPress(bool is_enabled) {
|
||||
}
|
||||
|
||||
bool NPadData::GetAssigningSingleOnSlSrPress() const {
|
||||
return status.assigning_single_on_sl_sr_press.As<bool>();
|
||||
return status.assigning_single_on_sl_sr_press;
|
||||
}
|
||||
|
||||
void NPadData::SetHomeProtectionEnabled(bool is_enabled, Core::HID::NpadIdType npad_id) {
|
||||
|
||||
@@ -548,8 +548,7 @@ void TouchResource::OnTouchUpdate(s64 timestamp) {
|
||||
}
|
||||
|
||||
auto& touch_shared = applet_data->shared_memory_format->touch_screen;
|
||||
StorePreviousTouchState(previous_touch_state, data.finger_map, current_touch_state,
|
||||
applet_data->flag.enable_touchscreen.As<bool>());
|
||||
StorePreviousTouchState(previous_touch_state, data.finger_map, current_touch_state, applet_data->flag.enable_touchscreen);
|
||||
touch_shared.touch_screen_lifo.WriteNextEntry(current_touch_state);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user