├── .github └── FUNDING.yml ├── .gitignore ├── .idea ├── codeStyles │ ├── Project.xml │ └── codeStyleConfig.xml ├── compiler.xml ├── encodings.xml ├── gradle.xml ├── jarRepositories.xml ├── markdown-navigator-enh.xml ├── markdown-navigator.xml ├── misc.xml ├── runConfigurations.xml └── vcs.xml ├── LICENSE ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── github │ │ └── roarappstudio │ │ └── btkontroller │ │ ├── BluetoothController.kt │ │ ├── ConfigActivity.kt │ │ ├── DescriptorCollection.kt │ │ ├── DescriptorCollectionNotUsed.kt │ │ ├── Kontroller.kt │ │ ├── SelectDeviceActivity.kt │ │ ├── SplashScreen.kt │ │ ├── Unhide.kt │ │ ├── Value.kt │ │ ├── WheelPicker.java │ │ ├── extraLibraries │ │ └── CustomGestureDetector.kt │ │ ├── listeners │ │ ├── CompositeListener.kt │ │ ├── GestureDetectListener.kt │ │ └── ViewListener.kt │ │ ├── reports │ │ ├── AbsMouseReport.kt │ │ ├── FeatureReport.kt │ │ ├── KeyboardReport.kt │ │ ├── MouseReport.kt │ │ ├── RadialControllerInput.kt │ │ ├── RadialControllerOutput.kt │ │ ├── ScrollableTrackpadMouseReport.kt │ │ ├── TestTrackpadMouseReport.kt │ │ └── TrackpadMouseReport.kt │ │ └── senders │ │ ├── KeyboardSender.kt │ │ ├── RadialSender.kt │ │ ├── RadialSender2.kt │ │ ├── RadialSender3.kt │ │ ├── RelativeMouseSender.kt │ │ ├── Sender.kt │ │ └── SensorSender.kt │ └── res │ ├── drawable-anydpi │ ├── ic_action_app_connected.xml │ ├── ic_action_app_not_connected.xml │ └── ic_action_keyboard.xml │ ├── drawable-hdpi │ ├── ic_action_app_connected.png │ ├── ic_action_app_not_connected.png │ └── ic_action_keyboard.png │ ├── drawable-mdpi │ ├── ic_action_app_connected.png │ ├── ic_action_app_not_connected.png │ ├── ic_action_keyboard.png │ └── ripple_item_no.xml │ ├── drawable-v24 │ └── ic_launcher_foreground.xml │ ├── drawable-xhdpi │ ├── ic_action_app_connected.png │ ├── ic_action_app_not_connected.png │ └── ic_action_keyboard.png │ ├── drawable-xxhdpi │ ├── ic_action_app_connected.png │ ├── ic_action_app_not_connected.png │ └── ic_action_keyboard.png │ ├── drawable │ ├── btn_black.xml │ ├── code_logo_0.png │ ├── code_logo_1.png │ ├── code_logo_2.png │ ├── ic_icon_ansi.xml │ ├── ic_icon_hid.xml │ ├── ic_icon_unicode.xml │ ├── ic_launcher_background.xml │ ├── ic_launcher_background_ble.xml │ ├── ic_launcher_foreground_ble.xml │ ├── surface_dial.png │ └── view_border.xml │ ├── layout-land │ └── layout.xml │ ├── layout │ ├── activity_config.xml │ ├── keyboard_num.xml │ ├── keyboard_num2.xml │ └── layout.xml │ ├── menu │ └── select_device_activity_menu.xml │ ├── mipmap-anydpi-v26 │ ├── ic_launcher.xml │ ├── ic_launcher_ble.xml │ └── ic_launcher_ble_round.xml │ ├── values-zh │ └── strings.xml │ └── values │ ├── attrs.xml │ ├── colors.xml │ ├── dimens.xml │ ├── ids.xml │ ├── strings.xml │ └── styles.xml ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: ['https://www.paypal.me/raghavpay/USD'] 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | /.idea/codeStyles 11 | .DS_Store 12 | /build 13 | /captures 14 | .externalNativeBuild 15 | /app/release/ 16 | -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | xmlns:android 14 | 15 | ^$ 16 | 17 | 18 | 19 |
20 |
21 | 22 | 23 | 24 | xmlns:.* 25 | 26 | ^$ 27 | 28 | 29 | BY_NAME 30 | 31 |
32 |
33 | 34 | 35 | 36 | .*:id 37 | 38 | http://schemas.android.com/apk/res/android 39 | 40 | 41 | 42 |
43 |
44 | 45 | 46 | 47 | .*:name 48 | 49 | http://schemas.android.com/apk/res/android 50 | 51 | 52 | 53 |
54 |
55 | 56 | 57 | 58 | name 59 | 60 | ^$ 61 | 62 | 63 | 64 |
65 |
66 | 67 | 68 | 69 | style 70 | 71 | ^$ 72 | 73 | 74 | 75 |
76 |
77 | 78 | 79 | 80 | .* 81 | 82 | ^$ 83 | 84 | 85 | BY_NAME 86 | 87 |
88 |
89 | 90 | 91 | 92 | .* 93 | 94 | http://schemas.android.com/apk/res/android 95 | 96 | 97 | ANDROID_ATTRIBUTE_ORDER 98 | 99 |
100 |
101 | 102 | 103 | 104 | .* 105 | 106 | .* 107 | 108 | 109 | BY_NAME 110 | 111 |
112 |
113 |
114 |
115 | 116 | 118 |
119 |
-------------------------------------------------------------------------------- /.idea/codeStyles/codeStyleConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 19 | 20 | -------------------------------------------------------------------------------- /.idea/jarRepositories.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 14 | 15 | 19 | 20 | 24 | 25 | 29 | 30 | 34 | 35 | -------------------------------------------------------------------------------- /.idea/markdown-navigator-enh.xml: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /.idea/markdown-navigator.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 29 | 30 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 14 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AB Dial (Android Bluetooth Radial Controler) 2 | 3 | This is an application to control your pc as a radial controler (like Surface Dial) or keyboard using the Bluetooth HID Device profile in Android 9(Pie) & above devices. App is currently in development. 4 | 5 | It is forked from Kontroller(https://github.com/raghavk92/Kontroller) , an application to control your pc,mac,tv,ipad etc as a mouse or keyboard using the Bluetooth HID Device profile in Android 9(Pie) & above devices. App is currently in development. 6 | 7 | Get it from Coolapk: 8 | Get it from Coolapk 9 | 10 | Procedure to use the app: 11 | 1) Remove previous pairings with the host device in bluetooth settings(This has to be done once) 12 | 2) Open the app 13 | 3) Send a pairing request from the host device to the controlling device 14 | 4) Accept the pairing on the device running Kontroller 15 | 16 | Many device manufacturers have disabled the Bluetooth HID device profile on their devices. You would have to ask your device manufacturers to enable it. You can check with this app {[Bluetooth HID Device Profile Compatibility Checker](https://play.google.com/store/apps/details?id=com.rkaneapplabs.bluetooth_hid.bluetoothproxy)} if the Bluetooth HID device profile is disabled for you or not. 17 | 18 | For OnePlus users- you can upvote this [Idea](https://forums.oneplus.com/threads/converting-one-plus-devices-into-a-bluetooth-controller-mouse-keyboard-etc.1192272/) in the community forums after login(This may help in bringing the issue into notice to One Plus) 19 | 20 | 21 | # 中文说明 22 | 这是一个把Android手机虚拟为蓝牙外设的工具。眼馋surface dial好久了,现在终于手搓出一个虚拟设备! 23 | 这是从 Kontroller(https://github.com/raghavk92/Kontroller) fork而来,增加了radial controler的功能并修改了包名。 24 | 25 | ### 使用前提: 26 | 1) 手机系统Android9以上。(硬性要求) 27 | 2) 电脑需要运行Windows 10 周年更新或更高版本并且具有蓝牙 4.0 LE。(这是微软官网要求,别问我周年更新是啥,我也不懂。)蓝牙4.0实际上是非必须的,我的笔记本的蓝牙网卡坏掉了,插了一个2.1的适配器,也能正常工作 28 | 29 | ### 使用方法: 30 | 1) 从电脑上删除手机和电脑的蓝牙配对 31 | 2) 在手机上打开APP 32 | 3) 在选项中为auto pair打勾 33 | 4) 用电脑搜索手机并配对。在APP的顶部弹出配对请求时,点击同意(很重要,如果顶部没有弹出请求而是底部直接弹出,操作就失败了) 34 | 35 | 通过点击图标中央,或者在环状区域滑动,可以实现surface dial的操作及功能。 36 | 点击键盘图标,可以用此APP模拟蓝牙键盘(只能用键盘输入英文和数字符号,不可拼音打字) 37 | 38 | ### 异常处理: 39 | 1) 确认操作要点。先删除之前的配对/打开APP后再开始配对/配对过程APP不可以切换到后台/配对请求是从通知栏顶部弹出的,而不是直接从屏幕底部弹出 40 | 2) 如果始终不能连上: 41 | 你的手机的系统可能被厂商删除了一部分协议支持。可以通过安装Bluetooth HID Device Profile Compatibility Checker进行检查: 42 | 谷歌市场 https://play.google.com/store/apps/details?id=com.rkaneapplabs.bluetooth_hid.bluetoothproxy 43 | 百度网盘 https://pan.baidu.com/s/12aiHsOAUT696E7v2P60Iyw 提取码:66k5 44 | 如果是系统不支持,那就不要挣扎了。(据说1+是不行的) 45 | 3) APP一开始可以用,自动断开不能自动连上: 46 | 先检查APP设置的Enable autopair是否打勾。 47 | APP保持在前台,关闭手机蓝牙再重新打开,就能连上了。(开关电脑的蓝牙是无效的) 48 | 49 | 视频说明:http://www.bilibili.com/video/BV1tV411k73h 50 | 项目地址:https://github.com/tumuyan/Kontroller 51 | 下载地址:https://www.coolapk.com/apk/266123 -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'kotlin-android' 3 | apply plugin: 'kotlin-android-extensions' 4 | 5 | android { 6 | 7 | signingConfigs { 8 | release { 9 | storeFile file(RELEASE_STORE_FILE) 10 | keyAlias RELEASE_KEY_ALIAS 11 | storePassword RELEASE_KEY_PASSWORD 12 | keyPassword RELEASE_STORE_PASSWORD 13 | } 14 | } 15 | 16 | compileSdkVersion 30 17 | defaultConfig { 18 | applicationId "com.tumuyan.abdial" 19 | minSdkVersion 28 20 | targetSdkVersion 30 21 | versionCode 9 22 | versionName "0.0.9" 23 | signingConfig signingConfigs.release 24 | } 25 | 26 | compileOptions { 27 | targetCompatibility 1.8 28 | sourceCompatibility 1.8 29 | } 30 | buildTypes { 31 | release { 32 | minifyEnabled true 33 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 34 | } 35 | } 36 | buildToolsVersion = '30.0.2' 37 | 38 | 39 | bundle { 40 | language { 41 | enableSplit = true 42 | } 43 | density { 44 | enableSplit = true 45 | } 46 | abi { 47 | enableSplit = true 48 | } 49 | } 50 | } 51 | 52 | dependencies { 53 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" 54 | implementation "org.jetbrains.anko:anko-commons:$anko_version" 55 | implementation "org.jetbrains.anko:anko-sdk25:$anko_version" 56 | implementation 'com.chibatching.kotpref:kotpref:2.6.0' 57 | } 58 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | 23 | -assumenosideeffects class android.util.Log { 24 | public static boolean isLoggable(java.lang.String, int); 25 | public static int v(...); 26 | public static int d(...); 27 | public static int i(...); 28 | } 29 | 30 | -dontwarn ** 31 | -target 1.7 32 | -dontusemixedcaseclassnames 33 | -dontskipnonpubliclibraryclasses 34 | -dontpreverify 35 | -verbose 36 | -optimizations !code/simplification/arithmetic,!code/allocation/variable 37 | -keep class ** 38 | -keepclassmembers class *{*;} 39 | -keepattributes * 40 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 15 | 18 | 21 | 22 | 30 | 31 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /app/src/main/java/com/github/roarappstudio/btkontroller/BluetoothController.kt: -------------------------------------------------------------------------------- 1 | package com.github.roarappstudio.btkontroller 2 | 3 | import android.bluetooth.* 4 | import android.content.Context 5 | import android.util.Log 6 | import com.github.roarappstudio.btkontroller.reports.FeatureReport 7 | import android.content.Intent 8 | 9 | 10 | @Suppress("MemberVisibilityCanBePrivate") 11 | object BluetoothController: BluetoothHidDevice.Callback(), BluetoothProfile.ServiceListener { 12 | 13 | val featureReport = FeatureReport() 14 | 15 | 16 | 17 | override fun onSetReport(device: BluetoothDevice?, type: Byte, id: Byte, data: ByteArray?) { 18 | Log.i("setfirst","setfirst") 19 | super.onSetReport(device, type, id, data) 20 | Log.i("setreport","this $device and $type and $id and $data") 21 | 22 | } 23 | 24 | 25 | override fun onGetReport(device: BluetoothDevice?, type: Byte, id: Byte, bufferSize: Int) { 26 | 27 | Log.i("getbefore", "first") 28 | super.onGetReport(device, type, id, bufferSize) 29 | 30 | Log.i("get", "second") 31 | if (type == BluetoothHidDevice.REPORT_TYPE_FEATURE) { 32 | featureReport.wheelResolutionMultiplier = true 33 | featureReport.acPanResolutionMultiplier = true 34 | Log.i("getbthid","$btHid") 35 | 36 | var wasrs=btHid?.replyReport(device, type, FeatureReport.ID, featureReport.bytes) 37 | Log.i("replysuccess flag ",wasrs.toString()) 38 | } 39 | 40 | 41 | } 42 | 43 | 44 | val btAdapter by lazy { BluetoothAdapter.getDefaultAdapter()!! } 45 | var btHid: BluetoothHidDevice? = null 46 | var context: Context? = null 47 | var hostDevice: BluetoothDevice? = null 48 | var autoPairFlag = false 49 | 50 | var mpluggedDevice :BluetoothDevice? = null 51 | 52 | 53 | 54 | private var deviceListener: ((BluetoothHidDevice, BluetoothDevice)->Unit)? = null 55 | private var disconnectListener: (()->Unit)? = null 56 | 57 | fun init(ctx: Context) { 58 | context = ctx 59 | if (btHid != null) 60 | return 61 | btAdapter.getProfileProxy(ctx, this, BluetoothProfile.HID_DEVICE) 62 | } 63 | 64 | fun getSender(callback: (BluetoothHidDevice, BluetoothDevice)->Unit) { 65 | btHid?.let { hidd -> 66 | hostDevice?.let { host -> 67 | callback(hidd, host) 68 | return 69 | } 70 | } 71 | deviceListener = callback 72 | } 73 | 74 | 75 | fun getDisconnector(callback: ()->Unit) { 76 | Log.e(TAG, "getDisconnector") 77 | disconnectListener = callback 78 | } 79 | 80 | /*****************************************************/ 81 | /** BluetoothProfile.ServiceListener implementation **/ 82 | /*****************************************************/ 83 | 84 | override fun onServiceDisconnected(profile: Int) { 85 | Log.e(TAG, "Service disconnected!") 86 | disconnectListener?.invoke() 87 | if (profile == BluetoothProfile.HID_DEVICE) 88 | btHid = null 89 | } 90 | 91 | override fun onServiceConnected(profile: Int, proxy: BluetoothProfile) { 92 | Log.i(TAG, "Connected to service") 93 | if (profile != BluetoothProfile.HID_DEVICE) { 94 | Log.wtf(TAG, "WTF? $profile") 95 | return 96 | } 97 | 98 | val btHid = proxy as? BluetoothHidDevice 99 | if (btHid == null) { 100 | Log.wtf(TAG, "WTF? Proxy received but it's not BluetoothHidDevice") 101 | 102 | return 103 | } 104 | this.btHid = btHid 105 | btHid.registerApp(sdpRecord, null, qosOut, {it.run()}, this)//-- 106 | // btAdapter.setScanMode(BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE, 300000) 107 | if (mpluggedDevice == null && !btAdapter.isDiscovering) { 108 | context?.startActivity(Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE)) 109 | } 110 | 111 | } 112 | 113 | 114 | 115 | /************************************************/ 116 | /** BluetoothHidDevice.Callback implementation **/ 117 | /************************************************/ 118 | 119 | override open fun onInterruptData( 120 | device: BluetoothDevice, 121 | reportId: Byte, 122 | data: ByteArray? 123 | ): Unit { 124 | Log.d( 125 | TAG, 126 | "onInterruptData: device=$device reportId=$reportId" 127 | ) 128 | super.onInterruptData(device, reportId, data) 129 | } 130 | 131 | /** 132 | * Callback called when Virtual Cable is removed. After this callback is received connection 133 | * will be disconnected automatically. 134 | */ 135 | override fun onVirtualCableUnplug(device: BluetoothDevice) { 136 | Log.d( 137 | TAG, 138 | "onVirtualCableUnplug: device=$device" 139 | ) 140 | super.onVirtualCableUnplug(device) 141 | } 142 | 143 | 144 | 145 | override fun onConnectionStateChanged(device: BluetoothDevice?, state: Int) { 146 | super.onConnectionStateChanged(device, state) 147 | Log.i(TAG, "Connection state ${when(state) { 148 | BluetoothProfile.STATE_CONNECTING -> "CONNECTING" 149 | BluetoothProfile.STATE_CONNECTED -> "CONNECTED" 150 | BluetoothProfile.STATE_DISCONNECTING -> "DISCONNECTING" 151 | BluetoothProfile.STATE_DISCONNECTED -> "DISCONNECTED" 152 | 153 | else -> state.toString() 154 | }}") 155 | if (state == BluetoothProfile.STATE_CONNECTED) { 156 | if (device != null) { 157 | hostDevice = device 158 | 159 | deviceListener?.invoke(btHid!!, device) 160 | 161 | //deviceListener = null 162 | } else { 163 | Log.e(TAG, "Device not connected") 164 | } 165 | } else { 166 | hostDevice = null 167 | if(state == BluetoothProfile.STATE_DISCONNECTED) 168 | { 169 | Log.e(TAG, "onConnectionStateChanged disconnect)") 170 | disconnectListener?.invoke() 171 | } 172 | 173 | } 174 | } 175 | 176 | override fun onAppStatusChanged(pluggedDevice: BluetoothDevice?, registered: Boolean) { 177 | super.onAppStatusChanged(pluggedDevice, registered) 178 | if(registered) 179 | { 180 | var pairedDevices = btHid?.getDevicesMatchingConnectionStates(intArrayOf(BluetoothProfile.STATE_CONNECTING,BluetoothProfile.STATE_CONNECTED,BluetoothProfile.STATE_DISCONNECTED,BluetoothProfile.STATE_DISCONNECTING)) 181 | Log.d("paired d", "paired devices are : $pairedDevices") 182 | // Log.d("paired d","${btHid?.getConnectionState(pairedDevices?.get(0))}") 183 | mpluggedDevice = pluggedDevice 184 | 185 | if (autoPairFlag) { 186 | if (pluggedDevice != null && btHid?.getConnectionState(pluggedDevice) == BluetoothProfile.STATE_DISCONNECTED) { 187 | btHid?.connect(pluggedDevice) 188 | //hostDevice.toString() 189 | } else { 190 | pairedDevices?.firstOrNull()?.let { 191 | val pairedDState = btHid?.getConnectionState(it) 192 | Log.d("paired d", pairedDState.toString()) 193 | if (pairedDState == BluetoothProfile.STATE_DISCONNECTED) { 194 | btHid?.connect(it) 195 | } 196 | } 197 | } 198 | 199 | } 200 | 201 | } 202 | } 203 | 204 | 205 | 206 | 207 | 208 | /*************/ 209 | /** Garbage **/ 210 | /*************/ 211 | 212 | const val TAG = "BluetoothController" 213 | 214 | private val sdpRecord by lazy { 215 | BluetoothHidDeviceAppSdpSettings( 216 | "Pixel HID1", 217 | "Mobile BController", 218 | "bla", 219 | BluetoothHidDevice.SUBCLASS1_COMBO, 220 | DescriptorCollection.MOUSE_KEYBOARD_COMBO_RADIAL 221 | ) 222 | } 223 | 224 | 225 | 226 | private val qosOut by lazy { 227 | BluetoothHidDeviceAppQosSettings( 228 | BluetoothHidDeviceAppQosSettings.SERVICE_BEST_EFFORT, 229 | 800, 230 | 9, 231 | 0, 232 | 11250, 233 | BluetoothHidDeviceAppQosSettings.MAX 234 | ) 235 | } 236 | 237 | } -------------------------------------------------------------------------------- /app/src/main/java/com/github/roarappstudio/btkontroller/ConfigActivity.kt: -------------------------------------------------------------------------------- 1 | package com.github.roarappstudio.btkontroller 2 | 3 | import android.app.Activity 4 | import android.app.AlertDialog 5 | import android.content.Context 6 | import android.os.Bundle 7 | import android.widget.Button 8 | import android.widget.EditText 9 | import android.widget.ToggleButton 10 | import org.jetbrains.anko.find 11 | 12 | 13 | class ConfigActivity : Activity() { 14 | 15 | private var text_haptic_use: Button ?=null 16 | private var edit_wheel_haptic_min_time:EditText?=null 17 | private var edit_wheel_haptic_skip_count:EditText?=null 18 | // private var edit_wheel_haptic_vibrate_time:EditText?=null 19 | private var text_wheel_haptic_vibrate_time:Button?=null 20 | 21 | private var edit_delay_time:EditText?=null 22 | private var toggle_replace_newline:ToggleButton?=null 23 | private var toggle_sendkey_fast:ToggleButton?=null 24 | 25 | private var toggle_wheel_color:ToggleButton?=null 26 | 27 | override fun onCreate(savedInstanceState: Bundle?) { 28 | super.onCreate(savedInstanceState) 29 | setContentView(R.layout.activity_config) 30 | haptic_use_items = arrayOf(getString(R.string.haptic_use_system),getString(R.string.haptic_use_mandatory),getString(R.string.haptic_use_null)) 31 | 32 | text_haptic_use= find