1 package com.neuronrobotics.sdk.addons.gamepad;
8 import com.neuronrobotics.bowlerstudio.assets.AssetFactory;
9 import com.neuronrobotics.bowlerstudio.assets.ConfigurationDatabase;
11 import javafx.application.Application;
12 import javafx.application.Platform;
13 import javafx.event.ActionEvent;
14 import javafx.event.EventHandler;
15 import javafx.fxml.FXML;
16 import javafx.fxml.FXMLLoader;
17 import javafx.scene.Parent;
18 import javafx.scene.Scene;
19 import javafx.scene.control.Button;
20 import javafx.scene.control.Label;
21 import javafx.scene.control.TextField;
22 import javafx.scene.image.ImageView;
23 import javafx.scene.input.MouseEvent;
24 import javafx.stage.Modality;
25 import javafx.stage.Stage;
29 import java.util.ArrayList;
30 import java.util.HashMap;
31 import java.util.List;
32 import java.util.ResourceBundle;
34 import java.util.ResourceBundle;
35 import javafx.fxml.FXML;
36 import javafx.scene.layout.ColumnConstraints;
37 import javafx.scene.layout.GridPane;
38 import javafx.scene.layout.VBox;
54 private HashMap<Integer, TextField>
fields =
new HashMap<>();
65 assert
grid != null :
"fx:id=\"grid\" was not injected: check your FXML file 'jogTrainerWidget.fxml'.";
68 assert
controllername!=
null:
"fx:id=\"grid\" was not injected: check your FXML file 'jogTrainerWidget.fxml'.";
71 save =
new Button(
"Save Mapping");
72 Button
reset =
new Button(
"Reset");
73 reset.setOnAction(event -> {
75 for(Integer key:
fields.keySet()) {
76 fields.get(key).setText(
"");
80 save.setOnAction(
new EventHandler<ActionEvent>() {
83 public void handle(ActionEvent event) {
86 for (
int i = 0; i < maps.size(); i++)
97 System.out.println(
"There are "+maps.size()+
" rows");
98 for (i = 0; i < maps.size(); i++) {
99 String map = maps.get(i);
101 Label name =
new Label(map);
102 Label setto =
new Label(
"set to");
103 TextField toBeMapped =
new TextField();
108 toBeMapped.setDisable(
true);
109 grid.add(name, 0, i);
110 grid.add(setto, 1, i);
111 grid.add(toBeMapped, 2, i);
112 fields.put(i, toBeMapped);
118 Platform.runLater(() ->
fields.get(0).setDisable(
true));
135 URL fileURL = fxmlFIle.toURI().toURL();
136 FXMLLoader loader =
new FXMLLoader(fileURL);
137 loader.setLocation(fileURL);
139 loader.setController(
this);
141 loader.setClassLoader(getClass().getClassLoader());
142 root = loader.load();
143 Platform.runLater(() -> {
146 Scene scene =
new Scene(root);
162 save.setDisable(
true);
168 public void onEvent(String name,
float value) {
173 if(Math.abs(value)>0.0001) {
174 System.out.println(
"Waiting for value to settle for "+
axisWaiting);
184 System.out.println(
"Waiting for value to settle for "+
axisWaiting+
" got value from "+name);
189 if(s.contentEquals(name)) {
190 System.out.println(
"mapping skipped for "+name);
196 if(name.contentEquals(s))
203 System.out.println(
"Adding Axis "+name);
206 Platform.runLater(() -> {
208 textField.setText(name);
210 textField.setDisable(
true);
213 save.setDisable(false);
214 gameController.removeListeners(this);
223 Platform.runLater(
new Runnable() {
227 Stage s =
new Stage();
234 }
catch (Exception e) {
static File loadFile(String file)
static Object setObject(String paramsKey, String objectKey, Object value)
static String getHardwareAxisFromMappedValue(String controllerName, String mappedValue)
static void clearMapping(String controllerName)
static boolean areAllAxisMapped(String controllerName)
static List< String > getDefaultMaps()
static boolean isMapedAxis(String controllerName, String mappedValue)