本文整理汇总了Java中com.badlogic.gdx.controllers.Controllers.getControllers方法的典型用法代码示例。如果您正苦于以下问题:Java Controllers.getControllers方法的具体用法?Java Controllers.getControllers怎么用?Java Controllers.getControllers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.controllers.Controllers
的用法示例。
在下文中一共展示了Controllers.getControllers方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: dispatchStickInputs
import com.badlogic.gdx.controllers.Controllers; //导入方法依赖的package包/类
private void dispatchStickInputs() {
Array<Controller> availableControllers = Controllers.getControllers();
for (int id = 0; id < availableControllers.size; id++) {
Controller controller = availableControllers.get(id);
if (controller != null) {
Array<NhgInput> stickInputs = stickInputsMap.get(id);
if (stickInputs != null) {
for (NhgInput input : stickInputs) {
if (input != null && isValidInput(input)) {
processStickInput(id, controller, input);
dispatchStickInput(input);
}
}
}
}
}
}
示例2: unmappedAnalog
import com.badlogic.gdx.controllers.Controllers; //导入方法依赖的package包/类
@Override
protected long unmappedAnalog(int unmappedAnalogNr) {
Array<com.badlogic.gdx.controllers.Controller> controllers = Controllers.getControllers();
float axisValue = 0;
float axisValueAbs = 0;
float currentAxis;
float currentAxisAbs;
for (int i = controllers.size - 1; i >= 0; i--) {
com.badlogic.gdx.controllers.Controller c = controllers.get(i);
currentAxis = c.getAxis(unmappedAnalogNr);
currentAxisAbs = Math.abs(currentAxis);
//Gdx.app.log("unmappedAnalog","Nr: "+unmappedAnalogNr+" Value: "+currentAxis);
if (currentAxisAbs > axisValueAbs) { // select biggest absolute value on this axis
axisValue = currentAxis;
axisValueAbs = currentAxisAbs;
}
}
if (axisValueAbs >= CONTROLLER_THRESHOLD) {
return (long) (axisValue * 0x7fffffff);
}
return 0; // else
}
示例3: create
import com.badlogic.gdx.controllers.Controllers; //导入方法依赖的package包/类
@Override
public void create () {
Array<Controller> controllers = Controllers.getControllers();
if (controllers.size > 0) {
controller = controllers.first();
}
Controllers.addListener(controllerListener);
setScreen(new MainMenu(this));
music = Gdx.audio.newMusic(Gdx.files.getFileHandle("data/8.12.mp3", FileType.Internal));
music.setLooping(true);
music.play();
Gdx.input.setInputProcessor(new InputAdapter() {
@Override
public boolean keyUp (int keycode) {
if (keycode == Keys.ENTER && Gdx.app.getType() == ApplicationType.WebGL) {
Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayMode());
}
return true;
}
});
fps = new FPSLogger();
}
示例4: create
import com.badlogic.gdx.controllers.Controllers; //导入方法依赖的package包/类
public void create() {
// Texture.setEnforcePotImages(false);
MyInputProcessor iP = new MyInputProcessor();
Gdx.input.setInputProcessor(iP);
Controllers.addListener(iP);
res.loadTextures();
res.loadMusic();
res.loadScriptList(Gdx.files.internal("assets/scripts"));
res.loadLevelNames();
res.loadEventToTexture();
cam = new Camera();
cam.setToOrtho(false, width/scale, height/scale);
hudCam = new OrthographicCamera();
hudCam.setToOrtho(false, width/2, height/2);
b2dCam = new Camera();
b2dCam.setToOrtho(false, width/scale/PPM, height/scale/PPM);
sb = new FadingSpriteBatch();
gsm = new GameStateManager(this);
if(Controllers.getControllers().size == 0)
hasControllers = false;
else hasControllers = true;
}
示例5: create
import com.badlogic.gdx.controllers.Controllers; //导入方法依赖的package包/类
@Override
public void create () {
Array<Controller> controllers = Controllers.getControllers();
if (controllers.size > 0) {
controller = controllers.first();
}
Controllers.addListener(controllerListener);
setScreen(new MainMenu(this));
music = Gdx.audio.newMusic(Gdx.files.getFileHandle("data/8.12.mp3", FileType.Internal));
music.setLooping(true);
music.play();
Gdx.input.setInputProcessor(new InputAdapter() {
@Override
public boolean keyUp (int keycode) {
if (keycode == Keys.ENTER && Gdx.app.getType() == ApplicationType.WebGL) {
if (!Gdx.graphics.isFullscreen()) Gdx.graphics.setDisplayMode(Gdx.graphics.getDisplayModes()[0]);
}
return true;
}
});
fps = new FPSLogger();
}
示例6: create
import com.badlogic.gdx.controllers.Controllers; //导入方法依赖的package包/类
@Override
public void create() {
Gdx.app.setLogLevel(Application.LOG_DEBUG);
batch = new SpriteBatch();
hero = new Hero(screenWidth, screenHeight);
score = new Score(screenWidth, screenHeight);
finalScore = new FinalScore(screenWidth, screenHeight);
bullets = new ArrayList<Bullet>();
clouds = new ArrayList<Cloud>();
if (Controllers.getControllers().size > 0) {
controller = Controllers.getControllers().first();
}
websocketHelper = new WebsocketHelper();
websocketHelper.connectWebSocket();
camera = new OrthographicCamera();
camera.setToOrtho(true, screenWidth, screenHeight);
lastTime = TimeUtils.nanoTime();
lastTimeSpawnedCloud = lastTime;
}
示例7: testForBindingController
import com.badlogic.gdx.controllers.Controllers; //导入方法依赖的package包/类
private Controller testForBindingController() {
for (Controller c : Controllers.getControllers()) {
for (int i = 0; i < 10; i++) {
if (c.getButton(i)) {
return c;
}
}
for (int i = 0; i < 4; i++) {
if (Math.abs(c.getAxis(i)) > 0.75f) {
return c;
}
}
if (c.getPov(0) != PovDirection.center)
return c;
}
return null;
}
示例8: create
import com.badlogic.gdx.controllers.Controllers; //导入方法依赖的package包/类
@Override
public void create () {
Array<Controller> controllers = Controllers.getControllers();
if (controllers.size > 0) {
controller = controllers.first();
}
Controllers.addListener(controllerListener);
setScreen(new MainMenu(this));
music = Gdx.audio.newMusic(Gdx.files.getFileHandle("data/8.12.mp3", FileType.Internal));
music.setLooping(true);
music.play();
Gdx.input.setInputProcessor(new InputAdapter() {
@Override
public boolean keyUp (int keycode) {
if (keycode == Keys.ENTER && Gdx.app.getType() == ApplicationType.WebGL) {
if (!Gdx.graphics.isFullscreen()) Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayModes()[0]);
}
return true;
}
});
fps = new FPSLogger();
}
示例9: initialise
import com.badlogic.gdx.controllers.Controllers; //导入方法依赖的package包/类
@Override
public void initialise(GameContainer gc) {
uiContainer = new UiContainer(gc, assetManager);
uiContainer.setKeyboardNavigationEnabled(UATApplication.USE_KEYBOARD_NAVIGATION);
gc.addResizeListener(this);
initialiseUi();
if(Controllers.getControllers().size > 0) {
try {
System.out.println(uiContainer.getId());
controllerInput = UiUtils.setUpControllerInput(Controllers.getControllers().get(0), uiContainer);
if(controllerInput != null) {
controllerInput.disable();
}
} catch (ControllerPlatformException e) {
e.printStackTrace();
}
}
}
示例10: logControllers
import com.badlogic.gdx.controllers.Controllers; //导入方法依赖的package包/类
private void logControllers() {
Array<Controller> controllers = Controllers.getControllers();
Gdx.app.log(getClass().getSimpleName(), "****** Controller Names *********");
for(Controller controller: controllers) {
Gdx.app.log(getClass().getSimpleName(), controller.getName());
}
Gdx.app.log(getClass().getSimpleName(), "********************************");
}
示例11: autoConfigure
import com.badlogic.gdx.controllers.Controllers; //导入方法依赖的package包/类
public void autoConfigure() {
Array<Controller> controllers = Controllers.getControllers();
if (controllers.size > 0) {
Controller controller = controllers.get(0);
if (isXbox360Controller(controller.getName())) {
buttonIndexToButton.put(com.gradualgames.ggvm.Controller.Buttons.A, XBOX_360_A);
buttonIndexToButton.put(com.gradualgames.ggvm.Controller.Buttons.B, XBOX_360_X);
buttonIndexToButton.put(com.gradualgames.ggvm.Controller.Buttons.SELECT, XBOX_360_LEFT_SHOULDER);
buttonIndexToButton.put(com.gradualgames.ggvm.Controller.Buttons.START, XBOX_360_START);
} else if (controller.getName().equals(RETRO_USB_NAME)) {
buttonIndexToButton.put(com.gradualgames.ggvm.Controller.Buttons.A, RETRO_USB_A);
buttonIndexToButton.put(com.gradualgames.ggvm.Controller.Buttons.B, RETRO_USB_B);
buttonIndexToButton.put(com.gradualgames.ggvm.Controller.Buttons.SELECT, RETRO_USB_SELECT);
buttonIndexToButton.put(com.gradualgames.ggvm.Controller.Buttons.START, RETRO_USB_START);
actualAxisToAxisCode.put(Axis.X, 1);
actualAxisToAxisCode.put(Axis.Y, 0);
}
}
buttonIndexToKeyCode.put(com.gradualgames.ggvm.Controller.Buttons.A, Input.Keys.F);
buttonIndexToKeyCode.put(com.gradualgames.ggvm.Controller.Buttons.B, Input.Keys.D);
buttonIndexToKeyCode.put(com.gradualgames.ggvm.Controller.Buttons.SELECT, Input.Keys.A);
buttonIndexToKeyCode.put(com.gradualgames.ggvm.Controller.Buttons.START, Input.Keys.S);
buttonIndexToKeyCode.put(com.gradualgames.ggvm.Controller.Buttons.UP, Input.Keys.UP);
buttonIndexToKeyCode.put(com.gradualgames.ggvm.Controller.Buttons.RIGHT, Input.Keys.RIGHT);
buttonIndexToKeyCode.put(com.gradualgames.ggvm.Controller.Buttons.DOWN, Input.Keys.DOWN);
buttonIndexToKeyCode.put(com.gradualgames.ggvm.Controller.Buttons.LEFT, Input.Keys.LEFT);
}
示例12: getNameForButton
import com.badlogic.gdx.controllers.Controllers; //导入方法依赖的package包/类
public String getNameForButton(int button) {
Array<Controller> controllers = Controllers.getControllers();
if (controllers.size > 0) {
Controller controller = controllers.get(0);
if (KeyboardInputProcessor.isXbox360Controller(controller.getName())) {
switch(button) {
case XBOX_360_A:
return "A";
case XBOX_360_B:
return "B";
case XBOX_360_X:
return "X";
case XBOX_360_Y:
return "Y";
case XBOX_360_LEFT_SHOULDER:
return "LSHLDR";
case XBOX_360_RIGHT_SHOULDER:
return "RSHLDR";
case XBOX_360_BACK:
return "BACK";
case XBOX_360_START:
return "START";
}
} else if (controller.getName().equals(RETRO_USB_NAME)) {
switch(button) {
case RETRO_USB_A:
return "A";
case RETRO_USB_B:
return "B";
case RETRO_USB_SELECT:
return "SELECT";
case RETRO_USB_START:
return "START";
}
}
}
return Integer.toString(button);
}
示例13: init
import com.badlogic.gdx.controllers.Controllers; //导入方法依赖的package包/类
@Override
public void init(StageControl stage) {
for (Controller controller : Controllers.getControllers()) {
ConfigController config = new ConfigController(controller.getName());
config.load();
configs.put(controller, config);
}
}
示例14: init
import com.badlogic.gdx.controllers.Controllers; //导入方法依赖的package包/类
/**
* Initialisierung.
*
* Lädt alle angeschlossenen Controller und legt den InputProcessor fest.
*
* @param inputProcessor der InputProcessor an den Controllereingaben gesendet werden sollen
*/
public void init(InputProcessor inputProcessor)
{
this.feedForwardProcessor = inputProcessor;
for (Controller controller : Controllers.getControllers())
{
loadController(controller);
}
buildInverse();
}
示例15: checkController
import com.badlogic.gdx.controllers.Controllers; //导入方法依赖的package包/类
/**
* Prüft, ob ein Button, der zu dieser Aktion gehört, auf einem Controller im Moment gedrückt ist.
*
* Dabei werden auch Axenstellungen geprüft.
*
* @param action die Aktion
* @return true, wenn die Aktion auf einem Controller aktiv ist
*/
private static boolean checkController(Action action)
{
if (Controllers.getControllers().size <= 0) return false;
boolean result = false;
if (getInstance().controllerGameButtonBinding.containsKey(action))
{
ButtonKey[] buttonKeys = getInstance().controllerGameButtonBinding.get(action);
for (ButtonKey buttonKey : buttonKeys)
result |= buttonKey.getController() != null && buttonKey.getController().getButton(buttonKey.getButtonCode());
}
if (getInstance().controllerGameAxisBinding.containsKey(action))
{
AxisKey[] axisKeys = getInstance().controllerGameAxisBinding.get(action);
for (AxisKey axisKey : axisKeys)
{
if (axisKey.getController() != null)
{
float axisValue = axisKey.getController().getAxis(axisKey.getAxisCode());
result |= axisKey.isHigh() && axisValue >= 0.7f;
result |= !axisKey.isHigh() && axisValue <= -0.7f;
}
}
}
return result;
}