win32: add hotkey to switch aspect ratio (#912)

This commit is contained in:
OV2 2024-05-09 14:59:31 +02:00
parent ba6f67510e
commit bf83f0f605
4 changed files with 43 additions and 7 deletions

View File

@ -939,6 +939,7 @@ void WinRegisterConfigItems()
ADD(SaveFileSelect); ADD(LoadFileSelect);
ADD(Mute);
ADD(ToggleBackdrop);
ADD(AspectRatio);
#undef ADD
#undef ADDN
#undef CATEGORY

View File

@ -136,6 +136,8 @@ Nintendo is a trademark.")
#define HOTKEYS_LABEL_4_11 TEXT("Save to file:")
#define HOTKEYS_LABEL_4_12 TEXT("Load from file:")
#define HOTKEYS_SWITCH_ASPECT_RATIO TEXT("Switch aspect Ratio:")
// gaming buttons and axes
#define GAMEDEVICE_JOYNUMPREFIX "(J%x)" // don't change this
#define GAMEDEVICE_JOYBUTPREFIX "#[%d]" // don't change this

View File

@ -125,7 +125,8 @@ void S9xWinScanJoypads();
#define TIMER_SCANJOYPADS (99999)
#define NC_SEARCHDB 0x8000
#define MAX_SWITCHABLE_HOTKEY_DIALOG_ITEMS 14
constexpr int MAX_SWITCHABLE_HOTKEY_DIALOG_ITEMS = 14;
constexpr int MAX_SWITCHABLE_HOTKEY_DIALOG_PAGES = 5;
#ifdef UNICODE
#define S9XW_SHARD_PATH SHARD_PATHW
@ -1222,6 +1223,18 @@ int HandleKeyMessage(WPARAM wParam, LPARAM lParam)
FreezeUnfreezeDialog(FALSE);
hitHotKey = true;
}
if (wParam == CustomKeys.AspectRatio.key
&& modifiers == CustomKeys.AspectRatio.modifiers)
{
if (GUI.AspectWidth == ASPECT_WIDTH_4_3)
{
GUI.AspectWidth = ASPECT_WIDTH_8_7;
}
else
{
GUI.AspectWidth = ASPECT_WIDTH_4_3;
}
}
if (wParam == CustomKeys.Mute.key
&& modifiers == CustomKeys.Mute.modifiers)
@ -7562,10 +7575,10 @@ INT_PTR CALLBACK DlgFunky(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
SendDlgItemMessage(hDlg, IDC_ASPECTDROP, CB_ADDSTRING, 0, (LPARAM)TEXT("8:7"));
SendDlgItemMessage(hDlg, IDC_ASPECTDROP, CB_ADDSTRING, 0, (LPARAM)TEXT("4:3"));
switch (GUI.AspectWidth) {
case 256:
case ASPECT_WIDTH_4_3:
SendDlgItemMessage(hDlg, IDC_ASPECTDROP, CB_SETCURSEL, (WPARAM)0, 0);
break;
case 299:
case ASPECT_WIDTH_8_7:
SendDlgItemMessage(hDlg, IDC_ASPECTDROP, CB_SETCURSEL, (WPARAM)1, 0);
break;
default:
@ -7731,10 +7744,10 @@ INT_PTR CALLBACK DlgFunky(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
int newsel = SendDlgItemMessage(hDlg,IDC_ASPECTDROP,CB_GETCURSEL,0,0);
switch(newsel) {
case 0:
GUI.AspectWidth = 256;
GUI.AspectWidth = ASPECT_WIDTH_4_3;
break;
case 1:
GUI.AspectWidth = 299;
GUI.AspectWidth = ASPECT_WIDTH_8_7;
break;
default:
GUI.AspectWidth = prevAspectWidth;
@ -8301,7 +8314,7 @@ struct hotkey_dialog_item {
// this structure defines the four sub pages in the hotkey config dialog
// to keep an entry blank, set the SCustomKey pointer to NULL and the text to an empty string
static hotkey_dialog_item hotkey_dialog_items[4][MAX_SWITCHABLE_HOTKEY_DIALOG_ITEMS] = {
static hotkey_dialog_item hotkey_dialog_items[MAX_SWITCHABLE_HOTKEY_DIALOG_PAGES][MAX_SWITCHABLE_HOTKEY_DIALOG_ITEMS] = {
{
{ &CustomKeys.SpeedUp, HOTKEYS_LABEL_1_1 },
{ &CustomKeys.SpeedDown, HOTKEYS_LABEL_1_2 },
@ -8366,6 +8379,22 @@ static hotkey_dialog_item hotkey_dialog_items[4][MAX_SWITCHABLE_HOTKEY_DIALOG_IT
{ NULL, _T("") },
{ NULL, _T("") },
},
{
{ &CustomKeys.AspectRatio, HOTKEYS_SWITCH_ASPECT_RATIO },
{ NULL, _T("") },
{ NULL, _T("") },
{ NULL, _T("") },
{ NULL, _T("") },
{ NULL, _T("") },
{ NULL, _T("") },
{ NULL, _T("") },
{ NULL, _T("") },
{ NULL, _T("") },
{ NULL, _T("") },
{ NULL, _T("") },
{ NULL, _T("") },
{ NULL, _T("") },
},
};
static void set_hotkeyinfo(HWND hDlg)
@ -8434,7 +8463,7 @@ switch(msg)
SetWindowText(hDlg,HOTKEYS_TITLE);
// insert hotkey page list items
for(i=1 ; i <= 4 ; i++)
for(i=1 ; i <= MAX_SWITCHABLE_HOTKEY_DIALOG_PAGES; i++)
{
TCHAR temp[256];
_stprintf(temp,HOTKEYS_HKCOMBO,i);

View File

@ -39,6 +39,9 @@
#define NUM_SAVE_BANKS 10
#define LAST_SAVE_BANK (NUM_SAVE_BANKS - 1)
constexpr int ASPECT_WIDTH_4_3 = 256;
constexpr int ASPECT_WIDTH_8_7 = 299;
#include "_tfwopen.h"
#ifdef UNICODE
#define _tToChar WideToUtf8
@ -348,6 +351,7 @@ struct SCustomKeys {
SCustomKey SaveFileSelect;
SCustomKey LoadFileSelect;
SCustomKey Mute;
SCustomKey AspectRatio;
};
struct SJoypad {