@cldmv/node-android-tv-remote 1.5.1 → 1.5.3
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/package.json
CHANGED
|
@@ -403,6 +403,7 @@ module.exports = function (config) {
|
|
|
403
403
|
/**
|
|
404
404
|
* Returns the current connection status as tracked by the module.
|
|
405
405
|
* Optionally performs a live check against adb devices if requested.
|
|
406
|
+
* Also updates the internal connected state if a live check is performed.
|
|
406
407
|
* @public
|
|
407
408
|
* @param {boolean} [liveCheck=false] - If true, checks adb devices for actual connection.
|
|
408
409
|
* @returns {Promise<"connected"|"disconnected"|"unknown">}
|
|
@@ -418,8 +419,10 @@ module.exports = function (config) {
|
|
|
418
419
|
const devices = await client.listDevices();
|
|
419
420
|
const deviceId = host;
|
|
420
421
|
const found = devices.some((d) => d.id === deviceId);
|
|
422
|
+
connected = found; // Keep internal state in sync with live check
|
|
421
423
|
return found ? "connected" : "disconnected";
|
|
422
424
|
} catch {
|
|
425
|
+
connected = false;
|
|
423
426
|
return "unknown";
|
|
424
427
|
}
|
|
425
428
|
}
|
|
@@ -498,7 +501,9 @@ module.exports = function (config) {
|
|
|
498
501
|
* @example
|
|
499
502
|
* if (remote.isConnected) { ... }
|
|
500
503
|
*/
|
|
501
|
-
|
|
504
|
+
get isConnected() {
|
|
505
|
+
return isConnected();
|
|
506
|
+
},
|
|
502
507
|
/**
|
|
503
508
|
* Get or set Android settings via ADB.
|
|
504
509
|
* @public
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Usage: node test/interactive-remote.js
|
|
4
4
|
|
|
5
5
|
const readline = require("readline");
|
|
6
|
-
const
|
|
6
|
+
const createRemote = require("../src/lib/android-tv-remote");
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Prompts the user for input in the terminal.
|
|
@@ -36,7 +36,8 @@ async function main() {
|
|
|
36
36
|
process.exit(1);
|
|
37
37
|
}
|
|
38
38
|
try {
|
|
39
|
-
|
|
39
|
+
const remote = createRemote({ ip, port });
|
|
40
|
+
await remote.connect();
|
|
40
41
|
console.log(`Connected to ${ip}:${port}`);
|
|
41
42
|
// List of buttons to press (as method names on remote.press)
|
|
42
43
|
const buttons = ["home", "up", "down", "left", "right", "ok", "back"];
|