Removed uses of CList, CEvent, CEventEx, CEventHandler.

Fixed TR1 compilance.
Input configuration support for Win32.
Support for analog axis in PadMan.

git-svn-id: http://svn.purei.org/purei/trunk@361 b36208d7-6611-0410-8bec-b1987f11c4a2
This commit is contained in:
jpd002 2008-08-24 21:28:42 +00:00
parent e8ecbf8435
commit 14129468e4
58 changed files with 1334 additions and 1011 deletions

View File

@ -5,6 +5,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Purei", "Purei.vcproj", "{2
ProjectSection(ProjectDependencies) = postProject
{574213AF-BAE8-4910-A0ED-97867315252C} = {574213AF-BAE8-4910-A0ED-97867315252C}
{E3CCDBB1-FB55-4416-BE80-FAB313BE549C} = {E3CCDBB1-FB55-4416-BE80-FAB313BE549C}
{9A081ACD-40DA-4924-8EA2-2A02F5B73B37} = {9A081ACD-40DA-4924-8EA2-2A02F5B73B37}
{AFF74BD9-3269-4E34-AE19-0A5CBA5354D0} = {AFF74BD9-3269-4E34-AE19-0A5CBA5354D0}
{5616C3F7-5DC5-4762-BC6E-2170E96F13FB} = {5616C3F7-5DC5-4762-BC6E-2170E96F13FB}
EndProjectSection
@ -12,11 +13,19 @@ EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Framework", "..\Framework\Framework.vcproj", "{E3CCDBB1-FB55-4416-BE80-FAB313BE549C}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FrameworkOpenGl", "..\Framework\FrameworkOpenGl.vcproj", "{5616C3F7-5DC5-4762-BC6E-2170E96F13FB}"
ProjectSection(ProjectDependencies) = postProject
{E3CCDBB1-FB55-4416-BE80-FAB313BE549C} = {E3CCDBB1-FB55-4416-BE80-FAB313BE549C}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlib-1.2.3", "..\zlib-1.2.3\zlib-1.2.3.vcproj", "{574213AF-BAE8-4910-A0ED-97867315252C}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bzip2-1.0.4", "..\bzip2-1.0.4\bzip2-1.0.4.vcproj", "{AFF74BD9-3269-4E34-AE19-0A5CBA5354D0}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FrameworkDirectX", "..\Framework\FrameworkDirectX.vcproj", "{9A081ACD-40DA-4924-8EA2-2A02F5B73B37}"
ProjectSection(ProjectDependencies) = postProject
{E3CCDBB1-FB55-4416-BE80-FAB313BE549C} = {E3CCDBB1-FB55-4416-BE80-FAB313BE549C}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
@ -43,6 +52,10 @@ Global
{AFF74BD9-3269-4E34-AE19-0A5CBA5354D0}.Debug|Win32.Build.0 = Debug|Win32
{AFF74BD9-3269-4E34-AE19-0A5CBA5354D0}.Release|Win32.ActiveCfg = Release|Win32
{AFF74BD9-3269-4E34-AE19-0A5CBA5354D0}.Release|Win32.Build.0 = Release|Win32
{9A081ACD-40DA-4924-8EA2-2A02F5B73B37}.Debug|Win32.ActiveCfg = Debug|Win32
{9A081ACD-40DA-4924-8EA2-2A02F5B73B37}.Debug|Win32.Build.0 = Debug|Win32
{9A081ACD-40DA-4924-8EA2-2A02F5B73B37}.Release|Win32.ActiveCfg = Release|Win32
{9A081ACD-40DA-4924-8EA2-2A02F5B73B37}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -180,6 +180,14 @@
<Filter
Name="Core"
>
<File
RelativePath=".\Source\AppConfig.cpp"
>
</File>
<File
RelativePath=".\Source\AppConfig.h"
>
</File>
<File
RelativePath=".\Source\ArrayStack.h"
>
@ -213,11 +221,11 @@
>
</File>
<File
RelativePath=".\Source\Config.cpp"
RelativePath=".\Source\ControllerInfo.cpp"
>
</File>
<File
RelativePath=".\Source\Config.h"
RelativePath=".\Source\ControllerInfo.h"
>
</File>
<File
@ -588,18 +596,14 @@
RelativePath=".\Source\PadHandler.h"
>
</File>
<File
RelativePath=".\Source\PadListener.cpp"
>
</File>
<File
RelativePath=".\Source\PadListener.h"
>
</File>
<File
RelativePath=".\Source\PathUtils.cpp"
>
</File>
<File
RelativePath=".\Source\PathUtils.h"
>
</File>
<File
RelativePath=".\Source\Profiler.cpp"
>
@ -1080,6 +1084,14 @@
RelativePath=".\Source\win32ui\CommandSink.h"
>
</File>
<File
RelativePath=".\Source\win32ui\ControllerSettingsWnd.cpp"
>
</File>
<File
RelativePath=".\Source\win32ui\ControllerSettingsWnd.h"
>
</File>
<File
RelativePath=".\Source\win32ui\Debugger.cpp"
>
@ -1192,6 +1204,22 @@
RelativePath=".\Source\win32ui\IconView.h"
>
</File>
<File
RelativePath=".\Source\win32ui\InputBindingSelectionWindow.cpp"
>
</File>
<File
RelativePath=".\Source\win32ui\InputBindingSelectionWindow.h"
>
</File>
<File
RelativePath=".\Source\win32ui\InputConfig.cpp"
>
</File>
<File
RelativePath=".\Source\win32ui\InputConfig.h"
>
</File>
<File
RelativePath=".\Source\win32ui\Main.cpp"
>
@ -1260,14 +1288,6 @@
RelativePath=".\Source\win32ui\MemoryViewPtr.h"
>
</File>
<File
RelativePath=".\Source\win32ui\ModalWindow.cpp"
>
</File>
<File
RelativePath=".\Source\win32ui\ModalWindow.h"
>
</File>
<File
RelativePath=".\Source\win32ui\NiceTabs.cpp"
>

44
Source/AppConfig.cpp Normal file
View File

@ -0,0 +1,44 @@
#include "AppConfig.h"
#include "PathUtils.h"
#define DEFAULT_CONFIG_PATH ("config.xml")
using namespace Framework;
using namespace boost;
CAppConfig::CAppConfig() :
CConfig(BuildConfigPath())
{
}
CAppConfig::~CAppConfig()
{
}
CConfig::PathType CAppConfig::BuildConfigPath()
{
#if defined(MACOSX)
passwd* userInfo = getpwuid(getuid());
if(userInfo == NULL) return DEFAULT_CONFIG_PATH;
return string(userInfo->pw_dir) + "/Library/Preferences/com.vapps.Purei.xml";
#elif defined(WIN32)
CConfig::PathType userPath(PathUtils::GetRoamingDataPath() / L"Virtual Applications" / L"Purei");
PathUtils::EnsurePathExists(userPath);
// CConfig::PathType companyPath = userPath / L"Virtual Applications";
// CConfig::PathType productPath = companyPath / L"Purei";
// try
// {
// filesystem::create_directory(companyPath);
// filesystem::create_directory(productPath);
// }
// catch(...)
// {
// //Creation failed (maybe because it already exists)
// }
return (userPath / L"Config.xml");
#else
return DEFAULT_CONFIG_PATH;
#endif
}

19
Source/AppConfig.h Normal file
View File

@ -0,0 +1,19 @@
#ifndef _APPCONFIG_H_
#define _APPCONFIG_H_
#include "Config.h"
#include "Singleton.h"
class CAppConfig : public Framework::CConfig, public CSingleton<CAppConfig>
{
public:
friend CSingleton<CAppConfig>;
private:
CAppConfig();
virtual ~CAppConfig();
static CConfig::PathType BuildConfigPath();
};
#endif

View File

@ -1,436 +0,0 @@
#include <string.h>
#include <stdlib.h>
#ifdef MACOSX
#include <pwd.h>
#endif
#ifdef WIN32
#include <shlobj.h>
#include <boost/filesystem/operations.hpp>
#endif
#include "Config.h"
#include "StdStream.h"
#include "xml/Writer.h"
#include "xml/Parser.h"
#include "xml/Utils.h"
#include "xml/FilteringNodeIterator.h"
#define DEFAULT_CONFIG_PATH "config.xml"
using namespace Framework;
using namespace std;
using namespace boost;
CConfig::CConfig()
{
Load();
}
CConfig::~CConfig()
{
Save();
for(PreferenceMapType::iterator preferenceIterator(m_preferences.begin());
preferenceIterator != m_preferences.end(); preferenceIterator++)
{
delete preferenceIterator->second;
}
}
template <> CConfig::CPreference* CConfig::CastPreference<CConfig::CPreference>(CPreference* pPreference)
{
return pPreference;
}
template <> CConfig::CPreferenceInteger* CConfig::CastPreference<CConfig::CPreferenceInteger>(CPreference* pPreference)
{
if(pPreference->GetType() != TYPE_INTEGER)
{
return NULL;
}
return (CPreferenceInteger*)pPreference;
}
template <> CConfig::CPreferenceBoolean* CConfig::CastPreference<CConfig::CPreferenceBoolean>(CPreference* pPreference)
{
if(pPreference->GetType() != TYPE_BOOLEAN)
{
return NULL;
}
return (CPreferenceBoolean*)pPreference;
}
template <> CConfig::CPreferenceString* CConfig::CastPreference<CConfig::CPreferenceString>(CPreference* pPreference)
{
if(pPreference->GetType() != TYPE_STRING)
{
return NULL;
}
return (CPreferenceString*)pPreference;
}
template <typename Type> Type* CConfig::FindPreference(const char* sName)
{
CPreference* pRet = NULL;
{
mutex::scoped_lock mutexLock(m_mutex);
PreferenceMapType::iterator preferenceIterator(m_preferences.find(sName));
if(preferenceIterator != m_preferences.end())
{
pRet = preferenceIterator->second;
}
}
if(pRet == NULL) return NULL;
Type* pPrefCast = CastPreference<Type>(pRet);
return pPrefCast;
}
void CConfig::RegisterPreferenceInteger(const char* sName, int nValue)
{
if(FindPreference<CPreference>(sName) != NULL)
{
return;
}
CPreferenceInteger* pPref = new CPreferenceInteger(sName, nValue);
InsertPreference(pPref);
}
void CConfig::RegisterPreferenceBoolean(const char* sName, bool nValue)
{
if(FindPreference<CPreference>(sName) != NULL)
{
return;
}
CPreferenceBoolean* pPref = new CPreferenceBoolean(sName, nValue);
InsertPreference(pPref);
}
void CConfig::RegisterPreferenceString(const char* sName, const char* sValue)
{
if(FindPreference<CPreference>(sName) != NULL)
{
return;
}
CPreferenceString* pPref = new CPreferenceString(sName, sValue);
InsertPreference(pPref);
}
int CConfig::GetPreferenceInteger(const char* sName)
{
CPreferenceInteger* pPref = FindPreference<CPreferenceInteger>(sName);
if(pPref == NULL) return 0;
return pPref->GetValue();
}
bool CConfig::GetPreferenceBoolean(const char* sName)
{
CPreferenceBoolean* pPref = FindPreference<CPreferenceBoolean>(sName);
if(pPref == NULL) return false;
return pPref->GetValue();
}
const char* CConfig::GetPreferenceString(const char* sName)
{
CPreferenceString* pPref = FindPreference<CPreferenceString>(sName);
if(pPref == NULL) return false;
return pPref->GetValue();
}
bool CConfig::SetPreferenceInteger(const char* sName, int nValue)
{
CPreferenceInteger* pPref = FindPreference<CPreferenceInteger>(sName);
if(pPref == NULL) return false;
pPref->SetValue(nValue);
return true;
}
bool CConfig::SetPreferenceBoolean(const char* sName, bool nValue)
{
CPreferenceBoolean* pPref = FindPreference<CPreferenceBoolean>(sName);
if(pPref == NULL) return false;
pPref->SetValue(nValue);
return true;
}
bool CConfig::SetPreferenceString(const char* sName, const char* sValue)
{
CPreferenceString* pPref = FindPreference<CPreferenceString>(sName);
if(pPref == NULL) return false;
pPref->SetValue(sValue);
return true;
}
string CConfig::GetConfigPath() const
{
#if defined(MACOSX)
passwd* userInfo = getpwuid(getuid());
if(userInfo == NULL) return DEFAULT_CONFIG_PATH;
return string(userInfo->pw_dir) + "/Library/Preferences/com.vapps.Purei.xml";
#elif defined(WIN32)
char userPathString[MAX_PATH];
SHGetFolderPathA(NULL, CSIDL_APPDATA, NULL, 0, userPathString);
filesystem::path userPath(userPathString, filesystem::native);
filesystem::path companyPath = userPath / "Virtual Applications";
filesystem::path productPath = companyPath / "Purei";
try
{
filesystem::create_directory(companyPath);
filesystem::create_directory(productPath);
}
catch(...)
{
//Creation failed (maybe because it already exists)
}
return (productPath / "Config.xml").string();
#else
return DEFAULT_CONFIG_PATH;
#endif
}
void CConfig::Load()
{
Xml::CNode* pDocument;
try
{
CStdStream configFile(fopen(GetConfigPath().c_str(), "rb"));
pDocument = Xml::CParser::ParseDocument(&configFile);
}
catch(...)
{
return;
}
Xml::CNode* pConfig = pDocument->Select("Config");
if(pConfig == NULL)
{
delete pDocument;
return;
}
for(Xml::CFilteringNodeIterator itNode(pConfig, "Preference"); !itNode.IsEnd(); itNode++)
{
Xml::CNode* pPref = (*itNode);
const char* sType = pPref->GetAttribute("Type");
const char* sName = pPref->GetAttribute("Name");
if(sType == NULL) continue;
if(sName == NULL) continue;
if(!strcmp(sType, "integer"))
{
int nValue;
if(Xml::GetAttributeIntValue(pPref, "Value", &nValue))
{
RegisterPreferenceInteger(sName, nValue);
}
}
else if(!strcmp(sType, "boolean"))
{
bool nValue;
if(Xml::GetAttributeBoolValue(pPref, "Value", &nValue))
{
RegisterPreferenceBoolean(sName, nValue);
}
}
else if(!strcmp(sType, "string"))
{
const char* sValue;
if(Xml::GetAttributeStringValue(pPref, "Value", &sValue))
{
RegisterPreferenceString(sName, sValue);
}
}
}
delete pDocument;
}
void CConfig::Save()
{
try
{
CStdStream stream(fopen(GetConfigPath().c_str(), "wb"));
Xml::CNode* pConfig = new Xml::CNode("Config", true);
for(PreferenceMapType::const_iterator preferenceIterator(m_preferences.begin());
preferenceIterator != m_preferences.end(); preferenceIterator++)
{
CPreference* pPref = (preferenceIterator->second);
Xml::CNode* pPrefNode = new Xml::CNode("Preference", true);
pPref->Serialize(pPrefNode);
pConfig->InsertNode(pPrefNode);
}
{
Xml::CNode* pDocument = new Xml::CNode;
pDocument->InsertNode(pConfig);
Xml::CWriter::WriteDocument(&stream, pDocument);
delete pDocument;
}
}
catch(...)
{
return;
}
}
void CConfig::InsertPreference(CPreference* pPref)
{
mutex::scoped_lock mutexLock(m_mutex);
m_preferences[pPref->GetName()] = pPref;
}
/////////////////////////////////////////////////////////
//CPreference implementation
/////////////////////////////////////////////////////////
CConfig::CPreference::CPreference(const char* sName, PREFERENCE_TYPE nType)
{
m_sName = sName;
m_nType = nType;
}
CConfig::CPreference::~CPreference()
{
}
const char* CConfig::CPreference::GetName()
{
return m_sName.c_str();
}
CConfig::PREFERENCE_TYPE CConfig::CPreference::GetType()
{
return m_nType;
}
const char* CConfig::CPreference::GetTypeString()
{
switch(m_nType)
{
case TYPE_INTEGER:
return "integer";
break;
case TYPE_STRING:
return "string";
break;
case TYPE_BOOLEAN:
return "boolean";
break;
}
return "";
}
void CConfig::CPreference::Serialize(Xml::CNode* pNode)
{
pNode->InsertAttribute(Xml::CreateAttributeStringValue("Name", m_sName.c_str()));
pNode->InsertAttribute(Xml::CreateAttributeStringValue("Type", GetTypeString()));
}
/////////////////////////////////////////////////////////
//CPreferenceInteger implementation
/////////////////////////////////////////////////////////
CConfig::CPreferenceInteger::CPreferenceInteger(const char* sName, int nValue) :
CPreference(sName, TYPE_INTEGER)
{
m_nValue = nValue;
}
CConfig::CPreferenceInteger::~CPreferenceInteger()
{
}
int CConfig::CPreferenceInteger::GetValue()
{
return m_nValue;
}
void CConfig::CPreferenceInteger::SetValue(int nValue)
{
m_nValue = nValue;
}
void CConfig::CPreferenceInteger::Serialize(Xml::CNode* pNode)
{
CPreference::Serialize(pNode);
pNode->InsertAttribute(Xml::CreateAttributeIntValue("Value", m_nValue));
}
/////////////////////////////////////////////////////////
//CPreferenceBoolean implementation
/////////////////////////////////////////////////////////
CConfig::CPreferenceBoolean::CPreferenceBoolean(const char* sName, bool nValue) :
CPreference(sName, TYPE_BOOLEAN)
{
m_nValue = nValue;
}
CConfig::CPreferenceBoolean::~CPreferenceBoolean()
{
}
bool CConfig::CPreferenceBoolean::GetValue()
{
return m_nValue;
}
void CConfig::CPreferenceBoolean::SetValue(bool nValue)
{
m_nValue = nValue;
}
void CConfig::CPreferenceBoolean::Serialize(Xml::CNode* pNode)
{
CPreference::Serialize(pNode);
pNode->InsertAttribute(Xml::CreateAttributeBoolValue("Value", m_nValue));
}
/////////////////////////////////////////////////////////
//CPreferenceString implementation
/////////////////////////////////////////////////////////
CConfig::CPreferenceString::CPreferenceString(const char* sName, const char* sValue) :
CPreference(sName, TYPE_STRING)
{
m_sValue = sValue;
}
CConfig::CPreferenceString::~CPreferenceString()
{
}
const char* CConfig::CPreferenceString::GetValue()
{
return m_sValue.c_str();
}
void CConfig::CPreferenceString::SetValue(const char* sValue)
{
m_sValue = sValue;
}
void CConfig::CPreferenceString::Serialize(Xml::CNode* pNode)
{
CPreference::Serialize(pNode);
pNode->InsertAttribute(Xml::CreateAttributeStringValue("Value", m_sValue.c_str()));
}

View File

@ -1,106 +0,0 @@
#ifndef _CONFIG_H_
#define _CONFIG_H_
#include <string>
#include <boost/thread.hpp>
#include <boost/utility.hpp>
#include "Singleton.h"
#include <map>
#include "xml/Node.h"
class CConfig : public CSingleton<CConfig>, boost::noncopyable
{
public:
friend class CSingleton<CConfig>;
void RegisterPreferenceInteger(const char*, int);
void RegisterPreferenceBoolean(const char*, bool);
void RegisterPreferenceString(const char*, const char*);
int GetPreferenceInteger(const char*);
bool GetPreferenceBoolean(const char*);
const char* GetPreferenceString(const char*);
bool SetPreferenceInteger(const char*, int);
bool SetPreferenceBoolean(const char*, bool);
bool SetPreferenceString(const char*, const char*);
void Save();
std::string GetConfigPath() const;
private:
enum PREFERENCE_TYPE
{
TYPE_INTEGER,
TYPE_BOOLEAN,
TYPE_STRING,
};
class CPreference
{
public:
CPreference(const char*, PREFERENCE_TYPE);
virtual ~CPreference();
const char* GetName();
PREFERENCE_TYPE GetType();
const char* GetTypeString();
virtual void Serialize(Framework::Xml::CNode*);
private:
std::string m_sName;
PREFERENCE_TYPE m_nType;
};
class CPreferenceInteger : public CPreference
{
public:
CPreferenceInteger(const char*, int);
virtual ~CPreferenceInteger();
int GetValue();
void SetValue(int);
virtual void Serialize(Framework::Xml::CNode*);
private:
int m_nValue;
};
class CPreferenceBoolean : public CPreference
{
public:
CPreferenceBoolean(const char*, bool);
virtual ~CPreferenceBoolean();
bool GetValue();
void SetValue(bool);
virtual void Serialize(Framework::Xml::CNode*);
private:
bool m_nValue;
};
class CPreferenceString : public CPreference
{
public:
CPreferenceString(const char*, const char*);
virtual ~CPreferenceString();
const char* GetValue();
void SetValue(const char*);
virtual void Serialize(Framework::Xml::CNode*);
private:
std::string m_sValue;
};
typedef std::map<std::string, CPreference*> PreferenceMapType;
CConfig();
~CConfig();
void Load();
template <typename Type> Type* FindPreference(const char*);
template <typename Type> Type* CastPreference(CPreference*);
void InsertPreference(CPreference*);
PreferenceMapType m_preferences;
boost::mutex m_mutex;
};
#endif

35
Source/ControllerInfo.cpp Normal file
View File

@ -0,0 +1,35 @@
#include "ControllerInfo.h"
using namespace PS2;
const char* CControllerInfo::m_buttonName[CControllerInfo::MAX_BUTTONS] =
{
"analog_left_x",
"analog_left_y",
"analog_right_x",
"analog_right_y",
"dpad_up",
"dpad_down",
"dpad_left",
"dpad_right",
"select",
"start",
"square",
"triangle",
"circle",
"cross",
"l1",
"l2",
"r1",
"r2",
};
bool CControllerInfo::IsAxis(BUTTON button)
{
return
(button == ANALOG_LEFT_X) ||
(button == ANALOG_LEFT_Y) ||
(button == ANALOG_RIGHT_X) ||
(button == ANALOG_RIGHT_Y);
}

37
Source/ControllerInfo.h Normal file
View File

@ -0,0 +1,37 @@
#ifndef _CONTROLLERINFO_H_
#define _CONTROLLERINFO_H_
namespace PS2
{
class CControllerInfo
{
public:
enum BUTTON
{
ANALOG_LEFT_X,
ANALOG_LEFT_Y,
ANALOG_RIGHT_X,
ANALOG_RIGHT_Y,
DPAD_UP,
DPAD_DOWN,
DPAD_LEFT,
DPAD_RIGHT,
SELECT,
START,
SQUARE,
TRIANGLE,
CIRCLE,
CROSS,
L1,
L2,
R1,
R2,
MAX_BUTTONS
};
static const char* m_buttonName[MAX_BUTTONS];
static bool IsAxis(BUTTON);
};
};
#endif

View File

@ -1,7 +1,7 @@
#include <stdio.h>
#include <assert.h>
#include <math.h>
#include "Config.h"
#include "AppConfig.h"
#include "GSH_OpenGL.h"
#include "PtrMacro.h"
@ -16,10 +16,10 @@ m_pFragShader(NULL)
{
m_pCvtBuffer = NULL;
CConfig::GetInstance().RegisterPreferenceBoolean(PREF_CGSH_OPENGL_LINEASQUADS, false);
CConfig::GetInstance().RegisterPreferenceBoolean(PREF_CGSH_OPENGL_FORCEBILINEARTEXTURES, false);
CConfig::GetInstance().RegisterPreferenceBoolean(PREF_CGSH_OPENGL_FORCEFLIPPINGVSYNC, false);
CConfig::GetInstance().RegisterPreferenceBoolean(PREF_CGSH_OPENGL_FIXSMALLZVALUES, false);
CAppConfig::GetInstance().RegisterPreferenceBoolean(PREF_CGSH_OPENGL_LINEASQUADS, false);
CAppConfig::GetInstance().RegisterPreferenceBoolean(PREF_CGSH_OPENGL_FORCEBILINEARTEXTURES, false);
CAppConfig::GetInstance().RegisterPreferenceBoolean(PREF_CGSH_OPENGL_FORCEFLIPPINGVSYNC, false);
CAppConfig::GetInstance().RegisterPreferenceBoolean(PREF_CGSH_OPENGL_FIXSMALLZVALUES, false);
LoadSettings();
}
@ -50,10 +50,10 @@ void CGSH_OpenGL::LoadState(CZipArchiveReader& archive)
void CGSH_OpenGL::LoadSettings()
{
m_nLinesAsQuads = CConfig::GetInstance().GetPreferenceBoolean(PREF_CGSH_OPENGL_LINEASQUADS);
m_nForceBilinearTextures = CConfig::GetInstance().GetPreferenceBoolean(PREF_CGSH_OPENGL_FORCEBILINEARTEXTURES);
m_nForceFlippingVSync = CConfig::GetInstance().GetPreferenceBoolean(PREF_CGSH_OPENGL_FORCEFLIPPINGVSYNC);
m_fixSmallZValues = CConfig::GetInstance().GetPreferenceBoolean(PREF_CGSH_OPENGL_FIXSMALLZVALUES);
m_nLinesAsQuads = CAppConfig::GetInstance().GetPreferenceBoolean(PREF_CGSH_OPENGL_LINEASQUADS);
m_nForceBilinearTextures = CAppConfig::GetInstance().GetPreferenceBoolean(PREF_CGSH_OPENGL_FORCEBILINEARTEXTURES);
m_nForceFlippingVSync = CAppConfig::GetInstance().GetPreferenceBoolean(PREF_CGSH_OPENGL_FORCEFLIPPINGVSYNC);
m_fixSmallZValues = CAppConfig::GetInstance().GetPreferenceBoolean(PREF_CGSH_OPENGL_FIXSMALLZVALUES);
}
void CGSH_OpenGL::InitializeRC()

View File

@ -44,6 +44,13 @@ int CMipsExecutor::Execute(int cycles)
block = FindBlockStartingAt(address);
if(block == NULL)
{
//REMOVE
if(address == 0x00424bc0)
{
int i = 0;
i++;
}
//REMOVE
//We need to partition the space and compile the blocks
PartitionFunction(address);
block = FindBlockStartingAt(address);
@ -117,6 +124,26 @@ CBasicBlock* CMipsExecutor::FindBlockStartingAt(uint32 address)
void CMipsExecutor::CreateBlock(uint32 start, uint32 end)
{
//REMOVE
if(start == end && end == 0x00424bbc)
{
int i = 0;
i++;
}
if(start == 0x00424bc0 && end == 0x00424bc8)
{
int i = 0;
i++;
}
if(start == 0x00424bc8)
{
int i = 0;
i++;
}
//REMOVE
{
CBasicBlock* block = FindBlockAt(start);
if(block != NULL)
@ -136,6 +163,12 @@ void CMipsExecutor::CreateBlock(uint32 start, uint32 end)
CreateBlock(otherBegin, start - 4);
assert(FindBlockAt(start) == NULL);
}
// else if(otherBegin == start)
// {
// DeleteBlock(block);
// CreateBlock(end + 4, otherEnd);
// assert(FindBlockAt(end) == NULL);
// }
else
{
//Delete the currently existing block otherwise
@ -145,12 +178,18 @@ void CMipsExecutor::CreateBlock(uint32 start, uint32 end)
}
}
assert(FindBlockAt(end) == NULL);
//REMOVE
assert(m_blockBegin.find(start) == m_blockBegin.end());
assert(m_blockEnd.find(end) == m_blockEnd.end());
//REMOVE
{
CBasicBlock* block = new CBasicBlock(m_context, start, end);
m_blocks.push_back(block);
m_blockBegin[start] = block;
m_blockEnd[end] = block;
}
assert(m_blocks.size() == m_blockBegin.size());
assert(m_blockBegin.size() == m_blockEnd.size());
}
void CMipsExecutor::DeleteBlock(CBasicBlock* block)
@ -165,6 +204,14 @@ void CMipsExecutor::DeleteBlock(CBasicBlock* block)
currBlock->SetBranchHint(NULL);
}
}
//REMOVE
if(block->GetBeginAddress() == 0x00424bc0)
{
int i = 0;
i++;
}
//REMOVE
//Remove block from our lists
m_blocks.remove(block);
m_blockBegin.erase(block->GetBeginAddress());

