Java 类org.lwjgl.input.Controllers 实例源码

项目:Controller-Support    文件:DaemonMain.java   
@Override
public boolean awaitControllerSelection() {
    Controllers.clearEvents();
    while(!controllerSelected) {
        Controllers.poll();
        if(Controllers.next()) {
            if(Controllers.isEventButton()) {
                controllerSelected = true;
                selectedController = Controllers.getEventSource();
                int selectedButton = Controllers.getEventControlIndex();
                while(selectedController.isButtonPressed(selectedButton))selectedController.poll();
                return true;
            }
        }
    }
    return false;
}
项目:fuzzy-octo-shame    文件:MotherBrain.java   
/**
 *
 */
private void logAllControllers() {
    for (int i = 0; i < Controllers.getControllerCount(); i++) {
        final Controller controller = Controllers.getController(i);
        Log.debug(controller.getName());
        final int controllerAxisCount = controller.getAxisCount();
        Log.debug("org.lwjgl.input.Controller#getAxisName");
        for (int j = 0; j < controllerAxisCount; j++) {
            Log.debug(controller.getAxisName(j));
        }
        final int controllerButtonCount = controller.getButtonCount();
        Log.debug("org.lwjgl.input.Controller#getButtonCount");
        Log.debug(String.valueOf(controllerButtonCount));
        Log.debug("org.lwjgl.input.Controller#getButtonName");
        for (int j = 0; j < controllerButtonCount; j++) {
            Log.debug(controller.getButtonName(j));
        }
        final int controllerRumblerCount = controller.getRumblerCount();
        Log.debug("org.lwjgl.input.Controller#getRumblerName");
        for (int j = 0; j < controllerRumblerCount; j++) {
            Log.debug(controller.getRumblerName(j));
        }
        controllers.add(controller);
    }
}
项目:chess-game    文件:RemoteController.java   
public RemoteController(ChessbotCommunicator comm, int botID)
{
    PropertyConfigurator.configure("log/log4j.properties");

    this.comm = comm;
    this.botID = botID;

    try {
        Controllers.create();
    } catch (LWJGLException e) {
        log.info("Exception", e);
    }

    Controllers.poll();

    if (Controllers.getControllerCount() != 0) {
        controller = Controllers.getController(0);
        log.info("Found controller");
    }
    else
        log.info("Could not find any controllers");
}
项目:Controller-Support    文件:DaemonMain.java   
@Override
public ByteBuf getControllerData() {
    Controllers.poll();
    ByteBuf buf = SerializationHelper.serializeControllerData(Unpooled.buffer(), selectedController);
    if(debug)debug();
    Controllers.clearEvents();
    return buf;
}
项目:Controller-Support    文件:DaemonMain.java   
private void debug() {
    while(Controllers.next()) {
        if(Controllers.isEventButton() && Controllers.getEventButtonState()) {
            System.out.println(String.format("Button '%s' was pressed!", Controllers.getEventControlIndex()));
        } else if(Controllers.isEventAxis() && Controllers.getEventSource().getAxisValue(Controllers.getEventControlIndex()) != 0.0) {
            System.out.println(String.format("Axis '%s' was moved!", Controllers.getEventControlIndex()));
        } else if(Controllers.isEventPovX() || Controllers.isEventPovY()) {
            System.out.println("POV-Action!");
        }
    }
}
项目:PhET    文件:Display.java   
static void pollDevices() {
    // Poll the input devices while we're here
    if ( Mouse.isCreated() ) {
        Mouse.poll();
        Mouse.updateCursor();
    }

    if ( Keyboard.isCreated() ) {
        Keyboard.poll();
    }

    if ( Controllers.isCreated() ) {
        Controllers.poll();
    }
}
项目:PhET    文件:ControllersTest.java   
public void start() {
    try {
        Controllers.create();
    } catch (LWJGLException e) {
        e.printStackTrace();
        return;
    }
    System.out.println("Controllers.getControllerCount() = " + Controllers.getControllerCount());
}
项目:YellowSquare    文件:GamePanel.java   
public void tick(GameContainer gc, long delta) {
    for (int i = 0; i < Controllers.getControllerCount(); i++) {
        if (Controllers.getController(i).getName().startsWith("Controller")) {
            xAxis = Controllers.getController(i).getXAxisValue();
            yAxis = Controllers.getController(i).getYAxisValue();
            xSecondAxis = Controllers.getController(i).getAxisValue(3);
            ySecondAxis = Controllers.getController(i).getAxisValue(2);
            if (xAxis != -1)
                xChange = true;
            if (yAxis != -1)
                yChange = true;
            if (xSecondAxis != -1)
                xSecondChange = true;
            if (ySecondAxis != -1)
                ySecondChange = true;
            if (xAxis == -1 && !xChange)
                xAxis = 0;
            if (yAxis == -1 && !yChange)
                yAxis = 0;
            if (xSecondAxis == -1 && !xSecondChange)
                xSecondAxis = 0;
            if (ySecondAxis == -1 && !ySecondChange)
                ySecondAxis = 0;
        }
    }

    ScreenshotTaker.tick(gc);

    if (paused)
        return;

    Entity.staticTick(delta);

    Animation.staticTick();

    gsm.tick();

    Editor.tick();
}
项目:fuzzy-octo-shame    文件:MotherBrain.java   
/**
 *
 */
