Move files from core.mimis to relevant subprojects

This commit is contained in:
2016-07-11 22:18:05 +01:00
parent c8e113cdfb
commit 60b10632d5
55 changed files with 59 additions and 71 deletions

View File

@@ -0,0 +1,3 @@
dependencies {
compile project(':core.input')
}

View File

@@ -0,0 +1,57 @@
/**
* Copyright (C) 2015 Rik Veenboer <rik.veenboer@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package mimis.device.javainput.xbox360;
import mimis.exception.button.UnknownButtonException;
import mimis.input.Button;
import de.hardcode.jxinput.event.JXInputButtonEvent;
public enum Xbox360Button implements Button {
GREEN ("Button 0"), // A
RED ("Button 1"), // B
BLUE ("Button 2"), // X
YELLOW ("Button 3"), // Y
LB ("Button 4"),
RB ("Button 5"),
BACK ("Button 6"),
START ("Button 7"),
LEFT_STICK ("Button 8"),
RIGHT_STICK ("Button 9");
protected String code;
private Xbox360Button(String code) {
this.code = code;
}
public String getCode() {
return code;
}
public static Xbox360Button create(String code) throws UnknownButtonException {
for (Xbox360Button button : Xbox360Button.values()) {
if (button.getCode().equals(code)) {
return button;
}
}
throw new UnknownButtonException();
}
public static Xbox360Button create(JXInputButtonEvent event) throws UnknownButtonException {
return create(event.getButton().getName());
}
}

View File

@@ -0,0 +1,53 @@
/**
* Copyright (C) 2015 Rik Veenboer <rik.veenboer@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package mimis.device.javainput.xbox360;
import base.exception.worker.ActivateException;
import de.hardcode.jxinput.event.JXInputButtonEvent;
import de.hardcode.jxinput.event.JXInputDirectionalEvent;
import mimis.device.javainput.DirectionButton;
import mimis.device.javainput.JavaInputDevice;
import mimis.exception.button.UnknownButtonException;
import mimis.exception.button.UnknownDirectionException;
import mimis.input.Button;
import mimis.value.Action;
public class Xbox360Device extends JavaInputDevice {
protected static final String TITLE = "Xbox360";
protected static final String NAME = "Controller (XBOX 360 For Windows)";
protected static Xbox360TaskMapCycle taskMapCycle;
public Xbox360Device() {
super(TITLE, NAME);
taskMapCycle = new Xbox360TaskMapCycle();
}
public void activate() throws ActivateException {
super.activate();
parser(Action.ADD, taskMapCycle.mimis);
parser(Action.ADD, taskMapCycle.player);
}
protected Button getButton(JXInputButtonEvent event) throws UnknownButtonException {
return Xbox360Button.create(event);
}
protected Button getButton(JXInputDirectionalEvent event) throws UnknownDirectionException {
return DirectionButton.create(event);
}
}

View File

@@ -0,0 +1,59 @@
/**
* Copyright (C) 2015 Rik Veenboer <rik.veenboer@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package mimis.device.javainput.xbox360;
import mimis.device.javainput.DirectionButton;
import mimis.input.Task;
import mimis.input.state.Press;
import mimis.state.TaskMap;
import mimis.state.TaskMapCycle;
import mimis.value.Action;
import mimis.value.Target;
public class Xbox360TaskMapCycle extends TaskMapCycle {
protected static final long serialVersionUID = 1L;
public TaskMap mimis, player;
public Xbox360TaskMapCycle() {
/* Mimis */
mimis = new TaskMap();
mimis.add(
new Press(Xbox360Button.GREEN),
new Task(Action.PREVIOUS, Target.MAIN));
mimis.add(
new Press(Xbox360Button.RED),
new Task(Action.NEXT, Target.MAIN));
add(mimis);
/* Player */
player = new TaskMap();
player.add(
new Press(DirectionButton.WEST),
new Task(Action.PREVIOUS, Target.CURRENT));
player.add(
new Press(DirectionButton.EAST),
new Task(Action.NEXT, Target.CURRENT));
player.add(
new Press(DirectionButton.SOUTH),
new Task(Action.VOLUME_DOWN, Target.CURRENT));
player.add(
new Press(DirectionButton.NORTH),
new Task(Action.VOLUME_UP, Target.CURRENT));
add(player);
}
}