From 22a662dee7991303597d4a78196ff8835a969f08 Mon Sep 17 00:00:00 2001 From: Kazuki Matsumoto <1132081+karasusan@users.noreply.github.com> Date: Tue, 10 Jan 2023 18:31:00 +0900 Subject: [PATCH] fix NullReferenceException in InputRemoting (#831) --- WebApp/client/src/inputdevice.js | 8 ++++---- WebApp/client/src/sender.js | 8 ++++---- .../Runtime/Scripts/InputSystem/InputRemoting.cs | 5 +++-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/WebApp/client/src/inputdevice.js b/WebApp/client/src/inputdevice.js index 3a9dfd67e..a7f32f628 100644 --- a/WebApp/client/src/inputdevice.js +++ b/WebApp/client/src/inputdevice.js @@ -43,7 +43,7 @@ export class InputDevice { * name; * layout; * deviceId; - * variants; + * usages; * description; * * _inputState; @@ -54,14 +54,14 @@ export class InputDevice { * @param {Number} name * @param {String} layout * @param {Number} deviceId - * @param {String} variants + * @param {String[]} usages * @param {Object} description */ - constructor(name, layout, deviceId, variants, description) { + constructor(name, layout, deviceId, usages, description) { this.name = name; this.layout = layout; this.deviceId = deviceId; - this.variants = variants; + this.usages = usages; this.description = description; this._inputState = null; diff --git a/WebApp/client/src/sender.js b/WebApp/client/src/sender.js index 88d909166..3ca3eb841 100644 --- a/WebApp/client/src/sender.js +++ b/WebApp/client/src/sender.js @@ -38,7 +38,7 @@ export class Sender extends LocalInputManager { m_Version: "", m_Capabilities: "" }; - this.mouse = new Mouse("Mouse", "Mouse", 1, "", descriptionMouse); + this.mouse = new Mouse("Mouse", "Mouse", 1, null, descriptionMouse); this._devices.push(this.mouse); this._elem.addEventListener('click', this._onMouseEvent.bind(this), false); @@ -58,7 +58,7 @@ export class Sender extends LocalInputManager { m_Version: "", m_Capabilities: "" }; - this.keyboard = new Keyboard("Keyboard", "Keyboard", 2, "", descriptionKeyboard); + this.keyboard = new Keyboard("Keyboard", "Keyboard", 2, null, descriptionKeyboard); this._devices.push(this.keyboard); document.addEventListener('keyup', this._onKeyEvent.bind(this), false); @@ -75,7 +75,7 @@ export class Sender extends LocalInputManager { m_Version: "", m_Capabilities: "" }; - this.gamepad = new Gamepad("Gamepad", "Gamepad", 3, "", descriptionGamepad); + this.gamepad = new Gamepad("Gamepad", "Gamepad", 3, null, descriptionGamepad); this._devices.push(this.gamepad); window.addEventListener("gamepadconnected", this._onGamepadEvent.bind(this), false); @@ -94,7 +94,7 @@ export class Sender extends LocalInputManager { m_Version: "", m_Capabilities: "" }; - this.touchscreen = new Touchscreen("Touchscreen", "Touchscreen", 4, "", descriptionTouch); + this.touchscreen = new Touchscreen("Touchscreen", "Touchscreen", 4, null, descriptionTouch); this._devices.push(this.touchscreen); this._elem.addEventListener('touchend', this._onTouchEvent.bind(this), false); diff --git a/com.unity.renderstreaming/Runtime/Scripts/InputSystem/InputRemoting.cs b/com.unity.renderstreaming/Runtime/Scripts/InputSystem/InputRemoting.cs index 66b2e3feb..da06f6c4f 100644 --- a/com.unity.renderstreaming/Runtime/Scripts/InputSystem/InputRemoting.cs +++ b/com.unity.renderstreaming/Runtime/Scripts/InputSystem/InputRemoting.cs @@ -653,8 +653,9 @@ public static void Process(InputRemoting Receiver, Message msg) var deviceFlagsRemote = 1 << 3; device.SetDeviceFlags(device.GetDeviceFlags() | deviceFlagsRemote); - foreach (var usage in data.usages) - Receiver.m_LocalManager.AddDeviceUsage(device, usage); + if(data.usages != null) + foreach (var usage in data.usages) + Receiver.m_LocalManager.AddDeviceUsage(device, usage); // Remember it. var record = new RemoteInputDevice