-
Notifications
You must be signed in to change notification settings - Fork 80
Record Keyboard Controller #690
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…to add KeyboardListeners.
…ng with the timestamp, on_keyboard_command_sent/stopped.
…listener(). added remove_keyboard_listener()
…holders for button and dpad.
… json_to_cpp_code_pro_controller() with button and dpad converted to their respective strings.
…o_controller() to reuse same code that exposes the controller fields.
…n exception if given json filename already exists to avoid overwriting.
7cdb5d6 to
1c847b3
Compare
4bd7158 to
35fefea
Compare
| SysbotBase, | ||
| }; | ||
|
|
||
| enum class ControllerCategory{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If these are one-to-one with the 4 controller classes (ProController, Left/RightJoycon, StandardHid::Keyboard), maybe rename this to ControllerClass?
| KeyboardEventHandler(); | ||
| virtual ~KeyboardEventHandler(); | ||
|
|
||
| struct KeyboardListener{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indent
| if (m_controller == nullptr){ | ||
| return; | ||
| } | ||
| m_controller->cancel_all_commands(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move the timestamp read to just before this line since it's closer to the actual time being sent to the Switch. Having it before the lock could mean an arbitrary delay.
|
|
||
| std::string button_to_code_string(Button button){ | ||
| std::string str; | ||
| if (button & BUTTON_Y) str += BUTTON_CODE_STRINGS.get_string(BUTTON_Y) + " | "; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can actually loop this. EnumStringMap has begin() and end() iterators to let you iterate it.
| nullptr, | ||
| switch_state.buttons, | ||
| switch_state.joystick_x, | ||
| switch_state.joystick_y, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing here. Move the timestamp read to just before the command is sent.
| switch_state.dpad, | ||
| switch_state.left_x, | ||
| switch_state.left_y, | ||
| switch_state.right_x, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing here with the timestamp.
Common/Cpp/Json/JsonObject.h
Outdated
| return dump() == x.dump(); | ||
| } | ||
| bool operator!=(const JsonObject& x){ | ||
| return dump() != x.dump(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are more commonly written as a delegation: return !(*this == *this);
…s taken. refactor JsonObject operator!=. refactor button_to_code_string() and button_to_string().
No description provided.