Skip to content

Commit 22a662d

Browse files
authored
fix NullReferenceException in InputRemoting (#831)
1 parent 7c29abb commit 22a662d

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

WebApp/client/src/inputdevice.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export class InputDevice {
4343
* name;
4444
* layout;
4545
* deviceId;
46-
* variants;
46+
* usages;
4747
* description;
4848
*
4949
* _inputState;
@@ -54,14 +54,14 @@ export class InputDevice {
5454
* @param {Number} name
5555
* @param {String} layout
5656
* @param {Number} deviceId
57-
* @param {String} variants
57+
* @param {String[]} usages
5858
* @param {Object} description
5959
*/
60-
constructor(name, layout, deviceId, variants, description) {
60+
constructor(name, layout, deviceId, usages, description) {
6161
this.name = name;
6262
this.layout = layout;
6363
this.deviceId = deviceId;
64-
this.variants = variants;
64+
this.usages = usages;
6565
this.description = description;
6666

6767
this._inputState = null;

WebApp/client/src/sender.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class Sender extends LocalInputManager {
3838
m_Version: "",
3939
m_Capabilities: ""
4040
};
41-
this.mouse = new Mouse("Mouse", "Mouse", 1, "", descriptionMouse);
41+
this.mouse = new Mouse("Mouse", "Mouse", 1, null, descriptionMouse);
4242
this._devices.push(this.mouse);
4343

4444
this._elem.addEventListener('click', this._onMouseEvent.bind(this), false);
@@ -58,7 +58,7 @@ export class Sender extends LocalInputManager {
5858
m_Version: "",
5959
m_Capabilities: ""
6060
};
61-
this.keyboard = new Keyboard("Keyboard", "Keyboard", 2, "", descriptionKeyboard);
61+
this.keyboard = new Keyboard("Keyboard", "Keyboard", 2, null, descriptionKeyboard);
6262
this._devices.push(this.keyboard);
6363

6464
document.addEventListener('keyup', this._onKeyEvent.bind(this), false);
@@ -75,7 +75,7 @@ export class Sender extends LocalInputManager {
7575
m_Version: "",
7676
m_Capabilities: ""
7777
};
78-
this.gamepad = new Gamepad("Gamepad", "Gamepad", 3, "", descriptionGamepad);
78+
this.gamepad = new Gamepad("Gamepad", "Gamepad", 3, null, descriptionGamepad);
7979
this._devices.push(this.gamepad);
8080

8181
window.addEventListener("gamepadconnected", this._onGamepadEvent.bind(this), false);
@@ -94,7 +94,7 @@ export class Sender extends LocalInputManager {
9494
m_Version: "",
9595
m_Capabilities: ""
9696
};
97-
this.touchscreen = new Touchscreen("Touchscreen", "Touchscreen", 4, "", descriptionTouch);
97+
this.touchscreen = new Touchscreen("Touchscreen", "Touchscreen", 4, null, descriptionTouch);
9898
this._devices.push(this.touchscreen);
9999

100100
this._elem.addEventListener('touchend', this._onTouchEvent.bind(this), false);

com.unity.renderstreaming/Runtime/Scripts/InputSystem/InputRemoting.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -653,8 +653,9 @@ public static void Process(InputRemoting Receiver, Message msg)
653653
var deviceFlagsRemote = 1 << 3;
654654
device.SetDeviceFlags(device.GetDeviceFlags() | deviceFlagsRemote);
655655

656-
foreach (var usage in data.usages)
657-
Receiver.m_LocalManager.AddDeviceUsage(device, usage);
656+
if(data.usages != null)
657+
foreach (var usage in data.usages)
658+
Receiver.m_LocalManager.AddDeviceUsage(device, usage);
658659

659660
// Remember it.
660661
var record = new RemoteInputDevice

0 commit comments

Comments
 (0)