Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
150afb2b4a
|
No files matched your search
@@ -1,17 +1,18 @@
|
||||
name: Build native binaries on Debian 11
|
||||
name: Build vk_gpu_info on Debian 11
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- scripts
|
||||
paths:
|
||||
- 'build-aux/src/**'
|
||||
- 'build-aux/src/vk_gpu_info.c'
|
||||
- '.gitea/workflows/build-vk-gpu-info-debian.yml'
|
||||
|
||||
jobs:
|
||||
build-debian11:
|
||||
name: Build native binaries on Debian 11
|
||||
name: Build vk_gpu_info on Debian 11
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: debian:11
|
||||
@@ -20,13 +21,8 @@ jobs:
|
||||
steps:
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
set -- build-essential cmake pkg-config libvulkan-dev libwayland-dev libx11-dev git curl wget nodejs npm
|
||||
if ! (apt-get update -o APT::Update::Error-Mode=any && apt-get install -y "$@"); then
|
||||
echo 'APT failed; retrying with security.debian.org for bullseye-security.'
|
||||
sed -i '/^[[:space:]]*deb .* bullseye-security /s|http://deb.debian.org/debian-security|http://security.debian.org/debian-security|' /etc/apt/sources.list &&
|
||||
apt-get update -o APT::Update::Error-Mode=any &&
|
||||
apt-get install -y "$@"
|
||||
fi
|
||||
apt-get update
|
||||
apt-get install -y build-essential pkg-config libvulkan-dev git curl wget nodejs npm
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: https://git.linux-gaming.ru/actions/setup-node@v2
|
||||
@@ -35,46 +31,26 @@ jobs:
|
||||
|
||||
- name: Checkout code
|
||||
uses: https://git.linux-gaming.ru/actions/checkout@v3
|
||||
with:
|
||||
ref: ${{ gitea.ref }}
|
||||
token: ${{ secrets.GITEA_TOKEN }}
|
||||
|
||||
- name: Build SDL3 for linking
|
||||
- name: Compile vk_gpu_info
|
||||
run: |
|
||||
# SDL 3.2.10 is not available in Debian 11. Only the backends are shipped.
|
||||
sdl_commit=877399b2b2cf21e67554ed9046410f268ce1d1b2
|
||||
curl --fail --location --max-time 120 \
|
||||
"https://codeload.github.com/libsdl-org/SDL/tar.gz/${sdl_commit}" -o /tmp/sdl3.tar.gz
|
||||
mkdir -p /tmp/sdl3-src
|
||||
tar -xzf /tmp/sdl3.tar.gz -C /tmp/sdl3-src --strip-components=1
|
||||
cmake -S /tmp/sdl3-src -B /tmp/sdl3-build \
|
||||
-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/tmp/sdl3 \
|
||||
-DCMAKE_INSTALL_LIBDIR=lib -DSDL_UNIX_CONSOLE_BUILD=ON \
|
||||
-DSDL_SHARED=ON -DSDL_STATIC=OFF -DSDL_TEST_LIBRARY=OFF
|
||||
cmake --build /tmp/sdl3-build --parallel "$(nproc)"
|
||||
cmake --install /tmp/sdl3-build
|
||||
|
||||
- name: Compile native binaries
|
||||
run: |
|
||||
export PKG_CONFIG_PATH="/tmp/sdl3/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}"
|
||||
mkdir -p build-aux/bin build-aux/lib
|
||||
gcc -std=c99 -o build-aux/bin/vk_gpu_info build-aux/src/vk_gpu_info.c -lvulkan
|
||||
gcc -shared -fPIC -Wl,-z,defs -o build-aux/lib/libportprotonqt_gamepad.so \
|
||||
build-aux/src/gamepad_backend.c $(pkg-config --cflags --libs sdl3)
|
||||
gcc -shared -fPIC -Wl,-z,defs -o build-aux/lib/libportprotonqt_keyboard.so \
|
||||
build-aux/src/keyboard_backend.c $(pkg-config --cflags --libs wayland-client x11)
|
||||
mkdir -p build-aux/bin
|
||||
gcc -o build-aux/bin/vk_gpu_info build-aux/src/vk_gpu_info.c -lvulkan
|
||||
|
||||
- name: Test vk_gpu_info execution
|
||||
run: |
|
||||
test -x build-aux/bin/vk_gpu_info
|
||||
timeout 10s build-aux/bin/vk_gpu_info || echo "Vulkan smoke test failed; CI may lack a Vulkan device."
|
||||
# Check if the executable was created
|
||||
if [ -f "build-aux/bin/vk_gpu_info" ]; then
|
||||
echo "vk_gpu_info executable created successfully"
|
||||
# Try to run it (may fail if no Vulkan devices present, but that's OK for build test)
|
||||
timeout 10s build-aux/bin/vk_gpu_info || echo "vk_gpu_info ran but may have failed due to lack of Vulkan hardware (expected in CI)"
|
||||
else
|
||||
echo "ERROR: vk_gpu_info executable was not created"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Upload native binaries
|
||||
- name: Upload vk_gpu_info binary
|
||||
uses: https://git.linux-gaming.ru/actions/gitea-upload-artifact@v4
|
||||
with:
|
||||
name: native-binaries-debian11
|
||||
path: |
|
||||
build-aux/bin/vk_gpu_info
|
||||
build-aux/lib/libportprotonqt_gamepad.so
|
||||
build-aux/lib/libportprotonqt_keyboard.so
|
||||
if-no-files-found: error
|
||||
name: vk_gpu_info-debian11-binary
|
||||
path: build-aux/bin/vk_gpu_info
|
||||
@@ -177,7 +177,7 @@ jobs:
|
||||
install -y --disablerepo=fedora-cisco-openh264 \
|
||||
git rpmdevtools meson ninja-build python3-devel \
|
||||
systemd-rpm-macros vulkan-loader-devel redhat-rpm-config nodejs npm \
|
||||
gcc gettext 'pkgconfig(sdl3)' 'pkgconfig(wayland-client)' 'pkgconfig(x11)'
|
||||
gcc gettext 'pkgconfig(sdl3)'
|
||||
|
||||
- name: Setup rpmbuild environment
|
||||
run: |
|
||||
|
||||
@@ -22,7 +22,7 @@ jobs:
|
||||
name: Check code
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: archlinux:base-devel@sha256:624bdc7fc6615155d67bc34cf7146c0c9fd0e3c92943977da63a630e4ca49c30
|
||||
image: archlinux:base-devel@sha256:3cbf69d2d5958d6a294f3722c5668e6187c4df8e00fa27f72352f0bf83e495e1
|
||||
steps:
|
||||
- name: Configure Arch mirrors
|
||||
run: |
|
||||
|
||||
@@ -30,6 +30,8 @@ jobs:
|
||||
run: python dev-scripts/get_id.py
|
||||
env:
|
||||
STEAM_KEY: ${{ secrets.STEAM_KEY }}
|
||||
LINUX_GAMING_API_KEY: ${{ secrets.LINUX_GAMING_API_KEY }}
|
||||
LINUX_GAMING_API_USERNAME: ${{ secrets.LINUX_GAMING_API_USERNAME }}
|
||||
|
||||
- name: Commit and push changes
|
||||
env:
|
||||
|
||||
@@ -80,7 +80,7 @@ jobs:
|
||||
needs: changes
|
||||
if: needs.changes.outputs.appimage == 'true' || github.event_name == 'workflow_dispatch'
|
||||
container:
|
||||
image: archlinux:base-devel@sha256:624bdc7fc6615155d67bc34cf7146c0c9fd0e3c92943977da63a630e4ca49c30
|
||||
image: archlinux:base-devel@sha256:3cbf69d2d5958d6a294f3722c5668e6187c4df8e00fa27f72352f0bf83e495e1
|
||||
options: --privileged --device /dev/fuse
|
||||
steps:
|
||||
- name: Configure Arch mirrors
|
||||
@@ -164,7 +164,7 @@ jobs:
|
||||
install -y --disablerepo=fedora-cisco-openh264 \
|
||||
git rpmdevtools meson ninja-build python3-devel \
|
||||
systemd-rpm-macros vulkan-loader-devel redhat-rpm-config nodejs npm \
|
||||
gcc gettext 'pkgconfig(sdl3)' 'pkgconfig(wayland-client)' 'pkgconfig(x11)'
|
||||
gcc gettext 'pkgconfig(sdl3)'
|
||||
|
||||
- name: Setup rpmbuild environment
|
||||
run: |
|
||||
@@ -210,7 +210,7 @@ jobs:
|
||||
needs: changes
|
||||
if: needs.changes.outputs.arch == 'true' || github.event_name == 'workflow_dispatch'
|
||||
container:
|
||||
image: archlinux:base-devel@sha256:624bdc7fc6615155d67bc34cf7146c0c9fd0e3c92943977da63a630e4ca49c30
|
||||
image: archlinux:base-devel@sha256:3cbf69d2d5958d6a294f3722c5668e6187c4df8e00fa27f72352f0bf83e495e1
|
||||
|
||||
steps:
|
||||
- name: Configure Arch mirrors
|
||||
@@ -296,7 +296,7 @@ jobs:
|
||||
needs: changes
|
||||
if: needs.changes.outputs.debian == 'true' || github.event_name == 'workflow_dispatch'
|
||||
container:
|
||||
image: debian:trixie-20261027@sha256:2dc419c6d7fe3dad0a2f9fd469c34cc90b0f9ba642d8fde837fe3d7d34a0e7f1
|
||||
image: debian:trixie-20261005@sha256:913f6706df59a68922d1dd08f78c2476560a8d367897200a6005b00e5f67c2d5
|
||||
options: --privileged
|
||||
|
||||
steps:
|
||||
|
||||
@@ -40,6 +40,6 @@ jobs:
|
||||
env:
|
||||
RENOVATE_CONFIG_FILE: "/tmp/renovate-config/config.js"
|
||||
RENOVATE_BINARY_SOURCE: "global"
|
||||
GITHUB_COM_TOKEN: ${{ secrets.GHP_COM_TOKEN }}
|
||||
GITHUB_COM_TOKEN: ${{ secrets.GITHUB_COM_TOKEN }}
|
||||
LOG_LEVEL: "debug"
|
||||
RENOVATE_TOKEN: ${{ secrets.RENOVATE_TOKEN }}
|
||||
@@ -1,49 +0,0 @@
|
||||
name: Update Wine GPU names
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
- cron: '0 4 * * 1'
|
||||
|
||||
concurrency:
|
||||
group: update-wine-gpu-names
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
update:
|
||||
if: gitea.repository == 'Linux-Gaming/PortProtonQt'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: https://git.linux-gaming.ru/actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
||||
with:
|
||||
ref: main
|
||||
token: ${{ secrets.GITEA_TOKEN }}
|
||||
|
||||
- name: Set up Python
|
||||
uses: https://git.linux-gaming.ru/actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7
|
||||
with:
|
||||
python-version-file: pyproject.toml
|
||||
|
||||
- name: Update Wine GPU names
|
||||
id: update
|
||||
run: |
|
||||
python dev-scripts/update_wine_gpu_names.py
|
||||
if git diff --quiet -- build-aux/src/wine_gpu_names.h; then
|
||||
echo "changed=false" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "changed=true" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
- name: Commit and push table changes
|
||||
if: steps.update.outputs.changed == 'true'
|
||||
run: |
|
||||
git add -- build-aux/src/wine_gpu_names.h
|
||||
if git diff --cached --quiet; then
|
||||
echo "Wine GPU names are unchanged."
|
||||
exit 0
|
||||
fi
|
||||
git config --local user.name 'Gitea Actions'
|
||||
git config --local user.email 'gitea-actions@users.noreply.gitea.com'
|
||||
git commit -m 'chore: sync Wine GPU names'
|
||||
git push origin HEAD:main
|
||||
@@ -7,9 +7,6 @@
|
||||
|
||||
### Added
|
||||
|
||||
- Добавлена поддержка нативных Linux-игр: библиотека обнаруживает игры по ярлыкам `.desktop`, а через диалог добавления игры можно выбрать исполняемый файл Linux
|
||||
- Добавлена системная экранная клавиатура с управлением геймпадом: её можно открыть из меню в системном трее или сочетанием `Start` + верхняя кнопка геймпада (`Y` на Xbox, `△` на PlayStation)
|
||||
- В Run After / Wrapper добавлена поддержка `%command%` для передачи команды игры обёртке, например `mako-launch %command%`, без повторного запуска игры
|
||||
- Добавлено отслеживание запуска Steam-игр на странице игры
|
||||
- Добавлен CLI для получения локальных данных библиотеки
|
||||
- Для Run After / Wrapper добавлен раскрываемый список с отдельным полем для каждой записи, удалением записей и кнопкой полной очистки
|
||||
@@ -46,12 +43,6 @@
|
||||
|
||||
### Fixed
|
||||
|
||||
- Обложки заполняют отведённую область без растягивания
|
||||
- Исправлена загрузка оценок времени прохождения с HowLongToBeat в карточках игр
|
||||
- При нажатии вниз на D-pad с верхней панели библиотеки фокус переходит на первую карточку верхнего ряда, а не перескакивает на нижние ряды
|
||||
- В карточках игр GOG отображается краткое описание без рекламы, баннеров и списков особенностей
|
||||
- Недокачанные JPEG-обложки больше не попадают в кэш
|
||||
- Исправлена фильтрация видеокарт DXVK и VKD3D при расхождении нативного имени GPU с именем Wine
|
||||
- Запросы установки других игр GOG и EGS во время получения списка DLC добавляются в очередь вместо ошибки «Другая загрузка уже выполняется»
|
||||
- Виртуальная мышь создаётся только при включении эмуляции геймпадом и удаляется при её выключении
|
||||
- При ошибке загрузки каталога WINE/Proton отображаются локально установленные версии
|
||||
@@ -80,7 +71,6 @@
|
||||
- @rogerio-mattos
|
||||
- @Rubin13
|
||||
- @iodnoorov
|
||||
- @gstkein
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
<p>
|
||||
<a href="https://github.com/linux-gaming-ru/PortProtonQt/releases"><img src="https://img.shields.io/github/v/release/linux-gaming-ru/PortProtonQt?style=flat-square&label=Release" alt="Releases"></a>
|
||||
<a href="https://github.com/linux-gaming-ru/PortProtonQt/releases"><img src="https://img.shields.io/badge/Downloads-18.9k-green?style=flat-square" alt="Total Downloads"></a>
|
||||
<a href="https://github.com/linux-gaming-ru/PortProtonQt/releases"><img src="https://img.shields.io/badge/Downloads-17.9k-green?style=flat-square" alt="Total Downloads"></a>
|
||||
<a href="LICENSE"><img src="https://img.shields.io/badge/License-GPL--3.0-blue?style=flat-square" alt="License: GPL-3.0"></a>
|
||||
<a href="pyproject.toml"><img src="https://img.shields.io/badge/Python-3.11%2B-blue?style=flat-square&logo=python" alt="Python 3.11+"></a>
|
||||
<a href="https://github.com/linux-gaming-ru/PortProtonQt"><img src="https://img.shields.io/badge/Platform-Linux-blue?style=flat-square&logo=linux" alt="Platform: Linux"></a>
|
||||
@@ -80,7 +80,7 @@ PortProtonQt uses code and dependencies from the following projects:
|
||||
- [heroic-gogdl](https://github.com/Heroic-Games-Launcher/heroic-gogdl) — GOG downloading module, [GPLv3](https://github.com/Heroic-Games-Launcher/heroic-gogdl/blob/main/LICENSE) license.
|
||||
- [Legendary](https://github.com/Heroic-Games-Launcher/legendary) — Epic Games launcher alternative, [GPLv3](https://github.com/Heroic-Games-Launcher/legendary/blob/master/LICENSE) license.
|
||||
- [pyte](https://github.com/selectel/pyte) — ANSI escape code parser, [LGPLv3](https://github.com/selectel/pyte?tab=LGPL-3.0-1-ov-file) license.
|
||||
- [gjs-osk](https://github.com/Vishram1123/gjs-osk) — source of the original virtual keyboard layout data and reference for the system keyboard's compact layout and modifier key handling, [GPLv3](https://github.com/Vishram1123/gjs-osk/blob/main/LICENSE) license.
|
||||
- [gjs-osk](https://github.com/Vishram1123/gjs-osk) — base for virtual keyboard layout data, GPLv3 license.
|
||||
- [omikuji](https://github.com/omikuji-launcher/omikuji) — inspiration and source material for the procedural detail page backgrounds, [GPLv3](https://github.com/omikuji-launcher/omikuji/blob/master/LICENSE) license.
|
||||
- [Bottles](https://github.com/bottlesdevs/Bottles) — source of the compatibility analysis rules, GPL-3.0-only license.
|
||||
|
||||
|
||||
+2
-2
@@ -9,7 +9,7 @@
|
||||
|
||||
<p>
|
||||
<a href="https://git.linux-gaming.ru/Linux-Gaming/PortProtonQt/releases"><img src="https://img.shields.io/github/v/release/linux-gaming-ru/PortProtonQt?style=flat-square&label=Релиз" alt="Релизы"></a>
|
||||
<a href="https://git.linux-gaming.ru/Linux-Gaming/PortProtonQt/releases"><img src="https://img.shields.io/badge/Загрузки-18.9k-green?style=flat-square" alt="Всего загрузок"></a>
|
||||
<a href="https://git.linux-gaming.ru/Linux-Gaming/PortProtonQt/releases"><img src="https://img.shields.io/badge/Загрузки-17.9k-green?style=flat-square" alt="Всего загрузок"></a>
|
||||
<a href="LICENSE"><img src="https://img.shields.io/badge/Лицензия-GPL--3.0-blue?style=flat-square" alt="Лицензия: GPL-3.0"></a>
|
||||
<a href="pyproject.toml"><img src="https://img.shields.io/badge/Python-3.11+-blue?style=flat-square&logo=python" alt="Python 3.11+"></a>
|
||||
<a href="https://git.linux-gaming.ru/Linux-Gaming/PortProtonQt"><img src="https://img.shields.io/badge/Платформа-Linux-blue?style=flat-square&logo=linux" alt="Платформа: Linux"></a>
|
||||
@@ -80,7 +80,7 @@ PortProtonQt использует код и зависимости от след
|
||||
- [heroic-gogdl](https://github.com/Heroic-Games-Launcher/heroic-gogdl) — модуль загрузки игр GOG, лицензия [GPLv3](https://github.com/Heroic-Games-Launcher/heroic-gogdl/blob/main/LICENSE).
|
||||
- [Legendary](https://github.com/Heroic-Games-Launcher/legendary) — альтернатива Epic Games Launcher, лицензия [GPLv3](https://github.com/Heroic-Games-Launcher/legendary/blob/master/LICENSE).
|
||||
- [pyte](https://github.com/selectel/pyte) — разбор ANSI escape-кодов, лицензия [LGPLv3](https://github.com/selectel/pyte?tab=LGPL-3.0-1-ov-file)
|
||||
- [gjs-osk](https://github.com/Vishram1123/gjs-osk) — источник исходных данных раскладок виртуальной клавиатуры и образец compact-компоновки системной клавиатуры и обработки клавиш-модификаторов, лицензия [GPLv3](https://github.com/Vishram1123/gjs-osk/blob/main/LICENSE).
|
||||
- [gjs-osk](https://github.com/Vishram1123/gjs-osk) — основа данных раскладок виртуальной клавиатуры, лицензия GPLv3.
|
||||
- [omikuji](https://github.com/omikuji-launcher/omikuji) — источник вдохновения и материалов для процедурных фонов детальной страницы, лицензия [GPLv3](https://github.com/omikuji-launcher/omikuji/blob/master/LICENSE).
|
||||
- [Bottles](https://github.com/bottlesdevs/Bottles) — источник правил анализа совместимости, лицензия GPL-3.0-only.
|
||||
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ arch=('x86_64')
|
||||
url="https://git.linux-gaming.ru/Linux-Gaming/PortProtonQt"
|
||||
license=('GPL-3.0')
|
||||
depends=('python-requests' 'python-babel' 'python-evdev' 'python-orjson'
|
||||
'python-psutil' 'python-tqdm' 'python-vdf' 'python-libarchive-c' 'pyside6' 'python-rapidfuzz' 'python-pefile' 'python-pillow' 'perl-image-exiftool' 'python-websocket-client' 'cabextract' 'unzip' 'curl' 'file' 'findutils' 'gawk' 'grep' 'tar' 'xz' 'zstd' 'gzip' 'unrar' 'qt6-svg' 'qt6-imageformats' 'qt6-multimedia' 'pciutils' 'mesa-utils' 'vulkan-icd-loader' 'procps-ng' 'psmisc' '7zip' 'python-dbus-fast' 'sdl3' 'desktop-file-utils' 'wayland' 'libx11' 'xkeyboard-config')
|
||||
'python-psutil' 'python-tqdm' 'python-vdf' 'python-libarchive-c' 'pyside6' 'python-rapidfuzz' 'python-pefile' 'python-pillow' 'perl-image-exiftool' 'python-websocket-client' 'cabextract' 'unzip' 'curl' 'file' 'findutils' 'gawk' 'grep' 'tar' 'xz' 'zstd' 'gzip' 'unrar' 'qt6-svg' 'qt6-imageformats' 'qt6-multimedia' 'pciutils' 'mesa-utils' 'vulkan-icd-loader' 'procps-ng' 'psmisc' '7zip' 'python-dbus-fast' 'sdl3' 'desktop-file-utils')
|
||||
makedepends=('meson' 'ninja' 'vulkan-headers' 'gettext' 'sdl3')
|
||||
conflicts=("portprotonqt-steam-compat")
|
||||
provides=('portprotonqt-steam-compat')
|
||||
|
||||
@@ -8,7 +8,7 @@ arch=('x86_64')
|
||||
url="https://git.linux-gaming.ru/Linux-Gaming/PortProtonQt"
|
||||
license=('GPL-3.0')
|
||||
depends=('python-requests' 'python-babel' 'python-evdev' 'python-orjson'
|
||||
'python-psutil' 'python-tqdm' 'python-vdf' 'python-libarchive-c' 'pyside6' 'python-rapidfuzz' 'python-pefile' 'python-pillow' 'perl-image-exiftool' 'python-websocket-client' 'cabextract' 'unzip' 'curl' 'file' 'findutils' 'gawk' 'grep' 'tar' 'xz' 'zstd' 'gzip' 'unrar' 'qt6-svg' 'qt6-imageformats' 'qt6-multimedia' 'pciutils' 'mesa-utils' 'vulkan-icd-loader' 'procps-ng' 'psmisc' '7zip' 'python-dbus-fast' 'sdl3' 'desktop-file-utils' 'wayland' 'libx11' 'xkeyboard-config')
|
||||
'python-psutil' 'python-tqdm' 'python-vdf' 'python-libarchive-c' 'pyside6' 'python-rapidfuzz' 'python-pefile' 'python-pillow' 'perl-image-exiftool' 'python-websocket-client' 'cabextract' 'unzip' 'curl' 'file' 'findutils' 'gawk' 'grep' 'tar' 'xz' 'zstd' 'gzip' 'unrar' 'qt6-svg' 'qt6-imageformats' 'qt6-multimedia' 'pciutils' 'mesa-utils' 'vulkan-icd-loader' 'procps-ng' 'psmisc' '7zip' 'python-dbus-fast' 'sdl3' 'desktop-file-utils')
|
||||
makedepends=('meson' 'ninja' 'vulkan-headers' 'gettext' 'sdl3')
|
||||
conflicts=("portprotonqt-steam-compat")
|
||||
provides=('portprotonqt-steam-compat')
|
||||
|
||||
Binary file not shown.
@@ -23,8 +23,6 @@ BuildRequires: gettext
|
||||
BuildRequires: systemd-rpm-macros
|
||||
BuildRequires: vulkan-loader-devel
|
||||
BuildRequires: pkgconfig(sdl3)
|
||||
BuildRequires: pkgconfig(wayland-client)
|
||||
BuildRequires: pkgconfig(x11)
|
||||
BuildRequires: gcc
|
||||
|
||||
Obsoletes: python3-%{pypi_name}-git < %{version}-%{release}
|
||||
@@ -68,7 +66,6 @@ Requires: psmisc
|
||||
Requires: 7zip
|
||||
Requires: python3-dbus-fast
|
||||
Requires: desktop-file-utils
|
||||
Requires: xkeyboard-config
|
||||
|
||||
# System Tab
|
||||
Recommends: NetworkManager
|
||||
|
||||
@@ -20,8 +20,6 @@ BuildRequires: gettext
|
||||
BuildRequires: systemd-rpm-macros
|
||||
BuildRequires: vulkan-loader-devel
|
||||
BuildRequires: pkgconfig(sdl3)
|
||||
BuildRequires: pkgconfig(wayland-client)
|
||||
BuildRequires: pkgconfig(x11)
|
||||
BuildRequires: gcc
|
||||
|
||||
Obsoletes: python3-%{pypi_name} < %{version}-%{release}
|
||||
@@ -65,7 +63,6 @@ Requires: psmisc
|
||||
Requires: 7zip
|
||||
Requires: python3-dbus-fast
|
||||
Requires: desktop-file-utils
|
||||
Requires: xkeyboard-config
|
||||
|
||||
# System Tab
|
||||
Recommends: NetworkManager
|
||||
|
||||
Binary file not shown.
@@ -2008,37 +2008,6 @@ pw_init_db () {
|
||||
return 0
|
||||
}
|
||||
|
||||
pw_select_gpu () {
|
||||
[[ -n "${PW_GPU_USE}" && "${PW_GPU_USE}" != "disabled" ]] || return 0
|
||||
local vk_gpu_info_cmd vk_info_output line current_device_name="" filter_name="${PW_GPU_USE}"
|
||||
vk_gpu_info_cmd="$(dirname "${BASH_SOURCE[0]}")/../../../bin/vk_gpu_info"
|
||||
if [[ ! -x "${vk_gpu_info_cmd}" ]] ; then
|
||||
vk_gpu_info_cmd="$(command -v vk_gpu_info 2>/dev/null || true)"
|
||||
fi
|
||||
if [[ -n "${vk_gpu_info_cmd}" ]] ; then
|
||||
if vk_info_output="$("${vk_gpu_info_cmd}" 2>/dev/null)" ; then
|
||||
while IFS= read -r line ; do
|
||||
case "$line" in
|
||||
"GPU #"*) current_device_name="" ;;
|
||||
"device_name: "*) current_device_name="${line#device_name: }" ;;
|
||||
"wine_device_name: "*)
|
||||
if [[ "${current_device_name}" == "${PW_GPU_USE}" && -n "${line#wine_device_name: }" ]] ; then
|
||||
filter_name="${line#wine_device_name: }"
|
||||
break
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done <<< "${vk_info_output}"
|
||||
else
|
||||
print_warning "vk_gpu_info failed; using the native GPU name for device filters."
|
||||
fi
|
||||
fi
|
||||
[[ -v DXVK_FILTER_DEVICE_NAME ]] || export DXVK_FILTER_DEVICE_NAME="${filter_name}"
|
||||
[[ -v VKD3D_FILTER_DEVICE_NAME ]] || export VKD3D_FILTER_DEVICE_NAME="${filter_name}"
|
||||
export MESA_VK_DEVICE_SELECT_FORCE_DEFAULT_DEVICE="1"
|
||||
export MESA_VK_DEVICE_SELECT="$PW_vendorID:$PW_deviceID"
|
||||
}
|
||||
|
||||
pw_check_vulkan_extensions () {
|
||||
local ext_name="$1"
|
||||
local ext_key
|
||||
@@ -3043,7 +3012,12 @@ start_portproton () {
|
||||
|
||||
[[ "${PW_VKBASALT_USER_CONF}" == 1 ]] && pw_select_vkbasalt_user_conf
|
||||
|
||||
pw_select_gpu
|
||||
if [[ $PW_GPU_USE != "disabled" ]] ; then
|
||||
export DXVK_FILTER_DEVICE_NAME="$PW_GPU_USE"
|
||||
export VKD3D_FILTER_DEVICE_NAME="$PW_GPU_USE"
|
||||
export MESA_VK_DEVICE_SELECT_FORCE_DEFAULT_DEVICE="1"
|
||||
export MESA_VK_DEVICE_SELECT="$PW_vendorID:$PW_deviceID"
|
||||
fi
|
||||
|
||||
if [[ -f "$PATH_TO_GAME/dxvk.conf" ]] ; then
|
||||
export DXVK_CONFIG_FILE="$PATH_TO_GAME/dxvk.conf"
|
||||
@@ -3823,6 +3797,10 @@ start_portproton () {
|
||||
*) get_and_set_reg_file --delete 'Software\Wine\Drivers' 'Audio' ;;
|
||||
esac
|
||||
|
||||
if [[ -n "${PW_NETWORK_BLOCKLIST:-}" ]] ; then
|
||||
export PW_LD_PRELOAD="${PW_LD_PRELOAD:+${PW_LD_PRELOAD}:}libppqt-network-filter.so"
|
||||
fi
|
||||
|
||||
add_in_start_portproton
|
||||
|
||||
local steam_emu_language=""
|
||||
@@ -4064,22 +4042,6 @@ pw_launch_wrapper () {
|
||||
return
|
||||
fi
|
||||
|
||||
local wrapper_arg
|
||||
local -a launch_cmd=()
|
||||
local wrapper_command_seen=0
|
||||
for wrapper_arg in "${wrapper_cmd[@]}" ; do
|
||||
if [[ "$wrapper_arg" == '%command%' ]] ; then
|
||||
launch_cmd+=("$@")
|
||||
wrapper_command_seen=1
|
||||
else
|
||||
launch_cmd+=("$wrapper_arg")
|
||||
fi
|
||||
done
|
||||
if [[ "$wrapper_command_seen" == 1 ]] ; then
|
||||
"${launch_cmd[@]}"
|
||||
return
|
||||
fi
|
||||
|
||||
if [[ "${wrapper_cmd[0]##*/}" == "systemd-run" ]] ; then
|
||||
"${wrapper_cmd[@]}" -- "$@"
|
||||
return
|
||||
|
||||
@@ -1,224 +0,0 @@
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/XKBlib.h>
|
||||
#include <string.h>
|
||||
#include <wayland-client.h>
|
||||
|
||||
struct wl_display *portproton_keyboard_wayland_connect(const char *name)
|
||||
{
|
||||
return wl_display_connect(name);
|
||||
}
|
||||
|
||||
Display *portproton_keyboard_x11_open_display(const char *name)
|
||||
{
|
||||
Display *display = XOpenDisplay(name);
|
||||
if (display)
|
||||
XkbSelectEvents(display, XkbUseCoreKbd,
|
||||
XkbMapNotifyMask | XkbNewKeyboardNotifyMask,
|
||||
XkbMapNotifyMask | XkbNewKeyboardNotifyMask);
|
||||
return display;
|
||||
}
|
||||
|
||||
static int keyboard_group_name(Display *display, unsigned int group,
|
||||
char *buffer, size_t size)
|
||||
{
|
||||
XkbDescPtr keyboard = XkbGetMap(display, 0, XkbUseCoreKbd);
|
||||
int found = 0;
|
||||
if (!keyboard)
|
||||
return 0;
|
||||
if (XkbGetNames(display, XkbGroupNamesMask, keyboard) == Success &&
|
||||
keyboard->names && group < XkbNumKbdGroups && keyboard->names->groups[group]) {
|
||||
char *name = XGetAtomName(display, keyboard->names->groups[group]);
|
||||
if (name) {
|
||||
size_t length = strlen(name);
|
||||
found = length > 0 && length < size;
|
||||
if (found)
|
||||
memcpy(buffer, name, length + 1);
|
||||
XFree(name);
|
||||
}
|
||||
}
|
||||
XkbFreeKeyboard(keyboard, XkbAllComponentsMask, True);
|
||||
return found;
|
||||
}
|
||||
|
||||
int portproton_keyboard_x11_layout_name(Display *display, unsigned int group,
|
||||
char *buffer, size_t size)
|
||||
{
|
||||
const long property_length = 1024;
|
||||
Atom property = XInternAtom(display, "_XKB_RULES_NAMES", True);
|
||||
Atom type;
|
||||
int format;
|
||||
unsigned long length, remaining;
|
||||
unsigned char *data = NULL;
|
||||
if (!buffer || size == 0)
|
||||
return 0;
|
||||
if (!property)
|
||||
return keyboard_group_name(display, group, buffer, size);
|
||||
if (XGetWindowProperty(display, DefaultRootWindow(display), property, 0,
|
||||
property_length, False, XA_STRING, &type, &format,
|
||||
&length, &remaining, &data) != Success || !data)
|
||||
return keyboard_group_name(display, group, buffer, size);
|
||||
char *start = (char *)data;
|
||||
char *end = start + length;
|
||||
for (unsigned int field = 0; field < 2 && start < end; ++field) {
|
||||
char *separator = memchr(start, '\0', (size_t)(end - start));
|
||||
start = separator ? separator + 1 : end;
|
||||
}
|
||||
char *layouts_end = memchr(start, '\0', (size_t)(end - start));
|
||||
if (!layouts_end)
|
||||
layouts_end = end;
|
||||
for (unsigned int index = 0; index < group && start < layouts_end; ++index) {
|
||||
char *separator = memchr(start, ',', (size_t)(layouts_end - start));
|
||||
start = separator ? separator + 1 : layouts_end;
|
||||
}
|
||||
char *separator = memchr(start, ',', (size_t)(layouts_end - start));
|
||||
size_t count = (size_t)((separator ? separator : layouts_end) - start);
|
||||
int found = format == 8 && count > 0 && count < size;
|
||||
if (found) {
|
||||
memcpy(buffer, start, count);
|
||||
buffer[count] = '\0';
|
||||
}
|
||||
XFree(data);
|
||||
return found || keyboard_group_name(display, group, buffer, size);
|
||||
}
|
||||
int portproton_keyboard_x11_state(Display *display, unsigned int *values)
|
||||
{
|
||||
XkbStateRec state;
|
||||
int opcode, event_base, error_base;
|
||||
int major = XkbMajorVersion, minor = XkbMinorVersion;
|
||||
if (!XkbQueryExtension(display, &opcode, &event_base, &error_base, &major, &minor))
|
||||
return 0;
|
||||
/* Reading XKB events also invalidates Xlib's cached keyboard map. */
|
||||
while (XPending(display)) {
|
||||
XkbEvent event;
|
||||
XNextEvent(display, &event.core);
|
||||
if (event.type == MappingNotify)
|
||||
XRefreshKeyboardMapping(&event.core.xmapping);
|
||||
else if (event.type == event_base && event.any.xkb_type == XkbMapNotify)
|
||||
XkbRefreshKeyboardMapping(&event.map);
|
||||
}
|
||||
if (XkbGetState(display, XkbUseCoreKbd, &state) != Success)
|
||||
return 0;
|
||||
values[0] = state.group;
|
||||
values[1] = state.mods;
|
||||
values[2] = state.locked_mods;
|
||||
return 1;
|
||||
}
|
||||
|
||||
unsigned int portproton_keyboard_x11_keysym(Display *display, unsigned int code,
|
||||
unsigned int mask)
|
||||
{
|
||||
unsigned int consumed;
|
||||
KeySym symbol;
|
||||
if (!XkbLookupKeySym(display, code, mask, &consumed, &symbol))
|
||||
return 0;
|
||||
return (unsigned int)symbol;
|
||||
}
|
||||
|
||||
static const struct wl_message keyboard_group_requests[] = {
|
||||
{"set_group", "u", NULL}, {"destroy", "", NULL}
|
||||
};
|
||||
static const struct wl_message keyboard_group_events[] = {{"group", "u", NULL}};
|
||||
static const struct wl_interface keyboard_group_interface = {
|
||||
"zcosmic_keyboard_layout_v1", 1, 2, keyboard_group_requests, 1, keyboard_group_events
|
||||
};
|
||||
static const struct wl_interface *keyboard_manager_types[] = {
|
||||
&keyboard_group_interface, &wl_keyboard_interface
|
||||
};
|
||||
static const struct wl_message keyboard_manager_requests[] = {
|
||||
{"get_keyboard_layout", "no", keyboard_manager_types}, {"destroy", "", NULL}
|
||||
};
|
||||
static const struct wl_interface keyboard_manager_interface = {
|
||||
"zcosmic_keyboard_layout_manager_v1", 1, 2, keyboard_manager_requests, 0, NULL
|
||||
};
|
||||
|
||||
static const struct wl_message keyboard_layer_requests[] = {
|
||||
{"set_size", "uu", NULL}, {"set_anchor", "u", NULL},
|
||||
{"set_exclusive_zone", "i", NULL}, {"set_margin", "iiii", NULL},
|
||||
{"set_keyboard_interactivity", "u", NULL}, {"get_popup", "o", NULL},
|
||||
{"ack_configure", "u", NULL}, {"destroy", "", NULL}
|
||||
};
|
||||
static const struct wl_message keyboard_layer_events[] = {
|
||||
{"configure", "uuu", NULL}, {"closed", "", NULL}
|
||||
};
|
||||
static const struct wl_interface keyboard_layer_interface = {
|
||||
"zwlr_layer_surface_v1", 1, 8, keyboard_layer_requests, 2, keyboard_layer_events
|
||||
};
|
||||
static const struct wl_interface *keyboard_shell_types[] = {
|
||||
&keyboard_layer_interface, &wl_surface_interface, &wl_output_interface, NULL, NULL
|
||||
};
|
||||
static const struct wl_message keyboard_shell_requests[] = {
|
||||
{"get_layer_surface", "no?ous", keyboard_shell_types}
|
||||
};
|
||||
static const struct wl_interface keyboard_shell_interface = {
|
||||
"zwlr_layer_shell_v1", 1, 1, keyboard_shell_requests, 0, NULL
|
||||
};
|
||||
|
||||
const struct wl_interface *portproton_keyboard_wayland_interface(const char *name)
|
||||
{
|
||||
const struct wl_interface *interfaces[] = {
|
||||
&wl_registry_interface, &wl_seat_interface, &wl_keyboard_interface,
|
||||
&keyboard_group_interface, &keyboard_manager_interface,
|
||||
&wl_callback_interface, &wl_compositor_interface, &wl_shm_interface,
|
||||
&wl_surface_interface, &wl_output_interface, &wl_region_interface,
|
||||
&wl_shm_pool_interface, &wl_buffer_interface, &wl_pointer_interface,
|
||||
&wl_touch_interface, &keyboard_layer_interface, &keyboard_shell_interface
|
||||
};
|
||||
for (size_t index = 0; index < sizeof(interfaces) / sizeof(interfaces[0]); ++index) {
|
||||
if (strcmp(name, interfaces[index]->name) == 0)
|
||||
return interfaces[index];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
enum keyboard_probe_global {
|
||||
KEYBOARD_PROBE_COMPOSITOR,
|
||||
KEYBOARD_PROBE_SHM,
|
||||
KEYBOARD_PROBE_LAYER_SHELL,
|
||||
KEYBOARD_PROBE_GLOBAL_COUNT
|
||||
};
|
||||
|
||||
static void keyboard_probe_global(void *data, struct wl_registry *registry,
|
||||
uint32_t name, const char *interface, uint32_t version)
|
||||
{
|
||||
uint32_t *globals = data;
|
||||
const char *required[] = {"wl_compositor", "wl_shm", "zwlr_layer_shell_v1"};
|
||||
(void)registry;
|
||||
(void)version;
|
||||
for (size_t index = 0; index < sizeof(required) / sizeof(required[0]); ++index) {
|
||||
if (strcmp(interface, required[index]) == 0)
|
||||
globals[index] = name;
|
||||
}
|
||||
}
|
||||
|
||||
static void keyboard_probe_removed(void *data, struct wl_registry *registry, uint32_t name)
|
||||
{
|
||||
uint32_t *globals = data;
|
||||
(void)registry;
|
||||
for (size_t index = 0; index < KEYBOARD_PROBE_GLOBAL_COUNT; ++index) {
|
||||
if (globals[index] == name)
|
||||
globals[index] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int portproton_keyboard_has_layer_shell(void)
|
||||
{
|
||||
struct wl_display *display = wl_display_connect(NULL);
|
||||
if (!display)
|
||||
return 0;
|
||||
uint32_t globals[KEYBOARD_PROBE_GLOBAL_COUNT] = {0};
|
||||
const struct wl_registry_listener listener = {
|
||||
.global = keyboard_probe_global, .global_remove = keyboard_probe_removed
|
||||
};
|
||||
struct wl_registry *registry = wl_display_get_registry(display);
|
||||
if (!registry) {
|
||||
wl_display_disconnect(display);
|
||||
return 0;
|
||||
}
|
||||
int ready = wl_registry_add_listener(registry, &listener, globals) == 0 &&
|
||||
wl_display_roundtrip(display) >= 0;
|
||||
wl_registry_destroy(registry);
|
||||
wl_display_disconnect(display);
|
||||
return ready && globals[KEYBOARD_PROBE_COMPOSITOR] &&
|
||||
globals[KEYBOARD_PROBE_SHM] && globals[KEYBOARD_PROBE_LAYER_SHELL];
|
||||
}
|
||||
@@ -2,7 +2,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <vulkan/vulkan.h>
|
||||
#include "wine_gpu_names.h"
|
||||
|
||||
typedef struct {
|
||||
uint32_t vendor_id;
|
||||
@@ -276,7 +275,6 @@ int main() {
|
||||
printf("vendor_id: 0x%04x\n", props.vendorID);
|
||||
printf("device_id: 0x%04x\n", props.deviceID);
|
||||
printf("device_name: %s\n", device_name);
|
||||
printf("wine_device_name: %s\n", wine_device_name(props.vendorID, props.deviceID, device_name));
|
||||
printf("driver_name: %s\n", driver_name);
|
||||
printf("driver_info: %s\n", driver_info);
|
||||
printf("api_version: %u.%u.%u\n",
|
||||
|
||||
@@ -1,371 +0,0 @@
|
||||
/*
|
||||
* GPU names derived from Wine gpu_device_name()
|
||||
*
|
||||
* Copyright 1994 Alexandre Julliard
|
||||
* Copyright 2019 Zhiyi Zhang for CodeWeavers
|
||||
* Copyright 2021 Jacek Caban for CodeWeavers
|
||||
*
|
||||
* Adapted from LGPL-2.1-or-later Wine code under section 3 of LGPL-2.1.
|
||||
* This adaptation is licensed under GPL-3.0.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 3 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// Source: wine-mirror/wine, dlls/win32u/sysparams.c
|
||||
// Revision: 9f8c4ae4d35c7ff4153267aba9618c026f5f5583
|
||||
#ifndef WINE_GPU_NAMES_H
|
||||
#define WINE_GPU_NAMES_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
static const struct {
|
||||
uint32_t vendor_id;
|
||||
uint32_t device_id;
|
||||
const char *name;
|
||||
} wine_gpu_names[] = {
|
||||
{0x10de, 0x0018, "NVIDIA RIVA 128"},
|
||||
{0x10de, 0x0020, "NVIDIA RIVA TNT"},
|
||||
{0x10de, 0x0028, "NVIDIA RIVA TNT2/TNT2 Pro"},
|
||||
{0x10de, 0x0100, "NVIDIA GeForce 256"},
|
||||
{0x10de, 0x0150, "NVIDIA GeForce2 GTS/GeForce2 Pro"},
|
||||
{0x10de, 0x0110, "NVIDIA GeForce2 MX/MX 400"},
|
||||
{0x10de, 0x0200, "NVIDIA GeForce3"},
|
||||
{0x10de, 0x0170, "NVIDIA GeForce4 MX 460"},
|
||||
{0x10de, 0x0253, "NVIDIA GeForce4 Ti 4200"},
|
||||
{0x10de, 0x0320, "NVIDIA GeForce FX 5200"},
|
||||
{0x10de, 0x0312, "NVIDIA GeForce FX 5600"},
|
||||
{0x10de, 0x0302, "NVIDIA GeForce FX 5800"},
|
||||
{0x10de, 0x014f, "NVIDIA GeForce 6200"},
|
||||
{0x10de, 0x0140, "NVIDIA GeForce 6600 GT"},
|
||||
{0x10de, 0x0041, "NVIDIA GeForce 6800"},
|
||||
{0x10de, 0x01d7, "NVIDIA GeForce Go 7300"},
|
||||
{0x10de, 0x01d8, "NVIDIA GeForce Go 7400"},
|
||||
{0x10de, 0x0391, "NVIDIA GeForce 7600 GT"},
|
||||
{0x10de, 0x0092, "NVIDIA GeForce 7800 GT"},
|
||||
{0x10de, 0x0849, "NVIDIA GeForce 8200"},
|
||||
{0x10de, 0x084b, "NVIDIA GeForce 8200"},
|
||||
{0x10de, 0x0423, "NVIDIA GeForce 8300 GS"},
|
||||
{0x10de, 0x0404, "NVIDIA GeForce 8400 GS"},
|
||||
{0x10de, 0x0421, "NVIDIA GeForce 8500 GT"},
|
||||
{0x10de, 0x0402, "NVIDIA GeForce 8600 GT"},
|
||||
{0x10de, 0x0407, "NVIDIA GeForce 8600M GT"},
|
||||
{0x10de, 0x0193, "NVIDIA GeForce 8800 GTS"},
|
||||
{0x10de, 0x0191, "NVIDIA GeForce 8800 GTX"},
|
||||
{0x10de, 0x086d, "NVIDIA GeForce 9200"},
|
||||
{0x10de, 0x086c, "NVIDIA GeForce 9300"},
|
||||
{0x10de, 0x0863, "NVIDIA GeForce 9400M"},
|
||||
{0x10de, 0x042c, "NVIDIA GeForce 9400 GT"},
|
||||
{0x10de, 0x0640, "NVIDIA GeForce 9500 GT"},
|
||||
{0x10de, 0x0622, "NVIDIA GeForce 9600 GT"},
|
||||
{0x10de, 0x064a, "NVIDIA GeForce 9700M GT"},
|
||||
{0x10de, 0x0614, "NVIDIA GeForce 9800 GT"},
|
||||
{0x10de, 0x0a23, "NVIDIA GeForce 210"},
|
||||
{0x10de, 0x0a20, "NVIDIA GeForce GT 220"},
|
||||
{0x10de, 0x0ca3, "NVIDIA GeForce GT 240"},
|
||||
{0x10de, 0x0615, "NVIDIA GeForce GTS 250"},
|
||||
{0x10de, 0x05e2, "NVIDIA GeForce GTX 260"},
|
||||
{0x10de, 0x05e6, "NVIDIA GeForce GTX 275"},
|
||||
{0x10de, 0x05e1, "NVIDIA GeForce GTX 280"},
|
||||
{0x10de, 0x0a7a, "NVIDIA GeForce 315M"},
|
||||
{0x10de, 0x08a3, "NVIDIA GeForce 320M"},
|
||||
{0x10de, 0x0a2d, "NVIDIA GeForce GT 320M"},
|
||||
{0x10de, 0x0a35, "NVIDIA GeForce GT 325M"},
|
||||
{0x10de, 0x0ca0, "NVIDIA GeForce GT 330"},
|
||||
{0x10de, 0x0cb0, "NVIDIA GeForce GTS 350M"},
|
||||
{0x10de, 0x1055, "NVIDIA GeForce 410M"},
|
||||
{0x10de, 0x0de2, "NVIDIA GeForce GT 420"},
|
||||
{0x10de, 0x0df0, "NVIDIA GeForce GT 425M"},
|
||||
{0x10de, 0x0de1, "NVIDIA GeForce GT 430"},
|
||||
{0x10de, 0x0de0, "NVIDIA GeForce GT 440"},
|
||||
{0x10de, 0x0dc4, "NVIDIA GeForce GTS 450"},
|
||||
{0x10de, 0x0e22, "NVIDIA GeForce GTX 460"},
|
||||
{0x10de, 0x0dd1, "NVIDIA GeForce GTX 460M"},
|
||||
{0x10de, 0x06c4, "NVIDIA GeForce GTX 465"},
|
||||
{0x10de, 0x06cd, "NVIDIA GeForce GTX 470"},
|
||||
{0x10de, 0x06c0, "NVIDIA GeForce GTX 480"},
|
||||
{0x10de, 0x1040, "NVIDIA GeForce GT 520"},
|
||||
{0x10de, 0x0dec, "NVIDIA GeForce GT 525M"},
|
||||
{0x10de, 0x0df4, "NVIDIA GeForce GT 540M"},
|
||||
{0x10de, 0x1244, "NVIDIA GeForce GTX 550 Ti"},
|
||||
{0x10de, 0x04b8, "NVIDIA GeForce GT 555M"},
|
||||
{0x10de, 0x1200, "NVIDIA GeForce GTX 560 Ti"},
|
||||
{0x10de, 0x1251, "NVIDIA GeForce GTX 560M"},
|
||||
{0x10de, 0x1201, "NVIDIA GeForce GTX 560"},
|
||||
{0x10de, 0x1081, "NVIDIA GeForce GTX 570"},
|
||||
{0x10de, 0x1080, "NVIDIA GeForce GTX 580"},
|
||||
{0x10de, 0x104a, "NVIDIA GeForce GT 610"},
|
||||
{0x10de, 0x0f00, "NVIDIA GeForce GT 630"},
|
||||
{0x10de, 0x0de9, "NVIDIA GeForce GT 630M"},
|
||||
{0x10de, 0x0fc1, "NVIDIA GeForce GT 640"},
|
||||
{0x10de, 0x0fd2, "NVIDIA GeForce GT 640M"},
|
||||
{0x10de, 0x0fd1, "NVIDIA GeForce GT 650M"},
|
||||
{0x10de, 0x0fc6, "NVIDIA GeForce GTX 650"},
|
||||
{0x10de, 0x11c6, "NVIDIA GeForce GTX 650 Ti"},
|
||||
{0x10de, 0x11c0, "NVIDIA GeForce GTX 660"},
|
||||
{0x10de, 0x0fd4, "NVIDIA GeForce GTX 660M"},
|
||||
{0x10de, 0x1183, "NVIDIA GeForce GTX 660 Ti"},
|
||||
{0x10de, 0x1189, "NVIDIA GeForce GTX 670"},
|
||||
{0x10de, 0x11a1, "NVIDIA GeForce GTX 670MX"},
|
||||
{0x10de, 0x11a7, "NVIDIA GeForce GTX 675MX"},
|
||||
{0x10de, 0x11a2, "NVIDIA GeForce GTX 675MX"},
|
||||
{0x10de, 0x1180, "NVIDIA GeForce GTX 680"},
|
||||
{0x10de, 0x1188, "NVIDIA GeForce GTX 690"},
|
||||
{0x10de, 0x128b, "NVIDIA GeForce GT 720"},
|
||||
{0x10de, 0x1287, "NVIDIA GeForce GT 730"},
|
||||
{0x10de, 0x0fe1, "NVIDIA GeForce GT 730M"},
|
||||
{0x10de, 0x1292, "NVIDIA GeForce GT 740M"},
|
||||
{0x10de, 0x0fe9, "NVIDIA GeForce GT 750M"},
|
||||
{0x10de, 0x0fcd, "NVIDIA GeForce GT 755M"},
|
||||
{0x10de, 0x1381, "NVIDIA GeForce GTX 750"},
|
||||
{0x10de, 0x1380, "NVIDIA GeForce GTX 750 Ti"},
|
||||
{0x10de, 0x1187, "NVIDIA GeForce GTX 760"},
|
||||
{0x10de, 0x1193, "NVIDIA GeForce GTX 760 Ti"},
|
||||
{0x10de, 0x11e2, "NVIDIA GeForce GTX 765M"},
|
||||
{0x10de, 0x11e0, "NVIDIA GeForce GTX 770M"},
|
||||
{0x10de, 0x1184, "NVIDIA GeForce GTX 770"},
|
||||
{0x10de, 0x119d, "NVIDIA GeForce GTX 775M"},
|
||||
{0x10de, 0x1004, "NVIDIA GeForce GTX 780"},
|
||||
{0x10de, 0x119e, "NVIDIA GeForce GTX 780M"},
|
||||
{0x10de, 0x100a, "NVIDIA GeForce GTX 780 Ti"},
|
||||
{0x10de, 0x1005, "NVIDIA GeForce GTX TITAN"},
|
||||
{0x10de, 0x100c, "NVIDIA GeForce GTX TITAN Black"},
|
||||
{0x10de, 0x17c2, "NVIDIA GeForce GTX TITAN X"},
|
||||
{0x10de, 0x1001, "NVIDIA GeForce GTX TITAN Z"},
|
||||
{0x10de, 0x0fed, "NVIDIA GeForce 820M"},
|
||||
{0x10de, 0x1340, "NVIDIA GeForce 830M"},
|
||||
{0x10de, 0x1341, "NVIDIA GeForce 840M"},
|
||||
{0x10de, 0x1344, "NVIDIA GeForce 845M"},
|
||||
{0x10de, 0x1391, "NVIDIA GeForce GTX 850M"},
|
||||
{0x10de, 0x1392, "NVIDIA GeForce GTX 860M"},
|
||||
{0x10de, 0x119a, "NVIDIA GeForce GTX 860M"},
|
||||
{0x10de, 0x1199, "NVIDIA GeForce GTX 870M"},
|
||||
{0x10de, 0x1198, "NVIDIA GeForce GTX 880M"},
|
||||
{0x10de, 0x1347, "NVIDIA GeForce 940M"},
|
||||
{0x10de, 0x1402, "NVIDIA GeForce GTX 950"},
|
||||
{0x10de, 0x139a, "NVIDIA GeForce GTX 950M"},
|
||||
{0x10de, 0x1401, "NVIDIA GeForce GTX 960"},
|
||||
{0x10de, 0x139b, "NVIDIA GeForce GTX 960M"},
|
||||
{0x10de, 0x13c2, "NVIDIA GeForce GTX 970"},
|
||||
{0x10de, 0x13d8, "NVIDIA GeForce GTX 970M"},
|
||||
{0x10de, 0x13c0, "NVIDIA GeForce GTX 980"},
|
||||
{0x10de, 0x17c8, "NVIDIA GeForce GTX 980 Ti"},
|
||||
{0x10de, 0x1d01, "NVIDIA GeForce GT 1030"},
|
||||
{0x10de, 0x1c81, "NVIDIA GeForce GTX 1050"},
|
||||
{0x10de, 0x1c82, "NVIDIA GeForce GTX 1050 Ti"},
|
||||
{0x10de, 0x1c02, "NVIDIA GeForce GTX 1060 3GB"},
|
||||
{0x10de, 0x1c03, "NVIDIA GeForce GTX 1060"},
|
||||
{0x10de, 0x1c20, "NVIDIA GeForce GTX 1060M"},
|
||||
{0x10de, 0x1b81, "NVIDIA GeForce GTX 1070"},
|
||||
{0x10de, 0x1be1, "NVIDIA GeForce GTX 1070M"},
|
||||
{0x10de, 0x1b80, "NVIDIA GeForce GTX 1080"},
|
||||
{0x10de, 0x1be0, "NVIDIA GeForce GTX 1080M"},
|
||||
{0x10de, 0x1b06, "NVIDIA GeForce GTX 1080 Ti"},
|
||||
{0x10de, 0x1b00, "NVIDIA TITAN X (Pascal)"},
|
||||
{0x10de, 0x1d81, "NVIDIA TITAN V"},
|
||||
{0x10de, 0x1f82, "NVIDIA GeForce GTX 1650"},
|
||||
{0x10de, 0x2187, "NVIDIA GeForce GTX 1650 SUPER"},
|
||||
{0x10de, 0x21c4, "NVIDIA GeForce GTX 1660 SUPER"},
|
||||
{0x10de, 0x2182, "NVIDIA GeForce GTX 1660 Ti"},
|
||||
{0x10de, 0x1f08, "NVIDIA GeForce RTX 2060"},
|
||||
{0x10de, 0x1f07, "NVIDIA GeForce RTX 2070"},
|
||||
{0x10de, 0x1e87, "NVIDIA GeForce RTX 2080"},
|
||||
{0x10de, 0x1e07, "NVIDIA GeForce RTX 2080 Ti"},
|
||||
{0x10de, 0x2507, "NVIDIA GeForce RTX 3050"},
|
||||
{0x10de, 0x2544, "NVIDIA GeForce RTX 3060"},
|
||||
{0x10de, 0x2504, "NVIDIA GeForce RTX 3060 (Low Hash Rate)"},
|
||||
{0x10de, 0x2414, "NVIDIA GeForce RTX 3060 Ti (GA103)"},
|
||||
{0x10de, 0x2486, "NVIDIA GeForce RTX 3060 Ti (GA104)"},
|
||||
{0x10de, 0x2489, "NVIDIA GeForce RTX 3060 Ti (GA104, Low Hash Rate)"},
|
||||
{0x10de, 0x2484, "NVIDIA GeForce RTX 3070"},
|
||||
{0x10de, 0x2488, "NVIDIA GeForce RTX 3070 (Low Hash Rate)"},
|
||||
{0x10de, 0x249d, "NVIDIA GeForce RTX 3070 (mobile)"},
|
||||
{0x10de, 0x2482, "NVIDIA GeForce RTX 3070 Ti"},
|
||||
{0x10de, 0x2206, "NVIDIA GeForce RTX 3080 10GB"},
|
||||
{0x10de, 0x2216, "NVIDIA GeForce RTX 3080 10GB (Low Hash Rate)"},
|
||||
{0x10de, 0x220a, "NVIDIA GeForce RTX 3080 12GB"},
|
||||
{0x10de, 0x2208, "NVIDIA GeForce RTX 3080 Ti"},
|
||||
{0x10de, 0x2204, "NVIDIA GeForce RTX 3090"},
|
||||
{0x10de, 0x2203, "NVIDIA GeForce RTX 3090 Ti"},
|
||||
{0x10de, 0x1eb8, "NVIDIA Tesla T4"},
|
||||
{0x10de, 0x2236, "NVIDIA Ampere A10"},
|
||||
{0x10de, 0x2882, "NVIDIA GeForce RTX 4060"},
|
||||
{0x10de, 0x28a0, "NVIDIA GeForce RTX 4060M"},
|
||||
{0x10de, 0x2803, "NVIDIA GeForce RTX 4060 Ti 8GB"},
|
||||
{0x10de, 0x2805, "NVIDIA GeForce RTX 4060 Ti 16GB"},
|
||||
{0x10de, 0x2786, "NVIDIA GeForce RTX 4070"},
|
||||
{0x10de, 0x2783, "NVIDIA GeForce RTX 4070 SUPER"},
|
||||
{0x10de, 0x2782, "NVIDIA GeForce RTX 4070 Ti"},
|
||||
{0x10de, 0x2705, "NVIDIA GeForce RTX 4070 Ti SUPER"},
|
||||
{0x10de, 0x2704, "NVIDIA GeForce RTX 4080"},
|
||||
{0x10de, 0x2702, "NVIDIA GeForce RTX 4080 SUPER"},
|
||||
{0x10de, 0x2684, "NVIDIA GeForce RTX 4090"},
|
||||
{0x1002, 0x5246, "ATI Rage Fury"},
|
||||
{0x1002, 0x5144, "ATI RADEON 7200 SERIES"},
|
||||
{0x1002, 0x514c, "ATI RADEON 8500 SERIES"},
|
||||
{0x1002, 0x4144, "ATI Radeon 9500"},
|
||||
{0x1002, 0x5955, "ATI RADEON XPRESS 200M Series"},
|
||||
{0x1002, 0x5e4c, "ATI Radeon X700 SE"},
|
||||
{0x1002, 0x71c2, "ATI Radeon X1600 Series"},
|
||||
{0x1002, 0x94c7, "ATI Mobility Radeon HD 2350"},
|
||||
{0x1002, 0x9581, "ATI Mobility Radeon HD 2600"},
|
||||
{0x1002, 0x9400, "ATI Radeon HD 2900 XT"},
|
||||
{0x1002, 0x9620, "ATI Radeon HD 3200 Graphics"},
|
||||
{0x1002, 0x9515, "ATI Radeon HD 3850 AGP"},
|
||||
{0x1002, 0x9712, "ATI Mobility Radeon HD 4200"},
|
||||
{0x1002, 0x954f, "ATI Radeon HD 4350"},
|
||||
{0x1002, 0x9495, "ATI Radeon HD 4600 Series"},
|
||||
{0x1002, 0x944e, "ATI Radeon HD 4700 Series"},
|
||||
{0x1002, 0x944c, "ATI Radeon HD 4800 Series"},
|
||||
{0x1002, 0x68f9, "ATI Radeon HD 5400 Series"},
|
||||
{0x1002, 0x68d8, "ATI Radeon HD 5600 Series"},
|
||||
{0x1002, 0x68be, "ATI Radeon HD 5700 Series"},
|
||||
{0x1002, 0x6898, "ATI Radeon HD 5800 Series"},
|
||||
{0x1002, 0x689c, "ATI Radeon HD 5900 Series"},
|
||||
{0x1002, 0x9803, "AMD Radeon HD 6300 series Graphics"},
|
||||
{0x1002, 0x6770, "AMD Radeon HD 6400 Series"},
|
||||
{0x1002, 0x9644, "AMD Radeon HD 6410D"},
|
||||
{0x1002, 0x9648, "AMD Radeon HD 6480G"},
|
||||
{0x1002, 0x6760, "AMD Radeon HD 6490M"},
|
||||
{0x1002, 0x9640, "AMD Radeon HD 6550D"},
|
||||
{0x1002, 0x6758, "AMD Radeon HD 6600 Series"},
|
||||
{0x1002, 0x6741, "AMD Radeon HD 6600M Series"},
|
||||
{0x1002, 0x68ba, "AMD Radeon HD 6700 Series"},
|
||||
{0x1002, 0x6739, "AMD Radeon HD 6800 Series"},
|
||||
{0x1002, 0x6719, "AMD Radeon HD 6900 Series"},
|
||||
{0x1002, 0x9901, "AMD Radeon HD 7660D"},
|
||||
{0x1002, 0x683d, "AMD Radeon HD 7700 Series"},
|
||||
{0x1002, 0x6819, "AMD Radeon HD 7800 Series"},
|
||||
{0x1002, 0x6818, "AMD Radeon HD 7870 Series"},
|
||||
{0x1002, 0x679a, "AMD Radeon HD 7900 Series"},
|
||||
{0x1002, 0x6660, "AMD Radeon HD 8600M Series"},
|
||||
{0x1002, 0x6610, "AMD Radeon HD 8670"},
|
||||
{0x1002, 0x665c, "AMD Radeon HD 8770"},
|
||||
{0x1002, 0x9830, "AMD Radeon HD 8400 / R3 Series"},
|
||||
{0x1002, 0x130f, "AMD Radeon(TM) R7 Graphics"},
|
||||
{0x1002, 0x6939, "AMD Radeon R9 285"},
|
||||
{0x1002, 0x67b1, "AMD Radeon R9 290"},
|
||||
{0x1002, 0x67b0, "AMD Radeon R9 290X"},
|
||||
{0x1002, 0x7300, "AMD Radeon (TM) R9 Fury Series"},
|
||||
{0x1002, 0x6821, "AMD Radeon R9 M370X"},
|
||||
{0x1002, 0x6647, "AMD Radeon R9 M380"},
|
||||
{0x1002, 0x6920, "AMD Radeon R9 M395X"},
|
||||
{0x1002, 0x67ef, "Radeon(TM) RX 460 Graphics"},
|
||||
{0x1002, 0x67df, "Radeon (TM) RX 480 Graphics"},
|
||||
{0x1002, 0x73df, "AMD Radeon RX 6700 XT"},
|
||||
{0x1002, 0x687f, "Radeon RX Vega"},
|
||||
{0x1002, 0x69af, "Radeon Pro Vega 20"},
|
||||
{0x1002, 0x15dd, "AMD Radeon(TM) Vega 10 Mobile Graphics"},
|
||||
{0x1002, 0x66af, "Radeon RX Vega 20"},
|
||||
{0x1002, 0x731f, "Radeon RX 5700 / 5700 XT"},
|
||||
{0x1002, 0x7340, "Radeon RX 5500M"},
|
||||
{0x1002, 0x73bf, "Radeon RX 6800/6800 XT / 6900 XT"},
|
||||
{0x1002, 0x7480, "AMD Radeon RX 7600 XT"},
|
||||
{0x1002, 0x7590, "AMD Radeon RX 9060 XT"},
|
||||
{0x1002, 0x73a1, "Radeon Pro V620"},
|
||||
{0x1002, 0x73ae, "Radeon Pro V620 VF"},
|
||||
{0x1002, 0x163f, "AMD VANGOGH"},
|
||||
{0x1002, 0x164e, "AMD Radeon(TM) Graphics"},
|
||||
{0x8086, 0x3577, "Intel(R) 82830M Graphics Controller"},
|
||||
{0x8086, 0x3582, "Intel(R) 82852/82855 GM/GME Graphics Controller"},
|
||||
{0x8086, 0x2562, "Intel(R) 845G"},
|
||||
{0x8086, 0x2572, "Intel(R) 82865G Graphics Controller"},
|
||||
{0x8086, 0x2582, "Intel(R) 82915G/GV/910GL Express Chipset Family"},
|
||||
{0x8086, 0x258a, "Intel(R) E7221G"},
|
||||
{0x8086, 0x2592, "Mobile Intel(R) 915GM/GMS,910GML Express Chipset Family"},
|
||||
{0x8086, 0x2772, "Intel(R) 945G"},
|
||||
{0x8086, 0x27a2, "Mobile Intel(R) 945GM Express Chipset Family"},
|
||||
{0x8086, 0x27ae, "Intel(R) 945GME"},
|
||||
{0x8086, 0x29b2, "Intel(R) Q35"},
|
||||
{0x8086, 0x29c2, "Intel(R) G33"},
|
||||
{0x8086, 0x29d2, "Intel(R) Q33"},
|
||||
{0x8086, 0xa001, "Intel(R) IGD"},
|
||||
{0x8086, 0xa011, "Intel(R) IGD"},
|
||||
{0x8086, 0x2992, "Intel(R) 965Q"},
|
||||
{0x8086, 0x2982, "Intel(R) 965G"},
|
||||
{0x8086, 0x2972, "Intel(R) 946GZ"},
|
||||
{0x8086, 0x2a02, "Mobile Intel(R) 965 Express Chipset Family"},
|
||||
{0x8086, 0x2a12, "Intel(R) 965GME"},
|
||||
{0x8086, 0x2a42, "Mobile Intel(R) GM45 Express Chipset Family"},
|
||||
{0x8086, 0x2e02, "Intel(R) Integrated Graphics Device"},
|
||||
{0x8086, 0x2e22, "Intel(R) G45/G43"},
|
||||
{0x8086, 0x2e12, "Intel(R) Q45/Q43"},
|
||||
{0x8086, 0x2e32, "Intel(R) G41"},
|
||||
{0x8086, 0x2e92, "Intel(R) B43"},
|
||||
{0x8086, 0x0042, "Intel(R) HD Graphics"},
|
||||
{0x8086, 0x0046, "Intel(R) HD Graphics"},
|
||||
{0x8086, 0x0122, "Intel(R) HD Graphics 3000"},
|
||||
{0x8086, 0x0126, "Intel(R) HD Graphics 3000"},
|
||||
{0x8086, 0x010a, "Intel(R) HD Graphics Family"},
|
||||
{0x8086, 0x0162, "Intel(R) HD Graphics 4000"},
|
||||
{0x8086, 0x0166, "Intel(R) HD Graphics 4000"},
|
||||
{0x8086, 0x015a, "Intel(R) HD Graphics Family"},
|
||||
{0x8086, 0x0412, "Intel(R) HD Graphics 4600"},
|
||||
{0x8086, 0x0416, "Intel(R) HD Graphics 4600"},
|
||||
{0x8086, 0x0a26, "Intel(R) HD Graphics 5000"},
|
||||
{0x8086, 0x0422, "Intel(R) HD Graphics 5000"},
|
||||
{0x8086, 0x0a22, "Intel(R) Iris(TM) Graphics 5100"},
|
||||
{0x8086, 0x0a2a, "Intel(R) Iris(TM) Graphics 5100"},
|
||||
{0x8086, 0x0a2b, "Intel(R) Iris(TM) Graphics 5100"},
|
||||
{0x8086, 0x0a2e, "Intel(R) Iris(TM) Graphics 5100"},
|
||||
{0x8086, 0x0d22, "Intel(R) Iris(TM) Pro Graphics 5200"},
|
||||
{0x8086, 0x0d26, "Intel(R) Iris(TM) Pro Graphics 5200"},
|
||||
{0x8086, 0x0d2a, "Intel(R) Iris(TM) Pro Graphics 5200"},
|
||||
{0x8086, 0x0d2b, "Intel(R) Iris(TM) Pro Graphics 5200"},
|
||||
{0x8086, 0x0d2e, "Intel(R) Iris(TM) Pro Graphics 5200"},
|
||||
{0x8086, 0x0c22, "Intel(R) Iris(TM) Pro Graphics 5200"},
|
||||
{0x8086, 0x161e, "Intel(R) HD Graphics 5300"},
|
||||
{0x8086, 0x1616, "Intel(R) HD Graphics 5500"},
|
||||
{0x8086, 0x1612, "Intel(R) HD Graphics 5600"},
|
||||
{0x8086, 0x1626, "Intel(R) HD Graphics 6000"},
|
||||
{0x8086, 0x162b, "Intel(R) Iris(TM) Graphics 6100"},
|
||||
{0x8086, 0x1622, "Intel(R) Iris(TM) Pro Graphics 6200"},
|
||||
{0x8086, 0x162a, "Intel(R) Iris(TM) Pro Graphics P6300"},
|
||||
{0x8086, 0x1902, "Intel(R) HD Graphics 510"},
|
||||
{0x8086, 0x1906, "Intel(R) HD Graphics 510"},
|
||||
{0x8086, 0x190b, "Intel(R) HD Graphics 510"},
|
||||
{0x8086, 0x191e, "Intel(R) HD Graphics 515"},
|
||||
{0x8086, 0x1916, "Intel(R) HD Graphics 520"},
|
||||
{0x8086, 0x1921, "Intel(R) HD Graphics 520"},
|
||||
{0x8086, 0x1912, "Intel(R) HD Graphics 530"},
|
||||
{0x8086, 0x191b, "Intel(R) HD Graphics 530"},
|
||||
{0x8086, 0x191d, "Intel(R) HD Graphics P530"},
|
||||
{0x8086, 0x1926, "Intel(R) Iris(TM) Graphics 540"},
|
||||
{0x8086, 0x1927, "Intel(R) Iris(TM) Graphics 550"},
|
||||
{0x8086, 0x192b, "Intel(R) Iris(TM) Graphics 555"},
|
||||
{0x8086, 0x192d, "Intel(R) Iris(TM) Graphics P555"},
|
||||
{0x8086, 0x1932, "Intel(R) Iris(TM) Pro Graphics 580"},
|
||||
{0x8086, 0x193b, "Intel(R) Iris(TM) Pro Graphics 580"},
|
||||
{0x8086, 0x193a, "Intel(R) Iris(TM) Pro Graphics P580"},
|
||||
{0x8086, 0x193d, "Intel(R) Iris(TM) Pro Graphics P580"},
|
||||
{0x8086, 0x87c0, "Intel(R) UHD Graphics 617"},
|
||||
{0x8086, 0x3ea0, "Intel(R) UHD Graphics 620"},
|
||||
{0x8086, 0x5917, "Intel(R) UHD Graphics 620"},
|
||||
{0x8086, 0x591e, "Intel(R) HD Graphics 615"},
|
||||
{0x8086, 0x5916, "Intel(R) HD Graphics 620"},
|
||||
{0x8086, 0x5912, "Intel(R) HD Graphics 630"},
|
||||
{0x8086, 0x591b, "Intel(R) HD Graphics 630"},
|
||||
{0x8086, 0x3e9b, "Intel(R) UHD Graphics 630"},
|
||||
{0x8086, 0x3e91, "Intel(R) UHD Graphics 630"},
|
||||
};
|
||||
|
||||
static inline const char *wine_device_name(uint32_t vendor_id, uint32_t device_id, const char *native_name) {
|
||||
for (size_t i = 0; i < sizeof(wine_gpu_names) / sizeof(wine_gpu_names[0]); i++) {
|
||||
if (wine_gpu_names[i].vendor_id == vendor_id && wine_gpu_names[i].device_id == device_id) {
|
||||
return wine_gpu_names[i].name;
|
||||
}
|
||||
}
|
||||
return native_name;
|
||||
}
|
||||
|
||||
#endif
|
||||
Vendored
-3
@@ -7,8 +7,6 @@ Build-Depends:
|
||||
gettext,
|
||||
libsdl3-dev,
|
||||
libvulkan-dev,
|
||||
libwayland-dev,
|
||||
libx11-dev,
|
||||
meson,
|
||||
ninja-build,
|
||||
pkgconf,
|
||||
@@ -57,7 +55,6 @@ Depends:
|
||||
qt6-svg-plugins,
|
||||
unrar-free,
|
||||
unzip,
|
||||
xkb-data,
|
||||
xz-utils,
|
||||
zstd,
|
||||
${misc:Depends},
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Regenerate bundled keyboard layers; libxkbcommon is a generation-only tool."""
|
||||
import ctypes as C
|
||||
import ctypes.util
|
||||
from pathlib import Path
|
||||
import re
|
||||
|
||||
import orjson
|
||||
|
||||
from portprotonqt.system_keyboard.input import KEY_ROWS
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
lib = C.CDLL(ctypes.util.find_library('xkbcommon'))
|
||||
|
||||
|
||||
class Names(C.Structure):
|
||||
_fields_ = [(name, C.c_char_p) for name in ('rules', 'model', 'layout', 'variant', 'options')]
|
||||
|
||||
|
||||
for name, args, result in (
|
||||
('xkb_context_new', [C.c_int], C.c_void_p),
|
||||
('xkb_keymap_new_from_names', [C.c_void_p, C.POINTER(Names), C.c_int], C.c_void_p),
|
||||
('xkb_state_new', [C.c_void_p], C.c_void_p),
|
||||
('xkb_state_update_key', [C.c_void_p, C.c_uint, C.c_int], C.c_int),
|
||||
('xkb_state_key_get_utf8', [C.c_void_p, C.c_uint, C.c_void_p, C.c_size_t], C.c_int),
|
||||
('xkb_state_key_get_one_sym', [C.c_void_p, C.c_uint], C.c_uint),
|
||||
('xkb_keysym_get_name', [C.c_uint, C.c_void_p, C.c_size_t], C.c_int),
|
||||
('xkb_keysym_to_utf32', [C.c_uint], C.c_uint),
|
||||
('xkb_keysym_to_upper', [C.c_uint], C.c_uint),
|
||||
('xkb_keysym_from_name', [C.c_char_p, C.c_int], C.c_uint),
|
||||
('xkb_state_unref', [C.c_void_p], None),
|
||||
('xkb_keymap_unref', [C.c_void_p], None),
|
||||
('xkb_context_unref', [C.c_void_p], None),
|
||||
):
|
||||
function = getattr(lib, name)
|
||||
function.argtypes, function.restype = args, result
|
||||
|
||||
path = ROOT / 'portprotonqt/keyboard_layouts.json'
|
||||
data = orjson.loads(path.read_bytes())
|
||||
context = lib.xkb_context_new(0)
|
||||
failures = []
|
||||
for identifier, layout in data.items():
|
||||
language, _, variant = identifier.partition('+')
|
||||
names = Names(None, b'pc105', language.encode(), variant.encode(), b'')
|
||||
keymap = lib.xkb_keymap_new_from_names(context, C.byref(names), 0)
|
||||
if not keymap:
|
||||
failures.append(identifier)
|
||||
continue
|
||||
for layer, modifiers in (
|
||||
('altgr', (108,)), ('shift_altgr', (50, 108)),
|
||||
('caps', (66,)), ('shift_caps', (50, 66)),
|
||||
('altgr_caps', (108, 66)), ('shift_altgr_caps', (50, 108, 66)),
|
||||
):
|
||||
state = lib.xkb_state_new(keymap)
|
||||
for code in modifiers:
|
||||
lib.xkb_state_update_key(state, code, 1)
|
||||
rows = []
|
||||
for fallbacks, codes in zip(layout['normal'], KEY_ROWS, strict=True):
|
||||
row = []
|
||||
for fallback, code in zip(fallbacks, codes, strict=True):
|
||||
buffer = C.create_string_buffer(128)
|
||||
lib.xkb_state_key_get_utf8(state, code + 8, buffer, len(buffer))
|
||||
label = buffer.value.decode()
|
||||
if not label or not label.isprintable():
|
||||
symbol = lib.xkb_state_key_get_one_sym(state, code + 8)
|
||||
lib.xkb_keysym_get_name(symbol, buffer, len(buffer))
|
||||
label = buffer.value.decode() or fallback
|
||||
row.append(label.replace('&', '&&') if code not in (15, 58, 42) else fallback)
|
||||
rows.append(row)
|
||||
layout[layer] = rows
|
||||
lib.xkb_state_unref(state)
|
||||
lib.xkb_keymap_unref(keymap)
|
||||
lib.xkb_context_unref(context)
|
||||
if failures:
|
||||
raise SystemExit(f'Cannot generate layouts: {failures}')
|
||||
path.write_bytes(orjson.dumps(data) + b'\n')
|
||||
|
||||
symbols = {'names': {}, 'values': {}, 'keysyms': {}, 'upper': {}}
|
||||
header = Path('/usr/include/xkbcommon/xkbcommon-keysyms.h').read_text()
|
||||
for name in re.findall(r'^#define XKB_KEY_(\w+)\s', header, re.MULTILINE):
|
||||
symbol = lib.xkb_keysym_from_name(name.encode(), 0)
|
||||
value = lib.xkb_keysym_to_utf32(symbol)
|
||||
buffer = C.create_string_buffer(128)
|
||||
lib.xkb_keysym_get_name(symbol, buffer, len(buffer))
|
||||
symbols['keysyms'][str(symbol)] = buffer.value.decode()
|
||||
if value and chr(value).isprintable():
|
||||
symbols['keysyms'][str(symbol)] = chr(value)
|
||||
symbols['names'][name] = chr(value)
|
||||
symbols['values'][str(symbol)] = chr(value)
|
||||
upper = lib.xkb_keysym_to_utf32(lib.xkb_keysym_to_upper(symbol))
|
||||
if upper and chr(upper).isprintable():
|
||||
symbols['upper'][chr(value)] = chr(upper)
|
||||
(ROOT / 'portprotonqt/keyboard_symbols.json').write_bytes(orjson.dumps(symbols) + b'\n')
|
||||
@@ -1,104 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Synchronize GPU names with Wine without rewriting the surrounding header."""
|
||||
import os
|
||||
from pathlib import Path
|
||||
import re
|
||||
import subprocess
|
||||
import tempfile
|
||||
from urllib.request import urlopen
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
HEADER = ROOT / "build-aux/src/wine_gpu_names.h"
|
||||
WINE_REPOSITORY = "https://github.com/wine-mirror/wine.git"
|
||||
WINE_SOURCE = "dlls/win32u/sysparams.c"
|
||||
NETWORK_TIMEOUT = 30
|
||||
MAX_SOURCE_BYTES = 2 * 1024 * 1024
|
||||
C_STRING = r'"(?:[^"\\\r\n]|\\[^\r\n])*"'
|
||||
WINE_ROW = re.compile(
|
||||
r'case\s+MAKELONG\(\s*(0x[0-9a-fA-F]+)\s*,\s*(0x[0-9a-fA-F]+)\s*\)'
|
||||
r'\s*:\s*return\s+(' + C_STRING + r')\s*;'
|
||||
)
|
||||
HEADER_ROW = re.compile(
|
||||
r'^ \{(0x[0-9a-fA-F]+), (0x[0-9a-fA-F]+), (' + C_STRING + r')\},$', re.M,
|
||||
)
|
||||
TABLE = re.compile(r'(\} wine_gpu_names\[\] = \{\n)(.*?)(\n\};)', re.S)
|
||||
|
||||
|
||||
def parse_wine_names(source):
|
||||
function = re.search(
|
||||
r'\bconst char\s*\*gpu_device_name\([^)]*\)\s*\{(.*?)\n\};', source, re.S,
|
||||
)
|
||||
if function is None:
|
||||
raise ValueError("Wine gpu_device_name() was not found")
|
||||
body = function.group(1)
|
||||
rows = WINE_ROW.findall(body)
|
||||
if not rows or len(rows) != len(re.findall(r'\bcase\b', body)):
|
||||
raise ValueError("Wine GPU table is empty or contains unsupported cases")
|
||||
result = []
|
||||
seen = set()
|
||||
for vendor, device, name in rows:
|
||||
identity = (int(vendor, 16), int(device, 16))
|
||||
if identity in seen or any(value > 0xffff for value in identity) or name == '""':
|
||||
raise ValueError(f"Invalid or duplicate Wine GPU entry: {vendor}:{device}")
|
||||
seen.add(identity)
|
||||
result.append((f"0x{identity[0]:04x}", f"0x{identity[1]:04x}", name))
|
||||
return result
|
||||
|
||||
|
||||
def update_header(header, source, revision):
|
||||
if not re.fullmatch(r'[0-9a-f]{40}', revision):
|
||||
raise ValueError("Invalid Wine source revision")
|
||||
rows = parse_wine_names(source)
|
||||
tables = list(TABLE.finditer(header))
|
||||
if len(tables) != 1:
|
||||
raise ValueError("Expected exactly one wine_gpu_names array in the header")
|
||||
table = tables[0]
|
||||
existing = HEADER_ROW.findall(table.group(2))
|
||||
if not existing or len(existing) != len(table.group(2).strip().splitlines()):
|
||||
raise ValueError("Unsupported existing header table format")
|
||||
if rows == existing:
|
||||
return header
|
||||
replacement = "\n".join(f" {{{vendor}, {device}, {name}}}," for vendor, device, name in rows)
|
||||
updated = header[:table.start(2)] + replacement + header[table.end(2):]
|
||||
updated, count = re.subn(r'^// Revision: [0-9a-f]{40}$', f"// Revision: {revision}", updated, flags=re.M)
|
||||
if count != 1:
|
||||
raise ValueError("Expected exactly one Wine revision comment")
|
||||
return updated
|
||||
|
||||
|
||||
def main():
|
||||
print("Resolving Wine master revision...", flush=True)
|
||||
refs = subprocess.run(
|
||||
["git", "ls-remote", WINE_REPOSITORY, "refs/heads/master"],
|
||||
capture_output=True, text=True, check=True, timeout=NETWORK_TIMEOUT,
|
||||
).stdout.split()
|
||||
if len(refs) != 2 or not re.fullmatch(r'[0-9a-f]{40}', refs[0]):
|
||||
raise ValueError("Could not resolve Wine master revision")
|
||||
revision = refs[0]
|
||||
url = f"https://raw.githubusercontent.com/wine-mirror/wine/{revision}/{WINE_SOURCE}"
|
||||
print(f"Fetching Wine GPU names at {revision}...", flush=True)
|
||||
with urlopen(url, timeout=NETWORK_TIMEOUT) as response:
|
||||
source = response.read(MAX_SOURCE_BYTES + 1)
|
||||
if len(source) > MAX_SOURCE_BYTES:
|
||||
raise ValueError("Wine source exceeds the download size limit")
|
||||
header = HEADER.read_text(encoding="utf-8")
|
||||
updated = update_header(header, source.decode("utf-8"), revision)
|
||||
if updated == header:
|
||||
print("Wine GPU names are unchanged.")
|
||||
return
|
||||
temporary = None
|
||||
try:
|
||||
with tempfile.NamedTemporaryFile(mode="w", encoding="utf-8", dir=HEADER.parent, delete=False) as output:
|
||||
temporary = Path(output.name)
|
||||
output.write(updated)
|
||||
temporary.chmod(HEADER.stat().st_mode & 0o777)
|
||||
os.replace(temporary, HEADER)
|
||||
finally:
|
||||
if temporary is not None:
|
||||
temporary.unlink(missing_ok=True)
|
||||
print(f"Updated {len(parse_wine_names(source.decode('utf-8')))} Wine GPU names.")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -40,8 +40,6 @@ pkgdatadir = pythondir / meson.project_name()
|
||||
cc = meson.get_compiler('c')
|
||||
sdl3_dep = dependency('sdl3', required: true)
|
||||
gamepad_sources = files('build-aux/src/gamepad_backend.c')
|
||||
keyboard_deps = [dependency('wayland-client'), dependency('x11')]
|
||||
keyboard_sources = files('build-aux/src/keyboard_backend.c')
|
||||
|
||||
# Install Python package
|
||||
subdir('portprotonqt')
|
||||
|
||||
@@ -140,7 +140,7 @@ def _add_source_corner(
|
||||
) -> None:
|
||||
"""Add source corner badge to cover frame."""
|
||||
source = game_source.lower()
|
||||
if source not in ("steam", "gog", "egs", "portproton", "native") or theme_manager is None:
|
||||
if source not in ("steam", "gog", "egs", "portproton") or theme_manager is None:
|
||||
return
|
||||
|
||||
icon_name = f"badge_{source}"
|
||||
|
||||
@@ -363,12 +363,8 @@ class ExeSettingsDialog(
|
||||
target.setFocus(Qt.FocusReason.OtherFocusReason)
|
||||
|
||||
def _clear_run_after_entries(self, target: QLineEdit) -> None:
|
||||
table = self.advanced_table
|
||||
for row in reversed(range(table.rowCount())):
|
||||
item = table.item(row, 0)
|
||||
if item and item.data(Qt.ItemDataRole.UserRole) == "run_after_entry":
|
||||
table.removeRow(row)
|
||||
target.setProperty("ppqt_run_after_expanded", False)
|
||||
if target.property("ppqt_run_after_expanded"):
|
||||
self._toggle_run_after_entries(target)
|
||||
target.clear()
|
||||
if target.isVisible():
|
||||
target.setFocus(Qt.FocusReason.OtherFocusReason)
|
||||
@@ -1059,7 +1055,7 @@ class ExeSettingsDialog(
|
||||
line_edit.setEnabled(False)
|
||||
line_edit.setStyleSheet(self.theme.SETTINGS_DISABLED_INPUT_STYLE)
|
||||
|
||||
if setting['key'] == 'PW_RUN_AFTER_EXE':
|
||||
if setting['key'] in ('PW_RUN_AFTER_EXE', 'PW_NETWORK_BLOCKLIST'):
|
||||
text_container = QWidget()
|
||||
text_container.setProperty("ppqt_run_after_exe_widget", True)
|
||||
container_layout = QVBoxLayout(text_container)
|
||||
@@ -1076,7 +1072,7 @@ class ExeSettingsDialog(
|
||||
if is_blocked:
|
||||
browse_button.setEnabled(False)
|
||||
|
||||
def open_run_after_exe_selector(
|
||||
def open_setting_file_selector(
|
||||
_checked: bool = False,
|
||||
target_line_edit=line_edit,
|
||||
file_filter=lambda path: path.lower().endswith(".exe") or os.access(path, os.X_OK),
|
||||
@@ -1098,7 +1094,7 @@ class ExeSettingsDialog(
|
||||
)
|
||||
file_explorer.exec()
|
||||
|
||||
browse_button.clicked.connect(open_run_after_exe_selector)
|
||||
browse_button.clicked.connect(open_setting_file_selector)
|
||||
expand_button = AutoSizeButton("≡")
|
||||
expand_button.setStyleSheet(self.theme.ACTION_BUTTON_STYLE)
|
||||
expand_button.clicked.connect(
|
||||
|
||||
+62
-48
@@ -1,6 +1,5 @@
|
||||
from PySide6.QtCore import QObject, Signal, QThread, Qt, QCoreApplication
|
||||
import threading
|
||||
from tempfile import NamedTemporaryFile
|
||||
import os
|
||||
import time
|
||||
import requests
|
||||
@@ -27,57 +26,36 @@ def get_requests_session():
|
||||
session.verify = True
|
||||
return session
|
||||
|
||||
def is_complete_download(path: str | Path) -> bool:
|
||||
"""Check for a cached file, rejecting JPEGs without an end marker."""
|
||||
jpeg_start = b"\xff\xd8"
|
||||
jpeg_end = b"\xff\xd9"
|
||||
try:
|
||||
with open(path, "rb") as stream:
|
||||
if stream.read(len(jpeg_start)) != jpeg_start:
|
||||
return True
|
||||
stream.seek(-len(jpeg_end), os.SEEK_END)
|
||||
return stream.read() == jpeg_end
|
||||
except OSError:
|
||||
return False
|
||||
|
||||
|
||||
def _save_download(response: requests.Response, local_path: str, timeout: float) -> None:
|
||||
deadline = time.monotonic() + timeout
|
||||
total_size = int(response.headers.get('Content-Length', 0))
|
||||
destination = Path(local_path)
|
||||
destination.parent.mkdir(parents=True, exist_ok=True)
|
||||
with NamedTemporaryFile(dir=destination.parent, delete=False) as stream:
|
||||
temporary = Path(stream.name)
|
||||
try:
|
||||
with tqdm(total=total_size or None, unit='B', unit_scale=True,
|
||||
unit_divisor=1024, desc=f"Downloading {destination.name}", ascii=True) as pbar:
|
||||
for chunk in response.iter_content(chunk_size=8192):
|
||||
if time.monotonic() > deadline:
|
||||
raise requests.exceptions.ReadTimeout(f"Download exceeded {timeout}s total timeout")
|
||||
if chunk:
|
||||
stream.write(chunk)
|
||||
pbar.update(len(chunk))
|
||||
stream.close()
|
||||
if not is_complete_download(temporary):
|
||||
raise OSError("Incomplete JPEG download")
|
||||
temporary.replace(destination)
|
||||
finally:
|
||||
temporary.unlink(missing_ok=True)
|
||||
|
||||
|
||||
def download_with_cache(url, local_path, timeout=5, downloader_instance=None):
|
||||
if is_complete_download(local_path):
|
||||
if os.path.exists(local_path):
|
||||
return local_path
|
||||
session = get_requests_session()
|
||||
try:
|
||||
with session.get(url, stream=True, timeout=timeout) as response:
|
||||
response.raise_for_status()
|
||||
_save_download(response, local_path, timeout)
|
||||
deadline = time.monotonic() + timeout
|
||||
total_size = int(response.headers.get('Content-Length', 0))
|
||||
os.makedirs(os.path.dirname(local_path), exist_ok=True)
|
||||
desc = Path(local_path).name
|
||||
with tqdm(total=total_size if total_size > 0 else None,
|
||||
unit='B', unit_scale=True, unit_divisor=1024,
|
||||
desc=f"Downloading {desc}", ascii=True) as pbar:
|
||||
with open(local_path, 'wb') as f:
|
||||
for chunk in response.iter_content(chunk_size=8192):
|
||||
if time.monotonic() > deadline:
|
||||
raise requests.exceptions.ReadTimeout(
|
||||
f"Download exceeded {timeout}s total timeout for {url}"
|
||||
)
|
||||
if chunk:
|
||||
f.write(chunk)
|
||||
pbar.update(len(chunk))
|
||||
return local_path
|
||||
except Exception as e:
|
||||
logger.error(f"Download error {url}: {e}")
|
||||
if downloader_instance and hasattr(downloader_instance, '_last_error'):
|
||||
downloader_instance._last_error[url] = True
|
||||
if os.path.exists(local_path):
|
||||
os.remove(local_path)
|
||||
return None
|
||||
|
||||
class Downloader(QObject):
|
||||
@@ -123,7 +101,7 @@ class Downloader(QObject):
|
||||
last_request_time = [0.0]
|
||||
|
||||
def _download_one(url, local_path):
|
||||
if is_complete_download(local_path):
|
||||
if os.path.exists(local_path):
|
||||
return local_path
|
||||
try:
|
||||
with rate_limit_lock:
|
||||
@@ -134,7 +112,22 @@ class Downloader(QObject):
|
||||
|
||||
with session.get(url, stream=True, timeout=timeout) as response:
|
||||
response.raise_for_status()
|
||||
_save_download(response, local_path, timeout)
|
||||
deadline = time.monotonic() + timeout
|
||||
total_size = int(response.headers.get('Content-Length', 0))
|
||||
os.makedirs(os.path.dirname(local_path), exist_ok=True)
|
||||
desc = Path(local_path).name
|
||||
with tqdm(total=total_size if total_size > 0 else None,
|
||||
unit='B', unit_scale=True, unit_divisor=1024,
|
||||
desc=f"Downloading {desc}", ascii=True) as pbar:
|
||||
with open(local_path, 'wb') as f:
|
||||
for chunk in response.iter_content(chunk_size=8192):
|
||||
if time.monotonic() > deadline:
|
||||
raise requests.exceptions.ReadTimeout(
|
||||
f"Download exceeded {timeout}s total timeout for {url}"
|
||||
)
|
||||
if chunk:
|
||||
f.write(chunk)
|
||||
pbar.update(len(chunk))
|
||||
return local_path
|
||||
except requests.exceptions.HTTPError as e:
|
||||
if e.response is not None and e.response.status_code == 429:
|
||||
@@ -143,22 +136,43 @@ class Downloader(QObject):
|
||||
try:
|
||||
with session.get(url, stream=True, timeout=timeout) as response:
|
||||
response.raise_for_status()
|
||||
_save_download(response, local_path, timeout)
|
||||
deadline = time.monotonic() + timeout
|
||||
total_size = int(response.headers.get('Content-Length', 0))
|
||||
os.makedirs(os.path.dirname(local_path), exist_ok=True)
|
||||
desc = Path(local_path).name
|
||||
with tqdm(total=total_size if total_size > 0 else None,
|
||||
unit='B', unit_scale=True, unit_divisor=1024,
|
||||
desc=f"Downloading {desc}", ascii=True) as pbar:
|
||||
with open(local_path, 'wb') as f:
|
||||
for chunk in response.iter_content(chunk_size=8192):
|
||||
if time.monotonic() > deadline:
|
||||
raise requests.exceptions.ReadTimeout(
|
||||
f"Download exceeded {timeout}s total timeout for {url}"
|
||||
)
|
||||
if chunk:
|
||||
f.write(chunk)
|
||||
pbar.update(len(chunk))
|
||||
return local_path
|
||||
except Exception as retry_e:
|
||||
logger.error(f"Retry download error {url}: {retry_e}")
|
||||
with self._global_lock:
|
||||
self._last_error[url] = True
|
||||
if os.path.exists(local_path):
|
||||
os.remove(local_path)
|
||||
return None
|
||||
else:
|
||||
logger.error(f"Download error {url}: {e}")
|
||||
with self._global_lock:
|
||||
self._last_error[url] = True
|
||||
if os.path.exists(local_path):
|
||||
os.remove(local_path)
|
||||
return None
|
||||
except Exception as e:
|
||||
logger.error(f"Download error {url}: {e}")
|
||||
with self._global_lock:
|
||||
self._last_error[url] = True
|
||||
if os.path.exists(local_path):
|
||||
os.remove(local_path)
|
||||
return None
|
||||
|
||||
with ThreadPoolExecutor(max_workers=max_workers) as executor:
|
||||
@@ -184,7 +198,7 @@ class Downloader(QObject):
|
||||
return None
|
||||
if url in self._cache:
|
||||
cached_path = self._cache[url]
|
||||
if is_complete_download(cached_path):
|
||||
if os.path.exists(cached_path):
|
||||
if os.path.abspath(cached_path) == os.path.abspath(local_path):
|
||||
return cached_path
|
||||
else:
|
||||
@@ -196,7 +210,7 @@ class Downloader(QObject):
|
||||
return None
|
||||
if url in self._cache:
|
||||
cached_path = self._cache[url]
|
||||
if is_complete_download(cached_path) and os.path.abspath(cached_path) == os.path.abspath(local_path):
|
||||
if os.path.exists(cached_path) and os.path.abspath(cached_path) == os.path.abspath(local_path):
|
||||
return cached_path
|
||||
result = download_with_cache(url, local_path, timeout, self)
|
||||
with self._global_lock:
|
||||
@@ -227,7 +241,7 @@ class Downloader(QObject):
|
||||
emitted_urls.add(url)
|
||||
continue
|
||||
cached_path = self._cache.get(url)
|
||||
if (cached_path and is_complete_download(cached_path)
|
||||
if (cached_path and os.path.exists(cached_path)
|
||||
and os.path.abspath(cached_path) == os.path.abspath(path)):
|
||||
if on_result and url not in emitted_urls:
|
||||
on_result(url, cached_path)
|
||||
@@ -275,7 +289,7 @@ class Downloader(QObject):
|
||||
def download_async(self, url: str, local_path: str, timeout: int = 5, callback: Callable[[str | None], None] | None = None, parallel: bool = False) -> QThread | None:
|
||||
with self._global_lock:
|
||||
previous_error = url in self._last_error
|
||||
cached = not previous_error and is_complete_download(local_path)
|
||||
cached = not previous_error and os.path.exists(local_path)
|
||||
if cached:
|
||||
self._cache[url] = local_path
|
||||
if previous_error or cached:
|
||||
|
||||
@@ -517,7 +517,7 @@ class GameCard(AnimatedCard):
|
||||
self.egsLabel.setVisible(self.egs_visible and not self.vertical_layout)
|
||||
|
||||
self.nativeLabel = SourceCorner(
|
||||
icon=self.theme_manager.get_icon("badge_native", as_path=True),
|
||||
icon=self.theme_manager.get_icon("badge_linux", as_path=True),
|
||||
config=corner_config,
|
||||
parent=self.coverWidget,
|
||||
)
|
||||
@@ -669,7 +669,7 @@ class GameCard(AnimatedCard):
|
||||
(self.steamLabel, "badge_steam"),
|
||||
(self.gogLabel, "badge_gog"),
|
||||
(self.egsLabel, "badge_egs"),
|
||||
(self.nativeLabel, "badge_native"),
|
||||
(self.nativeLabel, "badge_linux"),
|
||||
(self.portprotonLabel, "badge_portproton"),
|
||||
):
|
||||
icon = self.theme_manager.get_icon(
|
||||
@@ -817,8 +817,9 @@ class GameCard(AnimatedCard):
|
||||
radius = int(self.card_layout_cfg.get("cover_radius", 8) * self._scale)
|
||||
aspect_mode = Qt.AspectRatioMode.KeepAspectRatio
|
||||
else:
|
||||
target_width = self.coverLabel.minimumWidth()
|
||||
target_height = self.coverLabel.minimumHeight()
|
||||
target_width = int(self.base_card_width * self._scale)
|
||||
cover_ratio = self.card_layout_cfg.get("cover_aspect_ratio", 1.5)
|
||||
target_height = int(target_width * cover_ratio)
|
||||
radius = int(self.card_layout_cfg.get("cover_radius", 15) * self._scale)
|
||||
aspect_mode = Qt.AspectRatioMode.KeepAspectRatioByExpanding
|
||||
scaled_pixmap = self.base_pixmap.scaled(
|
||||
@@ -827,12 +828,6 @@ class GameCard(AnimatedCard):
|
||||
aspect_mode,
|
||||
Qt.TransformationMode.SmoothTransformation,
|
||||
)
|
||||
if not self.list_layout:
|
||||
scaled_pixmap = scaled_pixmap.copy(
|
||||
(scaled_pixmap.width() - target_width) // 2,
|
||||
(scaled_pixmap.height() - target_height) // 2,
|
||||
target_width, target_height,
|
||||
)
|
||||
rounded_pixmap = round_corners(scaled_pixmap, radius)
|
||||
try:
|
||||
self.coverLabel.setPixmap(rounded_pixmap)
|
||||
|
||||
+14
-68
@@ -10,7 +10,6 @@ import time
|
||||
import zlib
|
||||
from collections.abc import Callable
|
||||
from concurrent.futures import ThreadPoolExecutor, as_completed
|
||||
from html import unescape
|
||||
from pathlib import Path
|
||||
from urllib.parse import parse_qs, urlparse
|
||||
|
||||
@@ -316,12 +315,7 @@ class GOGAPI:
|
||||
def load_library(self) -> list[dict]:
|
||||
"""Load the cached GOG library."""
|
||||
data = self._load_json(self.library_path, [])
|
||||
if not isinstance(data, list):
|
||||
return []
|
||||
for game in data:
|
||||
if isinstance(game, dict) and isinstance(game.get("description"), str):
|
||||
game["description"] = self._short_description(game["description"])
|
||||
return data
|
||||
return data if isinstance(data, list) else []
|
||||
|
||||
def clear_library_cache(self) -> None:
|
||||
"""Remove cached GOG covers and descriptions."""
|
||||
@@ -696,7 +690,7 @@ class GOGAPI:
|
||||
),
|
||||
{},
|
||||
)
|
||||
description = self._short_description(self._localized_value(data.get("summary")))
|
||||
description = self._localized_value(data.get("summary"))
|
||||
language = get_metadata_language().lower()
|
||||
try:
|
||||
product_response = requests.get(
|
||||
@@ -709,11 +703,18 @@ class GOGAPI:
|
||||
)
|
||||
product_response.raise_for_status()
|
||||
product_description = product_response.json().get("description", {})
|
||||
description = (
|
||||
self._short_description(str(product_description.get("lead") or ""))
|
||||
or self._short_description(str(product_description.get("full") or ""))
|
||||
or description
|
||||
)
|
||||
localized_lead = str(product_description.get("lead") or "")
|
||||
if localized_lead:
|
||||
paragraphs = re.split(
|
||||
r"(?:<br\s*/?>\s*){2,}", localized_lead, flags=re.IGNORECASE
|
||||
)
|
||||
paragraph_count = (
|
||||
2 if re.match(r"\s*<(?:b|strong)>", paragraphs[0], re.IGNORECASE)
|
||||
else 1
|
||||
)
|
||||
description = "<br><br>".join(
|
||||
paragraph.strip() for paragraph in paragraphs[:paragraph_count]
|
||||
)
|
||||
except requests.RequestException as error:
|
||||
logger.warning(
|
||||
"Failed to load localized GOG description for %s: %s",
|
||||
@@ -731,61 +732,6 @@ class GOGAPI:
|
||||
"steam_appid": str(steam_release.get("external_id", "")),
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
def _short_description(description: str) -> str:
|
||||
# GOG uses these modules for storefront callouts, not the synopsis.
|
||||
intro = re.sub(
|
||||
r"<p\b[^>]*\bclass\s*=\s*(['\"])module\1[^>]*>.*?</p\s*>", "",
|
||||
description, flags=re.IGNORECASE | re.DOTALL,
|
||||
)
|
||||
# Store cross-sells start with a linked cover inside an overflow box.
|
||||
intro = re.sub(
|
||||
r"<div\s+style=(['\"])overflow:\s*hidden;?\1\s*>\s*"
|
||||
r"<a\b[^>]*>\s*<img\b[^>]*>\s*</a>.*?</div\s*>",
|
||||
"", intro, flags=re.IGNORECASE | re.DOTALL,
|
||||
)
|
||||
intro = re.sub(r"<img\b[^>]*>", "", intro, flags=re.IGNORECASE)
|
||||
intro = re.split(r"<(?:ul|ol|li)\b", intro, maxsplit=1, flags=re.IGNORECASE)[0]
|
||||
intro = re.sub(
|
||||
r"(?:<b>\s*)?<h[1-6]\b[^>]*>.*?</h[1-6]\s*>(?:\s*</b>)?",
|
||||
"<br><br>", intro,
|
||||
flags=re.IGNORECASE | re.DOTALL,
|
||||
)
|
||||
paragraphs = re.split(
|
||||
r"(?:<br\s*/?>\s*){2,}|</?(?:p|div|hr)\b[^>]*>|\r?\n[ \t]*\r?\n",
|
||||
intro, flags=re.IGNORECASE,
|
||||
)
|
||||
content = []
|
||||
for paragraph in paragraphs:
|
||||
text = unescape(re.sub(r"<[^>]*>", "", paragraph)).strip()
|
||||
if not text or re.fullmatch(
|
||||
r"(?:Внимание!\s*)?В этой игре нет русской локализации\.?"
|
||||
r"|The full version of .+? is available on GOG\.com\.\s+"
|
||||
r"You can (?:buy|purchase) it here[.!]?",
|
||||
text, re.IGNORECASE,
|
||||
):
|
||||
continue
|
||||
paragraph = re.sub(
|
||||
r"^(?:\s*<br\s*/?>)+|(?:(?:<br\s*/?>| )\s*)+$", "", paragraph,
|
||||
flags=re.IGNORECASE,
|
||||
).strip()
|
||||
if re.search(r"</?[a-z][^>]*>", paragraph, re.IGNORECASE):
|
||||
# Qt's AutoText detection stops at the first plain newline.
|
||||
paragraph = re.sub(r"<(/?)strong\s*>", r"<\1b>", paragraph, flags=re.IGNORECASE)
|
||||
paragraph = re.sub(r"(?:\r?\n)+", "<br>", paragraph)
|
||||
content.append(paragraph)
|
||||
paragraphs = content
|
||||
# Prefer the synopsis over a standalone italic epigraph.
|
||||
if len(paragraphs) > 1 and re.fullmatch(
|
||||
r"(?:(?:<b>|<strong>))*<(i|em)>[^<]*</\1>(?:(?:</b>|</strong>))*",
|
||||
paragraphs[0], re.IGNORECASE,
|
||||
):
|
||||
return paragraphs[1]
|
||||
# Keep a standalone bold notice together with the introduction.
|
||||
if paragraphs and re.fullmatch(r"<(b|strong)>[^<]*</\1>", paragraphs[0], re.IGNORECASE):
|
||||
return "<br><br>".join(paragraphs[:2])
|
||||
return paragraphs[0] if paragraphs else ""
|
||||
|
||||
@staticmethod
|
||||
def _localized_value(values: dict | None) -> str:
|
||||
if not isinstance(values, dict):
|
||||
|
||||
@@ -23,22 +23,20 @@ class GameEntry:
|
||||
class SearchConfig:
|
||||
"""Search configuration."""
|
||||
token: str
|
||||
hp_key: str | None = None
|
||||
hp_val: str | None = None
|
||||
hp_key: str
|
||||
hp_val: str
|
||||
|
||||
class HTTPClient:
|
||||
"""HTTP client for HowLongToBeat API."""
|
||||
BASE_URL = 'https://howlongtobeat.com/'
|
||||
SEARCH_URL = BASE_URL + "api/search/site"
|
||||
AUTH_URL = SEARCH_URL + "/init"
|
||||
AUTH_URL = BASE_URL + "api/bleed/init"
|
||||
SEARCH_URL = BASE_URL + "api/bleed"
|
||||
|
||||
def __init__(self, timeout: int = 60):
|
||||
self.timeout = timeout
|
||||
self.session = requests.Session()
|
||||
self.session.headers.update({
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36',
|
||||
'Accept': 'application/json',
|
||||
'Origin': self.BASE_URL.rstrip('/'),
|
||||
'referer': self.BASE_URL
|
||||
})
|
||||
proxy_settings = proxy_config.get_proxy()
|
||||
@@ -54,18 +52,15 @@ class HTTPClient:
|
||||
)
|
||||
response.raise_for_status()
|
||||
data = response.json()
|
||||
except requests.RequestException as exc:
|
||||
status = exc.response.status_code if exc.response is not None else type(exc).__name__
|
||||
logger.warning("HLTB initialization failed: %s", status)
|
||||
except (requests.RequestException, ValueError):
|
||||
return None
|
||||
token = data.get("token") if isinstance(data, dict) else None
|
||||
if not isinstance(token, str) or not token:
|
||||
logger.warning("HLTB initialization returned no token")
|
||||
if not data.get("token") or not data.get("hpKey") or not data.get("hpVal"):
|
||||
return None
|
||||
hp_key, hp_val = data.get("hpKey"), data.get("hpVal")
|
||||
if isinstance(hp_key, str) and hp_key and isinstance(hp_val, str) and hp_val:
|
||||
return SearchConfig(token, hp_key, hp_val)
|
||||
return SearchConfig(token)
|
||||
return SearchConfig(
|
||||
token=data["token"],
|
||||
hp_key=data["hpKey"],
|
||||
hp_val=data["hpVal"]
|
||||
)
|
||||
|
||||
def search_games(self, game_name: str, page: int = 1, config: SearchConfig | None = None) -> str | None:
|
||||
if not config:
|
||||
@@ -76,10 +71,11 @@ class HTTPClient:
|
||||
payload = self._build_search_payload(game_name, page, config)
|
||||
headers = {
|
||||
'content-type': 'application/json',
|
||||
'x-auth-token': config.token
|
||||
'accept': '*/*',
|
||||
'x-auth-token': config.token,
|
||||
'x-hp-key': config.hp_key,
|
||||
'x-hp-val': config.hp_val
|
||||
}
|
||||
if config.hp_key and config.hp_val:
|
||||
headers.update({'x-hp-key': config.hp_key, 'x-hp-val': config.hp_val})
|
||||
try:
|
||||
response = self.session.post(
|
||||
self.SEARCH_URL,
|
||||
@@ -110,15 +106,14 @@ class HTTPClient:
|
||||
'platform': "",
|
||||
'sortCategory': "popular",
|
||||
'rangeCategory': "main",
|
||||
'rangeTime': {'min': None, 'max': None},
|
||||
'rangeTime': {'min': 0, 'max': 0},
|
||||
'gameplay': {
|
||||
'perspective': "",
|
||||
'flow': "",
|
||||
'genre': "",
|
||||
"difficulty": ""
|
||||
},
|
||||
'year': "",
|
||||
'modifier': ""
|
||||
'rangeYear': {'max': "", 'min': ""}
|
||||
},
|
||||
'users': {'sortCategory': "postcount"},
|
||||
'lists': {'sortCategory': "follows"},
|
||||
@@ -126,10 +121,10 @@ class HTTPClient:
|
||||
'sort': 0,
|
||||
'randomizer': 0
|
||||
},
|
||||
'useCache': True
|
||||
'useCache': True,
|
||||
'fields': ["comp_main", "comp_plus", "comp_100"]
|
||||
}
|
||||
if config.hp_key and config.hp_val:
|
||||
payload[config.hp_key] = config.hp_val
|
||||
payload[config.hp_key] = config.hp_val
|
||||
return payload
|
||||
|
||||
class ResultParser:
|
||||
|
||||
@@ -10,7 +10,7 @@ from PySide6.QtWidgets import QSpacerItem, QGraphicsPixmapItem, QDialog, QApplic
|
||||
from PIL import Image, ImageQt, ImageSequence
|
||||
from portprotonqt.config import CACHE_DIR, ui_config
|
||||
from portprotonqt.theme_manager import ThemeManager, load_theme
|
||||
from portprotonqt.downloader import Downloader, is_complete_download
|
||||
from portprotonqt.downloader import Downloader
|
||||
from portprotonqt.icon_extractor import generate_thumbnail
|
||||
from portprotonqt.logger import get_logger
|
||||
from portprotonqt.qt_utils import get_device_pixel_ratio
|
||||
@@ -223,12 +223,10 @@ def set_animated_cover(label: QLabel, path: str, width: int, height: int, radius
|
||||
if not QFile.exists(path):
|
||||
return False
|
||||
if ext in (".png", ".apng") and _is_png_cover(path):
|
||||
_set_cover_mask(label, width, height, radius)
|
||||
animation = _PillowAnimatedCover(label, path, width, height, radius)
|
||||
if not animation.start():
|
||||
label.removeEventFilter(animation)
|
||||
animation.deleteLater()
|
||||
return False
|
||||
_set_cover_mask(label, width, height, radius)
|
||||
_animated_cover_movies[label] = animation
|
||||
_animated_cover_radii[label] = radius
|
||||
return True
|
||||
@@ -471,7 +469,7 @@ def load_pixmap_async(
|
||||
appid = parts[idx + 1]
|
||||
if appid:
|
||||
local_path = os.path.join(image_folder, f"{appid}.jpg")
|
||||
if is_complete_download(local_path):
|
||||
if os.path.exists(local_path):
|
||||
pixmap = QPixmap(local_path)
|
||||
# Check if the pixmap loaded successfully
|
||||
if pixmap.isNull():
|
||||
@@ -508,7 +506,7 @@ def load_pixmap_async(
|
||||
local_path = os.path.join(image_folder, filename)
|
||||
|
||||
logger.debug("SGDB cover check: %s exists=%s", local_path, os.path.exists(local_path))
|
||||
if is_complete_download(local_path):
|
||||
if os.path.exists(local_path):
|
||||
pixmap = QPixmap(local_path)
|
||||
# Check if the pixmap loaded successfully
|
||||
if pixmap.isNull():
|
||||
@@ -545,7 +543,7 @@ def load_pixmap_async(
|
||||
if not filename:
|
||||
filename = f"{app_name}{_get_cover_url_suffix(cover)}"
|
||||
local_path = os.path.join(image_folder, filename)
|
||||
if is_complete_download(local_path):
|
||||
if os.path.exists(local_path):
|
||||
pixmap = QPixmap(local_path)
|
||||
# Check if the pixmap loaded successfully
|
||||
if pixmap.isNull():
|
||||
|
||||
@@ -290,7 +290,6 @@ class InputManager(
|
||||
except Exception as e:
|
||||
logger.error("EMUL: Error closing virtual mouse: %s", e)
|
||||
self.ui = None
|
||||
self._keyboard_mouse_drag = False
|
||||
self.mouse_emulation_thread = None
|
||||
self.stick_x_raw = 0
|
||||
self.stick_y_raw = 0
|
||||
@@ -441,7 +440,6 @@ class InputManager(
|
||||
except Exception as e:
|
||||
logger.error("EMUL: Error closing virtual mouse: %s", e)
|
||||
self.ui = None
|
||||
self._keyboard_mouse_drag = False
|
||||
self.mouse_emulation_enabled = False
|
||||
self.stick_x_raw = 0
|
||||
self.stick_y_raw = 0
|
||||
@@ -524,15 +522,6 @@ class InputManager(
|
||||
self.ui.write(ecodes.EV_REL, ecodes.REL_WHEEL, steps)
|
||||
self.ui.syn()
|
||||
|
||||
def _set_keyboard_mouse_drag(self, held: bool) -> bool:
|
||||
if held == getattr(self, '_keyboard_mouse_drag', False):
|
||||
return False
|
||||
if self.ui:
|
||||
self.ui.write(ecodes.EV_KEY, ecodes.BTN_LEFT, int(held))
|
||||
self.ui.syn()
|
||||
self._keyboard_mouse_drag = held
|
||||
return True
|
||||
|
||||
def click_left(self):
|
||||
"""Left mouse button click"""
|
||||
if self.ui:
|
||||
|
||||
@@ -311,17 +311,6 @@ class DpadInputMixin(InputMixin):
|
||||
|
||||
@Slot(int, int, float)
|
||||
def handle_dpad_slot(self, code: int, value: int, current_time: float) -> None:
|
||||
keyboard = getattr(self._parent, 'system_keyboard', None)
|
||||
if keyboard is not None and keyboard.isVisible():
|
||||
if value == 0 or self._should_skip_regular_events():
|
||||
self._reset_dpad_repeat()
|
||||
return
|
||||
directions = {PAD_DPAD_X: ('left', 'right'), PAD_AXIS_LEFT_X: ('left', 'right'),
|
||||
PAD_DPAD_Y: ('up', 'down'), PAD_AXIS_LEFT_Y: ('up', 'down')}
|
||||
if code in directions:
|
||||
self._start_dpad_repeat(code, value, current_time)
|
||||
keyboard.send('direction', directions[code][value > 0])
|
||||
return
|
||||
if self._route_surface_dpad(code, value, current_time):
|
||||
return
|
||||
self._handle_default_dpad(code, value, current_time)
|
||||
|
||||
@@ -15,6 +15,7 @@ from PySide6.QtWidgets import (
|
||||
QListWidget,
|
||||
QMenu,
|
||||
QMessageBox,
|
||||
QScrollArea,
|
||||
QTableWidget,
|
||||
QWidget,
|
||||
)
|
||||
@@ -472,12 +473,16 @@ class KeyboardInputMixin(InputMixin):
|
||||
def _focus_first_game_card(self, container: QWidget | None) -> bool:
|
||||
if container is None:
|
||||
return False
|
||||
cards = [card for card in container.findChildren(AnimatedCard) if card.isVisible() and card.isEnabled()]
|
||||
if not cards:
|
||||
return False
|
||||
first_card = min(cards, key=lambda card: (card.y(), card.x()))
|
||||
self._focus_grid_card(first_card)
|
||||
return True
|
||||
for card in container.findChildren(AnimatedCard):
|
||||
if card.isVisible() and card.isEnabled():
|
||||
card.setFocus(Qt.FocusReason.OtherFocusReason)
|
||||
scroll_area = container.parentWidget()
|
||||
while scroll_area and not isinstance(scroll_area, QScrollArea):
|
||||
scroll_area = scroll_area.parentWidget()
|
||||
if isinstance(scroll_area, QScrollArea):
|
||||
scroll_area.ensureWidgetVisible(card, 50, 50)
|
||||
return True
|
||||
return False
|
||||
|
||||
def _focus_first_library_card(self) -> bool:
|
||||
container = getattr(self._parent, "gamesListWidget", None)
|
||||
|
||||
@@ -57,6 +57,8 @@ class GamepadRuntimeMixin(InputMixin):
|
||||
|
||||
def _on_gamepad_hotplug(self, action: str) -> None:
|
||||
try:
|
||||
if self._gamepad_polling_suspended:
|
||||
return
|
||||
if action == 'add':
|
||||
self.check_gamepad()
|
||||
elif action == 'remove':
|
||||
@@ -78,6 +80,8 @@ class GamepadRuntimeMixin(InputMixin):
|
||||
|
||||
def check_gamepad(self) -> None:
|
||||
try:
|
||||
if self._gamepad_polling_suspended:
|
||||
return
|
||||
new_gamepad = self.find_gamepad()
|
||||
|
||||
if new_gamepad:
|
||||
@@ -115,7 +119,6 @@ class GamepadRuntimeMixin(InputMixin):
|
||||
|
||||
def _reset_input_state(self) -> None:
|
||||
"""Reset cached joystick state when the active device changes."""
|
||||
self._set_keyboard_mouse_drag(False)
|
||||
self._button_states.clear()
|
||||
self._hat_states.clear()
|
||||
self._axis_states.clear()
|
||||
@@ -125,7 +128,6 @@ class GamepadRuntimeMixin(InputMixin):
|
||||
self.lt_pressed = False
|
||||
self.rt_pressed = False
|
||||
self.start_held = False
|
||||
self._start_consumed = False
|
||||
self.select_held = False
|
||||
self.pending_menu_fullscreen_time = 0.0
|
||||
self.guide_held = False
|
||||
@@ -171,9 +173,6 @@ class GamepadRuntimeMixin(InputMixin):
|
||||
keyboard = getattr(self._parent, "keyboard", None)
|
||||
if keyboard and hasattr(keyboard, "update_keyboard"):
|
||||
keyboard.update_keyboard()
|
||||
system_keyboard = getattr(self._parent, 'system_keyboard', None)
|
||||
if system_keyboard is not None:
|
||||
system_keyboard.send('gamepad', self.gamepad_type.value if self.gamepad is not None else None)
|
||||
|
||||
def find_gamepad(self) -> SDLGamepad | None:
|
||||
"""Open the SDL3 handle that combines all connected gamepads."""
|
||||
@@ -207,9 +206,6 @@ class GamepadRuntimeMixin(InputMixin):
|
||||
logger.info("Gamepad axes configured for SDL backend: %s", device.name)
|
||||
|
||||
def _handle_pending_menu_fullscreen(self, current_time: float) -> None:
|
||||
if getattr(self, '_gamepad_polling_suspended', False):
|
||||
self.pending_menu_fullscreen_time = 0.0
|
||||
return
|
||||
if not self.pending_menu_fullscreen_time:
|
||||
return
|
||||
if current_time < self.pending_menu_fullscreen_time:
|
||||
@@ -221,10 +217,10 @@ class GamepadRuntimeMixin(InputMixin):
|
||||
|
||||
def _poll_button_events(self, gamepad: SDLGamepad, current_time: float) -> None:
|
||||
"""Emit button changes using SDL's standardized controller mapping."""
|
||||
# Deliver modifier buttons before their combinations in the same snapshot.
|
||||
# Deliver Guide before Select when both change in the same SDL snapshot.
|
||||
buttons = sorted(
|
||||
SDL_CONTROLLER_BUTTON_TO_PAD.items(),
|
||||
key=lambda item: (item[1] not in BUTTONS['guide'], item[1] != PAD_BUTTON_START),
|
||||
key=lambda item: item[1] not in BUTTONS['guide'],
|
||||
)
|
||||
for button_index, button_code in buttons:
|
||||
value = gamepad.get_button(button_index)
|
||||
@@ -234,8 +230,6 @@ class GamepadRuntimeMixin(InputMixin):
|
||||
if self._button_states.get(button_index) == value:
|
||||
return
|
||||
self._button_states[button_index] = value
|
||||
if not value and button_code in BUTTONS['confirm'] and self._set_keyboard_mouse_drag(False):
|
||||
return
|
||||
if getattr(self._parent, "boot_animation", None) is not None:
|
||||
self.button_event.emit(button_code, value)
|
||||
return
|
||||
@@ -248,8 +242,6 @@ class GamepadRuntimeMixin(InputMixin):
|
||||
if button_code == PAD_BUTTON_START:
|
||||
self.start_held = value == 1
|
||||
emulation_combo = self._handle_emulation_combo(button_code, value)
|
||||
if self._handle_system_keyboard_input(button_code, value, emulation_combo):
|
||||
return
|
||||
if self._is_mouse_emulation_active() and value == 1:
|
||||
if button_code in BUTTONS['confirm']:
|
||||
self.click_left()
|
||||
@@ -269,49 +261,10 @@ class GamepadRuntimeMixin(InputMixin):
|
||||
(button_code == PAD_BUTTON_START and self.select_held)
|
||||
)
|
||||
if emulation_combo:
|
||||
self._set_keyboard_mouse_drag(False)
|
||||
self.emulation_triggered = not self.emulation_triggered
|
||||
self.pending_menu_fullscreen_time = 0.0
|
||||
return emulation_combo
|
||||
|
||||
def _handle_system_keyboard_input(self, button_code: int, value: int, combo: bool) -> bool:
|
||||
keyboard = getattr(getattr(self, '_parent', None), 'system_keyboard', None)
|
||||
if keyboard is None:
|
||||
return False
|
||||
if combo:
|
||||
self._start_consumed = True
|
||||
return True
|
||||
if button_code == PAD_BUTTON_START:
|
||||
if value:
|
||||
self._start_consumed = False
|
||||
return True
|
||||
if getattr(self, '_start_consumed', False):
|
||||
return True
|
||||
if value and button_code in BUTTONS['prev_dir'] and self.start_held:
|
||||
self._start_consumed = True
|
||||
keyboard.toggle()
|
||||
return True
|
||||
if keyboard.isVisible():
|
||||
if button_code in BUTTONS['confirm'] and self._is_mouse_emulation_active() and self.ui:
|
||||
self._set_keyboard_mouse_drag(bool(value))
|
||||
return True
|
||||
actions = {'confirm': 'confirm', 'back': 'back', 'menu': 'back',
|
||||
'prev_tab': 'language', 'next_tab': 'shift', 'add_game': 'backspace'}
|
||||
if button_code == PAD_BUTTON_START and not value:
|
||||
keyboard.send('button', 'confirm')
|
||||
else:
|
||||
for name, action in actions.items():
|
||||
if button_code in BUTTONS[name]:
|
||||
if value:
|
||||
keyboard.send('button', action)
|
||||
elif name == 'add_game':
|
||||
keyboard.send('button', 'backspace_release')
|
||||
break
|
||||
return True
|
||||
if button_code == PAD_BUTTON_START and not value:
|
||||
self.button_event.emit(PAD_BUTTON_START, 1)
|
||||
return False
|
||||
|
||||
def _should_schedule_menu_fullscreen(self, button_code: int, value: int, emulation_combo: bool) -> bool:
|
||||
return (
|
||||
value == 1 and button_code in BUTTONS['menu'] and
|
||||
@@ -337,9 +290,9 @@ class GamepadRuntimeMixin(InputMixin):
|
||||
elif hat_value[0] > 0:
|
||||
self.move_mouse(10, 0)
|
||||
if previous_value[1] != hat_value[1]:
|
||||
if hat_value[1] < 0:
|
||||
if hat_value[1] > 0:
|
||||
self.move_mouse(0, -10)
|
||||
elif hat_value[1] > 0:
|
||||
elif hat_value[1] < 0:
|
||||
self.move_mouse(0, 10)
|
||||
|
||||
if self._should_skip_regular_events():
|
||||
@@ -398,15 +351,10 @@ class GamepadRuntimeMixin(InputMixin):
|
||||
|
||||
def _should_skip_regular_events(self) -> bool:
|
||||
"""Skip regular UI events while mouse emulation owns the controller."""
|
||||
keyboard = getattr(getattr(self, '_parent', None), 'system_keyboard', None)
|
||||
if keyboard is not None and keyboard.isVisible():
|
||||
return self._is_mouse_emulation_active() and bool(self.ui)
|
||||
if getattr(self, '_gamepad_polling_suspended', False):
|
||||
return True
|
||||
return self._is_mouse_emulation_active() and QApplication.activeWindow() is not None
|
||||
|
||||
def _poll_gamepad(self) -> None:
|
||||
if not self.running:
|
||||
if not self.running or self._gamepad_polling_suspended:
|
||||
return
|
||||
current_time = time.time()
|
||||
active_gamepad = self.gamepad
|
||||
@@ -434,7 +382,7 @@ class GamepadRuntimeMixin(InputMixin):
|
||||
self._poll_axis_events(active_gamepad, current_time)
|
||||
if (
|
||||
current_time - self.last_update >= self.update_interval and
|
||||
self._is_mouse_emulation_active()
|
||||
self.mouse_emulation_enabled and self.emulation_active and self.emulation_triggered
|
||||
):
|
||||
self.update_mouse_position()
|
||||
self.last_update = current_time
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"af+fa-olpc":{"normal":[["","۱","۲","۳","۴","۵","۶","۷","۸","۹","۰","-","="],["TAB","ض","ص","ث","ق","ف","غ","ع","ه","خ","ح","ج","چ","\\"],["CAPS","ش","س","ی","ب","ل","ا","ت","ن","م","ک","گ"],["⬆","<","ظ","ط","ز","ر","ذ","د","پ","و",".","/"]],"shift":[["÷","!","٬","٫","؋","٪","×","،","*",")","(","ـ","+"],["TAB","ْ","ٌ","ٍ","ً","ُ","ِ","َ","ّ","]","[","}","{","|"],["CAPS","ؤ","ئ","ي","إ","أ","آ","ة","»","«",":","؛"],["⬆",">","ك","ٓ","ژ","ٰ","","ٔ","ء",">","<","؟"]],"altgr":[["U200D","۱","۲","۳","۴","۵","۶","۷","۸","۹","۰","-","="],["TAB","ض","ص","ث","ق","ف","غ","ع","ه","خ","ح","ج","چ","\\"],["CAPS","ش","س","ی","ب","ل","ا","ت","ن","م","ک","گ"],["⬆","<","ظ","ط","ز","ر","ذ","د","پ","و",".","/"]],"shift_altgr":[["÷","!","٬","٫","؋","٪","×","،","*",")","(","ـ","+"],["TAB","ْ","ٌ","ٍ","ً","ُ","ِ","َ","ّ","]","[","}","{","|"],["CAPS","ؤ","ئ","ي","إ","أ","آ","ة","»","«",":","؛"],["⬆",">","ك","ٓ","ژ","ٰ","U200C","ٔ","ء",">","<","؟"]],"caps":[["U200D","۱","۲","۳","۴","۵","۶","۷","۸","۹","۰","-","="],["TAB","ض","ص","ث","ق","ف","غ","ع","ه","خ","ح","ج","چ","\\"],["CAPS","ش","س","ی","ب","ل","ا","ت","ن","م","ک","گ"],["⬆","<","ظ","ط","ز","ر","ذ","د","پ","و",".","/"]],"shift_caps":[["÷","!","٬","٫","؋","٪","×","،","*",")","(","ـ","+"],["TAB","ْ","ٌ","ٍ","ً","ُ","ِ","َ","ّ","]","[","}","{","|"],["CAPS","ؤ","ئ","ي","إ","أ","آ","ة","»","«",":","؛"],["⬆",">","ك","ٓ","ژ","ٰ","U200C","ٔ","ء",">","<","؟"]],"altgr_caps":[["U200D","۱","۲","۳","۴","۵","۶","۷","۸","۹","۰","-","="],["TAB","ض","ص","ث","ق","ف","غ","ع","ه","خ","ح","ج","چ","\\"],["CAPS","ش","س","ی","ب","ل","ا","ت","ن","م","ک","گ"],["⬆","<","ظ","ط","ز","ر","ذ","د","پ","و",".","/"]],"shift_altgr_caps":[["÷","!","٬","٫","؋","٪","×","،","*",")","(","ـ","+"],["TAB","ْ","ٌ","ٍ","ً","ُ","ِ","َ","ّ","]","[","}","{","|"],["CAPS","ؤ","ئ","ي","إ","أ","آ","ة","»","«",":","؛"],["⬆",">","ك","ٓ","ژ","ٰ","U200C","ٔ","ء",">","<","؟"]]},"af+ps-olpc":{"normal":[["","۱","۲","۳","۴","۵","۶","۷","۸","۹","۰","-","="],["TAB","ض","ص","ث","ق","ف","غ","ع","ه","خ","ح","ج","چ","\\"],["CAPS","ش","س","ی","ب","ل","ا","ت","ن","م","ک","ګ"],["⬆","<","ظ","ې","ز","ر","ذ","د","ړ","و","ږ","/"]],"shift":[["ٔ","!","٬","٫","؋","٪","×","»","«",")","(","ـ","+"],["TAB","ْ","ٌ","ٍ","ً","ُ","ِ","َ","ّ","ځ","څ","]","[","*"],["CAPS","ښ","ۍ","ي","پ","أ","آ","ټ","ڼ","ة",":","؛"],["⬆",">","ئ","ط","ژ","ء","","ډ","ؤ",".",".","؟"]],"altgr":[["U200D","۱","۲","۳","۴","۵","۶","۷","۸","۹","۰","-","="],["TAB","ض","ص","ث","ق","ف","غ","ع","ه","خ","ح","ج","چ","\\"],["CAPS","ش","س","ی","ب","ل","ا","ت","ن","م","ک","ګ"],["⬆","<","ظ","ې","ز","ر","ذ","د","ړ","و","ږ","/"]],"shift_altgr":[["ٔ","!","٬","٫","؋","٪","×","»","«",")","(","ـ","+"],["TAB","ْ","ٌ","ٍ","ً","ُ","ِ","َ","ّ","ځ","څ","]","[","*"],["CAPS","ښ","ۍ","ي","پ","أ","آ","ټ","ڼ","ة",":","؛"],["⬆",">","ئ","ط","ژ","ء","U200C","ډ","ؤ",".",".","؟"]],"caps":[["U200D","۱","۲","۳","۴","۵","۶","۷","۸","۹","۰","-","="],["TAB","ض","ص","ث","ق","ف","غ","ع","ه","خ","ح","ج","چ","\\"],["CAPS","ش","س","ی","ب","ل","ا","ت","ن","م","ک","ګ"],["⬆","<","ظ","ې","ز","ر","ذ","د","ړ","و","ږ","/"]],"shift_caps":[["ٔ","!","٬","٫","؋","٪","×","»","«",")","(","ـ","+"],["TAB","ْ","ٌ","ٍ","ً","ُ","ِ","َ","ّ","ځ","څ","]","[","*"],["CAPS","ښ","ۍ","ي","پ","أ","آ","ټ","ڼ","ة",":","؛"],["⬆",">","ئ","ط","ژ","ء","U200C","ډ","ؤ",".",".","؟"]],"altgr_caps":[["U200D","۱","۲","۳","۴","۵","۶","۷","۸","۹","۰","-","="],["TAB","ض","ص","ث","ق","ف","غ","ع","ه","خ","ح","ج","چ","\\"],["CAPS","ش","س","ی","ب","ل","ا","ت","ن","م","ک","ګ"],["⬆","<","ظ","ې","ز","ر","ذ","د","ړ","و","ږ","/"]],"shift_altgr_caps":[["ٔ","!","٬","٫","؋","٪","×","»","«",")","(","ـ","+"],["TAB","ْ","ٌ","ٍ","ً","ُ","ِ","َ","ّ","ځ","څ","]","[","*"],["CAPS","ښ","ۍ","ي","پ","أ","آ","ټ","ڼ","ة",":","؛"],["⬆",">","ئ","ط","ژ","ء","U200C","ډ","ؤ",".",".","؟"]]},"af+ps":{"normal":[["","۱","۲","۳","۴","۵","۶","۷","۸","۹","۰","-","="],["TAB","ض","ص","ث","ق","ف","غ","ع","ه","خ","ح","ج","چ","\\"],["CAPS","ش","س","ی","ب","ل","ا","ت","ن","م","ک","ګ"],["⬆","<","ۍ","ې","ز","ر","ذ","د","ړ","و","ږ","/"]],"shift":[["÷","!","٬","٫","","٪","×","»","«",")","(","ـ","+"],["TAB","ْ","ٌ","ٍ","ً","ُ","ِ","َ","ّ","ځ","څ","]","[","*"],["CAPS","ښ","ئ","ي","پ","أ","آ","ټ","ڼ","ة",":","؛"],["⬆",">","ظ","ط","ژ","ء","","ډ","ؤ","،",".","؟"]],"altgr":[["dead_tilde","`Line truncated
|
||||
{"af+fa-olpc":{"normal":[["","۱","۲","۳","۴","۵","۶","۷","۸","۹","۰","-","="],["TAB","ض","ص","ث","ق","ف","غ","ع","ه","خ","ح","ج","چ","\\"],["CAPS","ش","س","ی","ب","ل","ا","ت","ن","م","ک","گ"],["⬆","<","ظ","ط","ز","ر","ذ","د","پ","و",".","/"]],"shift":[["÷","!","٬","٫","؋","٪","×","،","*",")","(","ـ","+"],["TAB","ْ","ٌ","ٍ","ً","ُ","ِ","َ","ّ","]","[","}","{","|"],["CAPS","ؤ","ئ","ي","إ","أ","آ","ة","»","«",":","؛"],["⬆",">","ك","ٓ","ژ","ٰ","","ٔ","ء",">","<","؟"]]},"af+ps-olpc":{"normal":[["","۱","۲","۳","۴","۵","۶","۷","۸","۹","۰","-","="],["TAB","ض","ص","ث","ق","ف","غ","ع","ه","خ","ح","ج","چ","\\"],["CAPS","ش","س","ی","ب","ل","ا","ت","ن","م","ک","ګ"],["⬆","<","ظ","ې","ز","ر","ذ","د","ړ","و","ږ","/"]],"shift":[["ٔ","!","٬","٫","؋","٪","×","»","«",")","(","ـ","+"],["TAB","ْ","ٌ","ٍ","ً","ُ","ِ","َ","ّ","ځ","څ","]","[","*"],["CAPS","ښ","ۍ","ي","پ","أ","آ","ټ","ڼ","ة",":","؛"],["⬆",">","ئ","ط","ژ","ء","","ډ","ؤ",".",".","؟"]]},"af+ps":{"normal":[["","۱","۲","۳","۴","۵","۶","۷","۸","۹","۰","-","="],["TAB","ض","ص","ث","ق","ف","غ","ع","ه","خ","ح","ج","چ","\\"],["CAPS","ش","س","ی","ب","ل","ا","ت","ن","م","ک","ګ"],["⬆","<","ۍ","ې","ز","ر","ذ","د","ړ","و","ږ","/"]],"shift":[["÷","!","٬","٫","","٪","×","»","«",")","(","ـ","+"],["TAB","ْ","ٌ","ٍ","ً","ُ","ِ","َ","ّ","ځ","څ","]","[","*"],["CAPS","ښ","ئ","ي","پ","أ","آ","ټ","ڼ","ة",":","؛"],["⬆",">","ظ","ط","ژ","ء","","ډ","ؤ","،",".","؟"]]},"af+uz-olpc":{"normal":[["","۱","۲","۳","۴","۵","۶","۷","۸","۹","۰","-","="],["TAB","ض","ص","ث","ق","ف","غ","ع","ه","خ","ح","ج","چ","\\"],["CAPS","ش","س","ی","ب","ل","ا","ت","ن","م","ک","گ"],["⬆","<","ظ","ط","ز","ر","ذ","د","پ","و",".","/"]],"shift":[["÷","!","٬","٫","؋","٪","×","،","*",")","(","ـ","+"],["TAB","ْ","ٌ","ٍ","ً","ُ","ِ","َ","ّ","]","[","}","{","|"],["CAPS","ؤ","ئ","ي","ې","أ","آ","ة","»","«",":","؛"],["⬆",">","ۉ","ۇ","ژ","إ","","ٔ","ء",">","<","؟"]]},"af+uz":{"normal":[["","۱","۲","۳","۴","۵","۶","۷","۸","۹","۰","-","="],["TAB","ض","ص","ث","ق","ف","غ","ع","ه","خ","ح","ج","چ","\\"],["CAPS","ش","س","ی","ب","ل","ا","ت","ن","م","ک","گ"],["⬆","<","ظ","ط","ز","ر","ذ","د","پ","و",".","/"]],"shift":[["÷","!","٬","٫","","٪","×","،","*",")","(","ـ","+"],["TAB","ْ","ٌ","ٍ","ً","ُ","ِ","َ","ّ","]","[","}","{","|"],["CAPS","ؤ","ئ","ي","ې","أ","آ","ة","»","«",":","؛"],["⬆",">","ۉ","ۇ","ژ","إ","","ٔ","ء",">","<","؟"]]},"af":{"normal":[["","۱","۲","۳","۴","۵","۶","۷","۸","۹","۰","-","="],["TAB","ض","ص","ث","ق","ف","غ","ع","ه","خ","ح","ج","چ","\\"],["CAPS","ش","س","ی","ب","ل","ا","ت","ن","م","ک","گ"],["⬆","<","ظ","ط","ز","ر","ذ","د","پ","و",".","/"]],"shift":[["÷","!","٬","٫","","٪","×","،","*",")","(","ـ","+"],["TAB","ْ","ٌ","ٍ","ً","ُ","ِ","َ","ّ","]","[","}","{","|"],["CAPS","ؤ","ئ","ي","إ","أ","آ","ة","»","«",":","؛"],["⬆",">","ك","ٓ","ژ","ٰ","","ٔ","ء",">","<","؟"]]},"al+plisi":{"normal":[["`","1","2","3","4","5","6","7","8","9","0","-","="],["TAB","q","w","e","r","t","y","u","i","o","p","ç",">","\\"],["CAPS","a","s","d","f","g","h","j","k","l","ë","'"],["⬆","<","z","x","c","v","b","n","m",",",".","/"]],"shift":[["~","!","@","#","$","%","^","&&","*","(",")","_","+"],["TAB","Q","W","E","R","T","Y","U","I","O","P","Ç","<","|"],["CAPS","A","S","D","F","G","H","J","K","L","Ë","\""],["⬆",">","Z","X","C","V","B","N","M",";",":","?"]]},"al+veqilharxhi":{"normal":[["`","1","2","3","4","5","6","7","8","9","0","-","="],["TAB","𐖰","𐖟","𐖞","𐖱","𐖵","𐖻","𐖷","𐖥","𐖮","𐖯","[","]","\\"],["CAPS","𐖗","𐖳","𐖜","𐖠","𐖡","𐖣","𐖧","𐖨","𐖩",";","'"],["⬆","<","𐖼","𐖹","𐖚","𐖸","𐖘","𐖬","𐖫",",",".","/"]],"shift":[["~","!","@","#","$","%","^","&&","*","(",")","_","+"],["TAB","𐖉","𐕸","𐕷","𐖊","𐖎","𐖔","𐖐","𐕾","𐖇","𐖈","{","}","|"],["CAPS","𐕰","𐖌","𐕵","𐕹","𐕺","𐕼","𐖀","𐖁","𐖂",":","\""],["⬆",">","𐖕","𐖒","𐕳","𐖑","𐕱","𐖅","𐖄","<",">","?"]]},"al":{"normal":[["\\","1","2","3","4","5","6","7","8","9","0","-","="],["TAB","q","w","e","r","t","z","u","i","o","p","ç","@","]"],["CAPS","a","s","d","f","g","h","j","k","l","ë","["],["⬆","<","y","x","c","v","b","n","m",",",".","/"]],"shift":[["|","!","\"","#","$","%","^","&&","*","(",")","_","+"],["TAB","Q","W","E","R","T","Z","U","I","O","P","Ç","'","}"],["CAPS","A","S","D","F","G","H","J","K","L","Ë","{"],["⬆",">","Y","X","C","V","B","N","M",";",":","?"]]},"am+eastern-alt":{"normal":[["՝","։","ձ","յ","՛",",","-",".","«","»","օ","ռ","ժ"],["TABLine truncated
|
||||
@@ -1 +0,0 @@
|
||||
{"names":{"KP_Space":" ","KP_Equal":"=","KP_Multiply":"*","KP_Add":"+","KP_Separator":",","KP_Subtract":"-","KP_Decimal":".","KP_Divide":"/","KP_0":"0","KP_1":"1","KP_2":"2","KP_3":"3","KP_4":"4","KP_5":"5","KP_6":"6","KP_7":"7","KP_8":"8","KP_9":"9","space":" ","exclam":"!","quotedbl":"\"","numbersign":"#","dollar":"$","percent":"%","ampersand":"&","apostrophe":"'","quoteright":"'","parenleft":"(","parenright":")","asterisk":"*","plus":"+","comma":",","minus":"-","period":".","slash":"/","0":"0","1":"1","2":"2","3":"3","4":"4","5":"5","6":"6","7":"7","8":"8","9":"9","colon":":","semicolon":";","less":"<","equal":"=","greater":">","question":"?","at":"@","A":"A","B":"B","C":"C","D":"D","E":"E","F":"F","G":"G","H":"H","I":"I","J":"J","K":"K","L":"L","M":"M","N":"N","O":"O","P":"P","Q":"Q","R":"R","S":"S","T":"T","U":"U","V":"V","W":"W","X":"X","Y":"Y","Z":"Z","bracketleft":"[","backslash":"\\","bracketright":"]","asciicircum":"^","underscore":"_","grave":"`","quoteleft":"`","a":"a","b":"b","c":"c","d":"d","e":"e","f":"f","g":"g","h":"h","i":"i","j":"j","k":"k","l":"l","m":"m","n":"n","o":"o","p":"p","q":"q","r":"r","s":"s","t":"t","u":"u","v":"v","w":"w","x":"x","y":"y","z":"z","braceleft":"{","bar":"|","braceright":"}","asciitilde":"~","exclamdown":"¡","cent":"¢","sterling":"£","currency":"¤","yen":"¥","brokenbar":"¦","section":"§","diaeresis":"¨","copyright":"©","ordfeminine":"ª","guillemotleft":"«","guillemetleft":"«","notsign":"¬","registered":"®","macron":"¯","degree":"°","plusminus":"±","twosuperior":"²","threesuperior":"³","acute":"´","mu":"µ","paragraph":"¶","periodcentered":"·","cedilla":"¸","onesuperior":"¹","masculine":"º","ordmasculine":"º","guillemotright":"»","guillemetright":"»","onequarter":"¼","onehalf":"½","threequarters":"¾","questiondown":"¿","Agrave":"À","Aacute":"Á","Acircumflex":"Â","Atilde":"Ã","Adiaeresis":"Ä","Aring":"Å","AE":"Æ","Ccedilla":"Ç","Egrave":"È","Eacute":"É","Ecircumflex":"Ê","Ediaeresis":"Ë","Igrave":"Ì","Iacute":"Í","Icircumflex":"Î","Idiaeresis":"Ï","ETH":"Ð","Eth":"Ð","Ntilde":"Ñ","Ograve":"Ò","Oacute":"Ó","Ocircumflex":"Ô","Otilde":"Õ","Odiaeresis":"Ö","multiply":"×","Oslash":"Ø","Ooblique":"Ø","Ugrave":"Ù","Uacute":"Ú","Ucircumflex":"Û","Udiaeresis":"Ü","Yacute":"Ý","THORN":"Þ","Thorn":"Þ","ssharp":"ß","agrave":"à","aacute":"á","acircumflex":"â","atilde":"ã","adiaeresis":"ä","aring":"å","ae":"æ","ccedilla":"ç","egrave":"è","eacute":"é","ecircumflex":"ê","ediaeresis":"ë","igrave":"ì","iacute":"í","icircumflex":"î","idiaeresis":"ï","eth":"ð","ntilde":"ñ","ograve":"ò","oacute":"ó","ocircumflex":"ô","otilde":"õ","odiaeresis":"ö","division":"÷","oslash":"ø","ooblique":"ø","ugrave":"ù","uacute":"ú","ucircumflex":"û","udiaeresis":"ü","yacute":"ý","thorn":"þ","ydiaeresis":"ÿ","Aogonek":"Ą","breve":"˘","Lstroke":"Ł","Lcaron":"Ľ","Sacute":"Ś","Scaron":"Š","Scedilla":"Ş","Tcaron":"Ť","Zacute":"Ź","Zcaron":"Ž","Zabovedot":"Ż","aogonek":"ą","ogonek":"˛","lstroke":"ł","lcaron":"ľ","sacute":"ś","caron":"ˇ","scaron":"š","scedilla":"ş","tcaron":"ť","zacute":"ź","doubleacute":"˝","zcaron":"ž","zabovedot":"ż","Racute":"Ŕ","Abreve":"Ă","Lacute":"Ĺ","Cacute":"Ć","Ccaron":"Č","Eogonek":"Ę","Ecaron":"Ě","Dcaron":"Ď","Dstroke":"Đ","Nacute":"Ń","Ncaron":"Ň","Odoubleacute":"Ő","Rcaron":"Ř","Uring":"Ů","Udoubleacute":"Ű","Tcedilla":"Ţ","racute":"ŕ","abreve":"ă","lacute":"ĺ","cacute":"ć","ccaron":"č","eogonek":"ę","ecaron":"ě","dcaron":"ď","dstroke":"đ","nacute":"ń","ncaron":"ň","odoubleacute":"ő","rcaron":"ř","uring":"ů","udoubleacute":"ű","tcedilla":"ţ","abovedot":"˙","Hstroke":"Ħ","Hcircumflex":"Ĥ","Iabovedot":"İ","Gbreve":"Ğ","Jcircumflex":"Ĵ","hstroke":"ħ","hcircumflex":"ĥ","idotless":"ı","gbreve":"ğ","jcircumflex":"ĵ","Cabovedot":"Ċ","Ccircumflex":"Ĉ","Gabovedot":"Ġ","Gcircumflex":"Ĝ","Ubreve":"Ŭ","Scircumflex":"Ŝ","cabovedot":"ċ","ccircumflex":"ĉ","gabovedot":"ġ","gcircumflex":"ĝ","ubreve":"ŭ","scircumflex":"ŝ","kra":"ĸ","kappa":"ĸ","Rcedilla":"Ŗ","Itilde":"Ĩ","Lcedilla":"Ļ","Emacron":"Ē","Gcedilla":"Ģ","Tslash":"Ŧ","rcedilla":"ŗ","itilde":"ĩ","lcedilla":"ļ","emacron":"ē","gcedilla":"ģ","tslash":"ŧ","ENG":"Ŋ","eng":"ŋ","Amacron":"Ā","Iogonek":"Į","Eabovedot":"Ė","Imacron":"Ī","Ncedilla":"Ņ","Omacron":"Ō","Kcedilla":"Ķ","Uogonek":"Ų","Utilde":"Ũ","Umacron":"Ū","amacron":"ā","iogonek":"į","eabovedot":"ė","imacron":"ī","ncedilla":"ņ","omacron":"ō","kcedilla":"ķ","uogonek":"ų","utilde":"ũ","umacron":"ū","Wcircumflex":"Ŵ","wcircumflex":"ŵ","Ycircumflex":"Ŷ","ycircumflex":"ŷ","Babovedot":"Ḃ","babovedot":"ḃ","Dabovedot":"Ḋ","dabovedot":"ḋ","Fabovedot":"Ḟ","fabovedot":"ḟ","Mabovedot":"Ṁ","mabovedot":"ṁ","Pabovedot":"Ṗ","pabovedot":"ṗ","Sabovedot":"Ṡ","sabovedot":"ṡ","Tabovedot":"Ṫ","tabovedot":"ṫ","Wgrave":"Ẁ","wgrave":"ẁ","Wacute":"Ẃ","wacuteLine truncated
|
||||
@@ -420,13 +420,6 @@ msgstr ""
|
||||
msgid "Refresh Grid"
|
||||
msgstr ""
|
||||
|
||||
msgid "Cannot launch game while another game is running"
|
||||
msgstr ""
|
||||
|
||||
#, python-brace-format
|
||||
msgid "Failed to launch game: {0}"
|
||||
msgstr ""
|
||||
|
||||
msgid "Never"
|
||||
msgstr ""
|
||||
|
||||
@@ -486,6 +479,9 @@ msgstr ""
|
||||
msgid "PortProton start script not found"
|
||||
msgstr ""
|
||||
|
||||
msgid "Cannot launch game while another game is running"
|
||||
msgstr ""
|
||||
|
||||
msgid "Invalid command format (empty exec line)"
|
||||
msgstr ""
|
||||
|
||||
@@ -493,7 +489,7 @@ msgid "Invalid command format (native)"
|
||||
msgstr ""
|
||||
|
||||
#, python-brace-format
|
||||
msgid "Launch \"{name}\" with PortProton"
|
||||
msgid "Failed to launch game: {0}"
|
||||
msgstr ""
|
||||
|
||||
msgid "Choose Folder"
|
||||
@@ -696,10 +692,9 @@ msgstr ""
|
||||
msgid "Run After / Wrapper"
|
||||
msgstr ""
|
||||
|
||||
#, python-format
|
||||
msgid ""
|
||||
"Path to a second .exe, script, or wrapper command. Use %command% for the "
|
||||
"game command"
|
||||
"Path to a second .exe, script, or wrapper command. Example: systemd-run "
|
||||
"--user --scope --slice=app.slice"
|
||||
msgstr ""
|
||||
|
||||
msgid "CPU Cores Limit"
|
||||
@@ -800,6 +795,10 @@ msgstr ""
|
||||
msgid "No favorites"
|
||||
msgstr ""
|
||||
|
||||
#, python-brace-format
|
||||
msgid "Launch \"{name}\" with PortProton"
|
||||
msgstr ""
|
||||
|
||||
msgid "Debug log mode was launched"
|
||||
msgstr ""
|
||||
|
||||
@@ -1063,6 +1062,10 @@ msgstr ""
|
||||
msgid "Download Selected"
|
||||
msgstr ""
|
||||
|
||||
#, python-brace-format
|
||||
msgid "Error loading WINE/Proton: {error}"
|
||||
msgstr ""
|
||||
|
||||
msgid "Version WINE/Proton"
|
||||
msgstr ""
|
||||
|
||||
@@ -1082,9 +1085,6 @@ msgstr ""
|
||||
msgid "Select to remove this WINE/Proton"
|
||||
msgstr ""
|
||||
|
||||
msgid "Loading…"
|
||||
msgstr ""
|
||||
|
||||
#, python-brace-format
|
||||
msgid "Selected {} WINE/Proton:\n"
|
||||
msgstr ""
|
||||
@@ -1189,9 +1189,6 @@ msgstr ""
|
||||
msgid "Exe Settings"
|
||||
msgstr ""
|
||||
|
||||
msgid "Native"
|
||||
msgstr ""
|
||||
|
||||
msgid "Edit user.conf"
|
||||
msgstr ""
|
||||
|
||||
@@ -2006,9 +2003,6 @@ msgstr ""
|
||||
msgid "Mouse Emulation"
|
||||
msgstr ""
|
||||
|
||||
msgid "System Keyboard"
|
||||
msgstr ""
|
||||
|
||||
msgid "Connect"
|
||||
msgstr ""
|
||||
|
||||
@@ -2129,6 +2123,9 @@ msgstr ""
|
||||
msgid "Select installation folder"
|
||||
msgstr ""
|
||||
|
||||
msgid "Another download is running"
|
||||
msgstr ""
|
||||
|
||||
msgid "Another GOG operation is already running"
|
||||
msgstr ""
|
||||
|
||||
@@ -2514,6 +2511,9 @@ msgstr ""
|
||||
msgid "Light"
|
||||
msgstr ""
|
||||
|
||||
msgid "Loading…"
|
||||
msgstr ""
|
||||
|
||||
msgid "Failed to load themes"
|
||||
msgstr ""
|
||||
|
||||
|
||||
@@ -433,13 +433,6 @@ msgstr "Entpacken"
|
||||
msgid "Refresh Grid"
|
||||
msgstr "Ansicht aktualisieren"
|
||||
|
||||
msgid "Cannot launch game while another game is running"
|
||||
msgstr "Das Spiel kann nicht gestartet werden, während ein anderes Spiel läuft"
|
||||
|
||||
#, python-brace-format
|
||||
msgid "Failed to launch game: {0}"
|
||||
msgstr "Spiel konnte nicht gestartet werden: {0}"
|
||||
|
||||
msgid "Never"
|
||||
msgstr "Niemals"
|
||||
|
||||
@@ -504,6 +497,9 @@ msgstr "Spiel nicht gefunden."
|
||||
msgid "PortProton start script not found"
|
||||
msgstr "PortProton-Startskript nicht gefunden"
|
||||
|
||||
msgid "Cannot launch game while another game is running"
|
||||
msgstr "Das Spiel kann nicht gestartet werden, während ein anderes Spiel läuft"
|
||||
|
||||
msgid "Invalid command format (empty exec line)"
|
||||
msgstr "Ungültiges Befehlsformat (leere exec-Zeile)"
|
||||
|
||||
@@ -511,8 +507,8 @@ msgid "Invalid command format (native)"
|
||||
msgstr "Ungültiges Befehlsformat"
|
||||
|
||||
#, python-brace-format
|
||||
msgid "Launch \"{name}\" with PortProton"
|
||||
msgstr "Ausführen \"{name}\" mit PortProton"
|
||||
msgid "Failed to launch game: {0}"
|
||||
msgstr "Spiel konnte nicht gestartet werden: {0}"
|
||||
|
||||
msgid "Choose Folder"
|
||||
msgstr "Ordner auswählen"
|
||||
@@ -754,13 +750,12 @@ msgstr ""
|
||||
msgid "Run After / Wrapper"
|
||||
msgstr "Nach Start ausführen / Wrapper"
|
||||
|
||||
#, fuzzy, python-format
|
||||
msgid ""
|
||||
"Path to a second .exe, script, or wrapper command. Use %command% for the "
|
||||
"game command"
|
||||
"Path to a second .exe, script, or wrapper command. Example: systemd-run "
|
||||
"--user --scope --slice=app.slice"
|
||||
msgstr ""
|
||||
"Pfad zu einer zweiten .exe-Datei, einem Skript oder einem Wrapper-Befehl."
|
||||
" Beispiel: systemd-run --user --scope --slice=app.slice"
|
||||
"Pfad zu einer zweiten .exe-Datei, einem Skript oder einem Wrapper-Befehl. "
|
||||
"Beispiel: systemd-run --user --scope --slice=app.slice"
|
||||
|
||||
msgid "CPU Cores Limit"
|
||||
msgstr "CPU-Kerne-Limit"
|
||||
@@ -877,6 +872,10 @@ msgstr "Keine aktuellen Spiele"
|
||||
msgid "No favorites"
|
||||
msgstr "Keine Favoriten"
|
||||
|
||||
#, python-brace-format
|
||||
msgid "Launch \"{name}\" with PortProton"
|
||||
msgstr "Ausführen \"{name}\" mit PortProton"
|
||||
|
||||
msgid "Debug log mode was launched"
|
||||
msgstr "Der Debug-Protokollmodus wurde gestartet"
|
||||
|
||||
@@ -1146,6 +1145,10 @@ msgstr "Herunterladen: "
|
||||
msgid "Download Selected"
|
||||
msgstr "Ausgewählte herunterladen"
|
||||
|
||||
#, python-brace-format
|
||||
msgid "Error loading WINE/Proton: {error}"
|
||||
msgstr "Fehler beim Herunterladen von WINE/Proton: {error}"
|
||||
|
||||
msgid "Version WINE/Proton"
|
||||
msgstr "WINE/Proton Version"
|
||||
|
||||
@@ -1165,9 +1168,6 @@ msgstr "Installiert"
|
||||
msgid "Select to remove this WINE/Proton"
|
||||
msgstr "Wähle, um WINE/Proton zu entfernen"
|
||||
|
||||
msgid "Loading…"
|
||||
msgstr "Laden…"
|
||||
|
||||
#, python-brace-format
|
||||
msgid "Selected {} WINE/Proton:\n"
|
||||
msgstr "Ausgewählt {} WINE/Proton:\n"
|
||||
@@ -1278,10 +1278,6 @@ msgstr "Globale Spieleinstellungen"
|
||||
msgid "Exe Settings"
|
||||
msgstr "Einstellungen für die exe-Datei"
|
||||
|
||||
#, fuzzy
|
||||
msgid "Native"
|
||||
msgstr "Nach Bildausgabe"
|
||||
|
||||
msgid "Edit user.conf"
|
||||
msgstr "user.conf bearbeiten"
|
||||
|
||||
@@ -2114,10 +2110,6 @@ msgstr "Vollbild"
|
||||
msgid "Mouse Emulation"
|
||||
msgstr "Mausemulation"
|
||||
|
||||
#, fuzzy
|
||||
msgid "System Keyboard"
|
||||
msgstr "Tastatur-Eingabe abfangen"
|
||||
|
||||
msgid "Connect"
|
||||
msgstr "Verbinden"
|
||||
|
||||
@@ -2238,6 +2230,9 @@ msgstr "Aktualisierung der Epic-Bibliothek fehlgeschlagen: {0}"
|
||||
msgid "Select installation folder"
|
||||
msgstr "Installationsordner auswählen"
|
||||
|
||||
msgid "Another download is running"
|
||||
msgstr "Ein weiterer Download läuft"
|
||||
|
||||
msgid "Another GOG operation is already running"
|
||||
msgstr "Eine andere GOG-Aktion läuft bereits"
|
||||
|
||||
@@ -2629,6 +2624,9 @@ msgstr "Dunkel"
|
||||
msgid "Light"
|
||||
msgstr "Hell"
|
||||
|
||||
msgid "Loading…"
|
||||
msgstr "Laden…"
|
||||
|
||||
msgid "Failed to load themes"
|
||||
msgstr "Laden der Themes fehlgeschlagen"
|
||||
|
||||
|
||||
@@ -434,13 +434,6 @@ msgstr "Extrayendo"
|
||||
msgid "Refresh Grid"
|
||||
msgstr "Actualizar cuadrícula"
|
||||
|
||||
msgid "Cannot launch game while another game is running"
|
||||
msgstr "No se puede iniciar el juego mientras hay otro en ejecución"
|
||||
|
||||
#, python-brace-format
|
||||
msgid "Failed to launch game: {0}"
|
||||
msgstr "Error al iniciar el juego: {0}"
|
||||
|
||||
msgid "Never"
|
||||
msgstr "Nunca"
|
||||
|
||||
@@ -504,6 +497,9 @@ msgstr "Juego no encontrado."
|
||||
msgid "PortProton start script not found"
|
||||
msgstr "No se ha encontrado el script de inicio de PortProton"
|
||||
|
||||
msgid "Cannot launch game while another game is running"
|
||||
msgstr "No se puede iniciar el juego mientras hay otro en ejecución"
|
||||
|
||||
msgid "Invalid command format (empty exec line)"
|
||||
msgstr "Formato de comando no válido (línea de ejecución vacía)"
|
||||
|
||||
@@ -511,8 +507,8 @@ msgid "Invalid command format (native)"
|
||||
msgstr "Formato de comando no válido (nativo)"
|
||||
|
||||
#, python-brace-format
|
||||
msgid "Launch \"{name}\" with PortProton"
|
||||
msgstr "Iniciar «{name}» con PortProton"
|
||||
msgid "Failed to launch game: {0}"
|
||||
msgstr "Error al iniciar el juego: {0}"
|
||||
|
||||
msgid "Choose Folder"
|
||||
msgstr "Seleccionar carpeta"
|
||||
@@ -769,10 +765,9 @@ msgstr ""
|
||||
msgid "Run After / Wrapper"
|
||||
msgstr "Ejecutar después / Envoltorio"
|
||||
|
||||
#, fuzzy, python-format
|
||||
msgid ""
|
||||
"Path to a second .exe, script, or wrapper command. Use %command% for the "
|
||||
"game command"
|
||||
"Path to a second .exe, script, or wrapper command. Example: systemd-run "
|
||||
"--user --scope --slice=app.slice"
|
||||
msgstr ""
|
||||
"Ruta a un segundo archivo .exe, script o comando de envoltura. Ejemplo: "
|
||||
"systemd-run --user --scope --slice=app.slice"
|
||||
@@ -892,6 +887,10 @@ msgstr "Sin juegos recientes"
|
||||
msgid "No favorites"
|
||||
msgstr "Sin favoritos"
|
||||
|
||||
#, python-brace-format
|
||||
msgid "Launch \"{name}\" with PortProton"
|
||||
msgstr "Iniciar «{name}» con PortProton"
|
||||
|
||||
msgid "Debug log mode was launched"
|
||||
msgstr "Se ha iniciado el modo de registro de depuración"
|
||||
|
||||
@@ -1160,6 +1159,10 @@ msgstr "Descargando: "
|
||||
msgid "Download Selected"
|
||||
msgstr "Descargar seleccionados"
|
||||
|
||||
#, python-brace-format
|
||||
msgid "Error loading WINE/Proton: {error}"
|
||||
msgstr "Error al cargar WINE/Proton: {error}"
|
||||
|
||||
msgid "Version WINE/Proton"
|
||||
msgstr "Versión de WINE/Proton"
|
||||
|
||||
@@ -1179,9 +1182,6 @@ msgstr "Instalado"
|
||||
msgid "Select to remove this WINE/Proton"
|
||||
msgstr "Seleccione para eliminar WINE/Proton"
|
||||
|
||||
msgid "Loading…"
|
||||
msgstr "Cargando…"
|
||||
|
||||
#, python-brace-format
|
||||
msgid "Selected {} WINE/Proton:\n"
|
||||
msgstr "Seleccionado {} WINE/Proton:\n"
|
||||
@@ -1291,9 +1291,6 @@ msgstr "Ajustes de Wine"
|
||||
msgid "Exe Settings"
|
||||
msgstr ""
|
||||
|
||||
msgid "Native"
|
||||
msgstr ""
|
||||
|
||||
msgid "Edit user.conf"
|
||||
msgstr ""
|
||||
|
||||
@@ -2117,9 +2114,6 @@ msgstr ""
|
||||
msgid "Mouse Emulation"
|
||||
msgstr ""
|
||||
|
||||
msgid "System Keyboard"
|
||||
msgstr ""
|
||||
|
||||
msgid "Connect"
|
||||
msgstr ""
|
||||
|
||||
@@ -2241,6 +2235,10 @@ msgstr "Error al iniciar el juego: {0}"
|
||||
msgid "Select installation folder"
|
||||
msgstr ""
|
||||
|
||||
#, fuzzy
|
||||
msgid "Another download is running"
|
||||
msgstr "Descargando"
|
||||
|
||||
msgid "Another GOG operation is already running"
|
||||
msgstr ""
|
||||
|
||||
@@ -2635,6 +2633,9 @@ msgstr ""
|
||||
msgid "Light"
|
||||
msgstr ""
|
||||
|
||||
msgid "Loading…"
|
||||
msgstr "Cargando…"
|
||||
|
||||
msgid "Failed to load themes"
|
||||
msgstr "Error al cargar los temas"
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PortProtonQt 0.1.1\n"
|
||||
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
|
||||
"POT-Creation-Date: 2026-11-20 23:00+0500\n"
|
||||
"POT-Creation-Date: 2026-10-24 18:13+0500\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
@@ -416,13 +416,6 @@ msgstr ""
|
||||
msgid "Refresh Grid"
|
||||
msgstr ""
|
||||
|
||||
msgid "Cannot launch game while another game is running"
|
||||
msgstr ""
|
||||
|
||||
#, python-brace-format
|
||||
msgid "Failed to launch game: {0}"
|
||||
msgstr ""
|
||||
|
||||
msgid "Never"
|
||||
msgstr ""
|
||||
|
||||
@@ -482,6 +475,9 @@ msgstr ""
|
||||
msgid "PortProton start script not found"
|
||||
msgstr ""
|
||||
|
||||
msgid "Cannot launch game while another game is running"
|
||||
msgstr ""
|
||||
|
||||
msgid "Invalid command format (empty exec line)"
|
||||
msgstr ""
|
||||
|
||||
@@ -489,7 +485,7 @@ msgid "Invalid command format (native)"
|
||||
msgstr ""
|
||||
|
||||
#, python-brace-format
|
||||
msgid "Launch \"{name}\" with PortProton"
|
||||
msgid "Failed to launch game: {0}"
|
||||
msgstr ""
|
||||
|
||||
msgid "Choose Folder"
|
||||
@@ -692,10 +688,9 @@ msgstr ""
|
||||
msgid "Run After / Wrapper"
|
||||
msgstr ""
|
||||
|
||||
#, python-format
|
||||
msgid ""
|
||||
"Path to a second .exe, script, or wrapper command. Use %command% for the "
|
||||
"game command"
|
||||
"Path to a second .exe, script, or wrapper command. Example: systemd-run "
|
||||
"--user --scope --slice=app.slice"
|
||||
msgstr ""
|
||||
|
||||
msgid "CPU Cores Limit"
|
||||
@@ -796,6 +791,10 @@ msgstr ""
|
||||
msgid "No favorites"
|
||||
msgstr ""
|
||||
|
||||
#, python-brace-format
|
||||
msgid "Launch \"{name}\" with PortProton"
|
||||
msgstr ""
|
||||
|
||||
msgid "Debug log mode was launched"
|
||||
msgstr ""
|
||||
|
||||
@@ -1059,6 +1058,10 @@ msgstr ""
|
||||
msgid "Download Selected"
|
||||
msgstr ""
|
||||
|
||||
#, python-brace-format
|
||||
msgid "Error loading WINE/Proton: {error}"
|
||||
msgstr ""
|
||||
|
||||
msgid "Version WINE/Proton"
|
||||
msgstr ""
|
||||
|
||||
@@ -1078,9 +1081,6 @@ msgstr ""
|
||||
msgid "Select to remove this WINE/Proton"
|
||||
msgstr ""
|
||||
|
||||
msgid "Loading…"
|
||||
msgstr ""
|
||||
|
||||
#, python-brace-format
|
||||
msgid "Selected {} WINE/Proton:\n"
|
||||
msgstr ""
|
||||
@@ -1185,9 +1185,6 @@ msgstr ""
|
||||
msgid "Exe Settings"
|
||||
msgstr ""
|
||||
|
||||
msgid "Native"
|
||||
msgstr ""
|
||||
|
||||
msgid "Edit user.conf"
|
||||
msgstr ""
|
||||
|
||||
@@ -2002,9 +1999,6 @@ msgstr ""
|
||||
msgid "Mouse Emulation"
|
||||
msgstr ""
|
||||
|
||||
msgid "System Keyboard"
|
||||
msgstr ""
|
||||
|
||||
msgid "Connect"
|
||||
msgstr ""
|
||||
|
||||
@@ -2125,6 +2119,9 @@ msgstr ""
|
||||
msgid "Select installation folder"
|
||||
msgstr ""
|
||||
|
||||
msgid "Another download is running"
|
||||
msgstr ""
|
||||
|
||||
msgid "Another GOG operation is already running"
|
||||
msgstr ""
|
||||
|
||||
@@ -2511,6 +2508,9 @@ msgstr ""
|
||||
msgid "Light"
|
||||
msgstr ""
|
||||
|
||||
msgid "Loading…"
|
||||
msgstr ""
|
||||
|
||||
msgid "Failed to load themes"
|
||||
msgstr ""
|
||||
|
||||
|
||||
@@ -433,13 +433,6 @@ msgstr "Extraindo"
|
||||
msgid "Refresh Grid"
|
||||
msgstr "Atualizar Grade"
|
||||
|
||||
msgid "Cannot launch game while another game is running"
|
||||
msgstr "Não é possível iniciar o jogo enquanto outro jogo estiver em execução"
|
||||
|
||||
#, python-brace-format
|
||||
msgid "Failed to launch game: {0}"
|
||||
msgstr "Falha ao iniciar o jogo: {0}"
|
||||
|
||||
msgid "Never"
|
||||
msgstr "Nunca"
|
||||
|
||||
@@ -503,6 +496,9 @@ msgstr "Jogo não encontrado."
|
||||
msgid "PortProton start script not found"
|
||||
msgstr "Script de inicialização do PortProton não encontrado"
|
||||
|
||||
msgid "Cannot launch game while another game is running"
|
||||
msgstr "Não é possível iniciar o jogo enquanto outro jogo estiver em execução"
|
||||
|
||||
msgid "Invalid command format (empty exec line)"
|
||||
msgstr "Formato de comando inválido (linha exec vazia)"
|
||||
|
||||
@@ -510,8 +506,8 @@ msgid "Invalid command format (native)"
|
||||
msgstr "Formato de comando inválido (nativo)"
|
||||
|
||||
#, python-brace-format
|
||||
msgid "Launch \"{name}\" with PortProton"
|
||||
msgstr "Iniciar \"{name}\" com o PortProton"
|
||||
msgid "Failed to launch game: {0}"
|
||||
msgstr "Falha ao iniciar o jogo: {0}"
|
||||
|
||||
msgid "Choose Folder"
|
||||
msgstr "Escolher Pasta"
|
||||
@@ -754,10 +750,9 @@ msgstr ""
|
||||
msgid "Run After / Wrapper"
|
||||
msgstr "Executar após / Wrapper"
|
||||
|
||||
#, fuzzy, python-format
|
||||
msgid ""
|
||||
"Path to a second .exe, script, or wrapper command. Use %command% for the "
|
||||
"game command"
|
||||
"Path to a second .exe, script, or wrapper command. Example: systemd-run "
|
||||
"--user --scope --slice=app.slice"
|
||||
msgstr ""
|
||||
"Caminho para um segundo arquivo .exe, script ou comando wrapper. Exemplo:"
|
||||
" systemd-run --user --scope --slice=app.slice"
|
||||
@@ -879,6 +874,10 @@ msgstr "Nenhum jogo recente"
|
||||
msgid "No favorites"
|
||||
msgstr "Nenhum favorito"
|
||||
|
||||
#, python-brace-format
|
||||
msgid "Launch \"{name}\" with PortProton"
|
||||
msgstr "Iniciar \"{name}\" com o PortProton"
|
||||
|
||||
msgid "Debug log mode was launched"
|
||||
msgstr "O modo de log de depuração foi iniciado"
|
||||
|
||||
@@ -1146,6 +1145,10 @@ msgstr "Baixando: "
|
||||
msgid "Download Selected"
|
||||
msgstr "Baixar Selecionados"
|
||||
|
||||
#, python-brace-format
|
||||
msgid "Error loading WINE/Proton: {error}"
|
||||
msgstr "Erro ao carregar WINE/Proton: {error}"
|
||||
|
||||
msgid "Version WINE/Proton"
|
||||
msgstr "Versão WINE/Proton"
|
||||
|
||||
@@ -1165,9 +1168,6 @@ msgstr "Instalado"
|
||||
msgid "Select to remove this WINE/Proton"
|
||||
msgstr "Selecione para remover este WINE/Proton"
|
||||
|
||||
msgid "Loading…"
|
||||
msgstr "Carregando…"
|
||||
|
||||
#, python-brace-format
|
||||
msgid "Selected {} WINE/Proton:\n"
|
||||
msgstr "{} WINE/Proton selecionado(s):\n"
|
||||
@@ -1277,10 +1277,6 @@ msgstr "Configurações globais dos jogos"
|
||||
msgid "Exe Settings"
|
||||
msgstr "Configurações do Exe"
|
||||
|
||||
#, fuzzy
|
||||
msgid "Native"
|
||||
msgstr "Tardio"
|
||||
|
||||
msgid "Edit user.conf"
|
||||
msgstr "Editar o arquivo user.conf"
|
||||
|
||||
@@ -2111,10 +2107,6 @@ msgstr "Tela Cheia"
|
||||
msgid "Mouse Emulation"
|
||||
msgstr "Emulação de Mouse"
|
||||
|
||||
#, fuzzy
|
||||
msgid "System Keyboard"
|
||||
msgstr "Capturar o teclado"
|
||||
|
||||
msgid "Connect"
|
||||
msgstr "Conectar"
|
||||
|
||||
@@ -2235,6 +2227,9 @@ msgstr "Falha ao atualizar a biblioteca da Epic: {0}"
|
||||
msgid "Select installation folder"
|
||||
msgstr "Selecionar pasta de instalação"
|
||||
|
||||
msgid "Another download is running"
|
||||
msgstr "Outro download está em andamento"
|
||||
|
||||
msgid "Another GOG operation is already running"
|
||||
msgstr "Outra operação da GOG já está em execução"
|
||||
|
||||
@@ -2624,6 +2619,9 @@ msgstr "Escuro"
|
||||
msgid "Light"
|
||||
msgstr "Claro"
|
||||
|
||||
msgid "Loading…"
|
||||
msgstr "Carregando…"
|
||||
|
||||
msgid "Failed to load themes"
|
||||
msgstr "Falha ao carregar temas"
|
||||
|
||||
|
||||
@@ -431,13 +431,6 @@ msgstr "Распаковка"
|
||||
msgid "Refresh Grid"
|
||||
msgstr "Обновить сетку"
|
||||
|
||||
msgid "Cannot launch game while another game is running"
|
||||
msgstr "Невозможно запустить игру пока запущена другая"
|
||||
|
||||
#, python-brace-format
|
||||
msgid "Failed to launch game: {0}"
|
||||
msgstr "Не удалось запустить игру: {0}"
|
||||
|
||||
msgid "Never"
|
||||
msgstr "Никогда"
|
||||
|
||||
@@ -500,6 +493,9 @@ msgstr "Игра не найдена."
|
||||
msgid "PortProton start script not found"
|
||||
msgstr "Скрипт запуска PortProton не найден"
|
||||
|
||||
msgid "Cannot launch game while another game is running"
|
||||
msgstr "Невозможно запустить игру пока запущена другая"
|
||||
|
||||
msgid "Invalid command format (empty exec line)"
|
||||
msgstr "Неправильный формат команды (пустая строка exec)"
|
||||
|
||||
@@ -507,8 +503,8 @@ msgid "Invalid command format (native)"
|
||||
msgstr "Неверный формат команды (нативный)"
|
||||
|
||||
#, python-brace-format
|
||||
msgid "Launch \"{name}\" with PortProton"
|
||||
msgstr "Запустить «{name}» с помощью PortProton"
|
||||
msgid "Failed to launch game: {0}"
|
||||
msgstr "Не удалось запустить игру: {0}"
|
||||
|
||||
msgid "Choose Folder"
|
||||
msgstr "Выбрать папку"
|
||||
@@ -750,10 +746,9 @@ msgstr ""
|
||||
msgid "Run After / Wrapper"
|
||||
msgstr "Запустить после"
|
||||
|
||||
#, fuzzy, python-format
|
||||
msgid ""
|
||||
"Path to a second .exe, script, or wrapper command. Use %command% for the "
|
||||
"game command"
|
||||
"Path to a second .exe, script, or wrapper command. Example: systemd-run "
|
||||
"--user --scope --slice=app.slice"
|
||||
msgstr ""
|
||||
"Путь к второму файлу .exe, скрипту или команде-обёртке. Пример: systemd-"
|
||||
"run --user --scope --slice=app.slice"
|
||||
@@ -877,6 +872,10 @@ msgstr "Нет недавних игр"
|
||||
msgid "No favorites"
|
||||
msgstr "Нет избранных"
|
||||
|
||||
#, python-brace-format
|
||||
msgid "Launch \"{name}\" with PortProton"
|
||||
msgstr "Запустить «{name}» с помощью PortProton"
|
||||
|
||||
msgid "Debug log mode was launched"
|
||||
msgstr "Запущен режим логирования"
|
||||
|
||||
@@ -1144,6 +1143,10 @@ msgstr "Скачивание: "
|
||||
msgid "Download Selected"
|
||||
msgstr "Скачать выбранное"
|
||||
|
||||
#, python-brace-format
|
||||
msgid "Error loading WINE/Proton: {error}"
|
||||
msgstr "Ошибка загрузки WINE/Proton: {error}"
|
||||
|
||||
msgid "Version WINE/Proton"
|
||||
msgstr "Версия WINE/Proton"
|
||||
|
||||
@@ -1163,9 +1166,6 @@ msgstr "Установленные"
|
||||
msgid "Select to remove this WINE/Proton"
|
||||
msgstr "Выберите, чтобы удалить WINE/Proton"
|
||||
|
||||
msgid "Loading…"
|
||||
msgstr "Загрузка…"
|
||||
|
||||
#, python-brace-format
|
||||
msgid "Selected {} WINE/Proton:\n"
|
||||
msgstr "Выбрано {} WINE/Proton:\n"
|
||||
@@ -1275,10 +1275,6 @@ msgstr "Глобальные настройки игры"
|
||||
msgid "Exe Settings"
|
||||
msgstr "Настройки EXE"
|
||||
|
||||
#, fuzzy
|
||||
msgid "Native"
|
||||
msgstr "После отображения кадра"
|
||||
|
||||
msgid "Edit user.conf"
|
||||
msgstr "Изменить user.conf"
|
||||
|
||||
@@ -2107,10 +2103,6 @@ msgstr "Полный экран"
|
||||
msgid "Mouse Emulation"
|
||||
msgstr "Эмуляция мыши"
|
||||
|
||||
#, fuzzy
|
||||
msgid "System Keyboard"
|
||||
msgstr "Перехват нажатий кнопок клавиатуры"
|
||||
|
||||
msgid "Connect"
|
||||
msgstr "Подключиться"
|
||||
|
||||
@@ -2229,6 +2221,9 @@ msgstr "Не удалось обновить библиотеку Epic: {0}"
|
||||
msgid "Select installation folder"
|
||||
msgstr "Выберите папку установки"
|
||||
|
||||
msgid "Another download is running"
|
||||
msgstr "Другая загрузка уже выполняется"
|
||||
|
||||
msgid "Another GOG operation is already running"
|
||||
msgstr "Другая операция GOG уже выполняется"
|
||||
|
||||
@@ -2614,6 +2609,9 @@ msgstr "Тёмная"
|
||||
msgid "Light"
|
||||
msgstr "Светлая"
|
||||
|
||||
msgid "Loading…"
|
||||
msgstr "Загрузка…"
|
||||
|
||||
msgid "Failed to load themes"
|
||||
msgstr "Не удалось загрузить темы"
|
||||
|
||||
|
||||
@@ -422,13 +422,6 @@ msgstr "正在提取"
|
||||
msgid "Refresh Grid"
|
||||
msgstr "刷新网格"
|
||||
|
||||
msgid "Cannot launch game while another game is running"
|
||||
msgstr "另一游戏正在运行时无法启动游戏"
|
||||
|
||||
#, python-brace-format
|
||||
msgid "Failed to launch game: {0}"
|
||||
msgstr "启动游戏失败:{0}"
|
||||
|
||||
msgid "Never"
|
||||
msgstr "从不"
|
||||
|
||||
@@ -493,6 +486,9 @@ msgstr "未找到游戏。"
|
||||
msgid "PortProton start script not found"
|
||||
msgstr "未找到 PortProton 启动脚本"
|
||||
|
||||
msgid "Cannot launch game while another game is running"
|
||||
msgstr "另一游戏正在运行时无法启动游戏"
|
||||
|
||||
msgid "Invalid command format (empty exec line)"
|
||||
msgstr "命令格式无效(exec 行为空)"
|
||||
|
||||
@@ -500,8 +496,8 @@ msgid "Invalid command format (native)"
|
||||
msgstr "命令格式无效(原生)"
|
||||
|
||||
#, python-brace-format
|
||||
msgid "Launch \"{name}\" with PortProton"
|
||||
msgstr "使用 PortProton 启动\"{name}\""
|
||||
msgid "Failed to launch game: {0}"
|
||||
msgstr "启动游戏失败:{0}"
|
||||
|
||||
msgid "Choose Folder"
|
||||
msgstr "选择文件夹"
|
||||
@@ -727,10 +723,9 @@ msgstr ""
|
||||
msgid "Run After / Wrapper"
|
||||
msgstr "运行后 / 包装器"
|
||||
|
||||
#, fuzzy, python-format
|
||||
msgid ""
|
||||
"Path to a second .exe, script, or wrapper command. Use %command% for the "
|
||||
"game command"
|
||||
"Path to a second .exe, script, or wrapper command. Example: systemd-run "
|
||||
"--user --scope --slice=app.slice"
|
||||
msgstr "指向第二个 .exe、脚本或包装器命令的路径。示例:systemd-run --user --scope --slice=app.slice"
|
||||
|
||||
msgid "CPU Cores Limit"
|
||||
@@ -841,6 +836,10 @@ msgstr "无最近游戏"
|
||||
msgid "No favorites"
|
||||
msgstr "无收藏"
|
||||
|
||||
#, python-brace-format
|
||||
msgid "Launch \"{name}\" with PortProton"
|
||||
msgstr "使用 PortProton 启动\"{name}\""
|
||||
|
||||
msgid "Debug log mode was launched"
|
||||
msgstr "调试日志模式已启动"
|
||||
|
||||
@@ -1111,6 +1110,10 @@ msgstr "正在下载: "
|
||||
msgid "Download Selected"
|
||||
msgstr "下载选定项"
|
||||
|
||||
#, python-brace-format
|
||||
msgid "Error loading WINE/Proton: {error}"
|
||||
msgstr "加载 WINE/Proton 时出错:{error}"
|
||||
|
||||
msgid "Version WINE/Proton"
|
||||
msgstr "WINE/Proton 版本"
|
||||
|
||||
@@ -1130,9 +1133,6 @@ msgstr "已安装"
|
||||
msgid "Select to remove this WINE/Proton"
|
||||
msgstr "选择以移除此 WINE/Proton"
|
||||
|
||||
msgid "Loading…"
|
||||
msgstr "加载中…"
|
||||
|
||||
#, python-brace-format
|
||||
msgid "Selected {} WINE/Proton:\n"
|
||||
msgstr "已选择 {} 个 WINE/Proton:\n"
|
||||
@@ -1243,10 +1243,6 @@ msgstr "保存设置"
|
||||
msgid "Exe Settings"
|
||||
msgstr "可执行文件设置"
|
||||
|
||||
#, fuzzy
|
||||
msgid "Native"
|
||||
msgstr "晚"
|
||||
|
||||
msgid "Edit user.conf"
|
||||
msgstr "编辑 user.conf"
|
||||
|
||||
@@ -2064,10 +2060,6 @@ msgstr "全屏"
|
||||
msgid "Mouse Emulation"
|
||||
msgstr "鼠标模拟"
|
||||
|
||||
#, fuzzy
|
||||
msgid "System Keyboard"
|
||||
msgstr "捕获键盘"
|
||||
|
||||
msgid "Connect"
|
||||
msgstr "连接"
|
||||
|
||||
@@ -2199,6 +2191,10 @@ msgstr "启动游戏失败:{0}"
|
||||
msgid "Select installation folder"
|
||||
msgstr "选择安装文件夹"
|
||||
|
||||
#, fuzzy
|
||||
msgid "Another download is running"
|
||||
msgstr "正在下载"
|
||||
|
||||
msgid "Another GOG operation is already running"
|
||||
msgstr "另一个 GOG 操作正在运行中"
|
||||
|
||||
@@ -2598,6 +2594,9 @@ msgstr "深色"
|
||||
msgid "Light"
|
||||
msgstr "浅色"
|
||||
|
||||
msgid "Loading…"
|
||||
msgstr "加载中…"
|
||||
|
||||
msgid "Failed to load themes"
|
||||
msgstr "加载主题失败"
|
||||
|
||||
|
||||
+11
-25
@@ -29,7 +29,7 @@ from portprotonqt.detail_pages import DetailPageManager
|
||||
from portprotonqt.portproton_api import PortProtonAPI, remove_empty_custom_data_dirs
|
||||
from portprotonqt.gog_api import GOGAPI
|
||||
from portprotonqt.egs_api import EGSAPI
|
||||
from portprotonqt.native_games import NativeLibraryWorker, NATIVE_URI_PREFIX, get_native_launch, is_native_executable, read_native_game
|
||||
from portprotonqt.native_games import NativeLibraryWorker, NATIVE_URI_PREFIX, get_native_launch, read_native_game
|
||||
from portprotonqt.debug_utils import get_prefix_name
|
||||
from portprotonqt.input_manager import InputManager, MainWindowProtocol
|
||||
from portprotonqt.context_menu_manager import ContextMenuManager
|
||||
@@ -579,8 +579,6 @@ class MainWindow(
|
||||
self.restore_state()
|
||||
|
||||
self.keyboard = VirtualKeyboard(self, self.theme)
|
||||
from portprotonqt.system_keyboard import SystemKeyboard
|
||||
self.system_keyboard = SystemKeyboard(self)
|
||||
|
||||
self.detail_animations = DetailPageAnimations(self, self.theme)
|
||||
self._animations = {}
|
||||
@@ -1195,44 +1193,35 @@ class MainWindow(
|
||||
dialog.deleteLater()
|
||||
|
||||
def _launch_native_game(self, exec_line: str, button: QPushButton | None = None) -> None:
|
||||
target = Path(exec_line.removeprefix(NATIVE_URI_PREFIX))
|
||||
is_shortcut = exec_line.startswith(NATIVE_URI_PREFIX)
|
||||
desktop_path = Path(exec_line.removeprefix(NATIVE_URI_PREFIX))
|
||||
if self.game_processes:
|
||||
if getattr(self, "native_game_running", False) and self.game_start_exe == str(target):
|
||||
if getattr(self, "native_game_running", False) and self.game_start_exe == str(desktop_path):
|
||||
self.stop_running_game(button)
|
||||
else:
|
||||
QMessageBox.warning(self, _("Error"), _("Cannot launch game while another game is running"))
|
||||
return
|
||||
try:
|
||||
if not target.is_absolute():
|
||||
raise ValueError("Invalid native launch path")
|
||||
if is_shortcut:
|
||||
if target.suffix != ".desktop":
|
||||
raise ValueError("Invalid native desktop path")
|
||||
command, directory = get_native_launch(str(target))
|
||||
else:
|
||||
if not is_native_executable(str(target)):
|
||||
raise PermissionError(str(target))
|
||||
command, directory = [str(target)], str(target.parent)
|
||||
if not desktop_path.is_absolute() or desktop_path.suffix != ".desktop":
|
||||
raise ValueError("Invalid native desktop path")
|
||||
command, directory = get_native_launch(str(desktop_path))
|
||||
process = subprocess.Popen(command, cwd=directory, start_new_session=True, text=True)
|
||||
except Exception as error:
|
||||
logger.warning("Failed to launch native game %s: %s", target, error)
|
||||
logger.warning("Failed to launch native game %s: %s", desktop_path, error)
|
||||
QMessageBox.warning(self, _("Error"), _("Failed to launch game: {0}").format(error))
|
||||
return
|
||||
self.native_game_running = True
|
||||
self.game_stopped_by_user = False
|
||||
self.game_processes = [process]
|
||||
self.current_running_button = button
|
||||
self.target_exe = target.name
|
||||
self.game_start_exe = str(target)
|
||||
self.target_exe = desktop_path.name
|
||||
self.game_start_exe = str(desktop_path)
|
||||
self.game_start_exact_path = True
|
||||
self.game_start_time = datetime.now()
|
||||
self.game_launch_monotonic = time.monotonic()
|
||||
self.game_launch_started = True
|
||||
self.wine_download_seen = False
|
||||
if is_shortcut:
|
||||
save_last_launch(target.stem, self.game_start_time)
|
||||
self._update_last_launch_after_start(str(target), self.game_start_time)
|
||||
save_last_launch(desktop_path.stem, self.game_start_time)
|
||||
self._update_last_launch_after_start(str(desktop_path), self.game_start_time)
|
||||
self.launch_output_queue = Queue()
|
||||
self.input_manager.suspend_gamepad_polling()
|
||||
self._set_running_button_stop()
|
||||
@@ -3540,9 +3529,6 @@ class MainWindow(
|
||||
|
||||
# Full application close
|
||||
event.accept()
|
||||
system_keyboard = getattr(self, 'system_keyboard', None)
|
||||
if system_keyboard is not None:
|
||||
system_keyboard.shutdown()
|
||||
|
||||
watcher = getattr(self, "system_theme_watcher", None)
|
||||
if watcher is not None:
|
||||
|
||||
@@ -77,36 +77,14 @@ shared_library(
|
||||
install_dir: pkgdatadir,
|
||||
)
|
||||
|
||||
shared_library(
|
||||
'portprotonqt_keyboard',
|
||||
keyboard_sources,
|
||||
dependencies: keyboard_deps,
|
||||
install: true,
|
||||
install_dir: pkgdatadir,
|
||||
)
|
||||
|
||||
install_data(
|
||||
['compatibility_rules.json',
|
||||
'keyboard_layouts.json',
|
||||
'keyboard_symbols.json',
|
||||
],
|
||||
install_dir: pythondir / meson.project_name(),
|
||||
)
|
||||
|
||||
# Install animations package
|
||||
install_data(
|
||||
['system_keyboard/__init__.py',
|
||||
'system_keyboard/__main__.py',
|
||||
'system_keyboard/input.py',
|
||||
'system_keyboard/keys.py',
|
||||
'system_keyboard/layouts.py',
|
||||
'system_keyboard/detection.py',
|
||||
'system_keyboard/native.py',
|
||||
'system_keyboard/window.py',
|
||||
],
|
||||
install_dir: pythondir / meson.project_name() / 'system_keyboard',
|
||||
)
|
||||
|
||||
install_data(
|
||||
['animations/__init__.py',
|
||||
'animations/detail_background.py',
|
||||
|
||||
@@ -32,9 +32,9 @@ NATIVE_ADVANCED_KEYS = frozenset({"LAUNCH_PARAMETERS", "PW_MESA_GL_VERSION_OVERR
|
||||
|
||||
|
||||
def is_native_executable(path: str) -> bool:
|
||||
"""Recognize native executables, not desktop shortcuts or Wine targets."""
|
||||
"""Recognize native launch files while preserving Windows and disc formats."""
|
||||
return (
|
||||
not path.lower().endswith(LAUNCH_FILE_EXTENSIONS + (".desktop",))
|
||||
Path(path).suffix.lower() not in LAUNCH_FILE_EXTENSIONS
|
||||
and os.path.isfile(path)
|
||||
and os.access(path, os.X_OK)
|
||||
)
|
||||
@@ -393,11 +393,6 @@ def read_native_game(path: Path) -> tuple | None:
|
||||
cached_icon = get_exe_icon_cache_path(executable)
|
||||
if os.path.isfile(cached_icon):
|
||||
cover = cached_icon
|
||||
if not cover and entry.get("Icon"):
|
||||
from portprotonqt.steam_api.shortcuts import _generate_icon
|
||||
|
||||
icon_cache = data_home / "PortProtonQt/cache/native_icons" / custom.name
|
||||
cover = _generate_icon(str(path), str(icon_cache))
|
||||
return (name, description, cover,
|
||||
"", "", NATIVE_URI_PREFIX + str(path), _("Never"), "", "", "", 0, 0,
|
||||
"native", "", "", "")
|
||||
|
||||
@@ -316,7 +316,15 @@ def get_advanced_settings(disabled_text, logical_core_options=None, locale_optio
|
||||
advanced_settings.append({
|
||||
'key': 'PW_RUN_AFTER_EXE',
|
||||
'name': _("Run After / Wrapper"),
|
||||
'description': _("Path to a second .exe, script, or wrapper command. Use %command% for the game command"),
|
||||
'description': _("Path to a second .exe, script, or wrapper command. Example: systemd-run --user --scope --slice=app.slice"),
|
||||
'type': 'text',
|
||||
'default': ''
|
||||
})
|
||||
|
||||
advanced_settings.append({
|
||||
'key': 'PW_NETWORK_BLOCKLIST',
|
||||
'name': _("Blocked Network Destinations"),
|
||||
'description': _("Comma-separated IP addresses, domains, wildcard patterns, or absolute paths to hosts files. Example: 192.0.2.1,example.com,*.ru,/home/user/hosts"),
|
||||
'type': 'text',
|
||||
'default': ''
|
||||
})
|
||||
@@ -405,6 +413,7 @@ ADVANCED_SETTING_KEYS = [
|
||||
'WINEDLLOVERRIDES',
|
||||
'LAUNCH_PARAMETERS',
|
||||
'PW_RUN_AFTER_EXE',
|
||||
'PW_NETWORK_BLOCKLIST',
|
||||
'PW_WINE_CPU_TOPOLOGY',
|
||||
'PW_MESA_GL_VERSION_OVERRIDE',
|
||||
'PW_VKD3D_FEATURE_LEVEL',
|
||||
|
||||
@@ -1,109 +0,0 @@
|
||||
"""Launch and control the system keyboard independently of application focus."""
|
||||
|
||||
import sys
|
||||
|
||||
import orjson
|
||||
from PySide6.QtCore import QObject, QProcess
|
||||
from PySide6.QtWidgets import QApplication, QWidget
|
||||
|
||||
from portprotonqt.config import ui_config
|
||||
from portprotonqt.logger import get_logger
|
||||
|
||||
logger = get_logger(__name__)
|
||||
SHUTDOWN_TIMEOUT_MS = 3000
|
||||
MAX_EMOJI_LENGTH = 16
|
||||
|
||||
|
||||
class SystemKeyboard(QObject):
|
||||
"""Retain the child process and forward gamepad commands over its stdin."""
|
||||
|
||||
def __init__(self, parent: QWidget) -> None:
|
||||
super().__init__(parent)
|
||||
self.owner = parent
|
||||
self.process = QProcess(self)
|
||||
self.process.started.connect(self._started)
|
||||
self.process.readyReadStandardOutput.connect(self._read_state)
|
||||
self.process.setProcessChannelMode(QProcess.ProcessChannelMode.ForwardedErrorChannel)
|
||||
self.process.errorOccurred.connect(self._process_error)
|
||||
self.process.finished.connect(self._finished)
|
||||
self.visible = False
|
||||
self.shift_pressed = False
|
||||
self.output = bytearray()
|
||||
self.closing = False
|
||||
app = QApplication.instance()
|
||||
if app is not None:
|
||||
app.aboutToQuit.connect(self.shutdown)
|
||||
|
||||
def isVisible(self) -> bool:
|
||||
return self.visible
|
||||
|
||||
def toggle(self) -> None:
|
||||
if self.visible:
|
||||
self.hide()
|
||||
return
|
||||
self.visible = True
|
||||
if self.process.state() != QProcess.ProcessState.NotRunning:
|
||||
self.send('show')
|
||||
return
|
||||
self.output.clear()
|
||||
self.process.start(sys.executable, ['-m', 'portprotonqt.system_keyboard'])
|
||||
|
||||
def _started(self) -> None:
|
||||
self.send('theme', ui_config.get_theme())
|
||||
manager = getattr(self.owner, 'input_manager', None)
|
||||
connected = getattr(manager, 'gamepad', None) is not None
|
||||
self.send('gamepad', manager.gamepad_type.value if manager is not None and connected else None)
|
||||
self.send('show' if self.visible else 'hide')
|
||||
|
||||
def send(self, action: str, value: object = None) -> None:
|
||||
if self.process.state() == QProcess.ProcessState.Running:
|
||||
self.process.write(orjson.dumps({'action': action, 'value': value}) + b'\n')
|
||||
|
||||
def hide(self) -> None:
|
||||
self.visible = False
|
||||
self.send('hide')
|
||||
|
||||
def _read_state(self) -> None:
|
||||
self.output.extend(bytes(self.process.readAllStandardOutput().data()))
|
||||
while b'\n' in self.output:
|
||||
line, _, remainder = self.output.partition(b'\n')
|
||||
self.output = bytearray(remainder)
|
||||
try:
|
||||
data = orjson.loads(line)
|
||||
except orjson.JSONDecodeError:
|
||||
logger.warning('Invalid system keyboard response: %r', line)
|
||||
continue
|
||||
if isinstance(data, dict) and data.get('event') == 'hidden':
|
||||
self.visible = False
|
||||
self.shift_pressed = False
|
||||
elif isinstance(data, dict) and data.get('event') == 'shift':
|
||||
self.shift_pressed = bool(data.get('value'))
|
||||
elif isinstance(data, dict) and data.get('event') == 'emoji' and self.visible:
|
||||
value = data.get('value')
|
||||
if (isinstance(value, str) and 0 < len(value) <= MAX_EMOJI_LENGTH
|
||||
and value.isprintable() and not value.isascii()):
|
||||
QApplication.clipboard().setText(value)
|
||||
|
||||
def _process_error(self, error: QProcess.ProcessError) -> None:
|
||||
if error == QProcess.ProcessError.FailedToStart:
|
||||
self.visible = False
|
||||
logger.error('Cannot open system keyboard: %s', self.process.errorString())
|
||||
|
||||
def _finished(self, code: int, status: QProcess.ExitStatus) -> None:
|
||||
self.visible = False
|
||||
self.shift_pressed = False
|
||||
if not self.closing and (code or status == QProcess.ExitStatus.CrashExit):
|
||||
logger.error('System keyboard exited with code %s (%s)', code, status.name)
|
||||
|
||||
def shutdown(self) -> None:
|
||||
self.closing = True
|
||||
self.visible = False
|
||||
self.send('quit')
|
||||
if self.process.state() == QProcess.ProcessState.NotRunning:
|
||||
return
|
||||
if self.process.waitForFinished(SHUTDOWN_TIMEOUT_MS):
|
||||
return
|
||||
self.process.terminate()
|
||||
if not self.process.waitForFinished(SHUTDOWN_TIMEOUT_MS):
|
||||
self.process.kill()
|
||||
self.process.waitForFinished(SHUTDOWN_TIMEOUT_MS)
|
||||
@@ -1,77 +0,0 @@
|
||||
"""Isolated Qt frontend: X11/XWayland or a native Wayland layer surface."""
|
||||
|
||||
import ctypes
|
||||
import os
|
||||
import sys
|
||||
|
||||
import orjson
|
||||
from typing import Any
|
||||
from PySide6.QtCore import QSocketNotifier
|
||||
from PySide6.QtWidgets import QApplication
|
||||
|
||||
from portprotonqt.logger import get_logger, setup_logger
|
||||
|
||||
logger = get_logger(__name__)
|
||||
COMMAND_READ_SIZE = 8192
|
||||
|
||||
|
||||
class CommandReader:
|
||||
def __init__(self, window: Any) -> None:
|
||||
self.window = window
|
||||
self.buffer = bytearray()
|
||||
os.set_blocking(sys.stdin.fileno(), False)
|
||||
self.notifier = QSocketNotifier(sys.stdin.fileno(), QSocketNotifier.Type.Read)
|
||||
self.notifier.activated.connect(self.read)
|
||||
|
||||
def read(self) -> None:
|
||||
try:
|
||||
data = os.read(sys.stdin.fileno(), COMMAND_READ_SIZE)
|
||||
except BlockingIOError:
|
||||
return
|
||||
if not data:
|
||||
self.notifier.setEnabled(False)
|
||||
self.window.command('quit')
|
||||
return
|
||||
self.buffer.extend(data)
|
||||
while b'\n' in self.buffer:
|
||||
line, _, remaining = self.buffer.partition(b'\n')
|
||||
self.buffer = bytearray(remaining)
|
||||
try:
|
||||
command = orjson.loads(line)
|
||||
if isinstance(command, dict) and isinstance(command.get('action'), str):
|
||||
self.window.command(command['action'], command.get('value'))
|
||||
except Exception:
|
||||
logger.exception('Invalid system keyboard command')
|
||||
|
||||
|
||||
def main() -> int:
|
||||
setup_logger('WARNING')
|
||||
from portprotonqt.system_keyboard.native import load_library
|
||||
layer_shell = False
|
||||
if os.environ.get('WAYLAND_DISPLAY'):
|
||||
library = load_library()
|
||||
library.portproton_keyboard_has_layer_shell.argtypes = []
|
||||
library.portproton_keyboard_has_layer_shell.restype = ctypes.c_int
|
||||
layer_shell = bool(library.portproton_keyboard_has_layer_shell())
|
||||
app = QApplication([sys.argv[0]])
|
||||
app.setQuitOnLastWindowClosed(False)
|
||||
from portprotonqt.system_keyboard.window import SystemKeyboardWindow, WaylandWindow
|
||||
window = SystemKeyboardWindow(layer_shell=layer_shell)
|
||||
try:
|
||||
if layer_shell:
|
||||
window.native_layer = WaylandWindow(window)
|
||||
reader = CommandReader(window)
|
||||
app.aboutToQuit.connect(window.shutdown)
|
||||
window.worker.start()
|
||||
result = app.exec()
|
||||
window.shutdown()
|
||||
del reader
|
||||
return result
|
||||
except Exception:
|
||||
logger.exception('Failed to start system keyboard')
|
||||
window.shutdown()
|
||||
return 1
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
raise SystemExit(main())
|
||||
@@ -1,641 +0,0 @@
|
||||
"""Detect active keyboard layouts through X11, compositor IPC or desktop settings."""
|
||||
|
||||
import ast
|
||||
import asyncio
|
||||
import ctypes as C
|
||||
import os
|
||||
import re
|
||||
import select
|
||||
import subprocess
|
||||
import xml.etree.ElementTree as ET
|
||||
from collections.abc import Mapping
|
||||
from configparser import ConfigParser
|
||||
from pathlib import Path
|
||||
from types import SimpleNamespace
|
||||
from typing import Any
|
||||
|
||||
import orjson
|
||||
from evdev import ecodes
|
||||
from dbus_fast import BusType, Message
|
||||
from dbus_fast.aio import MessageBus
|
||||
|
||||
from portprotonqt.logger import get_logger
|
||||
from portprotonqt.scripts_utils.dbus_tools import _bus_call, dbus_call
|
||||
from portprotonqt.system_keyboard.keys import (ROWS, MODIFIERS, XKB_KEYCODE_OFFSET, XKB_CORE_KEYBOARD,
|
||||
XKB_SHIFT_MASK, XKB_LOCK_MASK, XKB_ALTGR_MASK, XKB_GROUP_COUNT, XKB_GROUP_SHIFT)
|
||||
from portprotonqt.system_keyboard.layouts import Layout, keysym_label
|
||||
from portprotonqt.system_keyboard.native import load_library
|
||||
|
||||
logger = get_logger(__name__)
|
||||
LAYOUT_NAME_BUFFER_BYTES = 256
|
||||
IBUS_SCHEMA = 'org.freedesktop.ibus.general'
|
||||
|
||||
|
||||
def is_x11_session(environment: Mapping[str, str]) -> bool:
|
||||
if environment.get('XDG_SESSION_TYPE'):
|
||||
return environment['XDG_SESSION_TYPE'] == 'x11'
|
||||
return bool(environment.get('DISPLAY')) and not environment.get('WAYLAND_DISPLAY')
|
||||
|
||||
|
||||
class X11Layout:
|
||||
def __init__(self) -> None:
|
||||
self.display = None
|
||||
self.lib = load_library()
|
||||
functions = {
|
||||
'portproton_keyboard_x11_open_display': ([C.c_char_p], C.c_void_p),
|
||||
'XCloseDisplay': ([C.c_void_p], C.c_int),
|
||||
'portproton_keyboard_x11_state': ([C.c_void_p, C.POINTER(C.c_uint)], C.c_int),
|
||||
'XkbLockGroup': ([C.c_void_p, C.c_uint, C.c_uint], C.c_int),
|
||||
'XkbLockModifiers': ([C.c_void_p, C.c_uint, C.c_uint, C.c_uint], C.c_int),
|
||||
'portproton_keyboard_x11_keysym': ([C.c_void_p, C.c_uint, C.c_uint], C.c_uint),
|
||||
'XStringToKeysym': ([C.c_char_p], C.c_ulong),
|
||||
'XKeysymToKeycode': ([C.c_void_p, C.c_ulong], C.c_ubyte),
|
||||
'XSync': ([C.c_void_p, C.c_int], C.c_int),
|
||||
'portproton_keyboard_x11_layout_name': ([C.c_void_p, C.c_uint, C.c_void_p, C.c_size_t], C.c_int),
|
||||
}
|
||||
for name, (args, result) in functions.items():
|
||||
function = getattr(self.lib, name)
|
||||
function.argtypes, function.restype = args, result
|
||||
self.display = self.lib.portproton_keyboard_x11_open_display(None)
|
||||
if not self.display:
|
||||
raise RuntimeError('Cannot read the X11 keyboard layout')
|
||||
|
||||
def state(self) -> SimpleNamespace:
|
||||
values = (C.c_uint * 3)()
|
||||
if not self.lib.portproton_keyboard_x11_state(self.display, values):
|
||||
raise RuntimeError('Cannot read XKB state')
|
||||
return SimpleNamespace(group=values[0], mods=values[1], locked_mods=values[2])
|
||||
|
||||
def switch(self) -> None:
|
||||
group = (self.state().group + 1) % XKB_GROUP_COUNT
|
||||
if not self.lib.XkbLockGroup(self.display, XKB_CORE_KEYBOARD, group):
|
||||
raise RuntimeError('Cannot switch XKB layout')
|
||||
self.lib.XSync(self.display, False)
|
||||
|
||||
def caps_lock(self) -> bool:
|
||||
return bool(self.state().locked_mods & XKB_LOCK_MASK)
|
||||
|
||||
def layout_identifier(self) -> str:
|
||||
name = C.create_string_buffer(LAYOUT_NAME_BUFFER_BYTES)
|
||||
if self.lib.portproton_keyboard_x11_layout_name(self.display, self.state().group, name, len(name)):
|
||||
return name.value.decode()
|
||||
return 'System'
|
||||
|
||||
def toggle_caps_lock(self) -> None:
|
||||
value = 0 if self.caps_lock() else XKB_LOCK_MASK
|
||||
if not self.lib.XkbLockModifiers(self.display, XKB_CORE_KEYBOARD, XKB_LOCK_MASK, value):
|
||||
raise RuntimeError('Cannot switch XKB Caps Lock')
|
||||
self.lib.XSync(self.display, False)
|
||||
|
||||
def keycode(self, name: str) -> int:
|
||||
symbol = self.lib.XStringToKeysym(name.encode())
|
||||
code = self.lib.XKeysymToKeycode(self.display, symbol) if symbol else 0
|
||||
if code < XKB_KEYCODE_OFFSET:
|
||||
raise ValueError(f'Unknown shortcut key: {name}')
|
||||
return code - XKB_KEYCODE_OFFSET
|
||||
|
||||
def labels(self, modifiers: set[int] | tuple[int, ...] = ()) -> dict[str, str]:
|
||||
state = self.state()
|
||||
mask = state.mods & (XKB_SHIFT_MASK | XKB_LOCK_MASK | XKB_ALTGR_MASK)
|
||||
for code, bit in ((ecodes.KEY_LEFTSHIFT, XKB_SHIFT_MASK),
|
||||
(ecodes.KEY_RIGHTSHIFT, XKB_SHIFT_MASK),
|
||||
(ecodes.KEY_CAPSLOCK, XKB_LOCK_MASK),
|
||||
(ecodes.KEY_RIGHTALT, XKB_ALTGR_MASK)):
|
||||
if code in modifiers:
|
||||
mask |= bit
|
||||
# Match XkbBuildCoreState from X11/extensions/XKB.h.
|
||||
mask |= state.group << XKB_GROUP_SHIFT
|
||||
result = {}
|
||||
for row in ROWS:
|
||||
for fallback, code in row:
|
||||
if code in MODIFIERS or code in {ecodes.KEY_TAB, ecodes.KEY_CAPSLOCK}:
|
||||
continue
|
||||
value = self.lib.portproton_keyboard_x11_keysym(
|
||||
self.display, code + XKB_KEYCODE_OFFSET, mask)
|
||||
character = keysym_label(value) if value else ''
|
||||
result[str(code)] = character if character.isprintable() else fallback
|
||||
return result
|
||||
|
||||
def close(self) -> None:
|
||||
if self.display:
|
||||
self.lib.XCloseDisplay(self.display)
|
||||
self.display = None
|
||||
|
||||
|
||||
class IBusLayout(X11Layout):
|
||||
def switch(self) -> None:
|
||||
text = command(['gsettings', 'get', IBUS_SCHEMA, 'preload-engines']).strip()
|
||||
engines = ast.literal_eval(re.sub(r'^@as\s+', '', text))
|
||||
if (not isinstance(engines, list) or not engines
|
||||
or any(not isinstance(engine, str) or not engine.startswith('xkb:') for engine in engines)):
|
||||
raise ValueError('IBus input sources must be XKB keyboard layouts')
|
||||
current = command(['ibus', 'engine']).strip()
|
||||
if current not in engines:
|
||||
raise RuntimeError('Current IBus engine is not in the configured input sources')
|
||||
following = engines[(engines.index(current) + 1) % len(engines)]
|
||||
command(['ibus', 'engine', following])
|
||||
|
||||
|
||||
class CosmicLayout:
|
||||
def __init__(self) -> None:
|
||||
self.display = self.layout = None
|
||||
self.group = None
|
||||
self.error = None
|
||||
self.callbacks, self.proxies = [], []
|
||||
self.keyboard = self.manager = self.tracker = None
|
||||
self.lib = load_library()
|
||||
self._configure_library()
|
||||
self.group_interface = self._interface('zcosmic_keyboard_layout_v1')
|
||||
self.manager_interface = self._interface('zcosmic_keyboard_layout_manager_v1')
|
||||
try:
|
||||
self.display = self.lib.portproton_keyboard_wayland_connect(None)
|
||||
if not self.display:
|
||||
raise RuntimeError('Failed to connect to Wayland')
|
||||
self.registry = self._new(self.display, (1, self._interface('wl_registry')), C.c_void_p())
|
||||
self._listen(self.registry, [
|
||||
(self._global, [C.c_uint32, C.c_char_p, C.c_uint32]),
|
||||
(lambda *args: None, [C.c_uint32])])
|
||||
for _ in range(4):
|
||||
self._check(self.lib.wl_display_roundtrip(self.display))
|
||||
if self.layout is None or self.group is None:
|
||||
raise RuntimeError('COSMIC keyboard layout protocol or keymap unavailable')
|
||||
except Exception:
|
||||
self.close()
|
||||
raise
|
||||
|
||||
def _configure_library(self) -> None:
|
||||
p = C.c_void_p
|
||||
for name, args, result in (
|
||||
('portproton_keyboard_wayland_connect', [C.c_char_p], p),
|
||||
('portproton_keyboard_wayland_interface', [C.c_char_p], p),
|
||||
('wl_display_disconnect', [p], None),
|
||||
('wl_display_roundtrip', [p], C.c_int),
|
||||
('wl_display_dispatch', [p], C.c_int),
|
||||
('wl_display_dispatch_pending', [p], C.c_int),
|
||||
('wl_display_get_fd', [p], C.c_int),
|
||||
('wl_display_flush', [p], C.c_int),
|
||||
('wl_proxy_destroy', [p], None),
|
||||
('wl_proxy_add_listener', [p, p, p], C.c_int),
|
||||
('wl_proxy_marshal_flags', [p, C.c_uint32, p,
|
||||
C.c_uint32, C.c_uint32], p),
|
||||
):
|
||||
fn = getattr(self.lib, name)
|
||||
fn.argtypes, fn.restype = args, result
|
||||
|
||||
def _interface(self, name: str) -> int:
|
||||
interface = self.lib.portproton_keyboard_wayland_interface(name.encode())
|
||||
if not interface:
|
||||
raise RuntimeError(f'Unknown Wayland interface: {name}')
|
||||
return interface
|
||||
|
||||
def _new(self, proxy: Any, request: tuple[Any, Any], *args: Any) -> Any:
|
||||
opcode, interface = request
|
||||
result = self.lib.wl_proxy_marshal_flags(proxy, opcode, interface,
|
||||
1, 0, *args)
|
||||
if not result:
|
||||
raise RuntimeError('COSMIC: failed to create Wayland object')
|
||||
self.proxies.append(result)
|
||||
return result
|
||||
|
||||
def _listen(self, proxy: Any, handlers: Any) -> None:
|
||||
callbacks = []
|
||||
for handler, types in handlers:
|
||||
def guarded(data: Any, obj: Any, *args: Any, handler: Any = handler) -> None:
|
||||
try:
|
||||
handler(*args)
|
||||
except Exception as exc:
|
||||
self.error = exc
|
||||
callbacks.append(C.CFUNCTYPE(None, C.c_void_p, C.c_void_p, *types)(guarded))
|
||||
table = (C.c_void_p * len(callbacks))(*[C.cast(fn, C.c_void_p) for fn in callbacks])
|
||||
self.callbacks.append((callbacks, table))
|
||||
if self.lib.wl_proxy_add_listener(proxy, table, None) != 0:
|
||||
raise RuntimeError('COSMIC: failed to subscribe to Wayland events')
|
||||
|
||||
def _global(self, name: Any, interface: Any, version: Any) -> None:
|
||||
if interface == b'wl_seat' and not hasattr(self, 'seat'):
|
||||
self.seat = self._new(self.registry, (0, self._interface('wl_seat')),
|
||||
C.c_uint32(name), interface, C.c_uint32(1), C.c_void_p())
|
||||
self._listen(self.seat, [(self._capabilities, [C.c_uint32])])
|
||||
elif interface == b'zcosmic_keyboard_layout_manager_v1' and self.manager is None:
|
||||
self.manager = self._new(self.registry, (0, self.manager_interface),
|
||||
C.c_uint32(name), interface, C.c_uint32(1), C.c_void_p())
|
||||
self._track()
|
||||
|
||||
def _capabilities(self, capabilities: Any) -> None:
|
||||
if capabilities & 2 and self.keyboard is None:
|
||||
self.keyboard = self._new(self.seat, (1, self._interface('wl_keyboard')), C.c_void_p())
|
||||
u, p = C.c_uint32, C.c_void_p
|
||||
self._listen(self.keyboard, [
|
||||
(self._keymap, [u, C.c_int, u]),
|
||||
(lambda *args: None, [u, p, p]),
|
||||
(lambda *args: None, [u, p]),
|
||||
(lambda *args: None, [u, u, u, u]),
|
||||
(lambda *args: None, [u, u, u, u, u])])
|
||||
self._track()
|
||||
elif not capabilities & 2 and self.keyboard is not None:
|
||||
self.error = RuntimeError('COSMIC: keyboard disconnected')
|
||||
|
||||
def _track(self) -> None:
|
||||
if self.keyboard and self.manager and self.tracker is None:
|
||||
self.tracker = self._new(self.manager, (0, self.group_interface),
|
||||
C.c_void_p(), C.c_void_p(self.keyboard))
|
||||
self._listen(self.tracker, [(self._group, [C.c_uint32])])
|
||||
|
||||
def _group(self, group: Any) -> None:
|
||||
self.group = group
|
||||
|
||||
def layout_identifier(self) -> str:
|
||||
if self.layout is None or self.group is None:
|
||||
return 'System'
|
||||
return self.layout.layout_identifier(self.group)
|
||||
|
||||
def _keymap(self, format: Any, fd: Any, size: Any) -> None:
|
||||
try:
|
||||
if format != 1 or not 0 < size <= 16 * 1024 * 1024:
|
||||
raise RuntimeError('COSMIC: invalid Wayland keymap')
|
||||
text = os.pread(fd, size, 0)
|
||||
if len(text) != size:
|
||||
raise RuntimeError('COSMIC: incomplete Wayland keymap')
|
||||
replacement = Layout(keymap_text=text)
|
||||
finally:
|
||||
os.close(fd)
|
||||
self.layout = replacement
|
||||
|
||||
def _check(self, result: Any) -> None:
|
||||
if result < 0:
|
||||
raise RuntimeError('COSMIC: Wayland connection closed')
|
||||
if self.error is not None:
|
||||
raise self.error
|
||||
|
||||
def labels(self, modifiers: Any=()) -> Any:
|
||||
self._check(self.lib.wl_display_dispatch_pending(self.display))
|
||||
fd = self.lib.wl_display_get_fd(self.display)
|
||||
for _ in range(32):
|
||||
if not select.select([fd], [], [], 0)[0]:
|
||||
break
|
||||
self._check(self.lib.wl_display_dispatch(self.display))
|
||||
if self.layout is None or self.group is None:
|
||||
raise RuntimeError('COSMIC: keyboard layout unavailable')
|
||||
return self.layout.labels(modifiers, mask=(0, 0, 0, self.group))
|
||||
|
||||
def close(self) -> None:
|
||||
if self.layout is not None:
|
||||
self.layout = None
|
||||
if self.display:
|
||||
for proxy in reversed(self.proxies):
|
||||
self.lib.wl_proxy_destroy(proxy)
|
||||
self.proxies.clear()
|
||||
self.lib.wl_display_disconnect(self.display)
|
||||
self.display = None
|
||||
|
||||
|
||||
SOURCE_SCHEMA = 'org.gnome.desktop.input-sources'
|
||||
BINDINGS_SCHEMA = 'org.gnome.desktop.wm.keybindings'
|
||||
SHORTCUT_MODIFIERS = {
|
||||
'Control': ecodes.KEY_LEFTCTRL, 'Ctrl': ecodes.KEY_LEFTCTRL,
|
||||
'Primary': ecodes.KEY_LEFTCTRL, 'Alt': ecodes.KEY_LEFTALT,
|
||||
'Shift': ecodes.KEY_LEFTSHIFT, 'Super': ecodes.KEY_LEFTMETA,
|
||||
}
|
||||
|
||||
|
||||
class GSettingsLayout:
|
||||
def __init__(self) -> None:
|
||||
self.layout: Layout | None = None
|
||||
self.current: tuple[str, str] | None = None
|
||||
self._update()
|
||||
|
||||
def _read(self, key: str) -> object:
|
||||
text = command(['gsettings', 'get', SOURCE_SCHEMA, key]).strip()
|
||||
text = re.sub(r'^@[a-z()]+\s+|^uint32\s+', '', text)
|
||||
if text in ('true', 'false'):
|
||||
return text == 'true'
|
||||
return ast.literal_eval(text)
|
||||
|
||||
def _source(self) -> tuple[str, str]:
|
||||
sources = self._read('sources')
|
||||
if self._read('per-window'):
|
||||
raise ValueError('GSettings cannot track per-window input sources')
|
||||
if not isinstance(sources, list) or not sources:
|
||||
raise ValueError('GSettings has no input sources')
|
||||
if len(sources) == 1:
|
||||
selected = sources[0]
|
||||
else:
|
||||
recent = self._read('mru-sources')
|
||||
if not isinstance(recent, list) or not recent or recent[0] not in sources:
|
||||
raise ValueError('GSettings input-source history is unavailable')
|
||||
selected = recent[0]
|
||||
kind, name = selected
|
||||
if kind != 'xkb' or not isinstance(name, str) or not name:
|
||||
raise ValueError('GSettings input source is not an XKB layout')
|
||||
layout, _, variant = name.partition('+')
|
||||
return layout, variant
|
||||
|
||||
def _update(self) -> None:
|
||||
choice = self._source()
|
||||
if choice == self.current:
|
||||
return
|
||||
replacement = Layout(*choice)
|
||||
self.layout, self.current = replacement, choice
|
||||
|
||||
def labels(self, modifiers: set[int] | tuple[int, ...] = ()) -> dict[str, str]:
|
||||
self._update()
|
||||
assert self.layout is not None
|
||||
return self.layout.labels(modifiers)
|
||||
|
||||
@staticmethod
|
||||
def switch_codes() -> tuple[int, ...]:
|
||||
desktop = os.environ.get('XDG_CURRENT_DESKTOP', '').lower().split(':')
|
||||
cinnamon = any('cinnamon' in name for name in desktop)
|
||||
schema = 'org.cinnamon.desktop.keybindings.wm' if cinnamon else BINDINGS_SCHEMA
|
||||
# GNOME's forward shortcut toggles the two most recent sources; reverse MRU cycles all.
|
||||
key = 'switch-input-source' if cinnamon or 'budgie' in desktop else 'switch-input-source-backward'
|
||||
text = command(['gsettings', 'get', schema, key]).strip()
|
||||
bindings = ast.literal_eval(re.sub(r'^@as\s+', '', text))
|
||||
if not isinstance(bindings, list):
|
||||
raise ValueError('Invalid GSettings input-source shortcuts')
|
||||
keymap = X11Layout()
|
||||
try:
|
||||
for accelerator in bindings:
|
||||
modifiers = re.findall(r'<([^>]+)>', accelerator)
|
||||
name = re.sub(r'<[^>]+>', '', accelerator)
|
||||
if not name or any(item not in SHORTCUT_MODIFIERS for item in modifiers):
|
||||
continue
|
||||
try:
|
||||
code = keymap.keycode(name)
|
||||
except ValueError:
|
||||
continue
|
||||
return tuple(SHORTCUT_MODIFIERS[item] for item in modifiers) + (code,)
|
||||
finally:
|
||||
keymap.close()
|
||||
raise RuntimeError('No supported GSettings switch-input-source shortcut')
|
||||
|
||||
def close(self) -> None:
|
||||
if self.layout is not None:
|
||||
self.layout = None
|
||||
|
||||
|
||||
def compositor(environment: Any) -> Any:
|
||||
desktop = environment.get('XDG_CURRENT_DESKTOP', '').lower().split(':')
|
||||
for name, variable in [('hyprland', 'HYPRLAND_INSTANCE_SIGNATURE'),
|
||||
('sway', 'SWAYSOCK'), ('niri', 'NIRI_SOCKET'),
|
||||
('umbriel', 'UMBRIEL_SOCKET'), ('mango', 'MANGO_INSTANCE_SIGNATURE')]:
|
||||
if environment.get(variable):
|
||||
return name
|
||||
name = next((name for name in ('hyprland', 'sway', 'niri', 'cosmic', 'umbriel', 'mango')
|
||||
if name in desktop), None)
|
||||
if name is not None:
|
||||
return name
|
||||
return 'wayland' if environment.get('WAYLAND_DISPLAY') else None
|
||||
|
||||
|
||||
def command(args: Any) -> Any:
|
||||
try:
|
||||
return subprocess.run(args, capture_output=True, text=True,
|
||||
timeout=1, check=True).stdout
|
||||
except (OSError, subprocess.SubprocessError) as exc:
|
||||
raise RuntimeError(f'IPC error ({args[0]}): {exc}') from exc
|
||||
|
||||
|
||||
class NiriLayout:
|
||||
def __init__(self, registry: Any='/usr/share/X11/xkb/rules/evdev.xml') -> None:
|
||||
self.names = {}
|
||||
for entry in ET.parse(registry).findall('./layoutList/layout'):
|
||||
code = entry.findtext('./configItem/name')
|
||||
self.names[entry.findtext('./configItem/description')] = (code, '')
|
||||
for variant in entry.findall('./variantList/variant'):
|
||||
self.names[variant.findtext('./configItem/description')] = (
|
||||
code, variant.findtext('./configItem/name'))
|
||||
self.layout = None
|
||||
self.current = None
|
||||
self._update()
|
||||
|
||||
def _query_name(self) -> Any:
|
||||
data = orjson.loads(command(['niri', 'msg', '--json', 'keyboard-layouts']))
|
||||
index = data['current_idx']
|
||||
if type(index) is not int or not 0 <= index < len(data['names']):
|
||||
raise ValueError('Invalid niri keyboard layout index')
|
||||
return data['names'][index]
|
||||
|
||||
def _update(self) -> None:
|
||||
name = self._query_name()
|
||||
if name not in self.names:
|
||||
raise ValueError(f'Layout not found in XKB registry: {name}')
|
||||
choice = self.names[name]
|
||||
if choice != self.current:
|
||||
replacement = Layout(*choice)
|
||||
self.layout = replacement
|
||||
self.current = choice
|
||||
|
||||
def labels(self, modifiers: Any=()) -> Any:
|
||||
self._update()
|
||||
assert self.layout is not None
|
||||
return self.layout.labels(modifiers)
|
||||
|
||||
def switch(self) -> None:
|
||||
command(['niri', 'msg', 'action', 'switch-layout', 'next'])
|
||||
|
||||
def close(self) -> None:
|
||||
if self.layout is not None:
|
||||
self.layout = None
|
||||
|
||||
|
||||
class SwayLayout(NiriLayout):
|
||||
def _query_name(self) -> Any:
|
||||
inputs = orjson.loads(command(['swaymsg', '-t', 'get_inputs', '-r']))
|
||||
keyboards = [item for item in inputs if item.get('type') == 'keyboard'
|
||||
and item.get('xkb_active_layout_name')]
|
||||
if not keyboards:
|
||||
raise RuntimeError('Sway did not report a keyboard layout')
|
||||
# Never silently display one of several conflicting device layouts.
|
||||
names = {item['xkb_active_layout_name'] for item in keyboards}
|
||||
if len(names) != 1:
|
||||
raise RuntimeError('Sway keyboards have conflicting layouts')
|
||||
return keyboards[0]['xkb_active_layout_name']
|
||||
|
||||
def switch(self) -> Any:
|
||||
result = orjson.loads(command(['swaymsg', '-r', 'input type:keyboard xkb_switch_layout next']))
|
||||
if not result or not all(item.get('success') for item in result):
|
||||
raise RuntimeError(f'Sway failed to switch keyboard layout: {result}')
|
||||
|
||||
|
||||
class HyprlandLayout(NiriLayout):
|
||||
def _query_name(self) -> Any:
|
||||
data = orjson.loads(command(['hyprctl', '-j', 'devices']))
|
||||
keyboard = next((item for item in data['keyboards'] if item.get('main')), None)
|
||||
if keyboard is None or not keyboard.get('active_keymap'):
|
||||
raise RuntimeError('Hyprland did not report the main keyboard layout')
|
||||
self.keyboard = keyboard['name']
|
||||
return keyboard['active_keymap']
|
||||
|
||||
def switch(self) -> Any:
|
||||
self._query_name()
|
||||
result = command(['hyprctl', 'switchxkblayout', self.keyboard, 'next'])
|
||||
if result.strip() != 'ok':
|
||||
raise RuntimeError(f'Hyprland failed to switch keyboard layout: {result.strip()}')
|
||||
|
||||
|
||||
class KDELayout(GSettingsLayout):
|
||||
def __init__(self) -> None:
|
||||
self.layout = None
|
||||
self.current = None
|
||||
self.names: list[tuple[str, str, str]] = []
|
||||
self.sources: list[tuple[str, str]] = []
|
||||
self.runner = asyncio.Runner()
|
||||
self.bus: MessageBus | None = None
|
||||
try:
|
||||
self._update()
|
||||
except Exception:
|
||||
self.close()
|
||||
raise
|
||||
|
||||
async def _request(self, method: str) -> list[Any] | None:
|
||||
bus = self.bus
|
||||
if bus is None:
|
||||
bus = MessageBus(bus_type=BusType.SESSION)
|
||||
await dbus_call(bus.connect())
|
||||
self.bus = bus
|
||||
return await _bus_call(bus, Message(
|
||||
destination='org.kde.keyboard', path='/Layouts',
|
||||
interface='org.kde.KeyboardLayouts', member=method))
|
||||
|
||||
def _call(self, method: str) -> list[Any]:
|
||||
try:
|
||||
result = self.runner.run(self._request(method))
|
||||
except Exception as error:
|
||||
raise RuntimeError(f'KDE keyboard layout request failed: {error}') from error
|
||||
if result is None:
|
||||
raise RuntimeError(f'KDE keyboard layout request failed: {method}')
|
||||
return result
|
||||
|
||||
def _source(self) -> tuple[str, str]:
|
||||
result = self._call('getLayoutsList')
|
||||
if len(result) != 1:
|
||||
raise ValueError('Invalid KDE keyboard layouts response')
|
||||
rows = result[0]
|
||||
if not isinstance(rows, list) or any(
|
||||
not isinstance(row, (list, tuple)) or len(row) != 3 for row in rows
|
||||
):
|
||||
raise ValueError('Invalid KDE keyboard layout entries')
|
||||
entries = [(row[0], row[1], row[2]) for row in rows]
|
||||
names = [entry[0] for entry in entries]
|
||||
if not names or any(not isinstance(name, str) or not name for name in names):
|
||||
raise ValueError('Invalid KDE keyboard layout names')
|
||||
if entries != self.names:
|
||||
config = ConfigParser(interpolation=None)
|
||||
directory = Path(os.environ.get('XDG_CONFIG_HOME') or Path.home() / '.config')
|
||||
config.read(directory / 'kxkbrc', encoding='utf-8')
|
||||
variants = config.get('Layout', 'VariantList', fallback='').split(',')
|
||||
if not any(variants):
|
||||
variants = [''] * len(names)
|
||||
if len(variants) != len(names):
|
||||
raise ValueError('KDE keyboard layout variants do not match the layout list')
|
||||
self.sources = list(zip(names, variants, strict=True))
|
||||
self.names = entries
|
||||
current = self._call('getLayout')
|
||||
if len(current) != 1 or type(current[0]) is not int or not 0 <= current[0] < len(self.sources):
|
||||
raise ValueError('Invalid KDE keyboard layout index')
|
||||
return self.sources[current[0]]
|
||||
|
||||
def switch(self) -> None:
|
||||
self._call('switchToNextLayout')
|
||||
|
||||
def close(self) -> None:
|
||||
try:
|
||||
super().close()
|
||||
if self.bus is not None:
|
||||
self.bus.disconnect()
|
||||
self.runner.run(dbus_call(self.bus.wait_for_disconnect()))
|
||||
self.bus = None
|
||||
finally:
|
||||
self.runner.close()
|
||||
|
||||
|
||||
class CinnamonLayout(KDELayout):
|
||||
async def _request(self, method: str) -> list[Any] | None:
|
||||
bus = self.bus
|
||||
if bus is None:
|
||||
bus = MessageBus(bus_type=BusType.SESSION)
|
||||
await dbus_call(bus.connect())
|
||||
self.bus = bus
|
||||
return await _bus_call(bus, Message(
|
||||
destination='org.Cinnamon', path='/org/Cinnamon',
|
||||
interface='org.Cinnamon', member=method))
|
||||
|
||||
def _source(self) -> tuple[str, str]:
|
||||
result = self._call('GetInputSources')
|
||||
if len(result) != 1 or not isinstance(result[0], list):
|
||||
raise ValueError('Invalid Cinnamon input sources response')
|
||||
selected = []
|
||||
for source in result[0]:
|
||||
if not isinstance(source, (list, tuple)) or len(source) != 12:
|
||||
raise ValueError('Invalid Cinnamon input source entry')
|
||||
if source[-1] is True:
|
||||
selected.append(source)
|
||||
if len(selected) != 1:
|
||||
raise ValueError('Cinnamon current input source is unavailable')
|
||||
source = selected[0]
|
||||
layout, variant = source[7], source[8]
|
||||
if source[0] != 'xkb' or not isinstance(layout, str) or not layout:
|
||||
raise ValueError('Cinnamon input source is not an XKB layout')
|
||||
if not isinstance(variant, str):
|
||||
raise ValueError('Invalid Cinnamon XKB variant')
|
||||
return layout, variant
|
||||
|
||||
|
||||
class UmbrielLayout(NiriLayout):
|
||||
def _query_name(self) -> str:
|
||||
data = orjson.loads(command(['umbriel', 'keyboard-layouts', '--json']))
|
||||
if not isinstance(data, dict):
|
||||
raise ValueError('Invalid Umbriel keyboard layout response')
|
||||
names, index = data.get('names'), data.get('current_index')
|
||||
if not isinstance(names, list) or type(index) is not int or not 0 <= index < len(names):
|
||||
raise ValueError('Invalid Umbriel keyboard layout index')
|
||||
name = names[index]
|
||||
if not isinstance(name, str) or not name:
|
||||
raise ValueError('Invalid Umbriel keyboard layout name')
|
||||
return name
|
||||
|
||||
def switch(self) -> None:
|
||||
command(['umbriel', 'msg', 'keyboard-layout-next'])
|
||||
|
||||
|
||||
class MangoLayout(NiriLayout):
|
||||
def _query_name(self) -> str:
|
||||
data = orjson.loads(command(['mmsg', 'get', 'keyboardlayout']))
|
||||
name = data.get('layout') if isinstance(data, dict) else None
|
||||
if not isinstance(name, str) or not name:
|
||||
raise ValueError('Invalid Mango keyboard layout response')
|
||||
return name
|
||||
|
||||
def switch(self) -> None:
|
||||
# Zero cycles layouts; positive values select a one-based layout index.
|
||||
result = orjson.loads(command(['mmsg', 'dispatch', 'switch_keyboard_layout,0']))
|
||||
if not isinstance(result, dict) or result.get('success') is not True:
|
||||
raise RuntimeError(f'Mango failed to switch keyboard layout: {result}')
|
||||
|
||||
|
||||
def detect_layout() -> object:
|
||||
desktop = os.environ.get('XDG_CURRENT_DESKTOP', '').lower().split(':')
|
||||
if any('cinnamon' in name for name in desktop):
|
||||
return CinnamonLayout()
|
||||
if 'gnome' in desktop:
|
||||
return X11Layout() if is_x11_session(os.environ) else GSettingsLayout()
|
||||
if 'kde' in desktop:
|
||||
return KDELayout()
|
||||
name = compositor(os.environ)
|
||||
if name is None:
|
||||
ibus = (os.environ.get('XMODIFIERS') == '@im=ibus'
|
||||
or any(os.environ.get(key) == 'ibus' for key in ('GTK_IM_MODULE', 'QT_IM_MODULE')))
|
||||
if ibus and is_x11_session(os.environ):
|
||||
try:
|
||||
system_map = command(['gsettings', 'get', IBUS_SCHEMA, 'use-system-keyboard-layout'])
|
||||
if system_map.strip() == 'false' and command(['ibus', 'engine']).strip().startswith('xkb:'):
|
||||
return IBusLayout()
|
||||
except RuntimeError as error:
|
||||
logger.warning('IBus layout detection unavailable: %s', error)
|
||||
return X11Layout()
|
||||
adapter = {'cosmic': CosmicLayout, 'niri': NiriLayout, 'sway': SwayLayout,
|
||||
'hyprland': HyprlandLayout, 'umbriel': UmbrielLayout, 'mango': MangoLayout}.get(name)
|
||||
if adapter is None:
|
||||
raise RuntimeError('No keyboard layout adapter for this compositor')
|
||||
return adapter()
|
||||
@@ -1,231 +0,0 @@
|
||||
"""System input for the themed on-screen keyboard."""
|
||||
|
||||
from queue import Empty, Queue
|
||||
from threading import Event
|
||||
import time
|
||||
from typing import Any
|
||||
|
||||
from evdev import UInput, ecodes
|
||||
from PySide6.QtCore import QThread, Signal
|
||||
|
||||
from portprotonqt.logger import get_logger
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
INPUT_POLL_SECONDS = 0.15
|
||||
KEY_ROWS = (
|
||||
(ecodes.KEY_GRAVE, *range(ecodes.KEY_1, ecodes.KEY_EQUAL + 1)),
|
||||
(ecodes.KEY_TAB, *range(ecodes.KEY_Q, ecodes.KEY_RIGHTBRACE + 1), ecodes.KEY_BACKSLASH),
|
||||
(ecodes.KEY_CAPSLOCK, *range(ecodes.KEY_A, ecodes.KEY_APOSTROPHE + 1)),
|
||||
(ecodes.KEY_LEFTSHIFT, ecodes.KEY_102ND, *range(ecodes.KEY_Z, ecodes.KEY_SLASH + 1)),
|
||||
)
|
||||
SPECIAL_KEYS = (
|
||||
ecodes.KEY_BACKSPACE, ecodes.KEY_ENTER, ecodes.KEY_SPACE,
|
||||
ecodes.KEY_HOME, ecodes.KEY_END, ecodes.KEY_LEFT, ecodes.KEY_RIGHT,
|
||||
ecodes.KEY_UP, ecodes.KEY_DOWN,
|
||||
ecodes.KEY_LEFTCTRL, ecodes.KEY_KBD_LAYOUT_NEXT, ecodes.KEY_DELETE,
|
||||
ecodes.KEY_LEFTALT, ecodes.KEY_RIGHTALT, ecodes.KEY_LEFTMETA,
|
||||
)
|
||||
|
||||
|
||||
class SystemInputWorker(QThread):
|
||||
"""Own the input backend and serialize all key events off the UI thread."""
|
||||
|
||||
ready = Signal()
|
||||
failed = Signal(str)
|
||||
state_changed = Signal(dict)
|
||||
warning = Signal(str)
|
||||
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
self.commands: Queue[tuple[str, tuple[int, ...]]] = Queue()
|
||||
self.stopping = Event()
|
||||
self.enabled = Event()
|
||||
self.modifiers: set[int] = set()
|
||||
self.caps_lock = False
|
||||
self.layout: Any = None
|
||||
self.manual_layout = False
|
||||
|
||||
def run(self) -> None:
|
||||
from portprotonqt.system_keyboard.keys import SERVICE_KEYS
|
||||
|
||||
device = None
|
||||
try:
|
||||
keys = {code for row in KEY_ROWS for code in row} | set(SPECIAL_KEYS)
|
||||
keys.update(code for _, code in SERVICE_KEYS)
|
||||
device = UInput({ecodes.EV_KEY: sorted(keys), ecodes.EV_LED: [ecodes.LED_CAPSL]},
|
||||
name="PortProtonQt Keyboard", bustype=ecodes.BUS_USB)
|
||||
self._load_layout()
|
||||
self.ready.emit()
|
||||
self._run_commands(device)
|
||||
except OSError as error:
|
||||
logger.warning("System keyboard input unavailable: %s", error)
|
||||
self.failed.emit(str(error))
|
||||
except Exception as error:
|
||||
logger.exception("System keyboard input failed")
|
||||
self.failed.emit(str(error))
|
||||
finally:
|
||||
if device is not None:
|
||||
self._set_modifiers(device, ())
|
||||
device.close()
|
||||
close_layout = getattr(self.layout, 'close', None)
|
||||
if close_layout is not None:
|
||||
close_layout()
|
||||
|
||||
def _run_commands(self, device: UInput) -> None:
|
||||
next_poll = 0.0
|
||||
while not self.stopping.is_set():
|
||||
try:
|
||||
action, codes = self.commands.get(timeout=INPUT_POLL_SECONDS)
|
||||
except Empty:
|
||||
action, codes = '', ()
|
||||
if self.stopping.is_set():
|
||||
break
|
||||
try:
|
||||
if action:
|
||||
self._execute(device, action, codes)
|
||||
except RuntimeError as error:
|
||||
logger.warning('System keyboard command failed: %s', error)
|
||||
self.warning.emit(str(error))
|
||||
except ValueError as error:
|
||||
logger.warning('Invalid system keyboard command: %s', error)
|
||||
self.warning.emit(str(error))
|
||||
if action or time.monotonic() >= next_poll:
|
||||
self._refresh_state(device)
|
||||
next_poll = time.monotonic() + INPUT_POLL_SECONDS
|
||||
|
||||
def _load_layout(self) -> None:
|
||||
import os
|
||||
from portprotonqt.system_keyboard.detection import compositor, detect_layout
|
||||
from portprotonqt.system_keyboard.layouts import ManualLayout
|
||||
try:
|
||||
self.layout = detect_layout()
|
||||
except Exception as error:
|
||||
if not compositor(os.environ):
|
||||
raise
|
||||
logger.warning("System layout detection unavailable: %s", error)
|
||||
self.layout = ManualLayout()
|
||||
self.manual_layout = True
|
||||
self.warning.emit(f'{error}. Manual US/RU labels; external layout changes are not tracked.')
|
||||
|
||||
def _execute(self, device: UInput, action: str, codes: tuple[int, ...]) -> None:
|
||||
from portprotonqt.system_keyboard.detection import CinnamonLayout, GSettingsLayout, KDELayout, X11Layout, is_x11_session
|
||||
import os
|
||||
if action in {'tap', 'caps', 'language', 'modifiers'} and not self.enabled.is_set():
|
||||
return
|
||||
if action == 'modifiers':
|
||||
modifier_only = ((self.modifiers == {ecodes.KEY_LEFTMETA}
|
||||
and not is_x11_session(os.environ))
|
||||
or (len(self.modifiers) == 2 and ecodes.KEY_LEFTALT in self.modifiers
|
||||
and bool(self.modifiers & {ecodes.KEY_LEFTSHIFT, ecodes.KEY_RIGHTSHIFT})))
|
||||
if self.modifiers - set(codes) and modifier_only:
|
||||
# Replay modifier-only chords after the mouse release, with Shift last.
|
||||
chord = tuple(sorted(self.modifiers, key=lambda code: (
|
||||
code in {ecodes.KEY_LEFTSHIFT, ecodes.KEY_RIGHTSHIFT}, code)))
|
||||
self._set_modifiers(device, ())
|
||||
self.send_keys(device, chord)
|
||||
self._set_modifiers(device, codes)
|
||||
elif action == 'release':
|
||||
self._set_modifiers(device, ())
|
||||
elif action == 'caps':
|
||||
if isinstance(self.layout, X11Layout) and is_x11_session(os.environ):
|
||||
self.layout.toggle_caps_lock()
|
||||
else:
|
||||
self.send_keys(device, (ecodes.KEY_CAPSLOCK,))
|
||||
elif action == 'language':
|
||||
self._set_modifiers(device, ())
|
||||
if (type(self.layout) is X11Layout
|
||||
and 'gnome' in os.environ.get('XDG_CURRENT_DESKTOP', '').lower().split(':')):
|
||||
self.send_keys(device, GSettingsLayout.switch_codes())
|
||||
elif isinstance(self.layout, X11Layout) and is_x11_session(os.environ):
|
||||
self.layout.switch()
|
||||
elif isinstance(self.layout, CinnamonLayout):
|
||||
self.send_keys(device, self.layout.switch_codes())
|
||||
elif isinstance(self.layout, KDELayout):
|
||||
self.layout.switch()
|
||||
elif isinstance(self.layout, GSettingsLayout):
|
||||
self.send_keys(device, self.layout.switch_codes())
|
||||
elif self.manual_layout:
|
||||
self.send_keys(device, (ecodes.KEY_KBD_LAYOUT_NEXT,))
|
||||
self.layout.switch()
|
||||
elif hasattr(self.layout, 'switch') and not isinstance(self.layout, X11Layout):
|
||||
self.layout.switch()
|
||||
else:
|
||||
self.send_keys(device, (ecodes.KEY_KBD_LAYOUT_NEXT,))
|
||||
elif action == 'tap':
|
||||
try:
|
||||
self.send_keys(device, tuple(code for code in codes if code not in self.modifiers))
|
||||
finally:
|
||||
self._set_modifiers(device, ())
|
||||
|
||||
def _set_modifiers(self, device: UInput, codes: tuple[int, ...]) -> None:
|
||||
requested = set(codes)
|
||||
for code in sorted(self.modifiers - requested, reverse=True):
|
||||
try:
|
||||
device.write(ecodes.EV_KEY, code, 0)
|
||||
device.syn()
|
||||
except OSError:
|
||||
logger.exception('Failed to release system keyboard modifier %s', code)
|
||||
continue
|
||||
self.modifiers.discard(code)
|
||||
for code in sorted(requested - self.modifiers):
|
||||
self.modifiers.add(code)
|
||||
device.write(ecodes.EV_KEY, code, 1)
|
||||
device.syn()
|
||||
|
||||
def _refresh_state(self, device: UInput) -> None:
|
||||
from portprotonqt.system_keyboard.detection import X11Layout, is_x11_session
|
||||
import os
|
||||
try:
|
||||
for event in device.read():
|
||||
if event.type == ecodes.EV_LED and event.code == ecodes.LED_CAPSL:
|
||||
self.caps_lock = bool(event.value)
|
||||
except BlockingIOError:
|
||||
pass
|
||||
try:
|
||||
caps = (self.layout.caps_lock() if isinstance(self.layout, X11Layout)
|
||||
and is_x11_session(os.environ) else self.caps_lock)
|
||||
modifiers = self.modifiers & {ecodes.KEY_LEFTSHIFT, ecodes.KEY_RIGHTSHIFT, ecodes.KEY_RIGHTALT}
|
||||
if caps:
|
||||
modifiers.add(ecodes.KEY_CAPSLOCK)
|
||||
labels = self.layout.labels(modifiers)
|
||||
current = getattr(self.layout, 'current', None)
|
||||
name = current[0] if isinstance(current, tuple) else getattr(self.layout, 'language', 'System')
|
||||
if hasattr(self.layout, 'layout_identifier'):
|
||||
name = self.layout.layout_identifier()
|
||||
self.state_changed.emit({'labels': labels, 'caps': caps,
|
||||
'shift': bool(self.modifiers & {ecodes.KEY_LEFTSHIFT, ecodes.KEY_RIGHTSHIFT}),
|
||||
'modifiers': tuple(sorted(self.modifiers)), 'layout': name})
|
||||
except Exception as error:
|
||||
logger.warning("Cannot update system keyboard labels: %s", error)
|
||||
self.warning.emit(str(error))
|
||||
|
||||
def send_keys(self, device: UInput, codes: tuple[int, ...]) -> None:
|
||||
pressed = []
|
||||
try:
|
||||
for code in codes:
|
||||
pressed.append(code)
|
||||
device.write(ecodes.EV_KEY, code, 1)
|
||||
device.syn()
|
||||
finally:
|
||||
for code in reversed(pressed):
|
||||
try:
|
||||
device.write(ecodes.EV_KEY, code, 0)
|
||||
device.syn()
|
||||
except OSError:
|
||||
logger.exception("Failed to release system keyboard key %s", code)
|
||||
|
||||
def stop(self) -> None:
|
||||
self.enabled.clear()
|
||||
self.stopping.set()
|
||||
self.commands.put(('', ()))
|
||||
self.wait()
|
||||
|
||||
def cancel_pending(self) -> None:
|
||||
self.enabled.clear()
|
||||
while True:
|
||||
try:
|
||||
self.commands.get_nowait()
|
||||
except Empty:
|
||||
break
|
||||
self.commands.put(('release', ()))
|
||||
@@ -1,29 +0,0 @@
|
||||
"""Physical keys shared by uinput and XKB label readers."""
|
||||
|
||||
from evdev import ecodes
|
||||
|
||||
from portprotonqt.system_keyboard.input import KEY_ROWS
|
||||
|
||||
ROWS = [[("", code) for code in row] for row in KEY_ROWS]
|
||||
MODIFIERS = {ecodes.KEY_LEFTSHIFT, ecodes.KEY_LEFTCTRL, ecodes.KEY_LEFTMETA,
|
||||
ecodes.KEY_LEFTALT, ecodes.KEY_RIGHTALT, ecodes.KEY_RIGHTSHIFT, ecodes.KEY_RIGHTCTRL}
|
||||
SERVICE_KEYS = (
|
||||
('Esc', ecodes.KEY_ESC), ('PrtSc', ecodes.KEY_SYSRQ), ('Del', ecodes.KEY_DELETE),
|
||||
('⌫', ecodes.KEY_BACKSPACE), ('Enter', ecodes.KEY_ENTER), ('Space', ecodes.KEY_SPACE),
|
||||
('Ctrl', ecodes.KEY_LEFTCTRL), ('RCtrl', ecodes.KEY_RIGHTCTRL), ('Super', ecodes.KEY_LEFTMETA),
|
||||
('Alt', ecodes.KEY_LEFTALT), ('AltGr', ecodes.KEY_RIGHTALT), ('RShift', ecodes.KEY_RIGHTSHIFT),
|
||||
('◄', ecodes.KEY_LEFT), ('►', ecodes.KEY_RIGHT), ('▲', ecodes.KEY_UP), ('▼', ecodes.KEY_DOWN),
|
||||
*((f'F{number}', getattr(ecodes, f'KEY_F{number}')) for number in range(1, 13)),
|
||||
)
|
||||
KEY_KBD_LAYOUT_NEXT = ecodes.KEY_KBD_LAYOUT_NEXT
|
||||
LATCH_KEYS = frozenset(MODIFIERS | {code for key, code in SERVICE_KEYS if key.startswith('F')})
|
||||
XKB_KEYCODE_OFFSET = 8
|
||||
XKB_CORE_KEYBOARD = 0x0100
|
||||
XKB_SHIFT_MASK = 1
|
||||
XKB_LOCK_MASK = 2
|
||||
XKB_ALTGR_MASK = 128
|
||||
XKB_GROUP_COUNT = 4
|
||||
XKB_GROUP_SHIFT = 13
|
||||
KEYSYM_UNICODE_FLAG = 0x01000000
|
||||
KEYSYM_UNICODE_MASK = 0xFFFFFF
|
||||
UNICODE_MAX = 0x10FFFF
|
||||
@@ -1,156 +0,0 @@
|
||||
"""Read bundled keyboard layers and compositor-provided symbol maps."""
|
||||
from functools import lru_cache
|
||||
from importlib.resources import files
|
||||
import re
|
||||
from typing import Any
|
||||
|
||||
import orjson
|
||||
from evdev import ecodes
|
||||
|
||||
from portprotonqt.keyboard_layouts import keyboard_layouts
|
||||
from portprotonqt.system_keyboard.keys import (
|
||||
ROWS, MODIFIERS, XKB_SHIFT_MASK, XKB_LOCK_MASK, XKB_ALTGR_MASK, XKB_KEYCODE_OFFSET,
|
||||
KEYSYM_UNICODE_FLAG, KEYSYM_UNICODE_MASK, UNICODE_MAX,
|
||||
)
|
||||
|
||||
|
||||
@lru_cache(maxsize=1)
|
||||
def _symbols() -> dict[str, dict[str, str]]:
|
||||
return orjson.loads(files('portprotonqt').joinpath('keyboard_symbols.json').read_bytes())
|
||||
|
||||
|
||||
def keysym_label(symbol: int | str) -> str:
|
||||
"""Translate X11 keysyms without a runtime xkbcommon library."""
|
||||
if isinstance(symbol, int):
|
||||
value = symbol & KEYSYM_UNICODE_MASK if symbol & ~KEYSYM_UNICODE_MASK == KEYSYM_UNICODE_FLAG else symbol
|
||||
if symbol & ~KEYSYM_UNICODE_MASK == KEYSYM_UNICODE_FLAG and value <= UNICODE_MAX:
|
||||
return chr(value) if chr(value).isprintable() else ''
|
||||
return _symbols()['values'].get(str(symbol), '')
|
||||
if re.fullmatch(r'U[0-9a-fA-F]{4,8}', symbol):
|
||||
value = int(symbol[1:], 16)
|
||||
return chr(value) if value <= UNICODE_MAX and chr(value).isprintable() else symbol
|
||||
if symbol.startswith('0x'):
|
||||
value = int(symbol, 16)
|
||||
fallback = f'U{value & KEYSYM_UNICODE_MASK:04X}' if value & ~KEYSYM_UNICODE_MASK == KEYSYM_UNICODE_FLAG else symbol
|
||||
return _symbols()['keysyms'].get(str(value), keysym_label(value) or fallback)
|
||||
return _symbols()['names'].get(symbol, symbol)
|
||||
|
||||
|
||||
class Layout:
|
||||
def __init__(self, layout: Any='us', variant: Any='', *, keymap_text: Any=None) -> None:
|
||||
layout = 'us' if layout == 'en' else layout
|
||||
self.identifier = f'{layout}+{variant}' if variant else layout
|
||||
self.groups: dict[int, str] = {}
|
||||
self.types: dict[str, tuple[set[str], dict[frozenset[str], int], dict[frozenset[str], set[str]]]] = {}
|
||||
self.keys: dict[int, tuple[dict[int, str], dict[int, list[str]]]] = {}
|
||||
if keymap_text is not None:
|
||||
self._read_keymap(keymap_text.decode() if isinstance(keymap_text, bytes) else keymap_text)
|
||||
elif self.identifier not in keyboard_layouts:
|
||||
raise ValueError(f'Unknown keyboard layout: {self.identifier}')
|
||||
|
||||
def _read_keymap(self, text: str) -> None:
|
||||
text = re.sub(r'/\*.*?\*/|//[^\n]*', '', text, flags=re.DOTALL)
|
||||
codes = {name: int(code) - XKB_KEYCODE_OFFSET
|
||||
for name, code in re.findall(r'<([^>]+)>\s*=\s*(\d+)\s*;', text)}
|
||||
self.groups = {int(group) - 1: name for group, name in re.findall(
|
||||
r'name\[(?:Group)?(\d+)\]\s*=\s*"([^"]*)"', text)}
|
||||
for name, body in re.findall(r'type\s+"([^"]+)"\s*\{(.*?)\};', text, re.DOTALL):
|
||||
modifiers = re.search(r'modifiers\s*=\s*([^;]+)', body)
|
||||
allowed = set(modifiers[1].split('+')) if modifiers else set()
|
||||
levels = {frozenset(part.strip() for part in mask.split('+') if part.strip() != 'None'):
|
||||
int(level) - 1 for mask, level in re.findall(
|
||||
r'map\[([^]]+)\]\s*=\s*(?:Level)?(\d+)', body)}
|
||||
preserved = {frozenset(part.strip() for part in mask.split('+')):
|
||||
{part.strip() for part in value.split('+')} for mask, value in re.findall(
|
||||
r'preserve\[([^]]+)\]\s*=\s*([^;]+)', body)}
|
||||
self.types[name] = ({part.strip() for part in allowed}, levels, preserved)
|
||||
for name, body in re.findall(r'key\s+<([^>]+)>\s*\{(.*?)\};', text, re.DOTALL):
|
||||
if name not in codes:
|
||||
continue
|
||||
types = {int(group or 1) - 1: kind for group, kind in re.findall(
|
||||
r'type(?:\[(?:Group)?(\d+)\])?\s*=\s*"([^"]+)"', body)}
|
||||
groups = {int(group) - 1: [part.strip() for part in symbols.split(',')]
|
||||
for group, symbols in re.findall(
|
||||
r'symbols\[(?:Group)?(\d+)\]\s*=\s*\[([^]]*)\]', body)}
|
||||
if not groups:
|
||||
symbols = re.search(r'\[([^]]*)\]', body)
|
||||
if symbols:
|
||||
groups[0] = [part.strip() for part in symbols[1].split(',')]
|
||||
self.keys[codes[name]] = types, groups
|
||||
if not self.keys:
|
||||
raise ValueError('Keyboard keymap contains no physical keys')
|
||||
|
||||
def _keymap_labels(self, modifiers: set[int], mask: tuple[int, ...]) -> dict[str, str]:
|
||||
depressed, latched, locked, group = mask
|
||||
bits = depressed | latched | locked
|
||||
active = set()
|
||||
_, alt_groups = self.keys.get(ecodes.KEY_RIGHTALT, ({}, {}))
|
||||
alt_symbols = alt_groups.get(group, alt_groups.get(0, []))
|
||||
altgr_codes = {ecodes.KEY_RIGHTALT} if any(
|
||||
keysym_label(symbol) in {'ISO_Level3_Shift', 'Mode_switch'} for symbol in alt_symbols) else set()
|
||||
for name, bit, codes in (
|
||||
('Shift', XKB_SHIFT_MASK, {ecodes.KEY_LEFTSHIFT, ecodes.KEY_RIGHTSHIFT}),
|
||||
('Lock', XKB_LOCK_MASK, {ecodes.KEY_CAPSLOCK}),
|
||||
('LevelThree', XKB_ALTGR_MASK, altgr_codes),
|
||||
):
|
||||
if bits & bit or modifiers & codes:
|
||||
active.add(name)
|
||||
result = {}
|
||||
for code, (types, groups) in self.keys.items():
|
||||
if code in MODIFIERS:
|
||||
continue
|
||||
symbols = groups.get(group, groups.get(0, []))
|
||||
kind = types.get(group, types.get(0, ''))
|
||||
if not kind:
|
||||
labels = [keysym_label(symbol) for symbol in symbols]
|
||||
alphabetic = len(labels) > 1 and labels[0].islower() and labels[1].isupper()
|
||||
kind = 'ALPHABETIC' if alphabetic else 'TWO_LEVEL'
|
||||
if len(labels) > 2:
|
||||
kind = 'FOUR_LEVEL_SEMIALPHABETIC' if alphabetic else 'FOUR_LEVEL'
|
||||
if alphabetic and len(labels) > 3 and labels[2].islower() and labels[3].isupper():
|
||||
kind = 'FOUR_LEVEL_ALPHABETIC'
|
||||
if len(labels) == 1:
|
||||
kind = 'ONE_LEVEL'
|
||||
allowed, levels, preserved = self.types.get(kind, (set(), {}, {}))
|
||||
selected = frozenset(active & allowed)
|
||||
level = levels.get(selected, 0)
|
||||
symbol = symbols[level] if level < len(symbols) else 'NoSymbol'
|
||||
label = keysym_label(symbol)
|
||||
if 'Lock' in active and ('Lock' not in allowed or 'Lock' in preserved.get(selected, set())):
|
||||
label = _symbols()['upper'].get(label, label.upper() if len(label) == 1 else label)
|
||||
result[str(code)] = label
|
||||
return result
|
||||
|
||||
def labels(self, modifiers: Any=(), *, mask: Any=None) -> dict[str, str]:
|
||||
native_mask = (0, 0, 0, 0) if mask is None else tuple(mask)
|
||||
depressed, latched, locked, group = native_mask
|
||||
codes = set(modifiers)
|
||||
if self.keys:
|
||||
return self._keymap_labels(codes, native_mask)
|
||||
bits = depressed | latched | locked
|
||||
shift = bool(bits & XKB_SHIFT_MASK or codes & {ecodes.KEY_LEFTSHIFT, ecodes.KEY_RIGHTSHIFT})
|
||||
altgr = bool(bits & XKB_ALTGR_MASK or ecodes.KEY_RIGHTALT in codes)
|
||||
caps = bool(bits & XKB_LOCK_MASK or ecodes.KEY_CAPSLOCK in codes)
|
||||
layer = '_'.join(name for name, enabled in (
|
||||
('shift', shift), ('altgr', altgr), ('caps', caps)) if enabled) or 'normal'
|
||||
rows = keyboard_layouts[self.identifier][layer]
|
||||
return {str(code): label.replace('&&', '&')
|
||||
for labels, physical in zip(rows, ROWS, strict=True)
|
||||
for label, (_, code) in zip(labels, physical, strict=True) if code not in MODIFIERS}
|
||||
|
||||
def layout_identifier(self, group: int) -> str:
|
||||
return self.groups.get(group, self.identifier)
|
||||
|
||||
|
||||
class ManualLayout:
|
||||
def __init__(self) -> None:
|
||||
self.layout = Layout('us')
|
||||
self.language = 'us'
|
||||
|
||||
def switch(self) -> Any:
|
||||
language = 'ru' if self.language == 'us' else 'us'
|
||||
self.layout = Layout(language)
|
||||
self.language = language
|
||||
|
||||
def labels(self, modifiers: Any=()) -> Any:
|
||||
return self.layout.labels(modifiers)
|
||||
@@ -1,14 +0,0 @@
|
||||
"""Load the linked keyboard backend using the same paths as the SDL backend."""
|
||||
|
||||
import ctypes
|
||||
from pathlib import Path
|
||||
|
||||
KEYBOARD_LIBRARY_NAME = 'libportprotonqt_keyboard.so'
|
||||
SYSTEM_KEYBOARD_LIBRARY = Path(__file__).parent.parent / KEYBOARD_LIBRARY_NAME
|
||||
DEV_KEYBOARD_LIBRARY = Path(__file__).parent.parent.parent / 'build-aux' / 'lib' / KEYBOARD_LIBRARY_NAME
|
||||
KEYBOARD_LIBRARY_PATH = (SYSTEM_KEYBOARD_LIBRARY if SYSTEM_KEYBOARD_LIBRARY.is_file()
|
||||
else DEV_KEYBOARD_LIBRARY)
|
||||
|
||||
|
||||
def load_library() -> ctypes.CDLL:
|
||||
return ctypes.CDLL(str(KEYBOARD_LIBRARY_PATH))
|
||||
@@ -1,780 +0,0 @@
|
||||
"""Reuse the embedded keyboard's buttons and theme for system input."""
|
||||
|
||||
import ctypes as C
|
||||
from functools import partial
|
||||
import mmap
|
||||
import select
|
||||
import sys
|
||||
import tempfile
|
||||
from types import SimpleNamespace
|
||||
from typing import Any, cast
|
||||
|
||||
import orjson
|
||||
from evdev import ecodes
|
||||
from PySide6.QtCore import QEvent, QObject, QPoint, QPointF, QSocketNotifier, Qt, QTimer
|
||||
from PySide6.QtGui import QCloseEvent, QIcon, QMouseEvent, QImage, QRegion
|
||||
from PySide6.QtWidgets import QApplication, QFrame, QLabel, QPushButton, QSizePolicy, QWidget
|
||||
|
||||
from portprotonqt.config import gamepad_config, ui_config
|
||||
from portprotonqt.input_manager.constants import GamepadType
|
||||
from portprotonqt.keyboard_layouts import keyboard_layouts
|
||||
from portprotonqt.logger import get_logger
|
||||
from portprotonqt.tabs.control_hints import MainWindowControlHintsMixin
|
||||
from portprotonqt.theme_manager import ThemeManager
|
||||
from portprotonqt.virtual_keyboard import VirtualKeyboard
|
||||
|
||||
from portprotonqt.system_keyboard.input import KEY_ROWS, SystemInputWorker
|
||||
from portprotonqt.system_keyboard.keys import LATCH_KEYS, SERVICE_KEYS
|
||||
from portprotonqt.system_keyboard.native import load_library
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
|
||||
def report(event: str, value: object = None) -> None:
|
||||
sys.stdout.buffer.write(orjson.dumps({'event': event, 'value': value}) + b'\n')
|
||||
sys.stdout.buffer.flush()
|
||||
|
||||
|
||||
class SystemKeyboardPanel(VirtualKeyboard):
|
||||
def __init__(self, owner: 'SystemKeyboardWindow', theme: Any) -> None:
|
||||
self.owner = owner
|
||||
self.keycodes: dict[str, int] = {}
|
||||
self.labels: dict[str, str] = {}
|
||||
self.modifiers: set[int] = set()
|
||||
self.layout_name = 'System'
|
||||
self.drag_origin: QPoint | None = None
|
||||
self.emoji_open = False
|
||||
super().__init__(owner, theme)
|
||||
self.set_slide_animation_enabled(False)
|
||||
self.setObjectName('systemKeyboard')
|
||||
self.keyboard_container.setObjectName('systemKeyboardContainer')
|
||||
self.refresh_theme(theme)
|
||||
|
||||
def refresh_theme(self, theme: Any) -> None:
|
||||
super().refresh_theme(theme)
|
||||
self.setStyleSheet(theme.VIRTUAL_KEYBOARD_STYLE + theme.SYSTEM_KEYBOARD_BACKGROUND_STYLE)
|
||||
|
||||
def set_gamepad_icon(self, button: QPushButton, icon_type: str, gtype: Any = '') -> None:
|
||||
if self.owner.input_manager.gamepad:
|
||||
super().set_gamepad_icon(button, icon_type, gtype)
|
||||
else:
|
||||
button.setIcon(QIcon())
|
||||
|
||||
def get_layouts_setxkbmap(self) -> list[str]:
|
||||
return ['us']
|
||||
|
||||
def _space_button_text(self) -> str:
|
||||
return 'Space'
|
||||
|
||||
def _save_focused_coords(self) -> tuple[int, int] | None:
|
||||
current = self.selected_button
|
||||
if current is None:
|
||||
return None
|
||||
index = self.keyboard_layout.indexOf(current)
|
||||
if index < 0:
|
||||
return None
|
||||
row, column, _, _ = cast(tuple[int, int, int, int], self.keyboard_layout.getItemPosition(index))
|
||||
return row, column
|
||||
|
||||
def _apply_responsive_metrics(self) -> None:
|
||||
metrics = self.theme.SYSTEM_KEYBOARD
|
||||
self.num_cols = metrics['columns']
|
||||
self.button_height = metrics['key_height']
|
||||
self.spacing = metrics['spacing']
|
||||
margin = metrics['margin']
|
||||
self.keyboard_layout.setSpacing(self.spacing)
|
||||
self.keyboard_layout.setContentsMargins(margin, margin, margin, margin)
|
||||
width = min(self.owner.width(), metrics['width'])
|
||||
height = metrics['height'] + (metrics['warning_height'] if self.owner.warning_message else 0)
|
||||
if hasattr(self, 'keyboard_container'):
|
||||
self.keyboard_container.setFixedSize(width, height)
|
||||
for column in range(self.num_cols):
|
||||
self.keyboard_layout.setColumnStretch(column, 1)
|
||||
|
||||
def update_keyboard(self) -> None:
|
||||
self._apply_responsive_metrics()
|
||||
selected = next((key for key, button in self.buttons.items() if button is self.selected_button), None)
|
||||
self.selected_button = None
|
||||
while self.keyboard_layout.count():
|
||||
item = self.keyboard_layout.takeAt(0)
|
||||
widget = item.widget() if item is not None else None
|
||||
if widget is not None:
|
||||
widget.setParent(None)
|
||||
widget.deleteLater()
|
||||
self.buttons.clear()
|
||||
self.keycodes = dict(SERVICE_KEYS)
|
||||
for row, codes in zip(keyboard_layouts['us']['normal'], KEY_ROWS, strict=True):
|
||||
self.keycodes.update(zip(row, codes, strict=True))
|
||||
units = self.theme.SYSTEM_KEYBOARD['row_units']
|
||||
rows = self.theme.SYSTEM_KEYBOARD['emoji_rows' if self.emoji_open else 'rows']
|
||||
for row, keys in enumerate(rows):
|
||||
column = 0
|
||||
for key, span in keys:
|
||||
if key == '▲▼':
|
||||
self._add_key('▲', (row * units, column, 1, span))
|
||||
self._add_key('▼', (row * units + 1, column, 1, span))
|
||||
else:
|
||||
self._add_key(key, (row * units, column, units, span))
|
||||
column += span
|
||||
self.apply_key_state()
|
||||
default = rows[0][0][0]
|
||||
self._set_selected_button(self.buttons.get(selected or default, self.buttons[default]))
|
||||
if self.owner.warning_message:
|
||||
warning = QLabel(self.owner.warning_message)
|
||||
warning.setStyleSheet(self.theme.SETTINGS_TITLE_STYLE)
|
||||
warning.setWordWrap(True)
|
||||
self.keyboard_layout.addWidget(warning, len(self.theme.SYSTEM_KEYBOARD['rows']) * units,
|
||||
0, units, self.num_cols)
|
||||
|
||||
def _add_key(self, key: str, position: tuple[int, int, int, int]) -> None:
|
||||
button = QPushButton('⬆' if key == 'RShift' else key)
|
||||
button.setFocusPolicy(Qt.FocusPolicy.NoFocus)
|
||||
button.setSizePolicy(QSizePolicy.Policy.Ignored, QSizePolicy.Policy.Fixed)
|
||||
button.setMinimumWidth(self.theme.SYSTEM_KEYBOARD['minimum_key_width'])
|
||||
units = self.theme.SYSTEM_KEYBOARD['row_units']
|
||||
height = (self.button_height + self.spacing) * position[2] // units - self.spacing
|
||||
button.setFixedHeight(height)
|
||||
code = self.keycodes.get(key)
|
||||
if code is not None and code in LATCH_KEYS:
|
||||
button.setCheckable(True)
|
||||
button.clicked.connect(lambda checked: self._toggle_modifier(code, checked))
|
||||
elif key == 'CAPS':
|
||||
button.setCheckable(True)
|
||||
button.clicked.connect(self.on_caps_click)
|
||||
elif key == '⌫':
|
||||
button.setProperty('sound_event', False)
|
||||
button.pressed.connect(self.on_backspace_pressed)
|
||||
button.released.connect(self.stop_backspace_repeat)
|
||||
elif key in {'🌐', 'Hide'}:
|
||||
button.clicked.connect(self.on_lang_click if key == '🌐' else self.hide)
|
||||
else:
|
||||
button.clicked.connect(lambda checked=False: self.on_button_click(key))
|
||||
self.keyboard_layout.addWidget(button, *position)
|
||||
self.buttons[key] = button
|
||||
icon = {'⬆': 'right', 'RShift': 'right', '⌫': 'add_game', '🌐': 'left', 'Hide': 'back'}.get(key)
|
||||
if icon is not None:
|
||||
self.set_gamepad_icon(button, icon, self.input_manager.gamepad_type)
|
||||
|
||||
def _toggle_modifier(self, code: int, checked: bool) -> None:
|
||||
if checked:
|
||||
self.modifiers.add(code)
|
||||
else:
|
||||
self.modifiers.discard(code)
|
||||
self.shift_pressed = bool(self.modifiers & {ecodes.KEY_LEFTSHIFT, ecodes.KEY_RIGHTSHIFT})
|
||||
self.owner.worker.commands.put(('modifiers', tuple(sorted(self.modifiers))))
|
||||
self.apply_key_state()
|
||||
|
||||
def apply_key_state(self) -> None:
|
||||
for key, button in self.buttons.items():
|
||||
code = self.keycodes.get(key)
|
||||
if code not in LATCH_KEYS | {None, ecodes.KEY_TAB, ecodes.KEY_CAPSLOCK} and str(code) in self.labels:
|
||||
text = self.labels[str(code)].replace('&', '&&')
|
||||
if button.text() != text:
|
||||
button.setText(text)
|
||||
for key, button in self.buttons.items():
|
||||
checked = None
|
||||
if key == 'CAPS':
|
||||
checked = self.caps_lock
|
||||
elif button.isCheckable():
|
||||
checked = self.keycodes[key] in self.modifiers
|
||||
if checked is not None and button.isChecked() != checked:
|
||||
button.setChecked(checked)
|
||||
button.style().unpolish(button)
|
||||
button.style().polish(button)
|
||||
button.update()
|
||||
|
||||
def _release_modifiers(self) -> None:
|
||||
self.modifiers.clear()
|
||||
self.shift_pressed = False
|
||||
self.owner.worker.commands.put(('release', ()))
|
||||
self.apply_key_state()
|
||||
|
||||
def close_emoji_panel(self) -> None:
|
||||
if self.emoji_open:
|
||||
self.emoji_open = False
|
||||
self.update_keyboard()
|
||||
self._set_selected_button(self.buttons['🙂'])
|
||||
|
||||
def on_button_click(self, key: str) -> None:
|
||||
if self.emoji_open:
|
||||
if key != 'ABC':
|
||||
report('emoji', key)
|
||||
self.close_emoji_panel()
|
||||
return
|
||||
if key == '🙂':
|
||||
self.stop_backspace_repeat()
|
||||
self._release_modifiers()
|
||||
self.emoji_open = True
|
||||
self.update_keyboard()
|
||||
self._set_selected_button(self.buttons['😀'])
|
||||
return
|
||||
code = ecodes.KEY_SPACE if key == ' ' else self.keycodes.get(key)
|
||||
if code is not None:
|
||||
self.owner.worker.commands.put(('tap', (code,)))
|
||||
|
||||
def on_backspace_click(self) -> None:
|
||||
self.owner.worker.commands.put(('tap', (ecodes.KEY_BACKSPACE,)))
|
||||
|
||||
def on_enter_click(self) -> None:
|
||||
self.owner.worker.commands.put(('tap', (ecodes.KEY_ENTER,)))
|
||||
|
||||
def on_caps_click(self) -> None:
|
||||
self.apply_key_state()
|
||||
self.owner.worker.commands.put(('caps', ()))
|
||||
|
||||
def on_shift_click(self, checked: bool) -> None:
|
||||
self._toggle_modifier(ecodes.KEY_LEFTSHIFT, checked)
|
||||
|
||||
def on_lang_click(self) -> None:
|
||||
self.owner.worker.commands.put(('language', ()))
|
||||
|
||||
def up_key(self) -> None:
|
||||
self.owner.worker.commands.put(('tap', (ecodes.KEY_UP,)))
|
||||
|
||||
def down_key(self) -> None:
|
||||
self.owner.worker.commands.put(('tap', (ecodes.KEY_DOWN,)))
|
||||
|
||||
def left_key(self) -> None:
|
||||
self.owner.worker.commands.put(('tap', (ecodes.KEY_LEFT,)))
|
||||
|
||||
def right_key(self) -> None:
|
||||
self.owner.worker.commands.put(('tap', (ecodes.KEY_RIGHT,)))
|
||||
|
||||
def hide(self) -> None:
|
||||
self.stop_backspace_repeat()
|
||||
QFrame.hide(self)
|
||||
if getattr(self.owner, 'keyboard', None) is self:
|
||||
self.owner.hide_keyboard()
|
||||
|
||||
def eventFilter(self, obj: QObject, event: QEvent) -> bool:
|
||||
return QFrame.eventFilter(self, obj, event)
|
||||
|
||||
def mousePressEvent(self, event: QMouseEvent) -> None:
|
||||
if event.button() == Qt.MouseButton.LeftButton:
|
||||
self.drag_origin = event.globalPosition().toPoint()
|
||||
event.accept()
|
||||
return
|
||||
super().mousePressEvent(event)
|
||||
|
||||
def mouseMoveEvent(self, event: QMouseEvent) -> None:
|
||||
if self.drag_origin is not None:
|
||||
position = event.globalPosition().toPoint()
|
||||
delta = position - self.drag_origin
|
||||
self.drag_origin = position
|
||||
if self.owner.layer_shell:
|
||||
position = self.pos() + delta
|
||||
self.move(max(0, min(position.x(), self.owner.width() - self.width())),
|
||||
max(0, min(position.y(), self.owner.height() - self.height())))
|
||||
else:
|
||||
self.owner.move(self.owner.pos() + delta)
|
||||
event.accept()
|
||||
return
|
||||
super().mouseMoveEvent(event)
|
||||
|
||||
def mouseReleaseEvent(self, event: QMouseEvent) -> None:
|
||||
self.drag_origin = None
|
||||
super().mouseReleaseEvent(event)
|
||||
|
||||
|
||||
class SystemKeyboardWindow(QWidget, MainWindowControlHintsMixin):
|
||||
def __init__(self, layer_shell: bool = False) -> None:
|
||||
super().__init__(None, Qt.WindowType.Tool | Qt.WindowType.FramelessWindowHint
|
||||
| Qt.WindowType.WindowStaysOnTopHint | Qt.WindowType.WindowDoesNotAcceptFocus)
|
||||
self.setWindowTitle('PortProtonQt System Keyboard')
|
||||
self.setAttribute(Qt.WidgetAttribute.WA_ShowWithoutActivating)
|
||||
self.setAttribute(Qt.WidgetAttribute.WA_X11NetWmWindowTypeDock)
|
||||
self.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
|
||||
self.layer_shell = layer_shell
|
||||
self.setAttribute(Qt.WidgetAttribute.WA_DontShowOnScreen, layer_shell)
|
||||
self.native_layer: Any = None
|
||||
self.theme_manager = ThemeManager()
|
||||
self.theme = self.theme_manager.apply_theme(ui_config.get_theme())
|
||||
gtype = GamepadType.PLAYSTATION if gamepad_config.get_gamepad_type() == 'playstation' else GamepadType.XBOX
|
||||
self.input_manager = SimpleNamespace(gamepad_type=gtype, gamepad=False)
|
||||
self.worker = SystemInputWorker()
|
||||
self.ready = False
|
||||
self.wanted_visible = False
|
||||
self.warning_message = ''
|
||||
self.resize(self.theme.SYSTEM_KEYBOARD['width'], self.theme.SYSTEM_KEYBOARD['height'])
|
||||
self.keyboard = SystemKeyboardPanel(self, self.theme)
|
||||
self.worker.ready.connect(self._ready)
|
||||
self.worker.failed.connect(self._failed)
|
||||
self.worker.state_changed.connect(self._state_changed)
|
||||
self.worker.warning.connect(self._warning)
|
||||
self._position_keyboard()
|
||||
screen = self.screen()
|
||||
if screen is not None:
|
||||
screen.availableGeometryChanged.connect(self._position_keyboard)
|
||||
screen.geometryChanged.connect(self._position_keyboard)
|
||||
|
||||
def _position_keyboard(self) -> None:
|
||||
screen = self.screen()
|
||||
if screen is None:
|
||||
return
|
||||
metrics = self.theme.SYSTEM_KEYBOARD
|
||||
area = screen.geometry() if self.layer_shell else screen.availableGeometry()
|
||||
available_width = self.width() if self.layer_shell else area.width()
|
||||
width, height = min(available_width, metrics['width']), metrics['height']
|
||||
if self.warning_message:
|
||||
height += metrics['warning_height']
|
||||
if self.layer_shell:
|
||||
self.keyboard.setFixedSize(width, height)
|
||||
self.keyboard.move((self.width() - width) // 2, max(0, self.height() - height))
|
||||
else:
|
||||
self.resize(width, height)
|
||||
self.move(area.x() + (area.width() - width) // 2, area.bottom() - height + 1)
|
||||
self.keyboard.setFixedSize(width, height)
|
||||
self.keyboard.move(0, 0)
|
||||
self.keyboard.update_keyboard()
|
||||
|
||||
def show_keyboard(self) -> None:
|
||||
self.wanted_visible = True
|
||||
if not self.ready:
|
||||
return
|
||||
self.worker.enabled.set()
|
||||
self._position_keyboard()
|
||||
self.keyboard.show()
|
||||
self.show()
|
||||
self.keyboard.raise_()
|
||||
if self.native_layer is not None:
|
||||
self.native_layer.show_layer()
|
||||
|
||||
def hide_keyboard(self) -> None:
|
||||
self.wanted_visible = False
|
||||
self.worker.cancel_pending()
|
||||
self.keyboard.stop_backspace_repeat()
|
||||
self.keyboard._release_modifiers()
|
||||
self.keyboard.close_emoji_panel()
|
||||
if self.native_layer is not None:
|
||||
self.native_layer.hide_layer()
|
||||
self.hide()
|
||||
report('hidden')
|
||||
|
||||
def _ready(self) -> None:
|
||||
self.ready = True
|
||||
if self.wanted_visible:
|
||||
self.show_keyboard()
|
||||
|
||||
def _failed(self, message: str) -> None:
|
||||
logger.error('System keyboard: %s', message)
|
||||
app = QApplication.instance()
|
||||
if app is not None:
|
||||
app.exit(1)
|
||||
|
||||
def _warning(self, message: str) -> None:
|
||||
logger.warning('System keyboard: %s', message)
|
||||
if self.warning_message != message:
|
||||
self.warning_message = message
|
||||
self._position_keyboard()
|
||||
|
||||
def _state_changed(self, state: dict[str, Any]) -> None:
|
||||
changed = self.keyboard.labels != state['labels'] or self.keyboard.caps_lock != state['caps']
|
||||
changed |= self.keyboard.shift_pressed != state['shift']
|
||||
changed |= self.keyboard.modifiers != set(state['modifiers'])
|
||||
changed |= self.keyboard.layout_name != state['layout']
|
||||
self.keyboard.labels = state['labels']
|
||||
self.keyboard.caps_lock = state['caps']
|
||||
self.keyboard.shift_pressed = state['shift']
|
||||
self.keyboard.modifiers = set(state['modifiers'])
|
||||
self.keyboard.layout_name = state['layout']
|
||||
self.keyboard.apply_key_state()
|
||||
if changed:
|
||||
report('shift', state['shift'])
|
||||
|
||||
def command(self, action: str, value: Any = None) -> None:
|
||||
if action == 'show':
|
||||
self.show_keyboard()
|
||||
elif action == 'hide':
|
||||
self.hide_keyboard()
|
||||
elif action == 'theme' and isinstance(value, str):
|
||||
self.theme = self.theme_manager.apply_theme(value)
|
||||
self.keyboard.refresh_theme(self.theme)
|
||||
self.keyboard.current_theme_name = value
|
||||
self._position_keyboard()
|
||||
elif action == 'gamepad' and (value is None or isinstance(value, str)):
|
||||
self.input_manager.gamepad = value is not None
|
||||
if value is not None:
|
||||
self.input_manager.gamepad_type = GamepadType(value)
|
||||
self.keyboard.update_keyboard()
|
||||
elif action == 'direction' and value in ('up', 'down', 'left', 'right'):
|
||||
self.keyboard.focusNextKey(value)
|
||||
elif action == 'button' and self.ready and self.wanted_visible:
|
||||
handlers = {'confirm': self.keyboard.activateFocusedKey, 'back': self.hide_keyboard,
|
||||
'language': self.keyboard.on_lang_click, 'backspace': self.keyboard.on_backspace_pressed,
|
||||
'backspace_release': self.keyboard.stop_backspace_repeat}
|
||||
if self.keyboard.emoji_open and value != 'confirm':
|
||||
if value == 'back':
|
||||
self.keyboard.close_emoji_panel()
|
||||
return
|
||||
if value == 'shift':
|
||||
self.keyboard.on_shift_click(not self.keyboard.shift_pressed)
|
||||
elif value in handlers:
|
||||
handlers[value]()
|
||||
elif action == 'quit':
|
||||
app = QApplication.instance()
|
||||
if app is not None:
|
||||
app.quit()
|
||||
|
||||
def closeEvent(self, event: QCloseEvent) -> None:
|
||||
event.ignore()
|
||||
self.hide_keyboard()
|
||||
|
||||
def shutdown(self) -> None:
|
||||
self.keyboard.stop_backspace_repeat()
|
||||
self.worker.stop()
|
||||
if self.native_layer is not None:
|
||||
self.native_layer.shutdown()
|
||||
|
||||
|
||||
WL_VERSION = 1
|
||||
WL_DESTROY = 1
|
||||
WL_FIXED_SCALE = 256
|
||||
LAYER_OVERLAY = 3
|
||||
ANCHOR_ALL_EDGES = 15
|
||||
KEYBOARD_INTERACTIVITY_NONE = 0
|
||||
SHM_ARGB8888 = 0
|
||||
PIXEL_BYTES = 4
|
||||
FRAME_INTERVAL_MS = 33
|
||||
MAX_SURFACE_PIXELS = 33_177_600
|
||||
POINTER_BUTTON_LEFT = 272
|
||||
|
||||
|
||||
class WaylandWindow(QObject):
|
||||
"""Keep native surfaces separate from Qt's offscreen platform plugin."""
|
||||
|
||||
def __init__(self, window: Any) -> None:
|
||||
super().__init__(window)
|
||||
self.window = window
|
||||
self.callbacks: list[Any] = []
|
||||
self.proxies: list[int] = []
|
||||
self.buffers: dict[int, dict[str, Any]] = {}
|
||||
self.compositor = self.shm = self.shell = None
|
||||
self.seat: int | None = None
|
||||
self.surface = self.layer = self.pointer = self.touch = None
|
||||
self.display = None
|
||||
self.wanted_visible = self.configured = False
|
||||
self.dirty = True
|
||||
self.position = QPointF()
|
||||
self.pressed_widget: Any = None
|
||||
self.lib = load_library()
|
||||
self._configure_library()
|
||||
self.layer_interface = self._interface('zwlr_layer_surface_v1')
|
||||
self.shell_interface = self._interface('zwlr_layer_shell_v1')
|
||||
self.display = self.lib.portproton_keyboard_wayland_connect(None)
|
||||
if not self.display:
|
||||
raise RuntimeError('Cannot connect to the Wayland compositor')
|
||||
self.registry = self._request(self.display, (1, self._interface('wl_registry')), (C.c_void_p(),))
|
||||
self._listen(self.registry, [(self._global, [C.c_uint32, C.c_char_p, C.c_uint32]),
|
||||
(self._global_removed, [C.c_uint32])])
|
||||
self.sync = self._request(self.display, (0, self._interface('wl_callback')), (C.c_void_p(),))
|
||||
self._listen(self.sync, [(self._registry_ready, [C.c_uint32])])
|
||||
self.notifier = QSocketNotifier(self.lib.wl_display_get_fd(self.display), QSocketNotifier.Type.Read, self)
|
||||
self.notifier.activated.connect(self._dispatch)
|
||||
self.timer = QTimer(self)
|
||||
self.timer.setInterval(FRAME_INTERVAL_MS)
|
||||
self.timer.timeout.connect(self._render)
|
||||
self.timer.start()
|
||||
app = QApplication.instance()
|
||||
if app is not None:
|
||||
app.installEventFilter(self)
|
||||
self.lib.wl_display_flush(self.display)
|
||||
|
||||
def _configure_library(self) -> None:
|
||||
p = C.c_void_p
|
||||
functions = {
|
||||
'portproton_keyboard_wayland_connect': ([C.c_char_p], p),
|
||||
'portproton_keyboard_wayland_interface': ([C.c_char_p], p),
|
||||
'wl_display_disconnect': ([p], None),
|
||||
'wl_display_dispatch_pending': ([p], C.c_int),
|
||||
'wl_display_prepare_read': ([p], C.c_int),
|
||||
'wl_display_read_events': ([p], C.c_int),
|
||||
'wl_display_cancel_read': ([p], None),
|
||||
'wl_display_get_fd': ([p], C.c_int),
|
||||
'wl_display_flush': ([p], C.c_int),
|
||||
'wl_proxy_destroy': ([p], None),
|
||||
'wl_proxy_add_listener': ([p, p, p], C.c_int),
|
||||
'wl_proxy_marshal_flags': ([p, C.c_uint32, p, C.c_uint32, C.c_uint32], p),
|
||||
}
|
||||
for name, (args, result) in functions.items():
|
||||
function = getattr(self.lib, name)
|
||||
function.argtypes, function.restype = args, result
|
||||
|
||||
def _interface(self, name: str) -> int:
|
||||
interface = self.lib.portproton_keyboard_wayland_interface(name.encode())
|
||||
if not interface:
|
||||
raise RuntimeError(f'Unknown Wayland interface: {name}')
|
||||
return interface
|
||||
|
||||
def _request(self, proxy: int | None, request: tuple[int, Any], arguments: tuple[Any, ...] = ()) -> Any:
|
||||
opcode, interface = request
|
||||
result = self.lib.wl_proxy_marshal_flags(proxy, opcode, interface, WL_VERSION, 0, *arguments)
|
||||
if interface is not None:
|
||||
if not result:
|
||||
raise RuntimeError('Cannot create Wayland protocol object')
|
||||
self.proxies.append(result)
|
||||
return result
|
||||
|
||||
def _listen(self, proxy: int, handlers: list[tuple[Any, list[Any]]]) -> None:
|
||||
callbacks = []
|
||||
for handler, types in handlers:
|
||||
def guarded(data: Any, obj: Any, *args: Any, handler: Any = handler) -> None:
|
||||
try:
|
||||
handler(*args)
|
||||
except Exception:
|
||||
logger.exception('System keyboard Wayland event failed')
|
||||
QApplication.exit(1)
|
||||
callbacks.append(C.CFUNCTYPE(None, C.c_void_p, C.c_void_p, *types)(guarded))
|
||||
table = (C.c_void_p * len(callbacks))(*[C.cast(callback, C.c_void_p) for callback in callbacks])
|
||||
self.callbacks.append((callbacks, table))
|
||||
if self.lib.wl_proxy_add_listener(proxy, table, None) != 0:
|
||||
raise RuntimeError('Cannot subscribe to Wayland events')
|
||||
|
||||
def _global(self, name: int, interface: bytes, version: int) -> None:
|
||||
interfaces = {b'wl_compositor': ('compositor', self._interface('wl_compositor')),
|
||||
b'wl_shm': ('shm', self._interface('wl_shm')),
|
||||
b'zwlr_layer_shell_v1': ('shell', self.shell_interface),
|
||||
b'wl_seat': ('seat', self._interface('wl_seat'))}
|
||||
if interface not in interfaces:
|
||||
return
|
||||
attribute, metadata = interfaces[interface]
|
||||
if getattr(self, attribute, None) is not None:
|
||||
return
|
||||
proxy = self._request(self.registry, (0, metadata),
|
||||
(C.c_uint32(name), interface, C.c_uint32(WL_VERSION), C.c_void_p()))
|
||||
setattr(self, attribute, proxy)
|
||||
if interface == b'wl_seat':
|
||||
self._listen(proxy, [(self._seat_capabilities, [C.c_uint32])])
|
||||
self._create_surface()
|
||||
|
||||
def _global_removed(self, name: int) -> None:
|
||||
logger.debug('Wayland global removed: %s', name)
|
||||
|
||||
def _registry_ready(self, serial: int) -> None:
|
||||
self.lib.wl_proxy_destroy(self.sync)
|
||||
self.proxies.remove(self.sync)
|
||||
if not all((self.compositor, self.shm, self.shell)):
|
||||
logger.error('The compositor does not provide layer-shell or shared-memory surfaces')
|
||||
QApplication.exit(1)
|
||||
|
||||
def show_layer(self) -> None:
|
||||
self.wanted_visible = True
|
||||
self._create_surface()
|
||||
|
||||
def _create_surface(self) -> None:
|
||||
if self.surface or not self.wanted_visible or not all((self.compositor, self.shm, self.shell)):
|
||||
return
|
||||
self.surface = self._request(self.compositor, (0, self._interface('wl_surface')), (C.c_void_p(),))
|
||||
self._listen(self.surface, [(self._surface_output, [C.c_void_p]),
|
||||
(self._surface_output, [C.c_void_p])])
|
||||
self.layer = self._request(self.shell, (0, self.layer_interface),
|
||||
(C.c_void_p(), C.c_void_p(self.surface), C.c_void_p(),
|
||||
C.c_uint32(LAYER_OVERLAY), b'portprotonqt-system-keyboard'))
|
||||
self._listen(self.layer, [(self._configured, [C.c_uint32, C.c_uint32, C.c_uint32]),
|
||||
(self.window.hide_keyboard, [])])
|
||||
self._request(self.layer, (0, None), (C.c_uint32(0), C.c_uint32(0)))
|
||||
self._request(self.layer, (1, None), (C.c_uint32(ANCHOR_ALL_EDGES),))
|
||||
self._request(self.layer, (2, None), (C.c_int32(-1),))
|
||||
self._request(self.layer, (4, None), (C.c_uint32(KEYBOARD_INTERACTIVITY_NONE),))
|
||||
self._input_region(False)
|
||||
self._request(self.surface, (6, None))
|
||||
self.lib.wl_display_flush(self.display)
|
||||
|
||||
def _configured(self, serial: int, width: int, height: int) -> None:
|
||||
if not width or not height or width * height > MAX_SURFACE_PIXELS:
|
||||
raise ValueError('Invalid Wayland layer-surface dimensions')
|
||||
self._request(self.layer, (6, None), (C.c_uint32(serial),))
|
||||
self.window.resize(width, height)
|
||||
self.window._position_keyboard()
|
||||
self.configured = self.dirty = True
|
||||
|
||||
def _surface_output(self, output: int) -> None:
|
||||
self.dirty = True
|
||||
|
||||
def _input_region(self, include_panel: bool = True) -> None:
|
||||
region = self._request(self.compositor, (1, self._interface('wl_region')), (C.c_void_p(),))
|
||||
if include_panel:
|
||||
rect = self.window.keyboard.geometry()
|
||||
args = tuple(C.c_int32(value) for value in (rect.x(), rect.y(), rect.width(), rect.height()))
|
||||
self._request(region, (1, None), args)
|
||||
self._request(self.surface, (5, None), (C.c_void_p(region),))
|
||||
self._destroy(region, 0)
|
||||
|
||||
def _destroy(self, proxy: int | None, opcode: int) -> None:
|
||||
if proxy is not None:
|
||||
self.lib.wl_proxy_marshal_flags(proxy, opcode, None, WL_VERSION, WL_DESTROY)
|
||||
self.proxies.remove(proxy)
|
||||
|
||||
def _buffer(self, width: int, height: int) -> int | None:
|
||||
size = width * height * PIXEL_BYTES
|
||||
for proxy, buffer in self.buffers.items():
|
||||
if buffer['size'] == (width, height) and not buffer['busy']:
|
||||
return proxy
|
||||
if sum(buffer['size'] == (width, height) for buffer in self.buffers.values()) >= 2:
|
||||
return None
|
||||
with tempfile.TemporaryFile() as storage:
|
||||
storage.truncate(size)
|
||||
memory = mmap.mmap(storage.fileno(), size)
|
||||
try:
|
||||
pool = self._request(self.shm, (0, self._interface('wl_shm_pool')),
|
||||
(C.c_void_p(), C.c_int(storage.fileno()), C.c_int32(size)))
|
||||
proxy = self._request(pool, (0, self._interface('wl_buffer')),
|
||||
(C.c_void_p(), C.c_int32(0), C.c_int32(width), C.c_int32(height),
|
||||
C.c_int32(width * PIXEL_BYTES), C.c_uint32(SHM_ARGB8888)))
|
||||
self._destroy(pool, 1)
|
||||
except Exception:
|
||||
memory.close()
|
||||
raise
|
||||
self.buffers[proxy] = {'memory': memory, 'size': (width, height), 'busy': False}
|
||||
self._listen(proxy, [(partial(self._released, proxy), [])])
|
||||
return proxy
|
||||
|
||||
def _released(self, proxy: int) -> None:
|
||||
buffer = self.buffers.get(proxy)
|
||||
if buffer is not None:
|
||||
buffer['busy'] = False
|
||||
if buffer['size'] != (self.window.width(), self.window.height()):
|
||||
self._destroy(proxy, 0)
|
||||
buffer['memory'].close()
|
||||
del self.buffers[proxy]
|
||||
|
||||
def _render(self) -> None:
|
||||
if not self.surface or not self.configured or not self.dirty:
|
||||
return
|
||||
width, height = self.window.width(), self.window.height()
|
||||
proxy = self._buffer(width, height)
|
||||
if proxy is None:
|
||||
return
|
||||
image = QImage(width, height, QImage.Format.Format_ARGB32_Premultiplied)
|
||||
image.fill(Qt.GlobalColor.transparent)
|
||||
self.dirty = False
|
||||
self.window.render(image, QPoint(), QRegion(), self.window.RenderFlag.DrawChildren)
|
||||
buffer = self.buffers[proxy]
|
||||
buffer['memory'].seek(0)
|
||||
buffer['memory'].write(image.constBits())
|
||||
buffer['busy'] = True
|
||||
self._request(self.surface, (1, None), (C.c_void_p(proxy), C.c_int32(0), C.c_int32(0)))
|
||||
self._request(self.surface, (2, None), tuple(C.c_int32(v) for v in (0, 0, width, height)))
|
||||
self._input_region()
|
||||
self._request(self.surface, (6, None))
|
||||
self.lib.wl_display_flush(self.display)
|
||||
|
||||
def eventFilter(self, obj: QObject, event: QEvent) -> bool:
|
||||
if event.type() == QEvent.Type.UpdateRequest:
|
||||
self.dirty = True
|
||||
return False
|
||||
|
||||
def _dispatch(self) -> None:
|
||||
while self.lib.wl_display_prepare_read(self.display) != 0:
|
||||
if self.lib.wl_display_dispatch_pending(self.display) < 0:
|
||||
QApplication.exit(1)
|
||||
return
|
||||
fd = self.lib.wl_display_get_fd(self.display)
|
||||
if select.select([fd], [], [], 0)[0]:
|
||||
result = self.lib.wl_display_read_events(self.display)
|
||||
else:
|
||||
self.lib.wl_display_cancel_read(self.display)
|
||||
result = 0
|
||||
if result < 0 or self.lib.wl_display_dispatch_pending(self.display) < 0:
|
||||
logger.error('System keyboard Wayland connection closed')
|
||||
QApplication.exit(1)
|
||||
return
|
||||
self.lib.wl_display_flush(self.display)
|
||||
|
||||
def _seat_capabilities(self, capabilities: int) -> None:
|
||||
if capabilities & 1 and self.pointer is None:
|
||||
self.pointer = self._request(self.seat, (0, self._interface('wl_pointer')), (C.c_void_p(),))
|
||||
u, i, p = C.c_uint32, C.c_int32, C.c_void_p
|
||||
self._listen(self.pointer, [(self._pointer_enter, [u, p, i, i]),
|
||||
(self._pointer_leave, [u, p]),
|
||||
(self._pointer_motion, [u, i, i]),
|
||||
(self._pointer_button, [u, u, u, u]),
|
||||
(self._pointer_axis, [u, u, i])])
|
||||
if capabilities & 4 and self.touch is None:
|
||||
self.touch = self._request(self.seat, (2, self._interface('wl_touch')), (C.c_void_p(),))
|
||||
u, i, p = C.c_uint32, C.c_int32, C.c_void_p
|
||||
self._listen(self.touch, [(self._touch_down, [u, u, p, i, i, i]),
|
||||
(self._touch_up, [u, u, i]), (self._touch_motion, [u, i, i, i]),
|
||||
(self._touch_frame, []), (self._touch_cancel, [])])
|
||||
|
||||
def _pointer_enter(self, *event: int) -> None:
|
||||
serial, surface, x, y = event
|
||||
self.position = QPointF(x / WL_FIXED_SCALE, y / WL_FIXED_SCALE)
|
||||
|
||||
def _pointer_leave(self, serial: int, surface: int) -> None:
|
||||
self.dirty = True
|
||||
|
||||
def _pointer_motion(self, timestamp: int, x: int, y: int) -> None:
|
||||
self.position = QPointF(x / WL_FIXED_SCALE, y / WL_FIXED_SCALE)
|
||||
self._mouse_event(QEvent.Type.MouseMove)
|
||||
|
||||
def _pointer_button(self, *event: int) -> None:
|
||||
serial, timestamp, button, state = event
|
||||
if button == POINTER_BUTTON_LEFT:
|
||||
kind = QEvent.Type.MouseButtonPress if state else QEvent.Type.MouseButtonRelease
|
||||
self._mouse_event(kind)
|
||||
|
||||
def _pointer_axis(self, timestamp: int, axis: int, value: int) -> None:
|
||||
logger.debug('System keyboard pointer axis: %s', axis)
|
||||
|
||||
def _touch_down(self, *event: int) -> None:
|
||||
serial, timestamp, surface, touch_id, x, y = event
|
||||
if self.pressed_widget is None:
|
||||
self.touch_id = touch_id
|
||||
self.position = QPointF(x / WL_FIXED_SCALE, y / WL_FIXED_SCALE)
|
||||
self._mouse_event(QEvent.Type.MouseButtonPress)
|
||||
|
||||
def _touch_up(self, serial: int, timestamp: int, touch_id: int) -> None:
|
||||
if touch_id == getattr(self, 'touch_id', None):
|
||||
self._mouse_event(QEvent.Type.MouseButtonRelease)
|
||||
self.touch_id = None
|
||||
|
||||
def _touch_motion(self, *event: int) -> None:
|
||||
timestamp, touch_id, x, y = event
|
||||
if touch_id == getattr(self, 'touch_id', None):
|
||||
self._pointer_motion(timestamp, x, y)
|
||||
|
||||
def _touch_frame(self) -> None:
|
||||
self.dirty = True
|
||||
|
||||
def _touch_cancel(self) -> None:
|
||||
self.touch_id = None
|
||||
self.pressed_widget = None
|
||||
self.window.keyboard.stop_backspace_repeat()
|
||||
|
||||
def _mouse_event(self, kind: QEvent.Type) -> None:
|
||||
point = self.position.toPoint()
|
||||
target = self.pressed_widget or self.window.childAt(point) or self.window.keyboard
|
||||
if isinstance(target, QPushButton) and self.window.keyboard.selected_button is not target:
|
||||
self.window.keyboard._set_selected_button(target)
|
||||
if kind == QEvent.Type.MouseButtonPress:
|
||||
self.pressed_widget = target
|
||||
local = QPointF(target.mapFrom(self.window, point))
|
||||
button = Qt.MouseButton.NoButton if kind == QEvent.Type.MouseMove else Qt.MouseButton.LeftButton
|
||||
held = self.pressed_widget is not None and kind != QEvent.Type.MouseButtonRelease
|
||||
buttons = Qt.MouseButton.LeftButton if held else Qt.MouseButton.NoButton
|
||||
event = QMouseEvent(kind, local, self.position, button, buttons, Qt.KeyboardModifier.NoModifier)
|
||||
QApplication.sendEvent(target, event)
|
||||
if kind == QEvent.Type.MouseButtonRelease:
|
||||
self.pressed_widget = None
|
||||
self.dirty = True
|
||||
|
||||
def hide_layer(self) -> None:
|
||||
self.wanted_visible = self.configured = False
|
||||
self.pressed_widget = None
|
||||
self._destroy(self.layer, 7)
|
||||
self._destroy(self.surface, 0)
|
||||
self.layer = self.surface = None
|
||||
self.lib.wl_display_flush(self.display)
|
||||
|
||||
def shutdown(self) -> None:
|
||||
self.timer.stop()
|
||||
self.notifier.setEnabled(False)
|
||||
if self.display:
|
||||
for proxy in reversed(self.proxies):
|
||||
self.lib.wl_proxy_destroy(proxy)
|
||||
self.proxies.clear()
|
||||
self.lib.wl_display_disconnect(self.display)
|
||||
self.display = None
|
||||
for buffer in self.buffers.values():
|
||||
buffer['memory'].close()
|
||||
self.buffers.clear()
|
||||
@@ -1,9 +1,6 @@
|
||||
"""Main window control hints mixin."""
|
||||
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from portprotonqt.system_keyboard import SystemKeyboard
|
||||
from typing import Any
|
||||
|
||||
from PySide6.QtCore import Qt, QRectF, Signal
|
||||
from PySide6.QtGui import QMouseEvent, QPainter, QPaintEvent, QPixmap
|
||||
@@ -19,8 +16,8 @@ from portprotonqt.qt_utils import get_device_pixel_ratio
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
GAMEPAD_HINT_ACTIONS = ("confirm", "back", "add_game", "search", "decrease_size", "increase_size", "context_menu", "menu", "guide_select", "system_keyboard", "mouse_emulation", "prev_section", "next_section")
|
||||
COMBINATION_HINT_ACTIONS = ("guide_select", "system_keyboard", "mouse_emulation")
|
||||
GAMEPAD_HINT_ACTIONS = ("confirm", "back", "add_game", "search", "decrease_size", "increase_size", "context_menu", "menu", "guide_select", "mouse_emulation", "prev_section", "next_section")
|
||||
COMBINATION_HINT_ACTIONS = ("guide_select", "mouse_emulation")
|
||||
VOLUME_HINT_ACTIONS = ("decrease_size", "increase_size")
|
||||
|
||||
def _load_control_hint_pixmap(paths: tuple[str | None, ...], width: int, height: int) -> QPixmap:
|
||||
@@ -121,7 +118,6 @@ class MainWindowControlHintsMixin:
|
||||
theme: Any
|
||||
theme_manager: Any
|
||||
input_manager: Any
|
||||
system_keyboard: "SystemKeyboard"
|
||||
stackedWidget: QStackedWidget
|
||||
leftNavButton: QLabel
|
||||
rightNavButton: QLabel
|
||||
@@ -224,7 +220,6 @@ class MainWindowControlHintsMixin:
|
||||
("search", _("Search")),
|
||||
("guide_select", _("Refresh Grid")),
|
||||
("mouse_emulation", _("Mouse Emulation")),
|
||||
("system_keyboard", _("System Keyboard")),
|
||||
("prev_section", _("Prev Tab")),
|
||||
("next_section", _("Next Tab")),
|
||||
]
|
||||
@@ -299,18 +294,7 @@ class MainWindowControlHintsMixin:
|
||||
layout.setSpacing(6)
|
||||
|
||||
guide_icon = _ControlHintIconLabel(26, 26)
|
||||
if action == "system_keyboard":
|
||||
_set_control_hint_icon(
|
||||
guide_icon,
|
||||
(
|
||||
self.theme_manager.get_icon("xbox_start", self.current_theme_name, as_path=True),
|
||||
self.theme_manager.get_icon("ps_options", self.current_theme_name, as_path=True),
|
||||
self.theme_manager.get_theme_image("placeholder", self.current_theme_name),
|
||||
),
|
||||
26,
|
||||
26,
|
||||
)
|
||||
elif action == "mouse_emulation":
|
||||
if action == "mouse_emulation":
|
||||
_set_control_hint_icon(
|
||||
guide_icon,
|
||||
(
|
||||
@@ -350,18 +334,7 @@ class MainWindowControlHintsMixin:
|
||||
|
||||
select_icon = _ControlHintIconLabel(26, 26)
|
||||
|
||||
if action == "system_keyboard":
|
||||
_set_control_hint_icon(
|
||||
select_icon,
|
||||
(
|
||||
self.theme_manager.get_icon("xbox_y", self.current_theme_name, as_path=True),
|
||||
self.theme_manager.get_icon("ps_triangle", self.current_theme_name, as_path=True),
|
||||
self.theme_manager.get_theme_image("placeholder", self.current_theme_name),
|
||||
),
|
||||
26,
|
||||
26,
|
||||
)
|
||||
elif action == "mouse_emulation":
|
||||
if action == "mouse_emulation":
|
||||
_set_control_hint_icon(
|
||||
select_icon,
|
||||
(
|
||||
@@ -418,9 +391,6 @@ class MainWindowControlHintsMixin:
|
||||
def _triggerControlHintAction(self, action: str | None) -> None:
|
||||
if action is None:
|
||||
return
|
||||
if action == "system_keyboard":
|
||||
self.system_keyboard.toggle()
|
||||
return
|
||||
if action == "menu":
|
||||
self._triggerControlHintFullscreen()
|
||||
return
|
||||
@@ -534,9 +504,7 @@ class MainWindowControlHintsMixin:
|
||||
):
|
||||
guide_icon, plus_icon, select_icon = icon_element
|
||||
|
||||
if action == "system_keyboard":
|
||||
guide_icon_name = "ps_options" if gtype == GamepadType.PLAYSTATION else "xbox_start"
|
||||
elif action == "mouse_emulation":
|
||||
if action == "mouse_emulation":
|
||||
if gtype == GamepadType.PLAYSTATION:
|
||||
guide_icon_name = "ps_share"
|
||||
else:
|
||||
@@ -569,9 +537,7 @@ class MainWindowControlHintsMixin:
|
||||
)
|
||||
|
||||
select_icon_name = "xbox_view"
|
||||
if action == "system_keyboard":
|
||||
select_icon_name = "ps_triangle" if gtype == GamepadType.PLAYSTATION else "xbox_y"
|
||||
elif action == "guide_select":
|
||||
if action == "guide_select":
|
||||
if gtype == GamepadType.XBOX:
|
||||
select_icon_name = "xbox_view"
|
||||
elif gtype == GamepadType.PLAYSTATION:
|
||||
|
||||
@@ -596,12 +596,9 @@ class MainWindowLibraryTabMixin(_MainWindowTypingBase):
|
||||
self.updateDeleteMissingExeButton()
|
||||
|
||||
def quickLaunch(self):
|
||||
"""Open the launch file picker."""
|
||||
def file_filter(path: str) -> bool:
|
||||
return path.lower().endswith(LAUNCH_FILE_EXTENSIONS) or is_native_executable(path)
|
||||
|
||||
file_explorer = FileExplorer(self, self.theme, file_filter=file_filter)
|
||||
file_explorer.file_signal.file_selected.connect(self._quick_launch_selected)
|
||||
"""Open file manager to select executable and then open its detail page."""
|
||||
file_explorer = FileExplorer(self, self.theme, file_filter=LAUNCH_FILE_EXTENSIONS)
|
||||
file_explorer.file_signal.file_selected.connect(self.handle_launch_exe)
|
||||
|
||||
parent_geometry = self.geometry()
|
||||
center_point = parent_geometry.center()
|
||||
@@ -611,13 +608,6 @@ class MainWindowLibraryTabMixin(_MainWindowTypingBase):
|
||||
|
||||
file_explorer.show()
|
||||
|
||||
@Slot(str)
|
||||
def _quick_launch_selected(self, path: str) -> None:
|
||||
if path.lower().endswith(LAUNCH_FILE_EXTENSIONS):
|
||||
self.handle_launch_exe(path)
|
||||
else:
|
||||
self._launch_native_game(os.path.abspath(path))
|
||||
|
||||
def on_search_text_changed(self, text: str):
|
||||
"""Search text change handler with debounce."""
|
||||
self.searchDebounceTimer.stop()
|
||||
|
||||
@@ -1771,12 +1771,12 @@ QPushButton:pressed {{
|
||||
border: {border_none} {color_transparent};
|
||||
color: {color_text};
|
||||
}}
|
||||
QPushButton:checked {{
|
||||
QPushButton[checked="true"] {{
|
||||
background-color: {color_accent};
|
||||
color: {color_text_accent_hover};
|
||||
border: {border_none} {color_transparent};
|
||||
}}
|
||||
QPushButton:checked:focus {{
|
||||
QPushButton[checked="true"]:focus {{
|
||||
border: {border_thin} {color_text};
|
||||
}}
|
||||
"""
|
||||
|
||||
File renamed without changes.
|
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
@@ -313,39 +313,6 @@ virtual_keyboard_fade_animation_duration = 140
|
||||
virtual_keyboard_slide_fade_animation_duration = 180
|
||||
virtual_keyboard_slide_bounce_animation_duration = 220
|
||||
virtual_keyboard_animation_type = "slide"
|
||||
SYSTEM_KEYBOARD = {
|
||||
"width": 1000,
|
||||
"height": 270,
|
||||
"minimum_key_width": 18,
|
||||
"warning_height": 36,
|
||||
"key_height": 40,
|
||||
"spacing": 4,
|
||||
"margin": 5,
|
||||
"row_units": 2,
|
||||
"columns": 30,
|
||||
"rows": (
|
||||
(("Esc", 2), ("F1", 2), ("F2", 2), ("F3", 2), ("F4", 2), ("F5", 2), ("F6", 2),
|
||||
("F7", 2), ("F8", 2), ("F9", 2), ("F10", 2), ("F11", 2), ("F12", 2), ("PrtSc", 2), ("Del", 2)),
|
||||
(("`", 2), ("1", 2), ("2", 2), ("3", 2), ("4", 2), ("5", 2), ("6", 2), ("7", 2),
|
||||
("8", 2), ("9", 2), ("0", 2), ("-", 2), ("=", 2), ("⌫", 4)),
|
||||
(("TAB", 3), ("q", 2), ("w", 2), ("e", 2), ("r", 2), ("t", 2), ("y", 2), ("u", 2),
|
||||
("i", 2), ("o", 2), ("p", 2), ("[", 2), ("]", 2), ("\\", 3)),
|
||||
(("CAPS", 4), ("a", 2), ("s", 2), ("d", 2), ("f", 2), ("g", 2), ("h", 2), ("j", 2),
|
||||
("k", 2), ("l", 2), (";", 2), ("'", 2), ("Enter", 4)),
|
||||
(("⬆", 4), ("<", 2), ("z", 2), ("x", 2), ("c", 2), ("v", 2), ("b", 2), ("n", 2),
|
||||
("m", 2), (",", 2), (".", 2), ("/", 2), ("RShift", 4)),
|
||||
(("Ctrl", 2), ("Super", 2), ("Alt", 2), ("Space", 8), ("🙂", 2), ("🌐", 2), ("AltGr", 2),
|
||||
("RCtrl", 2), ("◄", 2), ("▲▼", 2), ("►", 2), ("Hide", 2)),
|
||||
),
|
||||
"emoji_rows": (
|
||||
(("😀", 3), ("😃", 3), ("😄", 3), ("😁", 3), ("😆", 3), ("😅", 3), ("😂", 3), ("🤣", 3), ("🙂", 3), ("🙃", 3)),
|
||||
(("😉", 3), ("😊", 3), ("😍", 3), ("🥰", 3), ("😘", 3), ("😎", 3), ("🤔", 3), ("😴", 3), ("😭", 3), ("😡", 3)),
|
||||
(("👍", 3), ("👎", 3), ("👏", 3), ("🙌", 3), ("🙏", 3), ("🤝", 3), ("👋", 3), ("✌️", 3), ("💪", 3), ("👌", 3)),
|
||||
(("❤️", 3), ("💔", 3), ("🔥", 3), ("✨", 3), ("⭐", 3), ("🎉", 3), ("🎮", 3), ("🏆", 3), ("✅", 3), ("❌", 3)),
|
||||
(("🐱", 3), ("🐶", 3), ("🌈", 3), ("☀️", 3), ("🌙", 3), ("🌻", 3), ("🍕", 3), ("🍔", 3), ("☕", 3), ("🎵", 3)),
|
||||
(("ABC", 30),),
|
||||
),
|
||||
}
|
||||
DETAIL_PAGE_LAYOUT_MODE = "full"
|
||||
|
||||
COMPATIBILITY_REPORT_DIALOG = {
|
||||
|
||||
@@ -44,21 +44,6 @@ CONTEXT_MENU_STYLE = f"""
|
||||
}}
|
||||
"""
|
||||
|
||||
SYSTEM_KEYBOARD_BACKGROUND_STYLE = f"""
|
||||
QFrame#systemKeyboard {{
|
||||
background: {color_bg};
|
||||
border-radius: {border_radius_small};
|
||||
}}
|
||||
QWidget#systemKeyboardContainer {{
|
||||
background: {color_transparent};
|
||||
}}
|
||||
QFrame#systemKeyboard QPushButton {{
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
padding: 0;
|
||||
}}
|
||||
"""
|
||||
|
||||
VIRTUAL_KEYBOARD_STYLE = f"""
|
||||
QWidget {{
|
||||
background: {color_overlay};
|
||||
@@ -92,12 +77,12 @@ QPushButton:pressed {{
|
||||
background-color: {color_surface};
|
||||
border: {border_none} {color_transparent};
|
||||
}}
|
||||
QPushButton:checked {{
|
||||
QPushButton[checked="true"] {{
|
||||
background-color: {color_accent};
|
||||
color: {color_text_accent_hover};
|
||||
border: {border_none} {color_transparent};
|
||||
}}
|
||||
QPushButton:checked:focus {{
|
||||
QPushButton[checked="true"]:focus {{
|
||||
border: {border_thin} {color_text};
|
||||
}}
|
||||
"""
|
||||
|
||||
@@ -104,10 +104,6 @@ class TrayManager:
|
||||
self.tray_menu.addAction(self.pause_game_action)
|
||||
self.tray_menu.addAction(self.stop_game_action)
|
||||
self.update_game_actions()
|
||||
system_keyboard = getattr(getattr(self, 'main_window', None), 'system_keyboard', None)
|
||||
if system_keyboard is not None:
|
||||
keyboard_action = self.tray_menu.addAction('System Keyboard')
|
||||
keyboard_action.triggered.connect(system_keyboard.toggle)
|
||||
if self.minimal_mode:
|
||||
return
|
||||
self.tray_menu.addSeparator()
|
||||
|
||||
@@ -737,57 +737,3 @@ def test_steam_detail_button_attaches_to_existing_game_watch() -> None:
|
||||
window._toggle_steam_game.assert_called_once_with(
|
||||
"steam://rungameid/3263320", button, launch=False
|
||||
)
|
||||
|
||||
|
||||
@mark.parametrize("hp_fields", [{}, {"hpKey": "field"}, {"hpKey": "field", "hpVal": "value"}])
|
||||
def test_hltb_search_accepts_token_without_optional_pair(
|
||||
monkeypatch: MonkeyPatch, hp_fields: dict[str, str]
|
||||
) -> None:
|
||||
import orjson
|
||||
|
||||
from portprotonqt.howlongtobeat_api import HTTPClient, ResultParser
|
||||
|
||||
monkeypatch.setattr("portprotonqt.howlongtobeat_api.proxy_config.get_proxy", lambda: {})
|
||||
client = HTTPClient()
|
||||
session = MagicMock()
|
||||
monkeypatch.setattr(client, "session", session)
|
||||
session.get.return_value.json.return_value = {"token": "test-token", **hp_fields}
|
||||
session.post.return_value = SimpleNamespace(status_code=200, text='{"data": [{"comp_main": 12600}]}')
|
||||
|
||||
raw = client.search_games("MARVEL Cosmic Invasion")
|
||||
assert raw is not None
|
||||
assert ResultParser().parse_results(raw)[0].main_story == 3.5
|
||||
assert session.get.call_args.args[0].endswith("/api/search/site/init")
|
||||
assert session.post.call_args.args[0].endswith("/api/search/site")
|
||||
request = session.post.call_args.kwargs
|
||||
assert request["headers"]["x-auth-token"] == "test-token"
|
||||
payload = orjson.loads(request["data"])
|
||||
assert payload["searchTerms"] == ["MARVEL", "Cosmic", "Invasion"]
|
||||
assert payload.get("field") == hp_fields.get("hpVal")
|
||||
assert request["headers"].get("x-hp-key") == ("field" if "hpVal" in hp_fields else None)
|
||||
assert request["headers"].get("x-hp-val") == hp_fields.get("hpVal")
|
||||
|
||||
|
||||
def test_native_detail_cover_shows_linux_source_corner() -> None:
|
||||
from PySide6.QtWidgets import QApplication, QFrame
|
||||
|
||||
from portprotonqt.detail_pages.widgets import _add_source_corner
|
||||
from portprotonqt.game_card import SourceCorner
|
||||
|
||||
app = QApplication.instance() or QApplication([])
|
||||
cover = QFrame()
|
||||
cover.resize(300, 450)
|
||||
icon_path = Path(__file__).resolve().parents[1] / (
|
||||
"portprotonqt/themes/standart/images/icons/platforms/badge_native.svg"
|
||||
)
|
||||
theme_manager = MagicMock()
|
||||
theme_manager.get_icon.return_value = str(icon_path)
|
||||
theme = SimpleNamespace(get_source_corner_config=lambda: {})
|
||||
|
||||
_add_source_corner(cover, "native", theme, theme_manager, cover.width(), cover.height())
|
||||
app.processEvents()
|
||||
|
||||
theme_manager.get_icon.assert_called_once_with("badge_native", as_path=True)
|
||||
ribbon = cover.findChild(SourceCorner)
|
||||
assert ribbon is not None and not ribbon.isHidden()
|
||||
assert ribbon.geometry().bottomRight() == cover.rect().bottomRight()
|
||||
@@ -1,13 +1,10 @@
|
||||
"""Download cache completion and worker lifecycle regressions."""
|
||||
|
||||
from collections.abc import Iterator
|
||||
from io import BytesIO
|
||||
from pathlib import Path
|
||||
import threading
|
||||
from typing import Any, cast
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from PIL import Image
|
||||
import pytest
|
||||
from PySide6.QtCore import QCoreApplication, QThread
|
||||
from PySide6.QtWidgets import QApplication
|
||||
@@ -24,44 +21,6 @@ def application() -> QCoreApplication:
|
||||
return QApplication.instance() or QApplication([])
|
||||
|
||||
|
||||
@pytest.mark.parametrize("parallel", [False, True])
|
||||
@pytest.mark.parametrize("complete", [False, True])
|
||||
def test_truncated_cached_cover_is_redownloaded(
|
||||
monkeypatch: pytest.MonkeyPatch, tmp_path: Path, parallel: bool, complete: bool,
|
||||
) -> None:
|
||||
url = "https://example.com/cover.jpg"
|
||||
target = tmp_path / "cover.jpg"
|
||||
buffer = BytesIO()
|
||||
Image.new("RGB", (32, 32)).save(buffer, format="JPEG")
|
||||
jpeg = buffer.getvalue()
|
||||
truncated = jpeg[:-30]
|
||||
target.write_bytes(truncated)
|
||||
response = MagicMock()
|
||||
response.headers = {}
|
||||
|
||||
def chunks(chunk_size: int) -> Iterator[bytes]:
|
||||
yield jpeg[:100]
|
||||
assert target.read_bytes() == truncated
|
||||
yield (jpeg if complete else truncated)[100:]
|
||||
|
||||
response.iter_content.side_effect = chunks
|
||||
session = MagicMock()
|
||||
session.get.return_value.__enter__.return_value = response
|
||||
monkeypatch.setattr("portprotonqt.downloader.get_requests_session", lambda: session)
|
||||
downloader = Downloader()
|
||||
downloader._cache[url] = str(target)
|
||||
results: list[str | None] = []
|
||||
|
||||
worker = downloader.download_async(url, str(target), parallel=parallel, callback=results.append)
|
||||
|
||||
assert worker is not None
|
||||
assert worker.wait(THREAD_TIMEOUT_MS)
|
||||
QApplication.processEvents()
|
||||
assert results == [str(target) if complete else None]
|
||||
assert target.read_bytes() == (jpeg if complete else truncated)
|
||||
assert list(tmp_path.iterdir()) == [target]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("parallel", [False, True])
|
||||
@pytest.mark.parametrize("failed", [False, True])
|
||||
def test_resolved_download_completes_without_a_worker(
|
||||
|
||||
+2
-77
@@ -309,84 +309,9 @@ def test_download_sizes_cache(tmp_path: Path) -> None:
|
||||
assert api.get_cached_download_sizes("123") == (100, 200)
|
||||
|
||||
|
||||
GOG_SECTIONED_DESCRIPTION = (
|
||||
"<h4>Industrial revolution</h4>\n<p>\n<br>\nMagic meets technology.</p>"
|
||||
"<p> </p><h4>Features<br></h4><ul><li>Character development</li></ul>"
|
||||
)
|
||||
|
||||
|
||||
def test_load_library_shortens_cached_description(tmp_path: Path) -> None:
|
||||
api = GOGAPI()
|
||||
api.library_path = tmp_path / "library.json"
|
||||
games = [{"app_id": "1207658829", "description": GOG_SECTIONED_DESCRIPTION}]
|
||||
api._save_json(api.library_path, games)
|
||||
original = api.library_path.read_bytes()
|
||||
|
||||
assert api.load_library() == [{"app_id": "1207658829", "description": "Magic meets technology."}]
|
||||
assert api.library_path.read_bytes() == original
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("lead", "expected"),
|
||||
[
|
||||
(GOG_SECTIONED_DESCRIPTION, "Magic meets technology."),
|
||||
pytest.param(
|
||||
'<div><a href="/game/hellpoint"><img src="banner.jpg"></a>'
|
||||
'<span>The full version of Hellpoint is available on GOG.com. You can buy it '
|
||||
'<a href="/game/hellpoint"><b>here</b></a></span></div><hr>\n<br>\n'
|
||||
'The Thespian Feast — бесплатная глава Hellpoint.',
|
||||
"The Thespian Feast — бесплатная глава Hellpoint.",
|
||||
id="hellpoint-full-version-promo",
|
||||
),
|
||||
pytest.param(
|
||||
"<b><i>Я пишу это в состоянии значительного душевного напряжения.</i></b>"
|
||||
"<br><br>Dagon — трехмерная история по рассказу <b>Лавкрафта</b>.",
|
||||
"Dagon — трехмерная история по рассказу <b>Лавкрафта</b>.",
|
||||
id="dagon-epigraph-before-synopsis",
|
||||
),
|
||||
("<i>Only available description.</i>", "<i>Only available description.</i>"),
|
||||
pytest.param(
|
||||
'<p class="module">Discover <a href="https://example.com">more games</a>.</p>'
|
||||
'<br><hr><b><h4>Game Description</h4></b>\nShortly after landing…\n<br>\n'
|
||||
'<b><h4>About Quake II RTX</h4> </b>Technical details.',
|
||||
"Shortly after landing…",
|
||||
id="quake-rtx-promo",
|
||||
),
|
||||
pytest.param(
|
||||
'<p><img src="banner.jpg"></p><p class="module">В издание входит дополнение.</p>'
|
||||
'<p> </p><p>Реалистичный психологический триллер. ',
|
||||
"Реалистичный психологический триллер.",
|
||||
id="postal-edition-module",
|
||||
),
|
||||
pytest.param(
|
||||
'<b>Внимание! В этой игре нет русской локализации.</b><br><br>Описание игры.',
|
||||
"Описание игры.",
|
||||
id="sang-froid-localization-notice",
|
||||
),
|
||||
pytest.param(
|
||||
'<img src="logo.png" />\n<br>\n<b>Martial Law</b> — визуальная новелла.'
|
||||
'<h4>Особенности:</h4><ul><li>Много вариантов исхода.</li></ul><i>GameJam</i>',
|
||||
"<b>Martial Law</b> — визуальная новелла.",
|
||||
id="martial-law-logo-and-features",
|
||||
),
|
||||
("<p> </p>", "English description"),
|
||||
("Intro\n<strong>War Wind</strong> continues.", "Intro<br><b>War Wind</b> continues."),
|
||||
pytest.param(
|
||||
'<div style="overflow: hidden;"> <a href="/game/demo"><img src="cover.jpg"></a>'
|
||||
'<span>Demo</span></div><hr>Game synopsis.',
|
||||
"Game synopsis.",
|
||||
id="linked-cover-cross-sell",
|
||||
),
|
||||
pytest.param(
|
||||
{
|
||||
"lead": '<div><a href="/game/shores_unknown"><img src="banner.jpg"></a><span>',
|
||||
"full": '<div><span>The full version of Shores Unknown is available on GOG.com. '
|
||||
'You can purchase it <a href="/game/shores_unknown">here</a></span></div><hr>'
|
||||
'<i>Shores Unknown: Arrival</i> is a free demo.<br><br>Game features.',
|
||||
},
|
||||
"<i>Shores Unknown: Arrival</i> is a free demo.",
|
||||
id="shores-unknown-truncated-lead",
|
||||
),
|
||||
(
|
||||
"Description française.<br><br>Deuxième paragraphe.",
|
||||
"Description française.",
|
||||
@@ -398,7 +323,7 @@ def test_load_library_shortens_cached_description(tmp_path: Path) -> None:
|
||||
],
|
||||
)
|
||||
def test_get_game_loads_localized_product_description(
|
||||
monkeypatch: pytest.MonkeyPatch, lead: str | dict[str, str], expected: str
|
||||
monkeypatch: pytest.MonkeyPatch, lead: str, expected: str
|
||||
) -> None:
|
||||
gamesdb_response = Mock()
|
||||
gamesdb_response.json.return_value = {
|
||||
@@ -412,7 +337,7 @@ def test_get_game_loads_localized_product_description(
|
||||
}
|
||||
product_response = Mock()
|
||||
product_response.json.return_value = {
|
||||
"description": {"lead": lead} if isinstance(lead, str) else lead,
|
||||
"description": {"lead": lead},
|
||||
}
|
||||
request = Mock(side_effect=[gamesdb_response, product_response])
|
||||
monkeypatch.setattr("portprotonqt.gog_api.get_metadata_language", lambda: "fr")
|
||||
|
||||
@@ -650,8 +650,6 @@ def test_remote_cover_replaces_immediate_exe_fallback_only_on_success(
|
||||
lambda: SimpleNamespace(current_theme_module=theme),
|
||||
)
|
||||
|
||||
downloaded_path = fallback_path.parent / filename
|
||||
downloaded_path.write_bytes(b"\xff\xd8truncated JPEG")
|
||||
image_utils.load_pixmap_async(
|
||||
url, 100, 150,
|
||||
lambda pixmap: loaded_paths.append(cast(FakePixmap, pixmap).path),
|
||||
@@ -659,6 +657,7 @@ def test_remote_cover_replaces_immediate_exe_fallback_only_on_success(
|
||||
fallback_icon_path=str(fallback_path),
|
||||
)
|
||||
callbacks[0](None)
|
||||
downloaded_path = tmp_path / "cache" / "PortProtonQt" / "images" / filename
|
||||
downloaded_path.write_bytes(b"cover")
|
||||
callbacks[0](str(downloaded_path))
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ from shiboken6 import delete
|
||||
import portprotonqt.input_manager as input_manager
|
||||
import portprotonqt.input_manager.buttons as input_buttons
|
||||
import portprotonqt.input_manager.dpad as input_dpad
|
||||
import portprotonqt.input_manager.keyboard as input_keyboard
|
||||
import portprotonqt.input_manager.runtime as input_runtime
|
||||
import portprotonqt.native_gamepad as native_gamepad
|
||||
from portprotonqt.input_manager.constants import (
|
||||
@@ -137,7 +136,6 @@ def test_theme_tab_focusables_include_delete_button(monkeypatch: MonkeyPatch) ->
|
||||
|
||||
|
||||
def test_native_gamepad_result_preserves_python_interface(monkeypatch: MonkeyPatch) -> None:
|
||||
monkeypatch.setattr(native_gamepad, "_library", MagicMock())
|
||||
controller = 42
|
||||
monkeypatch.setattr(native_gamepad._library, "portproton_gamepad_find", lambda: controller)
|
||||
monkeypatch.setattr(native_gamepad._library, "portproton_gamepad_close", lambda _handle: None)
|
||||
@@ -161,7 +159,6 @@ def test_native_gamepad_result_preserves_python_interface(monkeypatch: MonkeyPat
|
||||
|
||||
|
||||
def test_native_gamepad_update_passes_collection_handle(monkeypatch: MonkeyPatch) -> None:
|
||||
monkeypatch.setattr(native_gamepad, "_library", MagicMock())
|
||||
updated_handles: list[int] = []
|
||||
gamepad = SDLGamepad(42, "Gamepads", "sdl3-gamepad:7", 7, 1)
|
||||
monkeypatch.setattr(native_gamepad._library, "portproton_gamepad_close", lambda _handle: None)
|
||||
@@ -192,7 +189,6 @@ def test_native_gamepad_update_passes_collection_handle(monkeypatch: MonkeyPatch
|
||||
|
||||
|
||||
def test_native_gamepad_reports_sdl_discovery_error(monkeypatch: MonkeyPatch) -> None:
|
||||
monkeypatch.setattr(native_gamepad, "_library", MagicMock())
|
||||
monkeypatch.setattr(native_gamepad._library, "portproton_gamepad_find", lambda: None)
|
||||
monkeypatch.setattr(
|
||||
native_gamepad._library,
|
||||
@@ -205,7 +201,6 @@ def test_native_gamepad_reports_sdl_discovery_error(monkeypatch: MonkeyPatch) ->
|
||||
|
||||
|
||||
def test_native_gamepad_absence_is_not_an_error(monkeypatch: MonkeyPatch) -> None:
|
||||
monkeypatch.setattr(native_gamepad, "_library", MagicMock())
|
||||
monkeypatch.setattr(native_gamepad._library, "portproton_gamepad_find", lambda: None)
|
||||
monkeypatch.setattr(native_gamepad._library, "portproton_gamepad_get_error", lambda: b"")
|
||||
|
||||
@@ -269,49 +264,6 @@ def test_sdl_dpad_vertical_directions() -> None:
|
||||
assert emitted == [(PAD_DPAD_Y, -1, 1.0), (PAD_DPAD_Y, 1, 2.0)]
|
||||
|
||||
|
||||
@mark.parametrize('emulation', [False, True])
|
||||
@mark.parametrize(('button', 'direction'), [
|
||||
(SDL_GAMEPAD_BUTTON_DPAD_UP, -1),
|
||||
(SDL_GAMEPAD_BUTTON_DPAD_DOWN, 1),
|
||||
])
|
||||
def test_system_keyboard_gamepad_drag(emulation: bool, button: int, direction: int) -> None:
|
||||
manager: Any = InputManager.__new__(InputManager)
|
||||
QObject.__init__(manager)
|
||||
keyboard = MagicMock()
|
||||
keyboard.isVisible.return_value = True
|
||||
manager._parent = SimpleNamespace(system_keyboard=keyboard)
|
||||
manager._button_states = {}
|
||||
manager._hat_states = {}
|
||||
manager.mouse_emulation_enabled = manager.emulation_active = True
|
||||
manager.emulation_triggered = emulation
|
||||
manager.ui = MagicMock()
|
||||
gamepad = cast(SDLGamepad, SimpleNamespace(
|
||||
get_button=lambda code: int(code == button),
|
||||
))
|
||||
dpad = MagicMock()
|
||||
manager.dpad_moved.connect(dpad)
|
||||
codes = input_manager.ecodes
|
||||
|
||||
manager._handle_button_value(0, PAD_BUTTON_SOUTH, 1, 1.0)
|
||||
manager._poll_hat_events(gamepad, 2.0)
|
||||
keyboard.isVisible.return_value = False
|
||||
manager._handle_button_value(0, PAD_BUTTON_SOUTH, 0, 3.0)
|
||||
|
||||
if emulation:
|
||||
keyboard.send.assert_not_called()
|
||||
dpad.assert_not_called()
|
||||
assert [call.args for call in manager.ui.write.call_args_list] == [
|
||||
(codes.EV_KEY, codes.BTN_LEFT, 1),
|
||||
(codes.EV_REL, codes.REL_X, 0),
|
||||
(codes.EV_REL, codes.REL_Y, 10 * direction),
|
||||
(codes.EV_KEY, codes.BTN_LEFT, 0),
|
||||
]
|
||||
else:
|
||||
keyboard.send.assert_called_once_with('button', 'confirm')
|
||||
dpad.assert_called_once_with(PAD_DPAD_Y, direction, 2.0)
|
||||
manager.ui.write.assert_not_called()
|
||||
|
||||
|
||||
def test_disabling_mouse_emulation_keeps_gamepad_events_working() -> None:
|
||||
emitted: list[tuple[int, int]] = []
|
||||
manager = InputManager.__new__(InputManager)
|
||||
@@ -574,32 +526,6 @@ def test_library_toolbar_navigation_includes_delete_missing_button() -> None:
|
||||
assert QApplication.focusWidget() is widgets[4]
|
||||
|
||||
|
||||
def test_dpad_down_from_toolbar_focuses_first_visual_card(monkeypatch: MonkeyPatch) -> None:
|
||||
app = QApplication.instance() or QApplication([])
|
||||
window = QWidget()
|
||||
toolbar_button = QPushButton(window)
|
||||
container = QWidget(window)
|
||||
container.setGeometry(0, 40, 100, 100)
|
||||
lower_card = DummyCard(container, FIRST_CARD_X)
|
||||
lower_card.move(FIRST_CARD_X, 40)
|
||||
right_card = DummyCard(container, NEXT_CARD_X)
|
||||
first_card = DummyCard(container, FIRST_CARD_X)
|
||||
window.show()
|
||||
app.processEvents()
|
||||
monkeypatch.setattr(input_keyboard, "AnimatedCard", DummyCard)
|
||||
manager = InputManager.__new__(InputManager)
|
||||
manager._parent = cast(MainWindowProtocol, SimpleNamespace(
|
||||
quickLaunchButton=toolbar_button,
|
||||
stackedWidget=SimpleNamespace(currentIndex=lambda: 0),
|
||||
gamesListWidget=container,
|
||||
))
|
||||
assert right_card.isVisible()
|
||||
for _ in range(2):
|
||||
toolbar_button.setFocus()
|
||||
assert manager._handle_library_dpad(PAD_DPAD_Y, 1)
|
||||
assert QApplication.focusWidget() is first_card
|
||||
|
||||
|
||||
def test_library_filter_navigation_includes_only_installed_checkbox() -> None:
|
||||
app = QApplication.instance() or QApplication([])
|
||||
controls = QWidget()
|
||||
|
||||
@@ -65,7 +65,7 @@ def test_native_card_uses_linux_source_corner(
|
||||
))
|
||||
assert card.native_visible
|
||||
assert isinstance(card.nativeLabel._icon, str)
|
||||
assert Path(card.nativeLabel._icon).name == "badge_native.svg"
|
||||
assert Path(card.nativeLabel._icon).name == "badge_linux.svg"
|
||||
assert Path(card.nativeLabel._icon).is_file()
|
||||
assert not card.portproton_visible
|
||||
card.deleteLater()
|
||||
|
||||
@@ -207,14 +207,6 @@ def test_horizontal_cards_fit_viewport_height(
|
||||
assert card.nameLabel.height() >= card.nameLabel.sizeHint().height()
|
||||
assert card.base_card_width <= manager.card_width
|
||||
assert card.base_card_width == manager.card_width
|
||||
cover = QPixmap(180, 300)
|
||||
cover.fill(QColor("red"))
|
||||
card.on_cover_loaded(cover)
|
||||
for scale in (1.0, 1.045, 1.25, 1.0):
|
||||
card.setScale(scale)
|
||||
app.processEvents()
|
||||
assert card.coverLabel.pixmap().size() == card.coverLabel.size()
|
||||
assert card.coverLabel.width() == int(card.base_card_width * scale)
|
||||
card.stop_background_activity()
|
||||
scroll.close()
|
||||
app.processEvents()
|
||||
@@ -257,18 +249,3 @@ def test_large_resize_keeps_cards_separate_between_batches(
|
||||
assert all(not geometry.intersects(other) for other in geometries[index + 1:])
|
||||
finally:
|
||||
scroll.close()
|
||||
|
||||
|
||||
def test_static_png_does_not_leave_cover_mask(tmp_path: Path) -> None:
|
||||
from PySide6.QtWidgets import QLabel
|
||||
from portprotonqt.image_utils import set_animated_cover
|
||||
|
||||
app = QApplication.instance() or QApplication([])
|
||||
path = tmp_path / "poster.png"
|
||||
pixmap = QPixmap(40, 60)
|
||||
pixmap.fill(QColor("red"))
|
||||
assert pixmap.save(str(path))
|
||||
label = QLabel()
|
||||
assert not set_animated_cover(label, str(path), 40, 60, 5)
|
||||
assert label.mask().isEmpty()
|
||||
app.processEvents()
|
||||
@@ -3571,11 +3571,3 @@ def test_steam_watch_keeps_stop_during_preparation_gap(monkeypatch: MonkeyPatch)
|
||||
monkeypatch.setattr(main_window_module.time, "monotonic", lambda: 1004.0)
|
||||
MainWindow._steam_scan_finished(cast(Any, window), "620")
|
||||
assert watch["running"] is False
|
||||
|
||||
|
||||
def test_system_keyboard_control_hint_opens_keyboard() -> None:
|
||||
window = SimpleNamespace(system_keyboard=SimpleNamespace(toggle=MagicMock()))
|
||||
|
||||
MainWindowControlHintsMixin._triggerControlHintAction(cast(Any, window), "system_keyboard")
|
||||
|
||||
window.system_keyboard.toggle.assert_called_once_with()
|
||||
+1
-109
@@ -12,7 +12,7 @@ import subprocess
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
import pytest
|
||||
from PySide6.QtCore import QEventLoop, QMimeData, QRect, QStandardPaths, QThread, QTimer, Qt, QUrl
|
||||
from PySide6.QtCore import QEventLoop, QStandardPaths, QThread, QTimer, Qt
|
||||
from PySide6.QtWidgets import QApplication, QMainWindow, QWidget, QPushButton
|
||||
from PySide6.QtGui import QIcon
|
||||
|
||||
@@ -169,71 +169,6 @@ def test_native_launch_preserves_desktop_file_and_bypasses_wine(
|
||||
window._set_running_button_stop.assert_called_once()
|
||||
|
||||
|
||||
@pytest.mark.parametrize("name", ["Game.AppImage", "Game.bin", "Game with spaces", "Game.exe"])
|
||||
def test_quick_launch_file_picker(tmp_path: Path, monkeypatch: pytest.MonkeyPatch, name: str) -> None:
|
||||
path = tmp_path / name
|
||||
path.touch(mode=0o755)
|
||||
text = tmp_path / "README"
|
||||
text.touch(mode=0o644)
|
||||
picker = MagicMock()
|
||||
monkeypatch.setattr("portprotonqt.tabs.library_tab.FileExplorer", picker)
|
||||
window = cast(Any, SimpleNamespace(
|
||||
theme=None, geometry=lambda: QRect(), game_processes=[], input_manager=MagicMock(),
|
||||
handle_launch_exe=MagicMock(), _set_running_button_stop=MagicMock(), checkTargetExe=MagicMock(),
|
||||
))
|
||||
window._quick_launch_selected = MainWindow._quick_launch_selected.__get__(window)
|
||||
window._launch_native_game = MainWindow._launch_native_game.__get__(window)
|
||||
popen = MagicMock()
|
||||
monkeypatch.setattr("portprotonqt.main_window.subprocess.Popen", popen)
|
||||
monkeypatch.setattr("portprotonqt.main_window.QTimer", MagicMock())
|
||||
monkeypatch.setattr("portprotonqt.main_window.SoundManager", MagicMock())
|
||||
|
||||
MainWindow.quickLaunch(window)
|
||||
file_filter = picker.call_args.kwargs["file_filter"]
|
||||
assert file_filter(str(path))
|
||||
assert not file_filter(str(text))
|
||||
shortcut = tmp_path / "Launcher.Desktop"
|
||||
shortcut.touch(mode=0o755)
|
||||
assert not file_filter(str(shortcut))
|
||||
callback, = picker.return_value.file_signal.file_selected.connect.call_args.args
|
||||
warning = MagicMock()
|
||||
monkeypatch.setattr("portprotonqt.main_window.QMessageBox.warning", warning)
|
||||
callback(str(shortcut))
|
||||
warning.assert_called_once()
|
||||
popen.assert_not_called()
|
||||
shortcut.unlink()
|
||||
|
||||
callback(str(path))
|
||||
|
||||
if path.suffix == ".exe":
|
||||
window.handle_launch_exe.assert_called_once_with(str(path))
|
||||
popen.assert_not_called()
|
||||
else:
|
||||
window.handle_launch_exe.assert_not_called()
|
||||
popen.assert_called_once_with([str(path)], cwd=str(tmp_path), start_new_session=True, text=True)
|
||||
assert window.native_game_running
|
||||
assert not list(tmp_path.rglob("*.desktop"))
|
||||
|
||||
|
||||
@pytest.mark.parametrize("name", ["Game.AppImage", "Game.bin", "Game"])
|
||||
def test_drop_native_executable_opens_add_dialog(tmp_path: Path, name: str) -> None:
|
||||
path = tmp_path / name
|
||||
path.touch(mode=0o755)
|
||||
mime = QMimeData()
|
||||
mime.setUrls([QUrl.fromLocalFile(str(path))])
|
||||
event = cast(Any, SimpleNamespace(
|
||||
mimeData=lambda: mime, acceptProposedAction=MagicMock(), ignore=MagicMock(),
|
||||
))
|
||||
window = cast(Any, SimpleNamespace(openAddGameDialog=MagicMock()))
|
||||
|
||||
MainWindow.dragEnterEvent(window, event)
|
||||
MainWindow.dropEvent(window, event)
|
||||
|
||||
assert event.acceptProposedAction.call_count == 2
|
||||
event.ignore.assert_not_called()
|
||||
window.openAddGameDialog.assert_called_once_with(str(path))
|
||||
|
||||
|
||||
def test_native_context_launch_does_not_require_portproton() -> None:
|
||||
parent = SimpleNamespace(toggleGame=MagicMock())
|
||||
manager = cast(Any, SimpleNamespace(parent=parent))
|
||||
@@ -1112,46 +1047,3 @@ def test_native_portdata_shortcut_is_only_loaded_as_native(
|
||||
callback = MagicMock()
|
||||
MainWindow._process_desktop_file_async(cast(Any, SimpleNamespace()), destination, callback)
|
||||
callback.assert_called_once_with(None)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("source", ["absolute", "theme", "missing"])
|
||||
def test_native_desktop_icon_fallback(
|
||||
tmp_path: Path, monkeypatch: pytest.MonkeyPatch, source: str,
|
||||
) -> None:
|
||||
from PySide6.QtGui import QImage
|
||||
|
||||
_app = QApplication.instance() or QApplication([])
|
||||
icon = tmp_path / "icons/hicolor/128x128/apps/native-test.png"
|
||||
icon.parent.mkdir(parents=True)
|
||||
image = QImage(128, 128, QImage.Format.Format_ARGB32)
|
||||
image.fill(0)
|
||||
assert image.save(str(icon))
|
||||
monkeypatch.setattr(QStandardPaths, "standardLocations", lambda _location: [str(tmp_path)])
|
||||
monkeypatch.setattr(QIcon, "fromTheme", lambda _name: QIcon())
|
||||
monkeypatch.setattr("portprotonqt.steam_api.api.get_cached_sgdb_cover", lambda _name: "")
|
||||
value = str(icon) if source == "absolute" else "native-test" if source == "theme" else "missing-test-icon"
|
||||
desktop = tmp_path / "game.desktop"
|
||||
desktop.write_text("[Desktop Entry]\nType=Application\nName=Game\nExec=true\nCategories=Game;\nIcon=" + value + "\n")
|
||||
game = read_native_game(desktop)
|
||||
assert game is not None
|
||||
if source == "missing":
|
||||
assert game[2] == ""
|
||||
else:
|
||||
assert not QImage(game[2]).isNull()
|
||||
assert Path(game[2]).is_relative_to(Path(os.environ["XDG_DATA_HOME"]) / "PortProtonQt/cache")
|
||||
monkeypatch.setattr("portprotonqt.steam_api.shortcuts._resolve_desktop_icon", MagicMock(side_effect=AssertionError("Cache not reused")))
|
||||
cached_game = read_native_game(desktop)
|
||||
assert cached_game is not None
|
||||
assert cached_game[2] == game[2]
|
||||
|
||||
|
||||
def test_native_cover_takes_priority_over_desktop_icon(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
monkeypatch.setattr("portprotonqt.steam_api.api.get_cached_sgdb_cover", lambda _name: "cover.png")
|
||||
generate = MagicMock(side_effect=AssertionError("Existing cover replaced"))
|
||||
monkeypatch.setattr("portprotonqt.steam_api.shortcuts._generate_icon", generate)
|
||||
desktop = tmp_path / "game.desktop"
|
||||
desktop.write_text("[Desktop Entry]\nType=Application\nName=Game\nExec=true\nCategories=Game;\nIcon=native-test\n")
|
||||
game = read_native_game(desktop)
|
||||
assert game is not None
|
||||
assert game[2] == "cover.png"
|
||||
generate.assert_not_called()
|
||||
@@ -1,10 +1,9 @@
|
||||
"""Tests for the bundled PortProton shell scripts."""
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
from pytest import mark, skip
|
||||
from pytest import mark
|
||||
|
||||
|
||||
@mark.parametrize("case", [
|
||||
@@ -327,132 +326,3 @@ def test_run_after_wrapper_preserves_command_with_comma(tmp_path: Path) -> None:
|
||||
capture_output=True, text=True, check=True,
|
||||
)
|
||||
assert result.stdout.splitlines() == ["first,second", "game"]
|
||||
|
||||
|
||||
def test_wine_gpu_name_lookup(tmp_path: Path) -> None:
|
||||
compiler = shutil.which("cc")
|
||||
if compiler is None:
|
||||
skip("C compiler is unavailable")
|
||||
source = tmp_path / "wine_names.c"
|
||||
source.write_text(
|
||||
'#include <stdio.h>\n#include "wine_gpu_names.h"\n'
|
||||
'int main(void) {\n'
|
||||
'puts(wine_device_name(0x1002, 0x163f, "AMD Custom GPU 0405 (RADV VANGOGH)"));\n'
|
||||
'puts(wine_device_name(0x10de, 0x249d, "NVIDIA GeForce RTX 3070 Laptop GPU"));\n'
|
||||
'puts(wine_device_name(0x8086, 0x5912, "Intel native name"));\n'
|
||||
'puts(wine_device_name(0xffff, 0x163f, "Unknown vendor"));\n'
|
||||
'puts(wine_device_name(0x1002, 0xffff, "Unknown device"));\n'
|
||||
'puts(wine_device_name(0x11002, 0x163f, "Non-PCI vendor"));\n'
|
||||
'return 0;\n}\n',
|
||||
)
|
||||
binary = tmp_path / "wine_names"
|
||||
subprocess.run(
|
||||
[compiler, "-std=c99", "-Wall", "-Wextra", "-Werror", "-I",
|
||||
str(Path("build-aux/src").resolve()), str(source), "-o", str(binary)],
|
||||
capture_output=True, text=True, check=True,
|
||||
)
|
||||
result = subprocess.run([str(binary)], capture_output=True, text=True, check=True)
|
||||
assert result.stdout.splitlines() == [
|
||||
"AMD VANGOGH", "NVIDIA GeForce RTX 3070 (mobile)", "Intel(R) HD Graphics 630",
|
||||
"Unknown vendor", "Unknown device", "Non-PCI vendor",
|
||||
]
|
||||
|
||||
|
||||
@mark.parametrize("names", [
|
||||
("AMD Custom GPU 0405 (RADV VANGOGH)", "AMD VANGOGH"),
|
||||
("NVIDIA GeForce RTX 3070 Laptop GPU", "NVIDIA GeForce RTX 3070 (mobile)"),
|
||||
("Unknown GPU", "Unknown GPU"),
|
||||
])
|
||||
@mark.parametrize("override", [
|
||||
{}, {"DXVK_FILTER_DEVICE_NAME": "custom-dxvk"},
|
||||
{"VKD3D_FILTER_DEVICE_NAME": "custom-vkd3d"},
|
||||
{"DXVK_FILTER_DEVICE_NAME": "", "VKD3D_FILTER_DEVICE_NAME": ""},
|
||||
])
|
||||
def test_gpu_selection_uses_wine_name_for_both_filters(
|
||||
tmp_path: Path, names: tuple[str, str], override: dict[str, str],
|
||||
) -> None:
|
||||
helper = Path("build-aux/share/portproton/scripts/functions_helper").read_text()
|
||||
function = "pw_select_gpu () {" + helper.split("pw_select_gpu () {", 1)[1].split(
|
||||
"\npw_check_vulkan_extensions () {", 1,
|
||||
)[0]
|
||||
binary = tmp_path / "vk_gpu_info"
|
||||
binary.write_text('#!/bin/bash\nprintf "%s" "$GPU_OUTPUT"\n')
|
||||
binary.chmod(0o755)
|
||||
native, wine = names
|
||||
output = (
|
||||
"GPU #0\ndevice_name: Other GPU\nwine_device_name: Other Wine GPU\n\n"
|
||||
f"GPU #1\ndevice_name: {native}\nwine_device_name: {wine}\n\n"
|
||||
"GPU #2\ndevice_name: Last GPU\nwine_device_name: Last Wine GPU\n"
|
||||
)
|
||||
result = subprocess.run(
|
||||
["bash", "-c", function + '\npw_select_gpu\n'
|
||||
'printf "%s\\n" "$DXVK_FILTER_DEVICE_NAME" "$VKD3D_FILTER_DEVICE_NAME" '
|
||||
'"$PW_GPU_USE" "$MESA_VK_DEVICE_SELECT" "$MESA_VK_DEVICE_SELECT_FORCE_DEFAULT_DEVICE"'],
|
||||
cwd=tmp_path, capture_output=True, text=True, check=True,
|
||||
env={"PATH": f"{tmp_path}:{os.defpath}", "GPU_OUTPUT": output, "PW_GPU_USE": native,
|
||||
"PW_vendorID": "0x1002", "PW_deviceID": "0x163f", **override},
|
||||
)
|
||||
assert result.stdout.splitlines() == [
|
||||
override.get("DXVK_FILTER_DEVICE_NAME", wine),
|
||||
override.get("VKD3D_FILTER_DEVICE_NAME", wine), native, "0x1002:0x163f", "1",
|
||||
]
|
||||
|
||||
|
||||
@mark.parametrize("case", [
|
||||
("GPU #0\ndevice_name: Selected GPU\n", 0),
|
||||
("GPU #0\ndevice_name: Selected GPU\nwine_device_name: \n", 0),
|
||||
("GPU #0\ndevice_name: Other GPU\nwine_device_name: Other Wine GPU\n", 0),
|
||||
("GPU #0\ndevice_name: Selected GPU\nwine_device_name: Wine GPU\n", 1),
|
||||
])
|
||||
@mark.parametrize("selected", ["Selected GPU", "disabled", ""])
|
||||
def test_gpu_selection_falls_back_to_native_name(
|
||||
tmp_path: Path, case: tuple[str, int], selected: str,
|
||||
) -> None:
|
||||
helper = Path("build-aux/share/portproton/scripts/functions_helper").read_text()
|
||||
function = "pw_select_gpu () {" + helper.split("pw_select_gpu () {", 1)[1].split(
|
||||
"\npw_check_vulkan_extensions () {", 1,
|
||||
)[0]
|
||||
output, status = case
|
||||
binary = tmp_path / "vk_gpu_info"
|
||||
binary.write_text(
|
||||
'#!/bin/bash\ntouch probe-ran\nprintf "%s" "$GPU_OUTPUT"\n'
|
||||
f'exit {status}\n',
|
||||
)
|
||||
binary.chmod(0o755)
|
||||
result = subprocess.run(
|
||||
["bash", "-c", function + '\nprint_warning () { echo "$*" >&2; }\npw_select_gpu\n'
|
||||
'printf "%s\\n" "${DXVK_FILTER_DEVICE_NAME-unset}" '
|
||||
'"${VKD3D_FILTER_DEVICE_NAME-unset}"'],
|
||||
cwd=tmp_path, capture_output=True, text=True, check=True,
|
||||
env={"PATH": f"{tmp_path}:{os.defpath}", "GPU_OUTPUT": output,
|
||||
"PW_GPU_USE": selected, "PW_vendorID": "0x1002", "PW_deviceID": "0x163f"},
|
||||
)
|
||||
expected = selected if selected == "Selected GPU" else "unset"
|
||||
assert result.stdout.splitlines() == [expected, expected]
|
||||
assert (tmp_path / "probe-ran").exists() == (selected == "Selected GPU")
|
||||
assert ("vk_gpu_info failed" in result.stderr) == (status != 0 and selected == "Selected GPU")
|
||||
|
||||
|
||||
@mark.parametrize("exit_code", [0, 37])
|
||||
def test_run_after_command_placeholder_preserves_arguments_and_status(
|
||||
tmp_path: Path, exit_code: int,
|
||||
) -> None:
|
||||
helper = Path("build-aux/share/portproton/scripts/functions_helper").read_text()
|
||||
wrapper = helper.split("pw_launch_wrapper () {", 1)[1].split(
|
||||
"export -f pw_launch_wrapper", 1,
|
||||
)[0]
|
||||
launcher = tmp_path / "Обёртка с пробелами"
|
||||
launcher.write_text(
|
||||
'#!/bin/bash\nexport WRAPPER_ACTIVE=yes\nexec "$@"\n',
|
||||
)
|
||||
launcher.chmod(0o755)
|
||||
result = subprocess.run(
|
||||
["bash", "-c", "pw_launch_wrapper () {" + wrapper
|
||||
+ '\npw_launch_wrapper bash -c \'printf "%s\\n" "$WRAPPER_ACTIVE" "$@"; '
|
||||
+ 'exit "$EXIT_CODE"\' game "аргумент с пробелами" \'$(false)\' ""'],
|
||||
env={"PATH": os.defpath, "PW_RUN_AFTER_EXE": f'"{launcher}" %command%',
|
||||
"EXIT_CODE": str(exit_code)},
|
||||
capture_output=True, text=True, check=False,
|
||||
)
|
||||
assert result.returncode == exit_code, result.stderr
|
||||
assert result.stdout == "yes\nаргумент с пробелами\n$(false)\n\n"
|
||||
@@ -1031,3 +1031,38 @@ def test_run_after_removing_only_entry_clears_field(tmp_path: Path) -> None:
|
||||
assert target.text() == ""
|
||||
assert owner.advanced_table.rowCount() == 2
|
||||
owner.advanced_table.deleteLater()
|
||||
|
||||
|
||||
@pytest.mark.parametrize("cleared_index", [0, 1])
|
||||
def test_executable_lists_clear_independently(cleared_index: int) -> None:
|
||||
from portprotonqt.dialogs.settings_dialog import ExeSettingsDialog
|
||||
|
||||
owner = cast(Any, QWidget())
|
||||
owner.advanced_table = QTableWidget(2, 3)
|
||||
owner.theme = SimpleNamespace(ACTION_BUTTON_STYLE="", LINE_EDIT_STYLE="")
|
||||
owner._toggle_run_after_entries = lambda target: ExeSettingsDialog._toggle_run_after_entries(
|
||||
cast(ExeSettingsDialog, owner), target
|
||||
)
|
||||
targets = []
|
||||
for row, key in enumerate(("PW_RUN_AFTER_EXE", "PW_NETWORK_BLOCKLIST")):
|
||||
container = QWidget()
|
||||
target = QLineEdit(container)
|
||||
target.setObjectName(key)
|
||||
target.setText("Game.exe,Trainer.exe")
|
||||
owner.advanced_table.setCellWidget(row, 1, container)
|
||||
targets.append(target)
|
||||
for target in targets:
|
||||
owner._toggle_run_after_entries(target)
|
||||
assert owner.advanced_table.rowCount() == 6
|
||||
|
||||
ExeSettingsDialog._clear_run_after_entries(cast(ExeSettingsDialog, owner), targets[cleared_index])
|
||||
|
||||
assert targets[cleared_index].text() == ""
|
||||
assert not targets[cleared_index].property("ppqt_run_after_expanded")
|
||||
remaining = targets[1 - cleared_index]
|
||||
assert remaining.text() == "Game.exe,Trainer.exe"
|
||||
assert remaining.property("ppqt_run_after_expanded")
|
||||
assert owner.advanced_table.rowCount() == 4
|
||||
owner._toggle_run_after_entries(remaining)
|
||||
assert owner.advanced_table.rowCount() == 2
|
||||
owner.advanced_table.deleteLater()
|
||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user