mirror of
https://github.com/barry-ran/QtScrcpy.git
synced 2025-04-19 19:15:07 +00:00
feat: debug keymap pos
This commit is contained in:
parent
72848e3e1a
commit
d089c9fc69
3 changed files with 12 additions and 0 deletions
|
@ -495,6 +495,14 @@ void VideoForm::mousePressEvent(QMouseEvent *event)
|
|||
}
|
||||
event->setLocalPos(m_videoWidget->mapFrom(this, event->localPos().toPoint()));
|
||||
emit m_device->mouseEvent(event, m_videoWidget->frameSize(), m_videoWidget->size());
|
||||
|
||||
// debug keymap pos
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
qreal x = event->localPos().x() / m_videoWidget->size().width();
|
||||
qreal y = event->localPos().y() / m_videoWidget->size().height();
|
||||
QString posTip = QString(R"("pos": {"x": %1, "y": %2})").arg(x).arg(y);
|
||||
qInfo(posTip.toStdString().c_str());
|
||||
}
|
||||
} else {
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
m_dragPosition = event->globalPos() - frameGeometry().topLeft();
|
||||
|
|
BIN
docs/image/debug-keymap-pos.png
Normal file
BIN
docs/image/debug-keymap-pos.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 780 KiB |
|
@ -10,6 +10,10 @@
|
|||
|
||||
- 按键映射中的坐标位置都是用相对位置表示的,屏幕的宽高都用1表示,例如屏幕的像素为1920x1080,那么坐标(0.5,0.5)则表示的是
|
||||
以屏幕左上角为原点,像素坐标(1920,1080)*(0.5,0.5)=(960,540)的位置。
|
||||
|
||||
或者鼠标左键单击时控制台会输出此时的pos,直接使用这个pos即可
|
||||

|
||||
|
||||
- 按键映射中的按键码是用Qt的枚举表示的,详细说明可以[参考Qt文档]( https://doc.qt.io/qt-5/qt.html )(搜索 The key names used by Qt. 可以快速定位)。
|
||||
- 开发人员选项中打开如下两个设置,可以方便的观察触摸点的坐标:
|
||||

|
||||
|
|
Loading…
Add table
Reference in a new issue