summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
7228359)
Who knew that you could attach QActions to the main window? Of course,
you'd have to be a complete idiot not to see something so completely and
blatantly obvoius! :-P The preceeding was a cheap dig at the kind folks
who hang out on #qt on Freenode, who grudgingly provided that little
tidbit of information as if it was the most obvious thing in the world.
The upshot is that the toolbar is gone from top of the screen in full
screen mode now, and that should make lots of people happy. :-) Also,
the initial GUI implementation for multiple controller profiles is in.
More to follow.
#include "controllertab.h"
#include "controllerwidget.h"
#include "controllertab.h"
#include "controllerwidget.h"
#include "joystick.h"
#include "keygrabber.h"
#include "joystick.h"
#include "keygrabber.h"
-ControllerTab::ControllerTab(QWidget * parent/*= 0*/): QWidget(parent)
+ControllerTab::ControllerTab(QWidget * parent/*= 0*/): QWidget(parent),
+ label(new QLabel(tr("Controller:"))),
+ profile(new QComboBox(this)),
+ redefineAll(new QPushButton(tr("Define All Inputs"))),
+ controllerWidget(new ControllerWidget(this))
- controllerWidget = new ControllerWidget(this);
- redefineAll = new QPushButton(tr("Define All Inputs"));
-
QVBoxLayout * layout = new QVBoxLayout;
QVBoxLayout * layout = new QVBoxLayout;
+ QHBoxLayout * top = new QHBoxLayout;
+ layout->addLayout(top);
+ top->addWidget(label);
+ top->addWidget(profile, 0, Qt::AlignLeft);
layout->addWidget(controllerWidget);
layout->addWidget(controllerWidget);
- layout->addWidget(redefineAll);
+ layout->addWidget(redefineAll, 0, Qt::AlignHCenter);
+// layout->setFixedWidth(label->width());
+// layout->setSizeConstraint(QLayout::SetFixedSize);
+// top->setSizeConstraint(QLayout::SetFixedSize);
+//printf("cw width = %i, label width = %i (min=%i, sizehint=%i)\n", controllerWidget->width(), label->width(), label->minimumWidth(), label->sizeHint().width());
+ // This is ugly, ugly, ugly. But it works. :-P It's a shame that Qt's
+ // layout system doesn't seem to allow for a nicer way to handle this.
+// profile->setFixedWidth(controllerWidget->sizeHint().width() - label->sizeHint().width());
+ setFixedWidth(sizeHint().width());
connect(redefineAll, SIGNAL(clicked()), this, SLOT(DefineAllKeys()));
connect(redefineAll, SIGNAL(clicked()), this, SLOT(DefineAllKeys()));
+
+//this is the default. :-/ need to set it somewhere else i guess...
+// profile->setSizeAdjustPolicy(QComboBox::AdjustToContentsOnFirstShow);
+ profile->addItem(tr("Keyboard"));
+
+ for(int i=0; i<Gamepad::numJoysticks; i++)
+ profile->addItem(Gamepad::GetJoystickName(i));
+//QSize ControllerTab::sizeHint(void) const
+//{
+// return
+//}
+
+
void ControllerTab::DefineAllKeys(void)
{
// char jagButtonName[21][10] = { "Up", "Down", "Left", "Right",
void ControllerTab::DefineAllKeys(void)
{
// char jagButtonName[21][10] = { "Up", "Down", "Left", "Right",
public:
ControllerTab(QWidget * parent = 0);
~ControllerTab();
public:
ControllerTab(QWidget * parent = 0);
~ControllerTab();
+// QSize sizeHint(void) const;
protected slots:
void DefineAllKeys(void);
private:
protected slots:
void DefineAllKeys(void);
private:
+ QLabel * label;
+ QComboBox * profile;
QPushButton * redefineAll;
public:
QPushButton * redefineAll;
public:
widgetSize += QSize(4, 4);
// We want to know when the mouse is moving over our widget...
setMouseTracking(true);
widgetSize += QSize(4, 4);
// We want to know when the mouse is moving over our widget...
setMouseTracking(true);
+//nope
+//setFixedSize(widgetSize);
// Class member initialization
/*static*/ int Gamepad::numJoysticks = 0;
/*static*/ SDL_Joystick * Gamepad::pad[8];
// Class member initialization
/*static*/ int Gamepad::numJoysticks = 0;
/*static*/ SDL_Joystick * Gamepad::pad[8];
+/*static*/ const char * Gamepad::padName[8];
/*static*/ int Gamepad::numButtons[8];
/*static*/ int Gamepad::numHats[8];
/*static*/ int Gamepad::numAxes[8];
/*static*/ int Gamepad::numButtons[8];
/*static*/ int Gamepad::numHats[8];
/*static*/ int Gamepad::numAxes[8];
for(int i=0; i<numJoysticks; i++)
{
pad[i] = SDL_JoystickOpen(i);
for(int i=0; i<numJoysticks; i++)
{
pad[i] = SDL_JoystickOpen(i);
+ padName[i] = SDL_JoystickName(i);
numButtons[i] = numHats[i] = 0;
if (pad[i])
numButtons[i] = numHats[i] = 0;
if (pad[i])
+const char * Gamepad::GetJoystickName(int joystickID)
+{
+ // Sanity check
+ if (joystickID >= 8)
+ return NULL;
+
+ return padName[joystickID];
+}
+
+
bool Gamepad::GetState(int joystickID, int buttonID)
{
uint8_t hatMask[8] = { 1, 2, 4, 8, 16, 32, 64, 128 };
bool Gamepad::GetState(int joystickID, int buttonID)
{
uint8_t hatMask[8] = { 1, 2, 4, 8, 16, 32, 64, 128 };
// Class methods...
static void AllocateJoysticks(void);
static void DeallocateJoysticks(void);
// Class methods...
static void AllocateJoysticks(void);
static void DeallocateJoysticks(void);
+ static const char * GetJoystickName(int joystickID);
static bool GetState(int joystickID, int buttonID);
static int CheckButtonPressed(void);
static int GetButtonID(void);
static bool GetState(int joystickID, int buttonID);
static int CheckButtonPressed(void);
static int GetButtonID(void);
// Support up to 8 gamepads
static int numJoysticks;
static SDL_Joystick * pad[8];
// Support up to 8 gamepads
static int numJoysticks;
static SDL_Joystick * pad[8];
+ static const char * padName[8];
static int numButtons[8];
static int numAxes[8];
static int numHats[8];
static int numButtons[8];
static int numAxes[8];
static int numHats[8];
-//void GLWidget::HideMouseIfTimedOut(void)
void GLWidget::HandleMouseHiding(void)
{
// Mouse watchdog timer handling. Basically, if the timeout value is
void GLWidget::HandleMouseHiding(void)
{
// Mouse watchdog timer handling. Basically, if the timeout value is
- // greater than zero, decrement it. Otherwise, check for zero, if so,
- // then hide the mouse and set the hideMouseTimeout value to -1 to
- // signal that the mouse has been hidden.
+ // greater than zero, decrement it. Otherwise, check for zero, if so, then
+ // hide the mouse and set the hideMouseTimeout value to -1 to signal that
+ // the mouse has been hidden.
if (hideMouseTimeout > 0)
hideMouseTimeout--;
else if (hideMouseTimeout == 0)
{
hideMouseTimeout--;
qApp->setOverrideCursor(Qt::BlankCursor);
if (hideMouseTimeout > 0)
hideMouseTimeout--;
else if (hideMouseTimeout == 0)
{
hideMouseTimeout--;
qApp->setOverrideCursor(Qt::BlankCursor);
-//printf("timer: hideMouseTimeout = %i, mouse hidden\n", hideMouseTimeout);
GLWidget(QWidget * parent = 0);
~GLWidget();
GLWidget(QWidget * parent = 0);
~GLWidget();
-// void HideMouseIfTimedOut(void);
void HandleMouseHiding(void);
void CheckAndRestoreMouseCursor(void);
// QSize minimumSizeHint() const;
void HandleMouseHiding(void);
void CheckAndRestoreMouseCursor(void);
// QSize minimumSizeHint() const;
showUntunedTankCircuit(true), cartridgeLoaded(false), CDActive(false),
pauseForFileSelector(false), loadAndGo(autoRun), plzDontKillMyComputer(false)
{
showUntunedTankCircuit(true), cartridgeLoaded(false), CDActive(false),
pauseForFileSelector(false), loadAndGo(autoRun), plzDontKillMyComputer(false)
{
for(int i=0; i<8; i++)
keyHeld[i] = false;
for(int i=0; i<8; i++)
keyHeld[i] = false;
// quitAppAct->setShortcuts(QKeySequence::Quit);
// quitAppAct->setShortcut(QKeySequence(tr("Alt+x")));
quitAppAct->setShortcut(QKeySequence(tr("Ctrl+q")));
// quitAppAct->setShortcuts(QKeySequence::Quit);
// quitAppAct->setShortcut(QKeySequence(tr("Alt+x")));
quitAppAct->setShortcut(QKeySequence(tr("Ctrl+q")));
+ quitAppAct->setShortcutContext(Qt::ApplicationShortcut);
quitAppAct->setStatusTip(tr("Quit Virtual Jaguar"));
connect(quitAppAct, SIGNAL(triggered()), this, SLOT(close()));
quitAppAct->setStatusTip(tr("Quit Virtual Jaguar"));
connect(quitAppAct, SIGNAL(triggered()), this, SLOT(close()));
pauseAct->setCheckable(true);
pauseAct->setDisabled(true);
pauseAct->setShortcut(QKeySequence(tr("Esc")));
pauseAct->setCheckable(true);
pauseAct->setDisabled(true);
pauseAct->setShortcut(QKeySequence(tr("Esc")));
+ pauseAct->setShortcutContext(Qt::ApplicationShortcut);
connect(pauseAct, SIGNAL(triggered()), this, SLOT(ToggleRunState()));
zoomActs = new QActionGroup(this);
connect(pauseAct, SIGNAL(triggered()), this, SLOT(ToggleRunState()));
zoomActs = new QActionGroup(this);
filePickAct = new QAction(QIcon(":/res/software.png"), tr("&Insert Cartridge..."), this);
filePickAct->setStatusTip(tr("Insert a cartridge into Virtual Jaguar"));
filePickAct->setShortcut(QKeySequence(tr("Ctrl+i")));
filePickAct = new QAction(QIcon(":/res/software.png"), tr("&Insert Cartridge..."), this);
filePickAct->setStatusTip(tr("Insert a cartridge into Virtual Jaguar"));
filePickAct->setShortcut(QKeySequence(tr("Ctrl+i")));
+ filePickAct->setShortcutContext(Qt::ApplicationShortcut);
connect(filePickAct, SIGNAL(triggered()), this, SLOT(InsertCart()));
configAct = new QAction(QIcon(":/res/wrench.png"), tr("&Configure"), this);
configAct->setStatusTip(tr("Configure options for Virtual Jaguar"));
configAct->setShortcut(QKeySequence(tr("Ctrl+c")));
connect(filePickAct, SIGNAL(triggered()), this, SLOT(InsertCart()));
configAct = new QAction(QIcon(":/res/wrench.png"), tr("&Configure"), this);
configAct->setStatusTip(tr("Configure options for Virtual Jaguar"));
configAct->setShortcut(QKeySequence(tr("Ctrl+c")));
+ configAct->setShortcutContext(Qt::ApplicationShortcut);
connect(configAct, SIGNAL(triggered()), this, SLOT(Configure()));
useCDAct = new QAction(QIcon(":/res/compact-disc.png"), tr("&Use CD Unit"), this);
connect(configAct, SIGNAL(triggered()), this, SLOT(Configure()));
useCDAct = new QAction(QIcon(":/res/compact-disc.png"), tr("&Use CD Unit"), this);
frameAdvanceAct = new QAction(QIcon(":/res/frame-advance.png"), tr("&Frame Advance"), this);
frameAdvanceAct->setShortcut(QKeySequence(tr("F7")));
frameAdvanceAct = new QAction(QIcon(":/res/frame-advance.png"), tr("&Frame Advance"), this);
frameAdvanceAct->setShortcut(QKeySequence(tr("F7")));
+ frameAdvanceAct->setShortcutContext(Qt::ApplicationShortcut);
frameAdvanceAct->setDisabled(true);
connect(frameAdvanceAct, SIGNAL(triggered()), this, SLOT(FrameAdvance()));
fullScreenAct = new QAction(QIcon(":/res/fullscreen.png"), tr("F&ull Screen"), this);
fullScreenAct->setShortcut(QKeySequence(tr("F9")));
frameAdvanceAct->setDisabled(true);
connect(frameAdvanceAct, SIGNAL(triggered()), this, SLOT(FrameAdvance()));
fullScreenAct = new QAction(QIcon(":/res/fullscreen.png"), tr("F&ull Screen"), this);
fullScreenAct->setShortcut(QKeySequence(tr("F9")));
+ fullScreenAct->setShortcutContext(Qt::ApplicationShortcut);
fullScreenAct->setCheckable(true);
connect(fullScreenAct, SIGNAL(triggered()), this, SLOT(ToggleFullScreen()));
fullScreenAct->setCheckable(true);
connect(fullScreenAct, SIGNAL(triggered()), this, SLOT(ToggleFullScreen()));
debugbar->addAction(riscDasmBrowseAct);
}
debugbar->addAction(riscDasmBrowseAct);
}
+ // Add actions to the main window, as hiding widgets with them
+ // disables them :-P
+ addAction(fullScreenAct);
+ addAction(quitAppAct);
+ addAction(configAct);
+ addAction(pauseAct);
+ addAction(filePickAct);
+ addAction(frameAdvanceAct);
+
// Create status bar
statusBar()->showMessage(tr("Ready"));
// Create status bar
statusBar()->showMessage(tr("Ready"));
// Otherwise, run the Jaguar simulation
HandleGamepads();
JaguarExecuteNew();
// Otherwise, run the Jaguar simulation
HandleGamepads();
JaguarExecuteNew();
-// videoWidget->HideMouseIfTimedOut();
videoWidget->HandleMouseHiding();
}
videoWidget->HandleMouseHiding();
}
pauseAct->setDisabled(true);
showUntunedTankCircuit = true;
DACPauseAudioThread();
pauseAct->setDisabled(true);
showUntunedTankCircuit = true;
DACPauseAudioThread();
- // This is just in case the ROM we were playing was in a narrow or wide field mode,
- // so the untuned tank sim doesn't look wrong. :-)
+ // This is just in case the ROM we were playing was in a narrow or wide
+ // field mode, so the untuned tank sim doesn't look wrong. :-)
TOMReset();
if (plzDontKillMyComputer)
{
TOMReset();
if (plzDontKillMyComputer)
{
- // We have to do it line by line, because the texture pitch is not the
- // same as the picture buffer's pitch.
+ // We have to do it line by line, because the texture pitch is not
+ // the same as the picture buffer's pitch.
for(uint32_t y=0; y<videoWidget->rasterHeight; y++)
{
memcpy(videoWidget->buffer + (y * videoWidget->textureWidth), testPattern + (y * VIRTUAL_SCREEN_WIDTH), VIRTUAL_SCREEN_WIDTH * sizeof(uint32_t));
for(uint32_t y=0; y<videoWidget->rasterHeight; y++)
{
memcpy(videoWidget->buffer + (y * videoWidget->textureWidth), testPattern + (y * VIRTUAL_SCREEN_WIDTH), VIRTUAL_SCREEN_WIDTH * sizeof(uint32_t));
if (CDActive)
{
// Should check for cartridgeLoaded here as well...!
if (CDActive)
{
// Should check for cartridgeLoaded here as well...!
-// We can clear it when toggling CDActive on, so that when we power cycle it does the
-// expected thing. Otherwise, if we use the file picker to insert a cart, we expect
-// to run the cart! Maybe have a RemoveCart function that only works if the CD unit
-// is active?
+// We can clear it when toggling CDActive on, so that when we power cycle it
+// does the expected thing. Otherwise, if we use the file picker to insert a
+// cart, we expect to run the cart! Maybe have a RemoveCart function that only
+// works if the CD unit is active?
setWindowTitle(QString("Virtual Jaguar " VJ_RELEASE_VERSION
" - Now playing: Jaguar CD"));
}
setWindowTitle(QString("Virtual Jaguar " VJ_RELEASE_VERSION
" - Now playing: Jaguar CD"));
}
mainWinPosition = pos();
menuBar()->hide();
statusBar()->hide();
mainWinPosition = pos();
menuBar()->hide();
statusBar()->hide();
- x1Act->setDisabled(true);
- x2Act->setDisabled(true);
- x3Act->setDisabled(true);
+ toolbar->hide();
+
+ if (debugbar)
+ debugbar->hide();
+
showFullScreen();
// This is needed because the fullscreen may happen on a different
// screen than screen 0:
int screenNum = QApplication::desktop()->screenNumber(videoWidget);
showFullScreen();
// This is needed because the fullscreen may happen on a different
// screen than screen 0:
int screenNum = QApplication::desktop()->screenNumber(videoWidget);
- QRect r = QApplication::desktop()->availableGeometry(screenNum);
+// QRect r = QApplication::desktop()->availableGeometry(screenNum);
+ QRect r = QApplication::desktop()->screenGeometry(screenNum);
double targetWidth = (double)VIRTUAL_SCREEN_WIDTH,
targetHeight = (double)(vjs.hardwareTypeNTSC ? VIRTUAL_SCREEN_HEIGHT_NTSC : VIRTUAL_SCREEN_HEIGHT_PAL);
double aspectRatio = targetWidth / targetHeight;
double targetWidth = (double)VIRTUAL_SCREEN_WIDTH,
targetHeight = (double)(vjs.hardwareTypeNTSC ? VIRTUAL_SCREEN_HEIGHT_NTSC : VIRTUAL_SCREEN_HEIGHT_PAL);
double aspectRatio = targetWidth / targetHeight;
// Reset the video widget to windowed mode
videoWidget->offset = 0;
videoWidget->fullscreen = false;
// Reset the video widget to windowed mode
videoWidget->offset = 0;
videoWidget->fullscreen = false;
- x1Act->setDisabled(false);
- x2Act->setDisabled(false);
- x3Act->setDisabled(false);
menuBar()->show();
statusBar()->show();
menuBar()->show();
statusBar()->show();
+ toolbar->show();
+
+ if (debugbar)
+ debugbar->show();
+
showNormal();
ResizeMainWindow();
move(mainWinPosition);
}
showNormal();
ResizeMainWindow();
move(mainWinPosition);
}
-
- // For some reason, this doesn't work: If the emu is paused, toggling from
- // fullscreen to windowed (& vice versa) shows a white screen.
- // (It was the ResizeGL() function in GLWidget: it was being called too
- // much, causing the buffer to be deleted, remade & cleared.)
-// videoWidget->updateGL();