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
|
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;
/**
* Keyboard State
*/
private KeyboardState state;
/**
* Build a keyboard access
*
* @throws InstantiationException Throw if failed to instanciate driver
*/
public Keyboard() throws InstantiationException{
this.device=new Driver();
this.state=new KeyboardState();
}
/**
*
* Change global keyboard color
*
* @param color Color to apply
* @param intensity Intensity wanted
*/
public void setColor(Color color, Intensity intensity){
//Save state
this.state.setColor(color, intensity);
// 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.state.getMode());
}
/**
*
* 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.state.setRegionColor(region, color, intensity);
// Set color
this.device.setColor(region, color, intensity);
// Apply color
this.device.commit(this.state.getMode());
}
}
|