Snapshot of mimis part
This commit is contained in:
@@ -28,6 +28,7 @@ import mimis.router.Router;
|
||||
import mimis.state.TaskMap;
|
||||
import mimis.value.Action;
|
||||
import base.work.Listen;
|
||||
import base.worker.Worker;
|
||||
import base.worker.Worker.Type;
|
||||
|
||||
public abstract class Component extends Listen<Input> {
|
||||
@@ -45,6 +46,7 @@ public abstract class Component extends Listen<Input> {
|
||||
}
|
||||
|
||||
public Component(String title) {
|
||||
super(Worker.Type.BACKGROUND);
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,8 +27,11 @@ import javax.swing.WindowConstants;
|
||||
import base.exception.worker.ActivateException;
|
||||
import mimis.input.Feedback;
|
||||
import mimis.input.Input;
|
||||
import mimis.input.Task;
|
||||
import mimis.manager.ButtonManager;
|
||||
import mimis.util.Swing;
|
||||
import mimis.value.Action;
|
||||
import mimis.value.Target;
|
||||
|
||||
public class Gui extends Component {
|
||||
public static final String ICON = "M.png";
|
||||
@@ -44,6 +47,7 @@ public class Gui extends Component {
|
||||
protected void processWindowEvent(WindowEvent event) {
|
||||
if (event.getID() == WindowEvent.WINDOW_CLOSING) {
|
||||
logger.debug("Window closing");
|
||||
route(new Task(Action.EXIT, Target.MIMIS));
|
||||
component.exit();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,11 +37,10 @@ public class Main extends Mimis {
|
||||
try {
|
||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||
} catch (Exception e) {}
|
||||
|
||||
}
|
||||
|
||||
public static Component[] getApplications() {
|
||||
return getComponents(mimis.application.Application.class);
|
||||
return getComponents(mimis.application.Application.class);
|
||||
}
|
||||
|
||||
public static Component[] getDevices() {
|
||||
@@ -96,6 +95,9 @@ public class Main extends Mimis {
|
||||
logger.debug("Exit managers");
|
||||
applicationManager.exit();
|
||||
deviceManager.exit();
|
||||
gui.exit();
|
||||
router.exit();
|
||||
parser.exit();
|
||||
}
|
||||
|
||||
public void end(Action action) {
|
||||
|
||||
@@ -31,6 +31,7 @@ import base.worker.Worker;
|
||||
public abstract class Mimis extends Component {
|
||||
protected Component[] currentArray;
|
||||
protected Manager manager;
|
||||
protected Parser parser;
|
||||
|
||||
protected ArrayCycle<Component> componentCycle;
|
||||
|
||||
@@ -39,7 +40,8 @@ public abstract class Mimis extends Component {
|
||||
this.currentArray = initialize(false, currentArray);
|
||||
componentCycle = new ArrayCycle<Component>(currentArray);
|
||||
router = new Router();
|
||||
manager = new Manager(initialize(true, router, new Parser()));
|
||||
parser = new Parser();
|
||||
manager = new Manager(initialize(true, router, parser));
|
||||
}
|
||||
|
||||
public void activate() throws ActivateException {
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
*/
|
||||
package mimis.application;
|
||||
|
||||
|
||||
public interface Application {
|
||||
|
||||
}
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
*/
|
||||
package mimis.device.javainput;
|
||||
|
||||
import base.exception.worker.ActivateException;
|
||||
import base.exception.worker.DeactivateException;
|
||||
import mimis.Component;
|
||||
import mimis.device.Device;
|
||||
import mimis.exception.ButtonException;
|
||||
@@ -27,6 +25,9 @@ import mimis.exception.device.DeviceNotFoundException;
|
||||
import mimis.input.Button;
|
||||
import mimis.input.state.Press;
|
||||
import mimis.input.state.Release;
|
||||
import base.exception.worker.ActivateException;
|
||||
import base.exception.worker.DeactivateException;
|
||||
import de.hardcode.jxinput.Axis;
|
||||
import de.hardcode.jxinput.JXInputDevice;
|
||||
import de.hardcode.jxinput.JXInputManager;
|
||||
import de.hardcode.jxinput.event.JXInputAxisEvent;
|
||||
@@ -61,7 +62,16 @@ public abstract class JavaInputDevice extends Component implements Device {
|
||||
javaInputListener.stop();
|
||||
}
|
||||
|
||||
public void processEvent(JXInputAxisEvent event) {}
|
||||
public void processEvent(JXInputAxisEvent event) {
|
||||
logger.error("AxisEvent");
|
||||
Axis axis = event.getAxis();
|
||||
double delta = event.getDelta();
|
||||
System.out.println(axis.getName());
|
||||
System.out.println(axis.getResolution());
|
||||
System.out.println(axis.getType());
|
||||
System.out.println(axis.getValue());
|
||||
System.out.println(delta);
|
||||
}
|
||||
|
||||
public void processEvent(JXInputButtonEvent event) throws ButtonException {
|
||||
Button button = getButton(event);
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.util.Queue;
|
||||
|
||||
import mimis.exception.ButtonException;
|
||||
import base.work.Work;
|
||||
import de.hardcode.jxinput.Axis;
|
||||
import de.hardcode.jxinput.Button;
|
||||
import de.hardcode.jxinput.Directional;
|
||||
import de.hardcode.jxinput.JXInputDevice;
|
||||
@@ -50,12 +51,12 @@ public class JavaInputListener extends Work implements JXInputAxisEventListener,
|
||||
}
|
||||
|
||||
protected void addListeners() {
|
||||
/*for (int i = 0; i < jxinputDevice.getMaxNumberOfAxes(); ++i) {
|
||||
for (int i = 0; i < jxinputDevice.getMaxNumberOfAxes(); ++i) {
|
||||
Axis axis = jxinputDevice.getAxis(i);
|
||||
if (axis != null) {
|
||||
JXInputEventManager.addListener(this, axis);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
for (int i = 0; i < jxinputDevice.getMaxNumberOfButtons(); ++i) {
|
||||
Button button = jxinputDevice.getButton(i);
|
||||
if (button != null) {
|
||||
@@ -89,11 +90,11 @@ public class JavaInputListener extends Work implements JXInputAxisEventListener,
|
||||
} else if (!buttonEventQueue.isEmpty()) {
|
||||
try {
|
||||
javaInputDevice.processEvent(buttonEventQueue.poll());
|
||||
} catch (ButtonException e) {}
|
||||
} catch (ButtonException e) {logger.error("fail", e);}
|
||||
} else if (!directionalEventQueue.isEmpty()) {
|
||||
try {
|
||||
javaInputDevice.processEvent(directionalEventQueue.poll());
|
||||
} catch (ButtonException e) {}
|
||||
} catch (ButtonException e) {logger.error("fail", e);}
|
||||
} else {
|
||||
worker.sleep();
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import base.exception.worker.ActivateException;
|
||||
import mimis.Component;
|
||||
import mimis.input.Input;
|
||||
import mimis.input.Task;
|
||||
@@ -31,6 +30,7 @@ import mimis.state.TaskMap;
|
||||
import mimis.value.Action;
|
||||
import mimis.value.Signal;
|
||||
import mimis.value.Target;
|
||||
import base.exception.worker.ActivateException;
|
||||
|
||||
public class Parser extends Component {
|
||||
protected TaskMap taskMap;
|
||||
@@ -71,6 +71,8 @@ public class Parser extends Component {
|
||||
case RESET:
|
||||
reset(parserInput.getComponent(), parserInput.getEnd());
|
||||
return;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} catch (NullPointerException e) {
|
||||
logger.error("Illegal use of ParserInput");
|
||||
@@ -78,7 +80,7 @@ public class Parser extends Component {
|
||||
}
|
||||
|
||||
public void input(State state) {
|
||||
//log.trace("input(State)");
|
||||
logger.trace("input(State)");
|
||||
Component component = state.getComponent();
|
||||
if (!activeMap.containsKey(component)) {
|
||||
activeMap.put(component, new ArrayList<Active>());
|
||||
|
||||
@@ -35,6 +35,7 @@ public class Router extends Component {
|
||||
}
|
||||
|
||||
public synchronized void listen(Component component, Class<? extends Input> clazz) {
|
||||
logger.debug(component + " is listening to " + clazz);
|
||||
if (!listenMap.containsKey(component)) {
|
||||
listenMap.put(component, new ArrayList<Class<? extends Input>>());
|
||||
}
|
||||
@@ -54,11 +55,16 @@ public class Router extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void input(Input input) {
|
||||
public void input(Input input) {
|
||||
for (Entry<Component, ArrayList<Class<? extends Input>>> entry : listenMap.entrySet()) {
|
||||
Component component = entry.getKey();
|
||||
|
||||
if (input instanceof Task) {
|
||||
System.err.println(component + " " + target((Task) input, component));
|
||||
|
||||
Task x = (Task) input;
|
||||
System.err.println(x.getTarget());
|
||||
|
||||
if (!target((Task) input, component)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -52,5 +52,4 @@ public class TaskMap extends HashMap<Sequence, Task> implements Input {
|
||||
public void add(Sequence sequence, Task task) {
|
||||
put(sequence, task);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ public class Reader {
|
||||
while ((line = bufferedReader.readLine()) != null) {
|
||||
stringBuffer.append(line + "\n");
|
||||
}
|
||||
bufferedReader.close();
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,2 @@
|
||||
mimis.application.cmd.windows.gomplayer.GomPlayerApplication
|
||||
mimis.application.cmd.windows.photoviewer.PhotoViewerApplication
|
||||
mimis.application.cmd.windows.winamp.WinampApplication
|
||||
mimis.application.cmd.windows.wmp.WMPApplication
|
||||
mimis.application.itunes.iTunesApplication
|
||||
mimis.application.lirc.ipod.iPodApplication
|
||||
mimis.application.mpc.MPCApplication
|
||||
mimis.application.vlc.VLCApplication
|
||||
mimis.application.itunes.iTunesApplication
|
||||
mimis.application.cmd.windows.lightroom.LightroomApplication
|
||||
@@ -1,7 +1,6 @@
|
||||
mimis.device.javainput.extreme3d.Extreme3DDevice
|
||||
mimis.device.javainput.rumblepad.RumblepadDevice
|
||||
mimis.device.jintellitype.JIntellitypeDevice
|
||||
mimis.device.lirc.LircDevice
|
||||
mimis.device.network.NetworkDevice
|
||||
mimis.device.panel.PanelDevice
|
||||
mimis.device.javainput.extreme3d.Extreme3DDevice
|
||||
mimis.device.javainput.rumblepad.RumblepadDevice
|
||||
mimis.device.javainput.xbox360.Xbox360Device
|
||||
mimis.device.jintellitype.JIntellitypeDevice
|
||||
mimis.device.panel.PanelDevice
|
||||
mimis.device.wiimote.WiimoteDevice
|
||||
@@ -1,4 +1,4 @@
|
||||
log4j.rootLogger=TRACE, CA
|
||||
log4j.rootLogger=INFO, CA
|
||||
log4j.appender.CA=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.CA.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.CA.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
|
||||
|
||||
Reference in New Issue
Block a user