mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-25 15:32:40 -05:00
commit
3e65526ed8
3 changed files with 22 additions and 0 deletions
|
@ -602,6 +602,15 @@ class Runtime extends EventEmitter {
|
||||||
return 'PERIPHERAL_LIST_UPDATE';
|
return 'PERIPHERAL_LIST_UPDATE';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event name for when the user picks a bluetooth device to connect to
|
||||||
|
* via Companion Device Manager (CDM)
|
||||||
|
* @const {string}
|
||||||
|
*/
|
||||||
|
static get USER_PICKED_PERIPHERAL () {
|
||||||
|
return 'USER_PICKED_PERIPHERAL';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event name for reporting that a peripheral has connected.
|
* Event name for reporting that a peripheral has connected.
|
||||||
* This causes the status button in the blocks menu to indicate 'connected'.
|
* This causes the status button in the blocks menu to indicate 'connected'.
|
||||||
|
|
|
@ -180,6 +180,16 @@ class BLE extends JSONRPC {
|
||||||
window.clearTimeout(this._discoverTimeoutID);
|
window.clearTimeout(this._discoverTimeoutID);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'userDidPickPeripheral':
|
||||||
|
this._availablePeripherals[params.peripheralId] = params;
|
||||||
|
this._runtime.emit(
|
||||||
|
this._runtime.constructor.USER_PICKED_PERIPHERAL,
|
||||||
|
this._availablePeripherals
|
||||||
|
);
|
||||||
|
if (this._discoverTimeoutID) {
|
||||||
|
window.clearTimeout(this._discoverTimeoutID);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case 'characteristicDidChange':
|
case 'characteristicDidChange':
|
||||||
if (this._characteristicDidChangeCallback) {
|
if (this._characteristicDidChangeCallback) {
|
||||||
this._characteristicDidChangeCallback(params.message);
|
this._characteristicDidChangeCallback(params.message);
|
||||||
|
|
|
@ -127,6 +127,9 @@ class VirtualMachine extends EventEmitter {
|
||||||
this.runtime.on(Runtime.PERIPHERAL_LIST_UPDATE, info => {
|
this.runtime.on(Runtime.PERIPHERAL_LIST_UPDATE, info => {
|
||||||
this.emit(Runtime.PERIPHERAL_LIST_UPDATE, info);
|
this.emit(Runtime.PERIPHERAL_LIST_UPDATE, info);
|
||||||
});
|
});
|
||||||
|
this.runtime.on(Runtime.USER_PICKED_PERIPHERAL, info => {
|
||||||
|
this.emit(Runtime.USER_PICKED_PERIPHERAL, info);
|
||||||
|
});
|
||||||
this.runtime.on(Runtime.PERIPHERAL_CONNECTED, () =>
|
this.runtime.on(Runtime.PERIPHERAL_CONNECTED, () =>
|
||||||
this.emit(Runtime.PERIPHERAL_CONNECTED)
|
this.emit(Runtime.PERIPHERAL_CONNECTED)
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue