Skip to content

Commit

Permalink
Current progress of GameController API integration. Related to issue #37
Browse files Browse the repository at this point in the history
.

Still a lot of work to do to make this more manageable. Definitely
need to move more classes into separate packages/folders.
  • Loading branch information
Ryochan7 committed Dec 29, 2013
1 parent 2209130 commit a56e131
Show file tree
Hide file tree
Showing 51 changed files with 3,751 additions and 344 deletions.
26 changes: 22 additions & 4 deletions src/antimicro.pro
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
#-------------------------------------------------

#USE_SDL_2 = 1
USE_SDL_2 = 1

isEmpty(INSTALL_PREFIX) {
unix {
Expand Down Expand Up @@ -181,7 +181,8 @@ SOURCES += main.cpp\
mousedialog/springmoderegionpreview.cpp \
joystickstatuswindow.cpp \
joybuttonstatusbox.cpp \
flashbuttonwidget.cpp
flashbuttonwidget.cpp \
inputdevice.cpp


unix {
Expand All @@ -190,6 +191,14 @@ unix {
SOURCES += wininfo.cpp
}

!isEmpty(USE_SDL_2) {
SOURCES += gamecontroller.cpp \
gamecontrollerdpad.cpp \
gamecontrollerset.cpp \
gamecontrollertrigger.cpp \
gamecontrollermappingdialog.cpp
}

HEADERS += mainwindow.h \
joybuttonwidget.h \
joystick.h \
Expand Down Expand Up @@ -242,8 +251,16 @@ HEADERS += mainwindow.h \
mousedialog/springmoderegionpreview.h \
joystickstatuswindow.h \
joybuttonstatusbox.h \
flashbuttonwidget.h
flashbuttonwidget.h \
inputdevice.h

!isEmpty(USE_SDL_2) {
HEADERS += gamecontroller.h \
gamecontrollerdpad.h \
gamecontrollerset.h \
gamecontrollertrigger.h \
gamecontrollermappingdialog.h
}

unix {
HEADERS += x11info.h
Expand All @@ -262,7 +279,8 @@ FORMS += mainwindow.ui \
dpadeditdialog.ui \
quicksetdialog.ui \
mousesettingsdialog.ui \
joystickstatuswindow.ui
joystickstatuswindow.ui \
gamecontrollermappingdialog.ui


unix {
Expand Down
24 changes: 16 additions & 8 deletions src/axiseditdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,18 @@ AxisEditDialog::AxisEditDialog(JoyAxis *axis, QWidget *parent) :
}

int currentThrottle = axis->getThrottle();
ui->comboBox_2->setCurrentIndex(currentThrottle+1);
if (currentThrottle == -1)
//ui->comboBox_2->setCurrentIndex(currentThrottle+1);
if (currentThrottle == JoyAxis::NegativeThrottle || currentThrottle == JoyAxis::NegativeHalfThrottle)
{
int tempindex = currentThrottle == JoyAxis::NegativeHalfThrottle ? 0 : 1;
ui->comboBox_2->setCurrentIndex(tempindex);
ui->nPushButton->setEnabled(true);
ui->pPushButton->setEnabled(false);
}
else if (currentThrottle == 1)
else if (currentThrottle == JoyAxis::PositiveThrottle || currentThrottle == JoyAxis::PositiveHalfThrottle)
{
int tempindex = currentThrottle == JoyAxis::PositiveThrottle ? 3 : 4;
ui->comboBox_2->setCurrentIndex(tempindex);
ui->pPushButton->setEnabled(true);
ui->nPushButton->setEnabled(false);
}
Expand Down Expand Up @@ -203,24 +207,28 @@ void AxisEditDialog::updateMaxZoneBox(int value)

void AxisEditDialog::updateThrottleUi(int index)
{
if (index == 0)
int tempthrottle = 0;
if (index == 0 || index == 1)
{
ui->nPushButton->setEnabled(true);
ui->pPushButton->setEnabled(false);
tempthrottle = index == 0 ? JoyAxis::NegativeHalfThrottle : JoyAxis::NegativeThrottle;
}
else if (index == 1)
else if (index == 2)
{
ui->nPushButton->setEnabled(true);
ui->pPushButton->setEnabled(true);
tempthrottle = JoyAxis::NormalThrottle;
}
else if (index == 2)
else if (index == 3 || index == 4)
{
ui->pPushButton->setEnabled(true);
ui->nPushButton->setEnabled(false);
tempthrottle = index == 3 ? JoyAxis::PositiveThrottle : JoyAxis::PositiveHalfThrottle;
}

ui->axisstatusBox->setThrottle(index - 1);
axis->setThrottle(index - 1);
axis->setThrottle(tempthrottle);
ui->axisstatusBox->setThrottle(tempthrottle);
}

void AxisEditDialog::updateJoyValue(int value)
Expand Down
16 changes: 13 additions & 3 deletions src/axiseditdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -327,14 +327,19 @@ defective analog stick.</string>
interpret an axis hold or release.</string>
</property>
<property name="currentIndex">
<number>1</number>
<number>2</number>
</property>
<property name="maxVisibleItems">
<number>3</number>
<number>5</number>
</property>
<property name="maxCount">
<number>3</number>
<number>5</number>
</property>
<item>
<property name="text">
<string>Negative Half Throttle</string>
</property>
</item>
<item>
<property name="text">
<string>Negative Throttle</string>
Expand All @@ -350,6 +355,11 @@ interpret an axis hold or release.</string>
<string>Positive Throttle</string>
</property>
</item>
<item>
<property name="text">
<string>Positive Half Throttle</string>
</property>
</item>
</widget>
</item>
<item>
Expand Down
22 changes: 15 additions & 7 deletions src/axisvaluebox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ AxisValueBox::AxisValueBox(QWidget *parent) :

void AxisValueBox::setThrottle(int throttle)
{
if (throttle <= 1 && throttle >= -1)
if (throttle <= JoyAxis::PositiveHalfThrottle && throttle >= JoyAxis::NegativeHalfThrottle)
{
this->throttle = throttle;
setValue(joyValue);
Expand All @@ -31,18 +31,26 @@ void AxisValueBox::setValue(int value)
{
if (value >= JoyAxis::AXISMIN && value <= JoyAxis::AXISMAX)
{
if (throttle == 0)
if (throttle == JoyAxis::NormalThrottle)
{
this->joyValue = value;
}
else if (throttle == -1)
else if (throttle == JoyAxis::NegativeThrottle)
{
this->joyValue = (value + JoyAxis::AXISMIN) / 2;
}
else if (throttle == 1)
else if (throttle == JoyAxis::PositiveThrottle)
{
this->joyValue = (value + JoyAxis::AXISMAX) / 2;
}
else if (throttle == JoyAxis::NegativeHalfThrottle)
{
this->joyValue = value <= 0 ? value : -value;
}
else if (throttle == JoyAxis::PositiveHalfThrottle)
{
this->joyValue = value >= 0 ? value : -value;
}
}
update();
}
Expand Down Expand Up @@ -158,7 +166,7 @@ void AxisValueBox::paintEvent(QPaintEvent *event)
brush.setColor(Qt::blue);
QBrush maxBrush(Qt::red);

if (throttle == 0)
if (throttle == JoyAxis::NormalThrottle)
{
qDrawPlainRect(&paint, rboxstart + 2 + deadLine, 2, 4, boxheight + 2, Qt::black, 1, &brush);
qDrawPlainRect(&paint, lboxend - deadLine - 2, 2, 4, boxheight + 2, Qt::black, 1, &brush);
Expand All @@ -167,14 +175,14 @@ void AxisValueBox::paintEvent(QPaintEvent *event)
qDrawPlainRect(&paint, rboxstart + 2 + maxLine, 2, 4, boxheight + 2, Qt::black, 1, &maxBrush);
qDrawPlainRect(&paint, lboxend - maxLine - 2, 2, 4, boxheight + 2, Qt::black, 1, &maxBrush);
}
else if (throttle == 1)
else if (throttle == JoyAxis::PositiveThrottle || JoyAxis::PositiveHalfThrottle)
{
qDrawPlainRect(&paint, lboxstart + deadLine - 2, 2, 4, boxheight + 2, Qt::black, 1, &brush);
paint.setPen(Qt::red);
qDrawPlainRect(&paint, lboxstart + maxLine, 2, 4, boxheight + 2, Qt::black, 1, &maxBrush);
}

else if (throttle == -1)
else if (throttle == JoyAxis::NegativeThrottle || throttle == JoyAxis::NegativeHalfThrottle)
{
qDrawPlainRect(&paint, singleend - deadLine - 2, 2, 4, boxheight + 2, Qt::black, 1, &brush);
paint.setPen(Qt::red);
Expand Down
3 changes: 3 additions & 0 deletions src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ const QString configPath = (!qgetenv("LocalAppData").isEmpty()) ?
QDir::homePath() + "/.config/antimicro";

#endif

const QString configFileName = "antimicro_settings.ini";
const QString controllerMappingFileName = "controller_mappings.ini";
const QString configFilePath = configPath + "/" + configFileName;
const QString controllerMappingFilePath = configPath + "/" + controllerMappingFileName;
const int LATESTCONFIGFILEVERSION = 5;
const QString programVersion = "1.2";
const QString localSocketKey = "antimicroSignalListener";
Expand Down
Loading

0 comments on commit a56e131

Please sign in to comment.