| 1176 | } |
| 1177 | |
| 1178 | _handleKeyEvent(keysym, code, down, numlock, capslock) { |
| 1179 | // If remote state of capslock is known, and it doesn't match the local led state of |
| 1180 | // the keyboard, we send a capslock keypress first to bring it into sync. |
| 1181 | // If we just pressed CapsLock, or we toggled it remotely due to it being out of sync |
| 1182 | // we clear the remote state so that we don't send duplicate or spurious fixes, |
| 1183 | // since it may take some time to receive the new remote CapsLock state. |
| 1184 | if (code == 'CapsLock' && down) { |
| 1185 | this._remoteCapsLock = null; |
| 1186 | } |
| 1187 | if (this._remoteCapsLock !== null && capslock !== null && this._remoteCapsLock !== capslock && down) { |
| 1188 | Log.Debug("Fixing remote caps lock"); |
| 1189 | |
| 1190 | this.sendKey(KeyTable.XK_Caps_Lock, 'CapsLock', true); |
| 1191 | this.sendKey(KeyTable.XK_Caps_Lock, 'CapsLock', false); |
| 1192 | // We clear the remote capsLock state when we do this to prevent issues with doing this twice |
| 1193 | // before we receive an update of the the remote state. |
| 1194 | this._remoteCapsLock = null; |
| 1195 | } |
| 1196 | |
| 1197 | // Logic for numlock is exactly the same. |
| 1198 | if (code == 'NumLock' && down) { |
| 1199 | this._remoteNumLock = null; |
| 1200 | } |
| 1201 | if (this._remoteNumLock !== null && numlock !== null && this._remoteNumLock !== numlock && down) { |
| 1202 | Log.Debug("Fixing remote num lock"); |
| 1203 | this.sendKey(KeyTable.XK_Num_Lock, 'NumLock', true); |
| 1204 | this.sendKey(KeyTable.XK_Num_Lock, 'NumLock', false); |
| 1205 | this._remoteNumLock = null; |
| 1206 | } |
| 1207 | this.sendKey(keysym, code, down); |
| 1208 | } |
| 1209 | |
| 1210 | static _convertButtonMask(buttons) { |
| 1211 | /* The bits in MouseEvent.buttons property correspond |