summaryrefslogtreecommitdiff
path: root/src/device/Keyboard.java
blob: 4acf4a15b9d4e1608446f0c96bee20176cce8b55 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package org.manzerbredes.open_klm.device;

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);

	}
	
	/**
	 * 
	 * Change region keyboard color
	 * 
	 * @param region Region to apply the color
	 * @param color Color to apply
	 * @param intensity Intensity wanted
	 */
	public void setRegionColor(Region region, Color color, Intensity intensity){
		// Save state
		this.KeyboardColor.put(region, color);
		
		// Set color
		this.device.setColor(region, color, intensity);
		
		// Apply color
		this.device.commit(this.mode);

	}
	
}