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.rumblepad;
import mimis.exception.button.UnknownButtonException;
import mimis.input.Button;
import de.hardcode.jxinput.event.JXInputButtonEvent;
public enum RumblepadButton implements Button {
ONE ("Button 0"),
TWO ("Button 1"),
THREE ("Button 2"),
FOUR ("Button 3"),
FIVE ("Button 4"),
SIX ("Button 5"),
SEVEN ("Button 6"),
EIGHT ("Button 7"),
NINE ("Button 8"),
TEN ("Button 9");
protected String code;
private RumblepadButton(String code) {
this.code = code;
}
public String getCode() {
return code;
}
public static RumblepadButton create(String code) throws UnknownButtonException {
for (RumblepadButton button : RumblepadButton.values()) {
if (button.getCode().equals(code)) {
return button;
}
}
throw new UnknownButtonException();
}
public static RumblepadButton create(JXInputButtonEvent event) throws UnknownButtonException {
return create(event.getButton().getName());
}
}

View File

@@ -0,0 +1,54 @@
/**
* 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.rumblepad;
import base.exception.worker.ActivateException;
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;
import de.hardcode.jxinput.event.JXInputButtonEvent;
import de.hardcode.jxinput.event.JXInputDirectionalEvent;
public class RumblepadDevice extends JavaInputDevice {
protected static final String TITLE = "RumblePad";
protected static final String NAME = "Logitech RumblePad 2 USB";
protected static RumblepadTaskMapCycle taskMapCycle;
public RumblepadDevice() {
super(TITLE, NAME);
taskMapCycle = new RumblepadTaskMapCycle();
}
public void activate() throws ActivateException {
super.activate();
parser(Action.ADD, taskMapCycle.mimis);
parser(Action.ADD, taskMapCycle.player);
parser(Action.ADD, taskMapCycle.like);
}
protected Button getButton(JXInputButtonEvent event) throws UnknownButtonException {
return RumblepadButton.create(event);
}
protected Button getButton(JXInputDirectionalEvent event) throws UnknownDirectionException {
return DirectionButton.create(event);
}
}

View File

@@ -0,0 +1,86 @@
/**
* 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.rumblepad;
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 RumblepadTaskMapCycle extends TaskMapCycle {
protected static final long serialVersionUID = 1L;
public TaskMap mimis, player, like;
public RumblepadTaskMapCycle() {
/* Mimis */
mimis = new TaskMap();
mimis.add(
new Press(RumblepadButton.ONE),
new Task(Action.PREVIOUS, Target.MAIN));
mimis.add(
new Press(RumblepadButton.THREE),
new Task(Action.NEXT, Target.MAIN));
add(mimis);
/* Player */
player = new TaskMap();
player.add(
new Press(DirectionButton.WEST),
new Task(Action.PLAY, Target.CURRENT));
player.add(
new Press(DirectionButton.EAST),
new Task(Action.MUTE, Target.CURRENT));
player.add(
new Press(RumblepadButton.NINE),
new Task(Action.SHUFFLE, Target.CURRENT));
player.add(
new Press(RumblepadButton.TEN),
new Task(Action.REPEAT, Target.CURRENT));
player.add(
new Press(RumblepadButton.EIGHT),
new Task(Action.NEXT, Target.CURRENT));
player.add(
new Press(RumblepadButton.SIX),
new Task(Action.PREVIOUS, Target.CURRENT));
player.add(
new Press(RumblepadButton.SEVEN),
new Task(Action.FORWARD, Target.CURRENT));
player.add(
new Press(RumblepadButton.FIVE),
new Task(Action.REWIND, 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);
like = new TaskMap();
like.add(
new Press(RumblepadButton.FOUR),
new Task(Action.LIKE, Target.CURRENT));
like.add(
new Press(RumblepadButton.TWO),
new Task(Action.DISLIKE, Target.CURRENT));
add(like);
}
}