mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-05-29 21:29:56 +02:00
Fixes and PR comments
This commit is contained in:
parent
0063f9ae1d
commit
e39219c2b5
10 changed files with 69 additions and 29 deletions
|
@ -11,6 +11,16 @@
|
||||||
|
|
||||||
// Assumes you only have the default keyboard connected
|
// Assumes you only have the default keyboard connected
|
||||||
|
|
||||||
|
function findAction(name) {
|
||||||
|
var actions = Controller.getAllActions();
|
||||||
|
for (var i = 0; i < actions.length; i++) {
|
||||||
|
if (actions[i].actionName == name) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// If the action isn't found, it will default to the first available action
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
var hydra = Controller.Hardware.Hydra2;
|
var hydra = Controller.Hardware.Hydra2;
|
||||||
|
@ -46,44 +56,48 @@ Controller.resetAllDeviceBindings();
|
||||||
// Query all actions
|
// Query all actions
|
||||||
print("All Actions: \n" + Controller.getAllActions());
|
print("All Actions: \n" + Controller.getAllActions());
|
||||||
|
|
||||||
|
var actionId = findAction("YAW_LEFT")
|
||||||
|
|
||||||
|
print("Yaw Left action ID: " + actionId)
|
||||||
|
|
||||||
// Each action stores:
|
// Each action stores:
|
||||||
// action: int representation of enum
|
// action: int representation of enum
|
||||||
print("Action 5 int: \n" + Controller.getAllActions()[5].action);
|
print("Action int: \n" + Controller.getAllActions()[actionId].action);
|
||||||
|
|
||||||
// actionName: string representation of enum
|
// actionName: string representation of enum
|
||||||
print("Action 5 name: \n" + Controller.getAllActions()[5].actionName);
|
print("Action name: \n" + Controller.getAllActions()[actionId].actionName);
|
||||||
|
|
||||||
// inputChannels: list of all inputchannels that control that action
|
// inputChannels: list of all inputchannels that control that action
|
||||||
print("Action 5 input channels: \n" + Controller.getAllActions()[5].inputChannels + "\n");
|
print("Action input channels: \n" + Controller.getAllActions()[actionId].inputChannels + "\n");
|
||||||
|
|
||||||
|
|
||||||
// Each input channel stores:
|
// Each input channel stores:
|
||||||
// action: Action that this InputChannel maps to
|
// action: Action that this InputChannel maps to
|
||||||
print("Input channel action: \n" + Controller.getAllActions()[5].inputChannels[0].action);
|
print("Input channel action: \n" + Controller.getAllActions()[actionId].inputChannels[0].action);
|
||||||
|
|
||||||
// scale: sensitivity of input
|
// scale: sensitivity of input
|
||||||
print("Input channel scale: \n" + Controller.getAllActions()[5].inputChannels[0].scale);
|
print("Input channel scale: \n" + Controller.getAllActions()[actionId].inputChannels[0].scale);
|
||||||
|
|
||||||
// input and modifier: Inputs
|
// input and modifier: Inputs
|
||||||
print("Input channel input and modifier: \n" + Controller.getAllActions()[5].inputChannels[0].input + "\n" + Controller.getAllActions()[5].inputChannels[0].modifier + "\n");
|
print("Input channel input and modifier: \n" + Controller.getAllActions()[actionId].inputChannels[0].input + "\n" + Controller.getAllActions()[actionId].inputChannels[0].modifier + "\n");
|
||||||
|
|
||||||
|
|
||||||
// Each Input stores:
|
// Each Input stores:
|
||||||
// device: device of input
|
// device: device of input
|
||||||
print("Input device: \n" + Controller.getAllActions()[5].inputChannels[0].input.device);
|
print("Input device: \n" + Controller.getAllActions()[actionId].inputChannels[0].input.device);
|
||||||
|
|
||||||
// channel: channel of input
|
// channel: channel of input
|
||||||
print("Input channel: \n" + Controller.getAllActions()[5].inputChannels[0].input.channel);
|
print("Input channel: \n" + Controller.getAllActions()[actionId].inputChannels[0].input.channel);
|
||||||
|
|
||||||
// type: type of input (Unknown, Button, Axis, Joint)
|
// type: type of input (Unknown, Button, Axis, Joint)
|
||||||
print("Input type: \n" + Controller.getAllActions()[5].inputChannels[0].input.type);
|
print("Input type: \n" + Controller.getAllActions()[actionId].inputChannels[0].input.type);
|
||||||
|
|
||||||
// id: id of input
|
// id: id of input
|
||||||
print("Input id: \n" + Controller.getAllActions()[5].inputChannels[0].input.id + "\n");
|
print("Input id: \n" + Controller.getAllActions()[actionId].inputChannels[0].input.id + "\n");
|
||||||
|
|
||||||
|
|
||||||
// You can get the name of a device from its id
|
// You can get the name of a device from its id
|
||||||
print("Device 1 name: \n" + Controller.getDeviceName(Controller.getAllActions()[5].inputChannels[0].input.id));
|
print("Device 1 name: \n" + Controller.getDeviceName(Controller.getAllActions()[actionId].inputChannels[0].input.id));
|
||||||
|
|
||||||
// You can also get all of a devices input channels
|
// You can also get all of a devices input channels
|
||||||
print("Device 1's input channels: \n" + Controller.getAllInputsForDevice(1) + "\n");
|
print("Device 1's input channels: \n" + Controller.getAllInputsForDevice(1) + "\n");
|
||||||
|
@ -119,7 +133,7 @@ for (i = 0; i < availableInputs.length; i++) {
|
||||||
|
|
||||||
// You can modify key bindings by using these avaiable inputs
|
// You can modify key bindings by using these avaiable inputs
|
||||||
// This will replace e (up) with 6
|
// This will replace e (up) with 6
|
||||||
var e = Controller.getAllActions()[5].inputChannels[0];
|
var e = Controller.getAllActions()[actionId].inputChannels[0];
|
||||||
Controller.removeInputChannel(e);
|
Controller.removeInputChannel(e);
|
||||||
e.input = availableInputs[6].input;
|
e.input = availableInputs[6].input;
|
||||||
Controller.addInputChannel(e);
|
Controller.addInputChannel(e);
|
|
@ -38,7 +38,7 @@ var mouseLook = (function () {
|
||||||
keyboardID = 0;
|
keyboardID = 0;
|
||||||
|
|
||||||
function onKeyPressEvent(event) {
|
function onKeyPressEvent(event) {
|
||||||
if (event.text == 'M') {
|
if (event.text == 'm') {
|
||||||
active = !active;
|
active = !active;
|
||||||
updateMapping();
|
updateMapping();
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include <avatar/MyAvatar.h>
|
#include <avatar/MyAvatar.h>
|
||||||
#include <HandData.h>
|
#include <HandData.h>
|
||||||
#include <HFBackEvent.h>
|
#include <HFBackEvent.h>
|
||||||
|
#include <plugins/PluginManager.h>
|
||||||
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
#include "devices/MotionTracker.h"
|
#include "devices/MotionTracker.h"
|
||||||
|
@ -115,7 +116,7 @@ void inputPairFromScriptValue(const QScriptValue& object, UserInputMapper::Input
|
||||||
inputPair.second = QString(object.property("inputName").toVariant().toString());
|
inputPair.second = QString(object.property("inputName").toVariant().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControllerScriptingInterface::registerControllerTypes(ScriptEngine* engine) {
|
void ControllerScriptingInterface::registerControllerTypes(QScriptEngine* engine) {
|
||||||
qScriptRegisterSequenceMetaType<QVector<UserInputMapper::Action> >(engine);
|
qScriptRegisterSequenceMetaType<QVector<UserInputMapper::Action> >(engine);
|
||||||
qScriptRegisterSequenceMetaType<QVector<UserInputMapper::InputChannel> >(engine);
|
qScriptRegisterSequenceMetaType<QVector<UserInputMapper::InputChannel> >(engine);
|
||||||
qScriptRegisterSequenceMetaType<QVector<UserInputMapper::InputPair> >(engine);
|
qScriptRegisterSequenceMetaType<QVector<UserInputMapper::InputPair> >(engine);
|
||||||
|
@ -426,11 +427,25 @@ void ControllerScriptingInterface::releaseInputController(controller::InputContr
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControllerScriptingInterface::update() {
|
void ControllerScriptingInterface::update() {
|
||||||
controller::ScriptingInterface::update();
|
static float last = secTimestampNow();
|
||||||
|
float now = secTimestampNow();
|
||||||
|
float delta = now - last;
|
||||||
|
last = now;
|
||||||
|
|
||||||
|
for(auto inputPlugin : PluginManager::getInstance()->getInputPlugins()) {
|
||||||
|
if (inputPlugin->isActive()) {
|
||||||
|
inputPlugin->pluginUpdate(delta, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
auto userInputMapper = DependencyManager::get<UserInputMapper>();
|
||||||
|
userInputMapper->update(delta);
|
||||||
|
|
||||||
for (auto entry : _inputControllers) {
|
for (auto entry : _inputControllers) {
|
||||||
entry.second->update();
|
entry.second->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
controller::ScriptingInterface::update();
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<UserInputMapper::Action> ControllerScriptingInterface::getAllActions() {
|
QVector<UserInputMapper::Action> ControllerScriptingInterface::getAllActions() {
|
||||||
|
|
|
@ -88,7 +88,7 @@ public:
|
||||||
Q_INVOKABLE QVector<QString> getActionNames() const;
|
Q_INVOKABLE QVector<QString> getActionNames() const;
|
||||||
|
|
||||||
|
|
||||||
virtual void registerControllerTypes(ScriptEngine* engine);
|
virtual void registerControllerTypes(QScriptEngine* engine);
|
||||||
|
|
||||||
void emitKeyPressEvent(QKeyEvent* event);
|
void emitKeyPressEvent(QKeyEvent* event);
|
||||||
void emitKeyReleaseEvent(QKeyEvent* event);
|
void emitKeyReleaseEvent(QKeyEvent* event);
|
||||||
|
|
|
@ -357,7 +357,7 @@ namespace controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
int ScriptingInterface::getNumberOfTriggers() const {
|
int ScriptingInterface::getNumberOfTriggers() const {
|
||||||
return 2;
|
return StandardCounts::TRIGGERS;
|
||||||
}
|
}
|
||||||
|
|
||||||
float ScriptingInterface::getTriggerValue(int triggerIndex) const {
|
float ScriptingInterface::getTriggerValue(int triggerIndex) const {
|
||||||
|
@ -365,7 +365,7 @@ namespace controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
int ScriptingInterface::getNumberOfJoysticks() const {
|
int ScriptingInterface::getNumberOfJoysticks() const {
|
||||||
return 2;
|
return StandardCounts::ANALOG_STICKS;
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec2 ScriptingInterface::getJoystickPosition(int joystickIndex) const {
|
glm::vec2 ScriptingInterface::getJoystickPosition(int joystickIndex) const {
|
||||||
|
@ -382,22 +382,26 @@ namespace controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
int ScriptingInterface::getNumberOfSpatialControls() const {
|
int ScriptingInterface::getNumberOfSpatialControls() const {
|
||||||
return 2;
|
return StandardCounts::POSES;
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 ScriptingInterface::getSpatialControlPosition(int controlIndex) const {
|
glm::vec3 ScriptingInterface::getSpatialControlPosition(int controlIndex) const {
|
||||||
|
// FIXME extract the position from the standard pose
|
||||||
return vec3();
|
return vec3();
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 ScriptingInterface::getSpatialControlVelocity(int controlIndex) const {
|
glm::vec3 ScriptingInterface::getSpatialControlVelocity(int controlIndex) const {
|
||||||
|
// FIXME extract the velocity from the standard pose
|
||||||
return vec3();
|
return vec3();
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 ScriptingInterface::getSpatialControlNormal(int controlIndex) const {
|
glm::vec3 ScriptingInterface::getSpatialControlNormal(int controlIndex) const {
|
||||||
|
// FIXME extract the normal from the standard pose
|
||||||
return vec3();
|
return vec3();
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::quat ScriptingInterface::getSpatialControlRawRotation(int controlIndex) const {
|
glm::quat ScriptingInterface::getSpatialControlRawRotation(int controlIndex) const {
|
||||||
|
// FIXME extract the rotation from the standard pose
|
||||||
return quat();
|
return quat();
|
||||||
}
|
}
|
||||||
} // namespace controllers
|
} // namespace controllers
|
||||||
|
|
|
@ -99,7 +99,7 @@ namespace controller {
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void update();
|
virtual void update();
|
||||||
//virtual void registerControllerTypes(ScriptEngine* engine) = 0;
|
virtual void registerControllerTypes(QScriptEngine* engine) = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class MappingBuilderProxy;
|
friend class MappingBuilderProxy;
|
||||||
|
|
|
@ -56,4 +56,9 @@ namespace controller {
|
||||||
NUM_STANDARD_POSES
|
NUM_STANDARD_POSES
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum StandardCounts {
|
||||||
|
TRIGGERS = 2,
|
||||||
|
ANALOG_STICKS = 2,
|
||||||
|
POSES = 2, // FIXME 3? if we want to expose the head?
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,8 @@ InputPluginList getInputPlugins() {
|
||||||
InputPlugin* PLUGIN_POOL[] = {
|
InputPlugin* PLUGIN_POOL[] = {
|
||||||
new KeyboardMouseDevice(),
|
new KeyboardMouseDevice(),
|
||||||
new SDL2Manager(),
|
new SDL2Manager(),
|
||||||
//new SixenseManager(),
|
new SixenseManager(),
|
||||||
//new ViveControllerManager(),
|
new ViveControllerManager(),
|
||||||
nullptr
|
nullptr
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,6 @@ void avatarDataFromScriptValue(const QScriptValue &object, AvatarData* &out) {
|
||||||
out = qobject_cast<AvatarData*>(object.toQObject());
|
out = qobject_cast<AvatarData*>(object.toQObject());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QScriptValue inputControllerToScriptValue(QScriptEngine *engine, controller::InputController* const &in) {
|
QScriptValue inputControllerToScriptValue(QScriptEngine *engine, controller::InputController* const &in) {
|
||||||
return engine->newQObject(in);
|
return engine->newQObject(in);
|
||||||
}
|
}
|
||||||
|
@ -85,7 +84,8 @@ void inputControllerFromScriptValue(const QScriptValue &object, controller::Inpu
|
||||||
out = qobject_cast<controller::InputController*>(object.toQObject());
|
out = qobject_cast<controller::InputController*>(object.toQObject());
|
||||||
}
|
}
|
||||||
|
|
||||||
ScriptEngine::ScriptEngine(const QString& scriptContents, const QString& fileNameString, controller::ScriptingInterface* controllerScriptingInterface, bool wantSignals) :
|
ScriptEngine::ScriptEngine(const QString& scriptContents, const QString& fileNameString,
|
||||||
|
controller::ScriptingInterface* controllerScriptingInterface, bool wantSignals) :
|
||||||
|
|
||||||
_scriptContents(scriptContents),
|
_scriptContents(scriptContents),
|
||||||
_isFinished(false),
|
_isFinished(false),
|
||||||
|
@ -93,6 +93,7 @@ ScriptEngine::ScriptEngine(const QString& scriptContents, const QString& fileNam
|
||||||
_isInitialized(false),
|
_isInitialized(false),
|
||||||
_timerFunctionMap(),
|
_timerFunctionMap(),
|
||||||
_wantSignals(wantSignals),
|
_wantSignals(wantSignals),
|
||||||
|
_controllerScriptingInterface(controllerScriptingInterface),
|
||||||
_fileNameString(fileNameString),
|
_fileNameString(fileNameString),
|
||||||
_quatLibrary(),
|
_quatLibrary(),
|
||||||
_vec3Library(),
|
_vec3Library(),
|
||||||
|
@ -300,7 +301,7 @@ void ScriptEngine::init() {
|
||||||
globalObject().setProperty("AudioEffectOptions", audioEffectOptionsConstructorValue);
|
globalObject().setProperty("AudioEffectOptions", audioEffectOptionsConstructorValue);
|
||||||
|
|
||||||
qScriptRegisterMetaType(this, injectorToScriptValue, injectorFromScriptValue);
|
qScriptRegisterMetaType(this, injectorToScriptValue, injectorFromScriptValue);
|
||||||
//qScriptRegisterMetaType(this, inputControllerToScriptValue, inputControllerFromScriptValue);
|
qScriptRegisterMetaType(this, inputControllerToScriptValue, inputControllerFromScriptValue);
|
||||||
qScriptRegisterMetaType(this, avatarDataToScriptValue, avatarDataFromScriptValue);
|
qScriptRegisterMetaType(this, avatarDataToScriptValue, avatarDataFromScriptValue);
|
||||||
qScriptRegisterMetaType(this, animationDetailsToScriptValue, animationDetailsFromScriptValue);
|
qScriptRegisterMetaType(this, animationDetailsToScriptValue, animationDetailsFromScriptValue);
|
||||||
qScriptRegisterMetaType(this, webSocketToScriptValue, webSocketFromScriptValue);
|
qScriptRegisterMetaType(this, webSocketToScriptValue, webSocketFromScriptValue);
|
||||||
|
@ -309,7 +310,7 @@ void ScriptEngine::init() {
|
||||||
|
|
||||||
registerGlobalObject("Script", this);
|
registerGlobalObject("Script", this);
|
||||||
registerGlobalObject("Audio", &AudioScriptingInterface::getInstance());
|
registerGlobalObject("Audio", &AudioScriptingInterface::getInstance());
|
||||||
// registerGlobalObject("Controller", _controllerScriptingInterface);
|
registerGlobalObject("Controller", _controllerScriptingInterface);
|
||||||
registerGlobalObject("Entities", entityScriptingInterface.data());
|
registerGlobalObject("Entities", entityScriptingInterface.data());
|
||||||
registerGlobalObject("Quat", &_quatLibrary);
|
registerGlobalObject("Quat", &_quatLibrary);
|
||||||
registerGlobalObject("Vec3", &_vec3Library);
|
registerGlobalObject("Vec3", &_vec3Library);
|
||||||
|
@ -319,9 +320,9 @@ void ScriptEngine::init() {
|
||||||
// constants
|
// constants
|
||||||
globalObject().setProperty("TREE_SCALE", newVariant(QVariant(TREE_SCALE)));
|
globalObject().setProperty("TREE_SCALE", newVariant(QVariant(TREE_SCALE)));
|
||||||
|
|
||||||
//if (_controllerScriptingInterface) {
|
if (_controllerScriptingInterface) {
|
||||||
// _controllerScriptingInterface->registerControllerTypes(this);
|
_controllerScriptingInterface->registerControllerTypes(this);
|
||||||
//}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -184,6 +184,7 @@ private:
|
||||||
QObject* setupTimerWithInterval(const QScriptValue& function, int intervalMS, bool isSingleShot);
|
QObject* setupTimerWithInterval(const QScriptValue& function, int intervalMS, bool isSingleShot);
|
||||||
void stopTimer(QTimer* timer);
|
void stopTimer(QTimer* timer);
|
||||||
|
|
||||||
|
controller::ScriptingInterface* _controllerScriptingInterface;
|
||||||
QString _fileNameString;
|
QString _fileNameString;
|
||||||
Quat _quatLibrary;
|
Quat _quatLibrary;
|
||||||
Vec3 _vec3Library;
|
Vec3 _vec3Library;
|
||||||
|
|
Loading…
Reference in a new issue