Enkele applicaties en devices grondig getest, omgeschreven naar nieuwigheden en bugs verholpen.
Todo: GOM, VLC, MPC. Interfacen van WMC. Extra knoppen in PanelDevice voor next en previous app?
This commit is contained in:
@@ -7,6 +7,7 @@ import mimis.exception.worker.DeactivateException;
|
|||||||
import mimis.manager.Exitable;
|
import mimis.manager.Exitable;
|
||||||
import mimis.manager.Titled;
|
import mimis.manager.Titled;
|
||||||
import mimis.value.Action;
|
import mimis.value.Action;
|
||||||
|
import mimis.value.Signal;
|
||||||
|
|
||||||
public abstract class Application extends EventHandler implements Titled, Exitable {
|
public abstract class Application extends EventHandler implements Titled, Exitable {
|
||||||
protected String title;
|
protected String title;
|
||||||
@@ -26,14 +27,17 @@ public abstract class Application extends EventHandler implements Titled, Exitab
|
|||||||
Action action = task.getAction();
|
Action action = task.getAction();
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case ACTIVATE:
|
case ACTIVATE:
|
||||||
try {
|
if (task.getSignal().equals(Signal.BEGIN)) {
|
||||||
if (active()) {
|
try {
|
||||||
deactivate();
|
log.debug(active());
|
||||||
} else {
|
if (active()) {
|
||||||
activate();
|
deactivate();
|
||||||
|
} else {
|
||||||
|
activate();
|
||||||
|
}
|
||||||
|
} catch (WorkerException e) {
|
||||||
|
log.error(e);
|
||||||
}
|
}
|
||||||
} catch (WorkerException e) {
|
|
||||||
log.error(e);
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -41,7 +45,8 @@ public abstract class Application extends EventHandler implements Titled, Exitab
|
|||||||
super.event(event);
|
super.event(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stop() {
|
public void stop() throws DeactivateException {
|
||||||
|
super.stop();
|
||||||
if (active()) {
|
if (active()) {
|
||||||
try {
|
try {
|
||||||
deactivate();
|
deactivate();
|
||||||
@@ -49,6 +54,5 @@ public abstract class Application extends EventHandler implements Titled, Exitab
|
|||||||
log.error(e);
|
log.error(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.stop();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -32,7 +32,7 @@ public abstract class Device extends EventHandler implements Titled, Exitable {
|
|||||||
sequenceParser.reset();
|
sequenceParser.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stop() {
|
public void stop() throws DeactivateException {
|
||||||
if (active()) {
|
if (active()) {
|
||||||
try {
|
try {
|
||||||
deactivate();
|
deactivate();
|
||||||
|
|||||||
@@ -11,14 +11,16 @@ import javax.swing.JToggleButton;
|
|||||||
import javax.swing.SwingConstants;
|
import javax.swing.SwingConstants;
|
||||||
import javax.swing.WindowConstants;
|
import javax.swing.WindowConstants;
|
||||||
|
|
||||||
|
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 GUI extends JFrame {
|
public class GUI extends JFrame {
|
||||||
protected Log log = LogFactory.getLog(getClass());
|
|
||||||
protected static final long serialVersionUID = 1L;
|
protected static final long serialVersionUID = 1L;
|
||||||
|
protected Log log = LogFactory.getLog(getClass());
|
||||||
|
|
||||||
protected static final String TITLE = "Mimis GUI";
|
protected static final String TITLE = "MIMIS Manager";
|
||||||
protected static final String APPLICATION_TITLE = "Applications";
|
protected static final String APPLICATION_TITLE = "Applications";
|
||||||
protected static final String DEVICE_TITLE = "Devices";
|
protected static final String DEVICE_TITLE = "Devices";
|
||||||
|
|
||||||
@@ -69,11 +71,15 @@ public class GUI extends JFrame {
|
|||||||
return textPanel;
|
return textPanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void processWindowEvent(WindowEvent e) {
|
protected void processWindowEvent(WindowEvent event) {
|
||||||
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
|
if (event.getID() == WindowEvent.WINDOW_CLOSING) {
|
||||||
log.debug("Window closing");
|
log.debug("Window closing");
|
||||||
stop();
|
stop();
|
||||||
mimis.stop();
|
try {
|
||||||
|
mimis.stop();
|
||||||
|
} catch (DeactivateException e) {
|
||||||
|
log.error(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
import javax.swing.JToggleButton;
|
import javax.swing.JToggleButton;
|
||||||
|
|
||||||
|
import mimis.exception.worker.DeactivateException;
|
||||||
import mimis.manager.Exitable;
|
import mimis.manager.Exitable;
|
||||||
import mimis.manager.ManageButton;
|
import mimis.manager.ManageButton;
|
||||||
import mimis.manager.Titled;
|
import mimis.manager.Titled;
|
||||||
@@ -26,7 +27,7 @@ public class Manager<T extends Worker & Titled & Exitable> extends Worker {
|
|||||||
createButtons();
|
createButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stop() {
|
public void stop() throws DeactivateException {
|
||||||
super.stop();
|
super.stop();
|
||||||
for (T manageable : manageableArray) {
|
for (T manageable : manageableArray) {
|
||||||
manageable.stop();
|
manageable.stop();
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import mimis.event.EventHandler;
|
|||||||
import mimis.event.EventRouter;
|
import mimis.event.EventRouter;
|
||||||
import mimis.event.Feedback;
|
import mimis.event.Feedback;
|
||||||
import mimis.exception.worker.ActivateException;
|
import mimis.exception.worker.ActivateException;
|
||||||
|
import mimis.exception.worker.DeactivateException;
|
||||||
import mimis.feedback.TextFeedback;
|
import mimis.feedback.TextFeedback;
|
||||||
import mimis.sequence.SequenceParser;
|
import mimis.sequence.SequenceParser;
|
||||||
import mimis.util.ArrayCycle;
|
import mimis.util.ArrayCycle;
|
||||||
@@ -73,8 +74,10 @@ public class Mimis extends EventHandler {
|
|||||||
super.activate(false);
|
super.activate(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stop() {
|
public void stop() throws DeactivateException {
|
||||||
super.stop();
|
super.stop();
|
||||||
|
log.debug("Stop GUI");
|
||||||
|
gui.stop();
|
||||||
|
|
||||||
log.debug("Stop event router");
|
log.debug("Stop event router");
|
||||||
eventRouter.stop();
|
eventRouter.stop();
|
||||||
@@ -95,7 +98,11 @@ public class Mimis extends EventHandler {
|
|||||||
add(new TextFeedback("Previous application: " + applicationCycle.current().title()));
|
add(new TextFeedback("Previous application: " + applicationCycle.current().title()));
|
||||||
break;
|
break;
|
||||||
case EXIT:
|
case EXIT:
|
||||||
stop();
|
try {
|
||||||
|
stop();
|
||||||
|
} catch (DeactivateException e) {
|
||||||
|
log.error(e);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,14 +30,9 @@ public abstract class Worker implements Runnable {
|
|||||||
start(THREAD);
|
start(THREAD);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stop() {
|
public void stop() throws DeactivateException {
|
||||||
log.trace("Stop");
|
|
||||||
if (active()) {
|
if (active()) {
|
||||||
try {
|
deactivate();
|
||||||
deactivate();
|
|
||||||
} catch (DeactivateException e) {
|
|
||||||
log.error(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
running = false;
|
running = false;
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
@@ -91,7 +86,6 @@ public abstract class Worker implements Runnable {
|
|||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
log.trace("Wait");
|
|
||||||
wait();
|
wait();
|
||||||
}
|
}
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ public abstract class CMDApplication extends Application {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void activate() throws ActivateException {
|
public void activate() throws ActivateException {
|
||||||
|
super.activate();
|
||||||
String key = String.format("%s\\%s", REGISTRY, program);
|
String key = String.format("%s\\%s", REGISTRY, program);
|
||||||
// Check of naam is gevonden in register
|
|
||||||
String path = Native.getValue(key);
|
String path = Native.getValue(key);
|
||||||
try {
|
try {
|
||||||
String command = path.startsWith("\"") ? path : String.format("\"%s\"", path);
|
String command = path.startsWith("\"") ? path : String.format("\"%s\"", path);
|
||||||
@@ -33,7 +33,6 @@ public abstract class CMDApplication extends Application {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new ActivateException();
|
throw new ActivateException();
|
||||||
}
|
}
|
||||||
super.activate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean active() {
|
public boolean active() {
|
||||||
@@ -45,9 +44,9 @@ public abstract class CMDApplication extends Application {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void deactivate() throws DeactivateException {
|
public void deactivate() throws DeactivateException {
|
||||||
|
super.deactivate();
|
||||||
if (process != null) {
|
if (process != null) {
|
||||||
process.destroy();
|
process.destroy();
|
||||||
}
|
}
|
||||||
super.deactivate();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,13 @@
|
|||||||
package mimis.application.cmd.windows;
|
package mimis.application.cmd.windows;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
import mimis.application.cmd.CMDApplication;
|
import mimis.application.cmd.CMDApplication;
|
||||||
|
|
||||||
import mimis.exception.worker.ActivateException;
|
import mimis.exception.worker.ActivateException;
|
||||||
|
import mimis.exception.worker.DeactivateException;
|
||||||
import mimis.util.Windows;
|
import mimis.util.Windows;
|
||||||
|
import mimis.util.VBScript;
|
||||||
import mimis.value.Command;
|
import mimis.value.Command;
|
||||||
import mimis.value.Key;
|
import mimis.value.Key;
|
||||||
import mimis.value.Type;
|
import mimis.value.Type;
|
||||||
@@ -12,7 +17,6 @@ public abstract class WindowsApplication extends CMDApplication {
|
|||||||
protected final static int START_SLEEP = 500;
|
protected final static int START_SLEEP = 500;
|
||||||
|
|
||||||
protected String name;
|
protected String name;
|
||||||
|
|
||||||
protected Process process;
|
protected Process process;
|
||||||
protected int handle;
|
protected int handle;
|
||||||
|
|
||||||
@@ -23,10 +27,10 @@ public abstract class WindowsApplication extends CMDApplication {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void activate() throws ActivateException {
|
public void activate() throws ActivateException {
|
||||||
|
super.activate();
|
||||||
handle = Windows.findWindow(name, null);
|
handle = Windows.findWindow(name, null);
|
||||||
log.info(handle);
|
log.info(handle);
|
||||||
if (handle < 1) {
|
if (handle < 1) {
|
||||||
super.activate();
|
|
||||||
sleep(START_SLEEP);
|
sleep(START_SLEEP);
|
||||||
handle = Windows.findWindow(name, null);
|
handle = Windows.findWindow(name, null);
|
||||||
}
|
}
|
||||||
@@ -40,6 +44,15 @@ public abstract class WindowsApplication extends CMDApplication {
|
|||||||
return (handle = Windows.findWindow(name, null)) > 0;
|
return (handle = Windows.findWindow(name, null)) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void deactivate() throws DeactivateException {
|
||||||
|
try {
|
||||||
|
VBScript.terminate(program);
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error(e);
|
||||||
|
throw new DeactivateException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ public class GomPlayerApplication extends WindowsApplication {
|
|||||||
super(PROGRAM, TITLE, NAME);
|
super(PROGRAM, TITLE, NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void action(Action action) {
|
public void begin(Action action) {
|
||||||
log.trace("GomPlayerApplication: " + action);
|
log.trace("GomPlayerApplication begin: " + action);
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case PLAY:
|
case PLAY:
|
||||||
command(0x800C);
|
command(0x800C);
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
package mimis.application.cmd.windows.winamp;
|
package mimis.application.cmd.windows.winamp;
|
||||||
|
|
||||||
|
import mimis.Worker;
|
||||||
import mimis.application.cmd.windows.WindowsApplication;
|
import mimis.application.cmd.windows.WindowsApplication;
|
||||||
|
import mimis.exception.worker.ActivateException;
|
||||||
|
import mimis.exception.worker.DeactivateException;
|
||||||
import mimis.value.Action;
|
import mimis.value.Action;
|
||||||
|
|
||||||
public class WinampApplication extends WindowsApplication {
|
public class WinampApplication extends WindowsApplication {
|
||||||
@@ -30,6 +33,11 @@ public class WinampApplication extends WindowsApplication {
|
|||||||
protected final static int WINAMP_BUTTON4_SHIFT = 40147;
|
protected final static int WINAMP_BUTTON4_SHIFT = 40147;
|
||||||
protected final static int WINAMP_VISPLUGIN = 40192;
|
protected final static int WINAMP_VISPLUGIN = 40192;
|
||||||
|
|
||||||
|
protected static final int VOLUME_SLEEP = 50;
|
||||||
|
protected static final int SEEK_SLEEP = 100;
|
||||||
|
|
||||||
|
protected VolumeWorker volumeWorker;
|
||||||
|
protected SeekWorker seekWorker;
|
||||||
protected double volume;
|
protected double volume;
|
||||||
protected boolean muted;
|
protected boolean muted;
|
||||||
protected boolean forward;
|
protected boolean forward;
|
||||||
@@ -39,29 +47,54 @@ public class WinampApplication extends WindowsApplication {
|
|||||||
super(PROGRAM, TITLE, NAME);
|
super(PROGRAM, TITLE, NAME);
|
||||||
volume = getVolume();
|
volume = getVolume();
|
||||||
muted = volume == 0;
|
muted = volume == 0;
|
||||||
|
volumeWorker = new VolumeWorker();
|
||||||
|
seekWorker = new SeekWorker();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void stop() throws DeactivateException {
|
||||||
|
super.stop();
|
||||||
|
volumeWorker.stop();
|
||||||
|
seekWorker.stop();
|
||||||
|
}
|
||||||
|
|
||||||
public void begin(Action action) {
|
public void begin(Action action) {
|
||||||
log.trace("WinampApplication: " + action);
|
log.trace("WinampApplication begin: " + action);
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case FORWARD:
|
case VOLUME_UP:
|
||||||
forward = true;
|
try {
|
||||||
while (forward) {
|
volumeWorker.activate(1);
|
||||||
command(WINAMP_FFWD5S);
|
} catch (ActivateException e) {
|
||||||
sleep(200);
|
log.error(e);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case REWIND:
|
case VOLUME_DOWN:
|
||||||
command(WINAMP_REW5S);
|
try {
|
||||||
break;
|
volumeWorker.activate(-1);
|
||||||
|
} catch (ActivateException e) {
|
||||||
|
log.error(e);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case FORWARD:
|
||||||
|
try {
|
||||||
|
seekWorker.activate(1);
|
||||||
|
} catch (ActivateException e) {
|
||||||
|
log.error(e);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case REWIND:
|
||||||
|
try {
|
||||||
|
seekWorker.activate(-1);
|
||||||
|
} catch (ActivateException e) {
|
||||||
|
log.error(e);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void end(Action action) {
|
public void end(Action action) {
|
||||||
log.trace("WinampApplication: " + action);
|
log.trace("WinampApplication end: " + action);
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case PLAY:
|
case PLAY:
|
||||||
System.out.println(user(0, IPC_ISPLAYING));
|
|
||||||
switch (user(0, IPC_ISPLAYING)) {
|
switch (user(0, IPC_ISPLAYING)) {
|
||||||
case STATUS_STOPPED:
|
case STATUS_STOPPED:
|
||||||
command(WINAMP_BUTTON2);
|
command(WINAMP_BUTTON2);
|
||||||
@@ -78,10 +111,12 @@ public class WinampApplication extends WindowsApplication {
|
|||||||
command(WINAMP_BUTTON1);
|
command(WINAMP_BUTTON1);
|
||||||
break;
|
break;
|
||||||
case FORWARD:
|
case FORWARD:
|
||||||
forward = false;
|
|
||||||
break;
|
|
||||||
case REWIND:
|
case REWIND:
|
||||||
command(WINAMP_REW5S);
|
try {
|
||||||
|
seekWorker.deactivate();
|
||||||
|
} catch (DeactivateException e) {
|
||||||
|
log.error(e);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case MUTE:
|
case MUTE:
|
||||||
if (muted) {
|
if (muted) {
|
||||||
@@ -93,11 +128,12 @@ public class WinampApplication extends WindowsApplication {
|
|||||||
muted = !muted;
|
muted = !muted;
|
||||||
break;
|
break;
|
||||||
case VOLUME_UP:
|
case VOLUME_UP:
|
||||||
command(WINAMP_VOLUMEUP);
|
|
||||||
break;
|
|
||||||
case VOLUME_DOWN:
|
case VOLUME_DOWN:
|
||||||
System.out.println(getVolume());
|
try {
|
||||||
command(WINAMP_VOLUMEDOWN);
|
volumeWorker.deactivate();
|
||||||
|
} catch (DeactivateException e) {
|
||||||
|
log.error(e);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case SHUFFLE:
|
case SHUFFLE:
|
||||||
command(WINAMP_FILE_SHUFFLE);
|
command(WINAMP_FILE_SHUFFLE);
|
||||||
@@ -132,4 +168,32 @@ public class WinampApplication extends WindowsApplication {
|
|||||||
public int getElapsed() {
|
public int getElapsed() {
|
||||||
return user(0, IPC_GETOUTPUTTIME) / 1000;
|
return user(0, IPC_GETOUTPUTTIME) / 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected class VolumeWorker extends Worker {
|
||||||
|
protected int volumeChangeSign;
|
||||||
|
|
||||||
|
public void activate(int volumeChangeSign) throws ActivateException {
|
||||||
|
super.activate();
|
||||||
|
this.volumeChangeSign = volumeChangeSign;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void work() {
|
||||||
|
command(volumeChangeSign > 0 ? WINAMP_VOLUMEUP : WINAMP_VOLUMEDOWN);
|
||||||
|
sleep(VOLUME_SLEEP);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
protected class SeekWorker extends Worker {
|
||||||
|
protected int seekDirection;
|
||||||
|
|
||||||
|
public void activate(int seekDirection) throws ActivateException {
|
||||||
|
super.activate();
|
||||||
|
this.seekDirection = seekDirection;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void work() {
|
||||||
|
command(seekDirection > 0 ? WINAMP_FFWD5S : WINAMP_REW5S);
|
||||||
|
sleep(VOLUME_SLEEP);
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
package mimis.application.cmd.windows.wmp;
|
package mimis.application.cmd.windows.wmp;
|
||||||
|
|
||||||
|
import mimis.Worker;
|
||||||
import mimis.application.cmd.windows.WindowsApplication;
|
import mimis.application.cmd.windows.WindowsApplication;
|
||||||
|
import mimis.exception.worker.ActivateException;
|
||||||
|
import mimis.exception.worker.DeactivateException;
|
||||||
import mimis.value.Action;
|
import mimis.value.Action;
|
||||||
|
|
||||||
public class WMPApplication extends WindowsApplication {
|
public class WMPApplication extends WindowsApplication {
|
||||||
@@ -8,12 +11,17 @@ public class WMPApplication extends WindowsApplication {
|
|||||||
protected final static String TITLE = "Windows Media Player";
|
protected final static String TITLE = "Windows Media Player";
|
||||||
protected final static String NAME = "WMPlayerApp";
|
protected final static String NAME = "WMPlayerApp";
|
||||||
|
|
||||||
|
protected static final int VOLUME_SLEEP = 120;
|
||||||
|
|
||||||
|
protected VolumeWorker volumeWorker;
|
||||||
|
|
||||||
public WMPApplication() {
|
public WMPApplication() {
|
||||||
super(PROGRAM, TITLE, NAME);
|
super(PROGRAM, TITLE, NAME);
|
||||||
|
volumeWorker = new VolumeWorker();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void action(Action action) {
|
public void begin(Action action) {
|
||||||
log.trace("WMPApplication: " + action);
|
log.trace("WMPApplication begin: " + action);
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case PLAY:
|
case PLAY:
|
||||||
command(18808);
|
command(18808);
|
||||||
@@ -34,10 +42,18 @@ public class WMPApplication extends WindowsApplication {
|
|||||||
command(18817);
|
command(18817);
|
||||||
break;
|
break;
|
||||||
case VOLUME_UP:
|
case VOLUME_UP:
|
||||||
command(18815);
|
try {
|
||||||
|
volumeWorker.activate(1);
|
||||||
|
} catch (ActivateException e) {
|
||||||
|
log.error(e);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case VOLUME_DOWN:
|
case VOLUME_DOWN:
|
||||||
command(18816);
|
try {
|
||||||
|
volumeWorker.activate(-1);
|
||||||
|
} catch (ActivateException e) {
|
||||||
|
log.error(e);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case SHUFFLE:
|
case SHUFFLE:
|
||||||
command(18842);
|
command(18842);
|
||||||
@@ -47,4 +63,38 @@ public class WMPApplication extends WindowsApplication {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void end(Action action) {
|
||||||
|
log.trace("WMPApplication end: " + action);
|
||||||
|
switch (action) {
|
||||||
|
case FORWARD:
|
||||||
|
command(18813);
|
||||||
|
break;
|
||||||
|
case REWIND:
|
||||||
|
command(18812);
|
||||||
|
break;
|
||||||
|
case VOLUME_UP:
|
||||||
|
case VOLUME_DOWN:
|
||||||
|
try {
|
||||||
|
volumeWorker.deactivate();
|
||||||
|
} catch (DeactivateException e) {
|
||||||
|
log.error(e);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected class VolumeWorker extends Worker {
|
||||||
|
protected int volumeChangeSign;
|
||||||
|
|
||||||
|
public void activate(int volumeChangeSign) throws ActivateException {
|
||||||
|
super.activate();
|
||||||
|
this.volumeChangeSign = volumeChangeSign;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void work() {
|
||||||
|
command (volumeChangeSign > 0 ? 18815 : 18816);
|
||||||
|
sleep(VOLUME_SLEEP);
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
package mimis.application.itunes;
|
package mimis.application.itunes;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
import mimis.Application;
|
import mimis.Application;
|
||||||
|
import mimis.Worker;
|
||||||
import mimis.exception.worker.ActivateException;
|
import mimis.exception.worker.ActivateException;
|
||||||
import mimis.exception.worker.DeactivateException;
|
import mimis.exception.worker.DeactivateException;
|
||||||
|
import mimis.util.VBScript;
|
||||||
import mimis.value.Action;
|
import mimis.value.Action;
|
||||||
|
|
||||||
import com.dt.iTunesController.ITCOMDisabledReason;
|
import com.dt.iTunesController.ITCOMDisabledReason;
|
||||||
@@ -12,19 +16,23 @@ import com.dt.iTunesController.iTunesEventsInterface;
|
|||||||
|
|
||||||
public class iTunesApplication extends Application implements iTunesEventsInterface {
|
public class iTunesApplication extends Application implements iTunesEventsInterface {
|
||||||
protected static final String TITLE = "iTunes";
|
protected static final String TITLE = "iTunes";
|
||||||
|
protected static final String PROGRAM = "iTunes.exe";
|
||||||
|
protected static final boolean QUIT = true;
|
||||||
|
|
||||||
protected static final boolean QUIT = false;
|
|
||||||
protected static final int VOLUME_CHANGE_RATE = 5;
|
protected static final int VOLUME_CHANGE_RATE = 5;
|
||||||
protected static final int VOLUME_SLEEP = 500;
|
protected static final int VOLUME_SLEEP = 100;
|
||||||
protected static final String PLAYLIST_LIKE = "Like";
|
protected static final String PLAYLIST_LIKE = "Like";
|
||||||
protected static final String PLAYLIST_DISLIKE = "Dislike";
|
protected static final String PLAYLIST_DISLIKE = "Dislike";
|
||||||
|
|
||||||
protected iTunes iTunes;
|
protected iTunes iTunes;
|
||||||
protected boolean volume;
|
protected VolumeWorker volumeWorker;
|
||||||
|
protected boolean quiting;
|
||||||
|
|
||||||
public iTunesApplication() {
|
public iTunesApplication() {
|
||||||
super(TITLE);
|
super(TITLE);
|
||||||
iTunes = new iTunes();
|
iTunes = new iTunes();
|
||||||
|
volumeWorker = new VolumeWorker();
|
||||||
|
quiting = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void activate() throws ActivateException {
|
public void activate() throws ActivateException {
|
||||||
@@ -36,6 +44,17 @@ public class iTunesApplication extends Application implements iTunesEventsInterf
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean active() {
|
public boolean active() {
|
||||||
|
try {
|
||||||
|
if (!active && !quiting && VBScript.isRunning(PROGRAM)) {
|
||||||
|
try {
|
||||||
|
activate();
|
||||||
|
} catch (ActivateException e) {
|
||||||
|
log.error(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error(e);
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
iTunes.getMute();
|
iTunes.getMute();
|
||||||
active = true;
|
active = true;
|
||||||
@@ -46,19 +65,26 @@ public class iTunesApplication extends Application implements iTunesEventsInterf
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void deactivate() throws DeactivateException {
|
public void deactivate() throws DeactivateException {
|
||||||
|
super.deactivate();
|
||||||
|
volumeWorker.deactivate();
|
||||||
try {
|
try {
|
||||||
if (QUIT) {
|
if (QUIT) {
|
||||||
|
quiting = true;
|
||||||
synchronized (iTunes) {
|
synchronized (iTunes) {
|
||||||
iTunes.quit();
|
iTunes.quit();
|
||||||
}
|
}
|
||||||
|
quiting = false;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new DeactivateException();
|
throw new DeactivateException();
|
||||||
} finally {
|
|
||||||
super.deactivate();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void stop() throws DeactivateException {
|
||||||
|
super.stop();
|
||||||
|
volumeWorker.stop();
|
||||||
|
}
|
||||||
|
|
||||||
protected void begin(Action action) {
|
protected void begin(Action action) {
|
||||||
log.trace("iTunesApplication begin: " + action);
|
log.trace("iTunesApplication begin: " + action);
|
||||||
if (!active) return;
|
if (!active) return;
|
||||||
@@ -70,10 +96,18 @@ public class iTunesApplication extends Application implements iTunesEventsInterf
|
|||||||
iTunes.rewind();
|
iTunes.rewind();
|
||||||
break;
|
break;
|
||||||
case VOLUME_UP:
|
case VOLUME_UP:
|
||||||
volume(true);
|
try {
|
||||||
|
volumeWorker.activate(VOLUME_CHANGE_RATE);
|
||||||
|
} catch (ActivateException e) {
|
||||||
|
log.error(e);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case VOLUME_DOWN:
|
case VOLUME_DOWN:
|
||||||
volume(false);
|
try {
|
||||||
|
volumeWorker.activate(-VOLUME_CHANGE_RATE);
|
||||||
|
} catch (ActivateException e) {
|
||||||
|
log.error(e);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -102,7 +136,11 @@ public class iTunesApplication extends Application implements iTunesEventsInterf
|
|||||||
break;
|
break;
|
||||||
case VOLUME_UP:
|
case VOLUME_UP:
|
||||||
case VOLUME_DOWN:
|
case VOLUME_DOWN:
|
||||||
volume = false;
|
try {
|
||||||
|
volumeWorker.deactivate();
|
||||||
|
} catch (DeactivateException e) {
|
||||||
|
log.error(e);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case SHUFFLE:
|
case SHUFFLE:
|
||||||
iTunes.toggleShuffle();
|
iTunes.toggleShuffle();
|
||||||
@@ -119,15 +157,6 @@ public class iTunesApplication extends Application implements iTunesEventsInterf
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void volume(boolean up) {
|
|
||||||
volume = true;
|
|
||||||
while (volume) {
|
|
||||||
int change = (up ? 1 : -1) * VOLUME_CHANGE_RATE;
|
|
||||||
iTunes.setSoundVolume(getVolume() + change);
|
|
||||||
sleep(VOLUME_SLEEP);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected int getVolume() {
|
protected int getVolume() {
|
||||||
return iTunes.getSoundVolume();
|
return iTunes.getSoundVolume();
|
||||||
}
|
}
|
||||||
@@ -150,5 +179,19 @@ public class iTunesApplication extends Application implements iTunesEventsInterf
|
|||||||
public void onCOMCallsEnabledEvent() {}
|
public void onCOMCallsEnabledEvent() {}
|
||||||
public void onQuittingEvent() {}
|
public void onQuittingEvent() {}
|
||||||
public void onAboutToPromptUserToQuitEvent() {}
|
public void onAboutToPromptUserToQuitEvent() {}
|
||||||
public void onSoundVolumeChangedEvent(int newVolume) {}
|
public void onSoundVolumeChangedEvent(int newVolume) {}
|
||||||
|
|
||||||
|
protected class VolumeWorker extends Worker {
|
||||||
|
protected int volumeChangeRate;
|
||||||
|
|
||||||
|
public void activate(int volumeChangeRate) throws ActivateException {
|
||||||
|
super.activate();
|
||||||
|
this.volumeChangeRate = volumeChangeRate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void work() {
|
||||||
|
iTunes.setSoundVolume(getVolume() + volumeChangeRate);
|
||||||
|
sleep(VOLUME_SLEEP);
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
@@ -42,6 +42,7 @@ public abstract class JavaInputDevice extends Device {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void deactivate() throws DeactivateException {
|
public void deactivate() throws DeactivateException {
|
||||||
|
super.deactivate();
|
||||||
if (active) {
|
if (active) {
|
||||||
javaInputListener.deactivate();
|
javaInputListener.deactivate();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import com.melloware.jintellitype.IntellitypeListener;
|
|||||||
import com.melloware.jintellitype.JIntellitype;
|
import com.melloware.jintellitype.JIntellitype;
|
||||||
|
|
||||||
public class JIntellitypeDevice extends Device implements HotkeyListener, IntellitypeListener {
|
public class JIntellitypeDevice extends Device implements HotkeyListener, IntellitypeListener {
|
||||||
protected static final String TITLE = "JIntellitype";
|
protected static final String TITLE = "Keyboard";
|
||||||
|
|
||||||
protected JIntellitypeEventMapCycle eventMapCycle;
|
protected JIntellitypeEventMapCycle eventMapCycle;
|
||||||
protected ArrayList<Hotkey> hotkeyList;
|
protected ArrayList<Hotkey> hotkeyList;
|
||||||
@@ -59,6 +59,10 @@ public class JIntellitypeDevice extends Device implements HotkeyListener, Intell
|
|||||||
super.deactivate();
|
super.deactivate();
|
||||||
jit.removeHotKeyListener(this);
|
jit.removeHotKeyListener(this);
|
||||||
jit.removeIntellitypeListener(this);
|
jit.removeIntellitypeListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stop() throws DeactivateException {
|
||||||
|
super.stop();
|
||||||
jit.cleanUp();
|
jit.cleanUp();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ public class LircDevice extends Device implements LircButtonListener, SignalList
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stop() {
|
public void stop() throws DeactivateException {
|
||||||
multiplexer.stop();
|
multiplexer.stop();
|
||||||
lircService.stop();
|
lircService.stop();
|
||||||
super.stop();
|
super.stop();
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ public enum DenonRC176Button implements LircButton {
|
|||||||
AMP_VOLUME_DOWN ("AMP_VOL_DOWN"),
|
AMP_VOLUME_DOWN ("AMP_VOL_DOWN"),
|
||||||
AMP_POWER ("AMP_POWER"),
|
AMP_POWER ("AMP_POWER"),
|
||||||
AMP_MUTE ("AMP_MUTE"),
|
AMP_MUTE ("AMP_MUTE"),
|
||||||
AMP_NEXT ("TUN_CH_UP"),
|
TUNER_UP ("TUN_CH_UP"),
|
||||||
AMP_PREVIOUS ("TUN_CH_DOWN");
|
TUNER_DOWN ("TUN_CH_DOWN");
|
||||||
|
|
||||||
public static final String NAME = "DENON_RC-176";
|
public static final String NAME = "DENON_RC-176";
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,24 @@ public class DenonRC176EventMap extends EventMap {
|
|||||||
protected static final long serialVersionUID = 1L;
|
protected static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public DenonRC176EventMap() {
|
public DenonRC176EventMap() {
|
||||||
|
/* Mimis */
|
||||||
|
add(DenonRC176Button.TUNER_UP, new Task(Target.MIMIS, Action.NEXT));
|
||||||
|
add(DenonRC176Button.TUNER_DOWN, new Task(Target.MIMIS, Action.PREVIOUS));
|
||||||
|
|
||||||
|
/* Application */
|
||||||
|
add(DenonRC176Button.AMP_POWER, new Task(Target.APPLICATION, Action.ACTIVATE));
|
||||||
|
add(DenonRC176Button.CD_NEXT, new Task(Target.APPLICATION, Action.NEXT));
|
||||||
|
add(DenonRC176Button.CD_PREVIOUS, new Task(Target.APPLICATION, Action.PREVIOUS));
|
||||||
|
add(DenonRC176Button.TAPE_REWIND, new Task(Target.APPLICATION, Action.REWIND));
|
||||||
|
add(DenonRC176Button.CD_PLAY, new Task(Target.APPLICATION, Action.PLAY));
|
||||||
|
add(DenonRC176Button.CD_PAUSE, new Task(Target.APPLICATION, Action.PLAY));
|
||||||
|
add(DenonRC176Button.TAPE_FORWARD, new Task(Target.APPLICATION, Action.FORWARD));
|
||||||
|
add(DenonRC176Button.AMP_MUTE, new Task(Target.APPLICATION, Action.MUTE));
|
||||||
add(DenonRC176Button.AMP_VOLUME_UP, new Task(Target.APPLICATION, Action.VOLUME_UP));
|
add(DenonRC176Button.AMP_VOLUME_UP, new Task(Target.APPLICATION, Action.VOLUME_UP));
|
||||||
|
add(DenonRC176Button.AMP_VOLUME_DOWN, new Task(Target.APPLICATION, Action.VOLUME_DOWN));
|
||||||
|
add(DenonRC176Button.CD_REPEAT, new Task(Target.APPLICATION, Action.REPEAT));
|
||||||
|
add(DenonRC176Button.CD_SHUFFLE, new Task(Target.APPLICATION, Action.SHUFFLE));
|
||||||
|
add(DenonRC176Button.TAPE_AB, new Task(Target.APPLICATION, Action.LIKE));
|
||||||
|
add(DenonRC176Button.TAPE_REC, new Task(Target.APPLICATION, Action.DISLIKE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,13 +18,14 @@ public class PhiliphsRCLE011EventMap extends EventMap {
|
|||||||
add(PhiliphsRCLE011Button.PROGRAM_UP, new Task(Target.APPLICATION, Action.NEXT));
|
add(PhiliphsRCLE011Button.PROGRAM_UP, new Task(Target.APPLICATION, Action.NEXT));
|
||||||
add(PhiliphsRCLE011Button.PROGRAM_DOWN, new Task(Target.APPLICATION, Action.PREVIOUS));
|
add(PhiliphsRCLE011Button.PROGRAM_DOWN, new Task(Target.APPLICATION, Action.PREVIOUS));
|
||||||
add(PhiliphsRCLE011Button.LEFT, new Task(Target.APPLICATION, Action.REWIND));
|
add(PhiliphsRCLE011Button.LEFT, new Task(Target.APPLICATION, Action.REWIND));
|
||||||
add(PhiliphsRCLE011Button.TUNE, new Task(Target.APPLICATION, Action.PAUSE));
|
add(PhiliphsRCLE011Button.TUNE, new Task(Target.APPLICATION, Action.PLAY));
|
||||||
add(PhiliphsRCLE011Button.RIGHT, new Task(Target.APPLICATION, Action.FORWARD));
|
add(PhiliphsRCLE011Button.RIGHT, new Task(Target.APPLICATION, Action.FORWARD));
|
||||||
add(PhiliphsRCLE011Button.VOLUME_DOWN, new Task(Target.APPLICATION, Action.VOLUME_DOWN));
|
add(PhiliphsRCLE011Button.VOLUME_DOWN, new Task(Target.APPLICATION, Action.VOLUME_DOWN));
|
||||||
add(PhiliphsRCLE011Button.MUTE, new Task(Target.APPLICATION, Action.MUTE));
|
add(PhiliphsRCLE011Button.MUTE, new Task(Target.APPLICATION, Action.MUTE));
|
||||||
add(PhiliphsRCLE011Button.VOLUME_UP, new Task(Target.APPLICATION, Action.VOLUME_UP));
|
add(PhiliphsRCLE011Button.VOLUME_UP, new Task(Target.APPLICATION, Action.VOLUME_UP));
|
||||||
add(PhiliphsRCLE011Button.VOLUME_UP, new Task(Target.APPLICATION, Action.VOLUME_UP));
|
|
||||||
add(PhiliphsRCLE011Button.CLOCK, new Task(Target.APPLICATION, Action.REPEAT));
|
add(PhiliphsRCLE011Button.CLOCK, new Task(Target.APPLICATION, Action.REPEAT));
|
||||||
add(PhiliphsRCLE011Button.OUT, new Task(Target.APPLICATION, Action.SHUFFLE));
|
add(PhiliphsRCLE011Button.OUT, new Task(Target.APPLICATION, Action.SHUFFLE));
|
||||||
|
add(PhiliphsRCLE011Button.RED, new Task(Target.APPLICATION, Action.DISLIKE));
|
||||||
|
add(PhiliphsRCLE011Button.GREEN, new Task(Target.APPLICATION, Action.LIKE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import mimis.Event;
|
|||||||
import mimis.Worker;
|
import mimis.Worker;
|
||||||
import mimis.event.Feedback;
|
import mimis.event.Feedback;
|
||||||
import mimis.exception.worker.ActivateException;
|
import mimis.exception.worker.ActivateException;
|
||||||
|
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;
|
||||||
@@ -43,7 +44,7 @@ public class NetworkDevice extends Device {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deactivate() {
|
public void deactivate() throws DeactivateException {
|
||||||
server.stop();
|
server.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,11 +77,11 @@ public class NetworkDevice extends Device {
|
|||||||
} catch (IOException e) {}
|
} catch (IOException e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stop() {
|
public void stop() throws DeactivateException {
|
||||||
|
super.stop();
|
||||||
for (Client client : clientList) {
|
for (Client client : clientList) {
|
||||||
client.stop();
|
client.stop();
|
||||||
}
|
}
|
||||||
super.stop();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,21 +1,29 @@
|
|||||||
package mimis.device.panel;
|
package mimis.device.panel;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.event.WindowEvent;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.WindowConstants;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
|
import mimis.exception.worker.DeactivateException;
|
||||||
import mimis.util.swing.HoldButton;
|
import mimis.util.swing.HoldButton;
|
||||||
import mimis.util.swing.HoldButtonListener;
|
import mimis.util.swing.HoldButtonListener;
|
||||||
import mimis.util.swing.ToggleButton;
|
import mimis.util.swing.ToggleButton;
|
||||||
|
|
||||||
public class Panel extends JFrame implements HoldButtonListener {
|
public class Panel extends JFrame implements HoldButtonListener {
|
||||||
protected static final long serialVersionUID = 1L;
|
protected static final long serialVersionUID = 1L;
|
||||||
|
protected Log log = LogFactory.getLog(getClass());
|
||||||
|
|
||||||
protected final static String TITLE = "MIMIS Panel Device";
|
protected final static String TITLE = "MIMIS Panel Device";
|
||||||
|
|
||||||
protected PanelButtonListener panelButtonListener;
|
protected PanelDevice panelDevice;
|
||||||
protected ClassLoader classLoader;
|
protected ClassLoader classLoader;
|
||||||
protected HoldButton previousButton;
|
protected HoldButton previousButton;
|
||||||
protected HoldButton rewindButton;
|
protected HoldButton rewindButton;
|
||||||
@@ -29,15 +37,16 @@ public class Panel extends JFrame implements HoldButtonListener {
|
|||||||
protected HoldButton repeatButton;
|
protected HoldButton repeatButton;
|
||||||
protected HoldButton shuffleButton;
|
protected HoldButton shuffleButton;
|
||||||
|
|
||||||
Panel(PanelButtonListener panelButtonListener) {
|
Panel(PanelDevice panelDevice) {
|
||||||
super(TITLE);
|
super(TITLE);
|
||||||
this.panelButtonListener = panelButtonListener;
|
this.panelDevice = panelDevice;
|
||||||
classLoader = getClass().getClassLoader();
|
classLoader = getClass().getClassLoader();
|
||||||
createControls();
|
createControls();
|
||||||
layoutControls();
|
layoutControls();
|
||||||
pack();
|
pack();
|
||||||
setResizable(false);
|
setResizable(false);
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
|
setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected URL getResource(String name) {
|
protected URL getResource(String name) {
|
||||||
@@ -109,51 +118,62 @@ public class Panel extends JFrame implements HoldButtonListener {
|
|||||||
/* Listeners */
|
/* Listeners */
|
||||||
public void buttonPressed(HoldButton button) {
|
public void buttonPressed(HoldButton button) {
|
||||||
if (button.equals(previousButton)) {
|
if (button.equals(previousButton)) {
|
||||||
panelButtonListener.buttonPressed(PanelButton.PREVIOUS);
|
panelDevice.buttonPressed(PanelButton.PREVIOUS);
|
||||||
} else if (button.equals(rewindButton)) {
|
} else if (button.equals(rewindButton)) {
|
||||||
panelButtonListener.buttonPressed(PanelButton.REWIND);
|
panelDevice.buttonPressed(PanelButton.REWIND);
|
||||||
} else if (button.equals(playPauseToggleButton)) {
|
} else if (button.equals(playPauseToggleButton)) {
|
||||||
panelButtonListener.buttonPressed(PanelButton.PLAY);
|
panelDevice.buttonPressed(PanelButton.PLAY);
|
||||||
} else if (button.equals(forwardButton)) {
|
} else if (button.equals(forwardButton)) {
|
||||||
panelButtonListener.buttonPressed(PanelButton.FORWARD);
|
panelDevice.buttonPressed(PanelButton.FORWARD);
|
||||||
} else if (button.equals(nextButton)) {
|
} else if (button.equals(nextButton)) {
|
||||||
panelButtonListener.buttonPressed(PanelButton.NEXT);
|
panelDevice.buttonPressed(PanelButton.NEXT);
|
||||||
} else if (button.equals(volumeDownButton)) {
|
} else if (button.equals(volumeDownButton)) {
|
||||||
panelButtonListener.buttonPressed(PanelButton.VOLUME_DOWN);
|
panelDevice.buttonPressed(PanelButton.VOLUME_DOWN);
|
||||||
} else if (button.equals(muteToggleButton)) {
|
} else if (button.equals(muteToggleButton)) {
|
||||||
panelButtonListener.buttonPressed(PanelButton.MUTE);
|
panelDevice.buttonPressed(PanelButton.MUTE);
|
||||||
} else if (button.equals(volumeUpButton)) {
|
} else if (button.equals(volumeUpButton)) {
|
||||||
panelButtonListener.buttonPressed(PanelButton.VOLUME_UP);
|
panelDevice.buttonPressed(PanelButton.VOLUME_UP);
|
||||||
} else if (button.equals(repeatButton)) {
|
} else if (button.equals(repeatButton)) {
|
||||||
panelButtonListener.buttonPressed(PanelButton.REPEAT);
|
panelDevice.buttonPressed(PanelButton.REPEAT);
|
||||||
} else if (button.equals(shuffleButton)) {
|
} else if (button.equals(shuffleButton)) {
|
||||||
panelButtonListener.buttonPressed(PanelButton.SHUFFLE);
|
panelDevice.buttonPressed(PanelButton.SHUFFLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void buttonReleased(HoldButton button) {
|
public void buttonReleased(HoldButton button) {
|
||||||
if (button.equals(previousButton)) {
|
if (button.equals(previousButton)) {
|
||||||
panelButtonListener.buttonReleased(PanelButton.PREVIOUS);
|
panelDevice.buttonReleased(PanelButton.PREVIOUS);
|
||||||
} else if (button.equals(rewindButton)) {
|
} else if (button.equals(rewindButton)) {
|
||||||
panelButtonListener.buttonReleased(PanelButton.REWIND);
|
panelDevice.buttonReleased(PanelButton.REWIND);
|
||||||
} else if (button.equals(playPauseToggleButton)) {
|
} else if (button.equals(playPauseToggleButton)) {
|
||||||
panelButtonListener.buttonReleased(PanelButton.PLAY);
|
panelDevice.buttonReleased(PanelButton.PLAY);
|
||||||
playPauseToggleButton.toggle();
|
playPauseToggleButton.toggle();
|
||||||
} else if (button.equals(forwardButton)) {
|
} else if (button.equals(forwardButton)) {
|
||||||
panelButtonListener.buttonReleased(PanelButton.FORWARD);
|
panelDevice.buttonReleased(PanelButton.FORWARD);
|
||||||
} else if (button.equals(nextButton)) {
|
} else if (button.equals(nextButton)) {
|
||||||
panelButtonListener.buttonReleased(PanelButton.NEXT);
|
panelDevice.buttonReleased(PanelButton.NEXT);
|
||||||
} else if (button.equals(volumeDownButton)) {
|
} else if (button.equals(volumeDownButton)) {
|
||||||
panelButtonListener.buttonReleased(PanelButton.VOLUME_DOWN);
|
panelDevice.buttonReleased(PanelButton.VOLUME_DOWN);
|
||||||
} else if (button.equals(muteToggleButton)) {
|
} else if (button.equals(muteToggleButton)) {
|
||||||
panelButtonListener.buttonReleased(PanelButton.MUTE);
|
panelDevice.buttonReleased(PanelButton.MUTE);
|
||||||
muteToggleButton.toggle();
|
muteToggleButton.toggle();
|
||||||
} else if (button.equals(volumeUpButton)) {
|
} else if (button.equals(volumeUpButton)) {
|
||||||
panelButtonListener.buttonReleased(PanelButton.VOLUME_UP);
|
panelDevice.buttonReleased(PanelButton.VOLUME_UP);
|
||||||
} else if (button.equals(repeatButton)) {
|
} else if (button.equals(repeatButton)) {
|
||||||
panelButtonListener.buttonReleased(PanelButton.REPEAT);
|
panelDevice.buttonReleased(PanelButton.REPEAT);
|
||||||
} else if (button.equals(shuffleButton)) {
|
} else if (button.equals(shuffleButton)) {
|
||||||
panelButtonListener.buttonReleased(PanelButton.SHUFFLE);
|
panelDevice.buttonReleased(PanelButton.SHUFFLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void processWindowEvent(WindowEvent event) {
|
||||||
|
if (event.getID() == WindowEvent.WINDOW_CLOSING) {
|
||||||
|
log.debug("Window closing");
|
||||||
|
try {
|
||||||
|
panelDevice.deactivate();
|
||||||
|
} catch (DeactivateException e) {
|
||||||
|
log.error(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
package mimis.device.panel;
|
|
||||||
|
|
||||||
public interface PanelButtonListener {
|
|
||||||
public void buttonPressed(PanelButton panelButton);
|
|
||||||
public void buttonReleased(PanelButton panelButton);
|
|
||||||
}
|
|
||||||
@@ -1,15 +1,14 @@
|
|||||||
package mimis.device.panel;
|
package mimis.device.panel;
|
||||||
|
|
||||||
import java.awt.event.WindowEvent;
|
|
||||||
|
|
||||||
import javax.swing.WindowConstants;
|
import javax.swing.WindowConstants;
|
||||||
|
|
||||||
import mimis.Device;
|
import mimis.Device;
|
||||||
import mimis.exception.worker.ActivateException;
|
import mimis.exception.worker.ActivateException;
|
||||||
|
import mimis.exception.worker.DeactivateException;
|
||||||
import mimis.sequence.state.Press;
|
import mimis.sequence.state.Press;
|
||||||
import mimis.sequence.state.Release;
|
import mimis.sequence.state.Release;
|
||||||
|
|
||||||
public class PanelDevice extends Device implements PanelButtonListener {
|
public class PanelDevice extends Device {
|
||||||
protected static final String TITLE = "Panel";
|
protected static final String TITLE = "Panel";
|
||||||
protected Panel panel;
|
protected Panel panel;
|
||||||
protected PanelEventMapCycle eventMapCycle;
|
protected PanelEventMapCycle eventMapCycle;
|
||||||
@@ -21,32 +20,19 @@ public class PanelDevice extends Device implements PanelButtonListener {
|
|||||||
|
|
||||||
public void activate() throws ActivateException {
|
public void activate() throws ActivateException {
|
||||||
super.activate();
|
super.activate();
|
||||||
panel = new Panel(this) {
|
panel = new Panel(this);
|
||||||
protected static final long serialVersionUID = 1L;
|
|
||||||
protected void processWindowEvent(WindowEvent e) {
|
|
||||||
log.debug("Window closing");
|
|
||||||
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
|
|
||||||
deactivate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
panel.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
|
panel.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
|
||||||
add(eventMapCycle.player);
|
add(eventMapCycle.player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean active() {
|
public boolean active() {
|
||||||
return active = panel != null && panel.isValid();
|
return active = panel != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deactivate() {
|
public void deactivate() throws DeactivateException {
|
||||||
|
super.deactivate();
|
||||||
panel.dispose();
|
panel.dispose();
|
||||||
}
|
panel = null;
|
||||||
|
|
||||||
protected void processWindowEvent(WindowEvent e) {
|
|
||||||
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
|
|
||||||
log.debug("Window closing");
|
|
||||||
deactivate();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void buttonPressed(PanelButton panelButton) {
|
public void buttonPressed(PanelButton panelButton) {
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ public class WiimoteDevice extends Device implements GestureListener {
|
|||||||
wiimoteDiscovery.disconnect();
|
wiimoteDiscovery.disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stop() {
|
public void stop() throws DeactivateException {
|
||||||
super.stop();
|
super.stop();
|
||||||
wiimoteService.exit();
|
wiimoteService.exit();
|
||||||
}
|
}
|
||||||
@@ -133,8 +133,10 @@ public class WiimoteDevice extends Device implements GestureListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void feedback(Feedback feedback) {
|
public void feedback(Feedback feedback) {
|
||||||
System.out.println("Wiimote feedback");
|
if (active()) {
|
||||||
wiimote.rumble(RUMBLE);
|
log.debug("Wiimote rumble feedback");
|
||||||
|
wiimote.rumble(RUMBLE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Connectivity */
|
/* Connectivity */
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ public class WiimoteDiscovery extends Worker {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stop() {
|
public void stop() throws DeactivateException {
|
||||||
super.stop();
|
super.stop();
|
||||||
disconnect();
|
disconnect();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import java.util.concurrent.ConcurrentLinkedQueue;
|
|||||||
|
|
||||||
import mimis.Event;
|
import mimis.Event;
|
||||||
import mimis.Worker;
|
import mimis.Worker;
|
||||||
|
import mimis.exception.worker.DeactivateException;
|
||||||
|
|
||||||
public abstract class EventListener extends Worker {
|
public abstract class EventListener extends Worker {
|
||||||
protected Queue<Event> eventQueue;
|
protected Queue<Event> eventQueue;
|
||||||
@@ -34,9 +35,9 @@ public abstract class EventListener extends Worker {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
event(eventQueue.poll());
|
event(eventQueue.poll());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stop() {
|
public void stop() throws DeactivateException {
|
||||||
super.stop();
|
super.stop();
|
||||||
synchronized (work) {
|
synchronized (work) {
|
||||||
work.notifyAll();
|
work.notifyAll();
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package mimis.manager;
|
package mimis.manager;
|
||||||
|
|
||||||
|
import mimis.exception.worker.DeactivateException;
|
||||||
|
|
||||||
public interface Exitable {
|
public interface Exitable {
|
||||||
public void stop();
|
public void stop() throws DeactivateException;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,7 +80,6 @@ public class SequenceParser {
|
|||||||
protected synchronized void add(Event event, Signal signal) {
|
protected synchronized void add(Event event, Signal signal) {
|
||||||
if (event instanceof Task) {
|
if (event instanceof Task) {
|
||||||
event = ((Task) event).setSignal(signal);
|
event = ((Task) event).setSignal(signal);
|
||||||
|
|
||||||
}
|
}
|
||||||
if (event.getTarget().equals(Target.SELF)) {
|
if (event.getTarget().equals(Target.SELF)) {
|
||||||
self.add(event);
|
self.add(event);
|
||||||
|
|||||||
@@ -6,33 +6,16 @@ public class ArrayCycle<E> extends ArrayList<E> {
|
|||||||
protected static final long serialVersionUID = 1L;
|
protected static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
protected int index = 0;
|
protected int index = 0;
|
||||||
//protected Object nonEmpty;
|
|
||||||
|
|
||||||
public ArrayCycle(E... elementArray) {
|
public ArrayCycle(E... elementArray) {
|
||||||
if (elementArray != null) {
|
if (elementArray != null) {
|
||||||
//nonEmpty = new Object();
|
|
||||||
for (E element : elementArray) {
|
for (E element : elementArray) {
|
||||||
add(element);
|
add(element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*public boolean add(E element) {
|
|
||||||
boolean result = super.add(element);
|
|
||||||
synchronized (nonEmpty) {
|
|
||||||
nonEmpty.notifyAll();
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
public E current() {
|
public E current() {
|
||||||
/*while (index == 0) {
|
|
||||||
synchronized (nonEmpty) {
|
|
||||||
try {
|
|
||||||
nonEmpty.wait();
|
|
||||||
} catch (InterruptedException e) {}
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
return this.get(index);
|
return this.get(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user