News!
I got this working without using an array here is how.
https://ibb.co/F8Yw1Q1Video:
https://youtu.be/c3SJeOamicQButton checker FSM
This example is only for choosing a PS touchpad and then selecting the left joystick button:
Each button is saved with a unique name to the player prefs. At startup are set with default values.
Each button has three essential variables that are used in order to achieve the swapping function. Picked type bool, Int (this is a global) and Default touchpad value (Joystick1Button13)
The picked bool is only true once you have chosen the button to change.
The int value is the way I check what combo was used.
The Default touchpad value (Joystick1Button13) used later.
Order of events as they happen.
1. Use the mouse to select the button (example PS touchpad) click to choose. Picked value set to true. Int value set to 14.
2. Select the joystick button you wish to use. Press key on the joystick. (The left joystick button)
3. The button checker fsm
Starts by checking for a duplicate state
If none return. If yes then a duplicate was found.
Switch keys around leads you to “find the only match”
This state checks again, but this time for a match found.
Check my bool state, checks the “Picked value” (This will be true)
We verify this in the “Two matching found” state.
The “identify key found state” gets the bool value of the left joystick button “Picked” and check that it is false.
Send the Global “Change”
Change: Swap keys state: Check that the bool “Picked” of the left joystick is false.
An int switch to manage all the possible combos (one done as testing) Check the global int (it will be set to 14 at this point) go to event “touchpad & left stick”
Working for touchpad and left stick state: Get the Default value (Joystick1Button13) and store it as “Swapped value” Set player pref “ps left joystick button” to the swapped value.
There will be 13 of possible combos for each key. That's a big int switch.
Writing this information has helped me spot areas where I can improve on the FSM.
The question: Is it worth all the extra work?