mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2026-09-12 06:39:26 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ac307cd13f |
@@ -69,8 +69,8 @@ u32 A32JitState::Cpsr() const {
|
||||
cpsr |= mcl::bit::get_bit<1>(upper_location_descriptor) ? 1 << 9 : 0;
|
||||
cpsr |= mcl::bit::get_bit<0>(upper_location_descriptor) ? 1 << 5 : 0;
|
||||
// IT state
|
||||
cpsr |= static_cast<u32>(upper_location_descriptor & 0b11111100'00000000);
|
||||
cpsr |= static_cast<u32>(upper_location_descriptor & 0b00000011'00000000) << 17;
|
||||
cpsr |= u32(upper_location_descriptor & 0b11111100'00000000);
|
||||
cpsr |= u32(upper_location_descriptor & 0b00000011'00000000) << 17;
|
||||
// Other flags
|
||||
cpsr |= cpsr_jaifm;
|
||||
|
||||
@@ -169,39 +169,36 @@ constexpr u32 FPSCR_NZCV_MASK = 0xF0000000;
|
||||
u32 A32JitState::Fpscr() const {
|
||||
DEBUG_ASSERT((fpsr_nzcv & ~FPSCR_NZCV_MASK) == 0);
|
||||
|
||||
const u32 fpcr_mode = static_cast<u32>(upper_location_descriptor) & FPSCR_MODE_MASK;
|
||||
const u32 fpcr_mode = u32(upper_location_descriptor) & FPSCR_MODE_MASK;
|
||||
const u32 mxcsr = guest_MXCSR | asimd_MXCSR;
|
||||
|
||||
u32 FPSCR = fpcr_mode | fpsr_nzcv;
|
||||
FPSCR |= (mxcsr & 0b0000000000001); // IOC = IE
|
||||
FPSCR |= (mxcsr & 0b0000000111100) >> 1; // IXC, UFC, OFC, DZC = PE, UE, OE, ZE
|
||||
FPSCR |= fpsr_exc;
|
||||
FPSCR |= fpsr_qc != 0 ? 1 << 27 : 0;
|
||||
|
||||
return FPSCR;
|
||||
u32 fpscr = fpcr_mode | fpsr_nzcv;
|
||||
fpscr |= (mxcsr & 0b0000000000001); // IOC = IE
|
||||
fpscr |= (mxcsr & 0b0000000111100) >> 1; // IXC, UFC, OFC, DZC = PE, UE, OE, ZE
|
||||
fpscr |= fpsr_exc;
|
||||
fpscr |= fpsr_qc != 0 ? 1 << 27 : 0;
|
||||
return fpscr;
|
||||
}
|
||||
|
||||
void A32JitState::SetFpscr(u32 FPSCR) {
|
||||
void A32JitState::SetFpscr(u32 value) {
|
||||
// Ensure that only upper half of upper_location_descriptor is used for FPSCR bits.
|
||||
static_assert((FPSCR_MODE_MASK & 0xFFFF0000) == FPSCR_MODE_MASK);
|
||||
|
||||
upper_location_descriptor &= 0x0000FFFF;
|
||||
upper_location_descriptor |= FPSCR & FPSCR_MODE_MASK;
|
||||
upper_location_descriptor |= value & FPSCR_MODE_MASK;
|
||||
|
||||
fpsr_nzcv = FPSCR & FPSCR_NZCV_MASK;
|
||||
fpsr_qc = (FPSCR >> 27) & 1;
|
||||
fpsr_nzcv = value & FPSCR_NZCV_MASK;
|
||||
fpsr_qc = (value >> 27) & 1;
|
||||
|
||||
guest_MXCSR = 0x00001f80;
|
||||
asimd_MXCSR = 0x00009fc0;
|
||||
|
||||
// RMode
|
||||
const std::array<u32, 4> MXCSR_RMode{0x0, 0x4000, 0x2000, 0x6000};
|
||||
guest_MXCSR |= MXCSR_RMode[(FPSCR >> 22) & 0x3];
|
||||
guest_MXCSR |= ((0x6000200040000000 >> (((value >> 18) & (0x3 << 4)))) & 0xf000);
|
||||
|
||||
// Cumulative flags IDC, IOC, IXC, UFC, OFC, DZC
|
||||
fpsr_exc = FPSCR & 0x9F;
|
||||
fpsr_exc = value & 0x9F;
|
||||
|
||||
if (mcl::bit::get_bit<24>(FPSCR)) {
|
||||
if (mcl::bit::get_bit<24>(value)) {
|
||||
// VFP Flush to Zero
|
||||
guest_MXCSR |= (1 << 15); // SSE Flush to Zero
|
||||
guest_MXCSR |= (1 << 6); // SSE Denormals are Zero
|
||||
|
||||
@@ -59,16 +59,16 @@ u32 A64JitState::GetFpcr() const {
|
||||
|
||||
void A64JitState::SetFpcr(u32 value) {
|
||||
fpcr = value & FPCR_MASK;
|
||||
|
||||
asimd_MXCSR &= 0x0000003D;
|
||||
guest_MXCSR &= 0x0000003D;
|
||||
asimd_MXCSR |= 0x00001f80;
|
||||
guest_MXCSR |= 0x00001f80; // Mask all exceptions
|
||||
|
||||
// RMode
|
||||
const std::array<u32, 4> MXCSR_RMode{0x0, 0x4000, 0x2000, 0x6000};
|
||||
guest_MXCSR |= MXCSR_RMode[(value >> 22) & 0x3];
|
||||
|
||||
// 0 -> 0x0000
|
||||
// 1 -> 0x4000
|
||||
// 2 -> 0x2000
|
||||
// 3 -> 0x6000
|
||||
guest_MXCSR |= ((0x6000200040000000 >> (((value >> 18) & (0x3 << 4)))) & 0xf000);
|
||||
if (mcl::bit::get_bit<24>(value)) {
|
||||
guest_MXCSR |= (1 << 15); // SSE Flush to Zero
|
||||
guest_MXCSR |= (1 << 6); // SSE Denormals are Zero
|
||||
|
||||
@@ -697,6 +697,16 @@ SDLDriver::SDLDriver(std::string input_engine_) : InputEngine(std::move(input_en
|
||||
SDL_AddEventWatch(&SDLEventWatcher, this);
|
||||
|
||||
initialized = true;
|
||||
if (start_thread) {
|
||||
vibration_thread = std::thread([this] {
|
||||
Common::SetCurrentThreadName("SDL_Vibration");
|
||||
using namespace std::chrono_literals;
|
||||
while (initialized) {
|
||||
SendVibrations();
|
||||
std::this_thread::sleep_for(250ms); // 4 TPS
|
||||
}
|
||||
});
|
||||
}
|
||||
// Because the events for joystick connection happens before we have our event watcher added, we
|
||||
// can just open all the joysticks right here
|
||||
int joystick_count = 0;
|
||||
@@ -715,6 +725,7 @@ SDLDriver::~SDLDriver() {
|
||||
|
||||
initialized = false;
|
||||
if (start_thread) {
|
||||
vibration_thread.join();
|
||||
SDL_QuitSubSystem(SDL_INIT_JOYSTICK | SDL_INIT_GAMEPAD);
|
||||
}
|
||||
}
|
||||
@@ -794,7 +805,10 @@ Common::Input::DriverResult SDLDriver::SetVibration(
|
||||
.type = Common::Input::VibrationAmplificationType::Exponential,
|
||||
};
|
||||
|
||||
joystick->RumblePlay(new_vibration);
|
||||
vibration_queue.Push(VibrationRequest{
|
||||
.identifier = identifier,
|
||||
.vibration = new_vibration,
|
||||
});
|
||||
|
||||
return Common::Input::DriverResult::Success;
|
||||
}
|
||||
@@ -838,6 +852,31 @@ bool SDLDriver::IsVibrationEnabled(const PadIdentifier& identifier) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void SDLDriver::SendVibrations() {
|
||||
std::vector<VibrationRequest> filtered_vibrations{};
|
||||
while (!vibration_queue.Empty()) {
|
||||
VibrationRequest request;
|
||||
vibration_queue.Pop(request);
|
||||
const auto joystick = GetSDLJoystickByGUID(request.identifier.guid.RawString(),
|
||||
static_cast<int>(request.identifier.port));
|
||||
const auto it = std::find_if(filtered_vibrations.begin(), filtered_vibrations.end(),
|
||||
[request](VibrationRequest vibration) {
|
||||
return vibration.identifier == request.identifier;
|
||||
});
|
||||
if (it == filtered_vibrations.end()) {
|
||||
filtered_vibrations.push_back(std::move(request));
|
||||
continue;
|
||||
}
|
||||
*it = request;
|
||||
}
|
||||
|
||||
for (const auto& vibration : filtered_vibrations) {
|
||||
const auto joystick = GetSDLJoystickByGUID(vibration.identifier.guid.RawString(),
|
||||
static_cast<int>(vibration.identifier.port));
|
||||
joystick->RumblePlay(vibration.vibration);
|
||||
}
|
||||
}
|
||||
|
||||
Common::ParamPackage SDLDriver::BuildAnalogParamPackageForButton(int port, const Common::UUID& guid,
|
||||
s32 axis, float value) const {
|
||||
Common::ParamPackage params{};
|
||||
|
||||
@@ -113,11 +113,16 @@ private:
|
||||
/// Returns true if the button is on the left joycon
|
||||
bool IsButtonOnLeftSide(Settings::NativeButton::Values button) const;
|
||||
|
||||
/// Queue of vibration request to controllers
|
||||
Common::SPSCQueue<VibrationRequest> vibration_queue;
|
||||
|
||||
/// Map of GUID of a list of corresponding virtual Joysticks
|
||||
::Common::unordered_map<Common::UUID, std::vector<std::shared_ptr<SDLJoystick>>> joystick_map;
|
||||
std::mutex joystick_map_mutex;
|
||||
|
||||
bool start_thread = false;
|
||||
std::atomic<bool> initialized = false;
|
||||
bool start_thread;
|
||||
|
||||
std::thread vibration_thread;
|
||||
};
|
||||
} // namespace InputCommon
|
||||
|
||||
Reference in New Issue
Block a user