mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-07-23 23:04:05 +02:00
;) (added semicolons to js example)
This commit is contained in:
parent
dd12e4740e
commit
b1b2d1f85c
1 changed files with 33 additions and 31 deletions
|
@ -9,86 +9,88 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
|
// Assumes you only have the default keyboard connected
|
||||||
|
|
||||||
// Resets every device to its default key bindings:
|
// Resets every device to its default key bindings:
|
||||||
Controller.resetAllDeviceBindings()
|
Controller.resetAllDeviceBindings();
|
||||||
|
|
||||||
// Query all actions
|
// Query all actions
|
||||||
print("All Actions: \n" + Controller.getAllActions())
|
print("All Actions: \n" + Controller.getAllActions());
|
||||||
|
|
||||||
// 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 5 int: \n" + Controller.getAllActions()[5].action);
|
||||||
|
|
||||||
// actionName: string representation of enum
|
// actionName: string representation of enum
|
||||||
print("Action 5 name: \n" + Controller.getAllActions()[5].actionName)
|
print("Action 5 name: \n" + Controller.getAllActions()[5].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 5 input channels: \n" + Controller.getAllActions()[5].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()[5].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()[5].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()[5].inputChannels[0].input + "\n" + Controller.getAllActions()[5].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()[5].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()[5].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()[5].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()[5].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()[5].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");
|
||||||
|
|
||||||
|
|
||||||
// Modifying properties:
|
// Modifying properties:
|
||||||
// The following code will switch the "w" and "s" key functionality and adjust their scales
|
// The following code will switch the "w" and "s" key functionality and adjust their scales
|
||||||
var s = Controller.getAllActions()[0].inputChannels[0]
|
var s = Controller.getAllActions()[0].inputChannels[0];
|
||||||
var w = Controller.getAllActions()[1].inputChannels[0]
|
var w = Controller.getAllActions()[1].inputChannels[0];
|
||||||
|
|
||||||
// You must remove an input controller before modifying it so the old input controller isn't registered anymore
|
// You must remove an input controller before modifying it so the old input controller isn't registered anymore
|
||||||
// removeInputChannel and addInputChannel return true if successful, false otherwise
|
// removeInputChannel and addInputChannel return true if successful, false otherwise
|
||||||
Controller.removeInputChannel(s)
|
Controller.removeInputChannel(s);
|
||||||
Controller.removeInputChannel(w)
|
Controller.removeInputChannel(w);
|
||||||
print(s.scale)
|
print(s.scale);
|
||||||
s.action = 1
|
s.action = 1;
|
||||||
s.scale = .01
|
s.scale = .01;
|
||||||
|
|
||||||
w.action = 0
|
w.action = 0;
|
||||||
w.scale = 10000
|
w.scale = 10000;
|
||||||
Controller.addInputChannel(s)
|
Controller.addInputChannel(s);
|
||||||
Controller.addInputChannel(w)
|
Controller.addInputChannel(w);
|
||||||
print(s.scale)
|
print(s.scale);
|
||||||
|
|
||||||
// You can get all the available inputs for any device
|
// You can get all the available inputs for any device
|
||||||
// Each AvailableInput has:
|
// Each AvailableInput has:
|
||||||
// input: the Input itself
|
// input: the Input itself
|
||||||
// inputName: string representing the input
|
// inputName: string representing the input
|
||||||
var availableInputs = Controller.getAvailableInputs(1)
|
var availableInputs = Controller.getAvailableInputs(1);
|
||||||
for (i = 0; i < availableInputs.length; i++) {
|
for (i = 0; i < availableInputs.length; i++) {
|
||||||
print(availableInputs[i].inputName);
|
print(availableInputs[i].inputName);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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()[5].inputChannels[0];
|
||||||
Controller.removeInputChannel(e)
|
Controller.removeInputChannel(e);
|
||||||
e.input = availableInputs[6].input
|
e.input = availableInputs[6].input;
|
||||||
Controller.addInputChannel(e)
|
Controller.addInputChannel(e);
|
Loading…
Reference in a new issue