diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp index 22fbec8cb..6204c1d5d 100644 --- a/src/core/hle/service/hid/hid.cpp +++ b/src/core/hle/service/hid/hid.cpp @@ -121,9 +121,15 @@ void Module::LoadInputDevices() { Settings::values.current_input_profile.buttons.begin() + Settings::NativeButton::BUTTON_HID_END, buttons.begin(), Input::CreateDevice); + zl_button = Input::CreateDevice( + Settings::values.current_input_profile.buttons[Settings::NativeButton::ZL]); + zr_button = Input::CreateDevice( + Settings::values.current_input_profile.buttons[Settings::NativeButton::ZR]); circle_pad = Input::CreateDevice( Settings::values.current_input_profile.analogs[Settings::NativeAnalog::CirclePad]); - motion_device = Input::CreateDevice( + c_stick = Input::CreateDevice( + Settings::values.current_input_profile.analogs[Settings::NativeAnalog::CStick]); + motion_device = Input::CreateDevice( Settings::values.current_input_profile.motion_device); touch_device = Input::CreateDevice( Settings::values.current_input_profile.touch_device); @@ -217,6 +223,16 @@ void Module::UpdatePadCallback(std::uintptr_t user_data, s64 cycles_late) { state.debug.Assign(buttons[Debug - BUTTON_HID_BEGIN]->GetStatus()); state.gpio14.Assign(buttons[Gpio14 - BUTTON_HID_BEGIN]->GetStatus()); + + // Setting up inputs for Cursor Class. + float c_stick_x_f, c_stick_y_f; + std::tie(c_stick_x_f, c_stick_y_f) = c_stick->GetStatus(); + stylusInput[0] = c_stick_x_f; + stylusInput[1] = c_stick_y_f; + stylusInput[2] = zl_button->GetStatus(); + stylusInput[3] = zr_button->GetStatus(); + // LOG_INFO(Service_HID, "C-Stick X: {}, C-Stick Y: {}, ZL: {}, ZR: {}", stylusInput[0], stylusInput[1], stylusInput[2], stylusInput[3]); + // Get current circle pad position and update circle pad direction float circle_pad_x_f, circle_pad_y_f; std::tie(circle_pad_x_f, circle_pad_y_f) = circle_pad->GetStatus(); @@ -320,6 +336,10 @@ void Module::UpdatePadCallback(std::uintptr_t user_data, s64 cycles_late) { system.CoreTiming().ScheduleEvent(pad_update_ticks - cycles_late, pad_update_event); } +std::array Module::getStylusInputs(){ + return stylusInput; +} + void Module::UpdateAccelerometerCallback(std::uintptr_t user_data, s64 cycles_late) { SharedMem* mem = reinterpret_cast(shared_mem->GetPointer()); diff --git a/src/core/hle/service/hid/hid.h b/src/core/hle/service/hid/hid.h index 33250e18b..7ef815838 100644 --- a/src/core/hle/service/hid/hid.h +++ b/src/core/hle/service/hid/hid.h @@ -242,7 +242,7 @@ public: class Interface : public ServiceFramework { public: Interface(std::shared_ptr hid, const char* name, u32 max_session); - + // Stylus X, Y, ZL, ZR std::shared_ptr GetModule() const; protected: @@ -335,7 +335,7 @@ public: void UseArticClient(const std::shared_ptr& client); void ReloadInputDevices(); - + std::array getStylusInputs(); const PadState& GetState() const; // Updating period for each HID device. These empirical values are measured from a 11.2 3DS. @@ -388,12 +388,15 @@ private: std::atomic is_device_reload_pending{true}; std::array, Settings::NativeButton::NUM_BUTTONS_HID> buttons; + std::unique_ptr zl_button; + std::unique_ptr zr_button; std::unique_ptr circle_pad; + std::unique_ptr c_stick; std::unique_ptr motion_device; std::unique_ptr controller_touch_device; std::unique_ptr touch_device; std::unique_ptr touch_btn_device; - + std::array stylusInput = {0}; std::shared_ptr artic_controller; std::shared_ptr artic_client;