当前位置: 首页>>代码示例>>Java>>正文


Java XInputButton类代码示例

本文整理汇总了Java中com.ivan.xinput.enums.XInputButton的典型用法代码示例。如果您正苦于以下问题:Java XInputButton类的具体用法?Java XInputButton怎么用?Java XInputButton使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


XInputButton类属于com.ivan.xinput.enums包,在下文中一共展示了XInputButton类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import com.ivan.xinput.enums.XInputButton; //导入依赖的package包/类
@Override
public void init() throws XInputNotLoadedException
{
	this.device = XInputDevice.getDeviceFor(0);
	this.device.addListener(new XInputDeviceListener()
	{
		@Override
		public void disconnected()
		{
			// do nothing
		}

		@Override
		public void connected()
		{
			// do nothing
		}

		@Override
		public void buttonChanged(XInputButton arg0, boolean arg1)
		{
			MainDialog.resetActivityTimer(XBOX_CONTROLLER);
		}
	});
}
 
开发者ID:PolyphasicDevTeam,项目名称:NoMoreOversleeps,代码行数:26,代码来源:IntegrationXboxController.java

示例2: fireAxisChanged

import com.ivan.xinput.enums.XInputButton; //导入依赖的package包/类
/**
 * Checks the value of axis has changed
 */
private void fireAxisChanged() {
	if (device != null && listener != null) {
		float lx_delta = device.getDelta().getAxes().getLXDelta();
		float ly_delta = device.getDelta().getAxes().getLYDelta();
		float lx = device.getComponents().getAxes().lx;
		float ly = device.getComponents().getAxes().ly;
		float lx_last = device.getLastComponents().getAxes().lx;
		float ly_last = device.getLastComponents().getAxes().ly;

		// Left trigger X-axis
		if (lx >= GOAL_VALUE && lx_delta != 0f)
			listener.keyPressed(XInputButton.DPAD_RIGHT);
		if (lx <= -GOAL_VALUE && lx_delta != 0f)
			listener.keyPressed(XInputButton.DPAD_LEFT);
		if (lx_delta < -MIN_VALUE && lx_last <= -MIN_VALUE) {
			listener.keyReleased(XInputButton.DPAD_LEFT);
		} else if (lx_delta > MIN_VALUE && lx_last >= MIN_VALUE) {
			listener.keyReleased(XInputButton.DPAD_RIGHT);
		}

		// Left trigger Y-axis
		if (ly >= GOAL_VALUE && ly_delta != 0f)
			listener.keyPressed(XInputButton.DPAD_UP);
		if (ly <= -GOAL_VALUE && ly_delta != 0f)
			listener.keyPressed(XInputButton.DPAD_DOWN);
		if (ly_delta < -MIN_VALUE && ly_last <= -MIN_VALUE) {
			listener.keyReleased(XInputButton.DPAD_DOWN);
		} else if (ly_delta > MIN_VALUE && ly_last >= MIN_VALUE) {
			listener.keyReleased(XInputButton.DPAD_UP);
		}
	}
}
 
开发者ID:n0Live,项目名称:BrickGame,代码行数:36,代码来源:Window.java

示例3: delta

import com.ivan.xinput.enums.XInputButton; //导入依赖的package包/类
/**
 * Determines if the state of a button was changed from one poll to the following poll.
 * 
 * @param from the old state
 * @param to the new state
 * @param button the button
 * @return <code>true</code> if there was a change, <code>false</code> otherwise
 */
private boolean delta(final XInputButtons from, final XInputButtons to, final XInputButton button) {
    switch (button) {
        case A:
            return !from.a && to.a;
        case B:
            return !from.b && to.b;
        case X:
            return !from.x && to.x;
        case Y:
            return !from.y && to.y;
        case BACK:
            return !from.back && to.back;
        case START:
            return !from.start && to.start;
        case LEFT_SHOULDER:
            return !from.lShoulder && to.lShoulder;
        case RIGHT_SHOULDER:
            return !from.rShoulder && to.rShoulder;
        case LEFT_THUMBSTICK:
            return !from.lThumb && to.lThumb;
        case RIGHT_THUMBSTICK:
            return !from.rThumb && to.rThumb;
        case DPAD_UP:
            return !from.up && to.up;
        case DPAD_DOWN:
            return !from.down && to.down;
        case DPAD_LEFT:
            return !from.left && to.left;
        case DPAD_RIGHT:
            return !from.right && to.right;
        case GUIDE_BUTTON:
            return !from.guide && to.guide;
        case UNKNOWN:
            return !from.unknown && to.unknown;
    }
    return false;
}
 
