Project64-input: Add base config UI

This commit is contained in:
zilmar 2020-06-17 16:53:10 +09:30
parent 51b78c117e
commit be939dca65
13 changed files with 283 additions and 1 deletions

5
.gitignore vendored
View File

@ -50,6 +50,8 @@ Thumbs.db
/Plugin/Input/AndroidInput_d.dll /Plugin/Input/AndroidInput_d.dll
/Plugin/Input/PJ64_NRage.dll /Plugin/Input/PJ64_NRage.dll
/Plugin/Input/PJ64_NRage_d.dll /Plugin/Input/PJ64_NRage_d.dll
/Plugin/Input/Project64-Input.dll
/Plugin/Input/Project64-Input_d.dll
/Plugin/RSP/lib /Plugin/RSP/lib
/Plugin/RSP/map /Plugin/RSP/map
/Plugin/RSP/pdb /Plugin/RSP/pdb
@ -76,6 +78,8 @@ Thumbs.db
/Plugin64/Input/AndroidInput_d.dll /Plugin64/Input/AndroidInput_d.dll
/Plugin64/Input/PJ64_NRage.dll /Plugin64/Input/PJ64_NRage.dll
/Plugin64/Input/PJ64_NRage_d.dll /Plugin64/Input/PJ64_NRage_d.dll
/Plugin64/Input/Project64-Input.dll
/Plugin64/Input/Project64-Input_d.dll
/Plugin64/RSP/lib /Plugin64/RSP/lib
/Plugin64/RSP/map /Plugin64/RSP/map
/Plugin64/RSP/pdb /Plugin64/RSP/pdb
@ -86,6 +90,7 @@ Thumbs.db
/Source/nragev20/Version.h /Source/nragev20/Version.h
/Source/Project64-audio/Version.h /Source/Project64-audio/Version.h
/Source/Project64-core/Version.h /Source/Project64-core/Version.h
/Source/Project64-input/Version.h
/Source/Project64-video/Version.h /Source/Project64-video/Version.h
/Source/RSP/Version.h /Source/RSP/Version.h
/Save /Save

View File

@ -60,9 +60,14 @@ EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "JoinSettings", "Source\JoinSettings\JoinSettings.vcxproj", "{B2E592F2-F416-4049-BD22-9CA9090242BB}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "JoinSettings", "Source\JoinSettings\JoinSettings.vcxproj", "{B2E592F2-F416-4049-BD22-9CA9090242BB}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Project64", "Source\Project64\Project64.vcxproj", "{7E534C8E-1ACE-4A88-8807-39A11ED4DA18}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Project64", "Source\Project64\Project64.vcxproj", "{7E534C8E-1ACE-4A88-8807-39A11ED4DA18}"
ProjectSection(ProjectDependencies) = postProject
{D3F979CE-8FA7-48C9-A2B3-A33594B48536} = {D3F979CE-8FA7-48C9-A2B3-A33594B48536}
EndProjectSection
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "discord-rpc", "Source\3rdParty\discord-rpc\discord-rpc.vcxproj", "{DCC841B2-298A-40F0-84D1-ACBABD3B86E8}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "discord-rpc", "Source\3rdParty\discord-rpc\discord-rpc.vcxproj", "{DCC841B2-298A-40F0-84D1-ACBABD3B86E8}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Project64-input", "Source\Project64-input\Project64-input.vcxproj", "{D3F979CE-8FA7-48C9-A2B3-A33594B48536}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32 Debug|Win32 = Debug|Win32
@ -222,6 +227,14 @@ Global
{DCC841B2-298A-40F0-84D1-ACBABD3B86E8}.Release|Win32.Build.0 = Release|Win32 {DCC841B2-298A-40F0-84D1-ACBABD3B86E8}.Release|Win32.Build.0 = Release|Win32
{DCC841B2-298A-40F0-84D1-ACBABD3B86E8}.Release|x64.ActiveCfg = Release|x64 {DCC841B2-298A-40F0-84D1-ACBABD3B86E8}.Release|x64.ActiveCfg = Release|x64
{DCC841B2-298A-40F0-84D1-ACBABD3B86E8}.Release|x64.Build.0 = Release|x64 {DCC841B2-298A-40F0-84D1-ACBABD3B86E8}.Release|x64.Build.0 = Release|x64
{D3F979CE-8FA7-48C9-A2B3-A33594B48536}.Debug|Win32.ActiveCfg = Debug|Win32
{D3F979CE-8FA7-48C9-A2B3-A33594B48536}.Debug|Win32.Build.0 = Debug|Win32
{D3F979CE-8FA7-48C9-A2B3-A33594B48536}.Debug|x64.ActiveCfg = Debug|x64
{D3F979CE-8FA7-48C9-A2B3-A33594B48536}.Debug|x64.Build.0 = Debug|x64
{D3F979CE-8FA7-48C9-A2B3-A33594B48536}.Release|Win32.ActiveCfg = Release|Win32
{D3F979CE-8FA7-48C9-A2B3-A33594B48536}.Release|Win32.Build.0 = Release|Win32
{D3F979CE-8FA7-48C9-A2B3-A33594B48536}.Release|x64.ActiveCfg = Release|x64
{D3F979CE-8FA7-48C9-A2B3-A33594B48536}.Release|x64.Build.0 = Release|x64
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

