Files
allwpilib/wpilibc/src/main/native/include/Joystick.h
Thad House e1195e8b9d Update to 2018_v4 image and new build system. (#598)
* Revert "Force OpenCV to 3.1.0 (#602)"

This reverts commit 50ed55e8e2.

* Removes Simulation

* Removes old build system

* Removes old gtest

* Adds new gmock and gtest

* Updates to new ni-libraries

* removes MyRobot (to be replaced)

* moves files to new location

* Adds new sim backend and new test executables

* updates .styleguide and .gitignore

* Changes cpp WPILibVersion to a function

MSVC throws an AV with the old version.

* Disables USBCamera on all systems except for linux

* 2018 NI Libraries

* New build system
2017-08-18 21:35:53 -07:00

89 lines
2.7 KiB
C++

/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2008-2017. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#pragma once
#include <stdint.h>
#include <memory>
#include <vector>
#include "ErrorBase.h"
#include "JoystickBase.h"
namespace frc {
class DriverStation;
/**
* Handle input from standard Joysticks connected to the Driver Station.
* This class handles standard input that comes from the Driver Station. Each
* time a value is requested the most recent value is returned. There is a
* single class instance for each joystick and the mapping of ports to hardware
* buttons depends on the code in the Driver Station.
*/
class Joystick : public JoystickBase, public ErrorBase {
public:
static const int kDefaultXAxis = 0;
static const int kDefaultYAxis = 1;
static const int kDefaultZAxis = 2;
static const int kDefaultTwistAxis = 2;
static const int kDefaultThrottleAxis = 3;
typedef enum {
kXAxis,
kYAxis,
kZAxis,
kTwistAxis,
kThrottleAxis,
kNumAxisTypes
} AxisType;
static const int kDefaultTriggerButton = 1;
static const int kDefaultTopButton = 2;
typedef enum { kTriggerButton, kTopButton, kNumButtonTypes } ButtonType;
explicit Joystick(int port);
Joystick(int port, int numAxisTypes, int numButtonTypes);
virtual ~Joystick() = default;
Joystick(const Joystick&) = delete;
Joystick& operator=(const Joystick&) = delete;
int GetAxisChannel(AxisType axis) const;
void SetAxisChannel(AxisType axis, int channel);
double GetX(JoystickHand hand = kRightHand) const override;
double GetY(JoystickHand hand = kRightHand) const override;
double GetZ(JoystickHand hand = kRightHand) const override;
double GetTwist() const override;
double GetThrottle() const override;
virtual double GetAxis(AxisType axis) const;
bool GetTrigger(JoystickHand hand = kRightHand) const override;
bool GetTop(JoystickHand hand = kRightHand) const override;
bool GetButton(ButtonType button) const;
static Joystick* GetStickForPort(int port);
virtual double GetMagnitude() const;
virtual double GetDirectionRadians() const;
virtual double GetDirectionDegrees() const;
int GetAxisType(int axis) const;
int GetAxisCount() const;
int GetButtonCount() const;
private:
DriverStation& m_ds;
std::vector<int> m_axes;
std::vector<int> m_buttons;
};
} // namespace frc