2021-10-24 18:23:46 +03:00
|
|
|
|
#include "pch.h"
|
2020-11-05 18:44:34 +03:00
|
|
|
|
#include "options.h"
|
2020-12-02 20:12:34 +03:00
|
|
|
|
|
|
|
|
|
#include "fullscrn.h"
|
2020-11-05 18:44:34 +03:00
|
|
|
|
#include "memory.h"
|
2020-12-02 20:12:34 +03:00
|
|
|
|
#include "midi.h"
|
2021-02-06 16:53:47 +03:00
|
|
|
|
#include "pb.h"
|
2020-12-04 18:35:47 +03:00
|
|
|
|
#include "resource.h"
|
2020-11-06 16:56:32 +03:00
|
|
|
|
#include "Sound.h"
|
2020-12-03 17:47:36 +03:00
|
|
|
|
#include "winmain.h"
|
2020-11-05 18:44:34 +03:00
|
|
|
|
|
|
|
|
|
LPCSTR options::OptionsRegPath;
|
|
|
|
|
LPSTR options::OptionsRegPathCur;
|
2020-11-06 16:56:32 +03:00
|
|
|
|
HMENU options::MenuHandle;
|
2021-02-09 18:09:44 +03:00
|
|
|
|
optionsStruct options::Options{};
|
2020-11-06 16:56:32 +03:00
|
|
|
|
|
2020-12-13 16:05:19 +03:00
|
|
|
|
winhelp_entry options::keymap_help[18]
|
|
|
|
|
{
|
|
|
|
|
winhelp_entry{0x1F5, 0x3EA},
|
|
|
|
|
winhelp_entry{0x191, 0x3EC},
|
|
|
|
|
winhelp_entry{0x192, 0x3ED},
|
|
|
|
|
winhelp_entry{0x193, 0x3F1},
|
|
|
|
|
winhelp_entry{0x194, 0x3EE},
|
|
|
|
|
winhelp_entry{0x195, 0x3EF},
|
|
|
|
|
winhelp_entry{0x196, 0x3F0},
|
|
|
|
|
winhelp_entry{0x385, 0x3EC},
|
|
|
|
|
winhelp_entry{0x386, 0x3ED},
|
|
|
|
|
winhelp_entry{0x387, 0x3F1},
|
|
|
|
|
winhelp_entry{0x388, 0x3EE},
|
|
|
|
|
winhelp_entry{0x389, 0x3EF},
|
|
|
|
|
winhelp_entry{0x38A, 0x3F0},
|
|
|
|
|
winhelp_entry{0x38C, -1},
|
|
|
|
|
winhelp_entry{0x38D, -1},
|
|
|
|
|
winhelp_entry{0x321, -1},
|
|
|
|
|
winhelp_entry{0x322, -1},
|
|
|
|
|
winhelp_entry{0, 0},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
short options::vk_list[28]
|
|
|
|
|
{
|
2021-01-06 17:06:13 +03:00
|
|
|
|
-32703,
|
2020-12-13 16:05:19 +03:00
|
|
|
|
0x5A,
|
2021-01-06 17:06:13 +03:00
|
|
|
|
-32720,
|
2020-12-13 16:05:19 +03:00
|
|
|
|
0x39,
|
|
|
|
|
0x402E,
|
|
|
|
|
0x402F,
|
|
|
|
|
0x403B,
|
|
|
|
|
0x4027,
|
|
|
|
|
0x405B,
|
|
|
|
|
0x405D,
|
|
|
|
|
0x20,
|
|
|
|
|
0x0D,
|
|
|
|
|
0x9,
|
|
|
|
|
0x14,
|
|
|
|
|
0x25,
|
|
|
|
|
0x27,
|
|
|
|
|
0x26,
|
|
|
|
|
0x28,
|
|
|
|
|
0x2D,
|
|
|
|
|
0x2E,
|
|
|
|
|
0x24,
|
|
|
|
|
0x23,
|
|
|
|
|
0x21,
|
|
|
|
|
0x22,
|
|
|
|
|
0x90,
|
|
|
|
|
0x91,
|
|
|
|
|
0x13,
|
|
|
|
|
-1
|
|
|
|
|
};
|
|
|
|
|
|
2021-10-24 18:23:46 +03:00
|
|
|
|
LanguageMenuEntry options::LanguageMenu[]
|
|
|
|
|
{
|
|
|
|
|
{L"English", Languages::English},
|
|
|
|
|
{L"Русский", Languages::Russian},
|
2021-10-25 17:40:38 +03:00
|
|
|
|
{L"简化字", Languages::SimplifiedChinese},
|
|
|
|
|
{L"正體字", Languages::TraditionalChinese},
|
2021-10-27 09:22:53 +03:00
|
|
|
|
{L"Polski", Languages::Polish},
|
2021-10-28 08:56:49 +03:00
|
|
|
|
{L"Deutsch", Languages::German},
|
2021-10-28 09:56:14 +03:00
|
|
|
|
{L"日本", Languages::Japanese},
|
2021-10-28 11:41:30 +03:00
|
|
|
|
{L"Français", Languages::French},
|
2021-10-28 18:17:36 +03:00
|
|
|
|
{L"Italiano", Languages::Italian},
|
2021-10-29 10:47:17 +03:00
|
|
|
|
{L"Magyar", Languages::Hungarian},
|
2021-11-02 14:04:25 +03:00
|
|
|
|
{L"Português", Languages::Portuguese},
|
|
|
|
|
{L"Português do Brasil", Languages::BrazilianPortuguese},
|
2021-10-30 16:50:49 +03:00
|
|
|
|
{L"Čeština", Languages::Czech},
|
|
|
|
|
{L"Dansk", Languages::Danish},
|
|
|
|
|
{L"Suomi", Languages::Finnish},
|
2021-10-31 13:18:21 +03:00
|
|
|
|
{L"עִברִית", Languages::Hebrew},
|
2021-10-31 17:03:32 +03:00
|
|
|
|
{L"اَلْعَرَبِيَّة", Languages::Arabic},
|
2021-10-31 17:25:24 +03:00
|
|
|
|
{L"Ελληνικά", Languages::Greek},
|
2021-10-31 17:35:41 +03:00
|
|
|
|
{L"Español", Languages::Spanish},
|
2021-10-31 18:29:41 +03:00
|
|
|
|
{L"한국어", Languages::Korean},
|
2021-11-01 11:09:13 +03:00
|
|
|
|
{L"Nederlands", Languages::Dutch},
|
2021-11-01 12:21:50 +03:00
|
|
|
|
{L"Norsk", Languages::Norwegian},
|
2021-11-02 14:24:47 +03:00
|
|
|
|
{L"Svenska", Languages::Swedish},
|
2021-11-02 15:33:22 +03:00
|
|
|
|
{L"Türkçe", Languages::Turkish},
|
2021-10-24 18:23:46 +03:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void options::ReadOptions()
|
2020-11-06 16:56:32 +03:00
|
|
|
|
{
|
|
|
|
|
Options.Sounds = 1;
|
|
|
|
|
Options.Music = 0;
|
|
|
|
|
Options.FullScreen = 0;
|
|
|
|
|
Options.Average = 5;
|
|
|
|
|
Options.PriorityAdj = 2;
|
2020-12-13 16:05:19 +03:00
|
|
|
|
Options.LeftFlipperKeyDft = 90;
|
|
|
|
|
Options.RightFlipperKeyDft = 191;
|
|
|
|
|
Options.PlungerKeyDft = 32;
|
|
|
|
|
Options.LeftTableBumpKeyDft = 88;
|
|
|
|
|
Options.RightTableBumpKeyDft = 190;
|
|
|
|
|
Options.BottomTableBumpKeyDft = 38;
|
|
|
|
|
pinball::get_rc_int(159, &Options.LeftFlipperKeyDft);
|
|
|
|
|
pinball::get_rc_int(160, &Options.RightFlipperKeyDft);
|
|
|
|
|
pinball::get_rc_int(161, &Options.PlungerKeyDft);
|
|
|
|
|
pinball::get_rc_int(162, &Options.LeftTableBumpKeyDft);
|
|
|
|
|
pinball::get_rc_int(163, &Options.RightTableBumpKeyDft);
|
|
|
|
|
pinball::get_rc_int(164, &Options.BottomTableBumpKeyDft);
|
|
|
|
|
Options.LeftFlipperKey = Options.LeftFlipperKeyDft;
|
|
|
|
|
Options.RightFlipperKey = Options.RightFlipperKeyDft;
|
|
|
|
|
Options.PlungerKey = Options.PlungerKeyDft;
|
|
|
|
|
Options.LeftTableBumpKey = Options.LeftTableBumpKeyDft;
|
|
|
|
|
Options.RightTableBumpKey = Options.RightTableBumpKeyDft;
|
2020-11-06 16:56:32 +03:00
|
|
|
|
Options.Players = 1;
|
2020-12-13 16:05:19 +03:00
|
|
|
|
Options.BottomTableBumpKey = Options.BottomTableBumpKeyDft;
|
2020-11-06 16:56:32 +03:00
|
|
|
|
Options.Sounds = get_int(nullptr, "Sounds", Options.Sounds);
|
|
|
|
|
Options.Music = get_int(nullptr, "Music", Options.Music);
|
|
|
|
|
Options.Average = get_int(nullptr, "Average", Options.Average);
|
|
|
|
|
Options.FullScreen = get_int(nullptr, "FullScreen", Options.FullScreen);
|
|
|
|
|
Options.PriorityAdj = get_int(nullptr, "Priority_Adjustment", Options.PriorityAdj);
|
|
|
|
|
Options.Players = get_int(nullptr, "Players", Options.Players);
|
|
|
|
|
Options.LeftFlipperKey = get_int(nullptr, "Left Flippper key", Options.LeftFlipperKey);
|
|
|
|
|
Options.RightFlipperKey = get_int(nullptr, "Right Flipper key", Options.RightFlipperKey);
|
|
|
|
|
Options.PlungerKey = get_int(nullptr, "Plunger key", Options.PlungerKey);
|
|
|
|
|
Options.LeftTableBumpKey = get_int(nullptr, "Left Table Bump key", Options.LeftTableBumpKey);
|
|
|
|
|
Options.RightTableBumpKey = get_int(nullptr, "Right Table Bump key", Options.RightTableBumpKey);
|
|
|
|
|
Options.BottomTableBumpKey = get_int(nullptr, "Bottom Table Bump key", Options.BottomTableBumpKey);
|
2021-02-09 18:09:44 +03:00
|
|
|
|
Options.UniformScaling = get_int(nullptr, "Uniform scaling", true);
|
2021-10-12 16:30:20 +03:00
|
|
|
|
Options.AlternativeRender = get_int(nullptr, "Alternative Render", false);
|
|
|
|
|
|
2021-10-24 18:23:46 +03:00
|
|
|
|
auto defaultLanguage = Languages::English;
|
|
|
|
|
auto language = static_cast<Languages>(get_int(nullptr, "Language", static_cast<int>(defaultLanguage)));
|
|
|
|
|
bool languageDefined = false;
|
|
|
|
|
for (auto menuEntry : LanguageMenu)
|
|
|
|
|
{
|
|
|
|
|
if (menuEntry.Language == language)
|
|
|
|
|
{
|
|
|
|
|
languageDefined = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!languageDefined)
|
|
|
|
|
language = defaultLanguage;
|
|
|
|
|
Options.Language = language;
|
|
|
|
|
|
|
|
|
|
// Alternative approaches: resource DLLs, single-language builds.
|
|
|
|
|
// SetThreadUILanguage does not work properly on Windows XP.
|
|
|
|
|
bool winXp = false;
|
|
|
|
|
OSVERSIONINFO version{};
|
|
|
|
|
version.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
|
|
|
|
|
|
|
|
|
#pragma warning (disable : 4996) // XP has no versionhelpers.h
|
|
|
|
|
if (GetVersionEx(&version))
|
|
|
|
|
#pragma warning (default : 4996)
|
|
|
|
|
{
|
|
|
|
|
if (version.dwMajorVersion < 6)
|
|
|
|
|
winXp = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (winXp)
|
|
|
|
|
SetThreadLocale(MAKELCID(static_cast<LANGID>(Options.Language), SORT_DEFAULT));
|
|
|
|
|
else
|
|
|
|
|
SetThreadUILanguage(static_cast<LANGID>(Options.Language));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void options::init(HMENU menuHandle)
|
|
|
|
|
{
|
|
|
|
|
MenuHandle = menuHandle;
|
|
|
|
|
|
2020-12-06 16:21:56 +03:00
|
|
|
|
menu_check(Menu1_Sounds, Options.Sounds);
|
2020-11-06 16:56:32 +03:00
|
|
|
|
Sound::Enable(0, 7, Options.Sounds);
|
2020-12-06 16:21:56 +03:00
|
|
|
|
menu_check(Menu1_Music, Options.Music);
|
|
|
|
|
menu_check(Menu1_Full_Screen, Options.FullScreen);
|
|
|
|
|
menu_check(Menu1_1Player, Options.Players == 1);
|
|
|
|
|
menu_check(Menu1_2Players, Options.Players == 2);
|
|
|
|
|
menu_check(Menu1_3Players, Options.Players == 3);
|
|
|
|
|
menu_check(Menu1_4Players, Options.Players == 4);
|
2021-02-09 18:09:44 +03:00
|
|
|
|
menu_check(Menu1_WindowUniformScale, Options.UniformScaling);
|
2021-10-12 16:30:20 +03:00
|
|
|
|
menu_check(Menu1_AlternativeRender, Options.AlternativeRender);
|
2020-11-06 16:56:32 +03:00
|
|
|
|
auto tmpBuf = memory::allocate(0x1F4u);
|
|
|
|
|
if (tmpBuf)
|
|
|
|
|
{
|
2021-02-18 12:53:25 +03:00
|
|
|
|
get_string(nullptr, "Shell Exe", tmpBuf, "", 500);
|
2020-11-06 16:56:32 +03:00
|
|
|
|
if (!*tmpBuf)
|
|
|
|
|
{
|
|
|
|
|
if (MenuHandle)
|
|
|
|
|
{
|
2020-12-04 18:35:47 +03:00
|
|
|
|
DeleteMenu(MenuHandle, Menu1_Select_Table, 0);
|
2020-12-03 17:47:36 +03:00
|
|
|
|
DrawMenuBar(winmain::hwnd_frame);
|
2020-11-06 16:56:32 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
memory::free(tmpBuf);
|
|
|
|
|
}
|
2021-02-06 16:53:47 +03:00
|
|
|
|
|
|
|
|
|
update_resolution_menu();
|
2021-10-24 18:23:46 +03:00
|
|
|
|
|
|
|
|
|
// Add language menu from code to decouple it from rc.
|
|
|
|
|
// AppendMenuW works with A window
|
|
|
|
|
auto hSubmenu = CreatePopupMenu();
|
|
|
|
|
auto index = Menu1_Language;
|
|
|
|
|
for (auto menuEntry : LanguageMenu)
|
|
|
|
|
{
|
|
|
|
|
UINT flags = MF_STRING;
|
|
|
|
|
if (menuEntry.Language == Options.Language)
|
|
|
|
|
flags |= MF_CHECKED;
|
|
|
|
|
AppendMenuW(hSubmenu, flags, index++, menuEntry.Name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
auto optionsMenu = GetSubMenu(MenuHandle, 1);
|
|
|
|
|
AppendMenu(optionsMenu, MF_STRING | MF_POPUP, reinterpret_cast<UINT_PTR>(hSubmenu), "Language");
|
2020-11-06 16:56:32 +03:00
|
|
|
|
}
|
2020-11-05 18:44:34 +03:00
|
|
|
|
|
2020-12-04 18:35:47 +03:00
|
|
|
|
void options::uninit()
|
|
|
|
|
{
|
|
|
|
|
set_int(nullptr, "Sounds", Options.Sounds);
|
|
|
|
|
set_int(nullptr, "Music", Options.Music);
|
|
|
|
|
set_int(nullptr, "FullScreen", Options.FullScreen);
|
|
|
|
|
set_int(nullptr, "Players", Options.Players);
|
|
|
|
|
set_int(nullptr, "Left Flippper key", Options.LeftFlipperKey);
|
|
|
|
|
set_int(nullptr, "Right Flipper key", Options.RightFlipperKey);
|
|
|
|
|
set_int(nullptr, "Plunger key", Options.PlungerKey);
|
|
|
|
|
set_int(nullptr, "Left Table Bump key", Options.LeftTableBumpKey);
|
|
|
|
|
set_int(nullptr, "Right Table Bump key", Options.RightTableBumpKey);
|
|
|
|
|
set_int(nullptr, "Bottom Table Bump key", Options.BottomTableBumpKey);
|
2021-02-06 16:53:47 +03:00
|
|
|
|
set_int(nullptr, "Screen Resolution", Options.Resolution);
|
2021-02-09 18:09:44 +03:00
|
|
|
|
set_int(nullptr, "Uniform scaling", Options.UniformScaling);
|
2021-10-12 16:30:20 +03:00
|
|
|
|
set_int(nullptr, "Alternative Render", Options.AlternativeRender);
|
2021-10-24 18:23:46 +03:00
|
|
|
|
set_int(nullptr, "Language", static_cast<int>(Options.Language));
|
2020-12-04 18:35:47 +03:00
|
|
|
|
}
|
|
|
|
|
|
2020-11-05 18:44:34 +03:00
|
|
|
|
void options::path_init(LPCSTR regPath)
|
|
|
|
|
{
|
|
|
|
|
char* buf = memory::allocate(lstrlenA(regPath) + 1);
|
|
|
|
|
OptionsRegPath = buf;
|
|
|
|
|
if (buf)
|
|
|
|
|
lstrcpyA(buf, regPath);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void options::path_uninit()
|
|
|
|
|
{
|
|
|
|
|
if (OptionsRegPath)
|
|
|
|
|
memory::free((void*)OptionsRegPath);
|
|
|
|
|
OptionsRegPath = nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LPCSTR options::path(LPCSTR regPath)
|
|
|
|
|
{
|
|
|
|
|
char* buf = OptionsRegPathCur;
|
|
|
|
|
if (!OptionsRegPathCur)
|
|
|
|
|
{
|
|
|
|
|
buf = memory::allocate(0x7D0u);
|
|
|
|
|
OptionsRegPathCur = buf;
|
|
|
|
|
if (!buf)
|
|
|
|
|
return OptionsRegPath;
|
|
|
|
|
}
|
|
|
|
|
lstrcpyA(buf, OptionsRegPath);
|
|
|
|
|
if (!regPath)
|
|
|
|
|
return OptionsRegPathCur;
|
|
|
|
|
lstrcatA(OptionsRegPathCur, "\\");
|
|
|
|
|
lstrcatA(OptionsRegPathCur, regPath);
|
|
|
|
|
return OptionsRegPathCur;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void options::path_free()
|
|
|
|
|
{
|
|
|
|
|
if (OptionsRegPathCur)
|
|
|
|
|
memory::free(OptionsRegPathCur);
|
|
|
|
|
OptionsRegPathCur = nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int options::get_int(LPCSTR optPath, LPCSTR lpValueName, int defaultValue)
|
|
|
|
|
{
|
2021-02-06 16:53:47 +03:00
|
|
|
|
DWORD dwDisposition;
|
2021-02-16 19:03:45 +03:00
|
|
|
|
HKEY hKey;
|
2020-11-05 18:44:34 +03:00
|
|
|
|
|
2021-02-16 19:03:45 +03:00
|
|
|
|
auto result = defaultValue;
|
2020-11-05 18:44:34 +03:00
|
|
|
|
if (!OptionsRegPath)
|
2021-02-16 19:03:45 +03:00
|
|
|
|
return result;
|
|
|
|
|
|
|
|
|
|
auto regPath = path(optPath);
|
|
|
|
|
if (!RegCreateKeyExA(HKEY_CURRENT_USER, regPath, 0, nullptr, 0, KEY_ALL_ACCESS, nullptr, &hKey, &dwDisposition))
|
2020-11-05 18:44:34 +03:00
|
|
|
|
{
|
2021-02-16 19:03:45 +03:00
|
|
|
|
DWORD bufferSize = 4;
|
|
|
|
|
RegQueryValueExA(hKey, lpValueName, nullptr, nullptr, reinterpret_cast<LPBYTE>(&result), &bufferSize);
|
|
|
|
|
RegCloseKey(hKey);
|
2020-11-05 18:44:34 +03:00
|
|
|
|
}
|
|
|
|
|
path_free();
|
2021-02-16 19:03:45 +03:00
|
|
|
|
return result;
|
2020-11-05 18:44:34 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void options::set_int(LPCSTR optPath, LPCSTR lpValueName, int data)
|
|
|
|
|
{
|
2020-12-27 18:19:36 +03:00
|
|
|
|
DWORD dwDisposition;
|
2021-02-16 19:03:45 +03:00
|
|
|
|
HKEY hKey;
|
2020-11-05 18:44:34 +03:00
|
|
|
|
|
2021-02-16 19:03:45 +03:00
|
|
|
|
if (!OptionsRegPath)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
auto regPath = path(optPath);
|
|
|
|
|
if (!RegCreateKeyExA(HKEY_CURRENT_USER, regPath, 0, nullptr, 0, KEY_ALL_ACCESS, nullptr, &hKey, &dwDisposition))
|
2020-11-05 18:44:34 +03:00
|
|
|
|
{
|
2021-02-16 19:03:45 +03:00
|
|
|
|
RegSetValueExA(hKey, lpValueName, 0, 4u, reinterpret_cast<LPBYTE>(&data), 4u);
|
|
|
|
|
RegCloseKey(hKey);
|
2020-11-05 18:44:34 +03:00
|
|
|
|
}
|
2021-02-16 19:03:45 +03:00
|
|
|
|
path_free();
|
2020-11-05 18:44:34 +03:00
|
|
|
|
}
|
|
|
|
|
|
2021-02-16 19:03:45 +03:00
|
|
|
|
void options::get_string(LPCSTR optPath, LPCSTR lpValueName, LPSTR dst, LPCSTR defaultValue, int iMaxLength)
|
2020-11-05 18:44:34 +03:00
|
|
|
|
{
|
2021-02-16 19:03:45 +03:00
|
|
|
|
DWORD dwDisposition;
|
|
|
|
|
HKEY hKey;
|
|
|
|
|
|
|
|
|
|
lstrcpynA(dst, defaultValue, iMaxLength);
|
|
|
|
|
if (!OptionsRegPath)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
auto regPath = path(optPath);
|
|
|
|
|
if (!RegCreateKeyExA(HKEY_CURRENT_USER, regPath, 0, nullptr, 0, KEY_ALL_ACCESS, nullptr, &hKey, &dwDisposition))
|
2020-11-05 18:44:34 +03:00
|
|
|
|
{
|
2021-02-16 19:03:45 +03:00
|
|
|
|
DWORD bufferSize = iMaxLength;
|
|
|
|
|
RegQueryValueExA(hKey, lpValueName, nullptr, nullptr, reinterpret_cast<LPBYTE>(dst), &bufferSize);
|
|
|
|
|
RegCloseKey(hKey);
|
2020-11-05 18:44:34 +03:00
|
|
|
|
}
|
2021-02-16 19:03:45 +03:00
|
|
|
|
path_free();
|
2020-11-05 18:44:34 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void options::set_string(LPCSTR optPath, LPCSTR lpValueName, LPCSTR value)
|
|
|
|
|
{
|
2020-12-27 18:19:36 +03:00
|
|
|
|
DWORD dwDisposition;
|
2021-02-16 19:03:45 +03:00
|
|
|
|
HKEY hKey;
|
2020-11-05 18:44:34 +03:00
|
|
|
|
|
2021-02-16 19:03:45 +03:00
|
|
|
|
if (!OptionsRegPath)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
auto regPath = path(optPath);
|
|
|
|
|
if (!RegCreateKeyExA(HKEY_CURRENT_USER, regPath, 0, nullptr, 0, KEY_ALL_ACCESS, nullptr, &hKey, &dwDisposition))
|
2020-11-05 18:44:34 +03:00
|
|
|
|
{
|
2021-02-16 19:03:45 +03:00
|
|
|
|
RegSetValueExA(hKey, lpValueName, 0, 1u, LPBYTE(value), lstrlenA(value) + 1);
|
|
|
|
|
RegCloseKey(hKey);
|
2020-11-05 18:44:34 +03:00
|
|
|
|
}
|
2021-02-16 19:03:45 +03:00
|
|
|
|
path_free();
|
2020-11-05 18:44:34 +03:00
|
|
|
|
}
|
2020-11-06 16:56:32 +03:00
|
|
|
|
|
2021-11-03 12:53:04 +03:00
|
|
|
|
void options::get_string(LPCSTR optPath, LPCWSTR lpValueName, LPWSTR dst, LPCWSTR defaultValue, int iMaxLength)
|
|
|
|
|
{
|
|
|
|
|
DWORD dwDisposition;
|
|
|
|
|
HKEY hKey;
|
|
|
|
|
|
|
|
|
|
lstrcpynW(dst, defaultValue, iMaxLength);
|
|
|
|
|
if (!OptionsRegPath)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
auto regPath = path(optPath);
|
|
|
|
|
if (!RegCreateKeyExA(HKEY_CURRENT_USER, regPath, 0, nullptr, 0, KEY_ALL_ACCESS, nullptr, &hKey, &dwDisposition))
|
|
|
|
|
{
|
|
|
|
|
DWORD bufferSize = iMaxLength * sizeof(wchar_t);
|
|
|
|
|
RegQueryValueExW(hKey, lpValueName, nullptr, nullptr, reinterpret_cast<LPBYTE>(dst), &bufferSize);
|
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
|
}
|
|
|
|
|
path_free();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void options::set_string(LPCSTR optPath, LPCWSTR lpValueName, LPCWSTR value)
|
|
|
|
|
{
|
|
|
|
|
DWORD dwDisposition;
|
|
|
|
|
HKEY hKey;
|
|
|
|
|
|
|
|
|
|
if (!OptionsRegPath)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
auto regPath = path(optPath);
|
|
|
|
|
if (!RegCreateKeyExA(HKEY_CURRENT_USER, regPath, 0, nullptr, 0, KEY_ALL_ACCESS, nullptr, &hKey, &dwDisposition))
|
|
|
|
|
{
|
|
|
|
|
DWORD bufferSize = (lstrlenW(value) + 1) * sizeof(wchar_t);
|
|
|
|
|
RegSetValueExW(hKey, lpValueName, 0, 1u, LPBYTE(value), bufferSize);
|
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
|
}
|
|
|
|
|
path_free();
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-06 16:56:32 +03:00
|
|
|
|
|
2020-12-02 20:12:34 +03:00
|
|
|
|
void options::menu_check(UINT uIDCheckItem, int check)
|
|
|
|
|
{
|
|
|
|
|
if (MenuHandle)
|
|
|
|
|
CheckMenuItem(MenuHandle, uIDCheckItem, check != 0 ? 8 : 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void options::menu_set(UINT uIDEnableItem, int enable)
|
2020-11-06 16:56:32 +03:00
|
|
|
|
{
|
|
|
|
|
if (MenuHandle)
|
2020-12-02 20:12:34 +03:00
|
|
|
|
EnableMenuItem(MenuHandle, uIDEnableItem, enable == 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void options::toggle(UINT uIDCheckItem)
|
|
|
|
|
{
|
|
|
|
|
int newValue;
|
|
|
|
|
switch (uIDCheckItem)
|
|
|
|
|
{
|
2020-12-04 18:35:47 +03:00
|
|
|
|
case Menu1_Sounds:
|
2020-12-02 20:12:34 +03:00
|
|
|
|
newValue = Options.Sounds == 0;
|
|
|
|
|
Options.Sounds = Options.Sounds == 0;
|
|
|
|
|
Sound::Enable(0, 7, newValue);
|
|
|
|
|
menu_check(uIDCheckItem, newValue);
|
|
|
|
|
return;
|
2020-12-04 18:35:47 +03:00
|
|
|
|
case Menu1_Music:
|
2020-12-02 20:12:34 +03:00
|
|
|
|
newValue = Options.Music == 0;
|
|
|
|
|
Options.Music = Options.Music == 0;
|
|
|
|
|
if (!newValue)
|
|
|
|
|
midi::music_stop();
|
|
|
|
|
else
|
|
|
|
|
midi::play_pb_theme(0);
|
|
|
|
|
menu_check(uIDCheckItem, newValue);
|
|
|
|
|
return;
|
2020-12-04 18:35:47 +03:00
|
|
|
|
case Menu1_Full_Screen:
|
2020-12-02 20:12:34 +03:00
|
|
|
|
newValue = Options.FullScreen == 0;
|
|
|
|
|
Options.FullScreen = Options.FullScreen == 0;
|
|
|
|
|
fullscrn::set_screen_mode(newValue);
|
|
|
|
|
menu_check(uIDCheckItem, newValue);
|
|
|
|
|
return;
|
2021-02-06 16:53:47 +03:00
|
|
|
|
case Menu1_1Player:
|
|
|
|
|
case Menu1_2Players:
|
|
|
|
|
case Menu1_3Players:
|
|
|
|
|
case Menu1_4Players:
|
|
|
|
|
Options.Players = uIDCheckItem - Menu1_1Player + 1;
|
2020-12-06 16:21:56 +03:00
|
|
|
|
menu_check(Menu1_1Player, Options.Players == 1);
|
|
|
|
|
menu_check(Menu1_2Players, Options.Players == 2);
|
|
|
|
|
menu_check(Menu1_3Players, Options.Players == 3);
|
|
|
|
|
menu_check(Menu1_4Players, Options.Players == 4);
|
2021-02-06 16:53:47 +03:00
|
|
|
|
break;
|
|
|
|
|
case Menu1_MaximumResolution:
|
|
|
|
|
case Menu1_640x480:
|
|
|
|
|
case Menu1_800x600:
|
|
|
|
|
case Menu1_1024x768:
|
|
|
|
|
{
|
2021-02-09 18:09:44 +03:00
|
|
|
|
for (unsigned i = Menu1_MaximumResolution; i <= Menu1_1024x768; ++i)
|
|
|
|
|
menu_check(i, i == uIDCheckItem);
|
|
|
|
|
|
2021-02-06 16:53:47 +03:00
|
|
|
|
int newResolution = uIDCheckItem - Menu1_640x480;
|
|
|
|
|
if (uIDCheckItem == Menu1_MaximumResolution)
|
|
|
|
|
{
|
|
|
|
|
Options.Resolution = -1;
|
|
|
|
|
if (fullscrn::GetMaxResolution() != fullscrn::GetResolution())
|
|
|
|
|
winmain::Restart();
|
|
|
|
|
}
|
|
|
|
|
else if (newResolution != fullscrn::GetResolution() && newResolution <= fullscrn::GetMaxResolution())
|
|
|
|
|
{
|
|
|
|
|
Options.Resolution = newResolution;
|
|
|
|
|
winmain::Restart();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
2021-02-09 18:09:44 +03:00
|
|
|
|
case Menu1_WindowUniformScale:
|
|
|
|
|
Options.UniformScaling ^= true;
|
|
|
|
|
menu_check(Menu1_WindowUniformScale, Options.UniformScaling);
|
|
|
|
|
fullscrn::window_size_changed();
|
|
|
|
|
fullscrn::paint();
|
|
|
|
|
break;
|
2021-10-12 16:30:20 +03:00
|
|
|
|
case Menu1_AlternativeRender:
|
|
|
|
|
Options.AlternativeRender ^= true;
|
|
|
|
|
menu_check(Menu1_AlternativeRender, Options.AlternativeRender);
|
|
|
|
|
fullscrn::window_size_changed();
|
|
|
|
|
fullscrn::paint();
|
|
|
|
|
break;
|
2021-02-06 16:53:47 +03:00
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2021-10-24 18:23:46 +03:00
|
|
|
|
|
|
|
|
|
if (uIDCheckItem >= Menu1_Language && uIDCheckItem < Menu1_LanguageMax)
|
|
|
|
|
{
|
|
|
|
|
auto languageId = uIDCheckItem - Menu1_Language;
|
|
|
|
|
Options.Language = LanguageMenu[languageId].Language;
|
|
|
|
|
winmain::Restart();
|
|
|
|
|
}
|
2021-02-06 16:53:47 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void options::update_resolution_menu()
|
|
|
|
|
{
|
|
|
|
|
auto maxResolution = fullscrn::get_max_supported_resolution();
|
|
|
|
|
fullscrn::SetMaxResolution(maxResolution);
|
2021-10-28 15:58:19 +08:00
|
|
|
|
PCWSTR maxResText = pinball::get_rc_Wstring(maxResolution + 2030, 0);
|
2021-02-06 16:53:47 +03:00
|
|
|
|
if (MenuHandle)
|
2021-10-28 15:58:19 +08:00
|
|
|
|
ModifyMenuW(MenuHandle, Menu1_MaximumResolution, 0, Menu1_MaximumResolution, maxResText);
|
2021-02-06 16:53:47 +03:00
|
|
|
|
|
|
|
|
|
for (auto resIndex = 0; resIndex < 3; resIndex++)
|
|
|
|
|
{
|
|
|
|
|
menu_set(fullscrn::resolution_array[resIndex].ResolutionMenuId, fullscrn::GetMaxResolution() >= resIndex);
|
|
|
|
|
}
|
|
|
|
|
for (auto i = Menu1_MaximumResolution; i <= Menu1_1024x768; ++i)
|
|
|
|
|
{
|
|
|
|
|
menu_check(i, 0);
|
|
|
|
|
}
|
|
|
|
|
if (Options.Resolution >= 0)
|
|
|
|
|
menu_check(fullscrn::resolution_array[fullscrn::GetResolution()].ResolutionMenuId, 1);
|
|
|
|
|
else
|
|
|
|
|
menu_check(Menu1_MaximumResolution, 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void options::init_resolution()
|
|
|
|
|
{
|
|
|
|
|
Options.Resolution = get_int(nullptr, "Screen Resolution", -1);
|
|
|
|
|
int maxRes = fullscrn::get_max_supported_resolution();
|
|
|
|
|
if (Options.Resolution == -1 || maxRes <= Options.Resolution)
|
|
|
|
|
{
|
|
|
|
|
fullscrn::SetMaxResolution(maxRes);
|
|
|
|
|
fullscrn::SetResolution(maxRes);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
fullscrn::SetResolution(Options.Resolution);
|
2020-12-02 20:12:34 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void options::keyboard()
|
|
|
|
|
{
|
2021-10-28 15:58:19 +08:00
|
|
|
|
DialogBoxParamW(winmain::hinst, L"KEYMAPPER", winmain::hwnd_frame, KeyMapDlgProc, 0);
|
2020-12-02 20:12:34 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
INT_PTR _stdcall options::KeyMapDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
|
{
|
2021-10-28 15:58:19 +08:00
|
|
|
|
WCHAR keyName[20];
|
2020-12-13 16:05:19 +03:00
|
|
|
|
int keyBindings[6];
|
2021-10-28 15:58:19 +08:00
|
|
|
|
WCHAR rcString[256];
|
2020-12-13 16:05:19 +03:00
|
|
|
|
|
|
|
|
|
switch (msg)
|
|
|
|
|
{
|
|
|
|
|
case WM_HELP:
|
|
|
|
|
WinHelpA(static_cast<HWND>(reinterpret_cast<HELPINFO*>(lParam)->hItemHandle), "pinball.hlp", HELP_WM_HELP,
|
|
|
|
|
(ULONG_PTR)keymap_help);
|
|
|
|
|
return 1;
|
|
|
|
|
case WM_CONTEXTMENU:
|
|
|
|
|
WinHelpA((HWND)wParam, "pinball.hlp", HELP_CONTEXTMENU, (ULONG_PTR)keymap_help);
|
|
|
|
|
return 1;
|
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
|
for (auto vkPtr = vk_list; *vkPtr != -1; vkPtr++)
|
|
|
|
|
{
|
|
|
|
|
short vk = *vkPtr;
|
|
|
|
|
auto vk2And = vk & 0x4000;
|
2021-02-16 19:03:45 +03:00
|
|
|
|
auto vkChar = static_cast<uint8_t>(vk);
|
2020-12-13 16:05:19 +03:00
|
|
|
|
unsigned short maxVk;
|
|
|
|
|
|
|
|
|
|
if (vk2And)
|
|
|
|
|
{
|
|
|
|
|
auto index = 128;
|
|
|
|
|
do
|
|
|
|
|
{
|
2021-10-28 15:58:19 +08:00
|
|
|
|
if (vkChar == MapVirtualKeyW(index, MAPVK_VK_TO_CHAR))
|
2020-12-13 16:05:19 +03:00
|
|
|
|
break;
|
|
|
|
|
++index;
|
|
|
|
|
}
|
|
|
|
|
while (index < 256);
|
|
|
|
|
|
|
|
|
|
if (index == 256)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
keyName[0] = static_cast<char>(vkChar);
|
|
|
|
|
keyName[1] = 0;
|
|
|
|
|
vkChar = index;
|
|
|
|
|
maxVk = index;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (vk >= 0)
|
|
|
|
|
{
|
|
|
|
|
maxVk = vkChar;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
++vkPtr;
|
|
|
|
|
maxVk = *vkPtr;
|
|
|
|
|
}
|
|
|
|
|
if (vkChar > maxVk)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int curVK = vkChar; curVK <= maxVk; curVK++)
|
|
|
|
|
{
|
|
|
|
|
if (vk2And || get_vk_key_name(curVK, keyName))
|
|
|
|
|
{
|
2021-10-28 15:58:19 +08:00
|
|
|
|
auto ind = SendDlgItemMessageW(hDlg, KEYMAPPER_FlipperL,CB_INSERTSTRING, -1, (LPARAM)keyName);
|
|
|
|
|
SendDlgItemMessageW(hDlg, KEYMAPPER_FlipperL, CB_SETITEMDATA, ind, curVK);
|
2020-12-13 16:05:19 +03:00
|
|
|
|
if (curVK == Options.LeftFlipperKey)
|
2021-10-28 15:58:19 +08:00
|
|
|
|
SendDlgItemMessageW(hDlg, KEYMAPPER_FlipperL, CB_SETCURSEL, ind, 0);
|
|
|
|
|
ind = SendDlgItemMessageW(hDlg, KEYMAPPER_FlipperR, CB_INSERTSTRING, -1, (LPARAM)keyName);
|
|
|
|
|
SendDlgItemMessageW(hDlg, KEYMAPPER_FlipperR, CB_SETITEMDATA, ind, curVK);
|
2020-12-13 16:05:19 +03:00
|
|
|
|
if (curVK == Options.RightFlipperKey)
|
2021-10-28 15:58:19 +08:00
|
|
|
|
SendDlgItemMessageW(hDlg, KEYMAPPER_FlipperR, CB_SETCURSEL, ind, 0);
|
|
|
|
|
ind = SendDlgItemMessageW(hDlg, KEYMAPPER_Plunger, CB_INSERTSTRING, -1, (LPARAM)keyName);
|
|
|
|
|
SendDlgItemMessageW(hDlg, KEYMAPPER_Plunger, CB_SETITEMDATA, ind, curVK);
|
2020-12-13 16:05:19 +03:00
|
|
|
|
if (curVK == Options.PlungerKey)
|
2021-10-28 15:58:19 +08:00
|
|
|
|
SendDlgItemMessageW(hDlg, KEYMAPPER_Plunger, CB_SETCURSEL, ind, 0);
|
|
|
|
|
ind = SendDlgItemMessageW(hDlg, KEYMAPPER_BumpLeft, CB_INSERTSTRING, -1, (LPARAM)keyName);
|
|
|
|
|
SendDlgItemMessageW(hDlg, KEYMAPPER_BumpLeft, CB_SETITEMDATA, ind, curVK);
|
2020-12-13 16:05:19 +03:00
|
|
|
|
if (curVK == Options.LeftTableBumpKey)
|
2021-10-28 15:58:19 +08:00
|
|
|
|
SendDlgItemMessageW(hDlg, KEYMAPPER_BumpLeft, CB_SETCURSEL, ind, 0);
|
|
|
|
|
ind = SendDlgItemMessageW(hDlg, KEYMAPPER_BumpRight, CB_INSERTSTRING, -1, (LPARAM)keyName);
|
|
|
|
|
SendDlgItemMessageW(hDlg, KEYMAPPER_BumpRight, CB_SETITEMDATA, ind, curVK);
|
2020-12-13 16:05:19 +03:00
|
|
|
|
if (curVK == Options.RightTableBumpKey)
|
2021-10-28 15:58:19 +08:00
|
|
|
|
SendDlgItemMessageW(hDlg, KEYMAPPER_BumpRight, CB_SETCURSEL, ind, 0);
|
|
|
|
|
ind = SendDlgItemMessageW(hDlg, KEYMAPPER_BumpBottom, CB_INSERTSTRING, -1, (LPARAM)keyName);
|
|
|
|
|
SendDlgItemMessageW(hDlg, KEYMAPPER_BumpBottom, CB_SETITEMDATA, ind, curVK);
|
2020-12-13 16:05:19 +03:00
|
|
|
|
if (curVK == Options.BottomTableBumpKey)
|
2021-10-28 15:58:19 +08:00
|
|
|
|
SendDlgItemMessageW(hDlg, KEYMAPPER_BumpBottom, CB_SETCURSEL, ind, 0);
|
2020-12-13 16:05:19 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 1;
|
|
|
|
|
case WM_COMMAND:
|
|
|
|
|
switch (wParam)
|
|
|
|
|
{
|
|
|
|
|
case KEYMAPPER_Ok:
|
|
|
|
|
{
|
2021-10-28 15:58:19 +08:00
|
|
|
|
auto ind = SendDlgItemMessageW(hDlg, KEYMAPPER_FlipperL, CB_GETCURSEL, 0, 0);
|
|
|
|
|
keyBindings[0] = static_cast<int>(SendDlgItemMessageW(hDlg, KEYMAPPER_FlipperL, CB_GETITEMDATA, ind, 0));
|
|
|
|
|
ind = SendDlgItemMessageW(hDlg, KEYMAPPER_FlipperR, CB_GETCURSEL, 0, 0);
|
|
|
|
|
keyBindings[1] = static_cast<int>(SendDlgItemMessageW(hDlg, KEYMAPPER_FlipperR, CB_GETITEMDATA, ind, 0));
|
|
|
|
|
ind = SendDlgItemMessageW(hDlg, KEYMAPPER_Plunger, CB_GETCURSEL, 0, 0);
|
|
|
|
|
keyBindings[2] = static_cast<int>(SendDlgItemMessageW(hDlg, KEYMAPPER_Plunger, CB_GETITEMDATA, ind, 0));
|
|
|
|
|
ind = SendDlgItemMessageW(hDlg, KEYMAPPER_BumpLeft, CB_GETCURSEL, 0, 0);
|
|
|
|
|
keyBindings[3] = static_cast<int>(SendDlgItemMessageW(hDlg, KEYMAPPER_BumpLeft, CB_GETITEMDATA, ind, 0));
|
|
|
|
|
ind = SendDlgItemMessageW(hDlg, KEYMAPPER_BumpRight, CB_GETCURSEL, 0, 0);
|
|
|
|
|
keyBindings[4] = static_cast<int>(SendDlgItemMessageW(hDlg, KEYMAPPER_BumpRight, CB_GETITEMDATA, ind, 0));
|
|
|
|
|
ind = SendDlgItemMessageW(hDlg, KEYMAPPER_BumpBottom, CB_GETCURSEL, 0, 0);
|
|
|
|
|
keyBindings[5] = static_cast<int>(SendDlgItemMessageW(hDlg, KEYMAPPER_BumpBottom, CB_GETITEMDATA, ind, 0));
|
2020-12-13 16:05:19 +03:00
|
|
|
|
|
|
|
|
|
auto sameKeyBound = 0;
|
|
|
|
|
auto index = 1;
|
|
|
|
|
auto optPtr = keyBindings;
|
|
|
|
|
while (!sameKeyBound)
|
|
|
|
|
{
|
|
|
|
|
for (auto keyInd = index; keyInd < 6; keyInd++)
|
|
|
|
|
{
|
|
|
|
|
if (sameKeyBound)
|
|
|
|
|
break;
|
|
|
|
|
if (*optPtr == keyBindings[keyInd])
|
|
|
|
|
{
|
2021-10-28 15:58:19 +08:00
|
|
|
|
lstrcpyW(rcString, pinball::get_rc_Wstring(43, 0));
|
|
|
|
|
MessageBoxW(hDlg, pinball::get_rc_Wstring(39, 0), rcString, 0x2000u);
|
2020-12-13 16:05:19 +03:00
|
|
|
|
sameKeyBound = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
++index;
|
|
|
|
|
++optPtr;
|
|
|
|
|
if (index - 1 >= 5)
|
|
|
|
|
{
|
|
|
|
|
if (sameKeyBound)
|
|
|
|
|
return 1;
|
|
|
|
|
Options.LeftFlipperKey = keyBindings[0];
|
|
|
|
|
Options.RightFlipperKey = keyBindings[1];
|
|
|
|
|
Options.PlungerKey = keyBindings[2];
|
|
|
|
|
Options.LeftTableBumpKey = keyBindings[3];
|
|
|
|
|
Options.RightTableBumpKey = keyBindings[4];
|
|
|
|
|
Options.BottomTableBumpKey = keyBindings[5];
|
|
|
|
|
EndDialog(hDlg, wParam);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
case KEYMAPPER_Cancel:
|
|
|
|
|
EndDialog(hDlg, wParam);
|
|
|
|
|
return 1;
|
|
|
|
|
case KEYMAPPER_Default:
|
|
|
|
|
{
|
|
|
|
|
auto name = (LPARAM)get_vk_key_name(Options.LeftFlipperKeyDft, keyName);
|
2021-10-28 15:58:19 +08:00
|
|
|
|
auto ind = SendDlgItemMessageW(hDlg, KEYMAPPER_FlipperL, CB_FINDSTRINGEXACT, 0, name);
|
|
|
|
|
SendDlgItemMessageW(hDlg, KEYMAPPER_FlipperL, CB_SETCURSEL, ind, 0);
|
2020-12-13 16:05:19 +03:00
|
|
|
|
name = (LPARAM)get_vk_key_name(Options.RightFlipperKeyDft, keyName);
|
2021-10-28 15:58:19 +08:00
|
|
|
|
ind = SendDlgItemMessageW(hDlg, KEYMAPPER_FlipperR, CB_FINDSTRINGEXACT, 0, name);
|
|
|
|
|
SendDlgItemMessageW(hDlg, KEYMAPPER_FlipperR, CB_SETCURSEL, ind, 0);
|
2020-12-13 16:05:19 +03:00
|
|
|
|
name = (LPARAM)get_vk_key_name(Options.PlungerKeyDft, keyName);
|
2021-10-28 15:58:19 +08:00
|
|
|
|
ind = SendDlgItemMessageW(hDlg, KEYMAPPER_Plunger, CB_FINDSTRINGEXACT, 0, name);
|
|
|
|
|
SendDlgItemMessageW(hDlg, KEYMAPPER_Plunger, CB_SETCURSEL, ind, 0);
|
2020-12-13 16:05:19 +03:00
|
|
|
|
name = (LPARAM)get_vk_key_name(Options.LeftTableBumpKeyDft, keyName);
|
2021-10-28 15:58:19 +08:00
|
|
|
|
ind = SendDlgItemMessageW(hDlg, KEYMAPPER_BumpLeft, CB_FINDSTRINGEXACT, 0, name);
|
|
|
|
|
SendDlgItemMessageW(hDlg, KEYMAPPER_BumpLeft, CB_SETCURSEL, ind, 0);
|
2020-12-13 16:05:19 +03:00
|
|
|
|
name = (LPARAM)get_vk_key_name(Options.RightTableBumpKeyDft, keyName);
|
2021-10-28 15:58:19 +08:00
|
|
|
|
ind = SendDlgItemMessageW(hDlg, KEYMAPPER_BumpRight, CB_FINDSTRINGEXACT, 0, name);
|
|
|
|
|
SendDlgItemMessageW(hDlg, KEYMAPPER_BumpRight, CB_SETCURSEL, ind, 0);
|
2020-12-13 16:05:19 +03:00
|
|
|
|
name = (LPARAM)get_vk_key_name(Options.BottomTableBumpKeyDft, keyName);
|
2021-10-28 15:58:19 +08:00
|
|
|
|
ind = SendDlgItemMessageW(hDlg, KEYMAPPER_BumpBottom, CB_FINDSTRINGEXACT, 0, name);
|
|
|
|
|
SendDlgItemMessageW(hDlg, KEYMAPPER_BumpBottom, CB_SETCURSEL, ind, 0);
|
2020-12-13 16:05:19 +03:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-02 20:12:34 +03:00
|
|
|
|
return 0;
|
2020-11-06 16:56:32 +03:00
|
|
|
|
}
|
2020-12-13 16:05:19 +03:00
|
|
|
|
|
|
|
|
|
|
2021-10-28 15:58:19 +08:00
|
|
|
|
LPWSTR options::get_vk_key_name(uint16_t vk, LPWSTR keyName)
|
2020-12-13 16:05:19 +03:00
|
|
|
|
{
|
2021-10-28 15:58:19 +08:00
|
|
|
|
LONG scanCode = MapVirtualKeyW(vk, MAPVK_VK_TO_VSC) << 16;
|
2020-12-13 16:05:19 +03:00
|
|
|
|
if (vk >= 0x21u && vk <= 0x2Eu)
|
|
|
|
|
scanCode |= 0x1000000u;
|
2021-10-28 15:58:19 +08:00
|
|
|
|
return GetKeyNameTextW(scanCode, keyName, 19) != 0 ? keyName : nullptr;
|
2020-12-13 16:05:19 +03:00
|
|
|
|
}
|