64 Commits

Author SHA1 Message Date
dijunkun
9d45e497f4 [config] disable SRTP by default 2025-10-18 02:09:40 +08:00
dijunkun
e5891eb397 [fix] use static pcre linking to ensure this lib runs on machines without pcre, fixes #5 2025-10-18 01:59:35 +08:00
dijunkun
92fd7f2e89 [feat] remove vc runtime from nsis script since using static linking 2025-10-16 16:03:27 +08:00
dijunkun
b8535fff6f [feat] switch to /MT static runtime to improve Windows compatibility 2025-10-16 12:40:53 +08:00
dijunkun
09f34a81ad [feat] add screen capture frame rate option in settings window 2025-10-15 17:28:36 +08:00
dijunkun
22cc552e85 [feat] set screen capture frame rate to 60 fps 2025-10-15 15:42:42 +08:00
dijunkun
69a4dfcbb9 [feat] add fps display in net traffic stats window 2025-10-15 11:26:45 +08:00
dijunkun
e1390ca2d3 [chore] update README 2025-10-13 17:12:45 +08:00
dijunkun
dccdcd1b6f [chore] update README 2025-10-13 16:48:46 +08:00
dijunkun
276c3a336f [chore] update README 2025-10-13 10:52:01 +08:00
dijunkun
08518a9409 [fix] resolve mouse control issue due to SRTP packet parsing 2025-10-11 23:57:45 +08:00
dijunkun
f6b0767bb1 [chore] update README 2025-10-11 23:57:26 +08:00
Junkun Di
641fc84430 [chore] pdate README_EN 2025-10-11 17:50:41 +08:00
Junkun Di
4ce79b87a3 [chore] update README 2025-10-11 17:49:49 +08:00
dijunkun
477b204913 [chore] update README 2025-10-11 17:47:24 +08:00
dijunkun
98f349ea2f [chore] update README 2025-10-11 16:32:42 +08:00
dijunkun
47b1e15eef [chore] update README 2025-10-10 09:16:29 +08:00
dijunkun
590bf50924 [chore] update README 2025-10-09 16:36:41 +08:00
dijunkun
097633e47d [chore] add license 2025-10-09 16:03:05 +08:00
Junkun Di
d9ba88107d [chore] update README.md 2025-10-09 15:29:06 +08:00
Junkun Di
f6a6ef0b08 [chore] update README_CN.md 2025-10-09 15:28:06 +08:00
Junkun Di
a93ee0c19e [chore] update README.md 2025-10-09 15:25:21 +08:00
dijunkun
7e73553aca [fix] fix line drawing in recent connections window 2025-10-09 15:23:37 +08:00
Junkun Di
b858bd78c0 [chore] update README.md 2025-10-09 15:07:58 +08:00
dijunkun
f10947edf9 Merge branch 'sdl3' of https://github.com/kunkundi/crossdesk into sdl3 2025-10-09 14:47:47 +08:00
dijunkun
c723cca8f9 [chore] update README.md 2025-10-09 14:47:33 +08:00
dijunkun
b8f8b07ebe [chore] remove password regenerate button 2025-10-01 01:30:04 +08:00
dijunkun
f9c6e5a6ef [fix] correct packet loss in network statistics 2025-09-30 17:54:41 +08:00
dijunkun
15bf8ef8c0 [feat] show shield icon when SRTP is enabled 2025-09-30 17:26:42 +08:00
dijunkun
6565816c0e [fix] fix log path issue on first launch 2025-09-30 15:50:22 +08:00
dijunkun
2aa67ccd57 [feat] prompt user to close crossdesk.exe during install/uninstall on Windows 2025-09-30 15:27:34 +08:00
dijunkun
88c75f94e4 [feat] add SRTP switch in settings 2025-09-24 20:27:56 +08:00
dijunkun
aea9505c4c [chore] move nvidia-cuda-toolkit from Depends to Recommends in linux amd64 package 2025-09-12 17:42:47 +08:00
dijunkun
646740aab6 [chore] update minirtc to latest 2025-09-12 17:28:39 +08:00
dijunkun
a458836e6e [fix] resolve certs file loading failure on linux 2025-09-12 16:29:20 +08:00
dijunkun
5fe7df8ea8 [feat] ensure VC++ Redistributable is installed on Windows during setup 2025-09-12 12:49:35 +08:00
dijunkun
fda3743f86 [feat] add run-after-install option for windows installer 2025-09-11 16:23:48 +08:00
dijunkun
9e4170b3a8 [fix] update minirtc to fix startup crash on Windows when CUDA is not supported or not installed by using explicit dynamic loading 2025-09-11 01:01:46 +08:00
dijunkun
43338aaf02 [fix] release all peers when settings modified 2025-09-10 22:53:07 +08:00
dijunkun
274b7fcedc [test] test libstdc++ 2025-09-10 15:46:51 +08:00
dijunkun
01a5660984 [fix] set YUV colorspace to SDL_COLORSPACE_BT601_LIMITED to resolve NV12 texture display issue 2025-09-08 09:52:16 +08:00
dijunkun
a45118f785 [feat] remove internet shortcut installing for windows script 2025-09-05 18:51:16 +08:00
dijunkun
b6631c3db0 [fix] fix crash due to wrong linux keycode value 2025-09-04 16:31:03 +08:00
dijunkun
84d164c3af [fix] compelete linux x11 keycode map 2025-09-04 15:46:09 +08:00
dijunkun
32815ce25a [feat] use crossdesk/ubuntu20.04:latest as build image to support more users 2025-09-03 18:40:29 +08:00
dijunkun
7c2b3f8c8d [fix] use x64 and amd64 instead of x86_64 in artifact name 2025-09-03 17:10:17 +08:00
dijunkun
309d9d6ed6 [fix] fix linux x86_64 package script no Size information issue 2025-09-03 15:55:16 +08:00
dijunkun
91ab21c5f2 [fix] fix function keys release handling issue 2025-09-02 18:58:54 +08:00
dijunkun
b8369c4f0a [feat] remove redundant ImGui ConfigFlags to improve performance 2025-09-02 17:10:55 +08:00
dijunkun
a068a32303 [fix] remove SDL3 input audio stream recording 2025-09-02 16:53:55 +08:00
dijunkun
b6fe0da581 [feat] use SDL_WaitEventTimeout to refresh frames and reduce CPU usage 2025-09-02 16:45:04 +08:00
dijunkun
6e7e2697b5 [fix] fix dpi scaling 2025-09-02 15:48:05 +08:00
dijunkun
22084072b0 [feat] update icon files 2025-09-01 18:12:47 +08:00
dijunkun
d5457373f4 [feat] use squircle icons 2025-08-29 17:53:47 +08:00
dijunkun
01ae299cde [feat] delete old files 2025-08-29 10:16:26 +08:00
dijunkun
fbcd4c21cf [feat] use rsync instead of appleboy/scp-action to update artifacts 2025-08-29 09:56:20 +08:00
dijunkun
cf9dc0a9a5 [fix] fix artifacts generation path on linux in github actions scripts 2025-08-28 23:29:18 +08:00
dijunkun
1b4f41af46 [feat] upload artifacts to chinese server for download 2025-08-28 19:16:11 +08:00
dijunkun
7f3425519b [fix] fix linux github actions building 2025-08-28 19:14:25 +08:00
dijunkun
434c92deb6 [fix] add crossdesk_128x128.png to icons 2025-08-28 18:37:26 +08:00
dijunkun
e5eae1feb4 [feat] update icons 2025-08-28 18:23:02 +08:00
dijunkun
37e37d7d20 [fix] mv deb to /tmp in install process 2025-08-28 17:48:09 +08:00
dijunkun
062568dc96 [fix] fix SDL3 texture display error 2025-08-26 16:26:06 +08:00
dijunkun
d60fdf9050 [feat] update SDL2 to SDL3 2025-08-25 19:46:30 +08:00
57 changed files with 7609 additions and 2733 deletions

View File

