mirror of
https://github.com/VallierDev/uu-remote-linux.git
synced 2026-11-16 16:50:41 +01:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b7f9f2aa68 | ||
|
|
6416f75b7f | ||
|
|
70cb5ad57e | ||
|
|
7fcc674440 | ||
|
|
19d0563781 |
No files matched your search
@@ -116,6 +116,7 @@ viewer does not reconnect them automatically.
|
|||||||
| `UU_FFMPEG_ROOT` | FFmpeg prefix (`bin/ffmpeg`, libs in `lib/x86_64-linux-gnu`) |
|
| `UU_FFMPEG_ROOT` | FFmpeg prefix (`bin/ffmpeg`, libs in `lib/x86_64-linux-gnu`) |
|
||||||
| `UU_AUDIO=0`, `UU_AUDIO_SOURCE` | disable sound / choose the Pulse source (default `@DEFAULT_MONITOR@`) |
|
| `UU_AUDIO=0`, `UU_AUDIO_SOURCE` | disable sound / choose the Pulse source (default `@DEFAULT_MONITOR@`) |
|
||||||
| `UU_LOGIN_WINDOW=0` | don't auto-open the login window |
|
| `UU_LOGIN_WINDOW=0` | don't auto-open the login window |
|
||||||
|
| `UU_USE_PROXY=1` | honor HTTP/SOCKS proxy env vars; cloud API clients bypass env proxies by default |
|
||||||
| `UU_REMOTE_ASSIST=0`, `UU_ASSIST_ALLOW=1`, `UU_ASSIST_UI=tty`, `UU_ASSIST_DEBUG=1` | disable assistance / allow at start / terminal UI for `assist` / include the server's short error message in assist errors |
|
| `UU_REMOTE_ASSIST=0`, `UU_ASSIST_ALLOW=1`, `UU_ASSIST_UI=tty`, `UU_ASSIST_DEBUG=1` | disable assistance / allow at start / terminal UI for `assist` / include the server's short error message in assist errors |
|
||||||
|
|
||||||
Token has no expiry field; API code 1120 (HTTP 422) means invalid/expired → re-login. The config is re-read
|
Token has no expiry field; API code 1120 (HTTP 422) means invalid/expired → re-login. The config is re-read
|
||||||
|
|||||||
Generated
+1
-1
@@ -2741,7 +2741,7 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "uu-remote-linux"
|
name = "uu-remote-linux"
|
||||||
version = "0.2.9"
|
version = "0.2.11"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"base64 0.22.1",
|
"base64 0.22.1",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "uu-remote-linux"
|
name = "uu-remote-linux"
|
||||||
version = "0.2.9"
|
version = "0.2.11"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
default-run = "uuremote-server"
|
default-run = "uuremote-server"
|
||||||
authors = ["uu-remote-linux contributors"]
|
authors = ["uu-remote-linux contributors"]
|
||||||
|
|||||||
@@ -225,6 +225,7 @@ Optional launcher icon:
|
|||||||
```sh
|
```sh
|
||||||
install -Dm644 contrib/desktop/uu-remote-linux.svg ~/.local/share/icons/hicolor/scalable/apps/uu-remote-linux.svg
|
install -Dm644 contrib/desktop/uu-remote-linux.svg ~/.local/share/icons/hicolor/scalable/apps/uu-remote-linux.svg
|
||||||
install -Dm644 contrib/desktop/uu-remote-linux.desktop ~/.local/share/applications/uu-remote-linux.desktop
|
install -Dm644 contrib/desktop/uu-remote-linux.desktop ~/.local/share/applications/uu-remote-linux.desktop
|
||||||
|
install -Dm644 contrib/desktop/uu-remote-linux-viewer.desktop ~/.local/share/applications/uu-remote-linux-viewer.desktop
|
||||||
```
|
```
|
||||||
|
|
||||||
Verified with the official Mac viewer: guest connections, wrong-code rejection, code rotation, switching assistance off,
|
Verified with the official Mac viewer: guest connections, wrong-code rejection, code rotation, switching assistance off,
|
||||||
@@ -287,6 +288,7 @@ Common environment variables:
|
|||||||
| `UU_ASSIST_ALLOW=1` | Allow remote assistance at start (overrides the saved switch) |
|
| `UU_ASSIST_ALLOW=1` | Allow remote assistance at start (overrides the saved switch) |
|
||||||
| `UU_LOGIN_WINDOW=0` | Do not open the login window automatically when credentials are missing |
|
| `UU_LOGIN_WINDOW=0` | Do not open the login window automatically when credentials are missing |
|
||||||
| `UU_PORT_MAPPING=0` | Disable port mapping (the official host's controlled-side switch) |
|
| `UU_PORT_MAPPING=0` | Disable port mapping (the official host's controlled-side switch) |
|
||||||
|
| `UU_USE_PROXY=1` | Honor HTTP/SOCKS proxy environment variables; by default proxies are ignored and NetEase servers are reached directly |
|
||||||
|
|
||||||
Host settings such as "lock after remote session" and "mute host" are stored in
|
Host settings such as "lock after remote session" and "mute host" are stored in
|
||||||
`~/.config/uuremote/host_settings.json`.
|
`~/.config/uuremote/host_settings.json`.
|
||||||
|
|||||||
@@ -199,6 +199,7 @@ X11 默认继续用 XTest,因为它能正确处理网络延迟下按住不放
|
|||||||
```sh
|
```sh
|
||||||
install -Dm644 contrib/desktop/uu-remote-linux.svg ~/.local/share/icons/hicolor/scalable/apps/uu-remote-linux.svg
|
install -Dm644 contrib/desktop/uu-remote-linux.svg ~/.local/share/icons/hicolor/scalable/apps/uu-remote-linux.svg
|
||||||
install -Dm644 contrib/desktop/uu-remote-linux.desktop ~/.local/share/applications/uu-remote-linux.desktop
|
install -Dm644 contrib/desktop/uu-remote-linux.desktop ~/.local/share/applications/uu-remote-linux.desktop
|
||||||
|
install -Dm644 contrib/desktop/uu-remote-linux-viewer.desktop ~/.local/share/applications/uu-remote-linux-viewer.desktop
|
||||||
```
|
```
|
||||||
|
|
||||||
验证情况:访客身份下的连接、错误验证码拒绝、用完换码、关闭后不可连接、登录与退出登录的切换,已用官方 Mac 客户端实测通过。
|
验证情况:访客身份下的连接、错误验证码拒绝、用完换码、关闭后不可连接、登录与退出登录的切换,已用官方 Mac 客户端实测通过。
|
||||||
@@ -257,6 +258,7 @@ systemctl --user restart uuremote-native.service
|
|||||||
| `UU_REMOTE_ASSIST=0` | 关闭远程协助(未登录时也不再以访客身份提供协助) |
|
| `UU_REMOTE_ASSIST=0` | 关闭远程协助(未登录时也不再以访客身份提供协助) |
|
||||||
| `UU_ASSIST_ALLOW=1` | 启动时就允许他人远程协助(覆盖窗口里保存的开关状态) |
|
| `UU_ASSIST_ALLOW=1` | 启动时就允许他人远程协助(覆盖窗口里保存的开关状态) |
|
||||||
| `UU_PORT_MAPPING=0` | 关闭端口映射(对应官方被控端的开关) |
|
| `UU_PORT_MAPPING=0` | 关闭端口映射(对应官方被控端的开关) |
|
||||||
|
| `UU_USE_PROXY=1` | 使用环境变量里的 HTTP/SOCKS 代理;默认忽略代理、直连网易服务器 |
|
||||||
|
|
||||||
「远程结束后自动锁屏」「静音运行」等设置保存在 `~/.config/uuremote/host_settings.json`。
|
「远程结束后自动锁屏」「静音运行」等设置保存在 `~/.config/uuremote/host_settings.json`。
|
||||||
|
|
||||||
|
|||||||
@@ -474,6 +474,7 @@ static gboolean show_window(gpointer d) {
|
|||||||
static void *ui_thread(void *d) {
|
static void *ui_thread(void *d) {
|
||||||
(void)d;
|
(void)d;
|
||||||
if (!gtk_init_check(NULL, NULL)) { pthread_mutex_lock(&init_lock); init_state = -1; pthread_cond_signal(&init_cond); pthread_mutex_unlock(&init_lock); return NULL; }
|
if (!gtk_init_check(NULL, NULL)) { pthread_mutex_lock(&init_lock); init_state = -1; pthread_cond_signal(&init_cond); pthread_mutex_unlock(&init_lock); return NULL; }
|
||||||
|
gtk_window_set_default_icon_name("uu-remote-linux"); // same taskbar icon as the host (#13)
|
||||||
// Light palette in CSS; keep a dark system theme from making unstyled text white on white (#43).
|
// Light palette in CSS; keep a dark system theme from making unstyled text white on white (#43).
|
||||||
g_object_set(gtk_settings_get_default(), "gtk-theme-name", "Adwaita", "gtk-application-prefer-dark-theme", FALSE, NULL);
|
g_object_set(gtk_settings_get_default(), "gtk-theme-name", "Adwaita", "gtk-application-prefer-dark-theme", FALSE, NULL);
|
||||||
show_window(NULL); gtk_main(); return NULL;
|
show_window(NULL); gtk_main(); return NULL;
|
||||||
|
|||||||
@@ -590,6 +590,7 @@ static gboolean on_delete(GtkWidget *w, GdkEvent *e, gpointer d) { (void)w; (voi
|
|||||||
static void *run(void *arg) {
|
static void *run(void *arg) {
|
||||||
(void)arg;
|
(void)arg;
|
||||||
int ok = gtk_init_check(NULL, NULL);
|
int ok = gtk_init_check(NULL, NULL);
|
||||||
|
if (ok) { gtk_window_set_default_icon_name("uu-remote-linux"); } // same taskbar icon as the host (#13)
|
||||||
// The CSS hard-codes a light palette; a dark system theme would turn unstyled text white on white (#43).
|
// The CSS hard-codes a light palette; a dark system theme would turn unstyled text white on white (#43).
|
||||||
if (ok) g_object_set(gtk_settings_get_default(), "gtk-theme-name", "Adwaita", "gtk-application-prefer-dark-theme", FALSE, NULL);
|
if (ok) g_object_set(gtk_settings_get_default(), "gtk-theme-name", "Adwaita", "gtk-application-prefer-dark-theme", FALSE, NULL);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
|
|||||||
+175
-8
@@ -58,6 +58,14 @@ static struct xkb_context *xkb;
|
|||||||
static struct xkb_keymap *keymap;
|
static struct xkb_keymap *keymap;
|
||||||
static struct xkb_state *key_state;
|
static struct xkb_state *key_state;
|
||||||
static unsigned char held_keys[768];
|
static unsigned char held_keys[768];
|
||||||
|
/* Mobile input-method text (#13/#46). The protocol has no per-key remap request, but
|
||||||
|
zwp_virtual_keyboard_v1_keymap may be re-sent at any time, so the pristine keymap text is kept
|
||||||
|
and a spare keycode is pointed at one character's keysym at a time. Never logs the text. */
|
||||||
|
#define UU_TEXT_SPARE 32
|
||||||
|
static char *keymap_text;
|
||||||
|
static size_t keymap_text_len, keymap_insert;
|
||||||
|
static xkb_keycode_t spare_codes[UU_TEXT_SPARE];
|
||||||
|
static unsigned spare_count;
|
||||||
struct output { struct wl_output *handle; char name[128]; int transform,scale; uint32_t width,height; };
|
struct output { struct wl_output *handle; char name[128]; int transform,scale; uint32_t width,height; };
|
||||||
static struct output outputs[32];
|
static struct output outputs[32];
|
||||||
static unsigned output_count, selected;
|
static unsigned output_count, selected;
|
||||||
@@ -116,6 +124,164 @@ static int sync_display(void) {
|
|||||||
if (!ready) wl_callback_destroy(cb);
|
if (!ready) wl_callback_destroy(cb);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
/* Hand a keymap to the virtual keyboard. The compositor dups the fd, so it is closed here. */
|
||||||
|
static int upload_keymap(const char *text,size_t length) {
|
||||||
|
int fd=memfd_create("uuremote-keymap",MFD_CLOEXEC);
|
||||||
|
if(fd<0) return -1;
|
||||||
|
if(ftruncate(fd,(off_t)length)!=0 || write(fd,text,length)!=(ssize_t)length) { close(fd); return -1; }
|
||||||
|
zwp_virtual_keyboard_v1_keymap(keyboard,WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1,fd,(uint32_t)length);
|
||||||
|
close(fd);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* A keymap uploaded to a keyboard the seat already has is never handed to the focused client again,
|
||||||
|
so pressing the remapped keycodes would still be translated with the keymap it has - which is how
|
||||||
|
every message came out as the one before it. Re-attaching the keyboard is what makes the
|
||||||
|
compositor send the keymap to the client (measured 2026-10-18 on Hyprland 0.56.2). */
|
||||||
|
static int rekey_keyboard(void) {
|
||||||
|
if(!keyboard_manager || !seat) return -1;
|
||||||
|
if(keyboard) zwp_virtual_keyboard_v1_destroy(keyboard);
|
||||||
|
keyboard=zwp_virtual_keyboard_manager_v1_create_virtual_keyboard(keyboard_manager,seat);
|
||||||
|
return keyboard?0:-1;
|
||||||
|
}
|
||||||
|
/* Offset of the '}' that closes the xkb_symbols section, so extra keys can be declared there.
|
||||||
|
Pairing the braces is enough because the bodies are balanced; looking for the last "};" is not,
|
||||||
|
the keymap's own brace follows, and an optional xkb_geometry section may too. */
|
||||||
|
static size_t symbols_close(const char *text) {
|
||||||
|
const char *section=strstr(text,"xkb_symbols");
|
||||||
|
if(!section) return 0;
|
||||||
|
const char *open=strchr(section,'{');
|
||||||
|
if(!open) return 0;
|
||||||
|
int depth=0;
|
||||||
|
for(const char *p=open;*p;p++) {
|
||||||
|
if(*p=='{') depth++;
|
||||||
|
else if(*p=='}' && --depth==0) return (size_t)(p-text);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* Named keycodes the keymap gives no symbol to. Reading the compositor's own list is the only
|
||||||
|
portable way: pressing an unmapped keycode types nothing, and uu_wl_key never matches one
|
||||||
|
because it searches by keysym. Highest first, since uu_wl_key takes the lowest match. */
|
||||||
|
static unsigned find_spare_codes(xkb_keycode_t *out,unsigned limit) {
|
||||||
|
unsigned count=0;
|
||||||
|
xkb_keycode_t min=xkb_keymap_min_keycode(keymap);
|
||||||
|
for(xkb_keycode_t code=xkb_keymap_max_keycode(keymap);code>min && count<limit;code--) {
|
||||||
|
if(code<8 || code>=sizeof(held_keys) || !xkb_keymap_key_get_name(keymap,code)) continue;
|
||||||
|
int mapped=0;
|
||||||
|
for(xkb_level_index_t level=0;level<xkb_keymap_num_levels_for_key(keymap,code,0) && !mapped;level++) {
|
||||||
|
const xkb_keysym_t *syms;
|
||||||
|
if(xkb_keymap_key_get_syms_by_level(keymap,code,0,level,&syms)>0) mapped=1;
|
||||||
|
}
|
||||||
|
if(!mapped) out[count++]=code;
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
/* A keycode the session keymap already produces this symbol with, unshifted. Typing through it
|
||||||
|
needs no upload, so no client can mistranslate it - and it is how plain latin text and spaces
|
||||||
|
arrive without touching the keymap at all. Spares never match: the pristine keymap leaves them
|
||||||
|
unmapped. */
|
||||||
|
static xkb_keycode_t existing_keycode(xkb_keysym_t symbol) {
|
||||||
|
for(xkb_keycode_t code=xkb_keymap_min_keycode(keymap);code<=xkb_keymap_max_keycode(keymap);code++) {
|
||||||
|
if(code<8 || code>=sizeof(held_keys)) continue;
|
||||||
|
const xkb_keysym_t *syms;
|
||||||
|
if(xkb_keymap_key_get_syms_by_level(keymap,code,0,0,&syms)==1 && syms[0]==symbol) return code;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
static void press_keycode(xkb_keycode_t code) {
|
||||||
|
zwp_virtual_keyboard_v1_key(keyboard,timestamp(),code-8,WL_KEYBOARD_KEY_STATE_PRESSED);
|
||||||
|
zwp_virtual_keyboard_v1_key(keyboard,timestamp(),code-8,WL_KEYBOARD_KEY_STATE_RELEASED);
|
||||||
|
held_keys[code]=0;
|
||||||
|
}
|
||||||
|
/* The replaced keyboard starts with nothing held, and a keycode held_keys still calls held would be
|
||||||
|
skipped by uu_wl_key's next press of it. */
|
||||||
|
static void release_held_keys_locked(void) {
|
||||||
|
for(xkb_keycode_t code=xkb_keymap_min_keycode(keymap);code<=xkb_keymap_max_keycode(keymap);code++) {
|
||||||
|
if(code<8 || code>=sizeof(held_keys) || !held_keys[code]) continue;
|
||||||
|
zwp_virtual_keyboard_v1_key(keyboard,timestamp(),code-8,WL_KEYBOARD_KEY_STATE_RELEASED);
|
||||||
|
xkb_state_update_key(key_state,code,XKB_KEY_UP);
|
||||||
|
}
|
||||||
|
memset(held_keys,0,sizeof(held_keys));
|
||||||
|
}
|
||||||
|
/* Upload one batch: re-attach the keyboard so the client takes the keymap, point spare keycodes at
|
||||||
|
these symbols, wait for the compositor to install it, then press them. Spares are left out of
|
||||||
|
key_state and held_keys: pressed and released here. */
|
||||||
|
static int flush_batch(char *buffer,size_t capacity,const char names[][64],const xkb_keycode_t *codes,unsigned count,int *typed) {
|
||||||
|
release_held_keys_locked();
|
||||||
|
if(rekey_keyboard()!=0) return -1;
|
||||||
|
size_t at=keymap_insert;
|
||||||
|
memcpy(buffer,keymap_text,at);
|
||||||
|
for(unsigned i=0;i<count;i++) {
|
||||||
|
int wrote=snprintf(buffer+at,capacity-at,"\tkey <%s> { [ %s ] };\n",xkb_keymap_key_get_name(keymap,codes[i]),names[i]);
|
||||||
|
if(wrote<0 || (size_t)wrote>=capacity-at) return -1;
|
||||||
|
at+=(size_t)wrote;
|
||||||
|
}
|
||||||
|
memcpy(buffer+at,keymap_text+keymap_insert,keymap_text_len-keymap_insert);
|
||||||
|
if(upload_keymap(buffer,at+(keymap_text_len-keymap_insert))!=0) return -1;
|
||||||
|
if(sync_display()!=0) return -1;
|
||||||
|
for(unsigned i=0;i<count;i++) { press_keycode(codes[i]); (*typed)++; }
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* Type UTF-8 like xdotool type does on X11, but on Wayland: characters the session keymap already
|
||||||
|
has go out as ordinary keycodes, the rest share the spares of one keymap upload (~70 KB, so one
|
||||||
|
batch per upload), in text order. Never logs the text. */
|
||||||
|
static int type_utf8_locked(const char *text) {
|
||||||
|
size_t capacity=keymap_text_len+(size_t)UU_TEXT_SPARE*96+64;
|
||||||
|
char *buffer=malloc(capacity);
|
||||||
|
if(!buffer) return -1;
|
||||||
|
char names[UU_TEXT_SPARE][64];
|
||||||
|
xkb_keycode_t codes[UU_TEXT_SPARE];
|
||||||
|
unsigned count=0;
|
||||||
|
int typed=0, failed=0;
|
||||||
|
const unsigned char *p=(const unsigned char *)text;
|
||||||
|
while(*p && !failed) {
|
||||||
|
unsigned cp=0; int n=0;
|
||||||
|
if(*p<0x80) { cp=*p; n=1; }
|
||||||
|
else if((*p&0xE0)==0xC0 && (p[1]&0xC0)==0x80) { cp=((p[0]&0x1F)<<6)|(p[1]&0x3F); n=2; }
|
||||||
|
else if((*p&0xF0)==0xE0 && (p[1]&0xC0)==0x80 && (p[2]&0xC0)==0x80) { cp=((p[0]&0x0F)<<12)|((p[1]&0x3F)<<6)|(p[2]&0x3F); n=3; }
|
||||||
|
else if((*p&0xF8)==0xF0 && (p[1]&0xC0)==0x80 && (p[2]&0xC0)==0x80 && (p[3]&0xC0)==0x80) { cp=((p[0]&0x07)<<18)|((p[1]&0x3F)<<12)|((p[2]&0x3F)<<6)|(p[3]&0x3F); n=4; }
|
||||||
|
else { p++; continue; }
|
||||||
|
p+=n;
|
||||||
|
xkb_keysym_t sym;
|
||||||
|
if(cp=='\n') sym=0xff0d; /* Return */
|
||||||
|
else if(cp=='\t') sym=0xff09; /* Tab */
|
||||||
|
else if(cp<0x20 || cp==0x7f || (cp>=0x80 && cp<0xa0)) continue; /* controls carry no text */
|
||||||
|
else if(cp<0x100) sym=cp; /* Latin-1 keysyms equal the code point */
|
||||||
|
else sym=(xkb_keysym_t)(0x1000000|cp); /* Unicode keysym */
|
||||||
|
xkb_keycode_t existing=existing_keycode(sym);
|
||||||
|
if(existing) {
|
||||||
|
if(count && flush_batch(buffer,capacity,names,codes,count,&typed)!=0) { failed=1; break; }
|
||||||
|
count=0;
|
||||||
|
press_keycode(existing); typed++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(count==UU_TEXT_SPARE) {
|
||||||
|
if(flush_batch(buffer,capacity,names,codes,count,&typed)!=0) { failed=1; break; }
|
||||||
|
count=0;
|
||||||
|
}
|
||||||
|
/* The name is what the keymap parser reads back; an unnamed keysym cannot be spelled. */
|
||||||
|
if(xkb_keysym_get_name(sym,names[count],sizeof(names[count]))<=0) continue;
|
||||||
|
codes[count]=spare_codes[count];
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
if(!failed && count) failed=flush_batch(buffer,capacity,names,codes,count,&typed)!=0;
|
||||||
|
free(buffer);
|
||||||
|
/* Restore the pristine keymap whatever happened above, so uu_wl_key keeps its own symbol map. */
|
||||||
|
if(upload_keymap(keymap_text,keymap_text_len)!=0) return -1;
|
||||||
|
return failed && !typed?-1:typed;
|
||||||
|
}
|
||||||
|
int uu_wl_type_utf8(const char *text) {
|
||||||
|
pthread_mutex_lock(&lock);
|
||||||
|
int typed=-1;
|
||||||
|
if(initialized && text && keymap_text && keymap_insert && spare_count) typed=type_utf8_locked(text);
|
||||||
|
if(typed>=0 && wl_display_flush(display)<0) typed=-1;
|
||||||
|
pthread_mutex_unlock(&lock); return typed;
|
||||||
|
}
|
||||||
|
/* Diagnostic: how many characters one keymap upload can carry, 0 when this keymap has no spare. */
|
||||||
|
int uu_wl_text_ready(void) {
|
||||||
|
pthread_mutex_lock(&lock);
|
||||||
|
int ready=initialized && keymap_text && keymap_insert ? (int)spare_count : 0;
|
||||||
|
pthread_mutex_unlock(&lock); return ready;
|
||||||
|
}
|
||||||
static void output_geometry(void*d,struct wl_output*o,int32_t x,int32_t y,int32_t w,int32_t h,int32_t sub,const char*m,const char*model,int32_t transform) { ((struct output*)d)->transform=transform; }
|
static void output_geometry(void*d,struct wl_output*o,int32_t x,int32_t y,int32_t w,int32_t h,int32_t sub,const char*m,const char*model,int32_t transform) { ((struct output*)d)->transform=transform; }
|
||||||
static void output_mode(void*d,struct wl_output*o,uint32_t f,int32_t w,int32_t h,int32_t rate) {
|
static void output_mode(void*d,struct wl_output*o,uint32_t f,int32_t w,int32_t h,int32_t rate) {
|
||||||
if(f&WL_OUTPUT_MODE_CURRENT) { ((struct output*)d)->width=w; ((struct output*)d)->height=h; }
|
if(f&WL_OUTPUT_MODE_CURRENT) { ((struct output*)d)->width=w; ((struct output*)d)->height=h; }
|
||||||
@@ -357,6 +523,7 @@ static void reset(void) {
|
|||||||
dmabuf=NULL; dmabuf_requested=dmabuf_disabled=dmabuf_reported=0; dmabuf_linear_formats=0;
|
dmabuf=NULL; dmabuf_requested=dmabuf_disabled=dmabuf_reported=0; dmabuf_linear_formats=0;
|
||||||
pending=0; output_count=0; initialized=0; memset(outputs,0,sizeof(outputs));
|
pending=0; output_count=0; initialized=0; memset(outputs,0,sizeof(outputs));
|
||||||
memset(held_keys,0,sizeof(held_keys));
|
memset(held_keys,0,sizeof(held_keys));
|
||||||
|
free(keymap_text); keymap_text=NULL; keymap_text_len=keymap_insert=0; spare_count=0;
|
||||||
}
|
}
|
||||||
int uu_wl_init(int32_t *w,int32_t *h) {
|
int uu_wl_init(int32_t *w,int32_t *h) {
|
||||||
pthread_mutex_lock(&lock);
|
pthread_mutex_lock(&lock);
|
||||||
@@ -390,15 +557,15 @@ int uu_wl_init(int32_t *w,int32_t *h) {
|
|||||||
keymap=xkb_keymap_new_from_names(xkb,&names,XKB_KEYMAP_COMPILE_NO_FLAGS);
|
keymap=xkb_keymap_new_from_names(xkb,&names,XKB_KEYMAP_COMPILE_NO_FLAGS);
|
||||||
if(!keymap) goto end;
|
if(!keymap) goto end;
|
||||||
key_state=xkb_state_new(keymap); if(!key_state) goto end;
|
key_state=xkb_state_new(keymap); if(!key_state) goto end;
|
||||||
char *map=xkb_keymap_get_as_string(keymap,XKB_KEYMAP_FORMAT_TEXT_V1);
|
keymap_text=xkb_keymap_get_as_string(keymap,XKB_KEYMAP_FORMAT_TEXT_V1);
|
||||||
if(!map) goto end;
|
if(!keymap_text) goto end;
|
||||||
size_t length=strlen(map)+1;
|
keymap_text_len=strlen(keymap_text)+1;
|
||||||
int fd=memfd_create("uuremote-keymap",MFD_CLOEXEC);
|
if(upload_keymap(keymap_text,keymap_text_len)!=0) goto end;
|
||||||
if(fd<0) { free(map); goto end; }
|
|
||||||
if(ftruncate(fd,(off_t)length)!=0 || write(fd,map,length)!=(ssize_t)length) { free(map); close(fd); goto end; }
|
|
||||||
free(map);
|
|
||||||
zwp_virtual_keyboard_v1_keymap(keyboard,WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1,fd,length); close(fd);
|
|
||||||
if(sync_display()!=0) goto end;
|
if(sync_display()!=0) goto end;
|
||||||
|
/* Text typing needs unmapped keycodes and a place to declare them. A keymap without either
|
||||||
|
only costs that path - uu_wl_type_utf8 refuses and the caller keeps its own fallback. */
|
||||||
|
keymap_insert=symbols_close(keymap_text);
|
||||||
|
spare_count=find_spare_codes(spare_codes,sizeof(spare_codes)/sizeof(spare_codes[0]));
|
||||||
initialized=1; *w=width; *h=height; result=0;
|
initialized=1; *w=width; *h=height; result=0;
|
||||||
end:
|
end:
|
||||||
if(result!=0) reset();
|
if(result!=0) reset();
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
Type=Application
|
||||||
|
Name=UU 远程 Linux 控制端
|
||||||
|
Name[en]=UU Remote Linux Viewer
|
||||||
|
GenericName=Remote desktop viewer
|
||||||
|
Comment=非官方 UU 远程控制端(实验性):远控你的 Windows / Mac / Linux 设备
|
||||||
|
Comment[en]=Unofficial NetEase UU Remote viewer (experimental)
|
||||||
|
Exec=uuremote-viewer ui
|
||||||
|
Icon=uu-remote-linux
|
||||||
|
Terminal=false
|
||||||
|
Categories=Network;RemoteAccess;
|
||||||
|
Keywords=remote;desktop;viewer;UU;远程;控制;
|
||||||
|
StartupNotify=false
|
||||||
|
StartupWMClass=uuremote-viewer
|
||||||
@@ -11,3 +11,5 @@ Terminal=false
|
|||||||
Categories=Network;RemoteAccess;
|
Categories=Network;RemoteAccess;
|
||||||
Keywords=remote;assist;UU;远程;协助;
|
Keywords=remote;assist;UU;远程;协助;
|
||||||
StartupNotify=false
|
StartupNotify=false
|
||||||
|
# Matches the GTK window class so docks/taskbars show this icon for the host window (#13).
|
||||||
|
StartupWMClass=uu-remote-linux
|
||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
# Unofficial UU Remote Linux host in a container, for NAS boxes (Synology DSM, etc.) without a desktop.
|
# Unofficial UU Remote Linux host in a container, for NAS boxes (Synology DSM, etc.) without a desktop.
|
||||||
# Headless mode: file transfer, terminal and port mapping; no remote desktop. Uses the published release binary.
|
# Headless mode: file transfer, terminal and port mapping; no remote desktop. Uses the published release binary.
|
||||||
FROM ubuntu:24.04
|
FROM ubuntu:24.04
|
||||||
ARG VERSION=v0.2.9
|
ARG VERSION=v0.2.11
|
||||||
LABEL org.opencontainers.image.source="https://github.com/VallierDev/uu-remote-linux" \
|
LABEL org.opencontainers.image.source="https://github.com/VallierDev/uu-remote-linux" \
|
||||||
org.opencontainers.image.description="Unofficial UU Remote Linux host, headless (file transfer, terminal, port mapping)" \
|
org.opencontainers.image.description="Unofficial UU Remote Linux host, headless (file transfer, terminal, port mapping)" \
|
||||||
org.opencontainers.image.licenses="GPL-3.0"
|
org.opencontainers.image.licenses="GPL-3.0"
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
修复 iPhone 上「超清 / 原画」「常规 / 真彩」点不动。/ Fix iPhone quality and chroma choices being locked.
|
||||||
|
|
||||||
|
### 修复 / Fixed
|
||||||
|
- **iPhone 无法切换画质与真彩**(#49,感谢 @RiverOnVenus 的细致排查):连接本项目主机时,iPhone 的「超清」「原画」
|
||||||
|
以及「常规 / 真彩」按钮点了没反应,只有帧率能改。原因是主机发出的设备能力消息(`forward_setting` 的 `device_capability`)
|
||||||
|
格式与官方 Windows 被控端不一致,iPhone 无法识别,于是锁定在默认值。现在按官方格式发送设备能力(含 4:4:4 等真实支持的格式),
|
||||||
|
并补发发送参数 `sender_para_info`。
|
||||||
|
已实测:iPhone(UU 远程 4.42.0)连接修复后的主机,可以切换画质(主机收到新的画质请求)。Mac 客户端不依赖这条消息,此前即正常。
|
||||||
|
- Device capability is now sent in the official nested shape (and `sender_para_info` is added), so the iPhone client unlocks
|
||||||
|
quality and chroma choices. Verified with the UU iPhone app 4.42.0.
|
||||||
|
|
||||||
|
### 其他 / Other
|
||||||
|
- 控制端窗口与主机使用同一图标,并新增控制端启动项 `contrib/desktop/uu-remote-linux-viewer.desktop`(#13)。
|
||||||
|
|
||||||
|
### 下载 / Download
|
||||||
|
`uu-remote-linux-v0.2.10-x86_64-linux.tar.gz`(主机 `uuremote-server` + 控制端 `uuremote-viewer`,附带 `contrib/`),或 `docker pull ghcr.io/vallierdev/uu-remote-linux:v0.2.10`。
|
||||||
|
|
||||||
|
**非官方项目,与网易无关。** / **Unofficial, not affiliated with NetEase.**
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
Wayland(wlroots)手机输入法上屏;登录默认直连,不走环境代理。/ Mobile IME text on wlroots Wayland; cloud API ignores ambient proxies by default.
|
||||||
|
|
||||||
|
### 新增 / Added
|
||||||
|
- **wlroots Wayland 支持手机输入法 `text_input`**(#51,感谢 @hiclaw):手机端输入法提交的文字,
|
||||||
|
在 Hyprland / Sway 等 wlroots 合成器上通过虚拟键盘的备用键码上屏。仅在 Hyprland 0.56.2 上实测;
|
||||||
|
KWin / GNOME(门户后端)仍不支持,见 #50。
|
||||||
|
- Mobile IME `text_input` now types through the virtual keyboard's spare keycodes on wlroots compositors.
|
||||||
|
Tested on Hyprland 0.56.2 only; KWin/GNOME (portal backend) are not covered yet.
|
||||||
|
|
||||||
|
### 变更 / Changed
|
||||||
|
- **云端接口默认忽略代理环境变量**(#52,感谢 @aresbit):本地有拦截 TLS 的 HTTP/SOCKS 代理时,登录会报
|
||||||
|
`tls handshake eof`。现在主机和控制端访问网易服务器默认直连,忽略 `http_proxy` / `https_proxy` / `all_proxy`;
|
||||||
|
确实需要经代理上网的环境请设置 `UU_USE_PROXY=1`。未在拦截代理环境中实机验证,CI 测试通过。
|
||||||
|
- Cloud API clients now bypass `http_proxy` / `https_proxy` / `all_proxy` by default; set `UU_USE_PROXY=1` if your
|
||||||
|
network requires a proxy. Not verified against an intercepting proxy; CI passes.
|
||||||
|
|
||||||
|
### 下载 / Download
|
||||||
|
`uu-remote-linux-v0.2.11-x86_64-linux.tar.gz`(主机 `uuremote-server` + 控制端 `uuremote-viewer`,附带 `contrib/`),或 `docker pull ghcr.io/vallierdev/uu-remote-linux:v0.2.11`。
|
||||||
|
|
||||||
|
**非官方项目,与网易无关。** / **Unofficial, not affiliated with NetEase.**
|
||||||
+22
-1
@@ -121,9 +121,24 @@ fn redact_urls(text: &str) -> String {
|
|||||||
out
|
out
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Cloud API clients ignore ambient HTTP/SOCKS proxy settings by default: a local
|
||||||
|
/// proxy that intercepts TLS breaks login and signaling. `UU_USE_PROXY=1` opts back
|
||||||
|
/// into reqwest's standard proxy environment handling.
|
||||||
|
pub fn http_client_builder() -> reqwest::ClientBuilder {
|
||||||
|
let builder = reqwest::Client::builder();
|
||||||
|
if std::env::var("UU_USE_PROXY").ok().as_deref().is_some_and(proxy_requested) {
|
||||||
|
builder
|
||||||
|
} else {
|
||||||
|
builder.no_proxy()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fn proxy_requested(value: &str) -> bool {
|
||||||
|
matches!(value.trim().to_ascii_lowercase().as_str(), "1" | "true" | "yes" | "on")
|
||||||
|
}
|
||||||
|
|
||||||
impl UUAuthClient {
|
impl UUAuthClient {
|
||||||
pub fn new(creds: Credentials) -> Self {
|
pub fn new(creds: Credentials) -> Self {
|
||||||
let http = reqwest::Client::builder()
|
let http = http_client_builder()
|
||||||
.timeout(std::time::Duration::from_secs(12))
|
.timeout(std::time::Duration::from_secs(12))
|
||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
@@ -346,4 +361,10 @@ mod guest_tests {
|
|||||||
let text = super::redact_urls("proxy http://user:[email protected]:3128 failed for (https://api.example/p?token=abc)");
|
let text = super::redact_urls("proxy http://user:[email protected]:3128 failed for (https://api.example/p?token=abc)");
|
||||||
assert_eq!(text, "proxy http://proxy.example:3128 failed for (https://api.example/p)");
|
assert_eq!(text, "proxy http://proxy.example:3128 failed for (https://api.example/p)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn proxy_opt_in_accepts_only_explicit_truthy_values() {
|
||||||
|
for value in ["1", "true", "TRUE", " yes ", "On"] { assert!(super::proxy_requested(value)); }
|
||||||
|
for value in ["", "0", "false", "no", "off", "2"] { assert!(!super::proxy_requested(value)); }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+58
-22
@@ -27,21 +27,49 @@ pub fn h264_device_capability(
|
|||||||
fps: i32,
|
fps: i32,
|
||||||
codec_impl: i32,
|
codec_impl: i32,
|
||||||
) -> Value {
|
) -> Value {
|
||||||
device_capability(client_id, ice_id, display_id, fps, codec_impl, false)
|
device_capability(client_id, ice_id, display_id, fps, codec_impl, false, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn device_capability(client_id: &str, ice_id: &str, display_id: i32, fps: i32, codec_impl: i32, hevc: bool) -> Value {
|
/// Shape of the official Windows host's `forward_setting` (observed from a live 4.37 host):
|
||||||
let mut codecs = vec![json!({"video_codec": VIDEO_CODEC_H264, "chroma_sampling": 1,
|
/// `{client_id, data: {device_capability: {display_info, ice_id, video_codec_capability}, type}}`.
|
||||||
"codec_impl": codec_impl, "bit_depth": 8})];
|
/// The payload sits under `data.device_capability` with `type` beside it. The earlier flat shape
|
||||||
// Official VideoCodecCapability::SerializeJson uses the same fields for CodecType H265=2.
|
/// (`type` at the top, fields directly in `data`) was not recognised by the iPhone client, which
|
||||||
if hevc { codecs.push(json!({"video_codec": 2, "chroma_sampling": 1, "codec_impl": codec_impl, "bit_depth": 8})); }
|
/// then kept quality and chroma locked at their defaults (#49). Only 8-bit and the chroma formats
|
||||||
|
/// the encoder really produces are listed; the first entry carries the maximum size as officially.
|
||||||
|
pub fn device_capability(client_id: &str, ice_id: &str, display_id: i32, fps: i32, codec_impl: i32, hevc: bool, full_chroma: bool) -> Value {
|
||||||
|
let mut codecs = Vec::new();
|
||||||
|
for codec in [VIDEO_CODEC_H264].into_iter().chain(hevc.then_some(2)) {
|
||||||
|
for chroma in [1].into_iter().chain(full_chroma.then_some(3)) {
|
||||||
|
let (width, height) = if codecs.is_empty() { (3840, 2160) } else { (0, 0) };
|
||||||
|
codecs.push(json!({"video_codec": codec, "chroma_sampling": chroma, "codec_impl": codec_impl,
|
||||||
|
"bit_depth": 8, "width": width, "height": height}));
|
||||||
|
}
|
||||||
|
}
|
||||||
json!({
|
json!({
|
||||||
"client_id": client_id,
|
"client_id": client_id,
|
||||||
"type": "device_capability",
|
|
||||||
"data": {
|
"data": {
|
||||||
"display_info": [{"id": display_id, "fps": fps, "type": 0, "hdr": 0}],
|
"device_capability": {
|
||||||
"video_codec_capability": codecs,
|
"display_info": [{"id": display_id, "fps": fps, "type": 0, "hdr": -1}],
|
||||||
"ice_id": ice_id
|
"video_codec_capability": codecs,
|
||||||
|
"ice_id": ice_id
|
||||||
|
},
|
||||||
|
"type": "device_capability"
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Official `sender_para_info` (capture and encoder names; the Windows host sends "DXGI" /
|
||||||
|
/// "NVIDIA NVENC") for the single video track.
|
||||||
|
pub fn sender_para_info(client_id: &str, ice_id: &str, capture_impl: &str, encoder_impl: &str) -> Value {
|
||||||
|
json!({
|
||||||
|
"client_id": client_id,
|
||||||
|
"data": {
|
||||||
|
"sender_para_info": {
|
||||||
|
"capture_impl": capture_impl, "encoder_impl": encoder_impl, "ice_id": ice_id,
|
||||||
|
"sender_media_infos": [{"capture_impl": capture_impl, "encoder_impl": encoder_impl, "video_track_index": 0}],
|
||||||
|
"video_track_index": 0
|
||||||
|
},
|
||||||
|
"type": "sender_para_info"
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -51,12 +79,20 @@ mod tests {
|
|||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn hevc_capability_uses_official_codec_enum_and_420_only() {
|
fn capability_uses_the_official_nested_shape_and_real_formats() {
|
||||||
let payload = device_capability("client-example", "ice-example", 0, 60, 5, true);
|
let payload = device_capability("client-example", "ice-example", 0, 60, 5, true, true);
|
||||||
assert_eq!(payload["data"]["video_codec_capability"], json!([
|
assert_eq!(payload["data"]["type"], "device_capability");
|
||||||
{"video_codec":1,"chroma_sampling":1,"codec_impl":5,"bit_depth":8},
|
assert!(payload.get("type").is_none());
|
||||||
{"video_codec":2,"chroma_sampling":1,"codec_impl":5,"bit_depth":8}]));
|
let caps = &payload["data"]["device_capability"]["video_codec_capability"];
|
||||||
assert_eq!(device_capability("c", "i", 0, 60, 5, false)["data"]["video_codec_capability"].as_array().unwrap().len(), 1);
|
assert_eq!(caps.as_array().unwrap().len(), 4);
|
||||||
|
assert_eq!(caps[0], json!({"video_codec":1,"chroma_sampling":1,"codec_impl":5,"bit_depth":8,"width":3840,"height":2160}));
|
||||||
|
assert_eq!(caps[3], json!({"video_codec":2,"chroma_sampling":3,"codec_impl":5,"bit_depth":8,"width":0,"height":0}));
|
||||||
|
assert_eq!(payload["data"]["device_capability"]["display_info"][0]["hdr"], -1);
|
||||||
|
let h264_420 = device_capability("c", "i", 0, 60, 5, false, false);
|
||||||
|
assert_eq!(h264_420["data"]["device_capability"]["video_codec_capability"].as_array().unwrap().len(), 1);
|
||||||
|
let sender = sender_para_info("c", "i", "X11", "NVIDIA NVENC");
|
||||||
|
assert_eq!(sender["data"]["type"], "sender_para_info");
|
||||||
|
assert_eq!(sender["data"]["sender_para_info"]["sender_media_infos"][0]["encoder_impl"], "NVIDIA NVENC");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -71,15 +107,15 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn device_capability_uses_object_data_and_string_ice_id() {
|
fn device_capability_uses_object_data_and_string_ice_id() {
|
||||||
let payload = h264_device_capability("client-example", "ice-example", 11, 60, 0);
|
let payload = h264_device_capability("client-example", "ice-example", 11, 60, 0);
|
||||||
assert_eq!(payload["type"], "device_capability");
|
let capability = &payload["data"]["device_capability"];
|
||||||
assert!(payload["data"].is_object());
|
assert!(capability.is_object());
|
||||||
assert_eq!(payload["data"]["ice_id"], "ice-example");
|
assert_eq!(capability["ice_id"], "ice-example");
|
||||||
let display = &payload["data"]["display_info"][0];
|
let display = &capability["display_info"][0];
|
||||||
assert_eq!(display.as_object().unwrap().len(), 4);
|
assert_eq!(display.as_object().unwrap().len(), 4);
|
||||||
assert_eq!(display["id"], 11);
|
assert_eq!(display["id"], 11);
|
||||||
assert_eq!(display["fps"], 60);
|
assert_eq!(display["fps"], 60);
|
||||||
let codec = &payload["data"]["video_codec_capability"][0];
|
let codec = &capability["video_codec_capability"][0];
|
||||||
assert_eq!(codec.as_object().unwrap().len(), 4);
|
assert_eq!(codec.as_object().unwrap().len(), 6);
|
||||||
assert_eq!(codec["video_codec"], 1);
|
assert_eq!(codec["video_codec"], 1);
|
||||||
assert_eq!(codec["codec_impl"], 0);
|
assert_eq!(codec["codec_impl"], 0);
|
||||||
assert_eq!(codec["bit_depth"], 8);
|
assert_eq!(codec["bit_depth"], 8);
|
||||||
|
|||||||
+15
-1
@@ -360,13 +360,27 @@ impl InputInjector {
|
|||||||
if self.backend==crate::desktop_backend::DesktopBackend::Wayland { crate::wayland::key(symbol,pressed) }
|
if self.backend==crate::desktop_backend::DesktopBackend::Wayland { crate::wayland::key(symbol,pressed) }
|
||||||
else { unsafe { x11_key_symbol(symbol as libc::c_ulong,i32::from(pressed)) } }
|
else { unsafe { x11_key_symbol(symbol as libc::c_ulong,i32::from(pressed)) } }
|
||||||
}
|
}
|
||||||
/// Mobile input-method text (`text_input`). X11 only for now; other backends log once.
|
/// Mobile input-method text (`text_input`). X11 types it directly; Wayland re-maps a spare
|
||||||
|
/// keycode in the virtual keyboard's keymap. Other backends log once.
|
||||||
pub fn text_input(&self, text: &str) {
|
pub fn text_input(&self, text: &str) {
|
||||||
let _serial=self.serial.lock().unwrap();
|
let _serial=self.serial.lock().unwrap();
|
||||||
let Ok(c_text)=std::ffi::CString::new(text.replace('\0',"")) else { return };
|
let Ok(c_text)=std::ffi::CString::new(text.replace('\0',"")) else { return };
|
||||||
if self.backend==crate::desktop_backend::DesktopBackend::X11 {
|
if self.backend==crate::desktop_backend::DesktopBackend::X11 {
|
||||||
let typed=unsafe { x11_type_utf8(c_text.as_ptr()) };
|
let typed=unsafe { x11_type_utf8(c_text.as_ptr()) };
|
||||||
log::info!("Desktop text input: chars={} result={}", text.chars().count(), typed);
|
log::info!("Desktop text input: chars={} result={}", text.chars().count(), typed);
|
||||||
|
} else if self.backend==crate::desktop_backend::DesktopBackend::Wayland {
|
||||||
|
// Escape hatch: keep the old behaviour without rebuilding.
|
||||||
|
if std::env::var("UU_WAYLAND_TEXT").is_ok_and(|v|v=="0") { return; }
|
||||||
|
let typed=crate::wayland::type_utf8(text);
|
||||||
|
if typed>=0 {
|
||||||
|
log::info!("Desktop text input: chars={} result={}", text.chars().count(), typed);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// A keymap whose keycodes are all mapped cannot carry text; report it once.
|
||||||
|
static WARNED:std::sync::atomic::AtomicBool=std::sync::atomic::AtomicBool::new(false);
|
||||||
|
if !WARNED.swap(true,std::sync::atomic::Ordering::Relaxed) {
|
||||||
|
log::warn!("Mobile text input unavailable on the Wayland backend (no spare keycode in this keymap)");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
static WARNED:std::sync::atomic::AtomicBool=std::sync::atomic::AtomicBool::new(false);
|
static WARNED:std::sync::atomic::AtomicBool=std::sync::atomic::AtomicBool::new(false);
|
||||||
if !WARNED.swap(true,std::sync::atomic::Ordering::Relaxed) {
|
if !WARNED.swap(true,std::sync::atomic::Ordering::Relaxed) {
|
||||||
|
|||||||
+5
-2
@@ -190,8 +190,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
.filter_module("uuremote_server", log::LevelFilter::Info).init();
|
.filter_module("uuremote_server", log::LevelFilter::Info).init();
|
||||||
} else { env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init(); }
|
} else { env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init(); }
|
||||||
// An unknown argument must never fall through to starting a second full host server.
|
// An unknown argument must never fall through to starting a second full host server.
|
||||||
const SUBCOMMANDS: [&str; 13] = ["show", "assist", "desktop-input-probe", "virtual-audio-probe", "login", "unlock-check", "desktop-probe", "desktop-video-probe", "desktop-audio-probe", "wayland-capture",
|
const SUBCOMMANDS: [&str; 14] = ["show", "assist", "desktop-input-probe", "virtual-audio-probe", "login", "unlock-check", "desktop-probe", "desktop-video-probe", "desktop-audio-probe", "wayland-capture",
|
||||||
"wayland-input-probe", "clipboard-acceptance", "portal-acceptance"];
|
"wayland-input-probe", "wayland-text-probe", "clipboard-acceptance", "portal-acceptance"];
|
||||||
if let Some(arg) = std::env::args().nth(1).filter(|a| !SUBCOMMANDS.contains(&a.as_str())) {
|
if let Some(arg) = std::env::args().nth(1).filter(|a| !SUBCOMMANDS.contains(&a.as_str())) {
|
||||||
let usage = format!("usage: uuremote-server [{}]\n (no argument: run the host)", SUBCOMMANDS.join(" | "));
|
let usage = format!("usage: uuremote-server [{}]\n (no argument: run the host)", SUBCOMMANDS.join(" | "));
|
||||||
if matches!(arg.as_str(), "help" | "-h" | "--help") { println!("{usage}"); return Ok(()); }
|
if matches!(arg.as_str(), "help" | "-h" | "--help") { println!("{usage}"); return Ok(()); }
|
||||||
@@ -353,6 +353,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
if std::env::args().nth(1).as_deref() == Some("wayland-input-probe") {
|
if std::env::args().nth(1).as_deref() == Some("wayland-input-probe") {
|
||||||
return wayland::input_probe().map_err(|e|e.into());
|
return wayland::input_probe().map_err(|e|e.into());
|
||||||
}
|
}
|
||||||
|
if std::env::args().nth(1).as_deref() == Some("wayland-text-probe") {
|
||||||
|
return wayland::text_probe().map_err(|e|e.into());
|
||||||
|
}
|
||||||
if std::env::args().nth(1).as_deref() == Some("wayland-capture") {
|
if std::env::args().nth(1).as_deref() == Some("wayland-capture") {
|
||||||
return wayland::capture_stdout().map_err(|e| e.into());
|
return wayland::capture_stdout().map_err(|e| e.into());
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -93,7 +93,7 @@ pub struct Api {
|
|||||||
}
|
}
|
||||||
impl Api {
|
impl Api {
|
||||||
pub fn new(signer: UUAuthClient, base: &str) -> Self {
|
pub fn new(signer: UUAuthClient, base: &str) -> Self {
|
||||||
Self { signer, base: base.trim_end_matches('/').into(), http: reqwest::Client::builder().timeout(Duration::from_secs(12)).build().unwrap() }
|
Self { signer, base: base.trim_end_matches('/').into(), http: crate::auth::http_client_builder().timeout(Duration::from_secs(12)).build().unwrap() }
|
||||||
}
|
}
|
||||||
pub async fn join_share(&self, connect_id: &str, connect_code: &str) -> Result<JoinData, Error> {
|
pub async fn join_share(&self, connect_id: &str, connect_code: &str) -> Result<JoinData, Error> {
|
||||||
if connect_id.trim().is_empty() || connect_code.trim().is_empty() || connect_id.chars().chain(connect_code.chars()).any(char::is_control) { return Err(Error::InvalidAssist); }
|
if connect_id.trim().is_empty() || connect_code.trim().is_empty() || connect_id.chars().chain(connect_code.chars()).any(char::is_control) { return Err(Error::InvalidAssist); }
|
||||||
|
|||||||
@@ -8,6 +8,26 @@ extern "C" {
|
|||||||
fn uu_wl_key(symbol: u64, pressed: i32) -> i32;
|
fn uu_wl_key(symbol: u64, pressed: i32) -> i32;
|
||||||
fn uu_wl_wake() -> i32;
|
fn uu_wl_wake() -> i32;
|
||||||
fn uu_wl_release_all() -> i32;
|
fn uu_wl_release_all() -> i32;
|
||||||
|
fn uu_wl_type_utf8(text: *const libc::c_char) -> i32;
|
||||||
|
fn uu_wl_text_ready() -> i32;
|
||||||
|
}
|
||||||
|
/// How many characters one keymap upload can carry; 0 means this keymap has no spare keycode.
|
||||||
|
pub fn text_ready()->i32 {
|
||||||
|
#[cfg(all(target_os="linux",feature="wayland"))]
|
||||||
|
{ return unsafe { uu_wl_text_ready() }; }
|
||||||
|
#[cfg(not(all(target_os="linux",feature="wayland")))]
|
||||||
|
-1
|
||||||
|
}
|
||||||
|
/// Mobile input-method text (#13/#46). Returns the number of characters typed, or a negative code
|
||||||
|
/// when this keymap has no spare keycode to carry them. Never logs the text.
|
||||||
|
pub fn type_utf8(text:&str)->i32 {
|
||||||
|
#[cfg(all(target_os="linux",feature="wayland"))]
|
||||||
|
{
|
||||||
|
let Ok(c_text)=std::ffi::CString::new(text.replace('\0',"")) else { return -1 };
|
||||||
|
return unsafe { uu_wl_type_utf8(c_text.as_ptr()) };
|
||||||
|
}
|
||||||
|
#[cfg(not(all(target_os="linux",feature="wayland")))]
|
||||||
|
{ let _=text; -1 }
|
||||||
}
|
}
|
||||||
pub fn release_all()->i32 {
|
pub fn release_all()->i32 {
|
||||||
#[cfg(all(target_os="linux",feature="wayland"))]
|
#[cfg(all(target_os="linux",feature="wayland"))]
|
||||||
@@ -144,3 +164,33 @@ pub fn input_probe()->Result<(),String> {
|
|||||||
println!("Wayland test events sent; verify the native GTK acceptance report.");
|
println!("Wayland test events sent; verify the native GTK acceptance report.");
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Local diagnostic for the mobile-text path: report the keymap's capacity for it, then type a
|
||||||
|
/// sample into the focused window. Only the built-in sample is echoed; UU_PROBE_TEXT stays private.
|
||||||
|
pub fn text_probe()->Result<(),String> {
|
||||||
|
init()?;
|
||||||
|
let ready=text_ready();
|
||||||
|
if ready<=0 { return Err("this keymap has no spare keycode: mobile text input cannot be carried".into()); }
|
||||||
|
const SAMPLE:&str="uu remote abc 你好世界";
|
||||||
|
let (sample,builtin)=match std::env::var("UU_PROBE_TEXT") {
|
||||||
|
Ok(value)=>(value,false), Err(_)=>(SAMPLE.to_owned(),true),
|
||||||
|
};
|
||||||
|
println!("Wayland text probe: spare keycodes={ready} characters={} bytes={}",sample.chars().count(),sample.len());
|
||||||
|
if builtin { println!("Sample: {sample}"); }
|
||||||
|
// UU_PROBE_SEQUENCE types each |-separated field as its own call - one text_input message each,
|
||||||
|
// the way the phone's input method sends them - with UU_PROBE_STEP_MS between the calls. One
|
||||||
|
// process means one virtual keyboard, exactly as the host has.
|
||||||
|
let step=std::env::var("UU_PROBE_STEP_MS").ok().and_then(|v|v.parse::<u64>().ok()).unwrap_or(0);
|
||||||
|
let sequence=std::env::var("UU_PROBE_SEQUENCE").unwrap_or_else(|_|sample.clone());
|
||||||
|
let mut typed=0;
|
||||||
|
for (index,message) in sequence.split('|').enumerate() {
|
||||||
|
if index>0 && step>0 { std::thread::sleep(std::time::Duration::from_millis(step)); }
|
||||||
|
let one=type_utf8(message);
|
||||||
|
if one<0 { return Err(format!("Wayland text typing failed ({one})")); }
|
||||||
|
typed+=one;
|
||||||
|
}
|
||||||
|
if typed<0 { return Err(format!("Wayland text typing failed ({typed})")); }
|
||||||
|
println!("Typed {typed} of {} characters in {} calls; check that they match.",
|
||||||
|
sequence.chars().filter(|character|*character!='|').count(),sequence.split('|').count());
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
+18
-1
@@ -177,10 +177,27 @@ impl WebRtcSession {
|
|||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
let ctx = ctx.lock().await.clone();
|
let ctx = ctx.lock().await.clone();
|
||||||
if let (Some(client), Some(ice)) = (&ctx.client_id, ctx.ice_id.as_ref().and_then(|v| v.as_str())) {
|
if let (Some(client), Some(ice)) = (&ctx.client_id, ctx.ice_id.as_ref().and_then(|v| v.as_str())) {
|
||||||
let payload = crate::capability::device_capability(client, ice, 0, crate::video::display_fps() as i32, 5, hevc);
|
let encoder = crate::video::Encoder::requested();
|
||||||
|
let codec_impl = if encoder == crate::video::Encoder::Nvenc { crate::capability::CODEC_IMPL_NVENC } else { 5 };
|
||||||
|
let payload = crate::capability::device_capability(client, ice, 0, crate::video::display_fps() as i32, codec_impl,
|
||||||
|
hevc, crate::video::full_chroma_available());
|
||||||
if let Err(e) = sig.emit_event(crate::capability::FORWARD_SETTING_EVENT, payload).await {
|
if let Err(e) = sig.emit_event(crate::capability::FORWARD_SETTING_EVENT, payload).await {
|
||||||
log::error!("Device capability notification failed: {}", e);
|
log::error!("Device capability notification failed: {}", e);
|
||||||
}
|
}
|
||||||
|
let capture_impl = match crate::desktop_backend::detect() {
|
||||||
|
Ok(crate::desktop_backend::DesktopBackend::Portal) => "PipeWire",
|
||||||
|
Ok(crate::desktop_backend::DesktopBackend::Wayland) => "Wayland",
|
||||||
|
_ => "X11",
|
||||||
|
};
|
||||||
|
let encoder_impl = match encoder {
|
||||||
|
crate::video::Encoder::Nvenc => "NVIDIA NVENC",
|
||||||
|
crate::video::Encoder::Vaapi => "VAAPI",
|
||||||
|
crate::video::Encoder::Cpu => "Software",
|
||||||
|
};
|
||||||
|
if let Err(e) = sig.emit_event(crate::capability::FORWARD_SETTING_EVENT,
|
||||||
|
crate::capability::sender_para_info(client, ice, capture_impl, encoder_impl)).await {
|
||||||
|
log::error!("Sender parameter notification failed: {}", e);
|
||||||
|
}
|
||||||
if let Some(control) = ctx.app_control_id.as_ref().and_then(|v| v.as_str()) {
|
if let Some(control) = ctx.app_control_id.as_ref().and_then(|v| v.as_str()) {
|
||||||
if let Err(e) = sig.emit_event(crate::capability::ICE_FINISHED_EVENT,
|
if let Err(e) = sig.emit_event(crate::capability::ICE_FINISHED_EVENT,
|
||||||
crate::capability::ice_finished(ice, control)).await {
|
crate::capability::ice_finished(ice, control)).await {
|
||||||
|
|||||||
Reference in new issue
Block a user