Fix the N3DS controls

This commit is contained in:
xperia64 2020-05-28 22:40:34 -04:00 committed by bunnei
parent aba2872781
commit e2769c2d9d
4 changed files with 14 additions and 6 deletions

View File

@ -514,6 +514,8 @@ public final class NativeLibrary {
public static final int TRIGGER_L = 773;
public static final int TRIGGER_R = 774;
public static final int DPAD = 780;
public static final int BUTTON_DEBUG = 781;
public static final int BUTTON_GPIO14 = 782;
}
/**

View File

@ -61,14 +61,15 @@ public:
bool ChangeButtonStatus(int button_id, bool pressed) {
std::lock_guard<std::mutex> guard(mutex);
bool button_found = false;
for (const KeyButtonPair& pair : list) {
if (pair.button_id == button_id) {
pair.key_button->status.store(pressed);
return true;
button_found = true;
}
}
// If we don't find the button don't consume the button press event
return false;
return button_found;
}
void ChangeAllButtonStatus(bool pressed) {
@ -132,14 +133,15 @@ public:
bool ChangeAxisValue(int axis_id, float axis) {
std::lock_guard<std::mutex> guard(mutex);
bool button_found = false;
for (const AnalogButtonPair& pair : list) {
if (pair.axis_id == axis_id) {
pair.key_button->axis_val.store(axis);
return true;
button_found = true;
}
}
// If we don't find the button don't consume the button press event
return false;
return button_found;
}
private:
@ -190,14 +192,15 @@ public:
bool ChangeJoystickStatus(int analog_id, float x, float y) {
std::lock_guard<std::mutex> guard(mutex);
bool button_found = false;
for (const AnalogPair& pair : list) {
if (pair.analog_id == analog_id) {
pair.key_button->x_axis.store(x);
pair.key_button->y_axis.store(y);
return true;
button_found = true;
}
}
return false;
return button_found;
}
private:

View File

@ -38,6 +38,8 @@ enum ButtonType {
N3DS_STICK_C_RIGHT = 772,
N3DS_TRIGGER_L = 773,
N3DS_TRIGGER_R = 774,
N3DS_BUTTON_DEBUG = 781,
N3DS_BUTTON_GPIO14 = 782
};
class ButtonList;

View File

@ -55,6 +55,7 @@ static const std::array<int, Settings::NativeButton::NumButtons> default_buttons
InputManager::N3DS_BUTTON_Y, InputManager::N3DS_DPAD_UP, InputManager::N3DS_DPAD_DOWN,
InputManager::N3DS_DPAD_LEFT, InputManager::N3DS_DPAD_RIGHT, InputManager::N3DS_TRIGGER_L,
InputManager::N3DS_TRIGGER_R, InputManager::N3DS_BUTTON_START, InputManager::N3DS_BUTTON_SELECT,
InputManager::N3DS_BUTTON_DEBUG, InputManager::N3DS_BUTTON_GPIO14,
InputManager::N3DS_BUTTON_ZL, InputManager::N3DS_BUTTON_ZR, InputManager::N3DS_BUTTON_HOME,
};