@@ -15,12 +15,12 @@ env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
# Linux x86_64
build-linux-x86_64:
name: Build on Ubuntu 22.04 x86_64
# Linux amd64
build-linux-amd64:
name: Build on Ubuntu 22.04 amd64
runs-on: ubuntu-22.04
container:
image: crossdesk/ubuntu22.04:latest
image: crossdesk/ubuntu20.04:latest
options: --user root
steps:
- name: Extract version number
@@ -62,14 +62,14 @@ jobs:
- name: Package
run: |
chmod +x ./scripts/linux/pkg_x86_64.sh
./scripts/linux/pkg_x86_64.sh ${LEGAL_VERSION}
chmod +x ./scripts/linux/pkg_amd64.sh
./scripts/linux/pkg_amd64.sh ${LEGAL_VERSION}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: crossdesk-linux-x86_64-${{ env.LEGAL_VERSION }}
path: ${{ github.workspace }}/crossdesk-linux-x86_64-${{ env.LEGAL_VERSION }}.deb
name: crossdesk-linux-amd64-${{ env.LEGAL_VERSION }}
path: ${{ github.workspace }}/crossdesk-linux-amd64-${{ env.LEGAL_VERSION }}.deb
# Linux arm64
build-linux-arm64:
@@ -139,11 +139,11 @@ jobs:
strategy:
matrix:
include:
- arch: x86_64
- arch: x64
runner: macos-13
cache-key: intel
out-dir: ./build/macosx/x86_64/release/crossdesk
package_script: ./scripts/macosx/pkg_x86_64.sh
package_script: ./scripts/macosx/pkg_x64.sh
- arch: arm64
runner: macos-14
cache-key: arm
@@ -202,8 +202,8 @@ jobs:
cp crossdesk-macos-${{ matrix.arch }}-${{ env.VERSION_NUM }}.pkg release/
# Windows
build-windows:
name: Build on Windows
build-windows-x64:
name: Build on Windows x64
runs-on: windows-2022
env:
XMAKE_GLOBALDIR: D:\xmake_global
@@ -255,12 +255,31 @@ jobs:
Write-Host "Resolved CUDA_PATH = $cudaPath"
Pop-Location
- name: Download INetC plugin
shell: powershell
run: |
$url = "https://github.com/DigitalMediaServer/NSIS-INetC-plugin/releases/download/v1.0.5.7/InetC.zip"
$out = "$env:RUNNER_TEMP\InetC.zip"
Invoke-WebRequest -Uri $url -OutFile $out
Expand-Archive $out -DestinationPath "$env:RUNNER_TEMP\InetC" -Force
$source = "$env:RUNNER_TEMP\InetC\x86-unicode\INetC.dll"
$target = "C:\Program Files (x86)\NSIS\Plugins\x86-unicode\INetC.dll"
Write-Host "Copying $source to $target"
Copy-Item $source $target -Force
- name: Checkout code
uses: actions/checkout@v4
- name: Initialize submodules
run: git submodule update --init --recursive
- name: Copy nsProcess plugin to NSIS folder
run: |
$nsisPluginDir = "C:\Program Files (x86)\NSIS\Plugins\x86-unicode"
copy "${{ github.workspace }}\scripts\windows\nsProcess.dll" $nsisPluginDir
- name: Build CrossDesk
run: xmake b -vy crossdesk
@@ -279,13 +298,14 @@ jobs:
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: crossdesk-win-x86_64-${{ env.VERSION_NUM }}
path: ${{ github.workspace }}/scripts/windows/crossdesk-win-x86_64-${{ env.VERSION_NUM }}.exe
name: crossdesk-win-x64-${{ env.VERSION_NUM }}
path: ${{ github.workspace }}/scripts/windows/crossdesk-win-x64-${{ env.VERSION_NUM }}.exe
release:
name: Publish Release
if: startsWith(github.ref, 'refs/tags/v')
needs: [build-linux-x86_64, build-linux-arm64, build-macos, build-windows]
needs:
[build-linux-amd64, build-linux-arm64, build-macos, build-windows-x64]
runs-on: ubuntu-latest
steps:
@@ -307,11 +327,14 @@ jobs:
- name: Rename artifacts
run: |
mkdir -p release
cp artifacts/crossdesk-macos-x86_64-${{ steps.version.outputs.VERSION_NUM }}/* release/crossdesk-macos-x86_64-${{ steps.version.outputs.VERSION_NUM }}.pkg
cp artifacts/crossdesk-macos-x64-${{ steps.version.outputs.VERSION_NUM }}/* release/crossdesk-macos-x64-${{ steps.version.outputs.VERSION_NUM }}.pkg
cp artifacts/crossdesk-macos-arm64-${{ steps.version.outputs.VERSION_NUM }}/* release/crossdesk-macos-arm64-${{ steps.version.outputs.VERSION_NUM }}.pkg
cp artifacts/crossdesk-linux-x86_64-${{ steps.version.outputs.VERSION_NUM }}/* release/crossdesk-linux-x86_64-${{ steps.version.outputs.VERSION_NUM }}.deb
cp artifacts/crossdesk-linux-amd64-${{ steps.version.outputs.VERSION_NUM }}/* release/crossdesk-linux-amd64-${{ steps.version.outputs.VERSION_NUM }}.deb
cp artifacts/crossdesk-linux-arm64-${{ steps.version.outputs.VERSION_NUM }}/* release/crossdesk-linux-arm64-${{ steps.version.outputs.VERSION_NUM }}.deb
cp artifacts/crossdesk-win-x86_64-${{ steps.version.outputs.VERSION_NUM }}/* release/crossdesk-win-x86_64-${{ steps.version.outputs.VERSION_NUM }}.exe
cp artifacts/crossdesk-win-x64-${{ steps.version.outputs.VERSION_NUM }}/* release/crossdesk-win-x64-${{ steps.version.outputs.VERSION_NUM }}.exe
- name: List release files
run: ls -lh release/
- name: Upload to Versioned GitHub Release
uses: softprops/action-gh-release@v2
@@ -341,3 +364,13 @@ jobs:
prerelease: false
files: release/*
generate_release_notes: false
- name: Upload artifacts to server
uses: burnett01/rsync-deployments@5.2
with:
switches: -avzr --progress --delete
path: release/*
remote_path: /var/www/html/downloads/
remote_host: ${{ secrets.SERVER_HOST }}
remote_user: ${{ secrets.SERVER_USER }}
remote_key: ${{ secrets.SERVER_KEY }}

View File

@@ -30,10 +30,10 @@ jobs:
- name: Update download links
run: |
cd pages
sed -E -i "s/crossdesk-win-x86_64-[0-9]+\.[0-9]+\.[0-9]+\.exe/crossdesk-win-x86_64-${VERSION_NUM}.exe/g" index.html
sed -E -i "s/crossdesk-macos-x86_64-[0-9]+\.[0-9]+\.[0-9]+\.pkg/crossdesk-macos-x86_64-${VERSION_NUM}.pkg/g" index.html
sed -E -i "s/crossdesk-win-x64-[0-9]+\.[0-9]+\.[0-9]+\.exe/crossdesk-win-x64-${VERSION_NUM}.exe/g" index.html
sed -E -i "s/crossdesk-macos-x64-[0-9]+\.[0-9]+\.[0-9]+\.pkg/crossdesk-macos-x64-${VERSION_NUM}.pkg/g" index.html
sed -E -i "s/crossdesk-macos-arm64-[0-9]+\.[0-9]+\.[0-9]+\.pkg/crossdesk-macos-arm64-${VERSION_NUM}.pkg/g" index.html
sed -E -i "s/crossdesk-linux-x86_64-[0-9]+\.[0-9]+\.[0-9]+\.deb/crossdesk-linux-x86_64-${VERSION_NUM}.deb/g" index.html
sed -E -i "s/crossdesk-linux-amd64-[0-9]+\.[0-9]+\.[0-9]+\.deb/crossdesk-linux-amd64-${VERSION_NUM}.deb/g" index.html
sed -E -i "s/crossdesk-linux-arm64-[0-9]+\.[0-9]+\.[0-9]+\.deb/crossdesk-linux-arm64-${VERSION_NUM}.deb/g" index.html
- name: Commit & Push changes

177
LICENSE
View File

@@ -1,20 +1,165 @@
The MIT License (MIT)
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (c) 2023 The Continuous Desk Authors
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

105
README.md
View File

@@ -1,67 +1,112 @@
# CrossDesk
#### More than remote desktop
#### 跨界连接,高效如一
----
[中文](README_CN.md) / [English](README.md)
[English](README_EN.md) / [中文](README.md)
![sup_example](https://github.com/dijunkun/continuous-desk/assets/29698109/46536bc8-3ddd-438d-bf52-dccf143f1c20)
![sup_example](https://github.com/user-attachments/assets/eeb64fbe-1f07-4626-be1c-b77396beb905)
# Intro
## 简介
CrossDesk is a lightweight cross-platform remote desktop. It allows multiple users to remotely control the same computer at the same time. In addition to desktop image transmission, it also supports end-to-end voice transmission, providing collaboration capabilities on the basis of remote desktop.
CrossDesk 是一个轻量级的跨平台远程桌面软件。
CrossDesk is an experimental application of [Projectx](https://github.com/dijunkun/projectx) real-time communications library. Projectx is a lightweight cross-platform real-time communications library. It has basic capabilities such as network traversal ([RFC5245](https://datatracker.ietf.org/doc/html/rfc5245)), video software/hardware encoding/decoding (H264), audio encoding/decoding ([Opus](https://github.com/xiph/opus)), signaling interaction, and network congestion control ([TCP over UDP](https://libnice.freedesktop.org/)).
CrossDesk 是 [MiniRTC](https://github.com/kunkundi/minirtc.git) 实时音视频传输库的实验性应用。MiniRTC 是一个轻量级的跨平台实时音视频传输库。它具有网络透传([RFC5245](https://datatracker.ietf.org/doc/html/rfc5245)视频软硬编解码H264/AV1音频编解码[Opus](https://github.com/xiph/opus)),信令交互,网络拥塞控制,传输加密([SRTP](https://tools.ietf.org/html/rfc3711))等基础能力。
## Usage
Enter the remote desktop ID in the 'REMOTE ID' field on the menu bar, and click 'Connect' button to initiate the remote connection.
## 使用
![usage1](https://github.com/dijunkun/continuous-desk/assets/29698109/2ad59e6d-bdba-46d0-90cf-cbc9c06c2278)
在菜单栏“对端ID”处输入远端桌面的ID点击“→”即可发起远程连接。
If the remote desktop is set with a connection password, the local end needs to enter the correct password to initiate the remote connection. If the password is incorrect, an "Incorrect password" alert will appear in the status bar.
![usage1](https://github.com/user-attachments/assets/3a4bb59f-c84c-44d2-9a20-11790aac510e)
![incorrect password](https://github.com/dijunkun/continuous-desk/assets/29698109/cb05501c-ec4e-4adf-952d-7a55ef770a97)
如果远端桌面设置了连接密码,则本端需填写正确的连接密码才能成功发起远程连接。
After connection successfully established, the status bar will display the message "ClientConnected."
![password](https://github.com/user-attachments/assets/1beadcce-640d-4f5c-8e77-51917b5294d5)
![success](https://github.com/dijunkun/continuous-desk/assets/29698109/0cca21f7-48fe-44a5-b83d-eafeb8a81eb1)
发起连接前,可在设置中自定义配置项,如语言、视频编码格式等。
![settings](https://github.com/user-attachments/assets/8bc5468d-7bbb-4e30-95bd-da1f352ac08c)
## How to build
## 如何编译
Requirements:
依赖:
- [xmake](https://xmake.io/#/guide/installation)
- [cmake](https://cmake.org/download/)
- [vcpkg](https://vcpkg.io/en/getting-started)
Following packages need to be installed on Linux:
Linux环境下需安装以下包
```
sudo apt-get install -y nvidia-cuda-toolkit libxcb-randr0-dev libxcb-xtest0-dev libxcb-xinerama0-dev libxcb-shape0-dev libxcb-xkb-dev libxcb-xfixes0-dev libxcb-shm0-dev libxv-dev libasound2-dev libsndio-dev libasound2-dev libpulse-dev
sudo apt-get install -y software-properties-common git curl unzip build-essential libx11-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libxcb-randr0-dev libxcb-xtest0-dev libxcb-xinerama0-dev libxcb-shape0-dev libxcb-xkb-dev libxcb-xfixes0-dev libxv-dev libxtst-dev libasound2-dev libsndio-dev libxcb-shm0-dev libasound2-dev libpulse-dev
```
Commands:
编译
```
git clone https://github.com/dijunkun/continuous-desk
git clone https://github.com/kunkundi/crossdesk.git
cd continuous-desk
cd crossdesk
git submodule init
git submodule update
xmake b remote_desk
xmake b crossdesk
```
Run:
```
# Windows/MacOS
xmake r remote_desk
#### 无 CUDA 环境下的开发支持
# root privileges are required on Linux
./remote_desk
对于未安装 **CUDA 环境** 的Linux开发者这里提供了预配置的 [Ubuntu 22.04 Docker 镜像](https://hub.docker.com/r/crossdesk/ubuntu22.04)。
该镜像内置必要的构建依赖,可在容器中开箱即用,无需额外配置即可直接编译项目。
进入容器,下载工程后执行:
```
export CUDA_PATH=/usr/local/cuda
export XMAKE_GLOBALDIR=/data
xmake b --root crossdesk
```
## LICENSE
运行
```
xmake r crossdesk
```
Continuous Desk is licenced under MIT, and some third-party libraries are distributed under their licenses.
#### 注意
运行时如果客户端状态栏显示 **未连接服务器**,请先在 [CrossDesk 官方网站](https://www.crossdesk.cn/) 安装客户端,以便在环境中安装所需的证书文件。
<img width="129" height="60" alt="image" src="https://github.com/user-attachments/assets/1812f7d6-516b-4b4f-8a3d-98bee505cc5a" />
## 关于 Xmake
#### 安装 Xmake
使用 curl
```
curl -fsSL https://xmake.io/shget.text | bash
```
使用 wget
```
wget https://xmake.io/shget.text -O - | bash
```
使用 powershell
```
irm https://xmake.io/psget.text | iex
```
#### 编译选项
```
# 切换编译模式
xmake f -m debug/release
# 可选编译参数
-r :重新构建目标
-v :显示详细的构建日志
-y :自动确认提示
# 示例
xmake b -vy crossdesk
```
#### 运行选项
```
# 使用调试模式运行
xmake r -d crossdesk
```
更多使用方法可参考 [Xmake官方文档](https://xmake.io/guide/quick-start.html) 。

View File

@@ -1,67 +0,0 @@
# Continuous Desk
#### 不止远程桌面
----
[English](README.md) / [中文](README_CN.md)
![sup_example](https://github.com/dijunkun/continuous-desk/assets/29698109/46536bc8-3ddd-438d-bf52-dccf143f1c20)
## 简介
Continuous Desk 是一个轻量级的跨平台远程桌面软件。它允许多个用户在同一时间远程操控同一台电脑。除桌面图像传输外,它还支持端到端的语音传输,在远程桌面基础上提供额外的协作能力。
Continuous Desk 是 [Projectx](https://github.com/dijunkun/projectx) 实时音视频传输库的实验性应用。Projectx 是一个轻量级的跨平台实时音视频传输库。它具有网络透传([RFC5245](https://datatracker.ietf.org/doc/html/rfc5245)视频软硬编解码H264音频编解码[Opus](https://github.com/xiph/opus)),信令交互,网络拥塞控制([TCP over UDP](https://libnice.freedesktop.org/))等基础能力。
## 使用
在菜单栏“REMOTE ID”处输入远端桌面的ID点击“Connect”即可发起远程连接。
![usage1](https://github.com/dijunkun/continuous-desk/assets/29698109/2ad59e6d-bdba-46d0-90cf-cbc9c06c2278)
如果远端桌面设置了连接密码则本端需填写正确的连接密码才能成功发起远程连接。密码错误时状态栏会出现“Incorrect password”告警提示。
![incorrect password](https://github.com/dijunkun/continuous-desk/assets/29698109/cb05501c-ec4e-4adf-952d-7a55ef770a97)
连接成功建立后状态栏会有“ClientConnected”相关字样。
![success](https://github.com/dijunkun/continuous-desk/assets/29698109/0cca21f7-48fe-44a5-b83d-eafeb8a81eb1)
## 编译
依赖:
- [xmake](https://xmake.io/#/guide/installation)
- [cmake](https://cmake.org/download/)
- [vcpkg](https://vcpkg.io/en/getting-started)
Linux环境下需安装以下包
```
sudo apt-get install -y nvidia-cuda-toolkit libxcb-randr0-dev libxcb-xtest0-dev libxcb-xinerama0-dev libxcb-shape0-dev libxcb-xkb-dev libxcb-xfixes0-dev libxcb-shm0-dev libxv-dev libasound2-dev libsndio-dev libasound2-dev libpulse-dev
```
编译命令
```
git clone https://github.com/dijunkun/continuous-desk
cd continuous-desk
git submodule init
git submodule update
xmake b remote_desk
```
运行
```
# Windows/MacOS
xmake r remote_desk
# Linux下需使用root权限运行
./remote_desk
```
## 许可证
Continuous Desk 使用 MIT 许可证,其中使用到的第三方库根据自身许可证进行分发。

116
README_EN.md Normal file
View File

@@ -0,0 +1,116 @@
# CrossDesk
#### Bridging work, uniting efficiency
----
[中文](README.md) / [English](README_EN.md)
![sup_example](https://github.com/user-attachments/assets/3f17d8f3-7c4a-4b63-bae4-903363628687)
# Intro
CrossDesk is a lightweight cross-platform remote desktop software.
CrossDesk is an experimental application of [MiniRTC](https://github.com/kunkundi/minirtc.git), a lightweight cross-platform real-time audio and video transmission library. MiniRTC provides fundamental capabilities including network traversal ([RFC5245](https://datatracker.ietf.org/doc/html/rfc5245)), video software/hardware encoding and decoding (H264/AV1), audio encoding/decoding ([Opus](https://github.com/xiph/opus)), signaling interaction, network congestion control, and transmission encryption ([SRTP](https://tools.ietf.org/html/rfc3711)).
## Usage
Enter the remote desktop ID in the menu bars “Remote ID” field and click “→” to initiate a remote connection.
![usage1](https://github.com/user-attachments/assets/bf39f8fa-de77-41a1-8db3-73d6cab9da6a)
If the remote desktop requires a connection password, you must enter the correct password on your side to successfully establish the connection.
![password](https://github.com/user-attachments/assets/f6556966-a84f-4301-a79b-2726b389ed71)
Before connecting, you can customize configuration options in the settings, such as language and video encoding format.
![settings](https://github.com/user-attachments/assets/12f7e9c3-a472-40c1-8fb9-ae7d1ae3865c)
## How to build
Requirements:
- [xmake](https://xmake.io/#/guide/installation)
- [cmake](https://cmake.org/download/)
Following packages need to be installed on Linux:
```
sudo apt-get install -y software-properties-common git curl unzip build-essential libx11-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libxcb-randr0-dev libxcb-xtest0-dev libxcb-xinerama0-dev libxcb-shape0-dev libxcb-xkb-dev libxcb-xfixes0-dev libxv-dev libxtst-dev libasound2-dev libsndio-dev libxcb-shm0-dev libasound2-dev libpulse-dev
```
Build:
```
git clone https://github.com/kunkundi/crossdesk.git
cd crossdesk
git submodule init
git submodule update
xmake b crossdesk
```
#### Development Without CUDA Environment
For developers who do not have a **CUDA environment** installed, a preconfigured [Ubuntu 22.04 Docker image](https://hub.docker.com/r/crossdesk/ubuntu22.04) is provided.
This image comes with all required build dependencies and allows you to build the project directly inside the container without any additional setup.
After entering the container, download the project and run:
```
export CUDA_PATH=/usr/local/cuda
export XMAKE_GLOBALDIR=/data
xmake b --root crossdesk
```
Run:
```
xmake r crossdesk
```
#### Notice
If the client status bar shows **Disconnected** during runtime, please first install the client from the [CrossDesk official website](https://www.crossdesk.cn/) to ensure the required certificate files are available in the environment.
<img width="108" height="57" alt="image" src="https://github.com/user-attachments/assets/26e8b9f3-b326-410e-9466-dd073eaf675a" />
## About Xmake
#### Installing Xmake
You can install Xmake using one of the following methods:
Using curl:
```
curl -fsSL https://xmake.io/shget.text | bash
```
Using wget:
```
wget https://xmake.io/shget.text -O - | bash
```
Using powershell:
```
irm https://xmake.io/psget.text | iex
```
#### Build Options
```
# Switch build mode
xmake f -m debug/release
# Optional build parameters
-r : Rebuild the target
-v : Show detailed build logs
-y : Automatically confirm prompts
# Example
xmake b -vy crossdesk
```
#### Run Options
```
# Run in debug mode
xmake r -d crossdesk
```
For more information, please refer to the [official Xmake documentation](https://xmake.io/guide/quick-start.html) .

File diff suppressed because it is too large Load Diff

View File

@@ -1 +0,0 @@
IDI_ICON1 ICON "app_icon.ico"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 687 B

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 687 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 840 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 746 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

BIN
icons/macos/crossdesk.icns Normal file

Binary file not shown.

BIN
icons/windows/crossdesk.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

BIN
image.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

View File

@@ -1,31 +1,40 @@
#!/bin/bash
set -e
PKG_NAME="crossdesk"
APP_NAME="CrossDesk"
APP_VERSION="$1"
ARCHITECTURE="amd64"
MAINTAINER="Junkun Di <junkun.di@hotmail.com>"
DESCRIPTION="A simple cross-platform remote desktop client."
DEB_DIR="$APP_NAME-$APP_VERSION"
DEB_DIR="${PKG_NAME}-${APP_VERSION}"
DEBIAN_DIR="$DEB_DIR/DEBIAN"
BIN_DIR="$DEB_DIR/usr/local/bin"
CERT_SRC_DIR="$DEB_DIR/opt/$APP_NAME/certs" # 用于中转安装时分发
ICON_DIR="$DEB_DIR/usr/share/icons/hicolor/256x256/apps"
BIN_DIR="$DEB_DIR/usr/bin"
CERT_SRC_DIR="$DEB_DIR/opt/$PKG_NAME/certs"
ICON_BASE_DIR="$DEB_DIR/usr/share/icons/hicolor"
DESKTOP_DIR="$DEB_DIR/usr/share/applications"
rm -rf "$DEB_DIR"
mkdir -p "$DEBIAN_DIR" "$BIN_DIR" "$CERT_SRC_DIR" "$ICON_DIR" "$DESKTOP_DIR"
mkdir -p "$DEBIAN_DIR" "$BIN_DIR" "$CERT_SRC_DIR" "$DESKTOP_DIR"
cp build/linux/x86_64/release/crossdesk "$BIN_DIR/$PKG_NAME"
chmod +x "$BIN_DIR/$PKG_NAME"
ln -s "$PKG_NAME" "$BIN_DIR/$APP_NAME"
cp build/linux/x86_64/release/crossdesk "$BIN_DIR"
cp certs/crossdesk.cn_root.crt "$CERT_SRC_DIR/crossdesk.cn_root.crt"
cp icons/crossdesk.png "$ICON_DIR/crossdesk.png"
chmod +x "$BIN_DIR/crossdesk"
for size in 16 24 32 48 64 96 128 256; do
mkdir -p "$ICON_BASE_DIR/${size}x${size}/apps"
cp "icons/linux/crossdesk_${size}x${size}.png" \
"$ICON_BASE_DIR/${size}x${size}/apps/${PKG_NAME}.png"
done
cat > "$DEBIAN_DIR/control" << EOF
Package: $APP_NAME
Package: $PKG_NAME
Version: $APP_VERSION
Architecture: $ARCHITECTURE
Maintainer: $MAINTAINER
@@ -33,18 +42,19 @@ Description: $DESCRIPTION
Depends: libc6 (>= 2.29), libstdc++6 (>= 9), libx11-6, libxcb1,
libxcb-randr0, libxcb-xtest0, libxcb-xinerama0, libxcb-shape0,
libxcb-xkb1, libxcb-xfixes0, libxv1, libxtst6, libasound2,
libsndio7.0, libxcb-shm0, libpulse0, nvidia-cuda-toolkit
libsndio7.0, libxcb-shm0, libpulse0
Recommends: nvidia-cuda-toolkit
Priority: optional
Section: utils
EOF
cat > "$DESKTOP_DIR/$APP_NAME.desktop" << EOF
cat > "$DESKTOP_DIR/$PKG_NAME.desktop" << EOF
[Desktop Entry]
Version=$APP_VERSION
Name=$APP_NAME
Comment=$DESCRIPTION
Exec=/usr/local/bin/crossdesk
Icon=crossdesk
Exec=/usr/bin/$PKG_NAME
Icon=$PKG_NAME
Terminal=false
Type=Application
Categories=Utility;
@@ -52,27 +62,27 @@ EOF
cat > "$DEBIAN_DIR/postrm" << EOF
#!/bin/bash
# post-removal script for $APP_NAME
set -e
if [ "\$1" = "remove" ] || [ "\$1" = "purge" ]; then
rm -f /usr/local/bin/crossdesk
rm -f /usr/share/icons/hicolor/256x256/apps/crossdesk.png
rm -f /usr/share/applications/$APP_NAME.desktop
rm -rf /opt/$APP_NAME
rm -f /usr/bin/$PKG_NAME || true
rm -f /usr/bin/$APP_NAME || true
rm -f /usr/share/applications/$PKG_NAME.desktop || true
rm -rf /opt/$PKG_NAME/certs || true
for size in 16 24 32 48 64 96 128 256; do
rm -f /usr/share/icons/hicolor/\${size}x\${size}/apps/$PKG_NAME.png || true
done
fi
exit 0
EOF
chmod +x "$DEBIAN_DIR/postrm"
cat > "$DEBIAN_DIR/postinst" << 'EOF'
#!/bin/bash
set -e
CERT_SRC="/opt/CrossDesk/certs"
CERT_SRC="/opt/crossdesk/certs"
CERT_FILE="crossdesk.cn_root.crt"
for user_home in /home/*; do
@@ -82,30 +92,29 @@ for user_home in /home/*; do
target="$config_dir/$CERT_FILE"
if [ ! -f "$target" ]; then
mkdir -p "$config_dir"
cp "$CERT_SRC/$CERT_FILE" "$target"
chown -R "$username:$username" "$user_home/.config/CrossDesk"
mkdir -p "$config_dir" || true
cp "$CERT_SRC/$CERT_FILE" "$target" || true
chown -R "$username:$username" "$user_home/.config/CrossDesk" || true
echo "✔ Installed cert for $username at $target"
fi
done
if [ -d "/root" ]; then
config_dir="/root/.config/CrossDesk/certs"
mkdir -p "$config_dir"
cp "$CERT_SRC/$CERT_FILE" "$config_dir/$CERT_FILE"
chown -R root:root /root/.config/CrossDesk
mkdir -p "$config_dir" || true
cp "$CERT_SRC/$CERT_FILE" "$config_dir/$CERT_FILE" || true
chown -R root:root /root/.config/CrossDesk || true
fi
exit 0
EOF
chmod +x "$DEBIAN_DIR/postinst"
dpkg-deb --build "$DEB_DIR"
OUTPUT_FILE="crossdesk-linux-x86_64-$APP_VERSION.deb"
OUTPUT_FILE="${PKG_NAME}-linux-${ARCHITECTURE}-${APP_VERSION}.deb"
mv "$DEB_DIR.deb" "$OUTPUT_FILE"
rm -rf "$DEB_DIR"
echo "✅ Deb package for $APP_NAME created successfully."
echo "✅ Deb package created: $OUTPUT_FILE"

View File

@@ -1,31 +1,40 @@
#!/bin/bash
set -e
PKG_NAME="crossdesk"
APP_NAME="CrossDesk"
APP_VERSION="$1"
ARCHITECTURE="arm64" # 改为 arm64
ARCHITECTURE="arm64"
MAINTAINER="Junkun Di <junkun.di@hotmail.com>"
DESCRIPTION="A simple cross-platform remote desktop client."
DEB_DIR="$APP_NAME-$APP_VERSION"
DEB_DIR="${PKG_NAME}-${APP_VERSION}"
DEBIAN_DIR="$DEB_DIR/DEBIAN"
BIN_DIR="$DEB_DIR/usr/local/bin"
CERT_SRC_DIR="$DEB_DIR/opt/$APP_NAME/certs"
ICON_DIR="$DEB_DIR/usr/share/icons/hicolor/256x256/apps"
BIN_DIR="$DEB_DIR/usr/bin"
CERT_SRC_DIR="$DEB_DIR/opt/$PKG_NAME/certs"
ICON_BASE_DIR="$DEB_DIR/usr/share/icons/hicolor"
DESKTOP_DIR="$DEB_DIR/usr/share/applications"
rm -rf "$DEB_DIR"
mkdir -p "$DEBIAN_DIR" "$BIN_DIR" "$CERT_SRC_DIR" "$ICON_DIR" "$DESKTOP_DIR"
mkdir -p "$DEBIAN_DIR" "$BIN_DIR" "$CERT_SRC_DIR" "$DESKTOP_DIR"
cp build/linux/arm64/release/crossdesk "$BIN_DIR"
cp certs/crossdesk.cn_root.crt "$CERT_SRC_DIR/crossdesk.cn_root.crt"
cp icons/crossdesk.png "$ICON_DIR/crossdesk.png"
chmod +x "$BIN_DIR/$PKG_NAME"
chmod +x "$BIN_DIR/crossdesk"
ln -s "$PKG_NAME" "$BIN_DIR/$APP_NAME"
cp certs/crossdesk.cn_root.crt "$CERT_SRC_DIR/crossdesk.cn_root.crt"
for size in 16 24 32 48 64 96 128 256; do
mkdir -p "$ICON_BASE_DIR/${size}x${size}/apps"
cp "icons/linux/crossdesk_${size}x${size}.png" \
"$ICON_BASE_DIR/${size}x${size}/apps/${PKG_NAME}.png"
done
cat > "$DEBIAN_DIR/control" << EOF
Package: $APP_NAME
Package: $PKG_NAME
Version: $APP_VERSION
Architecture: $ARCHITECTURE
Maintainer: $MAINTAINER
@@ -38,13 +47,13 @@ Priority: optional
Section: utils
EOF
cat > "$DESKTOP_DIR/$APP_NAME.desktop" << EOF
cat > "$DESKTOP_DIR/$PKG_NAME.desktop" << EOF
[Desktop Entry]
Version=$APP_VERSION
Name=$APP_NAME
Comment=$DESCRIPTION
Exec=/usr/local/bin/crossdesk
Icon=crossdesk
Exec=/usr/bin/$PKG_NAME
Icon=$PKG_NAME
Terminal=false
Type=Application
Categories=Utility;
@@ -52,27 +61,27 @@ EOF
cat > "$DEBIAN_DIR/postrm" << EOF
#!/bin/bash
# post-removal script for $APP_NAME
set -e
if [ "\$1" = "remove" ] || [ "\$1" = "purge" ]; then
rm -f /usr/local/bin/crossdesk
rm -f /usr/share/icons/hicolor/256x256/apps/crossdesk.png
rm -f /usr/share/applications/$APP_NAME.desktop
rm -rf /opt/$APP_NAME
rm -f /usr/bin/$PKG_NAME || true
rm -f /usr/bin/$APP_NAME || true
rm -f /usr/share/applications/$PKG_NAME.desktop || true
rm -rf /opt/$PKG_NAME/certs || true
for size in 16 24 32 48 64 96 128 256; do
rm -f /usr/share/icons/hicolor/\${size}x\${size}/apps/$PKG_NAME.png || true
done
fi
exit 0
EOF
chmod +x "$DEBIAN_DIR/postrm"
cat > "$DEBIAN_DIR/postinst" << 'EOF'
#!/bin/bash
set -e
CERT_SRC="/opt/CrossDesk/certs"
CERT_SRC="/opt/crossdesk/certs"
CERT_FILE="crossdesk.cn_root.crt"
for user_home in /home/*; do
@@ -82,18 +91,18 @@ for user_home in /home/*; do
target="$config_dir/$CERT_FILE"
if [ ! -f "$target" ]; then
mkdir -p "$config_dir"
cp "$CERT_SRC/$CERT_FILE" "$target"
chown -R "$username:$username" "$user_home/.config/CrossDesk"
mkdir -p "$config_dir" || true
cp "$CERT_SRC/$CERT_FILE" "$target" || true
chown -R "$username:$username" "$user_home/.config/CrossDesk" || true
echo "✔ Installed cert for $username at $target"
fi
done
if [ -d "/root" ]; then
config_dir="/root/.config/CrossDesk/certs"
mkdir -p "$config_dir"
cp "$CERT_SRC/$CERT_FILE" "$config_dir/$CERT_FILE"
chown -R root:root /root/.config/CrossDesk
mkdir -p "$config_dir" || true
cp "$CERT_SRC/$CERT_FILE" "$config_dir/$CERT_FILE" || true
chown -R root:root /root/.config/CrossDesk || true
fi
exit 0
@@ -108,4 +117,4 @@ mv "$DEB_DIR.deb" "$OUTPUT_FILE"
rm -rf "$DEB_DIR"
echo "✅ Deb package for $APP_NAME (ARM64) created successfully."
echo "✅ Deb package created: $OUTPUT_FILE"

View File

@@ -1,64 +1,54 @@
#!/bin/bash
set -e # 遇错退出
set -e
# === 配置变量 ===
APP_NAME="crossdesk"
APP_NAME_UPPER="CrossDesk" # 这个变量用来指定大写的应用名
EXECUTABLE_PATH="./build/macosx/arm64/release/crossdesk" # 可执行文件路径
APP_NAME_UPPER="CrossDesk"
EXECUTABLE_PATH="./build/macosx/arm64/release/crossdesk"
APP_VERSION="$1"
PLATFORM="macos"
ARCH="arm64"
IDENTIFIER="cn.crossdesk.app"
ICON_PATH="./icons/crossdesk.icns" # .icns 图标路径
ICON_PATH="icons/macos/crossdesk.icns"
MACOS_MIN_VERSION="10.12"
CERTS_SOURCE="./certs" # 你的证书文件目录,里面放所有需要安装的文件
CERTS_SOURCE="certs"
CERT_NAME="crossdesk.cn_root.crt"
APP_BUNDLE="${APP_NAME_UPPER}.app" # 使用大写的应用名称
APP_BUNDLE="${APP_NAME_UPPER}.app"
CONTENTS_DIR="${APP_BUNDLE}/Contents"
MACOS_DIR="${CONTENTS_DIR}/MacOS"
RESOURCES_DIR="${CONTENTS_DIR}/Resources"
PKG_NAME="${APP_NAME}-${PLATFORM}-${ARCH}-${APP_VERSION}.pkg" # 保持安装包名称小写
PKG_NAME="${APP_NAME}-${PLATFORM}-${ARCH}-${APP_VERSION}.pkg"
DMG_NAME="${APP_NAME}-${PLATFORM}-${ARCH}-${APP_VERSION}.dmg"
VOL_NAME="Install ${APP_NAME_UPPER}"
# === 清理旧文件 ===
echo "🧹 清理旧文件..."
echo "delete old files"
rm -rf "${APP_BUNDLE}" "${PKG_NAME}" "${DMG_NAME}" build_pkg_temp CrossDesk_dmg_temp
mkdir -p build_pkg_temp
# === 创建 .app 结构 ===
echo "📦 创建 ${APP_BUNDLE}..."
mkdir -p "${MACOS_DIR}" "${RESOURCES_DIR}"
echo "🚚 拷贝可执行文件..."
cp "${EXECUTABLE_PATH}" "${MACOS_DIR}/${APP_NAME_UPPER}" # 拷贝时使用大写的应用名称
cp "${EXECUTABLE_PATH}" "${MACOS_DIR}/${APP_NAME_UPPER}"
chmod +x "${MACOS_DIR}/${APP_NAME_UPPER}"
# === 图标 ===
if [ -f "${ICON_PATH}" ]; then
cp "${ICON_PATH}" "${RESOURCES_DIR}/crossedesk.icns"
ICON_KEY="<key>CFBundleIconFile</key><string>crossedesk.icns</string>"
echo "🎨 图标添加完成"
else
ICON_KEY=""
echo "⚠️ 未找到图标文件,跳过图标设置"
fi
# === 生成 Info.plist ===
echo "📝 生成 Info.plist..."
echo "generate Info.plist"
cat > "${CONTENTS_DIR}/Info.plist" <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleName</key>
<string>${APP_NAME_UPPER}</string> <!-- 使用大写名称 -->
<string>${APP_NAME_UPPER}</string>
<key>CFBundleDisplayName</key>
<string>${APP_NAME_UPPER}</string> <!-- 使用大写名称 -->
<string>${APP_NAME_UPPER}</string>
<key>CFBundleIdentifier</key>
<string>${IDENTIFIER}</string>
<key>CFBundleVersion</key>
@@ -66,7 +56,7 @@ cat > "${CONTENTS_DIR}/Info.plist" <<EOF
<key>CFBundleShortVersionString</key>
<string>${APP_VERSION}</string>
<key>CFBundleExecutable</key>
<string>${APP_NAME_UPPER}</string> <!-- 使用大写名称 -->
<string>${APP_NAME_UPPER}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
${ICON_KEY}
@@ -86,10 +76,9 @@ cat > "${CONTENTS_DIR}/Info.plist" <<EOF
</plist>
EOF
echo ".app 创建完成"
echo ".app created successfully."
# === 构建应用组件包 ===
echo "📦 构建应用组件包..."
echo "building pkg..."
pkgbuild \
--identifier "${IDENTIFIER}" \
--version "${APP_VERSION}" \
@@ -97,8 +86,6 @@ pkgbuild \
--component "${APP_BUNDLE}" \
build_pkg_temp/${APP_NAME}-component.pkg
# === 构建 certs 组件包 ===
# 先创建脚本目录和脚本文件
mkdir -p scripts
cat > scripts/postinstall <<'EOF'
@@ -116,7 +103,6 @@ EOF
chmod +x scripts/postinstall
# 构建 certs 组件包,增加 --scripts 参数指定 postinstall
pkgbuild \
--root "${CERTS_SOURCE}" \
--identifier "${IDENTIFIER}.certs" \
@@ -125,28 +111,15 @@ pkgbuild \
--scripts scripts \
build_pkg_temp/${APP_NAME}-certs.pkg
# === 组合产品包 ===
echo "🏗️ 组合最终安装包..."
productbuild \
--package build_pkg_temp/${APP_NAME}-component.pkg \
--package build_pkg_temp/${APP_NAME}-certs.pkg \
"${PKG_NAME}"
echo "✅ 生成安装包完成:${PKG_NAME}"
# === 可选:打包成 DMG ===
# echo "📦 可选打包成 DMG..."
# mkdir -p CrossDesk_dmg_temp
# cp "${PKG_NAME}" CrossDesk_dmg_temp/
# ln -s /Applications CrossDesk_dmg_temp/Applications
# hdiutil create -volname "${VOL_NAME}" \
# -srcfolder CrossDesk_dmg_temp \
# -ov -format UDZO "${DMG_NAME}"
echo "PKG package created: ${PKG_NAME}"
rm -rf build_pkg_temp scripts ${APP_BUNDLE}
echo "🎉 所有打包完成:"
echo " ✔️ 应用:${APP_BUNDLE}"
echo " ✔️ 安装包:${PKG_NAME}"
# echo " ✔️ 镜像包(可选):${DMG_NAME}"
echo "PKG package created successfully."
echo "package ${APP_BUNDLE}"
echo "installer ${PKG_NAME}"

View File

@@ -1,64 +1,54 @@
#!/bin/bash
set -e # 遇错退出
set -e
# === 配置变量 ===
APP_NAME="crossdesk"
APP_NAME_UPPER="CrossDesk" # 这个变量用来指定大写的应用名
EXECUTABLE_PATH="build/macosx/x86_64/release/crossdesk" # 可执行文件路径
APP_NAME_UPPER="CrossDesk"
EXECUTABLE_PATH="build/macosx/x86_64/release/crossdesk"
APP_VERSION="$1"
PLATFORM="macos"
ARCH="x86_64"
ARCH="x64"
IDENTIFIER="cn.crossdesk.app"
ICON_PATH="icons/crossdesk.icns" # .icns 图标路径
ICON_PATH="icons/macos/crossdesk.icns"
MACOS_MIN_VERSION="10.12"
CERTS_SOURCE="certs" # 你的证书文件目录,里面放所有需要安装的文件
CERTS_SOURCE="certs"
CERT_NAME="crossdesk.cn_root.crt"
APP_BUNDLE="${APP_NAME_UPPER}.app" # 使用大写的应用名称
APP_BUNDLE="${APP_NAME_UPPER}.app"
CONTENTS_DIR="${APP_BUNDLE}/Contents"
MACOS_DIR="${CONTENTS_DIR}/MacOS"
RESOURCES_DIR="${CONTENTS_DIR}/Resources"
PKG_NAME="${APP_NAME}-${PLATFORM}-${ARCH}-${APP_VERSION}.pkg" # 保持安装包名称小写
PKG_NAME="${APP_NAME}-${PLATFORM}-${ARCH}-${APP_VERSION}.pkg"
DMG_NAME="${APP_NAME}-${PLATFORM}-${ARCH}-${APP_VERSION}.dmg"
VOL_NAME="Install ${APP_NAME_UPPER}"
# === 清理旧文件 ===
echo "🧹 清理旧文件..."
echo "delete old files"
rm -rf "${APP_BUNDLE}" "${PKG_NAME}" "${DMG_NAME}" build_pkg_temp CrossDesk_dmg_temp
mkdir -p build_pkg_temp
# === 创建 .app 结构 ===
echo "📦 创建 ${APP_BUNDLE}..."
mkdir -p "${MACOS_DIR}" "${RESOURCES_DIR}"
echo "🚚 拷贝可执行文件..."
cp "${EXECUTABLE_PATH}" "${MACOS_DIR}/${APP_NAME_UPPER}" # 拷贝时使用大写的应用名称
cp "${EXECUTABLE_PATH}" "${MACOS_DIR}/${APP_NAME_UPPER}"
chmod +x "${MACOS_DIR}/${APP_NAME_UPPER}"
# === 图标 ===
if [ -f "${ICON_PATH}" ]; then
cp "${ICON_PATH}" "${RESOURCES_DIR}/crossedesk.icns"
ICON_KEY="<key>CFBundleIconFile</key><string>crossedesk.icns</string>"
echo "🎨 图标添加完成"
else
ICON_KEY=""
echo "⚠️ 未找到图标文件,跳过图标设置"
fi
# === 生成 Info.plist ===
echo "📝 生成 Info.plist..."
echo "generate Info.plist"
cat > "${CONTENTS_DIR}/Info.plist" <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleName</key>
<string>${APP_NAME_UPPER}</string> <!-- 使用大写名称 -->
<string>${APP_NAME_UPPER}</string>
<key>CFBundleDisplayName</key>
<string>${APP_NAME_UPPER}</string> <!-- 使用大写名称 -->
<string>${APP_NAME_UPPER}</string>
<key>CFBundleIdentifier</key>
<string>${IDENTIFIER}</string>
<key>CFBundleVersion</key>
@@ -66,7 +56,7 @@ cat > "${CONTENTS_DIR}/Info.plist" <<EOF
<key>CFBundleShortVersionString</key>
<string>${APP_VERSION}</string>
<key>CFBundleExecutable</key>
<string>${APP_NAME_UPPER}</string> <!-- 使用大写名称 -->
<string>${APP_NAME_UPPER}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
${ICON_KEY}
@@ -86,10 +76,9 @@ cat > "${CONTENTS_DIR}/Info.plist" <<EOF
</plist>
EOF
echo ".app 创建完成"
echo ".app created successfully."
# === 构建应用组件包 ===
echo "📦 构建应用组件包..."
echo "building pkg..."
pkgbuild \
--identifier "${IDENTIFIER}" \
--version "${APP_VERSION}" \
@@ -97,8 +86,6 @@ pkgbuild \
--component "${APP_BUNDLE}" \
build_pkg_temp/${APP_NAME}-component.pkg
# === 构建 certs 组件包 ===
# 先创建脚本目录和脚本文件
mkdir -p scripts
cat > scripts/postinstall <<'EOF'
@@ -116,7 +103,6 @@ EOF
chmod +x scripts/postinstall
# 构建 certs 组件包,增加 --scripts 参数指定 postinstall
pkgbuild \
--root "${CERTS_SOURCE}" \
--identifier "${IDENTIFIER}.certs" \
@@ -125,28 +111,15 @@ pkgbuild \
--scripts scripts \
build_pkg_temp/${APP_NAME}-certs.pkg
# === 组合产品包 ===
echo "🏗️ 组合最终安装包..."
productbuild \
--package build_pkg_temp/${APP_NAME}-component.pkg \
--package build_pkg_temp/${APP_NAME}-certs.pkg \
"${PKG_NAME}"
echo "✅ 生成安装包完成:${PKG_NAME}"
# === 可选:打包成 DMG ===
# echo "📦 可选打包成 DMG..."
# mkdir -p CrossDesk_dmg_temp
# cp "${PKG_NAME}" CrossDesk_dmg_temp/
# ln -s /Applications CrossDesk_dmg_temp/Applications
# hdiutil create -volname "${VOL_NAME}" \
# -srcfolder CrossDesk_dmg_temp \
# -ov -format UDZO "${DMG_NAME}"
echo "PKG package created: ${PKG_NAME}"
rm -rf build_pkg_temp scripts ${APP_BUNDLE}
echo "🎉 所有打包完成:"
echo " ✔️ 应用:${APP_BUNDLE}"
echo " ✔️ 安装包:${PKG_NAME}"
# echo " ✔️ 镜像包(可选):${DMG_NAME}"
echo "PKG package created successfully."
echo "package ${APP_BUNDLE}"
echo "installer ${PKG_NAME}"

View File

@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<!-- 应用程序标识 -->
<assemblyIdentity
version="1.0.0.0"
processorArchitecture="*"
name="CrossDesk"
type="win32" />
<!-- 描述信息 -->
<description>CrossDesk Application</description>
<!-- 权限:要求管理员运行 -->
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
<!-- DPI 感知设置:支持高分屏 -->
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<!-- Windows Vista/7 风格 DPI 感知 -->
<dpiAware>true/pm</dpiAware>
<!-- Windows 10/11 高级 DPI 感知 -->
<dpiAwareness>PerMonitorV2</dpiAwareness>
</windowsSettings>
</application>
<!-- Windows 兼容性声明 -->
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- 支持 Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
<!-- 支持 Windows 11向下兼容 Win10 GUID -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
</application>
</compatibility>
</assembly>

Binary file not shown.

View File

@@ -1,7 +1,7 @@
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><EFBFBD>
; Set search path
!addincludedir "${__FILEDIR__}"
; <EFBFBD><EFBFBD>װ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
; Installer initial constants
!define PRODUCT_NAME "CrossDesk"
!define PRODUCT_VERSION "${VERSION}"
!define PRODUCT_PUBLISHER "CrossDesk"
@@ -9,45 +9,78 @@
!define APP_NAME "CrossDesk"
!define UNINSTALL_REG_KEY "CrossDesk"
; <EFBFBD><EFBFBD><EFBFBD>ð<EFBFBD>װ<EFBFBD><EFBFBD>ͼ<EFBFBD><EFBFBD>·<EFBFBD><EFBFBD>
!define MUI_ICON "${__FILEDIR__}\..\..\icons\crossdesk.ico"
; Installer icon path
!define MUI_ICON "${__FILEDIR__}\..\..\icons\windows\crossdesk.ico"
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD>֤<EFBFBD><EFBFBD>·<EFBFBD><EFBFBD>
; Certificate path
!define CERT_FILE "${__FILEDIR__}\..\..\certs\crossdesk.cn_root.crt"
; ѹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
; Compression settings
SetCompressor /FINAL lzma
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԱȨ<EFBFBD>ޣ<EFBFBD>д<EFBFBD><EFBFBD>HKLM<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>
; Request admin privileges (needed to write HKLM)
RequestExecutionLevel admin
; ------ MUI <EFBFBD>ִ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ------
; ------ MUI Modern UI Definition ------
!include "MUI.nsh"
!define MUI_ABORTWARNING
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
; Add run-after-install option
!define MUI_FINISHPAGE_RUN
!define MUI_FINISHPAGE_RUN_TEXT "Run ${PRODUCT_NAME}"
!define MUI_FINISHPAGE_RUN_FUNCTION LaunchApp
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_LANGUAGE "SimpChinese"
!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
; ------ MUI <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ------
; ------ End of MUI Definition ------
; Include LogicLib for process handling
!include "LogicLib.nsh"
Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "crossdesk-win-x86_64-${PRODUCT_VERSION}.exe"
OutFile "crossdesk-win-x64-${PRODUCT_VERSION}.exe"
InstallDir "$PROGRAMFILES\CrossDesk"
InstallDirRegKey HKCU "Software\${PRODUCT_NAME}" "InstallDir"
ShowInstDetails show
Section "MainSection"
; Check if CrossDesk is running
StrCpy $1 "crossdesk.exe"
nsProcess::_FindProcess "$1"
Pop $R0
${If} $R0 = 0 ;
MessageBox MB_ICONQUESTION|MB_YESNO "CrossDesk is running. Do you want to close it and continue the installation?" IDYES closeApp IDNO cancelInstall
${Else}
Goto installApp
${EndIf}
closeApp:
nsProcess::_KillProcess "$1"
Pop $R0
Sleep 500
Goto installApp
cancelInstall:
SetDetailsPrint both
MessageBox MB_ICONEXCLAMATION|MB_OK "Installation has been aborted."
Abort
installApp:
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
; <EFBFBD><EFBFBD><EFBFBD>ó<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>·<EFBFBD><EFBFBD>
; Main application executable path
File /oname=crossdesk.exe "..\..\build\windows\x64\release\crossdesk.exe"
; ? <20><><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>װĿ¼
; Copy icon file to installation directory
File "${MUI_ICON}"
; д<EFBFBD><EFBFBD>ж<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
; Write uninstall information
WriteUninstaller "$INSTDIR\uninstall.exe"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTALL_REG_KEY}" "DisplayName" "${PRODUCT_NAME}"
@@ -55,9 +88,15 @@ Section "MainSection"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTALL_REG_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTALL_REG_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTALL_REG_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTALL_REG_KEY}" "DisplayIcon" "$INSTDIR\crossdesk.ico"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTALL_REG_KEY}" "DisplayIcon" "$INSTDIR\crossdesk.ico"
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTALL_REG_KEY}" "NoModify" 1
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTALL_REG_KEY}" "NoRepair" 1
WriteRegStr HKCU "Software\${PRODUCT_NAME}" "InstallDir" "$INSTDIR"
SectionEnd
; After installation
Section -Post
ExecWait '"C:\Program Files (x86)\Windows Kits\10\bin\10.0.26100.0\x86\mt.exe" -manifest "$INSTDIR\crossdesk.manifest" -outputresource:"$INSTDIR\crossdesk.exe";1'
SectionEnd
Section "Cert"
@@ -66,37 +105,60 @@ Section "Cert"
SectionEnd
Section -AdditionalIcons
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݷ<EFBFBD>ʽ
; Desktop shortcut
CreateShortCut "$DESKTOP\${PRODUCT_NAME}.lnk" "$INSTDIR\crossdesk.exe" "" "$INSTDIR\crossdesk.ico"
; <EFBFBD><EFBFBD>ʼ<EFBFBD>˵<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݷ<EFBFBD>ʽ
; Start menu shortcut
CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}.lnk" "$INSTDIR\crossdesk.exe" "" "$INSTDIR\crossdesk.ico"
; <20><>ҳ<EFBFBD><D2B3><EFBFBD>ݷ<EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD>
WriteIniStr "$DESKTOP\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
SectionEnd
Section "Uninstall"
; ɾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>س<EFBFBD><EFBFBD><EFBFBD>
; Check if CrossDesk is running
StrCpy $1 "crossdesk.exe"
nsProcess::_FindProcess "$1"
Pop $R0
${If} $R0 = 0
MessageBox MB_ICONQUESTION|MB_YESNO "CrossDesk is running. Do you want to close it and uninstall?" IDYES closeApp IDNO cancelUninstall
${Else}
Goto uninstallApp
${EndIf}
closeApp:
nsProcess::_KillProcess "$1"
Pop $R0
Sleep 500
Goto uninstallApp
cancelUninstall:
SetDetailsPrint both
MessageBox MB_ICONEXCLAMATION|MB_OK "Uninstallation has been aborted."
Abort
uninstallApp:
; Delete main executable and uninstaller
Delete "$INSTDIR\crossdesk.exe"
Delete "$INSTDIR\uninstall.exe"
; <EFBFBD>ݹ<EFBFBD>ɾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>װĿ¼
; Recursively delete installation directory
RMDir /r "$INSTDIR"
; ɾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϳ<EFBFBD>ʼ<EFBFBD>˵<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݷ<EFBFBD>ʽ
; Delete desktop and start menu shortcuts
Delete "$DESKTOP\${PRODUCT_NAME}.lnk"
Delete "$DESKTOP\${PRODUCT_NAME}.url"
Delete "$SMPROGRAMS\${PRODUCT_NAME}.lnk"
; ɾ<EFBFBD><EFBFBD>ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
; Delete registry uninstall entry
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTALL_REG_KEY}"
; <EFBFBD>ݹ<EFBFBD>ɾ<EFBFBD><EFBFBD><EFBFBD>û<EFBFBD> AppData <20>е<EFBFBD> CrossDesk <20>ļ<EFBFBD><C4BC><EFBFBD>
; Delete remembered install dir
DeleteRegKey HKCU "Software\${PRODUCT_NAME}"
; Recursively delete CrossDesk folder in user AppData
RMDir /r "$APPDATA\CrossDesk"
RMDir /r "$LOCALAPPDATA\CrossDesk"
SectionEnd
Section -Post
SectionEnd
; ------ Functions ------
Function LaunchApp
Exec "$INSTDIR\crossdesk.exe"
FunctionEnd

View File

@@ -1,5 +1,7 @@
#include "config_center.h"
#include "rd_log.h"
ConfigCenter::ConfigCenter() {}
ConfigCenter::~ConfigCenter() {}
@@ -14,6 +16,11 @@ int ConfigCenter::SetVideoQuality(VIDEO_QUALITY video_quality) {
return 0;
}
int ConfigCenter::SetVideoFrameRate(VIDEO_FRAME_RATE video_frame_rate) {
video_frame_rate_ = video_frame_rate;
return 0;
}
int ConfigCenter::SetVideoEncodeFormat(
VIDEO_ENCODE_FORMAT video_encode_format) {
video_encode_format_ = video_encode_format;
@@ -30,16 +37,28 @@ int ConfigCenter::SetTurn(bool enable_turn) {
return 0;
}
int ConfigCenter::SetSrtp(bool enable_srtp) {
enable_srtp_ = enable_srtp;
return 0;
}
ConfigCenter::LANGUAGE ConfigCenter::GetLanguage() { return language_; }
ConfigCenter::VIDEO_QUALITY ConfigCenter::GetVideoQuality() {
return video_quality_;
}
int ConfigCenter::GetVideoFrameRate() {
int fps = video_frame_rate_ == VIDEO_FRAME_RATE::FPS_30 ? 30 : 60;
return fps;
}
ConfigCenter::VIDEO_ENCODE_FORMAT ConfigCenter::GetVideoEncodeFormat() {
return video_encode_format_;
}
bool ConfigCenter::IsHardwareVideoCodec() { return hardware_video_codec_; }
bool ConfigCenter::IsEnableTurn() { return enable_turn_; }
bool ConfigCenter::IsEnableTurn() { return enable_turn_; }
bool ConfigCenter::IsEnableSrtp() { return enable_srtp_; }

View File

@@ -11,6 +11,7 @@ class ConfigCenter {
public:
enum class LANGUAGE { CHINESE = 0, ENGLISH = 1 };
enum class VIDEO_QUALITY { LOW = 0, MEDIUM = 1, HIGH = 2 };
enum class VIDEO_FRAME_RATE { FPS_30 = 0, FPS_60 = 1 };
enum class VIDEO_ENCODE_FORMAT { AV1 = 0, H264 = 1 };
public:
@@ -20,24 +21,30 @@ class ConfigCenter {
public:
int SetLanguage(LANGUAGE language);
int SetVideoQuality(VIDEO_QUALITY video_quality);
int SetVideoFrameRate(VIDEO_FRAME_RATE video_frame_rate);
int SetVideoEncodeFormat(VIDEO_ENCODE_FORMAT video_encode_format);
int SetHardwareVideoCodec(bool hardware_video_codec);
int SetTurn(bool enable_turn);
int SetSrtp(bool enable_srtp);
public:
LANGUAGE GetLanguage();
VIDEO_QUALITY GetVideoQuality();
int GetVideoFrameRate();
VIDEO_ENCODE_FORMAT GetVideoEncodeFormat();
bool IsHardwareVideoCodec();
bool IsEnableTurn();
bool IsEnableSrtp();
private:
// Default value should be same with parameters in localization.h
LANGUAGE language_ = LANGUAGE::CHINESE;
VIDEO_QUALITY video_quality_ = VIDEO_QUALITY::MEDIUM;
VIDEO_FRAME_RATE video_frame_rate_ = VIDEO_FRAME_RATE::FPS_30;
VIDEO_ENCODE_FORMAT video_encode_format_ = VIDEO_ENCODE_FORMAT::AV1;
bool hardware_video_codec_ = false;
bool enable_turn_ = false;
bool enable_srtp_ = false;
};
#endif

View File

@@ -123,12 +123,44 @@ int KeyboardCapturer::Unhook() {
return 0;
}
inline bool IsFunctionKey(int key_code) {
switch (key_code) {
case 0x7A:
case 0x78:
case 0x63:
case 0x76:
case 0x60:
case 0x61:
case 0x62:
case 0x64:
case 0x65:
case 0x6D:
case 0x67:
case 0x6F:
return true;
default:
return false;
}
}
int KeyboardCapturer::SendKeyboardCommand(int key_code, bool is_down) {
if (vkCodeToCGKeyCode.find(key_code) != vkCodeToCGKeyCode.end()) {
CGKeyCode cg_key_code = vkCodeToCGKeyCode[key_code];
CGEventRef event = CGEventCreateKeyboardEvent(NULL, cg_key_code, is_down);
CGEventRef clearFlags =
CGEventCreateKeyboardEvent(NULL, (CGKeyCode)0, true);
CGEventSetFlags(clearFlags, 0);
CGEventPost(kCGHIDEventTap, event);
CFRelease(event);
// F1-F12 keys often require the FN key to be pressed on Mac keyboards, so
// we simulate the FN key release when an F1-F12 key is released.
if (IsFunctionKey(cg_key_code) && !is_down) {
CGEventRef fn_release_event =
CGEventCreateKeyboardEvent(NULL, fn_key_code_, false);
CGEventPost(kCGHIDEventTap, fn_release_event);
CFRelease(fn_release_event);
}
}
return 0;

View File

@@ -31,6 +31,7 @@ class KeyboardCapturer : public DeviceController {
bool control_flag_ = false;
bool option_flag_ = false;
bool command_flag_ = false;
int fn_key_code_ = 0x3F;
};
#endif

View File

@@ -247,58 +247,494 @@ std::map<int, int> CGKeyCodeToVkCode = {
// Windows vkCode to X11 KeySym
std::map<int, int> vkCodeToX11KeySym = {
{0x41, 0x0041}, {0x42, 0x0042}, {0x43, 0x0043}, {0x44, 0x0044},
{0x45, 0x0045}, {0x46, 0x0046}, {0x47, 0x0047}, {0x48, 0x0048},
{0x49, 0x0049}, {0x4A, 0x004A}, {0x4B, 0x004B}, {0x4C, 0x004C},
{0x4D, 0x004D}, {0x4E, 0x004E}, {0x4F, 0x004F}, {0x50, 0x0050},
{0x51, 0x0051}, {0x52, 0x0052}, {0x53, 0x0053}, {0x54, 0x0054},
{0x55, 0x0055}, {0x56, 0x0056}, {0x57, 0x0057}, {0x58, 0x0058},
{0x59, 0x0059}, {0x5A, 0x005A}, {0x30, 0x0030}, {0x31, 0x0031},
{0x32, 0x0032}, {0x33, 0x0033}, {0x34, 0x0034}, {0x35, 0x0035},
{0x36, 0x0036}, {0x37, 0x0037}, {0x38, 0x0038}, {0x39, 0x0039},
{0x1B, 0xFF1B}, {0x0D, 0xFF0D}, {0x20, 0x0020}, {0x08, 0xFF08},
{0x09, 0xFF09}, {0x25, 0xFF51}, {0x27, 0xFF53}, {0x26, 0xFF52},
{0x28, 0xFF54}, {0x70, 0xFFBE}, {0x71, 0xFFBF}, {0x72, 0xFFC0},
{0x73, 0xFFC1}, {0x74, 0xFFC2}, {0x75, 0xFFC3}, {0x76, 0xFFC4},
{0x77, 0xFFC5}, {0x78, 0xFFC6}, {0x79, 0xFFC7}, {0x7A, 0xFFC8},
{0x7B, 0xFFC9},
// A-Z
{0x41, 0x0041}, // A
{0x42, 0x0042}, // B
{0x43, 0x0043}, // C
{0x44, 0x0044}, // D
{0x45, 0x0045}, // E
{0x46, 0x0046}, // F
{0x47, 0x0047}, // G
{0x48, 0x0048}, // H
{0x49, 0x0049}, // I
{0x4A, 0x004A}, // J
{0x4B, 0x004B}, // K
{0x4C, 0x004C}, // L
{0x4D, 0x004D}, // M
{0x4E, 0x004E}, // N
{0x4F, 0x004F}, // O
{0x50, 0x0050}, // P
{0x51, 0x0051}, // Q
{0x52, 0x0052}, // R
{0x53, 0x0053}, // S
{0x54, 0x0054}, // T
{0x55, 0x0055}, // U
{0x56, 0x0056}, // V
{0x57, 0x0057}, // W
{0x58, 0x0058}, // X
{0x59, 0x0059}, // Y
{0x5A, 0x005A}, // Z
// 0-9
{0x30, 0x0030}, // 0
{0x31, 0x0031}, // 1
{0x32, 0x0032}, // 2
{0x33, 0x0033}, // 3
{0x34, 0x0034}, // 4
{0x35, 0x0035}, // 5
{0x36, 0x0036}, // 6
{0x37, 0x0037}, // 7
{0x38, 0x0038}, // 8
{0x39, 0x0039}, // 9
// F1-F12
{0x70, 0xFFBE}, // F1
{0x71, 0xFFBF}, // F2
{0x72, 0xFFC0}, // F3
{0x73, 0xFFC1}, // F4
{0x74, 0xFFC2}, // F5
{0x75, 0xFFC3}, // F6
{0x76, 0xFFC4}, // F7
{0x77, 0xFFC5}, // F8
{0x78, 0xFFC6}, // F9
{0x79, 0xFFC7}, // F10
{0x7A, 0xFFC8}, // F11
{0x7B, 0xFFC9}, // F12
// control keys
{0x1B, 0xFF1B}, // Escape
{0x0D, 0xFF0D}, // Enter
{0x20, 0x0020}, // Space
{0x08, 0xFF08}, // Backspace
{0x09, 0xFF09}, // Tab
{0x2C, 0xFF15}, // Print Screen
{0x91, 0xFF14}, // Scroll Lock
{0x13, 0xFF13}, // Pause/Break
{0x2D, 0xFF63}, // Insert
{0x2E, 0xFFFF}, // Delete
{0x24, 0xFF50}, // Home
{0x23, 0xFF57}, // End
{0x21, 0xFF55}, // Page Up
{0x22, 0xFF56}, // Page Down
// arrow keys
{0x25, 0xFF51}, // Left Arrow
{0x27, 0xFF53}, // Right Arrow
{0x26, 0xFF52}, // Up Arrow
{0x28, 0xFF54}, // Down Arrow
// numpad
{0x60, 0x0030}, // Numpad 0
{0x61, 0x0031}, // Numpad 1
{0x62, 0x0032}, // Numpad 2
{0x63, 0x0033}, // Numpad 3
{0x64, 0x0034}, // Numpad 4
{0x65, 0x0035}, // Numpad 5
{0x66, 0x0036}, // Numpad 6
{0x67, 0x0037}, // Numpad 7
{0x68, 0x0038}, // Numpad 8
{0x69, 0x0039}, // Numpad 9
{0x6E, 0x003A}, // Numpad .
{0x6F, 0x002F}, // Numpad /
{0x6A, 0x002A}, // Numpad *
{0x6D, 0x002D}, // Numpad -
{0x6B, 0x002B}, // Numpad +
// symbol keys
{0xBA, 0x003B}, // ; (Semicolon)
{0xDE, 0x0027}, // ' (Quote)
{0xC0, 0x007E}, // ` (Grave)
{0xBC, 0x002C}, // , (Comma)
{0xBE, 0x002E}, // . (Period)
{0xBF, 0x002F}, // / (Slash)
{0xDC, 0x005C}, // \ (Backslash)
{0xDB, 0x005B}, // [ (Left Bracket)
{0xDD, 0x005D}, // ] (Right Bracket)
{0xBD, 0x002D}, // - (Minus)
{0xBB, 0x003D}, // = (Equals)
// modifier keys
{0x14, 0xFFE5}, // Caps Lock
{0xA0, 0xFFE1}, // Shift (Left)
{0xA1, 0xFFE2}, // Shift (Right)
{0xA2, 0xFFE3}, // Ctrl (Left)
{0xA3, 0xFFE4}, // Ctrl (Right)
{0xA4, 0xFFE9}, // Alt (Left)
{0xA5, 0xFFEA}, // Alt (Right)
{0x5B, 0xFFEB}, // Left Command (Windows key)
{0x5C, 0xFFEC}, // Right Command
};
// X11 KeySym to Windows vkCode
std::map<int, int> x11KeySymToVkCode = []() {
std::map<int, int> result;
for (const auto& pair : vkCodeToX11KeySym) {
result[pair.second] = pair.first;
}
return result;
}();
// std::map<int, int> x11KeySymToVkCode = []() {
// std::map<int, int> result;
// for (const auto& pair : vkCodeToX11KeySym) {
// result[pair.second] = pair.first;
// }
// return result;
// }();
std::map<int, int> x11KeySymToVkCode = {
// A-Z
{0x0041, 0x41}, // A
{0x0042, 0x42}, // B
{0x0043, 0x43}, // C
{0x0044, 0x44}, // D
{0x0045, 0x45}, // E
{0x0046, 0x46}, // F
{0x0047, 0x47}, // G
{0x0048, 0x48}, // H
{0x0049, 0x49}, // I
{0x004A, 0x4A}, // J
{0x004B, 0x4B}, // K
{0x004C, 0x4C}, // L
{0x004D, 0x4D}, // M
{0x004E, 0x4E}, // N
{0x004F, 0x4F}, // O
{0x0050, 0x50}, // P
{0x0051, 0x51}, // Q
{0x0052, 0x52}, // R
{0x0053, 0x53}, // S
{0x0054, 0x54}, // T
{0x0055, 0x55}, // U
{0x0056, 0x56}, // V
{0x0057, 0x57}, // W
{0x0058, 0x58}, // X
{0x0059, 0x59}, // Y
{0x005A, 0x5A}, // Z
// 0-9
{0x0030, 0x30}, // 0
{0x0031, 0x31}, // 1
{0x0032, 0x32}, // 2
{0x0033, 0x33}, // 3
{0x0034, 0x34}, // 4
{0x0035, 0x35}, // 5
{0x0036, 0x36}, // 6
{0x0037, 0x37}, // 7
{0x0038, 0x38}, // 8
{0x0039, 0x39}, // 9
// F1-F12
{0xFFBE, 0x70}, // F1
{0xFFBF, 0x71}, // F2
{0xFFC0, 0x72}, // F3
{0xFFC1, 0x73}, // F4
{0xFFC2, 0x74}, // F5
{0xFFC3, 0x75}, // F6
{0xFFC4, 0x76}, // F7
{0xFFC5, 0x77}, // F8
{0xFFC6, 0x78}, // F9
{0xFFC7, 0x79}, // F10
{0xFFC8, 0x7A}, // F11
{0xFFC9, 0x7B}, // F12
// control keys
{0xFF1B, 0x1B}, // Escape
{0xFF0D, 0x0D}, // Enter
{0x0020, 0x20}, // Space
{0xFF08, 0x08}, // Backspace
{0xFF09, 0x09}, // Tab
{0xFF15, 0x2C}, // Print Screen
{0xFF14, 0x91}, // Scroll Lock
{0xFF13, 0x13}, // Pause/Break
{0xFF63, 0x2D}, // Insert
{0xFFFF, 0x2E}, // Delete
{0xFF50, 0x24}, // Home
{0xFF57, 0x23}, // End
{0xFF55, 0x21}, // Page Up
{0xFF56, 0x22}, // Page Down
// arrow keys
{0xFF51, 0x25}, // Left Arrow
{0xFF53, 0x27}, // Right Arrow
{0xFF52, 0x26}, // Up Arrow
{0xFF54, 0x28}, // Down Arrow
// numpad
{0x0030, 0x60}, // Numpad 0
{0x0031, 0x61}, // Numpad 1
{0x0032, 0x62}, // Numpad 2
{0x0033, 0x63}, // Numpad 3
{0x0034, 0x64}, // Numpad 4
{0x0035, 0x65}, // Numpad 5
{0x0036, 0x66}, // Numpad 6
{0x0037, 0x67}, // Numpad 7
{0x0038, 0x68}, // Numpad 8
{0x0039, 0x69}, // Numpad 9
{0x003A, 0x6E}, // Numpad .
{0x002F, 0x6F}, // Numpad /
{0x002A, 0x6A}, // Numpad *
{0x002D, 0x6D}, // Numpad -
{0x002B, 0x6B}, // Numpad +
// symbol keys
{0x003B, 0xBA}, // ; (Semicolon)
{0x0027, 0xDE}, // ' (Quote)
{0x007E, 0xC0}, // ` (Grave)
{0x002C, 0xBC}, // , (Comma)
{0x002E, 0xBE}, // . (Period)
{0x002F, 0xBF}, // / (Slash)
{0x005C, 0xDC}, // \ (Backslash)
{0x005B, 0xDB}, // [ (Left Bracket)
{0x005D, 0xDD}, // ] (Right Bracket)
{0x002D, 0xBD}, // - (Minus)
{0x003D, 0xBB}, // = (Equals)
// modifier keys
{0xFFE5, 0x14}, // Caps Lock
{0xFFE1, 0xA0}, // Shift (Left)
{0xFFE2, 0xA1}, // Shift (Right)
{0xFFE3, 0xA2}, // Ctrl (Left)
{0xFFE4, 0xA3}, // Ctrl (Right)
{0xFFE9, 0xA4}, // Alt (Left)
{0xFFEA, 0xA5}, // Alt (Right)
{0xFFEB, 0x5B}, // Left Command (Windows key)
{0xFFEC, 0x5C}, // Right Command
};
// macOS CGKeyCode to X11 KeySym
std::map<int, int> cgKeyCodeToX11KeySym = {
{0x00, 0x0041}, {0x0B, 0x0042}, {0x08, 0x0043}, {0x02, 0x0044},
{0x0E, 0x0045}, {0x03, 0x0046}, {0x05, 0x0047}, {0x04, 0x0048},
{0x22, 0x0049}, {0x26, 0x004A}, {0x28, 0x004B}, {0x25, 0x004C},
{0x2E, 0x004D}, {0x2D, 0x004E}, {0x1F, 0x004F}, {0x23, 0x0050},
{0x0C, 0x0051}, {0x0F, 0x0052}, {0x01, 0x0053}, {0x11, 0x0054},
{0x20, 0x0055}, {0x09, 0x0056}, {0x0D, 0x0057}, {0x07, 0x0058},
{0x10, 0x0059}, {0x06, 0x005A}, {0x12, 0x0031}, {0x13, 0x0032},
{0x14, 0x0033}, {0x15, 0x0034}, {0x17, 0x0035}, {0x16, 0x0036},
{0x1A, 0x0037}, {0x1C, 0x0038}, {0x19, 0x0039}, {0x1D, 0x0030},
{0x35, 0xFF1B}, {0x24, 0xFF0D}, {0x31, 0x0020}, {0x33, 0xFF08},
{0x30, 0xFF09}, {0x7B, 0xFF51}, {0x7C, 0xFF53}, {0x7E, 0xFF52},
{0x7D, 0xFF54}, {0x7A, 0xFFBE}, {0x78, 0xFFBF}, {0x63, 0xFFC0},
{0x76, 0xFFC1}, {0x60, 0xFFC2}, {0x61, 0xFFC3}, {0x62, 0xFFC4},
{0x64, 0xFFC5}, {0x65, 0xFFC6}, {0x6D, 0xFFC7}, {0x67, 0xFFC8},
{0x6F, 0xFFC9},
// A-Z
{0x00, 0x0041}, // A
{0x0B, 0x0042}, // B
{0x08, 0x0043}, // C
{0x02, 0x0044}, // D
{0x0E, 0x0045}, // E
{0x03, 0x0046}, // F
{0x05, 0x0047}, // G
{0x04, 0x0048}, // H
{0x22, 0x0049}, // I
{0x26, 0x004A}, // J
{0x28, 0x004B}, // K
{0x25, 0x004C}, // L
{0x2E, 0x004D}, // M
{0x2D, 0x004E}, // N
{0x1F, 0x004F}, // O
{0x23, 0x0050}, // P
{0x0C, 0x0051}, // Q
{0x0F, 0x0052}, // R
{0x01, 0x0053}, // S
{0x11, 0x0054}, // T
{0x20, 0x0055}, // U
{0x09, 0x0056}, // V
{0x0D, 0x0057}, // W
{0x07, 0x0058}, // X
{0x10, 0x0059}, // Y
{0x06, 0x005A}, // Z
// 0-9
{0x1D, 0x0030}, // 0
{0x12, 0x0031}, // 1
{0x13, 0x0032}, // 2
{0x14, 0x0033}, // 3
{0x15, 0x0034}, // 4
{0x17, 0x0035}, // 5
{0x16, 0x0036}, // 6
{0x1A, 0x0037}, // 7
{0x1C, 0x0038}, // 8
{0x19, 0x0039}, // 9
// F1-F12
{0x7A, 0xFFBE}, // F1
{0x78, 0xFFBF}, // F2
{0x63, 0xFFC0}, // F3
{0x76, 0xFFC1}, // F4
{0x60, 0xFFC2}, // F5
{0x61, 0xFFC3}, // F6
{0x62, 0xFFC4}, // F7
{0x64, 0xFFC5}, // F8
{0x65, 0xFFC6}, // F9
{0x6D, 0xFFC7}, // F10
{0x67, 0xFFC8}, // F11
{0x6F, 0xFFC9}, // F12
// control keys
{0x35, 0xFF1B}, // Escape
{0x24, 0xFF0D}, // Enter
{0x31, 0x0020}, // Space
{0x33, 0xFF08}, // Backspace
{0x30, 0xFF09}, // Tab
{0x74, 0xFF15}, // Print Screen
{0x72, 0xFF63}, // Insert
{0x75, 0xFFFF}, // Delete
{0x73, 0xFF50}, // Home
{0x77, 0xFF57}, // End
{0x79, 0xFF55}, // Page Up
{0x7A, 0xFF56}, // Page Down
// arrow keys
{0x7B, 0xFF51}, // Left Arrow
{0x7C, 0xFF53}, // Right Arrow
{0x7E, 0xFF52}, // Up Arrow
{0x7D, 0xFF54}, // Down Arrow
// numpad
{0x52, 0x0030}, // Numpad 0
{0x53, 0x0031}, // Numpad 1
{0x54, 0x0032}, // Numpad 2
{0x55, 0x0033}, // Numpad 3
{0x56, 0x0034}, // Numpad 4
{0x57, 0x0035}, // Numpad 5
{0x58, 0x0036}, // Numpad 6
{0x59, 0x0037}, // Numpad 7
{0x5B, 0x0038}, // Numpad 8
{0x5C, 0x0039}, // Numpad 9
{0x41, 0x003A}, // Numpad .
{0x4B, 0x002F}, // Numpad /
{0x43, 0x002A}, // Numpad *
{0x4E, 0x002D}, // Numpad -
{0x45, 0x002B}, // Numpad +
// symbol keys
{0x29, 0x003B}, // ; (Semicolon)
{0x27, 0x0027}, // ' (Quote)
{0x32, 0x007E}, // ` (Backtick)
{0x2B, 0x002C}, // , (Comma)
{0x2F, 0x002E}, // . (Period)
{0x2C, 0x002F}, // / (Slash)
{0x2A, 0x005C}, // \ (Backslash)
{0x21, 0x005B}, // [ (Left Bracket)
{0x1E, 0x005D}, // ] (Right Bracket)
{0x1B, 0x002D}, // - (Minus)
{0x18, 0x003D}, // = (Equals)
// modifier keys
{0x39, 0xFFE5}, // Caps Lock
{0x38, 0xFFE1}, // Shift (Left)
{0x3C, 0xFFE2}, // Shift (Right)
{0x3B, 0xFFE3}, // Control (Left)
{0x3E, 0xFFE4}, // Control (Right)
{0x3A, 0xFFE9}, // Alt (Left)
{0x3D, 0xFFEA}, // Alt (Right)
{0x37, 0xFFEB}, // Left Command (Windows key)
{0x36, 0xFFEC}, // Right Command
};
// X11 KeySym to macOS CGKeyCode
std::map<int, int> x11KeySymToCgKeyCode = []() {
std::map<int, int> result;
for (const auto& pair : cgKeyCodeToX11KeySym) {
result[pair.second] = pair.first;
}
return result;
}();
// std::map<int, int> x11KeySymToCgKeyCode = []() {
// std::map<int, int> result;
// for (const auto& pair : cgKeyCodeToX11KeySym) {
// result[pair.second] = pair.first;
// }
// return result;
// }();
std::map<int, int> x11KeySymToCgKeyCode = {
// A-Z
{0x0041, 0x00}, // A
{0x0042, 0x0B}, // B
{0x0043, 0x08}, // C
{0x0044, 0x02}, // D
{0x0045, 0x0E}, // E
{0x0046, 0x03}, // F
{0x0047, 0x05}, // G
{0x0048, 0x04}, // H
{0x0049, 0x22}, // I
{0x004A, 0x26}, // J
{0x004B, 0x28}, // K
{0x004C, 0x25}, // L
{0x004D, 0x2E}, // M
{0x004E, 0x2D}, // N
{0x004F, 0x1F}, // O
{0x0050, 0x23}, // P
{0x0051, 0x0C}, // Q
{0x0052, 0x0F}, // R
{0x0053, 0x01}, // S
{0x0054, 0x11}, // T
{0x0055, 0x20}, // U
{0x0056, 0x09}, // V
{0x0057, 0x0D}, // W
{0x0058, 0x07}, // X
{0x0059, 0x10}, // Y
{0x005A, 0x06}, // Z
// 0-9
{0x0030, 0x1D}, // 0
{0x0031, 0x12}, // 1
{0x0032, 0x13}, // 2
{0x0033, 0x14}, // 3
{0x0034, 0x15}, // 4
{0x0035, 0x17}, // 5
{0x0036, 0x16}, // 6
{0x0037, 0x1A}, // 7
{0x0038, 0x1C}, // 8
{0x0039, 0x19}, // 9
// F1-F12
{0xFFBE, 0x7A}, // F1
{0xFFBF, 0x78}, // F2
{0xFFC0, 0x63}, // F3
{0xFFC1, 0x76}, // F4
{0xFFC2, 0x60}, // F5
{0xFFC3, 0x61}, // F6
{0xFFC4, 0x62}, // F7
{0xFFC5, 0x64}, // F8
{0xFFC6, 0x65}, // F9
{0xFFC7, 0x6D}, // F10
{0xFFC8, 0x67}, // F11
{0xFFC9, 0x6F}, // F12
// control keys
{0xFF1B, 0x35}, // Escape
{0xFF0D, 0x24}, // Enter
{0x0020, 0x31}, // Space
{0xFF08, 0x33}, // Backspace
{0xFF09, 0x30}, // Tab
{0xFF15, 0x74}, // Print Screen
{0xFF63, 0x72}, // Insert
{0xFFFF, 0x75}, // Delete
{0xFF50, 0x73}, // Home
{0xFF57, 0x77}, // End
{0xFF55, 0x79}, // Page Up
{0xFF56, 0x7A}, // Page Down
// arrow keys
{0xFF51, 0x7B}, // Left Arrow
{0xFF53, 0x7C}, // Right Arrow
{0xFF52, 0x7E}, // Up Arrow
{0xFF54, 0x7D}, // Down Arrow
// numpad
{0x0030, 0x52}, // Numpad 0
{0x0031, 0x53}, // Numpad 1
{0x0032, 0x54}, // Numpad 2
{0x0033, 0x55}, // Numpad 3
{0x0034, 0x56}, // Numpad 4
{0x0035, 0x57}, // Numpad 5
{0x0036, 0x58}, // Numpad 6
{0x0037, 0x59}, // Numpad 7
{0x0038, 0x5B}, // Numpad 8
{0x0039, 0x5C}, // Numpad 9
{0x003A, 0x41}, // Numpad .
{0x002F, 0x4B}, // Numpad /
{0x002A, 0x43}, // Numpad *
{0x002D, 0x4E}, // Numpad -
{0x002B, 0x45}, // Numpad +
// symbol keys
{0x003B, 0x29}, // ; (Semicolon)
{0x0027, 0x27}, // ' (Quote)
{0x007E, 0x32}, // ` (Backtick)
{0x002C, 0x2B}, // , (Comma)
{0x002E, 0x2F}, // . (Period)
{0x002F, 0x2C}, // / (Slash)
{0x005C, 0x2A}, // \ (Backslash)
{0x005B, 0x21}, // [ (Left Bracket)
{0x005D, 0x1E}, // ] (Right Bracket)
{0x002D, 0x1B}, // - (Minus)
{0x003D, 0x18}, // = (Equals)
// modifier keys
{0xFFE5, 0x39}, // Caps Lock
{0xFFE1, 0x38}, // Shift (Left)
{0xFFE2, 0x3C}, // Shift (Right)
{0xFFE3, 0x3B}, // Control (Left)
{0xFFE4, 0x3E}, // Control (Right)
{0xFFE9, 0x3A}, // Alt (Left)
{0xFFEA, 0x3D}, // Alt (Right)
{0xFFEB, 0x37}, // Left Command
{0xFFEC, 0x36}, // Right Command
};
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,861 @@
/*
File: HIToolbox/Events.h
Contains: Event Manager Interfaces.
Copyright: 锟<> 1985-2008 by Apple Computer, Inc., all rights reserved
Bugs?: For bug reports, consult the following page on
the World Wide Web:
http://developer.apple.com/bugreporter/
*/
#ifndef __EVENTS__
#define __EVENTS__
#ifndef __APPLICATIONSERVICES__
#include <ApplicationServices/ApplicationServices.h>
#endif
#include <AvailabilityMacros.h>
#if PRAGMA_ONCE
#pragma once
#endif
#ifdef __cplusplus
extern "C" {
#endif
#pragma pack(push, 2)
typedef UInt16 EventKind;
typedef UInt16 EventMask;
enum {
nullEvent = 0,
mouseDown = 1,
mouseUp = 2,
keyDown = 3,
keyUp = 4,
autoKey = 5,
updateEvt = 6,
diskEvt = 7, /* Not sent in Carbon. See kEventClassVolume in CarbonEvents.h*/
activateEvt = 8,
osEvt = 15,
kHighLevelEvent = 23
};
enum {
mDownMask = 1 << mouseDown, /* mouse button pressed*/
mUpMask = 1 << mouseUp, /* mouse button released*/
keyDownMask = 1 << keyDown, /* key pressed*/
keyUpMask = 1 << keyUp, /* key released*/
autoKeyMask = 1 << autoKey, /* key repeatedly held down*/
updateMask = 1 << updateEvt, /* window needs updating*/
diskMask = 1 << diskEvt, /* disk inserted*/
activMask = 1 << activateEvt, /* activate/deactivate window*/
highLevelEventMask = 0x0400, /* high-level events (includes AppleEvents)*/
osMask = 1 << osEvt, /* operating system events (suspend, resume)*/
everyEvent = 0xFFFF /* all of the above*/
};
enum {
charCodeMask = 0x000000FF,
keyCodeMask = 0x0000FF00,
adbAddrMask = 0x00FF0000,
osEvtMessageMask = (UInt32)0xFF000000
};
enum {
/* OS event messages. Event (sub)code is in the high byte of the message
field.*/
mouseMovedMessage = 0x00FA,
suspendResumeMessage = 0x0001
};
enum {
resumeFlag = 1 /* Bit 0 of message indicates resume vs suspend*/
};
#if CALL_NOT_IN_CARBON
/* convertClipboardFlag is not ever set under Carbon. This is because scrap
* conversion is */
/* not tied to suspend/resume events any longer. Your application should
* instead use the */
/* scrap promise mechanism and fulfill scrap requests only when your promise
* keeper proc */
/* is called. If you need to know if the scrap has changed, you can cache the
* last */
/* ScrapRef you received and compare it with the current ScrapRef */
enum {
convertClipboardFlag =
2 /* Bit 1 in resume message indicates clipboard change*/
};
#endif /* CALL_NOT_IN_CARBON */
/*
CARBON ALERT! BATTLESTATIONS!
The EventModifiers bits defined here are also used in the newer Carbon Event
key modifiers parameters. There are two main differences:
1) The Carbon key modifiers parameter is a UInt32, not a UInt16. Never try
to extract the key modifiers parameter from a Carbon Event into an
EventModifiers type. You will probably get your stack trashed. 2) The Carbon
key modifiers is just that: key modifiers. That parameter will never contain
the button state bit.
*/
typedef UInt16 EventModifiers;
enum {
/* modifiers */
activeFlagBit = 0, /* activate? (activateEvt and mouseDown)*/
btnStateBit = 7, /* state of button?*/
cmdKeyBit = 8, /* command key down?*/
shiftKeyBit = 9, /* shift key down?*/
alphaLockBit = 10, /* alpha lock down?*/
optionKeyBit = 11, /* option key down?*/
controlKeyBit = 12, /* control key down?*/
rightShiftKeyBit = 13, /* right shift key down? Not supported on Mac OS X.*/
rightOptionKeyBit = 14, /* right Option key down? Not supported on Mac OS X.*/
rightControlKeyBit =
15 /* right Control key down? Not supported on Mac OS X.*/
};
enum {
activeFlag = 1 << activeFlagBit,
btnState = 1 << btnStateBit,
cmdKey = 1 << cmdKeyBit,
shiftKey = 1 << shiftKeyBit,
alphaLock = 1 << alphaLockBit,
optionKey = 1 << optionKeyBit,
controlKey = 1 << controlKeyBit,
rightShiftKey = 1 << rightShiftKeyBit, /* Not supported on Mac OS X.*/
rightOptionKey = 1 << rightOptionKeyBit, /* Not supported on Mac OS X.*/
rightControlKey = 1 << rightControlKeyBit /* Not supported on Mac OS X.*/
};
/* MacRoman character codes*/
enum {
kNullCharCode = 0,
kHomeCharCode = 1,
kEnterCharCode = 3,
kEndCharCode = 4,
kHelpCharCode = 5,
kBellCharCode = 7,
kBackspaceCharCode = 8,
kTabCharCode = 9,
kLineFeedCharCode = 10,
kVerticalTabCharCode = 11,
kPageUpCharCode = 11,
kFormFeedCharCode = 12,
kPageDownCharCode = 12,
kReturnCharCode = 13,
kFunctionKeyCharCode = 16,
kCommandCharCode = 17, /* glyph available only in system fonts*/
kCheckCharCode = 18, /* glyph available only in system fonts*/
kDiamondCharCode = 19, /* glyph available only in system fonts*/
kAppleLogoCharCode = 20, /* glyph available only in system fonts*/
kEscapeCharCode = 27,
kClearCharCode = 27,
kLeftArrowCharCode = 28,
kRightArrowCharCode = 29,
kUpArrowCharCode = 30,
kDownArrowCharCode = 31,
kSpaceCharCode = 32,
kDeleteCharCode = 127,
kBulletCharCode = 165,
kNonBreakingSpaceCharCode = 202
};
/* useful Unicode code points*/
enum {
kShiftUnicode = 0x21E7, /* Unicode UPWARDS WHITE ARROW*/
kControlUnicode = 0x2303, /* Unicode UP ARROWHEAD*/
kOptionUnicode = 0x2325, /* Unicode OPTION KEY*/
kCommandUnicode = 0x2318, /* Unicode PLACE OF INTEREST SIGN*/
kPencilUnicode = 0x270E, /* Unicode LOWER RIGHT PENCIL; actually pointed left
until Mac OS X 10.3*/
kPencilLeftUnicode = 0xF802, /* Unicode LOWER LEFT PENCIL; available in Mac OS
X 10.3 and later*/
kCheckUnicode = 0x2713, /* Unicode CHECK MARK*/
kDiamondUnicode = 0x25C6, /* Unicode BLACK DIAMOND*/
kBulletUnicode = 0x2022, /* Unicode BULLET*/
kAppleLogoUnicode = 0xF8FF /* Unicode APPLE LOGO*/
};
/*
* Summary:
* Virtual keycodes
*
* Discussion:
* These constants are the virtual keycodes defined originally in
* Inside Mac Volume V, pg. V-191. They identify physical keys on a
* keyboard. Those constants with "ANSI" in the name are labeled
* according to the key position on an ANSI-standard US keyboard.
* For example, kVK_ANSI_A indicates the virtual keycode for the key
* with the letter 'A' in the US keyboard layout. Other keyboard
* layouts may have the 'A' key label on a different physical key;
* in this case, pressing 'A' will generate a different virtual
* keycode.
*/
enum {
kVK_ANSI_A = 0x00,
kVK_ANSI_S = 0x01,
kVK_ANSI_D = 0x02,
kVK_ANSI_F = 0x03,
kVK_ANSI_H = 0x04,
kVK_ANSI_G = 0x05,
kVK_ANSI_Z = 0x06,
kVK_ANSI_X = 0x07,
kVK_ANSI_C = 0x08,
kVK_ANSI_V = 0x09,
kVK_ANSI_B = 0x0B,
kVK_ANSI_Q = 0x0C,
kVK_ANSI_W = 0x0D,
kVK_ANSI_E = 0x0E,
kVK_ANSI_R = 0x0F,
kVK_ANSI_Y = 0x10,
kVK_ANSI_T = 0x11,
kVK_ANSI_1 = 0x12,
kVK_ANSI_2 = 0x13,
kVK_ANSI_3 = 0x14,
kVK_ANSI_4 = 0x15,
kVK_ANSI_6 = 0x16,
kVK_ANSI_5 = 0x17,
kVK_ANSI_Equal = 0x18,
kVK_ANSI_9 = 0x19,
kVK_ANSI_7 = 0x1A,
kVK_ANSI_Minus = 0x1B,
kVK_ANSI_8 = 0x1C,
kVK_ANSI_0 = 0x1D,
kVK_ANSI_RightBracket = 0x1E,
kVK_ANSI_O = 0x1F,
kVK_ANSI_U = 0x20,
kVK_ANSI_LeftBracket = 0x21,
kVK_ANSI_I = 0x22,
kVK_ANSI_P = 0x23,
kVK_ANSI_L = 0x25,
kVK_ANSI_J = 0x26,
kVK_ANSI_Quote = 0x27,
kVK_ANSI_K = 0x28,
kVK_ANSI_Semicolon = 0x29,
kVK_ANSI_Backslash = 0x2A,
kVK_ANSI_Comma = 0x2B,
kVK_ANSI_Slash = 0x2C,
kVK_ANSI_N = 0x2D,
kVK_ANSI_M = 0x2E,
kVK_ANSI_Period = 0x2F,
kVK_ANSI_Grave = 0x32,
kVK_ANSI_KeypadDecimal = 0x41,
kVK_ANSI_KeypadMultiply = 0x43,
kVK_ANSI_KeypadPlus = 0x45,
kVK_ANSI_KeypadClear = 0x47,
kVK_ANSI_KeypadDivide = 0x4B,
kVK_ANSI_KeypadEnter = 0x4C,
kVK_ANSI_KeypadMinus = 0x4E,
kVK_ANSI_KeypadEquals = 0x51,
kVK_ANSI_Keypad0 = 0x52,
kVK_ANSI_Keypad1 = 0x53,
kVK_ANSI_Keypad2 = 0x54,
kVK_ANSI_Keypad3 = 0x55,
kVK_ANSI_Keypad4 = 0x56,
kVK_ANSI_Keypad5 = 0x57,
kVK_ANSI_Keypad6 = 0x58,
kVK_ANSI_Keypad7 = 0x59,
kVK_ANSI_Keypad8 = 0x5B,
kVK_ANSI_Keypad9 = 0x5C
};
/* keycodes for keys that are independent of keyboard layout*/
enum {
kVK_Return = 0x24,
kVK_Tab = 0x30,
kVK_Space = 0x31,
kVK_Delete = 0x33,
kVK_Escape = 0x35,
kVK_Command = 0x37,
kVK_Shift = 0x38,
kVK_CapsLock = 0x39,
kVK_Option = 0x3A,
kVK_Control = 0x3B,
kVK_RightCommand = 0x36,
kVK_RightShift = 0x3C,
kVK_RightOption = 0x3D,
kVK_RightControl = 0x3E,
kVK_Function = 0x3F,
kVK_F17 = 0x40,
kVK_VolumeUp = 0x48,
kVK_VolumeDown = 0x49,
kVK_Mute = 0x4A,
kVK_F18 = 0x4F,
kVK_F19 = 0x50,
kVK_F20 = 0x5A,
kVK_F5 = 0x60,
kVK_F6 = 0x61,
kVK_F7 = 0x62,
kVK_F3 = 0x63,
kVK_F8 = 0x64,
kVK_F9 = 0x65,
kVK_F11 = 0x67,
kVK_F13 = 0x69,
kVK_F16 = 0x6A,
kVK_F14 = 0x6B,
kVK_F10 = 0x6D,
kVK_ContextualMenu = 0x6E,
kVK_F12 = 0x6F,
kVK_F15 = 0x71,
kVK_Help = 0x72,
kVK_Home = 0x73,
kVK_PageUp = 0x74,
kVK_ForwardDelete = 0x75,
kVK_F4 = 0x76,
kVK_End = 0x77,
kVK_F2 = 0x78,
kVK_PageDown = 0x79,
kVK_F1 = 0x7A,
kVK_LeftArrow = 0x7B,
kVK_RightArrow = 0x7C,
kVK_DownArrow = 0x7D,
kVK_UpArrow = 0x7E
};
/* ISO keyboards only*/
enum { kVK_ISO_Section = 0x0A };
/* JIS keyboards only*/
enum {
kVK_JIS_Yen = 0x5D,
kVK_JIS_Underscore = 0x5E,
kVK_JIS_KeypadComma = 0x5F,
kVK_JIS_Eisu = 0x66,
kVK_JIS_Kana = 0x68
};
struct EventRecord {
EventKind what;
unsigned long message;
UInt32 when;
Point where;
EventModifiers modifiers;
};
typedef struct EventRecord EventRecord;
typedef CALLBACK_API(void, FKEYProcPtr)(void);
typedef STACK_UPP_TYPE(FKEYProcPtr) FKEYUPP;
/*
* NewFKEYUPP()
*
* Availability:
* Mac OS X: not available
* CarbonLib: not available
* Non-Carbon CFM: available as macro/inline
*/
/*
* DisposeFKEYUPP()
*
* Availability:
* Mac OS X: not available
* CarbonLib: not available
* Non-Carbon CFM: available as macro/inline
*/
/*
* InvokeFKEYUPP()
*
* Availability:
* Mac OS X: not available
* CarbonLib: not available
* Non-Carbon CFM: available as macro/inline
*/
#if !__LP64__
/*
* GetMouse() *** DEPRECATED ***
*
* Deprecated:
* Use HIGetMousePosition instead.
*
* Mac OS X threading:
* Not thread safe
*
* Availability:
* Mac OS X: in version 10.0 and later in Carbon.framework [32-bit
* only] but deprecated in 10.5 CarbonLib: in CarbonLib 1.0 and later
* Non-Carbon CFM: in InterfaceLib 7.1 and later
*/
extern void GetMouse(Point *mouseLoc)
AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5;
#endif /* !__LP64__ */
/*
* Button() *** DEPRECATED ***
*
* Deprecated:
* Use GetCurrentButtonState or GetCurrentEventButtonState instead.
*
* Mac OS X threading:
* Not thread safe
*
* Availability:
* Mac OS X: in version 10.0 and later in Carbon.framework but
* deprecated in 10.6 CarbonLib: in CarbonLib 1.0 and later Non-Carbon
* CFM: in InterfaceLib 7.1 and later
*/
extern Boolean Button(void)
AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6;
#if !__LP64__
/*
* StillDown()
*
* Mac OS X threading:
* Not thread safe
*
* Availability:
* Mac OS X: in version 10.0 and later in Carbon.framework [32-bit
* only] CarbonLib: in CarbonLib 1.0 and later Non-Carbon CFM: in
* InterfaceLib 7.1 and later
*/
extern Boolean StillDown(void) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER;
/*
* WaitMouseUp()
*
* Mac OS X threading:
* Not thread safe
*
* Availability:
* Mac OS X: in version 10.0 and later in Carbon.framework [32-bit
* only] CarbonLib: in CarbonLib 1.0 and later Non-Carbon CFM: in
* InterfaceLib 7.1 and later
*/
extern Boolean WaitMouseUp(void) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER;
/*
* KeyTranslate() *** DEPRECATED ***
*
* Deprecated:
* Use UCKeyTranslate instead.
*
* Mac OS X threading:
* Not thread safe
*
* Availability:
* Mac OS X: in version 10.0 and later in Carbon.framework [32-bit
* only] but deprecated in 10.6 CarbonLib: in CarbonLib 1.0 and later
* Non-Carbon CFM: in InterfaceLib 7.1 and later
*/
extern UInt32 KeyTranslate(const void *transData, UInt16 keycode, UInt32 *state)
AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6;
/*
* GetCaretTime()
*
* Mac OS X threading:
* Not thread safe
*
* Availability:
* Mac OS X: in version 10.0 and later in Carbon.framework [32-bit
* only] CarbonLib: in CarbonLib 1.0 and later Non-Carbon CFM: in
* InterfaceLib 7.1 and later
*/
extern UInt32 GetCaretTime(void) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER;
#endif /* !__LP64__ */
/*
QuickTime 3.0 supports GetKeys() on unix and win32
But, on little endian machines you will have to be
careful about bit numberings and/or use a KeyMapByteArray
instead.
*/
#if TARGET_API_MAC_OS8
typedef UInt32 KeyMap[4];
#else
typedef BigEndianUInt32 KeyMap[4];
#endif /* TARGET_API_MAC_OS8 */
typedef UInt8 KeyMapByteArray[16];
/*
* GetKeys()
*
* Mac OS X threading:
* Not thread safe
*
* Availability:
* Mac OS X: in version 10.0 and later in Carbon.framework
* CarbonLib: in CarbonLib 1.0 and later
* Non-Carbon CFM: in InterfaceLib 7.1 and later
*/
extern void GetKeys(KeyMap theKeys) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER;
/* Obsolete event types & masks */
enum {
networkEvt = 10,
driverEvt = 11,
app1Evt = 12,
app2Evt = 13,
app3Evt = 14,
app4Evt = 15,
networkMask = 0x0400,
driverMask = 0x0800,
app1Mask = 0x1000,
app2Mask = 0x2000,
app3Mask = 0x4000,
app4Mask = 0x8000
};
struct EvQEl {
QElemPtr qLink;
SInt16 qType;
EventKind
evtQWhat; /* this part is identical to the EventRecord as defined above */
unsigned long evtQMessage;
UInt32 evtQWhen;
Point evtQWhere;
EventModifiers evtQModifiers;
};
typedef struct EvQEl EvQEl;
typedef EvQEl *EvQElPtr;
typedef CALLBACK_API(void, GetNextEventFilterProcPtr)(EventRecord *theEvent,
Boolean *result);
typedef STACK_UPP_TYPE(GetNextEventFilterProcPtr) GetNextEventFilterUPP;
/*
* NewGetNextEventFilterUPP()
*
* Availability:
* Mac OS X: not available
* CarbonLib: not available
* Non-Carbon CFM: available as macro/inline
*/
/*
* DisposeGetNextEventFilterUPP()
*
* Availability:
* Mac OS X: not available
* CarbonLib: not available
* Non-Carbon CFM: available as macro/inline
*/
/*
* InvokeGetNextEventFilterUPP()
*
* Availability:
* Mac OS X: not available
* CarbonLib: not available
* Non-Carbon CFM: available as macro/inline
*/
typedef GetNextEventFilterUPP GNEFilterUPP;
#if !__LP64__
/*
* GetDblTime()
*
* Summary:
* Returns the maximum time (in units of 1/60th of a second) allowed
* between two consecutive mouse-down events in order for the second
* click to be considered a double-click.
*
* Discussion:
* In 64-bit applications, you may replace calls to this API with
* calls to NXClickTime (declared in
* <IOKit/hidsystem/event_status_driver.h>) or with +[NSEvent
* doubleClickInterval] (available in Mac OS X 10.6 and later).
*
* Mac OS X threading:
* Not thread safe
*
* Result:
* The maximum time between mouse-downs allowed for a double-click.
*
* Availability:
* Mac OS X: in version 10.0 and later in Carbon.framework [32-bit
* only] CarbonLib: in CarbonLib 1.0 and later Non-Carbon CFM: in
* InterfaceLib 7.1 and later
*/
extern UInt32 GetDblTime(void) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER;
/*
* SetEventMask()
*
* Mac OS X threading:
* Not thread safe
*
* Availability:
* Mac OS X: in version 10.0 and later in Carbon.framework [32-bit
* only] CarbonLib: in CarbonLib 1.0 and later Non-Carbon CFM: in
* InterfaceLib 7.1 and later
*/
extern void SetEventMask(EventMask value)
AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER;
/*
* GetNextEvent() *** DEPRECATED ***
*
* Deprecated:
* Use ReceiveNextEvent instead.
*
* Mac OS X threading:
* Not thread safe
*
* Availability:
* Mac OS X: in version 10.0 and later in Carbon.framework [32-bit
* only] but deprecated in 10.6 CarbonLib: in CarbonLib 1.0 and later
* Non-Carbon CFM: in InterfaceLib 7.1 and later
*/
extern Boolean GetNextEvent(EventMask eventMask, EventRecord *theEvent)
AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6;
/*
* WaitNextEvent() *** DEPRECATED ***
*
* Deprecated:
* Use ReceiveNextEvent instead.
*
* Mac OS X threading:
* Not thread safe
*
* Availability:
* Mac OS X: in version 10.0 and later in Carbon.framework [32-bit
* only] but deprecated in 10.6 CarbonLib: in CarbonLib 1.0 and later
* Non-Carbon CFM: in InterfaceLib 7.1 and later
*/
extern Boolean WaitNextEvent(EventMask eventMask, EventRecord *theEvent,
UInt32 sleep, RgnHandle mouseRgn) /* can be NULL */
AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6;
/*
* EventAvail() *** DEPRECATED ***
*
* Deprecated:
* Use FindSpecificEventInQueue instead.
*
* Mac OS X threading:
* Not thread safe
*
* Availability:
* Mac OS X: in version 10.0 and later in Carbon.framework [32-bit
* only] but deprecated in 10.6 CarbonLib: in CarbonLib 1.0 and later
* Non-Carbon CFM: in InterfaceLib 7.1 and later
*/
extern Boolean EventAvail(EventMask eventMask, EventRecord *theEvent)
AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6;
/*
* PostEvent() *** DEPRECATED ***
*
* Deprecated:
* Use PostEventToQueue or CGEventPost instead.
*
* Mac OS X threading:
* Not thread safe
*
* Availability:
* Mac OS X: in version 10.0 and later in Carbon.framework [32-bit
* only] but deprecated in 10.6 CarbonLib: in CarbonLib 1.0 and later
* Non-Carbon CFM: in InterfaceLib 7.1 and later
*/
extern OSErr PostEvent(EventKind eventNum, UInt32 eventMsg)
AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6;
#endif /* !__LP64__ */
/*
* FlushEvents() *** DEPRECATED ***
*
* Deprecated:
* Use FlushEventsMatchingListFromQueue,
* FlushSpecificEventsFromQueue, or FlushEventQueue instead.
*
* Mac OS X threading:
* Not thread safe
*
* Availability:
* Mac OS X: in version 10.0 and later in Carbon.framework but
* deprecated in 10.6 CarbonLib: in CarbonLib 1.0 and later Non-Carbon
* CFM: in InterfaceLib 7.1 and later
*/
extern void FlushEvents(EventMask whichMask, EventMask stopMask)
AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6;
#if OLDROUTINENAMES
#define KeyTrans(transData, keycode, state) \
KeyTranslate(transData, keycode, state)
#endif /* OLDROUTINENAMES */
#if !__LP64__
/*
* KeyScript() *** DEPRECATED ***
*
* Deprecated:
* Use TISSelectInputSource API for positive verbs (ScriptCode).
* Use TSMDocument properties to restrict input sources:
* kTSMDocumentEnabledInputSourcesPropertyTag
* kTSMDocumentInputSourceOverridePropertyTag
*
* Summary:
* Switch to the specified script's default (last used) input source.
*
* Mac OS X threading:
* Not thread safe
*
* Availability:
* Mac OS X: in version 10.0 and later in Carbon.framework [32-bit
* only] but deprecated in 10.5 CarbonLib: in CarbonLib 1.0 and later
* Non-Carbon CFM: in InterfaceLib 7.1 and later
*/
extern void KeyScript(short code)
AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5;
#endif /* !__LP64__ */
/*
* IsCmdChar() *** DEPRECATED ***
*
* Deprecated:
* Use IsUserCancelEventRef or CheckEventQueueForUserCancel instead.
*
* Mac OS X threading:
* Not thread safe
*
* Availability:
* Mac OS X: in version 10.0 and later in Carbon.framework but
* deprecated in 10.6 CarbonLib: in CarbonLib 1.0 and later Non-Carbon
* CFM: in InterfaceLib 7.1 and later
*/
extern Boolean IsCmdChar(const EventRecord *event, short test)
AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6;
/*
LowMem accessor functions previously in LowMem.h
*/
/*
* LMGetKeyThresh()
*
* Mac OS X threading:
* Not thread safe
*
* Availability:
* Mac OS X: in version 10.0 and later in Carbon.framework
* CarbonLib: in CarbonLib 1.0 and later
* Non-Carbon CFM: in InterfaceLib 7.1 and later
*/
extern SInt16 LMGetKeyThresh(void) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER;
#if !__LP64__
/*
* LMSetKeyThresh()
*
* Mac OS X threading:
* Not thread safe
*
* Availability:
* Mac OS X: in version 10.0 and later in Carbon.framework [32-bit
* only] CarbonLib: in CarbonLib 1.0 and later Non-Carbon CFM: in
* InterfaceLib 7.1 and later
*/
extern void LMSetKeyThresh(SInt16 value)
AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER;
#endif /* !__LP64__ */
/*
* LMGetKeyRepThresh()
*
* Mac OS X threading:
* Not thread safe
*
* Availability:
* Mac OS X: in version 10.0 and later in Carbon.framework
* CarbonLib: in CarbonLib 1.0 and later
* Non-Carbon CFM: in InterfaceLib 7.1 and later
*/
extern SInt16 LMGetKeyRepThresh(void) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER;
#if !__LP64__
/*
* LMSetKeyRepThresh()
*
* Mac OS X threading:
* Not thread safe
*
* Availability:
* Mac OS X: in version 10.0 and later in Carbon.framework [32-bit
* only] CarbonLib: in CarbonLib 1.0 and later Non-Carbon CFM: in
* InterfaceLib 7.1 and later
*/
extern void LMSetKeyRepThresh(SInt16 value)
AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER;
#endif /* !__LP64__ */
/*
* LMGetKbdLast()
*
* Mac OS X threading:
* Not thread safe
*
* Availability:
* Mac OS X: in version 10.0 and later in Carbon.framework
* CarbonLib: in CarbonLib 1.0 and later
* Non-Carbon CFM: in InterfaceLib 7.1 and later
*/
extern UInt8 LMGetKbdLast(void) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER;
#if !__LP64__
/*
* LMSetKbdLast()
*
* Mac OS X threading:
* Not thread safe
*
* Availability:
* Mac OS X: in version 10.0 and later in Carbon.framework [32-bit
* only] CarbonLib: in CarbonLib 1.0 and later Non-Carbon CFM: in
* InterfaceLib 7.1 and later
*/
extern void LMSetKbdLast(UInt8 value) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER;
#endif /* !__LP64__ */
/*
* LMGetKbdType()
*
* Mac OS X threading:
* Not thread safe
*
* Availability:
* Mac OS X: in version 10.0 and later in Carbon.framework
* CarbonLib: in CarbonLib 1.0 and later
* Non-Carbon CFM: in InterfaceLib 7.1 and later
*/
extern UInt8 LMGetKbdType(void) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER;
#if !__LP64__
/*
* LMSetKbdType()
*
* Mac OS X threading:
* Not thread safe
*
* Availability:
* Mac OS X: in version 10.0 and later in Carbon.framework [32-bit
* only] CarbonLib: in CarbonLib 1.0 and later Non-Carbon CFM: in
* InterfaceLib 7.1 and later
*/
extern void LMSetKbdType(UInt8 value) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER;
#endif /* !__LP64__ */
#pragma pack(pop)
#ifdef __cplusplus
}
#endif
#endif /* __EVENTS__ */

