diff options
Diffstat (limited to 'src/drivers')
| -rw-r--r-- | src/drivers/DriverTypeA.java | 16 | ||||
| -rw-r--r-- | src/drivers/Driver_1770_ff00.java | 76 |
2 files changed, 79 insertions, 13 deletions
diff --git a/src/drivers/DriverTypeA.java b/src/drivers/DriverTypeA.java index a1166ee..4ad936e 100644 --- a/src/drivers/DriverTypeA.java +++ b/src/drivers/DriverTypeA.java @@ -92,7 +92,6 @@ public interface DriverTypeA{ } - /** * Set color of the region * @param region @@ -109,6 +108,21 @@ public interface DriverTypeA{ public void setColor(Color color, Intensity intensity); /** + * Set global secondary color (for waves) + * @param color + * @param intensity + */ + public void setSecondaryColor(Color color, Intensity intensity); + + /** + * Set secondary color (for waves) by region + * @param region + * @param color + * @param intensity + */ + public void setSecondaryRegionColor(Region region, Color color, Intensity intensity); + + /** * Set keyboard mode * @param mode */ 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<Region, Pair<Color,Intensity>> keyboardColorsState=new HashMap<>(); + private HashMap<Region, Pair<Color,Intensity>> primaryColorsState=new HashMap<>(); + + /** + * Define Keyboard secondary color state (for wave) + */ + private HashMap<Region, Pair<Color,Intensity>> 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<DriverTypeA.Color, DriverTypeA.Intensity>(Color.OFF, Intensity.HIGH)); + this.primaryColorsState.put(Region.MIDDLE, new Pair<DriverTypeA.Color, DriverTypeA.Intensity>(Color.OFF, Intensity.HIGH)); + this.primaryColorsState.put(Region.RIGHT, new Pair<DriverTypeA.Color, DriverTypeA.Intensity>(Color.OFF, Intensity.HIGH)); + // Init secondary color state + this.secondaryColorsState.put(Region.LEFT, new Pair<DriverTypeA.Color, DriverTypeA.Intensity>(Color.OFF, Intensity.LOW)); + this.secondaryColorsState.put(Region.MIDDLE, new Pair<DriverTypeA.Color, DriverTypeA.Intensity>(Color.OFF, Intensity.LOW)); + this.secondaryColorsState.put(Region.RIGHT, new Pair<DriverTypeA.Color, DriverTypeA.Intensity>(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<DriverTypeA.Color, DriverTypeA.Intensity>(color, intensity)); + this.primaryColorsState.put(region, new Pair<DriverTypeA.Color, DriverTypeA.Intensity>(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<DriverTypeA.Color, DriverTypeA.Intensity>(color, intensity)); - this.keyboardColorsState.put(Region.MIDDLE, new Pair<DriverTypeA.Color, DriverTypeA.Intensity>(color, intensity)); - this.keyboardColorsState.put(Region.RIGHT, new Pair<DriverTypeA.Color, DriverTypeA.Intensity>(color, intensity)); + this.primaryColorsState.put(Region.LEFT, new Pair<DriverTypeA.Color, DriverTypeA.Intensity>(color, intensity)); + this.primaryColorsState.put(Region.MIDDLE, new Pair<DriverTypeA.Color, DriverTypeA.Intensity>(color, intensity)); + this.primaryColorsState.put(Region.RIGHT, new Pair<DriverTypeA.Color, DriverTypeA.Intensity>(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<Region.values().length;i++){ + int entry=i*3; // 3 entry for each region (left:1,2,3 -- middle:4,5,6 -- right:7,8,9) + try { + // Set primary color (with 2 of intensity for speed problem) + // TODO Check intensity (fixed for speed) : + this.device.sendFeatureReport(this.getReport(1,2,67,entry+1 ,this.primaryColorsState.get(Region.values()[i]).getValue0().intValue(),2,0,236)); + // Set secondary color + this.device.sendFeatureReport(this.getReport(1,2,67,entry+2 ,this.secondaryColorsState.get(Region.values()[i]).getValue0().intValue(),this.secondaryColorsState.get(Region.values()[i]).getValue1().intValue(),0,236)); + // Set period + // TODO Check period : + this.device.sendFeatureReport(this.getReport(1,2,67,entry+3 ,2,2,0,236)); + + } catch (IOException e) { + e.printStackTrace(); + } + + } + } + + // Apply mode this.commit(); } @@ -130,6 +167,21 @@ public class Driver_1770_ff00 implements Driver, DriverTypeA{ } + @Override + public void setSecondaryColor(Color color, Intensity intensity) { + this.secondaryColorsState.put(Region.LEFT, new Pair<DriverTypeA.Color, DriverTypeA.Intensity>(color, intensity)); + this.secondaryColorsState.put(Region.MIDDLE, new Pair<DriverTypeA.Color, DriverTypeA.Intensity>(color, intensity)); + this.secondaryColorsState.put(Region.RIGHT, new Pair<DriverTypeA.Color, DriverTypeA.Intensity>(color, intensity)); + } + + + @Override + public void setSecondaryRegionColor(Region region, Color color, Intensity intensity) { + this.secondaryColorsState.put(region, new Pair<DriverTypeA.Color, DriverTypeA.Intensity>(color, intensity)); + } + + + |
