SMACC2
Loading...
Searching...
No Matches
cb_default_keyboard_behavior.hpp
Go to the documentation of this file.
1// Copyright 2021 RobosoftAI Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#pragma once
16
19
20#include <std_msgs/msg/u_int16.hpp>
21
22namespace cl_keyboard
23{
24using namespace cl_keyboard::components;
25
27{
28public:
30 std::function<void(char)> postEventKeyPress;
31
32 void onEntry();
33
34 template <typename TOrthogonal, typename TSourceObject>
36 {
37 postEventKeyPress = [=](char character)
38 {
39 if (character == 'a')
41 else if (character == 'b')
43 else if (character == 'c')
45 else if (character == 'd')
47 else if (character == 'e')
49 else if (character == 'f')
51 else if (character == 'g')
53 else if (character == 'h')
55 else if (character == 'i')
57 else if (character == 'j')
59 else if (character == 'k')
61 else if (character == 'l')
63 else if (character == 'm')
65 else if (character == 'n')
67 else if (character == 'o')
69 else if (character == 'p')
71 else if (character == 'q')
73 else if (character == 'r')
75 else if (character == 's')
77 else if (character == 't')
79 else if (character == 'u')
81 else if (character == 'v')
83 else if (character == 'w')
85 else if (character == 'x')
87 else if (character == 'y')
89 else if (character == 'z')
91 };
92 }
93
94 void OnKeyPress(char character);
95
96 template <typename TEv>
98 {
99 RCLCPP_WARN(
100 getLogger(), "CbDefaultKeyboardBehavior %ld ev: %s", (long)(void *)this,
101 smacc2::demangleSymbol(typeid(TEv).name()).c_str());
102 auto event = new TEv();
103 this->postEvent(event);
104 }
105};
106} // namespace cl_keyboard
virtual rclcpp::Logger getLogger() const
std::string demangleSymbol()