View File

@ -21,7 +21,7 @@
#include "IszImageStream.h"
#include "MemoryStateFile.h"
#include "zip/ZipArchiveWriter.h"
#include "Config.h"
#include "AppConfig.h"
#include "Profiler.h"
#include "iop/IopBios.h"
#include "iop/DirectoryDevice.h"
@ -101,10 +101,10 @@ m_timer(m_intc),
m_MAVU0(false),
m_MAVU1(true)
{
CConfig::GetInstance().RegisterPreferenceString(PREF_PS2_HOST_DIRECTORY, PREF_PS2_HOST_DIRECTORY_DEFAULT);
CConfig::GetInstance().RegisterPreferenceString(PREF_PS2_MC0_DIRECTORY, PREF_PS2_MC0_DIRECTORY_DEFAULT);
CConfig::GetInstance().RegisterPreferenceString(PREF_PS2_MC1_DIRECTORY, PREF_PS2_MC1_DIRECTORY_DEFAULT);
CConfig::GetInstance().RegisterPreferenceInteger(PREF_PS2_FRAMESKIP, PREF_PS2_FRAMESKIP_DEFAULT);
CAppConfig::GetInstance().RegisterPreferenceString(PREF_PS2_HOST_DIRECTORY, PREF_PS2_HOST_DIRECTORY_DEFAULT);
CAppConfig::GetInstance().RegisterPreferenceString(PREF_PS2_MC0_DIRECTORY, PREF_PS2_MC0_DIRECTORY_DEFAULT);
CAppConfig::GetInstance().RegisterPreferenceString(PREF_PS2_MC1_DIRECTORY, PREF_PS2_MC1_DIRECTORY_DEFAULT);
CAppConfig::GetInstance().RegisterPreferenceInteger(PREF_PS2_FRAMESKIP, PREF_PS2_FRAMESKIP_DEFAULT);
m_iopOs = new CIopBios(0x100, m_iop, m_iopRam, PS2::IOPRAMSIZE, m_sif, m_pCDROM0);
m_os = new CPS2OS(m_EE, m_VU1, m_pRAM, m_pBIOS, m_pGS, m_sif, *m_iopOs);
@ -234,7 +234,7 @@ unsigned int CPS2VM::LoadState(const char* sPath)
void CPS2VM::SetFrameSkip(unsigned int frameSkip)
{
m_frameSkip = frameSkip;
CConfig::GetInstance().SetPreferenceInteger(PREF_PS2_FRAMESKIP, m_frameSkip);
CAppConfig::GetInstance().SetPreferenceInteger(PREF_PS2_FRAMESKIP, m_frameSkip);
}
//unsigned int CPS2VM::SendMessage(PS2VM_MSG nMsg, void* pParam)
@ -384,7 +384,7 @@ void CPS2VM::ResetVM()
m_iopOs->GetIoman()->RegisterDevice("mc1", new Iop::Ioman::CDirectoryDevice(PREF_PS2_MC1_DIRECTORY));
m_iopOs->GetIoman()->RegisterDevice("cdrom0", new Iop::Ioman::CIsoDevice(m_pCDROM0));
m_frameSkip = CConfig::GetInstance().GetPreferenceInteger(PREF_PS2_FRAMESKIP);
m_frameSkip = CAppConfig::GetInstance().GetPreferenceInteger(PREF_PS2_FRAMESKIP);
RegisterModulesInPadHandler();
}
@ -553,14 +553,14 @@ void CPS2VM::OnGsNewFrame()
void CPS2VM::CDROM0_Initialize()
{
CConfig::GetInstance().RegisterPreferenceString("ps2.cdrom0.path", "");
CAppConfig::GetInstance().RegisterPreferenceString("ps2.cdrom0.path", "");
m_pCDROM0 = NULL;
}
void CPS2VM::CDROM0_Reset()
{
DELETEPTR(m_pCDROM0);
CDROM0_Mount(CConfig::GetInstance().GetPreferenceString("ps2.cdrom0.path"));
CDROM0_Mount(CAppConfig::GetInstance().GetPreferenceString("ps2.cdrom0.path"));
}
void CPS2VM::CDROM0_Mount(const char* sPath)
@ -611,7 +611,7 @@ void CPS2VM::CDROM0_Mount(const char* sPath)
}
}
CConfig::GetInstance().SetPreferenceString("ps2.cdrom0.path", sPath);
CAppConfig::GetInstance().SetPreferenceString("ps2.cdrom0.path", sPath);
}
void CPS2VM::CDROM0_Destroy()

