From 4f2486cddcf61f22df46cc172a65addd6845282c Mon Sep 17 00:00:00 2001 From: sirrow Date: Sun, 24 Jan 2021 15:13:05 +0900 Subject: [PATCH] add interface --- src/SwitchControlLibrary.cpp | 13 +++++++++++++ src/SwitchControlLibrary.h | 3 +++ 2 files changed, 16 insertions(+) diff --git a/src/SwitchControlLibrary.cpp b/src/SwitchControlLibrary.cpp index a705634..f8a53b5 100755 --- a/src/SwitchControlLibrary.cpp +++ b/src/SwitchControlLibrary.cpp @@ -64,6 +64,19 @@ void SwitchControlLibrary_::SendReport() CustomHID().SendReport(&_joystickInputData, sizeof(USB_JoystickReport_Input_t)); } +void SwitchControlLibrary_::PressButton(Button b) +{ + _joystickInputData.Button |= (uint16_t)b; + SendReport(); +} + +void SwitchControlLibrary_::ReleaseButton(Button b) +{ + _joystickInputData.Button &= ((uint16_t)b ^ 0xffff); + SendReport(); +} + + void SwitchControlLibrary_::PressButtonY() { _joystickInputData.Button |= (uint16_t)Button::Y; diff --git a/src/SwitchControlLibrary.h b/src/SwitchControlLibrary.h index 68b98b7..9f8bc22 100755 --- a/src/SwitchControlLibrary.h +++ b/src/SwitchControlLibrary.h @@ -61,6 +61,9 @@ class SwitchControlLibrary_ public: SwitchControlLibrary_(); + void PressButton(Button b); + void ReleaseButton(Button b); + void PressButtonY(); void ReleaseButtonY(); void PressButtonB();