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 <rkitover@gmail.com>
This commit is contained in:
parent
d8d3ee2b48
commit
7e1afcd37c
|
@ -214,13 +214,13 @@ UserInput StringToUserInput(const wxString& string) {
|
||||||
if (kHatRegex.Matches(remainder)) {
|
if (kHatRegex.Matches(remainder)) {
|
||||||
kHatRegex.GetMatch(&start, &length, 1);
|
kHatRegex.GetMatch(&start, &length, 1);
|
||||||
const int key = StringToInt(remainder.Mid(start, length));
|
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);
|
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);
|
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);
|
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);
|
return UserInput(key, wxJoyControl::HatWest, joy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue