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    /**
011     * This class is intended to be used within a program.  The programmer can manually set its value.
012     * Also includes a setting for whether or not it should invert its value.
013     *
014     * @author Joe
015     */
016    public class InternalButton extends Button {
017    
018        boolean pressed;
019        boolean inverted;
020    
021        /**
022         * Creates an InternalButton that is not inverted.
023         */
024        public InternalButton() {
025            this(false);
026        }
027    
028        /**
029         * Creates an InternalButton which is inverted depending on the input.
030         *
031         * @param inverted if false, then this button is pressed when set to true, otherwise it is pressed when set to false.
032         */
033        public InternalButton(boolean inverted) {
034            this.pressed = this.inverted = inverted;
035        }
036    
037        public void setInverted(boolean inverted) {
038            this.inverted = inverted;
039        }
040    
041        public void setPressed(boolean pressed) {
042            this.pressed = pressed;
043        }
044    
045        public boolean get() {
046            return pressed ^ inverted;
047        }
048    }