Applicaties gecontroleerd: GOM, MPC, VLC
Bugs opgelost: Extreme3D WiiMote Mooier favicon toegevoegd.
This commit is contained in:
@@ -14,7 +14,6 @@
|
|||||||
<classpathentry kind="lib" path="lib/jacob-1.15-M3.jar"/>
|
<classpathentry kind="lib" path="lib/jacob-1.15-M3.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/nativecall-0.4.1.jar"/>
|
<classpathentry kind="lib" path="lib/nativecall-0.4.1.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/nativeloader-200505172341.jar"/>
|
<classpathentry kind="lib" path="lib/nativeloader-200505172341.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/TableLayout.jar"/>
|
|
||||||
<classpathentry kind="lib" path="lib/jxinput.jar"/>
|
<classpathentry kind="lib" path="lib/jxinput.jar"/>
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 9.3 KiB After Width: | Height: | Size: 15 KiB |
@@ -6,6 +6,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
import javax.swing.JToggleButton;
|
import javax.swing.JToggleButton;
|
||||||
|
|
||||||
|
import mimis.application.cmd.windows.winamp.WinampApplication;
|
||||||
import mimis.exception.worker.DeactivateException;
|
import mimis.exception.worker.DeactivateException;
|
||||||
import mimis.manager.Exitable;
|
import mimis.manager.Exitable;
|
||||||
import mimis.manager.ManageButton;
|
import mimis.manager.ManageButton;
|
||||||
@@ -30,7 +31,9 @@ public class Manager<T extends Worker & Titled & Exitable> extends Worker {
|
|||||||
public void stop() throws DeactivateException {
|
public void stop() throws DeactivateException {
|
||||||
super.stop();
|
super.stop();
|
||||||
for (T manageable : manageableArray) {
|
for (T manageable : manageableArray) {
|
||||||
manageable.stop();
|
if (!(manageable instanceof WinampApplication)) {
|
||||||
|
manageable.stop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,10 +22,14 @@ public abstract class CMDApplication extends Application {
|
|||||||
this.title = title;
|
this.title = title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getPath() {
|
||||||
|
String key = String.format("%s\\%s", REGISTRY, program);
|
||||||
|
return Native.getValue(key);
|
||||||
|
}
|
||||||
|
|
||||||
public void activate() throws ActivateException {
|
public void activate() throws ActivateException {
|
||||||
super.activate();
|
super.activate();
|
||||||
String key = String.format("%s\\%s", REGISTRY, program);
|
String path = getPath();
|
||||||
String path = Native.getValue(key);
|
|
||||||
if (path == null) {
|
if (path == null) {
|
||||||
throw new ActivateException();
|
throw new ActivateException();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,12 @@ public class GomPlayerApplication extends WindowsApplication {
|
|||||||
volumeWorker = new VolumeWorker();
|
volumeWorker = new VolumeWorker();
|
||||||
seekWorker = new SeekWorker();
|
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("GomPlayerApplication begin: " + action);
|
log.trace("GomPlayerApplication begin: " + action);
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
package mimis.application.mpc;
|
package mimis.application.mpc;
|
||||||
|
|
||||||
|
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 MPCApplication extends WindowsApplication {
|
public class MPCApplication extends WindowsApplication {
|
||||||
@@ -8,11 +11,41 @@ public class MPCApplication extends WindowsApplication {
|
|||||||
protected final static String TITLE = "Media Player Classic";
|
protected final static String TITLE = "Media Player Classic";
|
||||||
protected final static String NAME = "MediaPlayerClassicW";
|
protected final static String NAME = "MediaPlayerClassicW";
|
||||||
|
|
||||||
|
protected static final int VOLUME_SLEEP = 50;
|
||||||
|
protected static final int SEEK_SLEEP = 50;
|
||||||
|
|
||||||
|
protected VolumeWorker volumeWorker;
|
||||||
|
protected SeekWorker seekWorker;
|
||||||
|
|
||||||
public MPCApplication() {
|
public MPCApplication() {
|
||||||
super(PROGRAM, TITLE, NAME);
|
super(PROGRAM, TITLE, NAME);
|
||||||
|
volumeWorker = new VolumeWorker();
|
||||||
|
seekWorker = new SeekWorker();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void action(Action action) {
|
public void begin(Action action) {
|
||||||
|
log.trace("MPCApplication: " + action);
|
||||||
|
try {
|
||||||
|
switch (action) {
|
||||||
|
case FORWARD:
|
||||||
|
seekWorker.activate(1);
|
||||||
|
break;
|
||||||
|
case REWIND:
|
||||||
|
seekWorker.activate(-1);
|
||||||
|
break;
|
||||||
|
case VOLUME_UP:
|
||||||
|
volumeWorker.activate(1);
|
||||||
|
break;
|
||||||
|
case VOLUME_DOWN:
|
||||||
|
volumeWorker.activate(-1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (ActivateException e) {
|
||||||
|
log.error(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void end(Action action) {
|
||||||
log.trace("MPCApplication: " + action);
|
log.trace("MPCApplication: " + action);
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case PLAY:
|
case PLAY:
|
||||||
@@ -25,19 +58,23 @@ public class MPCApplication extends WindowsApplication {
|
|||||||
command(920);
|
command(920);
|
||||||
break;
|
break;
|
||||||
case FORWARD:
|
case FORWARD:
|
||||||
command(900);
|
|
||||||
break;
|
|
||||||
case REWIND:
|
case REWIND:
|
||||||
command(889);
|
try {
|
||||||
|
seekWorker.deactivate();
|
||||||
|
} catch (DeactivateException e) {
|
||||||
|
log.error(e);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case MUTE:
|
case MUTE:
|
||||||
command(909);
|
command(909);
|
||||||
break;
|
break;
|
||||||
case VOLUME_UP:
|
case VOLUME_UP:
|
||||||
command(907);
|
|
||||||
break;
|
|
||||||
case VOLUME_DOWN:
|
case VOLUME_DOWN:
|
||||||
command(908);
|
try {
|
||||||
|
volumeWorker.deactivate();
|
||||||
|
} catch (DeactivateException e) {
|
||||||
|
log.error(e);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case FULLSCREEN:
|
case FULLSCREEN:
|
||||||
command(830);
|
command(830);
|
||||||
@@ -49,4 +86,31 @@ public class MPCApplication extends WindowsApplication {
|
|||||||
return TITLE;
|
return TITLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 ? 907 : 908);
|
||||||
|
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 ? 900 : 889);
|
||||||
|
sleep(SEEK_SLEEP);
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,37 +4,56 @@ import java.io.IOException;
|
|||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import mimis.Worker;
|
||||||
import mimis.application.cmd.CMDApplication;
|
import mimis.application.cmd.CMDApplication;
|
||||||
|
import mimis.exception.worker.ActivateException;
|
||||||
|
import mimis.exception.worker.DeactivateException;
|
||||||
|
import mimis.util.Native;
|
||||||
import mimis.value.Action;
|
import mimis.value.Action;
|
||||||
|
import mimis.value.Amount;
|
||||||
|
|
||||||
public class VLCApplication extends CMDApplication {
|
public class VLCApplication extends CMDApplication {
|
||||||
|
protected final static String REGISTRY = "HKEY_CLASSES_ROOT\\Applications\\vlc.exe\\shell\\Open\\command";
|
||||||
protected final static String PROGRAM = "vlc.exe";
|
protected final static String PROGRAM = "vlc.exe";
|
||||||
protected final static String TITLE = "VLC media player";
|
protected final static String TITLE = "VLC media player";
|
||||||
|
|
||||||
protected static final int POSTION_CHANGE_RATE = 1;
|
protected static final int POSTION_CHANGE_RATE = 1;
|
||||||
protected static final int VOLUME_CHANGE_RATE = 20;
|
protected static final int VOLUME_CHANGE_RATE = 20;
|
||||||
|
|
||||||
protected static final String HOST = "127.0.0.1"; // localhost
|
protected static final String HOST = "localhost";
|
||||||
protected static final int PORT = 1234;
|
protected static final int PORT = 8080;
|
||||||
|
|
||||||
|
protected static final int VOLUME_SLEEP = 100;
|
||||||
|
protected static final int SEEK_SLEEP = 100;
|
||||||
|
|
||||||
|
protected VolumeWorker volumeWorker;
|
||||||
|
protected SeekWorker seekWorker;
|
||||||
|
|
||||||
protected int volume = 255;
|
protected int volume = 255;
|
||||||
protected boolean muted = false;
|
protected boolean muted = false;
|
||||||
|
|
||||||
public VLCApplication() {
|
public VLCApplication() {
|
||||||
super(PROGRAM, TITLE);
|
super(PROGRAM, TITLE);
|
||||||
|
volumeWorker = new VolumeWorker();
|
||||||
|
seekWorker = new SeekWorker();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPath() {
|
||||||
|
Pattern pattern = Pattern.compile("\"([^\"]+)\"");
|
||||||
|
Matcher matcher = pattern.matcher(Native.getValue(REGISTRY));
|
||||||
|
return matcher.find() ? matcher.group(1) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void command(String command) {
|
public void command(String command) {
|
||||||
//String request = "http://" + HOST + ":" + PORT + "/requests/status.xml?command=" + command;
|
|
||||||
String request = String.format("http://%s:%d/requests/status.xml?command=%s", HOST, PORT, command);
|
String request = String.format("http://%s:%d/requests/status.xml?command=%s", HOST, PORT, command);
|
||||||
try {
|
try {
|
||||||
// Todo: check response voor 200, status ok
|
|
||||||
//int response = ((HttpURLConnection)(new URL(request)).openConnection()).getResponseCode();
|
|
||||||
URL url = new URL(request);
|
URL url = new URL(request);
|
||||||
HttpURLConnection httpUrlConnection = (HttpURLConnection) url.openConnection();
|
HttpURLConnection httpUrlConnection = (HttpURLConnection) url.openConnection();
|
||||||
int response = httpUrlConnection.getResponseCode();
|
int response = httpUrlConnection.getResponseCode();
|
||||||
log.debug("Response: " + response);
|
log.trace("Response: " + response);
|
||||||
} catch (MalformedURLException e) {
|
} catch (MalformedURLException e) {
|
||||||
log.error(e);
|
log.error(e);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@@ -42,6 +61,34 @@ public class VLCApplication extends CMDApplication {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void stop() throws DeactivateException {
|
||||||
|
super.stop();
|
||||||
|
volumeWorker.stop();
|
||||||
|
seekWorker.stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void begin(Action action) {
|
||||||
|
log.trace("VLCApplication begin: " + action);
|
||||||
|
try {
|
||||||
|
switch (action) {
|
||||||
|
case VOLUME_UP:
|
||||||
|
volumeWorker.activate("+");
|
||||||
|
break;
|
||||||
|
case VOLUME_DOWN:
|
||||||
|
volumeWorker.activate("-");
|
||||||
|
break;
|
||||||
|
case FORWARD:
|
||||||
|
seekWorker.activate(Amount.SMALL, "+");
|
||||||
|
break;
|
||||||
|
case REWIND:
|
||||||
|
seekWorker.activate(Amount.SMALL, "-");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (ActivateException e) {
|
||||||
|
log.error(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void end(Action action) {
|
public void end(Action action) {
|
||||||
log.trace("VLCApplication end: " + action);
|
log.trace("VLCApplication end: " + action);
|
||||||
switch (action) {
|
switch (action) {
|
||||||
@@ -58,19 +105,23 @@ public class VLCApplication extends CMDApplication {
|
|||||||
command("pl_previous");
|
command("pl_previous");
|
||||||
break;
|
break;
|
||||||
case FORWARD:
|
case FORWARD:
|
||||||
command("command=seek&val=+" + POSTION_CHANGE_RATE);
|
|
||||||
break;
|
|
||||||
case REWIND:
|
case REWIND:
|
||||||
command("command=seek&val=-" + POSTION_CHANGE_RATE);
|
try {
|
||||||
|
seekWorker.deactivate();
|
||||||
|
} catch (DeactivateException e) {
|
||||||
|
log.error(e);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case MUTE:
|
case MUTE:
|
||||||
command("volume&val=" + toggleMute());
|
command("volume&val=" + toggleMute());
|
||||||
break;
|
break;
|
||||||
case VOLUME_UP:
|
case VOLUME_UP:
|
||||||
volumeUp();
|
|
||||||
break;
|
|
||||||
case VOLUME_DOWN:
|
case VOLUME_DOWN:
|
||||||
volumeDown();
|
try {
|
||||||
|
volumeWorker.deactivate();
|
||||||
|
} catch (DeactivateException e) {
|
||||||
|
log.error(e);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case SHUFFLE:
|
case SHUFFLE:
|
||||||
command("command=pl_random");
|
command("command=pl_random");
|
||||||
@@ -102,4 +153,45 @@ public class VLCApplication extends CMDApplication {
|
|||||||
public String title() {
|
public String title() {
|
||||||
return TITLE;
|
return TITLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected class VolumeWorker extends Worker {
|
||||||
|
protected String volumeChangeSign;
|
||||||
|
|
||||||
|
public void activate(String volumeChangeSign) throws ActivateException {
|
||||||
|
super.activate();
|
||||||
|
this.volumeChangeSign = volumeChangeSign;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void work() {
|
||||||
|
volume += VOLUME_CHANGE_RATE;
|
||||||
|
command("volume&val=" + volumeChangeSign + VOLUME_CHANGE_RATE);
|
||||||
|
sleep(VOLUME_SLEEP);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
protected class SeekWorker extends Worker {
|
||||||
|
protected Amount amount;
|
||||||
|
protected String seekDirection;
|
||||||
|
|
||||||
|
public void activate(Amount amount, String seekDirection) throws ActivateException {
|
||||||
|
super.activate();
|
||||||
|
this.amount = amount;
|
||||||
|
this.seekDirection = seekDirection;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void work() {
|
||||||
|
switch (amount) {
|
||||||
|
case SMALL:
|
||||||
|
command("command=seek&val=" + seekDirection + POSTION_CHANGE_RATE);
|
||||||
|
break;
|
||||||
|
case MEDIUM:
|
||||||
|
command("command=seek&val=" + seekDirection + POSTION_CHANGE_RATE * 2);
|
||||||
|
break;
|
||||||
|
case LARGE:
|
||||||
|
command("command=seek&val=" + seekDirection + POSTION_CHANGE_RATE * 3);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
sleep(SEEK_SLEEP);
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,9 +48,7 @@ public abstract class JavaInputDevice extends Device {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void processEvent(JXInputAxisEvent event) {
|
public void processEvent(JXInputAxisEvent event) {}
|
||||||
//log.trace("JXInputAxisEvent: " + event);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void processEvent(JXInputButtonEvent event) throws ButtonException {
|
public void processEvent(JXInputButtonEvent event) throws ButtonException {
|
||||||
Button button = getButton(event);
|
Button button = getButton(event);
|
||||||
|
|||||||
@@ -6,8 +6,6 @@ import java.util.Queue;
|
|||||||
import mimis.Worker;
|
import mimis.Worker;
|
||||||
import mimis.exception.ButtonException;
|
import mimis.exception.ButtonException;
|
||||||
|
|
||||||
|
|
||||||
import de.hardcode.jxinput.Axis;
|
|
||||||
import de.hardcode.jxinput.Button;
|
import de.hardcode.jxinput.Button;
|
||||||
import de.hardcode.jxinput.Directional;
|
import de.hardcode.jxinput.Directional;
|
||||||
import de.hardcode.jxinput.JXInputDevice;
|
import de.hardcode.jxinput.JXInputDevice;
|
||||||
@@ -37,12 +35,12 @@ public class JavaInputListener extends Worker implements Runnable, JXInputAxisEv
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void addListeners() {
|
protected void addListeners() {
|
||||||
for (int i = 0; i < jxinputDevice.getMaxNumberOfAxes(); ++i) {
|
/*for (int i = 0; i < jxinputDevice.getMaxNumberOfAxes(); ++i) {
|
||||||
Axis axis = jxinputDevice.getAxis(i);
|
Axis axis = jxinputDevice.getAxis(i);
|
||||||
if (axis != null) {
|
if (axis != null) {
|
||||||
JXInputEventManager.addListener(this, axis);
|
JXInputEventManager.addListener(this, axis);
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
for (int i = 0; i < jxinputDevice.getMaxNumberOfButtons(); ++i) {
|
for (int i = 0; i < jxinputDevice.getMaxNumberOfButtons(); ++i) {
|
||||||
Button button = jxinputDevice.getButton(i);
|
Button button = jxinputDevice.getButton(i);
|
||||||
if (button != null) {
|
if (button != null) {
|
||||||
|
|||||||
@@ -5,18 +5,18 @@ import mimis.exception.button.UnknownButtonException;
|
|||||||
import de.hardcode.jxinput.event.JXInputButtonEvent;
|
import de.hardcode.jxinput.event.JXInputButtonEvent;
|
||||||
|
|
||||||
public enum Extreme3DButton implements Button {
|
public enum Extreme3DButton implements Button {
|
||||||
ONE ("ManageButton 0"),
|
ONE ("Button 0"),
|
||||||
TWO ("ManageButton 1"),
|
TWO ("Button 1"),
|
||||||
THREE ("ManageButton 2"),
|
THREE ("Button 2"),
|
||||||
FOUR ("ManageButton 3"),
|
FOUR ("Button 3"),
|
||||||
FIVE ("ManageButton 4"),
|
FIVE ("Button 4"),
|
||||||
SIX ("ManageButton 5"),
|
SIX ("Button 5"),
|
||||||
SEVEN ("ManageButton 6"),
|
SEVEN ("Button 6"),
|
||||||
EIGHT ("ManageButton 7"),
|
EIGHT ("Button 7"),
|
||||||
NINE ("ManageButton 8"),
|
NINE ("Button 8"),
|
||||||
TEN ("ManageButton 9"),
|
TEN ("Button 9"),
|
||||||
ELEVEN ("ManageButton 10"),
|
ELEVEN ("Button 10"),
|
||||||
TWELVE ("ManageButton 11");
|
TWELVE ("Button 11");
|
||||||
|
|
||||||
protected String code;
|
protected String code;
|
||||||
|
|
||||||
|
|||||||
@@ -48,9 +48,9 @@ public class WiimoteDevice extends Device implements GestureListener {
|
|||||||
|
|
||||||
/* Worker */
|
/* Worker */
|
||||||
public void activate() throws ActivateException {
|
public void activate() throws ActivateException {
|
||||||
super.activate();
|
|
||||||
connect();
|
connect();
|
||||||
add(eventMapCycle.player);
|
add(eventMapCycle.player);
|
||||||
|
super.activate();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean active() {
|
public boolean active() {
|
||||||
@@ -133,7 +133,7 @@ public class WiimoteDevice extends Device implements GestureListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void feedback(Feedback feedback) {
|
public void feedback(Feedback feedback) {
|
||||||
if (active()) {
|
if (wiimote != null && active()) {
|
||||||
log.debug("Wiimote rumble feedback");
|
log.debug("Wiimote rumble feedback");
|
||||||
wiimote.rumble(RUMBLE);
|
wiimote.rumble(RUMBLE);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user