|
@@ -614,6 +614,14 @@ class SymjaConsole {
|
|
|
this.showMcpAddress();
|
|
this.showMcpAddress();
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
+ // 调试:通过MCP evaluate("__open plugin_id")打开全屏插件
|
|
|
|
|
+ if (lower.startsWith('__open ')) {
|
|
|
|
|
+ var pid = lower.substring(7).trim();
|
|
|
|
|
+ var pl = this.plugins.find(function(p) { return p.id === pid || p.command === pid; });
|
|
|
|
|
+ if (pl) this.openPlugin(pl);
|
|
|
|
|
+ else this.addOutput('插件未找到: ' + pid, 'error');
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
if (lower === 'feedback') {
|
|
if (lower === 'feedback') {
|
|
|
this.showFeedback();
|
|
this.showFeedback();
|
|
|
return true;
|
|
return true;
|
|
@@ -1005,6 +1013,15 @@ class SymjaConsole {
|
|
|
onTouchStart: function(cb) { this._callbacks.touchstart = cb; },
|
|
onTouchStart: function(cb) { this._callbacks.touchstart = cb; },
|
|
|
onTouchMove: function(cb) { this._callbacks.touchmove = cb; },
|
|
onTouchMove: function(cb) { this._callbacks.touchmove = cb; },
|
|
|
onTouchEnd: function(cb) { this._callbacks.touchend = cb; this._bind(); },
|
|
onTouchEnd: function(cb) { this._callbacks.touchend = cb; this._bind(); },
|
|
|
|
|
+ /** 模拟触摸(MCP 调试用) */
|
|
|
|
|
+ _fireTouch: function(x, y) {
|
|
|
|
|
+ if (this._callbacks.touchend) {
|
|
|
|
|
+ this._callbacks.touchend({
|
|
|
|
|
+ changedTouches: [{clientX: x, clientY: y}],
|
|
|
|
|
+ preventDefault: function(){}
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
/** 将触摸事件的 clientX/Y 转换为画布逻辑坐标 */
|
|
/** 将触摸事件的 clientX/Y 转换为画布逻辑坐标 */
|
|
|
xy: function(e) {
|
|
xy: function(e) {
|
|
|
var touch = e.changedTouches ? e.changedTouches[0] : (e.touches ? e.touches[0] : e);
|
|
var touch = e.changedTouches ? e.changedTouches[0] : (e.touches ? e.touches[0] : e);
|
|
@@ -1650,8 +1667,12 @@ class SymjaConsole {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
startMcpPollingIfNeeded() {
|
|
startMcpPollingIfNeeded() {
|
|
|
- if (!this.getMcpEnabled()) return;
|
|
|
|
|
|
|
+ if (!this.getMcpEnabled()) {
|
|
|
|
|
+ console.log('MCP polling skipped: getMcpEnabled=false');
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
if (!this.mcpPollTimer) {
|
|
if (!this.mcpPollTimer) {
|
|
|
|
|
+ console.log('MCP polling started');
|
|
|
this.mcpPollTimer = setInterval(() => this.pollMcpEvents(), 1000);
|
|
this.mcpPollTimer = setInterval(() => this.pollMcpEvents(), 1000);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -2118,9 +2139,40 @@ class SymjaConsole {
|
|
|
try {
|
|
try {
|
|
|
if (typeof Android === 'undefined' || !Android.getMcpEvents) return;
|
|
if (typeof Android === 'undefined' || !Android.getMcpEvents) return;
|
|
|
const json = Android.getMcpEvents();
|
|
const json = Android.getMcpEvents();
|
|
|
|
|
+ if (json && json !== '[]') console.log('MCP poll got events:', json.substring(0, 200));
|
|
|
if (!json || json === '[]') return;
|
|
if (!json || json === '[]') return;
|
|
|
const events = JSON.parse(json);
|
|
const events = JSON.parse(json);
|
|
|
events.forEach(ev => {
|
|
events.forEach(ev => {
|
|
|
|
|
+ // 调试命令:MCP 触发打开全屏插件
|
|
|
|
|
+ if (ev.expression.startsWith('##OPEN_PLUGIN##')) {
|
|
|
|
|
+ var pid = ev.expression.substring(16);
|
|
|
|
|
+ var pl = this.plugins.find(function(p) { return p.id === pid || p.command === pid; });
|
|
|
|
|
+ if (pl) this.openPlugin(pl);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ // 调试命令:模拟画布点击 __tap x y (逻辑坐标)
|
|
|
|
|
+ if (ev.expression.startsWith('__tap ')) {
|
|
|
|
|
+ var parts = ev.expression.split(/\s+/);
|
|
|
|
|
+ var tx = parseFloat(parts[1]), ty = parseFloat(parts[2]);
|
|
|
|
|
+ if (!isNaN(tx) && !isNaN(ty)) {
|
|
|
|
|
+ // 将逻辑坐标转换为屏幕 clientX/Y
|
|
|
|
|
+ var c = document.querySelector('#fullscreenContent canvas');
|
|
|
|
|
+ if (c) {
|
|
|
|
|
+ var r = c.getBoundingClientRect();
|
|
|
|
|
+ var cx = r.left + (tx / (parseInt(c.style.width) || r.width)) * r.width;
|
|
|
|
|
+ var cy = r.top + (ty / (parseInt(c.style.height) || r.height)) * r.height;
|
|
|
|
|
+ // 通过 _fireTouch 直接触发插件回调
|
|
|
|
|
+ try {
|
|
|
|
|
+ // 获取当前插件的 IJS API 实例,调用 _fireTouch
|
|
|
|
|
+ var apiInstance = symjaConsole._lastIjsApi;
|
|
|
|
|
+ if (apiInstance && apiInstance.input && apiInstance.input._fireTouch) {
|
|
|
|
|
+ apiInstance.input._fireTouch(cx, cy);
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch(e) { console.log('_fireTouch error:', e); }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
this.mcpEventCount++;
|
|
this.mcpEventCount++;
|
|
|
this.addToHistory(ev.expression);
|
|
this.addToHistory(ev.expression);
|
|
|
this.addOutput(ev.expression, 'mcp-input', { seq: this.mcpEventCount });
|
|
this.addOutput(ev.expression, 'mcp-input', { seq: this.mcpEventCount });
|