summaryrefslogtreecommitdiff
path: root/src/drivers/Device_1770_ff00.java
diff options
context:
space:
mode:
authormanzerbredes <loic.guegan_secondary@yahoo.fr>2016-03-29 08:28:01 +0200
committermanzerbredes <loic.guegan_secondary@yahoo.fr>2016-03-29 08:28:01 +0200
commitfee23aed22ebdc81eb4d0d807f8d17712a71bb43 (patch)
tree29a413a567e3469d09795772c81754552bc7fca5 /src/drivers/Device_1770_ff00.java
parentd2115332a74eeac45c6324f4b41338b5a655de04 (diff)
Change project structure and driver modularity
Diffstat (limited to 'src/drivers/Device_1770_ff00.java')
-rw-r--r--src/drivers/Device_1770_ff00.java139
1 files changed, 0 insertions, 139 deletions
diff --git a/src/drivers/Device_1770_ff00.java b/src/drivers/Device_1770_ff00.java
deleted file mode 100644
index 77ee461..0000000
--- a/src/drivers/Device_1770_ff00.java
+++ /dev/null
@@ -1,139 +0,0 @@
-package org.manzerbredes.open_klm.drivers;
-
-import java.io.IOException;
-import java.util.HashMap;
-import org.javatuples.Pair;
-import com.codeminders.hidapi.*;
-
-
-/**
- *
- * Driver to communicate with the keyboard device
- * using HIDAPI.
- *
- * @author Manzerbredes
- *
- */
-public class Device_1770_ff00 implements DriverTypeA{
-
-
-
- /**
- * Device entry
- */
- HIDDevice device;
-
- /**
- * Define Keyboard color state
- */
- private HashMap<Region, Pair<Color,Intensity>> KeyboardColor=new HashMap<>();
-
- /**
- * Define Keyboard mode state
- */
- private Mode mode=Mode.NORMAL;
-
-
-
-
-
- /**
- * Init driver and HIDAPI library
- *
- * @throws InstantiationException
- */
- public Device_1770_ff00() throws InstantiationException{
- // Init HIDAPI Library
- com.codeminders.hidapi.ClassPathLibraryLoader.loadNativeHIDLibrary();
-
- // Try not bind the device
- try {
- HIDManager man=HIDManager.getInstance();
- this.device=man.openById(0x1770, 0xff00, null);
- if(this.device==null)
- throw new Exception();
- }
- catch(Exception e){
- throw new InstantiationException("Failed to instanciate driver. Device not found or permission denied (try as root)");
- }
-
- }
-
-
- /**
- * Build a byte[] report
- *
- * @param a
- * @param b
- * @param c
- * @param d
- * @param e
- * @param f
- * @param g
- * @param h
- * @return
- */
- private byte[] getReport(int a, int b, int c, int d, int e, int f, int g, int h){
- byte[] message = new byte[8];
- message[0] = (byte) a;
- message[1] = (byte) b;
- message[2] = (byte) c;
- message[3] = (byte) d;
- message[4] = (byte) e;
- message[5] = (byte) f;
- message[6] = (byte) g;
- message[7] = (byte) h;
- return message;
- }
-
-
-
-
-
-
- private void commit(){
- 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();
- }
- }
-
-
- @Override
- public void setRegionColor(Region region, Color color, Intensity intensity) {
- try {
- this.device.sendFeatureReport(this.getReport(1,2,66,region.intValue(),color.intValue(),intensity.intValue(),0,236));
- this.commit();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
-
- }
-
-
- @Override
- public void setColor(Color color, Intensity intensity) {
- try {
- this.device.sendFeatureReport(this.getReport(1,2,66,Region.LEFT.intValue(),color.intValue(),intensity.intValue(),0,236));
- 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();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- }
-
-
- @Override
- public void setMode(Mode mode) {
- this.mode=mode;
- this.commit();
- }
-
-} \ No newline at end of file