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


Java Component.getPollData方法代码示例

本文整理汇总了Java中net.java.games.input.Component.getPollData方法的典型用法代码示例。如果您正苦于以下问题:Java Component.getPollData方法的具体用法?Java Component.getPollData怎么用?Java Component.getPollData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.java.games.input.Component的用法示例。


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

示例1: 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;
}
 
开发者ID:ArcticWarriors,项目名称:snobot-2017,代码行数:25,代码来源:BaseJoystick.java

示例2: currentAxis

import net.java.games.input.Component; //导入方法依赖的package包/类
@Override
protected ControllerAxis currentAxis() {
    if (!checkController()) {
        return null;
    }
    
    Component xComponent = m_controller.getComponent(Component.Identifier.Axis.X);
    m_axis.pitch = xComponent.getPollData();
    
    Component yComponent = m_controller.getComponent(Component.Identifier.Axis.Y);
    m_axis.roll = yComponent.getPollData();
    
    Component zComponent = m_controller.getComponent(Component.Identifier.Axis.Z);
    m_axis.yaw = zComponent.getPollData();
    
    Component sComponent = m_controller.getComponent(Component.Identifier.Axis.SLIDER);
    m_axis.gaz = (sComponent == null ? 0.0f : sComponent.getPollData());
    
    return m_axis;
}
 
开发者ID:Koheiru,项目名称:J-ARDrone2,代码行数:21,代码来源:JoystickController.java

示例3: getPollData

import net.java.games.input.Component; //导入方法依赖的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

示例4: getButtonMask

import net.java.games.input.Component; //导入方法依赖的package包/类
@Override
public int getButtonMask()
{

    int output = 0;

    if (mController != null)
    {
        mController.poll();

        for (int i = 0; i < mButtons.size(); ++i)
        {
            Component component = mController.getComponent(mButtons.get(i));
            if (component != null)
            {
                int pressed = component.getPollData() == 0 ? 0 : 1;
                output += (pressed << i);
            }
        }
    }
    else
    {
        System.err.println("Controller is null.  The simulator could not setup a controller of type [" + mName + "]");
    }

    return output;
}
 
开发者ID:ArcticWarriors,项目名称:snobot-2017,代码行数:28,代码来源:BaseJoystick.java

示例5: getPovValues

import net.java.games.input.Component; //导入方法依赖的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

示例6: poll

