diff --git a/${project.build.directory}/classes/application.properties b/${project.build.directory}/classes/application.properties
new file mode 100644
index 0000000..508d8da
--- /dev/null
+++ b/${project.build.directory}/classes/application.properties
@@ -0,0 +1 @@
+spring.application.name=dualsensgui
diff --git a/${project.build.directory}/classes/bzh/risotto/dualsensgui/Command.class b/${project.build.directory}/classes/bzh/risotto/dualsensgui/Command.class
new file mode 100644
index 0000000..1024863
Binary files /dev/null and b/${project.build.directory}/classes/bzh/risotto/dualsensgui/Command.class differ
diff --git a/${project.build.directory}/classes/bzh/risotto/dualsensgui/DualsensController.class b/${project.build.directory}/classes/bzh/risotto/dualsensgui/DualsensController.class
new file mode 100644
index 0000000..ea95fb0
Binary files /dev/null and b/${project.build.directory}/classes/bzh/risotto/dualsensgui/DualsensController.class differ
diff --git a/${project.build.directory}/classes/bzh/risotto/dualsensgui/DualsensguiApplication.class b/${project.build.directory}/classes/bzh/risotto/dualsensgui/DualsensguiApplication.class
new file mode 100644
index 0000000..fc36d47
Binary files /dev/null and b/${project.build.directory}/classes/bzh/risotto/dualsensgui/DualsensguiApplication.class differ
diff --git a/${project.build.directory}/classes/bzh/risotto/dualsensgui/enums/MicrophoneLedState$1.class b/${project.build.directory}/classes/bzh/risotto/dualsensgui/enums/MicrophoneLedState$1.class
new file mode 100644
index 0000000..8d46f91
Binary files /dev/null and b/${project.build.directory}/classes/bzh/risotto/dualsensgui/enums/MicrophoneLedState$1.class differ
diff --git a/${project.build.directory}/classes/bzh/risotto/dualsensgui/enums/MicrophoneLedState$2.class b/${project.build.directory}/classes/bzh/risotto/dualsensgui/enums/MicrophoneLedState$2.class
new file mode 100644
index 0000000..31e9cad
Binary files /dev/null and b/${project.build.directory}/classes/bzh/risotto/dualsensgui/enums/MicrophoneLedState$2.class differ
diff --git a/${project.build.directory}/classes/bzh/risotto/dualsensgui/enums/MicrophoneLedState$3.class b/${project.build.directory}/classes/bzh/risotto/dualsensgui/enums/MicrophoneLedState$3.class
new file mode 100644
index 0000000..a8dd4ba
Binary files /dev/null and b/${project.build.directory}/classes/bzh/risotto/dualsensgui/enums/MicrophoneLedState$3.class differ
diff --git a/${project.build.directory}/classes/bzh/risotto/dualsensgui/enums/MicrophoneLedState.class b/${project.build.directory}/classes/bzh/risotto/dualsensgui/enums/MicrophoneLedState.class
new file mode 100644
index 0000000..8a2fed9
Binary files /dev/null and b/${project.build.directory}/classes/bzh/risotto/dualsensgui/enums/MicrophoneLedState.class differ
diff --git a/${project.build.directory}/classes/bzh/risotto/dualsensgui/enums/MicrophoneModeState$1.class b/${project.build.directory}/classes/bzh/risotto/dualsensgui/enums/MicrophoneModeState$1.class
new file mode 100644
index 0000000..7991f4a
Binary files /dev/null and b/${project.build.directory}/classes/bzh/risotto/dualsensgui/enums/MicrophoneModeState$1.class differ
diff --git a/${project.build.directory}/classes/bzh/risotto/dualsensgui/enums/MicrophoneModeState$2.class b/${project.build.directory}/classes/bzh/risotto/dualsensgui/enums/MicrophoneModeState$2.class
new file mode 100644
index 0000000..1822183
Binary files /dev/null and b/${project.build.directory}/classes/bzh/risotto/dualsensgui/enums/MicrophoneModeState$2.class differ
diff --git a/${project.build.directory}/classes/bzh/risotto/dualsensgui/enums/MicrophoneModeState$3.class b/${project.build.directory}/classes/bzh/risotto/dualsensgui/enums/MicrophoneModeState$3.class
new file mode 100644
index 0000000..f733672
Binary files /dev/null and b/${project.build.directory}/classes/bzh/risotto/dualsensgui/enums/MicrophoneModeState$3.class differ
diff --git a/${project.build.directory}/classes/bzh/risotto/dualsensgui/enums/MicrophoneModeState.class b/${project.build.directory}/classes/bzh/risotto/dualsensgui/enums/MicrophoneModeState.class
new file mode 100644
index 0000000..6c31c27
Binary files /dev/null and b/${project.build.directory}/classes/bzh/risotto/dualsensgui/enums/MicrophoneModeState.class differ
diff --git a/${project.build.directory}/classes/bzh/risotto/dualsensgui/enums/SpeakerState$1.class b/${project.build.directory}/classes/bzh/risotto/dualsensgui/enums/SpeakerState$1.class
new file mode 100644
index 0000000..b71e963
Binary files /dev/null and b/${project.build.directory}/classes/bzh/risotto/dualsensgui/enums/SpeakerState$1.class differ
diff --git a/${project.build.directory}/classes/bzh/risotto/dualsensgui/enums/SpeakerState$2.class b/${project.build.directory}/classes/bzh/risotto/dualsensgui/enums/SpeakerState$2.class
new file mode 100644
index 0000000..63ac04d
Binary files /dev/null and b/${project.build.directory}/classes/bzh/risotto/dualsensgui/enums/SpeakerState$2.class differ
diff --git a/${project.build.directory}/classes/bzh/risotto/dualsensgui/enums/SpeakerState$3.class b/${project.build.directory}/classes/bzh/risotto/dualsensgui/enums/SpeakerState$3.class
new file mode 100644
index 0000000..a3021a2
Binary files /dev/null and b/${project.build.directory}/classes/bzh/risotto/dualsensgui/enums/SpeakerState$3.class differ
diff --git a/${project.build.directory}/classes/bzh/risotto/dualsensgui/enums/SpeakerState.class b/${project.build.directory}/classes/bzh/risotto/dualsensgui/enums/SpeakerState.class
new file mode 100644
index 0000000..185cc62
Binary files /dev/null and b/${project.build.directory}/classes/bzh/risotto/dualsensgui/enums/SpeakerState.class differ
diff --git a/${project.build.directory}/classes/bzh/risotto/dualsensgui/enums/Trigger$1.class b/${project.build.directory}/classes/bzh/risotto/dualsensgui/enums/Trigger$1.class
new file mode 100644
index 0000000..2d88b3e
Binary files /dev/null and b/${project.build.directory}/classes/bzh/risotto/dualsensgui/enums/Trigger$1.class differ
diff --git a/${project.build.directory}/classes/bzh/risotto/dualsensgui/enums/Trigger$2.class b/${project.build.directory}/classes/bzh/risotto/dualsensgui/enums/Trigger$2.class
new file mode 100644
index 0000000..6edba37
Binary files /dev/null and b/${project.build.directory}/classes/bzh/risotto/dualsensgui/enums/Trigger$2.class differ
diff --git a/${project.build.directory}/classes/bzh/risotto/dualsensgui/enums/Trigger$3.class b/${project.build.directory}/classes/bzh/risotto/dualsensgui/enums/Trigger$3.class
new file mode 100644
index 0000000..8de098e
Binary files /dev/null and b/${project.build.directory}/classes/bzh/risotto/dualsensgui/enums/Trigger$3.class differ
diff --git a/${project.build.directory}/classes/bzh/risotto/dualsensgui/enums/Trigger.class b/${project.build.directory}/classes/bzh/risotto/dualsensgui/enums/Trigger.class
new file mode 100644
index 0000000..7e3cbb2
Binary files /dev/null and b/${project.build.directory}/classes/bzh/risotto/dualsensgui/enums/Trigger.class differ
diff --git a/${project.build.directory}/classes/bzh/risotto/dualsensgui/exception/OutOufBoundException.class b/${project.build.directory}/classes/bzh/risotto/dualsensgui/exception/OutOufBoundException.class
new file mode 100644
index 0000000..7a6729a
Binary files /dev/null and b/${project.build.directory}/classes/bzh/risotto/dualsensgui/exception/OutOufBoundException.class differ
diff --git a/${project.build.directory}/classes/log4j2.xml b/${project.build.directory}/classes/log4j2.xml
new file mode 100644
index 0000000..6ff0743
--- /dev/null
+++ b/${project.build.directory}/classes/log4j2.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/${project.build.directory}/classes/main/resources/application.properties b/${project.build.directory}/classes/main/resources/application.properties
new file mode 100644
index 0000000..508d8da
--- /dev/null
+++ b/${project.build.directory}/classes/main/resources/application.properties
@@ -0,0 +1 @@
+spring.application.name=dualsensgui
diff --git a/${project.build.directory}/classes/main/resources/log4j2.xml b/${project.build.directory}/classes/main/resources/log4j2.xml
new file mode 100644
index 0000000..6ff0743
--- /dev/null
+++ b/${project.build.directory}/classes/main/resources/log4j2.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/bzh/risotto/dualsensgui/Command.java b/src/main/java/bzh/risotto/dualsensgui/Command.java
new file mode 100644
index 0000000..a42475c
--- /dev/null
+++ b/src/main/java/bzh/risotto/dualsensgui/Command.java
@@ -0,0 +1,45 @@
+package bzh.risotto.dualsensgui;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+
+public class Command {
+
+ private static final Logger logger = LogManager.getLogger(Command.class);
+
+ private Command() {
+
+ }
+
+ public static String run(String command) {
+
+ StringBuilder res = new StringBuilder();
+
+ command = "dualsensectl " + command;
+ String[] commandParts = command.split(" ");
+
+ logger.info("executing command: {}", command);
+ try {
+ ProcessBuilder processBuilder = new ProcessBuilder(commandParts);
+ processBuilder.redirectErrorStream(true);
+ Process process = processBuilder.start();
+
+ BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
+ String line;
+ while ((line = reader.readLine()) != null) {
+ res.append(line);
+ }
+ process.waitFor();
+ } catch (Exception e) {
+
+ logger.error("Error while executing command: {}", command, e);
+ }
+
+ logger.debug(res);
+
+ return res.toString();
+ }
+}
diff --git a/src/main/java/bzh/risotto/dualsensgui/DualsensController.java b/src/main/java/bzh/risotto/dualsensgui/DualsensController.java
index d36f78c..f4731be 100644
--- a/src/main/java/bzh/risotto/dualsensgui/DualsensController.java
+++ b/src/main/java/bzh/risotto/dualsensgui/DualsensController.java
@@ -1,8 +1,10 @@
package bzh.risotto.dualsensgui;
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-
+import bzh.risotto.dualsensgui.enums.MicrophoneLedState;
+import bzh.risotto.dualsensgui.enums.MicrophoneModeState;
+import bzh.risotto.dualsensgui.enums.SpeakerState;
+import bzh.risotto.dualsensgui.enums.Trigger;
+import bzh.risotto.dualsensgui.exception.OutOufBoundException;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -15,41 +17,147 @@ public class DualsensController {
}
+ //info Get the controller firmware info
+
+ /**
+ * get the state of the battery
+ *
+ * @return the battery level
+ */
public int getBattery() {
- String res = run("battery");
+ String res = Command.run("battery");
String value = res.split(" ")[0];
return Integer.parseInt(value);
}
+ // lightbar STATE Enable (on) or disable (off) lightbar
+ public void enableLightbar() {
+ Command.run("lightbar on");
+
+ logger.info("lighbar enabled");
+ }
+
+ public void disableLightbar() {
+ Command.run("lightbar off");
+
+ logger.info("lighbar disabled");
+ }
+
+ // lightbar RED GREEN BLUE [BRIGHTNESS] Set lightbar color and brightness (0-255)
+ public void setLighbarColor(int red, int green, int blue) {
+ isBetween(red, 0, 255);
+ isBetween(green, 0, 255);
+ isBetween(blue, 0, 255);
+
+ Command.run("lightbar " + red + " " + green + " " + blue);
+
+ logger.info("lighbar color set to: R {}, G {}, B {}", red, green, blue);
+ }
+
+ public void setLighbarColor(int red, int green, int blue, int brightness) {
+ isBetween(red, 0, 255);
+ isBetween(green, 0, 255);
+ isBetween(blue, 0, 255);
+ isBetween(brightness, 0, 255);
+
+ Command.run("lightbar " + red + " " + green + " " + blue + " " + brightness);
+
+ logger.info("lighbar color set to: R {}, G {}, B {}, Brightness {}", red, green, blue, brightness);
+ }
+
+ // led-brightness NUMBER Set player and microphone LED dimming (0-2)
+ public void setLedBrightness(int brightness) {
+ isBetween(brightness, 0, 2);
+
+ Command.run("led-brightness " + brightness);
+ logger.info("led brightness set to: {}", brightness);
+ }
+
+ // player-leds NUMBER [instant] Set player LEDs (1-7) or disabled (0)
+ public void setLed(int playerLed) {
+ isBetween(playerLed, 0, 7);
+
+ Command.run("player-leds " + playerLed);
+ logger.info("player leds set to: {}", playerLed);
+ }
+
+ public void disableLed() {
+ Command.run("player-leds 0" );
+ logger.info("player leds disabled");
+ }
+
+ // microphone STATE Enable (on) or disable (off) microphone
+ public void enableMicrophone() {
+ Command.run("microphone on");
+ logger.info("microphone enabled");
+ }
+
+ public void disableMicrophone() {
+ Command.run("microphone off");
+ logger.info("microphone disabled");
+ }
+
+ // microphone-led STATE Enable (on), disable (off) or pulsate (pulse) microphone LED
+ public void setMicrophoneLed(MicrophoneLedState state) {
+ Command.run("microphone " + state);
+ logger.info("microphone led state set to: {}", state);
+ }
+
+ // microphone-mode STATE Toggle microphone usage to 'chat', 'asr' or 'both'
+ public void setMicrophoneMod(MicrophoneModeState state) {
+ Command.run("microphone-mode " + state);
+ logger.info("microphone mode set to: {}", state);
+ }
+
+ // microphone-volume VOLUME Set microphone volume (0-255)
+ public void setMicrophoneVolume(int volume) {
+ Command.run("microphone-volume " + volume);
+ logger.info("microphone volume set to: {}", volume);
+ }
+
+ // speaker STATE Toggle to 'internal' speaker, 'headphone' or 'both'
+ public void setSpeakerState(SpeakerState state) {
+ Command.run("speaker " + state);
+ logger.info("speaker state set to: {}", state );
+ }
+ // volume VOLUME Set audio volume (0-255) of internal speaker and headphone
+ public void setSpeakerVolume(int volume) {
+ isBetween(volume, 0, 255);
+ Command.run("volume " + volume);
+ logger.info("volume set to: {}", volume);
+
+ }
+
+ // attenuation RUMBLE TRIGGER Set the attenuation (0-7) of rumble/haptic motors and trigger vibration
+
+ // trigger TRIGGER off remove all effects
+
+ // trigger TRIGGER feedback POSITION STRENGTH set a resistance starting at position with a defined strength
public void setFeedback(Trigger trigger, int position, int strength) {
- run("trigger " + trigger + " feedback " + position + " " + strength);
+ Command.run("trigger " + trigger + " feedback " + position + " " + strength);
}
- private String run(String command) {
+ // trigger TRIGGER weapon START STOP STRENGTH Emulate weapon like gun trigger
- StringBuilder res = new StringBuilder();
+ // trigger TRIGGER bow START STOP STRENGTH SNAPFORCE Emulate weapon like bow
- command = "dualsensectl " + command;
- String[] commandParts = command.split(" ");
- try {
- ProcessBuilder processBuilder = new ProcessBuilder(commandParts);
- processBuilder.redirectErrorStream(true);
- Process process = processBuilder.start();
+ // trigger TRIGGER galloping START STOP FIRST_FOOT SECOND_FOOT FREQUENCY Emulate a galloping
- BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
- String line;
- while ((line = reader.readLine()) != null) {
- res.append(line);
- }
- process.waitFor();
- } catch (Exception e) {
+ // trigger TRIGGER machine START STOP STRENGTH_A STRENGTH_B FREQUENCY PERIOD Switch vibration between to strength at a specified period
- logger.error("Error while executing command: {}", command, e);
- }
+ // trigger TRIGGER vibration POSITION AMPLITUDE FREQUENCY Vibrates motor arm around specified position
- return res.toString();
- }
+ // trigger TRIGGER feedback-raw STRENGTH[10] set a resistance starting using array of strength
+
+ // trigger TRIGGER vibration-raw AMPLITUDE[10] FREQUENCY Vibrates motor arm at position and strength specified by an array of amplitude
+
+ // trigger TRIGGER MODE [PARAMS] set the trigger (left, right or both) mode with parameters (up to 9)
+
+ // monitor [add COMMAND] [remove COMMAND] Run shell command COMMAND on add/remove events
+
+
+ // power-off Turn off the controller (BT only)
public static DualsensController getController() {
@@ -59,4 +167,12 @@ public class DualsensController {
return dualsensController;
}
+
+ private boolean isBetween(int number, int start, int stop) {
+ if (number < start || number > stop) {
+ throw new OutOufBoundException(number, start, stop);
+ }
+
+ return true;
+ }
}
diff --git a/src/main/java/bzh/risotto/dualsensgui/DualsensguiApplication.java b/src/main/java/bzh/risotto/dualsensgui/DualsensguiApplication.java
index 5f7ccea..3c2729f 100644
--- a/src/main/java/bzh/risotto/dualsensgui/DualsensguiApplication.java
+++ b/src/main/java/bzh/risotto/dualsensgui/DualsensguiApplication.java
@@ -1,11 +1,8 @@
package bzh.risotto.dualsensgui;
-import org.springframework.boot.SpringApplication;
+import bzh.risotto.dualsensgui.enums.Trigger;
import org.springframework.boot.autoconfigure.SpringBootApplication;
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-
@SpringBootApplication
public class DualsensguiApplication {
@@ -16,6 +13,7 @@ public class DualsensguiApplication {
System.out.println(battery);
controller.setFeedback(Trigger.LEFT, 1, 1);
+ controller.setLighbarColor(255, 0, 150);
//SpringApplication.run(DualsensguiApplication.class, args);
}
diff --git a/src/main/java/bzh/risotto/dualsensgui/enums/MicrophoneLedState.java b/src/main/java/bzh/risotto/dualsensgui/enums/MicrophoneLedState.java
new file mode 100644
index 0000000..5003ba3
--- /dev/null
+++ b/src/main/java/bzh/risotto/dualsensgui/enums/MicrophoneLedState.java
@@ -0,0 +1,23 @@
+package bzh.risotto.dualsensgui.enums;
+
+public enum MicrophoneLedState {
+ ENABLE{
+ @Override
+ public String toString() {
+ return "on";
+ }
+ },
+ DISABLE {
+ @Override
+ public String toString() {
+ return "off";
+ }
+ },
+ PULSE {
+ @Override
+ public String toString() {
+ return "pulse";
+ }
+ }
+
+}
diff --git a/src/main/java/bzh/risotto/dualsensgui/enums/MicrophoneModeState.java b/src/main/java/bzh/risotto/dualsensgui/enums/MicrophoneModeState.java
new file mode 100644
index 0000000..a0e5358
--- /dev/null
+++ b/src/main/java/bzh/risotto/dualsensgui/enums/MicrophoneModeState.java
@@ -0,0 +1,22 @@
+package bzh.risotto.dualsensgui.enums;
+
+public enum MicrophoneModeState {
+ CHAT {
+ @Override
+ public String toString() {
+ return "chat";
+ }
+ },
+ ASR {
+ @Override
+ public String toString() {
+ return "asr";
+ }
+ },
+ BOTH {
+ @Override
+ public String toString() {
+ return "both";
+ }
+ }
+}
diff --git a/src/main/java/bzh/risotto/dualsensgui/enums/SpeakerState.java b/src/main/java/bzh/risotto/dualsensgui/enums/SpeakerState.java
new file mode 100644
index 0000000..719f781
--- /dev/null
+++ b/src/main/java/bzh/risotto/dualsensgui/enums/SpeakerState.java
@@ -0,0 +1,22 @@
+package bzh.risotto.dualsensgui.enums;
+
+public enum SpeakerState {
+ INTERNAL {
+ @Override
+ public String toString() {
+ return "internal";
+ }
+ },
+ HEADPHONE {
+ @Override
+ public String toString() {
+ return "headphone";
+ }
+ },
+ BOTH {
+ @Override
+ public String toString() {
+ return "both";
+ }
+ },
+}
diff --git a/src/main/java/bzh/risotto/dualsensgui/Trigger.java b/src/main/java/bzh/risotto/dualsensgui/enums/Trigger.java
similarity index 89%
rename from src/main/java/bzh/risotto/dualsensgui/Trigger.java
rename to src/main/java/bzh/risotto/dualsensgui/enums/Trigger.java
index b52ab5d..55db1a1 100644
--- a/src/main/java/bzh/risotto/dualsensgui/Trigger.java
+++ b/src/main/java/bzh/risotto/dualsensgui/enums/Trigger.java
@@ -1,4 +1,4 @@
-package bzh.risotto.dualsensgui;
+package bzh.risotto.dualsensgui.enums;
public enum Trigger {
LEFT {
diff --git a/src/main/java/bzh/risotto/dualsensgui/exception/OutOufBoundException.java b/src/main/java/bzh/risotto/dualsensgui/exception/OutOufBoundException.java
new file mode 100644
index 0000000..79ab498
--- /dev/null
+++ b/src/main/java/bzh/risotto/dualsensgui/exception/OutOufBoundException.java
@@ -0,0 +1,12 @@
+package bzh.risotto.dualsensgui.exception;
+
+public class OutOufBoundException extends RuntimeException {
+
+ public OutOufBoundException(int value, int start, int stop) {
+ super("Value: " + value + " is out off bound (" + start + "-" + stop + ")");
+ }
+
+ public OutOufBoundException(String message) {
+ super(message);
+ }
+}