deviceSourceManager.d.ts 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import { DeviceType } from "./deviceEnums";
  2. import type { Nullable } from "../../types";
  3. import { Observable } from "../../Misc/observable";
  4. import type { DeviceSource } from "./deviceSource";
  5. import type { IObservableManager, DeviceSourceType } from "../internalDeviceSourceManager";
  6. import type { IDisposable } from "../../scene";
  7. import type { AbstractEngine } from "../../Engines/abstractEngine";
  8. import type { IUIEvent } from "../../Events/deviceInputEvents";
  9. /**
  10. * Class to keep track of devices
  11. */
  12. export declare class DeviceSourceManager implements IDisposable, IObservableManager {
  13. /**
  14. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  15. */
  16. readonly onDeviceConnectedObservable: Observable<DeviceSourceType>;
  17. /**
  18. * Observable to be triggered when after a device is disconnected
  19. */
  20. readonly onDeviceDisconnectedObservable: Observable<DeviceSourceType>;
  21. private _engine;
  22. private _onDisposeObserver;
  23. private readonly _devices;
  24. private readonly _firstDevice;
  25. /**
  26. * Gets a DeviceSource, given a type and slot
  27. * @param deviceType - Type of Device
  28. * @param deviceSlot - Slot or ID of device
  29. * @returns DeviceSource
  30. */
  31. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  32. /**
  33. * Gets an array of DeviceSource objects for a given device type
  34. * @param deviceType - Type of Device
  35. * @returns All available DeviceSources of a given type
  36. */
  37. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  38. /**
  39. * Default constructor
  40. * @param engine - Used to get canvas (if applicable)
  41. */
  42. constructor(engine: AbstractEngine);
  43. /**
  44. * Dispose of DeviceSourceManager
  45. */
  46. dispose(): void;
  47. /**
  48. * @param deviceSource - Source to add
  49. * @internal
  50. */
  51. _addDevice(deviceSource: DeviceSourceType): void;
  52. /**
  53. * @param deviceType - DeviceType
  54. * @param deviceSlot - DeviceSlot
  55. * @internal
  56. */
  57. _removeDevice(deviceType: DeviceType, deviceSlot: number): void;
  58. /**
  59. * @param deviceType - DeviceType
  60. * @param deviceSlot - DeviceSlot
  61. * @param eventData - Event
  62. * @internal
  63. */
  64. _onInputChanged<T extends DeviceType>(deviceType: T, deviceSlot: number, eventData: IUIEvent): void;
  65. private _updateFirstDevices;
  66. }