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

add comments to controller classes

parent 07002bf8
No related branches found
No related tags found
2 merge requests!65Prototype,!52Feature addmacros
......@@ -4,6 +4,9 @@ import java.util.HashMap;
import java.util.Map;
public final class KeyConversion {
/**
* key map to convert from the keylistener keycodes to the windows keycodes
*/
public static final HashMap<Integer, Integer> map = new HashMap<Integer, Integer>(){
{
put(0x0000, 0x07); // UNDEFINED
......
......@@ -8,14 +8,17 @@ import static Controller.KeyConversion.map;
import static ui.MainScreen.dict;
public class KeyListener implements NativeKeyListener {
/**
* empty constructor
*/
public KeyListener(){}
@Override
public void nativeKeyPressed(NativeKeyEvent nativeKeyEvent) {
//if key pressed is in dictionary
try{
OSInterface.getInstance().sendKey(dict.get(map.get(nativeKeyEvent.getKeyCode())), true);
} catch(Exception e) {
System.out.println(map.get(nativeKeyEvent.getKeyCode()));
} catch(Exception ignored) {
}
}
......
......@@ -14,26 +14,42 @@ import java.util.logging.Level;
import java.util.logging.LogManager;
import java.util.logging.Logger;
public class RunHotkeys implements Runnable {
/**
* allows the stopping of the key listener
*/
boolean stop = false;
/**
* Creates a new keylistener
* @throws NativeHookException
*/
public RunHotkeys() throws NativeHookException {
GlobalScreen.registerNativeHook();
GlobalScreen.addNativeKeyListener(new KeyListener());
LogManager.getLogManager().reset();
// Get the logger for "org.jnativehook" and set the level to off.
Logger logger = Logger.getLogger(GlobalScreen.class.getPackage().getName());
logger.setLevel(Level.OFF);
GlobalScreen.registerNativeHook();
GlobalScreen.addNativeKeyListener(new KeyListener());
}
/**
* run until stoppage
*/
public void run() {
while (!stop) {
}
}
public void stop() {
/**
* stop the key listener
*/
public void stop() {
stop = true;
}
......
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