mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
split touch events to enabled and supported. (#43)
This commit is contained in:
parent
45c0b4527f
commit
c71a9d7626
@ -33,8 +33,12 @@ export class NekoControl extends EventEmitter<NekoControlEvents> {
|
|||||||
return this._connection.webrtc.connected && this._state.is_host
|
return this._connection.webrtc.connected && this._state.is_host
|
||||||
}
|
}
|
||||||
|
|
||||||
get hasTouchEvents() {
|
get enabledTouchEvents() {
|
||||||
return this._state.touch_events
|
return this._state.touch.enabled
|
||||||
|
}
|
||||||
|
|
||||||
|
get supportedTouchEvents() {
|
||||||
|
return this._state.touch.supported
|
||||||
}
|
}
|
||||||
|
|
||||||
public lock() {
|
public lock() {
|
||||||
|
@ -104,7 +104,8 @@ export class NekoMessages extends EventEmitter<NekoEvents> {
|
|||||||
protected [EVENT.SYSTEM_INIT](conf: message.SystemInit) {
|
protected [EVENT.SYSTEM_INIT](conf: message.SystemInit) {
|
||||||
this._localLog.debug(`EVENT.SYSTEM_INIT`)
|
this._localLog.debug(`EVENT.SYSTEM_INIT`)
|
||||||
Vue.set(this._state, 'session_id', conf.session_id)
|
Vue.set(this._state, 'session_id', conf.session_id)
|
||||||
Vue.set(this._state.control, 'touch_events', conf.touch_events)
|
// check if backend supports touch events
|
||||||
|
Vue.set(this._state.control.touch, 'supported', conf.touch_events)
|
||||||
Vue.set(this._state.connection, 'screencast', conf.screencast_enabled)
|
Vue.set(this._state.connection, 'screencast', conf.screencast_enabled)
|
||||||
Vue.set(this._state.connection.webrtc, 'videos', conf.webrtc.videos)
|
Vue.set(this._state.connection.webrtc, 'videos', conf.webrtc.videos)
|
||||||
|
|
||||||
|
@ -200,7 +200,10 @@
|
|||||||
layout: 'us',
|
layout: 'us',
|
||||||
variant: '',
|
variant: '',
|
||||||
},
|
},
|
||||||
touch_events: false,
|
touch: {
|
||||||
|
enabled: true,
|
||||||
|
supported: false,
|
||||||
|
},
|
||||||
host_id: null,
|
host_id: null,
|
||||||
is_host: false,
|
is_host: false,
|
||||||
locked: false,
|
locked: false,
|
||||||
@ -487,6 +490,10 @@
|
|||||||
Vue.set(this.state.control, 'keyboard', { layout, variant })
|
Vue.set(this.state.control, 'keyboard', { layout, variant })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public setTouchEnabled(value: boolean = true) {
|
||||||
|
Vue.set(this.state.control.touch, 'enabled', value)
|
||||||
|
}
|
||||||
|
|
||||||
public mobileKeyboardShow() {
|
public mobileKeyboardShow() {
|
||||||
this._overlay.mobileKeyboardShow()
|
this._overlay.mobileKeyboardShow()
|
||||||
}
|
}
|
||||||
|
@ -195,7 +195,7 @@
|
|||||||
// Initialize GestureHandler
|
// Initialize GestureHandler
|
||||||
this.gestureHandler = new GestureHandlerInit()
|
this.gestureHandler = new GestureHandlerInit()
|
||||||
|
|
||||||
// bind touch handler using @Watch on hasTouchEvents
|
// bind touch handler using @Watch on supportedTouchEvents
|
||||||
// because we need to know if touch events are supported
|
// because we need to know if touch events are supported
|
||||||
// by the server before we can bind touch handler
|
// by the server before we can bind touch handler
|
||||||
|
|
||||||
@ -467,13 +467,19 @@
|
|||||||
// touch and gesture handlers cannot be used together
|
// touch and gesture handlers cannot be used together
|
||||||
//
|
//
|
||||||
|
|
||||||
@Watch('control.hasTouchEvents')
|
@Watch('control.enabledTouchEvents')
|
||||||
|
@Watch('control.supportedTouchEvents')
|
||||||
onTouchEventsChange() {
|
onTouchEventsChange() {
|
||||||
if (this.control.hasTouchEvents) {
|
this.unbindGestureHandler()
|
||||||
this.unbindGestureHandler()
|
this.unbindTouchHandler()
|
||||||
|
|
||||||
|
if (!this.control.enabledTouchEvents) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.control.supportedTouchEvents) {
|
||||||
this.bindTouchHandler()
|
this.bindTouchHandler()
|
||||||
} else {
|
} else {
|
||||||
this.unbindTouchHandler()
|
|
||||||
this.bindGestureHandler()
|
this.bindGestureHandler()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ export interface Control {
|
|||||||
scroll: Scroll
|
scroll: Scroll
|
||||||
clipboard: Clipboard | null
|
clipboard: Clipboard | null
|
||||||
keyboard: Keyboard
|
keyboard: Keyboard
|
||||||
touch_events: boolean
|
touch: Touch
|
||||||
host_id: string | null
|
host_id: string | null
|
||||||
is_host: boolean
|
is_host: boolean
|
||||||
locked: boolean
|
locked: boolean
|
||||||
@ -90,6 +90,11 @@ export interface Keyboard {
|
|||||||
variant: string
|
variant: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface Touch {
|
||||||
|
enabled: boolean
|
||||||
|
supported: boolean
|
||||||
|
}
|
||||||
|
|
||||||
/////////////////////////////
|
/////////////////////////////
|
||||||
// Screen
|
// Screen
|
||||||
/////////////////////////////
|
/////////////////////////////
|
||||||
|
@ -335,8 +335,19 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>control.touch_events</th>
|
<th>control.touch.enabled</th>
|
||||||
<td>{{ neko.state.control.touch_events ? 'backend supports' : 'backend does not support' }}</td>
|
<td>
|
||||||
|
<div class="space-between">
|
||||||
|
<span>{{ neko.state.control.touch.enabled }}</span>
|
||||||
|
<button @click="neko.setTouchEnabled(!neko.state.control.touch.enabled)">
|
||||||
|
<i class="fas fa-toggle-on"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>control.touch.supported</th>
|
||||||
|
<td>{{ neko.state.control.touch.supported }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th rowspan="2">control.host_id</th>
|
<th rowspan="2">control.host_id</th>
|
||||||
|
Loading…
Reference in New Issue
Block a user