4f24343f32
change TouchToPixelPos to return std::pair<int, int> static_cast (SDL) various minor style and code improvements style - PascalCase for function names made touch events private const pointer arg in touch events make TouchToPixelPos a const member function did I do this right? braces on barely-multiline if remove question comment (confirmed in Discord) fixed consts remove unused parameter from TouchEndEvent DRY - High-DPI scaled touch put in separate function also fixes a bug where if you start touching (with either mouse or touchscreen) and drag the mouse to the LEFT of the emulator window, the touch point jumps to the RIGHT side of the touchscreen; draggin to above the window would make it jump to the bottom. implicit conversion from QPoint to QPointF, apparently I have no idea what const even means but I'll put it here anyway remove unused or used-once variables make touch scaling functions const, and put their implementations together removed unused FingerID parameters QTouchEvent forward declaration; add comment to TouchBegin that was lost in an edit better DRY in SDL To do -> TODO(NeatNit) remove unused include
78 lines
2.3 KiB
C++
78 lines
2.3 KiB
C++
// Copyright 2016 Citra Emulator Project
|
|
// Licensed under GPLv2 or any later version
|
|
// Refer to the license.txt file included.
|
|
|
|
#pragma once
|
|
|
|
#include <memory>
|
|
#include <utility>
|
|
#include "core/frontend/emu_window.h"
|
|
|
|
struct SDL_Window;
|
|
|
|
class EmuWindow_SDL2 : public Core::Frontend::EmuWindow {
|
|
public:
|
|
explicit EmuWindow_SDL2(bool fullscreen);
|
|
~EmuWindow_SDL2();
|
|
|
|
/// Swap buffers to display the next frame
|
|
void SwapBuffers() override;
|
|
|
|
/// Polls window events
|
|
void PollEvents() override;
|
|
|
|
/// Makes the graphics context current for the caller thread
|
|
void MakeCurrent() override;
|
|
|
|
/// Releases the GL context from the caller thread
|
|
void DoneCurrent() override;
|
|
|
|
/// Whether the window is still open, and a close request hasn't yet been sent
|
|
bool IsOpen() const;
|
|
|
|
private:
|
|
/// 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);
|
|
|
|
/// 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();
|
|
|
|
/// Called by PollEvents when any event that may cause the window to be resized occurs
|
|
void OnResize();
|
|
|
|
/// Called when user passes the fullscreen parameter flag
|
|
void Fullscreen();
|
|
|
|
/// Whether the GPU and driver supports the OpenGL extension required
|
|
bool SupportsRequiredGLExtensions();
|
|
|
|
/// Called when a configuration change affects the minimal size of the window
|
|
void OnMinimalClientAreaChangeRequest(
|
|
const std::pair<unsigned, unsigned>& minimal_size) override;
|
|
|
|
/// Is the window still open?
|
|
bool is_open = true;
|
|
|
|
/// Internal SDL2 render window
|
|
SDL_Window* render_window;
|
|
|
|
using SDL_GLContext = void*;
|
|
/// The OpenGL context associated with the window
|
|
SDL_GLContext gl_context;
|
|
};
|