2012-11-01 15:19:01 +00:00
|
|
|
// NOTE: Apologies for the quality of this code, this is really from pre-opensource Dolphin - that is, 2003.
|
|
|
|
|
|
|
|
#include <windows.h>
|
2012-11-17 22:44:29 +00:00
|
|
|
#include <tchar.h>
|
2013-03-29 17:50:08 +00:00
|
|
|
|
|
|
|
#include "base/NativeApp.h"
|
2013-03-11 21:55:29 +00:00
|
|
|
#include "Globals.h"
|
2012-11-01 15:19:01 +00:00
|
|
|
|
|
|
|
#include "shellapi.h"
|
|
|
|
#include "commctrl.h"
|
|
|
|
|
2013-03-29 17:50:08 +00:00
|
|
|
#include "input/input_state.h"
|
2013-03-11 21:55:29 +00:00
|
|
|
#include "Core/Debugger/SymbolMap.h"
|
|
|
|
#include "Windows/OpenGLBase.h"
|
|
|
|
#include "Windows/Debugger/Debugger_Disasm.h"
|
|
|
|
#include "Windows/Debugger/Debugger_MemoryDlg.h"
|
2012-11-01 15:19:01 +00:00
|
|
|
#include "main.h"
|
|
|
|
|
2013-03-11 21:55:29 +00:00
|
|
|
#include "Core/Core.h"
|
|
|
|
#include "Core/MemMap.h"
|
|
|
|
#include "Core/SaveState.h"
|
|
|
|
#include "Core/System.h"
|
|
|
|
#include "Core/Config.h"
|
|
|
|
#include "Windows/EmuThread.h"
|
2012-11-01 15:19:01 +00:00
|
|
|
|
|
|
|
#include "resource.h"
|
|
|
|
|
2013-03-11 21:55:29 +00:00
|
|
|
#include "Windows/WndMainWindow.h"
|
|
|
|
#include "Common/LogManager.h"
|
|
|
|
#include "Common/ConsoleListener.h"
|
|
|
|
#include "Windows/W32Util/DialogManager.h"
|
|
|
|
#include "Windows/W32Util/ShellUtil.h"
|
|
|
|
#include "Windows/W32Util/Misc.h"
|
|
|
|
#include "GPU/GPUInterface.h"
|
|
|
|
#include "GPU/GPUState.h"
|
2013-04-19 09:21:16 +00:00
|
|
|
#include "native/image/png_load.h"
|
2013-05-01 21:55:34 +00:00
|
|
|
#include "GPU/GLES/TextureScaler.h"
|
2013-05-17 10:31:06 +00:00
|
|
|
#include "ControlMapping.h"
|
2013-05-22 16:00:06 +00:00
|
|
|
#include "UI/OnScreenDisplay.h"
|
|
|
|
#include "i18n/i18n.h"
|
2012-11-01 15:19:01 +00:00
|
|
|
|
|
|
|
#ifdef THEMES
|
|
|
|
#include "XPTheme.h"
|
|
|
|
#endif
|
|
|
|
|
2013-04-16 19:12:55 +00:00
|
|
|
#define ENABLE_TOUCH 0
|
|
|
|
|
2013-05-04 21:21:06 +00:00
|
|
|
BOOL g_bFullScreen = FALSE;
|
2013-03-29 20:21:27 +00:00
|
|
|
static RECT g_normalRC = {0};
|
2012-12-05 06:31:41 +00:00
|
|
|
|
2013-03-29 17:50:08 +00:00
|
|
|
extern InputState input_state;
|
2013-05-17 10:31:06 +00:00
|
|
|
extern const char * getVirtualKeyName(unsigned char key);
|
|
|
|
extern const char * getXinputButtonName(unsigned int button);
|
2013-05-04 21:21:06 +00:00
|
|
|
#define TIMER_CURSORUPDATE 1
|
2013-05-04 21:54:22 +00:00
|
|
|
#define CURSORUPDATE_INTERVAL_MS 50
|
2013-04-18 09:13:00 +00:00
|
|
|
|
2012-11-01 15:19:01 +00:00
|
|
|
namespace MainWindow
|
|
|
|
{
|
|
|
|
HWND hwndMain;
|
|
|
|
HWND hwndDisplay;
|
|
|
|
HWND hwndGameList;
|
2013-03-29 20:21:27 +00:00
|
|
|
static HMENU menu;
|
2012-11-01 15:19:01 +00:00
|
|
|
|
2013-03-29 20:21:27 +00:00
|
|
|
static HINSTANCE hInst;
|
2012-11-01 15:19:01 +00:00
|
|
|
|
|
|
|
//W32Util::LayeredWindow *layer;
|
|
|
|
#define MAX_LOADSTRING 100
|
2013-03-29 20:21:27 +00:00
|
|
|
const TCHAR *szTitle = TEXT("PPSSPP");
|
|
|
|
const TCHAR *szWindowClass = TEXT("PPSSPPWnd");
|
|
|
|
const TCHAR *szDisplayClass = TEXT("PPSSPPDisplay");
|
2012-11-01 15:19:01 +00:00
|
|
|
|
2013-03-17 13:46:39 +00:00
|
|
|
// Forward declarations of functions included in this code module:
|
2012-11-01 15:19:01 +00:00
|
|
|
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
|
|
|
|
LRESULT CALLBACK DisplayProc(HWND, UINT, WPARAM, LPARAM);
|
|
|
|
LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM);
|
2013-01-02 21:57:57 +00:00
|
|
|
LRESULT CALLBACK Controls(HWND, UINT, WPARAM, LPARAM);
|
2012-11-01 15:19:01 +00:00
|
|
|
|
|
|
|
HWND GetHWND()
|
|
|
|
{
|
|
|
|
return hwndMain;
|
|
|
|
}
|
|
|
|
|
|
|
|
HWND GetDisplayHWND()
|
|
|
|
{
|
|
|
|
return hwndDisplay;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Init(HINSTANCE hInstance)
|
|
|
|
{
|
2013-02-19 00:28:13 +00:00
|
|
|
#ifdef THEMES
|
|
|
|
WTL::CTheme::IsThemingSupported();
|
2012-11-01 15:19:01 +00:00
|
|
|
#endif
|
|
|
|
//Register classes
|
|
|
|
WNDCLASSEX wcex;
|
|
|
|
wcex.cbSize = sizeof(WNDCLASSEX);
|
|
|
|
wcex.style = CS_HREDRAW | CS_VREDRAW;
|
|
|
|
wcex.lpfnWndProc = (WNDPROC)WndProc;
|
|
|
|
wcex.cbClsExtra = 0;
|
|
|
|
wcex.cbWndExtra = 0;
|
|
|
|
wcex.hInstance = hInstance;
|
|
|
|
wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_PPSSPP);
|
|
|
|
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
|
2012-12-05 06:31:41 +00:00
|
|
|
wcex.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
|
2012-11-01 15:19:01 +00:00
|
|
|
wcex.lpszMenuName = (LPCSTR)IDR_MENU1;
|
|
|
|
wcex.lpszClassName = szWindowClass;
|
|
|
|
wcex.hIconSm = (HICON)LoadImage(hInstance, (LPCTSTR)IDI_PPSSPP, IMAGE_ICON, 16,16,LR_SHARED);
|
|
|
|
RegisterClassEx(&wcex);
|
|
|
|
|
|
|
|
wcex.style = CS_HREDRAW | CS_VREDRAW;;
|
|
|
|
wcex.lpfnWndProc = (WNDPROC)DisplayProc;
|
|
|
|
wcex.hIcon = 0;
|
|
|
|
wcex.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
|
|
|
|
wcex.lpszMenuName = 0;
|
|
|
|
wcex.lpszClassName = szDisplayClass;
|
|
|
|
wcex.hIconSm = 0;
|
|
|
|
RegisterClassEx(&wcex);
|
|
|
|
}
|
|
|
|
|
2012-11-17 16:46:05 +00:00
|
|
|
void GetWindowRectAtZoom(int zoom, RECT &rcInner, RECT &rcOuter) {
|
2013-01-26 22:46:02 +00:00
|
|
|
// GetWindowRect(hwndMain, &rcInner);
|
2013-03-30 23:25:10 +00:00
|
|
|
rcInner.left = 0;
|
|
|
|
rcInner.top = 0;
|
2012-11-01 15:19:01 +00:00
|
|
|
|
2013-03-30 23:25:10 +00:00
|
|
|
rcInner.right=480*zoom;//+client edge
|
|
|
|
rcInner.bottom=272*zoom; //+client edge
|
2012-11-01 15:19:01 +00:00
|
|
|
|
2012-11-17 16:46:05 +00:00
|
|
|
rcOuter=rcInner;
|
|
|
|
AdjustWindowRect(&rcOuter, WS_OVERLAPPEDWINDOW, TRUE);
|
2013-03-30 23:25:10 +00:00
|
|
|
rcOuter.right += g_Config.iWindowX - rcOuter.left;
|
|
|
|
rcOuter.bottom += g_Config.iWindowY - rcOuter.top;
|
|
|
|
rcOuter.left = g_Config.iWindowX;
|
|
|
|
rcOuter.top = g_Config.iWindowY;
|
2012-11-17 16:46:05 +00:00
|
|
|
}
|
|
|
|
|
2013-03-30 16:49:02 +00:00
|
|
|
void SavePosition() {
|
|
|
|
WINDOWPLACEMENT placement;
|
|
|
|
GetWindowPlacement(hwndMain, &placement);
|
|
|
|
if (placement.showCmd == SW_SHOWNORMAL) {
|
|
|
|
RECT rc;
|
|
|
|
GetWindowRect(hwndMain, &rc);
|
|
|
|
g_Config.iWindowX = rc.left;
|
|
|
|
g_Config.iWindowY = rc.top;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-11 18:02:38 +00:00
|
|
|
void ResizeDisplay(bool noWindowMovement = false) {
|
2013-01-26 22:46:02 +00:00
|
|
|
RECT rc;
|
|
|
|
GetClientRect(hwndMain, &rc);
|
2013-02-11 18:02:38 +00:00
|
|
|
if (!noWindowMovement) {
|
|
|
|
|
|
|
|
if ((rc.right - rc.left) == PSP_CoreParameter().pixelWidth &&
|
|
|
|
(rc.bottom - rc.top) == PSP_CoreParameter().pixelHeight)
|
|
|
|
return;
|
|
|
|
PSP_CoreParameter().pixelWidth = rc.right - rc.left;
|
|
|
|
PSP_CoreParameter().pixelHeight = rc.bottom - rc.top;
|
|
|
|
MoveWindow(hwndDisplay, 0, 0, PSP_CoreParameter().pixelWidth, PSP_CoreParameter().pixelHeight, TRUE);
|
|
|
|
}
|
2013-01-26 23:15:39 +00:00
|
|
|
|
|
|
|
// round up to a zoom factor for the render size.
|
|
|
|
int zoom = (rc.right - rc.left + 479) / 480;
|
|
|
|
if (g_Config.SSAntiAliasing) zoom *= 2;
|
|
|
|
PSP_CoreParameter().renderWidth = 480 * zoom;
|
|
|
|
PSP_CoreParameter().renderHeight = 272 * zoom;
|
|
|
|
PSP_CoreParameter().outputWidth = 480 * zoom;
|
|
|
|
PSP_CoreParameter().outputHeight = 272 * zoom;
|
|
|
|
|
|
|
|
if (gpu)
|
|
|
|
gpu->Resized();
|
2013-01-26 22:46:02 +00:00
|
|
|
}
|
|
|
|
|
2012-12-21 15:49:02 +00:00
|
|
|
void SetZoom(float zoom) {
|
|
|
|
if (zoom < 5)
|
2012-12-21 23:41:09 +00:00
|
|
|
g_Config.iWindowZoom = (int) zoom;
|
2012-11-17 16:46:05 +00:00
|
|
|
RECT rc, rcOuter;
|
2012-12-21 23:41:09 +00:00
|
|
|
GetWindowRectAtZoom((int) zoom, rc, rcOuter);
|
2012-11-17 16:46:05 +00:00
|
|
|
MoveWindow(hwndMain, rcOuter.left, rcOuter.top, rcOuter.right - rcOuter.left, rcOuter.bottom - rcOuter.top, TRUE);
|
2013-01-26 22:46:02 +00:00
|
|
|
ResizeDisplay();
|
2012-11-01 15:19:01 +00:00
|
|
|
}
|
|
|
|
|
2013-05-01 21:55:34 +00:00
|
|
|
void setTexScalingLevel(int num) {
|
|
|
|
g_Config.iTexScalingLevel = num;
|
|
|
|
if(gpu) gpu->ClearCacheNextFrame();
|
|
|
|
}
|
|
|
|
void setTexScalingType(int num) {
|
|
|
|
g_Config.iTexScalingType = num;
|
2013-04-30 15:20:28 +00:00
|
|
|
if(gpu) gpu->ClearCacheNextFrame();
|
2013-04-30 01:47:33 +00:00
|
|
|
}
|
2013-05-10 00:36:23 +00:00
|
|
|
void setFpsLimit(int fps) {
|
|
|
|
g_Config.iFpsLimit = fps;
|
|
|
|
}
|
2013-04-30 01:47:33 +00:00
|
|
|
|
2012-11-01 15:19:01 +00:00
|
|
|
BOOL Show(HINSTANCE hInstance, int nCmdShow)
|
|
|
|
{
|
|
|
|
hInst = hInstance; // Store instance handle in our global variable
|
|
|
|
|
2012-11-17 16:46:05 +00:00
|
|
|
int zoom = g_Config.iWindowZoom;
|
|
|
|
if (zoom < 1) zoom = 1;
|
|
|
|
if (zoom > 4) zoom = 4;
|
|
|
|
|
2012-11-01 15:19:01 +00:00
|
|
|
RECT rc,rcOrig;
|
2012-11-17 16:46:05 +00:00
|
|
|
GetWindowRectAtZoom(zoom, rcOrig, rc);
|
2012-11-01 15:19:01 +00:00
|
|
|
|
2013-03-29 20:21:27 +00:00
|
|
|
u32 style = WS_OVERLAPPEDWINDOW;
|
2012-11-01 15:19:01 +00:00
|
|
|
|
|
|
|
hwndMain = CreateWindowEx(0,szWindowClass, "", style,
|
|
|
|
rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, NULL, NULL, hInstance, NULL);
|
2013-05-04 21:21:06 +00:00
|
|
|
SetTimer(hwndMain, TIMER_CURSORUPDATE, CURSORUPDATE_INTERVAL_MS, 0);
|
2012-11-01 15:19:01 +00:00
|
|
|
SetPlaying(0);
|
|
|
|
if (!hwndMain)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
menu = GetMenu(hwndMain);
|
|
|
|
#ifdef FINAL
|
|
|
|
RemoveMenu(menu,2,MF_BYPOSITION);
|
|
|
|
RemoveMenu(menu,2,MF_BYPOSITION);
|
|
|
|
#endif
|
|
|
|
MENUINFO info;
|
|
|
|
ZeroMemory(&info,sizeof(MENUINFO));
|
|
|
|
info.cbSize = sizeof(MENUINFO);
|
|
|
|
info.cyMax = 0;
|
|
|
|
info.dwStyle = MNS_CHECKORBMP;
|
|
|
|
info.fMask = MIM_STYLE;
|
2012-11-23 11:42:35 +00:00
|
|
|
for (int i = 0; i < GetMenuItemCount(menu); i++)
|
2012-11-01 15:19:01 +00:00
|
|
|
{
|
|
|
|
SetMenuInfo(GetSubMenu(menu,i),&info);
|
|
|
|
}
|
|
|
|
|
|
|
|
hwndDisplay = CreateWindowEx(0,szDisplayClass,TEXT(""),
|
|
|
|
WS_CHILD|WS_VISIBLE,
|
|
|
|
0,0,/*rcOrig.left,rcOrig.top,*/rcOrig.right-rcOrig.left,rcOrig.bottom-rcOrig.top,hwndMain,0,hInstance,0);
|
|
|
|
|
|
|
|
ShowWindow(hwndMain, nCmdShow);
|
|
|
|
//accept dragged files
|
|
|
|
DragAcceptFiles(hwndMain, TRUE);
|
|
|
|
|
2013-04-16 19:12:55 +00:00
|
|
|
#if ENABLE_TOUCH
|
|
|
|
RegisterTouchWindow(hwndDisplay, TWF_WANTPALM);
|
|
|
|
#endif
|
|
|
|
|
2012-11-01 15:19:01 +00:00
|
|
|
SetFocus(hwndMain);
|
2013-05-04 21:21:06 +00:00
|
|
|
SetFocus(hwndDisplay);
|
2012-11-01 15:19:01 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2013-03-28 19:26:24 +00:00
|
|
|
void BrowseAndBoot(std::string defaultPath)
|
2012-11-01 15:19:01 +00:00
|
|
|
{
|
2013-03-28 21:31:51 +00:00
|
|
|
std::string fn;
|
2013-05-25 05:45:28 +00:00
|
|
|
std::string filter = "PSP ROMs (*.iso *.cso *.pbp *.elf)|*.pbp;*.elf;*.iso;*.cso;*.prx|All files (*.*)|*.*||";
|
2013-05-24 16:46:20 +00:00
|
|
|
|
2012-11-01 15:19:01 +00:00
|
|
|
for (int i=0; i<(int)filter.length(); i++)
|
|
|
|
{
|
|
|
|
if (filter[i] == '|')
|
|
|
|
filter[i] = '\0';
|
|
|
|
}
|
|
|
|
|
2013-03-29 18:32:20 +00:00
|
|
|
if (W32Util::BrowseForFileName(true, GetHWND(), "Load File", defaultPath.size() ? defaultPath.c_str() : 0, filter.c_str(),"*.pbp;*.elf;*.iso;*.cso;",fn))
|
2012-11-01 15:19:01 +00:00
|
|
|
{
|
|
|
|
// decode the filename with fullpath
|
|
|
|
std::string fullpath = fn;
|
|
|
|
char drive[MAX_PATH];
|
|
|
|
char dir[MAX_PATH];
|
|
|
|
char fname[MAX_PATH];
|
|
|
|
char ext[MAX_PATH];
|
|
|
|
_splitpath(fullpath.c_str(), drive, dir, fname, ext);
|
|
|
|
|
|
|
|
std::string executable = std::string(drive) + std::string(dir) + std::string(fname) + std::string(ext);
|
2013-03-29 18:32:20 +00:00
|
|
|
NativeMessageReceived("boot", executable.c_str());
|
2012-11-01 15:19:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
LRESULT CALLBACK DisplayProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
switch (message)
|
|
|
|
{
|
|
|
|
case WM_ACTIVATE:
|
|
|
|
break;
|
|
|
|
case WM_SETFOCUS:
|
|
|
|
break;
|
|
|
|
case WM_SIZE:
|
|
|
|
break;
|
2013-03-29 18:32:20 +00:00
|
|
|
|
2012-11-01 15:19:01 +00:00
|
|
|
case WM_ERASEBKGND:
|
|
|
|
return DefWindowProc(hWnd, message, wParam, lParam);
|
2013-03-29 18:32:20 +00:00
|
|
|
|
2012-11-01 15:19:01 +00:00
|
|
|
case WM_LBUTTONDOWN:
|
2013-03-29 17:50:08 +00:00
|
|
|
{
|
|
|
|
lock_guard guard(input_state.lock);
|
|
|
|
input_state.mouse_valid = true;
|
|
|
|
input_state.pointer_down[0] = true;
|
|
|
|
input_state.pointer_x[0] = GET_X_LPARAM(lParam);
|
|
|
|
input_state.pointer_y[0] = GET_Y_LPARAM(lParam);
|
2013-04-01 02:15:59 +00:00
|
|
|
|
|
|
|
if (g_Config.iWindowZoom == 1)
|
|
|
|
{
|
|
|
|
input_state.pointer_x[0] *= 2;
|
|
|
|
input_state.pointer_y[0] *= 2;
|
|
|
|
}
|
2013-03-29 17:50:08 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_MOUSEMOVE:
|
|
|
|
{
|
|
|
|
lock_guard guard(input_state.lock);
|
|
|
|
input_state.pointer_x[0] = GET_X_LPARAM(lParam);
|
|
|
|
input_state.pointer_y[0] = GET_Y_LPARAM(lParam);
|
2013-04-01 02:15:59 +00:00
|
|
|
|
|
|
|
if (g_Config.iWindowZoom == 1)
|
|
|
|
{
|
|
|
|
input_state.pointer_x[0] *= 2;
|
|
|
|
input_state.pointer_y[0] *= 2;
|
|
|
|
}
|
2013-03-29 17:50:08 +00:00
|
|
|
}
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
2013-03-29 17:50:08 +00:00
|
|
|
case WM_LBUTTONUP:
|
|
|
|
{
|
|
|
|
lock_guard guard(input_state.lock);
|
|
|
|
input_state.pointer_down[0] = false;
|
|
|
|
input_state.pointer_x[0] = GET_X_LPARAM(lParam);
|
|
|
|
input_state.pointer_y[0] = GET_Y_LPARAM(lParam);
|
2013-04-01 02:15:59 +00:00
|
|
|
|
|
|
|
if (g_Config.iWindowZoom == 1)
|
|
|
|
{
|
|
|
|
input_state.pointer_x[0] *= 2;
|
|
|
|
input_state.pointer_y[0] *= 2;
|
|
|
|
}
|
2013-03-29 17:50:08 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2013-04-16 19:12:55 +00:00
|
|
|
case WM_TOUCH:
|
|
|
|
{
|
|
|
|
// TODO: Enabling this section will probably break things on Windows XP.
|
|
|
|
// We probably need to manually fetch pointers to GetTouchInputInfo and CloseTouchInputHandle.
|
|
|
|
#if ENABLE_TOUCH
|
|
|
|
UINT inputCount = LOWORD(wParam);
|
|
|
|
TOUCHINPUT *inputs = new TOUCHINPUT[inputCount];
|
|
|
|
if (GetTouchInputInfo((HTOUCHINPUT)lParam,
|
|
|
|
inputCount,
|
|
|
|
inputs,
|
|
|
|
sizeof(TOUCHINPUT)))
|
|
|
|
{
|
|
|
|
for (int i = 0; i < inputCount; i++) {
|
|
|
|
// TODO: process inputs here!
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!CloseTouchInputHandle((HTOUCHINPUT)lParam))
|
|
|
|
{
|
|
|
|
// error handling
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// GetLastError() and error handling
|
|
|
|
}
|
|
|
|
delete [] inputs;
|
|
|
|
return DefWindowProc(hWnd, message, wParam, lParam);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-11-01 15:19:01 +00:00
|
|
|
case WM_PAINT:
|
|
|
|
return DefWindowProc(hWnd, message, wParam, lParam);
|
|
|
|
default:
|
|
|
|
return DefWindowProc(hWnd, message, wParam, lParam);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
int wmId, wmEvent;
|
|
|
|
std::string fn;
|
|
|
|
|
2013-05-22 16:00:06 +00:00
|
|
|
I18NCategory *g = GetI18NCategory("Graphics");
|
|
|
|
|
2012-11-01 15:19:01 +00:00
|
|
|
switch (message)
|
|
|
|
{
|
|
|
|
case WM_CREATE:
|
2013-04-18 09:13:00 +00:00
|
|
|
loadControlsFromFile();
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_MOVE:
|
2013-03-30 16:49:02 +00:00
|
|
|
SavePosition();
|
2013-01-26 23:15:39 +00:00
|
|
|
ResizeDisplay();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_SIZE:
|
2013-03-30 16:49:02 +00:00
|
|
|
SavePosition();
|
2013-01-26 23:15:39 +00:00
|
|
|
ResizeDisplay();
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
2013-05-04 21:21:06 +00:00
|
|
|
case WM_TIMER:
|
|
|
|
// Hack: Take the opportunity to also show/hide the mouse cursor in fullscreen mode.
|
|
|
|
if (g_bFullScreen && globalUIState == UISTATE_INGAME) {
|
|
|
|
ShowCursor(FALSE);
|
|
|
|
} else {
|
|
|
|
ShowCursor(TRUE);
|
|
|
|
SetCursor(LoadCursor(NULL, IDC_ARROW));
|
|
|
|
}
|
|
|
|
SetTimer(hWnd, TIMER_CURSORUPDATE, CURSORUPDATE_INTERVAL_MS, 0);
|
|
|
|
return 0;
|
|
|
|
|
2012-11-01 15:19:01 +00:00
|
|
|
case WM_COMMAND:
|
|
|
|
wmId = LOWORD(wParam);
|
|
|
|
wmEvent = HIWORD(wParam);
|
|
|
|
// Parse the menu selections:
|
|
|
|
switch (wmId)
|
|
|
|
{
|
|
|
|
case ID_FILE_LOAD:
|
2013-03-28 19:26:24 +00:00
|
|
|
BrowseAndBoot("");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_FILE_LOAD_MEMSTICK:
|
|
|
|
{
|
|
|
|
std::string memStickDir, flash0dir;
|
|
|
|
GetSysDirectories(memStickDir, flash0dir);
|
2013-03-28 21:31:51 +00:00
|
|
|
memStickDir += "PSP\\GAME\\";
|
2013-03-28 19:26:24 +00:00
|
|
|
BrowseAndBoot(memStickDir);
|
|
|
|
}
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_FILE_REFRESHGAMELIST:
|
|
|
|
break;
|
|
|
|
|
2013-03-28 19:17:45 +00:00
|
|
|
case ID_FILE_MEMSTICK:
|
|
|
|
{
|
|
|
|
std::string memStickDir, flash0dir;
|
|
|
|
GetSysDirectories(memStickDir, flash0dir);
|
|
|
|
ShellExecuteA(NULL, "open", memStickDir.c_str(), 0, 0, SW_SHOW);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2012-11-01 15:19:01 +00:00
|
|
|
case ID_EMULATION_RUN:
|
2013-03-29 19:03:11 +00:00
|
|
|
if (Core_IsStepping()) {
|
|
|
|
Core_EnableStepping(false);
|
|
|
|
} else {
|
|
|
|
NativeMessageReceived("run", "");
|
|
|
|
}
|
2013-03-29 20:21:27 +00:00
|
|
|
if (disasmWindow[0])
|
|
|
|
SendMessage(disasmWindow[0]->GetDlgHandle(), WM_COMMAND, IDC_GO, 0);
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_EMULATION_STOP:
|
2013-04-21 02:54:25 +00:00
|
|
|
if (memoryWindow[0]) {
|
2013-03-29 20:21:27 +00:00
|
|
|
SendMessage(memoryWindow[0]->GetDlgHandle(), WM_CLOSE, 0, 0);
|
2013-04-21 02:54:25 +00:00
|
|
|
}
|
|
|
|
if (disasmWindow[0]) {
|
|
|
|
SendMessage(disasmWindow[0]->GetDlgHandle(), WM_CLOSE, 0, 0);
|
|
|
|
}
|
|
|
|
if (Core_IsStepping()) {
|
|
|
|
Core_EnableStepping(false);
|
|
|
|
}
|
2013-03-29 17:50:08 +00:00
|
|
|
NativeMessageReceived("stop", "");
|
2012-11-01 15:19:01 +00:00
|
|
|
SetPlaying(0);
|
|
|
|
Update();
|
|
|
|
break;
|
|
|
|
|
2013-03-29 19:03:11 +00:00
|
|
|
case ID_EMULATION_PAUSE:
|
|
|
|
if (disasmWindow[0])
|
|
|
|
{
|
|
|
|
SendMessage(disasmWindow[0]->GetDlgHandle(), WM_COMMAND, IDC_STOP, 0);
|
2013-03-29 20:21:27 +00:00
|
|
|
} else if (globalUIState == UISTATE_INGAME) {
|
|
|
|
Core_EnableStepping(true);
|
2013-03-29 19:03:11 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2013-02-03 00:17:35 +00:00
|
|
|
case ID_EMULATION_RESET:
|
2013-03-29 19:51:14 +00:00
|
|
|
NativeMessageReceived("reset", "");
|
2013-02-03 00:17:35 +00:00
|
|
|
break;
|
2012-11-01 15:19:01 +00:00
|
|
|
|
|
|
|
case ID_EMULATION_SPEEDLIMIT:
|
|
|
|
g_Config.bSpeedLimit = !g_Config.bSpeedLimit;
|
|
|
|
break;
|
|
|
|
|
2013-01-02 20:00:10 +00:00
|
|
|
case ID_FILE_LOADSTATEFILE:
|
2012-12-28 22:43:09 +00:00
|
|
|
if (W32Util::BrowseForFileName(true, hWnd, "Load state",0,"Save States (*.ppst)\0*.ppst\0All files\0*.*\0\0","ppst",fn))
|
2012-11-01 15:19:01 +00:00
|
|
|
{
|
|
|
|
SetCursor(LoadCursor(0,IDC_WAIT));
|
2012-12-28 21:50:59 +00:00
|
|
|
SaveState::Load(fn, SaveStateActionFinished);
|
2012-11-01 15:19:01 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2013-01-02 20:00:10 +00:00
|
|
|
case ID_FILE_SAVESTATEFILE:
|
2012-12-28 22:43:09 +00:00
|
|
|
if (W32Util::BrowseForFileName(false, hWnd, "Save state",0,"Save States (*.ppst)\0*.ppst\0All files\0*.*\0\0","ppst",fn))
|
2012-11-01 15:19:01 +00:00
|
|
|
{
|
|
|
|
SetCursor(LoadCursor(0,IDC_WAIT));
|
2012-12-28 21:50:59 +00:00
|
|
|
SaveState::Save(fn, SaveStateActionFinished);
|
2012-11-01 15:19:01 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2013-01-02 20:00:10 +00:00
|
|
|
// TODO: Add UI for multiple slots
|
|
|
|
|
|
|
|
case ID_FILE_QUICKLOADSTATE:
|
|
|
|
SetCursor(LoadCursor(0,IDC_WAIT));
|
|
|
|
SaveState::LoadSlot(0, SaveStateActionFinished);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_FILE_QUICKSAVESTATE:
|
|
|
|
SetCursor(LoadCursor(0,IDC_WAIT));
|
|
|
|
SaveState::SaveSlot(0, SaveStateActionFinished);
|
|
|
|
break;
|
|
|
|
|
2012-11-17 16:46:05 +00:00
|
|
|
case ID_OPTIONS_SCREEN1X:
|
|
|
|
SetZoom(1);
|
|
|
|
break;
|
|
|
|
case ID_OPTIONS_SCREEN2X:
|
|
|
|
SetZoom(2);
|
|
|
|
break;
|
|
|
|
case ID_OPTIONS_SCREEN3X:
|
|
|
|
SetZoom(3);
|
|
|
|
break;
|
|
|
|
case ID_OPTIONS_SCREEN4X:
|
|
|
|
SetZoom(4);
|
|
|
|
break;
|
|
|
|
|
2013-04-17 19:07:41 +00:00
|
|
|
case ID_OPTIONS_MIPMAP:
|
|
|
|
g_Config.bMipMap = !g_Config.bMipMap;
|
|
|
|
break;
|
|
|
|
|
2013-04-30 10:14:34 +00:00
|
|
|
case ID_TEXTURESCALING_OFF:
|
2013-05-01 21:55:34 +00:00
|
|
|
setTexScalingLevel(1);
|
2013-04-30 10:14:34 +00:00
|
|
|
break;
|
2013-05-01 21:55:34 +00:00
|
|
|
case ID_TEXTURESCALING_2X:
|
|
|
|
setTexScalingLevel(2);
|
2013-04-30 01:47:33 +00:00
|
|
|
break;
|
2013-05-01 21:55:34 +00:00
|
|
|
case ID_TEXTURESCALING_3X:
|
|
|
|
setTexScalingLevel(3);
|
2013-04-30 10:14:34 +00:00
|
|
|
break;
|
2013-05-01 21:55:34 +00:00
|
|
|
case ID_TEXTURESCALING_4X:
|
|
|
|
setTexScalingLevel(4);
|
2013-04-30 01:47:33 +00:00
|
|
|
break;
|
2013-05-01 21:55:34 +00:00
|
|
|
case ID_TEXTURESCALING_5X:
|
|
|
|
setTexScalingLevel(5);
|
2013-04-30 01:47:33 +00:00
|
|
|
break;
|
2013-05-01 21:55:34 +00:00
|
|
|
|
|
|
|
case ID_TEXTURESCALING_XBRZ:
|
|
|
|
setTexScalingType(TextureScaler::XBRZ);
|
2013-04-30 01:47:33 +00:00
|
|
|
break;
|
2013-05-01 21:55:34 +00:00
|
|
|
case ID_TEXTURESCALING_HYBRID:
|
|
|
|
setTexScalingType(TextureScaler::HYBRID);
|
2013-04-30 01:47:33 +00:00
|
|
|
break;
|
2013-05-04 23:27:15 +00:00
|
|
|
case ID_TEXTURESCALING_BICUBIC:
|
|
|
|
setTexScalingType(TextureScaler::BICUBIC);
|
|
|
|
break;
|
|
|
|
case ID_TEXTURESCALING_HYBRID_BICUBIC:
|
|
|
|
setTexScalingType(TextureScaler::HYBRID_BICUBIC);
|
|
|
|
break;
|
2013-04-30 01:47:33 +00:00
|
|
|
|
2013-05-03 14:21:46 +00:00
|
|
|
case ID_TEXTURESCALING_DEPOSTERIZE:
|
|
|
|
g_Config.bTexDeposterize = !g_Config.bTexDeposterize;
|
|
|
|
if(gpu) gpu->ClearCacheNextFrame();
|
|
|
|
break;
|
|
|
|
|
2012-11-20 10:35:48 +00:00
|
|
|
case ID_OPTIONS_BUFFEREDRENDERING:
|
|
|
|
g_Config.bBufferedRendering = !g_Config.bBufferedRendering;
|
2013-05-22 16:00:06 +00:00
|
|
|
osm.ShowOnOff(g->T("Buffered Rendering"), g_Config.bBufferedRendering);
|
2013-03-03 12:00:21 +00:00
|
|
|
if (gpu)
|
|
|
|
gpu->Resized(); // easy way to force a clear...
|
2012-11-20 10:35:48 +00:00
|
|
|
break;
|
|
|
|
|
2012-11-26 16:35:08 +00:00
|
|
|
case ID_OPTIONS_SHOWDEBUGSTATISTICS:
|
|
|
|
g_Config.bShowDebugStats = !g_Config.bShowDebugStats;
|
|
|
|
break;
|
|
|
|
|
2012-12-21 10:08:54 +00:00
|
|
|
case ID_OPTIONS_HARDWARETRANSFORM:
|
|
|
|
g_Config.bHardwareTransform = !g_Config.bHardwareTransform;
|
2013-05-22 16:00:06 +00:00
|
|
|
osm.ShowOnOff(g->T("Hardware Transform"), g_Config.bHardwareTransform);
|
2012-12-21 10:08:54 +00:00
|
|
|
break;
|
|
|
|
|
2013-02-13 17:21:21 +00:00
|
|
|
case ID_OPTIONS_STRETCHDISPLAY:
|
|
|
|
g_Config.bStretchToDisplay = !g_Config.bStretchToDisplay;
|
2013-03-03 12:00:21 +00:00
|
|
|
if (gpu)
|
|
|
|
gpu->Resized(); // easy way to force a clear...
|
2013-02-13 17:21:21 +00:00
|
|
|
break;
|
|
|
|
|
2013-02-18 23:44:22 +00:00
|
|
|
case ID_OPTIONS_FRAMESKIP:
|
2013-05-02 14:48:28 +00:00
|
|
|
g_Config.iFrameSkip = g_Config.iFrameSkip == 0 ? 1 : 0;
|
2013-05-22 16:00:06 +00:00
|
|
|
osm.ShowOnOff(g->T("Frame Skipping"), g_Config.iFrameSkip != 0);
|
2013-02-18 23:44:22 +00:00
|
|
|
break;
|
|
|
|
|
2013-03-12 17:04:36 +00:00
|
|
|
case ID_OPTIONS_USEMEDIAENGINE:
|
|
|
|
g_Config.bUseMediaEngine = !g_Config.bUseMediaEngine;
|
2013-05-22 16:00:06 +00:00
|
|
|
osm.ShowOnOff(g->T("Media Engine"), g_Config.bUseMediaEngine);
|
2013-03-12 17:04:36 +00:00
|
|
|
break;
|
|
|
|
|
2012-11-01 15:19:01 +00:00
|
|
|
case ID_FILE_EXIT:
|
|
|
|
DestroyWindow(hWnd);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_CPU_DYNAREC:
|
2013-02-16 08:49:33 +00:00
|
|
|
g_Config.bJit = true;
|
2013-05-22 16:00:06 +00:00
|
|
|
osm.ShowOnOff(g->T("Dynarec", "Dynarec (JIT)"), g_Config.bJit);
|
2013-03-29 20:21:27 +00:00
|
|
|
break;
|
|
|
|
|
2012-11-01 15:19:01 +00:00
|
|
|
case ID_CPU_INTERPRETER:
|
2013-02-16 08:49:33 +00:00
|
|
|
g_Config.bJit = false;
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
2013-01-04 09:26:14 +00:00
|
|
|
case ID_EMULATION_RUNONLOAD:
|
|
|
|
g_Config.bAutoRun = !g_Config.bAutoRun;
|
|
|
|
break;
|
2012-11-01 15:19:01 +00:00
|
|
|
|
2013-01-05 18:57:06 +00:00
|
|
|
case ID_DEBUG_DUMPNEXTFRAME:
|
2013-03-03 12:00:21 +00:00
|
|
|
if (gpu)
|
|
|
|
gpu->DumpNextFrame();
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_DEBUG_LOADMAPFILE:
|
2013-03-03 12:00:21 +00:00
|
|
|
if (W32Util::BrowseForFileName(true, hWnd, "Load .MAP",0,"Maps\0*.map\0All files\0*.*\0\0","map",fn)) {
|
2012-11-01 15:19:01 +00:00
|
|
|
symbolMap.LoadSymbolMap(fn.c_str());
|
|
|
|
// HLE_PatchFunctions();
|
2013-03-29 18:52:32 +00:00
|
|
|
if (disasmWindow[0])
|
|
|
|
disasmWindow[0]->NotifyMapLoaded();
|
|
|
|
if (memoryWindow[0])
|
|
|
|
memoryWindow[0]->NotifyMapLoaded();
|
2012-11-01 15:19:01 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ID_DEBUG_SAVEMAPFILE:
|
|
|
|
if (W32Util::BrowseForFileName(false, hWnd, "Save .MAP",0,"Maps\0*.map\0All files\0*.*\0\0","map",fn))
|
|
|
|
symbolMap.SaveSymbolMap(fn.c_str());
|
|
|
|
break;
|
2013-01-05 18:57:06 +00:00
|
|
|
|
2012-11-01 15:19:01 +00:00
|
|
|
case ID_DEBUG_RESETSYMBOLTABLE:
|
|
|
|
symbolMap.ResetSymbolMap();
|
|
|
|
for (int i=0; i<numCPUs; i++)
|
|
|
|
if (disasmWindow[i])
|
|
|
|
disasmWindow[i]->NotifyMapLoaded();
|
|
|
|
for (int i=0; i<numCPUs; i++)
|
|
|
|
if (memoryWindow[i])
|
|
|
|
memoryWindow[i]->NotifyMapLoaded();
|
|
|
|
break;
|
|
|
|
case ID_DEBUG_DISASSEMBLY:
|
|
|
|
if (disasmWindow[0])
|
|
|
|
disasmWindow[0]->Show(true);
|
|
|
|
break;
|
|
|
|
case ID_DEBUG_MEMORYVIEW:
|
|
|
|
if (memoryWindow[0])
|
|
|
|
memoryWindow[0]->Show(true);
|
|
|
|
break;
|
|
|
|
case ID_DEBUG_LOG:
|
2012-12-22 17:21:23 +00:00
|
|
|
LogManager::GetInstance()->GetConsoleListener()->Show(LogManager::GetInstance()->GetConsoleListener()->Hidden());
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_OPTIONS_IGNOREILLEGALREADS:
|
|
|
|
g_Config.bIgnoreBadMemAccess = !g_Config.bIgnoreBadMemAccess;
|
|
|
|
break;
|
2013-01-05 18:57:06 +00:00
|
|
|
|
2012-12-05 06:31:41 +00:00
|
|
|
case ID_OPTIONS_FULLSCREEN:
|
2013-01-29 17:12:05 +00:00
|
|
|
g_Config.bFullScreen = !g_Config.bFullScreen ;
|
2012-12-18 11:56:35 +00:00
|
|
|
if(g_bFullScreen) {
|
2012-12-05 06:31:41 +00:00
|
|
|
_ViewNormal(hWnd);
|
2013-01-27 13:05:09 +00:00
|
|
|
} else {
|
2012-12-05 06:31:41 +00:00
|
|
|
_ViewFullScreen(hWnd);
|
2012-12-18 11:56:35 +00:00
|
|
|
}
|
2012-12-05 06:31:41 +00:00
|
|
|
break;
|
2013-01-05 18:57:06 +00:00
|
|
|
|
2013-01-19 16:05:08 +00:00
|
|
|
case ID_OPTIONS_VERTEXCACHE:
|
|
|
|
g_Config.bVertexCache = !g_Config.bVertexCache;
|
|
|
|
break;
|
2013-02-11 18:02:38 +00:00
|
|
|
case ID_OPTIONS_SHOWFPS:
|
|
|
|
g_Config.bShowFPSCounter = !g_Config.bShowFPSCounter;
|
|
|
|
break;
|
2012-11-01 15:19:01 +00:00
|
|
|
case ID_OPTIONS_DISPLAYRAWFRAMEBUFFER:
|
|
|
|
g_Config.bDisplayFramebuffer = !g_Config.bDisplayFramebuffer;
|
|
|
|
break;
|
2012-12-21 16:49:53 +00:00
|
|
|
case ID_OPTIONS_FASTMEMORY:
|
|
|
|
g_Config.bFastMemory = !g_Config.bFastMemory;
|
|
|
|
break;
|
2013-01-10 11:51:18 +00:00
|
|
|
case ID_OPTIONS_USEVBO:
|
|
|
|
g_Config.bUseVBO = !g_Config.bUseVBO;
|
|
|
|
break;
|
2013-01-02 21:57:57 +00:00
|
|
|
case ID_OPTIONS_LINEARFILTERING:
|
2012-12-29 01:02:47 +00:00
|
|
|
g_Config.bLinearFiltering = !g_Config.bLinearFiltering;
|
|
|
|
break;
|
2013-01-10 02:28:49 +00:00
|
|
|
case ID_OPTIONS_SIMPLE2XSSAA:
|
2013-01-26 23:15:39 +00:00
|
|
|
g_Config.SSAntiAliasing = !g_Config.SSAntiAliasing;
|
2013-02-11 18:02:38 +00:00
|
|
|
ResizeDisplay(true);
|
2013-01-10 02:28:49 +00:00
|
|
|
break;
|
2013-01-02 21:57:57 +00:00
|
|
|
case ID_OPTIONS_CONTROLS:
|
|
|
|
DialogManager::EnableAll(FALSE);
|
|
|
|
DialogBox(hInst, (LPCTSTR)IDD_CONTROLS, hWnd, (DLGPROC)Controls);
|
|
|
|
DialogManager::EnableAll(TRUE);
|
|
|
|
break;
|
2013-04-16 19:38:17 +00:00
|
|
|
case ID_EMULATION_SOUND:
|
|
|
|
g_Config.bEnableSound = !g_Config.bEnableSound;
|
|
|
|
break;
|
|
|
|
case ID_HELP_OPENWEBSITE:
|
2012-11-01 15:19:01 +00:00
|
|
|
ShellExecute(NULL, "open", "http://www.ppsspp.org/", NULL, NULL, SW_SHOWNORMAL);
|
2013-04-16 19:38:17 +00:00
|
|
|
break;
|
2012-11-01 15:19:01 +00:00
|
|
|
|
2013-04-16 19:38:17 +00:00
|
|
|
case ID_HELP_ABOUT:
|
2012-11-01 15:19:01 +00:00
|
|
|
DialogManager::EnableAll(FALSE);
|
|
|
|
DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
|
|
|
|
DialogManager::EnableAll(TRUE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
MessageBox(hwndMain,"Unimplemented","Sorry",0);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WM_KEYDOWN:
|
2013-03-29 22:12:37 +00:00
|
|
|
return 0;
|
2013-05-13 09:13:49 +00:00
|
|
|
|
2012-11-01 15:19:01 +00:00
|
|
|
case WM_DROPFILES:
|
|
|
|
{
|
|
|
|
HDROP hdrop = (HDROP)wParam;
|
|
|
|
int count = DragQueryFile(hdrop,0xFFFFFFFF,0,0);
|
|
|
|
if (count != 1)
|
|
|
|
{
|
|
|
|
MessageBox(hwndMain,"You can only load one file at a time","Error",MB_ICONINFORMATION);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
TCHAR filename[512];
|
|
|
|
DragQueryFile(hdrop,0,filename,512);
|
|
|
|
TCHAR *type = filename+_tcslen(filename)-3;
|
|
|
|
|
2013-03-29 17:50:08 +00:00
|
|
|
SendMessage(hWnd, WM_COMMAND, ID_EMULATION_STOP, 0);
|
2013-04-07 03:09:29 +00:00
|
|
|
// Ugly, need to wait for the stop message to process in the EmuThread.
|
|
|
|
Sleep(20);
|
2012-11-01 15:19:01 +00:00
|
|
|
|
|
|
|
MainWindow::SetPlaying(filename);
|
|
|
|
MainWindow::Update();
|
|
|
|
|
2013-04-07 03:09:29 +00:00
|
|
|
NativeMessageReceived("boot", filename);
|
2012-11-01 15:19:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_CLOSE:
|
2013-02-23 21:21:28 +00:00
|
|
|
Core_Stop();
|
|
|
|
Core_WaitInactive(200);
|
2012-11-01 15:19:01 +00:00
|
|
|
EmuThread_Stop();
|
|
|
|
|
|
|
|
/*
|
|
|
|
if (g_Config.bConfirmOnQuit && CCore::IsRunning())
|
|
|
|
{
|
|
|
|
if (IDNO==MessageBox(hwndMain,"A game is in progress. Are you sure you want to exit?","Are you sure?",MB_YESNO|MB_ICONQUESTION))
|
|
|
|
return 1;//or 1?
|
|
|
|
else
|
|
|
|
return DefWindowProc(hWnd,message,wParam,lParam);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*/
|
2013-01-02 21:57:57 +00:00
|
|
|
return DefWindowProc(hWnd,message,wParam,lParam);
|
2013-01-05 18:57:06 +00:00
|
|
|
|
2012-11-01 15:19:01 +00:00
|
|
|
case WM_DESTROY:
|
|
|
|
PostQuitMessage(0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_USER+1:
|
2013-04-01 01:35:29 +00:00
|
|
|
if (disasmWindow[0])
|
|
|
|
SendMessage(disasmWindow[0]->GetDlgHandle(), WM_CLOSE, 0, 0);
|
|
|
|
if (memoryWindow[0])
|
2013-04-21 02:54:25 +00:00
|
|
|
SendMessage(memoryWindow[0]->GetDlgHandle(), WM_CLOSE, 0, 0);
|
2013-04-01 01:35:29 +00:00
|
|
|
|
2012-11-01 15:19:01 +00:00
|
|
|
disasmWindow[0] = new CDisasm(MainWindow::GetHInstance(), MainWindow::GetHWND(), currentDebugMIPS);
|
|
|
|
DialogManager::AddDlg(disasmWindow[0]);
|
2012-12-04 16:05:36 +00:00
|
|
|
disasmWindow[0]->Show(g_Config.bShowDebuggerOnLoad);
|
2013-05-04 21:54:22 +00:00
|
|
|
if (g_Config.bFullScreen)
|
|
|
|
_ViewFullScreen(hWnd);
|
2012-11-01 15:19:01 +00:00
|
|
|
memoryWindow[0] = new CMemoryDlg(MainWindow::GetHInstance(), MainWindow::GetHWND(), currentDebugMIPS);
|
|
|
|
DialogManager::AddDlg(memoryWindow[0]);
|
|
|
|
if (disasmWindow[0])
|
|
|
|
disasmWindow[0]->NotifyMapLoaded();
|
|
|
|
if (memoryWindow[0])
|
|
|
|
memoryWindow[0]->NotifyMapLoaded();
|
2012-12-22 17:21:23 +00:00
|
|
|
|
2013-04-01 01:28:13 +00:00
|
|
|
SetForegroundWindow(hwndMain);
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
2013-03-29 18:52:32 +00:00
|
|
|
|
|
|
|
|
2013-03-29 18:32:20 +00:00
|
|
|
case WM_MENUSELECT:
|
2013-05-13 08:08:10 +00:00
|
|
|
// Unfortunately, accelerate keys (hotkeys) shares the same enabled/disabled states
|
|
|
|
// with corresponding menu items.
|
2013-03-29 18:32:20 +00:00
|
|
|
UpdateMenus();
|
|
|
|
break;
|
2012-11-01 15:19:01 +00:00
|
|
|
|
2013-05-02 18:58:10 +00:00
|
|
|
// Turn off the screensaver.
|
|
|
|
// Note that if there's a screensaver password, this simple method
|
|
|
|
// doesn't work on Vista or higher.
|
|
|
|
case WM_SYSCOMMAND:
|
|
|
|
{
|
|
|
|
switch (wParam)
|
|
|
|
{
|
|
|
|
case SC_SCREENSAVE:
|
|
|
|
return 0;
|
|
|
|
case SC_MONITORPOWER:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return DefWindowProc(hWnd, message, wParam, lParam);
|
|
|
|
}
|
|
|
|
|
2012-11-01 15:19:01 +00:00
|
|
|
default:
|
|
|
|
return DefWindowProc(hWnd, message, wParam, lParam);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void UpdateMenus()
|
|
|
|
{
|
|
|
|
HMENU menu = GetMenu(GetHWND());
|
|
|
|
#define CHECKITEM(item,value) CheckMenuItem(menu,item,MF_BYCOMMAND | ((value) ? MF_CHECKED : MF_UNCHECKED));
|
|
|
|
|
|
|
|
CHECKITEM(ID_EMULATION_SPEEDLIMIT,g_Config.bSpeedLimit);
|
|
|
|
// CHECK(ID_OPTIONS_ENABLEFRAMEBUFFER,g_Config.bEnableFrameBuffer);
|
|
|
|
// CHECK(ID_OPTIONS_EMULATESYSCALL,g_bEmulateSyscall);
|
|
|
|
CHECKITEM(ID_OPTIONS_DISPLAYRAWFRAMEBUFFER, g_Config.bDisplayFramebuffer);
|
|
|
|
CHECKITEM(ID_OPTIONS_IGNOREILLEGALREADS,g_Config.bIgnoreBadMemAccess);
|
2013-02-16 13:24:02 +00:00
|
|
|
CHECKITEM(ID_CPU_INTERPRETER,g_Config.bJit == false);
|
|
|
|
CHECKITEM(ID_CPU_DYNAREC,g_Config.bJit == true);
|
2012-11-20 10:35:48 +00:00
|
|
|
CHECKITEM(ID_OPTIONS_BUFFEREDRENDERING, g_Config.bBufferedRendering);
|
2012-11-26 16:35:08 +00:00
|
|
|
CHECKITEM(ID_OPTIONS_SHOWDEBUGSTATISTICS, g_Config.bShowDebugStats);
|
2012-12-21 10:08:54 +00:00
|
|
|
CHECKITEM(ID_OPTIONS_HARDWARETRANSFORM, g_Config.bHardwareTransform);
|
2012-12-21 15:49:02 +00:00
|
|
|
CHECKITEM(ID_OPTIONS_FASTMEMORY, g_Config.bFastMemory);
|
2012-12-29 01:02:47 +00:00
|
|
|
CHECKITEM(ID_OPTIONS_LINEARFILTERING, g_Config.bLinearFiltering);
|
2013-01-26 23:15:39 +00:00
|
|
|
CHECKITEM(ID_OPTIONS_SIMPLE2XSSAA, g_Config.SSAntiAliasing);
|
2013-02-13 17:21:21 +00:00
|
|
|
CHECKITEM(ID_OPTIONS_STRETCHDISPLAY, g_Config.bStretchToDisplay);
|
2013-01-04 09:26:14 +00:00
|
|
|
CHECKITEM(ID_EMULATION_RUNONLOAD, g_Config.bAutoRun);
|
2013-01-10 11:51:18 +00:00
|
|
|
CHECKITEM(ID_OPTIONS_USEVBO, g_Config.bUseVBO);
|
2013-01-19 16:05:08 +00:00
|
|
|
CHECKITEM(ID_OPTIONS_VERTEXCACHE, g_Config.bVertexCache);
|
2013-02-11 18:02:38 +00:00
|
|
|
CHECKITEM(ID_OPTIONS_SHOWFPS, g_Config.bShowFPSCounter);
|
2013-05-02 14:48:28 +00:00
|
|
|
CHECKITEM(ID_OPTIONS_FRAMESKIP, g_Config.iFrameSkip != 0);
|
2013-03-12 17:04:36 +00:00
|
|
|
CHECKITEM(ID_OPTIONS_USEMEDIAENGINE, g_Config.bUseMediaEngine);
|
2013-04-17 19:07:41 +00:00
|
|
|
CHECKITEM(ID_OPTIONS_MIPMAP, g_Config.bMipMap);
|
2013-05-13 08:08:10 +00:00
|
|
|
CHECKITEM(ID_EMULATION_SOUND, g_Config.bEnableSound);
|
|
|
|
CHECKITEM(ID_TEXTURESCALING_DEPOSTERIZE, g_Config.bTexDeposterize);
|
2013-04-16 19:38:17 +00:00
|
|
|
|
2013-03-29 19:03:11 +00:00
|
|
|
static const int zoomitems[4] = {
|
2012-11-17 16:46:05 +00:00
|
|
|
ID_OPTIONS_SCREEN1X,
|
|
|
|
ID_OPTIONS_SCREEN2X,
|
|
|
|
ID_OPTIONS_SCREEN3X,
|
|
|
|
ID_OPTIONS_SCREEN4X,
|
|
|
|
};
|
|
|
|
for (int i = 0; i < 4; i++) {
|
|
|
|
CheckMenuItem(menu, zoomitems[i], MF_BYCOMMAND | ((i == g_Config.iWindowZoom - 1) ? MF_CHECKED : MF_UNCHECKED));
|
|
|
|
}
|
2013-04-30 01:47:33 +00:00
|
|
|
|
2013-04-30 10:14:34 +00:00
|
|
|
static const int texscalingitems[] = {
|
|
|
|
ID_TEXTURESCALING_OFF,
|
2013-05-01 21:55:34 +00:00
|
|
|
ID_TEXTURESCALING_2X,
|
|
|
|
ID_TEXTURESCALING_3X,
|
|
|
|
ID_TEXTURESCALING_4X,
|
|
|
|
ID_TEXTURESCALING_5X,
|
2013-04-30 01:47:33 +00:00
|
|
|
};
|
2013-04-30 10:14:34 +00:00
|
|
|
for (int i = 0; i < 5; i++) {
|
2013-05-01 21:55:34 +00:00
|
|
|
CheckMenuItem(menu, texscalingitems[i], MF_BYCOMMAND | ((i == g_Config.iTexScalingLevel-1) ? MF_CHECKED : MF_UNCHECKED));
|
|
|
|
}
|
|
|
|
|
|
|
|
static const int texscalingtypeitems[] = {
|
|
|
|
ID_TEXTURESCALING_XBRZ,
|
|
|
|
ID_TEXTURESCALING_HYBRID,
|
2013-05-04 23:27:15 +00:00
|
|
|
ID_TEXTURESCALING_BICUBIC,
|
|
|
|
ID_TEXTURESCALING_HYBRID_BICUBIC,
|
2013-05-01 21:55:34 +00:00
|
|
|
};
|
2013-05-04 23:27:15 +00:00
|
|
|
for (int i = 0; i < 4; i++) {
|
2013-05-01 21:55:34 +00:00
|
|
|
CheckMenuItem(menu, texscalingtypeitems[i], MF_BYCOMMAND | ((i == g_Config.iTexScalingType) ? MF_CHECKED : MF_UNCHECKED));
|
2013-04-30 01:47:33 +00:00
|
|
|
}
|
2013-05-13 08:08:10 +00:00
|
|
|
|
|
|
|
UpdateCommands();
|
|
|
|
}
|
|
|
|
|
|
|
|
void UpdateCommands()
|
|
|
|
{
|
|
|
|
static GlobalUIState lastGlobalUIState = UISTATE_PAUSEMENU;
|
|
|
|
static CoreState lastCoreState = CORE_ERROR;
|
|
|
|
|
|
|
|
if (lastGlobalUIState == globalUIState && lastCoreState == coreState)
|
|
|
|
return;
|
|
|
|
|
|
|
|
lastCoreState = coreState;
|
|
|
|
lastGlobalUIState = globalUIState;
|
|
|
|
|
|
|
|
HMENU menu = GetMenu(GetHWND());
|
|
|
|
EnableMenuItem(menu,ID_EMULATION_RUN, (Core_IsStepping() || globalUIState == UISTATE_PAUSEMENU) ? MF_ENABLED : MF_GRAYED);
|
|
|
|
|
|
|
|
UINT ingameEnable = globalUIState == UISTATE_INGAME ? MF_ENABLED : MF_GRAYED;
|
|
|
|
EnableMenuItem(menu,ID_EMULATION_PAUSE, ingameEnable);
|
|
|
|
EnableMenuItem(menu,ID_EMULATION_STOP, ingameEnable);
|
|
|
|
EnableMenuItem(menu,ID_EMULATION_RESET, ingameEnable);
|
|
|
|
|
|
|
|
UINT menuEnable = globalUIState == UISTATE_MENU ? MF_ENABLED : MF_GRAYED;
|
|
|
|
EnableMenuItem(menu,ID_FILE_LOAD, menuEnable);
|
|
|
|
EnableMenuItem(menu,ID_FILE_LOAD_MEMSTICK, menuEnable);
|
|
|
|
EnableMenuItem(menu,ID_FILE_SAVESTATEFILE, !menuEnable);
|
|
|
|
EnableMenuItem(menu,ID_FILE_LOADSTATEFILE, !menuEnable);
|
|
|
|
EnableMenuItem(menu,ID_FILE_QUICKSAVESTATE, !menuEnable);
|
|
|
|
EnableMenuItem(menu,ID_FILE_QUICKLOADSTATE, !menuEnable);
|
|
|
|
EnableMenuItem(menu,ID_CPU_DYNAREC, menuEnable);
|
|
|
|
EnableMenuItem(menu,ID_CPU_INTERPRETER, menuEnable);
|
|
|
|
EnableMenuItem(menu,ID_EMULATION_STOP, !menuEnable);
|
2012-11-01 15:19:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Message handler for about box.
|
|
|
|
LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
switch (message)
|
|
|
|
{
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
W32Util::CenterWindow(hDlg);
|
2013-03-11 21:55:29 +00:00
|
|
|
{
|
|
|
|
HWND versionBox = GetDlgItem(hDlg, IDC_VERSION);
|
|
|
|
char temp[256];
|
|
|
|
sprintf(temp, "PPSSPP %s", PPSSPP_GIT_VERSION);
|
|
|
|
SetWindowText(versionBox, temp);
|
|
|
|
}
|
2012-11-01 15:19:01 +00:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
case WM_COMMAND:
|
|
|
|
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
|
|
|
|
{
|
|
|
|
EndDialog(hDlg, LOWORD(wParam));
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2013-05-23 00:39:36 +00:00
|
|
|
#define CONTROLS_IDC_EDIT_BEGIN IDC_EDIT_KEY_MENU
|
2013-05-17 10:31:06 +00:00
|
|
|
#define CONTROLS_IDC_EDIT_END IDC_EDIT_KEY_ANALOG_RIGHT
|
2013-05-23 00:39:36 +00:00
|
|
|
#define CONTROLS_BUTTONS_COUNT (IDC_EDIT_KEYRIGHT - CONTROLS_IDC_EDIT_BEGIN + 1)
|
2013-05-17 10:31:06 +00:00
|
|
|
#define CONTROLS_BUTTONNAME_MAX 16
|
|
|
|
// for controls dialog device polling and bind update.
|
|
|
|
#define TIMER_CONTROLS_BINDUPDATE 1
|
|
|
|
#define BINDUPDATE_INTERVAL_MS 50
|
|
|
|
|
2013-03-29 20:21:27 +00:00
|
|
|
static const char *controllist[] = {
|
2013-05-17 10:31:06 +00:00
|
|
|
"Menu", // Open PauseScreen
|
|
|
|
"Back", // Toggle PauseScreen & Back Setting Page.
|
|
|
|
"Triangle",
|
|
|
|
"Rectangle",
|
|
|
|
"Cross",
|
|
|
|
"Circle",
|
|
|
|
"Select",
|
|
|
|
"Start",
|
|
|
|
"Left Trigger",
|
|
|
|
"Right Trigger",
|
|
|
|
"Turbo", // LBUMPER (Turbo)
|
|
|
|
"Reserved", // RBUMPER (Open PauseScreen)
|
|
|
|
"Up",
|
|
|
|
"Down",
|
|
|
|
"Left",
|
|
|
|
"Right",
|
|
|
|
"LY+",
|
|
|
|
"LY-",
|
|
|
|
"LX-",
|
|
|
|
"LX+",
|
2013-01-02 21:57:57 +00:00
|
|
|
};
|
2013-03-29 20:21:27 +00:00
|
|
|
|
2013-05-17 10:31:06 +00:00
|
|
|
struct ControlsDlgState {
|
|
|
|
HHOOK pKeydownHook;
|
|
|
|
HBITMAP hbmPspImage;
|
|
|
|
HWND hCtrlTab;
|
|
|
|
UINT_PTR timerId;
|
|
|
|
WNDPROC orgPSPImageProc;
|
2013-05-23 00:39:36 +00:00
|
|
|
WNDPROC orgEditProc;
|
2013-05-17 10:31:06 +00:00
|
|
|
ControlMapping *pCtrlMap;
|
|
|
|
HWND hStaticPspImage;
|
|
|
|
};
|
|
|
|
static ControlsDlgState *pCtrlDlgState;
|
|
|
|
|
2013-04-18 09:13:00 +00:00
|
|
|
RECT getRedrawRect(HWND hWnd) {
|
|
|
|
RECT rc;
|
|
|
|
HWND hDlg = GetParent(hWnd);
|
|
|
|
GetWindowRect(hWnd, &rc);
|
|
|
|
POINT pt = {0, 0};
|
|
|
|
ScreenToClient(hDlg, &pt);
|
|
|
|
rc.left += pt.x;
|
|
|
|
rc.right += pt.x;
|
|
|
|
rc.top += pt.y;
|
|
|
|
rc.bottom += pt.y;
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
LRESULT CALLBACK KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
2013-05-17 10:31:06 +00:00
|
|
|
if (pCtrlDlgState->pCtrlMap->GetTargetDevice() == CONTROLS_KEYBOARD_INDEX) {
|
|
|
|
HWND hEdit = GetFocus();
|
|
|
|
UINT nCtrlID = GetDlgCtrlID(hEdit);
|
2013-05-23 00:39:36 +00:00
|
|
|
if (nCtrlID < CONTROLS_IDC_EDIT_BEGIN || nCtrlID > CONTROLS_IDC_EDIT_END) {
|
2013-05-17 10:31:06 +00:00
|
|
|
return CallNextHookEx(pCtrlDlgState->pKeydownHook, nCode, wParam, lParam);
|
|
|
|
}
|
|
|
|
if (!(lParam&(1<<31))) {
|
|
|
|
// key down
|
|
|
|
HWND hDlg = GetParent(hEdit);
|
|
|
|
const char *str = getVirtualKeyName(wParam);
|
|
|
|
if (str) {
|
2013-05-19 09:12:22 +00:00
|
|
|
if (nCtrlID >= IDC_EDIT_KEY_ANALOG_UP) {
|
|
|
|
pCtrlDlgState->pCtrlMap->SetBindCode(wParam, CONTROLS_KEYBOARD_ANALOG_INDEX,
|
|
|
|
nCtrlID - IDC_EDIT_KEY_ANALOG_UP);
|
|
|
|
} else {
|
|
|
|
pCtrlDlgState->pCtrlMap->SetBindCode(wParam);
|
|
|
|
}
|
2013-05-17 10:31:06 +00:00
|
|
|
SetWindowTextA(hEdit, str);
|
|
|
|
RECT rc = getRedrawRect(hEdit);
|
|
|
|
InvalidateRect(hDlg, &rc, false);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
MessageBoxA(hDlg, "Not supported!", "controller", MB_OK);
|
2013-04-18 09:13:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2013-04-19 09:21:16 +00:00
|
|
|
HBITMAP LoadImageFromResource(HINSTANCE hInstance,LPCTSTR pszResourceName, LPCTSTR lpType)
|
2013-04-18 09:13:00 +00:00
|
|
|
{
|
|
|
|
HRSRC hrsrc = FindResource(hInstance, pszResourceName, lpType);
|
|
|
|
if (!hrsrc)
|
|
|
|
return FALSE;
|
|
|
|
DWORD dwlen = SizeofResource(hInstance, hrsrc);
|
|
|
|
BYTE *lpRsrc = (BYTE*)LoadResource(hInstance, hrsrc);
|
|
|
|
if (!lpRsrc)
|
|
|
|
return FALSE;
|
2013-04-19 09:21:16 +00:00
|
|
|
int width, height;
|
|
|
|
unsigned char *image_data = 0;
|
2013-04-19 15:36:32 +00:00
|
|
|
bool bResult = pngLoadPtr(lpRsrc, dwlen, &width, &height, &image_data, false) != 0;
|
2013-04-18 09:13:00 +00:00
|
|
|
FreeResource(lpRsrc);
|
2013-04-19 09:21:16 +00:00
|
|
|
if (!bResult)
|
|
|
|
return 0;
|
|
|
|
HBITMAP hbm = CreateBitmap(width, height, 1, 32, image_data);
|
|
|
|
free(image_data);
|
|
|
|
return hbm;
|
|
|
|
}
|
|
|
|
void BitBlt(HBITMAP hbm, HDC dstDC, int dstX, int dstY, int width, int height, int srcX, int srcY)
|
|
|
|
{
|
|
|
|
HDC hCompDC = CreateCompatibleDC(dstDC);
|
|
|
|
HBITMAP oldbm = (HBITMAP)SelectObject(hCompDC, hbm);
|
|
|
|
BitBlt(dstDC, dstX, dstY, width, height, hCompDC, srcX, srcY, SRCCOPY);
|
|
|
|
SelectObject(hCompDC, oldbm);
|
|
|
|
DeleteObject(hCompDC);
|
2013-04-18 09:13:00 +00:00
|
|
|
}
|
|
|
|
|
2013-05-23 00:39:36 +00:00
|
|
|
inline void SetWindowTextForButton(HWND hEdit, u32 buttonCode, const char *pszButtonName)
|
|
|
|
{
|
|
|
|
if (buttonCode == 0) {
|
|
|
|
SetWindowTextA(hEdit, "Disable");
|
|
|
|
} else {
|
|
|
|
SetWindowTextA(hEdit, pszButtonName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-17 10:31:06 +00:00
|
|
|
// Draw background image of Controls Dialog (pspmode.png) by use static control.
|
|
|
|
LRESULT CALLBACK PSPImageProc(HWND hStatic, UINT message, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
|
|
|
|
switch(message) {
|
|
|
|
case WM_PAINT:
|
|
|
|
{
|
|
|
|
PAINTSTRUCT pst;
|
|
|
|
HDC hdc = BeginPaint(hStatic, &pst);
|
|
|
|
|
|
|
|
BITMAP bm;
|
|
|
|
GetObject(pCtrlDlgState->hbmPspImage, sizeof(BITMAP), &bm);
|
|
|
|
BitBlt(pCtrlDlgState->hbmPspImage, hdc, 0, 0, bm.bmWidth, bm.bmHeight, 0 , 0);
|
|
|
|
EndPaint(hStatic, &pst);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return CallWindowProc(pCtrlDlgState->orgPSPImageProc, hStatic, message, wParam, lParam);
|
|
|
|
}
|
|
|
|
|
2013-05-23 00:39:36 +00:00
|
|
|
LRESULT CALLBACK ButtonsEditProc(HWND hEdit, UINT message, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
switch (message) {
|
|
|
|
case WM_RBUTTONUP:
|
|
|
|
{
|
|
|
|
UINT nCtrlID = GetDlgCtrlID(hEdit);
|
|
|
|
int deviceIdx = TabCtrl_GetCurSel(pCtrlDlgState->hCtrlTab);
|
|
|
|
if (deviceIdx != CONTROLS_KEYBOARD_INDEX && nCtrlID >= IDC_EDIT_KEY_ANALOG_UP)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
HMENU hSubMenu = GetSubMenu(g_hPopupMenus, 4);
|
|
|
|
POINT pos;
|
|
|
|
pos.x = LOWORD(lParam);
|
|
|
|
pos.y = HIWORD(lParam);
|
|
|
|
ClientToScreen(hEdit, &pos);
|
|
|
|
switch(TrackPopupMenuEx(GetSubMenu(g_hPopupMenus, 4), TPM_RETURNCMD, pos.x, pos.y, hEdit, NULL))
|
|
|
|
{
|
|
|
|
case ID_CONTROLS_KEY_DISABLE:
|
|
|
|
{
|
|
|
|
if (nCtrlID < IDC_EDIT_KEY_ANALOG_UP) {
|
|
|
|
pCtrlDlgState->pCtrlMap->SetDisableBind(deviceIdx, nCtrlID - CONTROLS_IDC_EDIT_BEGIN);
|
|
|
|
}
|
|
|
|
else if (deviceIdx == CONTROLS_KEYBOARD_INDEX) {
|
|
|
|
pCtrlDlgState->pCtrlMap->SetDisableBind(
|
|
|
|
CONTROLS_KEYBOARD_ANALOG_INDEX, nCtrlID - IDC_EDIT_KEY_ANALOG_UP);
|
|
|
|
}
|
|
|
|
SetWindowTextA(hEdit, "Disable");
|
|
|
|
RECT rc = getRedrawRect(hEdit);
|
|
|
|
HWND hDlg = GetParent(hEdit);
|
|
|
|
InvalidateRect(hDlg, &rc, false);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
default :
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return CallWindowProc(pCtrlDlgState->orgEditProc, hEdit, message, wParam, lParam);
|
|
|
|
}
|
|
|
|
|
2013-04-18 09:13:00 +00:00
|
|
|
// Message handler for control box.
|
2013-01-02 21:57:57 +00:00
|
|
|
LRESULT CALLBACK Controls(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
2013-05-17 10:31:06 +00:00
|
|
|
{
|
2013-01-02 21:57:57 +00:00
|
|
|
switch (message)
|
|
|
|
{
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
W32Util::CenterWindow(hDlg);
|
|
|
|
{
|
2013-05-17 10:31:06 +00:00
|
|
|
// IDC_EDIT_xxx is need continuous value to IDC_EDIT_KEY_ANALOG_RIGHT from IDC_EDIT_KEY_MENU.
|
|
|
|
// it is total 16.
|
|
|
|
// it is need the same order as the dinput_ctrl_map(and xinput/keyboard).
|
|
|
|
if (CONTROLS_BUTTONS_COUNT != 16) {
|
|
|
|
char mes[100];
|
|
|
|
snprintf(mes, 100, "CONTROLS_BUTTONS_COUNT(%d) is need 16.", CONTROLS_BUTTONS_COUNT);
|
|
|
|
MessageBoxA(hDlg, mes, "Controls dialog init error.", MB_OK);
|
|
|
|
}
|
|
|
|
pCtrlDlgState = new ControlsDlgState();
|
|
|
|
ZeroMemory(pCtrlDlgState, sizeof(ControlsDlgState));
|
|
|
|
pCtrlDlgState->pCtrlMap = ControlMapping::CreateInstance(CONTROLS_BUTTONS_COUNT);
|
|
|
|
if (!pCtrlDlgState->pCtrlMap) {
|
|
|
|
MessageBoxA(hDlg, "Cannot Created ControlMapping instance.", "Controls dialog init error.", MB_OK);
|
|
|
|
}
|
|
|
|
pCtrlDlgState->pCtrlMap->SetTargetDevice(CONTROLS_KEYBOARD_INDEX);
|
|
|
|
|
|
|
|
pCtrlDlgState->hCtrlTab = GetDlgItem(hDlg, IDC_TAB_INPUT_DEVICE);
|
|
|
|
TCITEM tcItem;
|
|
|
|
ZeroMemory(&tcItem, sizeof(tcItem));
|
|
|
|
tcItem.mask = TCIF_TEXT;
|
|
|
|
tcItem.dwState = 0;
|
|
|
|
tcItem.pszText = "Keyboard";
|
|
|
|
tcItem.cchTextMax = (int)strlen(tcItem.pszText)+1;
|
|
|
|
tcItem.iImage = 0;
|
|
|
|
TabCtrl_InsertItem(pCtrlDlgState->hCtrlTab, TabCtrl_GetItemCount(pCtrlDlgState->hCtrlTab),&tcItem);
|
|
|
|
tcItem.pszText = "DirectInput";
|
|
|
|
tcItem.cchTextMax = (int)strlen(tcItem.pszText)+1;
|
|
|
|
TabCtrl_InsertItem(pCtrlDlgState->hCtrlTab, TabCtrl_GetItemCount(pCtrlDlgState->hCtrlTab),&tcItem);
|
|
|
|
tcItem.pszText = "XInput";
|
|
|
|
tcItem.cchTextMax = (int)strlen(tcItem.pszText)+1;
|
|
|
|
TabCtrl_InsertItem(pCtrlDlgState->hCtrlTab, TabCtrl_GetItemCount(pCtrlDlgState->hCtrlTab),&tcItem);
|
|
|
|
int tp_w = 0, tp_h = 0;
|
2013-01-02 21:57:57 +00:00
|
|
|
// TODO: connect to keyboard device instead
|
2013-04-28 00:02:52 +00:00
|
|
|
{
|
2013-05-17 10:31:06 +00:00
|
|
|
|
2013-04-28 00:02:52 +00:00
|
|
|
HBITMAP hResBM = LoadImageFromResource(hInst, MAKEINTRESOURCE(IDB_IMAGE_PSP), "IMAGE");
|
2013-05-17 10:31:06 +00:00
|
|
|
pCtrlDlgState->hStaticPspImage = GetDlgItem(hDlg,IDC_STATIC_IMAGE_PSP);
|
|
|
|
RECT clientRect, tabPageRect, imgRect;
|
|
|
|
|
2013-04-28 00:02:52 +00:00
|
|
|
GetClientRect(hDlg, &clientRect);
|
2013-05-17 10:31:06 +00:00
|
|
|
memcpy(&tabPageRect, &clientRect, sizeof(RECT));
|
|
|
|
TabCtrl_AdjustRect(pCtrlDlgState->hCtrlTab, FALSE, &tabPageRect);
|
|
|
|
tp_w = tabPageRect.right - tabPageRect.left;
|
|
|
|
tp_h = tabPageRect.bottom - tabPageRect.top;
|
|
|
|
MoveWindow(pCtrlDlgState->hStaticPspImage, tabPageRect.left, tabPageRect.top, tp_w, tp_h, FALSE);
|
|
|
|
|
|
|
|
HDC hDC = GetDC(pCtrlDlgState->hStaticPspImage);
|
|
|
|
HBITMAP hMemBM = CreateCompatibleBitmap(hDC, tp_w, tp_h);
|
2013-04-28 00:02:52 +00:00
|
|
|
HDC hResDC = CreateCompatibleDC(hDC);
|
|
|
|
HDC hMemDC = CreateCompatibleDC(hDC);
|
|
|
|
SelectObject(hResDC, hResBM);
|
|
|
|
SelectObject(hMemDC, hMemBM);
|
|
|
|
|
|
|
|
BITMAP bm;
|
|
|
|
GetObject(hResBM, sizeof(BITMAP), &bm);
|
|
|
|
SetStretchBltMode(hMemDC, HALFTONE);
|
2013-05-17 10:31:06 +00:00
|
|
|
float scaleX = (float)bm.bmWidth / clientRect.right;
|
|
|
|
float scaleY = (float)bm.bmHeight / clientRect.bottom;
|
|
|
|
imgRect.left = (int)(tabPageRect.left * scaleX);
|
|
|
|
imgRect.top = (int)(tabPageRect.top * scaleY);
|
|
|
|
imgRect.right= (int)(bm.bmWidth - ((clientRect.right - tabPageRect.right) * scaleX));
|
|
|
|
imgRect.bottom = (int)(bm.bmHeight - ((clientRect.bottom - tabPageRect.bottom) * scaleY));
|
|
|
|
StretchBlt(hMemDC, 0, 0, tp_w, tp_h, hResDC, imgRect.left, imgRect.top,
|
|
|
|
imgRect.right - imgRect.left, imgRect.bottom - imgRect.top, SRCCOPY);
|
|
|
|
if (pCtrlDlgState->hbmPspImage)
|
|
|
|
DeleteObject(pCtrlDlgState->hbmPspImage);
|
|
|
|
pCtrlDlgState->hbmPspImage = hMemBM;
|
2013-04-28 00:02:52 +00:00
|
|
|
|
|
|
|
DeleteDC(hMemDC);
|
|
|
|
DeleteDC(hResDC);
|
2013-05-17 10:31:06 +00:00
|
|
|
ReleaseDC(pCtrlDlgState->hStaticPspImage, hDC);
|
2013-04-28 00:02:52 +00:00
|
|
|
DeleteObject(hResBM);
|
|
|
|
}
|
2013-05-17 10:31:06 +00:00
|
|
|
|
2013-05-23 00:39:36 +00:00
|
|
|
pCtrlDlgState->orgEditProc = (WNDPROC)GetWindowLongPtr(
|
|
|
|
GetDlgItem(hDlg, CONTROLS_IDC_EDIT_BEGIN), GWLP_WNDPROC);
|
|
|
|
for (int i = 0; i <= CONTROLS_IDC_EDIT_END - CONTROLS_IDC_EDIT_BEGIN; i++) {
|
|
|
|
HWND hEdit = GetDlgItem(hDlg, CONTROLS_IDC_EDIT_BEGIN + i);
|
|
|
|
if (i < CONTROLS_BUTTONS_COUNT) {
|
|
|
|
u32 keyCode = pCtrlDlgState->pCtrlMap->GetBindCode(CONTROLS_KEYBOARD_INDEX, i);
|
|
|
|
SetWindowTextForButton(hEdit, keyCode, getVirtualKeyName(keyCode));
|
|
|
|
} else {
|
|
|
|
u32 analogCode = pCtrlDlgState->pCtrlMap->GetBindCode(
|
|
|
|
CONTROLS_KEYBOARD_ANALOG_INDEX, i - CONTROLS_BUTTONS_COUNT);
|
|
|
|
SetWindowTextForButton(hEdit, analogCode, getVirtualKeyName(analogCode));
|
|
|
|
}
|
|
|
|
if (pCtrlDlgState->orgEditProc != (WNDPROC)GetWindowLongPtr(hEdit, GWLP_WNDPROC)) {
|
|
|
|
MessageBoxA(hDlg,
|
|
|
|
"Can not hook to the inherited Edit control. need wndproc of original edit control.",
|
|
|
|
"Controls dialog init error.", MB_OK);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
SetWindowLongPtr(hEdit, GWLP_WNDPROC, (LONG_PTR)ButtonsEditProc);
|
2013-05-19 09:12:22 +00:00
|
|
|
}
|
2013-05-23 00:39:36 +00:00
|
|
|
|
2013-04-19 06:20:26 +00:00
|
|
|
ComboBox_AddString(GetDlgItem(hDlg, IDC_FORCE_INPUT_DEVICE), "None");
|
|
|
|
ComboBox_AddString(GetDlgItem(hDlg, IDC_FORCE_INPUT_DEVICE), "XInput");
|
|
|
|
ComboBox_AddString(GetDlgItem(hDlg, IDC_FORCE_INPUT_DEVICE), "DirectInput");
|
|
|
|
if ((g_Config.iForceInputDevice < 0) || (g_Config.iForceInputDevice > 1))
|
|
|
|
{
|
|
|
|
ComboBox_SetCurSel(GetDlgItem(hDlg, IDC_FORCE_INPUT_DEVICE), 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ComboBox_SetCurSel(GetDlgItem(hDlg, IDC_FORCE_INPUT_DEVICE), (g_Config.iForceInputDevice + 1));
|
|
|
|
}
|
2013-05-19 12:10:05 +00:00
|
|
|
pCtrlDlgState->orgPSPImageProc = (WNDPROC)GetWindowLongPtr(pCtrlDlgState->hStaticPspImage, GWLP_WNDPROC);
|
|
|
|
SetWindowLongPtr(pCtrlDlgState->hStaticPspImage, GWLP_WNDPROC, (LONG_PTR)PSPImageProc);
|
2013-04-28 00:02:52 +00:00
|
|
|
DWORD dwThreadID = GetWindowThreadProcessId(hDlg, NULL);
|
2013-05-19 12:10:05 +00:00
|
|
|
pCtrlDlgState->pKeydownHook = SetWindowsHookEx(WH_KEYBOARD, KeyboardProc, NULL, dwThreadID);
|
2013-05-17 10:31:06 +00:00
|
|
|
|
|
|
|
pCtrlDlgState->timerId = SetTimer(hDlg, TIMER_CONTROLS_BINDUPDATE, BINDUPDATE_INTERVAL_MS, 0);
|
2013-01-02 21:57:57 +00:00
|
|
|
}
|
|
|
|
return TRUE;
|
2013-05-17 10:31:06 +00:00
|
|
|
case WM_TIMER:
|
|
|
|
{
|
|
|
|
if (wParam == TIMER_CONTROLS_BINDUPDATE &&
|
|
|
|
pCtrlDlgState->pCtrlMap->GetTargetDevice() != CONTROLS_KEYBOARD_INDEX) {
|
|
|
|
HWND hEdit = GetFocus();
|
|
|
|
UINT nCtrlID = GetDlgCtrlID(hEdit);
|
2013-05-23 00:39:36 +00:00
|
|
|
if (nCtrlID < CONTROLS_IDC_EDIT_BEGIN || nCtrlID > IDC_EDIT_KEYRIGHT) {
|
2013-05-17 10:31:06 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
// device polling and update.
|
|
|
|
int prevButton = pCtrlDlgState->pCtrlMap->GetBindCode();
|
|
|
|
pCtrlDlgState->pCtrlMap->UpdateState();
|
|
|
|
char str[CONTROLS_BUTTONNAME_MAX];
|
|
|
|
ZeroMemory(str, CONTROLS_BUTTONNAME_MAX * sizeof(char));
|
|
|
|
int buttonCode = pCtrlDlgState->pCtrlMap->GetBindCode();
|
|
|
|
if (buttonCode == -1 || prevButton == buttonCode)
|
|
|
|
break;
|
|
|
|
|
|
|
|
switch(pCtrlDlgState->pCtrlMap->GetTargetDevice())
|
|
|
|
{
|
|
|
|
case CONTROLS_KEYBOARD_INDEX:
|
|
|
|
{
|
|
|
|
; // leave it to KeyboardProc.
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CONTROLS_DIRECT_INPUT_INDEX:
|
|
|
|
{
|
|
|
|
if (buttonCode > 0xFF) {
|
|
|
|
int n = 1;
|
|
|
|
for (int i = buttonCode >> 8; i > 1; i >>= 1) {
|
|
|
|
n++;
|
|
|
|
}
|
|
|
|
snprintf(str, CONTROLS_BUTTONNAME_MAX, "%s",
|
2013-05-23 00:39:36 +00:00
|
|
|
controllist[(IDC_EDIT_KEYUP - CONTROLS_IDC_EDIT_BEGIN - 1) + n]);
|
2013-05-17 10:31:06 +00:00
|
|
|
} else {
|
|
|
|
snprintf(str, CONTROLS_BUTTONNAME_MAX, "%d", buttonCode + 1);
|
|
|
|
}
|
|
|
|
SetWindowTextA(hEdit, str);
|
|
|
|
RECT rc = getRedrawRect(hEdit);
|
|
|
|
InvalidateRect(hDlg, &rc, FALSE);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CONTROLS_XINPUT_INDEX:
|
|
|
|
{
|
2013-05-23 00:39:36 +00:00
|
|
|
SetWindowTextA(hEdit, getXinputButtonName(buttonCode));
|
2013-05-17 10:31:06 +00:00
|
|
|
RECT rc = getRedrawRect(hEdit);
|
|
|
|
InvalidateRect(hDlg, &rc, FALSE);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WM_NOTIFY:
|
|
|
|
{
|
|
|
|
switch (((NMHDR *)lParam)->code)
|
|
|
|
{
|
|
|
|
case TCN_SELCHANGE:
|
|
|
|
{
|
|
|
|
int cursel = TabCtrl_GetCurSel(pCtrlDlgState->hCtrlTab);
|
|
|
|
pCtrlDlgState->pCtrlMap->SetTargetDevice(cursel);
|
|
|
|
switch (cursel)
|
|
|
|
{
|
|
|
|
case CONTROLS_KEYBOARD_INDEX:
|
|
|
|
{
|
2013-05-23 00:39:36 +00:00
|
|
|
for (u32 i = 0; i <= IDC_EDIT_KEYRIGHT - CONTROLS_IDC_EDIT_BEGIN; i++) {
|
|
|
|
HWND hEdit = GetDlgItem(hDlg, CONTROLS_IDC_EDIT_BEGIN + i);
|
|
|
|
u32 keyCode = pCtrlDlgState->pCtrlMap->GetBindCode(i);
|
|
|
|
SetWindowTextForButton(hEdit, keyCode, getVirtualKeyName(keyCode));
|
2013-05-17 10:31:06 +00:00
|
|
|
}
|
2013-05-19 09:12:22 +00:00
|
|
|
for (u32 i = 0; i <= CONTROLS_IDC_EDIT_END - IDC_EDIT_KEY_ANALOG_UP; i++) {
|
|
|
|
HWND hEdit = GetDlgItem(hDlg, IDC_EDIT_KEY_ANALOG_UP + i);
|
|
|
|
Edit_SetReadOnly(hEdit, FALSE);
|
2013-05-23 00:39:36 +00:00
|
|
|
u32 analogCode = pCtrlDlgState->pCtrlMap->GetBindCode(
|
|
|
|
CONTROLS_KEYBOARD_ANALOG_INDEX, i);
|
|
|
|
SetWindowTextForButton(hEdit, analogCode, getVirtualKeyName(analogCode));
|
2013-05-19 09:12:22 +00:00
|
|
|
}
|
2013-05-17 10:31:06 +00:00
|
|
|
InvalidateRect(hDlg, 0, 0);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CONTROLS_DIRECT_INPUT_INDEX:
|
|
|
|
{
|
|
|
|
|
2013-05-23 00:39:36 +00:00
|
|
|
for (u32 i = 0; i <= CONTROLS_IDC_EDIT_END - CONTROLS_IDC_EDIT_BEGIN; i++) {
|
|
|
|
HWND hEdit = GetDlgItem(hDlg, CONTROLS_IDC_EDIT_BEGIN + i);
|
|
|
|
int buttonCode = (int)pCtrlDlgState->pCtrlMap->GetBindCode(i);
|
2013-05-17 10:31:06 +00:00
|
|
|
char str[16];
|
2013-05-23 00:39:36 +00:00
|
|
|
if (i >= IDC_EDIT_KEYUP - CONTROLS_IDC_EDIT_BEGIN) {
|
|
|
|
if (i >= IDC_EDIT_KEY_ANALOG_UP - CONTROLS_IDC_EDIT_BEGIN) {
|
2013-05-17 10:31:06 +00:00
|
|
|
Edit_SetReadOnly(hEdit, TRUE);
|
|
|
|
SetWindowTextA(hEdit, controllist[i]);
|
|
|
|
} else {
|
|
|
|
int n = 1;
|
2013-05-23 00:39:36 +00:00
|
|
|
if (buttonCode != -1) {
|
|
|
|
for (int i = buttonCode >> 8; i > 1; i >>= 1) {
|
|
|
|
n++;
|
|
|
|
}
|
|
|
|
snprintf(str, CONTROLS_BUTTONNAME_MAX, "%s",
|
|
|
|
controllist[(IDC_EDIT_KEYUP - CONTROLS_IDC_EDIT_BEGIN - 1) + n]);
|
2013-05-17 10:31:06 +00:00
|
|
|
}
|
2013-05-23 00:39:36 +00:00
|
|
|
SetWindowTextForButton(hEdit, buttonCode + 1, str);
|
2013-05-17 10:31:06 +00:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
snprintf(str, CONTROLS_BUTTONNAME_MAX, "%d", pCtrlDlgState->pCtrlMap->GetBindCode(i) + 1);
|
2013-05-23 00:39:36 +00:00
|
|
|
SetWindowTextForButton(hEdit, buttonCode + 1, str);
|
2013-05-17 10:31:06 +00:00
|
|
|
}
|
|
|
|
InvalidateRect(hDlg, 0, 0);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CONTROLS_XINPUT_INDEX:
|
|
|
|
{
|
2013-05-23 00:39:36 +00:00
|
|
|
for (u32 i = 0; i <= CONTROLS_IDC_EDIT_END - CONTROLS_IDC_EDIT_BEGIN; i++) {
|
|
|
|
HWND hEdit = GetDlgItem(hDlg, CONTROLS_IDC_EDIT_BEGIN + i);
|
|
|
|
if (i >= IDC_EDIT_KEY_ANALOG_UP - CONTROLS_IDC_EDIT_BEGIN) {
|
2013-05-17 10:31:06 +00:00
|
|
|
Edit_SetReadOnly(hEdit, TRUE);
|
|
|
|
SetWindowTextA(hEdit, controllist[i]);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
u32 button = pCtrlDlgState->pCtrlMap->GetBindCode(i);
|
2013-05-23 00:39:36 +00:00
|
|
|
SetWindowTextForButton(hEdit, button, getXinputButtonName(button));
|
2013-05-17 10:31:06 +00:00
|
|
|
}
|
|
|
|
InvalidateRect(hDlg, 0, 0);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
} // pCtrlDlgState->curDevice
|
|
|
|
} // TCN_SELCHANGING:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
} // ((NMHDR *)lParam)->code
|
|
|
|
} // WM_NOTIFY:
|
|
|
|
break;
|
2013-04-18 09:13:00 +00:00
|
|
|
case WM_PAINT:
|
|
|
|
{
|
2013-05-17 10:31:06 +00:00
|
|
|
return DefWindowProc(hDlg, message, wParam, lParam);
|
2013-04-18 09:13:00 +00:00
|
|
|
}
|
|
|
|
case WM_CTLCOLORSTATIC:
|
|
|
|
{
|
|
|
|
HDC hdc=(HDC)wParam;
|
2013-05-17 10:31:06 +00:00
|
|
|
HWND hCtrl = (HWND)lParam;
|
2013-04-18 09:13:00 +00:00
|
|
|
SetBkMode(hdc, TRANSPARENT);
|
2013-05-17 10:31:06 +00:00
|
|
|
int ctrlId = GetDlgCtrlID(hCtrl);
|
|
|
|
if (ctrlId >= IDC_EDIT_KEY_ANALOG_UP && ctrlId <= IDC_EDIT_KEY_ANALOG_RIGHT) {
|
|
|
|
SetTextColor(hdc, RGB(128,128,128));
|
|
|
|
RECT rc = getRedrawRect(hCtrl);
|
|
|
|
TabCtrl_AdjustRect(pCtrlDlgState->hCtrlTab, TRUE, &rc);
|
|
|
|
RECT clientrc;
|
|
|
|
GetClientRect(hCtrl, &clientrc);
|
|
|
|
TabCtrl_AdjustRect(pCtrlDlgState->hCtrlTab, TRUE, &clientrc);
|
|
|
|
BitBlt(pCtrlDlgState->hbmPspImage, hdc, 0, 0, rc.right - rc.left, rc.bottom - rc.top, rc.left, rc.top);
|
|
|
|
char str[11];
|
|
|
|
GetWindowTextA(hCtrl, str, 10);
|
|
|
|
DrawTextA(hdc, str, (int)strlen(str), &clientrc, DT_CENTER|DT_SINGLELINE);
|
|
|
|
}
|
2013-04-18 09:13:00 +00:00
|
|
|
return (LRESULT)GetStockObject(NULL_BRUSH);
|
|
|
|
}
|
|
|
|
case WM_CTLCOLOREDIT:
|
|
|
|
{
|
2013-04-19 06:20:26 +00:00
|
|
|
if ((HWND)lParam == GetDlgItem(hDlg, IDC_FORCE_INPUT_DEVICE))
|
|
|
|
return FALSE;
|
2013-04-18 09:13:00 +00:00
|
|
|
HDC hdc = (HDC)wParam;
|
|
|
|
SetBkMode(hdc, TRANSPARENT);
|
|
|
|
SetTextColor(hdc, RGB(255, 0, 0));
|
|
|
|
HWND hEdit = (HWND)lParam;
|
|
|
|
RECT rc = getRedrawRect(hEdit);
|
2013-05-17 10:31:06 +00:00
|
|
|
TabCtrl_AdjustRect(pCtrlDlgState->hCtrlTab, TRUE, &rc);
|
2013-04-18 09:13:00 +00:00
|
|
|
RECT clientrc;
|
|
|
|
GetClientRect(hEdit, &clientrc);
|
2013-05-17 10:31:06 +00:00
|
|
|
TabCtrl_AdjustRect(pCtrlDlgState->hCtrlTab, TRUE, &clientrc);
|
|
|
|
BitBlt(pCtrlDlgState->hbmPspImage, hdc, 0, 0, rc.right - rc.left, rc.bottom - rc.top, rc.left, rc.top);
|
2013-04-18 09:13:00 +00:00
|
|
|
char str[11];
|
|
|
|
GetWindowTextA(hEdit, str, 10);
|
2013-04-19 15:41:31 +00:00
|
|
|
DrawTextA(hdc, str, (int)strlen(str), &clientrc, DT_CENTER|DT_SINGLELINE);
|
2013-04-18 09:13:00 +00:00
|
|
|
return (LRESULT)GetStockObject(NULL_BRUSH);
|
|
|
|
}
|
2013-01-02 21:57:57 +00:00
|
|
|
case WM_COMMAND:
|
2013-04-18 09:13:00 +00:00
|
|
|
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
|
2013-01-02 21:57:57 +00:00
|
|
|
{
|
2013-04-18 09:13:00 +00:00
|
|
|
if (LOWORD(wParam) == IDOK) {
|
2013-04-19 06:20:26 +00:00
|
|
|
g_Config.iForceInputDevice = (ComboBox_GetCurSel(GetDlgItem(hDlg, IDC_FORCE_INPUT_DEVICE)) - 1);
|
2013-05-17 10:31:06 +00:00
|
|
|
pCtrlDlgState->pCtrlMap->BindToDevices();
|
2013-04-18 09:13:00 +00:00
|
|
|
saveControlsToFile();
|
|
|
|
}
|
2013-05-17 10:31:06 +00:00
|
|
|
UnhookWindowsHookEx(pCtrlDlgState->pKeydownHook);
|
|
|
|
KillTimer(hDlg, pCtrlDlgState->timerId);
|
2013-05-19 12:10:05 +00:00
|
|
|
SetWindowLongPtr(pCtrlDlgState->hStaticPspImage, GWLP_WNDPROC, (LONG_PTR)pCtrlDlgState->orgPSPImageProc);
|
2013-05-23 00:39:36 +00:00
|
|
|
for (u32 i = CONTROLS_IDC_EDIT_BEGIN; i <= CONTROLS_IDC_EDIT_END; i++) {
|
|
|
|
HWND hEdit = GetDlgItem(hDlg, i);
|
|
|
|
SetWindowLongPtr(hEdit, GWLP_WNDPROC, (LONG_PTR)pCtrlDlgState->orgEditProc);
|
|
|
|
}
|
2013-04-18 09:13:00 +00:00
|
|
|
EndDialog(hDlg, LOWORD(wParam));
|
2013-05-17 10:31:06 +00:00
|
|
|
if (pCtrlDlgState->hbmPspImage) {
|
|
|
|
DeleteObject(pCtrlDlgState->hbmPspImage);
|
|
|
|
pCtrlDlgState->hbmPspImage = 0;
|
|
|
|
}
|
2013-05-23 00:39:36 +00:00
|
|
|
if (pCtrlDlgState->pCtrlMap) {
|
|
|
|
delete pCtrlDlgState->pCtrlMap;
|
|
|
|
pCtrlDlgState->pCtrlMap = NULL;
|
|
|
|
}
|
2013-05-17 10:31:06 +00:00
|
|
|
if (pCtrlDlgState) {
|
|
|
|
delete pCtrlDlgState;
|
|
|
|
pCtrlDlgState = NULL;
|
2013-04-19 09:21:16 +00:00
|
|
|
}
|
2013-04-18 09:13:00 +00:00
|
|
|
return TRUE;
|
2013-05-23 00:39:36 +00:00
|
|
|
} else if (LOWORD(wParam) >= CONTROLS_IDC_EDIT_BEGIN &&
|
2013-05-17 10:31:06 +00:00
|
|
|
LOWORD(wParam) <= IDC_EDIT_KEYRIGHT &&
|
|
|
|
HIWORD(wParam) == EN_SETFOCUS) {
|
|
|
|
// send about buttonsMap-index of current focus Edit-Control to ControlMapping instance.
|
|
|
|
UINT nCtrlID = LOWORD(wParam);
|
2013-05-23 00:39:36 +00:00
|
|
|
if (nCtrlID < CONTROLS_IDC_EDIT_BEGIN || nCtrlID > IDC_EDIT_KEYRIGHT) {
|
2013-05-17 10:31:06 +00:00
|
|
|
break;
|
|
|
|
}
|
2013-05-23 00:39:36 +00:00
|
|
|
pCtrlDlgState->pCtrlMap->SetTargetButton(nCtrlID - CONTROLS_IDC_EDIT_BEGIN);
|
2013-01-02 21:57:57 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2012-11-01 15:19:01 +00:00
|
|
|
void Update()
|
|
|
|
{
|
|
|
|
InvalidateRect(hwndDisplay,0,0);
|
|
|
|
UpdateWindow(hwndDisplay);
|
|
|
|
SendMessage(hwndMain,WM_SIZE,0,0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Redraw()
|
|
|
|
{
|
|
|
|
InvalidateRect(hwndDisplay,0,0);
|
|
|
|
}
|
2013-03-29 20:21:27 +00:00
|
|
|
|
2012-12-05 06:31:41 +00:00
|
|
|
void _ViewNormal(HWND hWnd)
|
|
|
|
{
|
2013-05-02 22:27:46 +00:00
|
|
|
ShowCursor(TRUE);
|
|
|
|
SetCursor(LoadCursor(NULL, IDC_ARROW));
|
2013-05-04 21:21:06 +00:00
|
|
|
|
2012-12-22 00:57:44 +00:00
|
|
|
// put caption and border styles back
|
|
|
|
DWORD dwOldStyle = ::GetWindowLong(hWnd, GWL_STYLE);
|
|
|
|
DWORD dwNewStyle = dwOldStyle | WS_CAPTION | WS_THICKFRAME;
|
|
|
|
::SetWindowLong(hWnd, GWL_STYLE, dwNewStyle);
|
|
|
|
|
|
|
|
// put back the menu bar
|
|
|
|
::SetMenu(hWnd, menu);
|
|
|
|
|
|
|
|
// resize to normal view
|
|
|
|
// NOTE: use SWP_FRAMECHANGED to force redraw non-client
|
|
|
|
const int x = g_normalRC.left;
|
|
|
|
const int y = g_normalRC.top;
|
|
|
|
const int cx = g_normalRC.right - g_normalRC.left;
|
|
|
|
const int cy = g_normalRC.bottom - g_normalRC.top;
|
|
|
|
::SetWindowPos(hWnd, HWND_NOTOPMOST, x, y, cx, cy, SWP_FRAMECHANGED);
|
|
|
|
|
|
|
|
// reset full screen indicator
|
|
|
|
g_bFullScreen = FALSE;
|
2013-01-26 22:46:02 +00:00
|
|
|
ResizeDisplay();
|
2012-12-05 06:31:41 +00:00
|
|
|
}
|
|
|
|
|
2012-12-22 00:57:44 +00:00
|
|
|
void _ViewFullScreen(HWND hWnd)
|
|
|
|
{
|
2013-05-04 21:54:22 +00:00
|
|
|
if (globalUIState == UISTATE_INGAME)
|
|
|
|
ShowCursor(FALSE);
|
2013-05-04 21:21:06 +00:00
|
|
|
|
2012-12-22 00:57:44 +00:00
|
|
|
// keep in mind normal window rectangle
|
|
|
|
::GetWindowRect(hWnd, &g_normalRC);
|
|
|
|
|
|
|
|
// remove caption and border styles
|
|
|
|
DWORD dwOldStyle = ::GetWindowLong(hWnd, GWL_STYLE);
|
|
|
|
DWORD dwNewStyle = dwOldStyle & ~(WS_CAPTION | WS_THICKFRAME);
|
|
|
|
::SetWindowLong(hWnd, GWL_STYLE, dwNewStyle);
|
|
|
|
|
|
|
|
// remove the menu bar
|
|
|
|
::SetMenu(hWnd, NULL);
|
|
|
|
|
|
|
|
// resize to full screen view
|
|
|
|
// NOTE: use SWP_FRAMECHANGED to force redraw non-client
|
|
|
|
const int x = 0;
|
|
|
|
const int y = 0;
|
|
|
|
const int cx = ::GetSystemMetrics(SM_CXSCREEN);
|
|
|
|
const int cy = ::GetSystemMetrics(SM_CYSCREEN);
|
|
|
|
::SetWindowPos(hWnd, HWND_TOPMOST, x, y, cx, cy, SWP_FRAMECHANGED);
|
|
|
|
|
|
|
|
// set full screen indicator
|
|
|
|
g_bFullScreen = TRUE;
|
2013-01-26 22:46:02 +00:00
|
|
|
ResizeDisplay();
|
2012-12-22 00:57:44 +00:00
|
|
|
}
|
2012-11-01 15:19:01 +00:00
|
|
|
|
|
|
|
void SetPlaying(const char *text)
|
|
|
|
{
|
2013-03-02 20:31:11 +00:00
|
|
|
char temp[256];
|
2012-11-01 15:19:01 +00:00
|
|
|
if (text == 0)
|
2013-03-02 20:31:11 +00:00
|
|
|
snprintf(temp, 256, "PPSSPP %s", PPSSPP_GIT_VERSION);
|
2012-11-01 15:19:01 +00:00
|
|
|
else
|
2013-03-02 20:31:11 +00:00
|
|
|
snprintf(temp, 256, "%s - PPSSPP %s", text, PPSSPP_GIT_VERSION);
|
|
|
|
temp[255] = '\0';
|
|
|
|
SetWindowText(hwndMain, temp);
|
2012-11-01 15:19:01 +00:00
|
|
|
}
|
|
|
|
|
2013-01-02 20:00:10 +00:00
|
|
|
void SaveStateActionFinished(bool result, void *userdata)
|
2012-12-28 21:50:59 +00:00
|
|
|
{
|
|
|
|
if (!result)
|
2013-04-13 08:39:17 +00:00
|
|
|
MessageBox(0, "Savestate failure. Using savestates between different PPSSPP versions is not supported.", "Sorry", MB_OK);
|
2012-12-28 21:50:59 +00:00
|
|
|
SetCursor(LoadCursor(0, IDC_ARROW));
|
|
|
|
}
|
|
|
|
|
2012-11-01 15:19:01 +00:00
|
|
|
HINSTANCE GetHInstance()
|
|
|
|
{
|
|
|
|
return hInst;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|