From 4263d0e02cee82099463ac1e1c9caea0e294a644 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Sun, 27 Mar 2016 12:11:39 +0200 Subject: Begin keyboard class --- src/device/Keyboard.java | 54 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) (limited to 'src/device/Keyboard.java') 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 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 -- cgit v1.2.3