Merge pull request #587 from Xele02/qt_work

[Qt-desktop] Add support to USB gamePad
This commit is contained in:
Henrik Rydgård committed 2013-02-03 22:49:49 -08:00
commit 1a315921ff
20 files changed
+996 -12

No files matched your search

+19 -10
View File
@@ -3,7 +3,7 @@ QT += core gui opengl
include(Settings.pri)
linux {
CONFIG += mobility
CONFIG += mobility link_pkgconfig
MOBILITY += multimedia
}
else {
@@ -17,14 +17,18 @@ blackberry: LIBS += -L. -lCore -lCommon -lNative -lscreen -lsocket -lstdc++
win32: LIBS += -L. -lCore -lCommon -lNative -lwinmm -lws2_32 -lkernel32 -luser32 -lgdi32 -lshell32 -lcomctl32 -ldsound -lxinput
linux: LIBS += -L. -lCore -lCommon -lNative
linux: PRE_TARGETDEPS += ./libCommon.a ./libCore.a ./libNative.a
linux {
LIBS += -L. -lCore -lCommon -lNative
PRE_TARGETDEPS += ./libCommon.a ./libCore.a ./libNative.a
packagesExist(sdl) {
DEFINES += QT_HAS_SDL
PKGCONFIG += sdl
}
}
# Main
SOURCES += ../native/base/QtMain.cpp \
qkeyedit.cpp
HEADERS += ../native/base/QtMain.h \
qkeyedit.h
SOURCES += ../native/base/QtMain.cpp
HEADERS += ../native/base/QtMain.h
# Native
SOURCES += ../android/jni/EmuScreen.cpp \
@@ -44,7 +48,9 @@ linux:!mobile_platform {
qtemugl.cpp \
ctrldisasmview.cpp \
ctrlregisterlist.cpp \
controls.cpp
controls.cpp \
qkeyedit.cpp \
gamepaddialog.cpp
HEADERS += mainwindow.h \
debugger_disasm.h \
EmuThread.h \
@@ -52,7 +58,9 @@ linux:!mobile_platform {
qtemugl.h \
ctrldisasmview.h \
ctrlregisterlist.h \
controls.h
controls.h \
qkeyedit.h \
gamepaddialog.h
} else {
SOURCES += ../android/jni/NativeApp.cpp
}
@@ -74,7 +82,8 @@ symbian {
linux:!mobile_platform {
FORMS += mainwindow.ui \
debugger_disasm.ui \
controls.ui
controls.ui\
gamepaddialog.ui
RESOURCES += \
resources.qrc
+378
View File
@@ -0,0 +1,378 @@
#include "gamepaddialog.h"
#include "ui_gamepaddialog.h"
#include <QTimer>
#include "Core/Config.h"
// Input
struct GamePadInfo
{
int mapping_type; // 0 : pad button, 1 : pad axis, 2 : pad Hats
int mapping_in;
int mapping_sign;
QString ViewLabelName;
QString Name;
};
// Initial values are PS3 controller
GamePadInfo GamepadPadMapping[] = {
{0, 14, 0, "Prev_X", "Cross"}, //A
{0, 13, 0, "Prev_O", "Circle"}, //B
{0, 15, 0, "Prev_S", "Square"}, //X
{0, 12, 0, "Prev_T", "Triangle"}, //Y
{0, 10, 0, "Prev_LT", "Left Trigger"}, //LBUMPER
{0, 11, 0, "Prev_RT", "Right Trigger"}, //RBUMPER
{0, 3, 0, "Prev_Start", "Start"}, //START
{0, 0, 0, "Prev_Select", "Select"}, //SELECT
{0, 4, 0, "Prev_Up", "Up"}, //UP
{0, 6, 0, "Prev_Down", "Down"}, //DOWN
{0, 7, 0, "Prev_Left", "Left"}, //LEFT
{0, 5, 0, "Prev_Right", "Right"}, //RIGHT
{0, 0, 0, ""}, //MENU (event)
{0, 16, 0, "Prev_Home", "Home"}, //BACK
// Special case for analog stick
{1, 0, -1, "Prev_ALeft", "Stick left"},
{1, 0, 1, "Prev_ARight", "Stick right"},
{1, 1, -1, "Prev_AUp", "Stick up"},
{1, 1, 1, "Prev_ADown", "Stick bottom"}
};
// id for mapping in config start at offset 200 to not get over key mapping
const int configOffset = 200;
GamePadDialog::GamePadDialog(InputState* state, QWidget *parent) :
QDialog(parent),
ui(new Ui::GamePadDialog),
m_inputState(state),
#if QT_HAS_SDL
m_joystick(0),
#endif
m_isInit(false)
{
ui->setupUi(this);
SetViewMode();
#if QT_HAS_SDL
SDL_Init(SDL_INIT_JOYSTICK);
#endif
m_isInit = true;
data_timer = new QTimer();
data_timer->setInterval(50);
connect(data_timer,SIGNAL(timeout()),this,SLOT(pollJoystick()));
data_timer->start();
for(int i=0;i<18;i++)
{
QLabel* labelPreview = findChild<QLabel*>(GamepadPadMapping[i].ViewLabelName);
if(labelPreview)
{
labelPreview->setVisible(false);
}
if(g_Config.iMappingMap.find(i+configOffset) != g_Config.iMappingMap.end())
{
GetMappingFromInt(g_Config.iMappingMap[i+configOffset],
GamepadPadMapping[i].mapping_in,
GamepadPadMapping[i].mapping_type,
GamepadPadMapping[i].mapping_sign);
}
}
on_refreshListBtn_clicked();
}
GamePadDialog::~GamePadDialog()
{
data_timer->stop();
delete data_timer;
#if QT_HAS_SDL
if(m_joystick)
SDL_JoystickClose(m_joystick);
SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
#endif
delete ui;
}
void GamePadDialog::on_refreshListBtn_clicked()
{
#if QT_HAS_SDL
if(m_joystick)
{
SDL_JoystickClose(m_joystick);
ui->JoyName->setText("<b>No GamePad</b>");
m_joystick = 0;
}
SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
SDL_Init(SDL_INIT_JOYSTICK);
int numJoy = SDL_NumJoysticks();
ui->GamePadList->clear();
for(int i = 0; i < numJoy; i++)
{
QListWidgetItem* item = new QListWidgetItem();
QString padName = SDL_JoystickName(i);
if(padName == "") padName = "<b>Unknown GamePad</b>";
item->setText(padName);
item->setData(Qt::UserRole,i);
ui->GamePadList->addItem(item);
}
if(numJoy > 0)
{
ui->GamePadList->setCurrentRow(0);
on_SelectPadBtn_clicked();
}
#endif
}
void GamePadDialog::pollJoystick()
{
#if QT_HAS_SDL
if(!m_joystick)
return;
SDL_JoystickUpdate();
// Update buttons state
for(int i=0;i<14;i++)
{
float val = 0;
if(GamepadPadMapping[i].mapping_type == 0)
val = SDL_JoystickGetButton(m_joystick,GamepadPadMapping[i].mapping_in);
else if(GamepadPadMapping[i].mapping_type == 1)
{
val = SDL_JoystickGetAxis(m_joystick,GamepadPadMapping[i].mapping_in);
if(val*GamepadPadMapping[i].mapping_sign > 16384) val = 1;
else val = 0;
}
else if(GamepadPadMapping[i].mapping_type == 2)
val = SDL_JoystickGetHat(m_joystick,GamepadPadMapping[i].mapping_in);
QLabel* labelPreview = findChild<QLabel*>(GamepadPadMapping[i].ViewLabelName);
if(labelPreview)
{
labelPreview->setVisible(val != 0);
}
if(val)
{
m_inputState->pad_buttons |= (1<<i);
}
else
{
m_inputState->pad_buttons &= ~(1<<i);
}
}
// Update analog stick
m_inputState->pad_lstick_x = 0;
m_inputState->pad_lstick_y = 0;
for(int i = 14; i < 18; i++)
{
float val = 0;
if(GamepadPadMapping[i].mapping_type == 0)
val = SDL_JoystickGetButton(m_joystick,GamepadPadMapping[i].mapping_in);
else if(GamepadPadMapping[i].mapping_type == 1)
{
val = SDL_JoystickGetAxis(m_joystick,GamepadPadMapping[i].mapping_in);
if((val <= 0 && GamepadPadMapping[i].mapping_sign < 0) || (val >= 0 && GamepadPadMapping[i].mapping_sign > 0))
val = abs(val) * 1.0f / 32767;
else
val = 0;
}
else if(GamepadPadMapping[i].mapping_type == 2)
val = SDL_JoystickGetHat(m_joystick,GamepadPadMapping[i].mapping_in);
QLabel* labelPreview = findChild<QLabel*>(GamepadPadMapping[i].ViewLabelName);
if(labelPreview)
{
labelPreview->setVisible(val != 0);
}
switch(i)
{
case 14:
m_inputState->pad_lstick_x -= val;
break;
case 15:
m_inputState->pad_lstick_x += val;
break;
case 16:
m_inputState->pad_lstick_y -= val;
break;
default:
m_inputState->pad_lstick_y += val;
break;
}
}
if(isVisible())
{
for(int i = 0; i < ui->padValues->topLevelItemCount(); i++)
{
QTreeWidgetItem* item = ui->padValues->topLevelItem(i);
for(int j = 0; j < item->childCount(); j++)
{
QTreeWidgetItem* item2 = item->child(j);
if(item2->data(0,Qt::UserRole).toInt() == 0)
{
item2->setText(1,QVariant(SDL_JoystickGetButton(m_joystick,item2->data(0,Qt::UserRole+1).toInt())).toString());
}
else if(item2->data(0,Qt::UserRole).toInt() == 1)
{
int val = SDL_JoystickGetAxis(m_joystick,item2->data(0,Qt::UserRole+1).toInt());
if((val <= 0 && item2->data(0,Qt::UserRole+2).toInt() < 0) || (val >= 0 && item2->data(0,Qt::UserRole+2).toInt() > 0))
item2->setText(1,QVariant(val).toString());
}
else if(item2->data(0,Qt::UserRole).toInt() == 2)
{
item2->setText(1,QVariant(SDL_JoystickGetHat(m_joystick,item2->data(0,Qt::UserRole+1).toInt())).toString());
}
}
}
}
#endif
}
void GamePadDialog::on_SelectPadBtn_clicked()
{
#if QT_HAS_SDL
int selectedJoy = -1;
if(ui->GamePadList->currentItem() == 0)
{
return;
}
selectedJoy = ui->GamePadList->currentItem()->data(Qt::UserRole).toInt();
m_joyId = selectedJoy;
m_joystick = SDL_JoystickOpen(selectedJoy);
ui->padValues->clear();
ui->padValues->setColumnCount(3);
ui->padValues->setColumnWidth(0,100);
ui->padValues->setColumnWidth(1,50);
ui->padValues->setColumnWidth(2,50);
ui->comboPadInput->clear();
ui->comboPSPButton->clear();
QTreeWidgetItem* buttonItem = new QTreeWidgetItem();
buttonItem->setText(0,"Buttons");
ui->padValues->addTopLevelItem(buttonItem);
for(int i = 0; i < SDL_JoystickNumButtons(m_joystick); i++)
{
QTreeWidgetItem* item = new QTreeWidgetItem();
item->setText(0,QVariant(i).toString());
item->setText(1,QVariant(0).toString());
item->setData(0, Qt::UserRole,0);
item->setData(0, Qt::UserRole+1,i);
item->setData(0, Qt::UserRole+2,0);
buttonItem->addChild(item);
int id = i << 8;
ui->comboPadInput->addItem("Button "+QVariant(i).toString(),GetIntFromMapping(i,0,0));
}
QTreeWidgetItem* axesItem = new QTreeWidgetItem();
axesItem->setText(0,"Axes");
ui->padValues->addTopLevelItem(axesItem);
for(int i = 0; i < SDL_JoystickNumAxes(m_joystick); i++)
{
QTreeWidgetItem* item = new QTreeWidgetItem();
item->setText(0,QVariant(i).toString()+" Neg");
item->setText(1,QVariant(0).toString());
item->setData(0, Qt::UserRole,1);
item->setData(0, Qt::UserRole+1,i);
item->setData(0, Qt::UserRole+2,-1);
axesItem->addChild(item);
ui->comboPadInput->addItem("Axes "+QVariant(i).toString()+" Neg",GetIntFromMapping(i,1,-1));
item = new QTreeWidgetItem();
item->setText(0,QVariant(i).toString()+" Pos");
item->setText(1,QVariant(0).toString());
item->setData(0, Qt::UserRole,1);
item->setData(0, Qt::UserRole+1,i);
item->setData(0, Qt::UserRole+2,1);
axesItem->addChild(item);
ui->comboPadInput->addItem("Axes "+QVariant(i).toString()+" Pos",GetIntFromMapping(i,1,1));
}
QTreeWidgetItem* hatsItem = new QTreeWidgetItem();
hatsItem->setText(0,"Hats");
ui->padValues->addTopLevelItem(hatsItem);
for(int i = 0; i < SDL_JoystickNumHats(m_joystick); i++)
{
QTreeWidgetItem* item = new QTreeWidgetItem();
item->setText(0,QVariant(i).toString());
item->setText(1,QVariant(0).toString());
item->setData(0, Qt::UserRole,2);
item->setData(0, Qt::UserRole+1,i);
item->setData(0, Qt::UserRole+2,0);
hatsItem->addChild(item);
ui->comboPadInput->addItem("Button "+QVariant(i).toString(),GetIntFromMapping(i,2,0));
}
for(int i = 0; i < 18; i++)
{
if(GamepadPadMapping[i].Name != "")
{
ui->comboPSPButton->addItem(GamepadPadMapping[i].Name,i);
}
}
SetViewMode();
#endif
}
void GamePadDialog::SetViewMode()
{
#if QT_HAS_SDL
ui->buttonBox->setEnabled(true);
ui->refreshListBtn->setEnabled(true);
ui->SelectPadBtn->setEnabled(true);
if(!m_joystick)
ui->JoyName->setText("<b>No GamePad</b>");
else
ui->JoyName->setText(QString("<b>Current gamepad : ")+SDL_JoystickName(m_joyId)+"</b>");
#endif
}
void GamePadDialog::on_AssignBtn_clicked()
{
int idxPad = ui->comboPadInput->currentIndex();
int idxPSP = ui->comboPSPButton->currentIndex();
int pspButton = ui->comboPSPButton->itemData(idxPSP).toInt();
int padInfo = ui->comboPadInput->itemData(idxPad).toInt();
GetMappingFromInt(padInfo, GamepadPadMapping[pspButton].mapping_in,
GamepadPadMapping[pspButton].mapping_type,
GamepadPadMapping[pspButton].mapping_sign);
}
int GamePadDialog::GetIntFromMapping(int inputId, int type, int sign)
{
sign = (sign == -1 ? 1 : (sign == 1 ? 2 : 0));
return inputId << 8 | sign << 2 | type;
}
void GamePadDialog::GetMappingFromInt(int padInfo, int& inputId, int& type, int& sign)
{
inputId = padInfo >> 8;
type = padInfo & 0x3;
sign = (padInfo >> 2) & 0x3;
sign = (sign == 1 ? -1 : (sign == 2 ? 1 : 0));
}
void GamePadDialog::on_buttonBox_accepted()
{
for(int i = 0; i < 18; i++)
{
g_Config.iMappingMap[i+configOffset] = GetIntFromMapping(GamepadPadMapping[i].mapping_in,
GamepadPadMapping[i].mapping_type,
GamepadPadMapping[i].mapping_sign);
}
}
+51
View File
@@ -0,0 +1,51 @@
#ifndef GAMEPADDIALOG_H
#define GAMEPADDIALOG_H
#include <QDialog>
#if QT_HAS_SDL
#include "SDL/SDL.h"
#endif
#include "native/input/input_state.h"
namespace Ui {
class GamePadDialog;
}
class QTimer;
class GamePadDialog : public QDialog
{
Q_OBJECT
public:
explicit GamePadDialog(InputState* inputState, QWidget *parent = 0);
~GamePadDialog();
void SetViewMode();
void SetCalibMode();
void CalibNextButton();
private slots:
void on_refreshListBtn_clicked();
void on_SelectPadBtn_clicked();
void pollJoystick();
void on_AssignBtn_clicked();
void on_buttonBox_accepted();
private:
int GetIntFromMapping(int inputId, int type, int sign);
void GetMappingFromInt(int value, int &inputId, int &type, int &sign);
Ui::GamePadDialog *ui;
#if QT_HAS_SDL
SDL_Joystick* m_joystick;
int m_joyId;
#endif
InputState* m_inputState;
bool m_isInit;
QTimer *data_timer;
};
#endif // GAMEPADDIALOG_H
+512
View File
@@ -0,0 +1,512 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GamePadDialog</class>
<widget class="QDialog" name="GamePadDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>850</width>
<height>501</height>
</rect>
</property>
<property name="windowTitle">
<string>Gamepad Configuration</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>GamePad List</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QListWidget" name="GamePadList"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="refreshListBtn">
<property name="text">
<string>Refresh</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="SelectPadBtn">
<property name="text">
<string>Select</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Gamepad Values :</string>
</property>
</widget>
</item>
<item>
<widget class="QTreeWidget" name="padValues">
<attribute name="headerVisible">
<bool>false</bool>
</attribute>
<column>
<property name="text">
<string notr="true">1</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="JoyName">
<property name="text">
<string>TextLabel</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Assign Gamepad input</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboPadInput"/>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string> to PSP button/axis</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboPSPButton"/>
</item>
<item>
<widget class="QPushButton" name="AssignBtn">
<property name="text">
<string>Assign</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Press buttons on your gamePad to verify mapping :</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QWidget" name="widget" native="true">
<property name="minimumSize">
<size>
<width>500</width>
<height>218</height>
</size>
</property>
<widget class="QLabel" name="PSPImg">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>500</width>
<height>218</height>
</rect>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="resources.qrc">:/images/resources/psp.png</pixmap>
</property>
</widget>
<widget class="QLabel" name="Prev_Up">
<property name="geometry">
<rect>
<x>110</x>
<y>78</y>
<width>21</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="resources.qrc">:/images/resources/psp_up_red.png</pixmap>
</property>
</widget>
<widget class="QLabel" name="Prev_Left">
<property name="geometry">
<rect>
<x>92</x>
<y>93</y>
<width>21</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="resources.qrc">:/images/resources/psp_left_red.png</pixmap>
</property>
</widget>
<widget class="QLabel" name="Prev_Right">
<property name="geometry">
<rect>
<x>122</x>
<y>94</y>
<width>20</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="resources.qrc">:/images/resources/psp_right_red.png</pixmap>
</property>
</widget>
<widget class="QLabel" name="Prev_Down">
<property name="geometry">
<rect>
<x>109</x>
<y>105</y>
<width>21</width>
<height>30</height>
</rect>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="resources.qrc">:/images/resources/psp_down_red.png</pixmap>
</property>
</widget>
<widget class="QLabel" name="Prev_Home">
<property name="geometry">
<rect>
<x>141</x>
<y>165</y>
<width>30</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="resources.qrc">:/images/resources/psp_smallbtn_red.png</pixmap>
</property>
</widget>
<widget class="QLabel" name="Prev_Select">
<property name="geometry">
<rect>
<x>312</x>
<y>166</y>
<width>21</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="resources.qrc">:/images/resources/psp_smallbtn_red.png</pixmap>
</property>
</widget>
<widget class="QLabel" name="Prev_Start">
<property name="geometry">
<rect>
<x>339</x>
<y>166</y>
<width>21</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="resources.qrc">:/images/resources/psp_smallbtn_red.png</pixmap>
</property>
</widget>
<widget class="QLabel" name="Prev_S">
<property name="geometry">
<rect>
<x>351</x>
<y>92</y>
<width>21</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="resources.qrc">:/images/resources/psp_rightbtn_red.png</pixmap>
</property>
</widget>
<widget class="QLabel" name="Prev_X">
<property name="geometry">
<rect>
<x>374</x>
<y>114</y>
<width>21</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="resources.qrc">:/images/resources/psp_rightbtn_red.png</pixmap>
</property>
</widget>
<widget class="QLabel" name="Prev_O">
<property name="geometry">
<rect>
<x>396</x>
<y>93</y>
<width>21</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="resources.qrc">:/images/resources/psp_rightbtn_red.png</pixmap>
</property>
</widget>
<widget class="QLabel" name="Prev_T">
<property name="geometry">
<rect>
<x>374</x>
<y>71</y>
<width>21</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="resources.qrc">:/images/resources/psp_rightbtn_red.png</pixmap>
</property>
</widget>
<widget class="QLabel" name="Prev_RT">
<property name="geometry">
<rect>
<x>351</x>
<y>32</y>
<width>61</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="resources.qrc">:/images/resources/psp_rt_red.png</pixmap>
</property>
</widget>
<widget class="QLabel" name="Prev_LT">
<property name="geometry">
<rect>
<x>93</x>
<y>32</y>
<width>60</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="resources.qrc">:/images/resources/psp_lt_red.png</pixmap>
</property>
</widget>
<widget class="QLabel" name="Prev_ADown">
<property name="geometry">
<rect>
<x>107</x>
<y>144</y>
<width>21</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="resources.qrc">:/images/resources/psp_adown.png</pixmap>
</property>
</widget>
<widget class="QLabel" name="Prev_ALeft">
<property name="geometry">
<rect>
<x>107</x>
<y>139</y>
<width>16</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="resources.qrc">:/images/resources/psp_aleft.png</pixmap>
</property>
</widget>
<widget class="QLabel" name="Prev_AUp">
<property name="geometry">
<rect>
<x>108</x>
<y>134</y>
<width>21</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="resources.qrc">:/images/resources/psp_aup.png</pixmap>
</property>
</widget>
<widget class="QLabel" name="Prev_ARight">
<property name="geometry">
<rect>
<x>118</x>
<y>138</y>
<width>21</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="resources.qrc">:/images/resources/psp_aright.png</pixmap>
</property>
</widget>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="resources.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>GamePadDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>GamePadDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
+13
View File
@@ -32,6 +32,10 @@ MainWindow::MainWindow(QWidget *parent) :
qApp->installEventFilter(this);
controls = new Controls(this);
#if QT_HAS_SDL
gamePadDlg = new GamePadDialog(&input_state, this);
#endif
host = new QtHost(this);
w = ui->widget;
w->init(&input_state);
@@ -765,3 +769,12 @@ void MainWindow::on_actionLogDefError_triggered()
}
UpdateMenus();
}
void MainWindow::on_action_OptionsGamePadControls_triggered()
{
#if QT_HAS_SDL
gamePadDlg->show();
#else
QMessageBox::information(this,"Gamepad","You need to compile with SDL to have Gamepad support.", QMessageBox::Ok);
#endif
}
+4 -1
View File
@@ -7,6 +7,7 @@
#include "input/input_state.h"
#include "debugger_disasm.h"
#include "controls.h"
#include "gamepaddialog.h"
class QtEmuGL;
namespace Ui {
@@ -132,6 +133,8 @@ private slots:
void on_actionLogDefError_triggered();
void on_action_OptionsGamePadControls_triggered();
private:
Ui::MainWindow *ui;
@@ -139,10 +142,10 @@ private:
CoreState nextState;
InputState input_state;
bool g_bFullScreen;
Debugger_Disasm *dialogDisasm;
Controls* controls;
GamePadDialog* gamePadDlg;
};
#endif // MAINWINDOW_H
+7 -1
View File
@@ -136,6 +136,7 @@
<addaction name="action_OptionsScreen4x"/>
</widget>
<addaction name="action_OptionsControls"/>
<addaction name="action_OptionsGamePadControls"/>
<addaction name="separator"/>
<addaction name="action_OptionsFullScreen"/>
<addaction name="action_OptionsBufferedRendering"/>
@@ -320,7 +321,7 @@
</action>
<action name="action_OptionsControls">
<property name="text">
<string>&amp;Controls</string>
<string>Keyboard &amp;Controls</string>
</property>
</action>
<action name="action_OptionsFullScreen">
@@ -556,6 +557,11 @@
<string>Error</string>
</property>
</action>
<action name="action_OptionsGamePadControls">
<property name="text">
<string>GamePad Controls</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>
+12
View File
@@ -2,5 +2,17 @@
<qresource prefix="/images">
<file>resources/psp.png</file>
<file>resources/psp_map.png</file>
<file>resources/psp_rightbtn_red.png</file>
<file>resources/psp_smallbtn_red.png</file>
<file>resources/psp_down_red.png</file>
<file>resources/psp_up_red.png</file>
<file>resources/psp_right_red.png</file>
<file>resources/psp_left_red.png</file>
<file>resources/psp_rt_red.png</file>
<file>resources/psp_lt_red.png</file>
<file>resources/psp_aright.png</file>
<file>resources/psp_adown.png</file>
<file>resources/psp_aleft.png</file>
<file>resources/psp_aup.png</file>
</qresource>
</RCC>
Binary file not shown.

After

Width:  |  Height:  |  Size: 304 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 322 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 321 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 319 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 278 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 295 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 349 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 312 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 399 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 350 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 290 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 292 B