本文整理汇总了Java中net.java.games.input.Component.Identifier类的典型用法代码示例。如果您正苦于以下问题:Java Identifier类的具体用法?Java Identifier怎么用?Java Identifier使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Identifier类属于net.java.games.input.Component包,在下文中一共展示了Identifier类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: Gamepad
import net.java.games.input.Component.Identifier; //导入依赖的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));
}
}
}
开发者ID:jfcameron,项目名称:G2Dj,代码行数:27,代码来源:Gamepad.java
示例2: loadIdentifiers
import net.java.games.input.Component.Identifier; //导入依赖的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 ++;
}
}
}
开发者ID:mleoking,项目名称:PhET,代码行数:25,代码来源:JInputJoyInput.java
示例3: processPollData
import net.java.games.input.Component.Identifier; //导入依赖的package包/类
@SuppressWarnings("InfiniteLoopStatement")
@Override
public void processPollData() {
Event event = new Event();
while (controller.getEventQueue().getNextEvent(event)) {
Identifier id = event.getComponent().getIdentifier();
if (id.equals(Button._7)) {
startButtonHandler.handle(event.getComponent());
} else if (id instanceof Button && container.handlersEnabled()) {
ControllerEventHandler handler = buttonsHandlerMap.get(id.getName());
if (handler != null) {
handler.handle(event.getComponent());
}
}
}
}
开发者ID:Sythog,项目名称:gamepad-control,代码行数:17,代码来源:EventBasedButtonsListener.java
示例4: listenToFirstButtonPressed
import net.java.games.input.Component.Identifier; //导入依赖的package包/类
private void listenToFirstButtonPressed(ControllerListenerContainer container) {
Controller controller = container.getController();
boolean buttonPressed = false;
while (!buttonPressed) {
controller.poll();
Event event = new Event();
while (controller.getEventQueue().getNextEvent(event)) {
Identifier id = event.getComponent().getIdentifier();
if (id instanceof Button) {
propertyManager.setProperty(propName, id.getName());
propertyManager.storeProperties();
buttonPressed = true;
}
}
}
}
开发者ID:Sythog,项目名称:gamepad-control,代码行数:17,代码来源:TextBoxesOneMouseClickListener.java
示例5: retrieveGamepadValues
import net.java.games.input.Component.Identifier; //导入依赖的package包/类
private void retrieveGamepadValues() {
if (this.gamePadIndex == -1 || this.gamePadIndex != -1 && Input.getGamepad(this.gamePadIndex) == null) {
return;
}
final float x = Input.getGamepad(this.gamePadIndex).getPollData(Identifier.Axis.X);
final float y = Input.getGamepad(this.gamePadIndex).getPollData(Identifier.Axis.Y);
if (Math.abs(x) > this.gamePadDeadzone) {
this.setDx(x);
this.setMovedX(true);
}
if (Math.abs(y) > this.gamePadDeadzone) {
this.setDy(y);
this.setMovedY(true);
}
if (this.isRotateWithRightStick()) {
final float rightX = Input.getGamepad(this.gamePadIndex).getPollData(Identifier.Axis.RX);
final float rightY = Input.getGamepad(this.gamePadIndex).getPollData(Identifier.Axis.RY);
float targetX = 0;
float targetY = 0;
if (Math.abs(rightX) > this.gamePadRightStick) {
targetX = rightX;
}
if (Math.abs(rightY) > this.gamePadRightStick) {
targetY = rightY;
}
if (targetX != 0 || targetY != 0) {
final Point2D target = new Point2D.Double(this.getEntity().getDimensionCenter().getX() + targetX, this.getEntity().getDimensionCenter().getY() + targetY);
final double angle = GeometricUtilities.calcRotationAngleInDegrees(this.getEntity().getDimensionCenter(), target);
this.getEntity().setAngle((float) angle);
}
}
}
开发者ID:gurkenlabs,项目名称:litiengine,代码行数:38,代码来源:GamepadEntityController.java
示例6: getPollData
import net.java.games.input.Component.Identifier; //导入依赖的package包/类
@Override
public float getPollData(final Identifier identifier) {
final Component comp = this.controller.getComponent(identifier);
if (comp == null) {
return 0;
}
return comp.getPollData();
}
开发者ID:gurkenlabs,项目名称:litiengine,代码行数:10,代码来源:Gamepad.java
示例7: BaseJoystick
import net.java.games.input.Component.Identifier; //导入依赖的package包/类
public BaseJoystick(String aName, Controller aController, List<Identifier> aAxisList, List<Identifier> aButtonList, List<Identifier> aPOV)
{
mController = aController;
mAxis = aAxisList;
mButtons = aButtonList;
mPOV = aPOV;
mName = aName;
mAxisValues = new float[mAxis.size()];
mPovValues = new short[mPOV.size()];
}
开发者ID:ArcticWarriors,项目名称:snobot-2017,代码行数:12,代码来源:BaseJoystick.java
示例8: getPovValues
import net.java.games.input.Component.Identifier; //导入依赖的package包/类
@Override
public short[] getPovValues()
{
int i;
for (i = 0; i < mPOV.size(); ++i)
{
Identifier id = mPOV.get(i);
Component component = mController.getComponent(id);
if (component != null)
{
double value = component.getPollData();
if (value == 0)
{
mPovValues[i] = -1;
}
else
{
mPovValues[i] = (short) ((value - .25) * 360);
}
}
}
for (; i < mPovValues.length; ++i)
{
mPovValues[i] = -1;
}
return mPovValues;
}
开发者ID:ArcticWarriors,项目名称:snobot-2017,代码行数:30,代码来源:BaseJoystick.java
示例9: findCompIndex
import net.java.games.input.Component.Identifier; //导入依赖的package包/类
/**
* TODO - remove this - not needed Search through comps[] for id, returning
* the corresponding array index, or -1
*/
private int findCompIndex(Component[] comps, Component.Identifier id, String nm) {
Component c;
for (int i = 0; i < comps.length; i++) {
c = comps[i];
if ((c.getIdentifier() == id) && !c.isRelative()) {
log.info("Found " + c.getName() + "; index: " + i);
return i;
}
}
log.info("No " + nm + " component found");
return -1;
}
开发者ID:glaudiston,项目名称:project-bianca,代码行数:18,代码来源:Joystick.java
示例10: changeComponentToHandle
import net.java.games.input.Component.Identifier; //导入依赖的package包/类
@Override
public void changeComponentToHandle(ControllerEventHandler handler, Identifier component) {
if (buttonsHandlerMap.containsValue(handler)) {
BiMap<ControllerEventHandler, String> inverse = buttonsHandlerMap.inverse();
if (!inverse.containsValue(component.getName())) {
inverse.remove(handler);
inverse.put(handler, component.getName());
buttonsHandlerMap = inverse.inverse();
}
}
}
开发者ID:Sythog,项目名称:gamepad-control,代码行数:12,代码来源:EventBasedButtonsListener.java
示例11: addComponent
import net.java.games.input.Component.Identifier; //导入依赖的package包/类
private static final String addComponent(final Identifier identifier) {
components.put(identifier.getName(), identifier);
return identifier.getName();
}
开发者ID:gurkenlabs,项目名称:litiengine,代码行数:5,代码来源:Gamepad.java
示例12: get
import net.java.games.input.Component.Identifier; //导入依赖的package包/类
private static final Identifier get(final String name) {
return components.get(name);
}
开发者ID:gurkenlabs,项目名称:litiengine,代码行数:4,代码来源:Gamepad.java
示例13: getPovValues
import net.java.games.input.Component.Identifier; //导入依赖的package包/类
public short[] getPovValues()
{
boolean up = mController.getComponent(Identifier.Key.UP).getPollData() != 0;
boolean right = mController.getComponent(Identifier.Key.RIGHT).getPollData() != 0;
boolean down = mController.getComponent(Identifier.Key.DOWN).getPollData() != 0;
boolean left = mController.getComponent(Identifier.Key.LEFT).getPollData() != 0;
if (up && right)
{
mPovValues[0] = 45;
}
else if (right && down)
{
mPovValues[0] = 135;
}
else if (left && down)
{
mPovValues[0] = 225;
}
else if (left && up)
{
mPovValues[0] = -45;
}
else if (up)
{
mPovValues[0] = 0;
}
else if (right)
{
mPovValues[0] = 90;
}
else if (down)
{
mPovValues[0] = 180;
}
else if (left)
{
mPovValues[0] = 270;
}
else
{
mPovValues[0] = -1;
}
return mPovValues;
}
开发者ID:ArcticWarriors,项目名称:snobot-2017,代码行数:47,代码来源:KeyboardJoystick.java
示例14: getComponents
import net.java.games.input.Component.Identifier; //导入依赖的package包/类
/**
* Store the indices for the analog sticks axes (x,y) and (z,rz), POV hat,
* and button components of the controller.
*/
public HashMap<String, Integer> getComponents() {
HashMap<String, Integer> ret = new HashMap<String, Integer>();
if (controller == null) {
error("no controller set");
return ret;
}
components = controller.getComponents();
if (components.length == 0) {
error("No Components found");
return ret;
} else {
info("Num. Components: " + components.length);
}
Component c;
for (int i = 0; i < components.length; i++) {
c = components[i];
Identifier id = c.getIdentifier();
if (id instanceof Component.Identifier.Axis) {
}
ret.put(c.getIdentifier().toString(), i);
}
// substitutions
for (Map.Entry<String, String> entry : mapIds.entrySet()) {
String from = entry.getKey();
String to = entry.getValue();
if (ret.containsKey(from)) {
Integer move = ret.get(from);
ret.put(mapIds.get(from), move);
}
}
// get the indices for the axes of the analog sticks: (x,y) and (z,rz)
xAxisIdx = findCompIndex(components, Component.Identifier.Axis.X, "x-axis");
yAxisIdx = findCompIndex(components, Component.Identifier.Axis.Y, "y-axis");
zAxisIdx = findCompIndex(components, Component.Identifier.Axis.Z, "z-axis");
rzAxisIdx = findCompIndex(components, Component.Identifier.Axis.RZ, "rz-axis");
// get POV hat index
povIdx = findCompIndex(components, Component.Identifier.Axis.POV, "POV hat");
findButtons(components);
return ret;
}
开发者ID:glaudiston,项目名称:project-bianca,代码行数:54,代码来源:Joystick.java
示例15: getHandlerForComponent
import net.java.games.input.Component.Identifier; //导入依赖的package包/类
@Override
public ControllerEventHandler getHandlerForComponent(Identifier component) {
return AXIS_HANDLER_MAP.get(component);
}
开发者ID:Sythog,项目名称:gamepad-control,代码行数:5,代码来源:ContinuousAxisListener.java
示例16: changeComponentToHandle
import net.java.games.input.Component.Identifier; //导入依赖的package包/类
@Override
public void changeComponentToHandle(ControllerEventHandler handler, Identifier component) {
throw new UnsupportedOperationException("Not yet implemented");
}
开发者ID:Sythog,项目名称:gamepad-control,代码行数:5,代码来源:ContinuousAxisListener.java
示例17: getHandlerForComponent
import net.java.games.input.Component.Identifier; //导入依赖的package包/类
@Override
public ControllerEventHandler getHandlerForComponent(Identifier component) {
return buttonsHandlerMap.get(component.getName());
}
开发者ID:Sythog,项目名称:gamepad-control,代码行数:5,代码来源:EventBasedButtonsListener.java
示例18: getPollData
import net.java.games.input.Component.Identifier; //导入依赖的package包/类
public float getPollData(Identifier identifier);
开发者ID:gurkenlabs,项目名称:litiengine,代码行数:2,代码来源:IGamepad.java
示例19: getHandlerForComponent
import net.java.games.input.Component.Identifier; //导入依赖的package包/类
public abstract ControllerEventHandler getHandlerForComponent(Identifier component);
开发者ID:Sythog,项目名称:gamepad-control,代码行数:2,代码来源:ControllerListener.java
示例20: changeComponentToHandle
import net.java.games.input.Component.Identifier; //导入依赖的package包/类
public abstract void changeComponentToHandle(ControllerEventHandler handler, Identifier component);
开发者ID:Sythog,项目名称:gamepad-control,代码行数:2,代码来源:ControllerListener.java
注:本文中的net.java.games.input.Component.Identifier类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论