Mechanisme van devices tot applicaties gecontroleerd, gerepareerd en uitgetest: Panel en Jintellitype -> Winamp.
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
log4j.rootLogger=DEBUG, CA
|
log4j.rootLogger=TRACE, CA
|
||||||
log4j.appender.CA=org.apache.log4j.ConsoleAppender
|
log4j.appender.CA=org.apache.log4j.ConsoleAppender
|
||||||
log4j.appender.CA.layout=org.apache.log4j.PatternLayout
|
log4j.appender.CA.layout=org.apache.log4j.PatternLayout
|
||||||
log4j.appender.CA.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
|
log4j.appender.CA.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
|
||||||
@@ -1,8 +1,11 @@
|
|||||||
package mimis;
|
package mimis;
|
||||||
|
|
||||||
import mimis.event.EventHandler;
|
import mimis.event.EventHandler;
|
||||||
|
import mimis.event.Task;
|
||||||
|
import mimis.exception.WorkerException;
|
||||||
import mimis.exception.worker.DeactivateException;
|
import mimis.exception.worker.DeactivateException;
|
||||||
import mimis.manager.Titled;
|
import mimis.manager.Titled;
|
||||||
|
import mimis.value.Action;
|
||||||
|
|
||||||
public abstract class Application extends EventHandler implements Titled, Exitable {
|
public abstract class Application extends EventHandler implements Titled, Exitable {
|
||||||
protected String title;
|
protected String title;
|
||||||
@@ -10,13 +13,34 @@ public abstract class Application extends EventHandler implements Titled, Exitab
|
|||||||
|
|
||||||
public Application(String title) {
|
public Application(String title) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
active = false;
|
//initialise();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String title() {
|
public String title() {
|
||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void add(Event event) {
|
||||||
|
if (event instanceof Task) {
|
||||||
|
Task task = (Task) event;
|
||||||
|
Action action = task.getAction();
|
||||||
|
switch (action) {
|
||||||
|
case ACTIVATE:
|
||||||
|
try {
|
||||||
|
if (active()) {
|
||||||
|
deactivate();
|
||||||
|
} else {
|
||||||
|
activate();
|
||||||
|
}
|
||||||
|
} catch (WorkerException e) {
|
||||||
|
log.error(e);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
super.event(event);
|
||||||
|
}
|
||||||
|
|
||||||
public void stop() {
|
public void stop() {
|
||||||
if (active()) {
|
if (active()) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import mimis.event.EventHandler;
|
|||||||
import mimis.event.Task;
|
import mimis.event.Task;
|
||||||
import mimis.event.task.Continuous;
|
import mimis.event.task.Continuous;
|
||||||
import mimis.event.task.Stopper;
|
import mimis.event.task.Stopper;
|
||||||
|
import mimis.exception.worker.ActivateException;
|
||||||
import mimis.exception.worker.DeactivateException;
|
import mimis.exception.worker.DeactivateException;
|
||||||
import mimis.macro.Sequence;
|
import mimis.macro.Sequence;
|
||||||
import mimis.macro.SequenceListener;
|
import mimis.macro.SequenceListener;
|
||||||
@@ -15,21 +16,15 @@ import mimis.manager.Titled;
|
|||||||
|
|
||||||
public abstract class Device extends EventHandler implements Titled, Exitable {
|
public abstract class Device extends EventHandler implements Titled, Exitable {
|
||||||
protected String title;
|
protected String title;
|
||||||
protected boolean active;
|
|
||||||
protected SequenceListener sequenceListener;
|
protected SequenceListener sequenceListener;
|
||||||
|
|
||||||
static {
|
|
||||||
SequenceListener.initialise(eventRouter);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Device(String title) {
|
public Device(String title) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start() {
|
public void activate() throws ActivateException {
|
||||||
log.fatal("start");
|
super.activate();
|
||||||
sequenceListener = new SequenceListener(this);
|
sequenceListener = new SequenceListener(this);
|
||||||
super.start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Register macro's */
|
/* Register macro's */
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ import java.awt.GridLayout;
|
|||||||
import java.awt.TextArea;
|
import java.awt.TextArea;
|
||||||
import java.awt.event.WindowEvent;
|
import java.awt.event.WindowEvent;
|
||||||
|
|
||||||
|
import javax.swing.JButton;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JToggleButton;
|
|
||||||
import javax.swing.SwingConstants;
|
import javax.swing.SwingConstants;
|
||||||
import javax.swing.WindowConstants;
|
import javax.swing.WindowConstants;
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ public class GUI extends JFrame {
|
|||||||
protected JPanel createManagerPanel(Manager<?> manager, String title) {
|
protected JPanel createManagerPanel(Manager<?> manager, String title) {
|
||||||
JPanel panel = new JPanel(new GridLayout(0, 1));
|
JPanel panel = new JPanel(new GridLayout(0, 1));
|
||||||
panel.add(new JLabel(title, SwingConstants.CENTER));
|
panel.add(new JLabel(title, SwingConstants.CENTER));
|
||||||
for (JToggleButton button : manager.getButtons()) {
|
for (JButton button : manager.getButtons()) {
|
||||||
panel.add(button);
|
panel.add(button);
|
||||||
}
|
}
|
||||||
return panel;
|
return panel;
|
||||||
@@ -84,7 +84,11 @@ public class GUI extends JFrame {
|
|||||||
public void write(String string) {
|
public void write(String string) {
|
||||||
textArea.append(string);
|
textArea.append(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void writeLine(String string) {
|
||||||
|
write(string + "\n");
|
||||||
|
}
|
||||||
|
|
||||||
public void clear() {
|
public void clear() {
|
||||||
textArea.setText(null);
|
textArea.setText(null);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import mimis.exception.worker.ActivateException;
|
|||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
protected Log log = LogFactory.getLog(getClass());
|
protected Log log = LogFactory.getLog(getClass());
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import java.util.Calendar;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.swing.JToggleButton;
|
import javax.swing.JButton;
|
||||||
|
|
||||||
import mimis.manager.SelectButton;
|
import mimis.manager.SelectButton;
|
||||||
import mimis.manager.Titled;
|
import mimis.manager.Titled;
|
||||||
@@ -19,10 +19,6 @@ public class Manager<T extends Worker & Titled & Exitable> extends Worker {
|
|||||||
|
|
||||||
protected T[] manageableArray;
|
protected T[] manageableArray;
|
||||||
protected Map<T, SelectButton<T>> buttonMap;
|
protected Map<T, SelectButton<T>> buttonMap;
|
||||||
|
|
||||||
public Manager(String title) {
|
|
||||||
log.debug("Manager constructed");
|
|
||||||
}
|
|
||||||
|
|
||||||
public Manager(T[] manageableArray) {
|
public Manager(T[] manageableArray) {
|
||||||
this.manageableArray = manageableArray;
|
this.manageableArray = manageableArray;
|
||||||
@@ -30,7 +26,6 @@ public class Manager<T extends Worker & Titled & Exitable> extends Worker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void stop() {
|
public void stop() {
|
||||||
super.stop();
|
|
||||||
for (T manageable : manageableArray) {
|
for (T manageable : manageableArray) {
|
||||||
manageable.stop();
|
manageable.stop();
|
||||||
}
|
}
|
||||||
@@ -45,15 +40,17 @@ public class Manager<T extends Worker & Titled & Exitable> extends Worker {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected JToggleButton[] getButtons() {
|
protected JButton[] getButtons() {
|
||||||
return buttonMap.values().toArray(new JToggleButton[]{});
|
return buttonMap.values().toArray(new JButton[]{});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void work() {
|
protected void work() {
|
||||||
long before = Calendar.getInstance().getTimeInMillis();
|
long before = Calendar.getInstance().getTimeInMillis();
|
||||||
for (T manageable : manageableArray) {
|
for (T manageable : manageableArray) {
|
||||||
boolean active = manageable.active();
|
boolean active = manageable.active();
|
||||||
buttonMap.get(manageable).setPressed(active);
|
//buttonMap.get(manageable).getModel().setArmed(active);
|
||||||
|
|
||||||
|
buttonMap.get(manageable).getModel().setPressed(active);
|
||||||
}
|
}
|
||||||
long after = Calendar.getInstance().getTimeInMillis();
|
long after = Calendar.getInstance().getTimeInMillis();
|
||||||
int sleep = INTERVAL - (int) (after - before);
|
int sleep = INTERVAL - (int) (after - before);
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import mimis.event.EventRouter;
|
|||||||
import mimis.event.Feedback;
|
import mimis.event.Feedback;
|
||||||
import mimis.exception.worker.ActivateException;
|
import mimis.exception.worker.ActivateException;
|
||||||
import mimis.feedback.TextFeedback;
|
import mimis.feedback.TextFeedback;
|
||||||
|
import mimis.macro.SequenceListener;
|
||||||
import mimis.util.ArrayCycle;
|
import mimis.util.ArrayCycle;
|
||||||
import mimis.value.Action;
|
import mimis.value.Action;
|
||||||
|
|
||||||
@@ -35,16 +36,28 @@ public class Mimis extends EventHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Mimis(EventRouter eventRouter, Application[] applicationArray, Device[] deviceArray) {
|
public Mimis(EventRouter eventRouter, Application[] applicationArray, Device[] deviceArray) {
|
||||||
EventHandler.initialise(eventRouter);
|
|
||||||
applicationManager = new Manager<Application>(applicationArray);
|
|
||||||
deviceManager = new Manager<Device>(deviceArray);
|
|
||||||
|
|
||||||
this.applicationArray = applicationArray;
|
this.applicationArray = applicationArray;
|
||||||
this.deviceArray = deviceArray;
|
this.deviceArray = deviceArray;
|
||||||
applicationCycle = new ArrayCycle<Application>(applicationArray);
|
applicationCycle = new ArrayCycle<Application>(applicationArray);
|
||||||
|
|
||||||
|
log.debug("Initialise EventHandler and SequenceListener");
|
||||||
|
EventHandler.initialise(eventRouter);
|
||||||
|
SequenceListener.initialise(eventRouter);
|
||||||
|
|
||||||
|
log.debug("Add EventListeners to EventRouter");
|
||||||
|
eventRouter.add(this);
|
||||||
|
eventRouter.add(applicationArray);
|
||||||
|
eventRouter.add(deviceArray);
|
||||||
|
|
||||||
|
log.debug("Create managers");
|
||||||
|
applicationManager = new Manager<Application>(applicationArray);
|
||||||
|
deviceManager = new Manager<Device>(deviceArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void activate() throws ActivateException {
|
public void activate() throws ActivateException {
|
||||||
|
log.debug("Activate event router");
|
||||||
|
eventRouter.activate();
|
||||||
|
|
||||||
log.debug("Activate managers");
|
log.debug("Activate managers");
|
||||||
applicationManager.activate();
|
applicationManager.activate();
|
||||||
deviceManager.activate();
|
deviceManager.activate();
|
||||||
@@ -85,10 +98,10 @@ public class Mimis extends EventHandler {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void feedback(Feedback feedback) {
|
protected void feedback(Feedback feedback) {
|
||||||
if (feedback instanceof TextFeedback) {
|
if (feedback instanceof TextFeedback) {
|
||||||
gui.write(((TextFeedback) feedback).getText());
|
gui.writeLine(((TextFeedback) feedback).getText());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ public abstract class Worker implements Runnable {
|
|||||||
protected boolean active = false;
|
protected boolean active = false;
|
||||||
|
|
||||||
public void start(boolean thread) {
|
public void start(boolean thread) {
|
||||||
log.trace("Start");
|
|
||||||
running = true;
|
running = true;
|
||||||
if (thread) {
|
if (thread) {
|
||||||
log.debug("Start thread");
|
log.debug("Start thread");
|
||||||
@@ -69,10 +68,10 @@ public abstract class Worker implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void activate(boolean thread) {
|
public void activate(boolean thread) {
|
||||||
|
active = true;
|
||||||
if (!running) {
|
if (!running) {
|
||||||
start(thread);
|
start(thread);
|
||||||
}
|
}
|
||||||
active = true;
|
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
notifyAll();
|
notifyAll();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ public abstract class WindowsApplication extends CMDApplication {
|
|||||||
|
|
||||||
public void activate() throws ActivateException {
|
public void activate() throws ActivateException {
|
||||||
handle = Windows.findWindow(name, null);
|
handle = Windows.findWindow(name, null);
|
||||||
|
log.info(handle);
|
||||||
if (handle < 1) {
|
if (handle < 1) {
|
||||||
super.activate();
|
super.activate();
|
||||||
sleep(START_SLEEP);
|
sleep(START_SLEEP);
|
||||||
@@ -34,7 +35,11 @@ public abstract class WindowsApplication extends CMDApplication {
|
|||||||
throw new ActivateException();
|
throw new ActivateException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean active() {
|
||||||
|
return (handle = Windows.findWindow(name, null)) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
protected void command(Command command) {
|
protected void command(Command command) {
|
||||||
Windows.sendMessage(handle, Windows.WM_APPCOMMAND, handle, command.getCode() << 16);
|
Windows.sendMessage(handle, Windows.WM_APPCOMMAND, handle, command.getCode() << 16);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ public class WinampApplication extends WindowsApplication {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void action(Action action) {
|
public void action(Action action) {
|
||||||
|
log.fatal(handle);
|
||||||
log.trace("WinampApplication: " + action);
|
log.trace("WinampApplication: " + action);
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case PLAY:
|
case PLAY:
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ public class iTunesApplication extends Application implements iTunesEventsInterf
|
|||||||
|
|
||||||
protected void action(Action action) {
|
protected void action(Action action) {
|
||||||
log.trace("iTunesApplication: " + action);
|
log.trace("iTunesApplication: " + action);
|
||||||
|
if (!active) return;
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case PLAY:
|
case PLAY:
|
||||||
iTunes.playPause();
|
iTunes.playPause();
|
||||||
|
|||||||
@@ -18,17 +18,22 @@ import de.hardcode.jxinput.event.JXInputButtonEvent;
|
|||||||
import de.hardcode.jxinput.event.JXInputDirectionalEvent;
|
import de.hardcode.jxinput.event.JXInputDirectionalEvent;
|
||||||
|
|
||||||
public abstract class JavaInputDevice extends Device {
|
public abstract class JavaInputDevice extends Device {
|
||||||
public JavaInputDevice(String title) {
|
protected String name;
|
||||||
|
|
||||||
|
public JavaInputDevice(String title, String name) {
|
||||||
super(title);
|
super(title);
|
||||||
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected JavaInputListener javaInputListener;
|
protected JavaInputListener javaInputListener;
|
||||||
protected Button previousDirectionalButton;
|
protected Button previousDirectionalButton;
|
||||||
|
|
||||||
public void activate(String name) throws ActivateException {
|
public void activate() throws ActivateException {
|
||||||
log.fatal("act");
|
super.activate();
|
||||||
try {
|
try {
|
||||||
javaInputListener = new JavaInputListener(this, getDevice(name));
|
JXInputDevice jxinputDevice = getDevice(name);
|
||||||
|
log.debug(jxinputDevice);
|
||||||
|
javaInputListener = new JavaInputListener(this, jxinputDevice);
|
||||||
} catch (DeviceNotFoundException e) {
|
} catch (DeviceNotFoundException e) {
|
||||||
throw new ActivateException();
|
throw new ActivateException();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import mimis.event.Task;
|
|||||||
import mimis.exception.MacroException;
|
import mimis.exception.MacroException;
|
||||||
import mimis.exception.button.UnknownButtonException;
|
import mimis.exception.button.UnknownButtonException;
|
||||||
import mimis.exception.button.UnknownDirectionException;
|
import mimis.exception.button.UnknownDirectionException;
|
||||||
|
import mimis.exception.worker.ActivateException;
|
||||||
import mimis.macro.state.Hold;
|
import mimis.macro.state.Hold;
|
||||||
import mimis.macro.state.Press;
|
import mimis.macro.state.Press;
|
||||||
import mimis.macro.state.Release;
|
import mimis.macro.state.Release;
|
||||||
@@ -17,14 +18,15 @@ import de.hardcode.jxinput.event.JXInputButtonEvent;
|
|||||||
import de.hardcode.jxinput.event.JXInputDirectionalEvent;
|
import de.hardcode.jxinput.event.JXInputDirectionalEvent;
|
||||||
|
|
||||||
public class Extreme3DDevice extends JavaInputDevice {
|
public class Extreme3DDevice extends JavaInputDevice {
|
||||||
|
protected static final String TITLE = "Extreme 3D";
|
||||||
protected static final String NAME = "Logitech Extreme 3D";
|
protected static final String NAME = "Logitech Extreme 3D";
|
||||||
|
|
||||||
public Extreme3DDevice() {
|
public Extreme3DDevice() {
|
||||||
super(NAME);
|
super(TITLE, NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start() {
|
public void activate() throws ActivateException {
|
||||||
super.start();
|
super.activate();
|
||||||
try {
|
try {
|
||||||
add(
|
add(
|
||||||
new Press(Extreme3DButton.TWELVE),
|
new Press(Extreme3DButton.TWELVE),
|
||||||
|
|||||||
@@ -5,16 +5,16 @@ import mimis.exception.button.UnknownButtonException;
|
|||||||
import de.hardcode.jxinput.event.JXInputButtonEvent;
|
import de.hardcode.jxinput.event.JXInputButtonEvent;
|
||||||
|
|
||||||
public enum RumblepadButton implements Button {
|
public enum RumblepadButton implements Button {
|
||||||
ONE ("SelectButton 0"),
|
ONE ("Button 0"),
|
||||||
TWO ("SelectButton 1"),
|
TWO ("Button 1"),
|
||||||
THREE ("SelectButton 2"),
|
THREE ("Button 2"),
|
||||||
FOUR ("SelectButton 3"),
|
FOUR ("Button 3"),
|
||||||
FIVE ("SelectButton 4"),
|
FIVE ("Button 4"),
|
||||||
SIX ("SelectButton 5"),
|
SIX ("Button 5"),
|
||||||
SEVEN ("SelectButton 6"),
|
SEVEN ("Button 6"),
|
||||||
EIGHT ("SelectButton 7"),
|
EIGHT ("Button 7"),
|
||||||
NINE ("SelectButton 8"),
|
NINE ("Button 8"),
|
||||||
TEN ("SelectButton 9");
|
TEN ("Button 9");
|
||||||
|
|
||||||
protected String code;
|
protected String code;
|
||||||
|
|
||||||
|
|||||||
@@ -17,20 +17,15 @@ import de.hardcode.jxinput.event.JXInputButtonEvent;
|
|||||||
import de.hardcode.jxinput.event.JXInputDirectionalEvent;
|
import de.hardcode.jxinput.event.JXInputDirectionalEvent;
|
||||||
|
|
||||||
public class RumblepadDevice extends JavaInputDevice {
|
public class RumblepadDevice extends JavaInputDevice {
|
||||||
|
protected static final String TITLE = "RumblePad";
|
||||||
protected static final String NAME = "Logitech RumblePad 2 USB";
|
protected static final String NAME = "Logitech RumblePad 2 USB";
|
||||||
|
|
||||||
public RumblepadDevice() {
|
public RumblepadDevice() {
|
||||||
super(NAME);
|
super(TITLE, NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void activate() throws ActivateException {
|
public void activate() throws ActivateException {
|
||||||
super.activate();
|
super.activate();
|
||||||
start();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void start() {
|
|
||||||
log.fatal("start");
|
|
||||||
|
|
||||||
add(
|
add(
|
||||||
new Press(RumblepadButton.ONE),
|
new Press(RumblepadButton.ONE),
|
||||||
new Task(Target.APPLICATION, Action.PLAY));
|
new Task(Target.APPLICATION, Action.PLAY));
|
||||||
@@ -58,7 +53,6 @@ public class RumblepadDevice extends JavaInputDevice {
|
|||||||
add(
|
add(
|
||||||
new Hold(RumblepadButton.TEN),
|
new Hold(RumblepadButton.TEN),
|
||||||
new Continuous(Action.VOLUME_UP, Target.APPLICATION, 100));
|
new Continuous(Action.VOLUME_UP, Target.APPLICATION, 100));
|
||||||
super.start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Button getButton(JXInputButtonEvent event) throws UnknownButtonException {
|
protected Button getButton(JXInputButtonEvent event) throws UnknownButtonException {
|
||||||
|
|||||||
@@ -34,6 +34,10 @@ public class Hotkey implements Button {
|
|||||||
this(key.getCode());
|
this(key.getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Hotkey(int modifier, Key key) {
|
||||||
|
this(modifier, key.getCode());
|
||||||
|
}
|
||||||
|
|
||||||
public static void initialise(ArrayList<Hotkey> actionList, JIntellitype jit) {
|
public static void initialise(ArrayList<Hotkey> actionList, JIntellitype jit) {
|
||||||
Hotkey.hotkeyList = actionList;
|
Hotkey.hotkeyList = actionList;
|
||||||
Hotkey.jit = jit;
|
Hotkey.jit = jit;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import java.util.ArrayList;
|
|||||||
import mimis.Device;
|
import mimis.Device;
|
||||||
import mimis.event.Task;
|
import mimis.event.Task;
|
||||||
import mimis.exception.button.UnknownButtonException;
|
import mimis.exception.button.UnknownButtonException;
|
||||||
|
import mimis.exception.worker.ActivateException;
|
||||||
import mimis.macro.state.Press;
|
import mimis.macro.state.Press;
|
||||||
import mimis.macro.state.Release;
|
import mimis.macro.state.Release;
|
||||||
import mimis.value.Action;
|
import mimis.value.Action;
|
||||||
@@ -29,8 +30,8 @@ public class JIntellitypeDevice extends Device implements HotkeyListener, Intell
|
|||||||
Hotkey.initialise(hotkeyList, jit);
|
Hotkey.initialise(hotkeyList, jit);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start() {
|
public void activate() throws ActivateException {
|
||||||
super.start();
|
super.activate();
|
||||||
jit.addHotKeyListener(this);
|
jit.addHotKeyListener(this);
|
||||||
jit.addIntellitypeListener(this);
|
jit.addIntellitypeListener(this);
|
||||||
add(
|
add(
|
||||||
@@ -61,6 +62,7 @@ public class JIntellitypeDevice extends Device implements HotkeyListener, Intell
|
|||||||
new Hotkey(Modifier.CTRL | Modifier.WIN, 'r'),
|
new Hotkey(Modifier.CTRL | Modifier.WIN, 'r'),
|
||||||
new Hotkey(Modifier.CTRL | Modifier.WIN, 's'),
|
new Hotkey(Modifier.CTRL | Modifier.WIN, 's'),
|
||||||
new Continuous(Action.REPEAT, Target.APPLICATIONS, 500));*/
|
new Continuous(Action.REPEAT, Target.APPLICATIONS, 500));*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void add(Hotkey hotkey, Task task) {
|
protected void add(Hotkey hotkey, Task task) {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import javax.swing.WindowConstants;
|
|||||||
|
|
||||||
import mimis.Device;
|
import mimis.Device;
|
||||||
import mimis.event.Task;
|
import mimis.event.Task;
|
||||||
|
import mimis.exception.worker.ActivateException;
|
||||||
import mimis.macro.state.Press;
|
import mimis.macro.state.Press;
|
||||||
import mimis.macro.state.Release;
|
import mimis.macro.state.Release;
|
||||||
import mimis.value.Action;
|
import mimis.value.Action;
|
||||||
@@ -20,7 +21,8 @@ public class PanelDevice extends Device implements PanelButtonListener {
|
|||||||
super(TITLE);
|
super(TITLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void activate() {
|
public void activate() throws ActivateException {
|
||||||
|
super.activate();
|
||||||
panel = new Panel(this) {
|
panel = new Panel(this) {
|
||||||
protected static final long serialVersionUID = 1L;
|
protected static final long serialVersionUID = 1L;
|
||||||
protected void processWindowEvent(WindowEvent e) {
|
protected void processWindowEvent(WindowEvent e) {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import mimis.event.Feedback;
|
|||||||
import mimis.event.Task;
|
import mimis.event.Task;
|
||||||
import mimis.exception.button.UnknownButtonException;
|
import mimis.exception.button.UnknownButtonException;
|
||||||
import mimis.exception.device.DeviceNotFoundException;
|
import mimis.exception.device.DeviceNotFoundException;
|
||||||
|
import mimis.exception.worker.ActivateException;
|
||||||
import mimis.macro.state.Hold;
|
import mimis.macro.state.Hold;
|
||||||
import mimis.macro.state.Press;
|
import mimis.macro.state.Press;
|
||||||
import mimis.macro.state.Release;
|
import mimis.macro.state.Release;
|
||||||
@@ -45,7 +46,16 @@ public class WiimoteDevice extends Device implements GestureListener {
|
|||||||
gestureDevice.add(this);
|
gestureDevice.add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initialise() {
|
public void activate() throws ActivateException {
|
||||||
|
super.activate();
|
||||||
|
try {
|
||||||
|
wiimote = wiimoteService.getDevice(this);
|
||||||
|
} catch (DeviceNotFoundException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
wiimote.activateMotionSensing();
|
||||||
|
|
||||||
add(
|
add(
|
||||||
new Hold(WiimoteButton.A),
|
new Hold(WiimoteButton.A),
|
||||||
new Task(Action.TRAIN),
|
new Task(Action.TRAIN),
|
||||||
@@ -167,16 +177,6 @@ public class WiimoteDevice extends Device implements GestureListener {
|
|||||||
wiimote.rumble(RUMBLE);
|
wiimote.rumble(RUMBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void activate() {
|
|
||||||
try {
|
|
||||||
wiimote = wiimoteService.getDevice(this);
|
|
||||||
} catch (DeviceNotFoundException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
wiimote.activateMotionSensing();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void deactivate() {
|
public void deactivate() {
|
||||||
wiimote.deactivateMotionSensing();
|
wiimote.deactivateMotionSensing();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,12 +11,8 @@ public abstract class EventHandler extends EventListener {
|
|||||||
EventHandler.eventRouter = eventRouter;
|
EventHandler.eventRouter = eventRouter;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void initialise() {
|
|
||||||
eventRouter.add(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void event(Event event) {
|
public void event(Event event) {
|
||||||
System.out.println(event);
|
log.debug("aaa" + event);
|
||||||
if (event instanceof Feedback) {
|
if (event instanceof Feedback) {
|
||||||
feedback((Feedback) event);
|
feedback((Feedback) event);
|
||||||
} else if (event instanceof Task) {
|
} else if (event instanceof Task) {
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ public abstract class EventListener extends Worker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void add(Event event) {
|
public void add(Event event) {
|
||||||
|
log.info("event " + event + " " + active);
|
||||||
eventQueue.add(event);
|
eventQueue.add(event);
|
||||||
synchronized (work) {
|
synchronized (work) {
|
||||||
work.notifyAll();
|
work.notifyAll();
|
||||||
|
|||||||
@@ -17,8 +17,10 @@ public abstract class EventRouter extends EventListener {
|
|||||||
eventListenerList = new ArrayList<EventListener>();
|
eventListenerList = new ArrayList<EventListener>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void add(EventListener eventListener) {
|
public void add(EventListener... eventListenerArray) {
|
||||||
eventListenerList.add(eventListener);
|
for (EventListener eventListener : eventListenerArray) {
|
||||||
|
eventListenerList.add(eventListener);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void remove(EventListener eventListener) {
|
public void remove(EventListener eventListener) {
|
||||||
|
|||||||
@@ -7,8 +7,7 @@ import mimis.value.Target;
|
|||||||
|
|
||||||
public class LocalRouter extends EventRouter {
|
public class LocalRouter extends EventRouter {
|
||||||
public void event(Event event) {
|
public void event(Event event) {
|
||||||
System.out.println("LocalSpreader krijgt event via evet()");
|
System.out.println("LocalSpreader krijgt event via event() " + event.getTarget());
|
||||||
System.out.println(application);
|
|
||||||
Target target = event.getTarget();
|
Target target = event.getTarget();
|
||||||
switch (target) {
|
switch (target) {
|
||||||
case APPLICATION:
|
case APPLICATION:
|
||||||
@@ -19,6 +18,7 @@ public class LocalRouter extends EventRouter {
|
|||||||
default:
|
default:
|
||||||
for (EventListener eventListener : eventListenerList) {
|
for (EventListener eventListener : eventListenerList) {
|
||||||
if (event.compatible(eventListener)) {
|
if (event.compatible(eventListener)) {
|
||||||
|
log.trace(eventListener);
|
||||||
eventListener.add(event);
|
eventListener.add(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,14 +3,18 @@ package mimis.macro;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
import mimis.Event;
|
import mimis.Event;
|
||||||
import mimis.event.EventHandler;
|
import mimis.event.EventHandler;
|
||||||
import mimis.event.EventListener;
|
import mimis.event.EventListener;
|
||||||
import mimis.event.Task;
|
import mimis.event.Task;
|
||||||
import mimis.value.Target;
|
import mimis.value.Target;
|
||||||
|
|
||||||
|
|
||||||
public class SequenceListener {
|
public class SequenceListener {
|
||||||
|
protected Log log = LogFactory.getLog(getClass());
|
||||||
|
|
||||||
protected EventHandler eventHandler;
|
protected EventHandler eventHandler;
|
||||||
protected ArrayList<Sequence> sequenceList;
|
protected ArrayList<Sequence> sequenceList;
|
||||||
protected HashMap<Sequence, Event> eventMap;
|
protected HashMap<Sequence, Event> eventMap;
|
||||||
@@ -37,6 +41,7 @@ public class SequenceListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void add(State state) {
|
public void add(State state) {
|
||||||
|
log.trace(state);
|
||||||
for (Sequence sequence : sequenceList) {
|
for (Sequence sequence : sequenceList) {
|
||||||
activeList.add(new Active(sequence));
|
activeList.add(new Active(sequence));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,16 @@
|
|||||||
package mimis.manager;
|
package mimis.manager;
|
||||||
|
|
||||||
import java.awt.event.ItemEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ItemListener;
|
import java.awt.event.ActionListener;
|
||||||
import javax.swing.Action;
|
import javax.swing.Action;
|
||||||
import javax.swing.JToggleButton;
|
import javax.swing.JButton;
|
||||||
|
|
||||||
import mimis.Worker;
|
import mimis.Worker;
|
||||||
import mimis.exception.worker.ActivateException;
|
import mimis.exception.worker.ActivateException;
|
||||||
import mimis.exception.worker.DeactivateException;
|
import mimis.exception.worker.DeactivateException;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
public class SelectButton<T extends Worker & Titled> extends JToggleButton implements ItemListener {
|
public class SelectButton<T extends Worker & Titled> extends JButton implements ActionListener {
|
||||||
protected Log log = LogFactory.getLog(getClass());
|
protected Log log = LogFactory.getLog(getClass());
|
||||||
|
|
||||||
protected static final long serialVersionUID = 1L;
|
protected static final long serialVersionUID = 1L;
|
||||||
@@ -22,31 +20,23 @@ public class SelectButton<T extends Worker & Titled> extends JToggleButton imple
|
|||||||
public SelectButton(T activatable) {
|
public SelectButton(T activatable) {
|
||||||
this.activatable = activatable;
|
this.activatable = activatable;
|
||||||
setText(activatable.title());
|
setText(activatable.title());
|
||||||
addItemListener(this);
|
setFocusable(false);
|
||||||
|
addActionListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void itemStateChanged(ItemEvent itemEvent) {
|
public void actionPerformed(ActionEvent event) {
|
||||||
int state = itemEvent.getStateChange();
|
if (activatable.active()) {
|
||||||
if (state == ItemEvent.SELECTED) {
|
|
||||||
log.trace("Selected: " + activatable.title());
|
|
||||||
setPressed(false);
|
|
||||||
try {
|
|
||||||
activatable.activate();
|
|
||||||
} catch (ActivateException e) {
|
|
||||||
log.error(e);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
log.trace("Deselected: " + activatable.title());
|
|
||||||
setPressed(true);
|
|
||||||
try {
|
try {
|
||||||
activatable.deactivate();
|
activatable.deactivate();
|
||||||
} catch (DeactivateException e) {
|
} catch (DeactivateException e) {
|
||||||
log.error(e);
|
log.error(e);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
}
|
try {
|
||||||
|
activatable.activate();
|
||||||
public void setPressed(boolean pressed) {
|
} catch (ActivateException e) {
|
||||||
getModel().setPressed(pressed);
|
log.error(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,5 +16,5 @@ public enum Action {
|
|||||||
VOLUME_DOWN,
|
VOLUME_DOWN,
|
||||||
VOLUME_UP,
|
VOLUME_UP,
|
||||||
FULLSCREEN,
|
FULLSCREEN,
|
||||||
TRAIN, STOP, SAVE, RECOGNIZE, LOAD, SHUFFLE, FADEOUT, QUIT, VISUALISER, LIKE, DISLIKE;
|
TRAIN, STOP, SAVE, RECOGNIZE, LOAD, SHUFFLE, FADEOUT, QUIT, VISUALISER, LIKE, DISLIKE, ACTIVATE;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user