1 /******************************************************************************* 2 * Copyright 2011 See AUTHORS file. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 ******************************************************************************/ 16 17 package com.badlogic.gdx.controllers.desktop.ois; 18 19 import com.badlogic.gdx.ApplicationAdapter; 20 import com.badlogic.gdx.controllers.desktop.DesktopControllersBuild; 21 import com.badlogic.gdx.controllers.desktop.OisControllers; 22 import com.badlogic.gdx.controllers.desktop.ois.OisJoystick.OisPov; 23 import com.badlogic.gdx.utils.SharedLibraryLoader; 24 25 public class OisTest { 26 public static void main (String[] args) throws Exception { 27 DesktopControllersBuild.main(null); 28 new SharedLibraryLoader("libs/gdx-controllers-desktop-natives.jar").load("gdx-controllers-desktop"); 29 30 ApplicationAdapter app = new ApplicationAdapter() { 31 Ois ois; 32 33 public void create () { 34 ois = new Ois(OisControllers.getWindowHandle()); 35 if (ois.getJoysticks().size() > 0) { 36 ois.getJoysticks().get(0).setListener(new OisListener() { 37 @Override 38 public void xSliderMoved (OisJoystick joystick, int slider, boolean value) { 39 System.out.println("xSliderMoved: " + slider + ", " + value); 40 } 41 42 @Override 43 public void ySliderMoved (OisJoystick joystick, int slider, boolean value) { 44 System.out.println("ySliderMoved: " + slider + ", " + value); 45 } 46 47 @Override 48 public void povMoved (OisJoystick joystick, int pov, OisPov value) { 49 System.out.println("povMoved: " + pov + ", " + value); 50 51 } 52 53 @Override 54 public void buttonReleased (OisJoystick joystick, int button) { 55 System.out.println("buttonReleased: " + button); 56 } 57 58 @Override 59 public void buttonPressed (OisJoystick joystick, int button) { 60 System.out.println("buttonPressed: " + button); 61 } 62 63 @Override 64 public void axisMoved (OisJoystick joystick, int axis, float value) { 65 System.out.println("axisMoved: " + axis + ", " + value); 66 } 67 }); 68 } 69 } 70 71 public void render () { 72 ois.update(); 73 } 74 }; 75 76 // new LwjglApplication(app); 77 // new LwjglFrame(app, "Controllers", 200, 200, false); 78 } 79 } 80