Skip to content

Commit

Permalink
Added global config option to allow disabling of circle to square axe…
Browse files Browse the repository at this point in the history
…s mapping
  • Loading branch information
bwRavencl committed Jun 26, 2024
1 parent 7aaa280 commit 8a08196
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
21 changes: 21 additions & 0 deletions src/main/java/de/bwravencl/controllerbuddy/gui/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ public final class Main {
private static final String PREFERENCES_LAST_PROFILE = "last_profile";
private static final String PREFERENCES_VJOY_DEVICE = "vjoy_device";
private static final String PREFERENCES_VJOY_DIRECTORY = "vjoy_directory";
private static final String PREFERENCES_MAP_CIRCULAR_AXES_TO_SQUARE = "map_circular_axes_to_square";
private static final String PREFERENCES_HAPTIC_FEEDBACK = "haptic_feedback";
private static final String PREFERENCES_SKIP_CONTROLLER_DIALOGS = "skip_controller_dialogs";
private static final String PREFERENCES_AUTO_RESTART_OUTPUT = "auto_restart_output";
Expand Down Expand Up @@ -642,6 +643,22 @@ public void windowOpened(final WindowEvent e) {
(int) ((JSpinner) event.getSource()).getValue()));
pollIntervalPanel.add(pollIntervalSpinner);

final var mapCircularAxesToSquarePanel = new JPanel(DEFAULT_FLOW_LAYOUT);
inputSettingsPanel.add(mapCircularAxesToSquarePanel, constraints);

final var mapCircularAxesToSquareLabel = new JLabel(strings.getString("MAP_CIRCULAR_AXES_TO_SQUARE_LABEL"));
mapCircularAxesToSquareLabel.setPreferredSize(SETTINGS_LABEL_DIMENSION);
mapCircularAxesToSquarePanel.add(mapCircularAxesToSquareLabel);

final var mapCircularAxesToSquareCheckBox = new JCheckBox(
strings.getString("MAP_CIRCULAR_AXES_TO_SQUARE_CHECK_BOX"));
mapCircularAxesToSquareCheckBox.setSelected(isMapCircularAxesToSquareAxes());
mapCircularAxesToSquareCheckBox.addActionListener(event -> {
final var mapCircularAxesToSquare = ((JCheckBox) event.getSource()).isSelected();
preferences.putBoolean(PREFERENCES_MAP_CIRCULAR_AXES_TO_SQUARE, mapCircularAxesToSquare);
});
mapCircularAxesToSquarePanel.add(mapCircularAxesToSquareCheckBox);

final var hapticFeedbackPanel = new JPanel(DEFAULT_FLOW_LAYOUT);
inputSettingsPanel.add(hapticFeedbackPanel, constraints);

Expand Down Expand Up @@ -1860,6 +1877,10 @@ public boolean isLocalRunning() {
return taskRunner.isTaskOfTypeRunning(LocalRunMode.class);
}

public boolean isMapCircularAxesToSquareAxes() {
return preferences.getBoolean(PREFERENCES_MAP_CIRCULAR_AXES_TO_SQUARE, true);
}

public boolean isOpenVrOverlayActive() {
return openVrOverlay != null;
}
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/de/bwravencl/controllerbuddy/input/Input.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public final class Input {
private int hotSwappingButtonId = HotSwappingButton.None.id;
private boolean skipAxisInitialization;
private boolean initialized;
private boolean mapCircularAxesToSquareAxes;
private boolean hapticFeedback;

public Input(final Main main, final ControllerInfo controller, final EnumMap<VirtualAxis, Integer> axes) {
Expand Down Expand Up @@ -253,6 +254,7 @@ public int getScrollClicks() {
}

public void init() {
mapCircularAxesToSquareAxes = main.isMapCircularAxesToSquareAxes();
hapticFeedback = main.isHapticFeedback();

final var presentControllers = Main.getPresentControllers();
Expand Down Expand Up @@ -437,8 +439,10 @@ public boolean poll() {
final var axisToActionMap = activeMode.getAxisToActionsMap();
final var buttonToActionMap = activeMode.getButtonToActionsMap();

mapCircularAxesToSquareAxes(state, GLFW.GLFW_GAMEPAD_AXIS_LEFT_X, GLFW.GLFW_GAMEPAD_AXIS_LEFT_Y);
mapCircularAxesToSquareAxes(state, GLFW.GLFW_GAMEPAD_AXIS_RIGHT_X, GLFW.GLFW_GAMEPAD_AXIS_RIGHT_Y);
if (mapCircularAxesToSquareAxes) {
mapCircularAxesToSquareAxes(state, GLFW.GLFW_GAMEPAD_AXIS_LEFT_X, GLFW.GLFW_GAMEPAD_AXIS_LEFT_Y);
mapCircularAxesToSquareAxes(state, GLFW.GLFW_GAMEPAD_AXIS_RIGHT_X, GLFW.GLFW_GAMEPAD_AXIS_RIGHT_Y);
}

for (var axis = 0; axis <= GLFW.GLFW_GAMEPAD_AXIS_LAST; axis++) {
final var axisValue = state.axes(axis);
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/strings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ SHOW_VR_OVERLAY_CHECK_BOX = Show VR Overlay
INPUT_OUTPUT_SETTINGS_BORDER_TITLE = Input-Output
POLL_INTERVAL_LABEL = Poll Interval
HAPTIC_FEEDBACK_LABEL = Haptic Feedback
MAP_CIRCULAR_AXES_TO_SQUARE_LABEL = Physical Axes
MAP_CIRCULAR_AXES_TO_SQUARE_CHECK_BOX = Enable Circle to Square Mapping
HAPTIC_FEEDBACK_CHECK_BOX = Enable Haptic Feedback
AUTO_RESTART_OUTPUT_LABEL = Auto-Restart Output
AUTO_RESTART_OUTPUT_CHECK_BOX = Restart Output on Controller Connection
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/strings_de_DE.properties
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ SHOW_VR_OVERLAY_CHECK_BOX = VR Overlay anzeigen

INPUT_OUTPUT_SETTINGS_BORDER_TITLE = Ein-Ausgabe
POLL_INTERVAL_LABEL = Poll Intervall
MAP_CIRCULAR_AXES_TO_SQUARE_LABEL = Physische Achsen
MAP_CIRCULAR_AXES_TO_SQUARE_CHECK_BOX = Abbildung von Kreis auf Quadrat aktivieren
HAPTIC_FEEDBACK_LABEL = Haptisches Feedback
HAPTIC_FEEDBACK_CHECK_BOX = Haptisches Feedback aktivieren
AUTO_RESTART_OUTPUT_LABEL = Auto-Neustart der Ausgabe
Expand Down

0 comments on commit 8a08196

Please sign in to comment.