Skip to content

Conversation

@jw098
Copy link
Collaborator

@jw098 jw098 commented Sep 12, 2025

No description provided.

@jw098 jw098 changed the title KeyboardListener Record Keyboard Controller Sep 18, 2025
…ng with the timestamp, on_keyboard_command_sent/stopped.
…listener(). added remove_keyboard_listener()
… 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.
SysbotBase,
};

enum class ControllerCategory{
Copy link
Collaborator

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{
Copy link
Collaborator

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();
Copy link
Collaborator

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) + " | ";
Copy link
Collaborator

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,
Copy link
Collaborator

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,
Copy link
Collaborator

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.

return dump() == x.dump();
}
bool operator!=(const JsonObject& x){
return dump() != x.dump();
Copy link
Collaborator

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().
@Mysticial Mysticial merged commit ed4ce95 into PokemonAutomation:main Sep 21, 2025
5 checks passed
@jw098 jw098 deleted the record-keypress branch September 24, 2025 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants