├── .github └── workflows │ ├── build-client.yml │ ├── build-server.yml │ └── deploy-web.yml ├── .gitignore ├── LICENSE ├── README.md ├── client ├── .gitignore ├── .metadata ├── .vscode │ └── settings.json ├── analysis_options.yaml ├── android │ ├── .gitignore │ ├── app │ │ ├── build.gradle │ │ └── src │ │ │ ├── debug │ │ │ └── AndroidManifest.xml │ │ │ ├── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── kotlin │ │ │ │ └── com │ │ │ │ │ └── example │ │ │ │ │ └── vtablet │ │ │ │ │ └── MainActivity.kt │ │ │ └── res │ │ │ │ ├── drawable-v21 │ │ │ │ └── launch_background.xml │ │ │ │ ├── drawable │ │ │ │ └── launch_background.xml │ │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher_foreground.png │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher_foreground.png │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher_foreground.png │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher_foreground.png │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher_foreground.png │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── playstore-icon.png │ │ │ │ ├── values-night │ │ │ │ └── styles.xml │ │ │ │ └── values │ │ │ │ ├── ic_launcher_background.xml │ │ │ │ └── styles.xml │ │ │ └── profile │ │ │ └── AndroidManifest.xml │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ └── gradle-wrapper.properties │ └── settings.gradle ├── assets │ └── icon │ │ └── icon_256x.ico ├── ios │ ├── .gitignore │ ├── Flutter │ │ ├── AppFrameworkInfo.plist │ │ ├── Debug.xcconfig │ │ └── Release.xcconfig │ ├── Runner.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ │ └── WorkspaceSettings.xcsettings │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ ├── Runner.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ └── WorkspaceSettings.xcsettings │ └── Runner │ │ ├── AppDelegate.swift │ │ ├── Assets.xcassets │ │ ├── AppIcon.appiconset │ │ │ ├── Contents.json │ │ │ ├── Icon-App-1024x1024@1x.png │ │ │ ├── Icon-App-20x20@1x.png │ │ │ ├── Icon-App-20x20@2x.png │ │ │ ├── Icon-App-20x20@3x.png │ │ │ ├── Icon-App-29x29@1x.png │ │ │ ├── Icon-App-29x29@2x.png │ │ │ ├── Icon-App-29x29@3x.png │ │ │ ├── Icon-App-40x40@1x.png │ │ │ ├── Icon-App-40x40@2x.png │ │ │ ├── Icon-App-40x40@3x.png │ │ │ ├── Icon-App-60x60@2x.png │ │ │ ├── Icon-App-60x60@3x.png │ │ │ ├── Icon-App-76x76@1x.png │ │ │ ├── Icon-App-76x76@2x.png │ │ │ └── Icon-App-83.5x83.5@2x.png │ │ └── LaunchImage.imageset │ │ │ ├── Contents.json │ │ │ ├── LaunchImage.png │ │ │ ├── LaunchImage@2x.png │ │ │ ├── LaunchImage@3x.png │ │ │ └── README.md │ │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ │ ├── Info.plist │ │ └── Runner-Bridging-Header.h ├── l10n.yaml ├── lib │ ├── components │ │ ├── delay.dart │ │ └── setting_card.dart │ ├── configs.dart │ ├── home.dart │ ├── l10n │ │ ├── app_en.arb │ │ └── app_zh.arb │ ├── main.dart │ ├── services │ │ ├── connect.dart │ │ └── states.dart │ ├── setting_screens │ │ ├── about.dart │ │ ├── appearance.dart │ │ ├── connection.dart │ │ └── control.dart │ └── vtablet.dart ├── linux │ ├── .gitignore │ ├── CMakeLists.txt │ ├── flutter │ │ ├── CMakeLists.txt │ │ ├── generated_plugin_registrant.cc │ │ ├── generated_plugin_registrant.h │ │ └── generated_plugins.cmake │ ├── main.cc │ ├── my_application.cc │ └── my_application.h ├── macos │ ├── .gitignore │ ├── Flutter │ │ ├── Flutter-Debug.xcconfig │ │ ├── Flutter-Release.xcconfig │ │ └── GeneratedPluginRegistrant.swift │ ├── Runner.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ └── xcshareddata │ │ │ │ └── IDEWorkspaceChecks.plist │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ ├── Runner.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ └── Runner │ │ ├── AppDelegate.swift │ │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ ├── Contents.json │ │ │ ├── app_icon_1024.png │ │ │ ├── app_icon_128.png │ │ │ ├── app_icon_16.png │ │ │ ├── app_icon_256.png │ │ │ ├── app_icon_32.png │ │ │ ├── app_icon_512.png │ │ │ └── app_icon_64.png │ │ ├── Base.lproj │ │ └── MainMenu.xib │ │ ├── Configs │ │ ├── AppInfo.xcconfig │ │ ├── Debug.xcconfig │ │ ├── Release.xcconfig │ │ └── Warnings.xcconfig │ │ ├── DebugProfile.entitlements │ │ ├── Info.plist │ │ ├── MainFlutterWindow.swift │ │ └── Release.entitlements ├── pubspec.lock ├── pubspec.yaml ├── web │ ├── .well-known │ │ └── assetlinks.json │ ├── favicon.png │ ├── icons │ │ ├── Icon-192.png │ │ ├── Icon-512.png │ │ ├── Icon-maskable-192.png │ │ └── Icon-maskable-512.png │ ├── index.html │ └── manifest.json └── windows │ ├── .gitignore │ ├── CMakeLists.txt │ ├── flutter │ ├── CMakeLists.txt │ ├── generated_plugin_registrant.cc │ ├── generated_plugin_registrant.h │ └── generated_plugins.cmake │ └── runner │ ├── CMakeLists.txt │ ├── Runner.rc │ ├── flutter_window.cpp │ ├── flutter_window.h │ ├── main.cpp │ ├── resource.h │ ├── resources │ └── app_icon.ico │ ├── runner.exe.manifest │ ├── utils.cpp │ ├── utils.h │ ├── win32_window.cpp │ └── win32_window.h └── server ├── .gitattributes ├── .gitignore ├── .vscode └── tasks.json ├── assets └── icon_256x.ico ├── bin ├── build.bat └── run.bat ├── controllers.go ├── docs └── connect.md ├── go.mod ├── go.sum ├── icon.go ├── internal ├── adb │ ├── adb.go │ ├── adb_windows.go │ └── windows │ │ ├── AdbWinApi.dll │ │ ├── AdbWinUsbApi.dll │ │ ├── NOTICE.txt │ │ ├── adb.exe │ │ ├── libwinpthread-1.dll │ │ └── source.properties ├── logger │ └── logger.go ├── pointer │ └── pointer.go ├── protocol │ └── const.go └── tools │ └── cmd.go ├── main.go ├── rsrc.syso ├── services.go └── tray.go /.github/workflows/build-client.yml: -------------------------------------------------------------------------------- 1 | name: Build Flutter Client (Android) 2 | 3 | on: 4 | # pull: 5 | # branches: [main] 6 | workflow_dispatch: 7 | 8 | jobs: 9 | Build-Client: 10 | runs-on: ubuntu-latest 11 | defaults: 12 | run: 13 | working-directory: ./client 14 | steps: 15 | - uses: actions/checkout@v3 16 | - uses: actions/setup-java@v2 17 | with: 18 | distribution: 'microsoft' 19 | java-version: '17' 20 | - uses: subosito/flutter-action@v2 21 | with: 22 | channel: 'stable' 23 | flutter-version: 3.27.1 24 | - run: flutter pub get 25 | 26 | # Build Android 27 | - run: flutter build apk 28 | - run: flutter build appbundle 29 | 30 | # Sign Android 31 | - name: Setup build tool version variable 32 | shell: bash 33 | run: | 34 | BUILD_TOOL_VERSION=$(ls /usr/local/lib/android/sdk/build-tools/ | tail -n 1) 35 | echo "BUILD_TOOL_VERSION=$BUILD_TOOL_VERSION" >> $GITHUB_ENV 36 | echo Last build tool version is: $BUILD_TOOL_VERSION 37 | - uses: r0adkll/sign-android-release@v1 38 | name: Sign app APK 39 | id: sign_apk 40 | with: 41 | releaseDirectory: client/build/app/outputs/flutter-apk 42 | signingKeyBase64: ${{ secrets.SIGNING_KEY }} 43 | alias: ${{ secrets.ALIAS }} 44 | keyStorePassword: ${{ secrets.KEY_PASSWORD }} 45 | keyPassword: ${{ secrets.KEY_PASSWORD }} 46 | env: 47 | BUILD_TOOLS_VERSION: ${{ env.BUILD_TOOL_VERSION }} 48 | # - uses: r0adkll/sign-android-release@v1 49 | # name: Sign app AAB 50 | # # ID used to access action output 51 | # id: sign_aab 52 | # with: 53 | # releaseDirectory: client/build/app/outputs/bundle/release 54 | # signingKeyBase64: ${{ secrets.SIGNING_KEY }} 55 | # alias: ${{ secrets.ALIAS }} 56 | # keyStorePassword: ${{ secrets.KEY_PASSWORD }} 57 | # keyPassword: ${{ secrets.KEY_PASSWORD }} 58 | # env: 59 | # BUILD_TOOLS_VERSION: "30.0.2" 60 | 61 | - uses: actions/upload-artifact@v3 62 | with: 63 | name: vTablet_client_apk 64 | path: client/build/app/outputs/flutter-apk/app-release.apk 65 | - uses: actions/upload-artifact@v3 66 | with: 67 | name: vTablet_client_aab 68 | path: client/build/app/outputs/bundle/release/app-release.aab 69 | - uses: actions/upload-artifact@v3 70 | with: 71 | name: vTablet_client_apk_signed 72 | path: ${{steps.sign_apk.outputs.signedReleaseFile}} 73 | -------------------------------------------------------------------------------- /.github/workflows/build-server.yml: -------------------------------------------------------------------------------- 1 | name: Build Golang Server 2 | 3 | on: 4 | # pull: 5 | # branches: [main] 6 | workflow_dispatch: 7 | 8 | jobs: 9 | Build-Server: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v3 13 | - name: Build 14 | uses: crazy-max/ghaction-xgo@v2 15 | with: 16 | xgo_version: latest 17 | go_version: latest 18 | dest: build 19 | prefix: vtablet 20 | targets: windows/amd64,windows/386 21 | # targets: windows/amd64,windows/386,linux/amd64,darwin/amd64,darwin/arm64 22 | v: true 23 | x: true 24 | race: false 25 | ldflags: -H=windowsgui -s -w 26 | buildmode: default 27 | trimpath: true 28 | working_dir: ./server 29 | 30 | - name: Run UPX 31 | uses: crazy-max/ghaction-upx@v2 32 | with: 33 | version: latest 34 | files: | 35 | server/build/*.exe 36 | args: --best 37 | 38 | - uses: actions/upload-artifact@v3 39 | with: 40 | name: vTablet_server_windows_386 41 | path: server/build/vtablet-windows-386.exe 42 | 43 | - uses: actions/upload-artifact@v3 44 | with: 45 | name: vTablet_server_windows_amd64 46 | path: server/build/vtablet-windows-amd64.exe -------------------------------------------------------------------------------- /.github/workflows/deploy-web.yml: -------------------------------------------------------------------------------- 1 | name: Deploy Web 2 | 3 | on: 4 | # pull: 5 | # branches: [main] 6 | workflow_dispatch: 7 | 8 | jobs: 9 | Deploy-Web: 10 | runs-on: ubuntu-latest 11 | defaults: 12 | run: 13 | working-directory: ./client 14 | steps: 15 | - uses: actions/checkout@v3 16 | - uses: actions/setup-java@v2 17 | with: 18 | distribution: 'zulu' 19 | java-version: '11' 20 | - uses: subosito/flutter-action@v2 21 | with: 22 | channel: 'stable' 23 | - run: flutter pub get 24 | 25 | # Build Web 26 | - run: flutter build web 27 | 28 | - uses: actions/upload-artifact@v2 29 | with: 30 | name: vTablet_client_web 31 | path: client/build/web 32 | 33 | - name: Publish to Cloudflare Pages 34 | uses: cloudflare/pages-action@1 35 | with: 36 | apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} 37 | accountId: 5b730025d7878dcd418287d4e2b66d8e 38 | projectName: vtablet-app 39 | directory: client/build/web 40 | gitHubToken: ${{ secrets.GITHUB_TOKEN }} 41 | 42 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ./dist/** 2 | /vscode -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Teages 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vTablet 2 | 3 | Use your tablet as your osu digitizer! 4 | 5 | > [!WARNING] 6 | > 3.0 is currently in preview version, and there may be incompatible changes in the transmission protocol. Please be sure to update the server and client at the same time. 7 | 8 | ## Help 9 | 10 | (WIP) 11 | 12 | ## TODO 13 | 14 | - [ ] Update check 15 | - [ ] Benchmarks 16 | -------------------------------------------------------------------------------- /client/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | migrate_working_dir/ 12 | 13 | # IntelliJ related 14 | *.iml 15 | *.ipr 16 | *.iws 17 | .idea/ 18 | 19 | # The .vscode folder contains launch configuration and tasks you configure in 20 | # VS Code which you may wish to be included in version control, so this line 21 | # is commented out by default. 22 | #.vscode/ 23 | 24 | # Flutter/Dart/Pub related 25 | **/doc/api/ 26 | **/ios/Flutter/.last_build_id 27 | .dart_tool/ 28 | .flutter-plugins 29 | .flutter-plugins-dependencies 30 | .packages 31 | .pub-cache/ 32 | .pub/ 33 | build/** 34 | 35 | # Web related 36 | lib/generated_plugin_registrant.dart 37 | 38 | # Symbolication related 39 | app.*.symbols 40 | 41 | # Obfuscation related 42 | app.*.map.json 43 | 44 | # Android Studio will place build artifacts here 45 | /android/app/debug 46 | /android/app/profile 47 | /android/app/release 48 | -------------------------------------------------------------------------------- /client/.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled. 5 | 6 | version: 7 | revision: f1875d570e39de09040c8f79aa13cc56baab8db1 8 | channel: stable 9 | 10 | project_type: app 11 | 12 | # Tracks metadata for the flutter migrate command 13 | migration: 14 | platforms: 15 | - platform: root 16 | create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 17 | base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 18 | - platform: android 19 | create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 20 | base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 21 | - platform: ios 22 | create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 23 | base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 24 | - platform: linux 25 | create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 26 | base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 27 | - platform: macos 28 | create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 29 | base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 30 | - platform: web 31 | create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 32 | base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 33 | - platform: windows 34 | create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 35 | base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1 36 | 37 | # User provided section 38 | 39 | # List of Local paths (relative to this file) that should be 40 | # ignored by the migrate tool. 41 | # 42 | # Files that are not part of the templates will be ignored by default. 43 | unmanaged_files: 44 | - 'lib/main.dart' 45 | - 'ios/Runner.xcodeproj/project.pbxproj' 46 | -------------------------------------------------------------------------------- /client/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "editor.codeActionsOnSave": { 3 | "source.fixAll": "explicit" 4 | }, 5 | "cmake.configureOnOpen": false 6 | } -------------------------------------------------------------------------------- /client/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # This file configures the analyzer, which statically analyzes Dart code to 2 | # check for errors, warnings, and lints. 3 | # 4 | # The issues identified by the analyzer are surfaced in the UI of Dart-enabled 5 | # IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be 6 | # invoked from the command line by running `flutter analyze`. 7 | 8 | # The following line activates a set of recommended lints for Flutter apps, 9 | # packages, and plugins designed to encourage good coding practices. 10 | include: package:flutter_lints/flutter.yaml 11 | 12 | linter: 13 | # The lint rules applied to this project can be customized in the 14 | # section below to disable rules from the `package:flutter_lints/flutter.yaml` 15 | # included above or to enable additional rules. A list of all available lints 16 | # and their documentation is published at 17 | # https://dart-lang.github.io/linter/lints/index.html. 18 | # 19 | # Instead of disabling a lint rule for the entire project in the 20 | # section below, it can also be suppressed for a single line of code 21 | # or a specific dart file by using the `// ignore: name_of_lint` and 22 | # `// ignore_for_file: name_of_lint` syntax on the line or in the file 23 | # producing the lint. 24 | rules: 25 | # avoid_print: false # Uncomment to disable the `avoid_print` rule 26 | # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule 27 | 28 | # Additional information about this file can be found at 29 | # https://dart.dev/guides/language/analysis-options 30 | -------------------------------------------------------------------------------- /client/android/.gitignore: -------------------------------------------------------------------------------- 1 | gradle-wrapper.jar 2 | /.gradle 3 | /captures/ 4 | /gradlew 5 | /gradlew.bat 6 | /local.properties 7 | GeneratedPluginRegistrant.java 8 | 9 | # Remember to never publicly share your keystore. 10 | # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app 11 | key.properties 12 | **/*.keystore 13 | **/*.jks 14 | -------------------------------------------------------------------------------- /client/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id "com.android.application" 3 | id "kotlin-android" 4 | // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. 5 | id "dev.flutter.flutter-gradle-plugin" 6 | } 7 | 8 | android { 9 | namespace = "xyz.teages.vtablet" 10 | compileSdk = flutter.compileSdkVersion 11 | ndkVersion = flutter.ndkVersion 12 | 13 | compileOptions { 14 | sourceCompatibility = JavaVersion.VERSION_1_8 15 | targetCompatibility = JavaVersion.VERSION_1_8 16 | } 17 | 18 | kotlinOptions { 19 | jvmTarget = JavaVersion.VERSION_1_8 20 | } 21 | 22 | defaultConfig { 23 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 24 | applicationId = "xyz.teages.vtablet" 25 | // You can update the following values to match your application needs. 26 | // For more information, see: https://flutter.dev/to/review-gradle-config. 27 | minSdk = flutter.minSdkVersion 28 | targetSdk = flutter.targetSdkVersion 29 | versionCode = flutter.versionCode 30 | versionName = flutter.versionName 31 | } 32 | 33 | buildTypes { 34 | release { 35 | // TODO: Add your own signing config for the release build. 36 | // Signing with the debug keys for now, so `flutter run --release` works. 37 | signingConfig = signingConfigs.debug 38 | } 39 | } 40 | } 41 | 42 | flutter { 43 | source = "../.." 44 | } 45 | -------------------------------------------------------------------------------- /client/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /client/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 10 | 18 | 22 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 42 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /client/android/app/src/main/kotlin/com/example/vtablet/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package xyz.teages.vtablet 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | 5 | class MainActivity: FlutterActivity() { 6 | } 7 | -------------------------------------------------------------------------------- /client/android/app/src/main/res/drawable-v21/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /client/android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /client/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /client/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /client/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Teages/vTablet/a46e1fcf721593f0824f74c6285591b53e5b09f1/client/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /client/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Teages/vTablet/a46e1fcf721593f0824f74c6285591b53e5b09f1/client/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /client/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Teages/vTablet/a46e1fcf721593f0824f74c6285591b53e5b09f1/client/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /client/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Teages/vTablet/a46e1fcf721593f0824f74c6285591b53e5b09f1/client/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /client/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Teages/vTablet/a46e1fcf721593f0824f74c6285591b53e5b09f1/client/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /client/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Teages/vTablet/a46e1fcf721593f0824f74c6285591b53e5b09f1/client/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /client/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Teages/vTablet/a46e1fcf721593f0824f74c6285591b53e5b09f1/client/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /client/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Teages/vTablet/a46e1fcf721593f0824f74c6285591b53e5b09f1/client/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /client/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Teages/vTablet/a46e1fcf721593f0824f74c6285591b53e5b09f1/client/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /client/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Teages/vTablet/a46e1fcf721593f0824f74c6285591b53e5b09f1/client/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /client/android/app/src/main/res/playstore-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Teages/vTablet/a46e1fcf721593f0824f74c6285591b53e5b09f1/client/android/app/src/main/res/playstore-icon.png -------------------------------------------------------------------------------- /client/android/app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /client/android/app/src/main/res/values/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #78C2EF 4 | -------------------------------------------------------------------------------- /client/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /client/android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /client/android/build.gradle: -------------------------------------------------------------------------------- 1 | allprojects { 2 | repositories { 3 | google() 4 | mavenCentral() 5 | } 6 | } 7 | 8 | rootProject.buildDir = "../build" 9 | subprojects { 10 | project.buildDir = "${rootProject.buildDir}/${project.name}" 11 | } 12 | subprojects { 13 | project.evaluationDependsOn(":app") 14 | } 15 | 16 | tasks.register("clean", Delete) { 17 | delete rootProject.buildDir 18 | } 19 | -------------------------------------------------------------------------------- /client/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=2G -XX:+HeapDumpOnOutOfMemoryError 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | -------------------------------------------------------------------------------- /client/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip 6 | -------------------------------------------------------------------------------- /client/android/settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | def flutterSdkPath = { 3 | def properties = new Properties() 4 | file("local.properties").withInputStream { properties.load(it) } 5 | def flutterSdkPath = properties.getProperty("flutter.sdk") 6 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 7 | return flutterSdkPath 8 | }() 9 | 10 | includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") 11 | 12 | repositories { 13 | google() 14 | mavenCentral() 15 | gradlePluginPortal() 16 | } 17 | } 18 | 19 | plugins { 20 | id "dev.flutter.flutter-plugin-loader" version "1.0.0" 21 | id "com.android.application" version "8.1.0" apply false 22 | id "org.jetbrains.kotlin.android" version "1.8.22" apply false 23 | } 24 | 25 | include ":app" 26 | -------------------------------------------------------------------------------- /client/assets/icon/icon_256x.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Teages/vTablet/a46e1fcf721593f0824f74c6285591b53e5b09f1/client/assets/icon/icon_256x.ico -------------------------------------------------------------------------------- /client/ios/.gitignore: -------------------------------------------------------------------------------- 1 | **/dgph 2 | *.mode1v3 3 | *.mode2v3 4 | *.moved-aside 5 | *.pbxuser 6 | *.perspectivev3 7 | **/*sync/ 8 | .sconsign.dblite 9 | .tags* 10 | **/.vagrant/ 11 | **/DerivedData/ 12 | Icon? 13 | **/Pods/ 14 | **/.symlinks/ 15 | profile 16 | xcuserdata 17 | **/.generated/ 18 | Flutter/App.framework 19 | Flutter/Flutter.framework 20 | Flutter/Flutter.podspec 21 | Flutter/Generated.xcconfig 22 | Flutter/ephemeral/ 23 | Flutter/app.flx 24 | Flutter/app.zip 25 | Flutter/flutter_assets/ 26 | Flutter/flutter_export_environment.sh 27 | ServiceDefinitions.json 28 | Runner/GeneratedPluginRegistrant.* 29 | 30 | # Exceptions to above rules. 31 | !default.mode1v3 32 | !default.mode2v3 33 | !default.pbxuser 34 | !default.perspectivev3 35 | -------------------------------------------------------------------------------- /client/ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 9.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /client/ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /client/ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /client/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /client/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /client/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /client/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 69 | 71 | 77 | 78 | 79 | 80 | 82 | 83 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /client/ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /client/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /client/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /client/ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Flutter 3 | 4 | @UIApplicationMain 5 | @objc class AppDelegate: FlutterAppDelegate { 6 | override func application( 7 | _ application: UIApplication, 8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 9 | ) -> Bool { 10 | GeneratedPluginRegistrant.register(with: self) 11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-App-20x20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-App-20x20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-App-29x29@1x.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-App-29x29@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "29x29", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-App-29x29@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-App-40x40@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "40x40", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-App-40x40@3x.png", 43 | "scale" : "3x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-App-60x60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "Icon-App-60x60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "20x20", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-App-20x20@1x.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "20x20", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-App-20x20@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "29x29", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-App-29x29@1x.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "29x29", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-App-29x29@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "40x40", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-App-40x40@1x.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "40x40", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-App-40x40@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "76x76", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-App-76x76@1x.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "76x76", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-App-76x76@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "83.5x83.5", 107 | "idiom" : "ipad", 108 | "filename" : "Icon-App-83.5x83.5@2x.png", 109 | "scale" : "2x" 110 | }, 111 | { 112 | "size" : "1024x1024", 113 | "idiom" : "ios-marketing", 114 | "filename" : "Icon-App-1024x1024@1x.png", 115 | "scale" : "1x" 116 | } 117 | ], 118 | "info" : { 119 | "version" : 1, 120 | "author" : "xcode" 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Teages/vTablet/a46e1fcf721593f0824f74c6285591b53e5b09f1/client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Teages/vTablet/a46e1fcf721593f0824f74c6285591b53e5b09f1/client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Teages/vTablet/a46e1fcf721593f0824f74c6285591b53e5b09f1/client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Teages/vTablet/a46e1fcf721593f0824f74c6285591b53e5b09f1/client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Teages/vTablet/a46e1fcf721593f0824f74c6285591b53e5b09f1/client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Teages/vTablet/a46e1fcf721593f0824f74c6285591b53e5b09f1/client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Teages/vTablet/a46e1fcf721593f0824f74c6285591b53e5b09f1/client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Teages/vTablet/a46e1fcf721593f0824f74c6285591b53e5b09f1/client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Teages/vTablet/a46e1fcf721593f0824f74c6285591b53e5b09f1/client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Teages/vTablet/a46e1fcf721593f0824f74c6285591b53e5b09f1/client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Teages/vTablet/a46e1fcf721593f0824f74c6285591b53e5b09f1/client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Teages/vTablet/a46e1fcf721593f0824f74c6285591b53e5b09f1/client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Teages/vTablet/a46e1fcf721593f0824f74c6285591b53e5b09f1/client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Teages/vTablet/a46e1fcf721593f0824f74c6285591b53e5b09f1/client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Teages/vTablet/a46e1fcf721593f0824f74c6285591b53e5b09f1/client/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /client/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchImage.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchImage@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchImage@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /client/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Teages/vTablet/a46e1fcf721593f0824f74c6285591b53e5b09f1/client/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /client/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Teages/vTablet/a46e1fcf721593f0824f74c6285591b53e5b09f1/client/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /client/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Teages/vTablet/a46e1fcf721593f0824f74c6285591b53e5b09f1/client/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /client/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /client/ios/Runner/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /client/ios/Runner/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /client/ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleDisplayName 8 | Vtablet 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | vtablet 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | $(FLUTTER_BUILD_NUMBER) 25 | LSRequiresIPhoneOS 26 | 27 | UILaunchStoryboardName 28 | LaunchScreen 29 | UIMainStoryboardFile 30 | Main 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | UIViewControllerBasedStatusBarAppearance 45 | 46 | CADisableMinimumFrameDurationOnPhone 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /client/ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /client/l10n.yaml: -------------------------------------------------------------------------------- 1 | arb-dir: lib/l10n 2 | template-arb-file: app_zh.arb 3 | output-localization-file: localizations.dart -------------------------------------------------------------------------------- /client/lib/components/delay.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:vtablet/services/connect.dart'; 3 | 4 | class DelayDialog extends Container { 5 | DelayDialog({ 6 | Key? key, 7 | Function()? onClick, 8 | }) : super( 9 | key: key, 10 | child: ValueListenableBuilder( 11 | valueListenable: VTabletWS.delay, 12 | builder: (context, value, child) => ElevatedButton( 13 | onPressed: onClick ?? () {}, 14 | style: ElevatedButton.styleFrom( 15 | backgroundColor: getSignalColor(VTabletWS.delay.value), 16 | foregroundColor: Colors.black, 17 | ), 18 | child: Text("${VTabletWS.delay.value} ms"), 19 | ), 20 | )); 21 | static Color getSignalColor(delay) { 22 | if (delay > 40 || delay < 0) { 23 | return const Color.fromARGB(255, 249, 142, 142); 24 | } 25 | if (delay > 15) { 26 | return Colors.yellowAccent; 27 | } 28 | return Colors.greenAccent; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /client/lib/components/setting_card.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class CardWithTitle extends StatelessWidget { 4 | const CardWithTitle({ 5 | super.key, 6 | required this.title, 7 | required this.content, 8 | }); 9 | 10 | final String title; 11 | final List content; 12 | 13 | @override 14 | Widget build(BuildContext context) { 15 | return Container( 16 | child: Column( 17 | crossAxisAlignment: CrossAxisAlignment.start, 18 | children: [ 19 | Text( 20 | title, 21 | style: Theme.of(context).textTheme.headlineSmall, 22 | ), 23 | Card( 24 | elevation: 1.0, 25 | child: Container( 26 | width: double.infinity, 27 | padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 15), 28 | alignment: Alignment.topLeft, 29 | child: Wrap( 30 | spacing: 0, 31 | children: content, 32 | ), 33 | ), 34 | ), 35 | const SizedBox( 36 | height: 20, 37 | ), 38 | ], 39 | ), 40 | ); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /client/lib/configs.dart: -------------------------------------------------------------------------------- 1 | import 'package:vtablet/services/states.dart'; 2 | 3 | class Configs { 4 | static final serverHostSaved = 5 | _initConfig("server.host", "localhost:23052"); 6 | static final serverHost = 7 | _initState("server.host", serverHostSaved.get()); 8 | 9 | static final preventSleep = _initConfig("other.preventSleep", true); 10 | 11 | static final screenUidSaved = _initConfig("aria.screenId", ""); 12 | static final screenUid = _initState("aria.screenId", ""); 13 | 14 | static final ariaScale = _initConfig("aria.scale", 0.8); 15 | static final ariaOffsetX = _initConfig("aria.offset.x", 0); 16 | static final ariaOffsetY = _initConfig("aria.offset.y", 0); 17 | // static final ariaTransform = _initConfig("aria.transform", 1); 18 | static final ariaRatio = _initConfig("aria.ratio", 16 / 9); 19 | 20 | static final inputEnablePen = _initConfig("input.enable.pen", true); 21 | static final inputEnableTouch = 22 | _initConfig("input.enable.touch", false); 23 | static final inputEnableMouse = 24 | _initConfig("input.enable.mouse", false); 25 | 26 | static final inputIgnoreClick = _initConfig("input.ignoreClick", false); 27 | 28 | static final delay = _initState("delay", -1); 29 | 30 | static _Config _initConfig(String key, T defaultValue) { 31 | _Config config = _Config(key, defaultValue); 32 | return config; 33 | } 34 | 35 | static _State _initState(String key, T defaultValue) { 36 | _State state = _State(key, defaultValue); 37 | return state; 38 | } 39 | } 40 | 41 | class _Config { 42 | final String _key; 43 | final T _defaultValue; 44 | 45 | _Config(String key, T defaultValue) 46 | : _key = key, 47 | _defaultValue = defaultValue; 48 | 49 | T get() { 50 | return ConfigManager.getConfig(_key, _defaultValue); 51 | } 52 | 53 | set(T newValue) { 54 | ConfigManager.setConfig(_key, newValue); 55 | } 56 | } 57 | 58 | class _State { 59 | final String _key; 60 | final T _defaultValue; 61 | 62 | _State(String key, T defaultValue) 63 | : _key = key, 64 | _defaultValue = defaultValue; 65 | 66 | T get() { 67 | return StateManager.getConfig(_key, _defaultValue); 68 | } 69 | 70 | set(T newValue) { 71 | StateManager.setConfig(_key, newValue); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /client/lib/home.dart: -------------------------------------------------------------------------------- 1 | import 'package:app_links/app_links.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:flutter_gen/gen_l10n/localizations.dart'; 4 | import 'package:logger/logger.dart'; 5 | 6 | import 'package:fullscreen_window/fullscreen_window.dart'; 7 | import 'package:vtablet/configs.dart'; 8 | import 'package:vtablet/services/connect.dart'; 9 | import 'package:vtablet/setting_screens/about.dart'; 10 | import 'package:vtablet/setting_screens/appearance.dart'; 11 | import 'package:vtablet/setting_screens/control.dart'; 12 | import 'package:vtablet/vtablet.dart'; 13 | import 'package:wakelock_plus/wakelock_plus.dart'; 14 | 15 | import 'setting_screens/connection.dart'; 16 | 17 | class Home extends StatefulWidget { 18 | const Home({ 19 | super.key, 20 | required this.title, 21 | required this.handleBrightnessChange, 22 | }); 23 | 24 | final String title; 25 | final void Function() handleBrightnessChange; 26 | 27 | @override 28 | State createState() => _HomeState(); 29 | } 30 | 31 | class _HomeState extends State { 32 | int currentPageIndex = 0; 33 | 34 | _HomeState() : super() { 35 | () async { 36 | try { 37 | Uri? startUrl; 38 | try { 39 | startUrl = await AppLinks().getLatestLink(); 40 | } catch (e) { 41 | // Ignore 42 | } 43 | var server = startUrl?.queryParameters["server"] ?? 44 | Configs.serverHostSaved.get(); 45 | setState(() { 46 | Configs.serverHost.set(server); 47 | }); 48 | var ans = await Services.fetchData(); 49 | if (context.mounted) { 50 | if (ans) { 51 | ScaffoldMessenger.of(context).showSnackBar(SnackBar( 52 | content: Text(AppLocalizations.of(context)! 53 | .succeedConnected(Configs.serverHost.get())), 54 | duration: const Duration(seconds: 1), 55 | )); 56 | } 57 | setState(() {}); 58 | } 59 | } catch (e) { 60 | // Ignore 61 | Logger().i(e); 62 | } 63 | }(); 64 | } 65 | 66 | @override 67 | Widget build(BuildContext context) { 68 | return Scaffold( 69 | appBar: AppBar( 70 | title: Text(widget.title), 71 | actions: [ 72 | IconButton( 73 | onPressed: widget.handleBrightnessChange, 74 | icon: const Icon(Icons.dark_mode)) 75 | ], 76 | ), 77 | floatingActionButton: currentPageIndex == 0 78 | ? ValueListenableBuilder( 79 | valueListenable: VTabletWS.state, 80 | builder: (context, value, child) { 81 | return FloatingActionButton.extended( 82 | onPressed: () { 83 | if (VTabletWS.state.value == WsConnectionState.connected) { 84 | WakelockPlus.toggle(enable: Configs.preventSleep.get()); 85 | Navigator.push( 86 | context, 87 | MaterialPageRoute( 88 | builder: (context) => VTabletPage(), 89 | ), 90 | ); 91 | FullScreenWindow.setFullScreen(true); 92 | } else { 93 | ScaffoldMessenger.of(context).showSnackBar( 94 | SnackBar( 95 | content: Text( 96 | AppLocalizations.of(context)!.connectFirstPlease), 97 | duration: const Duration(seconds: 1), 98 | ), 99 | ); 100 | } 101 | }, 102 | label: const Text('Start'), 103 | icon: const Icon(Icons.play_arrow), 104 | backgroundColor: 105 | VTabletWS.state.value == WsConnectionState.connected 106 | ? null 107 | // : Theme.of(context).disabledColor, 108 | : Colors.grey, 109 | ); 110 | }, 111 | ) 112 | : null, 113 | bottomNavigationBar: MediaQuery.of(context).size.width < 640 114 | ? NavigationBar( 115 | onDestinationSelected: (int index) { 116 | setState(() { 117 | currentPageIndex = index; 118 | }); 119 | }, 120 | selectedIndex: currentPageIndex, 121 | destinations: const [ 122 | ConnectionDestination(), 123 | ControlDestination(), 124 | AppearanceDestination(), 125 | AboutDestination(), 126 | ], 127 | ) 128 | : null, 129 | body: Row( 130 | mainAxisSize: MainAxisSize.max, 131 | children: [ 132 | if (MediaQuery.of(context).size.width >= 640) 133 | NavigationRail( 134 | selectedIndex: currentPageIndex, 135 | onDestinationSelected: (int index) { 136 | setState(() { 137 | currentPageIndex = index; 138 | }); 139 | }, 140 | labelType: NavigationRailLabelType.all, 141 | // navigation rail items 142 | destinations: [ 143 | connectionRailDestination(context), 144 | controlRailDestination(context), 145 | appearanceRailDestination(context), 146 | aboutRailDestination(context), 147 | ], 148 | ), 149 | Expanded( 150 | child: [ 151 | const ConnectionPage(), 152 | const ControlPage(), 153 | const AppearancePage(), 154 | const AboutPage(), 155 | ][currentPageIndex], 156 | ), 157 | ], 158 | ), 159 | ); 160 | } 161 | } 162 | -------------------------------------------------------------------------------- /client/lib/l10n/app_en.arb: -------------------------------------------------------------------------------- 1 | { 2 | "aboutPageTitle": "About", 3 | "aboutSoftwareInfoTitle": "App Info", 4 | "aboutUpdateCheckTitle": "Update Check", 5 | "aboutDonateTitle": "Donate", 6 | "aboutGithubBtn": "Visit GitHub repo", 7 | 8 | "appearancePageTitle": "Appearance", 9 | "appearancePageContext": "Apprarance is not ready yet", 10 | 11 | 12 | "connectionPageTitle": "Connection", 13 | "connectionFirstTitle": "Connect to server", 14 | "connectionServer": "Server", 15 | "connectionConnectBtn": "Connect", 16 | "connectionDisconnectBtn": "Disconnect", 17 | "connectionState": "Connect State", 18 | "connectionStateConnected": "Connected", 19 | "connectionStateDisconnected": "Disconnected", 20 | "connectionMonitor": "Monitor {uid}: {width}x{height}", 21 | "@connectionMonitor": { 22 | "placeholders": { 23 | "uid": { 24 | "type": "String", 25 | "example": "ffffff" 26 | }, 27 | "width": { 28 | "type": "int", 29 | "example": "1920" 30 | }, 31 | "height": { 32 | "type": "int", 33 | "example": "1080" 34 | } 35 | } 36 | }, 37 | "connectionReconnectBtn": "Reconnect", 38 | 39 | "controlPageTitle": "Control", 40 | "controlAriaTitle": "Input Aria", 41 | "controlAriaScaleLabel": "Scale", 42 | "controlAriaOffsetXLabel": "Offset X", 43 | "controlAriaOffsetYLabel": "Offset Y", 44 | "controlInputTypeTitle": "Input Type", 45 | "controlInputTypenamePen": "Pen", 46 | "controlInputTypenameTouch": "Touch", 47 | "controlInputTypenameMouse": "Mouse", 48 | "controlInputIgnoreClick": "Ignore pressure input", 49 | "controlOtherTitle": "Other", 50 | "controlPreventSleep": "Prevent phone/tablet from sleeping", 51 | 52 | "clickAgainToExit": "Click again to exit.", 53 | "lostConnect": "Disconnected to server", 54 | "connectFirstPlease": "Please connect first", 55 | 56 | "succeedConnected": "Server found: {url}", 57 | "@succeedConnected": { 58 | "placeholders": { 59 | "url": { 60 | "type": "String", 61 | "example": "localhost" 62 | } 63 | } 64 | }, 65 | "failedConnected": "Server not responding: {url}", 66 | "@failedConnected": { 67 | "placeholders": { 68 | "url": { 69 | "type": "String", 70 | "example": "localhost" 71 | } 72 | } 73 | }, 74 | 75 | "helpBtn": "Help" 76 | } -------------------------------------------------------------------------------- /client/lib/l10n/app_zh.arb: -------------------------------------------------------------------------------- 1 | { 2 | "aboutPageTitle": "关于", 3 | "aboutSoftwareInfoTitle": "软件信息", 4 | "aboutUpdateCheckTitle": "更新检查", 5 | "aboutDonateTitle": "捐赠", 6 | "aboutGithubBtn": "访问项目 GitHub 仓库", 7 | 8 | "appearancePageTitle": "外观", 9 | "appearancePageContext": "外观设置正在准备中", 10 | 11 | 12 | "connectionPageTitle": "连接", 13 | "connectionFirstTitle": "连接服务器", 14 | "connectionServer": "服务器", 15 | "connectionConnectBtn": "连接", 16 | "connectionDisconnectBtn": "断开连接", 17 | "connectionState": "连接状态", 18 | "connectionStateConnected": "已连接", 19 | "connectionStateDisconnected": "未连接", 20 | "connectionMonitor": "显示器 {uid}: {width}x{height}", 21 | "@connectionMonitor": { 22 | "placeholders": { 23 | "uid": { 24 | "type": "String", 25 | "example": "ffffff" 26 | }, 27 | "width": { 28 | "type": "int", 29 | "example": "1920" 30 | }, 31 | "height": { 32 | "type": "int", 33 | "example": "1080" 34 | } 35 | } 36 | }, 37 | "connectionReconnectBtn": "重新连接", 38 | 39 | "controlPageTitle": "控制", 40 | "controlAriaTitle": "输入区域", 41 | "controlAriaScaleLabel": "缩放", 42 | "controlAriaOffsetXLabel": "X 偏移", 43 | "controlAriaOffsetYLabel": "Y 偏移", 44 | "controlInputTypeTitle": "输入类型", 45 | "controlInputTypenamePen": "笔", 46 | "controlInputTypenameTouch": "触摸", 47 | "controlInputTypenameMouse": "鼠标", 48 | "controlInputIgnoreClick": "忽略压力信息", 49 | "controlOtherTitle": "其他设置", 50 | "controlPreventSleep": "阻止手机/平板休眠", 51 | 52 | "clickAgainToExit": "再点一次以退出", 53 | "lostConnect": "与服务器断开连接", 54 | "connectFirstPlease": "请先连接", 55 | 56 | "succeedConnected": "找到服务器: {url}", 57 | "@succeedConnected": { 58 | "placeholders": { 59 | "url": { 60 | "type": "String", 61 | "example": "localhost" 62 | } 63 | } 64 | }, 65 | "failedConnected": "服务器未响应: {url}", 66 | "@failedConnected": { 67 | "placeholders": { 68 | "url": { 69 | "type": "String", 70 | "example": "localhost" 71 | } 72 | } 73 | }, 74 | 75 | "helpBtn": "帮助文档" 76 | } -------------------------------------------------------------------------------- /client/lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter/scheduler.dart'; 3 | import 'package:vtablet/services/states.dart'; 4 | import 'package:flutter_localizations/flutter_localizations.dart'; 5 | import 'package:flutter_gen/gen_l10n/localizations.dart'; 6 | 7 | import 'home.dart'; 8 | 9 | void main() { 10 | runApp(const App()); 11 | ConfigManager.initManager(); 12 | } 13 | 14 | class App extends StatefulWidget { 15 | const App({super.key}); 16 | 17 | @override 18 | State createState() => _AppState(); 19 | } 20 | 21 | class _AppState extends State { 22 | bool useMaterial3 = true; 23 | ThemeMode themeMode = ThemeMode.system; 24 | 25 | bool get useLightMode { 26 | switch (themeMode) { 27 | case ThemeMode.system: 28 | return SchedulerBinding.instance.window.platformBrightness == 29 | Brightness.light; 30 | case ThemeMode.light: 31 | return true; 32 | case ThemeMode.dark: 33 | return false; 34 | } 35 | } 36 | 37 | void handleBrightnessChange() { 38 | setState(() { 39 | themeMode = useLightMode ? ThemeMode.dark : ThemeMode.light; 40 | }); 41 | } 42 | 43 | @override 44 | Widget build(BuildContext context) { 45 | return MaterialApp( 46 | debugShowCheckedModeBanner: false, 47 | title: 'vTablet', 48 | localizationsDelegates: const [ 49 | AppLocalizations.delegate, 50 | GlobalMaterialLocalizations.delegate, 51 | GlobalWidgetsLocalizations.delegate, 52 | GlobalCupertinoLocalizations.delegate, 53 | ], 54 | supportedLocales: const [ 55 | Locale('zh'), // Chinese 56 | Locale('en'), // English 57 | ], 58 | themeMode: themeMode, 59 | theme: ThemeData( 60 | // colorSchemeSeed: colorSelected.color, 61 | useMaterial3: useMaterial3, 62 | brightness: Brightness.light, 63 | ), 64 | darkTheme: ThemeData( 65 | // colorSchemeSeed: colorSelected.color, 66 | useMaterial3: useMaterial3, 67 | brightness: Brightness.dark, 68 | ), 69 | home: Home( 70 | title: "vTablet", 71 | handleBrightnessChange: handleBrightnessChange, 72 | ), 73 | ); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /client/lib/services/connect.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | import 'dart:convert'; 3 | 4 | import 'package:flutter/foundation.dart'; 5 | import 'package:logger/logger.dart'; 6 | import 'package:vtablet/configs.dart'; 7 | import 'package:http/http.dart' as http; 8 | import 'package:web_socket_channel/io.dart'; 9 | import 'package:web_socket_channel/web_socket_channel.dart'; 10 | 11 | class ScreenData { 12 | final String uid; 13 | final String path; 14 | final int width; 15 | final int height; 16 | 17 | ScreenData(this.uid, this.path, this.width, this.height); 18 | 19 | ScreenData.fromJson(Map json) 20 | : uid = json['uid'], 21 | path = json['path'], 22 | width = json['width'], 23 | height = json['height']; 24 | 25 | List get props => [uid]; 26 | 27 | connect() { 28 | VTabletWS.connect(Configs.serverHostSaved.get(), path); 29 | Configs.screenUid.set(uid); 30 | Configs.screenUidSaved.set(uid); 31 | Configs.ariaRatio.set(width / height); 32 | } 33 | } 34 | 35 | class Services { 36 | // static List screens = []; 37 | static ValueNotifierList screens = ValueNotifierList([]); 38 | 39 | static Future fetchData() async { 40 | VTabletWS.disconnect(); 41 | 42 | var serverUrl = Configs.serverHost.get(); 43 | screens.removeAll(); 44 | try { 45 | final response = await http.get(Uri.parse('http://$serverUrl/connect')); 46 | if (response.statusCode == 200) { 47 | List ans = jsonDecode(response.body); 48 | for (dynamic originalData in ans) { 49 | screens.add(ScreenData.fromJson(originalData)); 50 | } 51 | Configs.serverHostSaved.set(serverUrl); 52 | 53 | // auto connect 54 | var lastScreen = Configs.screenUidSaved.get(); 55 | Logger().d(lastScreen); 56 | for (final screen in screens.value) { 57 | if (screen.uid == lastScreen) { 58 | () { 59 | screen.connect(); 60 | screens.forceUpdate(); 61 | }(); 62 | } 63 | } 64 | if (VTabletWS.state.value != WsConnectionState.connected) { 65 | screens.value[0].connect(); 66 | } 67 | } 68 | return true; 69 | } catch (e) { 70 | Logger().e(e); 71 | } 72 | return false; 73 | } 74 | 75 | static reset() async { 76 | await VTabletWS.disconnect(); 77 | screens.removeAll(); 78 | } 79 | } 80 | 81 | class WsClient { 82 | late WebSocketChannel channel; 83 | WsConnectionState state = WsConnectionState.disconnected; 84 | final Function(WsConnectionState) _onStateChange; 85 | 86 | int baseTime = DateTime.now().millisecondsSinceEpoch; 87 | 88 | WsClient.connect(String host, String path, Function(int) onDelay, 89 | Function(WsConnectionState) onStateChange) 90 | : _onStateChange = onStateChange { 91 | var uri = Uri.parse("ws://$host$path"); 92 | 93 | Map headers = {}; 94 | headers['origin'] = 'https://vtablet.teages.xyz'; 95 | _setState(WsConnectionState.pending); 96 | if (kIsWeb) { 97 | channel = WebSocketChannel.connect(uri); 98 | channel.sink.add('0000'); 99 | } else { 100 | channel = IOWebSocketChannel.connect(uri, headers: headers); 101 | } 102 | 103 | channel.stream.listen( 104 | (message) { 105 | if (state == WsConnectionState.pending) { 106 | _setState(WsConnectionState.connected); 107 | } 108 | var value = int.tryParse(message); 109 | if (value != null) { 110 | var delay = (((timeFromBase()) + value) / 2).ceil(); 111 | if (state == WsConnectionState.connected) { 112 | onDelay(delay); 113 | } 114 | } 115 | }, 116 | onError: _disconnectErr, 117 | onDone: disconnect, 118 | ); 119 | Timer(const Duration(milliseconds: 1000), () { 120 | _ping(); 121 | }); 122 | 123 | Timer.periodic(const Duration(seconds: 1), (timer) { 124 | if (state == WsConnectionState.connected) { 125 | _ping(); 126 | } 127 | }); 128 | } 129 | 130 | _setState(WsConnectionState newState) { 131 | if (state != WsConnectionState.deprecated) { 132 | _onStateChange(newState); 133 | state = newState; 134 | } 135 | } 136 | 137 | _ping() { 138 | _sendBlob(buildMessage( 139 | EventType.EvSyn.value, 140 | Syn.Ping.value, 141 | 0 - timeFromBase(), 142 | )); 143 | } 144 | 145 | sendDigi(int x, int y, int pressure, double tiltX, double tiltY) { 146 | var inputIgnoreClick = Configs.inputIgnoreClick.get(); 147 | var msg = [ 148 | buildMessage( 149 | EventType.EvAbs.value, 150 | Abs.X.value, 151 | x, 152 | ), 153 | buildMessage( 154 | EventType.EvAbs.value, 155 | Abs.Y.value, 156 | y, 157 | ), 158 | buildMessage( 159 | EventType.EvAbs.value, 160 | Abs.Pressure.value, 161 | inputIgnoreClick ? 0 : pressure, 162 | ), 163 | buildMessage( 164 | EventType.EvAbs.value, 165 | Abs.TiltX.value, 166 | (tiltX * 32767 / 90).floor(), 167 | ), 168 | buildMessage( 169 | EventType.EvAbs.value, 170 | Abs.TiltY.value, 171 | (tiltY * 32767 / 90).floor(), 172 | ), 173 | buildMessage( 174 | EventType.EvSyn.value, 175 | Syn.Report.value, 176 | 0, 177 | ) 178 | ]; 179 | 180 | _sendBlob(Uint8List.fromList(msg.expand((x) => x).toList())); 181 | } 182 | 183 | _sendBlob(Uint8List blob) { 184 | try { 185 | channel.sink.add(blob); 186 | } catch (e) { 187 | disconnect(); 188 | } 189 | } 190 | 191 | static Uint8List buildMessage(int motionType, int motionCode, int value) { 192 | var bytes = Uint8List(8); 193 | 194 | bytes[0] = (motionType >> 8) & 0xff; 195 | bytes[1] = motionType & 0xff; 196 | 197 | bytes[2] = (motionCode >> 8) & 0xff; 198 | bytes[3] = motionCode & 0xff; 199 | 200 | bytes[4] = (value >> 24) & 0xff; 201 | bytes[5] = (value >> 16) & 0xff; 202 | 203 | bytes[6] = (value >> 8) & 0xff; 204 | bytes[7] = value & 0xff; 205 | 206 | return bytes; 207 | } 208 | 209 | _disconnectErr(e) { 210 | Logger().d("WS err"); 211 | Logger().d(e.toString()); 212 | disconnect(); 213 | } 214 | 215 | disconnect() async { 216 | _setState(WsConnectionState.deprecated); 217 | try { 218 | await channel.sink.close(); 219 | } catch (e) { 220 | // Ignore 221 | } 222 | } 223 | 224 | int timeFromBase() { 225 | return (DateTime.now().millisecondsSinceEpoch - baseTime) % 0x100000000; 226 | } 227 | } 228 | 229 | class VTabletWS { 230 | static ValueNotifier state = 231 | ValueNotifier(WsConnectionState.disconnected); 232 | static ValueNotifier delay = ValueNotifier(-1); 233 | 234 | static WsClient? client; 235 | 236 | static connect(String host, String path) { 237 | client = WsClient.connect( 238 | host, 239 | path, 240 | (delayVal) { 241 | delay.value = delayVal; 242 | // Logger().d(delayVal, path); 243 | }, 244 | (stateVal) { 245 | state.value = stateVal; 246 | if (stateVal == WsConnectionState.disconnected || 247 | stateVal == WsConnectionState.deprecated) { 248 | delay.value = -1; 249 | } 250 | }, 251 | ); 252 | 253 | state.value = WsConnectionState.connected; 254 | } 255 | 256 | static disconnect() async { 257 | client?.disconnect(); 258 | state.value = WsConnectionState.disconnected; 259 | client = null; 260 | } 261 | 262 | static sendDigi(int x, int y, int pressure, double tiltX, double tiltY) { 263 | if (state.value == WsConnectionState.connected) { 264 | // Logger().d("$x, $y, $pressure"); 265 | client?.sendDigi(x, y, pressure, tiltX, tiltY); 266 | } 267 | } 268 | } 269 | 270 | enum WsConnectionState { pending, connected, disconnected, deprecated } 271 | 272 | class ValueNotifierList extends ValueNotifier> { 273 | ValueNotifierList(List initValue) : super(initValue); 274 | 275 | void add(T item) { 276 | value.add(item); 277 | _copyValue(); 278 | } 279 | 280 | void removeAll() { 281 | value.clear(); 282 | _copyValue(); 283 | } 284 | 285 | void forceUpdate() { 286 | _copyValue(); 287 | } 288 | 289 | void _copyValue() { 290 | value = [...value]; 291 | } 292 | } 293 | 294 | enum EventType { 295 | EvSyn, 296 | EvAbs, 297 | } 298 | 299 | enum Syn { 300 | Report, 301 | Ping, 302 | } 303 | 304 | enum Abs { 305 | X, 306 | Y, 307 | Pressure, 308 | TiltX, 309 | TiltY, 310 | } 311 | 312 | extension EventTypeExtension on EventType { 313 | int get value { 314 | switch (this) { 315 | case EventType.EvSyn: 316 | return 0x0000; 317 | case EventType.EvAbs: 318 | return 0x0003; 319 | default: 320 | throw Exception('Invalid EventType'); 321 | } 322 | } 323 | } 324 | 325 | extension SynExtension on Syn { 326 | int get value { 327 | switch (this) { 328 | case Syn.Report: 329 | return 0x0000; 330 | case Syn.Ping: 331 | return 0xffff; 332 | default: 333 | throw Exception('Invalid Syn'); 334 | } 335 | } 336 | } 337 | 338 | extension AbsExtension on Abs { 339 | int get value { 340 | switch (this) { 341 | case Abs.X: 342 | return 0x0000; 343 | case Abs.Y: 344 | return 0x0001; 345 | case Abs.Pressure: 346 | return 0x0018; 347 | case Abs.TiltX: 348 | return 0x001a; 349 | case Abs.TiltY: 350 | return 0x001b; 351 | default: 352 | throw Exception('Invalid Abs'); 353 | } 354 | } 355 | } 356 | -------------------------------------------------------------------------------- /client/lib/services/states.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | import 'dart:developer' as developer; 3 | 4 | import 'package:shared_preferences/shared_preferences.dart'; 5 | import 'package:flutter/foundation.dart'; 6 | 7 | class ConfigManager { 8 | static Map localStroage = {}; 9 | static SharedPreferences preferences = {} as SharedPreferences; 10 | 11 | static initManager() async { 12 | preferences = await SharedPreferences.getInstance(); 13 | try { 14 | var configStr = preferences.getString("appConfig"); 15 | configStr ??= "{}"; 16 | localStroage = json.decode(configStr); 17 | } catch (e) { 18 | // ignore 19 | } 20 | } 21 | 22 | static getConfig(String key, dynamic defaultValue) { 23 | var value = localStroage[key]; 24 | var valueType = value.runtimeType; 25 | if (value != null) { 26 | if (valueType == defaultValue.runtimeType) { 27 | return value; 28 | } else if (valueType == (1).runtimeType || 29 | defaultValue.runtimeType == (1).runtimeType) { 30 | return value; 31 | } else { 32 | if (kDebugMode) { 33 | var expectType = defaultValue.runtimeType; 34 | developer.log("Wrong type $valueType, expected $expectType.\n"); 35 | } 36 | } 37 | } 38 | return defaultValue; 39 | } 40 | 41 | static setConfig(String key, dynamic value) { 42 | localStroage[key] = value; 43 | () async { 44 | String str = json.encode(localStroage); 45 | await preferences.setString("appConfig", str); 46 | }(); 47 | } 48 | } 49 | 50 | class StateManager { 51 | static Map localStroage = {}; 52 | 53 | static getConfig(String key, dynamic defaultValue) { 54 | var value = localStroage[key]; 55 | var valueType = value.runtimeType; 56 | if (value != null) { 57 | if (valueType == defaultValue.runtimeType) { 58 | return value; 59 | } else { 60 | if (kDebugMode) { 61 | var expectType = defaultValue.runtimeType; 62 | developer.log("Wrong type$valueType, expected $expectType.\n"); 63 | } 64 | } 65 | } 66 | return defaultValue; 67 | } 68 | 69 | static setConfig(String key, dynamic value) { 70 | return localStroage[key] = value; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /client/lib/setting_screens/about.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | import 'package:mdi/mdi.dart'; 4 | import 'package:url_launcher/url_launcher_string.dart'; 5 | import 'package:flutter_gen/gen_l10n/localizations.dart'; 6 | 7 | import '../components/setting_card.dart'; 8 | 9 | class AboutPage extends StatelessWidget { 10 | const AboutPage({ 11 | super.key, 12 | }); 13 | 14 | @override 15 | Widget build(BuildContext context) { 16 | return Container( 17 | alignment: Alignment.topCenter, 18 | child: SingleChildScrollView( 19 | child: Column( 20 | children: [ 21 | Container( 22 | constraints: const BoxConstraints(maxWidth: 640), 23 | padding: const EdgeInsets.all(20), 24 | child: Column( 25 | crossAxisAlignment: CrossAxisAlignment.start, 26 | children: [ 27 | const CardAboutSoftwareInfo(), 28 | Text( 29 | 'Copyright © Teages. All rights reserved.', 30 | style: Theme.of(context).textTheme.bodyLarge, 31 | ), 32 | ]), 33 | ), 34 | ], 35 | ), 36 | ), 37 | ); 38 | } 39 | } 40 | 41 | class CardAboutSoftwareInfo extends StatelessWidget { 42 | const CardAboutSoftwareInfo({ 43 | super.key, 44 | }); 45 | 46 | @override 47 | Widget build(BuildContext context) { 48 | return CardWithTitle( 49 | title: AppLocalizations.of(context)!.aboutSoftwareInfoTitle, 50 | content: [ 51 | const Text( 52 | 'v3.0.0 (Preview 4) by Teages', 53 | ), 54 | const SizedBox( 55 | height: 35, 56 | ), 57 | ElevatedButton.icon( 58 | style: ElevatedButton.styleFrom( 59 | minimumSize: const Size.fromHeight(50), 60 | backgroundColor: Theme.of(context).primaryColor, 61 | ), 62 | onPressed: () { 63 | launchUrlString('https://github.com/Teages/vTablet', 64 | mode: LaunchMode.externalApplication); 65 | }, 66 | icon: const Icon( 67 | Mdi.github, 68 | color: Colors.white, 69 | ), 70 | label: Text( 71 | AppLocalizations.of(context)!.aboutGithubBtn, 72 | style: const TextStyle(color: Colors.white), 73 | ), 74 | ), 75 | ], 76 | ); 77 | } 78 | } 79 | 80 | class AboutDestination extends StatelessWidget { 81 | const AboutDestination({ 82 | super.key, 83 | }); 84 | 85 | @override 86 | Widget build(BuildContext context) { 87 | return NavigationDestination( 88 | icon: const Icon(Icons.info_outline), 89 | selectedIcon: const Icon(Icons.info), 90 | label: AppLocalizations.of(context)!.aboutPageTitle, 91 | ); 92 | } 93 | } 94 | 95 | NavigationRailDestination aboutRailDestination(BuildContext context) { 96 | return NavigationRailDestination( 97 | icon: const Icon(Icons.info_outline), 98 | selectedIcon: const Icon(Icons.info), 99 | label: Text(AppLocalizations.of(context)!.aboutPageTitle), 100 | ); 101 | } 102 | -------------------------------------------------------------------------------- /client/lib/setting_screens/appearance.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_gen/gen_l10n/localizations.dart'; 3 | 4 | class AppearancePage extends StatelessWidget { 5 | const AppearancePage({ 6 | super.key, 7 | }); 8 | 9 | @override 10 | Widget build(BuildContext context) { 11 | return Container( 12 | alignment: Alignment.center, 13 | child: Text(AppLocalizations.of(context)!.appearancePageContext), 14 | ); 15 | } 16 | } 17 | 18 | class AppearanceDestination extends StatelessWidget { 19 | const AppearanceDestination({ 20 | super.key, 21 | }); 22 | 23 | @override 24 | Widget build(BuildContext context) { 25 | return NavigationDestination( 26 | icon: const Icon(Icons.color_lens_outlined), 27 | selectedIcon: const Icon(Icons.color_lens), 28 | label: AppLocalizations.of(context)!.appearancePageTitle, 29 | ); 30 | } 31 | } 32 | 33 | NavigationRailDestination appearanceRailDestination(BuildContext context) { 34 | return NavigationRailDestination( 35 | icon: const Icon(Icons.color_lens_outlined), 36 | selectedIcon: const Icon(Icons.color_lens), 37 | label: Text(AppLocalizations.of(context)!.appearancePageTitle), 38 | ); 39 | } 40 | -------------------------------------------------------------------------------- /client/lib/setting_screens/control.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:vtablet/configs.dart'; 3 | import 'package:flutter_gen/gen_l10n/localizations.dart'; 4 | 5 | import '../components/setting_card.dart'; 6 | 7 | class ControlPage extends StatelessWidget { 8 | const ControlPage({ 9 | super.key, 10 | }); 11 | 12 | @override 13 | Widget build(BuildContext context) { 14 | return Container( 15 | alignment: Alignment.topCenter, 16 | child: SingleChildScrollView( 17 | child: Column( 18 | children: [ 19 | Container( 20 | constraints: const BoxConstraints(maxWidth: 640), 21 | padding: const EdgeInsets.all(20), 22 | child: const Column( 23 | crossAxisAlignment: CrossAxisAlignment.start, 24 | children: [ 25 | ControlAriaCard(), 26 | ControlInputTypeCard(), 27 | ControlOtherCard(), 28 | ]), 29 | ), 30 | ], 31 | ), 32 | ), 33 | ); 34 | } 35 | } 36 | 37 | class ControlOtherCard extends StatefulWidget { 38 | const ControlOtherCard({ 39 | super.key, 40 | }); 41 | 42 | @override 43 | State createState() => _ControlOtherCardState(); 44 | } 45 | 46 | class _ControlOtherCardState extends State { 47 | @override 48 | Widget build(BuildContext context) { 49 | return CardWithTitle( 50 | title: AppLocalizations.of(context)!.controlOtherTitle, 51 | content: [ 52 | Row( 53 | mainAxisAlignment: MainAxisAlignment.spaceBetween, 54 | children: [ 55 | Text(AppLocalizations.of(context)!.controlPreventSleep), 56 | Switch( 57 | value: Configs.preventSleep.get(), 58 | onChanged: (bool on) { 59 | setState(() { 60 | Configs.preventSleep.set(on); 61 | }); 62 | }, 63 | ), 64 | ], 65 | ), 66 | ], 67 | ); 68 | } 69 | } 70 | 71 | class ControlInputTypeCard extends StatefulWidget { 72 | const ControlInputTypeCard({ 73 | super.key, 74 | }); 75 | 76 | @override 77 | State createState() => _ControlInputTypeCardState(); 78 | } 79 | 80 | class _ControlInputTypeCardState extends State { 81 | @override 82 | Widget build(BuildContext context) { 83 | return CardWithTitle( 84 | title: AppLocalizations.of(context)!.controlInputTypeTitle, 85 | content: [ 86 | const InputChoice(), 87 | const SizedBox( 88 | height: 45, 89 | ), 90 | Row( 91 | mainAxisAlignment: MainAxisAlignment.spaceBetween, 92 | children: [ 93 | Text(AppLocalizations.of(context)!.controlInputIgnoreClick), 94 | Switch( 95 | value: Configs.inputIgnoreClick.get(), 96 | onChanged: (bool on) { 97 | setState(() { 98 | Configs.inputIgnoreClick.set(on); 99 | }); 100 | }, 101 | ), 102 | ], 103 | ), 104 | ], 105 | ); 106 | } 107 | } 108 | 109 | class ControlAriaCard extends StatefulWidget { 110 | const ControlAriaCard({ 111 | super.key, 112 | }); 113 | 114 | @override 115 | State createState() => _ControlAriaCardState(); 116 | } 117 | 118 | class _ControlAriaCardState extends State { 119 | @override 120 | Widget build(BuildContext context) { 121 | return CardWithTitle( 122 | title: AppLocalizations.of(context)!.controlAriaTitle, 123 | content: [ 124 | LabelSlider( 125 | label: AppLocalizations.of(context)!.controlAriaScaleLabel, 126 | value: Configs.ariaScale.get(), 127 | max: 1, 128 | min: 0, 129 | divisions: 100, 130 | onChanged: (newVal) => { 131 | setState(() { 132 | Configs.ariaScale.set(newVal); 133 | }) 134 | }, 135 | ), 136 | LabelSlider( 137 | label: AppLocalizations.of(context)!.controlAriaOffsetXLabel, 138 | value: Configs.ariaOffsetX.get(), 139 | max: 1, 140 | min: -1, 141 | divisions: 100, 142 | onChanged: (newVal) => { 143 | setState(() { 144 | Configs.ariaOffsetX.set(newVal); 145 | }) 146 | }, 147 | ), 148 | LabelSlider( 149 | label: AppLocalizations.of(context)!.controlAriaOffsetYLabel, 150 | value: Configs.ariaOffsetY.get(), 151 | max: 1, 152 | min: -1, 153 | divisions: 100, 154 | onChanged: (newVal) => { 155 | setState(() { 156 | Configs.ariaOffsetY.set(newVal); 157 | }) 158 | }, 159 | ), 160 | ], 161 | ); 162 | } 163 | } 164 | 165 | // ignore: must_be_immutable 166 | class LabelSlider extends StatefulWidget { 167 | LabelSlider({ 168 | super.key, 169 | required this.label, 170 | required this.value, 171 | required this.min, 172 | required this.max, 173 | required this.divisions, 174 | required this.onChanged, 175 | }); 176 | 177 | String label; 178 | 179 | double value = 0; 180 | double min = 0; 181 | double max = 0; 182 | int divisions = 0; 183 | 184 | Function(double) onChanged; 185 | 186 | @override 187 | State createState() => _LabelSliderState(); 188 | } 189 | 190 | class _LabelSliderState extends State { 191 | @override 192 | Widget build(BuildContext context) { 193 | return Flex( 194 | direction: Axis.horizontal, 195 | children: [ 196 | Text('${widget.label}: ${widget.value.toStringAsFixed(2)}'), 197 | Expanded( 198 | child: Slider( 199 | value: widget.value, 200 | min: widget.min, 201 | max: widget.max, 202 | divisions: widget.divisions, 203 | label: widget.value.toStringAsFixed(2), 204 | onChanged: (double value) { 205 | widget.value = value; 206 | widget.onChanged(value); 207 | }, 208 | ), 209 | ) 210 | ], 211 | ); 212 | } 213 | } 214 | 215 | class ControlDestination extends StatelessWidget { 216 | const ControlDestination({ 217 | super.key, 218 | }); 219 | 220 | @override 221 | Widget build(BuildContext context) { 222 | return NavigationDestination( 223 | icon: const Icon(Icons.games_outlined), 224 | selectedIcon: const Icon(Icons.games), 225 | label: AppLocalizations.of(context)!.controlPageTitle, 226 | ); 227 | } 228 | } 229 | 230 | NavigationRailDestination controlRailDestination(BuildContext context) { 231 | return NavigationRailDestination( 232 | icon: const Icon(Icons.games_outlined), 233 | selectedIcon: const Icon(Icons.games), 234 | label: Text(AppLocalizations.of(context)!.controlPageTitle), 235 | ); 236 | } 237 | 238 | enum InputTypes { pen, touch, mouse } 239 | 240 | class InputChoice extends StatefulWidget { 241 | const InputChoice({super.key}); 242 | 243 | @override 244 | State createState() => _InputChoiceState(); 245 | } 246 | 247 | class _InputChoiceState extends State { 248 | Set selection = getSelection(); 249 | 250 | static Set getSelection() { 251 | Set ans = {}; 252 | if (Configs.inputEnablePen.get()) { 253 | ans.add(InputTypes.pen); 254 | } 255 | if (Configs.inputEnableTouch.get()) { 256 | ans.add(InputTypes.touch); 257 | } 258 | if (Configs.inputEnableMouse.get()) { 259 | ans.add(InputTypes.mouse); 260 | } 261 | return ans; 262 | } 263 | 264 | @override 265 | Widget build(BuildContext context) { 266 | return SegmentedButton( 267 | segments: >[ 268 | ButtonSegment( 269 | value: InputTypes.pen, 270 | label: Text(AppLocalizations.of(context)!.controlInputTypenamePen), 271 | icon: const Icon(Icons.edit), 272 | ), 273 | ButtonSegment( 274 | value: InputTypes.touch, 275 | label: Text(AppLocalizations.of(context)!.controlInputTypenameTouch), 276 | icon: const Icon(Icons.touch_app), 277 | ), 278 | ButtonSegment( 279 | value: InputTypes.mouse, 280 | label: Text(AppLocalizations.of(context)!.controlInputTypenameMouse), 281 | icon: const Icon(Icons.mouse), 282 | ), 283 | ], 284 | selected: selection, 285 | onSelectionChanged: (newSelection) { 286 | setState(() { 287 | selection = newSelection; 288 | }); 289 | if (selection.contains(InputTypes.pen)) { 290 | Configs.inputEnablePen.set(true); 291 | } else { 292 | Configs.inputEnablePen.set(false); 293 | } 294 | if (selection.contains(InputTypes.touch)) { 295 | Configs.inputEnableTouch.set(true); 296 | } else { 297 | Configs.inputEnableTouch.set(false); 298 | } 299 | if (selection.contains(InputTypes.mouse)) { 300 | Configs.inputEnableMouse.set(true); 301 | } else { 302 | Configs.inputEnableMouse.set(false); 303 | } 304 | }, 305 | multiSelectionEnabled: true, 306 | ); 307 | } 308 | } 309 | -------------------------------------------------------------------------------- /client/lib/vtablet.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/gestures.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:vtablet/configs.dart'; 4 | import 'package:flutter_gen/gen_l10n/localizations.dart'; 5 | 6 | import 'dart:developer' as developer; 7 | import 'dart:math' as math; 8 | 9 | import 'package:wakelock_plus/wakelock_plus.dart'; 10 | import 'package:fullscreen_window/fullscreen_window.dart'; 11 | 12 | import 'package:vtablet/services/states.dart'; 13 | import 'package:vtablet/services/connect.dart'; 14 | import 'package:vtablet/components/delay.dart'; 15 | 16 | // ignore: must_be_immutable 17 | class VTabletPage extends StatelessWidget { 18 | final GlobalKey boxKey = GlobalKey(); 19 | final GlobalKey ariaKey = GlobalKey(); 20 | 21 | // Aria settings 22 | double scale = Configs.ariaScale.get(); 23 | double ratio = Configs.ariaRatio.get(); 24 | double offsetX = Configs.ariaOffsetX.get(); 25 | double offsetY = Configs.ariaOffsetY.get(); 26 | 27 | // Input settings 28 | bool enableMouse = Configs.inputEnableMouse.get(); 29 | bool enableTouch = Configs.inputEnableTouch.get(); 30 | bool enablePen = Configs.inputEnablePen.get(); 31 | 32 | // UI settings 33 | bool pureBackground = false; 34 | bool showDelay = ConfigManager.getConfig("ui.showDelay", true); 35 | 36 | // Other settings 37 | bool preventSleep = Configs.preventSleep.get(); 38 | 39 | late BuildContext buildContext; 40 | 41 | void lostConnect() { 42 | if (VTabletWS.state.value != WsConnectionState.connected) { 43 | WakelockPlus.disable(); 44 | developer.log("Disconnceted."); 45 | try { 46 | showDialog( 47 | context: buildContext, 48 | builder: (BuildContext context) { 49 | return AlertDialog( 50 | content: SingleChildScrollView( 51 | child: ListBody( 52 | children: [Text(AppLocalizations.of(context)!.lostConnect)], 53 | )), 54 | actions: [ 55 | TextButton( 56 | child: const Text("OK"), 57 | onPressed: () { 58 | Navigator.pop(buildContext); 59 | readyExit(); 60 | Navigator.pop(buildContext); 61 | }, 62 | ) 63 | ], 64 | ); 65 | }, 66 | ); 67 | } catch (e) { 68 | // Ignore 69 | } 70 | } 71 | } 72 | 73 | // init 74 | VTabletPage({ 75 | Key? key, 76 | }) : super(key: key) { 77 | // show dialog when disconnect 78 | 79 | VTabletWS.state.addListener(lostConnect); 80 | } 81 | 82 | pointerEventHandler(PointerEvent event) { 83 | // developer.log( 84 | // "${event.pressure} : (${event.position.dx}, ${event.position.dy}) "); 85 | var rawX = event.position.dx; 86 | var rawY = event.position.dy; 87 | var rawPressure = event.pressure; 88 | var rawType = event.kind; 89 | var rawTilt = event.tilt; 90 | var rawOrientation = event.orientation; 91 | 92 | var boxWidth = boxKey.currentContext!.size!.width; 93 | var boxHeight = boxKey.currentContext!.size!.height; 94 | var ariaWidth = ariaKey.currentContext!.size!.width; 95 | var ariaHeight = ariaKey.currentContext!.size!.height; 96 | 97 | int screenToDigi(double position, double airaOffsetProporte, 98 | double ariaSize, double boxSize) { 99 | double airaOffset = (airaOffsetProporte + 1) * (boxSize - ariaSize) * 0.5; 100 | 101 | return 32767 * (position - airaOffset) ~/ ariaSize; 102 | } 103 | 104 | int pointerX = screenToDigi(rawX, offsetX, ariaWidth, boxWidth); 105 | int pointerY = screenToDigi(rawY, offsetY, ariaHeight, boxHeight); 106 | int pressure = event.down ? (8192 * rawPressure).toInt() : 0; 107 | 108 | double tiltX = rawTilt * math.cos(rawOrientation) * 90; 109 | double tiltY = rawTilt * math.sin(rawOrientation) * 90; 110 | 111 | // developer.log( 112 | // 'Pointer($pointerX, $pointerY) $pressure ($tiltX, $tiltY) by $rawType'); 113 | 114 | switch (rawType) { 115 | case PointerDeviceKind.mouse: 116 | if (enableMouse) { 117 | VTabletWS.sendDigi(pointerX, pointerY, pressure, tiltX, tiltY); 118 | } 119 | break; 120 | case PointerDeviceKind.touch: 121 | if (enableTouch) { 122 | VTabletWS.sendDigi(pointerX, pointerY, pressure, tiltX, tiltY); 123 | } 124 | break; 125 | case PointerDeviceKind.stylus: 126 | if (enablePen) { 127 | VTabletWS.sendDigi(pointerX, pointerY, pressure, tiltX, tiltY); 128 | } 129 | break; 130 | default: 131 | developer.log("Unknown input devices $rawType"); 132 | } 133 | } 134 | 135 | int lastClickExit = 0; 136 | @override 137 | Widget build(BuildContext context) { 138 | buildContext = context; 139 | return WillPopScope( 140 | onWillPop: () async { 141 | readyExit(); 142 | return true; 143 | }, 144 | child: Scaffold( 145 | appBar: null, 146 | floatingActionButton: showDelay 147 | ? Opacity( 148 | opacity: 0.25, 149 | child: DelayDialog( 150 | onClick: () { 151 | if (DateTime.now().millisecondsSinceEpoch - lastClickExit < 152 | 1500) { 153 | readyExit(); 154 | Navigator.pop(context); 155 | } else { 156 | ScaffoldMessenger.of(context).showSnackBar(SnackBar( 157 | content: Text( 158 | AppLocalizations.of(context)!.clickAgainToExit), 159 | duration: const Duration(seconds: 1), 160 | )); 161 | } 162 | lastClickExit = DateTime.now().millisecondsSinceEpoch; 163 | }, 164 | ), 165 | ) 166 | : null, 167 | floatingActionButtonLocation: 168 | FloatingActionButtonLocation.miniStartFloat, 169 | body: Center( 170 | child: Listener( 171 | onPointerMove: (event) => pointerEventHandler(event), 172 | onPointerHover: (event) => pointerEventHandler(event), 173 | onPointerDown: (event) => pointerEventHandler(event), 174 | onPointerUp: (event) => pointerEventHandler(event), 175 | onPointerCancel: (event) => pointerEventHandler(event), 176 | child: Container( 177 | key: boxKey, 178 | color: Colors.black, 179 | height: double.infinity, 180 | width: double.infinity, 181 | child: FractionallySizedBox( 182 | alignment: Alignment(offsetX, offsetY), 183 | widthFactor: scale, 184 | heightFactor: scale, 185 | child: Container( 186 | // color: Color.fromARGB(40, 244, 67, 54), // Debug 187 | alignment: Alignment(offsetX, offsetY), 188 | child: AspectRatio( 189 | aspectRatio: ratio, 190 | child: Container( 191 | key: ariaKey, 192 | color: Color.fromARGB( 193 | pureBackground ? 0 : 30, 255, 255, 255), 194 | // child: Text(log), 195 | ), 196 | ), 197 | ), 198 | ), 199 | ), 200 | ), 201 | ), 202 | ), 203 | ); 204 | } 205 | 206 | void readyExit() { 207 | WakelockPlus.disable(); 208 | VTabletWS.state.removeListener(lostConnect); 209 | 210 | FullScreenWindow.setFullScreen(false); 211 | } 212 | } 213 | -------------------------------------------------------------------------------- /client/linux/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral 2 | -------------------------------------------------------------------------------- /client/linux/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Project-level configuration. 2 | cmake_minimum_required(VERSION 3.10) 3 | project(runner LANGUAGES CXX) 4 | 5 | # The name of the executable created for the application. Change this to change 6 | # the on-disk name of your application. 7 | set(BINARY_NAME "vtablet") 8 | # The unique GTK application identifier for this application. See: 9 | # https://wiki.gnome.org/HowDoI/ChooseApplicationID 10 | set(APPLICATION_ID "xyz.teages.vtablet") 11 | 12 | # Explicitly opt in to modern CMake behaviors to avoid warnings with recent 13 | # versions of CMake. 14 | cmake_policy(SET CMP0063 NEW) 15 | 16 | # Load bundled libraries from the lib/ directory relative to the binary. 17 | set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") 18 | 19 | # Root filesystem for cross-building. 20 | if(FLUTTER_TARGET_PLATFORM_SYSROOT) 21 | set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) 22 | set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) 23 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 24 | set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) 25 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 26 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 27 | endif() 28 | 29 | # Define build configuration options. 30 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 31 | set(CMAKE_BUILD_TYPE "Debug" CACHE 32 | STRING "Flutter build mode" FORCE) 33 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 34 | "Debug" "Profile" "Release") 35 | endif() 36 | 37 | # Compilation settings that should be applied to most targets. 38 | # 39 | # Be cautious about adding new options here, as plugins use this function by 40 | # default. In most cases, you should add new options to specific targets instead 41 | # of modifying this function. 42 | function(APPLY_STANDARD_SETTINGS TARGET) 43 | target_compile_features(${TARGET} PUBLIC cxx_std_14) 44 | target_compile_options(${TARGET} PRIVATE -Wall -Werror) 45 | target_compile_options(${TARGET} PRIVATE "$<$>:-O3>") 46 | target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>") 47 | endfunction() 48 | 49 | # Flutter library and tool build rules. 50 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") 51 | add_subdirectory(${FLUTTER_MANAGED_DIR}) 52 | 53 | # System-level dependencies. 54 | find_package(PkgConfig REQUIRED) 55 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) 56 | 57 | add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") 58 | 59 | # Define the application target. To change its name, change BINARY_NAME above, 60 | # not the value here, or `flutter run` will no longer work. 61 | # 62 | # Any new source files that you add to the application should be added here. 63 | add_executable(${BINARY_NAME} 64 | "main.cc" 65 | "my_application.cc" 66 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 67 | ) 68 | 69 | # Apply the standard set of build settings. This can be removed for applications 70 | # that need different build settings. 71 | apply_standard_settings(${BINARY_NAME}) 72 | 73 | # Add dependency libraries. Add any application-specific dependencies here. 74 | target_link_libraries(${BINARY_NAME} PRIVATE flutter) 75 | target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) 76 | 77 | # Run the Flutter tool portions of the build. This must not be removed. 78 | add_dependencies(${BINARY_NAME} flutter_assemble) 79 | 80 | # Only the install-generated bundle's copy of the executable will launch 81 | # correctly, since the resources must in the right relative locations. To avoid 82 | # people trying to run the unbundled copy, put it in a subdirectory instead of 83 | # the default top-level location. 84 | set_target_properties(${BINARY_NAME} 85 | PROPERTIES 86 | RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" 87 | ) 88 | 89 | # Generated plugin build rules, which manage building the plugins and adding 90 | # them to the application. 91 | include(flutter/generated_plugins.cmake) 92 | 93 | 94 | # === Installation === 95 | # By default, "installing" just makes a relocatable bundle in the build 96 | # directory. 97 | set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") 98 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 99 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 100 | endif() 101 | 102 | # Start with a clean build bundle directory every time. 103 | install(CODE " 104 | file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") 105 | " COMPONENT Runtime) 106 | 107 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 108 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") 109 | 110 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 111 | COMPONENT Runtime) 112 | 113 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 114 | COMPONENT Runtime) 115 | 116 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 117 | COMPONENT Runtime) 118 | 119 | foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) 120 | install(FILES "${bundled_library}" 121 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 122 | COMPONENT Runtime) 123 | endforeach(bundled_library) 124 | 125 | # Fully re-copy the assets directory on each build to avoid having stale files 126 | # from a previous install. 127 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 128 | install(CODE " 129 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 130 | " COMPONENT Runtime) 131 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 132 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 133 | 134 | # Install the AOT library on non-Debug builds only. 135 | if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") 136 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 137 | COMPONENT Runtime) 138 | endif() 139 | -------------------------------------------------------------------------------- /client/linux/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This file controls Flutter-level build steps. It should not be edited. 2 | cmake_minimum_required(VERSION 3.10) 3 | 4 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 5 | 6 | # Configuration provided via flutter tool. 7 | include(${EPHEMERAL_DIR}/generated_config.cmake) 8 | 9 | # TODO: Move the rest of this into files in ephemeral. See 10 | # https://github.com/flutter/flutter/issues/57146. 11 | 12 | # Serves the same purpose as list(TRANSFORM ... PREPEND ...), 13 | # which isn't available in 3.10. 14 | function(list_prepend LIST_NAME PREFIX) 15 | set(NEW_LIST "") 16 | foreach(element ${${LIST_NAME}}) 17 | list(APPEND NEW_LIST "${PREFIX}${element}") 18 | endforeach(element) 19 | set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) 20 | endfunction() 21 | 22 | # === Flutter Library === 23 | # System-level dependencies. 24 | find_package(PkgConfig REQUIRED) 25 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) 26 | pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) 27 | pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) 28 | 29 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") 30 | 31 | # Published to parent scope for install step. 32 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 33 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 34 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 35 | set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) 36 | 37 | list(APPEND FLUTTER_LIBRARY_HEADERS 38 | "fl_basic_message_channel.h" 39 | "fl_binary_codec.h" 40 | "fl_binary_messenger.h" 41 | "fl_dart_project.h" 42 | "fl_engine.h" 43 | "fl_json_message_codec.h" 44 | "fl_json_method_codec.h" 45 | "fl_message_codec.h" 46 | "fl_method_call.h" 47 | "fl_method_channel.h" 48 | "fl_method_codec.h" 49 | "fl_method_response.h" 50 | "fl_plugin_registrar.h" 51 | "fl_plugin_registry.h" 52 | "fl_standard_message_codec.h" 53 | "fl_standard_method_codec.h" 54 | "fl_string_codec.h" 55 | "fl_value.h" 56 | "fl_view.h" 57 | "flutter_linux.h" 58 | ) 59 | list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") 60 | add_library(flutter INTERFACE) 61 | target_include_directories(flutter INTERFACE 62 | "${EPHEMERAL_DIR}" 63 | ) 64 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") 65 | target_link_libraries(flutter INTERFACE 66 | PkgConfig::GTK 67 | PkgConfig::GLIB 68 | PkgConfig::GIO 69 | ) 70 | add_dependencies(flutter flutter_assemble) 71 | 72 | # === Flutter tool backend === 73 | # _phony_ is a non-existent file to force this command to run every time, 74 | # since currently there's no way to get a full input/output list from the 75 | # flutter tool. 76 | add_custom_command( 77 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 78 | ${CMAKE_CURRENT_BINARY_DIR}/_phony_ 79 | COMMAND ${CMAKE_COMMAND} -E env 80 | ${FLUTTER_TOOL_ENVIRONMENT} 81 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" 82 | ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} 83 | VERBATIM 84 | ) 85 | add_custom_target(flutter_assemble DEPENDS 86 | "${FLUTTER_LIBRARY}" 87 | ${FLUTTER_LIBRARY_HEADERS} 88 | ) 89 | -------------------------------------------------------------------------------- /client/linux/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | #include 10 | #include 11 | 12 | void fl_register_plugins(FlPluginRegistry* registry) { 13 | g_autoptr(FlPluginRegistrar) gtk_registrar = 14 | fl_plugin_registry_get_registrar_for_plugin(registry, "GtkPlugin"); 15 | gtk_plugin_register_with_registrar(gtk_registrar); 16 | g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar = 17 | fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin"); 18 | url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar); 19 | } 20 | -------------------------------------------------------------------------------- /client/linux/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void fl_register_plugins(FlPluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /client/linux/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | gtk 7 | url_launcher_linux 8 | ) 9 | 10 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 11 | ) 12 | 13 | set(PLUGIN_BUNDLED_LIBRARIES) 14 | 15 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 16 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) 17 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 18 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 19 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 20 | endforeach(plugin) 21 | 22 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 23 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) 24 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 25 | endforeach(ffi_plugin) 26 | -------------------------------------------------------------------------------- /client/linux/main.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | int main(int argc, char** argv) { 4 | g_autoptr(MyApplication) app = my_application_new(); 5 | return g_application_run(G_APPLICATION(app), argc, argv); 6 | } 7 | -------------------------------------------------------------------------------- /client/linux/my_application.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | #include 4 | #ifdef GDK_WINDOWING_X11 5 | #include 6 | #endif 7 | 8 | #include "flutter/generated_plugin_registrant.h" 9 | 10 | struct _MyApplication { 11 | GtkApplication parent_instance; 12 | char** dart_entrypoint_arguments; 13 | }; 14 | 15 | G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) 16 | 17 | // Implements GApplication::activate. 18 | static void my_application_activate(GApplication* application) { 19 | MyApplication* self = MY_APPLICATION(application); 20 | GtkWindow* window = 21 | GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); 22 | 23 | // Use a header bar when running in GNOME as this is the common style used 24 | // by applications and is the setup most users will be using (e.g. Ubuntu 25 | // desktop). 26 | // If running on X and not using GNOME then just use a traditional title bar 27 | // in case the window manager does more exotic layout, e.g. tiling. 28 | // If running on Wayland assume the header bar will work (may need changing 29 | // if future cases occur). 30 | gboolean use_header_bar = TRUE; 31 | #ifdef GDK_WINDOWING_X11 32 | GdkScreen* screen = gtk_window_get_screen(window); 33 | if (GDK_IS_X11_SCREEN(screen)) { 34 | const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); 35 | if (g_strcmp0(wm_name, "GNOME Shell") != 0) { 36 | use_header_bar = FALSE; 37 | } 38 | } 39 | #endif 40 | if (use_header_bar) { 41 | GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); 42 | gtk_widget_show(GTK_WIDGET(header_bar)); 43 | gtk_header_bar_set_title(header_bar, "vtablet"); 44 | gtk_header_bar_set_show_close_button(header_bar, TRUE); 45 | gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); 46 | } else { 47 | gtk_window_set_title(window, "vtablet"); 48 | } 49 | 50 | gtk_window_set_default_size(window, 1280, 720); 51 | gtk_widget_show(GTK_WIDGET(window)); 52 | 53 | g_autoptr(FlDartProject) project = fl_dart_project_new(); 54 | fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments); 55 | 56 | FlView* view = fl_view_new(project); 57 | gtk_widget_show(GTK_WIDGET(view)); 58 | gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); 59 | 60 | fl_register_plugins(FL_PLUGIN_REGISTRY(view)); 61 | 62 | gtk_widget_grab_focus(GTK_WIDGET(view)); 63 | } 64 | 65 | // Implements GApplication::local_command_line. 66 | static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) { 67 | MyApplication* self = MY_APPLICATION(application); 68 | // Strip out the first argument as it is the binary name. 69 | self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); 70 | 71 | g_autoptr(GError) error = nullptr; 72 | if (!g_application_register(application, nullptr, &error)) { 73 | g_warning("Failed to register: %s", error->message); 74 | *exit_status = 1; 75 | return TRUE; 76 | } 77 | 78 | g_application_activate(application); 79 | *exit_status = 0; 80 | 81 | return TRUE; 82 | } 83 | 84 | // Implements GObject::dispose. 85 | static void my_application_dispose(GObject* object) { 86 | MyApplication* self = MY_APPLICATION(object); 87 | g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); 88 | G_OBJECT_CLASS(my_application_parent_class)->dispose(object); 89 | } 90 | 91 | static void my_application_class_init(MyApplicationClass* klass) { 92 | G_APPLICATION_CLASS(klass)->activate = my_application_activate; 93 | G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line; 94 | G_OBJECT_CLASS(klass)->dispose = my_application_dispose; 95 | } 96 | 97 | static void my_application_init(MyApplication* self) {} 98 | 99 | MyApplication* my_application_new() { 100 | return MY_APPLICATION(g_object_new(my_application_get_type(), 101 | "application-id", APPLICATION_ID, 102 | "flags", G_APPLICATION_NON_UNIQUE, 103 | nullptr)); 104 | } 105 | -------------------------------------------------------------------------------- /client/linux/my_application.h: -------------------------------------------------------------------------------- 1 | #ifndef FLUTTER_MY_APPLICATION_H_ 2 | #define FLUTTER_MY_APPLICATION_H_ 3 | 4 | #include 5 | 6 | G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, 7 | GtkApplication) 8 | 9 | /** 10 | * my_application_new: 11 | * 12 | * Creates a new Flutter-based application. 13 | * 14 | * Returns: a new #MyApplication. 15 | */ 16 | MyApplication* my_application_new(); 17 | 18 | #endif // FLUTTER_MY_APPLICATION_H_ 19 | -------------------------------------------------------------------------------- /client/macos/.gitignore: -------------------------------------------------------------------------------- 1 | # Flutter-related 2 | **/Flutter/ephemeral/ 3 | **/Pods/ 4 | 5 | # Xcode-related 6 | **/dgph 7 | **/xcuserdata/ 8 | -------------------------------------------------------------------------------- /client/macos/Flutter/Flutter-Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "ephemeral/Flutter-Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /client/macos/Flutter/Flutter-Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "ephemeral/Flutter-Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /client/macos/Flutter/GeneratedPluginRegistrant.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | import FlutterMacOS 6 | import Foundation 7 | 8 | import app_links 9 | import package_info_plus 10 | import shared_preferences_foundation 11 | import url_launcher_macos 12 | import wakelock_plus 13 | 14 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { 15 | AppLinksMacosPlugin.register(with: registry.registrar(forPlugin: "AppLinksMacosPlugin")) 16 | FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin")) 17 | SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) 18 | UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) 19 | WakelockPlusMacosPlugin.register(with: registry.registrar(forPlugin: "WakelockPlusMacosPlugin")) 20 | } 21 | -------------------------------------------------------------------------------- /client/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /client/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 69 | 71 | 77 | 78 | 79 | 80 | 82 | 83 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /client/macos/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /client/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /client/macos/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | @NSApplicationMain 5 | class AppDelegate: FlutterAppDelegate { 6 | override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { 7 | return true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /client/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "16x16", 5 | "idiom" : "mac", 6 | "filename" : "app_icon_16.png", 7 | "scale" : "1x" 8 | }, 9 | { 10 | "size" : "16x16", 11 | "idiom" : "mac", 12 | "filename" : "app_icon_32.png", 13 | "scale" : "2x" 14 | }, 15 | { 16 | "size" : "32x32", 17 | "idiom" : "mac", 18 | "filename" : "app_icon_32.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "32x32", 23 | "idiom" : "mac", 24 | "filename" : "app_icon_64.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "128x128", 29 | "idiom" : "mac", 30 | "filename" : "app_icon_128.png", 31 | "scale" : "1x" 32 | }, 33 | { 34 | "size" : "128x128", 35 | "idiom" : "mac", 36 | "filename" : "app_icon_256.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "256x256", 41 | "idiom" : "mac", 42 | "filename" : "app_icon_256.png", 43 | "scale" : "1x" 44 | }, 45 | { 46 | "size" : "256x256", 47 | "idiom" : "mac", 48 | "filename" : "app_icon_512.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "512x512", 53 | "idiom" : "mac", 54 | "filename" : "app_icon_512.png", 55 | "scale" : "1x" 56 | }, 57 | { 58 | "size" : "512x512", 59 | "idiom" : "mac", 60 | "filename" : "app_icon_1024.png", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /client/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Teages/vTablet/a46e1fcf721593f0824f74c6285591b53e5b09f1/client/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png -------------------------------------------------------------------------------- /client/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Teages/vTablet/a46e1fcf721593f0824f74c6285591b53e5b09f1/client/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png -------------------------------------------------------------------------------- /client/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Teages/vTablet/a46e1fcf721593f0824f74c6285591b53e5b09f1/client/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png -------------------------------------------------------------------------------- /client/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Teages/vTablet/a46e1fcf721593f0824f74c6285591b53e5b09f1/client/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png -------------------------------------------------------------------------------- /client/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Teages/vTablet/a46e1fcf721593f0824f74c6285591b53e5b09f1/client/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png -------------------------------------------------------------------------------- /client/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Teages/vTablet/a46e1fcf721593f0824f74c6285591b53e5b09f1/client/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png -------------------------------------------------------------------------------- /client/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Teages/vTablet/a46e1fcf721593f0824f74c6285591b53e5b09f1/client/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png -------------------------------------------------------------------------------- /client/macos/Runner/Configs/AppInfo.xcconfig: -------------------------------------------------------------------------------- 1 | // Application-level settings for the Runner target. 2 | // 3 | // This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the 4 | // future. If not, the values below would default to using the project name when this becomes a 5 | // 'flutter create' template. 6 | 7 | // The application's name. By default this is also the title of the Flutter window. 8 | PRODUCT_NAME = vtablet 9 | 10 | // The application's bundle identifier 11 | PRODUCT_BUNDLE_IDENTIFIER = xyz.teages.vtablet 12 | 13 | // The copyright displayed in application information 14 | PRODUCT_COPYRIGHT = Copyright © 2022 xyz.teages. All rights reserved. 15 | -------------------------------------------------------------------------------- /client/macos/Runner/Configs/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Debug.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /client/macos/Runner/Configs/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Release.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /client/macos/Runner/Configs/Warnings.xcconfig: -------------------------------------------------------------------------------- 1 | WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings 2 | GCC_WARN_UNDECLARED_SELECTOR = YES 3 | CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES 4 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE 5 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES 6 | CLANG_WARN_PRAGMA_PACK = YES 7 | CLANG_WARN_STRICT_PROTOTYPES = YES 8 | CLANG_WARN_COMMA = YES 9 | GCC_WARN_STRICT_SELECTOR_MATCH = YES 10 | CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES 11 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES 12 | GCC_WARN_SHADOW = YES 13 | CLANG_WARN_UNREACHABLE_CODE = YES 14 | -------------------------------------------------------------------------------- /client/macos/Runner/DebugProfile.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.cs.allow-jit 8 | 9 | com.apple.security.network.server 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /client/macos/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleVersion 22 | $(FLUTTER_BUILD_NUMBER) 23 | LSMinimumSystemVersion 24 | $(MACOSX_DEPLOYMENT_TARGET) 25 | NSHumanReadableCopyright 26 | $(PRODUCT_COPYRIGHT) 27 | NSMainNibFile 28 | MainMenu 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /client/macos/Runner/MainFlutterWindow.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | class MainFlutterWindow: NSWindow { 5 | override func awakeFromNib() { 6 | let flutterViewController = FlutterViewController.init() 7 | let windowFrame = self.frame 8 | self.contentViewController = flutterViewController 9 | self.setFrame(windowFrame, display: true) 10 | 11 | RegisterGeneratedPlugins(registry: flutterViewController) 12 | 13 | super.awakeFromNib() 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /client/macos/Runner/Release.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /client/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: vtablet 2 | description: Use your tablet as your osu digitizer! 3 | 4 | # The following line prevents the package from being accidentally published to 5 | # pub.dev using `flutter pub publish`. This is preferred for private packages. 6 | publish_to: 'none' # Remove this line if you wish to publish to pub.dev 7 | 8 | # The following defines the version and build number for your application. 9 | # A version number is three numbers separated by dots, like 1.2.43 10 | # followed by an optional build number separated by a +. 11 | # Both the version and the builder number may be overridden in flutter 12 | # build by specifying --build-name and --build-number, respectively. 13 | # In Android, build-name is used as versionName while build-number used as versionCode. 14 | # Read more about Android versioning at https://developer.android.com/studio/publish/versioning 15 | # In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion. 16 | # Read more about iOS versioning at 17 | # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html 18 | # In Windows, build-name is used as the major, minor, and patch parts 19 | # of the product and file versions while build-number is used as the build suffix. 20 | version: 3.0.0+24 21 | 22 | environment: 23 | sdk: '>=2.19.6 <3.0.0' 24 | 25 | # Dependencies specify other packages that your package needs in order to work. 26 | # To automatically upgrade your package dependencies to the latest versions 27 | # consider running `flutter pub upgrade --major-versions`. Alternatively, 28 | # dependencies can be manually updated by changing the version numbers below to 29 | # the latest version available on pub.dev. To see which dependencies have newer 30 | # versions available, run `flutter pub outdated`. 31 | dependencies: 32 | flutter: 33 | sdk: flutter 34 | 35 | 36 | # The following adds the Cupertino Icons font to your application. 37 | # Use with the CupertinoIcons class for iOS style icons. 38 | cupertino_icons: ^1.0.2 39 | logger: ^2.5.0 40 | mdi: ^5.0.0-nullsafety.0 41 | web_socket_channel: ^3.0.1 42 | shared_preferences: ^2.1.0 43 | url_launcher: ^6.1.10 44 | http: ^1.2.2 45 | fullscreen_window: ^1.0.4 46 | flutter_localizations: 47 | sdk: flutter 48 | intl: any 49 | wakelock_plus: ^1.2.10 50 | app_links: ^6.3.3 51 | 52 | dev_dependencies: 53 | flutter_test: 54 | sdk: flutter 55 | flutter_launcher_icons: ^0.14.2 56 | 57 | # The "flutter_lints" package below contains a set of recommended lints to 58 | # encourage good coding practices. The lint set provided by the package is 59 | # activated in the `analysis_options.yaml` file located at the root of your 60 | # package. See that file for information about deactivating specific lint 61 | # rules and activating additional ones. 62 | flutter_lints: ^5.0.0 63 | 64 | # For information on the generic Dart part of this file, see the 65 | # following page: https://dart.dev/tools/pub/pubspec 66 | 67 | # The following section is specific to Flutter packages. 68 | flutter: 69 | 70 | # The following line ensures that the Material Icons font is 71 | # included with your application, so that you can use the icons in 72 | # the material Icons class. 73 | uses-material-design: true 74 | generate: true 75 | 76 | # To add assets to your application, add an assets section, like this: 77 | # assets: 78 | # - images/a_dot_burr.jpeg 79 | # - images/a_dot_ham.jpeg 80 | 81 | # An image asset can refer to one or more resolution-specific "variants", see 82 | # https://flutter.dev/assets-and-images/#resolution-aware 83 | 84 | # For details regarding adding assets from package dependencies, see 85 | # https://flutter.dev/assets-and-images/#from-packages 86 | 87 | # To add custom fonts to your application, add a fonts section here, 88 | # in this "flutter" section. Each entry in this list should have a 89 | # "family" key with the font family name, and a "fonts" key with a 90 | # list giving the asset and other descriptors for the font. For 91 | # example: 92 | # fonts: 93 | # - family: Schyler 94 | # fonts: 95 | # - asset: fonts/Schyler-Regular.ttf 96 | # - asset: fonts/Schyler-Italic.ttf 97 | # style: italic 98 | # - family: Trajan Pro 99 | # fonts: 100 | # - asset: fonts/TrajanPro.ttf 101 | # - asset: fonts/TrajanPro_Bold.ttf 102 | # weight: 700 103 | # 104 | # For details regarding fonts from package dependencies, 105 | # see https://flutter.dev/custom-fonts/#from-packages 106 | flutter_icons: 107 | android: "launcher_icon" 108 | ios: true 109 | image_path: "assets/icon/icon_256x.ico" 110 | min_sdk_android: 21 # android min sdk min:16, default 21 111 | web: 112 | generate: true 113 | image_path: "assets/icon/icon_256x.ico" 114 | background_color: "#78C2EF" 115 | theme_color: "#78C2EF" 116 | windows: 117 | generate: true 118 | image_path: "assets/icon/icon_256x.ico" 119 | icon_size: 256 # min:48, max:256, default: 48 120 | -------------------------------------------------------------------------------- /client/web/.well-known/assetlinks.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "relation": [ 4 | "delegate_permission/common.handle_all_urls" 5 | ], 6 | "target": { 7 | "namespace": "android_app", 8 | "package_name": "xyz.teages.vtablet", 9 | "sha256_cert_fingerprints": [ 10 | "7B:5D:BC:EA:9C:AB:55:E5:C5:78:24:4D:52:84:E3:B2:F0:D7:10:DE:4B:B0:DC:DE:0C:25:77:7F:E3:89:22:59" 11 | ] 12 | } 13 | } 14 | ] -------------------------------------------------------------------------------- /client/web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Teages/vTablet/a46e1fcf721593f0824f74c6285591b53e5b09f1/client/web/favicon.png -------------------------------------------------------------------------------- /client/web/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Teages/vTablet/a46e1fcf721593f0824f74c6285591b53e5b09f1/client/web/icons/Icon-192.png -------------------------------------------------------------------------------- /client/web/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Teages/vTablet/a46e1fcf721593f0824f74c6285591b53e5b09f1/client/web/icons/Icon-512.png -------------------------------------------------------------------------------- /client/web/icons/Icon-maskable-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Teages/vTablet/a46e1fcf721593f0824f74c6285591b53e5b09f1/client/web/icons/Icon-maskable-192.png -------------------------------------------------------------------------------- /client/web/icons/Icon-maskable-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Teages/vTablet/a46e1fcf721593f0824f74c6285591b53e5b09f1/client/web/icons/Icon-maskable-512.png -------------------------------------------------------------------------------- /client/web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | vTablet 33 | 34 | 35 | 39 | 40 | 41 | 42 | 43 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /client/web/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vTablet", 3 | "short_name": "vTablet", 4 | "start_url": ".", 5 | "display": "standalone", 6 | "background_color": "#0175C2", 7 | "theme_color": "#0175C2", 8 | "description": "A new Flutter project.", 9 | "orientation": "portrait-primary", 10 | "prefer_related_applications": false, 11 | "icons": [ 12 | { 13 | "src": "icons/Icon-192.png", 14 | "sizes": "192x192", 15 | "type": "image/png" 16 | }, 17 | { 18 | "src": "icons/Icon-512.png", 19 | "sizes": "512x512", 20 | "type": "image/png" 21 | }, 22 | { 23 | "src": "icons/Icon-maskable-192.png", 24 | "sizes": "192x192", 25 | "type": "image/png", 26 | "purpose": "maskable" 27 | }, 28 | { 29 | "src": "icons/Icon-maskable-512.png", 30 | "sizes": "512x512", 31 | "type": "image/png", 32 | "purpose": "maskable" 33 | } 34 | ] 35 | } 36 | -------------------------------------------------------------------------------- /client/windows/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral/ 2 | 3 | # Visual Studio user-specific files. 4 | *.suo 5 | *.user 6 | *.userosscache 7 | *.sln.docstates 8 | 9 | # Visual Studio build-related files. 10 | x64/ 11 | x86/ 12 | 13 | # Visual Studio cache files 14 | # files ending in .cache can be ignored 15 | *.[Cc]ache 16 | # but keep track of directories ending in .cache 17 | !*.[Cc]ache/ 18 | -------------------------------------------------------------------------------- /client/windows/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Project-level configuration. 2 | cmake_minimum_required(VERSION 3.14) 3 | project(vtablet LANGUAGES CXX) 4 | 5 | # The name of the executable created for the application. Change this to change 6 | # the on-disk name of your application. 7 | set(BINARY_NAME "vtablet") 8 | 9 | # Explicitly opt in to modern CMake behaviors to avoid warnings with recent 10 | # versions of CMake. 11 | cmake_policy(SET CMP0063 NEW) 12 | 13 | # Define build configuration option. 14 | get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) 15 | if(IS_MULTICONFIG) 16 | set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" 17 | CACHE STRING "" FORCE) 18 | else() 19 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 20 | set(CMAKE_BUILD_TYPE "Debug" CACHE 21 | STRING "Flutter build mode" FORCE) 22 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 23 | "Debug" "Profile" "Release") 24 | endif() 25 | endif() 26 | # Define settings for the Profile build mode. 27 | set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") 28 | set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") 29 | set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") 30 | set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") 31 | 32 | # Use Unicode for all projects. 33 | add_definitions(-DUNICODE -D_UNICODE) 34 | 35 | # Compilation settings that should be applied to most targets. 36 | # 37 | # Be cautious about adding new options here, as plugins use this function by 38 | # default. In most cases, you should add new options to specific targets instead 39 | # of modifying this function. 40 | function(APPLY_STANDARD_SETTINGS TARGET) 41 | target_compile_features(${TARGET} PUBLIC cxx_std_17) 42 | target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") 43 | target_compile_options(${TARGET} PRIVATE /EHsc) 44 | target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") 45 | target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") 46 | endfunction() 47 | 48 | # Flutter library and tool build rules. 49 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") 50 | add_subdirectory(${FLUTTER_MANAGED_DIR}) 51 | 52 | # Application build; see runner/CMakeLists.txt. 53 | add_subdirectory("runner") 54 | 55 | # Generated plugin build rules, which manage building the plugins and adding 56 | # them to the application. 57 | include(flutter/generated_plugins.cmake) 58 | 59 | 60 | # === Installation === 61 | # Support files are copied into place next to the executable, so that it can 62 | # run in place. This is done instead of making a separate bundle (as on Linux) 63 | # so that building and running from within Visual Studio will work. 64 | set(BUILD_BUNDLE_DIR "$") 65 | # Make the "install" step default, as it's required to run. 66 | set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) 67 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 68 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 69 | endif() 70 | 71 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 72 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") 73 | 74 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 75 | COMPONENT Runtime) 76 | 77 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 78 | COMPONENT Runtime) 79 | 80 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 81 | COMPONENT Runtime) 82 | 83 | if(PLUGIN_BUNDLED_LIBRARIES) 84 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" 85 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 86 | COMPONENT Runtime) 87 | endif() 88 | 89 | # Fully re-copy the assets directory on each build to avoid having stale files 90 | # from a previous install. 91 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 92 | install(CODE " 93 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 94 | " COMPONENT Runtime) 95 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 96 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 97 | 98 | # Install the AOT library on non-Debug builds only. 99 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 100 | CONFIGURATIONS Profile;Release 101 | COMPONENT Runtime) 102 | -------------------------------------------------------------------------------- /client/windows/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This file controls Flutter-level build steps. It should not be edited. 2 | cmake_minimum_required(VERSION 3.14) 3 | 4 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 5 | 6 | # Configuration provided via flutter tool. 7 | include(${EPHEMERAL_DIR}/generated_config.cmake) 8 | 9 | # TODO: Move the rest of this into files in ephemeral. See 10 | # https://github.com/flutter/flutter/issues/57146. 11 | set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") 12 | 13 | # === Flutter Library === 14 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") 15 | 16 | # Published to parent scope for install step. 17 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 18 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 19 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 20 | set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) 21 | 22 | list(APPEND FLUTTER_LIBRARY_HEADERS 23 | "flutter_export.h" 24 | "flutter_windows.h" 25 | "flutter_messenger.h" 26 | "flutter_plugin_registrar.h" 27 | "flutter_texture_registrar.h" 28 | ) 29 | list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") 30 | add_library(flutter INTERFACE) 31 | target_include_directories(flutter INTERFACE 32 | "${EPHEMERAL_DIR}" 33 | ) 34 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") 35 | add_dependencies(flutter flutter_assemble) 36 | 37 | # === Wrapper === 38 | list(APPEND CPP_WRAPPER_SOURCES_CORE 39 | "core_implementations.cc" 40 | "standard_codec.cc" 41 | ) 42 | list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") 43 | list(APPEND CPP_WRAPPER_SOURCES_PLUGIN 44 | "plugin_registrar.cc" 45 | ) 46 | list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") 47 | list(APPEND CPP_WRAPPER_SOURCES_APP 48 | "flutter_engine.cc" 49 | "flutter_view_controller.cc" 50 | ) 51 | list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") 52 | 53 | # Wrapper sources needed for a plugin. 54 | add_library(flutter_wrapper_plugin STATIC 55 | ${CPP_WRAPPER_SOURCES_CORE} 56 | ${CPP_WRAPPER_SOURCES_PLUGIN} 57 | ) 58 | apply_standard_settings(flutter_wrapper_plugin) 59 | set_target_properties(flutter_wrapper_plugin PROPERTIES 60 | POSITION_INDEPENDENT_CODE ON) 61 | set_target_properties(flutter_wrapper_plugin PROPERTIES 62 | CXX_VISIBILITY_PRESET hidden) 63 | target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) 64 | target_include_directories(flutter_wrapper_plugin PUBLIC 65 | "${WRAPPER_ROOT}/include" 66 | ) 67 | add_dependencies(flutter_wrapper_plugin flutter_assemble) 68 | 69 | # Wrapper sources needed for the runner. 70 | add_library(flutter_wrapper_app STATIC 71 | ${CPP_WRAPPER_SOURCES_CORE} 72 | ${CPP_WRAPPER_SOURCES_APP} 73 | ) 74 | apply_standard_settings(flutter_wrapper_app) 75 | target_link_libraries(flutter_wrapper_app PUBLIC flutter) 76 | target_include_directories(flutter_wrapper_app PUBLIC 77 | "${WRAPPER_ROOT}/include" 78 | ) 79 | add_dependencies(flutter_wrapper_app flutter_assemble) 80 | 81 | # === Flutter tool backend === 82 | # _phony_ is a non-existent file to force this command to run every time, 83 | # since currently there's no way to get a full input/output list from the 84 | # flutter tool. 85 | set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") 86 | set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) 87 | add_custom_command( 88 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 89 | ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} 90 | ${CPP_WRAPPER_SOURCES_APP} 91 | ${PHONY_OUTPUT} 92 | COMMAND ${CMAKE_COMMAND} -E env 93 | ${FLUTTER_TOOL_ENVIRONMENT} 94 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" 95 | windows-x64 $ 96 | VERBATIM 97 | ) 98 | add_custom_target(flutter_assemble DEPENDS 99 | "${FLUTTER_LIBRARY}" 100 | ${FLUTTER_LIBRARY_HEADERS} 101 | ${CPP_WRAPPER_SOURCES_CORE} 102 | ${CPP_WRAPPER_SOURCES_PLUGIN} 103 | ${CPP_WRAPPER_SOURCES_APP} 104 | ) 105 | -------------------------------------------------------------------------------- /client/windows/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | void RegisterPlugins(flutter::PluginRegistry* registry) { 14 | AppLinksPluginCApiRegisterWithRegistrar( 15 | registry->GetRegistrarForPlugin("AppLinksPluginCApi")); 16 | FullscreenWindowPluginCApiRegisterWithRegistrar( 17 | registry->GetRegistrarForPlugin("FullscreenWindowPluginCApi")); 18 | UrlLauncherWindowsRegisterWithRegistrar( 19 | registry->GetRegistrarForPlugin("UrlLauncherWindows")); 20 | } 21 | -------------------------------------------------------------------------------- /client/windows/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void RegisterPlugins(flutter::PluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /client/windows/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | app_links 7 | fullscreen_window 8 | url_launcher_windows 9 | ) 10 | 11 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 12 | ) 13 | 14 | set(PLUGIN_BUNDLED_LIBRARIES) 15 | 16 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 17 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) 18 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 19 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 20 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 21 | endforeach(plugin) 22 | 23 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 24 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) 25 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 26 | endforeach(ffi_plugin) 27 | -------------------------------------------------------------------------------- /client/windows/runner/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | project(runner LANGUAGES CXX) 3 | 4 | # Define the application target. To change its name, change BINARY_NAME in the 5 | # top-level CMakeLists.txt, not the value here, or `flutter run` will no longer 6 | # work. 7 | # 8 | # Any new source files that you add to the application should be added here. 9 | add_executable(${BINARY_NAME} WIN32 10 | "flutter_window.cpp" 11 | "main.cpp" 12 | "utils.cpp" 13 | "win32_window.cpp" 14 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 15 | "Runner.rc" 16 | "runner.exe.manifest" 17 | ) 18 | 19 | # Apply the standard set of build settings. This can be removed for applications 20 | # that need different build settings. 21 | apply_standard_settings(${BINARY_NAME}) 22 | 23 | # Disable Windows macros that collide with C++ standard library functions. 24 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") 25 | 26 | # Add dependency libraries and include directories. Add any application-specific 27 | # dependencies here. 28 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) 29 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") 30 | 31 | # Run the Flutter tool portions of the build. This must not be removed. 32 | add_dependencies(${BINARY_NAME} flutter_assemble) 33 | -------------------------------------------------------------------------------- /client/windows/runner/Runner.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #pragma code_page(65001) 4 | #include "resource.h" 5 | 6 | #define APSTUDIO_READONLY_SYMBOLS 7 | ///////////////////////////////////////////////////////////////////////////// 8 | // 9 | // Generated from the TEXTINCLUDE 2 resource. 10 | // 11 | #include "winres.h" 12 | 13 | ///////////////////////////////////////////////////////////////////////////// 14 | #undef APSTUDIO_READONLY_SYMBOLS 15 | 16 | ///////////////////////////////////////////////////////////////////////////// 17 | // English (United States) resources 18 | 19 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 20 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 21 | 22 | #ifdef APSTUDIO_INVOKED 23 | ///////////////////////////////////////////////////////////////////////////// 24 | // 25 | // TEXTINCLUDE 26 | // 27 | 28 | 1 TEXTINCLUDE 29 | BEGIN 30 | "resource.h\0" 31 | END 32 | 33 | 2 TEXTINCLUDE 34 | BEGIN 35 | "#include ""winres.h""\r\n" 36 | "\0" 37 | END 38 | 39 | 3 TEXTINCLUDE 40 | BEGIN 41 | "\r\n" 42 | "\0" 43 | END 44 | 45 | #endif // APSTUDIO_INVOKED 46 | 47 | 48 | ///////////////////////////////////////////////////////////////////////////// 49 | // 50 | // Icon 51 | // 52 | 53 | // Icon with lowest ID value placed first to ensure application icon 54 | // remains consistent on all systems. 55 | IDI_APP_ICON ICON "resources\\app_icon.ico" 56 | 57 | 58 | ///////////////////////////////////////////////////////////////////////////// 59 | // 60 | // Version 61 | // 62 | 63 | #ifdef FLUTTER_BUILD_NUMBER 64 | #define VERSION_AS_NUMBER FLUTTER_BUILD_NUMBER 65 | #else 66 | #define VERSION_AS_NUMBER 1,0,0 67 | #endif 68 | 69 | #ifdef FLUTTER_BUILD_NAME 70 | #define VERSION_AS_STRING #FLUTTER_BUILD_NAME 71 | #else 72 | #define VERSION_AS_STRING "1.0.0" 73 | #endif 74 | 75 | VS_VERSION_INFO VERSIONINFO 76 | FILEVERSION VERSION_AS_NUMBER 77 | PRODUCTVERSION VERSION_AS_NUMBER 78 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 79 | #ifdef _DEBUG 80 | FILEFLAGS VS_FF_DEBUG 81 | #else 82 | FILEFLAGS 0x0L 83 | #endif 84 | FILEOS VOS__WINDOWS32 85 | FILETYPE VFT_APP 86 | FILESUBTYPE 0x0L 87 | BEGIN 88 | BLOCK "StringFileInfo" 89 | BEGIN 90 | BLOCK "040904e4" 91 | BEGIN 92 | VALUE "CompanyName", "xyz.teages" "\0" 93 | VALUE "FileDescription", "vtablet" "\0" 94 | VALUE "FileVersion", VERSION_AS_STRING "\0" 95 | VALUE "InternalName", "vtablet" "\0" 96 | VALUE "LegalCopyright", "Copyright (C) 2022 xyz.teages. All rights reserved." "\0" 97 | VALUE "OriginalFilename", "vtablet.exe" "\0" 98 | VALUE "ProductName", "vtablet" "\0" 99 | VALUE "ProductVersion", VERSION_AS_STRING "\0" 100 | END 101 | END 102 | BLOCK "VarFileInfo" 103 | BEGIN 104 | VALUE "Translation", 0x409, 1252 105 | END 106 | END 107 | 108 | #endif // English (United States) resources 109 | ///////////////////////////////////////////////////////////////////////////// 110 | 111 | 112 | 113 | #ifndef APSTUDIO_INVOKED 114 | ///////////////////////////////////////////////////////////////////////////// 115 | // 116 | // Generated from the TEXTINCLUDE 3 resource. 117 | // 118 | 119 | 120 | ///////////////////////////////////////////////////////////////////////////// 121 | #endif // not APSTUDIO_INVOKED 122 | -------------------------------------------------------------------------------- /client/windows/runner/flutter_window.cpp: -------------------------------------------------------------------------------- 1 | #include "flutter_window.h" 2 | 3 | #include 4 | 5 | #include "flutter/generated_plugin_registrant.h" 6 | 7 | FlutterWindow::FlutterWindow(const flutter::DartProject& project) 8 | : project_(project) {} 9 | 10 | FlutterWindow::~FlutterWindow() {} 11 | 12 | bool FlutterWindow::OnCreate() { 13 | if (!Win32Window::OnCreate()) { 14 | return false; 15 | } 16 | 17 | RECT frame = GetClientArea(); 18 | 19 | // The size here must match the window dimensions to avoid unnecessary surface 20 | // creation / destruction in the startup path. 21 | flutter_controller_ = std::make_unique( 22 | frame.right - frame.left, frame.bottom - frame.top, project_); 23 | // Ensure that basic setup of the controller was successful. 24 | if (!flutter_controller_->engine() || !flutter_controller_->view()) { 25 | return false; 26 | } 27 | RegisterPlugins(flutter_controller_->engine()); 28 | SetChildContent(flutter_controller_->view()->GetNativeWindow()); 29 | return true; 30 | } 31 | 32 | void FlutterWindow::OnDestroy() { 33 | if (flutter_controller_) { 34 | flutter_controller_ = nullptr; 35 | } 36 | 37 | Win32Window::OnDestroy(); 38 | } 39 | 40 | LRESULT 41 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message, 42 | WPARAM const wparam, 43 | LPARAM const lparam) noexcept { 44 | // Give Flutter, including plugins, an opportunity to handle window messages. 45 | if (flutter_controller_) { 46 | std::optional result = 47 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, 48 | lparam); 49 | if (result) { 50 | return *result; 51 | } 52 | } 53 | 54 | switch (message) { 55 | case WM_FONTCHANGE: 56 | flutter_controller_->engine()->ReloadSystemFonts(); 57 | break; 58 | } 59 | 60 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam); 61 | } 62 | -------------------------------------------------------------------------------- /client/windows/runner/flutter_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_FLUTTER_WINDOW_H_ 2 | #define RUNNER_FLUTTER_WINDOW_H_ 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include "win32_window.h" 10 | 11 | // A window that does nothing but host a Flutter view. 12 | class FlutterWindow : public Win32Window { 13 | public: 14 | // Creates a new FlutterWindow hosting a Flutter view running |project|. 15 | explicit FlutterWindow(const flutter::DartProject& project); 16 | virtual ~FlutterWindow(); 17 | 18 | protected: 19 | // Win32Window: 20 | bool OnCreate() override; 21 | void OnDestroy() override; 22 | LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, 23 | LPARAM const lparam) noexcept override; 24 | 25 | private: 26 | // The project to run. 27 | flutter::DartProject project_; 28 | 29 | // The Flutter instance hosted by this window. 30 | std::unique_ptr flutter_controller_; 31 | }; 32 | 33 | #endif // RUNNER_FLUTTER_WINDOW_H_ 34 | -------------------------------------------------------------------------------- /client/windows/runner/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "flutter_window.h" 6 | #include "utils.h" 7 | 8 | int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, 9 | _In_ wchar_t *command_line, _In_ int show_command) { 10 | // Attach to console when present (e.g., 'flutter run') or create a 11 | // new console when running with a debugger. 12 | if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { 13 | CreateAndAttachConsole(); 14 | } 15 | 16 | // Initialize COM, so that it is available for use in the library and/or 17 | // plugins. 18 | ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); 19 | 20 | flutter::DartProject project(L"data"); 21 | 22 | std::vector command_line_arguments = 23 | GetCommandLineArguments(); 24 | 25 | project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); 26 | 27 | FlutterWindow window(project); 28 | Win32Window::Point origin(10, 10); 29 | Win32Window::Size size(1280, 720); 30 | if (!window.CreateAndShow(L"vtablet", origin, size)) { 31 | return EXIT_FAILURE; 32 | } 33 | window.SetQuitOnClose(true); 34 | 35 | ::MSG msg; 36 | while (::GetMessage(&msg, nullptr, 0, 0)) { 37 | ::TranslateMessage(&msg); 38 | ::DispatchMessage(&msg); 39 | } 40 | 41 | ::CoUninitialize(); 42 | return EXIT_SUCCESS; 43 | } 44 | -------------------------------------------------------------------------------- /client/windows/runner/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by Runner.rc 4 | // 5 | #define IDI_APP_ICON 101 6 | 7 | // Next default values for new objects 8 | // 9 | #ifdef APSTUDIO_INVOKED 10 | #ifndef APSTUDIO_READONLY_SYMBOLS 11 | #define _APS_NEXT_RESOURCE_VALUE 102 12 | #define _APS_NEXT_COMMAND_VALUE 40001 13 | #define _APS_NEXT_CONTROL_VALUE 1001 14 | #define _APS_NEXT_SYMED_VALUE 101 15 | #endif 16 | #endif 17 | -------------------------------------------------------------------------------- /client/windows/runner/resources/app_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Teages/vTablet/a46e1fcf721593f0824f74c6285591b53e5b09f1/client/windows/runner/resources/app_icon.ico -------------------------------------------------------------------------------- /client/windows/runner/runner.exe.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PerMonitorV2 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /client/windows/runner/utils.cpp: -------------------------------------------------------------------------------- 1 | #include "utils.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | void CreateAndAttachConsole() { 11 | if (::AllocConsole()) { 12 | FILE *unused; 13 | if (freopen_s(&unused, "CONOUT$", "w", stdout)) { 14 | _dup2(_fileno(stdout), 1); 15 | } 16 | if (freopen_s(&unused, "CONOUT$", "w", stderr)) { 17 | _dup2(_fileno(stdout), 2); 18 | } 19 | std::ios::sync_with_stdio(); 20 | FlutterDesktopResyncOutputStreams(); 21 | } 22 | } 23 | 24 | std::vector GetCommandLineArguments() { 25 | // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. 26 | int argc; 27 | wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); 28 | if (argv == nullptr) { 29 | return std::vector(); 30 | } 31 | 32 | std::vector command_line_arguments; 33 | 34 | // Skip the first argument as it's the binary name. 35 | for (int i = 1; i < argc; i++) { 36 | command_line_arguments.push_back(Utf8FromUtf16(argv[i])); 37 | } 38 | 39 | ::LocalFree(argv); 40 | 41 | return command_line_arguments; 42 | } 43 | 44 | std::string Utf8FromUtf16(const wchar_t* utf16_string) { 45 | if (utf16_string == nullptr) { 46 | return std::string(); 47 | } 48 | int target_length = ::WideCharToMultiByte( 49 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 50 | -1, nullptr, 0, nullptr, nullptr); 51 | std::string utf8_string; 52 | if (target_length == 0 || target_length > utf8_string.max_size()) { 53 | return utf8_string; 54 | } 55 | utf8_string.resize(target_length); 56 | int converted_length = ::WideCharToMultiByte( 57 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 58 | -1, utf8_string.data(), 59 | target_length, nullptr, nullptr); 60 | if (converted_length == 0) { 61 | return std::string(); 62 | } 63 | return utf8_string; 64 | } 65 | -------------------------------------------------------------------------------- /client/windows/runner/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_UTILS_H_ 2 | #define RUNNER_UTILS_H_ 3 | 4 | #include 5 | #include 6 | 7 | // Creates a console for the process, and redirects stdout and stderr to 8 | // it for both the runner and the Flutter library. 9 | void CreateAndAttachConsole(); 10 | 11 | // Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string 12 | // encoded in UTF-8. Returns an empty std::string on failure. 13 | std::string Utf8FromUtf16(const wchar_t* utf16_string); 14 | 15 | // Gets the command line arguments passed in as a std::vector, 16 | // encoded in UTF-8. Returns an empty std::vector on failure. 17 | std::vector GetCommandLineArguments(); 18 | 19 | #endif // RUNNER_UTILS_H_ 20 | -------------------------------------------------------------------------------- /client/windows/runner/win32_window.cpp: -------------------------------------------------------------------------------- 1 | #include "win32_window.h" 2 | 3 | #include 4 | 5 | #include "resource.h" 6 | 7 | namespace { 8 | 9 | constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW"; 10 | 11 | // The number of Win32Window objects that currently exist. 12 | static int g_active_window_count = 0; 13 | 14 | using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd); 15 | 16 | // Scale helper to convert logical scaler values to physical using passed in 17 | // scale factor 18 | int Scale(int source, double scale_factor) { 19 | return static_cast(source * scale_factor); 20 | } 21 | 22 | // Dynamically loads the |EnableNonClientDpiScaling| from the User32 module. 23 | // This API is only needed for PerMonitor V1 awareness mode. 24 | void EnableFullDpiSupportIfAvailable(HWND hwnd) { 25 | HMODULE user32_module = LoadLibraryA("User32.dll"); 26 | if (!user32_module) { 27 | return; 28 | } 29 | auto enable_non_client_dpi_scaling = 30 | reinterpret_cast( 31 | GetProcAddress(user32_module, "EnableNonClientDpiScaling")); 32 | if (enable_non_client_dpi_scaling != nullptr) { 33 | enable_non_client_dpi_scaling(hwnd); 34 | FreeLibrary(user32_module); 35 | } 36 | } 37 | 38 | } // namespace 39 | 40 | // Manages the Win32Window's window class registration. 41 | class WindowClassRegistrar { 42 | public: 43 | ~WindowClassRegistrar() = default; 44 | 45 | // Returns the singleton registar instance. 46 | static WindowClassRegistrar* GetInstance() { 47 | if (!instance_) { 48 | instance_ = new WindowClassRegistrar(); 49 | } 50 | return instance_; 51 | } 52 | 53 | // Returns the name of the window class, registering the class if it hasn't 54 | // previously been registered. 55 | const wchar_t* GetWindowClass(); 56 | 57 | // Unregisters the window class. Should only be called if there are no 58 | // instances of the window. 59 | void UnregisterWindowClass(); 60 | 61 | private: 62 | WindowClassRegistrar() = default; 63 | 64 | static WindowClassRegistrar* instance_; 65 | 66 | bool class_registered_ = false; 67 | }; 68 | 69 | WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr; 70 | 71 | const wchar_t* WindowClassRegistrar::GetWindowClass() { 72 | if (!class_registered_) { 73 | WNDCLASS window_class{}; 74 | window_class.hCursor = LoadCursor(nullptr, IDC_ARROW); 75 | window_class.lpszClassName = kWindowClassName; 76 | window_class.style = CS_HREDRAW | CS_VREDRAW; 77 | window_class.cbClsExtra = 0; 78 | window_class.cbWndExtra = 0; 79 | window_class.hInstance = GetModuleHandle(nullptr); 80 | window_class.hIcon = 81 | LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON)); 82 | window_class.hbrBackground = 0; 83 | window_class.lpszMenuName = nullptr; 84 | window_class.lpfnWndProc = Win32Window::WndProc; 85 | RegisterClass(&window_class); 86 | class_registered_ = true; 87 | } 88 | return kWindowClassName; 89 | } 90 | 91 | void WindowClassRegistrar::UnregisterWindowClass() { 92 | UnregisterClass(kWindowClassName, nullptr); 93 | class_registered_ = false; 94 | } 95 | 96 | Win32Window::Win32Window() { 97 | ++g_active_window_count; 98 | } 99 | 100 | Win32Window::~Win32Window() { 101 | --g_active_window_count; 102 | Destroy(); 103 | } 104 | 105 | bool Win32Window::CreateAndShow(const std::wstring& title, 106 | const Point& origin, 107 | const Size& size) { 108 | Destroy(); 109 | 110 | const wchar_t* window_class = 111 | WindowClassRegistrar::GetInstance()->GetWindowClass(); 112 | 113 | const POINT target_point = {static_cast(origin.x), 114 | static_cast(origin.y)}; 115 | HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST); 116 | UINT dpi = FlutterDesktopGetDpiForMonitor(monitor); 117 | double scale_factor = dpi / 96.0; 118 | 119 | HWND window = CreateWindow( 120 | window_class, title.c_str(), WS_OVERLAPPEDWINDOW | WS_VISIBLE, 121 | Scale(origin.x, scale_factor), Scale(origin.y, scale_factor), 122 | Scale(size.width, scale_factor), Scale(size.height, scale_factor), 123 | nullptr, nullptr, GetModuleHandle(nullptr), this); 124 | 125 | if (!window) { 126 | return false; 127 | } 128 | 129 | return OnCreate(); 130 | } 131 | 132 | // static 133 | LRESULT CALLBACK Win32Window::WndProc(HWND const window, 134 | UINT const message, 135 | WPARAM const wparam, 136 | LPARAM const lparam) noexcept { 137 | if (message == WM_NCCREATE) { 138 | auto window_struct = reinterpret_cast(lparam); 139 | SetWindowLongPtr(window, GWLP_USERDATA, 140 | reinterpret_cast(window_struct->lpCreateParams)); 141 | 142 | auto that = static_cast(window_struct->lpCreateParams); 143 | EnableFullDpiSupportIfAvailable(window); 144 | that->window_handle_ = window; 145 | } else if (Win32Window* that = GetThisFromHandle(window)) { 146 | return that->MessageHandler(window, message, wparam, lparam); 147 | } 148 | 149 | return DefWindowProc(window, message, wparam, lparam); 150 | } 151 | 152 | LRESULT 153 | Win32Window::MessageHandler(HWND hwnd, 154 | UINT const message, 155 | WPARAM const wparam, 156 | LPARAM const lparam) noexcept { 157 | switch (message) { 158 | case WM_DESTROY: 159 | window_handle_ = nullptr; 160 | Destroy(); 161 | if (quit_on_close_) { 162 | PostQuitMessage(0); 163 | } 164 | return 0; 165 | 166 | case WM_DPICHANGED: { 167 | auto newRectSize = reinterpret_cast(lparam); 168 | LONG newWidth = newRectSize->right - newRectSize->left; 169 | LONG newHeight = newRectSize->bottom - newRectSize->top; 170 | 171 | SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth, 172 | newHeight, SWP_NOZORDER | SWP_NOACTIVATE); 173 | 174 | return 0; 175 | } 176 | case WM_SIZE: { 177 | RECT rect = GetClientArea(); 178 | if (child_content_ != nullptr) { 179 | // Size and position the child window. 180 | MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left, 181 | rect.bottom - rect.top, TRUE); 182 | } 183 | return 0; 184 | } 185 | 186 | case WM_ACTIVATE: 187 | if (child_content_ != nullptr) { 188 | SetFocus(child_content_); 189 | } 190 | return 0; 191 | } 192 | 193 | return DefWindowProc(window_handle_, message, wparam, lparam); 194 | } 195 | 196 | void Win32Window::Destroy() { 197 | OnDestroy(); 198 | 199 | if (window_handle_) { 200 | DestroyWindow(window_handle_); 201 | window_handle_ = nullptr; 202 | } 203 | if (g_active_window_count == 0) { 204 | WindowClassRegistrar::GetInstance()->UnregisterWindowClass(); 205 | } 206 | } 207 | 208 | Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept { 209 | return reinterpret_cast( 210 | GetWindowLongPtr(window, GWLP_USERDATA)); 211 | } 212 | 213 | void Win32Window::SetChildContent(HWND content) { 214 | child_content_ = content; 215 | SetParent(content, window_handle_); 216 | RECT frame = GetClientArea(); 217 | 218 | MoveWindow(content, frame.left, frame.top, frame.right - frame.left, 219 | frame.bottom - frame.top, true); 220 | 221 | SetFocus(child_content_); 222 | } 223 | 224 | RECT Win32Window::GetClientArea() { 225 | RECT frame; 226 | GetClientRect(window_handle_, &frame); 227 | return frame; 228 | } 229 | 230 | HWND Win32Window::GetHandle() { 231 | return window_handle_; 232 | } 233 | 234 | void Win32Window::SetQuitOnClose(bool quit_on_close) { 235 | quit_on_close_ = quit_on_close; 236 | } 237 | 238 | bool Win32Window::OnCreate() { 239 | // No-op; provided for subclasses. 240 | return true; 241 | } 242 | 243 | void Win32Window::OnDestroy() { 244 | // No-op; provided for subclasses. 245 | } 246 | -------------------------------------------------------------------------------- /client/windows/runner/win32_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_WIN32_WINDOW_H_ 2 | #define RUNNER_WIN32_WINDOW_H_ 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | // A class abstraction for a high DPI-aware Win32 Window. Intended to be 11 | // inherited from by classes that wish to specialize with custom 12 | // rendering and input handling 13 | class Win32Window { 14 | public: 15 | struct Point { 16 | unsigned int x; 17 | unsigned int y; 18 | Point(unsigned int x, unsigned int y) : x(x), y(y) {} 19 | }; 20 | 21 | struct Size { 22 | unsigned int width; 23 | unsigned int height; 24 | Size(unsigned int width, unsigned int height) 25 | : width(width), height(height) {} 26 | }; 27 | 28 | Win32Window(); 29 | virtual ~Win32Window(); 30 | 31 | // Creates and shows a win32 window with |title| and position and size using 32 | // |origin| and |size|. New windows are created on the default monitor. Window 33 | // sizes are specified to the OS in physical pixels, hence to ensure a 34 | // consistent size to will treat the width height passed in to this function 35 | // as logical pixels and scale to appropriate for the default monitor. Returns 36 | // true if the window was created successfully. 37 | bool CreateAndShow(const std::wstring& title, 38 | const Point& origin, 39 | const Size& size); 40 | 41 | // Release OS resources associated with window. 42 | void Destroy(); 43 | 44 | // Inserts |content| into the window tree. 45 | void SetChildContent(HWND content); 46 | 47 | // Returns the backing Window handle to enable clients to set icon and other 48 | // window properties. Returns nullptr if the window has been destroyed. 49 | HWND GetHandle(); 50 | 51 | // If true, closing this window will quit the application. 52 | void SetQuitOnClose(bool quit_on_close); 53 | 54 | // Return a RECT representing the bounds of the current client area. 55 | RECT GetClientArea(); 56 | 57 | protected: 58 | // Processes and route salient window messages for mouse handling, 59 | // size change and DPI. Delegates handling of these to member overloads that 60 | // inheriting classes can handle. 61 | virtual LRESULT MessageHandler(HWND window, 62 | UINT const message, 63 | WPARAM const wparam, 64 | LPARAM const lparam) noexcept; 65 | 66 | // Called when CreateAndShow is called, allowing subclass window-related 67 | // setup. Subclasses should return false if setup fails. 68 | virtual bool OnCreate(); 69 | 70 | // Called when Destroy is called. 71 | virtual void OnDestroy(); 72 | 73 | private: 74 | friend class WindowClassRegistrar; 75 | 76 | // OS callback called by message pump. Handles the WM_NCCREATE message which 77 | // is passed when the non-client area is being created and enables automatic 78 | // non-client DPI scaling so that the non-client area automatically 79 | // responsponds to changes in DPI. All other messages are handled by 80 | // MessageHandler. 81 | static LRESULT CALLBACK WndProc(HWND const window, 82 | UINT const message, 83 | WPARAM const wparam, 84 | LPARAM const lparam) noexcept; 85 | 86 | // Retrieves a class instance pointer for |window| 87 | static Win32Window* GetThisFromHandle(HWND const window) noexcept; 88 | 89 | bool quit_on_close_ = false; 90 | 91 | // window handle for top level window. 92 | HWND window_handle_ = nullptr; 93 | 94 | // window handle for hosted content. 95 | HWND child_content_ = nullptr; 96 | }; 97 | 98 | #endif // RUNNER_WIN32_WINDOW_H_ 99 | -------------------------------------------------------------------------------- /server/.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /server/.gitignore: -------------------------------------------------------------------------------- 1 | # If you prefer the allow list template instead of the deny list, see community template: 2 | # https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore 3 | # 4 | # Binaries for programs and plugins 5 | # *.exe 6 | # *.exe~ 7 | # *.dll 8 | # *.so 9 | # *.dylib 10 | 11 | dist/* 12 | 13 | # Test binary, built with `go test -c` 14 | *.test 15 | 16 | # Output of the go coverage tool, specifically when used with LiteIDE 17 | *.out 18 | 19 | # Dependency directories (remove the comment below to include it) 20 | vendor/ 21 | 22 | # Go workspace file 23 | go.work 24 | 25 | 26 | !assets/** 27 | !libs/** 28 | !libs/**/** -------------------------------------------------------------------------------- /server/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "type": "shell", 4 | "cwd": "${workspaceFolder}", 5 | "tasks": [ 6 | { 7 | "label": "build & run", 8 | "command": "bin/build.bat; bin/run.bat", 9 | "group": { 10 | "kind": "build", 11 | "isDefault": true 12 | }, 13 | "problemMatcher": [] 14 | }, 15 | { 16 | "label": "install", 17 | "command": "go", 18 | "args": [ 19 | "install", 20 | "-v", 21 | "./..." 22 | ], 23 | "group": "build", 24 | "problemMatcher": [] 25 | }, 26 | { 27 | "label": "build", 28 | "command": "bin/build.bat", 29 | "group": "build", 30 | "problemMatcher": [] 31 | } 32 | ], 33 | } -------------------------------------------------------------------------------- /server/assets/icon_256x.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Teages/vTablet/a46e1fcf721593f0824f74c6285591b53e5b09f1/server/assets/icon_256x.ico -------------------------------------------------------------------------------- /server/bin/build.bat: -------------------------------------------------------------------------------- 1 | 2 | go build -o dist/windows_amd64/ -------------------------------------------------------------------------------- /server/bin/run.bat: -------------------------------------------------------------------------------- 1 | .\\dist\\windows_amd64\\vTablet.exe -------------------------------------------------------------------------------- /server/controllers.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "encoding/json" 5 | "flag" 6 | "fmt" 7 | "io" 8 | "log" 9 | "net/http" 10 | "strings" 11 | 12 | "github.com/Teages/go-vdigi" 13 | "golang.org/x/net/websocket" 14 | ) 15 | 16 | func initWebServices(port int) { 17 | flag.Parse() 18 | 19 | http.HandleFunc("/", clientPage) 20 | http.HandleFunc("/connect", connecter) 21 | 22 | for i := 0; i < vdigi.GetScreens().GetScreenCount(); i++ { 23 | screen, _ := vdigi.GetScreens().GetScreen(i) 24 | http.Handle(fmt.Sprintf("/digi/%s", screen.Uid), connectFactory(screen.Uid)) 25 | } 26 | 27 | addr := flag.String("addr", fmt.Sprintf("0.0.0.0:%d", port), "http service address") 28 | log.Fatal(http.ListenAndServe(*addr, nil)) 29 | } 30 | 31 | type ScreenData struct { 32 | Uid string `json:"uid"` 33 | Path string `json:"path"` 34 | Width int `json:"width"` 35 | Height int `json:"height"` 36 | } 37 | 38 | func connecter(w http.ResponseWriter, r *http.Request) { 39 | w.Header().Set("Content-Type", "application/json") 40 | w.Header().Set("Access-Control-Allow-Origin", "https://vtablet.teages.xyz") 41 | w.WriteHeader(http.StatusOK) 42 | 43 | var ans []ScreenData 44 | for i := 0; i < vdigi.GetScreens().GetScreenCount(); i++ { 45 | screen, _ := vdigi.GetScreens().GetScreen(i) 46 | ans = append(ans, ScreenData{ 47 | screen.Uid, 48 | fmt.Sprintf("/digi/%s", screen.Uid), 49 | screen.Width, 50 | screen.Height, 51 | }) 52 | } 53 | json_str, _ := json.Marshal(ans) 54 | io.WriteString(w, string(json_str)) 55 | } 56 | 57 | func connectFactory(screeUid string) websocket.Handler { 58 | return websocket.Handler(func(c *websocket.Conn) { 59 | origin := c.Config().Origin.Host 60 | allows := "http://localhost:23052\n" + "https://vtablet.teages.xyz\n" 61 | if !strings.Contains(allows, origin) { 62 | c.Close() 63 | return 64 | } 65 | pointerServices(screeUid, c) 66 | }) 67 | } 68 | 69 | func clientPage(w http.ResponseWriter, r *http.Request) { 70 | http.Redirect(w, r, "https://vtablet.teages.xyz", http.StatusFound) 71 | } 72 | -------------------------------------------------------------------------------- /server/docs/connect.md: -------------------------------------------------------------------------------- 1 | ## digi postion 2 | 3 | ```python 4 | (x * 32768 + y) * 8192 + p 5 | ``` -------------------------------------------------------------------------------- /server/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/Teages/vTablet 2 | 3 | go 1.20 4 | 5 | require ( 6 | github.com/Teages/go-autostart v0.0.0-20220902154128-6e07ff286975 7 | golang.org/x/sys v0.6.0 // indirect 8 | ) 9 | 10 | require ( 11 | github.com/getlantern/context v0.0.0-20220418194847-3d5e7a086201 // indirect 12 | github.com/getlantern/errors v1.0.3 // indirect 13 | github.com/getlantern/golog v0.0.0-20230206140254-6d0a2e0f79af // indirect 14 | github.com/getlantern/hex v0.0.0-20220104173244-ad7e4b9194dc // indirect 15 | github.com/getlantern/hidden v0.0.0-20220104173330-f221c5a24770 // indirect 16 | github.com/getlantern/ops v0.0.0-20220713155959-1315d978fff7 // indirect 17 | github.com/go-logr/logr v1.2.3 // indirect 18 | github.com/go-logr/stdr v1.2.2 // indirect 19 | github.com/go-stack/stack v1.8.1 // indirect 20 | github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c // indirect 21 | github.com/stretchr/testify v1.8.2 // indirect 22 | go.opentelemetry.io/otel v1.9.0 // indirect 23 | go.opentelemetry.io/otel/trace v1.9.0 // indirect 24 | go.uber.org/atomic v1.7.0 // indirect 25 | go.uber.org/multierr v1.6.0 // indirect 26 | go.uber.org/zap v1.19.1 // indirect 27 | ) 28 | 29 | require ( 30 | github.com/Teages/go-vdigi v0.2.1 31 | github.com/Teages/go-vfile v0.0.2 32 | github.com/getlantern/systray v1.2.1 33 | github.com/go-ole/go-ole v1.2.6 // indirect 34 | github.com/zach-klippenstein/goadb v0.0.0-20201208042340-620e0e950ed7 35 | golang.org/x/net v0.8.0 36 | ) 37 | -------------------------------------------------------------------------------- /server/go.sum: -------------------------------------------------------------------------------- 1 | github.com/Teages/go-autostart v0.0.0-20220902154128-6e07ff286975 h1:fJyPPigvnVBwmCsY8I3C9Ag4RsN+dRAqm5uq6fkbMMM= 2 | github.com/Teages/go-autostart v0.0.0-20220902154128-6e07ff286975/go.mod h1:x1oXrbaZQHmTTE9pLj3LYjefeLkEYY+AAq/RODO9Cfg= 3 | github.com/Teages/go-vdigi v0.2.1 h1:Xec0kR+qC5wnT4KQjuSoJuWQDyt8RJ1vxcf3MYpEuec= 4 | github.com/Teages/go-vdigi v0.2.1/go.mod h1:fcSffmrQ8TJu8GH//dIbnEbw9g8BxQPrJYs5aUAyd1A= 5 | github.com/Teages/go-vfile v0.0.2 h1:u2XOUsMrX9CIWp7s+pfMjlnrv3pUtijHdWxbqnmf+6E= 6 | github.com/Teages/go-vfile v0.0.2/go.mod h1:LhuEFb4vgmxCu3wzpgy9xNAF/2K+Awigkp+HMW5eXxM= 7 | github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= 8 | github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= 9 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 10 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 11 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 12 | github.com/getlantern/context v0.0.0-20190109183933-c447772a6520/go.mod h1:L+mq6/vvYHKjCX2oez0CgEAJmbq1fbb/oNJIWQkBybY= 13 | github.com/getlantern/context v0.0.0-20220418194847-3d5e7a086201 h1:oEZYEpZo28Wdx+5FZo4aU7JFXu0WG/4wJWese5reQSA= 14 | github.com/getlantern/context v0.0.0-20220418194847-3d5e7a086201/go.mod h1:Y9WZUHEb+mpra02CbQ/QczLUe6f0Dezxaw5DCJlJQGo= 15 | github.com/getlantern/errors v0.0.0-20190325191628-abdb3e3e36f7/go.mod h1:l+xpFBrCtDLpK9qNjxs+cHU6+BAdlBaxHqikB6Lku3A= 16 | github.com/getlantern/errors v1.0.1/go.mod h1:l+xpFBrCtDLpK9qNjxs+cHU6+BAdlBaxHqikB6Lku3A= 17 | github.com/getlantern/errors v1.0.3 h1:Ne4Ycj7NI1BtSyAfVeAT/DNoxz7/S2BUc3L2Ht1YSHE= 18 | github.com/getlantern/errors v1.0.3/go.mod h1:m8C7H1qmouvsGpwQqk/6NUpIVMpfzUPn608aBZDYV04= 19 | github.com/getlantern/golog v0.0.0-20190830074920-4ef2e798c2d7/go.mod h1:zx/1xUUeYPy3Pcmet8OSXLbF47l+3y6hIPpyLWoR9oc= 20 | github.com/getlantern/golog v0.0.0-20230206140254-6d0a2e0f79af h1:cvD5qCZpH/Q32Ae0i1W1lRkVuM21czEZaJpTuRiJjc4= 21 | github.com/getlantern/golog v0.0.0-20230206140254-6d0a2e0f79af/go.mod h1:+ZU1h+iOVqWReBpky6d5Y2WL0sF2Llxu+QcxJFs2+OU= 22 | github.com/getlantern/hex v0.0.0-20190417191902-c6586a6fe0b7/go.mod h1:dD3CgOrwlzca8ed61CsZouQS5h5jIzkK9ZWrTcf0s+o= 23 | github.com/getlantern/hex v0.0.0-20220104173244-ad7e4b9194dc h1:sue+aeVx7JF5v36H1HfvcGFImLpSD5goj8d+MitovDU= 24 | github.com/getlantern/hex v0.0.0-20220104173244-ad7e4b9194dc/go.mod h1:D9RWpXy/EFPYxiKUURo2TB8UBosbqkiLhttRrZYtvqM= 25 | github.com/getlantern/hidden v0.0.0-20190325191715-f02dbb02be55/go.mod h1:6mmzY2kW1TOOrVy+r41Za2MxXM+hhqTtY3oBKd2AgFA= 26 | github.com/getlantern/hidden v0.0.0-20220104173330-f221c5a24770 h1:cSrD9ryDfTV2yaur9Qk3rHYD414j3Q1rl7+L0AylxrE= 27 | github.com/getlantern/hidden v0.0.0-20220104173330-f221c5a24770/go.mod h1:GOQsoDnEHl6ZmNIL+5uVo+JWRFWozMEp18Izcb++H+A= 28 | github.com/getlantern/ops v0.0.0-20190325191751-d70cb0d6f85f/go.mod h1:D5ao98qkA6pxftxoqzibIBBrLSUli+kYnJqrgBf9cIA= 29 | github.com/getlantern/ops v0.0.0-20220713155959-1315d978fff7 h1:Od0xvR4iK3gZwhkIbxnHw4Teusv+n5G/F9dW7x+C2f0= 30 | github.com/getlantern/ops v0.0.0-20220713155959-1315d978fff7/go.mod h1:D5ao98qkA6pxftxoqzibIBBrLSUli+kYnJqrgBf9cIA= 31 | github.com/getlantern/systray v1.2.1 h1:udsC2k98v2hN359VTFShuQW6GGprRprw6kD6539JikI= 32 | github.com/getlantern/systray v1.2.1/go.mod h1:AecygODWIsBquJCJFop8MEQcJbWFfw/1yWbVabNgpCM= 33 | github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= 34 | github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0= 35 | github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= 36 | github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= 37 | github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= 38 | github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= 39 | github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= 40 | github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= 41 | github.com/go-stack/stack v1.8.1 h1:ntEHSVwIt7PNXNpgPmVfMrNhLtgjlmnZha2kOpuRiDw= 42 | github.com/go-stack/stack v1.8.1/go.mod h1:dcoOX6HbPZSZptuspn9bctJ+N/CnF5gGygcUP3XYfe4= 43 | github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= 44 | github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= 45 | github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= 46 | github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= 47 | github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= 48 | github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c h1:rp5dCmg/yLR3mgFuSOe4oEnDDmGLROTvMragMUXpTQw= 49 | github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c/go.mod h1:X07ZCGwUbLaax7L0S3Tw4hpejzu63ZrrQiUe6W0hcy0= 50 | github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= 51 | github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 52 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 53 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 54 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 55 | github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= 56 | github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= 57 | github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= 58 | github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= 59 | github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= 60 | github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= 61 | github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= 62 | github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= 63 | github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= 64 | github.com/zach-klippenstein/goadb v0.0.0-20201208042340-620e0e950ed7 h1:xwmuUst0P21SJmJlIOPPq/geECy23t+DUxgnRSqt6Hg= 65 | github.com/zach-klippenstein/goadb v0.0.0-20201208042340-620e0e950ed7/go.mod h1:Drd+klC4FSDx0vKNEQDsSpWX5so04NA7l0vzHqkH8AQ= 66 | go.opentelemetry.io/otel v1.9.0 h1:8WZNQFIB2a71LnANS9JeyidJKKGOOremcUtb/OtHISw= 67 | go.opentelemetry.io/otel v1.9.0/go.mod h1:np4EoPGzoPs3O67xUVNoPPcmSvsfOxNlNA4F4AC+0Eo= 68 | go.opentelemetry.io/otel/trace v1.9.0 h1:oZaCNJUjWcg60VXWee8lJKlqhPbXAPB51URuR47pQYc= 69 | go.opentelemetry.io/otel/trace v1.9.0/go.mod h1:2737Q0MuG8q1uILYm2YYVkAyLtOofiTNGg6VODnOiPo= 70 | go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= 71 | go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= 72 | go.uber.org/goleak v1.1.11-0.20210813005559-691160354723 h1:sHOAIxRGBp443oHZIPB+HsUGaksVCXVQENPxwTfQdH4= 73 | go.uber.org/goleak v1.1.11-0.20210813005559-691160354723/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= 74 | go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4= 75 | go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= 76 | go.uber.org/zap v1.19.1 h1:ue41HOKd1vGURxrmeKIgELGb3jPW9DMUDGtsinblHwI= 77 | go.uber.org/zap v1.19.1/go.mod h1:j3DNczoxDZroyBnOT1L/Q79cfUMGZxlv/9dzN7SM1rI= 78 | golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= 79 | golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= 80 | golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= 81 | golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= 82 | golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 83 | golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 84 | golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 85 | golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= 86 | golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= 87 | golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= 88 | golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 89 | golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 90 | golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 91 | golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 92 | golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 93 | golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 94 | golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 95 | golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 96 | golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 97 | golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= 98 | golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 99 | golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= 100 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 101 | golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= 102 | golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 103 | golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= 104 | golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 105 | golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= 106 | golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 107 | golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 108 | golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 109 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 110 | gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 111 | gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= 112 | gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 113 | gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 114 | gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 115 | gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= 116 | gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 117 | -------------------------------------------------------------------------------- /server/internal/adb/adb.go: -------------------------------------------------------------------------------- 1 | package adb 2 | 3 | import ( 4 | "flag" 5 | 6 | "github.com/Teages/vTablet/internal/logger" 7 | . "github.com/Teages/vTablet/internal/tools" 8 | adb "github.com/zach-klippenstein/goadb" 9 | ) 10 | 11 | var ( 12 | adbClient *adb.Adb 13 | ) 14 | 15 | func Watch(f func(adb.DeviceStateChangedEvent)) { 16 | if adbClient == nil { 17 | logger.Warn("Can't watch: adb server not found") 18 | return 19 | } 20 | go func() { 21 | for { 22 | w := adbClient.NewDeviceWatcher() 23 | for event := range w.C() { 24 | // logger.Log("\t[%s]%+v\n", time.Now(), event) 25 | f(event) 26 | } 27 | } 28 | }() 29 | } 30 | 31 | func AutoConnect(c func(string)) { 32 | Watch(func(event adb.DeviceStateChangedEvent) { 33 | if event.NewState == adb.StateOnline { 34 | logger.Log(event.Serial) 35 | c(event.Serial) 36 | } 37 | }) 38 | } 39 | 40 | func Exec(args ...string) { 41 | RunCommand(adbPath, args...) 42 | } 43 | 44 | func init() { 45 | Exec("start-server") 46 | a, err := adb.NewWithConfig(adb.ServerConfig{ 47 | PathToAdb: adbPath, 48 | Port: *flag.Int("p", adb.AdbPort, ""), 49 | }) 50 | if logger.Catch(err) { 51 | logger.Error("Can't start ADB server") 52 | adbClient = nil 53 | return 54 | } 55 | adbClient = a 56 | AutoConnect(func(serial string) { 57 | Exec("-s", serial, "reverse tcp:23052 tcp:23052") 58 | Exec("-s", serial, "shell am start -a android.intent.action.VIEW -d http://vtablet.teages.xyz?server=localhost:23052") 59 | }) 60 | } 61 | 62 | func Restart() { 63 | if adbClient == nil { 64 | logger.Warn("Can't restart ADB: adb server not found") 65 | return 66 | } 67 | adbClient.KillServer() 68 | Exec("start-server") 69 | } 70 | -------------------------------------------------------------------------------- /server/internal/adb/adb_windows.go: -------------------------------------------------------------------------------- 1 | package adb 2 | 3 | import ( 4 | "embed" 5 | 6 | "github.com/Teages/go-vfile" 7 | ) 8 | 9 | var ( 10 | //go:embed windows/* 11 | adbFiles embed.FS 12 | adbPath = func() string { 13 | vfile.JoinPart("libs/adb", "windows", adbFiles) 14 | return vfile.GetPath("libs/adb/adb.exe") 15 | }() 16 | ) 17 | -------------------------------------------------------------------------------- /server/internal/adb/windows/AdbWinApi.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Teages/vTablet/a46e1fcf721593f0824f74c6285591b53e5b09f1/server/internal/adb/windows/AdbWinApi.dll -------------------------------------------------------------------------------- /server/internal/adb/windows/AdbWinUsbApi.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Teages/vTablet/a46e1fcf721593f0824f74c6285591b53e5b09f1/server/internal/adb/windows/AdbWinUsbApi.dll -------------------------------------------------------------------------------- /server/internal/adb/windows/NOTICE.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Teages/vTablet/a46e1fcf721593f0824f74c6285591b53e5b09f1/server/internal/adb/windows/NOTICE.txt -------------------------------------------------------------------------------- /server/internal/adb/windows/adb.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Teages/vTablet/a46e1fcf721593f0824f74c6285591b53e5b09f1/server/internal/adb/windows/adb.exe -------------------------------------------------------------------------------- /server/internal/adb/windows/libwinpthread-1.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Teages/vTablet/a46e1fcf721593f0824f74c6285591b53e5b09f1/server/internal/adb/windows/libwinpthread-1.dll -------------------------------------------------------------------------------- /server/internal/adb/windows/source.properties: -------------------------------------------------------------------------------- 1 | Pkg.UserSrc=false 2 | Pkg.Revision=33.0.2 -------------------------------------------------------------------------------- /server/internal/logger/logger.go: -------------------------------------------------------------------------------- 1 | package logger 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | ) 7 | 8 | var ( 9 | logPath = "log/" + time.Now().Format("2006-01-02 15:04:05") 10 | ) 11 | 12 | func Msg(format string, a ...any) { 13 | fmt.Printf(format+"\n", a...) 14 | // TODO: log to file 15 | } 16 | 17 | func Log(format string, a ...any) { 18 | Msg("[LOG] "+format, a...) 19 | } 20 | 21 | func Warn(format string, a ...any) { 22 | Msg("[WARN] "+format, a...) 23 | } 24 | 25 | func Error(format string, a ...any) { 26 | Msg("[ERR] "+format, a...) 27 | } 28 | 29 | func Catch(err error) bool { 30 | if err != nil { 31 | Error(err.Error()) 32 | return true 33 | } 34 | return false 35 | } 36 | -------------------------------------------------------------------------------- /server/internal/pointer/pointer.go: -------------------------------------------------------------------------------- 1 | package pointer 2 | 3 | import ( 4 | "github.com/Teages/go-vdigi" 5 | ) 6 | 7 | type AbsPointer struct { 8 | screenId int 9 | device *vdigi.Pointer 10 | 11 | X int32 12 | Y int32 13 | Pressure uint32 14 | TiltX int32 15 | TiltY int32 16 | } 17 | 18 | func (p AbsPointer) getScreenSize() (int32, int32) { 19 | screen, _ := vdigi.GetScreens().GetScreen(p.screenId) 20 | 21 | width := screen.Width 22 | height := screen.Height 23 | 24 | return int32(width), int32(height) 25 | } 26 | 27 | func Create(screenUid string) AbsPointer { 28 | screenId, _ := vdigi.GetScreens().GetScreenIdByUid(screenUid) 29 | device, _ := vdigi.CreatePointerForScreen(screenId) 30 | return AbsPointer{screenId: screenId, device: device} 31 | } 32 | 33 | func (p AbsPointer) Update() error { 34 | width, height := p.getScreenSize() 35 | x := p.X * width / 32767 36 | y := p.Y * height / 32767 37 | tiltX := p.TiltX / 32767 / 90 38 | tiltY := p.TiltY / 32767 / 90 39 | pressure := p.Pressure 40 | return p.device.UpdateWithTilt(x, y, pressure, tiltX, tiltY) 41 | } 42 | 43 | func (p AbsPointer) Destroy() { 44 | p.device.Destroy() 45 | } 46 | -------------------------------------------------------------------------------- /server/internal/protocol/const.go: -------------------------------------------------------------------------------- 1 | package protocol 2 | 3 | type EventType uint16 4 | 5 | const ( 6 | EvSyn EventType = 0x0000 7 | // EvKey EventType = 0x0001 8 | // EvRel EventType = 0x0002 9 | EvAbs EventType = 0x0003 10 | ) 11 | 12 | type Syn uint16 13 | 14 | const ( 15 | SynReport Syn = 0x0000 16 | // SynConfig Syn = 0x0001 17 | // SynMtReport Syn = 0x0002 18 | // SynDropped Syn = 0x0003 19 | 20 | SynPing Syn = 0xffff 21 | ) 22 | 23 | // type Rel uint16 24 | 25 | // const ( 26 | // RelX Rel = 0x00 27 | // RelY Rel = 0x01 28 | // RelDIAL Rel = 0x07 29 | // RelWHEEL Rel = 0x08 30 | // RelMISC Rel = 0x09 31 | // RelRESERVED Rel = 0x0a 32 | // RelWHEELHIRES Rel = 0x0b 33 | // RelHWHEELHIRES Rel = 0x0c 34 | // ) 35 | 36 | type Abs uint16 37 | 38 | const ( 39 | AbsX Abs = 0x00 40 | AbsY Abs = 0x01 41 | AbsPressure Abs = 0x18 42 | AbsTiltX Abs = 0x1a 43 | AbsTiltY Abs = 0x1b 44 | ) 45 | -------------------------------------------------------------------------------- /server/internal/tools/cmd.go: -------------------------------------------------------------------------------- 1 | package tools 2 | 3 | import ( 4 | "os" 5 | "os/exec" 6 | "strings" 7 | "syscall" 8 | 9 | "github.com/Teages/vTablet/internal/logger" 10 | ) 11 | 12 | func GetSelfPath() string { 13 | exePath, err := os.Executable() 14 | logger.Catch(err) 15 | return exePath 16 | } 17 | 18 | func RunCommand(path string, args ...string) { 19 | exePath := strings.TrimSpace(path) 20 | arg := `/c ` + exePath + " " + strings.Join(args, " ") 21 | e := exec.Command("cmd", arg) 22 | e.SysProcAttr = &syscall.SysProcAttr{HideWindow: true} 23 | logger.Log("Running: %s %s", "cmd", arg) 24 | e.Stdout = os.Stdout 25 | e.Stderr = os.Stderr 26 | err := e.Run() 27 | logger.Catch(err) 28 | } 29 | -------------------------------------------------------------------------------- /server/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/Teages/go-vfile" 5 | _ "github.com/Teages/vTablet/internal/adb" 6 | ) 7 | 8 | func main() { 9 | go initWebServices(23052) 10 | initTray(func() { 11 | // onExit 12 | vfile.Close() 13 | }) 14 | } 15 | -------------------------------------------------------------------------------- /server/rsrc.syso: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Teages/vTablet/a46e1fcf721593f0824f74c6285591b53e5b09f1/server/rsrc.syso -------------------------------------------------------------------------------- /server/services.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "bytes" 5 | "encoding/binary" 6 | "strconv" 7 | 8 | "github.com/Teages/vTablet/internal/logger" 9 | "github.com/Teages/vTablet/internal/pointer" 10 | "github.com/Teages/vTablet/internal/protocol" 11 | "golang.org/x/net/websocket" 12 | ) 13 | 14 | var ( 15 | clientCount = 0 16 | ) 17 | 18 | func pointerServices(screeUid string, c *websocket.Conn) { 19 | pd := pointer.Create(screeUid) 20 | 21 | clientCount++ 22 | updateConnectState(clientCount) 23 | defer func() { 24 | clientCount-- 25 | updateConnectState(clientCount) 26 | c.Close() 27 | pd.Destroy() 28 | }() 29 | 30 | receivedMsg := make([]byte, 512) 31 | receivedSize := 0 32 | var err error 33 | 34 | responser := func(msg string) error { 35 | _, err = c.Write([]byte(msg)) 36 | if logger.Catch(err) { 37 | return err 38 | } 39 | return nil 40 | } 41 | 42 | for { 43 | receivedSize, err = c.Read(receivedMsg) 44 | if logger.Catch(err) { 45 | break 46 | } 47 | 48 | func(msg []byte) { 49 | handler := func(motionType uint16, motionCode uint16, motionValue int32) { 50 | motion := protocol.EventType(motionType) 51 | 52 | // syn 53 | if motion == protocol.EvSyn { 54 | code := protocol.Syn(motionCode) 55 | switch code { 56 | case protocol.SynReport: 57 | pd.Update() 58 | case protocol.SynPing: 59 | responser(strconv.Itoa(int(motionValue))) 60 | } 61 | } 62 | 63 | // abs 64 | if motion == protocol.EvAbs { 65 | code := protocol.Abs(motionCode) 66 | switch code { 67 | case protocol.AbsX: 68 | logger.Log("x %d", motionValue) 69 | pd.X = int32(motionValue) 70 | case protocol.AbsY: 71 | logger.Log("y %d", motionValue) 72 | pd.Y = int32(motionValue) 73 | case protocol.AbsPressure: 74 | logger.Log("pressure %d", motionValue) 75 | pd.Pressure = uint32(motionValue) 76 | case protocol.AbsTiltX: 77 | logger.Log("TiltX %d", motionValue) 78 | pd.TiltX = int32(motionValue) 79 | case protocol.AbsTiltY: 80 | logger.Log("TiltY %d", motionValue) 81 | pd.TiltY = int32(motionValue) 82 | default: 83 | logger.Error("Unknown abs code: %d", code) 84 | } 85 | } 86 | } 87 | 88 | // Pointer Event: type(4) motion(4) value(8), could be multiple 89 | for i := 0; i < len(msg); i += 8 { 90 | if i+8 > len(msg) { 91 | break 92 | } 93 | motionType := binary.BigEndian.Uint16(msg[i : i+2]) 94 | motionCode := binary.BigEndian.Uint16(msg[i+2 : i+4]) 95 | var motionValue int32 96 | binary.Read(bytes.NewReader(msg[i+4:i+8]), binary.BigEndian, &motionValue) 97 | handler(motionType, motionCode, motionValue) 98 | } 99 | }(receivedMsg[:receivedSize]) 100 | 101 | if logger.Catch(err) { 102 | break 103 | } 104 | } 105 | } 106 | 107 | // utils 108 | -------------------------------------------------------------------------------- /server/tray.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | "os/exec" 7 | "runtime" 8 | 9 | "github.com/Teages/go-autostart" 10 | "github.com/Teages/vTablet/internal/adb" 11 | "github.com/Teages/vTablet/internal/logger" 12 | . "github.com/Teages/vTablet/internal/tools" 13 | "github.com/getlantern/systray" 14 | ) 15 | 16 | var ( 17 | appName = "vTablet" 18 | appVersion = "v3.0.0 (Preview 4)" 19 | ) 20 | 21 | func initTray(onExit func()) { 22 | systray.Run(func() { 23 | systray.SetIcon(AppIconData_Disconnected) 24 | systray.SetTitle("vTablet") 25 | systray.SetTooltip("vTablet") 26 | 27 | mAbout := systray.AddMenuItem(fmt.Sprint(appName, " ", appVersion), "About") 28 | 29 | go func() { 30 | for { 31 | <-mAbout.ClickedCh 32 | openBrowser("https://github.com/Teages/vTablet") 33 | } 34 | }() 35 | 36 | systray.AddSeparator() 37 | 38 | // Start with OS 39 | aStartWithOS := &autostart.App{ 40 | Name: "vTablet", 41 | DisplayName: "Auto start vTablet services", 42 | Exec: []string{GetSelfPath()}, 43 | } 44 | mStartWithOS := systray.AddMenuItemCheckbox("Start with OS", "Start with OS", aStartWithOS.IsEnabled()) 45 | go func() { 46 | for { 47 | <-mStartWithOS.ClickedCh 48 | if aStartWithOS.IsEnabled() { 49 | logger.Catch(aStartWithOS.Disable()) 50 | mStartWithOS.Uncheck() 51 | } else { 52 | logger.Catch(aStartWithOS.Enable()) 53 | mStartWithOS.Check() 54 | } 55 | } 56 | }() 57 | 58 | systray.AddSeparator() 59 | 60 | mAdb := systray.AddMenuItem("Restart ADB", "Restart ADB services") 61 | go func() { 62 | for { 63 | <-mAdb.ClickedCh 64 | adb.Restart() 65 | } 66 | }() 67 | 68 | mQuit := systray.AddMenuItem("Quit", "Quit the app") 69 | go func() { 70 | <-mQuit.ClickedCh 71 | systray.Quit() 72 | }() 73 | }, onExit) 74 | } 75 | 76 | func updateConnectState(clientCount int) { 77 | if clientCount > 0 { 78 | onConnected() 79 | } else { 80 | onNoConnected() 81 | } 82 | } 83 | 84 | func onConnected() { 85 | systray.SetIcon(AppIconData_Connected) 86 | } 87 | 88 | func onNoConnected() { 89 | systray.SetIcon(AppIconData_Disconnected) 90 | } 91 | func openBrowser(url string) { 92 | var err error 93 | 94 | switch runtime.GOOS { 95 | case "linux": 96 | err = exec.Command("xdg-open", url).Start() 97 | case "windows": 98 | err = exec.Command("rundll32", "url.dll,FileProtocolHandler", url).Start() 99 | case "darwin": 100 | err = exec.Command("open", url).Start() 101 | default: 102 | err = fmt.Errorf("unsupported platform") 103 | } 104 | if err != nil { 105 | log.Fatal(err) 106 | } 107 | 108 | } 109 | --------------------------------------------------------------------------------