Esp32-RBGridUI
Library for creating UIs for the RBController app
Loading...
Searching...
No Matches
joystick.h
Go to the documentation of this file.
1#pragma once
2
3#include "../widgets/joystick.h"
4#include "widget.h"
5
6namespace gridui {
7namespace builder {
8
11class Joystick : public Widget, public BuilderMixin<Joystick, gridui::Joystick> {
12 static const char* name() { return "Joystick"; }
13
14 friend class gridui::_GridUi;
15 using Widget::Widget;
16
17public:
18 Joystick& color(const std::string& color) {
19 extra().set("color", color);
20 return *this;
21 }
22
23 Joystick& keys(const std::string& keys) {
24 extra().set("keys", keys);
25 return *this;
26 }
27
28 Joystick& text(const std::string& text) {
29 extra().set("text", text);
30 return *this;
31 }
32
33 Joystick& keys(char forward, char left, char backwards, char right, char click = 0) {
34 const char keys[6] = { forward, left, backwards, right, click, 0 };
35 extra().set("keys", keys);
36 return *this;
37 }
38
42 addCallback("click", cb);
43 return *this;
44 }
45
49 addCallback("pos", cb);
50 return *this;
51 }
52};
53
54};
55};
std::function< void(gridui::Joystick &)> callback_t
Definition widget.h:41
void addCallback(const std::string &name, const callback_t &cb)
Definition widget.h:54
Joystick & color(const std::string &color)
Definition joystick.h:18
Joystick & keys(const std::string &keys)
Definition joystick.h:23
Joystick & text(const std::string &text)
Definition joystick.h:28
Joystick & keys(char forward, char left, char backwards, char right, char click=0)
Definition joystick.h:33
rbjson::Object & extra()
Definition widget.cpp:16
Joystick & onPositionChanged(callback_t cb)
Definition joystick.h:48
Joystick & onClick(callback_t cb)
Definition joystick.h:41
Definition arm.h:8