mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-26 03:55:37 +00:00
Contains: - replacing a whole lot of things that were just a global with a 4 long array global - implementing sceUserServiceGetEvent to handle users connecting/disconnecting (only half done, currently you need to specify the number of players from config - Even more shit added to remapping, this time a new field denoting the controller ID for the input or output (for inputs it only concerns gamepads, as those are the only ones that you can connect more than one of) - reverts ngoquang's engine, as it's currently unused, and I didn't want to deal with yet another system that had to be updated
97 lines
2.2 KiB
C++
97 lines
2.2 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 GameController;
|
|
}
|
|
|
|
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::GameControllers* controllers,
|
|
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::GameControllers controllers{};
|
|
WindowSystemInfo window_info{};
|
|
SDL_Window* window{};
|
|
bool is_shown{};
|
|
bool is_open{true};
|
|
};
|
|
|
|
} // namespace Frontend
|