From 09b9f7cad0d4013a228e2d7019cfd9067ef49bd7 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Tue, 29 Mar 2016 18:05:00 +0200 Subject: Add waves mode --- src/drivers/Driver_1770_ff00.java | 76 ++++++++++++++++++++++++++++++++------- 1 file changed, 64 insertions(+), 12 deletions(-) (limited to 'src/drivers/Driver_1770_ff00.java') diff --git a/src/drivers/Driver_1770_ff00.java b/src/drivers/Driver_1770_ff00.java index 9b1d169..59c4dcb 100644 --- a/src/drivers/Driver_1770_ff00.java +++ b/src/drivers/Driver_1770_ff00.java @@ -8,7 +8,7 @@ import com.codeminders.hidapi.*; /** * - * Driver to communicate with the keyboard device + * Driver to communicate with the keyboard device 1770 ff00 * using HIDAPI. * * @author Manzerbredes @@ -22,9 +22,14 @@ public class Driver_1770_ff00 implements Driver, DriverTypeA{ HIDDevice device; /** - * Define Keyboard color state + * Define Keyboard primary color state */ - private HashMap> keyboardColorsState=new HashMap<>(); + private HashMap> primaryColorsState=new HashMap<>(); + + /** + * Define Keyboard secondary color state (for wave) + */ + private HashMap> secondaryColorsState=new HashMap<>(); /** * Define Keyboard mode state @@ -41,8 +46,20 @@ public class Driver_1770_ff00 implements Driver, DriverTypeA{ try { HIDManager man=HIDManager.getInstance(); this.device=man.openById(0x1770, 0xff00, null); - if(this.device!=null) + if(this.device!=null){ + // 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; + // Return true (init successfully done) return true; + } } catch(Exception e){ System.err.println(e.getMessage()); @@ -52,7 +69,7 @@ public class Driver_1770_ff00 implements Driver, DriverTypeA{ /** - * Build a byte[] report + * Build a byte[] report for convenience. * * @param a * @param b @@ -77,7 +94,6 @@ public class Driver_1770_ff00 implements Driver, DriverTypeA{ try { this.device.sendFeatureReport(this.getReport(1,2,65,this.mode.intValue(),0,0,0,236)); } catch (IOException e) { - // TODO Auto-generated catch block e.printStackTrace(); } } @@ -88,9 +104,8 @@ public class Driver_1770_ff00 implements Driver, DriverTypeA{ try { this.device.sendFeatureReport(this.getReport(1,2,66,region.intValue(),color.intValue(),intensity.intValue(),0,236)); this.commit(); - this.keyboardColorsState.put(region, new Pair(color, intensity)); + this.primaryColorsState.put(region, new Pair(color, intensity)); } catch (IOException e) { - // TODO Auto-generated catch block e.printStackTrace(); } @@ -105,12 +120,11 @@ public class Driver_1770_ff00 implements Driver, DriverTypeA{ this.device.sendFeatureReport(this.getReport(1,2,66,Region.MIDDLE.intValue(),color.intValue(),intensity.intValue(),0,236)); this.device.sendFeatureReport(this.getReport(1,2,66,Region.RIGHT.intValue(),color.intValue(),intensity.intValue(),0,236)); this.commit(); - this.keyboardColorsState.put(Region.LEFT, new Pair(color, intensity)); - this.keyboardColorsState.put(Region.MIDDLE, new Pair(color, intensity)); - this.keyboardColorsState.put(Region.RIGHT, new Pair(color, intensity)); + this.primaryColorsState.put(Region.LEFT, new Pair(color, intensity)); + this.primaryColorsState.put(Region.MIDDLE, new Pair(color, intensity)); + this.primaryColorsState.put(Region.RIGHT, new Pair(color, intensity)); } catch (IOException e) { - // TODO Auto-generated catch block e.printStackTrace(); } @@ -120,6 +134,29 @@ public class Driver_1770_ff00 implements Driver, DriverTypeA{ @Override public void setMode(Mode mode) { this.mode=mode; + + // Apply wave mode + if(this.mode==Mode.WAVE){ + for(int i=0;i(color, intensity)); + this.secondaryColorsState.put(Region.MIDDLE, new Pair(color, intensity)); + this.secondaryColorsState.put(Region.RIGHT, new Pair(color, intensity)); + } + + + @Override + public void setSecondaryRegionColor(Region region, Color color, Intensity intensity) { + this.secondaryColorsState.put(region, new Pair(color, intensity)); + } + + + -- cgit v1.2.3