diff options
| author | manzerbredes <loic.guegan_secondary@yahoo.fr> | 2016-03-27 12:11:39 +0200 |
|---|---|---|
| committer | manzerbredes <loic.guegan_secondary@yahoo.fr> | 2016-03-27 12:11:39 +0200 |
| commit | 4263d0e02cee82099463ac1e1c9caea0e294a644 (patch) | |
| tree | fa21bf413c13d63d7187506a20039183cd655736 | |
| parent | 72dde0cd93375e94e9472505cc6e7289cd54c158 (diff) | |
Begin keyboard class
| -rw-r--r-- | src/device/Driver.java | 2 | ||||
| -rw-r--r-- | src/device/Keyboard.java | 54 |
2 files changed, 53 insertions, 3 deletions
diff --git a/src/device/Driver.java b/src/device/Driver.java index c6d5810..fe57fd7 100644 --- a/src/device/Driver.java +++ b/src/device/Driver.java @@ -154,7 +154,7 @@ public class Driver{ } - public void setColor(Color color, Intensity intensity, Region region){ + public void setColor(Region region, Color color, Intensity intensity){ try { this.device.sendFeatureReport(this.getReport(1,2,66,region.intValue(),color.intValue(),intensity.intValue(),0,236)); } catch (IOException e) { diff --git a/src/device/Keyboard.java b/src/device/Keyboard.java index 4a594f1..e311413 100644 --- a/src/device/Keyboard.java +++ b/src/device/Keyboard.java @@ -1,10 +1,60 @@ package org.manzerbredes.open_klm.device; -public class Keyboard{ - +import java.util.HashMap; +import org.manzerbredes.open_klm.device.Driver.*; +public class Keyboard{ + + /** + * Device driver + */ + private Driver device; + + /** + * Define Keyboard color state + */ + private HashMap<Region, Color> KeyboardColor=new HashMap<>(); + + /** + * Define Keyboard mode state + */ + private Mode mode=Mode.NORMAL; + /** + * Build a keyboard access + */ + public Keyboard(){ + try { + this.device=new Driver(); + } catch (InstantiationException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + /** + * + * Change global keyboard color + * + * @param color Color to apply + * @param intensity Intensity wanted + */ + public void setColor(Color color, Intensity intensity){ + // Save state + this.KeyboardColor.put(Region.LEFT, color); + this.KeyboardColor.put(Region.MIDDLE, color); + this.KeyboardColor.put(Region.RIGHT, color); + + // Set color + this.device.setColor(Region.LEFT, color, intensity); + this.device.setColor(Region.MIDDLE, color, intensity); + this.device.setColor(Region.RIGHT, color, intensity); + + // Apply color + this.device.commit(this.mode); + + } + }
\ No newline at end of file |
