Merge pull request #6069 from ZappoMan/controllers

Hack in NewControllers into the JS layer of interface to allow testing
This commit is contained in:
Brad Davis 2015-10-13 19:08:26 -07:00
commit 0c31fb1b1b
4 changed files with 33 additions and 2 deletions

View file

@ -12,6 +12,20 @@
// Assumes you only have the default keyboard connected
var hydra = Controller.Hardware.Hydra2;
if (hydra !== undefined) {
print("-----------------------------------");
var mapping = NewControllers.newMapping("Default");
var standard = Controller.Standard;
print("standard:" + standard);
mapping.from(hydra.LeftButton1).to(standard.A);
mapping.from(hydra.LeftButton2).to(standard.B);
mapping.from(hydra.LeftButton3).to(standard.X);
NewControllers.enableMapping("Default");
print("-----------------------------------");
}
Object.keys(Controller.Standard).forEach(function (input) {
print("Controller.Standard." + input + ":" + Controller.Standard[input]);
});

View file

@ -14,6 +14,8 @@
#include <HandData.h>
#include <HFBackEvent.h>
#include <controllers/NewControllerScriptingInterface.h>
#include "Application.h"
#include "devices/MotionTracker.h"
#include "ControllerScriptingInterface.h"
@ -31,6 +33,11 @@ ControllerScriptingInterface::ControllerScriptingInterface() :
}
ControllerScriptingInterface::~ControllerScriptingInterface() {
delete _newControllerScriptingInterface;
}
static int actionMetaTypeId = qRegisterMetaType<UserInputMapper::Action>();
static int inputChannelMetaTypeId = qRegisterMetaType<UserInputMapper::InputChannel>();
static int inputMetaTypeId = qRegisterMetaType<UserInputMapper::Input>();
@ -121,6 +128,11 @@ void ControllerScriptingInterface::registerControllerTypes(ScriptEngine* engine)
qScriptRegisterMetaType(engine, inputPairToScriptValue, inputPairFromScriptValue);
wireUpControllers(engine);
// hack in the new controller scripting interface...
_newControllerScriptingInterface = new controller::NewControllerScriptingInterface();
engine->registerGlobalObject("NewControllers", _newControllerScriptingInterface);
}
void ControllerScriptingInterface::handleMetaEvent(HFMetaEvent* event) {

View file

@ -18,6 +18,9 @@
#include <AbstractControllerScriptingInterface.h>
class PalmData;
namespace controller {
class NewControllerScriptingInterface;
}
class InputController : public AbstractInputController {
Q_OBJECT
@ -55,7 +58,8 @@ class ControllerScriptingInterface : public AbstractControllerScriptingInterface
public:
ControllerScriptingInterface();
~ControllerScriptingInterface();
virtual void registerControllerTypes(ScriptEngine* engine);
void emitKeyPressEvent(QKeyEvent* event) { emit keyPressEvent(KeyEvent(*event)); }
@ -169,6 +173,7 @@ private:
void wireUpControllers(ScriptEngine* engine);
controller::NewControllerScriptingInterface* _newControllerScriptingInterface = nullptr;
};
const int NUMBER_OF_SPATIALCONTROLS_PER_PALM = 2; // the hand and the tip

View file

@ -22,7 +22,7 @@ InputPluginList getInputPlugins() {
InputPlugin* PLUGIN_POOL[] = {
new KeyboardMouseDevice(),
new SDL2Manager(),
//new SixenseManager(),
new SixenseManager(),
//new ViveControllerManager(),
nullptr
};