summaryrefslogtreecommitdiffstats
path: root/src/core/hle
diff options
context:
space:
mode:
authorwwylele <wwylele@gmail.com>2017-01-20 22:58:03 +0100
committerwwylele <wwylele@gmail.com>2017-03-01 22:30:57 +0100
commit70420272ca63425b52844632c6be3d3691446468 (patch)
tree193f709dcdeb8db5e978e59afa87cc0e444aa4e8 /src/core/hle
parentHID: use ButtonDevice (diff)
downloadyuzu-70420272ca63425b52844632c6be3d3691446468.tar
yuzu-70420272ca63425b52844632c6be3d3691446468.tar.gz
yuzu-70420272ca63425b52844632c6be3d3691446468.tar.bz2
yuzu-70420272ca63425b52844632c6be3d3691446468.tar.lz
yuzu-70420272ca63425b52844632c6be3d3691446468.tar.xz
yuzu-70420272ca63425b52844632c6be3d3691446468.tar.zst
yuzu-70420272ca63425b52844632c6be3d3691446468.zip
Diffstat (limited to 'src/core/hle')
-rw-r--r--src/core/hle/service/hid/hid.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp
index 0da731418..b19e831fe 100644
--- a/src/core/hle/service/hid/hid.cpp
+++ b/src/core/hle/service/hid/hid.cpp
@@ -51,6 +51,7 @@ constexpr u64 gyroscope_update_ticks = BASE_CLOCK_RATE_ARM11 / 101;
static std::atomic<bool> is_device_reload_pending;
static std::array<std::unique_ptr<Input::ButtonDevice>, Settings::NativeButton::NUM_BUTTONS_HID>
buttons;
+static std::unique_ptr<Input::AnalogDevice> circle_pad;
static PadState GetCirclePadDirectionState(s16 circle_pad_x, s16 circle_pad_y) {
// 30 degree and 60 degree are angular thresholds for directions
@@ -86,12 +87,15 @@ static void LoadInputDevices() {
std::transform(Settings::values.buttons.begin() + Settings::NativeButton::BUTTON_HID_BEGIN,
Settings::values.buttons.begin() + Settings::NativeButton::BUTTON_HID_END,
buttons.begin(), Input::CreateDevice<Input::ButtonDevice>);
+ circle_pad = Input::CreateDevice<Input::AnalogDevice>(
+ Settings::values.analogs[Settings::NativeAnalog::CirclePad]);
}
static void UnloadInputDevices() {
for (auto& button : buttons) {
button.reset();
}
+ circle_pad.reset();
}
static void UpdatePadCallback(u64 userdata, int cycles_late) {
@@ -116,8 +120,11 @@ static void UpdatePadCallback(u64 userdata, int cycles_late) {
state.select.Assign(buttons[Select - BUTTON_HID_BEGIN]->GetStatus());
// Get current circle pad position and update circle pad direction
- s16 circle_pad_x, circle_pad_y;
- std::tie(circle_pad_x, circle_pad_y) = VideoCore::g_emu_window->GetCirclePadState();
+ float circle_pad_x_f, circle_pad_y_f;
+ std::tie(circle_pad_x_f, circle_pad_y_f) = circle_pad->GetStatus();
+ constexpr int MAX_CIRCLEPAD_POS = 0x9C; // Max value for a circle pad position
+ s16 circle_pad_x = static_cast<s16>(circle_pad_x_f * MAX_CIRCLEPAD_POS);
+ s16 circle_pad_y = static_cast<s16>(circle_pad_y_f * MAX_CIRCLEPAD_POS);
state.hex |= GetCirclePadDirectionState(circle_pad_x, circle_pad_y).hex;
mem->pad.current_state.hex = state.hex;