mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-02 02:51:42 +00:00
Remove deprecated code (#8656)
This commit is contained in:
@@ -53,45 +53,7 @@ bool {{ ConsoleName }}Controller::Get{{ capitalize_first(button.name) }}ButtonRe
|
||||
BooleanEvent {{ ConsoleName }}Controller::{{ capitalize_first(button.name) }}(EventLoop* loop) const {
|
||||
return BooleanEvent(loop, [this]() { return this->Get{{ capitalize_first(button.name) }}Button(); });
|
||||
}
|
||||
{% endfor -%}
|
||||
{% if ConsoleName == "Xbox" or ConsoleName == "Stadia"%}
|
||||
bool {{ ConsoleName }}Controller::GetLeftBumper() const {
|
||||
return GetRawButton(Button::kLeftBumper);
|
||||
}
|
||||
|
||||
bool {{ ConsoleName }}Controller::GetRightBumper() const {
|
||||
return GetRawButton(Button::kRightBumper);
|
||||
}
|
||||
|
||||
bool {{ ConsoleName }}Controller::GetLeftBumperPressed() {
|
||||
return GetRawButtonPressed(Button::kLeftBumper);
|
||||
}
|
||||
|
||||
bool {{ ConsoleName }}Controller::GetRightBumperPressed() {
|
||||
return GetRawButtonPressed(Button::kRightBumper);
|
||||
}
|
||||
|
||||
bool {{ ConsoleName }}Controller::GetLeftBumperReleased() {
|
||||
return GetRawButtonReleased(Button::kLeftBumper);
|
||||
}
|
||||
|
||||
bool {{ ConsoleName }}Controller::GetRightBumperReleased() {
|
||||
return GetRawButtonReleased(Button::kRightBumper);
|
||||
}
|
||||
{%- elif ConsoleName == "PS4" or ConsoleName == "PS5" %}
|
||||
bool {{ ConsoleName }}Controller::GetTouchpad() const {
|
||||
return GetRawButton(Button::kTouchpad);
|
||||
}
|
||||
|
||||
bool {{ ConsoleName }}Controller::GetTouchpadPressed() {
|
||||
return GetRawButtonPressed(Button::kTouchpad);
|
||||
}
|
||||
|
||||
bool {{ ConsoleName }}Controller::GetTouchpadReleased() {
|
||||
return GetRawButtonReleased(Button::kTouchpad);
|
||||
}
|
||||
{%- endif %}
|
||||
|
||||
{% endfor %}
|
||||
void {{ ConsoleName }}Controller::InitSendable(wpi::util::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("HID");
|
||||
builder.PublishConstString("ControllerType", "{{ ConsoleName }}");
|
||||
|
||||
@@ -116,106 +116,7 @@ class {{ ConsoleName }}Controller : public GenericHID,
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
BooleanEvent {{ capitalize_first(button.name) }}(EventLoop* loop) const;
|
||||
{% endfor -%}
|
||||
{% if ConsoleName == "Xbox" or ConsoleName == "Stadia" %}
|
||||
/**
|
||||
* Read the value of the left bumper (LB) button on the controller.
|
||||
*
|
||||
* @return the state of the button
|
||||
* @deprecated Use GetLeftBumperButton instead. This function is deprecated
|
||||
* for removal to make function names consistent to allow the HID classes to
|
||||
* be automatically generated.
|
||||
*/
|
||||
[[deprecated("Use GetLeftBumperButton instead")]]
|
||||
bool GetLeftBumper() const;
|
||||
|
||||
/**
|
||||
* Read the value of the right bumper (RB) button on the controller.
|
||||
*
|
||||
* @return the state of the button
|
||||
* @deprecated Use GetRightBumperButton instead. This function is deprecated
|
||||
* for removal to make function names consistent to allow the HID classes to
|
||||
* be automatically generated.
|
||||
*/
|
||||
[[deprecated("Use GetRightBumperButton instead")]]
|
||||
bool GetRightBumper() const;
|
||||
|
||||
/**
|
||||
* Whether the left bumper (LB) was pressed since the last check.
|
||||
*
|
||||
* @return Whether the button was pressed since the last check
|
||||
* @deprecated Use GetLeftBumperButtonPressed instead. This function is
|
||||
* deprecated for removal to make function names consistent to allow the HID
|
||||
* classes to be automatically generated.
|
||||
*/
|
||||
[[deprecated("Use GetLeftBumperButtonPressed instead")]]
|
||||
bool GetLeftBumperPressed();
|
||||
|
||||
/**
|
||||
* Whether the right bumper (RB) was pressed since the last check.
|
||||
*
|
||||
* @return Whether the button was pressed since the last check
|
||||
* @deprecated Use GetRightBumperButtonPressed instead. This function is
|
||||
* deprecated for removal to make function names consistent to allow the HID
|
||||
* classes to be automatically generated.
|
||||
*/
|
||||
[[deprecated("Use GetRightBumperButtonPressed instead")]]
|
||||
bool GetRightBumperPressed();
|
||||
|
||||
/**
|
||||
* Whether the left bumper (LB) was released since the last check.
|
||||
*
|
||||
* @return Whether the button was released since the last check.
|
||||
* @deprecated Use GetLeftBumperButtonReleased instead. This function is
|
||||
* deprecated for removal to make function names consistent to allow the HID
|
||||
* classes to be automatically generated.
|
||||
*/
|
||||
[[deprecated("Use GetLeftBumperButtonReleased instead")]]
|
||||
bool GetLeftBumperReleased();
|
||||
|
||||
/**
|
||||
* Whether the right bumper (RB) was released since the last check.
|
||||
*
|
||||
* @return Whether the button was released since the last check.
|
||||
* @deprecated Use GetRightBumperButtonReleased instead. This function is
|
||||
* deprecated for removal to make function names consistent to allow the HID
|
||||
* classes to be automatically generated.
|
||||
*/
|
||||
[[deprecated("Use GetRightBumperButtonReleased instead")]]
|
||||
bool GetRightBumperReleased();
|
||||
{% elif ConsoleName == "PS4" or ConsoleName == "PS5" %}
|
||||
/**
|
||||
* Read the value of the touchpad button on the controller.
|
||||
*
|
||||
* @return The state of the button.
|
||||
* @deprecated Use GetTouchpadButton instead. This function is deprecated for
|
||||
* removal to make function names consistent to allow the HID classes to be
|
||||
* automatically generated.
|
||||
*/
|
||||
[[deprecated("Use GetTouchpadButton instead")]]
|
||||
bool GetTouchpad() const;
|
||||
/**
|
||||
* Whether the touchpad was pressed since the last check.
|
||||
*
|
||||
* @return Whether the touchpad was pressed since the last check.
|
||||
* @deprecated Use GetTouchpadButtonPressed instead. This function is
|
||||
* deprecated for removal to make function names consistent to allow the HID
|
||||
* classes to be automatically generated.
|
||||
*/
|
||||
[[deprecated("Use GetTouchpadButtonPressed instead")]]
|
||||
bool GetTouchpadPressed();
|
||||
|
||||
/**
|
||||
* Whether the touchpad was released since the last check.
|
||||
*
|
||||
* @return Whether the touchpad was released since the last check.
|
||||
* @deprecated Use GetLeftBumperButton instead. This function is deprecated
|
||||
* for removal to make function names consistent to allow the HID classes to
|
||||
* be automatically generated.
|
||||
*/
|
||||
[[deprecated("Use GetTouchpadButtonReleased instead")]]
|
||||
bool GetTouchpadReleased();
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
/** Represents a digital button on an {{ ConsoleName }}Controller. */
|
||||
struct Button {
|
||||
{%- for button in buttons %}
|
||||
|
||||
@@ -265,7 +265,6 @@ BooleanEvent NiDsPS4Controller::Touchpad(EventLoop* loop) const {
|
||||
return BooleanEvent(loop, [this]() { return this->GetTouchpadButton(); });
|
||||
}
|
||||
|
||||
|
||||
void NiDsPS4Controller::InitSendable(wpi::util::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("HID");
|
||||
builder.PublishConstString("ControllerType", "NiDsPS4");
|
||||
|
||||
@@ -265,7 +265,6 @@ BooleanEvent NiDsPS5Controller::Touchpad(EventLoop* loop) const {
|
||||
return BooleanEvent(loop, [this]() { return this->GetTouchpadButton(); });
|
||||
}
|
||||
|
||||
|
||||
void NiDsPS5Controller::InitSendable(wpi::util::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("HID");
|
||||
builder.PublishConstString("ControllerType", "NiDsPS5");
|
||||
|
||||
@@ -273,7 +273,6 @@ BooleanEvent NiDsStadiaController::Frame(EventLoop* loop) const {
|
||||
return BooleanEvent(loop, [this]() { return this->GetFrameButton(); });
|
||||
}
|
||||
|
||||
|
||||
void NiDsStadiaController::InitSendable(wpi::util::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("HID");
|
||||
builder.PublishConstString("ControllerType", "NiDsStadia");
|
||||
|
||||
@@ -217,7 +217,6 @@ BooleanEvent NiDsXboxController::RightStick(EventLoop* loop) const {
|
||||
return BooleanEvent(loop, [this]() { return this->GetRightStickButton(); });
|
||||
}
|
||||
|
||||
|
||||
void NiDsXboxController::InitSendable(wpi::util::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("HID");
|
||||
builder.PublishConstString("ControllerType", "NiDsXbox");
|
||||
|
||||
@@ -86,10 +86,6 @@ void IterativeRobotBase::TeleopExit() {}
|
||||
|
||||
void IterativeRobotBase::TestExit() {}
|
||||
|
||||
void IterativeRobotBase::SetNetworkTablesFlushEnabled(bool enabled) {
|
||||
m_ntFlushEnabled = enabled;
|
||||
}
|
||||
|
||||
wpi::units::second_t IterativeRobotBase::GetPeriod() const {
|
||||
return m_period;
|
||||
}
|
||||
@@ -171,9 +167,7 @@ void IterativeRobotBase::LoopFunc() {
|
||||
m_watchdog.Disable();
|
||||
|
||||
// Flush NetworkTables
|
||||
if (m_ntFlushEnabled) {
|
||||
wpi::nt::NetworkTableInstance::GetDefault().FlushLocal();
|
||||
}
|
||||
wpi::nt::NetworkTableInstance::GetDefault().FlushLocal();
|
||||
|
||||
// Warn on loop time overruns
|
||||
if (m_watchdog.IsExpired()) {
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include "wpi/system/Resource.hpp"
|
||||
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "wpi/system/Errors.hpp"
|
||||
#include "wpi/util/deprecated.hpp"
|
||||
|
||||
WPI_IGNORE_DEPRECATED
|
||||
using namespace wpi;
|
||||
|
||||
wpi::util::mutex Resource::m_createMutex;
|
||||
|
||||
void Resource::CreateResourceObject(std::unique_ptr<Resource>& r,
|
||||
uint32_t elements) {
|
||||
std::scoped_lock lock(m_createMutex);
|
||||
if (!r) {
|
||||
r = std::make_unique<Resource>(elements);
|
||||
}
|
||||
}
|
||||
WPI_UNIGNORE_DEPRECATED
|
||||
|
||||
Resource::Resource(uint32_t elements) {
|
||||
m_isAllocated = std::vector<bool>(elements, false);
|
||||
}
|
||||
|
||||
uint32_t Resource::Allocate(const std::string& resourceDesc) {
|
||||
std::scoped_lock lock(m_allocateMutex);
|
||||
for (uint32_t i = 0; i < m_isAllocated.size(); i++) {
|
||||
if (!m_isAllocated[i]) {
|
||||
m_isAllocated[i] = true;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
throw WPILIB_MakeError(err::NoAvailableResources, "{}", resourceDesc);
|
||||
}
|
||||
|
||||
uint32_t Resource::Allocate(uint32_t index, const std::string& resourceDesc) {
|
||||
std::scoped_lock lock(m_allocateMutex);
|
||||
if (index >= m_isAllocated.size()) {
|
||||
throw WPILIB_MakeError(err::ChannelIndexOutOfRange, "{}", resourceDesc);
|
||||
}
|
||||
if (m_isAllocated[index]) {
|
||||
throw WPILIB_MakeError(err::ResourceAlreadyAllocated, "{}", resourceDesc);
|
||||
}
|
||||
m_isAllocated[index] = true;
|
||||
return index;
|
||||
}
|
||||
|
||||
void Resource::Free(uint32_t index) {
|
||||
std::unique_lock lock(m_allocateMutex);
|
||||
if (index == std::numeric_limits<uint32_t>::max()) {
|
||||
return;
|
||||
}
|
||||
if (index >= m_isAllocated.size()) {
|
||||
throw WPILIB_MakeError(err::NotAllocated, "index {}", index);
|
||||
}
|
||||
if (!m_isAllocated[index]) {
|
||||
throw WPILIB_MakeError(err::NotAllocated, "index {}", index);
|
||||
}
|
||||
m_isAllocated[index] = false;
|
||||
}
|
||||
@@ -187,16 +187,6 @@ class IterativeRobotBase : public RobotBase {
|
||||
*/
|
||||
virtual void TestExit();
|
||||
|
||||
/**
|
||||
* Enables or disables flushing NetworkTables every loop iteration.
|
||||
* By default, this is enabled.
|
||||
*
|
||||
* @param enabled True to enable, false to disable
|
||||
* @deprecated Deprecated without replacement.
|
||||
*/
|
||||
[[deprecated("Deprecated without replacement.")]]
|
||||
void SetNetworkTablesFlushEnabled(bool enabled);
|
||||
|
||||
/**
|
||||
* Gets time period between calls to Periodic() functions.
|
||||
*/
|
||||
@@ -229,7 +219,6 @@ class IterativeRobotBase : public RobotBase {
|
||||
int m_lastMode = -1;
|
||||
wpi::units::second_t m_period;
|
||||
Watchdog m_watchdog;
|
||||
bool m_ntFlushEnabled = true;
|
||||
bool m_calledDsConnected = false;
|
||||
|
||||
void PrintLoopOverrunMessage();
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "wpi/util/mutex.hpp"
|
||||
|
||||
namespace wpi {
|
||||
|
||||
/**
|
||||
* The Resource class is a convenient way to track allocated resources.
|
||||
*
|
||||
* It tracks them as indices in the range [0 .. elements - 1]. E.g. the library
|
||||
* uses this to track hardware channel allocation.
|
||||
*
|
||||
* The Resource class does not allocate the hardware channels or other
|
||||
* resources; it just tracks which indices were marked in use by Allocate and
|
||||
* not yet freed by Free.
|
||||
* @deprecated Use the HandleResource classes instead
|
||||
*/
|
||||
class [[deprecated("Use the HandleResource classes instead")]] Resource {
|
||||
public:
|
||||
virtual ~Resource() = default;
|
||||
|
||||
/**
|
||||
* Factory method to create a Resource allocation-tracker *if* needed.
|
||||
*
|
||||
* @param r address of the caller's Resource pointer. If *r == nullptr,
|
||||
* this will construct a Resource and make *r point to it. If
|
||||
* *r != nullptr, i.e. the caller already has a Resource
|
||||
* instance, this won't do anything.
|
||||
* @param elements the number of elements for this Resource allocator to
|
||||
* track, that is, it will allocate resource numbers in the
|
||||
* range [0 .. elements - 1].
|
||||
*/
|
||||
static void CreateResourceObject(std::unique_ptr<Resource>& r,
|
||||
uint32_t elements);
|
||||
|
||||
/**
|
||||
* Allocate storage for a new instance of Resource.
|
||||
*
|
||||
* Allocate a bool array of values that will get initialized to indicate that
|
||||
* no resources have been allocated yet. The indices of the resources are
|
||||
* [0 .. elements - 1].
|
||||
*/
|
||||
explicit Resource(uint32_t size);
|
||||
|
||||
/**
|
||||
* Allocate a resource.
|
||||
*
|
||||
* When a resource is requested, mark it allocated. In this case, a free
|
||||
* resource value within the range is located and returned after it is marked
|
||||
* allocated.
|
||||
*/
|
||||
uint32_t Allocate(const std::string& resourceDesc);
|
||||
|
||||
/**
|
||||
* Allocate a specific resource value.
|
||||
*
|
||||
* The user requests a specific resource value, i.e. channel number and it is
|
||||
* verified unallocated, then returned.
|
||||
*/
|
||||
uint32_t Allocate(uint32_t index, const std::string& resourceDesc);
|
||||
|
||||
/**
|
||||
* Free an allocated resource.
|
||||
*
|
||||
* After a resource is no longer needed, for example a destructor is called
|
||||
* for a channel assignment class, Free will release the resource value so it
|
||||
* can be reused somewhere else in the program.
|
||||
*/
|
||||
void Free(uint32_t index);
|
||||
|
||||
private:
|
||||
std::vector<bool> m_isAllocated;
|
||||
wpi::util::mutex m_allocateMutex;
|
||||
|
||||
static wpi::util::mutex m_createMutex;
|
||||
};
|
||||
|
||||
} // namespace wpi
|
||||
@@ -23,7 +23,6 @@ classes:
|
||||
AutonomousExit:
|
||||
TeleopExit:
|
||||
TestExit:
|
||||
SetNetworkTablesFlushEnabled:
|
||||
GetPeriod:
|
||||
PrintWatchdogEpochs:
|
||||
doc: |
|
||||
|
||||
Reference in New Issue
Block a user