import net.java.games.input.Component; //导入方法依赖的package包/类
public void poll() {
	target.poll();

	Event event = new Event();
	EventQueue queue = target.getEventQueue();

	while (queue.getNextEvent(event)) {
		// handle button event
		if (buttons.contains(event.getComponent())) {
			Component button = event.getComponent();
			int buttonIndex = buttons.indexOf(button);
			buttonState[buttonIndex] = event.getValue() != 0;

			// fire button pressed event
			Controllers.addEvent(new ControllerEvent(this,event.getNanos(),ControllerEvent.BUTTON,buttonIndex,false,false));
		}

		// handle pov events
		if (pov.contains(event.getComponent())) {
			Component povComponent = event.getComponent();
			int povIndex = pov.indexOf(povComponent);
			float prevX = getPovX();
			float prevY = getPovY();
			povValues[povIndex] = event.getValue();

			if (prevX != getPovX()) {
				Controllers.addEvent(new ControllerEvent(this,event.getNanos(),ControllerEvent.POVX,0,false,false));
			}
			if (prevY != getPovY()) {
				Controllers.addEvent(new ControllerEvent(this,event.getNanos(),ControllerEvent.POVY,0,false,false));
			}
		}

		// handle axis updates
		if (axes.contains(event.getComponent())) {
			Component axis = event.getComponent();
			int axisIndex = axes.indexOf(axis);
			float value = axis.getPollData();

			// fixed dead zone since most axis don't report it :(
			if (Math.abs(value) < deadZones[axisIndex]) {
				value = 0;
			}
			if (Math.abs(value) < axis.getDeadZone()) {
				value = 0;
			}
			if (Math.abs(value) > axesMax[axisIndex]) {
				axesMax[axisIndex] = Math.abs(value);
			}

			// normalize the value based on maximum value read in the past
			value /= axesMax[axisIndex];
			// fire event
			Controllers.addEvent(new ControllerEvent(this,event.getNanos(),ControllerEvent.AXIS,axisIndex,
													 axisIndex == xaxis,axisIndex == yaxis));
			axesValue[axisIndex] = value;
		}
	}
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:60,代码来源:JInputController.java

示例7: handle

import net.java.games.input.Component; //导入方法依赖的package包/类
@Override
public void handle(Component event) {
    if (event.getPollData() == RELEASED) {
        controllerListenerContainer.toggleHandlers();
    }
}
 
开发者ID:Sythog,项目名称:gamepad-control,代码行数:7,代码来源:StartButtonHandler.java

示例8: poll

import net.java.games.input.Component; //导入方法依赖的package包/类
public void poll() {
	target.poll();

	Event event = new Event();
	EventQueue queue = target.getEventQueue();

	while (queue.getNextEvent(event)) {
		// handle button event
		if (buttons.contains(event.getComponent())) {
			Component button = event.getComponent();
			int buttonIndex = buttons.indexOf(button);
			buttonState[buttonIndex] = event.getValue() != 0;

			// fire button pressed event
			Controllers.addEvent(new ControllerEvent(this,event.getNanos(),ControllerEvent.BUTTON,buttonIndex,
													 buttonState[buttonIndex],false,false,0,0));
		}

		// handle pov events
		if (pov.contains(event.getComponent())) {
			Component povComponent = event.getComponent();
			int povIndex = pov.indexOf(povComponent);
			float prevX = getPovX();
			float prevY = getPovY();
			povValues[povIndex] = event.getValue();

			if (prevX != getPovX()) {
				Controllers.addEvent(new ControllerEvent(this,event.getNanos(),ControllerEvent.POVX,0,false,false));
			}
			if (prevY != getPovY()) {
				Controllers.addEvent(new ControllerEvent(this,event.getNanos(),ControllerEvent.POVY,0,false,false));
			}
		}

		// handle axis updates
		if (axes.contains(event.getComponent())) {
			Component axis = event.getComponent();
			int axisIndex = axes.indexOf(axis);
			float value = axis.getPollData();
			float xaxisValue = 0;
			float yaxisValue = 0;

			// fixed dead zone since most axis don't report it :(
			if (Math.abs(value) < deadZones[axisIndex]) {
				value = 0;
			}
			if (Math.abs(value) < axis.getDeadZone()) {
				value = 0;
			}
			if (Math.abs(value) > axesMax[axisIndex]) {
				axesMax[axisIndex] = Math.abs(value);
			}

			// normalize the value based on maximum value read in the past
			value /= axesMax[axisIndex];

			if (axisIndex == xaxis) {
				xaxisValue = value;
			}
			if (axisIndex == yaxis) {
				yaxisValue = value;
			}

			// fire event
			Controllers.addEvent(new ControllerEvent(this,event.getNanos(),ControllerEvent.AXIS,axisIndex,false,
													 axisIndex == xaxis,axisIndex == yaxis,xaxisValue,yaxisValue));
			axesValue[axisIndex] = value;
		}
	}
}
 
开发者ID:Superloup10,项目名称:Wolf_game,代码行数:71,代码来源:JInputController.java

示例9: poll

import net.java.games.input.Component; //导入方法依赖的package包/类
public void poll() {
    target.poll();

    Event event = new Event();
    EventQueue queue = target.getEventQueue();

    while (queue.getNextEvent(event)) {
        // handle button event
        if (buttons.contains(event.getComponent())) {
            Component button = event.getComponent();
            int buttonIndex = buttons.indexOf(button);
            buttonState[buttonIndex] = event.getValue() != 0;

            // fire button pressed event
            Controllers.addEvent(new ControllerEvent(this, event.getNanos(), ControllerEvent.BUTTON, buttonIndex,
                    buttonState[buttonIndex], false, false, 0, 0));
        }

        // handle pov events
        if (pov.contains(event.getComponent())) {
            Component povComponent = event.getComponent();
            int povIndex = pov.indexOf(povComponent);
            float prevX = getPovX();
            float prevY = getPovY();
            povValues[povIndex] = event.getValue();

            if (prevX != getPovX()) {
                Controllers.addEvent(new ControllerEvent(this, event.getNanos(), ControllerEvent.POVX, 0, false, false));
            }
            if (prevY != getPovY()) {
                Controllers.addEvent(new ControllerEvent(this, event.getNanos(), ControllerEvent.POVY, 0, false, false));
            }
        }

        // handle axis updates
        if (axes.contains(event.getComponent())) {
            Component axis = event.getComponent();
            int axisIndex = axes.indexOf(axis);
            float value = axis.getPollData();
            float xaxisValue = 0;
            float yaxisValue = 0;

            // fixed dead zone since most axis don't report it :(
            if (Math.abs(value) < deadZones[axisIndex]) {
                value = 0;
            }
            if (Math.abs(value) < axis.getDeadZone()) {
                value = 0;
            }
            if (Math.abs(value) > axesMax[axisIndex]) {
                axesMax[axisIndex] = Math.abs(value);
            }

            // normalize the value based on maximum value read in the past
            value /= axesMax[axisIndex];

            if (axisIndex == xaxis) {
                xaxisValue = value;
            }
            if (axisIndex == yaxis) {
                yaxisValue = value;
            }

            // fire event
            Controllers.addEvent(new ControllerEvent(this, event.getNanos(), ControllerEvent.AXIS, axisIndex, false,
                    axisIndex == xaxis, axisIndex == yaxis, xaxisValue, yaxisValue));
            axesValue[axisIndex] = value;
        }
    }
}
 
开发者ID:wildstang111,项目名称:2014_software,代码行数:71,代码来源:JInputController.java


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