本文整理汇总了Java中net.java.games.input.Component类的典型用法代码示例。如果您正苦于以下问题:Java Component类的具体用法?Java Component怎么用?Java Component使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Component类属于net.java.games.input包,在下文中一共展示了Component类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: HatSwitchHandler
import net.java.games.input.Component; //导入依赖的package包/类
public HatSwitchHandler(Controller c,
Component hat,
Component a, Component b, Component x, Component y,
Component r, Component l, Component start, Component select) {
super(
c,
new ComponentWrapper(hat, SNESInputEvent.SNES_UP, POV.UP, POV.UP_LEFT, POV.UP_RIGHT),
new ComponentWrapper(hat, SNESInputEvent.SNES_DOWN, POV.DOWN, POV.DOWN_LEFT, POV.DOWN_RIGHT),
new ComponentWrapper(hat, SNESInputEvent.SNES_RIGHT, POV.RIGHT, POV.UP_RIGHT, POV.DOWN_RIGHT),
new ComponentWrapper(hat, SNESInputEvent.SNES_LEFT, POV.LEFT, POV.UP_LEFT, POV.DOWN_LEFT),
new ComponentWrapper(a, SNESInputEvent.SNES_A, ON),
new ComponentWrapper(b, SNESInputEvent.SNES_B, ON),
new ComponentWrapper(x, SNESInputEvent.SNES_X, ON),
new ComponentWrapper(y, SNESInputEvent.SNES_Y, ON),
new ComponentWrapper(r, SNESInputEvent.SNES_R, ON),
new ComponentWrapper(l, SNESInputEvent.SNES_L, ON),
new ComponentWrapper(start, SNESInputEvent.SNES_START, ON),
new ComponentWrapper(select, SNESInputEvent.SNES_SELECT, ON)
);
}
示例2: DPadHandler
import net.java.games.input.Component; //导入依赖的package包/类
public DPadHandler(Controller c,
Component up, Component down, Component right, Component left,
Component a, Component b, Component x, Component y,
Component r, Component l, Component start, Component select) {
super(
c,
new ComponentWrapper(up, SNESInputEvent.SNES_UP, ON),
new ComponentWrapper(down, SNESInputEvent.SNES_DOWN, ON),
new ComponentWrapper(right, SNESInputEvent.SNES_RIGHT, ON),
new ComponentWrapper(left, SNESInputEvent.SNES_LEFT, ON),
new ComponentWrapper(a, SNESInputEvent.SNES_A, ON),
new ComponentWrapper(b, SNESInputEvent.SNES_B, ON),
new ComponentWrapper(x, SNESInputEvent.SNES_X, ON),
new ComponentWrapper(y, SNESInputEvent.SNES_Y, ON),
new ComponentWrapper(r, SNESInputEvent.SNES_R, ON),
new ComponentWrapper(l, SNESInputEvent.SNES_L, ON),
new ComponentWrapper(start, SNESInputEvent.SNES_START, ON),
new ComponentWrapper(select, SNESInputEvent.SNES_SELECT, ON)
);
}
示例3: AxisHandler
import net.java.games.input.Component; //导入依赖的package包/类
public AxisHandler(Controller c,
Component yaxis, Component xaxis,
Component a, Component b, Component x, Component y,
Component r, Component l, Component start, Component select) {
super(
c,
new ComponentWrapper(yaxis, SNESInputEvent.SNES_UP, -ON),
new ComponentWrapper(yaxis, SNESInputEvent.SNES_DOWN, ON),
new ComponentWrapper(xaxis, SNESInputEvent.SNES_RIGHT, ON),
new ComponentWrapper(xaxis, SNESInputEvent.SNES_LEFT, -ON),
new ComponentWrapper(a, SNESInputEvent.SNES_A, ON),
new ComponentWrapper(b, SNESInputEvent.SNES_B, ON),
new ComponentWrapper(x, SNESInputEvent.SNES_X, ON),
new ComponentWrapper(y, SNESInputEvent.SNES_Y, ON),
new ComponentWrapper(r, SNESInputEvent.SNES_R, ON),
new ComponentWrapper(l, SNESInputEvent.SNES_L, ON),
new ComponentWrapper(start, SNESInputEvent.SNES_START, ON),
new ComponentWrapper(select, SNESInputEvent.SNES_SELECT, ON)
);
}
示例4: Gamepad
import net.java.games.input.Component; //导入依赖的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));
}
}
}
示例5: FromJInputComponentPollData
import net.java.games.input.Component; //导入依赖的package包/类
public static HatState FromJInputComponentPollData(final float aJInputComponentPollData)
{
if (aJInputComponentPollData == net.java.games.input.Component.POV.UP)
return HatState.Up;
else if (aJInputComponentPollData == net.java.games.input.Component.POV.DOWN)
return HatState.Down;
else if (aJInputComponentPollData == net.java.games.input.Component.POV.LEFT)
return HatState.Left;
else if (aJInputComponentPollData == net.java.games.input.Component.POV.RIGHT)
return HatState.Right;
//cardinal+45
else if (aJInputComponentPollData == net.java.games.input.Component.POV.UP_LEFT)
return HatState.UpLeft;
else if (aJInputComponentPollData == net.java.games.input.Component.POV.UP_RIGHT)
return HatState.UpRight;
else if (aJInputComponentPollData == net.java.games.input.Component.POV.DOWN_LEFT)
return HatState.DownLeft;
else if (aJInputComponentPollData == net.java.games.input.Component.POV.DOWN_RIGHT)
return HatState.DownRight;
return HatState.Neutral;
}
示例6: getButton
import net.java.games.input.Component; //导入依赖的package包/类
/**
* Gets the button attribute of the YassInput class
*
* @param d Description of the Parameter
* @param i Description of the Parameter
* @return The button value
*/
public static int getButton(int d, int i) {
ControllerEnvironment ce = ControllerEnvironment.getDefaultEnvironment();
Controller[] cs = ce.getControllers();
int buttonCount = 0;
Component[] comps = cs[d].getComponents();
for (int c = 0; c < comps.length; c++) {
if (!(comps[c].getIdentifier() instanceof Component.Identifier.Axis)) {
if (buttonCount == i) {
return c;
}
buttonCount++;
}
}
return -1;
}
示例7: fireKeyPressed
import net.java.games.input.Component; //导入依赖的package包/类
/**
* Description of the Method
*
* @param e Description of the Parameter
*/
public void fireKeyPressed(KeyEvent e) {
for (Enumeration<KeyListener> en = listeners.elements(); en.hasMoreElements(); ) {
KeyListener l = en.nextElement();
l.keyPressed(new KeyEvent((java.awt.Component) e.getSource(), KeyEvent.KEY_PRESSED, System.currentTimeMillis(), e.getModifiers(), e.getKeyCode(), e.getKeyChar(), e.getKeyLocation()));
}
}
示例8: fireKeyReleased
import net.java.games.input.Component; //导入依赖的package包/类
/**
* Description of the Method
*
* @param e Description of the Parameter
*/
public void fireKeyReleased(KeyEvent e) {
for (Enumeration<KeyListener> en = listeners.elements(); en.hasMoreElements(); ) {
KeyListener l = en.nextElement();
l.keyReleased(new KeyEvent((java.awt.Component) e.getSource(), KeyEvent.KEY_RELEASED, System.currentTimeMillis(), e.getModifiers(), e.getKeyCode(), e.getKeyChar(), e.getKeyLocation()));
}
}
示例9: GenericGamepadJoystick
import net.java.games.input.Component; //导入依赖的package包/类
public GenericGamepadJoystick(Controller aController, String aName)
{
super(aName, aController, new ArrayList<>(), new ArrayList<>(), new ArrayList<>());
if (mController != null)
{
Component[] components = mController.getComponents();
for (int j = 0; j < components.length; j++)
{
if (components[j].isAnalog())
{
mAxis.add(components[j].getIdentifier());
}
else
{
mButtons.add(components[j].getIdentifier());
}
}
mAxisValues = new float[mAxis.size()];
mPovValues = new short[mPOV.size()];
}
}
示例10: getAxisValues
import net.java.games.input.Component; //导入依赖的package包/类
@Override
public float[] getAxisValues()
{
if (mController != null)
{
mController.poll();
for (int i = 0; i < mAxis.size(); ++i)
{
Component c = mController.getComponent(mAxis.get(i));
if (c != null)
{
mAxisValues[i] = c.getPollData();
}
}
}
else
{
System.err.println("Controller is null. The simulator could not setup a controller of type [" + mName + "]");
}
return mAxisValues;
}
示例11: createComponents
import net.java.games.input.Component; //导入依赖的package包/类
private static Component[] createComponents() {
List<Key> components = new ArrayList<Key>();
Field[] vkey_fields = org.lwjgl.input.Keyboard.class.getFields();
for ( Field vkey_field : vkey_fields ) {
try {
if (Modifier.isStatic(vkey_field.getModifiers()) && vkey_field.getType() == int.class &&
vkey_field.getName().startsWith("KEY_")) {
int vkey_code = vkey_field.getInt(null);
Component.Identifier.Key key_id = KeyMap.map(vkey_code);
if (key_id != Component.Identifier.Key.UNKNOWN)
components.add(new Key(key_id, vkey_code));
}
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}
return components.toArray(new Component[components.size()]);
}
示例12: getNextDeviceEvent
import net.java.games.input.Component; //导入依赖的package包/类
protected synchronized boolean getNextDeviceEvent(Event event) throws IOException {
if (!org.lwjgl.input.Keyboard.isCreated())
return false;
if (!org.lwjgl.input.Keyboard.next())
return false;
int lwjgl_key = org.lwjgl.input.Keyboard.getEventKey();
if (lwjgl_key == org.lwjgl.input.Keyboard.KEY_NONE)
return false;
Component.Identifier.Key key_id = KeyMap.map(lwjgl_key);
if (key_id == null)
return false;
Component key = getComponent(key_id);
if (key == null)
return false;
float value = org.lwjgl.input.Keyboard.getEventKeyState() ? 1 : 0;
event.set(key, value, org.lwjgl.input.Keyboard.getEventNanoseconds());
return true;
}
示例13: getPovX
import net.java.games.input.Component; //导入依赖的package包/类
public float getPovX() {
if (pov.size() == 0) {
return 0;
}
float value = povValues[0];
if ((value == Component.POV.DOWN_LEFT) ||
(value == Component.POV.UP_LEFT) ||
(value == Component.POV.LEFT)) {
return -1;
}
if ((value == Component.POV.DOWN_RIGHT) ||
(value == Component.POV.UP_RIGHT) ||
(value == Component.POV.RIGHT)) {
return 1;
}
return 0;
}
示例14: getPovY
import net.java.games.input.Component; //导入依赖的package包/类
public float getPovY() {
if (pov.size() == 0) {
return 0;
}
float value = povValues[0];
if ((value == Component.POV.DOWN_LEFT) ||
(value == Component.POV.DOWN_RIGHT) ||
(value == Component.POV.DOWN)) {
return 1;
}
if ((value == Component.POV.UP_LEFT) ||
(value == Component.POV.UP_RIGHT) ||
(value == Component.POV.UP)) {
return -1;
}
return 0;
}
示例15: loadIdentifiers
import net.java.games.input.Component; //导入依赖的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 ++;
}
}
}