Skip to content

Commit

Permalink
post: enable-moonlight-native-touch
Browse files Browse the repository at this point in the history
  • Loading branch information
bsdayo committed May 8, 2024
1 parent fc8fced commit b5a8681
Show file tree
Hide file tree
Showing 8 changed files with 390 additions and 31 deletions.
4 changes: 4 additions & 0 deletions .vitepress/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import path from 'path'
import { defineConfigWithTheme } from 'vitepress'
import UnoCSS from 'unocss/vite'
import footnote from 'markdown-it-footnote'

import { createContainer } from './utils'
import { ThemeConfig } from './theme'
Expand All @@ -15,7 +16,10 @@ export default defineConfigWithTheme<ThemeConfig>({
dark: 'one-dark-pro',
},

math: true,

config(md) {
md.use(footnote)
md.use(...createContainer('note', 'NOTE', md))
.use(...createContainer('abstract', 'ABSTRACT', md))
// info already added
Expand Down
5 changes: 5 additions & 0 deletions .vitepress/theme/custom.scss
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,8 @@ img.VPImage.logo {
border-radius: 50%;
}
}

// 脚注
a.footnote-backref {
font-family: Inter, ui-sans-serif, sans-serif;
}
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
"scripts": {
"dev": "vitepress dev . --host",
"build": "vitepress build .",
"preview": "vitepress preview .",
"new": "node scripts/new-post.js"
"preview": "vitepress preview ."
},
"devDependencies": {
"@fortawesome/fontawesome-svg-core": "^6.5.2",
Expand All @@ -20,6 +19,8 @@
"clsx": "^2.1.1",
"lucide-vue-next": "^0.378.0",
"markdown-it-container": "^4.0.0",
"markdown-it-footnote": "^4.0.0",
"markdown-it-mathjax3": "^4.3.2",
"medium-zoom": "^1.1.0",
"radix-vue": "^1.7.3",
"sass": "^1.76.0",
Expand Down
311 changes: 309 additions & 2 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions posts/blog-style-overview/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ for (var i = 0; i < 100; i++)
| Content 4 | Content 5 | Content 6 |
| Content 7 | Content 8 | Content 9 |

### 公式

- Inline: $a + \sqrt{b} = c^2$
- Block:

$$ a + \sqrt{b} = c^2 $$

### 自定义文本块

Colors borrowed from [Material for MkDocs: Admonitions](https://squidfunk.github.io/mkdocs-material/reference/admonitions/).
Expand Down
45 changes: 45 additions & 0 deletions posts/enable-moonlight-native-touch/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
title: 开启 Moonlight Android 端的原生触控支持
create: 2024-05-08T11:30:31+08:00
---

## TL;DR

Moonlight 实际上已经做好了原生触控的支持,但是在源码中被注释掉了,取消注释就能正常工作。

修改 [app/src/main/java/com/limelight/Game.java](https://github.com/moonlight-stream/moonlight-android/blob/master/app/src/main/java/com/limelight/Game.java#L2019-L2023)
去掉第 2019 和第 2023 行(可能不一致,编写本文时的提交为 `f54f8c8`)的注释即可

```java:line-numbers=2016 {4,8}
// TODO: Re-enable native touch when have a better solution for handling
// cancelled touches from Android gestures and 3 finger taps to activate
// the software keyboard.
if (!prefConfig.touchscreenTrackpad && trySendTouchEvent(view, event)) {
// If this host supports touch events and absolute touch is enabled,
// send it directly as a touch event.
return true;
}
```

随后编译安装,在设置里找到“将触控屏作为触摸板使用”并关闭,就可以享受丝滑的原生触控了。

## 经过

前段时间把平板换成了小米平板 6,发现在这颗骁龙 870 的加持下串流效果很不错,感觉不到多少延迟。但由于 Moonlight 里触控默认是直接操作鼠标指针,而不是原生的触屏,感觉操作还是不太方便(例如享受不到 Windows 原生的触控优化,以及不能多点触控)

前往 GitHub Issues 搜索 `multi touch`,找到[这样一个回复](https://github.com/moonlight-stream/moonlight-android/issues/1271#issuecomment-1806897929)

::: quote Maintainer @cgutman 的回复
Yep, this is actually already implemented but disabled. The problem preventing us from shipping it on Android is that full native multi-touch interferes with the ability to launch the virtual keyboard using the 3-finger tap combo. We need to implement some kind of overlay or something to allow activation of the keyboard before we can turn it on. We should also probably add some type of zoom feature since touch targets can be very tiny on a phone/tablet screen.

This wasn't an issue with the PC client because it never had virtual keyboard support.
:::

大意是 Android 端实际上已经做好了原生触控的功能,但是由于和三指打开键盘的功能冲突了,所以被临时注释掉了。
再往下有[一条评论](https://github.com/moonlight-stream/moonlight-android/issues/1271#issuecomment-2002416426)指出了应该修改的地方,也就是上面 [TL;DR](#tl-dr) 部分的内容。

## 体验

非常丝滑,局域网环境下和真正的 Windows 平板体验都差不太多

屏幕键盘可以用 Windows 自带的,够用
27 changes: 0 additions & 27 deletions scripts/new-post.js

This file was deleted.

17 changes: 17 additions & 0 deletions scripts/new-post.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
param (
[Parameter(Mandatory)] [string] $Id,
[Parameter(Mandatory)] [string] $Title
)

$date = Get-Date -Format "yyyy-MM-ddTHH:mm:ssK"
$postDir = Join-Path $PSScriptRoot "../posts/$Id"

New-Item -ItemType Directory -Path $postDir
@"
---
title: $Title
create: $date
---
"@ | Out-File -FilePath (Join-Path $postDir 'index.md')

0 comments on commit b5a8681

Please sign in to comment.