开发者ID:StrikerX3,项目名称:JXInput,代码行数:46,代码来源:XInputButtonsDelta.java

示例4: processDelta

import com.ivan.xinput.enums.XInputButton; //导入依赖的package包/类
private void processDelta() {
    final XInputButtonsDelta buttons = delta.getButtons();
    for (final XInputDeviceListener listener : listeners) {
        for (final XInputButton button : XInputButton.values()) {
            if (buttons.isPressed(button)) {
                listener.buttonChanged(button, true);
            } else if (buttons.isReleased(button)) {
                listener.buttonChanged(button, false);
            }
        }
    }
}
 
开发者ID:StrikerX3,项目名称:JXInput,代码行数:13,代码来源:XInputDevice.java

示例5: buttonChanged

import com.ivan.xinput.enums.XInputButton; //导入依赖的package包/类
@Override
public void buttonChanged(XInputButton button, boolean pressed) {
	if (pressed) keyPressed(button);
	else keyReleased(button);
}
 
开发者ID:n0Live,项目名称:BrickGame,代码行数:6,代码来源:XInputListener.java

示例6: buttonChanged

import com.ivan.xinput.enums.XInputButton; //导入依赖的package包/类
@Override
public void buttonChanged(final XInputButton button, final boolean pressed) {
}
 
开发者ID:StrikerX3,项目名称:JXInput,代码行数:4,代码来源:SimpleXInputDeviceListener.java

示例7: XInputCapabilities

import com.ivan.xinput.enums.XInputButton; //导入依赖的package包/类
XInputCapabilities(final ByteBuffer buffer) {
    // typedef struct _XINPUT_CAPABILITIES
    // {
    //     BYTE                                Type;
    //     BYTE                                SubType;
    //     WORD                                Flags;
    //     XINPUT_GAMEPAD                      Gamepad;
    //     XINPUT_VIBRATION                    Vibration;
    // } XINPUT_CAPABILITIES, *PXINPUT_CAPABILITIES;

    // typedef struct _XINPUT_GAMEPAD
    // {
    //     WORD                                wButtons;
    //     BYTE                                bLeftTrigger;
    //     BYTE                                bRightTrigger;
    //     SHORT                               sThumbLX;
    //     SHORT                               sThumbLY;
    //     SHORT                               sThumbRX;
    //     SHORT                               sThumbRY;
    // } XINPUT_GAMEPAD, *PXINPUT_GAMEPAD;

    // typedef struct _XINPUT_VIBRATION
    // {
    //     WORD                                wLeftMotorSpeed;
    //     WORD                                wRightMotorSpeed;
    // } XINPUT_VIBRATION, *PXINPUT_VIBRATION;

    final byte type = buffer.get();
    final byte subType = buffer.get();

    this.type = XInputDeviceType.fromNative(type);
    this.subType = XInputDeviceSubType.fromNative(subType);

    final short flags = buffer.getShort();
    forceFeedbackSupported = (flags & XInputConstants.XINPUT_CAPS_FFB_SUPPORTED) != 0;
    wireless = (flags & XInputConstants.XINPUT_CAPS_WIRELESS) != 0;
    voiceSupported = (flags & XInputConstants.XINPUT_CAPS_VOICE_SUPPORTED) != 0;
    pluginModulesSupported = (flags & XInputConstants.XINPUT_CAPS_PMD_SUPPORTED) != 0;
    noNavigation = (flags & XInputConstants.XINPUT_CAPS_NO_NAVIGATION) != 0;

    final short buttons = buffer.getShort();
    addSupportedButton(buttons, XINPUT_GAMEPAD_A, XInputButton.A);
    addSupportedButton(buttons, XINPUT_GAMEPAD_B, XInputButton.B);
    addSupportedButton(buttons, XINPUT_GAMEPAD_X, XInputButton.X);
    addSupportedButton(buttons, XINPUT_GAMEPAD_Y, XInputButton.Y);
    addSupportedButton(buttons, XINPUT_GAMEPAD_BACK, XInputButton.BACK);
    addSupportedButton(buttons, XINPUT_GAMEPAD_START, XInputButton.START);
    addSupportedButton(buttons, XINPUT_GAMEPAD_LEFT_SHOULDER, XInputButton.LEFT_SHOULDER);
    addSupportedButton(buttons, XINPUT_GAMEPAD_RIGHT_SHOULDER, XInputButton.RIGHT_SHOULDER);
    addSupportedButton(buttons, XINPUT_GAMEPAD_LEFT_THUMB, XInputButton.LEFT_THUMBSTICK);
    addSupportedButton(buttons, XINPUT_GAMEPAD_RIGHT_THUMB, XInputButton.RIGHT_THUMBSTICK);
    addSupportedButton(buttons, XINPUT_GAMEPAD_GUIDE_BUTTON, XInputButton.GUIDE_BUTTON);
    addSupportedButton(buttons, XINPUT_GAMEPAD_UNKNOWN, XInputButton.UNKNOWN);
    addSupportedButton(buttons, XINPUT_GAMEPAD_DPAD_UP, XInputButton.DPAD_UP);
    addSupportedButton(buttons, XINPUT_GAMEPAD_DPAD_DOWN, XInputButton.DPAD_DOWN);
    addSupportedButton(buttons, XINPUT_GAMEPAD_DPAD_LEFT, XInputButton.DPAD_LEFT);
    addSupportedButton(buttons, XINPUT_GAMEPAD_DPAD_RIGHT, XInputButton.DPAD_RIGHT);

    // add Guide button support manually
    if (XInputNatives.isGuideButtonSupported()) {
        supportedButtons.add(XInputButton.GUIDE_BUTTON);
    }

    resolutions = new XInputCapsResolutions(buffer);
}
 
