@@ -29,37 +29,71 @@ public InputMapControllerScreen(InputMapScreen inputMapScreen, GameOptions gameO
2929 controls .add (changeCtrl );
3030 }
3131
32+ private InputConfigItem InitItem (int axis , int button , String displayName ) {
33+ boolean isAxis = (axis > -1 );
34+ int controllerInput = isAxis ? axis : button ;
35+ String inputName = (isAxis ? "Axis: " : "Button: " ) + controllerInput ;
36+ InputConfigItem item = new InputConfigItem (displayName , inputName , isAxis , controllerInput );
37+ return item ;
38+ }
39+
3240 private void InitialiseList (GameOptions gameOptions ) {
3341 itemsList .clear ();
3442
35- // TODO: Ship Control Inputs
43+ // Ship Control Inputs
44+ itemsList .add (InitItem (gameOptions .getControllerAxisUpDown (), gameOptions .getControllerButtonUp (), "Up" ));
45+ itemsList .add (InitItem (gameOptions .getControllerAxisUpDown (), gameOptions .getControllerButtonDown (), "Down" ));
46+ itemsList .add (InitItem (gameOptions .getControllerAxisLeftRight (), gameOptions .getControllerButtonLeft (), "Left" ));
47+ itemsList .add (InitItem (gameOptions .getControllerAxisLeftRight (), gameOptions .getControllerButtonRight (), "Right" ));
48+ itemsList .add (InitItem (gameOptions .getControllerAxisShoot (), gameOptions .getControllerButtonShoot (), "Shoot" ));
49+ itemsList .add (InitItem (gameOptions .getControllerAxisShoot2 (), gameOptions .getControllerButtonShoot2 (), "Shoot Secondary" ));
50+ itemsList .add (InitItem (gameOptions .getControllerAxisAbility (), gameOptions .getControllerButtonAbility (), "Ability" ));
3651
3752 // Menu and Interface Keys
38- InputConfigItem pause = new InputConfigItem ("Pause" , gameOptions .getKeyPauseName ());
39- itemsList .add (pause );
40- InputConfigItem map = new InputConfigItem ("Map" , gameOptions .getKeyMapName ());
41- itemsList .add (map );
42- InputConfigItem inventory = new InputConfigItem ("Inventory" , gameOptions .getKeyInventoryName ());
43- itemsList .add (inventory );
44- InputConfigItem drop = new InputConfigItem ("Drop Item" , gameOptions .getKeyDropName ());
45- itemsList .add (drop );
46- InputConfigItem talk = new InputConfigItem ("Talk" , gameOptions .getKeyTalkName ());
47- itemsList .add (talk );
48- InputConfigItem sell = new InputConfigItem ("Sell" , gameOptions .getKeySellMenuName ());
49- itemsList .add (sell );
50- InputConfigItem buy = new InputConfigItem ("Buy" , gameOptions .getKeyBuyMenuName ());
51- itemsList .add (buy );
52- InputConfigItem changeShip = new InputConfigItem ("Change Ship" , gameOptions .getKeyChangeShipMenuName ());
53- itemsList .add (changeShip );
54- InputConfigItem hireShip = new InputConfigItem ("Hire Ship" , gameOptions .getKeyHireShipMenuName ());
55- itemsList .add (hireShip );
53+ itemsList .add (new InputConfigItem ("Pause" , gameOptions .getKeyPauseName ()));
54+ itemsList .add (new InputConfigItem ("Map" , gameOptions .getKeyMapName ()));
55+ itemsList .add (new InputConfigItem ("Inventory" , gameOptions .getKeyInventoryName ()));
56+ itemsList .add (new InputConfigItem ("Drop Item" , gameOptions .getKeyDropName ()));
57+ itemsList .add (new InputConfigItem ("Talk" , gameOptions .getKeyTalkName ()));
58+ itemsList .add (new InputConfigItem ("Sell" , gameOptions .getKeySellMenuName ()));
59+ itemsList .add (new InputConfigItem ("Buy" , gameOptions .getKeyBuyMenuName ()));
60+ itemsList .add (new InputConfigItem ("Change Ship" , gameOptions .getKeyChangeShipMenuName ()));
61+ itemsList .add (new InputConfigItem ("Hire Ship" , gameOptions .getKeyHireShipMenuName ()));
5662 }
5763
5864 @ Override
5965 public void save (GameOptions gameOptions ) {
6066 int index = 0 ;
6167
6268 // This needs to be in the same order the list is initialised
69+ InputConfigItem item = itemsList .get (index ++);
70+ gameOptions .setControllerAxisUpDown (item .isAxis () ? item .getControllerInput () : -1 );
71+ gameOptions .setControllerButtonUp (!item .isAxis () ? item .getControllerInput () : -1 );
72+
73+ item = itemsList .get (index ++);
74+ gameOptions .setControllerAxisUpDown (item .isAxis () ? item .getControllerInput () : -1 );
75+ gameOptions .setControllerButtonDown (!item .isAxis () ? item .getControllerInput () : -1 );
76+
77+ item = itemsList .get (index ++);
78+ gameOptions .setControllerAxisLeftRight (item .isAxis () ? item .getControllerInput () : -1 );
79+ gameOptions .setControllerButtonLeft (!item .isAxis () ? item .getControllerInput () : -1 );
80+
81+ item = itemsList .get (index ++);
82+ gameOptions .setControllerAxisLeftRight (item .isAxis () ? item .getControllerInput () : -1 );
83+ gameOptions .setControllerButtonRight (!item .isAxis () ? item .getControllerInput () : -1 );
84+
85+ item = itemsList .get (index ++);
86+ gameOptions .setControllerAxisShoot (item .isAxis () ? item .getControllerInput () : -1 );
87+ gameOptions .setControllerButtonShoot (!item .isAxis () ? item .getControllerInput () : -1 );
88+
89+ item = itemsList .get (index ++);
90+ gameOptions .setControllerAxisShoot2 (item .isAxis () ? item .getControllerInput () : -1 );
91+ gameOptions .setControllerButtonShoot2 (!item .isAxis () ? item .getControllerInput () : -1 );
92+
93+ item = itemsList .get (index ++);
94+ gameOptions .setControllerAxisAbility (item .isAxis () ? item .getControllerInput () : -1 );
95+ gameOptions .setControllerButtonAbility (!item .isAxis () ? item .getControllerInput () : -1 );
96+
6397 gameOptions .setKeyPauseName (itemsList .get (index ++).getInputKey ());
6498 gameOptions .setKeyMapName (itemsList .get (index ++).getInputKey ());
6599 gameOptions .setKeyInventoryName (itemsList .get (index ++).getInputKey ());
@@ -77,6 +111,14 @@ public void resetToDefaults(GameOptions gameOptions) {
77111 int index = 0 ;
78112
79113 // This needs to be in the same order the list is initialised
114+ itemsList .set (index ++, InitItem (GameOptions .DEFAULT_AXIS_UP_DOWN , GameOptions .DEFAULT_BUTTON_UP , "Up" ));
115+ itemsList .set (index ++, InitItem (GameOptions .DEFAULT_AXIS_UP_DOWN , GameOptions .DEFAULT_BUTTON_DOWN , "Down" ));
116+ itemsList .set (index ++, InitItem (GameOptions .DEFAULT_AXIS_LEFT_RIGHT , GameOptions .DEFAULT_BUTTON_LEFT , "Left" ));
117+ itemsList .set (index ++, InitItem (GameOptions .DEFAULT_AXIS_LEFT_RIGHT , GameOptions .DEFAULT_BUTTON_RIGHT , "Right" ));
118+ itemsList .set (index ++, InitItem (GameOptions .DEFAULT_AXIS_SHOOT , GameOptions .DEFAULT_BUTTON_SHOOT , "Shoot" ));
119+ itemsList .set (index ++, InitItem (GameOptions .DEFAULT_AXIS_SHOOT2 , GameOptions .DEFAULT_BUTTON_SHOOT2 , "Shoot Secondary" ));
120+ itemsList .set (index ++, InitItem (GameOptions .DEFAULT_AXIS_ABILITY , GameOptions .DEFAULT_BUTTON_ABILITY , "Ability" ));
121+
80122 InputConfigItem item = itemsList .get (index );
81123 item .setInputKey (GameOptions .DEFAULT_PAUSE );
82124 itemsList .set (index ++, item );
@@ -124,6 +166,8 @@ public void updateCustom(SolApplication cmp, SolInputManager.Ptr[] ptrs, boolean
124166 if (changeCtrl .isJustOff ()) {
125167 isEnterNewKey = !isEnterNewKey ;
126168
169+ // TODO: Capture Controller Inputs
170+
127171 // Can cancel the key entering by clicking this button a second time
128172 if (!isEnterNewKey ) {
129173 Gdx .input .setInputProcessor (null );
@@ -133,9 +177,11 @@ public void updateCustom(SolApplication cmp, SolInputManager.Ptr[] ptrs, boolean
133177 Gdx .input .setInputProcessor (new InputAdapter () {
134178 @ Override
135179 public boolean keyUp (int keycode ) {
136- InputConfigItem item = itemsList .get (selectedIndex );
137- item .setInputKey (Input .Keys .toString (keycode ));
138- itemsList .set (selectedIndex , item );
180+ if (selectedIndex >= 7 ) {
181+ InputConfigItem item = itemsList .get (selectedIndex );
182+ item .setInputKey (Input .Keys .toString (keycode ));
183+ itemsList .set (selectedIndex , item );
184+ }
139185 Gdx .input .setInputProcessor (null );
140186
141187 isEnterNewKey = false ;
0 commit comments