From 7e1afcd37c1f6dbfaa422fa946b884ccb267cf12 Mon Sep 17 00:00:00 2001 From: Rafael Kitover Date: Fri, 20 Oct 2023 17:45:54 +0000 Subject: [PATCH] Fix reading joystick hat config values Use the wxString-returning form of wxRegex.GetMatch() because the bool form always returns true if the initial match succeeded, causing every hat direction in the config to be interpreted as north, the first condition in the if statement. Fix #1192 Signed-off-by: Rafael Kitover --- src/wx/config/user-input.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/wx/config/user-input.cpp b/src/wx/config/user-input.cpp index ad569ea7..33ea5627 100644 --- a/src/wx/config/user-input.cpp +++ b/src/wx/config/user-input.cpp @@ -214,13 +214,13 @@ UserInput StringToUserInput(const wxString& string) { if (kHatRegex.Matches(remainder)) { kHatRegex.GetMatch(&start, &length, 1); const int key = StringToInt(remainder.Mid(start, length)); - if (kHatRegex.GetMatch(&start, &length, 3)) { + if (kHatRegex.GetMatch(remainder, 3).Length()) { return UserInput(key, wxJoyControl::HatNorth, joy); - } else if (kHatRegex.GetMatch(&start, &length, 4)) { + } else if (kHatRegex.GetMatch(remainder, 4).Length()) { return UserInput(key, wxJoyControl::HatSouth, joy); - } else if (kHatRegex.GetMatch(&start, &length, 5)) { + } else if (kHatRegex.GetMatch(remainder, 5).Length()) { return UserInput(key, wxJoyControl::HatEast, joy); - } else if (kHatRegex.GetMatch(&start, &length, 6)) { + } else if (kHatRegex.GetMatch(remainder, 6).Length()) { return UserInput(key, wxJoyControl::HatWest, joy); } }