当前位置: 首页>>代码示例>>Java>>正文


Java Controller.getType方法代码示例

本文整理汇总了Java中net.java.games.input.Controller.getType方法的典型用法代码示例。如果您正苦于以下问题:Java Controller.getType方法的具体用法?Java Controller.getType怎么用?Java Controller.getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.java.games.input.Controller的用法示例。


在下文中一共展示了Controller.getType方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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()]);
    
}
 
开发者ID:jfcameron,项目名称:G2Dj,代码行数:20,代码来源:GamepadHandler.java

示例2: 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();
        }
    }
}
 
开发者ID:SarutaSan72,项目名称:Yass,代码行数:21,代码来源:YassInput.java

示例3: initKeyboard

import net.java.games.input.Controller; //导入方法依赖的package包/类
/**
 * Init
 */
public static void initKeyboard() {
	controllerEnvironment = ControllerEnvironment.getDefaultEnvironment();
	controllers = controllerEnvironment.getControllers();

	for(int i = 0; i < controllers.length; i++) {
		Controller c = controllers[i];

		if((c.getType() == Controller.Type.KEYBOARD) && (c instanceof Keyboard)) {
			if(NullpoMinoSlick.useJInputKeyboard) {
				log.debug("initKeyboard: Keyboard found");
			}
			keyboard = (Keyboard)c;
		}
	}

	if((keyboard == null) && (NullpoMinoSlick.useJInputKeyboard)) {
		log.error("initKeyboard: Keyboard NOT FOUND");

		// Linux
		if(System.getProperty("os.name").startsWith("Linux")) {
			log.error("If you can use sudo, try the following command and start NullpoMino again:");
			log.error("sudo chmod go+r /dev/input/*");
		}
	}
}
 
开发者ID:PoochyEXE,项目名称:nullpomino,代码行数:29,代码来源:JInputManager.java

示例4: updateControllers

import net.java.games.input.Controller; //导入方法依赖的package包/类
public void updateControllers() {
	mousecontrollers.clear();
	keyboardcontrollers.clear();
	gamepadcontrollers.clear();

	Controller[] ca = ControllerEnvironment.getDefaultEnvironment().getControllers();
	for (Controller c : ca) {
		Type t = c.getType();
		if (t == Type.MOUSE)
			mousecontrollers.add((Mouse) c);
		if (t == Type.KEYBOARD)
			keyboardcontrollers.add((Keyboard) c);
		if (t == Type.GAMEPAD)
			gamepadcontrollers.add(c);
	}
}
 
开发者ID:tdc22,项目名称:JAwesomeEngine,代码行数:17,代码来源:JInputReader.java

示例5: updateGamepads

import net.java.games.input.Controller; //导入方法依赖的package包/类
private void updateGamepads() {
  this.handleHotPluggedControllers = true;
  try {
    this.hackTheShitOutOfJInputBecauseItSucksHard();
    // update plugged in gamepads
    for (int i = 0; i < ControllerEnvironment.getDefaultEnvironment().getControllers().length; i++) {
      final Controller controller = ControllerEnvironment.getDefaultEnvironment().getControllers()[i];
      final Type type = controller.getType();
      if (!type.equals(Type.GAMEPAD)) {
        continue;
      }

      final IGamepad existing = Input.getGamepad(i);
      if (existing != null && existing.getName().equals(controller.getName())) {
        // already added
        continue;
      }

      // add new gamepads
      final IGamepad newGamepad = new Gamepad(i, controller);
      Input.gamepads().add(newGamepad);
      for (final Consumer<IGamepad> cons : this.gamepadAddedConsumer) {
        cons.accept(newGamepad);
      }
    }
  } catch (IllegalStateException e) {
    this.loop.terminate();
  } finally {
    this.handleHotPluggedControllers = false;
  }
}
 
开发者ID:gurkenlabs,项目名称:litiengine,代码行数:32,代码来源:GamepadManager.java

示例6: getDefaultSpecialization

import net.java.games.input.Controller; //导入方法依赖的package包/类
private static Class<? extends IMockJoystick> getDefaultSpecialization(Controller aController)
{
    Class<? extends IMockJoystick> output = null;

    Type type = aController.getType();
    String name = aController.getName();

    if (type == Type.KEYBOARD)
    {
        output = KeyboardJoystick.class;
    }
    else if (type == Type.GAMEPAD)
    {
        switch (name)
        {
        default:
            System.err.println("Unknown joystick name " + name);
            output = GenericGamepadJoystick.class;
        }
    }
    else if (type == Type.STICK)
    {
        switch (name)
        {
        case "Wireless Controller":
            output = Ps4Joystick.class;
            break;
        default:
            System.err.println("Unknown joystick name " + name);
            output = GenericGamepadJoystick.class;
        }
    }
    else
    {
        System.err.println("Unknown joystick type " + type);
    }

    return output;
}
 
