mirror of
https://github.com/isledecomp/isle-portable.git
synced 2026-01-19 13:51:16 +00:00
Still suffering...but maybe getting closer
This commit is contained in:
parent
0c9d8d3228
commit
c5cb30bd86
@ -758,15 +758,24 @@ void CMainDialog::ForwardKeyChanged() {
|
|||||||
|
|
||||||
void CMainDialog::RebindInput(QPushButton* &button, SDL_Scancode &key)
|
void CMainDialog::RebindInput(QPushButton* &button, SDL_Scancode &key)
|
||||||
{
|
{
|
||||||
|
SDL_InitSubSystem(SDL_INIT_EVENTS);
|
||||||
button->setText(QString("Press a key..."));
|
button->setText(QString("Press a key..."));
|
||||||
currentKeyBind = &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<HWND>(inputWindow);
|
||||||
|
#else
|
||||||
|
hWnd = (HWND) SDL_GetPointerProperty(SDL_GetWindowProperties(inputWindow), SDL_PROP_WINDOW_WIN32_HWND_POINTER, NULL);
|
||||||
|
#endif
|
||||||
|
|
||||||
inputTimeout.setSingleShot(true);
|
inputTimeout.setSingleShot(true);
|
||||||
inputTimeout.setInterval(3 * 1000);
|
inputTimeout.setInterval(3 * 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_InitSubSystem(SDL_INIT_EVENTS);
|
SDL_ShowWindow(inputWindow);
|
||||||
sdlPoller.start();
|
sdlPoller.start();
|
||||||
inputTimeout.start();
|
inputTimeout.start();
|
||||||
}
|
}
|
||||||
@ -781,6 +790,8 @@ void CMainDialog::PollInputs()
|
|||||||
*currentKeyBind = sc;
|
*currentKeyBind = sc;
|
||||||
sdlPoller.disconnect();
|
sdlPoller.disconnect();
|
||||||
inputTimeout.disconnect();
|
inputTimeout.disconnect();
|
||||||
|
SDL_DestroyWindow(inputWindow);
|
||||||
|
m_modified = true;
|
||||||
UpdateInterface();
|
UpdateInterface();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -791,5 +802,6 @@ void CMainDialog::RebindTimeout()
|
|||||||
SDL_Log("Timeout");
|
SDL_Log("Timeout");
|
||||||
sdlPoller.disconnect();
|
sdlPoller.disconnect();
|
||||||
inputTimeout.disconnect();
|
inputTimeout.disconnect();
|
||||||
|
SDL_DestroyWindow(inputWindow);
|
||||||
UpdateInterface();
|
UpdateInterface();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,6 +5,12 @@
|
|||||||
#include "decomp.h"
|
#include "decomp.h"
|
||||||
#include "res/resource.h"
|
#include "res/resource.h"
|
||||||
|
|
||||||
|
#ifdef MINIWIN
|
||||||
|
#include "miniwin/d3d.h"
|
||||||
|
#else
|
||||||
|
#include <d3d.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
@ -33,6 +39,8 @@ class CMainDialog : public QDialog {
|
|||||||
QStringList assetPaths = QStringList();
|
QStringList assetPaths = QStringList();
|
||||||
Ui::MainDialog* m_ui = nullptr;
|
Ui::MainDialog* m_ui = nullptr;
|
||||||
SDL_DisplayMode** displayModes;
|
SDL_DisplayMode** displayModes;
|
||||||
|
SDL_Window* inputWindow;
|
||||||
|
HWND hWnd;
|
||||||
QTimer sdlPoller;
|
QTimer sdlPoller;
|
||||||
QTimer inputTimeout;
|
QTimer inputTimeout;
|
||||||
SDL_Scancode* currentKeyBind = nullptr;
|
SDL_Scancode* currentKeyBind = nullptr;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user