diff --git a/README.md b/README.md
index ff0b474..91386fc 100644
--- a/README.md
+++ b/README.md
@@ -50,4 +50,9 @@ Want to support development? Make a donation* (see below):
*Legal information:
* [EN] Please note! This is non-commercial application. Any received money considered as a gift.
-* [RU] Пожалуйста обратите внимание! Это некоммерческое приложение. Перечисляя средства вы совершаете дарение.
\ No newline at end of file
+* [RU] Пожалуйста обратите внимание! Это некоммерческое приложение. Перечисляя средства вы совершаете дарение.
+
+#### TODO
+[ ] Tray support
+[ ] Headless mode (CLI)
+[ ] Dark theme
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index c81797d..6fa8e6f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
loper
LogiLed
- 0.2-SNAPSHOT
+ 0.3-SNAPSHOT
diff --git a/src/main/java/logiled/Controllers/MainController.java b/src/main/java/logiled/Controllers/MainController.java
index 70b2863..c163c13 100644
--- a/src/main/java/logiled/Controllers/MainController.java
+++ b/src/main/java/logiled/Controllers/MainController.java
@@ -1,5 +1,6 @@
package logiled.Controllers;
+import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.*;
@@ -52,20 +53,25 @@ public class MainController implements Initializable {
HashMap> rules = KeysLedsController.getRules();
if (rules == null)
return;
+ applyBtn.setDisable(true);
KeyLedThread keyLedThread = new KeyLedThread(rules);
+ keyLedThread.setOnSucceeded(EventHandler -> applyBtn.setDisable(false)); // <- I guess this shit never fails
Thread commThread = new Thread(keyLedThread);
commThread.setDaemon(true);
commThread.start();
}
else if (MainTabPane.getSelectionModel().getSelectedItem().getId().equals("EffectsTab")) {
+ applyBtn.setDisable(true);
EffectsThread effectsThread = new EffectsThread(EffectsController.getEffect());
+ effectsThread.setOnSucceeded(EventHandler -> applyBtn.setDisable(false));
Thread commThread = new Thread(effectsThread);
commThread.setDaemon(true);
commThread.start();
}
else { // Consider as GameMode; refactor in case more tabs added.
- List disKeysList = GameModeController.getKeys();
- GameModeThread gameModeThread = new GameModeThread(disKeysList);
+ applyBtn.setDisable(true);
+ GameModeThread gameModeThread = new GameModeThread(GameModeController.getKeys());
+ gameModeThread.setOnSucceeded(EventHandler -> applyBtn.setDisable(false));
Thread commThread = new Thread(gameModeThread);
commThread.setDaemon(true);
commThread.start();
diff --git a/src/main/java/logiled/MainFx.java b/src/main/java/logiled/MainFx.java
index fa08ac9..1618b1f 100644
--- a/src/main/java/logiled/MainFx.java
+++ b/src/main/java/logiled/MainFx.java
@@ -11,7 +11,7 @@ import java.util.Locale;
import java.util.ResourceBundle;
public class MainFx extends Application {
- public static final String appVersion = "v0.2";
+ public static final String appVersion = "v0.3";
@Override
public void start(Stage primaryStage) throws Exception{
diff --git a/src/main/java/logiled/USB/EffectsThread.java b/src/main/java/logiled/USB/EffectsThread.java
index 2c20b8c..facb07b 100644
--- a/src/main/java/logiled/USB/EffectsThread.java
+++ b/src/main/java/logiled/USB/EffectsThread.java
@@ -5,7 +5,7 @@ import logiled.MessagesConsumer;
import java.util.HashMap;
-public class EffectsThread extends LoThread implements Runnable{
+public class EffectsThread extends LoThread {
private byte[] command;
@@ -49,16 +49,15 @@ public class EffectsThread extends LoThread implements Runnable{
command = effectWaveEdgeToCenter(effectData);
}
}
-
@Override
- public void run() {
+ protected Void call() throws Exception {
if (command == null)
- return;
+ return null;
UsbConnect usbConnect = new UsbConnect();
if (!usbConnect.isConnected())
- return;
+ return null;
handler = usbConnect.getHandlerKbrd();
@@ -66,6 +65,7 @@ public class EffectsThread extends LoThread implements Runnable{
MessagesConsumer.getInstance().inform("Complete!");
usbConnect.close();
+ return null;
}
private byte[] effectDisable(){
diff --git a/src/main/java/logiled/USB/GameModeThread.java b/src/main/java/logiled/USB/GameModeThread.java
index 39b65f9..f31645c 100644
--- a/src/main/java/logiled/USB/GameModeThread.java
+++ b/src/main/java/logiled/USB/GameModeThread.java
@@ -8,7 +8,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-public class GameModeThread extends LoThread implements Runnable{
+public class GameModeThread extends LoThread{
private static final byte[] game_key_prepare = {
0x11, (byte) 0xff, 0x03, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -48,11 +48,11 @@ public class GameModeThread extends LoThread implements Runnable{
}
@Override
- public void run() {
+ protected Void call() throws Exception {
UsbConnect usbConnect = new UsbConnect();
if (!usbConnect.isConnected())
- return;
+ return null;
handler = usbConnect.getHandlerKbrd();
@@ -68,5 +68,6 @@ public class GameModeThread extends LoThread implements Runnable{
MessagesConsumer.getInstance().inform("Complete!");
usbConnect.close();
+ return null;
}
}
diff --git a/src/main/java/logiled/USB/KeyLedThread.java b/src/main/java/logiled/USB/KeyLedThread.java
index 218a1fe..04fdb7e 100644
--- a/src/main/java/logiled/USB/KeyLedThread.java
+++ b/src/main/java/logiled/USB/KeyLedThread.java
@@ -1,5 +1,6 @@
package logiled.USB;
+import javafx.concurrent.Task;
import logiled.MessagesConsumer;
import java.util.ArrayList;
@@ -7,7 +8,7 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
-public class KeyLedThread extends LoThread implements Runnable{
+public class KeyLedThread extends LoThread {
// Keys and indicators individual settings
private static final byte[] commit = {
0x11, (byte) 0xff, 0x0c, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -77,15 +78,15 @@ public class KeyLedThread extends LoThread implements Runnable{
}
@Override
- public void run() {
+ protected Void call() throws Exception {
// If no commands in the query, then nothing to do
if (keyLedCommands.size() == 0)
- return;
+ return null;
UsbConnect usbConnect = new UsbConnect();
if (!usbConnect.isConnected())
- return;
+ return null;
handler = usbConnect.getHandlerKbrd();
@@ -101,6 +102,6 @@ public class KeyLedThread extends LoThread implements Runnable{
MessagesConsumer.getInstance().inform("Complete!");
usbConnect.close();
+ return null;
}
-
}
\ No newline at end of file
diff --git a/src/main/java/logiled/USB/LoThread.java b/src/main/java/logiled/USB/LoThread.java
index 6b777fb..307aa9a 100644
--- a/src/main/java/logiled/USB/LoThread.java
+++ b/src/main/java/logiled/USB/LoThread.java
@@ -1,5 +1,6 @@
package logiled.USB;
+import javafx.concurrent.Task;
import logiled.MessagesConsumer;
import org.usb4java.DeviceHandle;
import org.usb4java.LibUsb;
@@ -7,7 +8,7 @@ import org.usb4java.LibUsb;
import java.nio.ByteBuffer;
import java.nio.IntBuffer;
-abstract class LoThread {
+abstract class LoThread extends Task {
DeviceHandle handler;