开发者ID:ArcticWarriors,项目名称:snobot-2017,代码行数:40,代码来源:JoystickDiscoverer.java

示例7: getCompatibleControllers

import net.java.games.input.Controller; //导入方法依赖的package包/类
/**
	 * Get controllers from JInput that would be suitable
	 * 
	 * @return
	 */
	private static List<Controller> getCompatibleControllers() {
		ControllerEnvironment controllerEnvironment = ControllerEnvironment.getDefaultEnvironment(); 
//		controllerEnvironment.addControllerListener(new ControllerListener() {
//			public void controllerRemoved(ControllerEvent ev) {
//				System.err.println("ADDED: " + ev);
//			}
//
//		    /**
//		     * Invoked when a controller has been added.
//		     */
//		    public void controllerAdded(ControllerEvent ev) {
//				System.err.println("REMOVED: " + ev);
//		    }
//		});
		Controller[] controllers = controllerEnvironment.getControllers();
		List<Controller> advancedControllers = new ArrayList<>();
		for (Controller controller : controllers) {
			// For now, we only support 'Space Navigator' controllers... being more permissive can cause strange things to happen
			// (in particular, things go very badly wrong with VirtualBox)
			if (controller.getType() == Type.STICK && controller.getName().toLowerCase().equals("spacenavigator")) {
//			if (controller.getType() == Type.STICK || !controller.getName().toLowerCase().contains("virtualbox")) {
				logger.info("Registering controller: " + controller.getName() + ", " + controller.getType() ); 
				advancedControllers.add(controller);
			} else
				logger.trace("Skipping controller: " + controller.getName() + ", " + controller.getType() ); 
		}
		return advancedControllers;
	}
 
开发者ID:qupath,项目名称:qupath,代码行数:34,代码来源:AdvancedControllerActionFactory.java

示例8: getAvailablePadControllers

import net.java.games.input.Controller; //导入方法依赖的package包/类
/**
 * This method detects the available joysticks / gamepads on the computer
 * and return them in a list.
 *
 * @return List of available joysticks / gamepads connected to the computer
 */
private static Controller[] getAvailablePadControllers() {
    List<Controller> gameControllers = new ArrayList<Controller>();
    // Get a list of the controllers JInput knows about and can interact
    // with
    Controller[] controllers = ControllerEnvironment.getDefaultEnvironment().getControllers();
    // Check the useable controllers (gamepads or joysticks with at least 2
    // axis and 2 buttons)
    for (Controller controller : controllers) {
        if ((controller.getType() == Controller.Type.GAMEPAD) || (controller.getType() == Controller.Type.STICK)) {
            int nbOfAxis = 0;
            // Get this controllers components (buttons and axis)
            Component[] components = controller.getComponents();
            // Check the availability of X/Y axis and at least 2 buttons
            // (for A and B, because select and start can use the keyboard)
            for (Component component : components) {
                if ((component.getIdentifier() == Component.Identifier.Axis.X)
                        || (component.getIdentifier() == Component.Identifier.Axis.Y)) {
                    nbOfAxis++;
                }
            }
            if ((nbOfAxis >= 2) && (getButtons(controller).length >= 2)) {
                // Valid game controller
                gameControllers.add(controller);
            }
        }
    }
    return gameControllers.toArray(new Controller[0]);
}
 
开发者ID:kostkol87,项目名称:Nes-emulator,代码行数:35,代码来源:ControllerImpl.java

示例9: test

import net.java.games.input.Controller; //导入方法依赖的package包/类
public void test() {
	Controller[] controllers = ControllerEnvironment.getDefaultEnvironment().getControllers();

    for (Controller controller : controllers) {
        
        if(controller.getType() == Controller.Type.STICK) {
        	System.out.println("c: " + controller.getName() + "; " + controller.getPortNumber());
        }
    }
}
 
开发者ID:frc5806,项目名称:Noble,代码行数:11,代码来源:ListenerThread.java

示例10: findController

import net.java.games.input.Controller; //导入方法依赖的package包/类
private Controller findController() {
    Controller[] controllers = ControllerEnvironment.getDefaultEnvironment().getControllers();
    for(int i = 0; i < controllers.length; i++){
        Controller controller = controllers[i];
        if (controller.getType() == Controller.Type.STICK) {
            return controller;
        }
    }
    return null;
}
 
开发者ID:Koheiru,项目名称:J-ARDrone2,代码行数:11,代码来源:JoystickController.java

示例11: initializeJoysticks

import net.java.games.input.Controller; //导入方法依赖的package包/类
private void initializeJoysticks() {
    final Controller[] controllers = controllerEnvironment.getControllers();
    for (int i = 0; i < controllers.length; i++) {
        final Controller j = controllers[i];
        final Controller.Type t = j.getType();
        if (t == Controller.Type.GAMEPAD || t == Controller.Type.STICK) {
            joystickIds.put(j, i);
            joysticks.add(j);
        }
    }
    getPreferencesManager().setJoystickPositions(joystickPositions);
    joysticks.stream().forEach(this::fireJoystickAdded);
}
 
开发者ID:RobotsByTheC,项目名称:JDriverStation,代码行数:14,代码来源:JoystickManager.java

示例12: getAvailablePadControllers

import net.java.games.input.Controller; //导入方法依赖的package包/类
/**
 * This method detects the available joysticks / gamepads on the computer
 * and return them in a list.
 *
 * @return List of available joysticks / gamepads connected to the computer
 */
private static Controller[] getAvailablePadControllers() {
    List<Controller> gameControllers = new ArrayList<>();
    // Get a list of the controllers JInput knows about and can interact
    // with
    Controller[] controllers = ControllerEnvironment.getDefaultEnvironment().getControllers();
    // Check the useable controllers (gamepads or joysticks with at least 2
    // axis and 2 buttons)
    for (Controller controller : controllers) {
        if ((controller.getType() == Controller.Type.GAMEPAD) || (controller.getType() == Controller.Type.STICK)) {
            int nbOfAxis = 0;
            // Get this controllers components (buttons and axis)
            Component[] components = controller.getComponents();
            // Check the availability of X/Y axis and at least 2 buttons
            // (for A and B, because select and start can use the keyboard)
            for (Component component : components) {
                if ((component.getIdentifier() == Component.Identifier.Axis.X)
                        || (component.getIdentifier() == Component.Identifier.Axis.Y)) {
                    nbOfAxis++;
                }
            }
            if ((nbOfAxis >= 2) && (getButtons(controller).length >= 2)) {
                // Valid game controller
                gameControllers.add(controller);
            }
        }
    }
    return gameControllers.toArray(new Controller[0]);
}
 
开发者ID:andrew-hoffman,项目名称:halfnes,代码行数:35,代码来源:ControllerImpl.java

示例13: GamepadInputDeviceService

import net.java.games.input.Controller; //导入方法依赖的package包/类
public GamepadInputDeviceService(){
    try{final JVM jvm = new JVM();
    if(operatingSystem.contains("win")){
	jvm.loadFromJarToFile("/jinput-dx8_64.dll");
	jvm.loadFromJarToFile("/jinput-dx8.dll");
	jvm.loadFromJarToFile("/jinput-raw_64.dll");
	jvm.loadFromJarToFile("/jinput-raw.dll");
	jvm.loadFromJarToFile("/jinput-wintab.dll");
    } else if(operatingSystem.contains("linux")){
	jvm.loadFromJarToFile("/libjinput-linux64.so");
	jvm.loadFromJarToFile("/libjinput-linux.so");
    } else if(operatingSystem.contains("mac")){
	jvm.loadFromJarToFile("/libjinput-osx.jnilib");
    } else
	System.err.println("Warning: Couldn't determine OS; jInput will likely fail to load.");
    System.setProperty("net.java.games.input.librarypath", new File("DeleteMe").getAbsolutePath());
    }catch(Exception e){e.printStackTrace();}
    this.controllerEnvironment = ControllerEnvironment.getDefaultEnvironment();
    //Filter out the keyboards in favor of AWT's event-based tracking
    for(Controller controller:controllerEnvironment.getControllers()){
	final Type type = controller.getType();
	if(     type != Controller.Type.KEYBOARD && 
		type != Controller.Type.MOUSE    &&
		type != Controller.Type.TRACKBALL)
	    inputDevices.add(new GamepadInputDevice(controller));
    }//end for(controller types)
}
 
开发者ID:jtrfp,项目名称:terminal-recall,代码行数:28,代码来源:GamepadInputDeviceServiceFactory.java


注:本文中的net.java.games.input.Controller.getType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。