Cleanup of enums and JS names

This commit is contained in:
Brad Davis 2015-10-21 15:57:37 -07:00
parent b9b03bd842
commit 4a1df286fd
9 changed files with 150 additions and 117 deletions

View file

@ -131,27 +131,8 @@ HifiControls.VrDialog {
onClicked: {
var mapping = Controller.newMapping();
// Inverting a value
mapping.from(hydra.RY).invert().to(standard.RY);
mapping.from(hydra.RX).to(standard.RX);
mapping.from(hydra.LY).to(standard.LY);
mapping.from(hydra.LX).to(standard.LX);
// Assigning a value from a function
// mapping.from(function() { return Math.sin(Date.now() / 250); }).to(standard.RX);
// Constrainting a value to -1, 0, or 1, with a deadzone
// mapping.from(xbox.LY).deadZone(0.5).constrainToInteger().to(standard.LY);
mapping.from(standard.RY).invert().to(standard.RY);
mapping.makeAxis(standard.LB, standard.RB).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);
// mapping.modifier(keyboard.Ctrl).scale(2.0)
// mapping.from(keyboard.A).to(actions.TranslateLeft)
// mapping.from(keyboard.A, keyboard.Shift).to(actions.TurnLeft)
// mapping.from(keyboard.A, keyboard.Shift, keyboard.Ctrl).scale(2.0).to(actions.TurnLeft)
// // First loopbacks
// // Then non-loopbacks by constraint level (number of inputs)
// mapping.from(xbox.RX).deadZone(0.2).to(xbox.RX)
// mapping.from(standard.RB, standard.LB, keyboard.Shift).to(actions.TurnLeft)
// mapping.from(keyboard.A, keyboard.Shift).to(actions.TurnLeft)
// mapping.from(keyboard.W).when(keyboard.Shift).to(actions.Forward)
testMapping = mapping;
enabled = false
text = "Built"
@ -175,13 +156,13 @@ HifiControls.VrDialog {
}
Row {
Xbox { device: root.standard; label: "Standard"; width: 360 }
Standard { device: root.standard; label: "Standard"; width: 180 }
}
Row {
spacing: 8
Xbox { device: root.xbox; label: "XBox"; width: 360 }
Hydra { device: root.hydra; width: 360 }
Xbox { device: root.xbox; label: "XBox"; width: 180 }
Hydra { device: root.hydra; width: 180 }
}
Row {

View file

@ -0,0 +1,35 @@
import QtQuick 2.1
import QtQuick.Controls 1.0
import QtQuick.Layouts 1.0
import QtQuick.Dialogs 1.0
import "xbox"
Item {
id: root
property real aspect: 300.0 / 215.0
width: 300
height: width / aspect
property var device
property string label: ""
property real scale: width / 300.0
Xbox {
width: root.width; height: root.height
device: root.device
}
// Left primary
ToggleButton {
x: 0; y: parent.height - height;
controlId: root.device.LeftPrimaryThumb
width: 16 * root.scale; height: 16 * root.scale
}
// Left primary
ToggleButton {
x: parent.width - width; y: parent.height - height;
controlId: root.device.RB
width: 16 * root.scale; height: 16 * root.scale
}
}

View file

@ -100,20 +100,5 @@ Item {
width: 16 * root.scale; height: 12 * root.scale
x: (177 * root.scale); y: (45 * root.scale)
}
// Left primary
ToggleButton {
x: 0; y: parent.height - height;
controlId: root.device.LeftPrimaryThumb
width: 16 * root.scale; height: 16 * root.scale
}
// Left primary
ToggleButton {
x: parent.width - width; y: parent.height - height;
controlId: root.device.RightPrimaryThumb
width: 16 * root.scale; height: 16 * root.scale
}
}
}

View file

@ -33,18 +33,14 @@ ConnexionData::ConnexionData() : InputDevice("ConnexionClient") {}
void ConnexionData::handleAxisEvent() {
_axisStateMap[makeInput(ROTATION_AXIS_Y_POS).getChannel()] = (cc_rotation.y > 0.0f) ? cc_rotation.y / MAX_AXIS : 0.0f;
_axisStateMap[makeInput(ROTATION_AXIS_Y_NEG).getChannel()] = (cc_rotation.y < 0.0f) ? -cc_rotation.y / MAX_AXIS : 0.0f;
_axisStateMap[makeInput(POSITION_AXIS_X_POS).getChannel()] = (cc_position.x > 0.0f) ? cc_position.x / MAX_AXIS : 0.0f;
_axisStateMap[makeInput(POSITION_AXIS_X_NEG).getChannel()] = (cc_position.x < 0.0f) ? -cc_position.x / MAX_AXIS : 0.0f;
_axisStateMap[makeInput(POSITION_AXIS_Y_POS).getChannel()] = (cc_position.y > 0.0f) ? cc_position.y / MAX_AXIS : 0.0f;
_axisStateMap[makeInput(POSITION_AXIS_Y_NEG).getChannel()] = (cc_position.y < 0.0f) ? -cc_position.y / MAX_AXIS : 0.0f;
_axisStateMap[makeInput(POSITION_AXIS_Z_POS).getChannel()] = (cc_position.z > 0.0f) ? cc_position.z / MAX_AXIS : 0.0f;
_axisStateMap[makeInput(POSITION_AXIS_Z_NEG).getChannel()] = (cc_position.z < 0.0f) ? -cc_position.z / MAX_AXIS : 0.0f;
_axisStateMap[makeInput(ROTATION_AXIS_X_POS).getChannel()] = (cc_rotation.x > 0.0f) ? cc_rotation.x / MAX_AXIS : 0.0f;
_axisStateMap[makeInput(ROTATION_AXIS_X_NEG).getChannel()] = (cc_rotation.x < 0.0f) ? -cc_rotation.x / MAX_AXIS : 0.0f;
_axisStateMap[makeInput(ROTATION_AXIS_Z_POS).getChannel()] = (cc_rotation.z > 0.0f) ? cc_rotation.z / MAX_AXIS : 0.0f;
_axisStateMap[makeInput(ROTATION_AXIS_Z_NEG).getChannel()] = (cc_rotation.z < 0.0f) ? -cc_rotation.z / MAX_AXIS : 0.0f;
auto rotation = cc_rotation / MAX_AXIS;
_axisStateMap[ROTATE_X] = rotation.x;
_axisStateMap[ROTATE_Y] = rotation.y;
_axisStateMap[ROTATE_Z] = rotation.z;
auto position = cc_rotation / MAX_AXIS;
_axisStateMap[TRANSLATE_X] = position.x;
_axisStateMap[TRANSLATE_Y] = position.y;
_axisStateMap[TRANSLATE_Z] = position.z;
}
void ConnexionData::setButton(int lastButtonState) {
@ -57,24 +53,18 @@ void ConnexionData::buildDeviceProxy(controller::DeviceProxy::Pointer proxy) {
proxy->getButton = [this](const controller::Input& input, int timestamp) -> bool { return this->getButton(input.getChannel()); };
proxy->getAxis = [this](const controller::Input& input, int timestamp) -> float { return this->getAxis(input.getChannel()); };
proxy->getAvailabeInputs = [this]() -> QVector<controller::Input::NamedPair> {
QVector<controller::Input::NamedPair> availableInputs;
availableInputs.append(controller::Input::NamedPair(makeInput(BUTTON_1), "Left button"));
availableInputs.append(controller::Input::NamedPair(makeInput(BUTTON_2), "Right button"));
availableInputs.append(controller::Input::NamedPair(makeInput(BUTTON_3), "Both buttons"));
availableInputs.append(controller::Input::NamedPair(makeInput(POSITION_AXIS_Y_NEG), "Move backward"));
availableInputs.append(controller::Input::NamedPair(makeInput(POSITION_AXIS_Y_POS), "Move forward"));
availableInputs.append(controller::Input::NamedPair(makeInput(POSITION_AXIS_X_POS), "Move right"));
availableInputs.append(controller::Input::NamedPair(makeInput(POSITION_AXIS_X_NEG), "Move Left"));
availableInputs.append(controller::Input::NamedPair(makeInput(POSITION_AXIS_Z_POS), "Move up"));
availableInputs.append(controller::Input::NamedPair(makeInput(POSITION_AXIS_Z_NEG), "Move down"));
availableInputs.append(controller::Input::NamedPair(makeInput(ROTATION_AXIS_Y_NEG), "Rotate backward"));
availableInputs.append(controller::Input::NamedPair(makeInput(ROTATION_AXIS_Y_POS), "Rotate forward"));
availableInputs.append(controller::Input::NamedPair(makeInput(ROTATION_AXIS_X_POS), "Rotate right"));
availableInputs.append(controller::Input::NamedPair(makeInput(ROTATION_AXIS_X_NEG), "Rotate left"));
availableInputs.append(controller::Input::NamedPair(makeInput(ROTATION_AXIS_Z_POS), "Rotate up"));
availableInputs.append(controller::Input::NamedPair(makeInput(ROTATION_AXIS_Z_NEG), "Rotate down"));
using namespace controller;
static QVector<controller::Input::NamedPair> availableInputs {
Input::NamedPair(makeInput(BUTTON_1), "LeftButton"),
Input::NamedPair(makeInput(BUTTON_2), "RightButton"),
Input::NamedPair(makeInput(BUTTON_3), "BothButtons"),
Input::NamedPair(makeInput(TRANSLATE_X), "TranslateX"),
Input::NamedPair(makeInput(TRANSLATE_Y), "TranslateY"),
Input::NamedPair(makeInput(TRANSLATE_Z), "TranslateZ"),
Input::NamedPair(makeInput(ROTATE_X), "RotateX"),
Input::NamedPair(makeInput(ROTATE_Y), "RotateY"),
Input::NamedPair(makeInput(ROTATE_Z), "RotateZ"),
};
return availableInputs;
};
}

View file

@ -182,18 +182,12 @@ public:
static ConnexionData& getInstance();
ConnexionData();
enum PositionChannel {
POSITION_AXIS_X_POS = 1,
POSITION_AXIS_X_NEG = 2,
POSITION_AXIS_Y_POS = 3,
POSITION_AXIS_Y_NEG = 4,
POSITION_AXIS_Z_POS = 5,
POSITION_AXIS_Z_NEG = 6,
ROTATION_AXIS_X_POS = 7,
ROTATION_AXIS_X_NEG = 8,
ROTATION_AXIS_Y_POS = 9,
ROTATION_AXIS_Y_NEG = 10,
ROTATION_AXIS_Z_POS = 11,
ROTATION_AXIS_Z_NEG = 12
TRANSLATE_X,
TRANSLATE_Y,
TRANSLATE_Z,
ROTATE_X,
ROTATE_Y,
ROTATE_Z,
};
enum ButtonChannel {

View file

@ -12,6 +12,23 @@
namespace controller {
Input::NamedPair makePair(ChannelType type, Action action, const QString& name) {
auto input = Input(UserInputMapper::ACTIONS_DEVICE, toInt(action), type);
return Input::NamedPair(input, name);
}
Input::NamedPair makeAxisPair(Action action, const QString& name) {
return makePair(ChannelType::AXIS, action, name);
}
Input::NamedPair makeButtonPair(Action action, const QString& name) {
return makePair(ChannelType::BUTTON, action, name);
}
Input::NamedPair makePosePair(Action action, const QString& name) {
return makePair(ChannelType::POSE, action, name);
}
// Device functions
void ActionsDevice::buildDeviceProxy(DeviceProxy::Pointer proxy) {
proxy->_name = _name;
@ -19,33 +36,64 @@ namespace controller {
proxy->getAxis = [this](const Input& input, int timestamp) -> float { return 0; };
proxy->getAvailabeInputs = [this]() -> QVector<Input::NamedPair> {
QVector<Input::NamedPair> availableInputs{
Input::NamedPair(Input(UserInputMapper::ACTIONS_DEVICE, toInt(Action::LONGITUDINAL_BACKWARD), ChannelType::AXIS), "LONGITUDINAL_BACKWARD"),
Input::NamedPair(Input(UserInputMapper::ACTIONS_DEVICE, toInt(Action::LONGITUDINAL_FORWARD), ChannelType::AXIS), "LONGITUDINAL_FORWARD"),
Input::NamedPair(Input(UserInputMapper::ACTIONS_DEVICE, toInt(Action::LATERAL_LEFT), ChannelType::AXIS), "LATERAL_LEFT"),
Input::NamedPair(Input(UserInputMapper::ACTIONS_DEVICE, toInt(Action::LATERAL_RIGHT), ChannelType::AXIS), "LATERAL_RIGHT"),
Input::NamedPair(Input(UserInputMapper::ACTIONS_DEVICE, toInt(Action::VERTICAL_DOWN), ChannelType::AXIS), "VERTICAL_DOWN"),
Input::NamedPair(Input(UserInputMapper::ACTIONS_DEVICE, toInt(Action::VERTICAL_UP), ChannelType::AXIS), "VERTICAL_UP"),
Input::NamedPair(Input(UserInputMapper::ACTIONS_DEVICE, toInt(Action::YAW_LEFT), ChannelType::AXIS), "YAW_LEFT"),
Input::NamedPair(Input(UserInputMapper::ACTIONS_DEVICE, toInt(Action::YAW_RIGHT), ChannelType::AXIS), "YAW_RIGHT"),
Input::NamedPair(Input(UserInputMapper::ACTIONS_DEVICE, toInt(Action::PITCH_DOWN), ChannelType::AXIS), "PITCH_DOWN"),
Input::NamedPair(Input(UserInputMapper::ACTIONS_DEVICE, toInt(Action::PITCH_UP), ChannelType::AXIS), "PITCH_UP"),
Input::NamedPair(Input(UserInputMapper::ACTIONS_DEVICE, toInt(Action::BOOM_IN), ChannelType::AXIS), "BOOM_IN"),
Input::NamedPair(Input(UserInputMapper::ACTIONS_DEVICE, toInt(Action::BOOM_OUT), ChannelType::AXIS), "BOOM_OUT"),
Input::NamedPair(Input(UserInputMapper::ACTIONS_DEVICE, toInt(Action::LEFT_HAND), ChannelType::POSE), "LEFT_HAND"),
Input::NamedPair(Input(UserInputMapper::ACTIONS_DEVICE, toInt(Action::RIGHT_HAND), ChannelType::POSE), "RIGHT_HAND"),
Input::NamedPair(Input(UserInputMapper::ACTIONS_DEVICE, toInt(Action::LEFT_HAND_CLICK), ChannelType::BUTTON), "LEFT_HAND_CLICK"),
Input::NamedPair(Input(UserInputMapper::ACTIONS_DEVICE, toInt(Action::RIGHT_HAND_CLICK), ChannelType::BUTTON), "RIGHT_HAND_CLICK"),
Input::NamedPair(Input(UserInputMapper::ACTIONS_DEVICE, toInt(Action::SHIFT), ChannelType::BUTTON), "SHIFT"),
Input::NamedPair(Input(UserInputMapper::ACTIONS_DEVICE, toInt(Action::ACTION1), ChannelType::BUTTON), "ACTION1"),
Input::NamedPair(Input(UserInputMapper::ACTIONS_DEVICE, toInt(Action::ACTION2), ChannelType::BUTTON), "ACTION2"),
Input::NamedPair(Input(UserInputMapper::ACTIONS_DEVICE, toInt(Action::CONTEXT_MENU), ChannelType::BUTTON), "CONTEXT_MENU"),
Input::NamedPair(Input(UserInputMapper::ACTIONS_DEVICE, toInt(Action::TOGGLE_MUTE), ChannelType::AXIS), "TOGGLE_MUTE"),
Input::NamedPair(Input(UserInputMapper::ACTIONS_DEVICE, toInt(Action::TRANSLATE_X), ChannelType::AXIS), "TranslateX"),
Input::NamedPair(Input(UserInputMapper::ACTIONS_DEVICE, toInt(Action::TRANSLATE_Y), ChannelType::AXIS), "TranslateY"),
Input::NamedPair(Input(UserInputMapper::ACTIONS_DEVICE, toInt(Action::TRANSLATE_Z), ChannelType::AXIS), "TranslateZ"),
Input::NamedPair(Input(UserInputMapper::ACTIONS_DEVICE, toInt(Action::ROLL), ChannelType::AXIS), "Roll"),
Input::NamedPair(Input(UserInputMapper::ACTIONS_DEVICE, toInt(Action::PITCH), ChannelType::AXIS), "Pitch"),
Input::NamedPair(Input(UserInputMapper::ACTIONS_DEVICE, toInt(Action::YAW), ChannelType::AXIS), "Yaw")
makeAxisPair(Action::TRANSLATE_X, "TranslateX"),
makeAxisPair(Action::TRANSLATE_Y, "TranslateY"),
makeAxisPair(Action::TRANSLATE_Z, "TranslateZ"),
makeAxisPair(Action::ROLL, "Roll"),
makeAxisPair(Action::PITCH, "Pitch"),
makeAxisPair(Action::YAW, "Yaw"),
makeAxisPair(Action::LONGITUDINAL_BACKWARD, "Backward"),
makeAxisPair(Action::LONGITUDINAL_FORWARD, "Forward"),
makeAxisPair(Action::LATERAL_LEFT, "StrafeLeft"),
makeAxisPair(Action::LATERAL_RIGHT, "StrafeRight"),
makeAxisPair(Action::VERTICAL_DOWN, "Down"),
makeAxisPair(Action::VERTICAL_UP, "Up"),
makeAxisPair(Action::YAW_LEFT, "YawLeft"),
makeAxisPair(Action::YAW_RIGHT, "YawRight"),
makeAxisPair(Action::PITCH_DOWN, "PitchDown"),
makeAxisPair(Action::PITCH_UP, "PitchUp"),
makeAxisPair(Action::BOOM_IN, "BoomIn"),
makeAxisPair(Action::BOOM_OUT, "BoomOut"),
makePosePair(Action::LEFT_HAND, "LeftHand"),
makePosePair(Action::RIGHT_HAND, "RightHand"),
makeButtonPair(Action::LEFT_HAND_CLICK, "LeftHandClick"),
makeButtonPair(Action::RIGHT_HAND_CLICK, "RightHandClick"),
makeButtonPair(Action::SHIFT, "Shift"),
makeButtonPair(Action::ACTION1, "PrimaryAction"),
makeButtonPair(Action::ACTION2, "SecondaryAction"),
makeButtonPair(Action::CONTEXT_MENU, "ContextMenu"),
makeButtonPair(Action::TOGGLE_MUTE, "ToggleMute"),
// Deprecated aliases
// FIXME remove after we port all scripts
makeAxisPair(Action::LONGITUDINAL_BACKWARD, "LONGITUDINAL_BACKWARD"),
makeAxisPair(Action::LONGITUDINAL_FORWARD, "LONGITUDINAL_FORWARD"),
makeAxisPair(Action::LATERAL_LEFT, "LATERAL_LEFT"),
makeAxisPair(Action::LATERAL_RIGHT, "LATERAL_RIGHT"),
makeAxisPair(Action::VERTICAL_DOWN, "VERTICAL_DOWN"),
makeAxisPair(Action::VERTICAL_UP, "VERTICAL_UP"),
makeAxisPair(Action::YAW_LEFT, "YAW_LEFT"),
makeAxisPair(Action::YAW_RIGHT, "YAW_RIGHT"),
makeAxisPair(Action::PITCH_DOWN, "PITCH_DOWN"),
makeAxisPair(Action::PITCH_UP, "PITCH_UP"),
makeAxisPair(Action::BOOM_IN, "BOOM_IN"),
makeAxisPair(Action::BOOM_OUT, "BOOM_OUT"),
makePosePair(Action::LEFT_HAND, "LEFT_HAND"),
makePosePair(Action::RIGHT_HAND, "RIGHT_HAND"),
makeButtonPair(Action::LEFT_HAND_CLICK, "LEFT_HAND_CLICK"),
makeButtonPair(Action::RIGHT_HAND_CLICK, "RIGHT_HAND_CLICK"),
makeButtonPair(Action::SHIFT, "SHIFT"),
makeButtonPair(Action::ACTION1, "ACTION1"),
makeButtonPair(Action::ACTION2, "ACTION2"),
makeButtonPair(Action::CONTEXT_MENU, "CONTEXT_MENU"),
makeButtonPair(Action::TOGGLE_MUTE, "TOGGLE_MUTE"),
};
return availableInputs;
};

View file

@ -95,10 +95,10 @@ void StandardController::buildDeviceProxy(DeviceProxy::Pointer proxy) {
availableInputs.append(makePair(DR, "Right"));
availableInputs.append(makePair(LeftPrimaryThumb, "LeftPrimaryThumb"));
availableInputs.append(makePair(LeftSecondaryThumb, "LeftSecondaryThumb"));
availableInputs.append(makePair(RightPrimaryThumb, "RightPrimaryThumb"));
availableInputs.append(makePair(RightSecondaryThumb, "RightSecondaryThumb"));
availableInputs.append(makePair(LEFT_PRIMARY_THUMB, "LeftPrimaryThumb"));
availableInputs.append(makePair(LEFT_SECONDARY_THUMB, "LeftSecondaryThumb"));
availableInputs.append(makePair(RIGHT_PRIMARY_THUMB, "RightPrimaryThumb"));
availableInputs.append(makePair(RIGHT_SECONDARY_THUMB, "RightSecondaryThumb"));
return availableInputs;
};

View file

@ -37,10 +37,10 @@ namespace controller {
DR,
// These don't map to SDL types
LeftPrimaryThumb,
LeftSecondaryThumb,
RightPrimaryThumb,
RightSecondaryThumb,
LEFT_PRIMARY_THUMB,
LEFT_SECONDARY_THUMB,
RIGHT_PRIMARY_THUMB,
RIGHT_SECONDARY_THUMB,
NUM_STANDARD_BUTTONS
};

View file

@ -414,10 +414,10 @@ void ViveControllerManager::buildDeviceProxy(controller::DeviceProxy::Pointer pr
makePair(LS, "LS"),
makePair(RS, "RS"),
makePair(LEFT_HAND, "LeftHand"),
makePair(RIGHT_HAND, "RightHand"),
};
//availableInputs.append(Input::NamedPair(makeInput(LEFT_HAND), "Left Hand"));
//availableInputs.append(Input::NamedPair(makeInput(BUTTON_A, 0), "Left Button A"));
//availableInputs.append(Input::NamedPair(makeInput(GRIP_BUTTON, 0), "Left Grip Button"));
//availableInputs.append(Input::NamedPair(makeInput(TRACKPAD_BUTTON, 0), "Left Trackpad Button"));