Skip to content

Commit

Permalink
fix NullReferenceException in InputRemoting (#831)
Browse files Browse the repository at this point in the history
  • Loading branch information
karasusan authored Jan 10, 2023
1 parent 7c29abb commit 22a662d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
8 changes: 4 additions & 4 deletions WebApp/client/src/inputdevice.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class InputDevice {
* name;
* layout;
* deviceId;
* variants;
* usages;
* description;
*
* _inputState;
Expand All @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions WebApp/client/src/sender.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 22a662d

Please sign in to comment.