mirror of
https://github.com/AntiMicroX/antimicrox.git
synced 2026-07-31 17:46:19 -04:00
@@ -1,4 +1,5 @@
|
||||
//#include <QDebug>
|
||||
#include <QFileDialog>
|
||||
#include <QPushButton>
|
||||
#include <QHBoxLayout>
|
||||
#include <cmath>
|
||||
@@ -45,7 +46,18 @@ AdvanceButtonDialog::AdvanceButtonDialog(JoyButton *button, QWidget *parent) :
|
||||
JoyButtonSlot *buttonslot = iter.next();
|
||||
SimpleKeyGrabberButton *existingCode = new SimpleKeyGrabberButton(this);
|
||||
existingCode->setText(buttonslot->getSlotString());
|
||||
existingCode->setValue(buttonslot->getSlotCode(), buttonslot->getSlotCodeAlias(), buttonslot->getSlotMode());
|
||||
if (buttonslot->getSlotMode() == JoyButtonSlot::JoyLoadProfile)
|
||||
{
|
||||
if (!buttonslot->getTextData().isEmpty())
|
||||
{
|
||||
existingCode->setValue(buttonslot->getTextData(), JoyButtonSlot::JoyLoadProfile);
|
||||
existingCode->setToolTip(buttonslot->getTextData());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
existingCode->setValue(buttonslot->getSlotCode(), buttonslot->getSlotCodeAlias(), buttonslot->getSlotMode());
|
||||
}
|
||||
|
||||
QListWidgetItem *item = new QListWidgetItem();
|
||||
item->setData(Qt::UserRole, QVariant::fromValue<SimpleKeyGrabberButton*>(existingCode));
|
||||
@@ -145,6 +157,7 @@ AdvanceButtonDialog::AdvanceButtonDialog(JoyButton *button, QWidget *parent) :
|
||||
connect(button, SIGNAL(toggleChanged(bool)), ui->toggleCheckbox, SLOT(setChecked(bool)));
|
||||
connect(button, SIGNAL(turboChanged(bool)), this, SLOT(checkTurboSetting(bool)));
|
||||
connect(ui->turboModeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(setButtonTurboMode(int)));
|
||||
connect(ui->loadProfilePushButton, SIGNAL(clicked()), this, SLOT(showSelectProfileWindow()));
|
||||
}
|
||||
|
||||
AdvanceButtonDialog::~AdvanceButtonDialog()
|
||||
@@ -997,3 +1010,23 @@ void AdvanceButtonDialog::setButtonTurboMode(int value)
|
||||
this->button->setTurboMode(JoyButton::PulseTurbo);
|
||||
}
|
||||
}
|
||||
|
||||
void AdvanceButtonDialog::showSelectProfileWindow()
|
||||
{
|
||||
AntiMicroSettings *settings = this->button->getParentSet()->getInputDevice()->getSettings();
|
||||
|
||||
QString lookupDir = PadderCommon::preferredProfileDir(settings);
|
||||
QString filename = QFileDialog::getOpenFileName(this, tr("Choose Profile"), lookupDir, tr("Config Files (*.amgp *.xml)"));
|
||||
if (!filename.isEmpty())
|
||||
{
|
||||
int index = ui->slotListWidget->currentRow();
|
||||
SimpleKeyGrabberButton *tempbutton = ui->slotListWidget->currentItem()->data(Qt::UserRole).value<SimpleKeyGrabberButton*>();
|
||||
tempbutton->setValue(filename, JoyButtonSlot::JoyLoadProfile);
|
||||
// Stop all events on JoyButton
|
||||
this->button->eventReset();
|
||||
|
||||
this->button->setAssignedSlot(tempbutton->getValue(), index);
|
||||
tempbutton->setToolTip(filename);
|
||||
updateSlotsScrollArea(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,6 +84,7 @@ private slots:
|
||||
void setButtonCycleResetInterval(double value);
|
||||
void setButtonCycleReset(bool enabled);
|
||||
void setButtonTurboMode(int value);
|
||||
void showSelectProfileWindow();
|
||||
};
|
||||
|
||||
#endif // ADVANCEBUTTONDIALOG_H
|
||||
|
||||
@@ -270,6 +270,13 @@ has passed.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QPushButton" name="loadProfilePushButton">
|
||||
<property name="text">
|
||||
<string>Load</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
|
||||
@@ -4,8 +4,9 @@
|
||||
|
||||
const QString GameController::xmlName = "gamecontroller";
|
||||
|
||||
GameController::GameController(SDL_GameController *controller, int deviceIndex, QObject *parent) :
|
||||
InputDevice(deviceIndex, parent)
|
||||
GameController::GameController(SDL_GameController *controller, int deviceIndex, AntiMicroSettings *settings,
|
||||
QObject *parent) :
|
||||
InputDevice(deviceIndex, settings, parent)
|
||||
{
|
||||
this->controller = controller;
|
||||
SDL_Joystick *joyhandle = SDL_GameControllerGetJoystick(controller);
|
||||
|
||||
@@ -14,7 +14,7 @@ class GameController : public InputDevice
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit GameController(SDL_GameController *controller, int deviceIndex, QObject *parent = 0);
|
||||
explicit GameController(SDL_GameController *controller, int deviceIndex, AntiMicroSettings *settings, QObject *parent = 0);
|
||||
|
||||
virtual QString getName();
|
||||
virtual QString getSDLName();
|
||||
|
||||
@@ -249,7 +249,7 @@ void InputDaemon::refreshJoysticks()
|
||||
if (SDL_IsGameController(i) && !disableGameController)
|
||||
{
|
||||
SDL_GameController *controller = SDL_GameControllerOpen(i);
|
||||
GameController *damncontroller = new GameController(controller, i, this);
|
||||
GameController *damncontroller = new GameController(controller, i, settings, this);
|
||||
SDL_Joystick *sdlStick = SDL_GameControllerGetJoystick(controller);
|
||||
SDL_JoystickID joystickID = SDL_JoystickInstanceID(sdlStick);
|
||||
joysticks->insert(joystickID, damncontroller);
|
||||
@@ -257,14 +257,14 @@ void InputDaemon::refreshJoysticks()
|
||||
}
|
||||
else
|
||||
{
|
||||
Joystick *curJoystick = new Joystick(joystick, i, this);
|
||||
Joystick *curJoystick = new Joystick(joystick, i, settings, this);
|
||||
SDL_JoystickID joystickID = SDL_JoystickInstanceID(joystick);
|
||||
joysticks->insert(joystickID, curJoystick);
|
||||
trackjoysticks.insert(joystickID, curJoystick);
|
||||
}
|
||||
#else
|
||||
SDL_Joystick *joystick = SDL_JoystickOpen(i);
|
||||
Joystick *curJoystick = new Joystick(joystick, i, this);
|
||||
Joystick *curJoystick = new Joystick(joystick, i, settings, this);
|
||||
joysticks->insert(i, curJoystick);
|
||||
#endif
|
||||
}
|
||||
@@ -375,7 +375,7 @@ void InputDaemon::refreshMapping(QString mapping, InputDevice *device)
|
||||
joysticks->remove(joystickID);
|
||||
|
||||
SDL_GameController *controller = SDL_GameControllerOpen(i);
|
||||
GameController *damncontroller = new GameController(controller, i, this);
|
||||
GameController *damncontroller = new GameController(controller, i, settings, this);
|
||||
SDL_Joystick *sdlStick = SDL_GameControllerGetJoystick(controller);
|
||||
joystickID = SDL_JoystickInstanceID(sdlStick);
|
||||
joysticks->insert(joystickID, damncontroller);
|
||||
@@ -446,7 +446,7 @@ void InputDaemon::addInputDevice(int index)
|
||||
SDL_JoystickID tempJoystickID = SDL_JoystickInstanceID(sdlStick);
|
||||
if (!joysticks->contains(tempJoystickID))
|
||||
{
|
||||
GameController *damncontroller = new GameController(controller, index, this);
|
||||
GameController *damncontroller = new GameController(controller, index, settings, this);
|
||||
joysticks->insert(tempJoystickID, damncontroller);
|
||||
trackcontrollers.insert(tempJoystickID, damncontroller);
|
||||
|
||||
@@ -458,7 +458,7 @@ void InputDaemon::addInputDevice(int index)
|
||||
}
|
||||
else
|
||||
{
|
||||
Joystick *curJoystick = new Joystick(joystick, index, this);
|
||||
Joystick *curJoystick = new Joystick(joystick, index, settings, this);
|
||||
joysticks->insert(tempJoystickID, curJoystick);
|
||||
trackjoysticks.insert(tempJoystickID, curJoystick);
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ const int InputDevice::DEFAULTKEYPRESSTIME = 100;
|
||||
const unsigned int InputDevice::DEFAULTKEYREPEATDELAY = 660; // 660 ms
|
||||
const unsigned int InputDevice::DEFAULTKEYREPEATRATE = 40; // 40 ms. 25 times per second
|
||||
|
||||
InputDevice::InputDevice(int deviceIndex, QObject *parent) :
|
||||
InputDevice::InputDevice(int deviceIndex, AntiMicroSettings *settings, QObject *parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
buttonDownCount = 0;
|
||||
@@ -25,6 +25,7 @@ InputDevice::InputDevice(int deviceIndex, QObject *parent) :
|
||||
|
||||
keyRepeatDelay = 0;
|
||||
keyRepeatRate = 0;
|
||||
this->settings = settings;
|
||||
}
|
||||
|
||||
InputDevice::~InputDevice()
|
||||
@@ -1971,3 +1972,16 @@ void InputDevice::setCalibrationThrottle(int axisNum, JoyAxis::ThrottleTypes thr
|
||||
cali.insert(axisNum, throttle);
|
||||
}
|
||||
}
|
||||
|
||||
void InputDevice::sendLoadProfileRequest(QString location)
|
||||
{
|
||||
if (!location.isEmpty())
|
||||
{
|
||||
emit requestProfileLoad(location);
|
||||
}
|
||||
}
|
||||
|
||||
AntiMicroSettings* InputDevice::getSettings()
|
||||
{
|
||||
return settings;
|
||||
}
|
||||
|
||||
@@ -16,12 +16,13 @@ typedef Sint32 SDL_JoystickID;
|
||||
|
||||
#include "setjoystick.h"
|
||||
#include "common.h"
|
||||
#include "antimicrosettings.h"
|
||||
|
||||
class InputDevice : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit InputDevice(int deviceIndex, QObject *parent = 0);
|
||||
explicit InputDevice(int deviceIndex, AntiMicroSettings *settings, QObject *parent = 0);
|
||||
virtual ~InputDevice();
|
||||
|
||||
virtual int getNumberButtons();
|
||||
@@ -89,6 +90,9 @@ public:
|
||||
JoyAxis::ThrottleTypes getCalibrationThrottle(int axisNum);
|
||||
void setCalibrationThrottle(int axisNum, JoyAxis::ThrottleTypes throttle);
|
||||
|
||||
void sendLoadProfileRequest(QString location);
|
||||
AntiMicroSettings *getSettings();
|
||||
|
||||
void transferReset();
|
||||
void reInitButtons();
|
||||
|
||||
@@ -103,6 +107,7 @@ protected:
|
||||
SDL_Joystick* joyhandle;
|
||||
QHash<int, SetJoystick*> joystick_sets;
|
||||
QHash<int, JoyAxis::ThrottleTypes> cali;
|
||||
AntiMicroSettings *settings;
|
||||
int active_set;
|
||||
int joyNumber;
|
||||
int buttonDownCount;
|
||||
@@ -136,6 +141,7 @@ signals:
|
||||
void profileUpdated();
|
||||
void propertyUpdated();
|
||||
void profileNameEdited(QString text);
|
||||
void requestProfileLoad(QString location);
|
||||
|
||||
public slots:
|
||||
void reset();
|
||||
|
||||
@@ -817,6 +817,18 @@ void JoyButton::activateSlots()
|
||||
exit = true;
|
||||
}
|
||||
}
|
||||
else if (mode == JoyButtonSlot::JoyLoadProfile)
|
||||
{
|
||||
releaseActiveSlots();
|
||||
slotiter->toBack();
|
||||
exit = true;
|
||||
|
||||
QString location = slot->getTextData();
|
||||
if (!location.isEmpty())
|
||||
{
|
||||
parentSet->getInputDevice()->sendLoadProfileRequest(location);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (delaySequence && !activeSlots.isEmpty())
|
||||
@@ -1751,9 +1763,17 @@ bool JoyButton::readButtonConfig(QXmlStreamReader *xml)
|
||||
{
|
||||
JoyButtonSlot *buttonslot = new JoyButtonSlot(this);
|
||||
buttonslot->readConfig(xml);
|
||||
//setAssignedSlot(buttonslot->getSlotCode(), buttonslot->getSlotMode());
|
||||
bool inserted = setAssignedSlot(buttonslot);
|
||||
if (!inserted)
|
||||
bool validSlot = buttonslot->isValidSlot();
|
||||
if (validSlot)
|
||||
{
|
||||
bool inserted = insertAssignedSlot(buttonslot);
|
||||
if (!inserted)
|
||||
{
|
||||
delete buttonslot;
|
||||
buttonslot = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
delete buttonslot;
|
||||
buttonslot = 0;
|
||||
@@ -2099,6 +2119,18 @@ QString JoyButton::getActiveZoneSummary()
|
||||
|
||||
break;
|
||||
}
|
||||
case JoyButtonSlot::JoyLoadProfile:
|
||||
{
|
||||
QString temp = slot->getSlotString();
|
||||
if (behindHold)
|
||||
{
|
||||
temp.prepend("[H] ");
|
||||
behindHold = false;
|
||||
}
|
||||
stringlist.append(temp);
|
||||
i++;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
iter->toBack();
|
||||
@@ -2187,15 +2219,7 @@ bool JoyButton::setAssignedSlot(int code, JoyButtonSlot::JoySlotInputAction mode
|
||||
|
||||
if (slotInserted)
|
||||
{
|
||||
if (slot->getSlotMode() == JoyButtonSlot::JoyPause ||
|
||||
slot->getSlotMode() == JoyButtonSlot::JoyHold ||
|
||||
slot->getSlotMode() == JoyButtonSlot::JoyDistance ||
|
||||
slot->getSlotMode() == JoyButtonSlot::JoyRelease
|
||||
)
|
||||
{
|
||||
setUseTurbo(false);
|
||||
}
|
||||
|
||||
checkTurboCondition(slot);
|
||||
emit slotsChanged();
|
||||
}
|
||||
else
|
||||
@@ -2234,15 +2258,7 @@ bool JoyButton::setAssignedSlot(int code, unsigned int alias, JoyButtonSlot::Joy
|
||||
|
||||
if (slotInserted)
|
||||
{
|
||||
if (slot->getSlotMode() == JoyButtonSlot::JoyPause ||
|
||||
slot->getSlotMode() == JoyButtonSlot::JoyHold ||
|
||||
slot->getSlotMode() == JoyButtonSlot::JoyDistance ||
|
||||
slot->getSlotMode() == JoyButtonSlot::JoyRelease
|
||||
)
|
||||
{
|
||||
setUseTurbo(false);
|
||||
}
|
||||
|
||||
checkTurboCondition(slot);
|
||||
emit slotsChanged();
|
||||
}
|
||||
else
|
||||
@@ -2287,6 +2303,13 @@ bool JoyButton::setAssignedSlot(int code, unsigned int alias, int index, JoyButt
|
||||
if (index >= 0 && index < assignments.count())
|
||||
{
|
||||
// Insert slot and move existing slots.
|
||||
JoyButtonSlot *temp = assignments.at(index);
|
||||
if (temp)
|
||||
{
|
||||
delete temp;
|
||||
temp = 0;
|
||||
}
|
||||
|
||||
assignments.replace(index, slot);
|
||||
}
|
||||
else if (index >= assignments.count())
|
||||
@@ -2295,15 +2318,7 @@ bool JoyButton::setAssignedSlot(int code, unsigned int alias, int index, JoyButt
|
||||
assignments.append(slot);
|
||||
}
|
||||
|
||||
if (slot->getSlotMode() == JoyButtonSlot::JoyPause ||
|
||||
slot->getSlotMode() == JoyButtonSlot::JoyHold ||
|
||||
slot->getSlotMode() == JoyButtonSlot::JoyDistance ||
|
||||
slot->getSlotMode() == JoyButtonSlot::JoyRelease
|
||||
)
|
||||
{
|
||||
setUseTurbo(false);
|
||||
}
|
||||
|
||||
checkTurboCondition(slot);
|
||||
emit slotsChanged();
|
||||
}
|
||||
else
|
||||
@@ -2348,7 +2363,14 @@ bool JoyButton::insertAssignedSlot(int code, unsigned int alias, int index, JoyB
|
||||
if (index >= 0 && index < assignments.count())
|
||||
{
|
||||
// Slot already exists. Override code and place into desired slot
|
||||
assignments.insert(index, slot);
|
||||
JoyButtonSlot *temp = assignments.at(index);
|
||||
if (temp)
|
||||
{
|
||||
delete temp;
|
||||
temp = 0;
|
||||
}
|
||||
|
||||
assignments.replace(index, slot);
|
||||
}
|
||||
else if (index >= assignments.count())
|
||||
{
|
||||
@@ -2356,15 +2378,7 @@ bool JoyButton::insertAssignedSlot(int code, unsigned int alias, int index, JoyB
|
||||
assignments.append(slot);
|
||||
}
|
||||
|
||||
if (slot->getSlotMode() == JoyButtonSlot::JoyPause ||
|
||||
slot->getSlotMode() == JoyButtonSlot::JoyHold ||
|
||||
slot->getSlotMode() == JoyButtonSlot::JoyDistance ||
|
||||
slot->getSlotMode() == JoyButtonSlot::JoyRelease
|
||||
)
|
||||
{
|
||||
setUseTurbo(false);
|
||||
}
|
||||
|
||||
checkTurboCondition(slot);
|
||||
emit slotsChanged();
|
||||
}
|
||||
else
|
||||
@@ -2379,9 +2393,45 @@ bool JoyButton::insertAssignedSlot(int code, unsigned int alias, int index, JoyB
|
||||
return permitSlot;
|
||||
}
|
||||
|
||||
bool JoyButton::setAssignedSlot(JoyButtonSlot *newslot)
|
||||
bool JoyButton::insertAssignedSlot(JoyButtonSlot *newSlot)
|
||||
{
|
||||
bool slotInserted = false;
|
||||
bool permitSlot = false;
|
||||
|
||||
if (newSlot->getSlotMode() == JoyButtonSlot::JoyDistance)
|
||||
{
|
||||
if (newSlot->getSlotCode() >= 1 && newSlot->getSlotCode() <= 100)
|
||||
{
|
||||
double tempDistance = getTotalSlotDistance(newSlot);
|
||||
if (tempDistance <= 1.0)
|
||||
{
|
||||
permitSlot = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (newSlot->getSlotMode() == JoyButtonSlot::JoyLoadProfile)
|
||||
{
|
||||
permitSlot = true;
|
||||
}
|
||||
else if (newSlot->getSlotCode() >= 0)
|
||||
{
|
||||
permitSlot = true;
|
||||
}
|
||||
|
||||
if (permitSlot)
|
||||
{
|
||||
checkTurboCondition(newSlot);
|
||||
assignments.append(newSlot);
|
||||
|
||||
emit slotsChanged();
|
||||
}
|
||||
|
||||
return permitSlot;
|
||||
}
|
||||
|
||||
bool JoyButton::setAssignedSlot(JoyButtonSlot *otherSlot, int index)
|
||||
{
|
||||
bool permitSlot = false;
|
||||
JoyButtonSlot *newslot = new JoyButtonSlot(otherSlot, this);
|
||||
|
||||
if (newslot->getSlotMode() == JoyButtonSlot::JoyDistance)
|
||||
{
|
||||
@@ -2390,32 +2440,51 @@ bool JoyButton::setAssignedSlot(JoyButtonSlot *newslot)
|
||||
double tempDistance = getTotalSlotDistance(newslot);
|
||||
if (tempDistance <= 1.0)
|
||||
{
|
||||
assignments.append(newslot);
|
||||
slotInserted = true;
|
||||
permitSlot = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (newslot->getSlotMode() == JoyButtonSlot::JoyLoadProfile)
|
||||
{
|
||||
permitSlot = true;
|
||||
}
|
||||
else if (newslot->getSlotCode() >= 0)
|
||||
{
|
||||
assignments.append(newslot);
|
||||
slotInserted = true;
|
||||
permitSlot = true;
|
||||
}
|
||||
|
||||
if (slotInserted)
|
||||
if (permitSlot)
|
||||
{
|
||||
if (newslot->getSlotMode() == JoyButtonSlot::JoyPause ||
|
||||
newslot->getSlotMode() == JoyButtonSlot::JoyHold ||
|
||||
newslot->getSlotMode() == JoyButtonSlot::JoyDistance ||
|
||||
newslot->getSlotMode() == JoyButtonSlot::JoyRelease
|
||||
)
|
||||
checkTurboCondition(newslot);
|
||||
|
||||
if (index >= 0 && index < assignments.count())
|
||||
{
|
||||
setUseTurbo(false);
|
||||
// Slot already exists. Override code and place into desired slot
|
||||
JoyButtonSlot *temp = assignments.at(index);
|
||||
if (temp)
|
||||
{
|
||||
delete temp;
|
||||
temp = 0;
|
||||
//assignments.insert(index, temp);
|
||||
}
|
||||
|
||||
assignments.replace(index, newslot);
|
||||
}
|
||||
else if (index >= assignments.count())
|
||||
{
|
||||
// Append code into a new slot
|
||||
assignments.append(newslot);
|
||||
}
|
||||
|
||||
emit slotsChanged();
|
||||
}
|
||||
else
|
||||
{
|
||||
delete newslot;
|
||||
newslot = 0;
|
||||
}
|
||||
|
||||
return slotInserted;
|
||||
return permitSlot;
|
||||
}
|
||||
|
||||
QList<JoyButtonSlot*>* JoyButton::getAssignedSlots()
|
||||
@@ -4322,7 +4391,7 @@ void JoyButton::copyAssignments(JoyButton *destButton)
|
||||
{
|
||||
JoyButtonSlot *slot = iter.next();
|
||||
JoyButtonSlot *newslot = new JoyButtonSlot(slot, destButton);
|
||||
destButton->setAssignedSlot(newslot);
|
||||
destButton->insertAssignedSlot(newslot);
|
||||
//destButton->assignments.append(slot);
|
||||
}
|
||||
|
||||
@@ -4422,6 +4491,10 @@ JoyButtonMouseHelper* JoyButton::getMouseHelper()
|
||||
return &mouseHelper;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the list of buttons that have a pending mouse movement event.
|
||||
* @return QList<JoyButton*>*
|
||||
*/
|
||||
QList<JoyButton*>* JoyButton::getPendingMouseButtons()
|
||||
{
|
||||
return &pendingMouseButtons;
|
||||
@@ -4450,11 +4523,19 @@ void JoyButton::setWeightModifier(double modifier)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get mouse history buffer size.
|
||||
* @return Mouse history buffer size
|
||||
*/
|
||||
int JoyButton::getMouseHistorySize()
|
||||
{
|
||||
return mouseHistorySize;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set mouse history buffer size used for mouse smoothing.
|
||||
* @param Mouse history buffer size
|
||||
*/
|
||||
void JoyButton::setMouseHistorySize(int size)
|
||||
{
|
||||
if (size >= 1 && size <= MAXIMUMMOUSEHISTORYSIZE)
|
||||
@@ -4466,12 +4547,19 @@ void JoyButton::setMouseHistorySize(int size)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get active mouse movement refresh rate.
|
||||
* @return
|
||||
*/
|
||||
int JoyButton::getMouseRefreshRate()
|
||||
{
|
||||
return mouseRefreshRate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the mouse refresh rate when a mouse slot is active.
|
||||
* @param Refresh rate in ms.
|
||||
*/
|
||||
void JoyButton::setMouseRefreshRate(int refresh)
|
||||
{
|
||||
if (refresh >= 1 && refresh <= 16)
|
||||
@@ -4480,7 +4568,7 @@ void JoyButton::setMouseRefreshRate(int refresh)
|
||||
if (staticMouseEventTimer.isActive())
|
||||
{
|
||||
lastMouseTime.restart();
|
||||
staticMouseEventTimer.start(mouseRefreshRate);
|
||||
//staticMouseEventTimer.start(mouseRefreshRate);
|
||||
|
||||
// Clear current mouse history
|
||||
mouseHistoryX.clear();
|
||||
@@ -4488,3 +4576,23 @@ void JoyButton::setMouseRefreshRate(int refresh)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if turbo should be disabled for a slot
|
||||
* @param JoyButtonSlot to check
|
||||
*/
|
||||
void JoyButton::checkTurboCondition(JoyButtonSlot *slot)
|
||||
{
|
||||
JoyButtonSlot::JoySlotInputAction mode = slot->getSlotMode();
|
||||
switch (mode)
|
||||
{
|
||||
case JoyButtonSlot::JoyPause:
|
||||
case JoyButtonSlot::JoyHold:
|
||||
case JoyButtonSlot::JoyDistance:
|
||||
case JoyButtonSlot::JoyRelease:
|
||||
case JoyButtonSlot::JoyLoadProfile:
|
||||
{
|
||||
setUseTurbo(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,6 +56,7 @@ public:
|
||||
|
||||
bool insertAssignedSlot(int code, unsigned int alias, int index,
|
||||
JoyButtonSlot::JoySlotInputAction mode=JoyButtonSlot::JoyKeyboard);
|
||||
bool setAssignedSlot(JoyButtonSlot *otherSlot, int index);
|
||||
|
||||
void removeAssignedSlot(int index);
|
||||
|
||||
@@ -213,8 +214,9 @@ protected:
|
||||
void findHoldEventEnd();
|
||||
bool checkForDelaySequence();
|
||||
void checkForPressedSetChange();
|
||||
bool setAssignedSlot(JoyButtonSlot *newslot);
|
||||
bool insertAssignedSlot(JoyButtonSlot *newSlot);
|
||||
unsigned int getPreferredKeyPressTime();
|
||||
void checkTurboCondition(JoyButtonSlot *slot);
|
||||
|
||||
virtual bool readButtonConfig(QXmlStreamReader *xml);
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
//#include <QDebug>
|
||||
|
||||
#include <QFileInfo>
|
||||
|
||||
#include "joybuttonslot.h"
|
||||
|
||||
#include "antkeymapper.h"
|
||||
@@ -65,9 +67,10 @@ JoyButtonSlot::JoyButtonSlot(JoyButtonSlot *slot, QObject *parent) :
|
||||
deviceCode = slot->deviceCode;
|
||||
qkeyaliasCode = slot->qkeyaliasCode;
|
||||
mode = slot->mode;
|
||||
distance = 0.0;
|
||||
distance = slot->distance;
|
||||
mouseInterval = new QElapsedTimer();
|
||||
easingActive = false;
|
||||
textData = slot->getTextData();
|
||||
}
|
||||
|
||||
JoyButtonSlot::~JoyButtonSlot()
|
||||
@@ -170,6 +173,8 @@ void JoyButtonSlot::readConfig(QXmlStreamReader *xml)
|
||||
{
|
||||
if (xml->isStartElement() && xml->name() == "slot")
|
||||
{
|
||||
QString profile;
|
||||
|
||||
xml->readNextStartElement();
|
||||
while (!xml->atEnd() && (!xml->isEndElement() && xml->name() != "slot"))
|
||||
{
|
||||
@@ -183,6 +188,12 @@ void JoyButtonSlot::readConfig(QXmlStreamReader *xml)
|
||||
this->setSlotCode(tempchoice);
|
||||
}
|
||||
}
|
||||
else if (xml->name() == "profile" && xml->isStartElement())
|
||||
{
|
||||
QString temptext = xml->readElementText();
|
||||
profile = temptext;
|
||||
//this->setTextData(temptext);
|
||||
}
|
||||
else if (xml->name() == "mode" && xml->isStartElement())
|
||||
{
|
||||
QString temptext = xml->readElementText();
|
||||
@@ -231,6 +242,10 @@ void JoyButtonSlot::readConfig(QXmlStreamReader *xml)
|
||||
{
|
||||
this->setSlotMode(JoyDelay);
|
||||
}
|
||||
else if (temptext == "loadprofile")
|
||||
{
|
||||
this->setSlotMode(JoyLoadProfile);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -239,6 +254,7 @@ void JoyButtonSlot::readConfig(QXmlStreamReader *xml)
|
||||
|
||||
xml->readNextStartElement();
|
||||
}
|
||||
|
||||
if (this->getSlotMode() == JoyButtonSlot::JoyKeyboard)
|
||||
{
|
||||
unsigned int virtualkey = AntKeyMapper::getInstance()->returnVirtualKey(this->getSlotCode());
|
||||
@@ -257,8 +273,19 @@ void JoyButtonSlot::readConfig(QXmlStreamReader *xml)
|
||||
this->setSlotCode(temp);
|
||||
}
|
||||
}
|
||||
else if (this->getSlotMode() == JoyButtonSlot::JoyLoadProfile && !profile.isEmpty())
|
||||
{
|
||||
QFileInfo profileInfo(profile);
|
||||
if (!profileInfo.exists() || !(profileInfo.suffix() == "amgp" || profileInfo.suffix() == "xml"))
|
||||
{
|
||||
this->setTextData("");
|
||||
}
|
||||
else
|
||||
{
|
||||
this->setTextData(profile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void JoyButtonSlot::writeConfig(QXmlStreamWriter *xml)
|
||||
@@ -289,7 +316,10 @@ void JoyButtonSlot::writeConfig(QXmlStreamWriter *xml)
|
||||
//qDebug() << "ANT KEY: " << QString::number(tempkey, 16);
|
||||
xml->writeTextElement("code", QString("0x%1").arg(tempkey, 0, 16));
|
||||
}
|
||||
|
||||
}
|
||||
else if (mode == JoyLoadProfile && !textData.isEmpty())
|
||||
{
|
||||
xml->writeTextElement("profile", textData);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -341,6 +371,10 @@ void JoyButtonSlot::writeConfig(QXmlStreamWriter *xml)
|
||||
{
|
||||
xml->writeCharacters("delay");
|
||||
}
|
||||
else if (mode == JoyLoadProfile)
|
||||
{
|
||||
xml->writeCharacters("loadprofile");
|
||||
}
|
||||
|
||||
xml->writeEndElement();
|
||||
|
||||
@@ -496,6 +530,16 @@ QString JoyButtonSlot::getSlotString()
|
||||
|
||||
newlabel.append(temp);
|
||||
}
|
||||
else if (mode == JoyLoadProfile)
|
||||
{
|
||||
if (!textData.isEmpty())
|
||||
{
|
||||
QFileInfo profileInfo(textData);
|
||||
QString temp;
|
||||
temp.append(tr("Load %1").arg(profileInfo.baseName()));
|
||||
newlabel.append(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -540,3 +584,30 @@ QTime* JoyButtonSlot::getEasingTime()
|
||||
{
|
||||
return &easingTime;
|
||||
}
|
||||
|
||||
void JoyButtonSlot::setTextData(QString textData)
|
||||
{
|
||||
this->textData = textData;
|
||||
}
|
||||
|
||||
QString JoyButtonSlot::getTextData()
|
||||
{
|
||||
return textData;
|
||||
}
|
||||
|
||||
bool JoyButtonSlot::isValidSlot()
|
||||
{
|
||||
bool result = true;
|
||||
switch (mode)
|
||||
{
|
||||
case JoyLoadProfile:
|
||||
{
|
||||
if (textData.isEmpty())
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,8 @@ class JoyButtonSlot : public QObject
|
||||
public:
|
||||
enum JoySlotInputAction {JoyKeyboard=0, JoyMouseButton, JoyMouseMovement,
|
||||
JoyPause, JoyHold, JoyCycle, JoyDistance,
|
||||
JoyRelease, JoyMouseSpeedMod, JoyKeyPress, JoyDelay};
|
||||
JoyRelease, JoyMouseSpeedMod, JoyKeyPress, JoyDelay,
|
||||
JoyLoadProfile};
|
||||
enum JoySlotMouseDirection {MouseUp=1, MouseDown, MouseLeft, MouseRight};
|
||||
enum JoySlotMouseWheelButton {MouseWheelUp=4, MouseWheelDown=5,
|
||||
MouseWheelLeft=6, MouseWheelRight=7};
|
||||
@@ -48,6 +49,11 @@ public:
|
||||
void setEasingStatus(bool isActive);
|
||||
QTime* getEasingTime();
|
||||
|
||||
void setTextData(QString textData);
|
||||
QString getTextData();
|
||||
|
||||
bool isValidSlot();
|
||||
|
||||
virtual void readConfig(QXmlStreamReader *xml);
|
||||
virtual void writeConfig(QXmlStreamWriter *xml);
|
||||
|
||||
@@ -63,6 +69,7 @@ protected:
|
||||
QElapsedTimer *mouseInterval;
|
||||
QTime easingTime;
|
||||
bool easingActive;
|
||||
QString textData;
|
||||
|
||||
signals:
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
const QString Joystick::xmlName = "joystick";
|
||||
|
||||
Joystick::Joystick(SDL_Joystick *joyhandle, int deviceIndex, QObject *parent) :
|
||||
InputDevice(deviceIndex, parent)
|
||||
Joystick::Joystick(SDL_Joystick *joyhandle, int deviceIndex, AntiMicroSettings *settings, QObject *parent) :
|
||||
InputDevice(deviceIndex, settings, parent)
|
||||
{
|
||||
this->joyhandle = joyhandle;
|
||||
#ifdef USE_SDL_2
|
||||
|
||||
@@ -11,7 +11,7 @@ class Joystick : public InputDevice
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit Joystick(SDL_Joystick *joyhandle, int deviceIndex, QObject *parent=0);
|
||||
explicit Joystick(SDL_Joystick *joyhandle, int deviceIndex, AntiMicroSettings *settings, QObject *parent=0);
|
||||
|
||||
virtual QString getName();
|
||||
virtual QString getSDLName();
|
||||
|
||||
@@ -462,6 +462,8 @@ JoyTabWidget::JoyTabWidget(InputDevice *joystick, AntiMicroSettings *settings, Q
|
||||
connect(this, SIGNAL(joystickConfigChanged(int)), this, SLOT(refreshCopySetActions()));
|
||||
connect(joystick, SIGNAL(profileUpdated()), this, SLOT(displayProfileEditNotification()));
|
||||
|
||||
connect(joystick, SIGNAL(requestProfileLoad(QString)), this, SLOT(loadConfigFile(QString)), Qt::QueuedConnection);
|
||||
|
||||
reconnectCheckUnsavedEvent();
|
||||
reconnectMainComboBoxEvents();
|
||||
}
|
||||
@@ -471,7 +473,7 @@ void JoyTabWidget::openConfigFileDialog()
|
||||
int numberRecentProfiles = settings->value("NumberRecentProfiles", DEFAULTNUMBERPROFILES).toInt();
|
||||
QString lookupDir = PadderCommon::preferredProfileDir(settings);
|
||||
|
||||
QString filename = QFileDialog::getOpenFileName(this, tr("Open Config"), lookupDir, QString("Config Files (*.amgp *.xml)"));
|
||||
QString filename = QFileDialog::getOpenFileName(this, tr("Open Config"), lookupDir, tr("Config Files (*.amgp *.xml)"));
|
||||
|
||||
if (!filename.isNull() && !filename.isEmpty())
|
||||
{
|
||||
@@ -556,7 +558,7 @@ void JoyTabWidget::saveConfigFile()
|
||||
if (index == 0)
|
||||
{
|
||||
QString lookupDir = PadderCommon::preferredProfileDir(settings);
|
||||
QString tempfilename = QFileDialog::getSaveFileName(this, tr("Save Config"), lookupDir, QString("Config File (*.%1.amgp)").arg(joystick->getXmlName()));
|
||||
QString tempfilename = QFileDialog::getSaveFileName(this, tr("Save Config"), lookupDir, tr("Config File (*.%1.amgp)").arg(joystick->getXmlName()));
|
||||
if (!tempfilename.isEmpty())
|
||||
{
|
||||
filename = tempfilename;
|
||||
@@ -717,7 +719,7 @@ void JoyTabWidget::saveAsConfig()
|
||||
if (index == 0)
|
||||
{
|
||||
QString lookupDir = PadderCommon::preferredProfileDir(settings);
|
||||
QString tempfilename = QFileDialog::getSaveFileName(this, tr("Save Config"), lookupDir, QString("Config File (*.%1.amgp)").arg(joystick->getXmlName()));
|
||||
QString tempfilename = QFileDialog::getSaveFileName(this, tr("Save Config"), lookupDir, tr("Config File (*.%1.amgp)").arg(joystick->getXmlName()));
|
||||
if (!tempfilename.isEmpty())
|
||||
{
|
||||
filename = tempfilename;
|
||||
@@ -727,7 +729,7 @@ void JoyTabWidget::saveAsConfig()
|
||||
{
|
||||
QString configPath = configBox->itemData(index).toString();
|
||||
QFileInfo temp(configPath);
|
||||
QString tempfilename = QFileDialog::getSaveFileName(this, tr("Save Config"), temp.absoluteDir().absolutePath(), QString("Config File (*.%1.amgp)").arg(joystick->getXmlName()));
|
||||
QString tempfilename = QFileDialog::getSaveFileName(this, tr("Save Config"), temp.absoluteDir().absolutePath(), tr("Config File (*.%1.amgp)").arg(joystick->getXmlName()));
|
||||
if (!tempfilename.isEmpty())
|
||||
{
|
||||
filename = tempfilename;
|
||||
@@ -823,6 +825,8 @@ void JoyTabWidget::changeJoyConfig(int index)
|
||||
{
|
||||
removeCurrentButtons();
|
||||
|
||||
joystick->resetButtonDownCount();
|
||||
|
||||
XMLConfigReader reader;
|
||||
reader.setFileName(filename);
|
||||
reader.configJoystick(joystick);
|
||||
@@ -867,8 +871,10 @@ void JoyTabWidget::changeJoyConfig(int index)
|
||||
else if (index == 0)
|
||||
{
|
||||
removeCurrentButtons();
|
||||
|
||||
//joystick->reset();
|
||||
joystick->transferReset();
|
||||
joystick->resetButtonDownCount();
|
||||
joystick->reInitButtons();
|
||||
|
||||
fillButtons();
|
||||
@@ -1189,26 +1195,38 @@ void JoyTabWidget::showStickAssignmentDialog()
|
||||
|
||||
void JoyTabWidget::loadConfigFile(QString fileLocation)
|
||||
{
|
||||
int numberRecentProfiles = settings->value("NumberRecentProfiles", DEFAULTNUMBERPROFILES).toInt();
|
||||
QFileInfo fileinfo(fileLocation);
|
||||
if (fileinfo.exists() && (fileinfo.suffix() == "xml" || fileinfo.suffix() == "amgp"))
|
||||
checkForUnsavedProfile(-1);
|
||||
|
||||
if (!joystick->isDeviceEdited())
|
||||
{
|
||||
int searchIndex = configBox->findData(fileinfo.absoluteFilePath());
|
||||
if (searchIndex == -1)
|
||||
int numberRecentProfiles = settings->value("NumberRecentProfiles", DEFAULTNUMBERPROFILES).toInt();
|
||||
QFileInfo fileinfo(fileLocation);
|
||||
if (fileinfo.exists() && (fileinfo.suffix() == "xml" || fileinfo.suffix() == "amgp"))
|
||||
{
|
||||
if (numberRecentProfiles > 0 && configBox->count() == numberRecentProfiles+1)
|
||||
int searchIndex = configBox->findData(fileinfo.absoluteFilePath());
|
||||
if (searchIndex == -1)
|
||||
{
|
||||
configBox->removeItem(numberRecentProfiles-1);
|
||||
//configBox->removeItem(5);
|
||||
disconnectCheckUnsavedEvent();
|
||||
disconnectMainComboBoxEvents();
|
||||
|
||||
if (numberRecentProfiles > 0 && configBox->count() == numberRecentProfiles+1)
|
||||
{
|
||||
configBox->removeItem(numberRecentProfiles-1);
|
||||
//configBox->removeItem(5);
|
||||
}
|
||||
configBox->insertItem(1, fileinfo.baseName(), fileinfo.absoluteFilePath());
|
||||
|
||||
reconnectCheckUnsavedEvent();
|
||||
reconnectMainComboBoxEvents();
|
||||
|
||||
configBox->setCurrentIndex(1);
|
||||
emit joystickConfigChanged(joystick->getJoyNumber());
|
||||
}
|
||||
else if (searchIndex != configBox->currentIndex())
|
||||
{
|
||||
configBox->setCurrentIndex(searchIndex);
|
||||
emit joystickConfigChanged(joystick->getJoyNumber());
|
||||
}
|
||||
configBox->insertItem(1, fileinfo.baseName(), fileinfo.absoluteFilePath());
|
||||
configBox->setCurrentIndex(1);
|
||||
emit joystickConfigChanged(joystick->getJoyNumber());
|
||||
}
|
||||
else if (searchIndex != configBox->currentIndex())
|
||||
{
|
||||
configBox->setCurrentIndex(searchIndex);
|
||||
emit joystickConfigChanged(joystick->getJoyNumber());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1436,7 +1454,10 @@ void JoyTabWidget::checkForUnsavedProfile(int newindex)
|
||||
disconnectCheckUnsavedEvent();
|
||||
disconnectMainComboBoxEvents();
|
||||
|
||||
configBox->setCurrentIndex(comboBoxIndex);
|
||||
if (configBox->currentIndex() != comboBoxIndex)
|
||||
{
|
||||
configBox->setCurrentIndex(comboBoxIndex);
|
||||
}
|
||||
|
||||
QMessageBox msg;
|
||||
msg.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
|
||||
@@ -1457,7 +1478,11 @@ void JoyTabWidget::checkForUnsavedProfile(int newindex)
|
||||
saveConfigFile();
|
||||
reconnectCheckUnsavedEvent();
|
||||
reconnectMainComboBoxEvents();
|
||||
configBox->setCurrentIndex(newindex);
|
||||
if (newindex > -1)
|
||||
{
|
||||
configBox->setCurrentIndex(newindex);
|
||||
}
|
||||
|
||||
}
|
||||
else if (status == QMessageBox::Discard)
|
||||
{
|
||||
@@ -1465,7 +1490,11 @@ void JoyTabWidget::checkForUnsavedProfile(int newindex)
|
||||
configBox->setItemText(comboBoxIndex, oldProfileName);
|
||||
reconnectCheckUnsavedEvent();
|
||||
reconnectMainComboBoxEvents();
|
||||
configBox->setCurrentIndex(newindex);
|
||||
if (newindex > -1)
|
||||
{
|
||||
configBox->setCurrentIndex(newindex);
|
||||
}
|
||||
|
||||
}
|
||||
else if (status == QMessageBox::Cancel)
|
||||
{
|
||||
|
||||
@@ -33,7 +33,6 @@ public:
|
||||
int getCurrentConfigIndex();
|
||||
QString getCurrentConfigName();
|
||||
QString getConfigName(int index);
|
||||
void loadConfigFile(QString fileLocation);
|
||||
InputDevice *getJoystick();
|
||||
void unloadConfig();
|
||||
bool isDisplayingNames();
|
||||
@@ -144,6 +143,7 @@ public slots:
|
||||
void changeNameDisplay(bool displayNames);
|
||||
void changeCurrentSet(int index);
|
||||
void refreshSetButtons();
|
||||
void loadConfigFile(QString fileLocation);
|
||||
|
||||
private slots:
|
||||
void saveConfigFile();
|
||||
@@ -169,7 +169,7 @@ private slots:
|
||||
void changeSetEight();
|
||||
void displayProfileEditNotification();
|
||||
void removeProfileEditNotification();
|
||||
void checkForUnsavedProfile(int newindex);
|
||||
void checkForUnsavedProfile(int newindex=-1);
|
||||
void refreshButtons();
|
||||
|
||||
void checkStickDisplay();
|
||||
|
||||
@@ -274,6 +274,22 @@ void SimpleKeyGrabberButton::setValue(int value, JoyButtonSlot::JoySlotInputActi
|
||||
setText(buttonslot.getSlotString());
|
||||
}
|
||||
|
||||
void SimpleKeyGrabberButton::setValue(QString value, JoyButtonSlot::JoySlotInputAction mode)
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case JoyButtonSlot::JoyLoadProfile:
|
||||
{
|
||||
buttonslot.setTextData(value);
|
||||
buttonslot.setSlotMode(mode);
|
||||
edited = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
setText(buttonslot.getSlotString());
|
||||
}
|
||||
|
||||
JoyButtonSlot* SimpleKeyGrabberButton::getValue()
|
||||
{
|
||||
return &buttonslot;
|
||||
|
||||
@@ -16,6 +16,7 @@ public:
|
||||
|
||||
void setValue(int value, unsigned int alias, JoyButtonSlot::JoySlotInputAction mode=JoyButtonSlot::JoyKeyboard);
|
||||
void setValue(int value, JoyButtonSlot::JoySlotInputAction mode=JoyButtonSlot::JoyKeyboard);
|
||||
void setValue(QString value, JoyButtonSlot::JoySlotInputAction mode=JoyButtonSlot::JoyLoadProfile);
|
||||
JoyButtonSlot* getValue();
|
||||
bool isEdited();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user