diff options
author | bunnei <bunneidev@gmail.com> | 2018-01-17 03:54:46 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-17 03:54:46 +0100 |
commit | dc905463dcbe12a7d472a97b38d17597ee59450e (patch) | |
tree | 30731dccd6431d94c5a6fa8421a9ff4ec4c1259e /src/core/hle/service/hid/hid.cpp | |
parent | acc_u0: Add IPC interface and stub InitializeApplicationInfo. (diff) | |
parent | hid: clang-format (diff) | |
download | yuzu-dc905463dcbe12a7d472a97b38d17597ee59450e.tar yuzu-dc905463dcbe12a7d472a97b38d17597ee59450e.tar.gz yuzu-dc905463dcbe12a7d472a97b38d17597ee59450e.tar.bz2 yuzu-dc905463dcbe12a7d472a97b38d17597ee59450e.tar.lz yuzu-dc905463dcbe12a7d472a97b38d17597ee59450e.tar.xz yuzu-dc905463dcbe12a7d472a97b38d17597ee59450e.tar.zst yuzu-dc905463dcbe12a7d472a97b38d17597ee59450e.zip |
Diffstat (limited to 'src/core/hle/service/hid/hid.cpp')
-rw-r--r-- | src/core/hle/service/hid/hid.cpp | 103 |
1 files changed, 65 insertions, 38 deletions
diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp index 3c4259d27..6254237fa 100644 --- a/src/core/hle/service/hid/hid.cpp +++ b/src/core/hle/service/hid/hid.cpp @@ -65,44 +65,71 @@ private: if (is_device_reload_pending.exchange(false)) LoadInputDevices(); - // TODO(shinyquagsire23): This is a hack! - ControllerPadState& state = - mem->controllers[Controller_Handheld].layouts[Layout_Default].entries[0].buttons; - using namespace Settings::NativeButton; - state.a.Assign(buttons[A - BUTTON_HID_BEGIN]->GetStatus()); - state.b.Assign(buttons[B - BUTTON_HID_BEGIN]->GetStatus()); - state.x.Assign(buttons[X - BUTTON_HID_BEGIN]->GetStatus()); - state.y.Assign(buttons[Y - BUTTON_HID_BEGIN]->GetStatus()); - state.lstick.Assign(buttons[LStick - BUTTON_HID_BEGIN]->GetStatus()); - state.rstick.Assign(buttons[RStick - BUTTON_HID_BEGIN]->GetStatus()); - state.l.Assign(buttons[L - BUTTON_HID_BEGIN]->GetStatus()); - state.r.Assign(buttons[R - BUTTON_HID_BEGIN]->GetStatus()); - state.zl.Assign(buttons[ZL - BUTTON_HID_BEGIN]->GetStatus()); - state.zr.Assign(buttons[ZR - BUTTON_HID_BEGIN]->GetStatus()); - state.plus.Assign(buttons[Plus - BUTTON_HID_BEGIN]->GetStatus()); - state.minus.Assign(buttons[Minus - BUTTON_HID_BEGIN]->GetStatus()); - - state.dleft.Assign(buttons[DLeft - BUTTON_HID_BEGIN]->GetStatus()); - state.dup.Assign(buttons[DUp - BUTTON_HID_BEGIN]->GetStatus()); - state.dright.Assign(buttons[DRight - BUTTON_HID_BEGIN]->GetStatus()); - state.ddown.Assign(buttons[DDown - BUTTON_HID_BEGIN]->GetStatus()); - - state.lstick_left.Assign(buttons[LStick_Left - BUTTON_HID_BEGIN]->GetStatus()); - state.lstick_up.Assign(buttons[LStick_Up - BUTTON_HID_BEGIN]->GetStatus()); - state.lstick_right.Assign(buttons[LStick_Right - BUTTON_HID_BEGIN]->GetStatus()); - state.lstick_down.Assign(buttons[LStick_Down - BUTTON_HID_BEGIN]->GetStatus()); - - state.rstick_left.Assign(buttons[RStick_Left - BUTTON_HID_BEGIN]->GetStatus()); - state.rstick_up.Assign(buttons[RStick_Up - BUTTON_HID_BEGIN]->GetStatus()); - state.rstick_right.Assign(buttons[RStick_Right - BUTTON_HID_BEGIN]->GetStatus()); - state.rstick_down.Assign(buttons[RStick_Down - BUTTON_HID_BEGIN]->GetStatus()); - - state.sl.Assign(buttons[SL - BUTTON_HID_BEGIN]->GetStatus()); - state.sr.Assign(buttons[SR - BUTTON_HID_BEGIN]->GetStatus()); - - // TODO(shinyquagsire23): Analog stick vals - - // TODO(shinyquagsire23): Update pad info proper, (circular buffers, timestamps, layouts) + // Set up controllers as neon red+blue Joy-Con attached to console + ControllerHeader& controller_header = mem->controllers[Controller_Handheld].header; + controller_header.type = ControllerType_Handheld | ControllerType_JoyconPair; + controller_header.single_colors_descriptor = ColorDesc_ColorsNonexistent; + controller_header.right_color_body = JOYCON_BODY_NEON_RED; + controller_header.right_color_buttons = JOYCON_BUTTONS_NEON_RED; + controller_header.left_color_body = JOYCON_BODY_NEON_BLUE; + controller_header.left_color_buttons = JOYCON_BUTTONS_NEON_BLUE; + + for (int layoutIdx = 0; layoutIdx < HID_NUM_LAYOUTS; layoutIdx++) { + ControllerLayout& layout = mem->controllers[Controller_Handheld].layouts[layoutIdx]; + layout.header.num_entries = HID_NUM_ENTRIES; + layout.header.max_entry_index = HID_NUM_ENTRIES - 1; + + // HID shared memory stores the state of the past 17 samples in a circlular buffer, + // each with a timestamp in number of samples since boot. + layout.header.timestamp_ticks = CoreTiming::GetTicks(); + layout.header.latest_entry = (layout.header.latest_entry + 1) % HID_NUM_ENTRIES; + + ControllerInputEntry& entry = layout.entries[layout.header.latest_entry]; + entry.connection_state = ConnectionState_Connected | ConnectionState_Wired; + entry.timestamp++; + entry.timestamp_2++; // TODO(shinyquagsire23): Is this always identical to timestamp? + + // TODO(shinyquagsire23): Set up some LUTs for each layout mapping in the future? + // For now everything is just the default handheld layout, but split Joy-Con will + // rotate the face buttons and directions for certain layouts. + ControllerPadState& state = entry.buttons; + using namespace Settings::NativeButton; + state.a.Assign(buttons[A - BUTTON_HID_BEGIN]->GetStatus()); + state.b.Assign(buttons[B - BUTTON_HID_BEGIN]->GetStatus()); + state.x.Assign(buttons[X - BUTTON_HID_BEGIN]->GetStatus()); + state.y.Assign(buttons[Y - BUTTON_HID_BEGIN]->GetStatus()); + state.lstick.Assign(buttons[LStick - BUTTON_HID_BEGIN]->GetStatus()); + state.rstick.Assign(buttons[RStick - BUTTON_HID_BEGIN]->GetStatus()); + state.l.Assign(buttons[L - BUTTON_HID_BEGIN]->GetStatus()); + state.r.Assign(buttons[R - BUTTON_HID_BEGIN]->GetStatus()); + state.zl.Assign(buttons[ZL - BUTTON_HID_BEGIN]->GetStatus()); + state.zr.Assign(buttons[ZR - BUTTON_HID_BEGIN]->GetStatus()); + state.plus.Assign(buttons[Plus - BUTTON_HID_BEGIN]->GetStatus()); + state.minus.Assign(buttons[Minus - BUTTON_HID_BEGIN]->GetStatus()); + + state.dleft.Assign(buttons[DLeft - BUTTON_HID_BEGIN]->GetStatus()); + state.dup.Assign(buttons[DUp - BUTTON_HID_BEGIN]->GetStatus()); + state.dright.Assign(buttons[DRight - BUTTON_HID_BEGIN]->GetStatus()); + state.ddown.Assign(buttons[DDown - BUTTON_HID_BEGIN]->GetStatus()); + + state.lstick_left.Assign(buttons[LStick_Left - BUTTON_HID_BEGIN]->GetStatus()); + state.lstick_up.Assign(buttons[LStick_Up - BUTTON_HID_BEGIN]->GetStatus()); + state.lstick_right.Assign(buttons[LStick_Right - BUTTON_HID_BEGIN]->GetStatus()); + state.lstick_down.Assign(buttons[LStick_Down - BUTTON_HID_BEGIN]->GetStatus()); + + state.rstick_left.Assign(buttons[RStick_Left - BUTTON_HID_BEGIN]->GetStatus()); + state.rstick_up.Assign(buttons[RStick_Up - BUTTON_HID_BEGIN]->GetStatus()); + state.rstick_right.Assign(buttons[RStick_Right - BUTTON_HID_BEGIN]->GetStatus()); + state.rstick_down.Assign(buttons[RStick_Down - BUTTON_HID_BEGIN]->GetStatus()); + + state.sl.Assign(buttons[SL - BUTTON_HID_BEGIN]->GetStatus()); + state.sr.Assign(buttons[SR - BUTTON_HID_BEGIN]->GetStatus()); + + // TODO(shinyquagsire23): Analog stick vals + + // TODO(shinyquagsire23): Update pad info proper, (circular buffers, timestamps, + // layouts) + } // TODO(shinyquagsire23): Update touch info |