early-access version 2199

This commit is contained in:
pineappleEA
2021-11-14 23:19:09 +01:00
parent 102e64f684
commit 4daa435a46
76 changed files with 4516 additions and 3901 deletions

View File

@@ -24,6 +24,7 @@
#include "common/settings.h"
#include "core/hle/service/acc/profile_manager.h"
#include "input_common/main.h"
#include "input_common/udp/client.h"
#include "yuzu_cmd/config.h"
#include "yuzu_cmd/default_ini.h"
@@ -292,6 +293,8 @@ void Config::ReadValues() {
Settings::values.mouse_buttons[i] = default_param;
}
ReadSetting("ControlsGeneral", Settings::values.motion_device);
ReadSetting("ControlsGeneral", Settings::values.touch_device);
ReadSetting("ControlsGeneral", Settings::values.keyboard_enabled);
@@ -360,6 +363,7 @@ void Config::ReadValues() {
Settings::TouchFromButtonMap{"default", {}});
num_touch_from_button_maps = 1;
}
ReadSetting("ControlsGeneral", Settings::values.use_touch_from_button);
Settings::values.touch_from_button_map_index = std::clamp(
Settings::values.touch_from_button_map_index.GetValue(), 0, num_touch_from_button_maps - 1);

View File

@@ -84,10 +84,23 @@ enable_accurate_vibrations=
# 0: Disabled, 1 (default): Enabled
motion_enabled =
# Defines the udp device's touch screen coordinate system for cemuhookudp devices
# - "min_x", "min_y", "max_x", "max_y"
# for motion input, the following devices are available:
# - "motion_emu" (default) for emulating motion input from mouse input. Required parameters:
# - "update_period": update period in milliseconds (default to 100)
# - "sensitivity": the coefficient converting mouse movement to tilting angle (default to 0.01)
# - "cemuhookudp" reads motion input from a udp server that uses cemuhook's udp protocol
motion_device=
# for touch input, the following devices are available:
# - "emu_window" (default) for emulating touch input from mouse input to the emulation window. No parameters required
# - "cemuhookudp" reads touch input from a udp server that uses cemuhook's udp protocol
# - "min_x", "min_y", "max_x", "max_y": defines the udp device's touch screen coordinate system
touch_device=
# Whether to enable or disable touch input from button
# 0 (default): Disabled, 1: Enabled
use_touch_from_button=
# for mapping buttons to touch inputs.
#touch_from_button_map=1
#touch_from_button_maps_0_name=default

View File

@@ -9,10 +9,10 @@
#include "common/settings.h"
#include "core/core.h"
#include "core/perf_stats.h"
#include "input_common/drivers/keyboard.h"
#include "input_common/drivers/mouse.h"
#include "input_common/drivers/touch_screen.h"
#include "input_common/keyboard.h"
#include "input_common/main.h"
#include "input_common/mouse/mouse_input.h"
#include "input_common/sdl/sdl.h"
#include "yuzu_cmd/emu_window/emu_window_sdl2.h"
#include "yuzu_cmd/yuzu_icon.h"
@@ -32,32 +32,42 @@ EmuWindow_SDL2::~EmuWindow_SDL2() {
}
void EmuWindow_SDL2::OnMouseMotion(s32 x, s32 y) {
input_subsystem->GetMouse()->MouseMove(x, y, 0, 0, 0, 0);
TouchMoved((unsigned)std::max(x, 0), (unsigned)std::max(y, 0), 0);
input_subsystem->GetMouse()->MouseMove(x, y, 0, 0);
}
InputCommon::MouseButton EmuWindow_SDL2::SDLButtonToMouseButton(u32 button) const {
MouseInput::MouseButton EmuWindow_SDL2::SDLButtonToMouseButton(u32 button) const {
switch (button) {
case SDL_BUTTON_LEFT:
return InputCommon::MouseButton::Left;
return MouseInput::MouseButton::Left;
case SDL_BUTTON_RIGHT:
return InputCommon::MouseButton::Right;
return MouseInput::MouseButton::Right;
case SDL_BUTTON_MIDDLE:
return InputCommon::MouseButton::Wheel;
return MouseInput::MouseButton::Wheel;
case SDL_BUTTON_X1:
return InputCommon::MouseButton::Backward;
return MouseInput::MouseButton::Backward;
case SDL_BUTTON_X2:
return InputCommon::MouseButton::Forward;
return MouseInput::MouseButton::Forward;
default:
return InputCommon::MouseButton::Undefined;
return MouseInput::MouseButton::Undefined;
}
}
void EmuWindow_SDL2::OnMouseButton(u32 button, u8 state, s32 x, s32 y) {
const auto mouse_button = SDLButtonToMouseButton(button);
if (state == SDL_PRESSED) {
input_subsystem->GetMouse()->PressButton(x, y, 0, 0, mouse_button);
if (button == SDL_BUTTON_LEFT) {
if (state == SDL_PRESSED) {
TouchPressed((unsigned)std::max(x, 0), (unsigned)std::max(y, 0), 0);
} else {
TouchReleased(0);
}
} else {
input_subsystem->GetMouse()->ReleaseButton(mouse_button);
if (state == SDL_PRESSED) {
input_subsystem->GetMouse()->PressButton(x, y, mouse_button);
} else {
input_subsystem->GetMouse()->ReleaseButton(mouse_button);
}
}
}
@@ -72,35 +82,29 @@ std::pair<unsigned, unsigned> EmuWindow_SDL2::TouchToPixelPos(float touch_x, flo
static_cast<unsigned>(std::max(std::round(touch_y), 0.0f))};
}
void EmuWindow_SDL2::OnFingerDown(float x, float y, std::size_t id) {
int width, height;
SDL_GetWindowSize(render_window, &width, &height);
const auto [px, py] = TouchToPixelPos(x, y);
const float fx = px * 1.0f / width;
const float fy = py * 1.0f / height;
void EmuWindow_SDL2::OnFingerDown(float x, float y) {
// TODO(NeatNit): keep track of multitouch using the fingerID and a dictionary of some kind
// This isn't critical because the best we can do when we have that is to average them, like the
// 3DS does
input_subsystem->GetTouchScreen()->TouchPressed(fx, fy, id);
const auto [px, py] = TouchToPixelPos(x, y);
TouchPressed(px, py, 0);
}
void EmuWindow_SDL2::OnFingerMotion(float x, float y, std::size_t id) {
int width, height;
SDL_GetWindowSize(render_window, &width, &height);
void EmuWindow_SDL2::OnFingerMotion(float x, float y) {
const auto [px, py] = TouchToPixelPos(x, y);
const float fx = px * 1.0f / width;
const float fy = py * 1.0f / height;
input_subsystem->GetTouchScreen()->TouchMoved(fx, fy, id);
TouchMoved(px, py, 0);
}
void EmuWindow_SDL2::OnFingerUp() {
input_subsystem->GetTouchScreen()->TouchReleased(0);
TouchReleased(0);
}
void EmuWindow_SDL2::OnKeyEvent(int key, u8 state) {
if (state == SDL_PRESSED) {
input_subsystem->GetKeyboard()->PressKey(static_cast<std::size_t>(key));
input_subsystem->GetKeyboard()->PressKey(key);
} else if (state == SDL_RELEASED) {
input_subsystem->GetKeyboard()->ReleaseKey(static_cast<std::size_t>(key));
input_subsystem->GetKeyboard()->ReleaseKey(key);
}
}
@@ -201,12 +205,10 @@ void EmuWindow_SDL2::WaitEvent() {
}
break;
case SDL_FINGERDOWN:
OnFingerDown(event.tfinger.x, event.tfinger.y,
static_cast<std::size_t>(event.tfinger.touchId));
OnFingerDown(event.tfinger.x, event.tfinger.y);
break;
case SDL_FINGERMOTION:
OnFingerMotion(event.tfinger.x, event.tfinger.y,
static_cast<std::size_t>(event.tfinger.touchId));
OnFingerMotion(event.tfinger.x, event.tfinger.y);
break;
case SDL_FINGERUP:
OnFingerUp();

View File

@@ -16,8 +16,11 @@ class System;
namespace InputCommon {
class InputSubsystem;
}
namespace MouseInput {
enum class MouseButton;
} // namespace InputCommon
}
class EmuWindow_SDL2 : public Core::Frontend::EmuWindow {
public:
@@ -44,7 +47,7 @@ protected:
void OnMouseMotion(s32 x, s32 y);
/// Converts a SDL mouse button into MouseInput mouse button
InputCommon::MouseButton SDLButtonToMouseButton(u32 button) const;
MouseInput::MouseButton SDLButtonToMouseButton(u32 button) const;
/// Called by WaitEvent when a mouse button is pressed or released
void OnMouseButton(u32 button, u8 state, s32 x, s32 y);
@@ -53,10 +56,10 @@ protected:
std::pair<unsigned, unsigned> TouchToPixelPos(float touch_x, float touch_y) const;
/// Called by WaitEvent when a finger starts touching the touchscreen
void OnFingerDown(float x, float y, std::size_t id);
void OnFingerDown(float x, float y);
/// Called by WaitEvent when a finger moves while touching the touchscreen
void OnFingerMotion(float x, float y, std::size_t id);
void OnFingerMotion(float x, float y);
/// Called by WaitEvent when a finger stops touching the touchscreen
void OnFingerUp();

View File

@@ -17,6 +17,7 @@
#include "common/settings.h"
#include "common/string_util.h"
#include "core/core.h"
#include "input_common/keyboard.h"
#include "input_common/main.h"
#include "video_core/renderer_base.h"
#include "yuzu_cmd/emu_window/emu_window_sdl2_gl.h"