A nodejs package for controlling phone depend on scrcpy protocol.
npm install
npm run build
npm run dev
启动浏览器访问 localhost:9090
new VideoController({
sendCtrl: this._sendCtrl.bind(this),
videoElement: this.videoElement,
textHelperElement: this.textHelperElement
});
{ "type": 0, "action": 0, "keyCode": $KEYCODE, "metaState": 0, "repeat": 0 }
{ "type": 0, "action": 1, "keyCode": $KEYCODE, "metaState": 0, "repeat": 0 }
export enum AndroidKeycode {
Home = 3,
Back = 4,
Power = 26,
Menu = 82,
RencentApps = 187,
Camera = 27,
VoluneMute = 164,
VoluneUp = 24,
VolumeDown = 25,
}
{ "type": 2, "action": 0, "position": { "x": 0.812, "y": 0.284, "width": $realWidth, "height": $realHeight }, "buttons": 0, "pressure": 1 }
{ "type": 2, "action": 2, "position": { "x": 0.779, "y": 0.286, "width": $realWidth, "height": $realHeight }, "buttons": 0, "pressure": 1 }
{ "type": 2, "action": 2, "position": { "x": 0.762, "y": 0.286, "width": $realWidth, "height": $realHeight }, "buttons": 0, "pressure": 1 }
{ "type": 2, "action": 2, "position": { "x": 0.719, "y": 0.286, "width": $realWidth, "height": $realHeight }, "buttons": 0, "pressure": 1 }
{ "type": 2, "action": 1, "position": { "x": 0.719, "y": 0.286, "width": $realWidth, "height": $realHeight }, "buttons": 0, "pressure": 1 }
{ "type": 3, "position": { "x": 0.433, "y": 0.191, "width": $realWidth, "height": $realHeight }, "hScroll": 0, "vScroll": 0.04 }
{ "type": 3, "position": { "x": 0.433, "y": 0.191, "width": $realWidth, "height": $realHeight }, "hScroll": 0, "vScroll": 0.04 }
{ "type": 1, "text": "http://localhost:9090/", "paste": true }
{ "type": 9, "text": "http://localhost:9090/", "paste": true }
使用的投流模式, 默认为 webrtc
用来展示画面的video元素
用来辅助粘贴的text input元素
使用图片流时用来展示画面的img元素
发送触控事件使用的手指数量, 默认为1
发送触控事件使用的倾斜角度, 默认为0 (范围: 0 Deg - 180 Deg)
发送触控事件每个手指的间隔百分比, 默认为0.1 (范围: 0-1)
指定投流终端是否为PC终端(Mouse Move事件的触发条件不同)
用于发送控制指令的函数(比如经过包装的websocket信息发送函数)
模拟点击对端手机的某个功能按键键
模拟发送转屏信号
模拟发送回到主页信号
重置触控事件使用的手指数量
重置触控事件使用的倾斜角度
重置触控事件每个手指的间隔百分比