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;
009    
010    /**
011     * GenericHID Interface
012     */
013    public abstract class GenericHID {
014    
015        /**
016         * Which hand the Human Interface Device is associated with.
017         */
018        public static class Hand {
019    
020            /**
021             * The integer value representing this enumeration
022             */
023            public final int value;
024            static final int kLeft_val = 0;
025            static final int kRight_val = 1;
026            /**
027             * hand: left
028             */
029            public static final Hand kLeft = new Hand(kLeft_val);
030            /**
031             * hand: right
032             */
033            public static final Hand kRight = new Hand(kRight_val);
034    
035            private Hand(int value) {
036                this.value = value;
037            }
038        }
039    
040        /**
041         * Get the x position of the HID
042         * @return the x position of the HID
043         */
044        public final double getX() {
045            return getX(Hand.kRight);
046        }
047    
048        /**
049         * Get the x position of HID
050         * @param hand which hand, left or right
051         * @return the x position
052         */
053        public abstract double getX(Hand hand);
054    
055        /**
056         * Get the y position of the HID
057         * @return the y position
058         */
059        public final double getY() {
060            return getY(Hand.kRight);
061        }
062    
063        /**
064         * Get the y position of the HID
065         * @param hand which hand, left or right
066         * @return the y position
067         */
068        public abstract double getY(Hand hand);
069    
070        /**
071         * Get the z position of the HID
072         * @return the z position
073         */
074        public final double getZ() {
075            return getZ(Hand.kRight);
076        }
077    
078        /**
079         * Get the z position of the HID
080         * @param hand which hand, left or right
081         * @return the z position
082         */
083        public abstract double getZ(Hand hand);
084    
085        /**
086         * Get the twist value
087         * @return the twist value
088         */
089        public abstract double getTwist();
090    
091        /**
092         * Get the throttle
093         * @return the throttle value
094         */
095        public abstract double getThrottle();
096    
097        /**
098         * Get the raw axis
099         * @param which index of the axis
100         * @return the raw value of the selected axis
101         */
102        public abstract double getRawAxis(int which);
103    
104        /**
105         * Is the trigger pressed
106         * @return true if pressed
107         */
108        public final boolean getTrigger() {
109            return getTrigger(Hand.kRight);
110        }
111    
112        /**
113         * Is the trigger pressed
114         * @param hand which hand
115         * @return true if the trigger for the given hand is pressed
116         */
117        public abstract boolean getTrigger(Hand hand);
118    
119        /**
120         * Is the top button pressed
121         * @return true if the top button is pressed
122         */
123        public final boolean getTop() {
124            return getTop(Hand.kRight);
125        }
126    
127        /**
128         * Is the top button pressed
129         * @param hand which hand
130         * @return true if hte top button for the given hand is pressed
131         */
132        public abstract boolean getTop(Hand hand);
133    
134        /**
135         * Is the bumper pressed
136         * @return true if the bumper is pressed
137         */
138        public final boolean getBumper() {
139            return getBumper(Hand.kRight);
140        }
141    
142        /**
143         * Is the bumper pressed
144         * @param hand which hand
145         * @return true if hte bumper is pressed
146         */
147        public abstract boolean getBumper(Hand hand);
148    
149        /**
150         * Is the given button pressed
151         * @param button which button number
152         * @return true if the button is pressed
153         */
154        public abstract boolean getRawButton(int button);
155    }