Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .idea/gradle.xml
100644 → 100755

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 13 additions & 13 deletions .idea/misc.xml
100644 → 100755

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 0 additions & 12 deletions .idea/runConfigurations.xml

This file was deleted.

5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ To connect other devices with your app you need to open the app on your phone an

Please report any bugs you may have on your devices. If anyone is willing to contribute....they are welcome.


<a href='https://play.google.com/store/apps/details?id=com.github.roarappstudio.btkontroller&pcampaignid=MKT-Other-global-all-co-prtnr-py-PartBadge-Mar2515-1'><img alt='Get it on Google Play' src='https://play.google.com/intl/en_us/badges/images/generic/en_badge_web_generic.png'/></a>

Procedure to use the app:
1) Remove previous pairings with the host device in bluetooth settings(This has to be done once)
2) Open the app
Expand All @@ -20,5 +17,3 @@ Procedure to use the app:
5) Use as Mouse/keyboard for your host device

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.

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). (If any One Plus 8/8Pro or 8T or One Plus Nord) user see's the repo, I need to do some testing on these one plus devices to check if the feature is enabled on them or not. If you have one of these devices and are cool and fine with letting me do some testing on your device.Feel free to create an issue.
36 changes: 31 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,20 +1,46 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-parcelize'// 'kotlin-android-extensions'

//plugins {
// id 'com.android.application'
// id 'kotlin-android'
// id 'kotlin-parcelize'
//}

java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
//tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
// kotlinOptions {
// jvmTarget = "11"
// }
//}

android {
compileSdkVersion 28
buildFeatures {
viewBinding = true
}
namespace 'com.github.roarappstudio.btkontroller'
compileSdkVersion 30
defaultConfig {
applicationId "com.github.roarappstudio.btkontroller"
minSdkVersion 28
targetSdkVersion 28
//noinspection ExpiredTargetSdkVersion
targetSdkVersion 30
versionCode 2
versionName "0.0.2"
}

compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
targetCompatibility 1.8//JavaVersion.VERSION_17 // 1.8// 1.8
sourceCompatibility 1.8//JavaVersion.VERSION_17 // 1.8//1.8
}
kotlinOptions {
jvmTarget = "1.8"
}

