shadPS4/src/sdl_window.h
Dmugetsu ae2c9a745e
Gui: Adding Pause button working, full screen button and labels to buttons on main window gui (#2634)
* Adding names to gui buttoms and adjusting spacing.

* moving refresh button to last slot.

* Changing the implementation to tooltips for hover over them - qstring to detect background color.

* Fixing some themes with inverted tooltip base

* Suggestions / Fixes - Pause and FullScreen Buttons

* Update REUSE.toml

* cleaning up

* Icons stuff

* clang

* Buttons toggle - Cleaning code - Fixing Icons

* cleaning boolean

* Toggle pause and play icons and label to "Resume" when paused.

* Simplifying the toggles.

* New icons and final Push to review

* Reuse

* Icon rename, adding f9 press for pause game when no gui is on without needed of debug menu

* clang + reuse

* clang dosent work on this part

* again Clang

* Last fix for review. Light theme white resume icon fix.

* Proper fix for Resume icon

* New Rebase

* Fixed Orientation with docking issues and cleaning boxlayout code

* Adding spacer to separate actions, sizeslider on top of search bar. And adding margins

* Fixed Background not showing on OLED Theme

* Fixing check marks

* Adding all Daniel Suggestions and fixed F9 not working with debug menu open.

* Clang

* reverting all OLED theme changes

* Final suggestions
2025-03-26 23:50:52 +02:00

113 lines
2.6 KiB
C++

// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "common/types.h"
#include "core/libraries/pad/pad.h"
#include "input/controller.h"
#include "string"
#define SDL_EVENT_TOGGLE_FULLSCREEN (SDL_EVENT_USER + 1)
#define SDL_EVENT_TOGGLE_PAUSE (SDL_EVENT_USER + 2)
struct SDL_Window;
struct SDL_Gamepad;
union SDL_Event;
namespace Input {
class SDLInputEngine : public Engine {
public:
~SDLInputEngine() override;
void Init() override;
void SetLightBarRGB(u8 r, u8 g, u8 b) override;
void SetVibration(u8 smallMotor, u8 largeMotor) override;
float GetGyroPollRate() const override;
float GetAccelPollRate() const override;
State ReadState() override;
private:
SDL_Gamepad* m_gamepad = nullptr;
float m_gyro_poll_rate = 0.0f;
float m_accel_poll_rate = 0.0f;
};
} // namespace Input
namespace Frontend {
enum class WindowSystemType : u8 {
Headless,
Windows,
X11,
Wayland,
Metal,
};
struct WindowSystemInfo {
// Connection to a display server. This is used on X11 and Wayland platforms.
void* display_connection = nullptr;
// Render surface. This is a pointer to the native window handle, which depends
// on the platform. e.g. HWND for Windows, Window for X11. If the surface is
// set to nullptr, the video backend will run in headless mode.
void* render_surface = nullptr;
// Scale of the render surface. For hidpi systems, this will be >1.
float render_surface_scale = 1.0f;
// Window system type. Determines which GL context or Vulkan WSI is used.
WindowSystemType type = WindowSystemType::Headless;
};
class WindowSDL {
int keyboard_grab = 0;
public:
explicit WindowSDL(s32 width, s32 height, Input::GameController* controller,
std::string_view window_title);
~WindowSDL();
s32 GetWidth() const {
return width;
}
s32 GetHeight() const {
return height;
}
bool IsOpen() const {
return is_open;
}
[[nodiscard]] SDL_Window* GetSDLWindow() const {
return window;
}
WindowSystemInfo GetWindowInfo() const {
return window_info;
}
void WaitEvent();
void InitTimers();
void RequestKeyboard();
void ReleaseKeyboard();
private:
void OnResize();
void OnKeyboardMouseInput(const SDL_Event* event);
void OnGamepadEvent(const SDL_Event* event);
private:
s32 width;
s32 height;
Input::GameController* controller;
WindowSystemInfo window_info{};
SDL_Window* window{};
bool is_shown{};
bool is_open{true};
};
} // namespace Frontend