View File

@ -0,0 +1,83 @@
#include "InputConfigUI.h"
#include "wtl.h"
#include "wtl-BitmapPicture.h"
#include <Common\stdtypes.h>
#include <Common\StdString.h>
#include "resource.h"
class CControllerSettings :
public CPropertyPageImpl<CControllerSettings>
{
public:
enum { IDD = IDD_Controller };
BEGIN_MSG_MAP(CDebugSettings)
MSG_WM_INITDIALOG(OnInitDialog)
CHAIN_MSG_MAP(CPropertyPageImpl<CControllerSettings>)
END_MSG_MAP()
CControllerSettings();
void SetControllerNumber(uint32_t ControllerNumber);
BOOL OnInitDialog(CWindow /*wndFocus*/, LPARAM /*lInitParam*/);
private:
std::wstring m_Title;
uint32_t m_ControllerNumber;
CBitmapPicture m_ControllerImg;
};
CControllerSettings::CControllerSettings() :
m_ControllerNumber((uint32_t)-1)
{
}
void CControllerSettings::SetControllerNumber(uint32_t ControllerNumber)
{
m_Title = stdstr_f("Player %d", ControllerNumber + 1).ToUTF16();
SetTitle(m_Title.c_str());
m_ControllerNumber = ControllerNumber;
}
BOOL CControllerSettings::OnInitDialog(CWindow /*wndFocus*/, LPARAM /*lInitParam*/)
{
m_ControllerImg.SubclassWindow(GetDlgItem(IDC_BMP_CONTROLLER));
m_ControllerImg.SetBitmap(MAKEINTRESOURCE(IDB_CONTROLLER));
return TRUE;
}
class CInputConfigUI:
public CPropertySheetImpl<CInputConfigUI>
{
public:
CInputConfigUI();
~CInputConfigUI();
void OnSheetInitialized();
private:
CControllerSettings m_pgController[4];
};
void ConfigInput(void * hParent)
{
CInputConfigUI().DoModal((HWND)hParent);
}
CInputConfigUI::CInputConfigUI()
{
m_psh.pszCaption = L"Configure Input";
for (size_t i = 0, n = sizeof(m_pgController) / sizeof(m_pgController[0]); i < n; i++)
{
m_pgController[i].SetControllerNumber(i);
AddPage(&m_pgController[i].m_psp);
}
}
CInputConfigUI::~CInputConfigUI()
{
}
void CInputConfigUI::OnSheetInitialized()
{
ModifyStyleEx(WS_EX_CONTEXTHELP,0);
}

View File

@ -0,0 +1,3 @@
#pragma once
void ConfigInput(void * hParent);

View File

@ -9,6 +9,7 @@
* * * *
****************************************************************************/ ****************************************************************************/
#include "ControllerSpec1.1.h" #include "ControllerSpec1.1.h"
#include "InputConfigUI.h"
#include "Version.h" #include "Version.h"
#include <stdio.h> #include <stdio.h>
@ -61,9 +62,12 @@ to allow the user to configure the dll
input: a handle to the window that calls this function input: a handle to the window that calls this function
output: none output: none
*******************************************************************/ *******************************************************************/
EXPORT void CALL DllConfig(void * /*hParent*/) #ifdef _WIN32
EXPORT void CALL DllConfig(void * hParent)
{ {
ConfigInput(hParent);
} }
#endif
/****************************************************************** /******************************************************************
Function: DllTest Function: DllTest

View File

@ -47,11 +47,16 @@
</PreBuildEvent> </PreBuildEvent>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="InputConfigUI.cpp" />
<ClCompile Include="InputMain.cpp" /> <ClCompile Include="InputMain.cpp" />
<ClCompile Include="wtl-BitmapPicture.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="InputConfigUI.h" />
<ClInclude Include="ControllerSpec1.1.h" /> <ClInclude Include="ControllerSpec1.1.h" />
<ClInclude Include="resource.h" /> <ClInclude Include="resource.h" />
<ClInclude Include="wtl-BitmapPicture.h" />
<ClInclude Include="wtl.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="Version.h.in" /> <None Include="Version.h.in" />
@ -59,4 +64,12 @@
<ItemGroup> <ItemGroup>
<ResourceCompile Include="Project64-input.rc" /> <ResourceCompile Include="Project64-input.rc" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Image Include="Controller.bmp" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Common\Common.vcxproj">
<Project>{b4a4b994-9111-42b1-93c2-6f1ca8bc4421}</Project>
</ProjectReference>
</ItemGroup>
</Project> </Project>

View File

@ -18,6 +18,12 @@
<ClCompile Include="InputMain.cpp"> <ClCompile Include="InputMain.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="InputConfigUI.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="wtl-BitmapPicture.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="ControllerSpec1.1.h"> <ClInclude Include="ControllerSpec1.1.h">
@ -26,6 +32,15 @@
<ClInclude Include="resource.h"> <ClInclude Include="resource.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="InputConfigUI.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="wtl-BitmapPicture.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="wtl.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="Version.h.in"> <None Include="Version.h.in">
@ -37,4 +52,9 @@
<Filter>Resource Files</Filter> <Filter>Resource Files</Filter>
</ResourceCompile> </ResourceCompile>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Image Include="Controller.bmp">
<Filter>Resource Files</Filter>
</Image>
</ItemGroup>
</Project> </Project>

Binary file not shown.

View File

@ -0,0 +1,92 @@
#include "wtl-BitmapPicture.h"
CBitmapPicture::CBitmapPicture() :
m_hBitmap(NULL),
m_nResourceID(-1),
m_ResourceIcon(false)
{
memset(&m_bmInfo, 0, sizeof(m_bmInfo));
m_BackgroundBrush.CreateSolidBrush(::GetSysColor(COLOR_3DFACE));
}
LRESULT CBitmapPicture::OnPaint(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL &/*bHandled*/)
{
CPaintDC dc(m_hWnd);
CRect rect;
GetClientRect(&rect);
CBrush PaintBrush;
HBRUSH OldBrush = dc.SelectBrush(m_BackgroundBrush);
dc.PatBlt(rect.left, rect.top, rect.Width(), rect.Height(), PATCOPY);
if (m_ResourceIcon)
{
CIcon hIcon = (HICON)::LoadImage(ModuleHelper::GetResourceInstance(), m_nResourceID > 0 ? MAKEINTRESOURCE(m_nResourceID) : m_strResourceName.c_str(), IMAGE_ICON, m_IconWidth, m_IconHeight, LR_DEFAULTCOLOR | LR_DEFAULTSIZE);
if (!hIcon.IsNull())
{
dc.DrawIconEx(0, 0, hIcon, rect.Width(), rect.Height(), 0, NULL, DI_NORMAL);
}
}
else
{
CBitmap hBmp = (HBITMAP)::LoadImage(ModuleHelper::GetResourceInstance(), m_nResourceID > 0 ? MAKEINTRESOURCE(m_nResourceID) : m_strResourceName.c_str(), IMAGE_BITMAP, 0, 0, LR_LOADMAP3DCOLORS);
BITMAP bm;
hBmp.GetBitmap(&bm);
CDC dcMem;
dcMem.CreateCompatibleDC(dc);
dcMem.SelectBitmap(hBmp);
dc.StretchBlt(rect.left, rect.top, rect.Width(), rect.Height(), dcMem, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);
}
dc.SelectBrush(OldBrush);
return 0;
}
bool CBitmapPicture::SetIcon(LPCWSTR lpszResourceName, uint32_t nWidth, uint32_t nHeight)
{
CIcon hIcon = (HICON)::LoadImage(ModuleHelper::GetResourceInstance(), lpszResourceName, IMAGE_ICON, nWidth, nHeight, LR_DEFAULTCOLOR | LR_DEFAULTSIZE);
if (hIcon.IsNull())
{
return false;
}
ICONINFO IconInfo;
if (!hIcon.GetIconInfo(&IconInfo))
{
return false;
}
if (IS_INTRESOURCE(lpszResourceName))
{
m_nResourceID = (int)lpszResourceName;
}
else
{
m_strResourceName = lpszResourceName;
}
m_ResourceIcon = true;
m_IconWidth = nWidth;
m_IconHeight = nHeight;
return true;
}
bool CBitmapPicture::SetBitmap(HBITMAP hBitmap)
{
m_hBitmap.Attach(hBitmap);
return ::GetObject(m_hBitmap, sizeof(BITMAP), &m_bmInfo) != 0;
}
void CBitmapPicture::SetBitmap(LPCWSTR lpszResourceName)
{
if (IS_INTRESOURCE(lpszResourceName))
{
m_nResourceID = (int)lpszResourceName;
}
else
{
m_strResourceName = lpszResourceName;
}
m_ResourceIcon = false;
}
void CBitmapPicture::SetBackroundBrush(HBRUSH brush)
{
m_BackgroundBrush.Attach(brush);
}

