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


Java Gamepad类代码示例

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


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

示例1: GamepadManager

import com.qualcomm.robotcore.hardware.Gamepad; //导入依赖的package包/类
public GamepadManager(Gamepad gamepad, Function scalingFunction) {
    //create all the DigitalInputEdgeDetector objects
    a = new DigitalInputEdgeDetector(GamepadIEFactory.a(gamepad));
    b = new DigitalInputEdgeDetector(GamepadIEFactory.b(gamepad));
    x = new DigitalInputEdgeDetector(GamepadIEFactory.x(gamepad));
    y = new DigitalInputEdgeDetector(GamepadIEFactory.y(gamepad));
    left_bumper = new DigitalInputEdgeDetector(GamepadIEFactory.left_bumper(gamepad));
    right_bumper = new DigitalInputEdgeDetector(GamepadIEFactory.right_bumper(gamepad));
    dpad_up = new DigitalInputEdgeDetector(GamepadIEFactory.dpad_up(gamepad));
    dpad_down = new DigitalInputEdgeDetector(GamepadIEFactory.dpad_down(gamepad));
    dpad_left = new DigitalInputEdgeDetector(GamepadIEFactory.dpad_left(gamepad));
    dpad_right = new DigitalInputEdgeDetector(GamepadIEFactory.dpad_right(gamepad));
    left_stick_button = new DigitalInputEdgeDetector(GamepadIEFactory.left_stick_button(gamepad));
    right_stick_button = new DigitalInputEdgeDetector(GamepadIEFactory.right_stick_button(gamepad));
    back = new DigitalInputEdgeDetector(GamepadIEFactory.back(gamepad));
    start = new DigitalInputEdgeDetector(GamepadIEFactory.start(gamepad));

    //create all the AnalogInputScaler objects
    left_stick_x = new AnalogInputScaler(GamepadIEFactory.left_stick_x(gamepad), scalingFunction);
    left_stick_y = new AnalogInputScaler(GamepadIEFactory.left_stick_y(gamepad), scalingFunction);
    right_stick_x = new AnalogInputScaler(GamepadIEFactory.right_stick_x(gamepad), scalingFunction);
    right_stick_y = new AnalogInputScaler(GamepadIEFactory.right_stick_y(gamepad), scalingFunction);
    left_trigger = new AnalogInputScaler(GamepadIEFactory.left_trigger(gamepad), scalingFunction);
    right_trigger = new AnalogInputScaler(GamepadIEFactory.right_trigger(gamepad), scalingFunction);
}
 
开发者ID:FTC7393,项目名称:EVLib,代码行数:26,代码来源:GamepadManager.java

示例2: execute

import com.qualcomm.robotcore.hardware.Gamepad; //导入依赖的package包/类
/**
 * Executes the current state once by running the {@link State#execute()}, then checks to see if
 * the state needs to be changed by running the {@link State#changeState(Enum)} method of the
 * currently running state
 */
public void execute() {
    if (index == -1) {
        return;
    }

    STATE state = states.get(index);
    if (state.name().equalsIgnoreCase("NOTHING"))

        // Inject requested variables
        inject(state, "hardwareMap", HardwareMap.class, opMode.hardwareMap);
    inject(state, "gamepad1", Gamepad.class, opMode.gamepad1);
    inject(state, "gamepad2", Gamepad.class, opMode.gamepad2);
    inject(state, "telemetry", Telemetry.class, opMode.telemetry);
    inject(state, "opMode", opMode.getClass(), opMode);

    state.execute();
    if (state.stateChange()) {
        index = ++index;
        if (index > states.size()) {
            index = -1;
        }
    }
}
 
开发者ID:MHS-FIRSTrobotics,项目名称:RadicalRobotics2017,代码行数:29,代码来源:FiniteStateMachine.java

示例3: execute

import com.qualcomm.robotcore.hardware.Gamepad; //导入依赖的package包/类
/**
 * Executes the current state once by running the {@link State#execute()}, then checks to see if
 * the state needs to be changed by running the {@link State#changeState(Enum)} method of the
 * currently running state
 */
public void execute() {
    if (index == -1) {
        return;
    }

    STATE state = states.get(index);
    if (state.name().equalsIgnoreCase("NOTHING"))

        // Inject requested variables
        inject(state, "hardwareMap", HardwareMap.class, opMode.hardwareMap);
    inject(state, "gamepad1", Gamepad.class, opMode.gamepad1);
    inject(state, "gamepad2", Gamepad.class, opMode.gamepad2);
    inject(state, "telemetry", Telemetry.class, opMode.telemetry);
    inject(state, "opMode", opMode.getClass(), opMode);

    state.execute();
}
 
开发者ID:MHS-FIRSTrobotics,项目名称:RadicalRobotics2017,代码行数:23,代码来源:AdvancedFiniteStateMachine.java

示例4: execute

import com.qualcomm.robotcore.hardware.Gamepad; //导入依赖的package包/类
/**
 * Executes the current state once by running the {@link State#execute()}, then checks to see if
 * the state needs to be changed by running the {@link State#changeState(Enum)} method of the
 * currently running state
 */
public void execute() {
    if (index == -1) {
        return;
    }

    STATE state = states.get(index);
    if (state.name().equalsIgnoreCase("NOTHING"))

        // Inject requested variables
        inject(state, "hardwareMap", HardwareMap.class, opMode.hardwareMap);
    inject(state, "gamepad1", Gamepad.class, opMode.gamepad1);
    inject(state, "gamepad2", Gamepad.class, opMode.gamepad2);
    inject(state, "telemetry", Telemetry.class, opMode.telemetry);
    inject(state, "opMode", opMode.getClass(), opMode);

    state.execute();
    index = state.stateChange().ordinal();
}
 
开发者ID:MHS-FIRSTrobotics,项目名称:RadicalRobotics2017,代码行数:24,代码来源:FiniteStateMachine2.java

示例5: execute

import com.qualcomm.robotcore.hardware.Gamepad; //导入依赖的package包/类
/**
     * Executes the current state once by running the {@link State#execute()}, then checks to see if
     * the state needs to be changed by running the {@link State#changeState(Enum)} method of the
     * currently running state
     */
    public void execute() {
        if (index == -1) {
            return;
        }

        STATE state = states.get(index);
        if (state.name().equalsIgnoreCase("NOTHING"))

            // Inject requested variables
            inject(state, "hardwareMap", HardwareMap.class, opMode.hardwareMap);
        inject(state, "gamepad1", Gamepad.class, opMode.gamepad1);
        inject(state, "gamepad2", Gamepad.class, opMode.gamepad2);
        inject(state, "telemetry", Telemetry.class, opMode.telemetry);
        inject(state, "opMode", opMode.getClass(), opMode);

        state.execute();
//        if (state.stateChange()) {
//            index = ++index;
//            if (index > states.size()) {
//                index = -1;
//            }
//        }
    }
 
开发者ID:MHS-FIRSTrobotics,项目名称:TeamClutch2016,代码行数:29,代码来源:AdvancedFiniteStateMachine.java

示例6: Controller

import com.qualcomm.robotcore.hardware.Gamepad; //导入依赖的package包/类
/**
 * Initialize a controller from a Gamepad (FIRST library underlayer)
 */
public Controller(Gamepad g) {
    dpad_up = g.dpad_up ? ButtonState.HELD : ButtonState.NOT_PRESSED;
    dpad_down = g.dpad_down ? ButtonState.HELD : ButtonState.NOT_PRESSED;
    dpad_left = g.dpad_left ? ButtonState.HELD : ButtonState.NOT_PRESSED;
    dpad_right = g.dpad_right ? ButtonState.HELD : ButtonState.NOT_PRESSED;
    a = g.a ? ButtonState.HELD : ButtonState.NOT_PRESSED;
    b = g.b ? ButtonState.HELD : ButtonState.NOT_PRESSED;
    x = g.x ? ButtonState.HELD : ButtonState.NOT_PRESSED;
    y = g.y ? ButtonState.HELD : ButtonState.NOT_PRESSED;
    guide = g.guide ? ButtonState.HELD : ButtonState.NOT_PRESSED;
    start = g.start ? ButtonState.HELD : ButtonState.NOT_PRESSED;
    back = g.back ? ButtonState.HELD : ButtonState.NOT_PRESSED;
    left_bumper = g.left_bumper ? ButtonState.HELD : ButtonState.NOT_PRESSED;
    right_bumper = g.right_bumper ? ButtonState.HELD : ButtonState.NOT_PRESSED;
    right_trigger = g.right_trigger;
    left_stick_x = g.left_stick_x;
    left_stick_y = g.left_stick_y;
    right_stick_x = g.right_stick_x;
    right_stick_y = g.right_stick_y;
}
 
开发者ID:lasarobotics,项目名称:FTCLibrary,代码行数:24,代码来源:Controller.java

示例7: update

import com.qualcomm.robotcore.hardware.Gamepad; //导入依赖的package包/类
/**
 * Update the Controller states from a Gamepad.
 * CALL THIS METHOD ON EVERY EVENT LOOP!
 */
