1
0
Fork 0

Refactor and make the joystick querier re-runnable

The previous function could only be effectively run one because
it changes the value of the global 'joytype' to something other
than AUTO, which is what this function looks for to re-query
the joysticks.

Second, if this function is run more than once, then it clobbers
the prior set number of joysticks back to zero (without
re-requerying for the actual quantity), rendering the joysticks
unuseable.

Finally, this function depends on several SDL calls to the joystick
subsystem, but fails to check or initialize it.

The commit:
 - Checks for an initializes the joystick subsystem before using it
 - Always re-queries the current state of the joystick (re-runnable)
 - Simplifies the logic to determine useability (retains criteria)
 - Conservatively writes the joysticks quantities at the end
This commit is contained in:
krcroft 2020-03-18 16:46:29 -07:00 committed by Patryk Obara
parent d815c52965
commit 81efce0862
2 changed files with 49 additions and 58 deletions

View file

@ -2824,7 +2824,6 @@ int main(int argc, char* argv[]) {
}
/* Init the keyMapper */
MAPPER_Init();
if (control->cmdline->FindExist("-startmapper")) MAPPER_RunInternal();
/* Start up main machine */
control->StartUp();