-
-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Connect JoySensorButtons sensor GUI buttons
The buttons from the last commit were just dummies. The move forward with adding functionality, add a new JobButton type JoySensorButton which connects the GUI button with the JoySensor object. Add more boilerplate for the scaffold and connect QT signals/slots. The buttons still do nothing yet.
- Loading branch information
Showing
12 changed files
with
438 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
/* antimicrox Gamepad to KB+M event mapper | ||
* Copyright (C) 2022 Max Maisel <max.maisel@posteo.de> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "joysensorbutton.h" | ||
|
||
#include "event.h" | ||
#include "globalvariables.h" | ||
#include "joysensor.h" | ||
#include "joybutton.h" | ||
#include "setjoystick.h" | ||
#include "vdpad.h" | ||
|
||
#include <cmath> | ||
|
||
#include <QDebug> | ||
|
||
JoySensorButton::JoySensorButton(JoySensor *sensor, | ||
int index, int originset, SetJoystick *parentSet, QObject *parent) | ||
: JoyGradientButton(index, originset, parentSet, parent), | ||
m_sensor(sensor) | ||
{ | ||
} | ||
|
||
QString JoySensorButton::getPartialName(bool forceFullFormat, bool displayNames) const | ||
{ | ||
QString temp = QString(m_sensor->getPartialName(forceFullFormat, displayNames)); | ||
temp.append(": "); | ||
|
||
/* if (!buttonName.isEmpty() && displayNames) | ||
{ | ||
if (forceFullFormat) | ||
{ | ||
temp.append(tr("Button")).append(" "); | ||
} | ||
temp.append(buttonName); | ||
} else if (!defaultButtonName.isEmpty() && displayNames) | ||
{ | ||
if (forceFullFormat) | ||
{ | ||
temp.append(tr("Button")).append(" "); | ||
} | ||
temp.append(defaultButtonName); | ||
} else | ||
{ | ||
QString buttontype = QString(); | ||
switch (m_index) | ||
{ | ||
case 0: | ||
buttontype = tr("Negative"); | ||
break; | ||
case 1: | ||
buttontype = tr("Positive"); | ||
break; | ||
default: | ||
buttontype = tr("Unknown"); | ||
break; | ||
} | ||
temp.append(tr("Button")).append(" ").append(buttontype); | ||
}*/ | ||
|
||
return temp; | ||
} | ||
|
||
//QString JoyAxisButton::getXmlName() { return GlobalVariables::JoyAxisButton::xmlName; } | ||
|
||
/*void JoyAxisButton::setChangeSetCondition(SetChangeCondition condition, bool passive, bool updateActiveString) | ||
{ | ||
SetChangeCondition oldCondition = setSelectionCondition; | ||
if ((condition != setSelectionCondition) && !passive) | ||
{ | ||
if ((condition == SetChangeWhileHeld) || (condition == SetChangeTwoWay)) | ||
{ | ||
// Set new condition | ||
emit setAssignmentChanged(m_index, m_axis->getIndex(), setSelection, condition); | ||
} else if ((setSelectionCondition == SetChangeWhileHeld) || (setSelectionCondition == SetChangeTwoWay)) | ||
{ | ||
// Remove old condition | ||
emit setAssignmentChanged(m_index, m_axis->getIndex(), setSelection, SetChangeDisabled); | ||
} | ||
setSelectionCondition = condition; | ||
} else if (passive) | ||
{ | ||
setSelectionCondition = condition; | ||
} | ||
if (setSelectionCondition == SetChangeDisabled) | ||
{ | ||
setChangeSetSelection(-1); | ||
} | ||
if (setSelectionCondition != oldCondition) | ||
{ | ||
if (updateActiveString) | ||
{ | ||
buildActiveZoneSummaryString(); | ||
} | ||
emit propertyUpdated(); | ||
} | ||
}*/ | ||
|
||
/** | ||
* @brief Get the distance that an element is away from its assigned | ||
* dead zone | ||
* @return Normalized distance away from dead zone | ||
*/ | ||
//double JoyAxisButton::getDistanceFromDeadZone() { return m_axis->getDistanceFromDeadZone(); } | ||
|
||
/** | ||
* @brief Get the distance factor that should be used for mouse movement | ||
* @return Distance factor that should be used for mouse movement | ||
*/ | ||
//double JoyAxisButton::getMouseDistanceFromDeadZone() { return this->getDistanceFromDeadZone(); } | ||
|
||
/** | ||
* @brief Set the turbo mode that the button should use | ||
* @param Mode that should be used | ||
*/ | ||
/*void JoyAxisButton::setTurboMode(TurboMode mode) | ||
{ | ||
if (isPartRealAxis()) | ||
{ | ||
currentTurboMode = mode; | ||
} | ||
}*/ | ||
|
||
/** | ||
* @brief Check if button should be considered a part of a real controller | ||
* axis. Needed for some dialogs so the program won't have to resort to | ||
* type checking. | ||
* @return Status of being part of a real controller axis | ||
*/ | ||
bool JoySensorButton::isPartRealAxis() { return false; } | ||
|
||
/*double JoyAxisButton::getAccelerationDistance() { return m_axis->getRawDistance(m_axis->getCurrentThrottledValue()); } | ||
double JoyAxisButton::getLastAccelerationDistance() { return m_axis->getRawDistance(m_axis->getLastKnownThrottleValue()); } | ||
double JoyAxisButton::getLastMouseDistanceFromDeadZone() | ||
{ | ||
double distance = 0.0; | ||
if (m_axis->getAxisButtonByValue(m_axis->getLastKnownThrottleValue()) == this) | ||
{ | ||
distance = m_axis->getDistanceFromDeadZone(m_axis->getLastKnownThrottleValue()); | ||
} | ||
return distance; | ||
}*/ | ||
|
||
JoySensor *JoySensorButton::getSensor() const { return m_sensor; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* antimicrox Gamepad to KB+M event mapper | ||
* Copyright (C) 2022 Max Maisel <max.maisel@posteo.de> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
#pragma once | ||
|
||
#include "joybuttontypes/joygradientbutton.h" | ||
#include "logger.h" | ||
|
||
class VDPad; | ||
class SetJoystick; | ||
class JoySensor; | ||
|
||
class JoySensorButton : public JoyGradientButton | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
explicit JoySensorButton(JoySensor *sensor, int index, int originset, SetJoystick *parentSet, QObject *parent); | ||
|
||
virtual QString getPartialName(bool forceFullFormat = false, bool displayNames = false) const; | ||
/*virtual QString getXmlName(); | ||
virtual double getDistanceFromDeadZone(); | ||
virtual double getMouseDistanceFromDeadZone(); | ||
virtual double getLastMouseDistanceFromDeadZone(); | ||
virtual void setChangeSetCondition(SetChangeCondition condition, bool passive = false, bool updateActiveString = true); | ||
virtual void setVDPad(VDPad *vdpad); | ||
virtual void setTurboMode(TurboMode mode);*/ | ||
virtual bool isPartRealAxis(); | ||
|
||
/*virtual double getAccelerationDistance(); | ||
virtual double getLastAccelerationDistance();*/ | ||
|
||
JoySensor *getSensor() const; | ||
|
||
signals: | ||
void setAssignmentChanged(int current_button, int axis_index, int associated_set, int mode); | ||
|
||
private: | ||
JoySensor *m_sensor; | ||
}; |
Oops, something went wrong.