mirror of
https://github.com/opentx/opentx.git
synced 2025-07-20 14:55:13 +03:00
Fixes #1731: Joystick calibration crash after channel assignment
also additional fixes to stick postion mapping
This commit is contained in:
parent
5dc38fffe3
commit
24e97a78af
4 changed files with 40 additions and 28 deletions
|
@ -122,6 +122,15 @@ qreal Node::getX()
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Node::setX(qreal newX)
|
||||||
|
{
|
||||||
|
if(scene())
|
||||||
|
{
|
||||||
|
QRectF rect = scene()->sceneRect();
|
||||||
|
QGraphicsObject::setX(rect.left() + (newX+1) * rect.width()/2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
qreal Node::getY()
|
qreal Node::getY()
|
||||||
{
|
{
|
||||||
if(scene())
|
if(scene())
|
||||||
|
@ -132,6 +141,15 @@ qreal Node::getY()
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Node::setY(qreal newY)
|
||||||
|
{
|
||||||
|
if(scene())
|
||||||
|
{
|
||||||
|
QRectF rect = scene()->sceneRect();
|
||||||
|
QGraphicsObject::setY(rect.top() + (newY+1) * rect.height()/2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QList<Edge *> Node::edges() const
|
QList<Edge *> Node::edges() const
|
||||||
{
|
{
|
||||||
return edgeList;
|
return edgeList;
|
||||||
|
|
|
@ -72,6 +72,8 @@ class Node : public QGraphicsObject
|
||||||
int getBallSize() {return ballSize;}
|
int getBallSize() {return ballSize;}
|
||||||
qreal getX();
|
qreal getX();
|
||||||
qreal getY();
|
qreal getY();
|
||||||
|
void setX(qreal newX);
|
||||||
|
void setY(qreal newX);
|
||||||
|
|
||||||
void setCenteringX(bool val) {centerX = val;}
|
void setCenteringX(bool val) {centerX = val;}
|
||||||
void setCenteringY(bool val) {centerY = val;}
|
void setCenteringY(bool val) {centerY = val;}
|
||||||
|
|
|
@ -137,8 +137,9 @@ void joystickDialog::on_okButton_clicked() {
|
||||||
QCheckBox * ib[]={ui->ChInv_1, ui->ChInv_2, ui->ChInv_3, ui->ChInv_4, ui->ChInv_5, ui->ChInv_6, ui->ChInv_7, ui->ChInv_8};
|
QCheckBox * ib[]={ui->ChInv_1, ui->ChInv_2, ui->ChInv_3, ui->ChInv_4, ui->ChInv_5, ui->ChInv_6, ui->ChInv_7, ui->ChInv_8};
|
||||||
foreach(QComboBox *cb, findChildren<QComboBox *>(QRegExp("jsmapCB_[0-9]+"))) {
|
foreach(QComboBox *cb, findChildren<QComboBox *>(QRegExp("jsmapCB_[0-9]+"))) {
|
||||||
int axe=cb->objectName().mid(cb->objectName().lastIndexOf("_")+1).toInt()-1;
|
int axe=cb->objectName().mid(cb->objectName().lastIndexOf("_")+1).toInt()-1;
|
||||||
int stick=cb->currentIndex();
|
int stick=cb->currentIndex() - 1;
|
||||||
if (stick > 0) {
|
qDebug() << "joystick mapping " << cb->objectName() <<"axe:" << axe << "stick:" << stick;
|
||||||
|
if (stick >= 0) {
|
||||||
g.joystick[stick].stick_axe( axe );
|
g.joystick[stick].stick_axe( axe );
|
||||||
g.joystick[stick].stick_max( jscal[axe][2] );
|
g.joystick[stick].stick_max( jscal[axe][2] );
|
||||||
g.joystick[stick].stick_med( jscal[axe][1] );
|
g.joystick[stick].stick_med( jscal[axe][1] );
|
||||||
|
|
|
@ -298,7 +298,7 @@ void SimulatorDialog::initUi(T * ui)
|
||||||
for (int j=0; j<8; j++){
|
for (int j=0; j<8; j++){
|
||||||
int axe = g.joystick[j].stick_axe();
|
int axe = g.joystick[j].stick_axe();
|
||||||
if (axe>=0 && axe<8) {
|
if (axe>=0 && axe<8) {
|
||||||
jsmap[axe]=j;
|
jsmap[axe]=j+1;
|
||||||
jscal[axe][0] = g.joystick[j].stick_min();
|
jscal[axe][0] = g.joystick[j].stick_min();
|
||||||
jscal[axe][1] = g.joystick[j].stick_med();
|
jscal[axe][1] = g.joystick[j].stick_med();
|
||||||
jscal[axe][2] = g.joystick[j].stick_max();
|
jscal[axe][2] = g.joystick[j].stick_max();
|
||||||
|
@ -987,37 +987,28 @@ void SimulatorDialog::onjoystickAxisValueChanged(int axis, int value)
|
||||||
if (jscal[axis][3]==1) {
|
if (jscal[axis][3]==1) {
|
||||||
stickval*=-1;
|
stickval*=-1;
|
||||||
}
|
}
|
||||||
if (stick==1 || stick==2) {
|
if (stick==1 ) {
|
||||||
float currX=nodeRight->getX();
|
nodeRight->setY(-stickval/1024.0);
|
||||||
float currY=nodeRight->getY();
|
}
|
||||||
if (stick==1 ) {
|
else if (stick==2) {
|
||||||
nodeRight->setPos(currX*100-10,-stickval*100/1024-10);
|
nodeRight->setX(stickval/1024.0);
|
||||||
}
|
}
|
||||||
if (stick==2) {
|
else if (stick==3) {
|
||||||
nodeRight->setPos(stickval*100/1024-10,currY*100-10);
|
nodeLeft->setY(-stickval/1024.0);
|
||||||
}
|
}
|
||||||
}
|
else if (stick==4) {
|
||||||
else if (stick==3 || stick==4) {
|
nodeLeft->setX(stickval/1024.0);
|
||||||
float currX=nodeLeft->getX();
|
}
|
||||||
float currY=nodeLeft->getY();
|
else if (stick==5) {
|
||||||
if (stick==3) {
|
|
||||||
nodeLeft->setPos(currX*100-10,-stickval*100/1024-10);
|
|
||||||
}
|
|
||||||
if (stick==4) {
|
|
||||||
nodeLeft->setPos(stickval*100/1024-10,currY*100-10);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (stick==5) {
|
|
||||||
dialP_1->setValue(stickval);
|
dialP_1->setValue(stickval);
|
||||||
}
|
}
|
||||||
if (stick==6) {
|
else if (stick==6) {
|
||||||
dialP_2->setValue(stickval);
|
dialP_2->setValue(stickval);
|
||||||
}
|
}
|
||||||
if (stick==7) {
|
else if (stick==7) {
|
||||||
dialP_3->setValue(stickval);
|
dialP_3->setValue(stickval);
|
||||||
}
|
}
|
||||||
if (stick==8 && dialP_4) {
|
else if (stick==8 && dialP_4) {
|
||||||
dialP_4->setValue(stickval);
|
dialP_4->setValue(stickval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue