diff --git a/src/app/App.java b/src/app/App.java index 25d8d7a..6478a7e 100644 --- a/src/app/App.java +++ b/src/app/App.java @@ -68,9 +68,6 @@ public class App device.setRegionColor(Region.MIDDLE, Color.ORANGE, Intensity.HIGH); device.setRegionColor(Region.RIGHT, Color.PURPLE, Intensity.HIGH); device.setMode(Mode.NORMAL); - - - } } diff --git a/src/args/Args.java b/src/args/Args.java new file mode 100644 index 0000000..b614189 --- /dev/null +++ b/src/args/Args.java @@ -0,0 +1,16 @@ +package org.manzerbredes.open_klm.args; + +import org.manzerbredes.open_klm.drivers.Driver; + +/** + * All arguments parser must implement this interface + * + * @author Manzerbredes + * + */ +public interface Args{ + /** + * Apply parsed argument and exit the program + */ + public void applyAndExit(Driver aDriver, String[] args); +} \ No newline at end of file diff --git a/src/args/ArgsTypeA.java b/src/args/ArgsTypeA.java index eb172ef..0fd9a1e 100644 --- a/src/args/ArgsTypeA.java +++ b/src/args/ArgsTypeA.java @@ -1,6 +1,64 @@ package org.manzerbredes.open_klm.args; +import java.util.HashMap; -public class ArgsTypeA{ +import org.javatuples.Pair; +import org.manzerbredes.open_klm.drivers.Driver; +import org.manzerbredes.open_klm.drivers.DriverTypeA; +import org.manzerbredes.open_klm.drivers.DriverTypeA.*; + +/** + * Parse args for DriverTypeA + * + * @author Manzerbredes + * + */ +public class ArgsTypeA implements Args{ + /** + * Define Keyboard primary color state + */ + private HashMap> primaryColorsState=new HashMap<>(); + + /** + * Define Keyboard secondary color state (for wave) + */ + private HashMap> secondaryColorsState=new HashMap<>(); + + /** + * Define Keyboard mode state + */ + private Mode mode=Mode.NORMAL; + + + /** + * Build a ArgsTypeA + * + * @param driver The driver to use + */ + public ArgsTypeA(){ + // Init primary color state + this.primaryColorsState.put(Region.LEFT, new Pair(Color.OFF, Intensity.HIGH)); + this.primaryColorsState.put(Region.MIDDLE, new Pair(Color.OFF, Intensity.HIGH)); + this.primaryColorsState.put(Region.RIGHT, new Pair(Color.OFF, Intensity.HIGH)); + // Init secondary color state + this.secondaryColorsState.put(Region.LEFT, new Pair(Color.OFF, Intensity.LOW)); + this.secondaryColorsState.put(Region.MIDDLE, new Pair(Color.OFF, Intensity.LOW)); + this.secondaryColorsState.put(Region.RIGHT, new Pair(Color.OFF, Intensity.LOW)); + // Init mode + this.mode=Mode.NORMAL; + } + + @Override + public void applyAndExit(Driver aDriver, String[] args){ + if(aDriver.getType().equals(DriverTypeA.class)){ + + //TODO Parse and apply args with args4j + + System.exit(0); + } + + // Error invalid driver + System.exit(1); + } } \ No newline at end of file diff --git a/src/client/MainWindow.java b/src/client/MainWindow.java index f159621..15baf4c 100644 --- a/src/client/MainWindow.java +++ b/src/client/MainWindow.java @@ -51,7 +51,7 @@ public class MainWindow extends JFrame { Color leftRegion=(Color) left.getSelectedItem(); Color middleRegion=(Color) middle.getSelectedItem(); Color rightRegion=(Color) right.getSelectedItem(); - + keyboardTypeA.setRegionColor(Region.LEFT, leftRegion, Intensity.HIGH); keyboardTypeA.setRegionColor(Region.MIDDLE, middleRegion, Intensity.HIGH); keyboardTypeA.setRegionColor(Region.RIGHT, rightRegion, Intensity.HIGH);