input_common: add TouchFromButtonDevice

This commit is contained in:
z87 2020-04-01 21:07:16 +03:00
parent 36809b2e2e
commit 41facaece3
16 changed files with 792 additions and 2 deletions

View file

@ -103,6 +103,11 @@ void Module::LoadInputDevices() {
Settings::values.current_input_profile.motion_device);
touch_device = Input::CreateDevice<Input::TouchDevice>(
Settings::values.current_input_profile.touch_device);
if (Settings::values.current_input_profile.use_touch_from_button) {
touch_btn_device = Input::CreateDevice<Input::TouchDevice>("engine:touch_from_button");
} else {
touch_btn_device.reset();
}
}
void Module::UpdatePadCallback(u64 userdata, s64 cycles_late) {
@ -177,6 +182,9 @@ void Module::UpdatePadCallback(u64 userdata, s64 cycles_late) {
bool pressed = false;
float x, y;
std::tie(x, y, pressed) = touch_device->GetStatus();
if (!pressed && touch_btn_device) {
std::tie(x, y, pressed) = touch_btn_device->GetStatus();
}
touch_entry.x = static_cast<u16>(x * Core::kScreenBottomWidth);
touch_entry.y = static_cast<u16>(y * Core::kScreenBottomHeight);
touch_entry.valid.Assign(pressed ? 1 : 0);

View file

@ -336,6 +336,7 @@ private:
std::unique_ptr<Input::AnalogDevice> circle_pad;
std::unique_ptr<Input::MotionDevice> motion_device;
std::unique_ptr<Input::TouchDevice> touch_device;
std::unique_ptr<Input::TouchDevice> touch_btn_device;
template <class Archive>
void serialize(Archive& ar, const unsigned int);