Commit 84f31e95 authored by James Sexton's avatar James Sexton Committed by James
Browse files

Add option to disable mouse input for touchscreen (#61)

* Add mouse_touchscreen setting

* Add setting for mouse_touchscreen

* Implement mouse_touchscreen setting

* Update core_settings.h

* whitespace

* Allow controller input even if mouse_touchscreen is false

* bracket

* libretro: Add Travis testing (#62)

* libretro: Add Travis testing

* libretro: Remove Travis testing other platforms
parent 37192ff3
......@@ -101,6 +101,7 @@ void LibRetro::OnConfigureEnvironment() {
{"citra_analog_function",
"Right analog function; C-Stick and Touchscreen Pointer|Touchscreen Pointer|C-Stick"},
{"citra_deadzone", "Emulated pointer deadzone (%); 15|20|25|30|35|0|5|10"},
{"citra_mouse_touchscreen", "Enable mouse input for touchscreen; enabled|disabled"},
{"citra_use_virtual_sd", "Enable virtual SD card; enabled|disabled"},
{"citra_use_libretro_save_path", "Savegame location; LibRetro Default|Citra Default"},
{"citra_is_new_3ds", "3DS system model; Old 3DS|New 3DS"},
......@@ -184,6 +185,8 @@ void UpdateSettings() {
Settings::values.swap_screen = LibRetro::FetchVariable("citra_swap_screen", "Top") == "Bottom";
Settings::values.use_gdbstub =
LibRetro::FetchVariable("citra_use_gdbstub", "disabled") == "enabled";
LibRetro::settings.mouse_touchscreen =
LibRetro::FetchVariable("citra_mouse_touchscreen", "enabled") == "enabled";
// These values are a bit more hard to define, unfortunately.
auto scaling = LibRetro::FetchVariable("citra_resolution_factor", "1x (Native)");
......
......@@ -18,6 +18,8 @@ struct CoreSettings {
LibRetro::CStickFunction analog_function;
bool mouse_touchscreen;
} extern settings;
} // namespace LibRetro
......@@ -73,33 +73,39 @@ void MouseTracker::Restrict(int minX, int minY, int maxX, int maxY) {
void MouseTracker::Update(int bufferWidth, int bufferHeight,
MathUtil::Rectangle<unsigned> bottomScreen) {
// Check mouse input
bool state =
(bool)(LibRetro::CheckInput(0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_LEFT)) ||
(bool)(LibRetro::CheckInput(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R3));
// TODO: Provide config option for ratios here
auto widthSpeed = (bottomScreen.GetWidth() / 20.0);
auto heightSpeed = (bottomScreen.GetHeight() / 20.0);
// Read in and convert pointer values to absolute values on the canvas
auto pointerX = LibRetro::CheckInput(0, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_X);
auto pointerY = LibRetro::CheckInput(0, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_Y);
auto newX = static_cast<int>((pointerX + 0x7fff) / (float)(0x7fff * 2) * bufferWidth);
auto newY = static_cast<int>((pointerY + 0x7fff) / (float)(0x7fff * 2) * bufferHeight);
if ((pointerX != 0 || pointerY != 0) && (newX != lastMouseX || newY != lastMouseY)) {
bool state = false;
if (LibRetro::settings.mouse_touchscreen) {
// Check mouse input
state |= LibRetro::CheckInput(0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_LEFT);
// Read in and convert pointer values to absolute values on the canvas
auto pointerX = LibRetro::CheckInput(0, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_X);
auto pointerY = LibRetro::CheckInput(0, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_Y);
auto newX = static_cast<int>((pointerX + 0x7fff) / (float)(0x7fff * 2) * bufferWidth);
auto newY = static_cast<int>((pointerY + 0x7fff) / (float)(0x7fff * 2) * bufferHeight);
// Use mouse pointer movement
lastMouseX = newX;
lastMouseY = newY;
x = std::max(static_cast<int>(bottomScreen.left),
std::min(newX, static_cast<int>(bottomScreen.right))) -
bottomScreen.left;
y = std::max(static_cast<int>(bottomScreen.top),
std::min(newY, static_cast<int>(bottomScreen.bottom))) -
bottomScreen.top;
} else if (LibRetro::settings.analog_function != LibRetro::CStickFunction::CStick) {
if ((pointerX != 0 || pointerY != 0) && (newX != lastMouseX || newY != lastMouseY)) {
lastMouseX = newX;
lastMouseY = newY;
x = std::max(static_cast<int>(bottomScreen.left),
std::min(newX, static_cast<int>(bottomScreen.right))) -
bottomScreen.left;
y = std::max(static_cast<int>(bottomScreen.top),
std::min(newY, static_cast<int>(bottomScreen.bottom))) -
bottomScreen.top;
}
}
if (LibRetro::settings.analog_function != LibRetro::CStickFunction::CStick) {
// Check right analog input
state |= LibRetro::CheckInput(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R3);
// TODO: Provide config option for ratios here
auto widthSpeed = (bottomScreen.GetWidth() / 20.0);
auto heightSpeed = (bottomScreen.GetHeight() / 20.0);
// Use controller movement
float controllerX =
((float)LibRetro::CheckInput(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment