summaryrefslogtreecommitdiffstats
path: root/src/yuzu_cmd
diff options
context:
space:
mode:
Diffstat (limited to 'src/yuzu_cmd')
-rw-r--r--src/yuzu_cmd/config.cpp1
-rw-r--r--src/yuzu_cmd/emu_window/emu_window_sdl2.cpp48
-rw-r--r--src/yuzu_cmd/emu_window/emu_window_sdl2.h12
-rw-r--r--src/yuzu_cmd/yuzu.cpp19
4 files changed, 70 insertions, 10 deletions
diff --git a/src/yuzu_cmd/config.cpp b/src/yuzu_cmd/config.cpp
index 9d934e220..2470f4640 100644
--- a/src/yuzu_cmd/config.cpp
+++ b/src/yuzu_cmd/config.cpp
@@ -138,6 +138,7 @@ void Config::ReadValues() {
Settings::values.use_gdbstub = sdl2_config->GetBoolean("Debugging", "use_gdbstub", false);
Settings::values.gdbstub_port =
static_cast<u16>(sdl2_config->GetInteger("Debugging", "gdbstub_port", 24689));
+ Settings::values.program_args = sdl2_config->Get("Debugging", "program_args", "");
// Web Service
Settings::values.enable_telemetry =
diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp b/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp
index 155095095..a9ad92a80 100644
--- a/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp
+++ b/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp
@@ -40,6 +40,35 @@ void EmuWindow_SDL2::OnMouseButton(u32 button, u8 state, s32 x, s32 y) {
}
}
+std::pair<unsigned, unsigned> EmuWindow_SDL2::TouchToPixelPos(float touch_x, float touch_y) const {
+ int w, h;
+ SDL_GetWindowSize(render_window, &w, &h);
+
+ touch_x *= w;
+ touch_y *= h;
+
+ return {static_cast<unsigned>(std::max(std::round(touch_x), 0.0f)),
+ static_cast<unsigned>(std::max(std::round(touch_y), 0.0f))};
+}
+
+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
+
+ const auto [px, py] = TouchToPixelPos(x, y);
+ TouchPressed(px, py);
+}
+
+void EmuWindow_SDL2::OnFingerMotion(float x, float y) {
+ const auto [px, py] = TouchToPixelPos(x, y);
+ TouchMoved(px, py);
+}
+
+void EmuWindow_SDL2::OnFingerUp() {
+ TouchReleased();
+}
+
void EmuWindow_SDL2::OnKeyEvent(int key, u8 state) {
if (state == SDL_PRESSED) {
InputCommon::GetKeyboard()->PressKey(key);
@@ -219,11 +248,26 @@ void EmuWindow_SDL2::PollEvents() {
OnKeyEvent(static_cast<int>(event.key.keysym.scancode), event.key.state);
break;
case SDL_MOUSEMOTION:
- OnMouseMotion(event.motion.x, event.motion.y);
+ // ignore if it came from touch
+ if (event.button.which != SDL_TOUCH_MOUSEID)
+ OnMouseMotion(event.motion.x, event.motion.y);
break;
case SDL_MOUSEBUTTONDOWN:
case SDL_MOUSEBUTTONUP:
- OnMouseButton(event.button.button, event.button.state, event.button.x, event.button.y);
+ // ignore if it came from touch
+ if (event.button.which != SDL_TOUCH_MOUSEID) {
+ OnMouseButton(event.button.button, event.button.state, event.button.x,
+ event.button.y);
+ }
+ break;
+ case SDL_FINGERDOWN:
+ OnFingerDown(event.tfinger.x, event.tfinger.y);
+ break;
+ case SDL_FINGERMOTION:
+ OnFingerMotion(event.tfinger.x, event.tfinger.y);
+ break;
+ case SDL_FINGERUP:
+ OnFingerUp();
break;
case SDL_QUIT:
is_open = false;
diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2.h b/src/yuzu_cmd/emu_window/emu_window_sdl2.h
index d34902109..b0d4116cc 100644
--- a/src/yuzu_cmd/emu_window/emu_window_sdl2.h
+++ b/src/yuzu_cmd/emu_window/emu_window_sdl2.h
@@ -40,6 +40,18 @@ private:
/// Called by PollEvents when a mouse button is pressed or released
void OnMouseButton(u32 button, u8 state, s32 x, s32 y);
+ /// Translates pixel position (0..1) to pixel positions
+ std::pair<unsigned, unsigned> TouchToPixelPos(float touch_x, float touch_y) const;
+
+ /// Called by PollEvents when a finger starts touching the touchscreen
+ void OnFingerDown(float x, float y);
+
+ /// Called by PollEvents when a finger moves while touching the touchscreen
+ void OnFingerMotion(float x, float y);
+
+ /// Called by PollEvents when a finger stops touching the touchscreen
+ void OnFingerUp();
+
/// Called by PollEvents when any event that may cause the window to be resized occurs
void OnResize();
diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp
index 1d951ca3f..27aba95f6 100644
--- a/src/yuzu_cmd/yuzu.cpp
+++ b/src/yuzu_cmd/yuzu.cpp
@@ -56,9 +56,10 @@ static void PrintHelp(const char* argv0) {
std::cout << "Usage: " << argv0
<< " [options] <filename>\n"
"-g, --gdbport=NUMBER Enable gdb stub on port NUMBER\n"
- "-f, --fullscreen Start in fullscreen mode\n"
+ "-f, --fullscreen Start in fullscreen mode\n"
"-h, --help Display this help and exit\n"
- "-v, --version Output version information and exit\n";
+ "-v, --version Output version information and exit\n"
+ "-p, --program Pass following string as arguments to executable\n";
}
static void PrintVersion() {
@@ -103,15 +104,13 @@ int main(int argc, char** argv) {
bool fullscreen = false;
static struct option long_options[] = {
- {"gdbport", required_argument, 0, 'g'},
- {"fullscreen", no_argument, 0, 'f'},
- {"help", no_argument, 0, 'h'},
- {"version", no_argument, 0, 'v'},
- {0, 0, 0, 0},
+ {"gdbport", required_argument, 0, 'g'}, {"fullscreen", no_argument, 0, 'f'},
+ {"help", no_argument, 0, 'h'}, {"version", no_argument, 0, 'v'},
+ {"program", optional_argument, 0, 'p'}, {0, 0, 0, 0},
};
while (optind < argc) {
- char arg = getopt_long(argc, argv, "g:fhv", long_options, &option_index);
+ char arg = getopt_long(argc, argv, "g:fhvp::", long_options, &option_index);
if (arg != -1) {
switch (arg) {
case 'g':
@@ -135,6 +134,10 @@ int main(int argc, char** argv) {
case 'v':
PrintVersion();
return 0;
+ case 'p':
+ Settings::values.program_args = argv[optind];
+ ++optind;
+ break;
}
} else {
#ifdef _WIN32