//FIXME is Gamepad g necessary?
public void update(Gamepad g) {
    dpad_up = handleUpdate(dpad_up, g.dpad_up);
    dpad_down = handleUpdate(dpad_down, g.dpad_down);
    dpad_left = handleUpdate(dpad_left, g.dpad_left);
    dpad_right = handleUpdate(dpad_right, g.dpad_right);
    a = handleUpdate(a, g.a);
    b = handleUpdate(b, g.b);
    x = handleUpdate(x, g.x);
    y = handleUpdate(y, g.y);
    guide = handleUpdate(guide, g.guide);
    start = handleUpdate(start, g.start);
    back = handleUpdate(back, g.back);
    left_bumper = handleUpdate(left_bumper, g.left_bumper);
    right_bumper = handleUpdate(right_bumper, g.right_bumper);
    left_trigger = g.left_trigger;
    right_trigger = g.right_trigger;
    left_stick_x = g.left_stick_x;
    left_stick_y = g.left_stick_y;
    right_stick_x = g.right_stick_x;
    right_stick_y = g.right_stick_y;
}
 
开发者ID:lasarobotics,项目名称:FTCLibrary,代码行数:27,代码来源:Controller.java

示例8: RobotCore

import com.qualcomm.robotcore.hardware.Gamepad; //导入依赖的package包/类
public RobotCore(Telemetry telemetry, HardwareMap hardwareMap, Gamepad gamepad1, Gamepad gamepad2) {
    //Instantiate all static instances
    this.telemetry   = telemetry;
    this.hardwareMap = hardwareMap;
    this.gamepad1   = gamepad1;
    this.gamepad2   = gamepad2;
}
 
开发者ID:GarrettBurroughs,项目名称:Alloy,代码行数:8,代码来源:RobotCore.java

示例9: Gamepad_handler_2

import com.qualcomm.robotcore.hardware.Gamepad; //导入依赖的package包/类
public Gamepad_handler_2(HardwareWeRobotJ robot, Gamepad gamepad) {
    Thread thread = new Thread(this);
    this.robot = robot;
    this.gamepad = gamepad;
    initGamepad();
    thread.start();
}
 
开发者ID:nomelif,项目名称:ControlCodesRepo,代码行数:8,代码来源:Gamepad_handler_2.java

示例10: GestionDeplacement

import com.qualcomm.robotcore.hardware.Gamepad; //导入依赖的package包/类
public GestionDeplacement(HardwareWeRobotJ robot, Gamepad gamepad){
    Thread thread = new Thread(this);
    this.robot = robot;
    this.gamepad = gamepad;
    this.killed = false;
    initDeplacement();
    thread.start();
}
 
开发者ID:nomelif,项目名称:ControlCodesRepo,代码行数:9,代码来源:GestionDeplacement.java

示例11: a

import com.qualcomm.robotcore.hardware.Gamepad; //导入依赖的package包/类
public static InputExtractor<Boolean> a(final Gamepad gamepad) {
    return new InputExtractor<Boolean>() {
        @Override
        public Boolean getValue() {
            return gamepad.a;
        }
    };
}
 
开发者ID:FTC7393,项目名称:EVLib,代码行数:9,代码来源:GamepadIEFactory.java

示例12: b

import com.qualcomm.robotcore.hardware.Gamepad; //导入依赖的package包/类
public static InputExtractor<Boolean> b(final Gamepad gamepad) {
    return new InputExtractor<Boolean>() {
        @Override
        public Boolean getValue() {
            return gamepad.b;
        }
    };
}
 
开发者ID:FTC7393,项目名称:EVLib,代码行数:9,代码来源:GamepadIEFactory.java

示例13: x

import com.qualcomm.robotcore.hardware.Gamepad; //导入依赖的package包/类
public static InputExtractor<Boolean> x(final Gamepad gamepad) {
    return new InputExtractor<Boolean>() {
        @Override
        public Boolean getValue() {
            return gamepad.x;
        }
    };
}
 
开发者ID:FTC7393,项目名称:EVLib,代码行数:9,代码来源:GamepadIEFactory.java

示例14: y

import com.qualcomm.robotcore.hardware.Gamepad; //导入依赖的package包/类
public static InputExtractor<Boolean> y(final Gamepad gamepad) {
    return new InputExtractor<Boolean>() {
        @Override
        public Boolean getValue() {
            return gamepad.y;
        }
    };
}
 
开发者ID:FTC7393,项目名称:EVLib,代码行数:9,代码来源:GamepadIEFactory.java

示例15: left_bumper

import com.qualcomm.robotcore.hardware.Gamepad; //导入依赖的package包/类
public static InputExtractor<Boolean> left_bumper(final Gamepad gamepad) {
    return new InputExtractor<Boolean>() {
        @Override
        public Boolean getValue() {
            return gamepad.left_bumper;
        }
    };
}
 
开发者ID:FTC7393,项目名称:EVLib,代码行数:9,代码来源:GamepadIEFactory.java


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