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

94 lines
2.8 KiB
C++
Raw Normal View History

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 <utility>
2016-12-23 13:37:40 +00:00
#include "core/frontend/emu_window.h"
2016-03-01 17:24:18 +00:00
struct SDL_Window;
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
2018-08-11 20:20:19 -04:00
class EmuWindow_SDL2 : public Core::Frontend::EmuWindow {
2016-03-01 17:24:18 +00:00
public:
2022-06-13 15:41:36 -04:00
explicit EmuWindow_SDL2(InputCommon::InputSubsystem* input_subsystem_, Core::System& system_);
2016-03-01 17:24:18 +00:00
~EmuWindow_SDL2();
/// 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 WaitEvent();
// 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);
/// Called by WaitEvent when the mouse moves.
2016-03-01 17:24:18 +00:00
void OnMouseMotion(s32 x, s32 y);
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
/// 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);
2018-10-01 22:42:49 +03:00
/// Translates pixel position (0..1) to pixel positions
std::pair<unsigned, unsigned> TouchToPixelPos(float touch_x, float touch_y) const;
/// 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
/// Is the window still open?
bool is_open = true;
/// Is the window being shown?
bool is_shown = true;
2016-03-01 17:24:18 +00:00
/// Internal SDL2 render window
SDL_Window* render_window{};
2019-09-22 15:40:57 +02:00
/// Keeps track of how often to update the title bar during gameplay
u32 last_time = 0;
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 {};