1 #ifndef INPUTHELPER_GAME_H
2 #define INPUTHELPER_GAME_H
36 void handleKey(std::string JSONmessage) {
37 using namespace rapidjson;
39 rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator> alloc;
41 msg.Parse(JSONmessage.c_str());
43 std::string type = msg[
"type"].GetString();
45 bool setto = (type.compare(
"keydown") == 0);
47 std::string key = msg[
"key"].GetString();
49 if (key.compare(
"ArrowUp") == 0)
51 else if (key.compare(
"ArrowDown") == 0)
53 else if (key.compare(
"ArrowLeft") == 0)
55 else if (key.compare(
"ArrowRight") == 0)
57 else if (key.compare(
"w") == 0)
59 else if (key.compare(
"a") == 0)
61 else if (key.compare(
"s") == 0)
63 else if (key.compare(
"d") == 0)
65 else if (key.compare(
"q") == 0)
67 else if (key.compare(
" ") == 0)
72 virtual void keyup(std::string JSONmessage)
override {
74 std::cerr <<
"InputHelper::keyup(\"" << JSONmessage <<
"\")\n";
75 handleKey(JSONmessage);
78 virtual void keydown(std::string JSONmessage)
override {
80 std::cerr <<
"InputHelper::keydown(\"" << JSONmessage <<
"\")\n";
81 handleKey(JSONmessage);
This is meant to be an internal class, not something that the library user will use....
Definition: SocketConnection.h:34
Support for drawing Bar charts.
Definition: alltypes.h:4