inputTest.tscript 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. //-----------------------------------------------------------------------------
  2. // Module creation functions.
  3. //-----------------------------------------------------------------------------
  4. function inputTest::create( %this )
  5. {
  6. // If addToMainMenu is true, a button to display the input monitor will be
  7. // added to the MainMenu gui. If false, you will need to call
  8. // "$GameCanvas.pushDialog(InputMonitorDlg);" from the console or add a
  9. // shortcut somewhere else to access the Input Event Monitor.
  10. %this.addToMainMenu = true;
  11. }
  12. function inputTest::destroy( %this )
  13. {
  14. }
  15. function inputTest::initClient( %this )
  16. {
  17. %this.queueExec("./scripts/customProfiles." @ $TorqueScriptFileExtension);
  18. %this.queueExec("./scripts/inputMonitor." @ $TorqueScriptFileExtension);
  19. %this.queueExec("./scripts/gui/inputMonitor.gui");
  20. %this.queueExec("./scripts/joystickSettings." @ $TorqueScriptFileExtension);
  21. %this.queueExec("./scripts/gui/joystickSettings.gui");
  22. %this.queueExec("./scripts/menuButtons." @ $TorqueScriptFileExtension);
  23. }
  24. function onSDLDeviceConnected(%sdlIndex, %deviceName, %deviceType)
  25. {
  26. echo("onSDLDeviceConnected(" @ %sdlIndex @ ", \"" @ %deviceName @ "\", \"" @ %deviceType @ "\") - Called");
  27. // Note: This is called before the device is automatically processed to allow
  28. // overrides, so refreshing the gui needs to happen after the device has been opened
  29. if (JoystickSettingsDlg.isAwake())
  30. JoystickSettingsDlg.schedule(250, "updateDevices");
  31. if (InputMonitorDlg.isAwake())
  32. InputMonitorDlg.schedule(250, "updateDevicesLine");
  33. }
  34. function onSDLDeviceDisconnected(%sdlIndex)
  35. {
  36. echo("onSDLDeviceDisconnected(" @ %sdlIndex @ ") - Called");
  37. if (JoystickSettingsDlg.isAwake())
  38. JoystickSettingsDlg.schedule(250, "updateDevices");
  39. if (InputMonitorDlg.isAwake())
  40. InputMonitorDlg.schedule(250, "updateDevicesLine");
  41. }
  42. function listAllGCMappings()
  43. { // Lists all game controller device mappings that are currently installed
  44. %numMappings = SDLInputManager::GameControllerNumMappings();
  45. for (%i = 0; %i < %numMappings; %i++)
  46. echo(SDLInputManager::GameControllerMappingForIndex(%i));
  47. }