mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-06-15 15:28:46 +02:00
report the 360 axis values in xbox.js
This commit is contained in:
parent
d50c81e4a1
commit
13d3eb02e3
2 changed files with 15 additions and 4 deletions
|
@ -10,8 +10,10 @@
|
||||||
// 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
|
||||||
//
|
//
|
||||||
|
|
||||||
joysticks = Joysticks.availableJoystickNames;
|
gamepad = Joysticks.joystickWithName("Wireless 360 Controller");
|
||||||
|
|
||||||
for (i = 0; i < joysticks.length; i++) {
|
function reportAxisValue(axis, newValue, oldValue) {
|
||||||
print("Joystick " + i + " is " + joysticks[i]);
|
print("The value for axis " + axis + " has changed to " + newValue + ". It was " + oldValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gamepad.axisValueChanged.connect(reportAxisValue);
|
|
@ -3766,6 +3766,14 @@ void Application::saveScripts() {
|
||||||
_settings->endArray();
|
_settings->endArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QScriptValue joystickToScriptValue(QScriptEngine *engine, Joystick* const &in) {
|
||||||
|
return engine->newQObject(in);
|
||||||
|
}
|
||||||
|
|
||||||
|
void joystickFromScriptValue(const QScriptValue &object, Joystick* &out) {
|
||||||
|
out = qobject_cast<Joystick*>(object.toQObject());
|
||||||
|
}
|
||||||
|
|
||||||
ScriptEngine* Application::loadScript(const QString& scriptFilename, bool isUserLoaded,
|
ScriptEngine* Application::loadScript(const QString& scriptFilename, bool isUserLoaded,
|
||||||
bool loadScriptFromEditor, bool activateMainWindow) {
|
bool loadScriptFromEditor, bool activateMainWindow) {
|
||||||
QUrl scriptUrl(scriptFilename);
|
QUrl scriptUrl(scriptFilename);
|
||||||
|
@ -3850,6 +3858,7 @@ ScriptEngine* Application::loadScript(const QString& scriptFilename, bool isUser
|
||||||
scriptEngine->registerGlobalObject("AvatarManager", &_avatarManager);
|
scriptEngine->registerGlobalObject("AvatarManager", &_avatarManager);
|
||||||
|
|
||||||
scriptEngine->registerGlobalObject("Joysticks", &JoystickScriptingInterface::getInstance());
|
scriptEngine->registerGlobalObject("Joysticks", &JoystickScriptingInterface::getInstance());
|
||||||
|
qScriptRegisterMetaType(scriptEngine, joystickToScriptValue, joystickFromScriptValue);
|
||||||
|
|
||||||
#ifdef HAVE_RTMIDI
|
#ifdef HAVE_RTMIDI
|
||||||
scriptEngine->registerGlobalObject("MIDI", &MIDIManager::getInstance());
|
scriptEngine->registerGlobalObject("MIDI", &MIDIManager::getInstance());
|
||||||
|
|
Loading…
Reference in a new issue