View File

@@ -0,0 +1,206 @@
// virtual_key_codes.h
#ifndef VIRTUAL_KEY_CODES_H
#define VIRTUAL_KEY_CODES_H
#define VK_LBUTTON 0x01 // Left mouse button
#define VK_RBUTTON 0x02 // Right mouse button
#define VK_CANCEL 0x03 // Control-break processing
#define VK_MBUTTON 0x04 // Middle mouse button
#define VK_XBUTTON1 0x05 // X1 mouse button
#define VK_XBUTTON2 0x06 // X2 mouse button
// 0x07 Reserved
#define VK_BACK 0x08 // Backspace key
#define VK_TAB 0x09 // Tab key
// 0x0A-0B Reserved
#define VK_CLEAR 0x0C // Clear key
#define VK_RETURN 0x0D // Enter key
// 0x0E-0F Unassigned
#define VK_SHIFT 0x10 // Shift key
#define VK_CONTROL 0x11 // Ctrl key
#define VK_MENU 0x12 // Alt key
#define VK_PAUSE 0x13 // Pause key
#define VK_CAPITAL 0x14 // Caps lock key
#define VK_KANA 0x15 // IME Kana mode
#define VK_HANGUL 0x15 // IME Hangul mode
#define VK_IME_ON 0x16 // IME On
#define VK_JUNJA 0x17 // IME Junja mode
#define VK_FINAL 0x18 // IME final mode
#define VK_HANJA 0x19 // IME Hanja mode
#define VK_KANJI 0x19 // IME Kanji mode
#define VK_IME_OFF 0x1A // IME Off
#define VK_ESCAPE 0x1B // Esc key
#define VK_CONVERT 0x1C // IME convert
#define VK_NONCONVERT 0x1D // IME nonconvert
#define VK_ACCEPT 0x1E // IME accept
#define VK_MODECHANGE 0x1F // IME mode change request
#define VK_SPACE 0x20 // Spacebar key
#define VK_PRIOR 0x21 // Page up key
#define VK_NEXT 0x22 // Page down key
#define VK_END 0x23 // End key
#define VK_HOME 0x24 // Home key
#define VK_LEFT 0x25 // Left arrow key
#define VK_UP 0x26 // Up arrow key
#define VK_RIGHT 0x27 // Right arrow key
#define VK_DOWN 0x28 // Down arrow key
#define VK_SELECT 0x29 // Select key
#define VK_PRINT 0x2A // Print key
#define VK_EXECUTE 0x2B // Execute key
#define VK_SNAPSHOT 0x2C // Print screen key
#define VK_INSERT 0x2D // Insert key
#define VK_DELETE 0x2E // Delete key
#define VK_HELP 0x2F // Help key
#define VK_0 0x30 // 0 key
#define VK_1 0x31 // 1 key
#define VK_2 0x32 // 2 key
#define VK_3 0x33 // 3 key
#define VK_4 0x34 // 4 key
#define VK_5 0x35 // 5 key
#define VK_6 0x36 // 6 key
#define VK_7 0x37 // 7 key
#define VK_8 0x38 // 8 key
#define VK_9 0x39 // 9 key
// 0x3A-40 Undefined
#define VK_A 0x41 // A key
#define VK_B 0x42 // B key
#define VK_C 0x43 // C key
#define VK_D 0x44 // D key
#define VK_E 0x45 // E key
#define VK_F 0x46 // F key
#define VK_G 0x47 // G key
#define VK_H 0x48 // H key
#define VK_I 0x49 // I key
#define VK_J 0x4A // J key
#define VK_K 0x4B // K key
#define VK_L 0x4C // L key
#define VK_M 0x4D // M key
#define VK_N 0x4E // N key
#define VK_O 0x4F // O key
#define VK_P 0x50 // P key
#define VK_Q 0x51 // Q key
#define VK_R 0x52 // R key
#define VK_S 0x53 // S key
#define VK_T 0x54 // T key
#define VK_U 0x55 // U key
#define VK_V 0x56 // V key
#define VK_W 0x57 // W key
#define VK_X 0x58 // X key
#define VK_Y 0x59 // Y key
#define VK_Z 0x5A // Z key
#define VK_LWIN 0x5B // Left Windows logo key
#define VK_RWIN 0x5C // Right Windows logo key
#define VK_APPS 0x5D // Application key
// 0x5E Reserved
#define VK_SLEEP 0x5F // Computer Sleep key
#define VK_NUMPAD0 0x60 // Numeric keypad 0 key
#define VK_NUMPAD1 0x61 // Numeric keypad 1 key
#define VK_NUMPAD2 0x62 // Numeric keypad 2 key
#define VK_NUMPAD3 0x63 // Numeric keypad 3 key
#define VK_NUMPAD4 0x64 // Numeric keypad 4 key
#define VK_NUMPAD5 0x65 // Numeric keypad 5 key
#define VK_NUMPAD6 0x66 // Numeric keypad 6 key
#define VK_NUMPAD7 0x67 // Numeric keypad 7 key
#define VK_NUMPAD8 0x68 // Numeric keypad 8 key
#define VK_NUMPAD9 0x69 // Numeric keypad 9 key
#define VK_MULTIPLY 0x6A // Multiply key
#define VK_ADD 0x6B // Add key
#define VK_SEPARATOR 0x6C // Separator key
#define VK_SUBTRACT 0x6D // Subtract key
#define VK_DECIMAL 0x6E // Decimal key
#define VK_DIVIDE 0x6F // Divide key
#define VK_F1 0x70 // F1 key
#define VK_F2 0x71 // F2 key
#define VK_F3 0x72 // F3 key
#define VK_F4 0x73 // F4 key
#define VK_F5 0x74 // F5 key
#define VK_F6 0x75 // F6 key
#define VK_F7 0x76 // F7 key
#define VK_F8 0x77 // F8 key
#define VK_F9 0x78 // F9 key
#define VK_F10 0x79 // F10 key
#define VK_F11 0x7A // F11 key
#define VK_F12 0x7B // F12 key
#define VK_F13 0x7C // F13 key
#define VK_F14 0x7D // F14 key
#define VK_F15 0x7E // F15 key
#define VK_F16 0x7F // F16 key
#define VK_F17 0x80 // F17 key
#define VK_F18 0x81 // F18 key
#define VK_F19 0x82 // F19 key
#define VK_F20 0x83 // F20 key
#define VK_F21 0x84 // F21 key
#define VK_F22 0x85 // F22 key
#define VK_F23 0x86 // F23 key
#define VK_F24 0x87 // F24 key
// 0x880x8F Reserved
#define VK_NUMLOCK 0x90 // Num lock key
#define VK_SCROLL 0x91 // Scroll lock key
// 0x920x96 OEM specific
// 0x970x9F Unassigned
#define VK_LSHIFT 0xA0 // Left Shift key
#define VK_RSHIFT 0xA1 // Right Shift key
#define VK_LCONTROL 0xA2 // Left Ctrl key
#define VK_RCONTROL 0xA3 // Right Ctrl key
#define VK_LMENU 0xA4 // Left Alt key
#define VK_RMENU 0xA5 // Right Alt key
#define VK_BROWSER_BACK 0xA6 // Browser Back key
#define VK_BROWSER_FORWARD 0xA7 // Browser Forward key
#define VK_BROWSER_REFRESH 0xA8 // Browser Refresh key
#define VK_BROWSER_STOP 0xA9 // Browser Stop key
#define VK_BROWSER_SEARCH 0xAA // Browser Search key
#define VK_BROWSER_FAVORITES 0xAB // Browser Favorites key
#define VK_BROWSER_HOME 0xAC // Browser Start and Home key
#define VK_VOLUME_MUTE 0xAD // Volume Mute key
#define VK_VOLUME_DOWN 0xAE // Volume Down key
#define VK_VOLUME_UP 0xAF // Volume Up key
#define VK_MEDIA_NEXT_TRACK 0xB0 // Next Track key
#define VK_MEDIA_PREV_TRACK 0xB1 // Previous Track key
#define VK_MEDIA_STOP 0xB2 // Stop Media key
#define VK_MEDIA_PLAY_PAUSE 0xB3 // Play/Pause Media key
#define VK_LAUNCH_MAIL 0xB4 // Start Mail key
#define VK_LAUNCH_MEDIA_SELECT 0xB5 // Select Media key
#define VK_LAUNCH_APP1 0xB6 // Start Application 1 key
#define VK_LAUNCH_APP2 0xB7 // Start Application 2 key
// 0xB80xB9 Reserved
#define VK_OEM_1 0xBA // For US: Semicolon/Colon key
#define VK_OEM_PLUS 0xBB // Equals/Plus key
#define VK_OEM_COMMA 0xBC // Comma/Less Than key
#define VK_OEM_MINUS 0xBD // Dash/Underscore key
#define VK_OEM_PERIOD 0xBE // Period/Greater Than key
#define VK_OEM_2 0xBF // Slash/Question Mark key
#define VK_OEM_3 0xC0 // Grave Accent/Tilde key
// 0xC10xDA Reserved
#define VK_OEM_4 0xDB // Left Brace key
#define VK_OEM_5 0xDC // Backslash/Pipe key
#define VK_OEM_6 0xDD // Right Brace key
#define VK_OEM_7 0xDE // Apostrophe/Quote key
#define VK_OEM_8 0xDF // (Canadian CSA: Right Ctrl key)
// 0xE0 Reserved
#define VK_OEM_102 0xE2 // (European ISO: Backslash/Pipe key)
// 0xE3E4 OEM specific
#define VK_PROCESSKEY 0xE5 // IME PROCESS key
// 0xE6 OEM specific
#define VK_PACKET 0xE7 // Unicode characters as keystrokes
// 0xE8 Unassigned
// 0xE9F5 OEM specific
#define VK_ATTN 0xF6 // Attn key
#define VK_CRSEL 0xF7 // CrSel key
#define VK_EXSEL 0xF8 // ExSel key
#define VK_EREOF 0xF9 // Erase EOF key
#define VK_PLAY 0xFA // Play key
#define VK_ZOOM 0xFB // Zoom key
#define VK_NONAME 0xFC // Reserved
#define VK_PA1 0xFD // PA1 key
#define VK_OEM_CLEAR 0xFE // Clear key
#endif // VIRTUAL_KEY_CODES_H

