Merge branch 'sam/vive-hand-controllers' of github.com:hyperlogic/hifi into sam/vive-hand-controllers

Conflicts:
	examples/example/games/sword.js
This commit is contained in:
Anthony J. Thibault 2015-07-20 15:22:19 -07:00
commit 17220542d8
4 changed files with 19 additions and 9 deletions
examples/example/games
interface/src/scripting
libraries/input-plugins/src/input-plugins

View file

@ -13,11 +13,15 @@
/*jslint vars: true*/
var Script, Entities, MyAvatar, Window, Overlays, Controller, Vec3, Quat, print, ToolBar, Settings; // Referenced globals provided by High Fidelity.
Script.include("http://s3.amazonaws.com/hifi-public/scripts/libraries/toolBars.js");
var zombieGameScriptURL = "https://hifi-public.s3.amazonaws.com/eric/scripts/zombieFight.js?v2";
// var zombieGameScriptURL = "zombieFight.js";
Script.include(zombieGameScriptURL);
var zombieFight;
var zombieFight = new ZombieFight();
var hand = "right";
var zombieFight;
var nullActionID = "00000000-0000-0000-0000-000000000000";
var controllerID;
var controllerActive;
@ -78,7 +82,7 @@ var cleanupButton = toolBar.addOverlay("image", {
var flasher;
var leftTriggerButton = 0;
var leftHandClick = 14;
var leftTriggerValue = 0;
var prevLeftTriggerValue = 0;
@ -88,7 +92,7 @@ var RIGHT = 1;
var leftPalm = 2 * LEFT;
var rightPalm = 2 * RIGHT;
var rightTriggerButton = 1;
var rightHandClick = 15;
var prevRightTriggerValue = 0;
var rightTriggerValue = 0;
var TRIGGER_THRESHOLD = 0.2;
@ -357,8 +361,8 @@ function update() {
}
function updateControllerState() {
rightTriggerValue = Controller.getTriggerValue(rightTriggerButton);
leftTriggerValue = Controller.getTriggerValue(leftTriggerButton);
rightTriggerValue = Controller.getActionValue(rightHandClick);
leftTriggerValue = Controller.getActionValue(leftHandClick);
if (rightTriggerValue > TRIGGER_THRESHOLD && !swordHeld) {
grabSword("right")
@ -470,4 +474,4 @@ function onClick(event) {
Script.scriptEnding.connect(cleanUp);
Script.update.connect(update);
Controller.mousePressEvent.connect(onClick);
Controller.mousePressEvent.connect(onClick);

View file

@ -468,6 +468,10 @@ int ControllerScriptingInterface::findDevice(QString name) {
return DependencyManager::get<UserInputMapper>()->findDevice(name);
}
float ControllerScriptingInterface::getActionValue(int action) {
return DependencyManager::get<UserInputMapper>()->getActionState(UserInputMapper::Action(action));
}
InputController::InputController(int deviceTrackerId, int subTrackerId, QObject* parent) :
AbstractInputController(),
_deviceTrackerId(deviceTrackerId),

View file

@ -95,6 +95,8 @@ public slots:
Q_INVOKABLE virtual void resetAllDeviceBindings();
Q_INVOKABLE virtual void resetDevice(unsigned int device);
Q_INVOKABLE virtual int findDevice(QString name);
Q_INVOKABLE virtual float getActionValue(int action);
virtual bool isPrimaryButtonPressed() const;
virtual glm::vec2 getPrimaryJoystickPosition() const;

View file

@ -420,8 +420,8 @@ void SixenseManager::handlePoseEvent(glm::vec3 position, glm::quat rotation, int
#ifdef HAVE_SIXENSE
// Transform the measured position into body frame.
glm::vec3 neck = _neckBase;
// Zeroing y component of the "neck" effectively raises the measured position a little bit.
neck.y = 0.0f;
// Set y component of the "neck" to raise the measured position a little bit.
neck.y = 0.5f;
position = _orbRotation * (position - neck);
// adjustment for hydra controllers fit into hands