From f20ac83c378211b8ca966ddcf590d5bbb36ec6a3 Mon Sep 17 00:00:00 2001 From: Dmitry Isaenko Date: Mon, 14 Oct 2019 02:44:43 +0300 Subject: [PATCH] Some things for effects support --- .idea/vcs.xml | 6 + .../java/logiled/About/AboutController.java | 2 +- .../Controllers/EffectsController.java | 20 ++++ ...ontroller.java => KeysLedsController.java} | 27 +++-- .../logiled/Controllers/MainController.java | 33 ++++-- src/main/java/logiled/MainFx.java | 4 +- src/main/java/logiled/USB/Communications.java | 103 +++++++++++++++++- src/main/resources/AboutLayout.fxml | 2 +- src/main/resources/EffectsPane.fxml | 97 +++++++++++++++++ .../{KbrdPane.fxml => KeysLedsPane.fxml} | 2 +- src/main/resources/Main.fxml | 85 +++++++++++++-- src/main/resources/light.css | 4 +- src/main/resources/locale.properties | 13 ++- src/main/resources/locale_rus.properties | 11 ++ 14 files changed, 363 insertions(+), 46 deletions(-) create mode 100644 .idea/vcs.xml create mode 100644 src/main/java/logiled/Controllers/EffectsController.java rename src/main/java/logiled/Controllers/{KbrdController.java => KeysLedsController.java} (76%) create mode 100644 src/main/resources/EffectsPane.fxml rename src/main/resources/{KbrdPane.fxml => KeysLedsPane.fxml} (99%) diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/main/java/logiled/About/AboutController.java b/src/main/java/logiled/About/AboutController.java index c33dd8a..4386af7 100644 --- a/src/main/java/logiled/About/AboutController.java +++ b/src/main/java/logiled/About/AboutController.java @@ -46,7 +46,7 @@ public class AboutController implements Initializable { }); gitHubHLink.setOnAction(ActionEvent-> { try { - hs.showDocument("https://github.com/developersu/LoLed"); + hs.showDocument("https://github.com/developersu/LogiLed"); } catch (Exception ignored){} // No luck for linux =( }); blogspotHLink.setOnAction(ActionEvent-> { diff --git a/src/main/java/logiled/Controllers/EffectsController.java b/src/main/java/logiled/Controllers/EffectsController.java new file mode 100644 index 0000000..36411aa --- /dev/null +++ b/src/main/java/logiled/Controllers/EffectsController.java @@ -0,0 +1,20 @@ +package logiled.Controllers; + +import javafx.fxml.FXML; +import javafx.fxml.Initializable; +import javafx.scene.control.ToggleGroup; + +import java.net.URL; +import java.util.ResourceBundle; + +public class EffectsController implements Initializable { + + @FXML + private ToggleGroup effectsToggleGrp; + + @Override + public void initialize(URL url, ResourceBundle resourceBundle) { + + } + +} \ No newline at end of file diff --git a/src/main/java/logiled/Controllers/KbrdController.java b/src/main/java/logiled/Controllers/KeysLedsController.java similarity index 76% rename from src/main/java/logiled/Controllers/KbrdController.java rename to src/main/java/logiled/Controllers/KeysLedsController.java index f023e72..bcd03dc 100644 --- a/src/main/java/logiled/Controllers/KbrdController.java +++ b/src/main/java/logiled/Controllers/KeysLedsController.java @@ -14,7 +14,7 @@ import java.util.HashMap; import java.util.List; import java.util.ResourceBundle; -public class KbrdController implements Initializable { +public class KeysLedsController implements Initializable { @FXML private Button @@ -36,19 +36,16 @@ public class KbrdController implements Initializable { @Override public void initialize(URL url, ResourceBundle resourceBundle) { - rulesVBox.getChildren().addListener(new ListChangeListener() { - @Override - public void onChanged(Change change) { - change.next(); // Get changes - if (change.wasAdded()){ // If something added, turn on ability to remove such rule - remRuleBtn.setDisable(false); - return; - } // Otherwise, check if we have anything inside the pane - if (rulesVBox.getChildren().isEmpty()) // If so, select latest available 'box' - remRuleBtn.setDisable(true); - else // If the pane is empty, disable 'Remove' button. - RuleBox.select((RuleBox) rulesVBox.getChildren().get(rulesVBox.getChildren().size()-1)); - } + rulesVBox.getChildren().addListener((ListChangeListener) change -> { + change.next(); // Get changes + if (change.wasAdded()){ // If something added, turn on ability to remove such rule + remRuleBtn.setDisable(false); + return; + } // Otherwise, check if we have anything inside the pane + if (rulesVBox.getChildren().isEmpty()) // If so, select latest available 'box' + remRuleBtn.setDisable(true); + else // If the pane is empty, disable 'Remove' button. + RuleBox.select((RuleBox) rulesVBox.getChildren().get(rulesVBox.getChildren().size()-1)); }); addRuleBtn.setOnAction(ActionEvent -> rulesVBox.getChildren().add(new RuleBox())); @@ -89,6 +86,8 @@ public class KbrdController implements Initializable { if (ledSingleRuleSet != null) ledSet.add(ledSingleRuleSet); } + if (keySet.size() == 0 && ledSet.size() == 0) + return null; set.put("Key", keySet); set.put("Led", ledSet); return set; diff --git a/src/main/java/logiled/Controllers/MainController.java b/src/main/java/logiled/Controllers/MainController.java index cb3bf44..bdbb6db 100644 --- a/src/main/java/logiled/Controllers/MainController.java +++ b/src/main/java/logiled/Controllers/MainController.java @@ -2,20 +2,29 @@ package logiled.Controllers; import javafx.fxml.FXML; import javafx.fxml.Initializable; -import javafx.scene.control.Button; -import javafx.scene.control.Label; -import javafx.scene.control.MenuItem; +import javafx.scene.control.*; import logiled.About.AboutWindow; import logiled.MessagesConsumer; import logiled.USB.Communications; import java.net.URL; +import java.util.HashMap; +import java.util.List; import java.util.ResourceBundle; public class MainController implements Initializable { @FXML - private KbrdController KbrdPaneController; + private KeysLedsController KeysLedsController; + @FXML + private EffectsController EffectsController; + + @FXML + private TabPane MainTabPane; + /* + @FXML + private Tab KeyLedTab, EffectsTab; + */ @FXML private Button applyBtn; @@ -24,6 +33,8 @@ public class MainController implements Initializable { @FXML private MenuItem aboutMenuItem; + + @Override public void initialize(URL url, ResourceBundle resourceBundle) { aboutMenuItem.setOnAction(actionEvent -> new AboutWindow()); @@ -31,10 +42,16 @@ public class MainController implements Initializable { MessagesConsumer.getInstance().start(); applyBtn.setOnAction(actionEvent -> { - Communications communications = new Communications(KbrdPaneController.getRules()); - Thread commThread = new Thread(communications); - commThread.setDaemon(true); - commThread.start(); + if (MainTabPane.getSelectionModel().getSelectedItem().getId().equals("KeyLedTab")) { + HashMap> rules = KeysLedsController.getRules(); + if (rules == null) + return; + Communications communications = new Communications(rules); + Thread commThread = new Thread(communications); + commThread.setDaemon(true); + commThread.start(); + } + //else if (MainTabPane.getSelectionModel().getSelectedItem().getId().equals("EffectsTab")) { // todo } }); } } diff --git a/src/main/java/logiled/MainFx.java b/src/main/java/logiled/MainFx.java index 09ad9c7..5ac05b9 100644 --- a/src/main/java/logiled/MainFx.java +++ b/src/main/java/logiled/MainFx.java @@ -36,9 +36,9 @@ public class MainFx extends Application { ); primaryStage.setTitle("LogiLed "+appVersion); - primaryStage.setMinWidth(1160); + primaryStage.setMinWidth(1215); primaryStage.setMinHeight(550); - Scene mainScene = new Scene(root, 1160, 525); + Scene mainScene = new Scene(root, 1215, 525); mainScene.getStylesheets().add("/light.css"); primaryStage.setScene(mainScene); primaryStage.show(); diff --git a/src/main/java/logiled/USB/Communications.java b/src/main/java/logiled/USB/Communications.java index 00884be..47cc89d 100644 --- a/src/main/java/logiled/USB/Communications.java +++ b/src/main/java/logiled/USB/Communications.java @@ -12,30 +12,98 @@ import java.util.HashMap; import java.util.List; public class Communications implements Runnable{ - + // 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, 0x00, 0x00, 0x00, 0x00 }; private static final byte[] indicators = { // we have 2 leds on G513 + // KEY RED GRN BLU -//- 0x12, (byte) 0xff, 0x0c, 0x3a, 0x00, 0x40, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; private static final byte[] keys = { // Can store 14 rules + // LED RED GRN BLU -//- 0x12, (byte) 0xff, 0x0c, 0x3a, 0x00, 0x01, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + // -========= Effects =========- + private static final byte[] disable_colors = { + 0x11, (byte) 0xff, 0x0d, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00 + }; + private static final byte[] constant_color = { + // RED GRN BLU + 0x11, (byte) 0xff, 0x0d, 0x3c, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00 + }; + private static final byte[] wave_horizontal = { + // !! !! + 0x11, (byte) 0xff, 0x0d, 0x3c, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x64, 0x00, + 0x00, 0x00, 0x00, 0x00 + }; + private static final byte[] wave_vertical = { + // !! !! + 0x11, (byte) 0xff, 0x0d, 0x3c, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x64, 0x00, + 0x00, 0x00, 0x00, 0x00 + }; + private static final byte[] wave_center_to_edge = { + // !! !! + 0x11, (byte) 0xff, 0x0d, 0x3c, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x64, 0x00, + 0x00, 0x00, 0x00, 0x00 + }; + private static final byte[] wave_horizontal_reverse = { + // !! !! + 0x11, (byte) 0xff, 0x0d, 0x3c, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x64, 0x00, + 0x00, 0x00, 0x00, 0x00 + }; + private static final byte[] wave_vertical_reverse = { + // !! !! + 0x11, (byte) 0xff, 0x0d, 0x3c, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x64, 0x00, + 0x00, 0x00, 0x00, 0x00 + }; + private static final byte[] wave_edge_to_center = { + // !! !! + 0x11, (byte) 0xff, 0x0d, 0x3c, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x64, 0x00, + 0x00, 0x00, 0x00, 0x00 + }; + private static final byte[] cycle = { + // !! !! + 0x11, (byte) 0xff, 0x0d, 0x3c, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00 + }; + private static final byte[] breathe = { + // RED GRN BLU !! !! + 0x11, (byte) 0xff, 0x0d, 0x3c, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00 + }; + private static final byte[] cirles_on_press = { + // RED GRN BLU ms + 0x11, (byte) 0xff, 0x0d, 0x3c, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00 + }; + + // Game-key settings + //private static final byte[] game_key_rule + private static final byte[] game_key_set_default = { + 0x11, (byte) 0xff, 0x03, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00 + }; private DeviceHandle handler; // What would be sent to keyboard private List keyLedCommands; + /** + * Used to set keys & leds + * @param keyLedSet : set of rules, always not empty and not null + * */ public Communications(HashMap> keyLedSet){ keyLedCommands = new ArrayList<>(); @@ -71,9 +139,8 @@ public class Communications implements Runnable{ if (appendTo > 8) keyLedCommands.add(Arrays.copyOfRange(command, 0, command.length)); - // If any command has been added to chain, add commit command to the end - if (keyLedCommands.size() > 0) - keyLedCommands.add(commit); + // Add commit command to the end + keyLedCommands.add(commit); } @Override @@ -128,3 +195,31 @@ public class Communications implements Runnable{ return false; } } +/* + ANY + 0x11, 0xff, ???, 0x3c + + waves + cwave + !! !! + 0x11, 0xff, 0x0d, 0x3c, 0x00, 0x04, 0x56, 0x00 0x00, ----, ----, ----, ----, ====, 0x64, ????, ?!!?, 0x00, 0x00, 0x00 + + hwave + vwave + !! !! + 0x11, 0xff, 0x0d, 0x3c, 0x00, 0x04, 0x55, 0x00 0x00, ----, ----, ----, ----, ====, 0x64, ????, ?!!?, 0x00, 0x00, 0x00 + + cycle + !! !! + 0x11, 0xff, 0x0d, 0x3c, 0x00, 0x03, 0x55, 0x00 0x00, ----, ----, ----, ----, 0x00, 0x64, ????, ?!!?, 0x00, 0x00, 0x00 + + breathing + + 0x11, 0xff, 0x0d, 0x3c, 0x00, 0x02, RED_, GRN_, BLU_ ----, ----, ----, ----, 0x00, 0x64, ????, ?!!?, 0x00, 0x00, 0x00 + +---------------------- + hwave - new + 11 ff 0d 3c 00 04 00 00 00 00 00 00 e8 06 64 03 00 00 00 00 + + +* */ \ No newline at end of file diff --git a/src/main/resources/AboutLayout.fxml b/src/main/resources/AboutLayout.fxml index c395594..ac2d061 100644 --- a/src/main/resources/AboutLayout.fxml +++ b/src/main/resources/AboutLayout.fxml @@ -34,7 +34,7 @@ - + diff --git a/src/main/resources/EffectsPane.fxml b/src/main/resources/EffectsPane.fxml new file mode 100644 index 0000000..48a2bc0 --- /dev/null +++ b/src/main/resources/EffectsPane.fxml @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/KbrdPane.fxml b/src/main/resources/KeysLedsPane.fxml similarity index 99% rename from src/main/resources/KbrdPane.fxml rename to src/main/resources/KeysLedsPane.fxml index a5e74d0..b37ed80 100644 --- a/src/main/resources/KbrdPane.fxml +++ b/src/main/resources/KeysLedsPane.fxml @@ -13,7 +13,7 @@ - + diff --git a/src/main/resources/Main.fxml b/src/main/resources/Main.fxml index 92c0ec0..891af10 100644 --- a/src/main/resources/Main.fxml +++ b/src/main/resources/Main.fxml @@ -7,8 +7,12 @@ + + + + + - @@ -19,12 +23,44 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + @@ -55,17 +91,42 @@
- - - + + + + + + - + + + + + + + + + + + + + + + + + +
diff --git a/src/main/resources/light.css b/src/main/resources/light.css index 3f61c01..da23df0 100644 --- a/src/main/resources/light.css +++ b/src/main/resources/light.css @@ -116,10 +116,10 @@ -fx-fill: #2c2c2c; } .tab-pane .tab:selected SVGPath, .tab-pane .tab:selected:hover SVGPath{ - -fx-fill: #289de8; + -fx-fill: #141414; } .tab-pane .tab:hover SVGPath{ - -fx-fill: #1c6fa2; + -fx-fill: #2b2b2b; } .tab-pane .tab{ -fx-background-color: #fefefe; diff --git a/src/main/resources/locale.properties b/src/main/resources/locale.properties index 123ea9a..d1f53f5 100644 --- a/src/main/resources/locale.properties +++ b/src/main/resources/locale.properties @@ -680,5 +680,16 @@ into proprietary programs. If your program is a subroutine library, you\n\ may consider it more useful to permit linking proprietary applications with\n\ the library. If this is what you want to do, use the GNU Lesser General\n\ Public License instead of this License. But first, please read\n\ -.\n +. menu_item_about=About +effect_disable=Disable backlight +effect_constant=Constant color +effect_breath=Breath +effect_cirles_on_press=Circles on press +effect_cycle=Cycle +effect_wave_horizontal=Wave horizontal +effect_wave_vertical=Wave vertical +effect_wave_center_to_edge=Wave from center to edges +effect_wave_horizontal_reverse=Wave horizontal (reverse) +effect_wave_vertical_reverse=Wave vertical (reverse) +effect_wave_edge_to_center=Wave from edges to center diff --git a/src/main/resources/locale_rus.properties b/src/main/resources/locale_rus.properties index 1c972fc..021cf0a 100644 --- a/src/main/resources/locale_rus.properties +++ b/src/main/resources/locale_rus.properties @@ -8,3 +8,14 @@ about_LicenseLbl=Лицензионное соглашение about_Lbl_3=Разработано и поддерживается Дмитрием Исаенко. menu_item_about=О приложении about_Lbl_1=LoLed распространяется по условиям лицензии GNU GPLv3. +effect_disable=Отключить подсветку +effect_constant=Постоянный цвет +effect_breath=Дыхание +effect_cirles_on_press=Круги при нажатии +effect_cycle=Цикл +effect_wave_horizontal=Волна по-горизонтали +effect_wave_horizontal_reverse=Волна по-горизонтали (обратная) +effect_wave_vertical=Волна вертикальная +effect_wave_vertical_reverse=Волна вертикальная (обратная) +effect_wave_center_to_edge=Волна от центра к краям +effect_wave_edge_to_center=Волна от краёв к центру