001 /*----------------------------------------------------------------------------*/ 002 /* Copyright (c) FIRST 2008-2012. All Rights Reserved. */ 003 /* Open Source Software - may be modified and shared by FRC teams. The code */ 004 /* must be accompanied by the FIRST BSD license file in the root directory of */ 005 /* the project. */ 006 /*----------------------------------------------------------------------------*/ 007 008 package edu.wpi.first.wpilibj.buttons; 009 010 import edu.wpi.first.wpilibj.GenericHID; 011 012 /** 013 * 014 * @author bradmiller 015 */ 016 public class JoystickButton extends Button { 017 018 GenericHID m_joystick; 019 int m_buttonNumber; 020 021 /** 022 * Create a joystick button for triggering commands 023 * @param joystick The GenericHID object that has the button (e.g. Joystick, KinectStick, etc) 024 * @param buttonNumber The button number (see {@link GenericHID#getRawButton(int) } 025 */ 026 public JoystickButton(GenericHID joystick, int buttonNumber) { 027 m_joystick = joystick; 028 m_buttonNumber = buttonNumber; 029 } 030 031 /** 032 * Gets the value of the joystick button 033 * @return The value of the joystick button 034 */ 035 public boolean get() { 036 return m_joystick.getRawButton(m_buttonNumber); 037 } 038 }