From 6f3f8cbc590625d147230366d8d7cc7c94e1dd64 Mon Sep 17 00:00:00 2001 From: VoxelTek <53562267+VoxelTek@users.noreply.github.com> Date: Thu, 14 Aug 2025 13:17:11 +1000 Subject: [PATCH 1/8] Begin work on adjustable key mapping --- LEGO1/lego/legoomni/include/legoinputmanager.h | 11 ++++++++++- LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp | 4 ++-- LEGO1/lego/legoomni/src/input/legoinputmanager.cpp | 12 ++++++------ 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/LEGO1/lego/legoomni/include/legoinputmanager.h b/LEGO1/lego/legoomni/include/legoinputmanager.h index 04ac7294..9a445a68 100644 --- a/LEGO1/lego/legoomni/include/legoinputmanager.h +++ b/LEGO1/lego/legoomni/include/legoinputmanager.h @@ -12,6 +12,7 @@ #include #include #include +#include #include #ifdef MINIWIN #include "miniwin/windows.h" @@ -87,7 +88,7 @@ class LegoInputManager : public MxPresenter { c_right = 0x02, c_up = 0x04, c_down = 0x08, - c_ctrl = 0x10, + c_sprint = 0x10, c_leftOrRight = c_left | c_right, c_upOrDown = c_up | c_down @@ -100,6 +101,14 @@ class LegoInputManager : public MxPresenter { e_gamepad, }; + struct { + SDL_Scancode k_forward[2] = {SDL_SCANCODE_UP, SDL_SCANCODE_KP_8}; + SDL_Scancode k_back[2] = {SDL_SCANCODE_DOWN, SDL_SCANCODE_KP_2}; + SDL_Scancode k_left[2] = {SDL_SCANCODE_LEFT, SDL_SCANCODE_KP_4}; + SDL_Scancode k_right[2] = {SDL_SCANCODE_RIGHT, SDL_SCANCODE_KP_6}; + SDL_Scancode k_sprint[2] = {SDL_SCANCODE_LCTRL, SDL_SCANCODE_RCTRL}; + } g_keyMaps; + LegoInputManager(); ~LegoInputManager() override; diff --git a/LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp b/LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp index 4591fc88..fb8c93ae 100644 --- a/LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp +++ b/LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp @@ -623,8 +623,8 @@ MxResult LegoNavController::ProcessKeyboardInput() break; } - MxFloat maxAccelDivisor = keyFlags & LegoInputManager::c_ctrl ? 1.0f : 4.0f; - MxFloat minAccelDivisor = keyFlags & LegoInputManager::c_ctrl ? 1.0f : 2.0f; + MxFloat maxAccelDivisor = keyFlags & LegoInputManager::c_sprint ? 1.0f : 4.0f; + MxFloat minAccelDivisor = keyFlags & LegoInputManager::c_sprint ? 1.0f : 2.0f; if (!skipRotationVelAndAccelCalc) { m_targetRotationalVel = CalculateNewTargetVel(hMax, m_hMax / 2, m_maxRotationalVel); diff --git a/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp b/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp index 39a97cc0..469a626f 100644 --- a/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp +++ b/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp @@ -133,24 +133,24 @@ MxResult LegoInputManager::GetNavigationKeyStates(MxU32& p_keyFlags) MxU32 keyFlags = 0; - if (m_keyboardState[SDL_SCANCODE_KP_8] || m_keyboardState[SDL_SCANCODE_UP]) { + if (m_keyboardState[g_keyMaps.k_forward[0]] || m_keyboardState[g_keyMaps.k_forward[1]]) { keyFlags |= c_up; } - if ((m_keyboardState[SDL_SCANCODE_KP_2] || m_keyboardState[SDL_SCANCODE_DOWN])) { + if ((m_keyboardState[g_keyMaps.k_back[0]] || m_keyboardState[g_keyMaps.k_back[1]])) { keyFlags |= c_down; } - if ((m_keyboardState[SDL_SCANCODE_KP_4] || m_keyboardState[SDL_SCANCODE_LEFT])) { + if ((m_keyboardState[g_keyMaps.k_left[0]] || m_keyboardState[g_keyMaps.k_left[1]])) { keyFlags |= c_left; } - if ((m_keyboardState[SDL_SCANCODE_KP_6] || m_keyboardState[SDL_SCANCODE_RIGHT])) { + if ((m_keyboardState[g_keyMaps.k_right[0]] || m_keyboardState[g_keyMaps.k_right[1]])) { keyFlags |= c_right; } - if (m_keyboardState[SDL_SCANCODE_LCTRL] || m_keyboardState[SDL_SCANCODE_RCTRL]) { - keyFlags |= c_ctrl; + if (m_keyboardState[g_keyMaps.k_sprint[0]] || m_keyboardState[g_keyMaps.k_sprint[1]]) { + keyFlags |= c_sprint; } GetNavigationTouchStates(keyFlags); From 67b1d79c435601fca128421994b838896bfd02b7 Mon Sep 17 00:00:00 2001 From: VoxelTek <53562267+VoxelTek@users.noreply.github.com> Date: Thu, 14 Aug 2025 13:37:31 +1000 Subject: [PATCH 2/8] Initial work on `isle-config` UI stuff I'm really not sure I have the skills to cleanly implement something like this. I believe that someone else should take over, as I'm not experienced enough in C++ to accomplish this cleanly, or even at all. --- CONFIG/res/maindialog.ui | 134 ++++++++++++++++++++++++++++++++++++++- ISLE/isleapp.cpp | 1 + 2 files changed, 133 insertions(+), 2 deletions(-) diff --git a/CONFIG/res/maindialog.ui b/CONFIG/res/maindialog.ui index 99931197..9d74c1bb 100644 --- a/CONFIG/res/maindialog.ui +++ b/CONFIG/res/maindialog.ui @@ -955,6 +955,126 @@ The game will gradually increase the number of actors until this maximum is reac Controls + + + + false + + + Work-In-Progress, currently non-functional + + + Keyboard Mappings + + + + + + Forward + + + + + + + Back + + + + + + + Left + + + + + + + Right + + + + + + + Sprint + + + + + + + Up + + + + + + + Numpad 8 + + + + + + + Down + + + + + + + Numpad 2 + + + + + + + Left + + + + + + + Numpad 4 + + + + + + + Right + + + + + + + Numpad 6 + + + + + + + Left Control + + + + + + + Right Control + + + + + + @@ -1035,8 +1155,8 @@ The game will gradually increase the number of actors until this maximum is reac 0 0 - 449 - 369 + 217 + 217 @@ -1326,6 +1446,16 @@ Double-click a path to edit it. exFullResComboBox msaaSlider AFSlider + keyForward_1 + keyForward_2 + keyBack_1 + keyBack_2 + keyLeft_1 + keyLeft_2 + keyRight_1 + keyRight_2 + keySprint_1 + keySprint_2 touchComboBox rumbleCheckBox scrollArea diff --git a/ISLE/isleapp.cpp b/ISLE/isleapp.cpp index 83a7927c..875ecbde 100644 --- a/ISLE/isleapp.cpp +++ b/ISLE/isleapp.cpp @@ -45,6 +45,7 @@ #define SDL_MAIN_USE_CALLBACKS #include #include +#include #include #include #include From 9207590e78ed70ef5167103436b6810e3ae03342 Mon Sep 17 00:00:00 2001 From: VoxelTek <53562267+VoxelTek@users.noreply.github.com> Date: Fri, 15 Aug 2025 08:30:32 +1000 Subject: [PATCH 3/8] Slightly better approach for key mapping --- ISLE/isleapp.cpp | 1 + ISLE/isleapp.h | 1 + .../lego/legoomni/include/legoinputmanager.h | 9 +---- LEGO1/lego/legoomni/include/legokeymaps.h | 36 +++++++++++++++++++ 4 files changed, 39 insertions(+), 8 deletions(-) create mode 100644 LEGO1/lego/legoomni/include/legokeymaps.h diff --git a/ISLE/isleapp.cpp b/ISLE/isleapp.cpp index 875ecbde..f86b6e65 100644 --- a/ISLE/isleapp.cpp +++ b/ISLE/isleapp.cpp @@ -9,6 +9,7 @@ #include "legobuildingmanager.h" #include "legogamestate.h" #include "legoinputmanager.h" +#include "legokeymaps.h" #include "legomain.h" #include "legomodelpresenter.h" #include "legopartpresenter.h" diff --git a/ISLE/isleapp.h b/ISLE/isleapp.h index 470a5a72..9aa59c79 100644 --- a/ISLE/isleapp.h +++ b/ISLE/isleapp.h @@ -4,6 +4,7 @@ #include "cursor.h" #include "lego1_export.h" #include "legoinputmanager.h" +#include "legokeymaps.h" #include "legoutils.h" #include "mxtransitionmanager.h" #include "mxtypes.h" diff --git a/LEGO1/lego/legoomni/include/legoinputmanager.h b/LEGO1/lego/legoomni/include/legoinputmanager.h index 9a445a68..83c476a1 100644 --- a/LEGO1/lego/legoomni/include/legoinputmanager.h +++ b/LEGO1/lego/legoomni/include/legoinputmanager.h @@ -4,6 +4,7 @@ #include "decomp.h" #include "lego1_export.h" #include "legoeventnotificationparam.h" +#include "legokeymaps.h" #include "mxlist.h" #include "mxpresenter.h" #include "mxqueue.h" @@ -101,14 +102,6 @@ class LegoInputManager : public MxPresenter { e_gamepad, }; - struct { - SDL_Scancode k_forward[2] = {SDL_SCANCODE_UP, SDL_SCANCODE_KP_8}; - SDL_Scancode k_back[2] = {SDL_SCANCODE_DOWN, SDL_SCANCODE_KP_2}; - SDL_Scancode k_left[2] = {SDL_SCANCODE_LEFT, SDL_SCANCODE_KP_4}; - SDL_Scancode k_right[2] = {SDL_SCANCODE_RIGHT, SDL_SCANCODE_KP_6}; - SDL_Scancode k_sprint[2] = {SDL_SCANCODE_LCTRL, SDL_SCANCODE_RCTRL}; - } g_keyMaps; - LegoInputManager(); ~LegoInputManager() override; diff --git a/LEGO1/lego/legoomni/include/legokeymaps.h b/LEGO1/lego/legoomni/include/legokeymaps.h new file mode 100644 index 00000000..411c9ba8 --- /dev/null +++ b/LEGO1/lego/legoomni/include/legokeymaps.h @@ -0,0 +1,36 @@ +#ifndef LEGOKEYMAPS_H +#define LEGOKEYMAPS_H + +#include "decomp.h" +#include "lego1_export.h" +#include "legoeventnotificationparam.h" +#include "mxlist.h" +#include "mxpresenter.h" +#include "mxqueue.h" + +#include +#include +#include +#include +#include +#include +#ifdef MINIWIN +#include "miniwin/windows.h" +#else +#include +#endif + +#include +#include + + +struct { + SDL_Scancode k_forward[2] = {SDL_SCANCODE_UP, SDL_SCANCODE_KP_8}; + SDL_Scancode k_back[2] = {SDL_SCANCODE_DOWN, SDL_SCANCODE_KP_2}; + SDL_Scancode k_left[2] = {SDL_SCANCODE_LEFT, SDL_SCANCODE_KP_4}; + SDL_Scancode k_right[2] = {SDL_SCANCODE_RIGHT, SDL_SCANCODE_KP_6}; + SDL_Scancode k_sprint[2] = {SDL_SCANCODE_LCTRL, SDL_SCANCODE_RCTRL}; +} g_keyMaps; + + +#endif From e5656bace134e759fab904e41a706b839def6bcf Mon Sep 17 00:00:00 2001 From: VoxelTek <53562267+VoxelTek@users.noreply.github.com> Date: Mon, 18 Aug 2025 14:46:15 +1000 Subject: [PATCH 4/8] SDL event functions don't seem to work... --- CONFIG/MainDlg.cpp | 11 +++++++++++ CONFIG/MainDlg.h | 2 ++ CONFIG/config.cpp | 24 +++++++++++++++++++++++ CONFIG/config.h | 2 ++ CONFIG/res/maindialog.ui | 8 ++++---- ISLE/isleapp.cpp | 23 ++++++++++++++++++++++ LEGO1/lego/legoomni/include/legokeymaps.h | 7 ------- 7 files changed, 66 insertions(+), 11 deletions(-) diff --git a/CONFIG/MainDlg.cpp b/CONFIG/MainDlg.cpp index 73a85ab3..b5a6a502 100644 --- a/CONFIG/MainDlg.cpp +++ b/CONFIG/MainDlg.cpp @@ -73,6 +73,8 @@ CMainDialog::CMainDialog(QWidget* pParent) : QDialog(pParent) connect(m_ui->cancelButton, &QPushButton::clicked, this, &CMainDialog::reject); connect(m_ui->launchButton, &QPushButton::clicked, this, &CMainDialog::launch); + connect(m_ui->keyForward_1, &QPushButton::clicked, this, &CMainDialog::ForwardKeyChanged); + connect(m_ui->dataPathOpen, &QPushButton::clicked, this, &CMainDialog::SelectDataPathDialog); connect(m_ui->savePathOpen, &QPushButton::clicked, this, &CMainDialog::SelectSavePathDialog); @@ -749,3 +751,12 @@ void CMainDialog::FramerateChanged(int i) m_modified = true; UpdateInterface(); } + +void CMainDialog::ForwardKeyChanged() { + RebindInput(m_ui->keyForward_1); +} + +void CMainDialog::RebindInput(QPushButton* &button) +{ + button->setText(QString("Press a key...")); +} diff --git a/CONFIG/MainDlg.h b/CONFIG/MainDlg.h index 22cf7895..cffb4298 100644 --- a/CONFIG/MainDlg.h +++ b/CONFIG/MainDlg.h @@ -76,6 +76,8 @@ private slots: void AspectRatioChanged(int index); void EnsureAspectRatio(); void FramerateChanged(int i); + void ForwardKeyChanged(); + void RebindInput(QPushButton* &button); }; // SYNTHETIC: CONFIG 0x00403de0 diff --git a/CONFIG/config.cpp b/CONFIG/config.cpp index 4e9d414d..5f6441e0 100644 --- a/CONFIG/config.cpp +++ b/CONFIG/config.cpp @@ -199,6 +199,18 @@ bool CConfigApp::ReadRegisterSettings() m_exf_y_res = iniparser_getint(dict, "isle:Exclusive Y Resolution", m_exf_y_res); m_exf_fps = iniparser_getdouble(dict, "isle:Exclusive Framerate", m_exf_fps); m_frame_delta = iniparser_getdouble(dict, "isle:Frame Delta", m_frame_delta); + + g_keyMaps.k_forward[0] = (SDL_Scancode) iniparser_getint(dict, "input:Forward", g_keyMaps.k_forward[0]); + g_keyMaps.k_forward[1] = (SDL_Scancode) iniparser_getint(dict, "input:Forward Alt", g_keyMaps.k_forward[1]); + g_keyMaps.k_back[0] = (SDL_Scancode) iniparser_getint(dict, "input:Backward", g_keyMaps.k_back[0]); + g_keyMaps.k_back[1] = (SDL_Scancode) iniparser_getint(dict, "input:Backward Alt", g_keyMaps.k_back[1]); + g_keyMaps.k_left[0] = (SDL_Scancode) iniparser_getint(dict, "input:Left", g_keyMaps.k_left[0]); + g_keyMaps.k_left[1] = (SDL_Scancode) iniparser_getint(dict, "input:Left Alt", g_keyMaps.k_left[1]); + g_keyMaps.k_right[0] = (SDL_Scancode) iniparser_getint(dict, "input:Right", g_keyMaps.k_right[0]); + g_keyMaps.k_right[1] = (SDL_Scancode) iniparser_getint(dict, "input:Right Alt", g_keyMaps.k_right[1]); + g_keyMaps.k_sprint[0] = (SDL_Scancode) iniparser_getint(dict, "input:Sprint", g_keyMaps.k_sprint[0]); + g_keyMaps.k_sprint[1] = (SDL_Scancode) iniparser_getint(dict, "input:Sprint Alt", g_keyMaps.k_sprint[1]); + iniparser_freedict(dict); return true; } @@ -370,6 +382,7 @@ void CConfigApp::WriteRegisterSettings() const iniparser_set(dict, "extensions", NULL); iniparser_set(dict, "texture loader", NULL); iniparser_set(dict, "si loader", NULL); + iniparser_set(dict, "input", NULL); if (m_device_enumerator->FormatDeviceName(buffer, m_driver, m_device) >= 0) { iniparser_set(dict, "isle:3D Device ID", buffer); @@ -419,6 +432,17 @@ void CConfigApp::WriteRegisterSettings() const iniparser_set(dict, "isle:Exclusive Framerate", std::to_string(m_exf_fps).c_str()); iniparser_set(dict, "isle:Frame Delta", std::to_string(m_frame_delta).c_str()); + SetIniInt(dict, "input:Forward", g_keyMaps.k_forward[0]); + SetIniInt(dict, "input:Forward Alt", g_keyMaps.k_forward[1]); + SetIniInt(dict, "input:Backward", g_keyMaps.k_back[0]); + SetIniInt(dict, "input:Backward Alt", g_keyMaps.k_back[1]); + SetIniInt(dict, "input:Left", g_keyMaps.k_left[0]); + SetIniInt(dict, "input:Left Alt", g_keyMaps.k_left[1]); + SetIniInt(dict, "input:Right", g_keyMaps.k_right[0]); + SetIniInt(dict, "input:Right Alt", g_keyMaps.k_right[1]); + SetIniInt(dict, "input:Sprint", g_keyMaps.k_sprint[0]); + SetIniInt(dict, "input:Sprint Alt", g_keyMaps.k_sprint[1]); + #undef SetIniBool #undef SetIniInt diff --git a/CONFIG/config.h b/CONFIG/config.h index 71e876f6..169346c3 100644 --- a/CONFIG/config.h +++ b/CONFIG/config.h @@ -4,6 +4,7 @@ #include "AboutDlg.h" #include "compat.h" #include "decomp.h" +#include "lego/legoomni/include/legokeymaps.h" #ifdef MINIWIN #include "miniwin/d3d.h" @@ -12,6 +13,7 @@ #endif #include +#include class LegoDeviceEnumerate; struct Direct3DDeviceInfo; diff --git a/CONFIG/res/maindialog.ui b/CONFIG/res/maindialog.ui index 9d74c1bb..5a835e68 100644 --- a/CONFIG/res/maindialog.ui +++ b/CONFIG/res/maindialog.ui @@ -7,7 +7,7 @@ 0 0 640 - 480 + 502 @@ -958,7 +958,7 @@ The game will gradually increase the number of actors until this maximum is reac - false + true Work-In-Progress, currently non-functional @@ -1155,8 +1155,8 @@ The game will gradually increase the number of actors until this maximum is reac 0 0 - 217 - 217 + 449 + 391 diff --git a/ISLE/isleapp.cpp b/ISLE/isleapp.cpp index 6715315d..552eff23 100644 --- a/ISLE/isleapp.cpp +++ b/ISLE/isleapp.cpp @@ -1107,6 +1107,18 @@ bool IsleApp::LoadConfig() iniparser_set(dict, "isle:Exclusive Framerate", SDL_itoa(m_exclusiveFrameRate, buf, 10)); iniparser_set(dict, "isle:Frame Delta", SDL_itoa(m_frameDelta, buf, 10)); + iniparser_set(dict, "input", NULL); + iniparser_set(dict, "input:Forward", SDL_itoa(g_keyMaps.k_forward[0], buf, 10)); + iniparser_set(dict, "input:Forward Alt", SDL_itoa(g_keyMaps.k_forward[1], buf, 10)); + iniparser_set(dict, "input:Backward", SDL_itoa(g_keyMaps.k_back[0], buf, 10)); + iniparser_set(dict, "input:Backward Alt", SDL_itoa(g_keyMaps.k_back[1], buf, 10)); + iniparser_set(dict, "input:Left", SDL_itoa(g_keyMaps.k_left[0], buf, 10)); + iniparser_set(dict, "input:Left Alt", SDL_itoa(g_keyMaps.k_left[1], buf, 10)); + iniparser_set(dict, "input:Right", SDL_itoa(g_keyMaps.k_right[0], buf, 10)); + iniparser_set(dict, "input:Right Alt", SDL_itoa(g_keyMaps.k_right[1], buf, 10)); + iniparser_set(dict, "input:Sprint", SDL_itoa(g_keyMaps.k_sprint[0], buf, 10)); + iniparser_set(dict, "input:Sprint Alt", SDL_itoa(g_keyMaps.k_sprint[1], buf, 10)); + #ifdef EXTENSIONS iniparser_set(dict, "extensions", NULL); for (const char* key : Extensions::availableExtensions) { @@ -1184,6 +1196,17 @@ bool IsleApp::LoadConfig() m_videoParam.SetMSAASamples((m_msaaSamples = iniparser_getint(dict, "isle:MSAA", m_msaaSamples))); m_videoParam.SetAnisotropic((m_anisotropic = iniparser_getdouble(dict, "isle:Anisotropic", m_anisotropic))); + g_keyMaps.k_forward[0] = (SDL_Scancode) iniparser_getint(dict, "input:Forward", g_keyMaps.k_forward[0]); + g_keyMaps.k_forward[1] = (SDL_Scancode) iniparser_getint(dict, "input:Forward Alt", g_keyMaps.k_forward[1]); + g_keyMaps.k_back[0] = (SDL_Scancode) iniparser_getint(dict, "input:Backward", g_keyMaps.k_back[0]); + g_keyMaps.k_back[1] = (SDL_Scancode) iniparser_getint(dict, "input:Backward Alt", g_keyMaps.k_back[1]); + g_keyMaps.k_left[0] = (SDL_Scancode) iniparser_getint(dict, "input:Left", g_keyMaps.k_left[0]); + g_keyMaps.k_left[1] = (SDL_Scancode) iniparser_getint(dict, "input:Left Alt", g_keyMaps.k_left[1]); + g_keyMaps.k_right[0] = (SDL_Scancode) iniparser_getint(dict, "input:Right", g_keyMaps.k_right[0]); + g_keyMaps.k_right[1] = (SDL_Scancode) iniparser_getint(dict, "input:Right Alt", g_keyMaps.k_right[1]); + g_keyMaps.k_sprint[0] = (SDL_Scancode) iniparser_getint(dict, "input:Sprint", g_keyMaps.k_sprint[0]); + g_keyMaps.k_sprint[1] = (SDL_Scancode) iniparser_getint(dict, "input:Sprint Alt", g_keyMaps.k_sprint[1]); + const char* deviceId = iniparser_getstring(dict, "isle:3D Device ID", NULL); if (deviceId != NULL) { m_deviceId = SDL_strdup(deviceId); diff --git a/LEGO1/lego/legoomni/include/legokeymaps.h b/LEGO1/lego/legoomni/include/legokeymaps.h index 411c9ba8..32fef860 100644 --- a/LEGO1/lego/legoomni/include/legokeymaps.h +++ b/LEGO1/lego/legoomni/include/legokeymaps.h @@ -3,17 +3,10 @@ #include "decomp.h" #include "lego1_export.h" -#include "legoeventnotificationparam.h" -#include "mxlist.h" -#include "mxpresenter.h" -#include "mxqueue.h" -#include -#include #include #include #include -#include #ifdef MINIWIN #include "miniwin/windows.h" #else From 0c9d8d3228759aee17e819e463c4ceab656cae63 Mon Sep 17 00:00:00 2001 From: VoxelTek <53562267+VoxelTek@users.noreply.github.com> Date: Tue, 19 Aug 2025 11:23:27 +1000 Subject: [PATCH 5/8] sob it's not going well --- CONFIG/MainDlg.cpp | 47 +++++++++++++++++++++++++++++++++++++++------- CONFIG/MainDlg.h | 8 +++++++- CONFIG/config.cpp | 5 +++++ 3 files changed, 52 insertions(+), 8 deletions(-) diff --git a/CONFIG/MainDlg.cpp b/CONFIG/MainDlg.cpp index b5a6a502..dbbe4bc0 100644 --- a/CONFIG/MainDlg.cpp +++ b/CONFIG/MainDlg.cpp @@ -639,7 +639,7 @@ void CMainDialog::AddCustomAssetPath() QDir data_path = QDir(QString::fromStdString(currentConfigApp->m_cd_path)); QStringList new_files = QFileDialog::getOpenFileNames( this, - "Select one or more files to open", + "Open File(s)", data_path.absolutePath(), "Interleaf files (*.si)" ); @@ -721,7 +721,10 @@ void CMainDialog::YResChanged(int i) void CMainDialog::EnsureAspectRatio() { - if (currentConfigApp->m_aspect_ratio != 3) { + if (currentConfigApp->m_aspect_ratio == 3) { + m_ui->xResSpinBox->setReadOnly(false); + } + else { m_ui->xResSpinBox->setReadOnly(true); switch (currentConfigApp->m_aspect_ratio) { case 0: { @@ -740,9 +743,6 @@ void CMainDialog::EnsureAspectRatio() } } } - else { - m_ui->xResSpinBox->setReadOnly(false); - } } void CMainDialog::FramerateChanged(int i) @@ -753,10 +753,43 @@ void CMainDialog::FramerateChanged(int i) } void CMainDialog::ForwardKeyChanged() { - RebindInput(m_ui->keyForward_1); + RebindInput(m_ui->keyForward_1, g_keyMaps.k_forward[0]); } -void CMainDialog::RebindInput(QPushButton* &button) +void CMainDialog::RebindInput(QPushButton* &button, SDL_Scancode &key) { button->setText(QString("Press a key...")); + currentKeyBind = &key; + inputTimeout.setSingleShot(true); + inputTimeout.setInterval(3 * 1000); + sdlPoller.setSingleShot(false); + sdlPoller.setInterval(10); + connect(&inputTimeout, &QTimer::timeout, this, &CMainDialog::RebindTimeout); + connect(&sdlPoller, &QTimer::timeout, this, &CMainDialog::PollInputs); + SDL_InitSubSystem(SDL_INIT_EVENTS); + sdlPoller.start(); + inputTimeout.start(); +} + +void CMainDialog::PollInputs() +{ + SDL_Event event; + while (SDL_PollEvent(&event)) { + if (event.type == SDL_EVENT_KEY_DOWN) { + SDL_Log("Key down!"); + SDL_Scancode sc = event.key.scancode; + *currentKeyBind = sc; + sdlPoller.disconnect(); + inputTimeout.disconnect(); + UpdateInterface(); + } + } +} + +void CMainDialog::RebindTimeout() +{ + SDL_Log("Timeout"); + sdlPoller.disconnect(); + inputTimeout.disconnect(); + UpdateInterface(); } diff --git a/CONFIG/MainDlg.h b/CONFIG/MainDlg.h index cffb4298..5663e6f7 100644 --- a/CONFIG/MainDlg.h +++ b/CONFIG/MainDlg.h @@ -7,6 +7,7 @@ #include #include +#include #include namespace Ui @@ -32,6 +33,9 @@ class CMainDialog : public QDialog { QStringList assetPaths = QStringList(); Ui::MainDialog* m_ui = nullptr; SDL_DisplayMode** displayModes; + QTimer sdlPoller; + QTimer inputTimeout; + SDL_Scancode* currentKeyBind = nullptr; void keyReleaseEvent(QKeyEvent* event) override; bool OnInitDialog(); @@ -77,7 +81,9 @@ private slots: void EnsureAspectRatio(); void FramerateChanged(int i); void ForwardKeyChanged(); - void RebindInput(QPushButton* &button); + void RebindInput(QPushButton* &button, SDL_Scancode &key); + void PollInputs(); + void RebindTimeout(); }; // SYNTHETIC: CONFIG 0x00403de0 diff --git a/CONFIG/config.cpp b/CONFIG/config.cpp index 5f6441e0..c10ebad5 100644 --- a/CONFIG/config.cpp +++ b/CONFIG/config.cpp @@ -505,6 +505,11 @@ int main(int argc, char* argv[]) } qInfo() << "INI path =" << QString::fromStdString(g_theApp.GetIniPath()); + if (SDL_InitSubSystem(SDL_INIT_EVENTS) != true) { + qDebug() << "SDL_Init Error:" << SDL_GetError(); + //return 1; + } + int result = 1; if (g_theApp.InitInstance()) { CMainDialog main_dialog; From c5cb30bd86056cc0d3e2a776e7495cb7294f9a80 Mon Sep 17 00:00:00 2001 From: VoxelTek <53562267+VoxelTek@users.noreply.github.com> Date: Tue, 19 Aug 2025 14:49:51 +1000 Subject: [PATCH 6/8] Still suffering...but maybe getting closer --- CONFIG/MainDlg.cpp | 14 +++++++++++++- CONFIG/MainDlg.h | 8 ++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/CONFIG/MainDlg.cpp b/CONFIG/MainDlg.cpp index dbbe4bc0..b1d49b23 100644 --- a/CONFIG/MainDlg.cpp +++ b/CONFIG/MainDlg.cpp @@ -758,15 +758,24 @@ void CMainDialog::ForwardKeyChanged() { void CMainDialog::RebindInput(QPushButton* &button, SDL_Scancode &key) { + SDL_InitSubSystem(SDL_INIT_EVENTS); button->setText(QString("Press a key...")); currentKeyBind = &key; + + inputWindow = SDL_CreateWindow("Press a key...", 256, 128, SDL_WINDOW_HIDDEN | SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_ALWAYS_ON_TOP | SDL_WINDOW_UTILITY | SDL_WINDOW_KEYBOARD_GRABBED); +#ifdef MINIWIN + hWnd = reinterpret_cast(inputWindow); +#else + hWnd = (HWND) SDL_GetPointerProperty(SDL_GetWindowProperties(inputWindow), SDL_PROP_WINDOW_WIN32_HWND_POINTER, NULL); +#endif + inputTimeout.setSingleShot(true); inputTimeout.setInterval(3 * 1000); sdlPoller.setSingleShot(false); sdlPoller.setInterval(10); connect(&inputTimeout, &QTimer::timeout, this, &CMainDialog::RebindTimeout); connect(&sdlPoller, &QTimer::timeout, this, &CMainDialog::PollInputs); - SDL_InitSubSystem(SDL_INIT_EVENTS); + SDL_ShowWindow(inputWindow); sdlPoller.start(); inputTimeout.start(); } @@ -781,6 +790,8 @@ void CMainDialog::PollInputs() *currentKeyBind = sc; sdlPoller.disconnect(); inputTimeout.disconnect(); + SDL_DestroyWindow(inputWindow); + m_modified = true; UpdateInterface(); } } @@ -791,5 +802,6 @@ void CMainDialog::RebindTimeout() SDL_Log("Timeout"); sdlPoller.disconnect(); inputTimeout.disconnect(); + SDL_DestroyWindow(inputWindow); UpdateInterface(); } diff --git a/CONFIG/MainDlg.h b/CONFIG/MainDlg.h index 5663e6f7..03559e5f 100644 --- a/CONFIG/MainDlg.h +++ b/CONFIG/MainDlg.h @@ -5,6 +5,12 @@ #include "decomp.h" #include "res/resource.h" +#ifdef MINIWIN +#include "miniwin/d3d.h" +#else +#include +#endif + #include #include #include @@ -33,6 +39,8 @@ class CMainDialog : public QDialog { QStringList assetPaths = QStringList(); Ui::MainDialog* m_ui = nullptr; SDL_DisplayMode** displayModes; + SDL_Window* inputWindow; + HWND hWnd; QTimer sdlPoller; QTimer inputTimeout; SDL_Scancode* currentKeyBind = nullptr; From 7bbb50a1d881539f23212ab35f1ac20d66486915 Mon Sep 17 00:00:00 2001 From: VoxelTek <53562267+VoxelTek@users.noreply.github.com> Date: Wed, 20 Aug 2025 09:33:29 +1000 Subject: [PATCH 7/8] I think this is pretty much it, should be done --- CMakeLists.txt | 3 + CONFIG/MainDlg.cpp | 149 ++++++++++++++---- CONFIG/MainDlg.h | 26 ++- CONFIG/config.cpp | 4 +- CONFIG/config.h | 4 +- CONFIG/res/maindialog.ui | 3 - LEGO1/lego/legoomni/include/legokeymaps.h | 16 +- LEGO1/lego/legoomni/src/input/legokeymaps.cpp | 11 ++ 8 files changed, 160 insertions(+), 56 deletions(-) create mode 100644 LEGO1/lego/legoomni/src/input/legokeymaps.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index deebda7e..32bcbe27 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -450,6 +450,7 @@ target_sources(lego1 PRIVATE LEGO1/lego/legoomni/src/entity/legoworld.cpp LEGO1/lego/legoomni/src/entity/legoworldpresenter.cpp LEGO1/lego/legoomni/src/input/legoinputmanager.cpp + LEGO1/lego/legoomni/src/input/legokeymaps.cpp LEGO1/lego/legoomni/src/main/legomain.cpp LEGO1/lego/legoomni/src/main/scripts.cpp LEGO1/lego/legoomni/src/paths/legoanimactor.cpp @@ -639,6 +640,7 @@ if (ISLE_BUILD_CONFIG) qt_add_executable(isle-config WIN32 LEGO1/mxdirectx/mxdirectxinfo.cpp LEGO1/mxdirectx/legodxinfo.cpp + LEGO1/lego/legoomni/src/input/legokeymaps.cpp CONFIG/config.cpp CONFIG/AboutDlg.cpp CONFIG/MainDlg.cpp @@ -654,6 +656,7 @@ if (ISLE_BUILD_CONFIG) list(APPEND isle_targets isle-config) target_compile_definitions(isle-config PRIVATE _AFXDLL MXDIRECTX_FOR_CONFIG) target_include_directories(isle-config PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/LEGO1") + target_include_directories(isle-config PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/LEGO1/lego/legoomni/include") target_include_directories(isle-config PUBLIC "$") if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 14) target_link_libraries(isle-config PRIVATE DirectX5::DirectX5) diff --git a/CONFIG/MainDlg.cpp b/CONFIG/MainDlg.cpp index b1d49b23..a7cb9da8 100644 --- a/CONFIG/MainDlg.cpp +++ b/CONFIG/MainDlg.cpp @@ -74,6 +74,15 @@ CMainDialog::CMainDialog(QWidget* pParent) : QDialog(pParent) connect(m_ui->launchButton, &QPushButton::clicked, this, &CMainDialog::launch); connect(m_ui->keyForward_1, &QPushButton::clicked, this, &CMainDialog::ForwardKeyChanged); + connect(m_ui->keyForward_2, &QPushButton::clicked, this, &CMainDialog::ForwardKeyChangedAlt); + connect(m_ui->keyBack_1, &QPushButton::clicked, this, &CMainDialog::BackwardKeyChanged); + connect(m_ui->keyBack_2, &QPushButton::clicked, this, &CMainDialog::BackwardKeyChangedAlt); + connect(m_ui->keyLeft_1, &QPushButton::clicked, this, &CMainDialog::LeftKeyChanged); + connect(m_ui->keyLeft_2, &QPushButton::clicked, this, &CMainDialog::LeftKeyChangedAlt); + connect(m_ui->keyRight_1, &QPushButton::clicked, this, &CMainDialog::RightKeyChanged); + connect(m_ui->keyRight_2, &QPushButton::clicked, this, &CMainDialog::RightKeyChangedAlt); + connect(m_ui->keySprint_1, &QPushButton::clicked, this, &CMainDialog::SprintKeyChanged); + connect(m_ui->keySprint_2, &QPushButton::clicked, this, &CMainDialog::SprintKeyChangedAlt); connect(m_ui->dataPathOpen, &QPushButton::clicked, this, &CMainDialog::SelectDataPathDialog); connect(m_ui->savePathOpen, &QPushButton::clicked, this, &CMainDialog::SelectSavePathDialog); @@ -183,16 +192,18 @@ bool CMainDialog::OnInitDialog() m_ui->exFullResComboBox->clear(); int displayModeCount; - displayModes = SDL_GetFullscreenDisplayModes(SDL_GetPrimaryDisplay(), &displayModeCount); + m_displayModes = SDL_GetFullscreenDisplayModes(SDL_GetPrimaryDisplay(), &displayModeCount); for (int i = 0; i < displayModeCount; ++i) { - QString mode = - QString("%1x%2 @ %3Hz").arg(displayModes[i]->w).arg(displayModes[i]->h).arg(displayModes[i]->refresh_rate); + QString mode = QString("%1x%2 @ %3Hz") + .arg(m_displayModes[i]->w) + .arg(m_displayModes[i]->h) + .arg(m_displayModes[i]->refresh_rate); m_ui->exFullResComboBox->addItem(mode); - if ((displayModes[i]->w == currentConfigApp->m_exf_x_res) && - (displayModes[i]->h == currentConfigApp->m_exf_y_res) && - (displayModes[i]->refresh_rate == currentConfigApp->m_exf_fps)) { + if ((m_displayModes[i]->w == currentConfigApp->m_exf_x_res) && + (m_displayModes[i]->h == currentConfigApp->m_exf_y_res) && + (m_displayModes[i]->refresh_rate == currentConfigApp->m_exf_fps)) { m_ui->exFullResComboBox->setCurrentIndex(i); } } @@ -350,6 +361,22 @@ void CMainDialog::UpdateInterface() m_ui->msaaNum->setNum(currentConfigApp->m_msaa); m_ui->AFSlider->setValue(log2(currentConfigApp->m_anisotropy)); m_ui->AFNum->setNum(currentConfigApp->m_anisotropy); + + m_ui->keyForward_1->setText(GetKeyName(g_keyMaps.k_forward[0])); + m_ui->keyForward_2->setText(GetKeyName(g_keyMaps.k_forward[1])); + m_ui->keyBack_1->setText(GetKeyName(g_keyMaps.k_back[0])); + m_ui->keyBack_2->setText(GetKeyName(g_keyMaps.k_back[1])); + m_ui->keyLeft_1->setText(GetKeyName(g_keyMaps.k_left[0])); + m_ui->keyLeft_2->setText(GetKeyName(g_keyMaps.k_left[1])); + m_ui->keyRight_1->setText(GetKeyName(g_keyMaps.k_right[0])); + m_ui->keyRight_2->setText(GetKeyName(g_keyMaps.k_right[1])); + m_ui->keySprint_1->setText(GetKeyName(g_keyMaps.k_sprint[0])); + m_ui->keySprint_2->setText(GetKeyName(g_keyMaps.k_sprint[1])); +} + +QString CMainDialog::GetKeyName(SDL_Scancode key) +{ + return QString(SDL_GetKeyName(SDL_GetKeyFromScancode(key, 0, true))); } // FUNCTION: CONFIG 0x004045e0 @@ -490,9 +517,9 @@ void CMainDialog::TransitionTypeChanged(int index) void CMainDialog::ExclusiveResolutionChanged(int index) { - currentConfigApp->m_exf_x_res = displayModes[index]->w; - currentConfigApp->m_exf_y_res = displayModes[index]->h; - currentConfigApp->m_exf_fps = displayModes[index]->refresh_rate; + currentConfigApp->m_exf_x_res = m_displayModes[index]->w; + currentConfigApp->m_exf_y_res = m_displayModes[index]->h; + currentConfigApp->m_exf_fps = m_displayModes[index]->refresh_rate; m_modified = true; UpdateInterface(); } @@ -637,12 +664,8 @@ void CMainDialog::TexturePathEdited() void CMainDialog::AddCustomAssetPath() { QDir data_path = QDir(QString::fromStdString(currentConfigApp->m_cd_path)); - QStringList new_files = QFileDialog::getOpenFileNames( - this, - "Open File(s)", - data_path.absolutePath(), - "Interleaf files (*.si)" - ); + QStringList new_files = + QFileDialog::getOpenFileNames(this, "Open File(s)", data_path.absolutePath(), "Interleaf files (*.si)"); if (!new_files.isEmpty()) { for (QString& item : new_files) { item = data_path.relativeFilePath(item); @@ -752,30 +775,85 @@ void CMainDialog::FramerateChanged(int i) UpdateInterface(); } -void CMainDialog::ForwardKeyChanged() { +void CMainDialog::ForwardKeyChanged() +{ RebindInput(m_ui->keyForward_1, g_keyMaps.k_forward[0]); } -void CMainDialog::RebindInput(QPushButton* &button, SDL_Scancode &key) +void CMainDialog::ForwardKeyChangedAlt() +{ + RebindInput(m_ui->keyForward_2, g_keyMaps.k_forward[1]); +} + +void CMainDialog::BackwardKeyChanged() +{ + RebindInput(m_ui->keyBack_1, g_keyMaps.k_back[0]); +} + +void CMainDialog::BackwardKeyChangedAlt() +{ + RebindInput(m_ui->keyBack_2, g_keyMaps.k_back[1]); +} + +void CMainDialog::LeftKeyChanged() +{ + RebindInput(m_ui->keyLeft_1, g_keyMaps.k_left[0]); +} + +void CMainDialog::LeftKeyChangedAlt() +{ + RebindInput(m_ui->keyLeft_2, g_keyMaps.k_left[1]); +} + +void CMainDialog::RightKeyChanged() +{ + RebindInput(m_ui->keyRight_1, g_keyMaps.k_right[0]); +} + +void CMainDialog::RightKeyChangedAlt() +{ + RebindInput(m_ui->keyRight_2, g_keyMaps.k_right[1]); +} + +void CMainDialog::SprintKeyChanged() +{ + RebindInput(m_ui->keySprint_1, g_keyMaps.k_sprint[0]); +} + +void CMainDialog::SprintKeyChangedAlt() +{ + RebindInput(m_ui->keySprint_2, g_keyMaps.k_sprint[1]); +} + +void CMainDialog::RebindInput(QPushButton*& button, SDL_Scancode& key) { SDL_InitSubSystem(SDL_INIT_EVENTS); button->setText(QString("Press a key...")); - currentKeyBind = &key; + m_currentKeyBind = &key; - inputWindow = SDL_CreateWindow("Press a key...", 256, 128, SDL_WINDOW_HIDDEN | SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_ALWAYS_ON_TOP | SDL_WINDOW_UTILITY | SDL_WINDOW_KEYBOARD_GRABBED); + m_inputWindow = SDL_CreateWindow( + "Press a key...", + 256, + 128, + SDL_WINDOW_HIDDEN | SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_ALWAYS_ON_TOP | SDL_WINDOW_UTILITY | + SDL_WINDOW_KEYBOARD_GRABBED + ); #ifdef MINIWIN - hWnd = reinterpret_cast(inputWindow); + m_hWnd = reinterpret_cast(m_inputWindow); #else - hWnd = (HWND) SDL_GetPointerProperty(SDL_GetWindowProperties(inputWindow), SDL_PROP_WINDOW_WIN32_HWND_POINTER, NULL); + m_hWnd = + (HWND) SDL_GetPointerProperty(SDL_GetWindowProperties(m_inputWindow), SDL_PROP_WINDOW_WIN32_HWND_POINTER, NULL); #endif - inputTimeout.setSingleShot(true); - inputTimeout.setInterval(3 * 1000); + inputTimeout.setSingleShot(false); + inputTimeout.setInterval(1000); sdlPoller.setSingleShot(false); sdlPoller.setInterval(10); connect(&inputTimeout, &QTimer::timeout, this, &CMainDialog::RebindTimeout); connect(&sdlPoller, &QTimer::timeout, this, &CMainDialog::PollInputs); - SDL_ShowWindow(inputWindow); + SDL_ShowWindow(m_inputWindow); + SDL_RaiseWindow(m_inputWindow); + timeoutCountdown = 3; sdlPoller.start(); inputTimeout.start(); } @@ -785,13 +863,14 @@ void CMainDialog::PollInputs() SDL_Event event; while (SDL_PollEvent(&event)) { if (event.type == SDL_EVENT_KEY_DOWN) { - SDL_Log("Key down!"); - SDL_Scancode sc = event.key.scancode; - *currentKeyBind = sc; + if (event.key.scancode != SDL_SCANCODE_ESCAPE) { + SDL_Scancode sc = event.key.scancode; + *m_currentKeyBind = sc; + m_modified = true; + } sdlPoller.disconnect(); inputTimeout.disconnect(); - SDL_DestroyWindow(inputWindow); - m_modified = true; + SDL_DestroyWindow(m_inputWindow); UpdateInterface(); } } @@ -799,9 +878,11 @@ void CMainDialog::PollInputs() void CMainDialog::RebindTimeout() { - SDL_Log("Timeout"); - sdlPoller.disconnect(); - inputTimeout.disconnect(); - SDL_DestroyWindow(inputWindow); - UpdateInterface(); + timeoutCountdown -= 1; + if (timeoutCountdown <= 0) { + sdlPoller.disconnect(); + inputTimeout.disconnect(); + SDL_DestroyWindow(m_inputWindow); + UpdateInterface(); + } } diff --git a/CONFIG/MainDlg.h b/CONFIG/MainDlg.h index 03559e5f..e4b17e9a 100644 --- a/CONFIG/MainDlg.h +++ b/CONFIG/MainDlg.h @@ -13,6 +13,7 @@ #include #include +#include #include #include @@ -38,15 +39,17 @@ class CMainDialog : public QDialog { bool m_advanced = false; QStringList assetPaths = QStringList(); Ui::MainDialog* m_ui = nullptr; - SDL_DisplayMode** displayModes; - SDL_Window* inputWindow; - HWND hWnd; + SDL_DisplayMode** m_displayModes; + SDL_Window* m_inputWindow; + HWND m_hWnd; QTimer sdlPoller; - QTimer inputTimeout; - SDL_Scancode* currentKeyBind = nullptr; + QTimer inputTimeout; + int timeoutCountdown = 0; + SDL_Scancode* m_currentKeyBind = nullptr; void keyReleaseEvent(QKeyEvent* event) override; bool OnInitDialog(); + QString GetKeyName(SDL_Scancode key); private slots: void OnList3DevicesSelectionChanged(int row); void OnCheckbox3DSound(bool checked); @@ -88,10 +91,19 @@ private slots: void AspectRatioChanged(int index); void EnsureAspectRatio(); void FramerateChanged(int i); - void ForwardKeyChanged(); - void RebindInput(QPushButton* &button, SDL_Scancode &key); + void RebindInput(QPushButton*& button, SDL_Scancode& key); void PollInputs(); void RebindTimeout(); + void ForwardKeyChanged(); + void ForwardKeyChangedAlt(); + void BackwardKeyChanged(); + void BackwardKeyChangedAlt(); + void LeftKeyChanged(); + void LeftKeyChangedAlt(); + void RightKeyChanged(); + void RightKeyChangedAlt(); + void SprintKeyChanged(); + void SprintKeyChangedAlt(); }; // SYNTHETIC: CONFIG 0x00403de0 diff --git a/CONFIG/config.cpp b/CONFIG/config.cpp index c10ebad5..122e12ce 100644 --- a/CONFIG/config.cpp +++ b/CONFIG/config.cpp @@ -507,8 +507,8 @@ int main(int argc, char* argv[]) if (SDL_InitSubSystem(SDL_INIT_EVENTS) != true) { qDebug() << "SDL_Init Error:" << SDL_GetError(); - //return 1; - } + // return 1; + } int result = 1; if (g_theApp.InitInstance()) { diff --git a/CONFIG/config.h b/CONFIG/config.h index 169346c3..a3d87e99 100644 --- a/CONFIG/config.h +++ b/CONFIG/config.h @@ -4,7 +4,7 @@ #include "AboutDlg.h" #include "compat.h" #include "decomp.h" -#include "lego/legoomni/include/legokeymaps.h" +#include "legokeymaps.h" #ifdef MINIWIN #include "miniwin/d3d.h" @@ -12,8 +12,8 @@ #include #endif -#include #include +#include class LegoDeviceEnumerate; struct Direct3DDeviceInfo; diff --git a/CONFIG/res/maindialog.ui b/CONFIG/res/maindialog.ui index 5a835e68..bd77fd1a 100644 --- a/CONFIG/res/maindialog.ui +++ b/CONFIG/res/maindialog.ui @@ -960,9 +960,6 @@ The game will gradually increase the number of actors until this maximum is reac true - - Work-In-Progress, currently non-functional - Keyboard Mappings diff --git a/LEGO1/lego/legoomni/include/legokeymaps.h b/LEGO1/lego/legoomni/include/legokeymaps.h index 32fef860..fbb2a281 100644 --- a/LEGO1/lego/legoomni/include/legokeymaps.h +++ b/LEGO1/lego/legoomni/include/legokeymaps.h @@ -16,14 +16,14 @@ #include #include +struct KeyMaps { + SDL_Scancode k_forward[2]; + SDL_Scancode k_back[2]; + SDL_Scancode k_left[2]; + SDL_Scancode k_right[2]; + SDL_Scancode k_sprint[2]; +}; -struct { - SDL_Scancode k_forward[2] = {SDL_SCANCODE_UP, SDL_SCANCODE_KP_8}; - SDL_Scancode k_back[2] = {SDL_SCANCODE_DOWN, SDL_SCANCODE_KP_2}; - SDL_Scancode k_left[2] = {SDL_SCANCODE_LEFT, SDL_SCANCODE_KP_4}; - SDL_Scancode k_right[2] = {SDL_SCANCODE_RIGHT, SDL_SCANCODE_KP_6}; - SDL_Scancode k_sprint[2] = {SDL_SCANCODE_LCTRL, SDL_SCANCODE_RCTRL}; -} g_keyMaps; - +extern KeyMaps g_keyMaps; #endif diff --git a/LEGO1/lego/legoomni/src/input/legokeymaps.cpp b/LEGO1/lego/legoomni/src/input/legokeymaps.cpp new file mode 100644 index 00000000..668e9995 --- /dev/null +++ b/LEGO1/lego/legoomni/src/input/legokeymaps.cpp @@ -0,0 +1,11 @@ +#include "legokeymaps.h" + +#include + +KeyMaps g_keyMaps = { + {SDL_SCANCODE_UP, SDL_SCANCODE_KP_8}, + {SDL_SCANCODE_DOWN, SDL_SCANCODE_KP_2}, + {SDL_SCANCODE_LEFT, SDL_SCANCODE_KP_4}, + {SDL_SCANCODE_RIGHT, SDL_SCANCODE_KP_6}, + {SDL_SCANCODE_LCTRL, SDL_SCANCODE_RCTRL} +}; From 515cc584fd623a44a7f87e8b8380975ce70cae4d Mon Sep 17 00:00:00 2001 From: VoxelTek <53562267+VoxelTek@users.noreply.github.com> Date: Wed, 20 Aug 2025 10:03:01 +1000 Subject: [PATCH 8/8] Add SDL_EVENT_QUIT --- CONFIG/MainDlg.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONFIG/MainDlg.cpp b/CONFIG/MainDlg.cpp index a7cb9da8..730cf208 100644 --- a/CONFIG/MainDlg.cpp +++ b/CONFIG/MainDlg.cpp @@ -862,8 +862,8 @@ void CMainDialog::PollInputs() { SDL_Event event; while (SDL_PollEvent(&event)) { - if (event.type == SDL_EVENT_KEY_DOWN) { - if (event.key.scancode != SDL_SCANCODE_ESCAPE) { + if (event.type == SDL_EVENT_KEY_DOWN || event.type == SDL_EVENT_QUIT) { + if (event.type == SDL_EVENT_KEY_DOWN && event.key.scancode != SDL_SCANCODE_ESCAPE) { SDL_Scancode sc = event.key.scancode; *m_currentKeyBind = sc; m_modified = true;