use of org.javatari.pc.controls.JoystickConsoleControls.DeviceOption in project javatari by ppeccin.
the class JComboBoxNim method joyP0P1DeviceAction.
protected void joyP0P1DeviceAction() {
if (refreshInProgress)
return;
if (joyP0Device.isEnabled()) {
DeviceOption opt0 = (DeviceOption) joyP0Device.getSelectedItem();
Parameters.JOY_P0_DEVICE = opt0 != null ? opt0.device : Parameters.JOY_DEVICE_AUTO;
}
if (joyP1Device.isEnabled()) {
DeviceOption opt1 = (DeviceOption) joyP1Device.getSelectedItem();
Parameters.JOY_P1_DEVICE = opt1 != null ? opt1.device : Parameters.JOY_DEVICE_AUTO;
}
room.joystickControls().start();
refreshJoysticks();
}
use of org.javatari.pc.controls.JoystickConsoleControls.DeviceOption in project javatari by ppeccin.
the class JComboBoxNim method refreshJoysticks.
private void refreshJoysticks() {
if (refreshInProgress)
return;
refreshInProgress = true;
String pre = "But ";
String empty = " ";
Vector<DeviceOption> joyP0Opts = room.joystickControls().getJoystick0DeviceOptions();
if (!joyP0Opts.isEmpty()) {
joyP0Device.setModel(new DefaultComboBoxModel(joyP0Opts));
joyP0Device.setSelectedItem(room.joystickControls().getJoystick0DeviceOption());
joyP0Device.setEnabled(true);
} else {
joyP0Device.setModel(new DefaultComboBoxModel(new Vector<String>(Arrays.asList(new String[] { "Not Supported" }))));
joyP0Device.setSelectedIndex(0);
joyP0Device.setEnabled(false);
}
Vector<DeviceOption> joyP1Opts = room.joystickControls().getJoystick1DeviceOptions();
if (!joyP1Opts.isEmpty()) {
joyP1Device.setModel(new DefaultComboBoxModel(room.joystickControls().getJoystick1DeviceOptions()));
joyP1Device.setSelectedItem(room.joystickControls().getJoystick1DeviceOption());
joyP1Device.setEnabled(true);
} else {
joyP1Device.setModel(new DefaultComboBoxModel(new Vector<String>(Arrays.asList(new String[] { "Not Supported" }))));
joyP1Device.setSelectedIndex(0);
joyP1Device.setEnabled(false);
}
boolean joy0Present = room.joystickControls().isStarted() && room.joystickControls().getJoystick0() != null;
boolean joy1Present = room.joystickControls().isStarted() && room.joystickControls().getJoystick1() != null;
joyP0Button.setText(Parameters.JOY_P0_BUTTON == CONTROL_UNSET ? empty : pre + (Parameters.JOY_P0_BUTTON + 1));
joyP0Button2.setText(Parameters.JOY_P0_BUTTON2 == CONTROL_UNSET ? empty : pre + (Parameters.JOY_P0_BUTTON2 + 1));
joyP0Reset.setText(Parameters.JOY_P0_RESET == CONTROL_UNSET ? empty : pre + (Parameters.JOY_P0_RESET + 1));
joyP0Select.setText(Parameters.JOY_P0_SELECT == CONTROL_UNSET ? empty : pre + (Parameters.JOY_P0_SELECT + 1));
joyP0Pause.setText(Parameters.JOY_P0_PAUSE == CONTROL_UNSET ? empty : pre + (Parameters.JOY_P0_PAUSE + 1));
joyP0FastSpeed.setText(Parameters.JOY_P0_FAST_SPPED == CONTROL_UNSET ? empty : pre + (Parameters.JOY_P0_FAST_SPPED + 1));
joyP1Button.setText(Parameters.JOY_P1_BUTTON == CONTROL_UNSET ? empty : pre + (Parameters.JOY_P1_BUTTON + 1));
joyP1Button2.setText(Parameters.JOY_P1_BUTTON2 == CONTROL_UNSET ? empty : pre + (Parameters.JOY_P1_BUTTON2 + 1));
joyP1Reset.setText(Parameters.JOY_P1_RESET == CONTROL_UNSET ? empty : pre + (Parameters.JOY_P1_RESET + 1));
joyP1Select.setText(Parameters.JOY_P1_SELECT == CONTROL_UNSET ? empty : pre + (Parameters.JOY_P1_SELECT + 1));
joyP1Pause.setText(Parameters.JOY_P1_PAUSE == CONTROL_UNSET ? empty : pre + (Parameters.JOY_P1_PAUSE + 1));
joyP1FastSpeed.setText(Parameters.JOY_P1_FAST_SPPED == CONTROL_UNSET ? empty : pre + (Parameters.JOY_P1_FAST_SPPED + 1));
joyP0Deadzone.setEnabled(joy0Present);
joyP1Deadzone.setEnabled(joy1Present);
joyP0XAxis.setEnabled(joy0Present);
joyP1XAxis.setEnabled(joy1Present);
if (room.joystickControls().paddleMode) {
joyP0DeadzoneL.setText("Center");
joyP0Deadzone.setModel(new DefaultComboBoxModel(PADDLE_CENTER_OPTIONS));
joyP0Deadzone.setSelectedItem(Parameters.JOY_P0_PADDLE_CENTER == 0 ? PADDLE_CENTER_ZERO : String.format("%+d", Parameters.JOY_P0_PADDLE_CENTER));
joyP0Sensitivity.setEnabled(joy0Present);
joyP0Sensitivity.setSelectedItem(Parameters.JOY_P0_PADDLE_SENS == 0 ? PADDLE_SENS_DIGITAL : "" + Parameters.JOY_P0_PADDLE_SENS + "%");
joyP0XAxisL.setText("Axis");
joyP0XAxis.setSelectedIndex(Parameters.JOY_P0_PAD_AXIS + (Parameters.JOY_P0_PAD_AXIS_SIGNAL == -1 ? 6 : 0));
joyP0YAxis.setEnabled(false);
joyP0YAxis.setSelectedIndex(1);
joyP1DeadzoneL.setText("Center");
joyP1Deadzone.setModel(new DefaultComboBoxModel(PADDLE_CENTER_OPTIONS));
joyP1Deadzone.setSelectedItem(Parameters.JOY_P1_PADDLE_CENTER == 0 ? PADDLE_CENTER_ZERO : String.format("%+d", Parameters.JOY_P1_PADDLE_CENTER));
joyP1Sensitivity.setEnabled(joy1Present);
joyP1Sensitivity.setSelectedItem(Parameters.JOY_P1_PADDLE_SENS == 0 ? PADDLE_SENS_DIGITAL : "" + Parameters.JOY_P1_PADDLE_SENS + "%");
joyP1XAxisL.setText("Axis");
joyP1XAxis.setSelectedIndex(Parameters.JOY_P1_PAD_AXIS + (Parameters.JOY_P1_PAD_AXIS_SIGNAL == -1 ? 6 : 0));
joyP1YAxis.setEnabled(false);
joyP1YAxis.setSelectedIndex(1);
joystick0Icon.setIcon(joy0Present ? paddleIcon : paddleIconGrayed);
joystick1Icon.setIcon(joy1Present ? paddleIcon : paddleIconGrayed);
} else {
joyP0DeadzoneL.setText("Dead zone");
joyP0Deadzone.setModel(new DefaultComboBoxModel(JOY_DEADZONE_OPTIONS));
joyP0Deadzone.setSelectedItem("" + Parameters.JOY_P0_DEADZONE + "%");
joyP0Sensitivity.setEnabled(false);
joyP0Sensitivity.setSelectedIndex(0);
joyP0XAxisL.setText("X Axis");
joyP0XAxis.setSelectedIndex(Parameters.JOY_P0_XAXIS + (Parameters.JOY_P0_XAXIS_SIGNAL == -1 ? 6 : 0));
joyP0YAxis.setEnabled(joy0Present);
joyP0YAxis.setSelectedIndex(Parameters.JOY_P0_YAXIS + (Parameters.JOY_P0_YAXIS_SIGNAL == -1 ? 6 : 0));
joyP1DeadzoneL.setText("Dead zone");
joyP1Deadzone.setModel(new DefaultComboBoxModel(JOY_DEADZONE_OPTIONS));
joyP1Deadzone.setSelectedItem("" + Parameters.JOY_P1_DEADZONE + "%");
joyP1Sensitivity.setEnabled(false);
joyP1Sensitivity.setSelectedIndex(0);
joyP1XAxisL.setText("X Axis");
joyP1XAxis.setSelectedIndex(Parameters.JOY_P1_XAXIS + (Parameters.JOY_P1_XAXIS_SIGNAL == -1 ? 6 : 0));
joyP1YAxis.setEnabled(joy1Present);
joyP1YAxis.setSelectedIndex(Parameters.JOY_P1_YAXIS + (Parameters.JOY_P1_YAXIS_SIGNAL == -1 ? 6 : 0));
joystick0Icon.setIcon(joy0Present ? joystickIcon : joystickIconGrayed);
joystick1Icon.setIcon(joy1Present ? joystickIcon : joystickIconGrayed);
}
for (JTextField f : joystick0FieldsList) f.setEnabled(joy0Present);
for (JTextField f : joystick1FieldsList) f.setEnabled(joy1Present);
for (JTextField field : joysticksFieldsList) if (field == joystickEditField) {
field.setBackground(EDDITING);
field.setSelectionStart(0);
field.setSelectionEnd(0);
} else
field.setBackground(field.getText().trim().isEmpty() ? UNMAPPED : Color.WHITE);
joysticksEdittingL.setText(joystickEditField != null ? "- press button -" : "");
defaultsB.setText("Defaults");
defaultsB.setVisible(true);
String message;
if (room.awtControls().p1ControlsMode ^ room.joystickControls().swappedMode) {
joysticksPlayer1Lb.setText("Player 2");
joysticksPlayer2Lb.setText("Player 1");
message = "Swapped";
} else {
joysticksPlayer1Lb.setText("Player 1");
joysticksPlayer2Lb.setText("Player 2");
message = "";
}
joysticksMessageL.setText(message);
refreshInProgress = false;
}
Aggregations