浏览代码

Updated getDeviceSource

Dave Solares 5 年之前
父节点
当前提交
5769c03ea3
共有 1 个文件被更改,包括 11 次插入3 次删除
  1. 11 3
      src/DeviceInput/InputDevices/deviceSourceManager.ts

+ 11 - 3
src/DeviceInput/InputDevices/deviceSourceManager.ts

@@ -108,8 +108,16 @@ export class DeviceSourceManager implements IDisposable {
      * @param deviceSlot "Slot" or index that device is referenced in
      * @returns DeviceSource object
      */
-    public getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot: number = this._firstDevice[deviceType]): Nullable<DeviceSource<T>> {
-        if (!this._devices[deviceType] || this._firstDevice[deviceType] === undefined || this._devices[deviceType][deviceSlot] === undefined) {
+    public getDeviceSource<T extends DeviceType>(deviceType: DeviceType, deviceSlot?: number): Nullable<DeviceSource<T>> {
+        if (deviceSlot === undefined) {
+            if (this._firstDevice[deviceType] === undefined) {
+                return null;
+            }
+
+            deviceSlot = this._firstDevice[deviceType];
+        }
+
+        if (!this._devices[deviceType] || this._devices[deviceType][deviceSlot] === undefined) {
             return null;
         }
 
@@ -183,4 +191,4 @@ export class DeviceSourceManager implements IDisposable {
                 break;
         }
     }
-}
+}