buildTypes {
release {
minifyEnabled true
Expand Down
Binary file added app/release/app-release.apk
Binary file not shown.
20 changes: 20 additions & 0 deletions app/release/output-metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"version": 3,
"artifactType": {
"type": "APK",
"kind": "Directory"
},
"applicationId": "com.github.roarappstudio.btkontroller",
"variantName": "release",
"elements": [
{
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 2,
"versionName": "0.0.2",
"outputFile": "app-release.apk"
}
],
"elementType": "File"
}
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" package="com.github.roarappstudio.btkontroller">
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.BLUETOOTH"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,26 @@ object BluetoothController: BluetoothHidDevice.Callback(), BluetoothProfile.Serv


override fun onSetReport(device: BluetoothDevice?, type: Byte, id: Byte, data: ByteArray?) {
Log.i("setfirst","setfirst")
Log.i(TAG,"setfirst")
super.onSetReport(device, type, id, data)
Log.i("setreport","this $device and $type and $id and $data")
Log.i(TAG,"this $device and $type and $id and $data")

}


override fun onGetReport(device: BluetoothDevice?, type: Byte, id: Byte, bufferSize: Int) {

Log.i("getbefore", "first")
Log.i(TAG, "first")
super.onGetReport(device, type, id, bufferSize)

Log.i("get", "second")
Log.i(TAG, "second")
if (type == BluetoothHidDevice.REPORT_TYPE_FEATURE) {
featureReport.wheelResolutionMultiplier = true
featureReport.acPanResolutionMultiplier = true
Log.i("getbthid","$btHid")
Log.i(TAG,"$btHid")

var wasrs=btHid?.replyReport(device, type, FeatureReport.ID, featureReport.bytes)
Log.i("replysuccess flag ",wasrs.toString())
Log.i(TAG,"replysuccess flag "+wasrs.toString())
}


Expand Down Expand Up @@ -149,24 +149,23 @@ object BluetoothController: BluetoothHidDevice.Callback(), BluetoothProfile.Serv
if(registered)
{
var pairedDevices = btHid?.getDevicesMatchingConnectionStates(intArrayOf(BluetoothProfile.STATE_CONNECTING,BluetoothProfile.STATE_CONNECTED,BluetoothProfile.STATE_DISCONNECTED,BluetoothProfile.STATE_DISCONNECTING))
Log.d("paired d", "paired devices are : $pairedDevices")
Log.d("paired d","${btHid?.getConnectionState(pairedDevices?.get(0))}")
Log.d(TAG, "paired devices are : $pairedDevices")
//Log.d("paired d","${btHid?.getConnectionState(pairedDevices?.get(0))}")
mpluggedDevice = pluggedDevice
if(btHid?.getConnectionState(pluggedDevice)==0 && pluggedDevice!= null && autoPairFlag ==true)
if(btHid?.getConnectionState(pluggedDevice)==0 && pluggedDevice!= null && autoPairFlag ==true)
{
btHid?.connect(pluggedDevice)
//hostDevice.toString()


}


else if(btHid?.getConnectionState(pairedDevices?.get(0))==0 && autoPairFlag==true)
{
Log.i("ddaaqq","sssS"
)
btHid?.connect(pairedDevices?.get(0))
}
else if(pairedDevices != null && pairedDevices.size > 0 && btHid?.getConnectionState(pairedDevices?.get(0))==0 && autoPairFlag)
{
Log.i(TAG,"sssS"
)
btHid?.connect(pairedDevices?.get(0))
}
else {
Log.i(TAG, "none")
}

// val intent = Intent("CUSTOM_ACTION")
// intent.putExtra("DATE", Date().toString())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,9 +417,9 @@ class SelectDeviceActivity: Activity(),KeyEvent.Callback {

getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)

with(sharedPref.edit())
with(sharedPref?.edit())
{
putBoolean(getString(R.string.screen_on_flag), false)
this!!.putBoolean(getString(R.string.screen_on_flag), false)
commit()
}

Expand All @@ -429,7 +429,7 @@ class SelectDeviceActivity: Activity(),KeyEvent.Callback {
item.isChecked=true
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)

with(sharedPref.edit())
with(sharedPref!!.edit())
{
putBoolean(getString(R.string.screen_on_flag), true)
commit()
Expand All @@ -446,7 +446,7 @@ class SelectDeviceActivity: Activity(),KeyEvent.Callback {
item.isChecked = false
BluetoothController.autoPairFlag=false

with(sharedPref.edit())
with(sharedPref!!.edit())
{
putBoolean(getString(R.string.auto_pair_flag), BluetoothController.autoPairFlag)
commit()
Expand All @@ -462,7 +462,7 @@ class SelectDeviceActivity: Activity(),KeyEvent.Callback {
BluetoothController.btHid?.connect(BluetoothController.mpluggedDevice)
//hostDevice.toString()
}
with(sharedPref.edit())
with(sharedPref!!.edit())
{
putBoolean(getString(R.string.auto_pair_flag), BluetoothController.autoPairFlag)
commit()
Expand Down
19 changes: 16 additions & 3 deletions app/src/main/java/com/github/roarappstudio/btkontroller/Unhide.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,23 @@ import android.bluetooth.BluetoothDevice
/** Extensions which expose hidden API **/

fun BluetoothAdapter.setScanMode(mode: Int, duration: Int): Boolean =
this::class.java.getMethod("setScanMode", Int::class.java, Int::class.java).invoke(this, mode, duration) as Boolean
try {
this::class.java.getMethod("setScanMode", Int::class.java, Int::class.java)
.invoke(this, mode, duration) as Boolean
} catch (e : NoSuchMethodException) {
false
}

fun BluetoothDevice.cancelBondProcess(): Boolean =
this::class.java.getMethod("cancelBondProcess").invoke(this) as Boolean
try {
this::class.java.getMethod("cancelBondProcess").invoke(this) as Boolean
} catch (e : NoSuchMethodException) {
false
}

fun BluetoothDevice.removeBond(): Boolean =
this::class.java.getMethod("removeBond").invoke(this) as Boolean
try {
this::class.java.getMethod("removeBond").invoke(this) as Boolean
} catch (e : NoSuchMethodException) {
false
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import kotlin.experimental.and
import kotlin.experimental.or

@Suppress("EXPERIMENTAL_FEATURE_WARNING")
inline class FeatureReport (
class FeatureReport (
val bytes: ByteArray = ByteArray(1) {0}
) {

Expand Down Expand Up @@ -35,4 +35,4 @@ inline class FeatureReport (
companion object {
const val ID = 6.toByte()
}
}
}
27 changes: 23 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.3.21'
ext.kotlin_version = '2.0.20' // '1.7.20'
ext.anko_version='0.10.8'

repositories {
google()
maven {
allowInsecureProtocol = true
url = uri("http://maven.xdja.com:8081/nexus3/repository/aliyun/")
}
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
classpath 'com.android.tools.build:gradle:8.2.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

// NOTE: Do not place your application dependencies here; they belong
Expand All @@ -18,13 +22,28 @@ buildscript {
}

allprojects {
repositories {
repositories {//
google()
maven {
allowInsecureProtocol = true
url = uri("http://maven.xdja.com:8081/nexus3/repository/aliyun/") //org/jetbrains/anko/")
}
jcenter()

}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

subprojects {
afterEvaluate { project ->
if (project.hasProperty('android')) {
project.android {
if (namespace == null) {
namespace project.group
}
}
}
}
}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
11 changes: 5 additions & 6 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Fri May 24 14:30:21 IST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading