Added QT Hotkey configuration window.
This commit is contained in:
parent
1a99903933
commit
b2c094a6bf
|
@ -298,12 +298,14 @@ HEADERS += src/drivers/Qt/ConsoleWindow.h
|
||||||
HEADERS += src/drivers/Qt/ConsoleViewerGL.h
|
HEADERS += src/drivers/Qt/ConsoleViewerGL.h
|
||||||
HEADERS += src/drivers/Qt/ConsoleViewerSDL.h
|
HEADERS += src/drivers/Qt/ConsoleViewerSDL.h
|
||||||
HEADERS += src/drivers/Qt/GamePadConf.h
|
HEADERS += src/drivers/Qt/GamePadConf.h
|
||||||
|
HEADERS += src/drivers/Qt/HotKeyConf.h
|
||||||
HEADERS += src/drivers/Qt/ConsoleSoundConf.h
|
HEADERS += src/drivers/Qt/ConsoleSoundConf.h
|
||||||
SOURCES += src/drivers/Qt/main.cpp
|
SOURCES += src/drivers/Qt/main.cpp
|
||||||
SOURCES += src/drivers/Qt/ConsoleWindow.cpp
|
SOURCES += src/drivers/Qt/ConsoleWindow.cpp
|
||||||
SOURCES += src/drivers/Qt/ConsoleViewerGL.cpp
|
SOURCES += src/drivers/Qt/ConsoleViewerGL.cpp
|
||||||
SOURCES += src/drivers/Qt/ConsoleViewerSDL.cpp
|
SOURCES += src/drivers/Qt/ConsoleViewerSDL.cpp
|
||||||
SOURCES += src/drivers/Qt/GamePadConf.cpp
|
SOURCES += src/drivers/Qt/GamePadConf.cpp
|
||||||
|
SOURCES += src/drivers/Qt/HotKeyConf.cpp
|
||||||
SOURCES += src/drivers/Qt/ConsoleSoundConf.cpp
|
SOURCES += src/drivers/Qt/ConsoleSoundConf.cpp
|
||||||
SOURCES += src/drivers/Qt/fceuWrapper.cpp
|
SOURCES += src/drivers/Qt/fceuWrapper.cpp
|
||||||
SOURCES += src/drivers/Qt/config.cpp
|
SOURCES += src/drivers/Qt/config.cpp
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include "Qt/input.h"
|
#include "Qt/input.h"
|
||||||
#include "Qt/ConsoleWindow.h"
|
#include "Qt/ConsoleWindow.h"
|
||||||
#include "Qt/GamePadConf.h"
|
#include "Qt/GamePadConf.h"
|
||||||
|
#include "Qt/HotKeyConf.h"
|
||||||
#include "Qt/ConsoleSoundConf.h"
|
#include "Qt/ConsoleSoundConf.h"
|
||||||
#include "Qt/fceuWrapper.h"
|
#include "Qt/fceuWrapper.h"
|
||||||
#include "Qt/keyscan.h"
|
#include "Qt/keyscan.h"
|
||||||
|
@ -149,6 +150,14 @@ void consoleWin_t::createMainMenu(void)
|
||||||
|
|
||||||
optMenu->addAction(gameSoundConfig);
|
optMenu->addAction(gameSoundConfig);
|
||||||
|
|
||||||
|
// Options -> HotKey Config
|
||||||
|
hotkeyConfig = new QAction(tr("Hotkey Config"), this);
|
||||||
|
//hotkeyConfig->setShortcut( QKeySequence(tr("Ctrl+C")));
|
||||||
|
hotkeyConfig->setStatusTip(tr("Hotkey Configure"));
|
||||||
|
connect(hotkeyConfig, SIGNAL(triggered()), this, SLOT(openHotkeyConfWin(void)) );
|
||||||
|
|
||||||
|
optMenu->addAction(hotkeyConfig);
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
// Help
|
// Help
|
||||||
helpMenu = menuBar()->addMenu(tr("Help"));
|
helpMenu = menuBar()->addMenu(tr("Help"));
|
||||||
|
@ -259,7 +268,7 @@ void consoleWin_t::openGameSndConfWin(void)
|
||||||
{
|
{
|
||||||
ConsoleSndConfDialog_t *sndConfWin;
|
ConsoleSndConfDialog_t *sndConfWin;
|
||||||
|
|
||||||
printf("Open Sound Config Window\n");
|
//printf("Open Sound Config Window\n");
|
||||||
|
|
||||||
sndConfWin = new ConsoleSndConfDialog_t(this);
|
sndConfWin = new ConsoleSndConfDialog_t(this);
|
||||||
|
|
||||||
|
@ -268,7 +277,23 @@ void consoleWin_t::openGameSndConfWin(void)
|
||||||
|
|
||||||
delete sndConfWin;
|
delete sndConfWin;
|
||||||
|
|
||||||
printf("Sound Config Window Destroyed\n");
|
//printf("Sound Config Window Destroyed\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void consoleWin_t::openHotkeyConfWin(void)
|
||||||
|
{
|
||||||
|
HotKeyConfDialog_t *hkConfWin;
|
||||||
|
|
||||||
|
printf("Open Hot Key Config Window\n");
|
||||||
|
|
||||||
|
hkConfWin = new HotKeyConfDialog_t(this);
|
||||||
|
|
||||||
|
hkConfWin->show();
|
||||||
|
hkConfWin->exec();
|
||||||
|
|
||||||
|
delete hkConfWin;
|
||||||
|
|
||||||
|
printf("Hotkey Config Window Destroyed\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void consoleWin_t::aboutQPlot(void)
|
void consoleWin_t::aboutQPlot(void)
|
||||||
|
|
|
@ -56,6 +56,7 @@ class consoleWin_t : public QMainWindow
|
||||||
QAction *quitAct;
|
QAction *quitAct;
|
||||||
QAction *gamePadConfig;
|
QAction *gamePadConfig;
|
||||||
QAction *gameSoundConfig;
|
QAction *gameSoundConfig;
|
||||||
|
QAction *hotkeyConfig;
|
||||||
QAction *aboutAct;
|
QAction *aboutAct;
|
||||||
|
|
||||||
QTimer *gameTimer;
|
QTimer *gameTimer;
|
||||||
|
@ -78,6 +79,7 @@ class consoleWin_t : public QMainWindow
|
||||||
void aboutQPlot(void);
|
void aboutQPlot(void);
|
||||||
void openGamePadConfWin(void);
|
void openGamePadConfWin(void);
|
||||||
void openGameSndConfWin(void);
|
void openGameSndConfWin(void);
|
||||||
|
void openHotkeyConfWin(void);
|
||||||
void updatePeriodic(void);
|
void updatePeriodic(void);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,125 @@
|
||||||
|
// HotKeyConf.cpp
|
||||||
|
//
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include <SDL.h>
|
||||||
|
#include <QHeaderView>
|
||||||
|
|
||||||
|
#include "Qt/main.h"
|
||||||
|
#include "Qt/dface.h"
|
||||||
|
#include "Qt/input.h"
|
||||||
|
#include "Qt/config.h"
|
||||||
|
#include "Qt/keyscan.h"
|
||||||
|
#include "Qt/fceuWrapper.h"
|
||||||
|
#include "Qt/HotKeyConf.h"
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
HotKeyConfDialog_t::HotKeyConfDialog_t(QWidget *parent)
|
||||||
|
: QDialog( parent )
|
||||||
|
{
|
||||||
|
QVBoxLayout *mainLayout;
|
||||||
|
QTreeWidgetItem *item;
|
||||||
|
std::string prefix = "SDL.Hotkeys.";
|
||||||
|
int keycode;
|
||||||
|
|
||||||
|
setWindowTitle("Hotkey Configuration");
|
||||||
|
|
||||||
|
resize( 512, 512 );
|
||||||
|
|
||||||
|
mainLayout = new QVBoxLayout();
|
||||||
|
|
||||||
|
tree = new QTreeWidget();
|
||||||
|
|
||||||
|
tree->setColumnCount(2);
|
||||||
|
|
||||||
|
item = new QTreeWidgetItem();
|
||||||
|
item->setText( 0, QString::fromStdString( "Command" ) );
|
||||||
|
item->setText( 1, QString::fromStdString( "Key" ) );
|
||||||
|
item->setTextAlignment( 0, Qt::AlignLeft);
|
||||||
|
item->setTextAlignment( 1, Qt::AlignCenter);
|
||||||
|
|
||||||
|
tree->setHeaderItem( item );
|
||||||
|
|
||||||
|
tree->header()->setSectionResizeMode( QHeaderView::ResizeToContents );
|
||||||
|
|
||||||
|
for (int i=0; i<HK_MAX; i++)
|
||||||
|
{
|
||||||
|
std::string optionName = prefix + getHotkeyString(i);
|
||||||
|
|
||||||
|
g_config->getOption (optionName.c_str (), &keycode);
|
||||||
|
|
||||||
|
item = new QTreeWidgetItem();
|
||||||
|
|
||||||
|
item->setText( 0, QString::fromStdString( optionName ) );
|
||||||
|
item->setText( 1, QString::fromStdString( SDL_GetKeyName (keycode) ) );
|
||||||
|
|
||||||
|
item->setTextAlignment( 0, Qt::AlignLeft);
|
||||||
|
item->setTextAlignment( 1, Qt::AlignCenter);
|
||||||
|
|
||||||
|
tree->addTopLevelItem( item );
|
||||||
|
}
|
||||||
|
mainLayout->addWidget( tree );
|
||||||
|
|
||||||
|
setLayout( mainLayout );
|
||||||
|
}
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
HotKeyConfDialog_t::~HotKeyConfDialog_t(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void HotKeyConfDialog_t::closeWindow(void)
|
||||||
|
{
|
||||||
|
//printf("Close Window\n");
|
||||||
|
done(0);
|
||||||
|
}
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void HotKeyConfDialog_t::assignHotkey(QKeyEvent *event)
|
||||||
|
{
|
||||||
|
SDL_Keycode k = convQtKey2SDLKeyCode( (Qt::Key)event->key() );
|
||||||
|
|
||||||
|
if ( k != SDLK_UNKNOWN )
|
||||||
|
{
|
||||||
|
QList <QTreeWidgetItem *> l;
|
||||||
|
|
||||||
|
l = tree->selectedItems();
|
||||||
|
|
||||||
|
for (size_t i=0; i < l.size(); i++)
|
||||||
|
{
|
||||||
|
//int idx;
|
||||||
|
QString qs;
|
||||||
|
QTreeWidgetItem *item;
|
||||||
|
|
||||||
|
item = l.at(i);
|
||||||
|
|
||||||
|
//idx = tree->indexOfTopLevelItem( item );
|
||||||
|
|
||||||
|
qs = item->text(0);
|
||||||
|
|
||||||
|
g_config->setOption ( qs.toStdString(), k );
|
||||||
|
|
||||||
|
setHotKeys();
|
||||||
|
|
||||||
|
item->setText( 1, QString::fromStdString( SDL_GetKeyName (k) ) );
|
||||||
|
|
||||||
|
//printf("Hotkey Window Key Press: 0x%x item:%p\n '%s' : %i\n",
|
||||||
|
// k, item, qs.toStdString().c_str(), idx );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void HotKeyConfDialog_t::keyPressEvent(QKeyEvent *event)
|
||||||
|
{
|
||||||
|
//printf("Hotkey Window Key Press: 0x%x \n", event->key() );
|
||||||
|
assignHotkey( event );
|
||||||
|
}
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void HotKeyConfDialog_t::keyReleaseEvent(QKeyEvent *event)
|
||||||
|
{
|
||||||
|
//printf("Hotkey Window Key Release: 0x%x \n", event->key() );
|
||||||
|
assignHotkey( event );
|
||||||
|
}
|
||||||
|
//----------------------------------------------------------------------------
|
|
@ -0,0 +1,42 @@
|
||||||
|
// GamePadConf.h
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QComboBox>
|
||||||
|
#include <QCheckBox>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QFrame>
|
||||||
|
#include <QGroupBox>
|
||||||
|
#include <QTreeView>
|
||||||
|
#include <QTreeWidget>
|
||||||
|
|
||||||
|
#include "Qt/main.h"
|
||||||
|
|
||||||
|
class HotKeyConfDialog_t : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
HotKeyConfDialog_t(QWidget *parent = 0);
|
||||||
|
~HotKeyConfDialog_t(void);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void keyPressEvent(QKeyEvent *event);
|
||||||
|
void keyReleaseEvent(QKeyEvent *event);
|
||||||
|
void assignHotkey(QKeyEvent *event);
|
||||||
|
|
||||||
|
QTreeWidget *tree;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void closeWindow(void);
|
||||||
|
private slots:
|
||||||
|
|
||||||
|
};
|
|
@ -27,7 +27,7 @@ extern CFGSTRUCT InputConfig[];
|
||||||
extern ARGPSTRUCT InputArgs[];
|
extern ARGPSTRUCT InputArgs[];
|
||||||
extern int Hotkeys[];
|
extern int Hotkeys[];
|
||||||
void ParseGIInput(FCEUGI *GI);
|
void ParseGIInput(FCEUGI *GI);
|
||||||
void setHotKeys();
|
void setHotKeys(void);
|
||||||
int getKeyState( int k );
|
int getKeyState( int k );
|
||||||
int ButtonConfigBegin();
|
int ButtonConfigBegin();
|
||||||
void ButtonConfigEnd();
|
void ButtonConfigEnd();
|
||||||
|
|
Loading…
Reference in New Issue