mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 18:16:45 +02:00
Making anonymous mappings work
This commit is contained in:
parent
f77878ee79
commit
58d3578fb1
9 changed files with 47 additions and 8 deletions
|
@ -1,5 +1,9 @@
|
||||||
#include "Mapping.h"
|
#include "Mapping.h"
|
||||||
|
|
||||||
namespace controller {
|
namespace controller {
|
||||||
|
Mapping::Mapping(const QString& name ) : _name(name) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,10 @@ namespace controller {
|
||||||
using Map = std::map<Endpoint::Pointer, Route::List>;
|
using Map = std::map<Endpoint::Pointer, Route::List>;
|
||||||
using Pointer = std::shared_ptr<Mapping>;
|
using Pointer = std::shared_ptr<Mapping>;
|
||||||
|
|
||||||
|
Mapping(const QString& name);
|
||||||
|
|
||||||
Map _channelMappings;
|
Map _channelMappings;
|
||||||
|
const QString _name;
|
||||||
|
|
||||||
void parse(const QString& json);
|
void parse(const QString& json);
|
||||||
QString serialize();
|
QString serialize();
|
||||||
|
|
|
@ -158,7 +158,7 @@ namespace controller {
|
||||||
qCWarning(controllers) << "Refusing to recreate mapping named " << mappingName;
|
qCWarning(controllers) << "Refusing to recreate mapping named " << mappingName;
|
||||||
}
|
}
|
||||||
qDebug() << "Creating new Mapping " << mappingName;
|
qDebug() << "Creating new Mapping " << mappingName;
|
||||||
Mapping::Pointer mapping = std::make_shared<Mapping>();
|
auto mapping = std::make_shared<Mapping>(mappingName);
|
||||||
_mappingsByName[mappingName] = mapping;
|
_mappingsByName[mappingName] = mapping;
|
||||||
return new MappingBuilderProxy(*this, mapping);
|
return new MappingBuilderProxy(*this, mapping);
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ namespace controller {
|
||||||
Q_INVOKABLE float getValue(const int& source);
|
Q_INVOKABLE float getValue(const int& source);
|
||||||
|
|
||||||
Q_INVOKABLE void update();
|
Q_INVOKABLE void update();
|
||||||
Q_INVOKABLE QObject* newMapping(const QString& mappingName);
|
Q_INVOKABLE QObject* newMapping(const QString& mappingName = QUuid::createUuid().toString());
|
||||||
Q_INVOKABLE void enableMapping(const QString& mappingName, bool enable = true);
|
Q_INVOKABLE void enableMapping(const QString& mappingName, bool enable = true);
|
||||||
Q_INVOKABLE void disableMapping(const QString& mappingName) {
|
Q_INVOKABLE void disableMapping(const QString& mappingName) {
|
||||||
enableMapping(mappingName, false);
|
enableMapping(mappingName, false);
|
||||||
|
|
|
@ -41,4 +41,9 @@ QObject* MappingBuilderProxy::join(const QJSValue& source1, const QJSValue& sour
|
||||||
return from(_parent.compositeEndpointFor(source1Endpoint, source2Endpoint));
|
return from(_parent.compositeEndpointFor(source1Endpoint, source2Endpoint));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QObject* MappingBuilderProxy::enable(bool enable) {
|
||||||
|
_parent.enableMapping(_mapping->_name, enable);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,8 +30,10 @@ public:
|
||||||
|
|
||||||
Q_INVOKABLE QObject* from(const QJSValue& source);
|
Q_INVOKABLE QObject* from(const QJSValue& source);
|
||||||
Q_INVOKABLE QObject* from(const QScriptValue& source);
|
Q_INVOKABLE QObject* from(const QScriptValue& source);
|
||||||
|
|
||||||
Q_INVOKABLE QObject* join(const QJSValue& source1, const QJSValue& source2);
|
Q_INVOKABLE QObject* join(const QJSValue& source1, const QJSValue& source2);
|
||||||
|
Q_INVOKABLE QObject* enable(bool enable = true);
|
||||||
|
Q_INVOKABLE QObject* disable() { return enable(false); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QObject* from(const Endpoint::Pointer& source);
|
QObject* from(const Endpoint::Pointer& source);
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
set(TARGET_NAME controllers-test)
|
set(TARGET_NAME controllers-test)
|
||||||
|
|
||||||
# This is not a testcase -- just set it up as a regular hifi project
|
# This is not a testcase -- just set it up as a regular hifi project
|
||||||
setup_hifi_project(Script)
|
setup_hifi_project(Script Qml)
|
||||||
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "Tests/manual-tests/")
|
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "Tests/manual-tests/")
|
||||||
|
|
||||||
# link in the shared libraries
|
# link in the shared libraries
|
||||||
|
|
|
@ -11,7 +11,7 @@ Column {
|
||||||
property var xbox: NewControllers.Hardware.X360Controller1
|
property var xbox: NewControllers.Hardware.X360Controller1
|
||||||
property var actions: NewControllers.Actions
|
property var actions: NewControllers.Actions
|
||||||
property var standard: NewControllers.Standard
|
property var standard: NewControllers.Standard
|
||||||
property string mappingName: "TestMapping"
|
property var testMapping: null
|
||||||
|
|
||||||
spacing: 12
|
spacing: 12
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ Column {
|
||||||
Button {
|
Button {
|
||||||
text: "Build Mapping"
|
text: "Build Mapping"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
var mapping = NewControllers.newMapping(root.mappingName);
|
var mapping = NewControllers.newMapping();
|
||||||
// Inverting a value
|
// Inverting a value
|
||||||
mapping.from(xbox.RY).invert().to(standard.RY);
|
mapping.from(xbox.RY).invert().to(standard.RY);
|
||||||
// Assigning a value from a function
|
// Assigning a value from a function
|
||||||
|
@ -63,17 +63,22 @@ Column {
|
||||||
// Constrainting a value to -1, 0, or 1, with a deadzone
|
// Constrainting a value to -1, 0, or 1, with a deadzone
|
||||||
mapping.from(xbox.LY).deadZone(0.5).constrainToInteger().to(standard.LY);
|
mapping.from(xbox.LY).deadZone(0.5).constrainToInteger().to(standard.LY);
|
||||||
mapping.join(standard.LB, standard.RB).pulse(0.5).to(actions.Yaw);
|
mapping.join(standard.LB, standard.RB).pulse(0.5).to(actions.Yaw);
|
||||||
|
mapping.from(actions.Yaw).clamp(0, 1).invert().to(actions.YAW_RIGHT);
|
||||||
|
mapping.from(actions.Yaw).clamp(-1, 0).to(actions.YAW_LEFT);
|
||||||
|
testMapping = mapping;
|
||||||
|
enabled = false
|
||||||
|
text = "Built"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
text: "Enable Mapping"
|
text: "Enable Mapping"
|
||||||
onClicked: NewControllers.enableMapping(root.mappingName)
|
onClicked: root.testMapping.enable()
|
||||||
}
|
}
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
text: "Disable Mapping"
|
text: "Disable Mapping"
|
||||||
onClicked: NewControllers.disableMapping(root.mappingName)
|
onClicked: root.testMapping.disable()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,6 +90,7 @@ Column {
|
||||||
|
|
||||||
|
|
||||||
Row {
|
Row {
|
||||||
|
spacing: 8
|
||||||
ScrollingGraph {
|
ScrollingGraph {
|
||||||
controlId: NewControllers.Actions.Yaw
|
controlId: NewControllers.Actions.Yaw
|
||||||
label: "Yaw"
|
label: "Yaw"
|
||||||
|
@ -92,6 +98,22 @@ Column {
|
||||||
max: 3.0
|
max: 3.0
|
||||||
size: 128
|
size: 128
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ScrollingGraph {
|
||||||
|
controlId: NewControllers.Actions.YAW_LEFT
|
||||||
|
label: "Yaw Left"
|
||||||
|
min: -3.0
|
||||||
|
max: 3.0
|
||||||
|
size: 128
|
||||||
|
}
|
||||||
|
|
||||||
|
ScrollingGraph {
|
||||||
|
controlId: NewControllers.Actions.YAW_RIGHT
|
||||||
|
label: "Yaw Right"
|
||||||
|
min: -3.0
|
||||||
|
max: 3.0
|
||||||
|
size: 128
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,6 +82,9 @@ public:
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
QGuiApplication app(argc, argv);
|
QGuiApplication app(argc, argv);
|
||||||
QQmlApplicationEngine engine;
|
QQmlApplicationEngine engine;
|
||||||
|
for (auto path : qApp->libraryPaths()) {
|
||||||
|
qDebug() << path;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue