Open FFBoard
Open source force feedback firmware
CustomMain.cpp
Go to the documentation of this file.
1
/*
2
* exampleMain.cpp
3
*
4
* Created on: 23.01.2020
5
* Author: Yannick
6
*/
7
8
#include <
CustomMain.h
>
9
10
// Change this
11
ClassIdentifier
CustomMain::info
= {
12
.
name
=
"Custom"
,
13
.id=CLSID_CUSTOM,
14
.visibility =
ClassVisibility::hidden
15
};
16
// Copy this to your class for identification
17
const
ClassIdentifier
CustomMain::getInfo
(){
18
return
info
;
19
}
20
21
22
23
CustomMain::CustomMain
() {
24
registerCommands
();
// Register all the commands
25
}
26
27
CustomMain::~CustomMain
() {
28
29
}
30
31
void
CustomMain::registerCommands
(){
32
CommandHandler::registerCommands
();
// Register internal commands for getting the id and help
33
registerCommand
(
"command"
,
CustomMain_commands::command
,
"Controls the example variable"
);
34
}
35
36
std::string
CustomMain::getHelpstring
(){
37
return
"This is a basic example mainclass with commands"
;
38
}
39
40
CommandStatus
CustomMain::command
(
const
ParsedCommand
& cmd,std::vector<CommandReply>& replies){
41
switch
(
static_cast<
CustomMain_commands
>
(cmd.
cmdId
))
42
{
43
44
case
CustomMain_commands::command
:
45
// Sets or gets the variable
46
handleGetSet
(cmd, replies, this->
examplevar
);
47
break
;
48
49
50
default
:
51
return
CommandStatus::NOT_FOUND
;
52
}
53
return
CommandStatus::OK
;
54
}
ClassVisibility::hidden
@ hidden
CommandStatus
CommandStatus
Definition:
CommandHandler.h:39
CommandStatus::NOT_FOUND
@ NOT_FOUND
CommandStatus::OK
@ OK
CustomMain.h
CommandHandler::registerCommands
void registerCommands()
Definition:
CommandHandler.cpp:174
CommandHandler::registerCommand
void registerCommand(const char *cmd, const ID cmdid, const char *help=nullptr, uint32_t flags=0)
Definition:
CommandHandler.h:262
CommandHandler::handleGetSet
static CommandStatus handleGetSet(const ParsedCommand &cmd, std::vector< CommandReply > &replies, TVal &value)
Definition:
CommandHandler.h:201
CustomMain::CustomMain
CustomMain()
Definition:
CustomMain.cpp:23
CustomMain::info
static ClassIdentifier info
Definition:
CustomMain.h:23
CustomMain::CustomMain_commands
CustomMain_commands
Definition:
CustomMain.h:14
CustomMain::CustomMain_commands::command
@ command
CustomMain::command
CommandStatus command(const ParsedCommand &cmd, std::vector< CommandReply > &replies)
Definition:
CustomMain.cpp:40
CustomMain::~CustomMain
virtual ~CustomMain()
Definition:
CustomMain.cpp:27
CustomMain::getInfo
const ClassIdentifier getInfo()
Definition:
CustomMain.cpp:17
CustomMain::getHelpstring
std::string getHelpstring()
Definition:
CustomMain.cpp:36
CustomMain::examplevar
int32_t examplevar
Definition:
CustomMain.h:30
CustomMain::registerCommands
void registerCommands()
Definition:
CustomMain.cpp:31
ClassIdentifier
Definition:
ChoosableClass.h:15
ClassIdentifier::name
const char * name
Definition:
ChoosableClass.h:16
ParsedCommand
Definition:
CommandHandler.h:67
ParsedCommand::cmdId
uint32_t cmdId
Definition:
CommandHandler.h:68
Firmware
FFBoard
UserExtensions
Src
CustomMain.cpp
Generated by
1.9.2