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:
gabest11 2009-06-16 02:28:43 +00:00
parent 48eae0c907
commit d1c7d2f1a6
4 changed files with 101 additions and 101 deletions

View File

@ -4,58 +4,93 @@
#pragma once
#pragma warning(disable: 4996)
#pragma warning(disable: 4996 4995 4324 4100 4101 4201)
#ifndef VC_EXTRALEAN
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#endif
// The following macros define the minimum required platform. The minimum required platform
// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run
// 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.
// 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
#ifndef _WIN32_WINNT // Allow use of features specific to Windows NT 4 or later.
#define _WIN32_WINNT 0x0400 // Change this to the appropriate value to target Windows 2000 or later.
#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista.
#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows.
#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.
#endif
#ifndef _WIN32_IE // Allow use of features specific to IE 4.0 or later.
#define _WIN32_IE 0x0400 // Change this to the appropriate value to target IE 5.0 or later.
#ifndef _WIN32_IE // Specifies that the minimum required platform is Internet Explorer 7.0.
#define _WIN32_IE 0x0700 // Change this to the appropriate value to target other versions of IE.
#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 <afxext.h> // MFC extensions
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
//#include <afxmt.h>
#include <windows.h>
#include <commctrl.h>
#include <commdlg.h>
#include <shellapi.h>
#include <atlbase.h>
#include <atlcoll.h>
#include <atlpath.h>
#include <math.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_(type) extern "C" __declspec(dllexport) type __stdcall
#define ALIGN_STACK(n) __declspec(align(n)) int __dummy;
#ifndef RESTRICT
#ifdef __INTEL_COMPILER
#define RESTRICT restrict
#elif _MSC_VER >= 1400
#elif _MSC_VER >= 1400 // TODO: gcc
#define RESTRICT __restrict
#else
#define RESTRICT
#endif
#endif
#pragma warning(disable : 4995 4324 4100)
#if defined(_DEBUG) && defined(_MSC_VER)
#define ASSERT assert
#else
#define ASSERT(exp) ((void)0)
#endif

View File

@ -22,51 +22,19 @@
#include "stdafx.h"
#include "xpad.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
static HMODULE s_hModule;
//
// 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()
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
}
xpadApp theApp;
BOOL xpadApp::InitInstance()
{
__super::InitInstance();
SetRegistryKey(_T("Gabest"));
switch(ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
s_hModule = hModule;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
@ -328,7 +296,7 @@ public:
static class XPadPlugin
{
CAtlArray<XPad*> m_pads;
vector<XPad*> m_pads;
XPad* m_pad;
int m_index;
bool m_cfgreaddata;
@ -531,7 +499,7 @@ static class XPadPlugin
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;
}
@ -544,8 +512,8 @@ public:
, m_cfgreaddata(false)
, m_handler(NULL)
{
m_pads.Add(new XPad(0));
m_pads.Add(new XPad(1));
m_pads.push_back(new XPad(0));
m_pads.push_back(new XPad(1));
for(int i = 0; i < countof(m_handlers); i++)
{
@ -565,6 +533,16 @@ public:
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)
{
m_pad = m_pads[pad & 1];
@ -602,7 +580,7 @@ static int s_nRefs = 0;
static HWND s_hWnd = NULL;
static WNDPROC s_GSWndProc = NULL;
static class CKeyEventList : protected CAtlList<KeyEvent>, protected CCritSec
static class CKeyEventList : protected list<KeyEvent>, protected CCritSec
{
public:
void Push(UINT32 event, UINT32 key)
@ -614,16 +592,18 @@ public:
e.event = event;
e.key = key;
AddTail(e);
push_back(e);
}
bool Pop(KeyEvent& e)
{
CAutoLock cAutoLock(this);
if(IsEmpty()) return false;
if(empty()) return false;
e = RemoveHead();
e = front();
pop_front();
return true;
}
@ -647,7 +627,7 @@ LRESULT WINAPI PADwndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
break;
}
return s_GSWndProc(hWnd, msg, wParam, lParam);
return CallWindowProc(s_GSWndProc, hWnd, msg, wParam, lParam);
}
//

View File

@ -21,21 +21,6 @@
#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
#define PSE_LT_PAD 8

View File

@ -23,7 +23,7 @@
Name="Debug|Win32"
ConfigurationType="2"
InheritedPropertySheets=".\vsprops\common.vsprops;.\vsprops\ProjectRootDir.vsprops;..\..\common\vsprops\BaseProperties.vsprops;.\vsprops\debug.vsprops"
UseOfMFC="1"
UseOfMFC="0"
CharacterSet="2"
>
<Tool
@ -151,7 +151,7 @@
Name="Release|Win32"
ConfigurationType="2"
InheritedPropertySheets=".\vsprops\common.vsprops;.\vsprops\ProjectRootDir.vsprops;..\..\common\vsprops\BaseProperties.vsprops;.\vsprops\release.vsprops"
UseOfMFC="1"
UseOfMFC="0"
CharacterSet="2"
WholeProgramOptimization="1"
>
@ -281,7 +281,7 @@
Name="Debug SSE2|Win32"
ConfigurationType="2"
InheritedPropertySheets=".\vsprops\common.vsprops;.\vsprops\ProjectRootDir.vsprops;..\..\common\vsprops\BaseProperties.vsprops;.\vsprops\debug.vsprops;.\vsprops\sse2.vsprops"
UseOfMFC="1"
UseOfMFC="0"
CharacterSet="2"
>
<Tool
@ -408,7 +408,7 @@
Name="Release SSE2|Win32"
ConfigurationType="2"
InheritedPropertySheets=".\vsprops\common.vsprops;.\vsprops\ProjectRootDir.vsprops;..\..\common\vsprops\BaseProperties.vsprops;.\vsprops\release.vsprops;.\vsprops\sse2.vsprops"
UseOfMFC="1"
UseOfMFC="0"
CharacterSet="2"
WholeProgramOptimization="1"
>
@ -536,7 +536,7 @@
Name="Release SSSE3|Win32"
ConfigurationType="2"
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"
WholeProgramOptimization="1"
>
@ -664,7 +664,7 @@
Name="Debug SSSE3|Win32"
ConfigurationType="2"
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"
>
<Tool
@ -790,7 +790,7 @@
Name="Debug SSE4|Win32"
ConfigurationType="2"
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"
>
<Tool
@ -917,7 +917,7 @@
Name="Release SSE4|Win32"
ConfigurationType="2"
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"
WholeProgramOptimization="1"
>