From b552dc6f52e993c48551934a7c667ed4a2565cce Mon Sep 17 00:00:00 2001 From: Aaron Brady Date: Mon, 13 Aug 2018 11:21:55 -0700 Subject: [PATCH] Make WindowsDevice for Sonar Summary: This diff adds the ability for a windows desktop app to be a selectable device for Sonar. just to over-communicate what I'm thinking regarding the logging: windows system logs don't have a lot of valuable information in my experience, and there is a ton of garbage, but there is probably a way to tap into that if we want. however, I was thinking that redirecting stderr/stdout from every connected process would be useful. i.e. OVRServer could register a log plugin and it would write to the device's log output. not sure if this would be better than just having a logger plugin. This is probably a pretty naive question and this probably isn't the place to have this conversation...but here we are :) Reviewed By: jknoxville Differential Revision: D8861986 fbshipit-source-id: f6ccba28729692ae4566dd24302268ad54d437eb --- src/devices/WindowsDevice.js | 27 +++++++++++++++++++++++++++ src/dispatcher/index.js | 12 +++++++++--- src/dispatcher/windowsDevice.js | 21 +++++++++++++++++++++ 3 files changed, 57 insertions(+), 3 deletions(-) create mode 100644 src/devices/WindowsDevice.js create mode 100644 src/dispatcher/windowsDevice.js diff --git a/src/devices/WindowsDevice.js b/src/devices/WindowsDevice.js new file mode 100644 index 000000000..ba1d8471e --- /dev/null +++ b/src/devices/WindowsDevice.js @@ -0,0 +1,27 @@ +/** + * Copyright 2018-present Facebook. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * @format + */ + +import type {DeviceLogListener} from './BaseDevice.js'; +import BaseDevice from './BaseDevice.js'; + +export default class WindowsDevice extends BaseDevice { + supportedPlugins = []; + icon = 'icons/oculus.png'; + os = 'windows'; + + constructor() { + super('', 'physical', 'desktop'); + } + + teardown() {} + + supportedColumns(): Array { + return []; + } + + addLogListener(_callback: DeviceLogListener) {} +} diff --git a/src/dispatcher/index.js b/src/dispatcher/index.js index 66f4152b2..dc00ff00b 100644 --- a/src/dispatcher/index.js +++ b/src/dispatcher/index.js @@ -7,6 +7,7 @@ import androidDevice from './androidDevice'; import iOSDevice from './iOSDevice'; +import windowsDevice from './windowsDevice'; import application from './application'; import tracking from './tracking'; import server from './server'; @@ -15,6 +16,11 @@ import type Logger from '../fb-stubs/Logger.js'; import type {Store} from '../reducers/index.js'; export default (store: Store, logger: Logger) => - [application, androidDevice, iOSDevice, tracking, server].forEach(fn => - fn(store, logger), - ); + [ + application, + androidDevice, + iOSDevice, + windowsDevice, + tracking, + server, + ].forEach(fn => fn(store, logger)); diff --git a/src/dispatcher/windowsDevice.js b/src/dispatcher/windowsDevice.js new file mode 100644 index 000000000..e22098e99 --- /dev/null +++ b/src/dispatcher/windowsDevice.js @@ -0,0 +1,21 @@ +/** + * Copyright 2018-present Facebook. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * @format + */ + +import type {Store} from '../reducers/index.js'; +import type Logger from '../fb-stubs/Logger.js'; + +import WindowsDevice from '../devices/WindowsDevice'; + +export default (store: Store, logger: Logger) => { + if (process.platform !== 'win32') { + return; + } + store.dispatch({ + type: 'REGISTER_DEVICE', + payload: new WindowsDevice(), + }); +};