package kaka.cakelight;
+import org.jnativehook.GlobalScreen;
+import org.jnativehook.NativeHookException;
+import org.jnativehook.keyboard.NativeKeyAdapter;
+import org.jnativehook.keyboard.NativeKeyEvent;
+import org.jnativehook.mouse.NativeMouseEvent;
+import org.jnativehook.mouse.NativeMouseMotionAdapter;
+
public class CakeLight {
private Configuration config;
private Mode mode;
public void startLoop() {
Console.start(this, config);
+ initNativeHook();
// TODO
// FrameGrabber grabber = FrameGrabber.from(config);
// grabber.prepare();
// saveFile(data, "/home/kaka/test.img");
}
+ private void initNativeHook() {
+ try {
+ GlobalScreen.registerNativeHook();
+ GlobalScreen.addNativeKeyListener(new NativeKeyAdapter() {
+ @Override
+ public void nativeKeyPressed(NativeKeyEvent e) {
+ System.out.println("key code = " + e.getKeyCode() + ", key text = '" + NativeKeyEvent.getKeyText(e.getKeyCode()) + "'");
+ }
+ });
+ GlobalScreen.addNativeMouseMotionListener(new NativeMouseMotionAdapter() {
+ @Override
+ public void nativeMouseMoved(NativeMouseEvent e) {
+ System.out.println("mouse point = " + e.getPoint());
+ }
+ });
+ } catch (NativeHookException e) {
+ e.printStackTrace();
+ }
+ }
+
public void turnOff() {
cleanup();
ledController.onFrame(LedFrame.from(config).fillColor(0, 0, 0));