@SuppressWarnings("unused")
private void logFirstController() {
    if(controllers.size() >= 1) {
        final Controller firstController = controllers.get(0);
        while(Controllers.next()) {
            if(Controllers.getEventSource().equals(firstController)) {
                if(Controllers.isEventAxis()) {
                    Log.debug("isEventAxis");
                        if(Controllers.isEventXAxis()) {
                        Log.debug("isEventXAxis");
                    }
                    if(Controllers.isEventYAxis()) {
                        Log.debug("isEventYAxis");
                    }
                }
                if(Controllers.isEventButton()) {
                    final int eventControlIndex = Controllers.getEventControlIndex();
                    final Xbox360ControllerButton xbox360ControllerButton =
                            valueOf(eventControlIndex);
                    final ButtonState buttonState = ButtonState.valueOf(Controllers.getEventButtonState());
                    buttonStateMap.put(xbox360ControllerButton, buttonState);
                    final Set<Map.Entry<Xbox360ControllerButton, ButtonState>> entrySet = buttonStateMap.entrySet();
                    for (Map.Entry<Xbox360ControllerButton, ButtonState> entry: entrySet) {
                        Log.debug(entry.getKey().name() + entry.getValue().name());
                    }
                }
                if(Controllers.isEventPovX()) {
                    Log.debug("isEventPovX");
                }
                if(Controllers.isEventPovY()) {
                    Log.debug("isEventPovY");
                }
            }
        }
    }
}
项目:Wolf_game    文件:Display.java   
static void pollDevices() {
    // Poll the input devices while we're here
    if ( Mouse.isCreated() ) {
        Mouse.poll();
        Mouse.updateCursor();
    }

    if ( Keyboard.isCreated() ) {
        Keyboard.poll();
    }

    if ( Controllers.isCreated() ) {
        Controllers.poll();
    }
}
项目:Wolf_game    文件:ControllersTest.java   
public void start() {
    try {
        Controllers.create();
    } catch (LWJGLException e) {
        e.printStackTrace();
        return;
    }
    System.out.println("Controllers.getControllerCount() = " + Controllers.getControllerCount());
}
项目:jnuit    文件:LwjglNuitControls.java   
@Override
public Control[] getPossibleControls() {
    List<Control> possibleControls = new ArrayList<Control>();
    try {
        if (!Controllers.isCreated()) {
            Controllers.create();
        }
        for (int c = 0; c < Controllers.getControllerCount(); ++c) {
            Controller pad = Controllers.getController(c);
            for (int a = 0; a < pad.getAxisCount(); ++a) {
                possibleControls.add(new GamepadAxisControl(pad, a, true));
                possibleControls.add(new GamepadAxisControl(pad, a, false));
            }
            for (int b = 0; b < pad.getButtonCount(); ++b) {
                possibleControls.add(new GamepadButtonControl(pad, b));
            }
        }
    } catch (LWJGLException ex) {
        Logger.getLogger(LwjglNuitControls.class.getName()).log(Level.SEVERE, null, ex);
    }
    for (Field field : Keyboard.class.getFields()) {
        String name = field.getName();
        if (name.startsWith("KEY_")) {
            try {
                int key = field.getInt(null);
                possibleControls.add(new KeyControl(key));
            } catch (Exception e) {
                Logger.getLogger(ControlsConfigurator.class.getName()).log(Level.SEVERE, "error retrieving key", e);
            }
        }
    }
    for (int m = 0; m < Mouse.getButtonCount(); ++m) {
        possibleControls.add(new MouseButtonControl(m));
    }
    return possibleControls.toArray(new Control[possibleControls.size()]);
}
项目:jnuit    文件:LwjglNuitControls.java   
@Override
public Control[] getDefaultMenuUpControls() {
    Control[] controls = new Control[2];
    controls[0] = new KeyControl(Keyboard.KEY_UP);
    controls[1] = NullControl.INSTANCE;
    for (int c = 0; c < Controllers.getControllerCount(); ++c) {
        Controller pad = Controllers.getController(c);
        if (pad.getAxisCount() >= 2) {
            controls[1] = new GamepadAxisControl(pad, 1, true);
        }
    }
    return controls;
}
项目:jnuit    文件:LwjglNuitControls.java   
@Override
public Control[] getDefaultMenuDownControls() {
    Control[] controls = new Control[2];
    controls[0] = new KeyControl(Keyboard.KEY_DOWN);
    controls[1] = NullControl.INSTANCE;
    for (int c = 0; c < Controllers.getControllerCount(); ++c) {
        Controller pad = Controllers.getController(c);
        if (pad.getAxisCount() >= 2) {
            controls[1] = new GamepadAxisControl(pad, 1, false);
        }
    }
    return controls;
}
项目:jnuit    文件:LwjglNuitControls.java   
@Override
public Control[] getDefaultMenuLeftControls() {
    Control[] controls = new Control[2];
    controls[0] = new KeyControl(Keyboard.KEY_LEFT);
    controls[1] = NullControl.INSTANCE;
    for (int c = 0; c < Controllers.getControllerCount(); ++c) {
        Controller pad = Controllers.getController(c);
        if (pad.getAxisCount() >= 1) {
            controls[1] = new GamepadAxisControl(pad, 0, false);
        }
    }
    return controls;
}
项目:jnuit    文件:LwjglNuitControls.java   
@Override
public Control[] getDefaultMenuRightControls() {
    Control[] controls = new Control[2];
    controls[0] = new KeyControl(Keyboard.KEY_RIGHT);
    controls[1] = NullControl.INSTANCE;
    for (int c = 0; c < Controllers.getControllerCount(); ++c) {
        Controller pad = Controllers.getController(c);
        if (pad.getAxisCount() >= 1) {
            controls[1] = new GamepadAxisControl(pad, 0, true);
        }
    }
    return controls;
}
项目:jnuit    文件:LwjglNuitControls.java   
@Override
public Control[] getDefaultMenuOkControls() {
    Control[] controls = new Control[2];
    controls[0] = new KeyControl(Keyboard.KEY_RETURN);
    controls[1] = NullControl.INSTANCE;
    for (int c = 0; c < Controllers.getControllerCount(); ++c) {
        Controller pad = Controllers.getController(c);
        if (pad.getButtonCount() >= 1) {
            controls[1] = new GamepadButtonControl(pad, 0);
        }
    }
    return controls;
}
项目:jnuit    文件:LwjglNuitControls.java   
@Override
public Control[] getDefaultMenuCancelControls() {
    Control[] controls = new Control[2];
    controls[0] = new KeyControl(Keyboard.KEY_ESCAPE);
    controls[1] = NullControl.INSTANCE;
    for (int c = 0; c < Controllers.getControllerCount(); ++c) {
        Controller pad = Controllers.getController(c);
        if (pad.getButtonCount() >= 2) {
            controls[1] = new GamepadButtonControl(pad, 1);
        }
    }
    return controls;
}
项目:jnuit    文件:MainLoop.java   
public void tick() {
    game.setDelta(1.0f / 60.0f);
    game.process();
    Display.update(false);
    Display.sync(60);
    Display.processMessages();
    Mouse.poll();
    Keyboard.poll();
    Controllers.poll();
}
项目:jnuit    文件:MainLoop.java   
private void initGamepads() {
    try {
        Controllers.create();
    } catch (LWJGLException ex) {
        logger.log(Level.SEVERE, "Cannot init gamepad support", ex);
    }
}
项目:GPVM    文件:Display.java   
static void pollDevices() {
    // Poll the input devices while we're here
    if ( Mouse.isCreated() ) {
        Mouse.poll();
        Mouse.updateCursor();
    }

    if ( Keyboard.isCreated() ) {
        Keyboard.poll();
    }

    if ( Controllers.isCreated() ) {
        Controllers.poll();
    }
}
项目:GPVM    文件:ControllersTest.java   
public void start() {
    try {
        Controllers.create();
    } catch (LWJGLException e) {
        e.printStackTrace();
        return;
    }
    System.out.println("Controllers.getControllerCount() = " + Controllers.getControllerCount());
}
项目:GPVM    文件:Display.java   
static void pollDevices() {
    // Poll the input devices while we're here
    if ( Mouse.isCreated() ) {
        Mouse.poll();
        Mouse.updateCursor();
    }

    if ( Keyboard.isCreated() ) {
        Keyboard.poll();
    }

    if ( Controllers.isCreated() ) {
        Controllers.poll();
    }
}
项目:GPVM    文件:ControllersTest.java   
public void start() {
    try {
        Controllers.create();
    } catch (LWJGLException e) {
        e.printStackTrace();
        return;
    }
    System.out.println("Controllers.getControllerCount() = " + Controllers.getControllerCount());
}
项目:SpaceStationAlpha    文件:Display.java   
static void pollDevices() {
    // Poll the input devices while we're here
    if ( Mouse.isCreated() ) {
        Mouse.poll();
        Mouse.updateCursor();
    }

    if ( Keyboard.isCreated() ) {
        Keyboard.poll();
    }

    if ( Controllers.isCreated() ) {
        Controllers.poll();
    }
}
项目:SpaceStationAlpha    文件:ControllersTest.java   
public void start() {
    try {
        Controllers.create();
    } catch (LWJGLException e) {
        e.printStackTrace();
        return;
    }
    System.out.println("Controllers.getControllerCount() = " + Controllers.getControllerCount());
}
项目:TeacherSmash    文件:Display.java   
static void pollDevices() {
    // Poll the input devices while we're here
    if ( Mouse.isCreated() ) {
        Mouse.poll();
        Mouse.updateCursor();
    }

    if ( Keyboard.isCreated() ) {
        Keyboard.poll();
    }

    if ( Controllers.isCreated() ) {
        Controllers.poll();
    }
}
项目:TeacherSmash    文件:ControllersTest.java   
public void start() {
    try {
        Controllers.create();
    } catch (LWJGLException e) {
        e.printStackTrace();
        return;
    }
    System.out.println("Controllers.getControllerCount() = " + Controllers.getControllerCount());
}
项目:3d-Demo    文件:Display.java   
static void pollDevices() {
    // Poll the input devices while we're here
    if ( Mouse.isCreated() ) {
        Mouse.poll();
        Mouse.updateCursor();
    }

    if ( Keyboard.isCreated() ) {
        Keyboard.poll();
    }

    if ( Controllers.isCreated() ) {
        Controllers.poll();
    }
}
项目:3d-Demo    文件:ControllersTest.java   
public void start() {
    try {
        Controllers.create();
    } catch (LWJGLException e) {
        e.printStackTrace();
        return;
    }
    System.out.println("Controllers.getControllerCount() = " + Controllers.getControllerCount());
}
项目:cuina    文件:Input.java   
public static void update()
{
    if (Keyboard.isCreated()) Keyboard.poll();
    if (Mouse.isCreated()) Mouse.poll();
    if (Controllers.isCreated()) Controllers.poll();

    for (Control c : controls.values())
        c.update();
}
项目:cuina    文件:DirectionalControl.java   
@Override
public float getX()
{
    if (!Controllers.isCreated()) return 0;

    return Controllers.getController(target).getAxisValue(xAxis);
}
项目:cuina    文件:DirectionalControl.java   
@Override
public float getY()
{
    if (!Controllers.isCreated()) return 0;

    return Controllers.getController(target).getAxisValue(yAxis);
}
项目:Controller-Support    文件:DaemonMain.java   
public static void main(String[] args) {
    try {
        Controllers.create();
    } catch (LWJGLException e) {
        e.printStackTrace();
    }

    for(String s : args) {
        if(s.equals("debugControllerInput")) {
            debug = true;
            System.out.println("Debugging!");
        }
    }

    int port = Integer.parseInt(args[0]);
    System.out.println("Starting IPC-Server, Port: " + port);
    handler = new NetworkHandler();
    IPCMethodProvider provider = new IPCMethodProvider(ProvidedMethods.class, new DaemonMain(), handler);
    handler.setProvider(provider);

    EventLoopGroup eventGroup = new NioEventLoopGroup();

    Bootstrap b = new Bootstrap();
    b.group(eventGroup);
    b.channel(NioDatagramChannel.class);
    b.handler(handler);
    System.out.println("About to start bootstrap...");
    ChannelFuture future = b.bind("localhost", port).syncUninterruptibly();

    if(future.cause() instanceof BindException) {
        future.channel().close().syncUninterruptibly();
        b.group().shutdownGracefully();
        Controllers.destroy();
    }
    Runtime.getRuntime().addShutdownHook(new Thread(() -> {
        future.channel().close();
        Controllers.destroy();
    }));

    future.channel().closeFuture().syncUninterruptibly();
    b.group().shutdownGracefully();
}
项目:Controller-Support    文件:DaemonMain.java   
@Override
public boolean hasControllers() {
    return Controllers.getControllerCount() != 0;
}
项目:Utility    文件:ControllerMonitor.java   
public void update() {
    while(Controllers.next()) {
        handleInput();
    }
}
项目:cuina    文件:Control.java   
@Override
public boolean isTriggered()
{
    return Controllers.isCreated() && Controllers.getController(target).isButtonPressed(button);
}