bfg-common 1.5.512 → 1.5.514
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/localization/local_be.json +3 -2
- package/assets/localization/local_en.json +3 -2
- package/assets/localization/local_hy.json +3 -2
- package/assets/localization/local_kk.json +3 -2
- package/assets/localization/local_ru.json +3 -2
- package/assets/localization/local_zh.json +3 -2
- package/components/atoms/sortableView/SortableView.vue +2 -2
- package/components/atoms/table/info/lib/models/interfaces.ts +1 -0
- package/components/common/countdownTimer/CountdownTimer.vue +11 -4
- package/components/common/countdownTimer/CountdownTimerNew.vue +13 -5
- package/components/common/layout/theHeader/modals/reconnect/ReconnectNew.vue +1 -0
- package/components/common/readyToComplete/New.vue +9 -0
- package/components/common/spiceConsole/Drawer.vue +30 -2
- package/components/common/spiceConsole/lib/models/types.ts +1 -0
- package/package.json +1 -1
- package/plugins/console.ts +3 -4
- package/plugins/mouse.ts +21 -0
- package/public/spice-console/application/clientgui.js +5 -0
- package/public/spice-console/application/packetfactory.js +5 -0
- package/public/spice-console/application/virtualmouse.js +124 -86
- package/public/spice-console/process/cursorprocess.js +28 -18
- package/public/spice-console/process/inputprocess.js +133 -109
- package/public/spice-console/process/mainprocess.js +169 -37
- package/public/spice-console/spiceobjects/spiceobjects.js +49 -28
- package/public/spice-console-minify/run.min.js +1 -1
|
@@ -19,21 +19,31 @@
|
|
|
19
19
|
|
|
20
20
|
wdi.CursorProcess = $.spcExtend(wdi.EventObject.prototype, {
|
|
21
21
|
imageData: null,
|
|
22
|
-
|
|
22
|
+
|
|
23
23
|
process: function(spiceMessage) {
|
|
24
24
|
switch (spiceMessage.messageType) {
|
|
25
25
|
case wdi.SpiceVars.SPICE_MSG_CURSOR_INIT:
|
|
26
26
|
case wdi.SpiceVars.SPICE_MSG_CURSOR_SET:
|
|
27
|
-
var wdiCursor = this.extractCursor(spiceMessage)
|
|
28
|
-
if(wdiCursor) {
|
|
29
|
-
wdi.VirtualMouse.setHotspot(0, 0)
|
|
30
|
-
wdi.VirtualMouse.setMouse(
|
|
27
|
+
var wdiCursor = this.extractCursor(spiceMessage)
|
|
28
|
+
if (wdiCursor) {
|
|
29
|
+
wdi.VirtualMouse.setHotspot(0, 0)
|
|
30
|
+
wdi.VirtualMouse.setMouse(
|
|
31
|
+
wdiCursor.data,
|
|
32
|
+
wdiCursor.header.hot_spot_x,
|
|
33
|
+
wdiCursor.header.hot_spot_y
|
|
34
|
+
)
|
|
31
35
|
}
|
|
32
|
-
break
|
|
36
|
+
break
|
|
37
|
+
// Custom code
|
|
38
|
+
case wdi.SpiceVars.SPICE_MSG_CURSOR_MOVE:
|
|
39
|
+
var position = spiceMessage.args.position;
|
|
40
|
+
wdi.VirtualMouse.updateCursor(position.x, position.y)
|
|
41
|
+
break
|
|
42
|
+
// Custom code end
|
|
33
43
|
case wdi.SpiceVars.SPICE_MSG_CURSOR_HIDE:
|
|
34
44
|
// на windows-е скрывалась мишка когда на экоане входа мишка пересекала левую границу
|
|
35
45
|
// wdi.VirtualMouse.hideMouse();
|
|
36
|
-
break
|
|
46
|
+
break
|
|
37
47
|
}
|
|
38
48
|
},
|
|
39
49
|
|
|
@@ -51,22 +61,22 @@ wdi.CursorProcess = $.spcExtend(wdi.EventObject.prototype, {
|
|
|
51
61
|
ctx.putImageData(data, 0, 0);
|
|
52
62
|
return imageData.toDataURL("image/png");
|
|
53
63
|
},
|
|
54
|
-
|
|
64
|
+
|
|
55
65
|
extractCursor: function(spiceMessage) {
|
|
56
66
|
var flags = spiceMessage.args.cursor.flags;
|
|
57
67
|
var position = spiceMessage.args.position;
|
|
58
68
|
var visible = spiceMessage.args.visible;
|
|
59
|
-
|
|
69
|
+
|
|
60
70
|
//if there is no cursor, return null
|
|
61
71
|
if(flags & 1) {
|
|
62
72
|
return null;
|
|
63
73
|
}
|
|
64
|
-
|
|
74
|
+
|
|
65
75
|
var imageData = null;
|
|
66
|
-
|
|
76
|
+
|
|
67
77
|
//cursor from cache?
|
|
68
78
|
if(flags & wdi.SpiceCursorFlags.SPICE_CURSOR_FLAGS_FROM_CACHE) {
|
|
69
|
-
imageData = wdi.ImageCache.getCursorFrom(spiceMessage.args.cursor);
|
|
79
|
+
imageData = wdi.ImageCache.getCursorFrom(spiceMessage.args.cursor);
|
|
70
80
|
} else {
|
|
71
81
|
//cursor from packet
|
|
72
82
|
//any case should return url
|
|
@@ -88,22 +98,22 @@ wdi.CursorProcess = $.spcExtend(wdi.EventObject.prototype, {
|
|
|
88
98
|
case wdi.SpiceCursorType.SPICE_CURSOR_TYPE_COLOR32:
|
|
89
99
|
case wdi.SpiceCursorType.SPICE_CURSOR_TYPE_ENUM_END:
|
|
90
100
|
break;
|
|
91
|
-
}
|
|
101
|
+
}
|
|
92
102
|
}
|
|
93
|
-
|
|
103
|
+
|
|
94
104
|
//got no cursor? error!
|
|
95
105
|
if(!imageData) {
|
|
96
106
|
return null;
|
|
97
107
|
}
|
|
98
|
-
|
|
108
|
+
|
|
99
109
|
//we have cursor, cache it?
|
|
100
110
|
if(flags & wdi.SpiceCursorFlags.SPICE_CURSOR_FLAGS_CACHE_ME) {
|
|
101
111
|
wdi.ImageCache.addCursor(spiceMessage.args.cursor, imageData);
|
|
102
112
|
}
|
|
103
|
-
|
|
113
|
+
|
|
104
114
|
return {
|
|
105
|
-
data: imageData,
|
|
106
|
-
position: position,
|
|
115
|
+
data: imageData,
|
|
116
|
+
position: position,
|
|
107
117
|
visible: visible,
|
|
108
118
|
header: spiceMessage.args.cursor.header
|
|
109
119
|
};
|
|
@@ -23,6 +23,8 @@ wdi.InputProcess = $.spcExtend(wdi.EventObject.prototype, {
|
|
|
23
23
|
capsLockPressed: false,
|
|
24
24
|
numLockPressed: false,
|
|
25
25
|
shiftPressed: false,
|
|
26
|
+
mouseLastX: -1,
|
|
27
|
+
mouseLastY: -1,
|
|
26
28
|
|
|
27
29
|
init: function (c) {
|
|
28
30
|
this.superInit()
|
|
@@ -47,17 +49,39 @@ wdi.InputProcess = $.spcExtend(wdi.EventObject.prototype, {
|
|
|
47
49
|
send: function (data, type) {
|
|
48
50
|
var packet, scanCodes, i
|
|
49
51
|
|
|
52
|
+
const { $mouse } = useNuxtApp()
|
|
50
53
|
if (type == 'mousemove') {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
54
|
+
if (
|
|
55
|
+
$mouse.mode.value === wdi.SpiceMouseModeTypes.SPICE_MOUSE_MODE_CLIENT
|
|
56
|
+
) {
|
|
57
|
+
packet = new wdi.SpiceMessage({
|
|
58
|
+
messageType: wdi.SpiceVars.SPICE_MSGC_INPUTS_MOUSE_POSITION,
|
|
59
|
+
channel: wdi.SpiceVars.SPICE_CHANNEL_INPUTS,
|
|
60
|
+
args: new wdi.RedcMousePosition({
|
|
61
|
+
x: data[1][0] + wdi.VirtualMouse.hotspot.x,
|
|
62
|
+
y: data[1][1] + wdi.VirtualMouse.hotspot.y,
|
|
63
|
+
buttons_state: data[1][2],
|
|
64
|
+
display_id: 0,
|
|
65
|
+
}),
|
|
66
|
+
})
|
|
67
|
+
} else if (
|
|
68
|
+
$mouse.mode.value === wdi.SpiceMouseModeTypes.SPICE_MOUSE_MODE_SERVER
|
|
69
|
+
) {
|
|
70
|
+
const dx = this.mouseLastX !== -1 ? data[1][0] - this.mouseLastX : 0
|
|
71
|
+
const dy = this.mouseLastY !== -1 ? data[1][1] - this.mouseLastY : 0
|
|
72
|
+
packet = new wdi.SpiceMessage({
|
|
73
|
+
messageType: wdi.SpiceVars.SPICE_MSGC_INPUTS_MOUSE_MOTION,
|
|
74
|
+
channel: wdi.SpiceVars.SPICE_CHANNEL_INPUTS,
|
|
75
|
+
args: new wdi.RedcMouseMotion({
|
|
76
|
+
x: dx,
|
|
77
|
+
y: dy,
|
|
78
|
+
buttons_state: 0,
|
|
79
|
+
}),
|
|
80
|
+
})
|
|
81
|
+
this.mouseLastX = data[1][0]
|
|
82
|
+
this.mouseLastY = data[1][1]
|
|
83
|
+
}
|
|
84
|
+
|
|
61
85
|
this.spiceConnection.send(packet)
|
|
62
86
|
} else if (type == 'mousedown') {
|
|
63
87
|
packet = new wdi.SpiceMessage({
|
|
@@ -80,105 +104,105 @@ wdi.InputProcess = $.spcExtend(wdi.EventObject.prototype, {
|
|
|
80
104
|
})
|
|
81
105
|
this.spiceConnection.send(packet)
|
|
82
106
|
} else if (type == 'keydown' || type == 'keypress') {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
107
|
+
scanCodes = wdi.Keymap.getScanCodes(data[1][0])
|
|
108
|
+
|
|
109
|
+
const originalEvent = data[1][0].originalEvent
|
|
110
|
+
|
|
111
|
+
if (
|
|
112
|
+
type == 'keydown' &&
|
|
113
|
+
data[1][0].keyCode !== 20 &&
|
|
114
|
+
((!wdi.Keymap.isVirtualKeyboard &&
|
|
115
|
+
originalEvent &&
|
|
116
|
+
originalEvent.getModifierState &&
|
|
117
|
+
wdi.Keymap.capsLock !== originalEvent.getModifierState('CapsLock')) ||
|
|
118
|
+
(wdi.Keymap.isVirtualKeyboard &&
|
|
119
|
+
wdi.Keymap.isVirtualCapsLockOn !== wdi.Keymap.capsLock))
|
|
120
|
+
) {
|
|
121
|
+
const capsLockPacket = new wdi.SpiceMessage({
|
|
122
|
+
messageType: wdi.SpiceVars.SPICE_MSGC_INPUTS_KEY_DOWN,
|
|
123
|
+
channel: wdi.SpiceVars.SPICE_CHANNEL_INPUTS,
|
|
124
|
+
args: new wdi.SpiceScanCode([58, 0, 0]),
|
|
125
|
+
})
|
|
126
|
+
this.capsLockPressed = true
|
|
127
|
+
this.spiceConnection.send(capsLockPacket)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (
|
|
131
|
+
type == 'keydown' &&
|
|
132
|
+
originalEvent &&
|
|
133
|
+
originalEvent.getModifierState &&
|
|
134
|
+
data[1][0].keyCode !== 144 &&
|
|
135
|
+
wdi.Keymap.numLock !== originalEvent.getModifierState('NumLock')
|
|
136
|
+
) {
|
|
137
|
+
const numLockPacket = new wdi.SpiceMessage({
|
|
138
|
+
messageType: wdi.SpiceVars.SPICE_MSGC_INPUTS_KEY_DOWN,
|
|
139
|
+
channel: wdi.SpiceVars.SPICE_CHANNEL_INPUTS,
|
|
140
|
+
args: new wdi.SpiceScanCode([69, 0, 0]),
|
|
141
|
+
})
|
|
142
|
+
this.numLockPressed = true
|
|
143
|
+
this.spiceConnection.send(numLockPacket)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
for (i = 0; i < scanCodes.length; i++) {
|
|
147
|
+
packet = new wdi.SpiceMessage({
|
|
148
|
+
messageType: wdi.SpiceVars.SPICE_MSGC_INPUTS_KEY_DOWN,
|
|
149
|
+
channel: wdi.SpiceVars.SPICE_CHANNEL_INPUTS,
|
|
150
|
+
args: new wdi.SpiceScanCode(scanCodes[i]),
|
|
151
|
+
})
|
|
152
|
+
|
|
153
|
+
if (scanCodes[0] && scanCodes[0][0] === 42) {
|
|
154
|
+
this.shiftPressed = true
|
|
155
|
+
}
|
|
156
|
+
this.spiceConnection.send(packet)
|
|
157
|
+
}
|
|
158
|
+
} else if (type == 'keyup') {
|
|
159
|
+
scanCodes = wdi.Keymap.getScanCodes(data[1][0])
|
|
160
|
+
|
|
161
|
+
if (
|
|
162
|
+
scanCodes &&
|
|
163
|
+
scanCodes[0] &&
|
|
164
|
+
scanCodes[0][0] === 199 &&
|
|
165
|
+
scanCodes[0][1] === 0 &&
|
|
166
|
+
scanCodes[0][2] === 0
|
|
167
|
+
) {
|
|
168
|
+
scanCodes = [[224, 199, 0, 0]]
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (this.capsLockPressed) {
|
|
172
|
+
const capsLockPacket = new wdi.SpiceMessage({
|
|
173
|
+
messageType: wdi.SpiceVars.SPICE_MSGC_INPUTS_KEY_UP,
|
|
174
|
+
channel: wdi.SpiceVars.SPICE_CHANNEL_INPUTS,
|
|
175
|
+
args: new wdi.SpiceScanCode([186, 0, 0]),
|
|
176
|
+
})
|
|
177
|
+
this.spiceConnection.send(capsLockPacket)
|
|
178
|
+
this.capsLockPressed = false
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
if (this.numLockPressed) {
|
|
182
|
+
const numLockPacket = new wdi.SpiceMessage({
|
|
183
|
+
messageType: wdi.SpiceVars.SPICE_MSGC_INPUTS_KEY_UP,
|
|
184
|
+
channel: wdi.SpiceVars.SPICE_CHANNEL_INPUTS,
|
|
185
|
+
args: new wdi.SpiceScanCode([197, 0, 0]),
|
|
186
|
+
})
|
|
187
|
+
this.spiceConnection.send(numLockPacket)
|
|
188
|
+
this.numLockPressed = false
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (scanCodes[0] && scanCodes[0][0] === 142) {
|
|
192
|
+
this.shiftPressed = false
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
for (i = 0; i < scanCodes.length; i++) {
|
|
196
|
+
packet = new wdi.SpiceMessage({
|
|
197
|
+
messageType: wdi.SpiceVars.SPICE_MSGC_INPUTS_KEY_UP,
|
|
198
|
+
channel: wdi.SpiceVars.SPICE_CHANNEL_INPUTS,
|
|
199
|
+
args: new wdi.SpiceScanCode(scanCodes[i]),
|
|
200
|
+
})
|
|
201
|
+
|
|
202
|
+
this.spiceConnection.send(packet)
|
|
203
|
+
}
|
|
204
|
+
this.clientGui.inputManager.input.val('_')
|
|
205
|
+
} else if (type == 'joystick') {
|
|
182
206
|
packet = new wdi.SpiceMessage({
|
|
183
207
|
messageType: wdi.SpiceVars.SPICE_MSGC_INPUTS_MOUSE_MOTION,
|
|
184
208
|
channel: wdi.SpiceVars.SPICE_CHANNEL_INPUTS,
|
|
@@ -18,61 +18,193 @@
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
20
|
wdi.MainProcess = $.spcExtend(wdi.EventObject.prototype, {
|
|
21
|
-
init: function(c) {
|
|
22
|
-
this.superInit()
|
|
23
|
-
this.app = c.app
|
|
24
|
-
this.spiceConnection = c.app.spiceConnection
|
|
25
|
-
this.agent = c.app.agent
|
|
21
|
+
init: function (c) {
|
|
22
|
+
this.superInit()
|
|
23
|
+
this.app = c.app
|
|
24
|
+
this.spiceConnection = c.app.spiceConnection
|
|
25
|
+
this.agent = c.app.agent
|
|
26
|
+
this.currentMouseMode = wdi.SpiceMouseModeTypes.SPICE_MOUSE_MODE_CLIENT
|
|
26
27
|
},
|
|
27
28
|
|
|
28
|
-
dispose: function() {
|
|
29
|
-
this.clearEvents()
|
|
30
|
-
this.app = null
|
|
31
|
-
this.spiceConnection = null
|
|
32
|
-
this.agent = null
|
|
29
|
+
dispose: function () {
|
|
30
|
+
this.clearEvents()
|
|
31
|
+
this.app = null
|
|
32
|
+
this.spiceConnection = null
|
|
33
|
+
this.agent = null
|
|
33
34
|
},
|
|
34
35
|
|
|
35
|
-
process: function(spiceMessage) {
|
|
36
|
-
var channel =
|
|
36
|
+
process: function (spiceMessage) {
|
|
37
|
+
var channel =
|
|
38
|
+
this.spiceConnection.channels[wdi.SpiceVars.SPICE_CHANNEL_MAIN]
|
|
37
39
|
|
|
38
|
-
switch(spiceMessage.messageType) {
|
|
40
|
+
switch (spiceMessage.messageType) {
|
|
39
41
|
case wdi.SpiceVars.SPICE_MSG_MAIN_INIT:
|
|
40
|
-
channel.connectionId = spiceMessage.args.session_id
|
|
41
|
-
channel.fire('connectionId', channel.connectionId)
|
|
42
|
-
if(spiceMessage.args.agent_connected == 1) {
|
|
43
|
-
channel.fire('initAgent', spiceMessage.args.agent_tokens)
|
|
42
|
+
channel.connectionId = spiceMessage.args.session_id
|
|
43
|
+
channel.fire('connectionId', channel.connectionId)
|
|
44
|
+
if (spiceMessage.args.agent_connected == 1) {
|
|
45
|
+
channel.fire('initAgent', spiceMessage.args.agent_tokens)
|
|
44
46
|
}
|
|
45
47
|
if (spiceMessage.args.current_mouse_mode == 1) {
|
|
46
|
-
channel.fire('mouseMode', spiceMessage.args.current_mouse_mode)
|
|
48
|
+
channel.fire('mouseMode', spiceMessage.args.current_mouse_mode)
|
|
47
49
|
}
|
|
48
50
|
// the mouse mode must be change both if we have agent or not
|
|
49
|
-
this.changeMouseMode()
|
|
50
|
-
break
|
|
51
|
+
this.changeMouseMode()
|
|
52
|
+
break
|
|
51
53
|
case wdi.SpiceVars.SPICE_MSG_MAIN_AGENT_DATA:
|
|
52
|
-
var packet = spiceMessage.args
|
|
53
|
-
this.agent.onAgentData(packet)
|
|
54
|
-
|
|
54
|
+
var packet = spiceMessage.args
|
|
55
|
+
this.agent.onAgentData(packet)
|
|
56
|
+
break
|
|
55
57
|
case wdi.SpiceVars.SPICE_MSG_MAIN_AGENT_CONNECTED:
|
|
56
|
-
channel.fire('initAgent', spiceMessage.args.agent_tokens)
|
|
57
|
-
this.changeMouseMode()
|
|
58
|
-
break
|
|
58
|
+
channel.fire('initAgent', spiceMessage.args.agent_tokens)
|
|
59
|
+
this.changeMouseMode()
|
|
60
|
+
break
|
|
59
61
|
case wdi.SpiceVars.SPICE_MSG_MAIN_MULTI_MEDIA_TIME:
|
|
60
|
-
this.app.multimediaTime = spiceMessage.args.multimedia_time
|
|
61
|
-
break
|
|
62
|
+
this.app.multimediaTime = spiceMessage.args.multimedia_time
|
|
63
|
+
break
|
|
62
64
|
case wdi.SpiceVars.SPICE_MSG_MAIN_CHANNELS_LIST:
|
|
63
|
-
channel.fire('channelListAvailable', spiceMessage.args.channels)
|
|
64
|
-
break
|
|
65
|
+
channel.fire('channelListAvailable', spiceMessage.args.channels)
|
|
66
|
+
break
|
|
65
67
|
}
|
|
66
68
|
},
|
|
67
69
|
|
|
68
|
-
changeMouseMode: function(
|
|
70
|
+
changeMouseMode: function (
|
|
71
|
+
mode = wdi.SpiceMouseModeTypes.SPICE_MOUSE_MODE_CLIENT
|
|
72
|
+
) {
|
|
69
73
|
var packet = new wdi.SpiceMessage({
|
|
70
74
|
messageType: wdi.SpiceVars.SPICE_MSGC_MAIN_MOUSE_MODE_REQUEST,
|
|
71
75
|
channel: wdi.SpiceVars.SPICE_CHANNEL_MAIN,
|
|
72
76
|
args: new wdi.SpiceMouseModeRequest({
|
|
73
|
-
request_mode:
|
|
74
|
-
})
|
|
75
|
-
})
|
|
76
|
-
this.spiceConnection.send(packet)
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
request_mode: mode, // Custom code
|
|
78
|
+
}),
|
|
79
|
+
})
|
|
80
|
+
this.spiceConnection.send(packet)
|
|
81
|
+
|
|
82
|
+
// Custom code
|
|
83
|
+
this.currentMouseMode = mode
|
|
84
|
+
const { $mouse } = useNuxtApp()
|
|
85
|
+
$mouse.changeMode(mode)
|
|
86
|
+
// Initialize the cursor
|
|
87
|
+
if (mode === wdi.SpiceMouseModeTypes.SPICE_MOUSE_MODE_SERVER) {
|
|
88
|
+
wdi.VirtualMouse.initCursor();
|
|
89
|
+
|
|
90
|
+
const canvas = document.getElementById('eventLayer');
|
|
91
|
+
canvas.requestPointerLock?.();
|
|
92
|
+
|
|
93
|
+
const rect = canvas.getBoundingClientRect();
|
|
94
|
+
|
|
95
|
+
let posX = 0;
|
|
96
|
+
let posY = 0;
|
|
97
|
+
|
|
98
|
+
function initPosDefault() {
|
|
99
|
+
posX = canvas.width / 2;
|
|
100
|
+
posY = canvas.height / 2;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function dispatchMouseEventToCanvas(type, options = {}) {
|
|
104
|
+
// console.log(clientX, 111111, clientY)
|
|
105
|
+
const ev = new MouseEvent(type, {
|
|
106
|
+
bubbles: false,
|
|
107
|
+
cancelable: true,
|
|
108
|
+
view: window,
|
|
109
|
+
clientX: posX,
|
|
110
|
+
clientY: posY,
|
|
111
|
+
button: options.button ?? 0,
|
|
112
|
+
buttons: options.buttons ?? 0,
|
|
113
|
+
ctrlKey: options.ctrlKey ?? false,
|
|
114
|
+
shiftKey: options.shiftKey ?? false,
|
|
115
|
+
altKey: options.altKey ?? false,
|
|
116
|
+
metaKey: options.metaKey ?? false,
|
|
117
|
+
isLocked: true
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
canvas.dispatchEvent(ev);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function dispatchWheelToCanvas(sourceEvent) {
|
|
124
|
+
const we = new WheelEvent('wheel', {
|
|
125
|
+
bubbles: false,
|
|
126
|
+
cancelable: true,
|
|
127
|
+
clientX: posX,
|
|
128
|
+
clientY: posY,
|
|
129
|
+
deltaX: sourceEvent.deltaX,
|
|
130
|
+
deltaY: sourceEvent.deltaY,
|
|
131
|
+
deltaZ: sourceEvent.deltaZ,
|
|
132
|
+
deltaMode: sourceEvent.deltaMode,
|
|
133
|
+
});
|
|
134
|
+
canvas.dispatchEvent(we);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function onDocMouseMove(e) {
|
|
138
|
+
if (!e.isTrusted) return;
|
|
139
|
+
|
|
140
|
+
const dx = e.movementX || 0;
|
|
141
|
+
const dy = e.movementY || 0;
|
|
142
|
+
|
|
143
|
+
posX += dx;
|
|
144
|
+
posY += dy;
|
|
145
|
+
|
|
146
|
+
dispatchMouseEventToCanvas('mousemove', {
|
|
147
|
+
buttons: e.buttons,
|
|
148
|
+
ctrlKey: e.ctrlKey,
|
|
149
|
+
shiftKey: e.shiftKey,
|
|
150
|
+
altKey: e.altKey,
|
|
151
|
+
metaKey: e.metaKey,
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function onDocMouseDown(e) {
|
|
156
|
+
if (!e.isTrusted) return;
|
|
157
|
+
dispatchMouseEventToCanvas('mousedown', {
|
|
158
|
+
button: e.button,
|
|
159
|
+
buttons: e.buttons,
|
|
160
|
+
ctrlKey: e.ctrlKey,
|
|
161
|
+
shiftKey: e.shiftKey,
|
|
162
|
+
altKey: e.altKey,
|
|
163
|
+
metaKey: e.metaKey,
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
function onDocMouseUp(e) {
|
|
167
|
+
if (!e.isTrusted) return;
|
|
168
|
+
dispatchMouseEventToCanvas('mouseup', {
|
|
169
|
+
button: e.button,
|
|
170
|
+
buttons: e.buttons,
|
|
171
|
+
ctrlKey: e.ctrlKey,
|
|
172
|
+
shiftKey: e.shiftKey,
|
|
173
|
+
altKey: e.altKey,
|
|
174
|
+
metaKey: e.metaKey,
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
function onDocWheel(e) {
|
|
178
|
+
if (!e.isTrusted) return;
|
|
179
|
+
dispatchWheelToCanvas(e);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// Регистрируем pointerlockchange один раз (защита от повторной регистрации)
|
|
183
|
+
if (!this._pointerLockInitialized) {
|
|
184
|
+
this._pointerLockInitialized = true;
|
|
185
|
+
const onPointerLockChange = () => {
|
|
186
|
+
const locked = document.pointerLockElement === canvas;
|
|
187
|
+
if (locked) {
|
|
188
|
+
document.addEventListener('mousemove', onDocMouseMove);
|
|
189
|
+
document.addEventListener('mousedown', onDocMouseDown);
|
|
190
|
+
document.addEventListener('mouseup', onDocMouseUp);
|
|
191
|
+
document.addEventListener('wheel', onDocWheel, { passive: false });
|
|
192
|
+
} else {
|
|
193
|
+
document.removeEventListener('mousemove', onDocMouseMove);
|
|
194
|
+
document.removeEventListener('mousedown', onDocMouseDown);
|
|
195
|
+
document.removeEventListener('mouseup', onDocMouseUp);
|
|
196
|
+
document.removeEventListener('wheel', onDocWheel, { passive: false });
|
|
197
|
+
|
|
198
|
+
this.changeMouseMode(wdi.SpiceMouseModeTypes.SPICE_MOUSE_MODE_CLIENT)
|
|
199
|
+
wdi.VirtualMouse.removeCursor()
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
document.addEventListener('pointerlockchange', onPointerLockChange);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// Инициализация позиции (можно взять из последнего известного положения)
|
|
207
|
+
initPosDefault();
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
})
|