I think this is pretty much it, should be done

This commit is contained in:
VoxelTek 2025-08-20 09:33:29 +10:00
parent c5cb30bd86
commit 7bbb50a1d8
8 changed files with 160 additions and 56 deletions

View File

@ -450,6 +450,7 @@ target_sources(lego1 PRIVATE
LEGO1/lego/legoomni/src/entity/legoworld.cpp LEGO1/lego/legoomni/src/entity/legoworld.cpp
LEGO1/lego/legoomni/src/entity/legoworldpresenter.cpp LEGO1/lego/legoomni/src/entity/legoworldpresenter.cpp
LEGO1/lego/legoomni/src/input/legoinputmanager.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/legomain.cpp
LEGO1/lego/legoomni/src/main/scripts.cpp LEGO1/lego/legoomni/src/main/scripts.cpp
LEGO1/lego/legoomni/src/paths/legoanimactor.cpp LEGO1/lego/legoomni/src/paths/legoanimactor.cpp
@ -639,6 +640,7 @@ if (ISLE_BUILD_CONFIG)
qt_add_executable(isle-config WIN32 qt_add_executable(isle-config WIN32
LEGO1/mxdirectx/mxdirectxinfo.cpp LEGO1/mxdirectx/mxdirectxinfo.cpp
LEGO1/mxdirectx/legodxinfo.cpp LEGO1/mxdirectx/legodxinfo.cpp
LEGO1/lego/legoomni/src/input/legokeymaps.cpp
CONFIG/config.cpp CONFIG/config.cpp
CONFIG/AboutDlg.cpp CONFIG/AboutDlg.cpp
CONFIG/MainDlg.cpp CONFIG/MainDlg.cpp
@ -654,6 +656,7 @@ if (ISLE_BUILD_CONFIG)
list(APPEND isle_targets isle-config) list(APPEND isle_targets isle-config)
target_compile_definitions(isle-config PRIVATE _AFXDLL MXDIRECTX_FOR_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")
target_include_directories(isle-config PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/LEGO1/lego/legoomni/include")
target_include_directories(isle-config PUBLIC "$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/util>") target_include_directories(isle-config PUBLIC "$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/util>")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 14) if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 14)
target_link_libraries(isle-config PRIVATE DirectX5::DirectX5) target_link_libraries(isle-config PRIVATE DirectX5::DirectX5)

View File

@ -74,6 +74,15 @@ CMainDialog::CMainDialog(QWidget* pParent) : QDialog(pParent)
connect(m_ui->launchButton, &QPushButton::clicked, this, &CMainDialog::launch); connect(m_ui->launchButton, &QPushButton::clicked, this, &CMainDialog::launch);
connect(m_ui->keyForward_1, &QPushButton::clicked, this, &CMainDialog::ForwardKeyChanged); 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->dataPathOpen, &QPushButton::clicked, this, &CMainDialog::SelectDataPathDialog);
connect(m_ui->savePathOpen, &QPushButton::clicked, this, &CMainDialog::SelectSavePathDialog); connect(m_ui->savePathOpen, &QPushButton::clicked, this, &CMainDialog::SelectSavePathDialog);
@ -183,16 +192,18 @@ bool CMainDialog::OnInitDialog()
m_ui->exFullResComboBox->clear(); m_ui->exFullResComboBox->clear();
int displayModeCount; int displayModeCount;
displayModes = SDL_GetFullscreenDisplayModes(SDL_GetPrimaryDisplay(), &displayModeCount); m_displayModes = SDL_GetFullscreenDisplayModes(SDL_GetPrimaryDisplay(), &displayModeCount);
for (int i = 0; i < displayModeCount; ++i) { for (int i = 0; i < displayModeCount; ++i) {
QString mode = QString mode = QString("%1x%2 @ %3Hz")
QString("%1x%2 @ %3Hz").arg(displayModes[i]->w).arg(displayModes[i]->h).arg(displayModes[i]->refresh_rate); .arg(m_displayModes[i]->w)
.arg(m_displayModes[i]->h)
.arg(m_displayModes[i]->refresh_rate);
m_ui->exFullResComboBox->addItem(mode); m_ui->exFullResComboBox->addItem(mode);
if ((displayModes[i]->w == currentConfigApp->m_exf_x_res) && if ((m_displayModes[i]->w == currentConfigApp->m_exf_x_res) &&
(displayModes[i]->h == currentConfigApp->m_exf_y_res) && (m_displayModes[i]->h == currentConfigApp->m_exf_y_res) &&
(displayModes[i]->refresh_rate == currentConfigApp->m_exf_fps)) { (m_displayModes[i]->refresh_rate == currentConfigApp->m_exf_fps)) {
m_ui->exFullResComboBox->setCurrentIndex(i); m_ui->exFullResComboBox->setCurrentIndex(i);
} }
} }
@ -350,6 +361,22 @@ void CMainDialog::UpdateInterface()
m_ui->msaaNum->setNum(currentConfigApp->m_msaa); m_ui->msaaNum->setNum(currentConfigApp->m_msaa);
m_ui->AFSlider->setValue(log2(currentConfigApp->m_anisotropy)); m_ui->AFSlider->setValue(log2(currentConfigApp->m_anisotropy));
m_ui->AFNum->setNum(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 // FUNCTION: CONFIG 0x004045e0
@ -490,9 +517,9 @@ void CMainDialog::TransitionTypeChanged(int index)
void CMainDialog::ExclusiveResolutionChanged(int index) void CMainDialog::ExclusiveResolutionChanged(int index)
{ {
currentConfigApp->m_exf_x_res = displayModes[index]->w; currentConfigApp->m_exf_x_res = m_displayModes[index]->w;
currentConfigApp->m_exf_y_res = displayModes[index]->h; currentConfigApp->m_exf_y_res = m_displayModes[index]->h;
currentConfigApp->m_exf_fps = displayModes[index]->refresh_rate; currentConfigApp->m_exf_fps = m_displayModes[index]->refresh_rate;
m_modified = true; m_modified = true;
UpdateInterface(); UpdateInterface();
} }
@ -637,12 +664,8 @@ void CMainDialog::TexturePathEdited()
void CMainDialog::AddCustomAssetPath() void CMainDialog::AddCustomAssetPath()
{ {
QDir data_path = QDir(QString::fromStdString(currentConfigApp->m_cd_path)); QDir data_path = QDir(QString::fromStdString(currentConfigApp->m_cd_path));
QStringList new_files = QFileDialog::getOpenFileNames( QStringList new_files =
this, QFileDialog::getOpenFileNames(this, "Open File(s)", data_path.absolutePath(), "Interleaf files (*.si)");
"Open File(s)",
data_path.absolutePath(),
"Interleaf files (*.si)"
);
if (!new_files.isEmpty()) { if (!new_files.isEmpty()) {
for (QString& item : new_files) { for (QString& item : new_files) {
item = data_path.relativeFilePath(item); item = data_path.relativeFilePath(item);
@ -752,30 +775,85 @@ void CMainDialog::FramerateChanged(int i)
UpdateInterface(); UpdateInterface();
} }
void CMainDialog::ForwardKeyChanged() { void CMainDialog::ForwardKeyChanged()
{
RebindInput(m_ui->keyForward_1, g_keyMaps.k_forward[0]); 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); SDL_InitSubSystem(SDL_INIT_EVENTS);
button->setText(QString("Press a key...")); 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 #ifdef MINIWIN
hWnd = reinterpret_cast<HWND>(inputWindow); m_hWnd = reinterpret_cast<HWND>(m_inputWindow);
#else #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 #endif
inputTimeout.setSingleShot(true); inputTimeout.setSingleShot(false);
inputTimeout.setInterval(3 * 1000); inputTimeout.setInterval(1000);
sdlPoller.setSingleShot(false); sdlPoller.setSingleShot(false);
sdlPoller.setInterval(10); sdlPoller.setInterval(10);
connect(&inputTimeout, &QTimer::timeout, this, &CMainDialog::RebindTimeout); connect(&inputTimeout, &QTimer::timeout, this, &CMainDialog::RebindTimeout);
connect(&sdlPoller, &QTimer::timeout, this, &CMainDialog::PollInputs); connect(&sdlPoller, &QTimer::timeout, this, &CMainDialog::PollInputs);
SDL_ShowWindow(inputWindow); SDL_ShowWindow(m_inputWindow);
SDL_RaiseWindow(m_inputWindow);
timeoutCountdown = 3;
sdlPoller.start(); sdlPoller.start();
inputTimeout.start(); inputTimeout.start();
} }
@ -785,13 +863,14 @@ void CMainDialog::PollInputs()
SDL_Event event; SDL_Event event;
while (SDL_PollEvent(&event)) { while (SDL_PollEvent(&event)) {
if (event.type == SDL_EVENT_KEY_DOWN) { if (event.type == SDL_EVENT_KEY_DOWN) {
SDL_Log("Key down!"); if (event.key.scancode != SDL_SCANCODE_ESCAPE) {
SDL_Scancode sc = event.key.scancode; SDL_Scancode sc = event.key.scancode;
*currentKeyBind = sc; *m_currentKeyBind = sc;
m_modified = true;
}
sdlPoller.disconnect(); sdlPoller.disconnect();
inputTimeout.disconnect(); inputTimeout.disconnect();
SDL_DestroyWindow(inputWindow); SDL_DestroyWindow(m_inputWindow);
m_modified = true;
UpdateInterface(); UpdateInterface();
} }
} }
@ -799,9 +878,11 @@ void CMainDialog::PollInputs()
void CMainDialog::RebindTimeout() void CMainDialog::RebindTimeout()
{ {
SDL_Log("Timeout"); timeoutCountdown -= 1;
sdlPoller.disconnect(); if (timeoutCountdown <= 0) {
inputTimeout.disconnect(); sdlPoller.disconnect();
SDL_DestroyWindow(inputWindow); inputTimeout.disconnect();
UpdateInterface(); SDL_DestroyWindow(m_inputWindow);
UpdateInterface();
}
} }

View File

@ -13,6 +13,7 @@
#include <QDialog> #include <QDialog>
#include <QFileDialog> #include <QFileDialog>
#include <QString>
#include <QTimer> #include <QTimer>
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
@ -38,15 +39,17 @@ class CMainDialog : public QDialog {
bool m_advanced = false; bool m_advanced = false;
QStringList assetPaths = QStringList(); QStringList assetPaths = QStringList();
Ui::MainDialog* m_ui = nullptr; Ui::MainDialog* m_ui = nullptr;
SDL_DisplayMode** displayModes; SDL_DisplayMode** m_displayModes;
SDL_Window* inputWindow; SDL_Window* m_inputWindow;
HWND hWnd; HWND m_hWnd;
QTimer sdlPoller; QTimer sdlPoller;
QTimer inputTimeout; QTimer inputTimeout;
SDL_Scancode* currentKeyBind = nullptr; int timeoutCountdown = 0;
SDL_Scancode* m_currentKeyBind = nullptr;
void keyReleaseEvent(QKeyEvent* event) override; void keyReleaseEvent(QKeyEvent* event) override;
bool OnInitDialog(); bool OnInitDialog();
QString GetKeyName(SDL_Scancode key);
private slots: private slots:
void OnList3DevicesSelectionChanged(int row); void OnList3DevicesSelectionChanged(int row);
void OnCheckbox3DSound(bool checked); void OnCheckbox3DSound(bool checked);
@ -88,10 +91,19 @@ private slots:
void AspectRatioChanged(int index); void AspectRatioChanged(int index);
void EnsureAspectRatio(); void EnsureAspectRatio();
void FramerateChanged(int i); void FramerateChanged(int i);
void ForwardKeyChanged(); void RebindInput(QPushButton*& button, SDL_Scancode& key);
void RebindInput(QPushButton* &button, SDL_Scancode &key);
void PollInputs(); void PollInputs();
void RebindTimeout(); 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 // SYNTHETIC: CONFIG 0x00403de0

View File

@ -507,8 +507,8 @@ int main(int argc, char* argv[])
if (SDL_InitSubSystem(SDL_INIT_EVENTS) != true) { if (SDL_InitSubSystem(SDL_INIT_EVENTS) != true) {
qDebug() << "SDL_Init Error:" << SDL_GetError(); qDebug() << "SDL_Init Error:" << SDL_GetError();
//return 1; // return 1;
} }
int result = 1; int result = 1;
if (g_theApp.InitInstance()) { if (g_theApp.InitInstance()) {

View File

@ -4,7 +4,7 @@
#include "AboutDlg.h" #include "AboutDlg.h"
#include "compat.h" #include "compat.h"
#include "decomp.h" #include "decomp.h"
#include "lego/legoomni/include/legokeymaps.h" #include "legokeymaps.h"
#ifdef MINIWIN #ifdef MINIWIN
#include "miniwin/d3d.h" #include "miniwin/d3d.h"
@ -12,8 +12,8 @@
#include <d3d.h> #include <d3d.h>
#endif #endif
#include <string>
#include <SDL3/SDL_scancode.h> #include <SDL3/SDL_scancode.h>
#include <string>
class LegoDeviceEnumerate; class LegoDeviceEnumerate;
struct Direct3DDeviceInfo; struct Direct3DDeviceInfo;

View File

@ -960,9 +960,6 @@ The game will gradually increase the number of actors until this maximum is reac
<property name="enabled"> <property name="enabled">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="toolTip">
<string>Work-In-Progress, currently non-functional</string>
</property>
<property name="title"> <property name="title">
<string>Keyboard Mappings</string> <string>Keyboard Mappings</string>
</property> </property>

View File

@ -16,14 +16,14 @@
#include <map> #include <map>
#include <variant> #include <variant>
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 { extern KeyMaps g_keyMaps;
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 #endif

View File

@ -0,0 +1,11 @@
#include "legokeymaps.h"
#include <SDL3/SDL_scancode.h>
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}
};