mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2025-06-17 00:27:57 -05:00
kraken: Address comments from review
start lion review
This commit is contained in:
@ -248,7 +248,7 @@ bool GCAdapter::Setup() {
|
||||
std::size_t port = 0;
|
||||
for (GCController& pad : pads) {
|
||||
pad.identifier = {
|
||||
.guid = Common::UUID{""},
|
||||
.guid = Common::UUID{Common::INVALID_UUID},
|
||||
.port = port++,
|
||||
.pad = 0,
|
||||
};
|
||||
@ -325,8 +325,8 @@ bool GCAdapter::GetGCEndpoint(libusb_device* device) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Input::VibrationError GCAdapter::SetRumble(const PadIdentifier& identifier,
|
||||
const Input::VibrationStatus vibration) {
|
||||
Common::Input::VibrationError GCAdapter::SetRumble(const PadIdentifier& identifier,
|
||||
const Common::Input::VibrationStatus vibration) {
|
||||
const auto mean_amplitude = (vibration.low_amplitude + vibration.high_amplitude) * 0.5f;
|
||||
const auto processed_amplitude =
|
||||
static_cast<u8>((mean_amplitude + std::pow(mean_amplitude, 0.3f)) * 0.5f * 0x8);
|
||||
@ -334,9 +334,9 @@ Input::VibrationError GCAdapter::SetRumble(const PadIdentifier& identifier,
|
||||
pads[identifier.port].rumble_amplitude = processed_amplitude;
|
||||
|
||||
if (!rumble_enabled) {
|
||||
return Input::VibrationError::Disabled;
|
||||
return Common::Input::VibrationError::Disabled;
|
||||
}
|
||||
return Input::VibrationError::None;
|
||||
return Common::Input::VibrationError::None;
|
||||
}
|
||||
|
||||
void GCAdapter::UpdateVibrations() {
|
||||
|
@ -4,8 +4,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <stop_token>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
|
||||
#include "input_common/input_engine.h"
|
||||
@ -24,8 +27,8 @@ public:
|
||||
explicit GCAdapter(const std::string input_engine_);
|
||||
~GCAdapter();
|
||||
|
||||
Input::VibrationError SetRumble(const PadIdentifier& identifier,
|
||||
const Input::VibrationStatus vibration) override;
|
||||
Common::Input::VibrationError SetRumble(
|
||||
const PadIdentifier& identifier, const Common::Input::VibrationStatus vibration) override;
|
||||
|
||||
/// Used for automapping features
|
||||
std::vector<Common::ParamPackage> GetInputDevices() const override;
|
||||
|
@ -35,7 +35,7 @@ public:
|
||||
|
||||
private:
|
||||
const PadIdentifier identifier = {
|
||||
.guid = Common::UUID{""},
|
||||
.guid = Common::UUID{Common::INVALID_UUID},
|
||||
.port = 0,
|
||||
.pad = 0,
|
||||
};
|
||||
|
@ -63,7 +63,7 @@ private:
|
||||
void StopPanning();
|
||||
|
||||
const PadIdentifier identifier = {
|
||||
.guid = Common::UUID{""},
|
||||
.guid = Common::UUID{Common::INVALID_UUID},
|
||||
.port = 0,
|
||||
.pad = 0,
|
||||
};
|
||||
|
@ -92,7 +92,7 @@ public:
|
||||
return motion;
|
||||
}
|
||||
|
||||
bool RumblePlay(const Input::VibrationStatus vibration) {
|
||||
bool RumblePlay(const Common::Input::VibrationStatus vibration) {
|
||||
constexpr u32 rumble_max_duration_ms = 1000;
|
||||
if (sdl_controller) {
|
||||
return SDL_GameControllerRumble(
|
||||
@ -515,8 +515,8 @@ std::vector<Common::ParamPackage> SDLDriver::GetInputDevices() const {
|
||||
}
|
||||
return devices;
|
||||
}
|
||||
Input::VibrationError SDLDriver::SetRumble(const PadIdentifier& identifier,
|
||||
const Input::VibrationStatus vibration) {
|
||||
Common::Input::VibrationError SDLDriver::SetRumble(const PadIdentifier& identifier,
|
||||
const Common::Input::VibrationStatus vibration) {
|
||||
const auto joystick =
|
||||
GetSDLJoystickByGUID(identifier.guid.Format(), static_cast<int>(identifier.port));
|
||||
const auto process_amplitude_exp = [](f32 amplitude, f32 factor) {
|
||||
@ -527,7 +527,7 @@ Input::VibrationError SDLDriver::SetRumble(const PadIdentifier& identifier,
|
||||
f32 factor = 0.35f;
|
||||
|
||||
// If vibration is set as a linear output use a flatter value
|
||||
if (vibration.type == Input::VibrationAmplificationType::Linear) {
|
||||
if (vibration.type == Common::Input::VibrationAmplificationType::Linear) {
|
||||
factor = 0.5f;
|
||||
}
|
||||
|
||||
@ -536,19 +536,19 @@ Input::VibrationError SDLDriver::SetRumble(const PadIdentifier& identifier,
|
||||
factor = 1.0f;
|
||||
}
|
||||
|
||||
const Input::VibrationStatus new_vibration{
|
||||
const Common::Input::VibrationStatus new_vibration{
|
||||
.low_amplitude = process_amplitude_exp(vibration.low_amplitude, factor),
|
||||
.low_frequency = vibration.low_frequency,
|
||||
.high_amplitude = process_amplitude_exp(vibration.high_amplitude, factor),
|
||||
.high_frequency = vibration.high_frequency,
|
||||
.type = Input::VibrationAmplificationType::Exponential,
|
||||
.type = Common::Input::VibrationAmplificationType::Exponential,
|
||||
};
|
||||
|
||||
if (!joystick->RumblePlay(new_vibration)) {
|
||||
return Input::VibrationError::Unknown;
|
||||
return Common::Input::VibrationError::Unknown;
|
||||
}
|
||||
|
||||
return Input::VibrationError::None;
|
||||
return Common::Input::VibrationError::None;
|
||||
}
|
||||
Common::ParamPackage SDLDriver::BuildAnalogParamPackageForButton(int port, std::string guid,
|
||||
s32 axis, float value) const {
|
||||
|
@ -58,8 +58,8 @@ public:
|
||||
std::string GetHatButtonName(u8 direction_value) const override;
|
||||
u8 GetHatButtonId(const std::string direction_name) const override;
|
||||
|
||||
Input::VibrationError SetRumble(const PadIdentifier& identifier,
|
||||
const Input::VibrationStatus vibration) override;
|
||||
Common::Input::VibrationError SetRumble(
|
||||
const PadIdentifier& identifier, const Common::Input::VibrationStatus vibration) override;
|
||||
|
||||
private:
|
||||
void InitJoystick(int joystick_index);
|
||||
@ -105,9 +105,6 @@ private:
|
||||
/// Returns true if the button is on the left joycon
|
||||
bool IsButtonOnLeftSide(Settings::NativeButton::Values button) const;
|
||||
|
||||
// Set to true if SDL supports game controller subsystem
|
||||
bool has_gamecontroller = false;
|
||||
|
||||
/// Map of GUID of a list of corresponding virtual Joysticks
|
||||
std::unordered_map<std::string, std::vector<std::shared_ptr<SDLJoystick>>> joystick_map;
|
||||
std::mutex joystick_map_mutex;
|
||||
|
@ -41,7 +41,7 @@ public:
|
||||
|
||||
private:
|
||||
const PadIdentifier identifier = {
|
||||
.guid = Common::UUID{""},
|
||||
.guid = Common::UUID{Common::INVALID_UUID},
|
||||
.port = 0,
|
||||
.pad = 0,
|
||||
};
|
||||
|
Reference in New Issue
Block a user