mirror of https://github.com/PCSX2/pcsx2.git
xpad: fixed a crash that happened when subclassing an opengl window, also got rid of mfc.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1373 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
48eae0c907
commit
d1c7d2f1a6
|
@ -4,58 +4,93 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#pragma warning(disable: 4996)
|
#pragma warning(disable: 4996 4995 4324 4100 4101 4201)
|
||||||
|
|
||||||
#ifndef VC_EXTRALEAN
|
// The following macros define the minimum required platform. The minimum required platform
|
||||||
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
|
// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run
|
||||||
#endif
|
// your application. The macros work by enabling all features available on platform versions up to and
|
||||||
|
// including the version specified.
|
||||||
|
|
||||||
// Modify the following defines if you have to target a platform prior to the ones specified below.
|
// Modify the following defines if you have to target a platform prior to the ones specified below.
|
||||||
// Refer to MSDN for the latest info on corresponding values for different platforms.
|
// Refer to MSDN for the latest info on corresponding values for different platforms.
|
||||||
#ifndef WINVER // Allow use of features specific to Windows 95 and Windows NT 4 or later.
|
|
||||||
#define WINVER 0x0510 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
|
#ifndef WINVER // Specifies that the minimum required platform is Windows Vista.
|
||||||
|
#define WINVER 0x0600 // Change this to the appropriate value to target other versions of Windows.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef _WIN32_WINNT // Allow use of features specific to Windows NT 4 or later.
|
#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista.
|
||||||
#define _WIN32_WINNT 0x0400 // Change this to the appropriate value to target Windows 2000 or later.
|
#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later.
|
#ifndef _WIN32_WINDOWS // Specifies that the minimum required platform is Windows 98.
|
||||||
#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
|
#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef _WIN32_IE // Allow use of features specific to IE 4.0 or later.
|
#ifndef _WIN32_IE // Specifies that the minimum required platform is Internet Explorer 7.0.
|
||||||
#define _WIN32_IE 0x0400 // Change this to the appropriate value to target IE 5.0 or later.
|
#define _WIN32_IE 0x0700 // Change this to the appropriate value to target other versions of IE.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
|
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||||
|
|
||||||
#include <afxwin.h> // MFC core and standard components
|
#include <windows.h>
|
||||||
//#include <afxext.h> // MFC extensions
|
#include <commctrl.h>
|
||||||
#ifndef _AFX_NO_AFXCMN_SUPPORT
|
#include <commdlg.h>
|
||||||
#include <afxcmn.h> // MFC support for Windows Common Controls
|
#include <shellapi.h>
|
||||||
#endif // _AFX_NO_AFXCMN_SUPPORT
|
|
||||||
//#include <afxmt.h>
|
|
||||||
#include <atlbase.h>
|
#include <atlbase.h>
|
||||||
#include <atlcoll.h>
|
|
||||||
#include <atlpath.h>
|
|
||||||
#include <math.h>
|
|
||||||
#include <xinput.h>
|
#include <xinput.h>
|
||||||
|
|
||||||
#define countof(a) (sizeof(a)/sizeof(a[0]))
|
// stdc
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <intrin.h>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include <list>
|
||||||
|
#include <map>
|
||||||
|
#include <hash_map>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
using namespace stdext;
|
||||||
|
|
||||||
|
extern string format(const char* fmt, ...);
|
||||||
|
|
||||||
|
// syntactic sugar
|
||||||
|
|
||||||
|
// put these into vc9/common7/ide/usertype.dat to have them highlighted
|
||||||
|
|
||||||
|
typedef unsigned char uint8;
|
||||||
|
typedef signed char int8;
|
||||||
|
typedef unsigned short uint16;
|
||||||
|
typedef signed short int16;
|
||||||
|
typedef unsigned int uint32;
|
||||||
|
typedef signed int int32;
|
||||||
|
typedef unsigned long long uint64;
|
||||||
|
typedef signed long long int64;
|
||||||
|
|
||||||
|
#define countof(a) (sizeof(a) / sizeof(a[0]))
|
||||||
|
|
||||||
#define EXPORT_C extern "C" __declspec(dllexport) void __stdcall
|
#define EXPORT_C extern "C" __declspec(dllexport) void __stdcall
|
||||||
#define EXPORT_C_(type) extern "C" __declspec(dllexport) type __stdcall
|
#define EXPORT_C_(type) extern "C" __declspec(dllexport) type __stdcall
|
||||||
|
|
||||||
|
#define ALIGN_STACK(n) __declspec(align(n)) int __dummy;
|
||||||
|
|
||||||
#ifndef RESTRICT
|
#ifndef RESTRICT
|
||||||
#ifdef __INTEL_COMPILER
|
#ifdef __INTEL_COMPILER
|
||||||
#define RESTRICT restrict
|
#define RESTRICT restrict
|
||||||
#elif _MSC_VER >= 1400
|
#elif _MSC_VER >= 1400 // TODO: gcc
|
||||||
#define RESTRICT __restrict
|
#define RESTRICT __restrict
|
||||||
#else
|
#else
|
||||||
#define RESTRICT
|
#define RESTRICT
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#pragma warning(disable : 4995 4324 4100)
|
#if defined(_DEBUG) && defined(_MSC_VER)
|
||||||
|
#define ASSERT assert
|
||||||
|
#else
|
||||||
|
#define ASSERT(exp) ((void)0)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -22,51 +22,19 @@
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "xpad.h"
|
#include "xpad.h"
|
||||||
|
|
||||||
#ifdef _DEBUG
|
static HMODULE s_hModule;
|
||||||
#define new DEBUG_NEW
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//
|
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
|
||||||
// Note!
|
|
||||||
//
|
|
||||||
// If this DLL is dynamically linked against the MFC
|
|
||||||
// DLLs, any functions exported from this DLL which
|
|
||||||
// call into MFC must have the AFX_MANAGE_STATE macro
|
|
||||||
// added at the very beginning of the function.
|
|
||||||
//
|
|
||||||
// For example:
|
|
||||||
//
|
|
||||||
// extern "C" BOOL PASCAL EXPORT ExportedFunction()
|
|
||||||
// {
|
|
||||||
// AFX_MANAGE_STATE(AfxGetStaticModuleState());
|
|
||||||
// // normal function body here
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// It is very important that this macro appear in each
|
|
||||||
// function, prior to any calls into MFC. This means that
|
|
||||||
// it must appear as the first statement within the
|
|
||||||
// function, even before any object variable declarations
|
|
||||||
// as their constructors may generate calls into the MFC
|
|
||||||
// DLL.
|
|
||||||
//
|
|
||||||
// Please see MFC Technical Notes 33 and 58 for additional
|
|
||||||
// details.
|
|
||||||
//
|
|
||||||
|
|
||||||
BEGIN_MESSAGE_MAP(xpadApp, CWinApp)
|
|
||||||
END_MESSAGE_MAP()
|
|
||||||
|
|
||||||
xpadApp::xpadApp()
|
|
||||||
{
|
{
|
||||||
}
|
switch(ul_reason_for_call)
|
||||||
|
{
|
||||||
xpadApp theApp;
|
case DLL_PROCESS_ATTACH:
|
||||||
|
s_hModule = hModule;
|
||||||
BOOL xpadApp::InitInstance()
|
case DLL_THREAD_ATTACH:
|
||||||
{
|
case DLL_THREAD_DETACH:
|
||||||
__super::InitInstance();
|
case DLL_PROCESS_DETACH:
|
||||||
|
break;
|
||||||
SetRegistryKey(_T("Gabest"));
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -328,7 +296,7 @@ public:
|
||||||
|
|
||||||
static class XPadPlugin
|
static class XPadPlugin
|
||||||
{
|
{
|
||||||
CAtlArray<XPad*> m_pads;
|
vector<XPad*> m_pads;
|
||||||
XPad* m_pad;
|
XPad* m_pad;
|
||||||
int m_index;
|
int m_index;
|
||||||
bool m_cfgreaddata;
|
bool m_cfgreaddata;
|
||||||
|
@ -531,7 +499,7 @@ static class XPadPlugin
|
||||||
|
|
||||||
BYTE UnknownCommand(int index, BYTE value)
|
BYTE UnknownCommand(int index, BYTE value)
|
||||||
{
|
{
|
||||||
TRACE(_T("Unknown command %02x (%d, %02x)\n"), m_cmd, index, value);
|
// printf("Unknown command %02x (%d, %02x)\n", m_cmd, index, value);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -544,8 +512,8 @@ public:
|
||||||
, m_cfgreaddata(false)
|
, m_cfgreaddata(false)
|
||||||
, m_handler(NULL)
|
, m_handler(NULL)
|
||||||
{
|
{
|
||||||
m_pads.Add(new XPad(0));
|
m_pads.push_back(new XPad(0));
|
||||||
m_pads.Add(new XPad(1));
|
m_pads.push_back(new XPad(1));
|
||||||
|
|
||||||
for(int i = 0; i < countof(m_handlers); i++)
|
for(int i = 0; i < countof(m_handlers); i++)
|
||||||
{
|
{
|
||||||
|
@ -565,6 +533,16 @@ public:
|
||||||
m_handlers['O'] = &XPadPlugin::SetDS2NativeMode;
|
m_handlers['O'] = &XPadPlugin::SetDS2NativeMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual ~XPadPlugin()
|
||||||
|
{
|
||||||
|
for(vector<XPad*>::iterator i = m_pads.begin(); i != m_pads.end(); i++)
|
||||||
|
{
|
||||||
|
delete *i;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_pads.clear();
|
||||||
|
}
|
||||||
|
|
||||||
void StartPoll(int pad)
|
void StartPoll(int pad)
|
||||||
{
|
{
|
||||||
m_pad = m_pads[pad & 1];
|
m_pad = m_pads[pad & 1];
|
||||||
|
@ -602,7 +580,7 @@ static int s_nRefs = 0;
|
||||||
static HWND s_hWnd = NULL;
|
static HWND s_hWnd = NULL;
|
||||||
static WNDPROC s_GSWndProc = NULL;
|
static WNDPROC s_GSWndProc = NULL;
|
||||||
|
|
||||||
static class CKeyEventList : protected CAtlList<KeyEvent>, protected CCritSec
|
static class CKeyEventList : protected list<KeyEvent>, protected CCritSec
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void Push(UINT32 event, UINT32 key)
|
void Push(UINT32 event, UINT32 key)
|
||||||
|
@ -614,16 +592,18 @@ public:
|
||||||
e.event = event;
|
e.event = event;
|
||||||
e.key = key;
|
e.key = key;
|
||||||
|
|
||||||
AddTail(e);
|
push_back(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Pop(KeyEvent& e)
|
bool Pop(KeyEvent& e)
|
||||||
{
|
{
|
||||||
CAutoLock cAutoLock(this);
|
CAutoLock cAutoLock(this);
|
||||||
|
|
||||||
if(IsEmpty()) return false;
|
if(empty()) return false;
|
||||||
|
|
||||||
e = RemoveHead();
|
e = front();
|
||||||
|
|
||||||
|
pop_front();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -647,7 +627,7 @@ LRESULT WINAPI PADwndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return s_GSWndProc(hWnd, msg, wParam, lParam);
|
return CallWindowProc(s_GSWndProc, hWnd, msg, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -21,21 +21,6 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifndef __AFXWIN_H__
|
|
||||||
#error include 'stdafx.h' before including this file for PCH
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class xpadApp : public CWinApp
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
xpadApp();
|
|
||||||
|
|
||||||
public:
|
|
||||||
virtual BOOL InitInstance();
|
|
||||||
|
|
||||||
DECLARE_MESSAGE_MAP()
|
|
||||||
};
|
|
||||||
|
|
||||||
// ps1
|
// ps1
|
||||||
|
|
||||||
#define PSE_LT_PAD 8
|
#define PSE_LT_PAD 8
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
Name="Debug|Win32"
|
Name="Debug|Win32"
|
||||||
ConfigurationType="2"
|
ConfigurationType="2"
|
||||||
InheritedPropertySheets=".\vsprops\common.vsprops;.\vsprops\ProjectRootDir.vsprops;..\..\common\vsprops\BaseProperties.vsprops;.\vsprops\debug.vsprops"
|
InheritedPropertySheets=".\vsprops\common.vsprops;.\vsprops\ProjectRootDir.vsprops;..\..\common\vsprops\BaseProperties.vsprops;.\vsprops\debug.vsprops"
|
||||||
UseOfMFC="1"
|
UseOfMFC="0"
|
||||||
CharacterSet="2"
|
CharacterSet="2"
|
||||||
>
|
>
|
||||||
<Tool
|
<Tool
|
||||||
|
@ -151,7 +151,7 @@
|
||||||
Name="Release|Win32"
|
Name="Release|Win32"
|
||||||
ConfigurationType="2"
|
ConfigurationType="2"
|
||||||
InheritedPropertySheets=".\vsprops\common.vsprops;.\vsprops\ProjectRootDir.vsprops;..\..\common\vsprops\BaseProperties.vsprops;.\vsprops\release.vsprops"
|
InheritedPropertySheets=".\vsprops\common.vsprops;.\vsprops\ProjectRootDir.vsprops;..\..\common\vsprops\BaseProperties.vsprops;.\vsprops\release.vsprops"
|
||||||
UseOfMFC="1"
|
UseOfMFC="0"
|
||||||
CharacterSet="2"
|
CharacterSet="2"
|
||||||
WholeProgramOptimization="1"
|
WholeProgramOptimization="1"
|
||||||
>
|
>
|
||||||
|
@ -281,7 +281,7 @@
|
||||||
Name="Debug SSE2|Win32"
|
Name="Debug SSE2|Win32"
|
||||||
ConfigurationType="2"
|
ConfigurationType="2"
|
||||||
InheritedPropertySheets=".\vsprops\common.vsprops;.\vsprops\ProjectRootDir.vsprops;..\..\common\vsprops\BaseProperties.vsprops;.\vsprops\debug.vsprops;.\vsprops\sse2.vsprops"
|
InheritedPropertySheets=".\vsprops\common.vsprops;.\vsprops\ProjectRootDir.vsprops;..\..\common\vsprops\BaseProperties.vsprops;.\vsprops\debug.vsprops;.\vsprops\sse2.vsprops"
|
||||||
UseOfMFC="1"
|
UseOfMFC="0"
|
||||||
CharacterSet="2"
|
CharacterSet="2"
|
||||||
>
|
>
|
||||||
<Tool
|
<Tool
|
||||||
|
@ -408,7 +408,7 @@
|
||||||
Name="Release SSE2|Win32"
|
Name="Release SSE2|Win32"
|
||||||
ConfigurationType="2"
|
ConfigurationType="2"
|
||||||
InheritedPropertySheets=".\vsprops\common.vsprops;.\vsprops\ProjectRootDir.vsprops;..\..\common\vsprops\BaseProperties.vsprops;.\vsprops\release.vsprops;.\vsprops\sse2.vsprops"
|
InheritedPropertySheets=".\vsprops\common.vsprops;.\vsprops\ProjectRootDir.vsprops;..\..\common\vsprops\BaseProperties.vsprops;.\vsprops\release.vsprops;.\vsprops\sse2.vsprops"
|
||||||
UseOfMFC="1"
|
UseOfMFC="0"
|
||||||
CharacterSet="2"
|
CharacterSet="2"
|
||||||
WholeProgramOptimization="1"
|
WholeProgramOptimization="1"
|
||||||
>
|
>
|
||||||
|
@ -536,7 +536,7 @@
|
||||||
Name="Release SSSE3|Win32"
|
Name="Release SSSE3|Win32"
|
||||||
ConfigurationType="2"
|
ConfigurationType="2"
|
||||||
InheritedPropertySheets=".\vsprops\common.vsprops;.\vsprops\ProjectRootDir.vsprops;..\..\common\vsprops\BaseProperties.vsprops;.\vsprops\release.vsprops;.\vsprops\sse2.vsprops;.\vsprops\ssse3.vsprops"
|
InheritedPropertySheets=".\vsprops\common.vsprops;.\vsprops\ProjectRootDir.vsprops;..\..\common\vsprops\BaseProperties.vsprops;.\vsprops\release.vsprops;.\vsprops\sse2.vsprops;.\vsprops\ssse3.vsprops"
|
||||||
UseOfMFC="1"
|
UseOfMFC="0"
|
||||||
CharacterSet="2"
|
CharacterSet="2"
|
||||||
WholeProgramOptimization="1"
|
WholeProgramOptimization="1"
|
||||||
>
|
>
|
||||||
|
@ -664,7 +664,7 @@
|
||||||
Name="Debug SSSE3|Win32"
|
Name="Debug SSSE3|Win32"
|
||||||
ConfigurationType="2"
|
ConfigurationType="2"
|
||||||
InheritedPropertySheets=".\vsprops\common.vsprops;.\vsprops\ProjectRootDir.vsprops;..\..\common\vsprops\BaseProperties.vsprops;.\vsprops\debug.vsprops;.\vsprops\sse2.vsprops;.\vsprops\ssse3.vsprops"
|
InheritedPropertySheets=".\vsprops\common.vsprops;.\vsprops\ProjectRootDir.vsprops;..\..\common\vsprops\BaseProperties.vsprops;.\vsprops\debug.vsprops;.\vsprops\sse2.vsprops;.\vsprops\ssse3.vsprops"
|
||||||
UseOfMFC="1"
|
UseOfMFC="0"
|
||||||
CharacterSet="2"
|
CharacterSet="2"
|
||||||
>
|
>
|
||||||
<Tool
|
<Tool
|
||||||
|
@ -790,7 +790,7 @@
|
||||||
Name="Debug SSE4|Win32"
|
Name="Debug SSE4|Win32"
|
||||||
ConfigurationType="2"
|
ConfigurationType="2"
|
||||||
InheritedPropertySheets=".\vsprops\common.vsprops;.\vsprops\ProjectRootDir.vsprops;..\..\common\vsprops\BaseProperties.vsprops;.\vsprops\debug.vsprops;.\vsprops\sse2.vsprops;.\vsprops\sse4.vsprops"
|
InheritedPropertySheets=".\vsprops\common.vsprops;.\vsprops\ProjectRootDir.vsprops;..\..\common\vsprops\BaseProperties.vsprops;.\vsprops\debug.vsprops;.\vsprops\sse2.vsprops;.\vsprops\sse4.vsprops"
|
||||||
UseOfMFC="1"
|
UseOfMFC="0"
|
||||||
CharacterSet="2"
|
CharacterSet="2"
|
||||||
>
|
>
|
||||||
<Tool
|
<Tool
|
||||||
|
@ -917,7 +917,7 @@
|
||||||
Name="Release SSE4|Win32"
|
Name="Release SSE4|Win32"
|
||||||
ConfigurationType="2"
|
ConfigurationType="2"
|
||||||
InheritedPropertySheets=".\vsprops\common.vsprops;.\vsprops\ProjectRootDir.vsprops;..\..\common\vsprops\BaseProperties.vsprops;.\vsprops\release.vsprops;.\vsprops\sse2.vsprops;.\vsprops\sse4.vsprops"
|
InheritedPropertySheets=".\vsprops\common.vsprops;.\vsprops\ProjectRootDir.vsprops;..\..\common\vsprops\BaseProperties.vsprops;.\vsprops\release.vsprops;.\vsprops\sse2.vsprops;.\vsprops\sse4.vsprops"
|
||||||
UseOfMFC="1"
|
UseOfMFC="0"
|
||||||
CharacterSet="2"
|
CharacterSet="2"
|
||||||
WholeProgramOptimization="1"
|
WholeProgramOptimization="1"
|
||||||
>
|
>
|
||||||
|
|
Loading…
Reference in New Issue