33
Source/PadListener.cpp Normal file
View File

@ -0,0 +1,33 @@
#include <assert.h>
#include "PadListener.h"
using namespace PS2;
uint32 CPadListener::GetButtonMask(CControllerInfo::BUTTON button)
{
static uint32 buttonMask[CControllerInfo::MAX_BUTTONS] =
{
-1,
-1,
-1,
-1,
0x1000,
0x4000,
0x8000,
0x2000,
0x0100,
0x0800,
0x0080,
0x0010,
0x0020,
0x0040,
0x0004,
0x0001,
0x0008,
0x0002,
};
uint32 result = buttonMask[button];
assert(result != -1);
return result;
}

View File

@ -2,26 +2,15 @@
#define _PADLISTENER_H_
#include "Types.h"
#include "ControllerInfo.h"
class CPadListener
{
public:
enum BUTTON
{
BUTTON_LEFT = 0x8000,
BUTTON_DOWN = 0x4000,
BUTTON_RIGHT = 0x2000,
BUTTON_UP = 0x1000,
BUTTON_START = 0x0800,
BUTTON_SELECT = 0x0100,
BUTTON_SQUARE = 0x0080,
BUTTON_CROSS = 0x0040,
BUTTON_CIRCLE = 0x0020,
BUTTON_TRIANGLE = 0x0010,
};
virtual ~CPadListener() {}
virtual void SetButtonState(unsigned int, BUTTON, bool, uint8*) = 0;
virtual void SetButtonState(unsigned int, PS2::CControllerInfo::BUTTON, bool, uint8*) = 0;
virtual void SetAxisState(unsigned int, PS2::CControllerInfo::BUTTON, uint8, uint8*) = 0;
static uint32 GetButtonMask(PS2::CControllerInfo::BUTTON);
};
#endif

View File

@ -1,26 +0,0 @@
#include "PathUtils.h"
#include <boost/filesystem/operations.hpp>
using namespace boost;
using namespace std;
/*
namespace Framework
{
namespace PathUtils
{
void EnsurePathExists(const filesystem::path& path)
{
filesystem::path buildPath;
for(filesystem::path::iterator pathIterator(path.begin());
pathIterator != path.end(); pathIterator++)
{
buildPath /= (*pathIterator);
if(!filesystem::exists(buildPath))
{
filesystem::create_directory(buildPath);
}
}
}
}
}
*/

View File

@ -1,29 +0,0 @@
#ifndef _PATHUTILS_H_
#define _PATHUTILS_H_
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/operations.hpp>
namespace Framework
{
namespace PathUtils
{
template<typename String, typename Traits>
void EnsurePathExists(const boost::filesystem::basic_path<String, Traits>& path)
{
typedef boost::filesystem::basic_path<String, Traits> PathType;
PathType buildPath;
for(typename PathType::iterator pathIterator(path.begin());
pathIterator != path.end(); pathIterator++)
{
buildPath /= (*pathIterator);
if(!boost::filesystem::exists(buildPath))
{
boost::filesystem::create_directory(buildPath);
}
}
}
}
}
#endif

View File

@ -1,6 +1,6 @@
#include "DirectoryDevice.h"
#include "StdStream.h"
#include "../Config.h"
#include "../AppConfig.h"
using namespace Framework;
using namespace std;
@ -22,7 +22,7 @@ CStream* CDirectoryDevice::GetFile(uint32 accessType, const char* devicePath)
const char* mode(NULL);
string path;
const char* basePath = CConfig::GetInstance().GetPreferenceString(m_basePathPreferenceName.c_str());
const char* basePath = CAppConfig::GetInstance().GetPreferenceString(m_basePathPreferenceName.c_str());
path = basePath;
if(devicePath[0] != '/')

View File

