deviceSource.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import { Observable } from "../../Misc/observable.js";
  2. /**
  3. * Class that handles all input for a specific device
  4. */
  5. export class DeviceSource {
  6. /**
  7. * Default Constructor
  8. * @param deviceInputSystem - Reference to DeviceInputSystem
  9. * @param deviceType - Type of device
  10. * @param deviceSlot - "Slot" or index that device is referenced in
  11. */
  12. constructor(deviceInputSystem,
  13. /** Type of device */
  14. deviceType,
  15. /** "Slot" or index that device is referenced in */
  16. deviceSlot = 0) {
  17. this.deviceType = deviceType;
  18. this.deviceSlot = deviceSlot;
  19. // Public Members
  20. /**
  21. * Observable to handle device input changes per device
  22. */
  23. this.onInputChangedObservable = new Observable();
  24. this._deviceInputSystem = deviceInputSystem;
  25. }
  26. /**
  27. * Get input for specific input
  28. * @param inputIndex - index of specific input on device
  29. * @returns Input value from DeviceInputSystem
  30. */
  31. getInput(inputIndex) {
  32. return this._deviceInputSystem.pollInput(this.deviceType, this.deviceSlot, inputIndex);
  33. }
  34. }
  35. //# sourceMappingURL=deviceSource.js.map