本文整理汇总了Java中net.java.games.input.Controller类的典型用法代码示例。如果您正苦于以下问题:Java Controller类的具体用法?Java Controller怎么用?Java Controller使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Controller类属于net.java.games.input包,在下文中一共展示了Controller类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: nativesTest
import net.java.games.input.Controller; //导入依赖的package包/类
@Test
public void nativesTest() {
new NativeLibrary("jinput") //
.register(Platform.Windows_x86, "jinput-dx8.dll") //
.register(Platform.Windows_x86, "jinput-raw.dll") //
.register(Platform.Windows_x64, "jinput-dx8_64.dll") //
.register(Platform.Windows_x64, "jinput-raw_64.dll") //
.register(Platform.Linux_x86, "libjinput-linux.so") //
.register(Platform.Linux_x64, "libjinput-linux64.so") //
.register(Platform.MacOS, "libjinput-osx.jnilib") //
.require(true) //
.deleteOnExit(true)//
.extractTo(new File("target", "jinput-natives")) //
.load(Loaders.JAVA_LIBRARY_PATH__LOADER);
final Controller[] controllers = ControllerEnvironment.getDefaultEnvironment().getControllers();
assertTrue(controllers.length > 0);
for (final Controller controller : controllers) {
System.out.println(controller.getName());
}
}
示例2: HatSwitchHandler
import net.java.games.input.Controller; //导入依赖的package包/类
public HatSwitchHandler(Controller c,
Component hat,
Component a, Component b, Component x, Component y,
Component r, Component l, Component start, Component select) {
super(
c,
new ComponentWrapper(hat, SNESInputEvent.SNES_UP, POV.UP, POV.UP_LEFT, POV.UP_RIGHT),
new ComponentWrapper(hat, SNESInputEvent.SNES_DOWN, POV.DOWN, POV.DOWN_LEFT, POV.DOWN_RIGHT),
new ComponentWrapper(hat, SNESInputEvent.SNES_RIGHT, POV.RIGHT, POV.UP_RIGHT, POV.DOWN_RIGHT),
new ComponentWrapper(hat, SNESInputEvent.SNES_LEFT, POV.LEFT, POV.UP_LEFT, POV.DOWN_LEFT),
new ComponentWrapper(a, SNESInputEvent.SNES_A, ON),
new ComponentWrapper(b, SNESInputEvent.SNES_B, ON),
new ComponentWrapper(x, SNESInputEvent.SNES_X, ON),
new ComponentWrapper(y, SNESInputEvent.SNES_Y, ON),
new ComponentWrapper(r, SNESInputEvent.SNES_R, ON),
new ComponentWrapper(l, SNESInputEvent.SNES_L, ON),
new ComponentWrapper(start, SNESInputEvent.SNES_START, ON),
new ComponentWrapper(select, SNESInputEvent.SNES_SELECT, ON)
);
}
示例3: DPadHandler
import net.java.games.input.Controller; //导入依赖的package包/类
public DPadHandler(Controller c,
Component up, Component down, Component right, Component left,
Component a, Component b, Component x, Component y,
Component r, Component l, Component start, Component select) {
super(
c,
new ComponentWrapper(up, SNESInputEvent.SNES_UP, ON),
new ComponentWrapper(down, SNESInputEvent.SNES_DOWN, ON),
new ComponentWrapper(right, SNESInputEvent.SNES_RIGHT, ON),
new ComponentWrapper(left, SNESInputEvent.SNES_LEFT, ON),
new ComponentWrapper(a, SNESInputEvent.SNES_A, ON),
new ComponentWrapper(b, SNESInputEvent.SNES_B, ON),
new ComponentWrapper(x, SNESInputEvent.SNES_X, ON),
new ComponentWrapper(y, SNESInputEvent.SNES_Y, ON),
new ComponentWrapper(r, SNESInputEvent.SNES_R, ON),
new ComponentWrapper(l, SNESInputEvent.SNES_L, ON),
new ComponentWrapper(start, SNESInputEvent.SNES_START, ON),
new ComponentWrapper(select, SNESInputEvent.SNES_SELECT, ON)
);
}
示例4: AxisHandler
import net.java.games.input.Controller; //导入依赖的package包/类
public AxisHandler(Controller c,
Component yaxis, Component xaxis,
Component a, Component b, Component x, Component y,
Component r, Component l, Component start, Component select) {
super(
c,
new ComponentWrapper(yaxis, SNESInputEvent.SNES_UP, -ON),
new ComponentWrapper(yaxis, SNESInputEvent.SNES_DOWN, ON),
new ComponentWrapper(xaxis, SNESInputEvent.SNES_RIGHT, ON),
new ComponentWrapper(xaxis, SNESInputEvent.SNES_LEFT, -ON),
new ComponentWrapper(a, SNESInputEvent.SNES_A, ON),
new ComponentWrapper(b, SNESInputEvent.SNES_B, ON),
new ComponentWrapper(x, SNESInputEvent.SNES_X, ON),
new ComponentWrapper(y, SNESInputEvent.SNES_Y, ON),
new ComponentWrapper(r, SNESInputEvent.SNES_R, ON),
new ComponentWrapper(l, SNESInputEvent.SNES_L, ON),
new ComponentWrapper(start, SNESInputEvent.SNES_START, ON),
new ComponentWrapper(select, SNESInputEvent.SNES_SELECT, ON)
);
}
示例5: Gamepad
import net.java.games.input.Controller; //导入依赖的package包/类
public Gamepad(final net.java.games.input.Controller aJInputControllerHandle)
{
m_Name = aJInputControllerHandle.getName();
m_ControllerHandle = aJInputControllerHandle;
net.java.games.input.Component[] components = aJInputControllerHandle.getComponents();
net.java.games.input.Component currentComponent;
for(int i=0,s=components.length;i<s;i++)
{
currentComponent = components[i];
if (currentComponent.getIdentifier() instanceof Identifier.Button)
m_Buttons.put(currentComponent.getName(),new Button(currentComponent));
else if (currentComponent.getIdentifier() instanceof Identifier.Axis)
{
if (currentComponent.getIdentifier() == Identifier.Axis.POV)
m_Hats.put(currentComponent.getName(),new Hat(currentComponent));
else
m_Axes.put(currentComponent.getName(),new Axis(currentComponent));
}
}
}
示例6: GamepadHandler
import net.java.games.input.Controller; //导入依赖的package包/类
public GamepadHandler()
{
ArrayList<Controller> controllers = new ArrayList<Controller>(Arrays.asList(ControllerEnvironment.getDefaultEnvironment().getControllers()));
Controller current;
for (int i=0;i<controllers.size();i++)
{
current = controllers.get(i);
if (current.getType() == Controller.Type.GAMEPAD || current.getType() == Controller.Type.STICK)
m_GamePads.add(new Gamepad(current));
else
controllers.remove(i--);
}
//m_JInputControllerHandles = controllers.toArray(new net.java.games.input.Controller[controllers.size()]);
}
示例7: getButtonController
import net.java.games.input.Controller; //导入依赖的package包/类
/**
* Description of the Method
*
* @param index Description of the Parameter
* @return Description of the Return Value
*/
public static int getButtonController(int index) {
ControllerEnvironment ce = ControllerEnvironment.getDefaultEnvironment();
Controller[] cs = ce.getControllers();
int controllerCount = 0;
for (int d = 0; d < cs.length; d++) {
Controller.Type type = cs[d].getType();
if ((type == Controller.Type.GAMEPAD) || (type == Controller.Type.STICK) || cs[d].getName().toLowerCase().contains("wiimote") || cs[d].getName().toLowerCase().contains("shuttle")) {
if (controllerCount == index) {
return d;
}
controllerCount++;
}
}
return -1;
}
示例8: getButton
import net.java.games.input.Controller; //导入依赖的package包/类
/**
* Gets the button attribute of the YassInput class
*
* @param d Description of the Parameter
* @param i Description of the Parameter
* @return The button value
*/
public static int getButton(int d, int i) {
ControllerEnvironment ce = ControllerEnvironment.getDefaultEnvironment();
Controller[] cs = ce.getControllers();
int buttonCount = 0;
Component[] comps = cs[d].getComponents();
for (int c = 0; c < comps.length; c++) {
if (!(comps[c].getIdentifier() instanceof Component.Identifier.Axis)) {
if (buttonCount == i) {
return c;
}
buttonCount++;
}
}
return -1;
}
示例9: pollAllButtons
import net.java.games.input.Controller; //导入依赖的package包/类
/**
* Description of the Method
*/
public void pollAllButtons() {
ControllerEnvironment ce = ControllerEnvironment.getDefaultEnvironment();
Controller[] cs = ce.getControllers();
for (Controller cc : cs) {
Controller.Type type = cc.getType();
//if (type == Controller.Type.MOUSE || type == Controller.Type.KEYBOARD) {
// continue;
//} else
if (type == Controller.Type.GAMEPAD || type == Controller.Type.STICK) {
cc.poll();
} else if (type == Controller.Type.UNKNOWN) {
cc.poll();
} else if (cc.getName().toLowerCase().contains("wiimote")) {
cc.poll();
}
}
}
示例10: loadControllers
import net.java.games.input.Controller; //导入依赖的package包/类
private void loadControllers(){
Controller[] controllers = createDefaultEnvironment().getControllers();
for (int i = 0; i < hidData.length; i++) {
hidData[i] = null;
}
controllerCount = 0;
for (int i = 0; i < controllers.length; i++) {
if(!controllers[i].getType().equals(Type.GAMEPAD) &&
!controllers[i].getType().equals(Type.STICK))
continue;
hidData[controllerCount++] = loadController(controllers[i]);
if(controllerCount == hidData.length)
break;
}
}
示例11: rediscoverJoysticks
import net.java.games.input.Controller; //导入依赖的package包/类
public static Map<String, ControllerConfiguration> rediscoverJoysticks()
{
Controller[] availableControllers = ControllerEnvironment.getDefaultEnvironment().getControllers();
Map<String, ControllerConfiguration> controllerConfig = new LinkedHashMap<>();
Map<String, Integer> deviceCounter = new LinkedHashMap<>();
controllerConfig.clear();
for (Controller controller : availableControllers)
{
if (sTYPES_TO_IGNORE.contains(controller.getType()))
{
continue;
}
Class<? extends IMockJoystick> specializationClass = getDefaultSpecialization(controller);
int deviceCtr = deviceCounter.getOrDefault(controller.getName(), 0);
deviceCounter.put(controller.getName(), ++deviceCtr);
String deviceName = controller.getName() + " " + deviceCtr;
ControllerConfiguration configuration = new ControllerConfiguration(controller, specializationClass);
controllerConfig.put(deviceName, configuration);
}
return sort(controllerConfig);
}
示例12: GenericGamepadJoystick
import net.java.games.input.Controller; //导入依赖的package包/类
public GenericGamepadJoystick(Controller aController, String aName)
{
super(aName, aController, new ArrayList<>(), new ArrayList<>(), new ArrayList<>());
if (mController != null)
{
Component[] components = mController.getComponents();
for (int j = 0; j < components.length; j++)
{
if (components[j].isAnalog())
{
mAxis.add(components[j].getIdentifier());
}
else
{
mButtons.add(components[j].getIdentifier());
}
}
mAxisValues = new float[mAxis.size()];
mPovValues = new short[mPOV.size()];
}
}
示例13: JoystickTabPanel
import net.java.games.input.Controller; //导入依赖的package包/类
public JoystickTabPanel(String aJoystickName, Controller aController, Class<?> aDefaultSpecialization) throws IOException
{
mController = aController;
mJoystickName = aJoystickName;
initComponents();
if (JoystickDiscoverer.sAVAILABLE_SPECIALIZATIONS.containsKey(aDefaultSpecialization))
{
mSelectInterperetTypeBox.setSelectedItem(JoystickDiscoverer.sAVAILABLE_SPECIALIZATIONS.get(aDefaultSpecialization));
handleWrapperSelected(mSelectInterperetTypeBox.getSelectedItem().toString());
}
else
{
handleWrapperSelected(mSelectInterperetTypeBox.getItemAt(0));
}
}
示例14: loadIdentifiers
import net.java.games.input.Controller; //导入依赖的package包/类
private void loadIdentifiers(int controllerIdx, Controller c){
Component[] ces = c.getComponents();
int numButtons = 0;
int numAxes = 0;
xAxis = -1;
yAxis = -1;
for (Component comp : ces){
Identifier id = comp.getIdentifier();
if (id instanceof Button){
buttonIdsToIndices[controllerIdx].put((Button)id, numButtons);
numButtons ++;
}else if (id instanceof Axis){
Axis axis = (Axis) id;
if (axis == Axis.X){
xAxis = numAxes;
}else if (axis == Axis.Y){
yAxis = numAxes;
}
axisIdsToIndices[controllerIdx].put((Axis)id, numAxes);
numAxes ++;
}
}
}
示例15: turnOnController
import net.java.games.input.Controller; //导入依赖的package包/类
boolean turnOnController() {
if (isControllerOn())
return true;
advancedControllers.clear(); // Just to be sure...
for (Controller controller : getCompatibleControllers()) {
advancedControllers.add(new QuPathAdvancedInputController(controller, qupath, heartbeat));
}
if (advancedControllers.isEmpty()) {
logger.error("No advanced controller found!");
return false;
}
if (advancedControllers.size() > 1)
logger.warn("Number of controllers registered: " + advancedControllers.size());
timeline = getTimeline();
timeline.play();
controllerOn.set(true);
return true;
}