@ -13,6 +13,7 @@ using namespace Iop;
using namespace std;
using namespace Framework;
using namespace boost;
using namespace PS2;
CDbcMan::CDbcMan(CSIF& sif) :
m_nextSocketId(0)
@ -94,8 +95,10 @@ void CDbcMan::LoadState(CZipArchiveReader& archive)
}
}
void CDbcMan::SetButtonState(unsigned int nPadNumber, CPadListener::BUTTON nButton, bool nPressed, uint8* ram)
void CDbcMan::SetButtonState(unsigned int nPadNumber, CControllerInfo::BUTTON nButton, bool nPressed, uint8* ram)
{
uint32 buttonMask = GetButtonMask(nButton);
for(SocketMap::const_iterator socketIterator(m_sockets.begin());
socketIterator != m_sockets.end(); socketIterator++)
{
@ -104,10 +107,10 @@ void CDbcMan::SetButtonState(unsigned int nPadNumber, CPadListener::BUTTON nButt
uint8* buffer = &ram[socket.buf1];
uint16 nStatus = (buffer[0x1C] << 8) | (buffer[0x1D]);
nStatus &= (~nButton);
nStatus &= (~buttonMask);
if(!nPressed)
{
nStatus |= nButton;
nStatus |= buttonMask;
}
buffer[0x1C] = static_cast<uint8>(nStatus >> 8);
@ -117,6 +120,11 @@ void CDbcMan::SetButtonState(unsigned int nPadNumber, CPadListener::BUTTON nButt
}
}
void CDbcMan::SetAxisState(unsigned int padNumber, CControllerInfo::BUTTON axis, uint8 axisValue, uint8* ram)
{
}
void CDbcMan::CreateSocket(uint32* args, uint32 argsSize, uint32* ret, uint32 retSize, uint8* ram)
{
uint32 nType1, nType2, nPort, nSlot, nBuf1, nBuf2;

View File

@ -21,7 +21,8 @@ namespace Iop
virtual void Invoke(uint32, uint32*, uint32, uint32*, uint32, uint8*);
virtual void SaveState(CZipArchiveWriter&);
virtual void LoadState(CZipArchiveReader&);
virtual void SetButtonState(unsigned int, CPadListener::BUTTON, bool, uint8*);
virtual void SetButtonState(unsigned int, PS2::CControllerInfo::BUTTON, bool, uint8*);
virtual void SetAxisState(unsigned int, PS2::CControllerInfo::BUTTON, uint8, uint8*);
private:
enum MODULE_ID

View File

@ -1,4 +1,4 @@
#include "../Config.h"
#include "../AppConfig.h"
#include "Iop_Ioman.h"
#include "StdStream.h"
#include <stdexcept>
@ -13,11 +13,11 @@ CIoman::CIoman(uint8* ram, CSIF& sif) :
m_ram(ram),
m_nextFileHandle(3)
{
CConfig::GetInstance().RegisterPreferenceBoolean(PREF_IOP_FILEIO_STDLOGGING, false);
CAppConfig::GetInstance().RegisterPreferenceBoolean(PREF_IOP_FILEIO_STDLOGGING, false);
sif.RegisterModule(SIF_MODULE_ID, this);
//Insert standard files if requested.
if(CConfig::GetInstance().GetPreferenceBoolean(PREF_IOP_FILEIO_STDLOGGING))
if(CAppConfig::GetInstance().GetPreferenceBoolean(PREF_IOP_FILEIO_STDLOGGING))
{
try
{

View File

@ -2,7 +2,7 @@
#include <stdio.h>
#include <boost/filesystem/operations.hpp>
#include <boost/static_assert.hpp>
#include "../Config.h"
#include "../AppConfig.h"
#include "../Log.h"
#include "Iop_McServ.h"
@ -151,7 +151,7 @@ void CMcServ::Open(uint32* args, uint32 argsSize, uint32* ret, uint32 retSize, u
try
{
Path = filesystem::path(CConfig::GetInstance().GetPreferenceString(m_sMcPathPreference[pCmd->nPort]), filesystem::native);
Path = filesystem::path(CAppConfig::GetInstance().GetPreferenceString(m_sMcPathPreference[pCmd->nPort]), filesystem::native);
Path /= pCmd->sName;
}
catch(const exception& Exception)
@ -348,7 +348,7 @@ void CMcServ::ChDir(uint32* args, uint32 argsSize, uint32* ret, uint32 retSize,
try
{
filesystem::path McPath(CConfig::GetInstance().GetPreferenceString(m_sMcPathPreference[pCmd->nPort]), filesystem::native);
filesystem::path McPath(CAppConfig::GetInstance().GetPreferenceString(m_sMcPathPreference[pCmd->nPort]), filesystem::native);
McPath /= pCmd->sName;
if(filesystem::exists(McPath) && filesystem::is_directory(McPath))
@ -384,7 +384,7 @@ void CMcServ::GetDir(uint32* args, uint32 argsSize, uint32* ret, uint32 retSize,
try
{
filesystem::path McPath(CConfig::GetInstance().GetPreferenceString(m_sMcPathPreference[pCmd->nPort]), filesystem::native);
filesystem::path McPath(CAppConfig::GetInstance().GetPreferenceString(m_sMcPathPreference[pCmd->nPort]), filesystem::native);
McPath = filesystem::complete(McPath);
if(filesystem::exists(McPath))

View File

@ -9,9 +9,11 @@ using namespace Iop;
using namespace Framework;
using namespace boost;
using namespace std;
using namespace PS2;
#define PADNUM (1)
#define MODE (0x4)
#define MODE (0x7) //DUAL SHOCK
//#define MODE (0x4) //DIGITAL
#define LOG_NAME "iop_padman"
#define STATE_PADDATA ("iop_padman/paddata.xml")
@ -82,7 +84,7 @@ void CPadMan::LoadState(CZipArchiveReader& archive)
m_nPadDataType = registerFile.GetRegister32(STATE_PADDATA_TYPE);
}
void CPadMan::SetButtonState(unsigned int nPadNumber, CPadListener::BUTTON nButton, bool nPressed, uint8* ram)
void CPadMan::SetButtonState(unsigned int nPadNumber, CControllerInfo::BUTTON nButton, bool nPressed, uint8* ram)
{
if(m_nPadDataAddress == 0) return;
@ -90,6 +92,14 @@ void CPadMan::SetButtonState(unsigned int nPadNumber, CPadListener::BUTTON nButt
ram + m_nPadDataAddress, PADNUM);
}
void CPadMan::SetAxisState(unsigned int padNumber, CControllerInfo::BUTTON button, uint8 axisValue, uint8* ram)
{
if(m_nPadDataAddress == 0) return;
ExecutePadDataFunction(bind(&CPadMan::PDF_SetAxisState, _1, button, axisValue),
ram + m_nPadDataAddress, PADNUM);
}
void CPadMan::Open(uint32* args, uint32 argsSize, uint32* ret, uint32 retSize, uint8* ram)
{
uint32 nPort = args[1];
@ -180,16 +190,15 @@ void CPadMan::PDF_InitializeStruct1(CPadDataInterface* pPadData)
pPadData->SetModeTable(0, MODE);
}
void CPadMan::PDF_SetButtonState(CPadDataInterface* pPadData, BUTTON nButton, bool nPressed)
void CPadMan::PDF_SetButtonState(CPadDataInterface* pPadData, CControllerInfo::BUTTON nButton, bool nPressed)
{
uint16 nStatus;
uint16 nStatus = (pPadData->GetData(2) << 8) | (pPadData->GetData(3));
uint32 buttonMask = GetButtonMask(nButton);
nStatus = (pPadData->GetData(2) << 8) | (pPadData->GetData(3));
nStatus &= ~nButton;
nStatus &= ~buttonMask;
if(!nPressed)
{
nStatus |= nButton;
nStatus |= buttonMask;
}
pPadData->SetReqState(0);
@ -201,6 +210,31 @@ void CPadMan::PDF_SetButtonState(CPadDataInterface* pPadData, BUTTON nButton, bo
pPadData->SetData(1, MODE << 4);
}
void CPadMan::PDF_SetAxisState(CPadDataInterface* padData, CControllerInfo::BUTTON axis, uint8 axisValue)
{
//rjoy_h 4;
//rjoy_v 5;
//ljoy_h 6;
//ljoy_v 7;
assert(axis < 4);
unsigned int axisIndex[4] =
{
6,
7,
4,
5
};
padData->SetReqState(0);
padData->SetData(axisIndex[axis], axisValue);
padData->SetData(0, 0);
padData->SetData(1, MODE << 4);
}
template <> void CPadMan::CPadDataHandler<CPadMan::PADDATA>::SetModeCurId(unsigned int)
{

View File

@ -21,7 +21,8 @@ namespace Iop
virtual void Invoke(uint32, uint32*, uint32, uint32*, uint32, uint8*);
virtual void SaveState(CZipArchiveWriter&);
virtual void LoadState(CZipArchiveReader&);
virtual void SetButtonState(unsigned int, CPadListener::BUTTON, bool, uint8*);
virtual void SetButtonState(unsigned int, PS2::CControllerInfo::BUTTON, bool, uint8*);
virtual void SetAxisState(unsigned int, PS2::CControllerInfo::BUTTON, uint8, uint8*);
enum MODULE_ID
{
@ -164,7 +165,8 @@ namespace Iop
static void PDF_InitializeStruct0(CPadDataInterface*);
static void PDF_InitializeStruct1(CPadDataInterface*);
static void PDF_SetButtonState(CPadDataInterface*, BUTTON, bool);
static void PDF_SetButtonState(CPadDataInterface*, PS2::CControllerInfo::BUTTON, bool);
static void PDF_SetAxisState(CPadDataInterface*, PS2::CControllerInfo::BUTTON, uint8);
};
template <> void CPadMan::CPadDataHandler<CPadMan::PADDATA>::SetModeCurId(unsigned int);

View File

@ -1,13 +1,13 @@
#ifndef _CDROMSELECTIONWND_H_
#define _CDROMSELECTIONWND_H_
#include "ModalWindow.h"
#include "win32/ModalWindow.h"
#include "win32/Button.h"
#include "win32/Edit.h"
#include "win32/ComboBox.h"
#include "layout/LayoutObject.h"
class CCdromSelectionWnd : public CModalWindow
class CCdromSelectionWnd : public Framework::Win32::CModalWindow
{
public:
enum BINDINGTYPE

View File

@ -0,0 +1,228 @@
#include "ControllerSettingsWnd.h"
#include "win32/Rect.h"
#include "InputConfig.h"
#include "InputBindingSelectionWindow.h"
#include <vector>
#include <stdexcept>
#include <boost/lexical_cast.hpp>
#include "layout/LayoutEngine.h"
#include "string_cast.h"
#include "Types.h"
#define CLSNAME _T("ContollerSettingsWnd")
#define WNDSTYLE (WS_CAPTION | WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_SYSMENU)
#define WNDSTYLEEX (WS_EX_DLGMODALFRAME)
using namespace std;
using namespace std::tr1;
using namespace std::tr1::placeholders;
using namespace PS2;
using namespace Framework;
using namespace boost;
CControllerSettingsWnd::CControllerSettingsWnd(HWND parent, DirectInput::CManager* directInputManager) :
CModalWindow(parent),
m_directInputManager(directInputManager),
m_autoConfigButton(NULL),
m_bindingList(NULL),
m_samplingEnabled(true)
{
if(!DoesWindowClassExist(CLSNAME))
{
WNDCLASSEX wc;
memset(&wc, 0, sizeof(WNDCLASSEX));
wc.cbSize = sizeof(WNDCLASSEX);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW);
wc.hInstance = GetModuleHandle(NULL);
wc.lpszClassName = CLSNAME;
wc.lpfnWndProc = CWindow::WndProc;
wc.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
RegisterClassEx(&wc);
}
Create(WNDSTYLEEX, CLSNAME, _T("Controller Settings"), WNDSTYLE, Win32::CRect(0, 0, 550, 400), parent, NULL);
SetClassPtr();
m_bindingList = new Win32::CListView(m_hWnd, Win32::CRect(0, 0, 1, 1), LVS_REPORT | LVS_NOSORTHEADER);
m_ok = new Win32::CButton(_T("OK"), m_hWnd, Win32::CRect(0, 0, 1, 1));
m_cancel = new Win32::CButton(_T("Cancel"), m_hWnd, Win32::CRect(0, 0, 1, 1));
m_autoConfigButton = new Win32::CButton(_T("Auto Config"), m_hWnd, Win32::CRect(0, 0, 1, 1));
m_bindingList->SetExtendedListViewStyle(m_bindingList->GetExtendedListViewStyle() | LVS_EX_FULLROWSELECT);
m_layout =
VerticalLayoutContainer(
Win32::CLayoutWindow::CreateCustomBehavior(100, 100, 1, 1, m_bindingList) +
HorizontalLayoutContainer(
Win32::CLayoutWindow::CreateButtonBehavior(100, 23, m_autoConfigButton) +
CLayoutStretch::Create() +
Win32::CLayoutWindow::CreateButtonBehavior(100, 23, m_ok) +
Win32::CLayoutWindow::CreateButtonBehavior(100, 23, m_cancel)
)
);
RefreshLayout();
PopulateList();
UpdateBindings();
SetTimer(m_hWnd, NULL, 50, NULL);
}
CControllerSettingsWnd::~CControllerSettingsWnd()
{
}
void CControllerSettingsWnd::RefreshLayout()
{
RECT rc = GetClientRect();
SetRect(&rc, rc.left + 10, rc.top + 10, rc.right - 10, rc.bottom - 10);
m_layout->SetRect(rc.left, rc.top, rc.right, rc.bottom);
m_layout->RefreshGeometry();
Redraw();
}
long CControllerSettingsWnd::OnTimer()
{
if(m_samplingEnabled)
{
CInputConfig::InputEventHandler eventHandler(bind(&CControllerSettingsWnd::InputEventHandler, this, _1, _2));
m_directInputManager->ProcessEvents(
bind(&CInputConfig::TranslateInputEvent, &CInputConfig::GetInstance(), _1, _2, _3, std::tr1::cref(eventHandler)));
}
return TRUE;
}
long CControllerSettingsWnd::OnCommand(unsigned short id, unsigned short cmd, HWND from)
{
if(m_autoConfigButton && from == m_autoConfigButton->m_hWnd)
{
AutoConfigKeyboard();
}
if(m_ok && from == m_ok->m_hWnd)
{
CInputConfig::GetInstance().Save();
Destroy();
}
if(m_cancel && from == m_cancel->m_hWnd)
{
CInputConfig::GetInstance().Load();
Destroy();
}
return TRUE;
}
long CControllerSettingsWnd::OnNotify(WPARAM param, NMHDR* header)
{
if(m_bindingList && m_bindingList->m_hWnd == header->hwndFrom)
{
if(header->code == NM_DBLCLK)
{
OnListItemDblClick();
}
}
return FALSE;
}
void CControllerSettingsWnd::AutoConfigKeyboard()
{
CInputConfig::GetInstance().SetSimpleBinding(CControllerInfo::START, CInputConfig::BINDINGINFO(GUID_SysKeyboard, DIK_RETURN));
CInputConfig::GetInstance().SetSimpleBinding(CControllerInfo::SELECT, CInputConfig::BINDINGINFO(GUID_SysKeyboard, DIK_LSHIFT));
CInputConfig::GetInstance().SetSimpleBinding(CControllerInfo::DPAD_LEFT, CInputConfig::BINDINGINFO(GUID_SysKeyboard, DIK_LEFT));
CInputConfig::GetInstance().SetSimpleBinding(CControllerInfo::DPAD_RIGHT, CInputConfig::BINDINGINFO(GUID_SysKeyboard, DIK_RIGHT));
CInputConfig::GetInstance().SetSimpleBinding(CControllerInfo::DPAD_UP, CInputConfig::BINDINGINFO(GUID_SysKeyboard, DIK_UP));
CInputConfig::GetInstance().SetSimpleBinding(CControllerInfo::DPAD_DOWN, CInputConfig::BINDINGINFO(GUID_SysKeyboard, DIK_DOWN));
CInputConfig::GetInstance().SetSimpleBinding(CControllerInfo::SQUARE, CInputConfig::BINDINGINFO(GUID_SysKeyboard, DIK_A));
CInputConfig::GetInstance().SetSimpleBinding(CControllerInfo::CROSS, CInputConfig::BINDINGINFO(GUID_SysKeyboard, DIK_Z));
CInputConfig::GetInstance().SetSimpleBinding(CControllerInfo::TRIANGLE, CInputConfig::BINDINGINFO(GUID_SysKeyboard, DIK_S));
CInputConfig::GetInstance().SetSimpleBinding(CControllerInfo::CIRCLE, CInputConfig::BINDINGINFO(GUID_SysKeyboard, DIK_X));
UpdateBindings();
}
void CControllerSettingsWnd::InputEventHandler(CControllerInfo::BUTTON button, uint32 value)
{
UpdateButtonValue(button, value);
}
void CControllerSettingsWnd::UpdateBindings()
{
for(int i = 0; i < m_bindingList->GetItemCount(); i++)
{
CControllerInfo::BUTTON button = static_cast<CControllerInfo::BUTTON>(m_bindingList->GetItemData(i));
tstring description = CInputConfig::GetInstance().GetBindingDescription(m_directInputManager, button);
m_bindingList->SetItemText(i, 1, description.c_str());
}
}
void CControllerSettingsWnd::UpdateButtonValue(CControllerInfo::BUTTON button, uint32 value)
{
int listViewIndex = m_bindingList->FindItemData(button);
if(listViewIndex == -1) return;
if(CControllerInfo::IsAxis(button))
{
m_bindingList->SetItemText(listViewIndex, 2, lexical_cast<tstring>(value).c_str());
}
else
{
m_bindingList->SetItemText(listViewIndex, 2, value ? _T("pressed") : _T(""));
}
}
void CControllerSettingsWnd::OnListItemDblClick()
{
int selection = m_bindingList->GetSelection();
if(selection == -1) return;
m_samplingEnabled = false;
{
CControllerInfo::BUTTON button = static_cast<CControllerInfo::BUTTON>(m_bindingList->GetItemData(selection));
if(button < CControllerInfo::MAX_BUTTONS)
{
CInputBindingSelectionWindow dialog(m_hWnd, m_directInputManager, button);
dialog.DoModal();
UpdateBindings();
}
}
m_samplingEnabled = true;
}
void CControllerSettingsWnd::PopulateList()
{
LVCOLUMN column;
RECT rc = m_bindingList->GetClientRect();
memset(&column, 0, sizeof(LVCOLUMN));
column.pszText = _T("Button");
column.mask = LVCF_TEXT | LVCF_WIDTH;
column.cx = 1 * rc.right / 5;
m_bindingList->InsertColumn(0, &column);
memset(&column, 0, sizeof(LVCOLUMN));
column.pszText = _T("Binding");
column.mask = LVCF_TEXT | LVCF_WIDTH;
column.cx = 3 * rc.right / 5;
m_bindingList->InsertColumn(1, &column);
memset(&column, 0, sizeof(LVCOLUMN));
column.pszText = _T("Current Value");
column.mask = LVCF_TEXT | LVCF_WIDTH;
column.cx = 1 * rc.right / 5;
m_bindingList->InsertColumn(2, &column);
for(int i = CControllerInfo::MAX_BUTTONS - 1; i >= 0; i--)
{
tstring text = string_cast<tstring>(CControllerInfo::m_buttonName[i]);
LVITEM itm;
memset(&itm, 0, sizeof(LVITEM));
itm.mask = LVIF_TEXT | LVIF_PARAM;
itm.pszText = const_cast<TCHAR*>(text.c_str());
itm.lParam = i;
m_bindingList->InsertItem(&itm);
UpdateButtonValue(static_cast<CControllerInfo::BUTTON>(i), 0);
}
}

View File

@ -0,0 +1,41 @@
#ifndef _CONTROLLERSETTINGSWND_H_
#define _CONTROLLERSETTINGSWND_H_
#include "win32/ModalWindow.h"
#include "win32/Button.h"
#include "win32/ListView.h"
#include "directinput/Manager.h"
#include "../ControllerInfo.h"
#include "win32/Layouts.h"
class CControllerSettingsWnd : public Framework::Win32::CModalWindow
{
public:
CControllerSettingsWnd(HWND, DirectInput::CManager*);
virtual ~CControllerSettingsWnd();
protected:
long OnTimer();
long OnCommand(unsigned short, unsigned short, HWND);
long OnNotify(WPARAM, NMHDR*);
private:
void RefreshLayout();
void AutoConfigKeyboard();
void AutoConfigJoystick();
void InputEventHandler(PS2::CControllerInfo::BUTTON, uint32);
void UpdateButtonValue(PS2::CControllerInfo::BUTTON, uint32);
void UpdateBindings();
void PopulateList();
void OnListItemDblClick();
Framework::LayoutObjectPtr m_layout;
Framework::Win32::CListView* m_bindingList;
Framework::Win32::CButton* m_ok;
Framework::Win32::CButton* m_cancel;
Framework::Win32::CButton* m_autoConfigButton;
DirectInput::CManager* m_directInputManager;
bool m_samplingEnabled;
};
#endif

Binary file not shown.

View File

@ -75,7 +75,7 @@ CSettingsDialogProvider* CGSH_OpenGLWin32::GetSettingsDialogProvider()
return this;
}
CModalWindow* CGSH_OpenGLWin32::CreateSettingsDialog(HWND hParent)
Win32::CModalWindow* CGSH_OpenGLWin32::CreateSettingsDialog(HWND hParent)
{
return new CRendererSettingsWnd(hParent, this);
}

View File

@ -19,8 +19,8 @@ public:
CSettingsDialogProvider* GetSettingsDialogProvider();
CModalWindow* CreateSettingsDialog(HWND);
void OnSettingsDialogDestroyed();
Framework::Win32::CModalWindow* CreateSettingsDialog(HWND);
void OnSettingsDialogDestroyed();
private:
virtual void SetViewport(int, int);

View File

@ -0,0 +1,120 @@
#include "InputBindingSelectionWindow.h"
#include "win32/Rect.h"
#include "layout/LayoutEngine.h"
#include <boost/lexical_cast.hpp>
#include "string_cast.h"
#define CLSNAME _T("CInputBindingSelectionWindow")
#define WNDSTYLE (WS_CAPTION | WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_SYSMENU)
#define WNDSTYLEEX (WS_EX_DLGMODALFRAME)
using namespace std;
using namespace std::tr1;
using namespace std::tr1::placeholders;
using namespace boost;
using namespace PS2;
using namespace Framework;
CInputBindingSelectionWindow::CInputBindingSelectionWindow(
HWND parent, DirectInput::CManager* directInputManager, CControllerInfo::BUTTON button) :
CModalWindow(parent),
m_directInputManager(directInputManager),
m_button(button),
m_currentBindingLabel(NULL),
m_isActive(false),
m_selected(false)
{
if(!DoesWindowClassExist(CLSNAME))
{
RegisterClassEx(&MakeWndClass(CLSNAME));
}
tstring title = _T("Select new binding for ") + string_cast<tstring>(CControllerInfo::m_buttonName[m_button]);
m_binding = CInputConfig::GetInstance().GetBinding(button);
Create(WNDSTYLEEX, CLSNAME, title.c_str(), WNDSTYLE, Win32::CRect(0, 0, 400, 100), parent, NULL);
SetClassPtr();
m_currentBindingLabel = new Win32::CStatic(
m_hWnd,
m_binding ? m_binding->GetDescription(m_directInputManager).c_str() : _T("Unbound"),
SS_CENTER);
m_layout =
VerticalLayoutContainer(
CLayoutStretch::Create() +
Win32::CLayoutWindow::CreateTextBoxBehavior(100, 21, m_currentBindingLabel) +
CLayoutStretch::Create()
);
RefreshLayout();
SetTimer(m_hWnd, 0, 16, NULL);
}
CInputBindingSelectionWindow::~CInputBindingSelectionWindow()
{
}
long CInputBindingSelectionWindow::OnActivate(unsigned int activationType, bool minimized, HWND window)
{
m_isActive = activationType != WA_INACTIVE;
return TRUE;
}
long CInputBindingSelectionWindow::OnTimer()
{
m_directInputManager->ProcessEvents(bind(&CInputBindingSelectionWindow::ProcessEvent, this, _1, _2, _3));
if(m_selected)
{
CInputConfig::GetInstance().SetSimpleBinding(m_button, CInputConfig::BINDINGINFO(m_selectedDevice, m_selectedId));
Destroy();
}
return TRUE;
}
void CInputBindingSelectionWindow::RefreshLayout()
{
RECT rc = GetClientRect();
SetRect(&rc, rc.left + 10, rc.top + 10, rc.right - 10, rc.bottom - 10);
m_layout->SetRect(rc.left, rc.top, rc.right, rc.bottom);
m_layout->RefreshGeometry();
Redraw();
}
void CInputBindingSelectionWindow::ProcessEvent(const GUID& device, uint32 id, uint32 value)
{
if(!m_isActive) return;
if(m_selected) return;
DIDEVICEOBJECTINSTANCE objectInstance;
if(m_directInputManager->GetDeviceObjectInfo(device, id, &objectInstance))
{
if(objectInstance.dwType & DIDFT_AXIS)
{
float axisValue = static_cast<float>(static_cast<int16>(value - 0x7FFF)) / 32768.f;
if(abs(axisValue) < 0.85)
{
return;
}
}
else if(objectInstance.dwType & DIDFT_BUTTON)
{
if(!value) return;
}
else
{
return;
}
// DIDEVICEINSTANCE deviceInstance;
// m_directInputManager->GetDeviceInfo(device, &deviceInstance);
// tstring bindingText = tstring(deviceInstance.tszInstanceName) + _T(": ") + tstring(objectInstance.tszName);
// m_currentBindingLabel->SetText(bindingText.c_str());
m_selectedDevice = device;
m_selectedId = id;
m_selected = true;
}
}

View File

@ -0,0 +1,39 @@
#ifndef _INPUTBINDINGSELECTIONWINDOW_H_
#define _INPUTBINDINGSELECTIONWINDOW_H_
#include "win32/ModalWindow.h"
#include "win32/Static.h"
#include "../ControllerInfo.h"
#include "directinput/Manager.h"
#include "win32/Layouts.h"
#include "InputConfig.h"
class CInputBindingSelectionWindow : public Framework::Win32::CModalWindow
{
public:
CInputBindingSelectionWindow(HWND, DirectInput::CManager*, PS2::CControllerInfo::BUTTON);
virtual ~CInputBindingSelectionWindow();
protected:
long OnTimer();
long OnActivate(unsigned int, bool, HWND);
private:
void RefreshLayout();
void ProcessEvent(const GUID&, uint32, uint32);
Framework::Win32::CStatic* m_currentBindingLabel;
DirectInput::CManager* m_directInputManager;
PS2::CControllerInfo::BUTTON m_button;
GUID m_selectedDevice;
uint32 m_selectedId;
bool m_selected;
Framework::LayoutObjectPtr m_layout;
const CInputConfig::CBinding* m_binding;
bool m_isActive;
};
#endif

View File

@ -0,0 +1,202 @@
#include "InputConfig.h"
#include "win32/GuidUtils.h"
#include <string.h>
#include <boost/lexical_cast.hpp>
using namespace std;
using namespace Framework;
using namespace boost;
using namespace PS2;
#define CONFIG_PREFIX ("input")
#define CONFIG_BINDING_TYPE ("bindingtype")
#define CONFIG_SIMPLEBINDING_PREFIX ("simplebinding")
#define CONFIG_BINDINGINFO_DEVICE ("device")
#define CONFIG_BINDINGINFO_ID ("id")
#define CONFIG_SIMULATEDAXISBINDING_PREFIX ("simulatedaxisbinding")
#define CONFIG_SIMULATEDAXISBINDING_KEY1 ("key1")
#define CONFIG_SIMULATEDAXISBINDING_KEY2 ("key2")
CInputConfig::CInputConfig(CAppConfig& config)
{
for(unsigned int i = 0; i < CControllerInfo::MAX_BUTTONS; i++)
{
string prefBase = CConfig::MakePreferenceName(CONFIG_PREFIX, CControllerInfo::m_buttonName[i]);
config.RegisterPreferenceInteger(
CConfig::MakePreferenceName(prefBase, CONFIG_BINDING_TYPE).c_str(),
0);
CSimpleBinding::RegisterPreferences(config, prefBase.c_str());
}
Load();
}
CInputConfig::~CInputConfig()
{
}
void CInputConfig::Load()
{
for(unsigned int i = 0; i < CControllerInfo::MAX_BUTTONS; i++)
{
BINDINGTYPE bindingType = BINDING_UNBOUND;
string prefBase = CConfig::MakePreferenceName(CONFIG_PREFIX, CControllerInfo::m_buttonName[i]);
bindingType = static_cast<BINDINGTYPE>(CAppConfig::GetInstance().GetPreferenceInteger((prefBase + "." + string(CONFIG_BINDING_TYPE)).c_str()));
if(bindingType == BINDING_UNBOUND) continue;
BindingPtr binding;
switch(bindingType)
{
case BINDING_SIMPLE:
binding.reset(new CSimpleBinding());
break;
}
if(binding)
{
binding->Load(CAppConfig::GetInstance(), prefBase.c_str());
}
m_bindings[i] = binding;
}
}
void CInputConfig::Save()
{
for(unsigned int i = 0; i < CControllerInfo::MAX_BUTTONS; i++)
{
BindingPtr& binding = m_bindings[i];
if(binding == NULL) continue;
string prefBase = CConfig::MakePreferenceName(CONFIG_PREFIX, CControllerInfo::m_buttonName[i]);
CAppConfig::GetInstance().SetPreferenceInteger(
CConfig::MakePreferenceName(prefBase, CONFIG_BINDING_TYPE).c_str(),
binding->GetBindingType());
binding->Save(CAppConfig::GetInstance(), prefBase.c_str());
}
}
const CInputConfig::CBinding* CInputConfig::GetBinding(CControllerInfo::BUTTON button) const
{
if(button >= CControllerInfo::MAX_BUTTONS)
{
throw exception();
}
return m_bindings[button].get();
}
void CInputConfig::SetSimpleBinding(CControllerInfo::BUTTON button, const BINDINGINFO& binding)
{
if(button >= CControllerInfo::MAX_BUTTONS)
{
throw exception();
}
m_bindings[button].reset(new CSimpleBinding(binding.device, binding.id));
}
void CInputConfig::TranslateInputEvent(const GUID& device, uint32 id, uint32 value, const InputEventHandler& eventHandler)
{
for(unsigned int i = 0; i < CControllerInfo::MAX_BUTTONS; i++)
{
BindingPtr& binding = m_bindings[i];
if(!binding) continue;
binding->ProcessEvent(device, id, value, static_cast<CControllerInfo::BUTTON>(i), eventHandler);
}
}
tstring CInputConfig::GetBindingDescription(DirectInput::CManager* directInputManager, CControllerInfo::BUTTON button) const
{
assert(button < CControllerInfo::MAX_BUTTONS);
const BindingPtr& binding = m_bindings[button];
if(binding)
{
return binding->GetDescription(directInputManager);
}
else
{
return _T("");
}
}
////////////////////////////////////////////////
// SimpleBinding
////////////////////////////////////////////////
CInputConfig::CSimpleBinding::CSimpleBinding(const GUID& device, uint32 id) :
BINDINGINFO(device, id)
{
}
CInputConfig::CSimpleBinding::~CSimpleBinding()
{
}
CInputConfig::BINDINGTYPE CInputConfig::CSimpleBinding::GetBindingType() const
{
return BINDING_SIMPLE;
}
void CInputConfig::CSimpleBinding::Save(CConfig& config, const char* buttonBase) const
{
string prefBase = CConfig::MakePreferenceName(buttonBase, CONFIG_SIMPLEBINDING_PREFIX);
config.SetPreferenceString(
CConfig::MakePreferenceName(prefBase, CONFIG_BINDINGINFO_DEVICE).c_str(),
lexical_cast<string>(device).c_str());
config.SetPreferenceInteger(
CConfig::MakePreferenceName(prefBase, CONFIG_BINDINGINFO_ID).c_str(),
id);
}
void CInputConfig::CSimpleBinding::Load(CConfig& config, const char* buttonBase)
{
string prefBase = CConfig::MakePreferenceName(buttonBase, CONFIG_SIMPLEBINDING_PREFIX);
device = lexical_cast<GUID>(config.GetPreferenceString(CConfig::MakePreferenceName(prefBase, CONFIG_BINDINGINFO_DEVICE).c_str()));
id = config.GetPreferenceInteger(CConfig::MakePreferenceName(prefBase, CONFIG_BINDINGINFO_ID).c_str());
}
tstring CInputConfig::CSimpleBinding::GetDescription(DirectInput::CManager* directInputManager) const
{
DIDEVICEINSTANCE deviceInstance;
DIDEVICEOBJECTINSTANCE objectInstance;
if(!directInputManager->GetDeviceInfo(device, &deviceInstance))
{
return _T("");
}
if(!directInputManager->GetDeviceObjectInfo(device, id, &objectInstance))
{
return _T("");
}
return tstring(deviceInstance.tszInstanceName) + _T(": ") + tstring(objectInstance.tszName);
}
void CInputConfig::CSimpleBinding::ProcessEvent(const GUID& device, uint32 id, uint32 value, PS2::CControllerInfo::BUTTON button, const InputEventHandler& eventHandler)
{
if(id != BINDINGINFO::id) return;
if(device != BINDINGINFO::device) return;
eventHandler(button, value);
}
void CInputConfig::CSimpleBinding::RegisterPreferences(CConfig& config, const char* buttonBase)
{
string prefBase = CConfig::MakePreferenceName(buttonBase, CONFIG_SIMPLEBINDING_PREFIX);
config.RegisterPreferenceString(
CConfig::MakePreferenceName(prefBase, CONFIG_BINDINGINFO_DEVICE).c_str(),
lexical_cast<string>(GUID()).c_str());
config.RegisterPreferenceInteger(
CConfig::MakePreferenceName(prefBase, CONFIG_BINDINGINFO_ID).c_str(),
0);
}
////////////////////////////////////////////////
// SimulatedAxisBinding
////////////////////////////////////////////////
void CInputConfig::CSimulatedAxisBinding::RegisterPreferences(CConfig& config, const char* buttonBase)
{
// string prefBase = string(buttonBase) + "." + string(CONFIG_SIMPLEBINDING_PREFIX);
// config.RegisterPreferenceString(
// (prefBase + "." + string(CONFIG_SIMPLEBINDING_DEVICE)).c_str(), lexical_cast<string>(GUID()).c_str());
// config.RegisterPreferenceInteger(
// (prefBase + "." + string(CONFIG_SIMPLEBINDING_ID)).c_str(), 0);
}

View File

@ -0,0 +1,91 @@
#ifndef _INPUTCONFIG_H_
#define _INPUTCONFIG_H_
#include "directinput/Manager.h"
#include "tcharx.h"
#include "Types.h"
#include "Singleton.h"
#include "../AppConfig.h"
#include "../ControllerInfo.h"
#include <memory>
#include <functional>
class CInputConfig : public CDependantSingleton<CInputConfig, CAppConfig>
{
public:
friend class CDependantSingleton<CInputConfig, CAppConfig>;
typedef std::tr1::function<void (PS2::CControllerInfo::BUTTON, uint32)> InputEventHandler;
enum BINDINGTYPE
{
BINDING_UNBOUND = 0,
BINDING_SIMPLE = 1,
BINDING_SIMULATEDAXIS = 2,
};
struct BINDINGINFO
{
BINDINGINFO(const GUID& device, uint32 id) : device(device), id(id) { }
GUID device;
uint32 id;
};
class CBinding
{
public:
virtual ~CBinding() {};
virtual BINDINGTYPE GetBindingType() const = 0;
virtual void ProcessEvent(const GUID&, uint32, uint32, PS2::CControllerInfo::BUTTON, const InputEventHandler&) = 0;
virtual void Save(Framework::CConfig&, const char*) const = 0;
virtual void Load(Framework::CConfig&, const char*) = 0;
virtual std::tstring GetDescription(DirectInput::CManager*) const = 0;
};
class CSimpleBinding : public CBinding, private BINDINGINFO
{
public:
CSimpleBinding(const GUID& = GUID(), uint32 = 0);
virtual ~CSimpleBinding();
static void RegisterPreferences(Framework::CConfig&, const char*);
virtual BINDINGTYPE GetBindingType() const;
virtual void ProcessEvent(const GUID&, uint32, uint32, PS2::CControllerInfo::BUTTON, const InputEventHandler&);
virtual void Save(Framework::CConfig&, const char*) const;
virtual void Load(Framework::CConfig&, const char*);
virtual std::tstring GetDescription(DirectInput::CManager*) const;
};
class CSimulatedAxisBinding : public CBinding
{
public:
static void RegisterPreferences(Framework::CConfig&, const char*);
private:
BINDINGINFO key1Binding;
BINDINGINFO key2Binding;
};
const CBinding* GetBinding(PS2::CControllerInfo::BUTTON) const;
void SetSimpleBinding(PS2::CControllerInfo::BUTTON, const BINDINGINFO&);
// void SetSimulatedAxisBinding(Ps2::CControllerInfo::BUTTON,
void Load();
void Save();
void TranslateInputEvent(const GUID&, uint32, uint32, const InputEventHandler&);
std::tstring GetBindingDescription(DirectInput::CManager*, PS2::CControllerInfo::BUTTON) const;
private:
typedef std::tr1::shared_ptr<CBinding> BindingPtr;
CInputConfig(CAppConfig&);
virtual ~CInputConfig();
static void RegisterBindingPreference(Framework::CConfig&, const char*);
BindingPtr m_bindings[PS2::CControllerInfo::MAX_BUTTONS];
static const char* m_buttonName[PS2::CControllerInfo::MAX_BUTTONS];
};
#endif

Binary file not shown.

View File

@ -5,8 +5,8 @@
#include <string>
#include "win32/Window.h"
#include "win32/StatusBar.h"
#include "SettingsDialogProvider.h"
#include "OutputWnd.h"
#include "EventHandler.h"
#ifdef DEBUGGER_INCLUDED
#include "Debugger.h"
#endif
@ -37,7 +37,9 @@ private:
void ShowDebugger();
void ShowSysInfo();
void ShowAbout();
void ShowSettingsDialog(CSettingsDialogProvider*);
void ShowRendererSettings();
void ShowControllerSettings();
void ShowVfsManager();
void ShowMcManager();
@ -55,11 +57,9 @@ private:
void UpdateUI();
void OnNewFrame();
void OnOutputWndSizeChange(int);
void OnOutputWndSizeChange();
void OnExecutableChange();
Framework::CEventHandler<int>* m_pOnOutputWndSizeChangeHandler;
CPS2VM& m_virtualMachine;
unsigned int m_nFrames;

View File

@ -1,11 +1,11 @@
#include <boost/filesystem/operations.hpp>
#include <boost/bind.hpp>
#include <functional>
#include <fstream>
#include "string_cast.h"
#include "McManagerWnd.h"
#include "win32/Static.h"
#include "win32/FileDialog.h"
#include "../Config.h"
#include "../AppConfig.h"
#include "WinUtils.h"
#define CLSNAME _T("CMcManagerWnd")
@ -15,11 +15,13 @@
using namespace Framework;
using namespace boost;
using namespace std;
using namespace std::tr1;
using namespace std::tr1::placeholders;
CMcManagerWnd::CMcManagerWnd(HWND hParent) :
CModalWindow(hParent),
m_MemoryCard0(filesystem::path(CConfig::GetInstance().GetPreferenceString("ps2.mc0.directory"), filesystem::native)),
m_MemoryCard1(filesystem::path(CConfig::GetInstance().GetPreferenceString("ps2.mc1.directory"), filesystem::native))
m_MemoryCard0(filesystem::path(CAppConfig::GetInstance().GetPreferenceString("ps2.mc0.directory"), filesystem::native)),
m_MemoryCard1(filesystem::path(CAppConfig::GetInstance().GetPreferenceString("ps2.mc1.directory"), filesystem::native))
{
RECT rc;
@ -59,8 +61,8 @@ m_MemoryCard1(filesystem::path(CConfig::GetInstance().GetPreferenceString("ps2.m
m_pMemoryCardView = new CMemoryCardView(m_hWnd, &rc);
m_pSaveView = new CSaveView(m_hWnd);
m_pSaveView->m_OnDeleteClicked.InsertHandler(bind(&CMcManagerWnd::Delete, this, _1));
m_pMemoryCardView->m_OnSelectionChange.InsertHandler(bind(&CSaveView::SetSave, m_pSaveView, _1));
m_pSaveView->m_OnDeleteClicked.connect(bind(&CMcManagerWnd::Delete, this, _1));
m_pMemoryCardView->m_OnSelectionChange.connect(bind(&CSaveView::SetSave, m_pSaveView, _1));
m_pMemoryCardList->SetItemData(m_pMemoryCardList->AddString(_T("Memory Card Slot 0 (mc0)")), 0);
m_pMemoryCardList->SetItemData(m_pMemoryCardList->AddString(_T("Memory Card Slot 1 (mc1)")), 1);

View File

@ -1,7 +1,7 @@
#ifndef _MEMORYCARDMANAGER_H_
#define _MEMORYCARDMANAGER_H_
#include "ModalWindow.h"
#include "win32/ModalWindow.h"
#include "win32/ComboBox.h"
#include "win32/Button.h"
#include "win32/Layouts.h"
@ -10,7 +10,7 @@
#include "SaveView.h"
#include "../saves/SaveImporter.h"
class CMcManagerWnd : public CModalWindow
class CMcManagerWnd : public Framework::Win32::CModalWindow, public boost::signals::trackable
{
public:
CMcManagerWnd(HWND);

View File

@ -1,5 +1,6 @@
#include "MemoryCardView.h"
#include "win32/DeviceContext.h"
#include <boost/bind.hpp>
#include <exception>
#include <gl/gl.h>
#include <gl/glu.h>
@ -234,11 +235,11 @@ void CMemoryCardView::SetSelection(unsigned int nSelection)
if((m_ViewState.m_nSelection < m_nItemCount) && (m_pMemoryCard != NULL))
{
m_OnSelectionChange.Notify(m_pMemoryCard->GetSaveByIndex(m_ViewState.m_nSelection));
m_OnSelectionChange(m_pMemoryCard->GetSaveByIndex(m_ViewState.m_nSelection));
}
else
{
m_OnSelectionChange.Notify(NULL);
m_OnSelectionChange(NULL);
}
}

View File

@ -2,12 +2,12 @@
#define _MEMORYCARDVIEW_H_
#include <boost/thread.hpp>
#include <boost/signal.hpp>
#include <boost/ptr_container/ptr_map.hpp>
#include "win32/Window.h"
#include "win32/ClientDeviceContext.h"
#include "MemoryCard.h"
#include "IconView.h"
#include "EventEx.h"
#include "../ThreadMsg.h"
class CMemoryCardView : public Framework::Win32::CWindow
@ -18,7 +18,7 @@ public:
void SetMemoryCard(CMemoryCard*);
Framework::CEventEx<const CSave*> m_OnSelectionChange;
boost::signal<void (const CSave*)> m_OnSelectionChange;
protected:
long OnPaint();

View File

@ -1,48 +0,0 @@
#include "ModalWindow.h"
CModalWindow::CModalWindow(HWND hParent)
{
if(hParent != NULL)
{
EnableWindow(hParent, FALSE);
}
}
CModalWindow::~CModalWindow()
{
}
void CModalWindow::DoModal()
{
Center();
Show(SW_SHOW);
CWindow::StdMsgLoop(this);
}
long CModalWindow::OnSysCommand(unsigned int nCmd, LPARAM lParam)
{
switch(nCmd)
{
case SC_CLOSE:
UnModalWindow();
break;
}
return TRUE;
}
unsigned int CModalWindow::Destroy()
{
UnModalWindow();
return CWindow::Destroy();
}
void CModalWindow::UnModalWindow()
{
if(GetParent() != NULL)
{
EnableWindow(GetParent(), TRUE);
SetForegroundWindow(GetParent());
}
}

View File

@ -1,19 +0,0 @@
#ifndef _MODALWINDOW_H_
#define _MODALWINDOW_H_
#include "win32/Window.h"
class CModalWindow : public Framework::Win32::CWindow
{
public:
CModalWindow(HWND);
virtual ~CModalWindow();
void DoModal();
protected:
unsigned int Destroy();
long OnSysCommand(unsigned int, LPARAM);
void UnModalWindow();
};
#endif

View File

@ -11,7 +11,7 @@
#define EXBOTTOM (EXTOP + EXHEIGHT)
CNiceTabs::CNiceTabs(HWND hParent, RECT* pR) :
m_ListIdx(&m_List)
m_nSelected(0)
{
if(!DoesWindowClassExist(CLASSNAME))
{
@ -28,8 +28,6 @@ m_ListIdx(&m_List)
Create(NULL, CLASSNAME, CLASSNAME, WS_VISIBLE | WS_CHILD, pR, hParent, NULL);
SetClassPtr();
m_nSelected = 0;
m_nEx = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_EX));
m_nExd = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_EXD));
@ -39,44 +37,33 @@ m_ListIdx(&m_List)
CNiceTabs::~CNiceTabs()
{
TABITEM* t;
while(m_List.Count())
{
t = m_List.Pull();
free(t->sCaption);
free(t);
}
DeleteObject(m_nEx);
DeleteObject(m_nExd);
}
void CNiceTabs::InsertTab(const TCHAR* sCaption, unsigned long nFlags, unsigned int nID)
{
TABITEM* t;
t = (TABITEM*)malloc(sizeof(TABITEM));
t->sCaption = (TCHAR*)malloc((_tcslen(sCaption) + 1) * sizeof(TCHAR));
_tcscpy(t->sCaption, sCaption);
t->nWidth = MeasureString(t->sCaption);
t->nFlags = nFlags;
m_List.Insert(t, nID);
m_ListIdx.Reset();
TABITEM t;
t.sCaption = sCaption;
t.nWidth = MeasureString(sCaption);
t.nFlags = nFlags;
t.nID = nID;
m_List.push_back(t);
}
unsigned long CNiceTabs::GetTabWidth(unsigned int nTab)
unsigned long CNiceTabs::GetTabWidth(unsigned int index)
{
TABITEM* t;
t = m_ListIdx.GetAt(nTab);
assert(t);
return t->nWidth + 24 + 5;
const TABITEM& t(m_List[index]);
return t.nWidth + 24 + 5;
}
unsigned long CNiceTabs::GetTabBase(unsigned int nTab)
unsigned long CNiceTabs::GetTabBase(unsigned int index)
{
unsigned long nBase, i;
nBase = 4;
for(i = 0; i < nTab; i++)
{
unsigned long nBase = 4;
for(unsigned int i = 0; i < index; i++)
{
nBase += GetTabWidth(i);
}
}
return nBase;
}
@ -111,9 +98,6 @@ void CNiceTabs::Paint(HDC hDC)
HPEN nPen;
HFONT nFont;
RECT rcli, rc;
unsigned long nBase, nWidth;
TABITEM* t;
unsigned int i;
GetClientRect(&rcli);
@ -133,11 +117,12 @@ void CNiceTabs::Paint(HDC hDC)
DeleteObject(nPen);
//Draw the individual tabs
for(i = 0; i < m_List.Count(); i++)
for(unsigned int i = 0; i < m_List.size(); i++)
{
t = m_ListIdx.GetAt(i);
nWidth = GetTabWidth(i);
nBase = GetTabBase(i);
TABITEM& t(m_List[i]);
unsigned long nWidth = GetTabWidth(i);
unsigned long nBase = GetTabBase(i);
if(i == m_nSelected)
{
SetRect(&rc, nBase, 0, nBase + nWidth, 19);
@ -162,13 +147,13 @@ void CNiceTabs::Paint(HDC hDC)
DeleteObject(nPen);
SetTextColor(hDC, RGB(0x00, 0x00, 0x00));
TextOut(hDC, nBase + 24, 4, t->sCaption, (int)_tcslen(t->sCaption));
TextOut(hDC, nBase + 24, 4, t.sCaption.c_str(), t.sCaption.length());
}
else
{
SetTextColor(hDC, RGB(0x80, 0x80, 0x80));
TextOut(hDC, nBase + 24, 4, t->sCaption, (int)_tcslen(t->sCaption));
TextOut(hDC, nBase + 24, 4, t.sCaption.c_str(), t.sCaption.length());
if(i != (m_nSelected - 1))
{
//Draw the right line
@ -182,60 +167,58 @@ void CNiceTabs::Paint(HDC hDC)
}
}
t = m_ListIdx.GetAt(m_nSelected);
if(t != NULL)
{
if(m_List.size() != 0)
{
TABITEM& t(m_List[m_nSelected]);
if(!(t.nFlags & TAB_FLAG_UNDELETEABLE))
{
hMem = CreateCompatibleDC(hDC);
SelectObject(hMem, m_nEx);
BitBlt(hDC, EXLEFT(rcli), EXTOP, EXWIDTH, EXHEIGHT, hMem, 0, 0, SRCCOPY);
DeleteDC(hMem);
if(!(t->nFlags & TAB_FLAG_UNDELETEABLE))
{
hMem = CreateCompatibleDC(hDC);
SelectObject(hMem, m_nEx);
BitBlt(hDC, EXLEFT(rcli), EXTOP, EXWIDTH, EXHEIGHT, hMem, 0, 0, SRCCOPY);
DeleteDC(hMem);
if(m_nHoverEx)
{
if(m_nLButtonEx)
{
nPen = CreatePen(PS_SOLID, 0, RGB(0xFF, 0xFF, 0xFF));
}
else
{
nPen = CreatePen(PS_SOLID, 0, RGB(0x80, 0x80, 0x80));
}
if(m_nHoverEx)
{
if(m_nLButtonEx)
{
nPen = CreatePen(PS_SOLID, 0, RGB(0xFF, 0xFF, 0xFF));
}
else
{
nPen = CreatePen(PS_SOLID, 0, RGB(0x80, 0x80, 0x80));
}
SelectObject(hDC, nPen);
SelectObject(hDC, nPen);
MoveToEx(hDC, EXRIGHT(rcli) + 3, EXBOTTOM + 2, NULL);
LineTo(hDC, EXRIGHT(rcli) + 3, EXTOP - 3);
MoveToEx(hDC, EXRIGHT(rcli) + 3, EXBOTTOM + 2, NULL);
LineTo(hDC, EXRIGHT(rcli) + 3, EXTOP - 3);
MoveToEx(hDC, EXRIGHT(rcli) + 3, EXBOTTOM + 2, NULL);
LineTo(hDC, EXLEFT(rcli) - 3, EXBOTTOM + 2);
MoveToEx(hDC, EXRIGHT(rcli) + 3, EXBOTTOM + 2, NULL);
LineTo(hDC, EXLEFT(rcli) - 3, EXBOTTOM + 2);
DeleteObject(nPen);
DeleteObject(nPen);
if(m_nLButtonEx)
{
nPen = CreatePen(PS_SOLID, 0, RGB(0x80, 0x80, 0x80));
}
else
{
nPen = CreatePen(PS_SOLID, 0, RGB(0xFF, 0xFF, 0xFF));
}
if(m_nLButtonEx)
{
nPen = CreatePen(PS_SOLID, 0, RGB(0x80, 0x80, 0x80));
}
else
{
nPen = CreatePen(PS_SOLID, 0, RGB(0xFF, 0xFF, 0xFF));
}
SelectObject(hDC, nPen);
SelectObject(hDC, nPen);
MoveToEx(hDC, EXLEFT(rcli) - 3, EXTOP - 3, NULL);
LineTo(hDC, EXLEFT(rcli) - 3, EXBOTTOM + 2);
MoveToEx(hDC, EXLEFT(rcli) - 3, EXTOP - 3, NULL);
LineTo(hDC, EXLEFT(rcli) - 3, EXBOTTOM + 2);
MoveToEx(hDC, EXLEFT(rcli) - 3, EXTOP - 3, NULL);
LineTo(hDC, EXRIGHT(rcli) + 3, EXTOP - 3);
MoveToEx(hDC, EXLEFT(rcli) - 3, EXTOP - 3, NULL);
LineTo(hDC, EXRIGHT(rcli) + 3, EXTOP - 3);
DeleteObject(nPen);
}
}
}
DeleteObject(nPen);
}
}
}
DeleteObject(nFont);
@ -308,16 +291,14 @@ long CNiceTabs::OnMouseMove(WPARAM nButton, int nX, int nY)
long CNiceTabs::OnLeftButtonDown(int nX, int nY)
{
int nBase, nWidth;
nBase = GetTabBase(0);
for(unsigned int i = 0; i < m_List.Count(); i++)
int nBase = GetTabBase(0);
for(unsigned int i = 0; i < m_List.size(); i++)
{
nWidth = GetTabWidth(i);
int nWidth = GetTabWidth(i);
if((nX > nBase) && (nX < (nBase + nWidth)))
{
m_nSelected = i;
m_OnTabChange(m_ListIdx.KeyAt(i));
m_OnTabChange(m_List[i].nID);
RedrawWindow(m_hWnd, NULL, NULL, RDW_INVALIDATE);
break;
}
@ -337,26 +318,21 @@ long CNiceTabs::OnLeftButtonDown(int nX, int nY)
long CNiceTabs::OnLeftButtonUp(int nX, int nY)
{
if(m_nHoverEx == 1)
if(m_nHoverEx == 1 && m_nSelected != 0)
{
TABITEM* i;
m_nLButtonEx = 0;
i = m_ListIdx.GetAt(m_nSelected);
if(i->nFlags & TAB_FLAG_UNDELETEABLE)
TABITEM& t(m_List[m_nSelected]);
if(t.nFlags & TAB_FLAG_UNDELETEABLE)
{
return FALSE;
}
m_List.Remove(m_ListIdx.KeyAt(m_nSelected));
m_ListIdx.Reset();
m_List.erase(m_List.begin() + m_nSelected);
//Always safe to go back, since the first tab will never be deleted
m_nSelected--;
free(i->sCaption);
free(i);
m_OnTabChange(m_ListIdx.KeyAt(m_nSelected));
m_OnTabChange(m_List[m_nSelected].nID);
RedrawWindow(m_hWnd, NULL, NULL, RDW_INVALIDATE);
}
return FALSE;

View File

@ -1,26 +1,19 @@
#ifndef _NICETABS_H_
#define _NICETABS_H_
#include <vector>
#include <boost/signal.hpp>
#include "win32/CustomDrawn.h"
#include "List.h"
struct TABITEM
{
TCHAR* sCaption;
unsigned long nWidth;
unsigned long nFlags;
};
enum TABFLAGS
{
TAB_FLAG_UNDELETEABLE = 0x01,
TAB_FLAG_UNMOVABLE = 0x02,
};
class CNiceTabs : public Framework::Win32::CCustomDrawn
{
public:
enum TABFLAGS
{
TAB_FLAG_UNDELETEABLE = 0x01,
TAB_FLAG_UNMOVABLE = 0x02,
};
CNiceTabs(HWND, RECT*);
virtual ~CNiceTabs();
void InsertTab(const TCHAR*, unsigned long, unsigned int);
@ -35,17 +28,26 @@ protected:
long OnLeftButtonUp(int, int);
private:
struct TABITEM
{
std::tstring sCaption;
unsigned long nWidth;
unsigned long nFlags;
unsigned long nID;
};
typedef std::vector<TABITEM> TabItemList;
HFONT CreateOurFont();
unsigned long GetTabWidth(unsigned int);
unsigned long GetTabBase(unsigned int);
unsigned long GetTabWidth(unsigned int);
unsigned long GetTabBase(unsigned int);
unsigned long MeasureString(const TCHAR*);
Framework::CList<TABITEM> m_List;
Framework::CList<TABITEM>::INDEXOR m_ListIdx;
TabItemList m_List;
HBITMAP m_nEx;
HBITMAP m_nExd;
unsigned long m_nSelected;
unsigned int m_nSelected;
unsigned int m_nHoverEx;
unsigned int m_nLButtonEx;

View File

@ -32,7 +32,7 @@ COutputWnd::~COutputWnd()
long COutputWnd::OnSize(unsigned int nMode, unsigned int nX, unsigned int nY)
{
m_OnSizeChange.Notify(0);
m_OnSizeChange();
return TRUE;
}

View File

@ -2,14 +2,14 @@
#define _OUTPUTWND_H_
#include "win32/Window.h"
#include "Event.h"
#include <boost/signal.hpp>
class COutputWnd : public Framework::Win32::CWindow
{
public:
COutputWnd(HWND, RECT*);
~COutputWnd();
Framework::CEvent<int> m_OnSizeChange;
boost::signal<void ()> m_OnSizeChange;
protected:
long OnPaint();

View File

@ -1,28 +1,23 @@
#include "PH_DirectInput.h"
#include "ControllerSettingsWnd.h"
#include "InputConfig.h"
#define DIBUFFERSIZE (10)
using namespace Framework;
using namespace PS2;
using namespace std::tr1;
using namespace std::tr1::placeholders;
CPH_DirectInput::CPH_DirectInput(HWND hWnd)
CPH_DirectInput::CPH_DirectInput(HWND hWnd) :
m_hWnd(hWnd),
m_manager(NULL)
{
m_hWnd = hWnd;
m_pDI = NULL;
m_pKeyboard = NULL;
Initialize();
}
CPH_DirectInput::~CPH_DirectInput()
{
if(m_pKeyboard != NULL)
{
m_pKeyboard->Release();
}
if(m_pDI != NULL)
{
m_pDI->Release();
}
delete m_manager;
}
CPadHandler::FactoryFunction CPH_DirectInput::GetFactoryFunction(HWND hWnd)
@ -37,44 +32,41 @@ CPadHandler* CPH_DirectInput::PadHandlerFactory(HWND hWnd)
void CPH_DirectInput::Initialize()
{
DIPROPDWORD p;
m_manager = new DirectInput::CManager();
m_manager->CreateKeyboard(m_hWnd);
m_manager->CreateJoysticks(m_hWnd);
}
DirectInput8Create(GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, (void**)&m_pDI, NULL);
m_pDI->CreateDevice(GUID_SysKeyboard, &m_pKeyboard, NULL);
m_pKeyboard->SetDataFormat(&c_dfDIKeyboard);
m_pKeyboard->SetCooperativeLevel(m_hWnd, DISCL_FOREGROUND | DISCL_NONEXCLUSIVE);
memset(&p, 0, sizeof(DIPROPDWORD));
p.diph.dwSize = sizeof(DIPROPDWORD);
p.diph.dwHeaderSize = sizeof(DIPROPHEADER);
p.diph.dwHow = DIPH_DEVICE;
p.diph.dwObj = 0;
p.dwData = DIBUFFERSIZE;
m_pKeyboard->SetProperty(DIPROP_BUFFERSIZE, &p.diph);
m_pKeyboard->Acquire();
DirectInput::CManager* CPH_DirectInput::GetManager() const
{
return m_manager;
}
void CPH_DirectInput::Update(uint8* ram)
{
DWORD nElements, i;
HRESULT hRet;
CPadListener::BUTTON nButton;
CInputConfig::InputEventHandler eventHandler(bind(&CPH_DirectInput::ProcessEvents, this, _1, _2, ram));
m_manager->ProcessEvents(
bind(&CInputConfig::TranslateInputEvent, &CInputConfig::GetInstance(), _1, _2, _3, std::tr1::cref(eventHandler)));
/*
DIDEVICEOBJECTDATA d[DIBUFFERSIZE];
nElements = DIBUFFERSIZE;
hRet = m_pKeyboard->GetDeviceData(sizeof(DIDEVICEOBJECTDATA), d, &nElements, 0);
DWORD nElements = DIBUFFERSIZE;
HRESULT hRet = m_pKeyboard->GetDeviceData(sizeof(DIDEVICEOBJECTDATA), d, &nElements, 0);
if(FAILED(hRet))
{
m_pKeyboard->Acquire();
return;
}
for(i = 0; i < nElements; i++)
int8 analogX = 0;
int8 analogY = 0;
static bool rightPressed = false;
static bool leftPressed = false;
for(DWORD i = 0; i < nElements; i++)
{
if(TranslateKey(d[i].dwOfs, &nButton))
CPadListener::BUTTON nButton;
if(TranslateKey(d[i].dwOfs, &nButton))
{
for(ListenerList::iterator listenerIterator(m_listeners.begin());
listenerIterator != m_listeners.end(); listenerIterator++)
@ -83,56 +75,60 @@ void CPH_DirectInput::Update(uint8* ram)
pListener->SetButtonState(0, nButton, (d[i].dwData & 0x80) ? true : false, ram);
}
}
}
//REMOVE
if(d[i].dwOfs == DIK_LEFT)
{
leftPressed = (d[i].dwData & 0x80) ? true : false;
}
if(d[i].dwOfs == DIK_RIGHT)
{
rightPressed = (d[i].dwData & 0x80) ? true : false;
}
//REMOVE
}
if(rightPressed)
{
analogX += 0x7F;
}
if(leftPressed)
{
analogX -= 0x7F;
}
for(ListenerList::iterator listenerIterator(m_listeners.begin());
listenerIterator != m_listeners.end(); listenerIterator++)
{
CPadListener* pListener(*listenerIterator);
pListener->SetAnalogStickState(0, 0, rand() % 0x7F, rand() % 0x7F, ram);
}
*/
}
bool CPH_DirectInput::TranslateKey(uint32 nSrc, CPadListener::BUTTON* nDst)
void CPH_DirectInput::ProcessEvents(CControllerInfo::BUTTON button, uint32 value, uint8* ram)
{
switch(nSrc)
{
case DIK_RETURN:
(*nDst) = CPadListener::BUTTON_START;
return true;
break;
case DIK_LSHIFT:
case DIK_RSHIFT:
(*nDst) = CPadListener::BUTTON_SELECT;
return true;
break;
case DIK_LEFT:
(*nDst) = CPadListener::BUTTON_LEFT;
return true;
break;
case DIK_UP:
(*nDst) = CPadListener::BUTTON_UP;
return true;
break;
case DIK_DOWN:
(*nDst) = CPadListener::BUTTON_DOWN;
return true;
break;
case DIK_RIGHT:
(*nDst) = CPadListener::BUTTON_RIGHT;
return true;
break;
case DIK_A:
(*nDst) = CPadListener::BUTTON_SQUARE;
return true;
break;
case DIK_Z:
(*nDst) = CPadListener::BUTTON_CROSS;
return true;
break;
case DIK_S:
(*nDst) = CPadListener::BUTTON_TRIANGLE;
return true;
break;
case DIK_X:
(*nDst) = CPadListener::BUTTON_CIRCLE;
return true;
break;
default:
return false;
break;
}
for(ListenerList::iterator listenerIterator(m_listeners.begin());
listenerIterator != m_listeners.end(); listenerIterator++)
{
CPadListener* pListener(*listenerIterator);
if(CControllerInfo::IsAxis(button))
{
pListener->SetAxisState(0, button, static_cast<uint8>((value & 0xFFFF) >> 8), ram);
}
else
{
pListener->SetButtonState(0, button, value ? true : false, ram);
}
}
}
Win32::CModalWindow* CPH_DirectInput::CreateSettingsDialog(HWND parent)
{
return new CControllerSettingsWnd(parent, m_manager);
}
void CPH_DirectInput::OnSettingsDialogDestroyed()
{
}

View File

@ -1,28 +1,34 @@
#ifndef _PH_DIRECTINPUT_H_
#define _PH_DIRECTINPUT_H_
#define DIRECTINPUT_VERSION 0x0800
#include <dinput.h>
#include "directinput/Manager.h"
#include "Types.h"
#include "SettingsDialogProvider.h"
#include "../PadHandler.h"
#include "../ControllerInfo.h"
class CPH_DirectInput : public CPadHandler
class CPH_DirectInput : public CPadHandler, public CSettingsDialogProvider
{
public:
CPH_DirectInput(HWND);
virtual ~CPH_DirectInput();
void Update(uint8*);
CPH_DirectInput(HWND);
virtual ~CPH_DirectInput();
static FactoryFunction GetFactoryFunction(HWND);
void Update(uint8*);
DirectInput::CManager* GetManager() const;
virtual Framework::Win32::CModalWindow* CreateSettingsDialog(HWND);
virtual void OnSettingsDialogDestroyed();
static FactoryFunction GetFactoryFunction(HWND);
private:
static CPadHandler* PadHandlerFactory(HWND);
void Initialize();
bool TranslateKey(uint32, CPadListener::BUTTON*);
static CPadHandler* PadHandlerFactory(HWND);
void Initialize();
void ProcessEvents(PS2::CControllerInfo::BUTTON, uint32, uint8*);
LPDIRECTINPUT8 m_pDI;
LPDIRECTINPUTDEVICE8 m_pKeyboard;
HWND m_hWnd;
DirectInput::CManager* m_manager;
HWND m_hWnd;
};
#endif

View File

@ -4,7 +4,6 @@
#include <boost/signal.hpp>
#include <string>
#include "RegViewPage.h"
#include "EventHandler.h"
#include "../MIPS.h"
#include "../VirtualMachine.h"

View File

@ -5,7 +5,6 @@
#include "RegViewFPU.h"
#include "RegViewVU.h"
#include "PtrMacro.h"
#include "EventHandler.h"
#define CLSNAME _T("CRegViewWnd")
@ -50,10 +49,10 @@ CRegViewWnd::CRegViewWnd(HWND hParent, CVirtualMachine& virtualMachine, CMIPS* p
m_pRegView[3]->Show(SW_HIDE);
m_pTabs = new CNiceTabs(m_hWnd, &rc);
m_pTabs->InsertTab(_T("General"), TAB_FLAG_UNDELETEABLE, 0);
m_pTabs->InsertTab(_T("SCU"), TAB_FLAG_UNDELETEABLE, 1);
m_pTabs->InsertTab(_T("FPU"), TAB_FLAG_UNDELETEABLE, 2);
m_pTabs->InsertTab(_T("VU"), TAB_FLAG_UNDELETEABLE, 3);
m_pTabs->InsertTab(_T("General"), CNiceTabs::TAB_FLAG_UNDELETEABLE, 0);
m_pTabs->InsertTab(_T("SCU"), CNiceTabs::TAB_FLAG_UNDELETEABLE, 1);
m_pTabs->InsertTab(_T("FPU"), CNiceTabs::TAB_FLAG_UNDELETEABLE, 2);
m_pTabs->InsertTab(_T("VU"), CNiceTabs::TAB_FLAG_UNDELETEABLE, 3);
m_pCurrent = NULL;
SetCurrentView(0);

View File

@ -4,7 +4,7 @@
#include "layout/LayoutStretch.h"
#include "win32/LayoutWindow.h"
#include "win32/Static.h"
#include "../Config.h"
#include "../AppConfig.h"
#define CLSNAME _T("RendererSettingsWnd")
#define WNDSTYLE (WS_CAPTION | WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_SYSMENU)
@ -43,9 +43,9 @@ CModalWindow(hParent)
m_pOk = new Win32::CButton(_T("OK"), m_hWnd, &rc);
m_pCancel = new Win32::CButton(_T("Cancel"), m_hWnd, &rc);
m_nLinesAsQuads = CConfig::GetInstance().GetPreferenceBoolean(PREF_CGSH_OPENGL_LINEASQUADS);
m_nForceBilinearTextures = CConfig::GetInstance().GetPreferenceBoolean(PREF_CGSH_OPENGL_FORCEBILINEARTEXTURES);
m_nForceFlippingVSync = CConfig::GetInstance().GetPreferenceBoolean(PREF_CGSH_OPENGL_FORCEFLIPPINGVSYNC);
m_nLinesAsQuads = CAppConfig::GetInstance().GetPreferenceBoolean(PREF_CGSH_OPENGL_LINEASQUADS);
m_nForceBilinearTextures = CAppConfig::GetInstance().GetPreferenceBoolean(PREF_CGSH_OPENGL_FORCEBILINEARTEXTURES);
m_nForceFlippingVSync = CAppConfig::GetInstance().GetPreferenceBoolean(PREF_CGSH_OPENGL_FORCEFLIPPINGVSYNC);
m_pLineCheck = new Win32::CButton(_T("Render lines using quads"), m_hWnd, &rc, BS_CHECKBOX);
m_pLineCheck->SetCheck(m_nLinesAsQuads);
@ -183,9 +183,9 @@ void CRendererSettingsWnd::UpdateExtList()
void CRendererSettingsWnd::Save()
{
CConfig::GetInstance().SetPreferenceBoolean(PREF_CGSH_OPENGL_LINEASQUADS, m_nLinesAsQuads);
CConfig::GetInstance().SetPreferenceBoolean(PREF_CGSH_OPENGL_FORCEBILINEARTEXTURES, m_nForceBilinearTextures);
CConfig::GetInstance().SetPreferenceBoolean(PREF_CGSH_OPENGL_FORCEFLIPPINGVSYNC, m_nForceFlippingVSync);
CAppConfig::GetInstance().SetPreferenceBoolean(PREF_CGSH_OPENGL_LINEASQUADS, m_nLinesAsQuads);
CAppConfig::GetInstance().SetPreferenceBoolean(PREF_CGSH_OPENGL_FORCEBILINEARTEXTURES, m_nForceBilinearTextures);
CAppConfig::GetInstance().SetPreferenceBoolean(PREF_CGSH_OPENGL_FORCEFLIPPINGVSYNC, m_nForceFlippingVSync);
}
bool CRendererSettingsWnd::ProcessCheckBoxMessage(HWND hSender, Win32::CButton* pCheckBox, bool* pFlag)

View File

@ -1,13 +1,13 @@
#ifndef _RENDERERSETTINGSWND_H_
#define _RENDERERSETTINGSWND_H_
#include "ModalWindow.h"
#include "win32/ModalWindow.h"
#include "layout/VerticalLayout.h"
#include "win32/ListView.h"
#include "win32/Button.h"
#include "../GSH_OpenGL.h"
class CRendererSettingsWnd : public CModalWindow
class CRendererSettingsWnd : public Framework::Win32::CModalWindow
{
public:
CRendererSettingsWnd(HWND, CGSH_OpenGL*);

View File

@ -148,6 +148,7 @@ BEGIN
POPUP "Options"
BEGIN
MENUITEM "Renderer Settings...", ID_MAIN_OPTIONS_RENDERER
MENUITEM "Controller Settings...", ID_MAIN_OPTIONS_CONTROLLER
MENUITEM "&Virtual File System Manager...", ID_MAIN_OPTIONS_VFSMANAGER
MENUITEM "Memory Card Manager...", ID_MAIN_OPTIONS_MCMANAGER
END

View File

@ -252,7 +252,7 @@ long CSaveView::Delete()
{
if(m_pSave == NULL) return FALSE;
m_OnDeleteClicked.Notify(m_pSave);
m_OnDeleteClicked(m_pSave);
return FALSE;
}

View File

@ -2,17 +2,17 @@
#define _SAVEVIEW_H_
#include <boost/thread.hpp>
#include <boost/signal.hpp>
#include "win32/Window.h"
#include "win32/Edit.h"
#include "win32/Button.h"
#include "win32/Layouts.h"
#include "IconView.h"
#include "CommandSink.h"
#include "EventEx.h"
#include "../saves/Save.h"
#include "../ThreadMsg.h"
class CSaveView : public Framework::Win32::CWindow
class CSaveView : public Framework::Win32::CWindow, public boost::signals::trackable
{
public:
CSaveView(HWND);
@ -20,7 +20,7 @@ public:
void SetSave(const CSave*);
Framework::CEventEx<const CSave*> m_OnDeleteClicked;
boost::signal<void (const CSave*)> m_OnDeleteClicked;
protected:
long OnSize(unsigned int, unsigned int, unsigned int);

View File

@ -1,13 +1,13 @@
#ifndef _SETTINGSDIALOGPROVIDER_H_
#define _SETTINGSDIALOGPROVIDER_H_
#include "ModalWindow.h"
#include "win32/ModalWindow.h"
class CSettingsDialogProvider
{
public:
virtual CModalWindow* CreateSettingsDialog(HWND) = 0;
virtual void OnSettingsDialogDestroyed() = 0;
virtual Framework::Win32::CModalWindow* CreateSettingsDialog(HWND) = 0;
virtual void OnSettingsDialogDestroyed() = 0;
};
#endif

View File

@ -7,7 +7,7 @@
#include "win32/LayoutWindow.h"
#include "win32/Static.h"
#include "PtrMacro.h"
#include "../Config.h"
#include "../AppConfig.h"
#include "CdromSelectionWnd.h"
#include "string_cast.h"
@ -218,7 +218,7 @@ CVFSManagerWnd::CDirectoryDevice::CDirectoryDevice(const char* sName, const char
{
m_sName = sName;
m_sPreference = sPreference;
m_sValue = CConfig::GetInstance().GetPreferenceString(m_sPreference);
m_sValue = CAppConfig::GetInstance().GetPreferenceString(m_sPreference);
}
CVFSManagerWnd::CDirectoryDevice::~CDirectoryDevice()
@ -277,7 +277,7 @@ bool CVFSManagerWnd::CDirectoryDevice::RequestModification(HWND hParent)
void CVFSManagerWnd::CDirectoryDevice::Save()
{
CConfig::GetInstance().SetPreferenceString(m_sPreference, m_sValue.c_str());
CAppConfig::GetInstance().SetPreferenceString(m_sPreference, m_sValue.c_str());
}
int CVFSManagerWnd::CDirectoryDevice::BrowseCallback(HWND hFrom, unsigned int nMsg, LPARAM lParam, LPARAM pData)
@ -302,7 +302,7 @@ CVFSManagerWnd::CCdrom0Device::CCdrom0Device()
const char* sPath;
char sDevicePath[32];
sPath = CConfig::GetInstance().GetPreferenceString(CDROM0PATH);
sPath = CAppConfig::GetInstance().GetPreferenceString(CDROM0PATH);
//Detect the binding type from the path format
if(!strcmp(sPath, ""))
@ -397,12 +397,12 @@ void CVFSManagerWnd::CCdrom0Device::Save()
{
if(m_nBindingType == CCdromSelectionWnd::BINDING_IMAGE)
{
CConfig::GetInstance().SetPreferenceString(CDROM0PATH, m_sImagePath.c_str());
CAppConfig::GetInstance().SetPreferenceString(CDROM0PATH, m_sImagePath.c_str());
}
if(m_nBindingType == CCdromSelectionWnd::BINDING_PHYSICAL)
{
char sDevicePath[32];
sprintf(sDevicePath, "\\\\.\\%c:", m_sDevicePath[0]);
CConfig::GetInstance().SetPreferenceString(CDROM0PATH, sDevicePath);
CAppConfig::GetInstance().SetPreferenceString(CDROM0PATH, sDevicePath);
}
}

View File

@ -3,12 +3,12 @@
#include <string>
#include <map>
#include "ModalWindow.h"
#include "win32/ModalWindow.h"
#include "win32/Button.h"
#include "win32/ListView.h"
#include "layout/LayoutObject.h"
class CVFSManagerWnd : public CModalWindow
class CVFSManagerWnd : public Framework::Win32::CModalWindow
{
public:
CVFSManagerWnd(HWND);

View File

@ -150,13 +150,15 @@
#define ID_VM_FRAMESKIP_DECREMENT 40147
#define ID_MAIN_VM_FRAMESKIP_DECREMENT 40148
#define ID_MAIN_VM_FRAMESKIP_INCREMENT 40149
#define ID_OPTIONS_INPUTSETTINGS 40150
#define ID_MAIN_OPTIONS_CONTROLLER 40151
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 118
#define _APS_NEXT_COMMAND_VALUE 40150
#define _APS_NEXT_COMMAND_VALUE 40152
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif

Binary file not shown.