Files
eden/src/yuzu_cmd/emu_window/emu_window_sdl3.h
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

104 lines
3.2 KiB
C++
Raw Normal View History

2026-05-18 19:07:41 +02:00
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
2026-05-18 19:07:41 +02:00
2022-05-15 02:06:02 +02:00
// SPDX-FileCopyrightText: 2016 Citra Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
2016-03-01 17:24:18 +00:00
#pragma once
#include <tuple>
2016-03-01 17:24:18 +00:00
#include <utility>
#include <SDL3/SDL.h>
#include <SDL3/SDL_timer.h>
2016-12-23 13:37:40 +00:00
#include "core/frontend/emu_window.h"
#include "core/frontend/graphics_context.h"
2016-03-01 17:24:18 +00:00
namespace Core {
class System;
}
2020-08-27 15:16:47 -04:00
namespace InputCommon {
class InputSubsystem;
2021-02-23 20:39:02 -06:00
enum class MouseButton;
2021-09-20 19:40:00 -05:00
} // namespace InputCommon
2021-02-23 20:39:02 -06:00
2026-05-18 19:07:41 +02:00
class EmuWindow_SDL3 : public Core::Frontend::EmuWindow {
2016-03-01 17:24:18 +00:00
public:
2026-05-18 19:07:41 +02:00
explicit EmuWindow_SDL3(InputCommon::InputSubsystem* input_subsystem_, Core::System& system_);
~EmuWindow_SDL3();
2016-03-01 17:24:18 +00:00
/// Whether the window is still open, and a close request hasn't yet been sent
bool IsOpen() const;
2020-01-21 16:40:53 -03:00
/// Returns if window is shown (not minimized)
bool IsShown() const override;
/// Wait for the next event on the main thread.
void OnEvent(SDL_Event& event);
// Sets the window icon from yuzu.bmp
void SetWindowIcon();
protected:
/// Called by WaitEvent when a key is pressed or released.
2016-03-01 17:24:18 +00:00
void OnKeyEvent(int key, u8 state);
2021-02-23 20:39:02 -06:00
/// Converts a SDL mouse button into MouseInput mouse button
2021-09-20 19:40:00 -05:00
InputCommon::MouseButton SDLButtonToMouseButton(u32 button) const;
2021-02-23 20:39:02 -06:00
// Using std::pair<float,float> will invoke HFA miscompilation bug on g++10
// on newer versions it emits an annoying warning, so just not use an HFA
// https://stackoverflow.com/questions/77729813/parameter-passing-for-argument-when-c17-is-enabled-changed-to-match-c14
using FloatPairNonHFA = std::tuple<float, float, char>;
FloatPairNonHFA MouseToTouchPos(s32 touch_x, s32 touch_y) const;
2023-02-04 10:31:12 -06:00
/// Called by WaitEvent when a mouse button is pressed or released
2016-03-01 17:24:18 +00:00
void OnMouseButton(u32 button, u8 state, s32 x, s32 y);
2023-02-04 10:31:12 -06:00
/// Called by WaitEvent when the mouse moves.
void OnMouseMotion(s32 x, s32 y);
2018-10-01 22:42:49 +03:00
/// Called by WaitEvent when a finger starts touching the touchscreen
2021-09-20 19:40:00 -05:00
void OnFingerDown(float x, float y, std::size_t id);
2018-10-01 22:42:49 +03:00
/// Called by WaitEvent when a finger moves while touching the touchscreen
2021-09-20 19:40:00 -05:00
void OnFingerMotion(float x, float y, std::size_t id);
2018-10-01 22:42:49 +03:00
/// Called by WaitEvent when a finger stops touching the touchscreen
2018-10-01 22:42:49 +03:00
void OnFingerUp();
/// Called by WaitEvent when any event that may cause the window to be resized occurs
2016-03-01 17:24:18 +00:00
void OnResize();
2021-08-01 21:46:13 +02:00
/// Called when users want to hide the mouse cursor
void ShowCursor(bool show_cursor);
/// Called when user passes the fullscreen parameter flag
void Fullscreen();
2016-03-01 17:24:18 +00:00
/// Called when a configuration change affects the minimal size of the window
2021-04-23 11:17:33 -04:00
void OnMinimalClientAreaChangeRequest(std::pair<u32, u32> minimal_size) override;
2016-03-01 17:24:18 +00:00
/// Periodic changer of titlebar (independent of event loop)
SDL_TimerID titlebar_timer;
2016-03-01 17:24:18 +00:00
/// Is the window still open?
bool is_open = true;
/// Is the window being shown?
bool is_shown = true;
2026-05-18 19:07:41 +02:00
/// Internal SDL3 render window
SDL_Window* render_window{};
2019-09-22 15:40:57 +02:00
2020-08-27 15:16:47 -04:00
/// Input subsystem to use with this window.
InputCommon::InputSubsystem* input_subsystem;
2021-07-30 10:43:58 -04:00
/// yuzu core instance
Core::System& system;
2016-03-01 17:24:18 +00:00
};
2022-11-27 20:37:37 -05:00
class DummyContext : public Core::Frontend::GraphicsContext {};