mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 15:23:56 +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
|
||||
//
|
||||
|
||||
joysticks = Joysticks.availableJoystickNames;
|
||||
gamepad = Joysticks.joystickWithName("Wireless 360 Controller");
|
||||
|
||||
for (i = 0; i < joysticks.length; i++) {
|
||||
print("Joystick " + i + " is " + joysticks[i]);
|
||||
}
|
||||
function reportAxisValue(axis, newValue, oldValue) {
|
||||
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();
|
||||
}
|
||||
|
||||
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,
|
||||
bool loadScriptFromEditor, bool activateMainWindow) {
|
||||
QUrl scriptUrl(scriptFilename);
|
||||
|
@ -3850,6 +3858,7 @@ ScriptEngine* Application::loadScript(const QString& scriptFilename, bool isUser
|
|||
scriptEngine->registerGlobalObject("AvatarManager", &_avatarManager);
|
||||
|
||||
scriptEngine->registerGlobalObject("Joysticks", &JoystickScriptingInterface::getInstance());
|
||||
qScriptRegisterMetaType(scriptEngine, joystickToScriptValue, joystickFromScriptValue);
|
||||
|
||||
#ifdef HAVE_RTMIDI
|
||||
scriptEngine->registerGlobalObject("MIDI", &MIDIManager::getInstance());
|
||||
|
|
Loading…
Reference in a new issue