Merge pull request #5163 from z87/input-touch-mapping
input: allow mapping buttons to touchscreen
This commit is contained in:
commit
81a1e5680f
18 changed files with 1221 additions and 6 deletions
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -112,11 +112,18 @@ struct InputProfile {
|
|||
std::array<std::string, NativeAnalog::NumAnalogs> analogs;
|
||||
std::string motion_device;
|
||||
std::string touch_device;
|
||||
bool use_touch_from_button;
|
||||
int touch_from_button_map_index;
|
||||
std::string udp_input_address;
|
||||
u16 udp_input_port;
|
||||
u8 udp_pad_index;
|
||||
};
|
||||
|
||||
struct TouchFromButtonMap {
|
||||
std::string name;
|
||||
std::vector<std::string> buttons;
|
||||
};
|
||||
|
||||
struct Values {
|
||||
// CheckNew3DS
|
||||
bool is_new_3ds;
|
||||
|
@ -125,6 +132,7 @@ struct Values {
|
|||
InputProfile current_input_profile; ///< The current input profile
|
||||
int current_input_profile_index; ///< The current input profile index
|
||||
std::vector<InputProfile> input_profiles; ///< The list of input profiles
|
||||
std::vector<TouchFromButtonMap> touch_from_button_maps;
|
||||
|
||||
// Core
|
||||
bool use_cpu_jit;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue