mirror of
https://github.com/citra-emu/citra.git
synced 2024-11-25 21:40:14 +00:00
Add constant for input detect threshold. Possible fix for issue on linux with binding triggers. Change unique_mapping to std::set
This commit is contained in:
parent
233985129e
commit
bd94a96d3c
@ -52,7 +52,7 @@ void Keyboard::Clear() {
|
||||
Settings::InputDeviceMapping Keyboard::GetInput() {
|
||||
auto result = ProcessInput();
|
||||
for (const auto& entry : result) {
|
||||
if (entry.second > 0.5)
|
||||
if (entry.second > 0.0)
|
||||
return entry.first;
|
||||
}
|
||||
return Settings::InputDeviceMapping("");
|
||||
|
@ -60,7 +60,7 @@ std::map<Settings::InputDeviceMapping, float> SDLGamepad::ProcessInput() {
|
||||
fmaxf(-1, static_cast<float>(SDL_GameControllerGetAxis(gamepad, axis) / 32767.0));
|
||||
input_device_mapping.key = static_cast<int>(
|
||||
gamepadinput_to_sdlname_mapping[SDL_GameControllerGetStringForAxis(axis)]);
|
||||
if (strength < 0) {
|
||||
if (strength < 0 && i < 4) {
|
||||
button_status.emplace(input_device_mapping, 0);
|
||||
input_device_mapping.key += 1; // minus axis value is always one greater
|
||||
button_status.emplace(input_device_mapping, abs(strength));
|
||||
@ -114,9 +114,9 @@ Settings::InputDeviceMapping SDLGamepad::GetInput() {
|
||||
return Settings::InputDeviceMapping("");
|
||||
|
||||
auto results = ProcessInput();
|
||||
for (const auto& input : results) {
|
||||
if (input.second > 0.5)
|
||||
return input.first;
|
||||
for (const auto& entry : results) {
|
||||
if (entry.second > input_detect_threshold)
|
||||
return entry.first;
|
||||
}
|
||||
return Settings::InputDeviceMapping("");
|
||||
}
|
||||
|
@ -82,6 +82,7 @@ private:
|
||||
keys_pressed; ///< Map of keys that were pressed on previous iteration
|
||||
_SDL_GameController* gamepad = nullptr;
|
||||
int number; ///< Index of gamepad connection
|
||||
float input_detect_threshold = 0.8;
|
||||
|
||||
static void LoadGameControllerDB();
|
||||
};
|
||||
|
@ -149,24 +149,23 @@ void InputCore::SetTouchState(std::tuple<u16, u16, bool> value) {
|
||||
std::tie(touch_x, touch_y, touch_pressed) = value;
|
||||
}
|
||||
|
||||
bool InputCore::CheckIfMappingExists(
|
||||
const std::vector<Settings::InputDeviceMapping>& unique_mapping,
|
||||
Settings::InputDeviceMapping mapping_to_check) {
|
||||
bool InputCore::CheckIfMappingExists(const std::set<Settings::InputDeviceMapping>& unique_mapping,
|
||||
Settings::InputDeviceMapping mapping_to_check) {
|
||||
return std::any_of(
|
||||
unique_mapping.begin(), unique_mapping.end(),
|
||||
[mapping_to_check](const auto& mapping) { return mapping == mapping_to_check; });
|
||||
}
|
||||
|
||||
std::vector<Settings::InputDeviceMapping> InputCore::GatherUniqueMappings() {
|
||||
std::vector<Settings::InputDeviceMapping> unique_mappings;
|
||||
std::set<Settings::InputDeviceMapping> InputCore::GatherUniqueMappings() {
|
||||
std::set<Settings::InputDeviceMapping> unique_mappings;
|
||||
|
||||
for (const auto& mapping : Settings::values.input_mappings) {
|
||||
if (!CheckIfMappingExists(unique_mappings, mapping)) {
|
||||
unique_mappings.push_back(mapping);
|
||||
unique_mappings.insert(mapping);
|
||||
}
|
||||
}
|
||||
if (!CheckIfMappingExists(unique_mappings, Settings::values.pad_circle_modifier)) {
|
||||
unique_mappings.push_back(Settings::values.pad_circle_modifier);
|
||||
unique_mappings.insert(Settings::values.pad_circle_modifier);
|
||||
}
|
||||
return unique_mappings;
|
||||
}
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <set>
|
||||
#include <tuple>
|
||||
|
||||
#include "core/hle/service/hid/hid.h"
|
||||
@ -106,10 +107,10 @@ private:
|
||||
/**
|
||||
* Helper methodto check if device was already initialized
|
||||
*/
|
||||
static bool CheckIfMappingExists(const std::vector<Settings::InputDeviceMapping>& uniqueMapping,
|
||||
static bool CheckIfMappingExists(const std::set<Settings::InputDeviceMapping>& uniqueMapping,
|
||||
Settings::InputDeviceMapping mappingToCheck);
|
||||
|
||||
static std::vector<Settings::InputDeviceMapping>
|
||||
static std::set<Settings::InputDeviceMapping>
|
||||
GatherUniqueMappings(); /// Get unique input mappings from settings
|
||||
|
||||
static void BuildKeyMapping(); /// Builds map of input keys to 3ds buttons for unique device
|
||||
|
Loading…
Reference in New Issue
Block a user