View File

@ -0,0 +1,34 @@
#pragma once
#include "wtl.h"
#include <string>
class CBitmapPicture :
public CWindowImpl <CBitmapPicture>
{
public:
BEGIN_MSG_MAP(CBitmapPicture)
MESSAGE_HANDLER(WM_PAINT, OnPaint);
END_MSG_MAP()
CBitmapPicture();
LRESULT OnPaint(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL &/*bHandled*/);
bool SetIcon(LPCWSTR lpszResourceName, uint32_t nWidth, uint32_t nHeight);
void SetBitmap(LPCWSTR lpszResourceName);
void SetBackroundBrush(HBRUSH brush);
private:
CBitmapPicture(const CBitmapPicture&);
CBitmapPicture& operator=(const CBitmapPicture&);
bool CBitmapPicture::SetBitmap(HBITMAP hBitmap);
int m_nResourceID;
std::wstring m_strResourceName;
uint32_t m_IconWidth, m_IconHeight;
bool m_ResourceIcon;
BITMAP m_bmInfo;
CBitmap m_hBitmap;
CBrush m_BackgroundBrush;
};

View File

@ -0,0 +1,15 @@
#pragma once
#pragma warning(push)
#pragma warning(disable : 4091) // warning C4091: 'typedef ': ignored on left of 'tagGPFIDL_FLAGS' when no variable is declared
#pragma warning(disable : 4302) // warning C4302: 'type cast': truncation from 'LPCTSTR' to 'WORD'
#pragma warning(disable : 4458) // warning C4458: declaration of 'dwCommonButtons' hides class member
#pragma warning(disable : 4838) // warning C4838: conversion from 'int' to 'UINT' requires a narrowing conversion
#pragma warning(disable : 4996) // warning C4996: 'GetVersionExA': was declared deprecated
#pragma warning(disable : 4302) // warning C4302: 'type cast': truncation from 'LPCTSTR' to 'WORD'
#pragma warning(disable : 4457) // warning C4457: declaration of 'pstr' hides function parameter
#include <atlbase.h>
#include <wtl/atlapp.h>
#include <wtl/atldlgs.h>
#include <wtl/atlmisc.h>
#include <WTL/atlcrack.h>
#pragma warning(pop)