Skip to content
Snippets Groups Projects
Commit 7324ecbd authored by Dallin Nickel (djn011)'s avatar Dallin Nickel (djn011)
Browse files

Gets all saved hotkeys again upon reopening the program

parent da460d22
No related branches found
No related tags found
2 merge requests!65Prototype,!61Feature implement profiles
...@@ -27,7 +27,7 @@ public class Action { ...@@ -27,7 +27,7 @@ public class Action {
public void preformAction(){ public void preformAction(){
//for each keycode in the list, preform it //for each keycode in the list, preform it
for(Integer keyCode:this.getKeys()){ for(Integer keyCode:this.getKeys()){
OSInterface.getInstance().sendKey(keyCode, true); OSInterface.getInstance().sendKey(keyCode, false);
} }
} }
} }
\ No newline at end of file
...@@ -23,7 +23,6 @@ public class KeyListener implements NativeKeyListener { ...@@ -23,7 +23,6 @@ public class KeyListener implements NativeKeyListener {
checkActive check = new checkActive(); checkActive check = new checkActive();
if (check.CheckActive().hasHotkey(map.get(nativeKeyEvent.getKeyCode()))) if (check.CheckActive().hasHotkey(map.get(nativeKeyEvent.getKeyCode())))
check.CheckActive().getHotKey(map.get(nativeKeyEvent.getKeyCode())).preformAction(); check.CheckActive().getHotKey(map.get(nativeKeyEvent.getKeyCode())).preformAction();
System.out.println(check.CheckActive().HKeys);
} }
......
package Controller; //package Controller;
//
import model.OSInterface; //import model.OSInterface;
//
public class mouseAction { //public class mouseAction {
//L = left // //L = left
//R = right // //R = right
//D = down // //D = down
//U = up // //U = up
public String direction; // public String direction;
public mouseAction(String dir){ // public mouseAction(String dir){
this.direction = dir; // this.direction = dir;
} // }
//
/** // /**
* Get the direction of the mouseAction // * Get the direction of the mouseAction
*/ // */
public String getDirection(){ // public String getDirection(){
return this.direction; // return this.direction;
} // }
//
/** // /**
* Move the mouse accordingly based on its direction // * Move the mouse accordingly based on its direction
*/ // */
public void preformAction(){ // public void preformAction(){
//If its R move 5 pixels to the right // //If its R move 5 pixels to the right
if(this.direction.equals("R")){ // if(this.direction.equals("R")){
OSInterface.getInstance().moveMouse(5,0); // OSInterface.getInstance().moveMouse(5,0);
} // }
//If it L move 5 pixels to the left // //If it L move 5 pixels to the left
else if(this.direction.equals("L")){ // else if(this.direction.equals("L")){
OSInterface.getInstance().moveMouse(-5,0); // OSInterface.getInstance().moveMouse(-5,0);
} // }
//If it is U move 5 pixels up // //If it is U move 5 pixels up
else if(this.direction.equals("U")){ // else if(this.direction.equals("U")){
OSInterface.getInstance().moveMouse(0,5); // OSInterface.getInstance().moveMouse(0,5);
} // }
//If it is D move 5 pixels down // //If it is D move 5 pixels down
else if(this.direction.equals("D")){ // else if(this.direction.equals("D")){
OSInterface.getInstance().moveMouse(0,-5); // OSInterface.getInstance().moveMouse(0,-5);
} // }
} // }
} //}
package model; //package model;
//
import Controller.mouseAction; //import Controller.mouseAction;
//
public class mouseEmulator{ //public class mouseEmulator{
protected int keyCode; // protected int keyCode;
protected int id; // protected int id;
protected final mouseAction action; // protected final mouseAction action;
//
public mouseEmulator(String dir, int keycode, int id ) { // public mouseEmulator(String dir, int keycode, int id ) {
this.action = new mouseAction(dir); // this.action = new mouseAction(dir);
this.keyCode = keycode; // this.keyCode = keycode;
this.id = id; // this.id = id;
} // }
/** // /**
* Gets the virtual keyCode. // * Gets the virtual keyCode.
*/ // */
public int getKeyCode() { // public int getKeyCode() {
return keyCode; // return keyCode;
} // }
//
/** // /**
* Gets the unique ID. // * Gets the unique ID.
*/ // */
public int getID() { // public int getID() {
return id; // return id;
} // }
} //}
...@@ -69,13 +69,14 @@ public class saveEverything { ...@@ -69,13 +69,14 @@ public class saveEverything {
//Go through each hotkey in the profile and add it to the database //Go through each hotkey in the profile and add it to the database
//To the correct profile //To the correct profile
for (JsonElement profileHotkey : profileHotkeys) { for (JsonElement profileHotkey : profileHotkeys) {
//Get the hotkey values //Get the hotkey values
JsonObject theHotKeyValues = (JsonObject) profileHotkey; JsonObject theHotKeyValues = (JsonObject) profileHotkey;
//Create a new addHotkey value //Create a new addHotkey value
addHotkey addHK = new addHotkey(); addHotkey addHK = new addHotkey();
//Get all our values from the JSON object //Get all our values from the JSON object
int KeyCode = theHotKeyValues.get("KeyCode").getAsInt(); int KeyCode = theHotKeyValues.get("KeyCode").getAsInt();
JsonArray hotkeys = theHotKeyValues.get("HotKeys").getAsJsonArray(); JsonArray hotkeys = theHotKeyValues.get("Actions").getAsJsonArray();
ArrayList<Integer> actions = new ArrayList<>(); ArrayList<Integer> actions = new ArrayList<>();
if (hotkeys != null){ if (hotkeys != null){
for (int i = 0; i<hotkeys.size(); i++){ for (int i = 0; i<hotkeys.size(); i++){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment