![]() |
Open FFBoard
Open source force feedback firmware
|
#include <FFBHIDMain.h>
Public Member Functions | |
FFBHIDMain (uint8_t axisCount) | |
virtual | ~FFBHIDMain () |
void | setFFBEffectsCalc (std::shared_ptr< EffectsControlItf > ffb, std::shared_ptr< EffectsCalculator > effects_calc) |
const ClassIdentifier | getInfo ()=0 |
CommandStatus | command (const ParsedCommand &cmd, std::vector< CommandReply > &replies) |
void | registerCommands () |
virtual std::string | getHelpstring () |
virtual void | usbInit ()=0 |
void | usbSuspend () |
void | usbResume () |
void | saveFlash () |
void | restoreFlash () |
void | Run () |
void | updateControl () |
void | emergencyStop (bool reset) |
uint32_t | getRate () |
bool | getFfbActive () |
void | exti (uint16_t GPIO_Pin) |
void | errorCallback (const Error &error, bool cleared) |
void | systick () |
![]() | |
const ClassType | getClassType () override |
returns the used classchooser selection id of this instance More... | |
FFBoardMain () | |
virtual | ~FFBoardMain () |
virtual void | update () |
virtual void | cdcRcv (char *Buf, uint32_t *Len) |
virtual void | cdcRcvReady (uint8_t itf) |
![]() | |
virtual | ~ChoosableClass () |
uint16_t | getSelectionID () |
![]() | |
CommandHandler (const char *clsname, uint16_t clsid, uint8_t instance=0) | |
virtual | ~CommandHandler () |
virtual bool | hasCommands () |
virtual void | setCommandsEnabled (bool enable) |
void | registerCommands () |
virtual CommandStatus | internalCommand (const ParsedCommand &cmd, std::vector< CommandReply > &replies) |
virtual std::string | getCommandsHelpstring () |
virtual std::string | getCsvHelpstring () |
virtual uint8_t | getCommandHandlerInstance () |
void | broadcastCommandReply (CommandReply reply, uint32_t cmdId, CMDtype type) |
void | sendCommandReplyAsync (CommandReply reply, uint32_t cmdId, CMDtype type, CommandInterface *interface=nullptr) |
virtual uint16_t | getCommandHandlerID () |
virtual CmdHandlerInfo * | getCommandHandlerInfo () |
virtual bool | isValidCommandId (uint32_t cmdid, uint32_t ignoredFlags=0, uint32_t requiredFlag=0) |
virtual CmdHandlerCommanddef * | getCommandFromName (const std::string &cmd, uint32_t ignoredFlags=0) |
virtual CmdHandlerCommanddef * | getCommandFromId (const uint32_t id, uint32_t ignoredFlags=0) |
template<typename ID > | |
void | registerCommand (const char *cmd, const ID cmdid, const char *help=nullptr, uint32_t flags=0) |
![]() | |
Thread (const std::string Name, uint16_t StackDepth, UBaseType_t Priority) | |
Thread (const char *Name, uint16_t StackDepth, UBaseType_t Priority) | |
Thread (uint16_t StackDepth, UBaseType_t Priority) | |
bool | Start () |
virtual | ~Thread () |
TaskHandle_t | GetHandle () |
void | Suspend () |
void | Resume () |
void | ResumeFromISR () |
void | Notify () |
void | NotifyFromISR () |
uint32_t | WaitForNotification (TickType_t Timeout=portMAX_DELAY) |
UBaseType_t | GetPriority () |
UBaseType_t | GetPriorityFromISR () |
void | SetPriority (UBaseType_t NewPriority) |
std::string | GetName () |
char * | GetName () |
![]() | |
UsbHidHandler () | |
virtual | ~UsbHidHandler () |
virtual void | hidOut (uint8_t report_id, hid_report_type_t report_type, uint8_t const *buffer, uint16_t bufsize) |
virtual uint16_t | hidGet (uint8_t report_id, hid_report_type_t report_type, uint8_t *buffer, uint16_t reqlen) |
void | registerHidCallback () |
void | transferComplete (uint8_t itf, uint8_t const *report, uint8_t len) |
Static Public Member Functions | |
static bool | isCreatable () |
![]() | |
static bool | isCreatable () |
![]() | |
static bool | isCreatable () |
![]() | |
static void | logSerial (std::string string) |
Send a log formatted sequence. More... | |
static void | logSerialDebug (std::string string) |
Send a log formatted sequence if debug is on. More... | |
static bool | logsEnabled () |
static void | setLogsEnabled (bool enabled) |
static uint32_t | getClassIdFromName (const char *name) |
static const char * | getClassNameFromId (const uint32_t id) |
static CommandHandler * | getHandlerFromHandlerId (const uint16_t cmdhandlerID) |
static CommandHandler * | getHandlerFromId (const uint16_t id, const uint8_t instance=0xFF) |
static CommandHandler * | getHandlerFromClassName (const char *name, const uint8_t instance=0xFF) |
static std::vector< CommandHandler * > | getHandlersFromClassName (const char *name) |
static std::vector< CommandHandler * > | getHandlersFromId (const uint16_t id) |
static bool | isInHandlerList (CommandHandler *handler) |
static std::string | getAllHelpstrings () |
static std::vector< CommandHandler * > & | getCommandHandlers () |
template<typename TVal > | |
static CommandStatus | handleGetSet (const ParsedCommand &cmd, std::vector< CommandReply > &replies, TVal &value) |
template<typename TVal , class cls , class cls1 > | |
static CommandStatus | handleGetSetFunc (const ParsedCommand &cmd, std::vector< CommandReply > &replies, TVal &value, void(cls1::*setfunc)(TVal), cls *obj) |
template<typename TVal , class cls , class cls1 , class cls2 > | |
static CommandStatus | handleGetFuncSetFunc (const ParsedCommand &cmd, std::vector< CommandReply > &replies, TVal(cls1::*getfunc)(), void(cls2::*setfunc)(TVal), cls *obj) |
template<typename TVal , class cls , class cls1 > | |
static CommandStatus | handleGetFuncSet (const ParsedCommand &cmd, std::vector< CommandReply > &replies, TVal &value, TVal(cls1::*getfunc)(), cls *obj) |
![]() | |
static void | Yield () |
static void | StartScheduler () |
static void | EndScheduler () |
![]() | |
static void | setHidDesc (const uint8_t *desc) |
static const uint8_t * | getHidDesc () |
Protected Attributes | |
std::shared_ptr< EffectsControlItf > | ffb |
std::shared_ptr< EffectsCalculator > | effects_calc |
uint8_t | axisCount =0 |
![]() | |
std::unique_ptr< USBdevice > | usbdev |
![]() | |
uint16_t | selectionId |
Should only be written by ClassChooser during creation. More... | |
![]() | |
bool | commandsEnabled = true |
std::vector< CmdHandlerCommanddef > | registeredCommands |
CmdHandlerInfo | cmdHandlerInfo |
Private Types | |
enum class | FFBWheel_commands : uint32_t { ffbactive , axes , btntypes , lsbtn , addbtn , aintypes , lsain , addain , hidrate , hidsendspd , estop , cfrate } |
Private Member Functions | |
void | send_report () |
void | setReportRate (uint8_t rateidx) |
std::string | usb_report_rates_names () |
![]() | |
PersistentStorage () | |
virtual | ~PersistentStorage () |
void | restoreFlashDelayed () |
![]() | |
ExtiHandler () | |
virtual | ~ExtiHandler () |
![]() | |
ErrorHandler () | |
virtual | ~ErrorHandler () |
![]() | |
SelectableInputs (const ClassChooser< ButtonSource > &btn_chooser, const ClassChooser< AnalogSource > &analog_chooser) | |
virtual | ~SelectableInputs () |
virtual void | setBtnTypes (uint16_t btntypes) |
virtual void | addBtnType (uint16_t id) |
virtual void | clearBtnTypes () |
virtual void | setAinTypes (uint16_t aintypes) |
virtual void | addAinType (uint16_t id) |
virtual void | clearAinTypes () |
virtual uint8_t | getButtonValues (uint64_t &values) |
virtual std::vector< int32_t > * | getAnalogValues () |
Private Attributes | |
volatile Control_t | control |
const bool | allowEstopReset = true |
const Error | estopError = Error(ErrorCode::emergencyStop, ErrorType::critical, "Emergency stop button triggered") |
uint8_t | usb_report_rate = HID_BINTERVAL |
uint8_t | usb_report_rate_idx = 0 |
const uint8_t | usb_report_rates [4] = {1,2,4,8} |
uint8_t | report_rate_cnt = 0 |
std::unique_ptr< AxesManager > | axes_manager |
std::vector< std::unique_ptr< ButtonSource > > | btns |
std::vector< std::unique_ptr< AnalogSource > > | analog_inputs |
reportHID_t | reportHID |
reportHID_t | lastReportHID |
uint8_t | reportSendCounter = 0 |
const uint8_t | analogAxisCount = 8 |
std::unique_ptr< HID_CommandInterface > | hidCommands = std::make_unique<HID_CommandInterface>() |
uint32_t | lastUsbReportTick = 0 |
volatile uint32_t | lastEstop = 0 |
![]() | |
bool | restoreDelayedFlag = false |
![]() | |
std::vector< std::unique_ptr< ButtonSource > > | btns |
std::vector< std::unique_ptr< AnalogSource > > | analog_inputs |
cpp_freertos::BinarySemaphore | sourcesSem = cpp_freertos::BinarySemaphore(true) |
uint16_t | btnsources = 0 |
uint16_t | ainsources = 0 |
std::vector< int32_t > | analogsources_buf |
ClassChooser< ButtonSource > | btn_chooser |
ClassChooser< AnalogSource > | analog_chooser |
Additional Inherited Members | |
![]() | |
std::unique_ptr< FFBoardMainCommandThread > | commandThread |
std::unique_ptr< CDC_CommandInterface > | cdcCmdInterface = std::make_unique<CDC_CommandInterface>() |
ErrorPrinter | errorPrinter |
SystemCommands | systemCommands |
System command handler. More... | |
std::unique_ptr< UART_CommandInterface > | uartCmdInterface = std::make_unique<UART_CommandInterface>(115200) |
![]() | |
static ClassIdentifier | info ={.name = "Basic (Failsafe)" ,.id=0} |
![]() | |
static ClassIdentifier | info |
![]() | |
static bool | logEnabled = true |
![]() | |
static UsbHidHandler * | globalHidHandler = nullptr |
static uint8_t * | hid_desc = nullptr |
![]() | |
void | setInstance (uint8_t instance) |
virtual void | addCommandHandler () |
virtual void | removeCommandHandler () |
![]() | |
virtual void | Cleanup () |
void | Delay (const TickType_t Delay) |
void | DelayUntil (const TickType_t Period) |
void | ResetDelayUntil () |
bool | Wait (ConditionVariable &Cv, Mutex &CvLock, TickType_t Timeout=portMAX_DELAY) |
![]() | |
static std::vector< uint16_t > & | getCommandHandlerIds () |
![]() | |
static char | cdcbuf [] |
![]() | |
static std::vector< PersistentStorage * > & | getFlashHandlers () |
static void | restoreFlashStartupCb () |
![]() | |
static void | addError (const Error &error) |
static void | clearError (const Error &error) |
static void | clearError (ErrorCode errorcode) |
static void | clearTemp () |
static void | clearAll () |
static std::span< Error > | getErrors () |
static void | sortErrors () |
![]() | |
static bool | startupComplete = false |
![]() | |
static std::vector< ExtiHandler * > | extiHandlers |
![]() | |
static std::vector< ErrorHandler * > | errorHandlers |
static std::array< Error, ERRORHANDLER_MAXERRORS > | errors |
Definition at line 36 of file FFBHIDMain.h.
|
strongprivate |
Enumerator | |
---|---|
ffbactive | |
axes | |
btntypes | |
lsbtn | |
addbtn | |
aintypes | |
lsain | |
addain | |
hidrate | |
hidsendspd | |
estop | |
cfrate |
Definition at line 37 of file FFBHIDMain.h.
FFBHIDMain::FFBHIDMain | ( | uint8_t | axisCount | ) |
setFFBEffectsCalc must be called in constructor of derived class to finish the setup
Definition at line 23 of file FFBHIDMain.cpp.
|
virtual |
Definition at line 48 of file FFBHIDMain.cpp.
|
virtual |
[in] | cmd | The parsed command to be executed. |
[out] | replies | A vector to return one or multiple reply objects into. Replies to the interface will be generated based on the reply objects. A string reply may not contain start, end and separation markers: [,],| Other characters are allowed. |
Reimplemented from FFBoardMain.
Definition at line 32 of file FFBHIDMain_commmands.cpp.
void FFBHIDMain::emergencyStop | ( | bool | reset | ) |
Definition at line 224 of file FFBHIDMain.cpp.
|
virtual |
Reimplemented from ErrorHandler.
Definition at line 290 of file FFBHIDMain.cpp.
|
virtual |
Reimplemented from ExtiHandler.
Definition at line 262 of file FFBHIDMain.cpp.
bool FFBHIDMain::getFfbActive | ( | ) |
Definition at line 141 of file FFBHIDMain.cpp.
|
inlinevirtual |
Returns a description of this class
Reimplemented from FFBoardMain.
Definition at line 52 of file FFBHIDMain.h.
|
pure virtual |
Reimplemented from FFBoardMain.
Implemented in FFBHIDExt, FFBJoystick, and FFBWheel.
uint32_t FFBHIDMain::getRate | ( | ) |
Definition at line 137 of file FFBHIDMain.cpp.
|
inlinestatic |
Definition at line 48 of file FFBHIDMain.h.
void FFBHIDMain::registerCommands | ( | ) |
Definition at line 11 of file FFBHIDMain_commmands.cpp.
|
virtual |
Read parameters from flash and restore settings
Reimplemented from PersistentStorage.
Definition at line 55 of file FFBHIDMain.cpp.
|
virtual |
Implementation of your actual thread code. You must override this function.
Implements cpp_freertos::Thread.
Definition at line 85 of file FFBHIDMain.cpp.
|
virtual |
Save parameters to flash
Reimplemented from PersistentStorage.
Definition at line 73 of file FFBHIDMain.cpp.
|
private |
Sends periodic gamepad reports of buttons and analog axes
Definition at line 148 of file FFBHIDMain.cpp.
void FFBHIDMain::setFFBEffectsCalc | ( | std::shared_ptr< EffectsControlItf > | ffb, |
std::shared_ptr< EffectsCalculator > | effects_calc | ||
) |
MUST be called in the constructor of the derived class. This finishes the construction because the constructor of this class will be called before the ffb and effects calc objects are created in the derived class.
Definition at line 39 of file FFBHIDMain.cpp.
|
private |
Changes the hid report rate based on the index for usb_report_rates
Definition at line 205 of file FFBHIDMain.cpp.
void FFBHIDMain::systick | ( | ) |
void FFBHIDMain::updateControl | ( | ) |
Main update loop
Definition at line 103 of file FFBHIDMain.cpp.
|
private |
Generates the speed strings to display to the user
Definition at line 214 of file FFBHIDMain.cpp.
|
pure virtual |
Called during the startup Should initialize a USBdevice and call registerUsb()
Reimplemented from FFBoardMain.
Implemented in FFBHIDExt, FFBJoystick, and FFBWheel.
|
virtual |
|
virtual |
USB unplugged Deactivates FFB
Reimplemented from FFBoardMain.
Definition at line 238 of file FFBHIDMain.cpp.
|
private |
Definition at line 86 of file FFBHIDMain.h.
|
private |
Definition at line 106 of file FFBHIDMain.h.
|
private |
Definition at line 112 of file FFBHIDMain.h.
|
private |
Definition at line 102 of file FFBHIDMain.h.
|
protected |
Definition at line 81 of file FFBHIDMain.h.
|
private |
Definition at line 105 of file FFBHIDMain.h.
|
private |
Definition at line 84 of file FFBHIDMain.h.
|
protected |
Definition at line 80 of file FFBHIDMain.h.
|
private |
Definition at line 88 of file FFBHIDMain.h.
|
protected |
Definition at line 79 of file FFBHIDMain.h.
|
private |
Definition at line 114 of file FFBHIDMain.h.
|
private |
Definition at line 118 of file FFBHIDMain.h.
|
private |
Definition at line 109 of file FFBHIDMain.h.
|
private |
Definition at line 116 of file FFBHIDMain.h.
|
private |
Definition at line 100 of file FFBHIDMain.h.
|
private |
Definition at line 108 of file FFBHIDMain.h.
|
private |
Definition at line 110 of file FFBHIDMain.h.
|
private |
Definition at line 94 of file FFBHIDMain.h.
|
private |
Definition at line 95 of file FFBHIDMain.h.
|
private |
Definition at line 96 of file FFBHIDMain.h.