diff --git a/src/main/java/se/lantz/gui/gamepad/GamePadDialog.java b/src/main/java/se/lantz/gui/gamepad/GamePadDialog.java index b839a9e..0591570 100644 --- a/src/main/java/se/lantz/gui/gamepad/GamePadDialog.java +++ b/src/main/java/se/lantz/gui/gamepad/GamePadDialog.java @@ -10,6 +10,7 @@ public class GamePadDialog extends BaseDialog { private GamepadBackgroundPanel panel; private JoystickModel model; + private Dimension dialogSize = new Dimension(660, 790); public GamePadDialog(Frame owner, JoystickModel model) { @@ -18,8 +19,8 @@ public class GamePadDialog extends BaseDialog this.model = new JoystickModel(model.isPort1()); setTitle("Edit joystick/gamepad configuration"); addContent(getGamepadBackgroundPanel()); - this.setPreferredSize(new Dimension(660, 770)); - this.setMinimumSize(new Dimension(660, 770)); + this.setPreferredSize(dialogSize); + this.setResizable(false); //Set initial values to the model this.model.setConfigStringFromDb(model.getConfigString()); } @@ -32,7 +33,7 @@ public class GamePadDialog extends BaseDialog } return panel; } - + public String getJoyConfigString() { return this.model.getConfigString(); diff --git a/src/main/java/se/lantz/gui/gamepad/GamePadImagePanel.java b/src/main/java/se/lantz/gui/gamepad/GamePadImagePanel.java index 3cad40a..a23b49a 100644 --- a/src/main/java/se/lantz/gui/gamepad/GamePadImagePanel.java +++ b/src/main/java/se/lantz/gui/gamepad/GamePadImagePanel.java @@ -37,7 +37,7 @@ public class GamePadImagePanel extends JPanel } } - ImageIcon gamepadImage = new ImageIcon(getClass().getResource("/se/lantz/logitech320.png")); + ImageIcon gamepadImage = new ImageIcon(getClass().getResource("/se/lantz/logitech.png")); private JLabel imageLabel; private GamePadButton currentButton = null; @@ -103,10 +103,13 @@ public class GamePadImagePanel extends JPanel graphics2D.fillRect(72, 57, 12, 20); break; case A: + graphics2D.drawOval(241, 94, 22, 22); break; case B: + graphics2D.drawOval(263, 72, 22, 22); break; case BACK_GUIDE: + graphics2D.drawOval(124, 55, 20, 16); break; case DOWN: //Oval around dpad @@ -121,10 +124,13 @@ public class GamePadImagePanel extends JPanel graphics2D.fillRect(54, 75, 20, 12); break; case LEFT_SHOULDER: + graphics2D.drawRect(242, 240, 35, 25); break; case LEFT_STICK: + graphics2D.fillOval(202, 126, 15, 15); break; case LEFT_TRIGGER: + graphics2D.drawOval(240, 270, 36, 36); break; case RIGHT: //Oval around dpad @@ -133,14 +139,19 @@ public class GamePadImagePanel extends JPanel graphics2D.fillRect(82, 75, 20, 12); break; case RIGHT_SHOULDER: + graphics2D.drawRect(48, 240, 35, 25); break; case RIGHT_STICK: + graphics2D.fillOval(114, 126, 15, 15); break; case RIGHT_TRIGGER: + graphics2D.drawOval(48, 270, 36, 36); break; case X: + graphics2D.drawOval(219, 72, 22, 22); break; case Y: + graphics2D.drawOval(241, 49, 22, 22); break; default: break; diff --git a/src/main/java/se/lantz/gui/gamepad/GamePadInfoPanel.java b/src/main/java/se/lantz/gui/gamepad/GamePadInfoPanel.java index b9ccf91..9cbef98 100644 --- a/src/main/java/se/lantz/gui/gamepad/GamePadInfoPanel.java +++ b/src/main/java/se/lantz/gui/gamepad/GamePadInfoPanel.java @@ -64,7 +64,7 @@ public class GamePadInfoPanel extends JPanel if (extraButtonsInfoLabel == null) { extraButtonsInfoLabel = new JLabel("Notice the extra buttons left shoulder, right shoulder, left stick and right stick. \r\n" + "They are not available on the joystick but are common on alternative USB controllers. \r\n" + - "The latter two are for controllers with two sticks that press down for additional button functions. It’s up to you what you map to those buttons (if anything)."); + "The latter two are for controllers with two sticks that press down for additional button functions. It’s up to you what you map to those buttons (if anything). Below are the functions for THEC64 Joystick shown in parenthesis for comparison."); } return extraButtonsInfoLabel; } diff --git a/src/main/java/se/lantz/gui/gamepad/MappingComponent.java b/src/main/java/se/lantz/gui/gamepad/MappingComponent.java index dc1bf5b..3d29c35 100644 --- a/src/main/java/se/lantz/gui/gamepad/MappingComponent.java +++ b/src/main/java/se/lantz/gui/gamepad/MappingComponent.java @@ -1,14 +1,19 @@ package se.lantz.gui.gamepad; +import java.awt.Component; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; +import java.awt.KeyboardFocusManager; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.beans.Beans; import javax.swing.JLabel; import javax.swing.JPanel; +import javax.swing.SwingUtilities; import se.lantz.gui.KeySelectionComboBox; import se.lantz.gui.gamepad.GamePadImagePanel.GamePadButton; @@ -183,7 +188,22 @@ public class MappingComponent extends JPanel @Override public void mouseExited(MouseEvent e) { - imagePanel.setCurrentButtonAndRepaint(null); + if (!keySelectionComboBox.hasFocus()) + { + Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); + if (focusOwner instanceof KeySelectionComboBox) + { + MappingComponent focusedMappingComponent = (MappingComponent)SwingUtilities.getAncestorOfClass(MappingComponent.class, focusOwner); + if (focusedMappingComponent != null) + { + imagePanel.setCurrentButtonAndRepaint(focusedMappingComponent.button); + } + } + else + { + imagePanel.setCurrentButtonAndRepaint(null); + } + } } @Override @@ -192,6 +212,20 @@ public class MappingComponent extends JPanel imagePanel.setCurrentButtonAndRepaint(button); } }); + keySelectionComboBox.addFocusListener(new FocusAdapter() + { + @Override + public void focusGained(FocusEvent e) + { + imagePanel.setCurrentButtonAndRepaint(button); + } + + @Override + public void focusLost(FocusEvent e) + { + imagePanel.setCurrentButtonAndRepaint(null); + } + }); } return keySelectionComboBox; } diff --git a/src/main/resources/se/lantz/logitech.png b/src/main/resources/se/lantz/logitech.png index 7cd771e..3cd1344 100644 Binary files a/src/main/resources/se/lantz/logitech.png and b/src/main/resources/se/lantz/logitech.png differ diff --git a/src/main/resources/se/lantz/logitech320.png b/src/main/resources/se/lantz/logitech320.png deleted file mode 100644 index 3cd1344..0000000 Binary files a/src/main/resources/se/lantz/logitech320.png and /dev/null differ