2016-03-01 17:24:18 +00:00
|
|
|
// Copyright 2016 Citra Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2016-12-11 21:32:41 +00:00
|
|
|
#include <memory>
|
2016-03-01 17:24:18 +00:00
|
|
|
#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;
|
|
|
|
|
2020-02-17 20:35:14 +00:00
|
|
|
namespace Core {
|
|
|
|
class System;
|
|
|
|
}
|
|
|
|
|
2020-08-27 19:16:47 +00:00
|
|
|
namespace InputCommon {
|
|
|
|
class InputSubsystem;
|
|
|
|
}
|
|
|
|
|
2018-08-12 00:20:19 +00:00
|
|
|
class EmuWindow_SDL2 : public Core::Frontend::EmuWindow {
|
2016-03-01 17:24:18 +00:00
|
|
|
public:
|
2020-08-27 19:16:47 +00:00
|
|
|
explicit EmuWindow_SDL2(Core::System& system, bool fullscreen,
|
|
|
|
InputCommon::InputSubsystem* input_subsystem);
|
2016-03-01 17:24:18 +00:00
|
|
|
~EmuWindow_SDL2();
|
|
|
|
|
|
|
|
/// Polls window events
|
|
|
|
void PollEvents() override;
|
|
|
|
|
|
|
|
/// Whether the window is still open, and a close request hasn't yet been sent
|
|
|
|
bool IsOpen() const;
|
|
|
|
|
2020-01-21 19:40:53 +00:00
|
|
|
/// Returns if window is shown (not minimized)
|
|
|
|
bool IsShown() const override;
|
|
|
|
|
2020-02-17 20:35:14 +00:00
|
|
|
/// Presents the next frame
|
|
|
|
virtual void Present() = 0;
|
|
|
|
|
2019-05-25 20:47:13 +00:00
|
|
|
protected:
|
2016-03-01 17:24:18 +00:00
|
|
|
/// Called by PollEvents when a key is pressed or released.
|
|
|
|
void OnKeyEvent(int key, u8 state);
|
|
|
|
|
|
|
|
/// Called by PollEvents when the mouse moves.
|
|
|
|
void OnMouseMotion(s32 x, s32 y);
|
|
|
|
|
|
|
|
/// Called by PollEvents when a mouse button is pressed or released
|
|
|
|
void OnMouseButton(u32 button, u8 state, s32 x, s32 y);
|
|
|
|
|
2018-10-01 19:42:49 +00:00
|
|
|
/// 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();
|
|
|
|
|
2016-03-01 17:24:18 +00:00
|
|
|
/// Called by PollEvents when any event that may cause the window to be resized occurs
|
|
|
|
void OnResize();
|
|
|
|
|
2018-04-21 07:52:34 +00:00
|
|
|
/// 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
|
2019-05-25 20:50:20 +00:00
|
|
|
void OnMinimalClientAreaChangeRequest(std::pair<unsigned, unsigned> minimal_size) override;
|
2016-03-01 17:24:18 +00:00
|
|
|
|
2020-02-17 20:35:14 +00:00
|
|
|
/// Instance of the system, used to access renderer for the presentation thread
|
|
|
|
Core::System& system;
|
|
|
|
|
2016-03-01 17:24:18 +00:00
|
|
|
/// Is the window still open?
|
|
|
|
bool is_open = true;
|
|
|
|
|
2019-05-25 20:47:13 +00:00
|
|
|
/// Is the window being shown?
|
|
|
|
bool is_shown = true;
|
|
|
|
|
2016-03-01 17:24:18 +00:00
|
|
|
/// Internal SDL2 render window
|
2020-02-17 20:35:14 +00:00
|
|
|
SDL_Window* render_window{};
|
2019-09-22 13:40:57 +00:00
|
|
|
|
|
|
|
/// Keeps track of how often to update the title bar during gameplay
|
|
|
|
u32 last_time = 0;
|
2020-08-27 19:16:47 +00:00
|
|
|
|
|
|
|
/// Input subsystem to use with this window.
|
|
|
|
InputCommon::InputSubsystem* input_subsystem;
|
2016-03-01 17:24:18 +00:00
|
|
|
};
|