Some cleanup around input_state

This commit is contained in:
Henrik Rydgard 2016-01-01 12:50:38 +01:00
parent 03aa820c28
commit 3398288bd0
9 changed files with 46 additions and 39 deletions

View File

@ -56,11 +56,7 @@ static double lastActivity = 0.0;
static double lastKeepAwake = 0.0;
static GraphicsContext *graphicsContext;
#ifdef _WIN32
InputState input_state;
#else
extern InputState input_state;
#endif
void Core_NotifyWindowHidden(bool hidden) {
windowHidden = hidden;

View File

@ -4,7 +4,9 @@
#include "base/NativeApp.h"
#include "base/mutex.h"
#include "i18n/i18n.h"
#include "input/input_state.h"
#include "util/text/utf8.h"
#include "Common/Log.h"
#include "Common/StringUtils.h"
#include "../Globals.h"
@ -29,6 +31,8 @@ static recursive_mutex emuThreadLock;
static HANDLE emuThread;
static volatile long emuThreadReady;
InputState input_state;
extern std::vector<std::wstring> GetWideCmdLine();
enum EmuThreadStatus : long

View File

@ -1,6 +1,5 @@
#include "Common/CommonWindows.h"
#include <d3d9.h>
#include <DxErr.h>
#include "GPU/Directx9/helper/global.h"
#include "GPU/Directx9/helper/dx_fbo.h"
@ -16,20 +15,6 @@
#include "thin3d/thin3d.h"
#include "thin3d/d3dx9_loader.h"
// TODO: Move these into the context class.
static bool has9Ex = false;
static LPDIRECT3D9 d3d;
static LPDIRECT3D9EX d3dEx;
static int adapterId;
static LPDIRECT3DDEVICE9 device;
static LPDIRECT3DDEVICE9EX deviceEx;
static HDC hDC; // Private GDI Device Context
static HGLRC hRC; // Permanent Rendering Context
static HWND hWnd; // Holds Our Window Handle
static D3DPRESENT_PARAMETERS pp;
static HMODULE hD3D9;
void D3D9Context::SwapBuffers() {
if (has9Ex) {
deviceEx->EndScene();
@ -56,7 +41,7 @@ bool IsWin7OrLater() {
return (major > 6) || ((major == 6) && (minor >= 1));
}
static void GetRes(int &xres, int &yres) {
static void GetRes(HWND hWnd, int &xres, int &yres) {
RECT rc;
GetClientRect(hWnd, &rc);
xres = rc.right - rc.left;
@ -143,7 +128,7 @@ bool D3D9Context::Init(HINSTANCE hInst, HWND wnd, std::string *error_message) {
dwBehaviorFlags |= D3DCREATE_SOFTWARE_VERTEXPROCESSING;
int xres, yres;
GetRes(xres, yres);
GetRes(hWnd, xres, yres);
memset(&pp, 0, sizeof(pp));
pp.BackBufferWidth = xres;
@ -206,7 +191,7 @@ void D3D9Context::Resize() {
// This should only be called from the emu thread.
int xres, yres;
GetRes(xres, yres);
GetRes(hWnd, xres, yres);
bool w_changed = pp.BackBufferWidth != xres;
bool h_changed = pp.BackBufferHeight != yres;

View File

@ -4,11 +4,16 @@
#include "Common/CommonWindows.h"
#include "Windows/GPU/WindowsGraphicsContext.h"
#include <d3d9.h>
class Thin3DContext;
class D3D9Context : public WindowsGraphicsContext {
public:
D3D9Context() : has9Ex(false), d3d(nullptr), d3dEx(nullptr), adapterId(-1), device(nullptr), deviceEx(nullptr), hDC(nullptr), hRC(nullptr), hWnd(nullptr), hD3D9(nullptr) {
memset(&pp, 0, sizeof(pp));
}
bool Init(HINSTANCE hInst, HWND window, std::string *error_message) override;
void Shutdown() override;
void SwapInterval(int interval) override;
@ -17,5 +22,18 @@ public:
void Resize() override;
Thin3DContext *CreateThin3DContext() override;
private:
bool has9Ex;
LPDIRECT3D9 d3d;
LPDIRECT3D9EX d3dEx;
int adapterId;
LPDIRECT3DDEVICE9 device;
LPDIRECT3DDEVICE9EX deviceEx;
HDC hDC; // Private GDI Device Context
HGLRC hRC; // Permanent Rendering Context
HWND hWnd; // Holds Our Window Handle
HMODULE hD3D9;
D3DPRESENT_PARAMETERS pp;
};

View File

@ -31,16 +31,6 @@
#include "Windows/W32Util/Misc.h"
#include "Windows/GPU/WindowsGLContext.h"
static HDC hDC; // Private GDI Device Context
static HGLRC hRC; // Permanent Rendering Context
static HWND hWnd; // Holds Our Window Handle
static volatile bool pauseRequested;
static volatile bool resumeRequested;
static HANDLE pauseEvent;
static HANDLE resumeEvent;
static int xres, yres;
void WindowsGLContext::SwapBuffers() {
::SwapBuffers(hDC);

View File

@ -20,4 +20,15 @@ public:
void Resize() override;
Thin3DContext *CreateThin3DContext() override;
private:
HDC hDC; // Private GDI Device Context
HGLRC hRC; // Permanent Rendering Context
HWND hWnd; // Holds Our Window Handle
volatile bool pauseRequested;
volatile bool resumeRequested;
HANDLE pauseEvent;
HANDLE resumeEvent;
int xres, yres;
};

View File

@ -87,6 +87,7 @@ bool AndroidEGLGraphicsContext::Init(ANativeWindow *wnd, int backbufferWidth, in
return false;
}
gl->MakeCurrent();
return true;
}
void AndroidEGLGraphicsContext::Shutdown() {
@ -134,10 +135,10 @@ static int desiredBackbufferSizeY;
static jmethodID postCommand;
static jobject nativeActivity;
static volatile bool exitRenderLoop;
bool renderLoopRunning;
static bool renderLoopRunning;
float dp_xscale = 1.0f;
float dp_yscale = 1.0f;
static float dp_xscale = 1.0f;
static float dp_yscale = 1.0f;
InputState input_state;

View File

@ -83,9 +83,7 @@ bool System_InputBoxGetWString(const wchar_t *title, const std::wstring &default
void System_AskForPermission(SystemPermission permission) {}
PermissionStatus System_GetPermissionStatus(SystemPermission permission) { return PERMISSION_STATUS_GRANTED; }
#ifndef _WIN32
InputState input_state;
#endif
int printUsage(const char *progname, const char *reason)
{

View File

@ -33,11 +33,13 @@
#include "base/NativeApp.h"
#include "base/logging.h"
#include "Common/CPUDetect.h"
#include "Common/ArmEmitter.h"
#include "input/input_state.h"
#include "ext/disarm.h"
#include "math/math_util.h"
#include "util/text/parsers.h"
#include "Common/CPUDetect.h"
#include "Common/ArmEmitter.h"
#include "Core/Config.h"
#include "Core/MIPS/MIPSVFPUUtils.h"
#include "Core/FileSystems/ISOFileSystem.h"
@ -46,6 +48,8 @@
#include "unittest/TestVertexJit.h"
#include "unittest/UnitTest.h"
InputState input_state;
std::string System_GetProperty(SystemProperty prop) { return ""; }
int System_GetPropertyInt(SystemProperty prop) { return -1; }
void NativeMessageReceived(const char *message, const char *value) {}