开发者ID:StrikerX3,项目名称:JXInput,代码行数:66,代码来源:XInputCapabilities.java

示例8: addSupportedButton

import com.ivan.xinput.enums.XInputButton; //导入依赖的package包/类
private void addSupportedButton(final short buttons, final short bit, final XInputButton button) {
    if ((buttons & bit) == bit) {
        supportedButtons.add(button);
    }
}
 
开发者ID:StrikerX3,项目名称:JXInput,代码行数:6,代码来源:XInputCapabilities.java

示例9: keyPressed

import com.ivan.xinput.enums.XInputButton; //导入依赖的package包/类
/**
 * Called when a XInputButton has been pressed.
 * 
 * @param button
 *            the button
 */
public void keyPressed(XInputButton button) {
	if (robot != null && keycodeMap.containsKey(button)) {
		robot.keyPress(keycodeMap.get(button));
	}
}
 
开发者ID:n0Live,项目名称:BrickGame,代码行数:12,代码来源:XInputListener.java

示例10: keyReleased

import com.ivan.xinput.enums.XInputButton; //导入依赖的package包/类
/**
 * Called when a XInputButton has been released.
 * 
 * @param button
 *            the button
 */
public void keyReleased(XInputButton button) {
	if (robot != null && keycodeMap.containsKey(button)) {
		robot.keyRelease(keycodeMap.get(button));
	}
}
 
开发者ID:n0Live,项目名称:BrickGame,代码行数:12,代码来源:XInputListener.java

示例11: isPressed

import com.ivan.xinput.enums.XInputButton; //导入依赖的package包/类
/**
 * Returns <code>true</code> if the button was pressed (i.e. changed from released to pressed between two consecutive polls).
 * 
 * @param button the button
 * @return <code>true</code> if the button was pressed, <code>false</code> otherwise
 */
public boolean isPressed(final XInputButton button) {
    return delta(lastButtons, buttons, button);
}
 
开发者ID:StrikerX3,项目名称:JXInput,代码行数:10,代码来源:XInputButtonsDelta.java

示例12: isReleased

import com.ivan.xinput.enums.XInputButton; //导入依赖的package包/类
/**
 * Returns <code>true</code> if the button was released (i.e. changed from pressed to released between two consecutive polls).
 * 
 * @param button the button
 * @return <code>true</code> if the button was released, <code>false</code> otherwise
 */
public boolean isReleased(final XInputButton button) {
    return delta(buttons, lastButtons, button);
}
 
开发者ID:StrikerX3,项目名称:JXInput,代码行数:10,代码来源:XInputButtonsDelta.java

示例13: buttonChanged

import com.ivan.xinput.enums.XInputButton; //导入依赖的package包/类
/**
 * Called when a button is pressed or released.
 *
 * @param button the button
 * @param pressed <code>true</code> if the button was pressed, <code>false</code> if released.
 */
void buttonChanged(final XInputButton button, final boolean pressed);
 
开发者ID:StrikerX3,项目名称:JXInput,代码行数:8,代码来源:XInputDeviceListener.java

示例14: getSupportedButtons

import com.ivan.xinput.enums.XInputButton; //导入依赖的package包/类
/**
 * Retrieves the buttons supported by the device.
 *
 * @return a set of buttons supported by the device
 */
public EnumSet<XInputButton> getSupportedButtons() {
    return supportedButtons;
}
 
开发者ID:StrikerX3,项目名称:JXInput,代码行数:9,代码来源:XInputCapabilities.java


注:本文中的com.ivan.xinput.enums.XInputButton类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。