mirror of
https://github.com/Rosalie241/RMG.git
synced 2026-11-13 09:38:43 +01:00
RMG-Input: implement octagonal input range
The implementation takes configured deadzone and range into account, with 9% deadzone equating to the real N64 deadzone.
This commit is contained in:
1 parent
24eccb5489
commit
e1180bc574
6 files changed
+109
-36
No files matched your search
@@ -170,23 +170,18 @@ void ControllerImageWidget::paintEvent(QPaintEvent *event)
|
||||
const double maxOffsetx = maxOffsety;
|
||||
const double dist = sqrt(pow(this->xAxisState, 2) + pow(this->yAxisState, 2));
|
||||
|
||||
// take deadzone into account
|
||||
if (dist > this->deadzoneValue)
|
||||
{
|
||||
offsetx = (maxOffsetx / 100 * this->xAxisState);
|
||||
offsety = (maxOffsety / 100 * this->yAxisState);
|
||||
}
|
||||
int octagonX = 0, octagonY = 0;
|
||||
simulateOctagon(
|
||||
this->xAxisState / 100.0, // inputX
|
||||
this->yAxisState / 100.0, // inputY
|
||||
this->deadzoneValue / 100.0, // deadzoneFactor
|
||||
this->rangeValue / 100.0, // scalingFactor
|
||||
octagonX, // outputX
|
||||
octagonY // outputY
|
||||
);
|
||||
|
||||
// take circle range into account
|
||||
if (dist > 100)
|
||||
{
|
||||
offsetx = (maxOffsetx / 100 * (this->xAxisState / dist * 100));
|
||||
offsety = (maxOffsety / 100 * (this->yAxisState / dist * 100));
|
||||
}
|
||||
|
||||
// take range into account
|
||||
offsetx = offsetx / 100 * this->rangeValue;
|
||||
offsety = offsety / 100 * this->rangeValue;
|
||||
offsetx = octagonX * (maxOffsetx / N64_AXIS_PEAK);
|
||||
offsety = octagonY * (maxOffsety / N64_AXIS_PEAK);
|
||||
|
||||
// adjust rect with offset
|
||||
rectF.adjust(
|
||||
|
||||
Reference in new issue
Block a user