diff --git a/companion/src/modeledit/node.cpp b/companion/src/modeledit/node.cpp index b421490f9..33e92e0ca 100644 --- a/companion/src/modeledit/node.cpp +++ b/companion/src/modeledit/node.cpp @@ -122,6 +122,15 @@ qreal Node::getX() 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() { if(scene()) @@ -132,6 +141,15 @@ qreal Node::getY() return 0; } +void Node::setY(qreal newY) +{ + if(scene()) + { + QRectF rect = scene()->sceneRect(); + QGraphicsObject::setY(rect.top() + (newY+1) * rect.height()/2); + } +} + QList Node::edges() const { return edgeList; diff --git a/companion/src/modeledit/node.h b/companion/src/modeledit/node.h index 9bc699cb6..8d80e14c2 100644 --- a/companion/src/modeledit/node.h +++ b/companion/src/modeledit/node.h @@ -72,6 +72,8 @@ class Node : public QGraphicsObject int getBallSize() {return ballSize;} qreal getX(); qreal getY(); + void setX(qreal newX); + void setY(qreal newX); void setCenteringX(bool val) {centerX = val;} void setCenteringY(bool val) {centerY = val;} diff --git a/companion/src/simulation/joystickdialog.cpp b/companion/src/simulation/joystickdialog.cpp index 431717324..79b3b1c9a 100644 --- a/companion/src/simulation/joystickdialog.cpp +++ b/companion/src/simulation/joystickdialog.cpp @@ -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}; foreach(QComboBox *cb, findChildren(QRegExp("jsmapCB_[0-9]+"))) { int axe=cb->objectName().mid(cb->objectName().lastIndexOf("_")+1).toInt()-1; - int stick=cb->currentIndex(); - if (stick > 0) { + int stick=cb->currentIndex() - 1; + qDebug() << "joystick mapping " << cb->objectName() <<"axe:" << axe << "stick:" << stick; + if (stick >= 0) { g.joystick[stick].stick_axe( axe ); g.joystick[stick].stick_max( jscal[axe][2] ); g.joystick[stick].stick_med( jscal[axe][1] ); diff --git a/companion/src/simulation/simulatordialog.cpp b/companion/src/simulation/simulatordialog.cpp index 7ddce661c..b11b985a8 100644 --- a/companion/src/simulation/simulatordialog.cpp +++ b/companion/src/simulation/simulatordialog.cpp @@ -298,7 +298,7 @@ void SimulatorDialog::initUi(T * ui) for (int j=0; j<8; j++){ int axe = g.joystick[j].stick_axe(); if (axe>=0 && axe<8) { - jsmap[axe]=j; + jsmap[axe]=j+1; jscal[axe][0] = g.joystick[j].stick_min(); jscal[axe][1] = g.joystick[j].stick_med(); jscal[axe][2] = g.joystick[j].stick_max(); @@ -987,37 +987,28 @@ void SimulatorDialog::onjoystickAxisValueChanged(int axis, int value) if (jscal[axis][3]==1) { stickval*=-1; } - if (stick==1 || stick==2) { - float currX=nodeRight->getX(); - float currY=nodeRight->getY(); - if (stick==1 ) { - nodeRight->setPos(currX*100-10,-stickval*100/1024-10); - } - if (stick==2) { - nodeRight->setPos(stickval*100/1024-10,currY*100-10); - } - } - else if (stick==3 || stick==4) { - float currX=nodeLeft->getX(); - float currY=nodeLeft->getY(); - 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) { + if (stick==1 ) { + nodeRight->setY(-stickval/1024.0); + } + else if (stick==2) { + nodeRight->setX(stickval/1024.0); + } + else if (stick==3) { + nodeLeft->setY(-stickval/1024.0); + } + else if (stick==4) { + nodeLeft->setX(stickval/1024.0); + } + else if (stick==5) { dialP_1->setValue(stickval); } - if (stick==6) { + else if (stick==6) { dialP_2->setValue(stickval); } - if (stick==7) { + else if (stick==7) { dialP_3->setValue(stickval); } - if (stick==8 && dialP_4) { + else if (stick==8 && dialP_4) { dialP_4->setValue(stickval); } }