-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PLAYER-19] keybinding (post refacto dialog) #82
Changes from 6 commits
e67547a
adf4417
27efda7
bb2733d
0f2f58b
ca11d54
97c8341
6225eb8
945ec43
878896d
79a0831
9636952
3e80de7
f9f7af6
9cc3cb4
6965a6c
1d08aa5
a5d6da7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ const Screencast = require('./plugins/Screencast'); | |
const StreamResolution = require('./plugins/StreamResolution'); | ||
const CoordinateUtils = require('./plugins/CoordinateUtils'); | ||
const KeyboardEvents = require('./plugins/KeyboardEvents'); | ||
const KeyboardMapping = require('./plugins/KeyboardMapping'); | ||
const MouseEvents = require('./plugins/MouseEvents'); | ||
const PeerConnectionStats = require('./plugins/PeerConnectionStats'); | ||
const Gamepad = require('./plugins/Gamepad'); | ||
|
@@ -52,8 +53,6 @@ module.exports = class DeviceRenderer { | |
this.initialized = false; | ||
this.reconnecting = false; | ||
|
||
// Enabled features | ||
this.keyboardEventsEnabled = false; | ||
this.touchEventsEnabled = false; | ||
this.mouseEventsEnabled = false; | ||
this.gamepadEventsEnabled = false; | ||
|
@@ -88,17 +87,6 @@ module.exports = class DeviceRenderer { | |
// last accessed x/y position | ||
this.x = 0; | ||
this.y = 0; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Click handler handle has been move to overlayplugin class (decoupling) |
||
this.clickHandlerCloseOverlay = (event) => { | ||
if ( | ||
event.target.closest('.gm-overlay') === null && | ||
!event.target.classList.contains('gm-icon-button') && | ||
!event.target.classList.contains('gm-dont-close') | ||
) { | ||
this.store.dispatch({type: 'OVERLAY_OPEN', payload: {toOpen: false}}); | ||
} | ||
}; | ||
this.addListener(document, 'click', this.clickHandlerCloseOverlay); | ||
} | ||
|
||
/** | ||
|
@@ -119,6 +107,7 @@ module.exports = class DeviceRenderer { | |
{enabled: this.options.streamResolution, class: StreamResolution}, | ||
{enabled: this.options.touch || this.options.mouse, class: CoordinateUtils}, | ||
{enabled: this.options.keyboard, class: KeyboardEvents}, | ||
{enabled: this.options.keyboardMapping, class: KeyboardMapping}, | ||
{enabled: this.options.mouse, class: MouseEvents}, | ||
{ | ||
enabled: this.options.gamepad, | ||
|
@@ -486,10 +475,6 @@ module.exports = class DeviceRenderer { | |
this.mouseEvents.addMouseCallbacks(); | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. decoupling see above |
||
if (this.keyboardEventsEnabled) { | ||
this.keyboardEvents.addKeyboardCallbacks(); | ||
} | ||
|
||
if (this.gamepadEventsEnabled) { | ||
this.gamepadManager.addGamepadCallbacks(); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -127,7 +127,7 @@ module.exports = class FingerPrint extends OverlayPlugin { | |
|
||
// register callback | ||
this.instance.registerEventCallback('fingerprint', (message) => this.handleFingerprintEvent(message)); | ||
if (this.instance.store.getState().isWebRTCConnectionReady) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. getState was unecessary for a little store, |
||
if (this.instance.store.state.isWebRTCConnectionReady) { | ||
this.sendDataToInstance(FINGERPRINT_MESSAGES.toSend.NOTIFY_ALL); | ||
} else { | ||
const unSubscribe = this.instance.store.subscribe(({isWebRTCConnectionReady}) => { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,18 @@ module.exports = class Fullscreen { | |
this.instance.addListener(document, 'fullscreenchange', this.onFullscreenEvent.bind(this), false); | ||
} | ||
|
||
this.instance.apiManager.registerFunction({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Requested from socis |
||
name: 'fullsreen', | ||
category: 'video', | ||
fn: () => { | ||
if (this.fullscreenEnabled()) { | ||
this.exitFullscreen(); | ||
} else { | ||
this.goFullscreen(this.instance.root); | ||
} | ||
}, | ||
description: 'toggle fullscreen mode', | ||
}); | ||
// Display widget | ||
this.renderToolbarButton(); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,15 +54,20 @@ module.exports = class KeyboardEvents { | |
|
||
// Register plugin | ||
this.instance.keyboardEvents = this; | ||
this.instance.keyboardEventsEnabled = true; | ||
|
||
this.transmitKeys = this.instance.store.getState().isKeyboardEventsEnabled; | ||
this.isListenerAdded = false; | ||
this.currentlyPressedKeys = new Map(); | ||
|
||
this.instance.store.subscribe(({isKeyboardEventsEnabled}) => { | ||
this.transmitKeys = isKeyboardEventsEnabled; | ||
if (isKeyboardEventsEnabled) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. little refact to decoupling keyboard handle events of deviceRenderer js |
||
this.addKeyboardCallbacks(); | ||
} else { | ||
this.removeKeyboardCallbacks(); | ||
} | ||
}); | ||
|
||
// activate the plugin listening | ||
this.instance.store.dispatch({type: 'KEYBOARD_EVENTS_ENABLED', payload: true}); | ||
} | ||
|
||
/** | ||
|
@@ -89,9 +94,6 @@ module.exports = class KeyboardEvents { | |
* @param {Event} event Event. | ||
*/ | ||
onKeyPress(event) { | ||
if (!this.transmitKeys) { | ||
return; | ||
} | ||
const key = event.charCode; | ||
let text = event.key || String.fromCharCode(key); | ||
if (text === 'Spacebar') { | ||
|
@@ -118,10 +120,6 @@ module.exports = class KeyboardEvents { | |
* @return {boolean} Whether or not the event must continue propagation. | ||
*/ | ||
onKeyDown(event) { | ||
if (!this.transmitKeys) { | ||
return true; | ||
} | ||
|
||
let key; | ||
/** | ||
* Convert invisible key or shortcut keys when ctrl/meta are pressed | ||
|
@@ -176,10 +174,6 @@ module.exports = class KeyboardEvents { | |
* @return {boolean} Whether or not the event must continue propagation. | ||
*/ | ||
onKeyUp(event) { | ||
if (!this.transmitKeys) { | ||
return true; | ||
} | ||
|
||
let key; | ||
/** | ||
* Convert invisible key or shortcut keys when ctrl/meta are pressed | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a category for API manager exposed fn => window.player.media.mute()