Merge pull request #121 from OpenVR-Advanced-Settings/alpha-kung

Clean up offsets ui and add snap turn settings
This commit is contained in:
Kung-vr
2019-03-19 16:02:08 +09:00
committed by GitHub
8 changed files with 182 additions and 106 deletions
+1 -1
View File
@@ -177,7 +177,7 @@
"/actions/main/in/SwapSpaceDragToLeftHandOverride" : "Swap Active Space Drag to Left Hand (Override)", "/actions/main/in/SwapSpaceDragToLeftHandOverride" : "Swap Active Space Drag to Left Hand (Override)",
"/actions/main/in/SwapSpaceDragToRightHandOverride" : "Swap Active Space Drag to Right Hand (Override)", "/actions/main/in/SwapSpaceDragToRightHandOverride" : "Swap Active Space Drag to Right Hand (Override)",
"/actions/main/in/GravityToggle" : "Gravity Toggle", "/actions/main/in/GravityToggle" : "Gravity Toggle",
"/actions/main/in/GravityReverse" : "Gravity Reverse", "/actions/main/in/GravityReverse" : "Gravity Reverse (Held)",
"/actions/main/in/HeightToggle" : "Height Toggle", "/actions/main/in/HeightToggle" : "Height Toggle",
"/actions/main/in/ResetOffsets" : "Reset Offsets", "/actions/main/in/ResetOffsets" : "Reset Offsets",
"/actions/main/in/SnapTurnLeft" : "Snap-Turn Left", "/actions/main/in/SnapTurnLeft" : "Snap-Turn Left",
+1 -61
View File
@@ -6,7 +6,7 @@ import "common"
MyStackViewPage { MyStackViewPage {
headerText: "Space Settings" headerText: "Space Offsets"
content: ColumnLayout { content: ColumnLayout {
spacing: 18 spacing: 18
@@ -314,58 +314,10 @@ MyStackViewPage {
} }
} }
} }
MyToggleButton {
id: spaceRotateHandToggle
text: "Enable Space-Turn Binding"
onCheckedChanged: {
MoveCenterTabController.rotateHand = this.checked
}
}
MyText {
text: "Note: TurnSignal will ignore turning during Space-Turn rotation."
font.pointSize: 15.0
}
} }
} }
} }
GroupBox {
Layout.fillWidth: true
label: MyText {
leftPadding: 10
text: "Space Drag Binding"
bottomPadding: -10
}
background: Rectangle {
color: "transparent"
border.color: "#ffffff"
radius: 8
}
ColumnLayout {
RowLayout {
Layout.fillWidth: true
MyToggleButton {
id: moveShortcutLeft
text: "Enable Left Hand"
onCheckedChanged: {
MoveCenterTabController.moveShortcutLeft = this.checked
}
}
MyToggleButton {
id: moveShortcutRight
text: "Enable Right Hand"
onCheckedChanged: {
MoveCenterTabController.moveShortcutRight = this.checked
}
}
}
}
}
ColumnLayout { ColumnLayout {
RowLayout { RowLayout {
@@ -397,13 +349,10 @@ MyStackViewPage {
Component.onCompleted: { Component.onCompleted: {
spaceAdjustChaperoneToggle.checked = MoveCenterTabController.adjustChaperone spaceAdjustChaperoneToggle.checked = MoveCenterTabController.adjustChaperone
spaceRotateHandToggle.checked = MoveCenterTabController.rotateHand
spaceMoveXText.text = MoveCenterTabController.offsetX.toFixed(2) spaceMoveXText.text = MoveCenterTabController.offsetX.toFixed(2)
spaceMoveYText.text = MoveCenterTabController.offsetY.toFixed(2) spaceMoveYText.text = MoveCenterTabController.offsetY.toFixed(2)
spaceMoveZText.text = MoveCenterTabController.offsetZ.toFixed(2) spaceMoveZText.text = MoveCenterTabController.offsetZ.toFixed(2)
spaceRotationSlider.value = MoveCenterTabController.rotation spaceRotationSlider.value = MoveCenterTabController.rotation
moveShortcutRight.checked = MoveCenterTabController.moveShortcutRight
moveShortcutLeft.checked = MoveCenterTabController.moveShortcutLeft
lockXToggle.checked = MoveCenterTabController.lockXToggle lockXToggle.checked = MoveCenterTabController.lockXToggle
lockYToggle.checked = MoveCenterTabController.lockYToggle lockYToggle.checked = MoveCenterTabController.lockYToggle
lockZToggle.checked = MoveCenterTabController.lockZToggle lockZToggle.checked = MoveCenterTabController.lockZToggle
@@ -445,15 +394,6 @@ MyStackViewPage {
} }
onAdjustChaperoneChanged: { onAdjustChaperoneChanged: {
spaceAdjustChaperoneToggle.checked = MoveCenterTabController.adjustChaperone spaceAdjustChaperoneToggle.checked = MoveCenterTabController.adjustChaperone
}
onRotateHandChanged: {
spaceRotateHandToggle.checked = MoveCenterTabController.rotateHand
}
onMoveShortcutRightChanged: {
moveShortcutRight.checked = MoveCenterTabController.moveShortcutRight
}
onMoveShortcutLeftChanged: {
moveShortcutLeft.checked = MoveCenterTabController.moveShortcutLeft
} }
onLockXToggleChanged: { onLockXToggleChanged: {
lockXToggle.checked = MoveCenterTabController.lockXToggle lockXToggle.checked = MoveCenterTabController.lockXToggle
+3
View File
@@ -7,6 +7,7 @@ import "space_drag"
import "space_turn" import "space_turn"
import "height_toggle" import "height_toggle"
import "gravity" import "gravity"
import "snap_turn"
MyStackViewPage { MyStackViewPage {
headerText: "Motion Settings" headerText: "Motion Settings"
@@ -22,6 +23,8 @@ MyStackViewPage {
GravityGroupBox { id: gravityGroupBox } GravityGroupBox { id: gravityGroupBox }
SnapTurnGroupBox { id: snapTurnGroupBox }
Item { Item {
Layout.fillHeight: true Layout.fillHeight: true
} }
@@ -47,7 +47,7 @@ GroupBox {
MyText { MyText {
text: "Gravity Strength (+ is down):" text: "Gravity Strength (+ is down):"
horizontalAlignment: Text.AlignRight horizontalAlignment: Text.AlignRight
Layout.rightMargin: 10 Layout.rightMargin: 2
} }
MyTextField { MyTextField {
@@ -118,14 +118,14 @@ GroupBox {
} }
MyText { MyText {
text: "Fling Strength" text: "Fling Strength:"
horizontalAlignment: Text.AlignRight horizontalAlignment: Text.AlignRight
Layout.rightMargin: 10 Layout.rightMargin: 2
} }
MyTextField { MyTextField {
id: flingStrengthText id: flingStrengthText
text: "1.00" text: "1.0"
keyBoardUID: 153 keyBoardUID: 153
Layout.preferredWidth: 120 Layout.preferredWidth: 120
Layout.leftMargin: 10 Layout.leftMargin: 10
@@ -134,14 +134,46 @@ GroupBox {
function onInputEvent(input) { function onInputEvent(input) {
var val = parseFloat(input) var val = parseFloat(input)
if (!isNaN(val)) { if (!isNaN(val)) {
MoveCenterTabController.flingStrength = val.toFixed(2) MoveCenterTabController.flingStrength = val.toFixed(1)
text = MoveCenterTabController.flingStrength.toFixed(2) text = MoveCenterTabController.flingStrength.toFixed(1)
} else { } else {
text = MoveCenterTabController.flingStrength.toFixed(2) text = MoveCenterTabController.flingStrength.toFixed(1)
} }
} }
} }
MyPushButton2 {
Layout.preferredWidth: 50
text: "1x"
onClicked: {
MoveCenterTabController.flingStrength = 1.0
}
}
MyPushButton2 {
Layout.preferredWidth: 50
text: "2x"
onClicked: {
MoveCenterTabController.flingStrength = 2.0
}
}
MyPushButton2 {
Layout.preferredWidth: 50
text: "3x"
onClicked: {
MoveCenterTabController.flingStrength = 3.0
}
}
MyPushButton2 {
Layout.preferredWidth: 50
text: "4x"
onClicked: {
MoveCenterTabController.flingStrength = 4.0
}
}
} }
} }
@@ -47,7 +47,7 @@ GroupBox {
MyText { MyText {
text: "Height Offset (+ is down):" text: "Height Offset (+ is down):"
horizontalAlignment: Text.AlignRight horizontalAlignment: Text.AlignRight
Layout.rightMargin: 10 Layout.rightMargin: 2
} }
MyTextField { MyTextField {
@@ -64,7 +64,7 @@ GroupBox {
MoveCenterTabController.heightToggleOffset = val.toFixed(2) MoveCenterTabController.heightToggleOffset = val.toFixed(2)
text = MoveCenterTabController.heightToggleOffset.toFixed(2) text = MoveCenterTabController.heightToggleOffset.toFixed(2)
} else { } else {
text = MoveCenterTabController.heighToggleOffset.toFixed(2) text = MoveCenterTabController.heightToggleOffset.toFixed(2)
} }
} }
} }
@@ -0,0 +1,100 @@
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.3
import ovras.advsettings 1.0
import "../../common"
GroupBox {
id: snapTurnGroupBox
Layout.fillWidth: true
ColumnLayout {
anchors.fill: parent
RowLayout {
Layout.fillWidth: true
MyText {
text: "Snap Turn Angle:"
horizontalAlignment: Text.AlignRight
Layout.rightMargin: 2
}
MyTextField {
id: snapTurnAngleText
text: "45°"
keyBoardUID: 154
Layout.preferredWidth: 150
Layout.leftMargin: 10
horizontalAlignment: Text.AlignHCenter
function onInputEvent(input) {
var val = parseFloat(input)
if (!isNaN(val)) {
val = val % 180
MoveCenterTabController.snapTurnAngle = val.toFixed(2) * 100
text = ( Math.round( MoveCenterTabController.snapTurnAngle / 100 ) ) + "°"
} else {
text = ( Math.round( MoveCenterTabController.snapTurnAngle / 100 ) ) + "°"
}
}
}
Item {
Layout.fillWidth: true
}
MyPushButton {
id: snapTurnButton15
Layout.preferredWidth: 90
text:"15°"
onClicked: {
MoveCenterTabController.snapTurnAngle = 1500
}
}
MyPushButton {
id: snapTurnButton30
Layout.preferredWidth: 90
text:"30°"
onClicked: {
MoveCenterTabController.snapTurnAngle = 3000
}
}
MyPushButton {
id: snapTurnButton45
Layout.preferredWidth: 90
text:"45°"
onClicked: {
MoveCenterTabController.snapTurnAngle = 4500
}
}
MyPushButton {
id: snapTurnButton90
Layout.preferredWidth: 90
text:"90°"
onClicked: {
MoveCenterTabController.snapTurnAngle = 9000
}
}
MyPushButton {
id: snapTurnButton180
Layout.preferredWidth: 90
text:"180°"
onClicked: {
MoveCenterTabController.snapTurnAngle = 18000
}
}
}
}
Component.onCompleted: {
snapTurnAngleText.text = ( Math.round( MoveCenterTabController.snapTurnAngle / 100 ) ) + "°"
}
Connections {
target: MoveCenterTabController
onSnapTurnAngleChanged: {
snapTurnAngleText.text = ( Math.round( MoveCenterTabController.snapTurnAngle / 100 ) ) + "°"
}
}
}
+30 -26
View File
@@ -46,11 +46,6 @@ void MoveCenterTabController::initStage1()
{ {
m_adjustChaperone = value.toBool(); m_adjustChaperone = value.toBool();
} }
value = settings->value( "rotateHand", m_settingsHandTurningEnabled );
if ( value.isValid() && !value.isNull() )
{
m_settingsHandTurningEnabled = value.toBool();
}
value = settings->value( "moveShortcutRight", value = settings->value( "moveShortcutRight",
m_settingsRightHandDragEnabled ); m_settingsRightHandDragEnabled );
if ( value.isValid() && !value.isNull() ) if ( value.isValid() && !value.isNull() )
@@ -83,6 +78,11 @@ void MoveCenterTabController::initStage1()
{ {
m_turnComfortFactor = value.toUInt(); m_turnComfortFactor = value.toUInt();
} }
value = settings->value( "snapTurnAngle", m_snapTurnAngle );
if ( value.isValid() && !value.isNull() )
{
m_snapTurnAngle = value.toInt();
}
value = settings->value( "heightToggleOffset", m_heightToggleOffset ); value = settings->value( "heightToggleOffset", m_heightToggleOffset );
if ( value.isValid() && !value.isNull() ) if ( value.isValid() && !value.isNull() )
{ {
@@ -261,6 +261,28 @@ void MoveCenterTabController::setTempRotation( int value, bool notify )
} }
} }
int MoveCenterTabController::snapTurnAngle() const
{
return m_snapTurnAngle;
}
void MoveCenterTabController::setSnapTurnAngle( int value, bool notify )
{
if ( m_snapTurnAngle != value )
{
m_snapTurnAngle = value;
auto settings = OverlayController::appSettings();
settings->beginGroup( "playspaceSettings" );
settings->setValue( "snapTurnAngle", m_snapTurnAngle );
settings->endGroup();
settings->sync();
if ( notify )
{
emit snapTurnAngleChanged( m_snapTurnAngle );
}
}
}
bool MoveCenterTabController::adjustChaperone() const bool MoveCenterTabController::adjustChaperone() const
{ {
return m_adjustChaperone; return m_adjustChaperone;
@@ -283,25 +305,6 @@ void MoveCenterTabController::setAdjustChaperone( bool value, bool notify )
} }
} }
bool MoveCenterTabController::rotateHand() const
{
return m_settingsHandTurningEnabled;
}
void MoveCenterTabController::setRotateHand( bool value, bool notify )
{
m_settingsHandTurningEnabled = value;
auto settings = OverlayController::appSettings();
settings->beginGroup( "playspaceSettings" );
settings->setValue( "rotateHand", m_settingsHandTurningEnabled );
settings->endGroup();
settings->sync();
if ( notify )
{
emit rotateHandChanged( m_settingsHandTurningEnabled );
}
}
bool MoveCenterTabController::moveShortcutRight() const bool MoveCenterTabController::moveShortcutRight() const
{ {
return m_settingsRightHandDragEnabled; return m_settingsRightHandDragEnabled;
@@ -491,6 +494,7 @@ void MoveCenterTabController::setGravityStrength( float value, bool notify )
{ {
emit gravityStrengthChanged( m_gravityStrength ); emit gravityStrengthChanged( m_gravityStrength );
} }
m_lastGravityUpdateTimePoint = std::chrono::steady_clock::now();
} }
float MoveCenterTabController::flingStrength() const float MoveCenterTabController::flingStrength() const
@@ -1387,7 +1391,7 @@ void MoveCenterTabController::snapTurnLeft( bool snapTurnLeftJustPressed )
// TODO add interface to configure snap angle. // TODO add interface to configure snap angle.
// temporarily hard coded to 45 degrees // temporarily hard coded to 45 degrees
int newRotationAngleDeg = m_rotation - 4500; int newRotationAngleDeg = m_rotation - m_snapTurnAngle;
// Keep angle within -18000 ~ 18000 centidegrees // Keep angle within -18000 ~ 18000 centidegrees
if ( newRotationAngleDeg > 18000 ) if ( newRotationAngleDeg > 18000 )
{ {
@@ -1410,7 +1414,7 @@ void MoveCenterTabController::snapTurnRight( bool snapTurnRightJustPressed )
// TODO add interface to configure snap angle. // TODO add interface to configure snap angle.
// temporarily hard coded to 45 degrees // temporarily hard coded to 45 degrees
int newRotationAngleDeg = m_rotation + 4500; int newRotationAngleDeg = m_rotation + m_snapTurnAngle;
// Keep angle within -18000 ~ 18000 centidegrees // Keep angle within -18000 ~ 18000 centidegrees
if ( newRotationAngleDeg > 18000 ) if ( newRotationAngleDeg > 18000 )
{ {
+6 -9
View File
@@ -34,6 +34,8 @@ class MoveCenterTabController : public QObject
int rotation READ rotation WRITE setRotation NOTIFY rotationChanged ) int rotation READ rotation WRITE setRotation NOTIFY rotationChanged )
Q_PROPERTY( int tempRotation READ tempRotation WRITE setTempRotation NOTIFY Q_PROPERTY( int tempRotation READ tempRotation WRITE setTempRotation NOTIFY
tempRotationChanged ) tempRotationChanged )
Q_PROPERTY( int snapTurnAngle READ snapTurnAngle WRITE setSnapTurnAngle
NOTIFY snapTurnAngleChanged )
Q_PROPERTY( bool adjustChaperone READ adjustChaperone WRITE Q_PROPERTY( bool adjustChaperone READ adjustChaperone WRITE
setAdjustChaperone NOTIFY adjustChaperoneChanged ) setAdjustChaperone NOTIFY adjustChaperoneChanged )
Q_PROPERTY( bool moveShortcutRight READ moveShortcutRight WRITE Q_PROPERTY( bool moveShortcutRight READ moveShortcutRight WRITE
@@ -66,8 +68,6 @@ class MoveCenterTabController : public QObject
requireLockYChanged ) requireLockYChanged )
Q_PROPERTY( bool lockZToggle READ lockZToggle WRITE setLockZ NOTIFY Q_PROPERTY( bool lockZToggle READ lockZToggle WRITE setLockZ NOTIFY
requireLockZChanged ) requireLockZChanged )
Q_PROPERTY( bool rotateHand READ rotateHand WRITE setRotateHand NOTIFY
rotateHandChanged )
private: private:
OverlayController* parent; OverlayController* parent;
@@ -83,8 +83,8 @@ private:
int m_rotation = 0; int m_rotation = 0;
int m_oldRotation = 0; int m_oldRotation = 0;
int m_tempRotation = 0; int m_tempRotation = 0;
int m_snapTurnAngle = 4500;
bool m_adjustChaperone = true; bool m_adjustChaperone = true;
bool m_settingsHandTurningEnabled = false;
bool m_moveShortcutRightPressed = false; bool m_moveShortcutRightPressed = false;
bool m_moveShortcutLeftPressed = false; bool m_moveShortcutLeftPressed = false;
vr::TrackedDeviceIndex_t m_activeMoveController; vr::TrackedDeviceIndex_t m_activeMoveController;
@@ -173,8 +173,8 @@ public:
float offsetZ() const; float offsetZ() const;
int rotation() const; int rotation() const;
int tempRotation() const; int tempRotation() const;
int snapTurnAngle() const;
bool adjustChaperone() const; bool adjustChaperone() const;
bool rotateHand() const;
bool moveShortcutRight() const; bool moveShortcutRight() const;
bool moveShortcutLeft() const; bool moveShortcutLeft() const;
bool turnBindRight() const; bool turnBindRight() const;
@@ -223,13 +223,10 @@ public slots:
void setOffsetZ( float value, bool notify = true ); void setOffsetZ( float value, bool notify = true );
void setRotation( int value, bool notify = true ); void setRotation( int value, bool notify = true );
void setTempRotation( int value, bool notify = true ); void setTempRotation( int value, bool notify = true );
void setSnapTurnAngle( int value, bool notify = true );
void setAdjustChaperone( bool value, bool notify = true ); void setAdjustChaperone( bool value, bool notify = true );
void setRotateHand( bool value, bool notify = true );
void setMoveShortcutRight( bool value, bool notify = true ); void setMoveShortcutRight( bool value, bool notify = true );
void setMoveShortcutLeft( bool value, bool notify = true ); void setMoveShortcutLeft( bool value, bool notify = true );
void setTurnBindRight( bool value, bool notify = true ); void setTurnBindRight( bool value, bool notify = true );
@@ -261,8 +258,8 @@ signals:
void offsetZChanged( float value ); void offsetZChanged( float value );
void rotationChanged( int value ); void rotationChanged( int value );
void tempRotationChanged( int value ); void tempRotationChanged( int value );
void snapTurnAngleChanged( int value );
void adjustChaperoneChanged( bool value ); void adjustChaperoneChanged( bool value );
void rotateHandChanged( bool value );
void moveShortcutRightChanged( bool value ); void moveShortcutRightChanged( bool value );
void moveShortcutLeftChanged( bool value ); void moveShortcutLeftChanged( bool value );
void turnBindRightChanged( bool value ); void turnBindRightChanged( bool value );