View File

@@ -71,6 +71,9 @@ static std::vector<std::string> language_en = {
reinterpret_cast<const char*>(u8"英文"), "English"};
static std::vector<std::string> video_quality = {
reinterpret_cast<const char*>(u8"视频质量:"), "Video Quality:"};
static std::vector<std::string> video_frame_rate = {
reinterpret_cast<const char*>(u8"画面采集帧率:"),
"Video Capture Frame Rate:"};
static std::vector<std::string> video_quality_high = {
reinterpret_cast<const char*>(u8""), "High"};
static std::vector<std::string> video_quality_medium = {
@@ -89,6 +92,9 @@ static std::vector<std::string> enable_hardware_video_codec = {
static std::vector<std::string> enable_turn = {
reinterpret_cast<const char*>(u8"启用中继服务:"), "Enable TURN Service:"};
static std::vector<std::string> enable_srtp = {
reinterpret_cast<const char*>(u8"启用SRTP:"), "Enable SRTP:"};
static std::vector<std::string> ok = {reinterpret_cast<const char*>(u8"确认"),
"OK"};
static std::vector<std::string> cancel = {

View File

@@ -52,7 +52,7 @@ class ScreenCapturerX11 : public ScreenCapturer {
std::atomic<bool> running_{false};
std::atomic<bool> paused_{false};
std::atomic<int> monitor_index_{0};
int fps_ = 30;
int fps_ = 60;
cb_desktop_data callback_;
std::vector<DisplayInfo> display_info_list_;

View File

@@ -76,7 +76,7 @@ class API_AVAILABLE(macos(14.0)) ScreenCapturerSckImpl : public ScreenCapturer {
unsigned char *nv12_frame_ = nullptr;
int width_ = 0;
int height_ = 0;
int fps_ = 30;
int fps_ = 60;
public:
// Called by SckHelper when shareable content is returned by ScreenCaptureKit. `content` will be

View File

@@ -32,7 +32,7 @@ class ScreenCapturerWgc : public ScreenCapturer,
int SwitchTo(int monitor_index);
void OnFrame(const WgcSession::wgc_session_frame &frame, int id);
void OnFrame(const WgcSession::wgc_session_frame& frame, int id);
protected:
void CleanUp();
@@ -57,12 +57,12 @@ class ScreenCapturerWgc : public ScreenCapturer,
std::atomic_bool running_;
std::atomic_bool inited_;
int fps_;
int fps_ = 60;
cb_desktop_data on_data_ = nullptr;
unsigned char *nv12_frame_ = nullptr;
unsigned char *nv12_frame_scaled_ = nullptr;
unsigned char* nv12_frame_ = nullptr;
unsigned char* nv12_frame_scaled_ = nullptr;
};
#endif

View File

@@ -195,9 +195,9 @@ int Render::ControlBar(std::shared_ptr<SubStreamWindowProperties>& props) {
: localization::fullscreen[localization_language_index_];
if (fullscreen_button_pressed_) {
SDL_SetWindowFullscreen(stream_window_, SDL_WINDOW_FULLSCREEN_DESKTOP);
SDL_SetWindowFullscreen(stream_window_, true);
} else {
SDL_SetWindowFullscreen(stream_window_, SDL_FALSE);
SDL_SetWindowFullscreen(stream_window_, false);
}
props->reset_control_bar_pos_ = true;
}
@@ -259,7 +259,7 @@ int Render::NetTrafficStats(std::shared_ptr<SubStreamWindowProperties>& props) {
if (ImGui::BeginTable("NetTrafficStats", 4, ImGuiTableFlags_BordersH,
ImVec2(props->control_window_max_width_ - 10.0f,
props->control_window_max_height_ - 40.0f))) {
props->control_window_max_height_ - 60.0f))) {
ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed);
ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthStretch);
ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthStretch);
@@ -275,7 +275,6 @@ int Render::NetTrafficStats(std::shared_ptr<SubStreamWindowProperties>& props) {
ImGui::Text("%s",
localization::loss_rate[localization_language_index_].c_str());
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::Text("%s",
localization::video[localization_language_index_].c_str());
@@ -286,7 +285,6 @@ int Render::NetTrafficStats(std::shared_ptr<SubStreamWindowProperties>& props) {
ImGui::TableNextColumn();
LossRateDisplay(props->net_traffic_stats_.video_inbound_stats.loss_rate);
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::Text("%s",
localization::audio[localization_language_index_].c_str());
@@ -297,7 +295,6 @@ int Render::NetTrafficStats(std::shared_ptr<SubStreamWindowProperties>& props) {
ImGui::TableNextColumn();
LossRateDisplay(props->net_traffic_stats_.audio_inbound_stats.loss_rate);
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::Text("%s", localization::data[localization_language_index_].c_str());
ImGui::TableNextColumn();
@@ -307,7 +304,6 @@ int Render::NetTrafficStats(std::shared_ptr<SubStreamWindowProperties>& props) {
ImGui::TableNextColumn();
LossRateDisplay(props->net_traffic_stats_.data_inbound_stats.loss_rate);
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::Text("%s",
localization::total[localization_language_index_].c_str());
@@ -318,6 +314,11 @@ int Render::NetTrafficStats(std::shared_ptr<SubStreamWindowProperties>& props) {
ImGui::TableNextColumn();
LossRateDisplay(props->net_traffic_stats_.total_inbound_stats.loss_rate);
ImGui::TableNextColumn();
ImGui::Text("FPS");
ImGui::TableNextColumn();
ImGui::Text("%d", props->fps_);
ImGui::EndTable();
}

View File

@@ -18,20 +18,24 @@
#define IPUT_WINDOW_WIDTH 160
#define INPUT_WINDOW_PADDING_CN 66
#define INPUT_WINDOW_PADDING_EN 96
#define SETTINGS_WINDOW_WIDTH_CN 181
#define SETTINGS_WINDOW_WIDTH_EN 228
#define SETTINGS_WINDOW_HEIGHT_CN 220
#define SETTINGS_WINDOW_HEIGHT_EN 220
#define SETTINGS_WINDOW_WIDTH_CN 182
#define SETTINGS_WINDOW_WIDTH_EN 248
#define SETTINGS_WINDOW_HEIGHT_CN 275
#define SETTINGS_WINDOW_HEIGHT_EN 275
#define LANGUAGE_SELECT_WINDOW_PADDING_CN 100
#define LANGUAGE_SELECT_WINDOW_PADDING_EN 147
#define LANGUAGE_SELECT_WINDOW_PADDING_EN 167
#define VIDEO_QUALITY_SELECT_WINDOW_PADDING_CN 100
#define VIDEO_QUALITY_SELECT_WINDOW_PADDING_EN 147
#define VIDEO_QUALITY_SELECT_WINDOW_PADDING_EN 167
#define VIDEO_FRAME_RATE_SELECT_WINDOW_PADDING_CN 100
#define VIDEO_FRAME_RATE_SELECT_WINDOW_PADDING_EN 167
#define VIDEO_ENCODE_FORMAT_SELECT_WINDOW_PADDING_CN 100
#define VIDEO_ENCODE_FORMAT_SELECT_WINDOW_PADDING_EN 147
#define VIDEO_ENCODE_FORMAT_SELECT_WINDOW_PADDING_EN 167
#define ENABLE_HARDWARE_VIDEO_CODEC_CHECKBOX_PADDING_CN 151
#define ENABLE_HARDWARE_VIDEO_CODEC_CHECKBOX_PADDING_EN 198
#define ENABLE_HARDWARE_VIDEO_CODEC_CHECKBOX_PADDING_EN 218
#define ENABLE_TURN_CHECKBOX_PADDING_CN 151
#define ENABLE_TURN_CHECKBOX_PADDING_EN 198
#define ENABLE_TURN_CHECKBOX_PADDING_EN 218
#define ENABLE_SRTP_CHECKBOX_PADDING_CN 151
#define ENABLE_SRTP_CHECKBOX_PADDING_EN 218
#define SETTINGS_SELECT_WINDOW_WIDTH 73
#define SETTINGS_OK_BUTTON_PADDING_CN 55
#define SETTINGS_OK_BUTTON_PADDING_EN 78

View File

@@ -74,7 +74,7 @@ int Render::LocalWindow() {
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0, 0, 0, 0));
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0, 0, 0, 0));
ImGui::SetWindowFontScale(0.5f);
if (ImGui::Button(ICON_FA_COPY, ImVec2(35, 38))) {
if (ImGui::Button(ICON_FA_COPY, ImVec2(22, 38))) {
local_id_copied_ = true;
ImGui::SetClipboardText(client_id_);
copy_start_time_ = ImGui::GetTime();
@@ -84,7 +84,7 @@ int Render::LocalWindow() {
double time_duration = ImGui::GetTime() - copy_start_time_;
if (local_id_copied_ && time_duration < 1.0f) {
const ImGuiViewport *viewport = ImGui::GetMainViewport();
const ImGuiViewport* viewport = ImGui::GetMainViewport();
ImGui::SetNextWindowPos(
ImVec2((viewport->WorkSize.x - viewport->WorkPos.x -
notification_window_width_) /
@@ -159,7 +159,7 @@ int Render::LocalWindow() {
}
if (!show_password_) {
ImDrawList *draw_list = ImGui::GetWindowDrawList();
ImDrawList* draw_list = ImGui::GetWindowDrawList();
draw_list->AddLine(ImVec2(l_x + 3.0f, l_y + 12.5f),
ImVec2(l_x + 20.3f, l_y + 26.5f),
IM_COL32(239, 240, 242, 255), 2.0f);
@@ -170,19 +170,6 @@ int Render::LocalWindow() {
ImGui::SameLine();
if (ImGui::Button(
regenerate_password_ ? ICON_FA_SPINNER : ICON_FA_ARROWS_ROTATE,
ImVec2(22, 38))) {
regenerate_password_ = true;
regenerate_password_start_time_ = ImGui::GetTime();
LeaveConnection(peer_, client_id_);
}
if (ImGui::GetTime() - regenerate_password_start_time_ > 0.3f) {
regenerate_password_ = false;
}
ImGui::SameLine();
if (ImGui::Button(ICON_FA_PEN, ImVec2(22, 38))) {
show_reset_password_window_ = true;
}
@@ -190,7 +177,7 @@ int Render::LocalWindow() {
ImGui::PopStyleColor(3);
if (show_reset_password_window_) {
const ImGuiViewport *viewport = ImGui::GetMainViewport();
const ImGuiViewport* viewport = ImGui::GetMainViewport();
ImGui::SetNextWindowPos(
ImVec2((viewport->WorkSize.x - viewport->WorkPos.x -

View File

@@ -209,8 +209,8 @@ int Render::ShowRecentConnections() {
ImVec2 line_end = ImVec2(
image_screen_pos.x + recent_connection_image_width_ + 20.0f,
image_screen_pos.y + recent_connection_image_height_ + button_height);
ImGui::GetForegroundDrawList()->AddLine(line_start, line_end,
IM_COL32(0, 0, 0, 122), 1.0f);
ImGui::GetWindowDrawList()->AddLine(line_start, line_end,
IM_COL32(0, 0, 0, 122), 1.0f);
}
count++;

View File

@@ -1,5 +1,7 @@
#include "render.h"
#include <libyuv.h>
#include <filesystem>
#include <fstream>
#include <iostream>
@@ -19,8 +21,6 @@
#define MOUSE_GRAB_PADDING 5
#define STREAM_FRASH (SDL_USEREVENT + 1)
std::vector<char> Render::SerializeRemoteAction(const RemoteAction& action) {
std::vector<char> buffer;
buffer.push_back(static_cast<char>(action.type));
@@ -185,11 +185,14 @@ int Render::SaveSettingsIntoCacheFile() {
sizeof(language_button_value_));
memcpy(&cd_cache_.video_quality, &video_quality_button_value_,
sizeof(video_quality_button_value_));
memcpy(&cd_cache_.video_frame_rate, &video_frame_rate_button_value_,
sizeof(video_frame_rate_button_value_));
memcpy(&cd_cache_.video_encode_format, &video_encode_format_button_value_,
sizeof(video_encode_format_button_value_));
memcpy(&cd_cache_.enable_hardware_video_codec, &enable_hardware_video_codec_,
sizeof(enable_hardware_video_codec_));
memcpy(&cd_cache_.enable_turn, &enable_turn_, sizeof(enable_turn_));
memcpy(&cd_cache_.enable_srtp, &enable_srtp_, sizeof(enable_srtp_));
memcpy(&cd_cache_.key, &aes128_key_, sizeof(aes128_key_));
memcpy(&cd_cache_.iv, &aes128_iv_, sizeof(aes128_iv_));
@@ -200,10 +203,13 @@ int Render::SaveSettingsIntoCacheFile() {
config_center_.SetLanguage((ConfigCenter::LANGUAGE)language_button_value_);
config_center_.SetVideoQuality(
(ConfigCenter::VIDEO_QUALITY)video_quality_button_value_);
config_center_.SetVideoFrameRate(
(ConfigCenter::VIDEO_FRAME_RATE)video_frame_rate_button_value_);
config_center_.SetVideoEncodeFormat(
(ConfigCenter::VIDEO_ENCODE_FORMAT)video_encode_format_button_value_);
config_center_.SetHardwareVideoCodec(enable_hardware_video_codec_);
config_center_.SetTurn(enable_turn_);
config_center_.SetSrtp(enable_srtp_);
LOG_INFO("Save settings into cache file success");
@@ -225,14 +231,18 @@ int Render::LoadSettingsFromCacheFile() {
video_encode_format_button_value_ = 1;
enable_hardware_video_codec_ = false;
enable_turn_ = false;
enable_srtp_ = false;
config_center_.SetLanguage((ConfigCenter::LANGUAGE)language_button_value_);
config_center_.SetVideoQuality(
(ConfigCenter::VIDEO_QUALITY)video_quality_button_value_);
config_center_.SetVideoFrameRate(
(ConfigCenter::VIDEO_FRAME_RATE)video_frame_rate_button_value_);
config_center_.SetVideoEncodeFormat(
(ConfigCenter::VIDEO_ENCODE_FORMAT)video_encode_format_button_value_);
config_center_.SetHardwareVideoCodec(enable_hardware_video_codec_);
config_center_.SetTurn(enable_turn_);
config_center_.SetSrtp(enable_srtp_);
thumbnail_.reset();
thumbnail_ = std::make_unique<Thumbnail>(cache_path_ + "/thumbnails/");
@@ -281,23 +291,29 @@ int Render::LoadSettingsFromCacheFile() {
language_button_value_ = cd_cache_.language;
video_quality_button_value_ = cd_cache_.video_quality;
video_frame_rate_button_value_ = cd_cache_.video_frame_rate;
video_encode_format_button_value_ = cd_cache_.video_encode_format;
enable_hardware_video_codec_ = cd_cache_.enable_hardware_video_codec;
enable_turn_ = cd_cache_.enable_turn;
enable_srtp_ = cd_cache_.enable_srtp;
language_button_value_last_ = language_button_value_;
video_quality_button_value_last_ = video_quality_button_value_;
video_encode_format_button_value_last_ = video_encode_format_button_value_;
enable_hardware_video_codec_last_ = enable_hardware_video_codec_;
enable_turn_last_ = enable_turn_;
enable_srtp_last_ = enable_srtp_;
config_center_.SetLanguage((ConfigCenter::LANGUAGE)language_button_value_);
config_center_.SetVideoQuality(
(ConfigCenter::VIDEO_QUALITY)video_quality_button_value_);
config_center_.SetVideoFrameRate(
(ConfigCenter::VIDEO_FRAME_RATE)video_frame_rate_button_value_);
config_center_.SetVideoEncodeFormat(
(ConfigCenter::VIDEO_ENCODE_FORMAT)video_encode_format_button_value_);
config_center_.SetHardwareVideoCodec(enable_hardware_video_codec_);
config_center_.SetTurn(enable_turn_);
config_center_.SetSrtp(enable_srtp_);
LOG_INFO("Load settings from cache file");
@@ -305,25 +321,25 @@ int Render::LoadSettingsFromCacheFile() {
}
int Render::ScreenCapturerInit() {
if (screen_capturer_) {
LOG_INFO("Screen capturer already initialized");
return 0;
if (!screen_capturer_) {
screen_capturer_ = (ScreenCapturer*)screen_capturer_factory_->Create();
}
screen_capturer_ = (ScreenCapturer*)screen_capturer_factory_->Create();
last_frame_time_ = std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::steady_clock::now().time_since_epoch())
.count();
int fps = config_center_.GetVideoFrameRate();
LOG_INFO("Init screen capturer with {} fps", fps);
int screen_capturer_init_ret = screen_capturer_->Init(
60,
fps,
[this](unsigned char* data, int size, int width, int height,
const char* display_name) -> void {
auto now_time = std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::steady_clock::now().time_since_epoch())
.count();
auto duration = now_time - last_frame_time_;
if (duration >= 33) {
if (duration * config_center_.GetVideoFrameRate() >= 1000) { // ~60 FPS
XVideoFrame frame;
frame.data = (const char*)data;
frame.size = size;
@@ -476,6 +492,7 @@ int Render::CreateConnectionPeer() {
? true
: false;
params_.enable_turn = config_center_.IsEnableTurn();
params_.enable_srtp = config_center_.IsEnableSrtp();
params_.on_receive_video_buffer = nullptr;
params_.on_receive_audio_buffer = OnReceiveAudioBufferCb;
params_.on_receive_data_buffer = OnReceiveDataBufferCb;
@@ -512,49 +529,29 @@ int Render::CreateConnectionPeer() {
}
int Render::AudioDeviceInit() {
// Audio
SDL_AudioSpec want_in = {};
SDL_AudioSpec want_out = {};
SDL_zero(want_in);
want_in.freq = 48000;
want_in.format = AUDIO_S16LSB;
want_in.channels = 1;
want_in.samples = 480;
want_in.callback = SdlCaptureAudioIn;
want_in.userdata = this;
SDL_AudioSpec desired_out{};
desired_out.freq = 48000;
desired_out.format = SDL_AUDIO_S16;
desired_out.channels = 1;
// input_dev_ = SDL_OpenAudioDevice(NULL, 1, &want_in, &have_in, 0);
// if (input_dev_ == 0) {
// SDL_Log("Failed to open input: %s", SDL_GetError());
// // return 1;
// }
SDL_zero(want_out);
want_out.freq = 48000;
want_out.format = AUDIO_S16LSB;
want_out.channels = 1;
// want_out.silence = 0;
want_out.samples = 480;
want_out.callback = nullptr;
want_out.userdata = this;
output_dev_ = SDL_OpenAudioDevice(nullptr, 0, &want_out, NULL, 0);
if (output_dev_ == 0) {
SDL_Log("Failed to open input: %s", SDL_GetError());
// return 1;
output_stream_ = SDL_OpenAudioDeviceStream(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK,
&desired_out, nullptr, nullptr);
if (!output_stream_) {
LOG_ERROR("Failed to open output stream: {}", SDL_GetError());
return -1;
}
// SDL_PauseAudioDevice(input_dev_, 0);
SDL_PauseAudioDevice(output_dev_, 0);
SDL_ResumeAudioDevice(SDL_GetAudioStreamDevice(output_stream_));
return 0;
}
int Render::AudioDeviceDestroy() {
SDL_PauseAudioDevice(output_dev_, 1);
SDL_CloseAudioDevice(output_dev_);
// SDL_CloseAudioDevice(input_dev_);
if (output_stream_) {
SDL_CloseAudioDevice(SDL_GetAudioStreamDevice(output_stream_));
SDL_DestroyAudioStream(output_stream_);
output_stream_ = nullptr;
}
return 0;
}
@@ -595,22 +592,18 @@ int Render::CreateMainWindow() {
ImGui::SetCurrentContext(main_ctx_);
SDL_WindowFlags window_flags =
(SDL_WindowFlags)(SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_BORDERLESS |
SDL_WINDOW_HIDDEN);
main_window_ =
SDL_CreateWindow("Remote Desk", SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED, (int)main_window_width_default_,
(int)main_window_height_default_, window_flags);
main_renderer_ = SDL_CreateRenderer(
main_window_, -1, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED);
if (main_renderer_ == nullptr) {
LOG_ERROR("Error creating SDL_Renderer");
return 0;
if (!SDL_CreateWindowAndRenderer(
"Remote Desk", (int)main_window_width_default_,
(int)main_window_height_default_,
SDL_WINDOW_HIGH_PIXEL_DENSITY | SDL_WINDOW_BORDERLESS |
SDL_WINDOW_HIDDEN,
&main_window_, &main_renderer_)) {
LOG_ERROR("Error creating main_window_ and main_renderer_: {}",
SDL_GetError());
return -1;
}
SDL_SetWindowResizable(main_window_, SDL_FALSE);
SDL_SetWindowResizable(main_window_, false);
// for window region action
SDL_SetWindowHitTest(main_window_, HitTestCallback, this);
@@ -647,35 +640,27 @@ int Render::CreateStreamWindow() {
ImGui::SetCurrentContext(stream_ctx_);
SDL_WindowFlags window_flags =
(SDL_WindowFlags)(SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_BORDERLESS);
stream_window_ =
SDL_CreateWindow("Stream window", SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED, stream_window_width_default_,
stream_window_height_default_, window_flags);
stream_renderer_ = SDL_CreateRenderer(
stream_window_, -1, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED);
if (stream_renderer_ == nullptr) {
LOG_ERROR("Error creating SDL_Renderer");
return 0;
if (!SDL_CreateWindowAndRenderer(
"Stream window", (int)stream_window_width_default_,
(int)stream_window_height_default_,
SDL_WINDOW_HIGH_PIXEL_DENSITY | SDL_WINDOW_BORDERLESS,
&stream_window_, &stream_renderer_)) {
LOG_ERROR("Error creating stream_window_ and stream_renderer_: {}",
SDL_GetError());
return -1;
}
stream_pixformat_ = SDL_PIXELFORMAT_NV12;
// stream_texture_ = SDL_CreateTexture(stream_renderer_, stream_pixformat_,
// SDL_TEXTUREACCESS_STREAMING,
// texture_width_, texture_height_);
SDL_SetWindowResizable(stream_window_, SDL_TRUE);
SDL_SetWindowResizable(stream_window_, true);
// for window region action
SDL_SetWindowHitTest(stream_window_, HitTestCallback, this);
// change props->stream_render_rect_
SDL_Event event;
event.type = SDL_WINDOWEVENT;
event.type = SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED;
event.window.windowID = SDL_GetWindowID(stream_window_);
event.window.event = SDL_WINDOWEVENT_SIZE_CHANGED;
SDL_PushEvent(&event);
stream_window_created_ = true;
@@ -709,14 +694,7 @@ int Render::SetupFontAndStyle() {
// Setup Dear ImGui style
ImGuiIO& io = ImGui::GetIO();
imgui_cache_path_ = cache_path_ + "/crossdesk.ini";
io.IniFilename = imgui_cache_path_.c_str();
io.ConfigFlags |=
ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
io.ConfigFlags |=
ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
io.IniFilename = NULL; // disable imgui.ini
// Load Fonts
ImFontConfig config;
@@ -744,25 +722,25 @@ int Render::SetupMainWindow() {
SetupFontAndStyle();
SDL_GL_GetDrawableSize(main_window_, &main_window_width_real_,
&main_window_height_real_);
SDL_GetWindowSizeInPixels(main_window_, &main_window_width_real_,
&main_window_height_real_);
main_window_dpi_scaling_w_ = main_window_width_real_ / main_window_width_;
main_window_dpi_scaling_h_ = main_window_width_real_ / main_window_width_;
SDL_RenderSetScale(main_renderer_, main_window_dpi_scaling_w_,
SDL_SetRenderScale(main_renderer_, main_window_dpi_scaling_w_,
main_window_dpi_scaling_h_);
LOG_INFO("Use dpi scaling [{}x{}] for main window",
main_window_dpi_scaling_w_, main_window_dpi_scaling_h_);
ImGui_ImplSDL2_InitForSDLRenderer(main_window_, main_renderer_);
ImGui_ImplSDLRenderer2_Init(main_renderer_);
ImGui_ImplSDL3_InitForSDLRenderer(main_window_, main_renderer_);
ImGui_ImplSDLRenderer3_Init(main_renderer_);
return 0;
}
int Render::DestroyMainWindowContext() {
ImGui::SetCurrentContext(main_ctx_);
ImGui_ImplSDLRenderer2_Shutdown();
ImGui_ImplSDL2_Shutdown();
ImGui_ImplSDLRenderer3_Shutdown();
ImGui_ImplSDL3_Shutdown();
ImGui::DestroyContext(main_ctx_);
return 0;
@@ -782,21 +760,21 @@ int Render::SetupStreamWindow() {
SetupFontAndStyle();
SDL_GL_GetDrawableSize(stream_window_, &stream_window_width_real_,
&stream_window_height_real_);
SDL_GetWindowSizeInPixels(stream_window_, &stream_window_width_real_,
&stream_window_height_real_);
stream_window_dpi_scaling_w_ =
stream_window_width_real_ / stream_window_width_;
stream_window_dpi_scaling_h_ =
stream_window_width_real_ / stream_window_width_;
SDL_RenderSetScale(stream_renderer_, stream_window_dpi_scaling_w_,
SDL_SetRenderScale(stream_renderer_, stream_window_dpi_scaling_w_,
stream_window_dpi_scaling_h_);
LOG_INFO("Use dpi scaling [{}x{}] for stream window",
stream_window_dpi_scaling_w_, stream_window_dpi_scaling_h_);
ImGui_ImplSDL2_InitForSDLRenderer(stream_window_, stream_renderer_);
ImGui_ImplSDLRenderer2_Init(stream_renderer_);
ImGui_ImplSDL3_InitForSDLRenderer(stream_window_, stream_renderer_);
ImGui_ImplSDLRenderer3_Init(stream_renderer_);
stream_window_inited_ = true;
LOG_INFO("Stream window inited");
@@ -807,8 +785,8 @@ int Render::SetupStreamWindow() {
int Render::DestroyStreamWindowContext() {
stream_window_inited_ = false;
ImGui::SetCurrentContext(stream_ctx_);
ImGui_ImplSDLRenderer2_Shutdown();
ImGui_ImplSDL2_Shutdown();
ImGui_ImplSDLRenderer3_Shutdown();
ImGui_ImplSDL3_Shutdown();
ImGui::DestroyContext(stream_ctx_);
return 0;
@@ -821,8 +799,8 @@ int Render::DrawMainWindow() {
}
ImGui::SetCurrentContext(main_ctx_);
ImGui_ImplSDLRenderer2_NewFrame();
ImGui_ImplSDL2_NewFrame();
ImGui_ImplSDLRenderer3_NewFrame();
ImGui_ImplSDL3_NewFrame();
ImGui::NewFrame();
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(1.0f, 1.0f, 1.0f, 1.0f));
@@ -845,7 +823,7 @@ int Render::DrawMainWindow() {
// Rendering
ImGui::Render();
SDL_RenderClear(main_renderer_);
ImGui_ImplSDLRenderer2_RenderDrawData(ImGui::GetDrawData(), main_renderer_);
ImGui_ImplSDLRenderer3_RenderDrawData(ImGui::GetDrawData(), main_renderer_);
SDL_RenderPresent(main_renderer_);
return 0;
@@ -858,8 +836,8 @@ int Render::DrawStreamWindow() {
}
ImGui::SetCurrentContext(stream_ctx_);
ImGui_ImplSDLRenderer2_NewFrame();
ImGui_ImplSDL2_NewFrame();
ImGui_ImplSDLRenderer3_NewFrame();
ImGui_ImplSDL3_NewFrame();
ImGui::NewFrame();
StreamWindow();
@@ -889,11 +867,16 @@ int Render::DrawStreamWindow() {
for (auto& it : client_properties_) {
auto props = it.second;
if (props->tab_selected_) {
SDL_RenderCopy(stream_renderer_, props->stream_texture_, NULL,
&(props->stream_render_rect_));
SDL_FRect render_rect_f = {
static_cast<float>(props->stream_render_rect_.x),
static_cast<float>(props->stream_render_rect_.y),
static_cast<float>(props->stream_render_rect_.w),
static_cast<float>(props->stream_render_rect_.h)};
SDL_RenderTexture(stream_renderer_, props->stream_texture_, NULL,
&render_rect_f);
}
}
ImGui_ImplSDLRenderer2_RenderDrawData(ImGui::GetDrawData(), stream_renderer_);
ImGui_ImplSDLRenderer3_RenderDrawData(ImGui::GetDrawData(), stream_renderer_);
SDL_RenderPresent(stream_renderer_);
return 0;
@@ -925,13 +908,7 @@ int Render::Run() {
return 0;
}
void Render::InitializeLogger() {
if (std::filesystem::exists(exec_log_path_)) {
InitLogger(exec_log_path_);
} else {
InitLogger("logs");
}
}
void Render::InitializeLogger() { InitLogger(exec_log_path_); }
void Render::InitializeSettings() {
LoadSettingsFromCacheFile();
@@ -946,20 +923,23 @@ void Render::InitializeSettings() {
}
void Render::InitializeSDL() {
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER |
SDL_INIT_GAMECONTROLLER) != 0) {
printf("Error: %s\n", SDL_GetError());
exit(-1);
if (!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO)) {
LOG_ERROR("Error: {}", SDL_GetError());
return;
}
SDL_DisplayMode DM;
SDL_GetCurrentDisplayMode(0, &DM);
screen_width_ = DM.w;
screen_height_ = DM.h;
const SDL_DisplayMode* dm = SDL_GetCurrentDisplayMode(0);
if (dm) {
screen_width_ = dm->w;
screen_height_ = dm->h;
}
STREAM_REFRESH_EVENT = SDL_RegisterEvents(1);
if (STREAM_REFRESH_EVENT == (uint32_t)-1) {
LOG_ERROR("Failed to register custom SDL event");
}
LOG_INFO("Screen resolution: [{}x{}]", screen_width_, screen_height_);
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "1");
}
void Render::InitializeModules() {
@@ -989,8 +969,12 @@ void Render::MainLoop() {
CreateConnectionPeer();
}
SDL_Event event;
if (SDL_WaitEventTimeout(&event, sdl_refresh_ms_)) {
ProcessSdlEvent(event);
}
UpdateLabels();
ProcessSdlEvent();
HandleRecentConnections();
HandleStreamWindow();
@@ -1082,10 +1066,10 @@ void Render::HandleStreamWindow() {
if (stream_window_inited_) {
if (!stream_window_grabbed_ && control_mouse_) {
SDL_SetWindowGrab(stream_window_, SDL_TRUE);
SDL_SetWindowMouseGrab(stream_window_, true);
stream_window_grabbed_ = true;
} else if (stream_window_grabbed_ && !control_mouse_) {
SDL_SetWindowGrab(stream_window_, SDL_FALSE);
SDL_SetWindowMouseGrab(stream_window_, false);
stream_window_grabbed_ = false;
}
}
@@ -1141,7 +1125,7 @@ void Render::CleanupFactories() {
}
void Render::CleanupPeer(std::shared_ptr<SubStreamWindowProperties> props) {
SDL_FlushEvent(STREAM_FRASH);
SDL_FlushEvent(STREAM_REFRESH_EVENT);
if (props->dst_buffer_) {
thumbnail_->SaveToThumbnail(
@@ -1236,149 +1220,183 @@ void Render::UpdateRenderRect() {
}
}
void Render::ProcessSdlEvent() {
SDL_Event event;
while (SDL_PollEvent(&event)) {
if (main_ctx_) {
ImGui::SetCurrentContext(main_ctx_);
ImGui_ImplSDL2_ProcessEvent(&event);
void Render::ProcessSdlEvent(const SDL_Event& event) {
if (main_ctx_) {
ImGui::SetCurrentContext(main_ctx_);
ImGui_ImplSDL3_ProcessEvent(&event);
} else {
LOG_ERROR("Main context is null");
return;
}
if (stream_window_inited_) {
if (stream_ctx_) {
ImGui::SetCurrentContext(stream_ctx_);
ImGui_ImplSDL3_ProcessEvent(&event);
} else {
LOG_ERROR("Main context is null");
LOG_ERROR("Stream context is null");
return;
}
}
if (stream_window_inited_) {
if (stream_ctx_) {
ImGui::SetCurrentContext(stream_ctx_);
ImGui_ImplSDL2_ProcessEvent(&event);
switch (event.type) {
case SDL_EVENT_QUIT:
if (stream_window_inited_) {
LOG_INFO("Destroy stream window");
SDL_SetWindowMouseGrab(stream_window_, false);
DestroyStreamWindow();
DestroyStreamWindowContext();
for (auto& [host_name, props] : client_properties_) {
thumbnail_->SaveToThumbnail(
(char*)props->dst_buffer_, props->video_width_,
props->video_height_, host_name, props->remote_host_name_,
props->remember_password_ ? props->remote_password_ : "");
if (props->peer_) {
std::string client_id = (host_name == client_id_)
? "C-" + std::string(client_id_)
: client_id_;
LOG_INFO("[{}] Leave connection [{}]", client_id, host_name);
LeaveConnection(props->peer_, host_name.c_str());
LOG_INFO("Destroy peer [{}]", client_id);
DestroyPeer(&props->peer_);
}
props->streaming_ = false;
props->remember_password_ = false;
props->connection_established_ = false;
props->audio_capture_button_pressed_ = false;
memset(&props->net_traffic_stats_, 0,
sizeof(props->net_traffic_stats_));
SDL_SetWindowFullscreen(main_window_, false);
SDL_FlushEvents(STREAM_REFRESH_EVENT, STREAM_REFRESH_EVENT);
memset(audio_buffer_, 0, 720);
}
client_properties_.clear();
rejoin_ = false;
is_client_mode_ = false;
reload_recent_connections_ = true;
fullscreen_button_pressed_ = false;
just_created_ = false;
recent_connection_image_save_time_ = SDL_GetTicks();
} else {
LOG_ERROR("Stream context is null");
return;
LOG_INFO("Quit program");
exit_ = true;
}
}
break;
switch (event.type) {
case SDL_QUIT:
if (stream_window_inited_) {
LOG_INFO("Destroy stream window");
SDL_SetWindowGrab(stream_window_, SDL_FALSE);
DestroyStreamWindow();
DestroyStreamWindowContext();
case SDL_EVENT_WINDOW_CLOSE_REQUESTED:
if (event.window.windowID != SDL_GetWindowID(stream_window_)) {
exit_ = true;
}
break;
for (auto& [host_name, props] : client_properties_) {
thumbnail_->SaveToThumbnail(
(char*)props->dst_buffer_, props->video_width_,
props->video_height_, host_name, props->remote_host_name_,
props->remember_password_ ? props->remote_password_ : "");
case SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED:
if (stream_window_created_ &&
event.window.windowID == SDL_GetWindowID(stream_window_)) {
UpdateRenderRect();
}
break;
if (props->peer_) {
std::string client_id = (host_name == client_id_)
? "C-" + std::string(client_id_)
: client_id_;
LOG_INFO("[{}] Leave connection [{}]", client_id, host_name);
LeaveConnection(props->peer_, host_name.c_str());
LOG_INFO("Destroy peer [{}]", client_id);
DestroyPeer(&props->peer_);
}
case SDL_EVENT_WINDOW_FOCUS_GAINED:
if (stream_window_ &&
SDL_GetWindowID(stream_window_) == event.window.windowID) {
foucs_on_stream_window_ = true;
} else if (main_window_ &&
SDL_GetWindowID(main_window_) == event.window.windowID) {
foucs_on_main_window_ = true;
}
break;
props->streaming_ = false;
props->remember_password_ = false;
props->connection_established_ = false;
props->audio_capture_button_pressed_ = false;
case SDL_EVENT_WINDOW_FOCUS_LOST:
if (stream_window_ &&
SDL_GetWindowID(stream_window_) == event.window.windowID) {
foucs_on_stream_window_ = false;
} else if (main_window_ &&
SDL_GetWindowID(main_window_) == event.window.windowID) {
foucs_on_main_window_ = false;
}
break;
memset(&props->net_traffic_stats_, 0,
sizeof(props->net_traffic_stats_));
SDL_SetWindowFullscreen(main_window_, SDL_FALSE);
SDL_FlushEvents(STREAM_FRASH, STREAM_FRASH);
memset(audio_buffer_, 0, 720);
}
client_properties_.clear();
case SDL_EVENT_MOUSE_MOTION:
case SDL_EVENT_MOUSE_BUTTON_DOWN:
case SDL_EVENT_MOUSE_BUTTON_UP:
case SDL_EVENT_MOUSE_WHEEL:
if (foucs_on_stream_window_) {
ProcessMouseEvent(event);
}
break;
rejoin_ = false;
is_client_mode_ = false;
reload_recent_connections_ = true;
fullscreen_button_pressed_ = false;
just_created_ = false;
recent_connection_image_save_time_ = SDL_GetTicks();
} else {
LOG_INFO("Quit program");
exit_ = true;
}
break;
case SDL_WINDOWEVENT:
if (event.window.event == SDL_WINDOWEVENT_CLOSE &&
event.window.windowID != SDL_GetWindowID(stream_window_)) {
exit_ = true;
} else if (event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED &&
stream_window_created_ &&
event.window.windowID == SDL_GetWindowID(stream_window_)) {
UpdateRenderRect();
} else if (event.window.event == SDL_WINDOWEVENT_FOCUS_GAINED ||
event.window.event == SDL_WINDOWEVENT_FOCUS_LOST) {
bool focus_gained =
event.window.event == SDL_WINDOWEVENT_FOCUS_GAINED;
if (stream_window_ &&
SDL_GetWindowID(stream_window_) == event.window.windowID) {
foucs_on_stream_window_ = focus_gained;
} else if (main_window_ &&
SDL_GetWindowID(main_window_) == event.window.windowID) {
foucs_on_main_window_ = focus_gained;
}
}
break;
case STREAM_FRASH: {
default:
if (event.type == STREAM_REFRESH_EVENT) {
auto* props = static_cast<SubStreamWindowProperties*>(event.user.data1);
if (!props) {
continue;
break;
}
if (props->video_width_ <= 0 || props->video_height_ <= 0) {
continue;
break;
}
if (!props->dst_buffer_) {
continue;
break;
}
if (props->stream_texture_) {
if (props->video_width_ != props->texture_width_ ||
props->video_height_ != props->texture_height_) {
// LOG_WARN("Resolution changed, old: [{}x{}], new: [{}x{}]",
// props->texture_width_, props->texture_height_,
// props->video_width_, props->video_height_);
props->texture_width_ = props->video_width_;
props->texture_height_ = props->video_height_;
SDL_DestroyTexture(props->stream_texture_);
props->stream_texture_ = SDL_CreateTexture(
stream_renderer_, stream_pixformat_,
SDL_TEXTUREACCESS_STREAMING, props->texture_width_,
props->texture_height_);
// props->stream_texture_ = SDL_CreateTexture(
// stream_renderer_, stream_pixformat_,
// SDL_TEXTUREACCESS_STREAMING, props->texture_width_,
// props->texture_height_);
SDL_PropertiesID nvProps = SDL_CreateProperties();
SDL_SetNumberProperty(nvProps, SDL_PROP_TEXTURE_CREATE_WIDTH_NUMBER,
props->texture_width_);
SDL_SetNumberProperty(nvProps,
SDL_PROP_TEXTURE_CREATE_HEIGHT_NUMBER,
props->texture_height_);
SDL_SetNumberProperty(nvProps,
SDL_PROP_TEXTURE_CREATE_FORMAT_NUMBER,
SDL_PIXELFORMAT_NV12);
SDL_SetNumberProperty(nvProps,
SDL_PROP_TEXTURE_CREATE_COLORSPACE_NUMBER,
SDL_COLORSPACE_BT601_LIMITED);
props->stream_texture_ =
SDL_CreateTextureWithProperties(stream_renderer_, nvProps);
SDL_DestroyProperties(nvProps);
}
} else {
props->texture_width_ = props->video_width_;
props->texture_height_ = props->video_height_;
props->stream_texture_ = SDL_CreateTexture(
stream_renderer_, stream_pixformat_, SDL_TEXTUREACCESS_STREAMING,
props->texture_width_, props->texture_height_);
// props->stream_texture_ = SDL_CreateTexture(
// stream_renderer_, stream_pixformat_,
// SDL_TEXTUREACCESS_STREAMING, props->texture_width_,
// props->texture_height_);
SDL_PropertiesID nvProps = SDL_CreateProperties();
SDL_SetNumberProperty(nvProps, SDL_PROP_TEXTURE_CREATE_WIDTH_NUMBER,
props->texture_width_);
SDL_SetNumberProperty(nvProps, SDL_PROP_TEXTURE_CREATE_HEIGHT_NUMBER,
props->texture_height_);
SDL_SetNumberProperty(nvProps, SDL_PROP_TEXTURE_CREATE_FORMAT_NUMBER,
SDL_PIXELFORMAT_NV12);
SDL_SetNumberProperty(nvProps,
SDL_PROP_TEXTURE_CREATE_COLORSPACE_NUMBER,
SDL_COLORSPACE_BT601_LIMITED);
props->stream_texture_ =
SDL_CreateTextureWithProperties(stream_renderer_, nvProps);
SDL_DestroyProperties(nvProps);
}
SDL_UpdateTexture(props->stream_texture_, NULL, props->dst_buffer_,
props->texture_width_);
break;
}
case SDL_MOUSEMOTION:
case SDL_MOUSEBUTTONDOWN:
case SDL_MOUSEBUTTONUP:
case SDL_MOUSEWHEEL:
if (foucs_on_stream_window_) {
ProcessMouseEvent(event);
}
break;
default:
break;
}
break;
}
}

View File

@@ -7,7 +7,7 @@
#ifndef _MAIN_WINDOW_H_
#define _MAIN_WINDOW_H_
#include <SDL.h>
#include <SDL3/SDL.h>
#include <atomic>
#include <chrono>
@@ -21,8 +21,8 @@
#include "config_center.h"
#include "device_controller_factory.h"
#include "imgui.h"
#include "imgui_impl_sdl2.h"
#include "imgui_impl_sdlrenderer2.h"
#include "imgui_impl_sdl3.h"
#include "imgui_impl_sdlrenderer3.h"
#include "imgui_internal.h"
#include "minirtc.h"
#include "path_manager.h"
@@ -34,7 +34,7 @@ class Render {
public:
struct SubStreamWindowProperties {
Params params_;
PeerPtr *peer_ = nullptr;
PeerPtr* peer_ = nullptr;
std::string audio_label_ = "control_audio";
std::string data_label_ = "control_data";
std::string local_id_ = "";
@@ -65,7 +65,7 @@ class Render {
float control_window_min_width_ = 20;
float control_window_max_width_ = 230;
float control_window_min_height_ = 40;
float control_window_max_height_ = 150;
float control_window_max_height_ = 170;
float control_window_width_ = 230;
float control_window_height_ = 40;
float control_bar_pos_x_ = 0;
@@ -74,12 +74,12 @@ class Render {
float mouse_diff_control_bar_pos_y_ = 0;
double control_bar_button_pressed_time_ = 0;
double net_traffic_stats_button_pressed_time_ = 0;
unsigned char *dst_buffer_ = nullptr;
unsigned char* dst_buffer_ = nullptr;
size_t dst_buffer_capacity_ = 0;
int mouse_pos_x_ = 0;
int mouse_pos_y_ = 0;
int mouse_pos_x_last_ = 0;
int mouse_pos_y_last_ = 0;
float mouse_pos_x_ = 0;
float mouse_pos_y_ = 0;
float mouse_pos_x_last_ = 0;
float mouse_pos_y_last_ = 0;
int texture_width_ = 1280;
int texture_height_ = 720;
int video_width_ = 0;
@@ -102,12 +102,17 @@ class Render {
std::string audio_capture_button_label_ = "Audio Capture";
std::string remote_host_name_ = "";
std::vector<DisplayInfo> display_info_list_;
SDL_Texture *stream_texture_ = nullptr;
SDL_Texture* stream_texture_ = nullptr;
uint8_t* argb_buffer_ = nullptr;
int argb_buffer_size_ = 0;
SDL_Rect stream_render_rect_;
SDL_Rect stream_render_rect_last_;
ImVec2 control_window_pos_;
ConnectionStatus connection_status_ = ConnectionStatus::Closed;
TraversalMode traversal_mode_ = TraversalMode::UnknownMode;
int fps_ = 0;
int frame_count_ = 0;
std::chrono::steady_clock::time_point last_time_;
XNetTrafficStats net_traffic_stats_;
};
@@ -136,7 +141,7 @@ class Render {
void CleanSubStreamWindowProperties(
std::shared_ptr<SubStreamWindowProperties> props);
void UpdateRenderRect();
void ProcessSdlEvent();
void ProcessSdlEvent(const SDL_Event& event);
private:
int CreateStreamRenderWindow();
@@ -147,16 +152,16 @@ class Render {
int RemoteWindow();
int RecentConnectionsWindow();
int SettingWindow();
int ControlWindow(std::shared_ptr<SubStreamWindowProperties> &props);
int ControlBar(std::shared_ptr<SubStreamWindowProperties> &props);
int ControlWindow(std::shared_ptr<SubStreamWindowProperties>& props);
int ControlBar(std::shared_ptr<SubStreamWindowProperties>& props);
int AboutWindow();
int StatusBar();
bool ConnectionStatusWindow(
std::shared_ptr<SubStreamWindowProperties> &props);
std::shared_ptr<SubStreamWindowProperties>& props);
int ShowRecentConnections();
private:
int ConnectTo(const std::string &remote_id, const char *password,
int ConnectTo(const std::string& remote_id, const char* password,
bool remember_password);
int CreateMainWindow();
int DestroyMainWindow();
@@ -170,51 +175,51 @@ class Render {
int DrawMainWindow();
int DrawStreamWindow();
int ConfirmDeleteConnection();
int NetTrafficStats(std::shared_ptr<SubStreamWindowProperties> &props);
int NetTrafficStats(std::shared_ptr<SubStreamWindowProperties>& props);
void DrawConnectionStatusText(
std::shared_ptr<SubStreamWindowProperties> &props);
std::shared_ptr<SubStreamWindowProperties>& props);
public:
static void OnReceiveVideoBufferCb(const XVideoFrame *video_frame,
const char *user_id, size_t user_id_size,
void *user_data);
static void OnReceiveVideoBufferCb(const XVideoFrame* video_frame,
const char* user_id, size_t user_id_size,
void* user_data);
static void OnReceiveAudioBufferCb(const char *data, size_t size,
const char *user_id, size_t user_id_size,
void *user_data);
static void OnReceiveAudioBufferCb(const char* data, size_t size,
const char* user_id, size_t user_id_size,
void* user_data);
static void OnReceiveDataBufferCb(const char *data, size_t size,
const char *user_id, size_t user_id_size,
void *user_data);
static void OnReceiveDataBufferCb(const char* data, size_t size,
const char* user_id, size_t user_id_size,
void* user_data);
static void OnSignalStatusCb(SignalStatus status, const char *user_id,
size_t user_id_size, void *user_data);
static void OnSignalStatusCb(SignalStatus status, const char* user_id,
size_t user_id_size, void* user_data);
static void OnConnectionStatusCb(ConnectionStatus status, const char *user_id,
size_t user_id_size, void *user_data);
static void OnConnectionStatusCb(ConnectionStatus status, const char* user_id,
size_t user_id_size, void* user_data);
static void NetStatusReport(const char *client_id, size_t client_id_size,
static void NetStatusReport(const char* client_id, size_t client_id_size,
TraversalMode mode,
const XNetTrafficStats *net_traffic_stats,
const char *user_id, const size_t user_id_size,
void *user_data);
const XNetTrafficStats* net_traffic_stats,
const char* user_id, const size_t user_id_size,
void* user_data);
static SDL_HitTestResult HitTestCallback(SDL_Window *window,
const SDL_Point *area, void *data);
static SDL_HitTestResult HitTestCallback(SDL_Window* window,
const SDL_Point* area, void* data);
static std::vector<char> SerializeRemoteAction(const RemoteAction &action);
static std::vector<char> SerializeRemoteAction(const RemoteAction& action);
static bool DeserializeRemoteAction(const char *data, size_t size,
RemoteAction &out);
static bool DeserializeRemoteAction(const char* data, size_t size,
RemoteAction& out);
static void FreeRemoteAction(RemoteAction &action);
static void FreeRemoteAction(RemoteAction& action);
private:
int SendKeyCommand(int key_code, bool is_down);
int ProcessMouseEvent(SDL_Event &event);
int ProcessMouseEvent(const SDL_Event& event);
static void SdlCaptureAudioIn(void *userdata, Uint8 *stream, int len);
static void SdlCaptureAudioOut(void *userdata, Uint8 *stream, int len);
static void SdlCaptureAudioIn(void* userdata, Uint8* stream, int len);
static void SdlCaptureAudioOut(void* userdata, Uint8* stream, int len);
private:
int SaveSettingsIntoCacheFile();
@@ -243,9 +248,11 @@ class Render {
char client_id_with_password[17];
int language;
int video_quality;
int video_frame_rate;
int video_encode_format;
bool enable_hardware_video_codec;
bool enable_turn;
bool enable_srtp;
unsigned char key[16];
unsigned char iv[16];
@@ -262,7 +269,6 @@ class Render {
std::string exec_log_path_;
std::string dll_log_path_;
std::string cache_path_;
std::string imgui_cache_path_;
int localization_language_index_ = -1;
int localization_language_index_last_ = -1;
bool modules_inited_ = false;
@@ -285,10 +291,11 @@ class Render {
uint32_t recent_connection_image_save_time_ = 0;
// main window render
SDL_Window *main_window_ = nullptr;
SDL_Renderer *main_renderer_ = nullptr;
ImGuiContext *main_ctx_ = nullptr;
SDL_Window* main_window_ = nullptr;
SDL_Renderer* main_renderer_ = nullptr;
ImGuiContext* main_ctx_ = nullptr;
bool exit_ = false;
const int sdl_refresh_ms_ = 16; // ~60 FPS
// main window properties
bool start_mouse_controller_ = false;
@@ -346,11 +353,13 @@ class Render {
std::string focused_remote_id_ = "";
bool need_to_send_host_info_ = false;
SDL_Event last_mouse_event;
SDL_AudioStream* output_stream_;
uint32_t STREAM_REFRESH_EVENT = 0;
// stream window render
SDL_Window *stream_window_ = nullptr;
SDL_Renderer *stream_renderer_ = nullptr;
ImGuiContext *stream_ctx_ = nullptr;
SDL_Window* stream_window_ = nullptr;
SDL_Renderer* stream_renderer_ = nullptr;
ImGuiContext* stream_ctx_ = nullptr;
// stream window properties
bool need_to_create_stream_window_ = false;
@@ -363,7 +372,7 @@ class Render {
int stream_window_height_default_ = 720;
float stream_window_width_ = 1280;
float stream_window_height_ = 720;
uint32_t stream_pixformat_ = 0;
SDL_PixelFormat stream_pixformat_ = SDL_PIXELFORMAT_NV12;
int stream_window_width_real_ = 1280;
int stream_window_height_real_ = 720;
float stream_window_dpi_scaling_w_ = 1.0f;
@@ -377,7 +386,6 @@ class Render {
bool rejoin_ = false;
bool local_id_copied_ = false;
bool show_password_ = true;
bool regenerate_password_ = false;
bool show_about_window_ = false;
bool show_connection_status_window_ = false;
bool show_reset_password_window_ = false;
@@ -391,12 +399,11 @@ class Render {
std::string delete_connection_name_ = "";
bool re_enter_remote_id_ = false;
double copy_start_time_ = 0;
double regenerate_password_start_time_ = 0;
SignalStatus signal_status_ = SignalStatus::SignalClosed;
std::string signal_status_str_ = "";
bool signal_connected_ = false;
PeerPtr *peer_ = nullptr;
PeerPtr *peer_reserved_ = nullptr;
PeerPtr* peer_ = nullptr;
PeerPtr* peer_reserved_ = nullptr;
std::string video_primary_label_ = "primary_display";
std::string video_secondary_label_ = "secondary_display";
std::string audio_label_ = "audio";
@@ -404,13 +411,13 @@ class Render {
Params params_;
SDL_AudioDeviceID input_dev_;
SDL_AudioDeviceID output_dev_;
ScreenCapturerFactory *screen_capturer_factory_ = nullptr;
ScreenCapturer *screen_capturer_ = nullptr;
SpeakerCapturerFactory *speaker_capturer_factory_ = nullptr;
SpeakerCapturer *speaker_capturer_ = nullptr;
DeviceControllerFactory *device_controller_factory_ = nullptr;
MouseController *mouse_controller_ = nullptr;
KeyboardCapturer *keyboard_capturer_ = nullptr;
ScreenCapturerFactory* screen_capturer_factory_ = nullptr;
ScreenCapturer* screen_capturer_ = nullptr;
SpeakerCapturerFactory* speaker_capturer_factory_ = nullptr;
SpeakerCapturer* speaker_capturer_ = nullptr;
DeviceControllerFactory* device_controller_factory_ = nullptr;
MouseController* mouse_controller_ = nullptr;
KeyboardCapturer* keyboard_capturer_ = nullptr;
std::vector<DisplayInfo> display_info_list_;
uint64_t last_frame_time_;
char client_id_[10] = "";
@@ -419,21 +426,24 @@ class Render {
char password_saved_[7] = "";
int language_button_value_ = 0;
int video_quality_button_value_ = 0;
int video_frame_rate_button_value_ = 0;
int video_encode_format_button_value_ = 0;
bool enable_hardware_video_codec_ = false;
bool enable_turn_ = false;
bool enable_srtp_ = false;
int language_button_value_last_ = 0;
int video_quality_button_value_last_ = 0;
int video_encode_format_button_value_last_ = 0;
bool enable_hardware_video_codec_last_ = false;
bool enable_turn_last_ = false;
bool enable_srtp_last_ = false;
bool settings_window_pos_reset_ = true;
/* ------ main window property end ------ */
/* ------ sub stream window property start ------ */
std::unordered_map<std::string, std::shared_ptr<SubStreamWindowProperties>>
client_properties_;
void CloseTab(decltype(client_properties_)::iterator &it);
void CloseTab(decltype(client_properties_)::iterator& it);
/* ------ stream window property end ------ */
};

View File

@@ -6,8 +6,6 @@
#define NV12_BUFFER_SIZE 1280 * 720 * 3 / 2
#define STREAM_FRASH (SDL_USEREVENT + 1)
#ifdef DESK_PORT_DEBUG
#else
#define MOUSE_CONTROL 1
@@ -28,7 +26,7 @@ int Render::SendKeyCommand(int key_code, bool is_down) {
client_properties_.end()) {
auto props = client_properties_[controlled_remote_id_];
if (props->connection_status_ == ConnectionStatus::Connected) {
SendDataFrame(props->peer_, (const char *)&remote_action,
SendDataFrame(props->peer_, (const char*)&remote_action,
sizeof(remote_action), props->data_label_.c_str());
}
}
@@ -37,14 +35,14 @@ int Render::SendKeyCommand(int key_code, bool is_down) {
return 0;
}
int Render::ProcessMouseEvent(SDL_Event &event) {
int Render::ProcessMouseEvent(const SDL_Event& event) {
controlled_remote_id_ = "";
int video_width, video_height = 0;
int render_width, render_height = 0;
float ratio_x, ratio_y = 0;
RemoteAction remote_action;
for (auto &it : client_properties_) {
for (auto& it : client_properties_) {
auto props = it.second;
if (!props->control_mouse_) {
continue;
@@ -68,7 +66,7 @@ int Render::ProcessMouseEvent(SDL_Event &event) {
(float)(event.button.y - props->stream_render_rect_.y) /
render_height;
if (SDL_MOUSEBUTTONDOWN == event.type) {
if (SDL_EVENT_MOUSE_BUTTON_DOWN == event.type) {
remote_action.type = ControlType::mouse;
if (SDL_BUTTON_LEFT == event.button.button) {
remote_action.m.flag = MouseFlag::left_down;
@@ -77,7 +75,7 @@ int Render::ProcessMouseEvent(SDL_Event &event) {
} else if (SDL_BUTTON_MIDDLE == event.button.button) {
remote_action.m.flag = MouseFlag::middle_down;
}
} else if (SDL_MOUSEBUTTONUP == event.type) {
} else if (SDL_EVENT_MOUSE_BUTTON_UP == event.type) {
remote_action.type = ControlType::mouse;
if (SDL_BUTTON_LEFT == event.button.button) {
remote_action.m.flag = MouseFlag::left_up;
@@ -86,7 +84,7 @@ int Render::ProcessMouseEvent(SDL_Event &event) {
} else if (SDL_BUTTON_MIDDLE == event.button.button) {
remote_action.m.flag = MouseFlag::middle_up;
}
} else if (SDL_MOUSEMOTION == event.type) {
} else if (SDL_EVENT_MOUSE_MOTION == event.type) {
remote_action.type = ControlType::mouse;
remote_action.m.flag = MouseFlag::move;
}
@@ -94,9 +92,9 @@ int Render::ProcessMouseEvent(SDL_Event &event) {
if (props->control_bar_hovered_ || props->display_selectable_hovered_) {
remote_action.m.flag = MouseFlag::move;
}
SendDataFrame(props->peer_, (const char *)&remote_action,
SendDataFrame(props->peer_, (const char*)&remote_action,
sizeof(remote_action), props->data_label_.c_str());
} else if (SDL_MOUSEWHEEL == event.type &&
} else if (SDL_EVENT_MOUSE_WHEEL == event.type &&
last_mouse_event.button.x >= props->stream_render_rect_.x &&
last_mouse_event.button.x <= props->stream_render_rect_.x +
props->stream_render_rect_.w &&
@@ -127,7 +125,7 @@ int Render::ProcessMouseEvent(SDL_Event &event) {
(float)(event.button.y - props->stream_render_rect_.y) /
render_height;
SendDataFrame(props->peer_, (const char *)&remote_action,
SendDataFrame(props->peer_, (const char*)&remote_action,
sizeof(remote_action), props->data_label_.c_str());
}
}
@@ -135,8 +133,8 @@ int Render::ProcessMouseEvent(SDL_Event &event) {
return 0;
}
void Render::SdlCaptureAudioIn(void *userdata, Uint8 *stream, int len) {
Render *render = (Render *)userdata;
void Render::SdlCaptureAudioIn(void* userdata, Uint8* stream, int len) {
Render* render = (Render*)userdata;
if (!render) {
return;
}
@@ -145,7 +143,7 @@ void Render::SdlCaptureAudioIn(void *userdata, Uint8 *stream, int len) {
for (auto it : render->client_properties_) {
auto props = it.second;
if (props->connection_status_ == ConnectionStatus::Connected) {
SendAudioFrame(props->peer_, (const char *)stream, len,
SendAudioFrame(props->peer_, (const char*)stream, len,
render->audio_label_.c_str());
}
}
@@ -158,8 +156,8 @@ void Render::SdlCaptureAudioIn(void *userdata, Uint8 *stream, int len) {
}
}
void Render::SdlCaptureAudioOut([[maybe_unused]] void *userdata,
[[maybe_unused]] Uint8 *stream,
void Render::SdlCaptureAudioOut([[maybe_unused]] void* userdata,
[[maybe_unused]] Uint8* stream,
[[maybe_unused]] int len) {
// Render *render = (Render *)userdata;
// for (auto it : render->client_properties_) {
@@ -186,10 +184,10 @@ void Render::SdlCaptureAudioOut([[maybe_unused]] void *userdata,
// render->audio_buffer_fresh_ = false;
}
void Render::OnReceiveVideoBufferCb(const XVideoFrame *video_frame,
const char *user_id, size_t user_id_size,
void *user_data) {
Render *render = (Render *)user_data;
void Render::OnReceiveVideoBufferCb(const XVideoFrame* video_frame,
const char* user_id, size_t user_id_size,
void* user_data) {
Render* render = (Render*)user_data;
if (!render) {
return;
}
@@ -199,7 +197,7 @@ void Render::OnReceiveVideoBufferCb(const XVideoFrame *video_frame,
render->client_properties_.end()) {
return;
}
SubStreamWindowProperties *props =
SubStreamWindowProperties* props =
render->client_properties_.find(remote_id)->second.get();
if (props->connection_established_) {
@@ -231,30 +229,50 @@ void Render::OnReceiveVideoBufferCb(const XVideoFrame *video_frame,
}
SDL_Event event;
event.type = STREAM_FRASH;
event.user.type = STREAM_FRASH;
event.type = render->STREAM_REFRESH_EVENT;
event.user.data1 = props;
SDL_PushEvent(&event);
props->streaming_ = true;
if (props->net_traffic_stats_button_pressed_) {
props->frame_count_++;
auto now = std::chrono::steady_clock::now();
auto elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(
now - props->last_time_)
.count();
if (elapsed >= 1000) {
props->fps_ = props->frame_count_ * 1000 / elapsed;
props->frame_count_ = 0;
props->last_time_ = now;
}
}
}
}
void Render::OnReceiveAudioBufferCb(const char *data, size_t size,
const char *user_id, size_t user_id_size,
void *user_data) {
Render *render = (Render *)user_data;
void Render::OnReceiveAudioBufferCb(const char* data, size_t size,
const char* user_id, size_t user_id_size,
void* user_data) {
Render* render = (Render*)user_data;
if (!render) {
return;
}
render->audio_buffer_fresh_ = true;
SDL_QueueAudio(render->output_dev_, data, (uint32_t)size);
if (render->output_stream_) {
int pushed = SDL_PutAudioStreamData(
render->output_stream_, (const Uint8*)data, static_cast<int>(size));
if (pushed < 0) {
LOG_ERROR("Failed to push audio data: {}", SDL_GetError());
}
}
}
void Render::OnReceiveDataBufferCb(const char *data, size_t size,
const char *user_id, size_t user_id_size,
void *user_data) {
Render *render = (Render *)user_data;
void Render::OnReceiveDataBufferCb(const char* data, size_t size,
const char* user_id, size_t user_id_size,
void* user_data) {
Render* render = (Render*)user_data;
if (!render) {
return;
}
@@ -321,9 +339,9 @@ void Render::OnReceiveDataBufferCb(const char *data, size_t size,
}
}
void Render::OnSignalStatusCb(SignalStatus status, const char *user_id,
size_t user_id_size, void *user_data) {
Render *render = (Render *)user_data;
void Render::OnSignalStatusCb(SignalStatus status, const char* user_id,
size_t user_id_size, void* user_data) {
Render* render = (Render*)user_data;
if (!render) {
return;
}
@@ -374,9 +392,9 @@ void Render::OnSignalStatusCb(SignalStatus status, const char *user_id,
}
}
void Render::OnConnectionStatusCb(ConnectionStatus status, const char *user_id,
const size_t user_id_size, void *user_data) {
Render *render = (Render *)user_data;
void Render::OnConnectionStatusCb(ConnectionStatus status, const char* user_id,
const size_t user_id_size, void* user_data) {
Render* render = (Render*)user_data;
if (!render) return;
std::string remote_id(user_id, user_id_size);
@@ -464,19 +482,19 @@ void Render::OnConnectionStatusCb(ConnectionStatus status, const char *user_id,
}
}
void Render::NetStatusReport(const char *client_id, size_t client_id_size,
void Render::NetStatusReport(const char* client_id, size_t client_id_size,
TraversalMode mode,
const XNetTrafficStats *net_traffic_stats,
const char *user_id, const size_t user_id_size,
void *user_data) {
Render *render = (Render *)user_data;
const XNetTrafficStats* net_traffic_stats,
const char* user_id, const size_t user_id_size,
void* user_data) {
Render* render = (Render*)user_data;
if (!render) {
return;
}
if (strchr(client_id, '@') != nullptr && strchr(user_id, '-') == nullptr) {
std::string id, password;
const char *at_pos = strchr(client_id, '@');
const char* at_pos = strchr(client_id, '@');
if (at_pos == nullptr) {
id = client_id;
password.clear();

View File

@@ -6,7 +6,7 @@
int Render::SettingWindow() {
if (show_settings_window_) {
if (settings_window_pos_reset_) {
const ImGuiViewport *viewport = ImGui::GetMainViewport();
const ImGuiViewport* viewport = ImGui::GetMainViewport();
if (ConfigCenter::LANGUAGE::CHINESE == localization_language_) {
ImGui::SetNextWindowPos(
ImVec2((viewport->WorkSize.x - viewport->WorkPos.x -
@@ -36,6 +36,9 @@ int Render::SettingWindow() {
// Settings
{
static int settings_items_padding = 30;
int settings_items_offset = 0;
ImGui::SetWindowFontScale(0.5f);
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(1.0f, 1.0f, 1.0f, 1.0f));
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 5.0f);
@@ -49,11 +52,12 @@ int Render::SettingWindow() {
ImGui::SetWindowFontScale(0.5f);
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0f);
{
const char *language_items[] = {
const char* language_items[] = {
localization::language_zh[localization_language_index_].c_str(),
localization::language_en[localization_language_index_].c_str()};
ImGui::SetCursorPosY(32);
settings_items_offset += settings_items_padding;
ImGui::SetCursorPosY(settings_items_offset + 2);
ImGui::Text(
"%s", localization::language[localization_language_index_].c_str());
if (ConfigCenter::LANGUAGE::CHINESE == localization_language_) {
@@ -61,7 +65,7 @@ int Render::SettingWindow() {
} else {
ImGui::SetCursorPosX(LANGUAGE_SELECT_WINDOW_PADDING_EN);
}
ImGui::SetCursorPosY(30);
ImGui::SetCursorPosY(settings_items_offset);
ImGui::SetNextItemWidth(SETTINGS_SELECT_WINDOW_WIDTH);
ImGui::Combo("##language", &language_button_value_, language_items,
@@ -75,7 +79,7 @@ int Render::SettingWindow() {
}
{
const char *video_quality_items[] = {
const char* video_quality_items[] = {
localization::video_quality_high[localization_language_index_]
.c_str(),
localization::video_quality_medium[localization_language_index_]
@@ -83,7 +87,8 @@ int Render::SettingWindow() {
localization::video_quality_low[localization_language_index_]
.c_str()};
ImGui::SetCursorPosY(62);
settings_items_offset += settings_items_padding;
ImGui::SetCursorPosY(settings_items_offset + 2);
ImGui::Text(
"%s",
localization::video_quality[localization_language_index_].c_str());
@@ -93,7 +98,7 @@ int Render::SettingWindow() {
} else {
ImGui::SetCursorPosX(VIDEO_QUALITY_SELECT_WINDOW_PADDING_EN);
}
ImGui::SetCursorPosY(60);
ImGui::SetCursorPosY(settings_items_offset);
ImGui::SetNextItemWidth(SETTINGS_SELECT_WINDOW_WIDTH);
ImGui::Combo("##video_quality", &video_quality_button_value_,
@@ -103,11 +108,36 @@ int Render::SettingWindow() {
ImGui::Separator();
{
const char *video_encode_format_items[] = {
const char* video_frame_rate_items[] = {"30", "60"};
settings_items_offset += settings_items_padding;
ImGui::SetCursorPosY(settings_items_offset + 2);
ImGui::Text("%s",
localization::video_frame_rate[localization_language_index_]
.c_str());
if (ConfigCenter::LANGUAGE::CHINESE == localization_language_) {
ImGui::SetCursorPosX(VIDEO_FRAME_RATE_SELECT_WINDOW_PADDING_CN);
} else {
ImGui::SetCursorPosX(VIDEO_FRAME_RATE_SELECT_WINDOW_PADDING_EN);
}
ImGui::SetCursorPosY(settings_items_offset);
ImGui::SetNextItemWidth(SETTINGS_SELECT_WINDOW_WIDTH);
ImGui::Combo("##video_frame_rate", &video_frame_rate_button_value_,
video_frame_rate_items,
IM_ARRAYSIZE(video_frame_rate_items));
}
ImGui::Separator();
{
const char* video_encode_format_items[] = {
localization::av1[localization_language_index_].c_str(),
localization::h264[localization_language_index_].c_str()};
ImGui::SetCursorPosY(92);
settings_items_offset += settings_items_padding;
ImGui::SetCursorPosY(settings_items_offset + 2);
ImGui::Text(
"%s",
localization::video_encode_format[localization_language_index_]
@@ -118,7 +148,7 @@ int Render::SettingWindow() {
} else {
ImGui::SetCursorPosX(VIDEO_ENCODE_FORMAT_SELECT_WINDOW_PADDING_EN);
}
ImGui::SetCursorPosY(90);
ImGui::SetCursorPosY(settings_items_offset);
ImGui::SetNextItemWidth(SETTINGS_SELECT_WINDOW_WIDTH);
ImGui::Combo(
@@ -129,7 +159,8 @@ int Render::SettingWindow() {
ImGui::Separator();
{
ImGui::SetCursorPosY(122);
settings_items_offset += settings_items_padding;
ImGui::SetCursorPosY(settings_items_offset + 2);
ImGui::Text("%s", localization::enable_hardware_video_codec
[localization_language_index_]
.c_str());
@@ -139,7 +170,7 @@ int Render::SettingWindow() {
} else {
ImGui::SetCursorPosX(ENABLE_HARDWARE_VIDEO_CODEC_CHECKBOX_PADDING_EN);
}
ImGui::SetCursorPosY(120);
ImGui::SetCursorPosY(settings_items_offset);
ImGui::Checkbox("##enable_hardware_video_codec",
&enable_hardware_video_codec_);
}
@@ -147,7 +178,8 @@ int Render::SettingWindow() {
ImGui::Separator();
{
ImGui::SetCursorPosY(152);
settings_items_offset += settings_items_padding;
ImGui::SetCursorPosY(settings_items_offset + 2);
ImGui::Text(
"%s",
localization::enable_turn[localization_language_index_].c_str());
@@ -157,10 +189,28 @@ int Render::SettingWindow() {
} else {
ImGui::SetCursorPosX(ENABLE_TURN_CHECKBOX_PADDING_EN);
}
ImGui::SetCursorPosY(150);
ImGui::SetCursorPosY(settings_items_offset);
ImGui::Checkbox("##enable_turn", &enable_turn_);
}
ImGui::Separator();
{
settings_items_offset += settings_items_padding;
ImGui::SetCursorPosY(settings_items_offset + 2);
ImGui::Text(
"%s",
localization::enable_srtp[localization_language_index_].c_str());
if (ConfigCenter::LANGUAGE::CHINESE == localization_language_) {
ImGui::SetCursorPosX(ENABLE_SRTP_CHECKBOX_PADDING_CN);
} else {
ImGui::SetCursorPosX(ENABLE_SRTP_CHECKBOX_PADDING_EN);
}
ImGui::SetCursorPosY(settings_items_offset);
ImGui::Checkbox("##enable_srtp", &enable_srtp_);
}
if (stream_window_inited_) {
ImGui::EndDisabled();
}
@@ -170,7 +220,9 @@ int Render::SettingWindow() {
} else {
ImGui::SetCursorPosX(SETTINGS_OK_BUTTON_PADDING_EN);
}
ImGui::SetCursorPosY(190.0f);
settings_items_offset += settings_items_padding;
ImGui::SetCursorPosY(settings_items_offset);
ImGui::PopStyleVar();
// OK
@@ -227,6 +279,14 @@ int Render::SettingWindow() {
}
enable_turn_last_ = enable_turn_;
// SRTP
if (enable_srtp_) {
config_center_.SetSrtp(true);
} else {
config_center_.SetSrtp(false);
}
enable_srtp_last_ = enable_srtp_;
SaveSettingsIntoCacheFile();
settings_window_pos_reset_ = true;
@@ -236,7 +296,7 @@ int Render::SettingWindow() {
// Recreate peer instance
if (!stream_window_inited_) {
LOG_INFO("Recreate peer instance");
DestroyPeer(&peer_);
CleanupPeers();
CreateConnectionPeer();
}
}

View File

@@ -34,7 +34,7 @@ void Render::CloseTab(decltype(client_properties_)::iterator& it) {
it = client_properties_.erase(it);
if (client_properties_.empty()) {
SDL_Event event;
event.type = SDL_QUIT;
event.type = SDL_EVENT_QUIT;
SDL_PushEvent(&event);
}
}
@@ -86,8 +86,11 @@ int Render::StreamWindow() {
}
ImGui::SetWindowFontScale(0.6f);
if (ImGui::BeginTabItem(props->remote_id_.c_str(),
&props->tab_opened_)) {
std::string tab_label =
enable_srtp_
? std::string(ICON_FA_SHIELD_HALVED) + " " + props->remote_id_
: props->remote_id_;
if (ImGui::BeginTabItem(tab_label.c_str(), &props->tab_opened_)) {
props->tab_selected_ = true;
ImGui::SetWindowFontScale(1.0f);
@@ -120,7 +123,7 @@ int Render::StreamWindow() {
it = client_properties_.erase(it);
if (client_properties_.empty()) {
SDL_Event event;
event.type = SDL_QUIT;
event.type = SDL_EVENT_QUIT;
SDL_PushEvent(&event);
}
} else {
@@ -175,11 +178,11 @@ int Render::StreamWindow() {
if (!props->peer_) {
fullscreen_button_pressed_ = false;
SDL_SetWindowFullscreen(stream_window_, SDL_FALSE);
SDL_SetWindowFullscreen(stream_window_, false);
it = client_properties_.erase(it);
if (client_properties_.empty()) {
SDL_Event event;
event.type = SDL_QUIT;
event.type = SDL_EVENT_QUIT;
SDL_PushEvent(&event);
}
} else {

View File

@@ -38,9 +38,10 @@ bool LoadTextureFromMemory(const void* data, size_t data_size,
}
// ABGR
SDL_Surface* surface = SDL_CreateRGBSurfaceFrom(
(void*)image_data, image_width, image_height, channels * 8,
channels * image_width, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000);
int pitch = image_width * channels;
SDL_Surface* surface =
SDL_CreateSurfaceFrom(image_width, image_height, SDL_PIXELFORMAT_RGBA32,
(void*)image_data, pitch);
if (surface == nullptr) {
LOG_ERROR("Failed to create SDL surface: [{}]", SDL_GetError());
return false;
@@ -55,7 +56,7 @@ bool LoadTextureFromMemory(const void* data, size_t data_size,
*out_width = image_width;
*out_height = image_height;
SDL_FreeSurface(surface);
SDL_DestroySurface(surface);
stbi_image_free(image_data);
return true;

View File

@@ -7,7 +7,7 @@
#ifndef _THUMBNAIL_H_
#define _THUMBNAIL_H_
#include <SDL.h>
#include <SDL3/SDL.h>
#include <filesystem>
#include <map>

View File

@@ -139,7 +139,7 @@ int Render::TitleBar(bool main_window) {
std::string close_button = "##xmark"; // ICON_FA_XMARK;
if (ImGui::Button(close_button.c_str(), ImVec2(BUTTON_PADDING, 30))) {
SDL_Event event;
event.type = SDL_QUIT;
event.type = SDL_EVENT_QUIT;
SDL_PushEvent(&event);
}
draw_list->AddLine(ImVec2(xmark_pos_x - xmark_size / 2 - 0.25f,

View File

@@ -17,26 +17,24 @@ if is_mode("debug") then
end
add_requires("spdlog 1.14.1", {system = false})
add_requires("imgui v1.91.5-docking", {configs = {sdl2 = true, sdl2_renderer = true}})
add_requires("imgui v1.91.5-docking", {configs = {sdl3 = true, sdl3_renderer = true}})
add_requires("openssl3 3.3.2", {system = false})
add_requires("libsdl2", {configs = {pulseaudio = true}})
add_packages("libsdl2")
if is_os("windows") then
add_requires("libyuv", "miniaudio 0.11.21")
add_links("Shell32", "windowsapp", "dwmapi", "User32", "kernel32",
"SDL2-static", "SDL2main", "gdi32", "winmm", "setupapi", "version",
"SDL3-static", "gdi32", "winmm", "setupapi", "version",
"Imm32", "iphlpapi")
add_cxflags("/WX")
set_runtimes("MT")
elseif is_os("linux") then
add_links("pulse-simple", "pulse")
add_requires("libyuv")
add_syslinks("pthread", "dl")
add_links("SDL2", "asound", "X11", "Xtst", "Xrandr")
add_links("SDL3", "asound", "X11", "Xtst", "Xrandr")
add_cxflags("-Wno-unused-variable")
elseif is_os("macosx") then
add_links("SDL2", "SDL2main")
add_links("SDL3")
add_ldflags("-Wl,-ld_classic")
add_cxflags("-Wno-unused-variable")
add_frameworks("OpenGL", "IOSurface", "ScreenCaptureKit", "AVFoundation",
@@ -144,11 +142,4 @@ target("single_window")
target("crossdesk")
set_kind("binary")
add_deps("rd_log", "common", "single_window")
if is_os("windows") then
add_files("icons/app.rc")
elseif is_os("macosx") then
-- add_rules("xcode.application")
-- add_files("Info.plist")
elseif is_os("linux") then
end
add_files("src/gui/main.cpp")