commit 8caa4ec1bb54e0dfb9da2cbb0b3d6936e6eb0175
Author: zlzw <583819556@qq.com>
Date: Thu Dec 11 23:34:17 2025 +0800
init
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..aa724b7
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,15 @@
+*.iml
+.gradle
+/local.properties
+/.idea/caches
+/.idea/libraries
+/.idea/modules.xml
+/.idea/workspace.xml
+/.idea/navEditor.xml
+/.idea/assetWizardSettings.xml
+.DS_Store
+/build
+/captures
+.externalNativeBuild
+.cxx
+local.properties
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..26d3352
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/.idea/AndroidProjectSystem.xml b/.idea/AndroidProjectSystem.xml
new file mode 100644
index 0000000..4a53bee
--- /dev/null
+++ b/.idea/AndroidProjectSystem.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 0000000..b86273d
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/deploymentTargetSelector.xml b/.idea/deploymentTargetSelector.xml
new file mode 100644
index 0000000..b268ef3
--- /dev/null
+++ b/.idea/deploymentTargetSelector.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
new file mode 100644
index 0000000..97f0a8e
--- /dev/null
+++ b/.idea/gradle.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/markdown.xml b/.idea/markdown.xml
new file mode 100644
index 0000000..c61ea33
--- /dev/null
+++ b/.idea/markdown.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/migrations.xml b/.idea/migrations.xml
new file mode 100644
index 0000000..f8051a6
--- /dev/null
+++ b/.idea/migrations.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..74dd639
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml
new file mode 100644
index 0000000..16660f1
--- /dev/null
+++ b/.idea/runConfigurations.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..5971f41
--- /dev/null
+++ b/README.md
@@ -0,0 +1,56 @@
+# 通过游戏控制器
+我测试通过[官方文档](https://developer.android.com/develop/ui/views/touch-and-input/game-controllers/controller-input?hl=zh-cn)方式检查设备是无法获取到相关设备的
+
+```java
+val deviceIds = InputDevice.getDeviceIds()
+ deviceIds.forEach { it->
+ run {
+ InputDevice.getDevice(it)?.let { device ->
+ run {
+ Log.e("USB", "设备ID:${device.id} , 设备vid:${device.vendorId} , 设备pid:${device.productId}")
+ }
+ }
+ }
+ }
+```
+这里通过插拔设备打印的设备信息列表都是一致的。且没有弹窗申请。
+
+# 通过USB设备获取
+
+通过Steam Link 观察到它的连接方式是用USB Host模式
+可以参考[官方文档](https://developer.android.com/develop/connectivity/usb/host?hl=zh-cn)
+
+通过Demo的`通过USB设备获取`按钮可以观察到能在插拔USB设备的情况下打印不同的列表
+
+
+
+```java
+ usbManager = getSystemService(USB_SERVICE) as UsbManager
+ usbManager.deviceList?.forEach { it ->
+ run {
+ Log.d("USB", "设备ID:${it.value.deviceName} , 设备vid:${it.value.vendorId} , 设备pid:${it.value.productId}")
+ sb.append("设备ID:${it.value.deviceName} , 设备vid:${it.value.vendorId} , 设备pid:${it.value.productId}\n")
+ if (it.value.productId == pid && it.value.vendorId == vid) {
+ requestPermission(it.value)
+ }
+ }
+ }
+
+fun requestPermission(device: UsbDevice) {
+ val permissionIntent = PendingIntent.getBroadcast(
+ this,
+ 0,
+ Intent(ACTION_USB_PERMISSION),
+ PendingIntent.FLAG_IMMUTABLE
+ )
+ if (usbManager.hasPermission(device)) {
+ connectUsb(device)
+ } else {
+ usbManager.requestPermission(device, permissionIntent)
+ }
+}
+
+```
+
+## 总结
+建议新增使用USB方式获取手柄信息,我估计SteamLink能响应我之前反馈的PS手柄的PS按键也是采用该方案。
diff --git a/app/.gitignore b/app/.gitignore
new file mode 100644
index 0000000..42afabf
--- /dev/null
+++ b/app/.gitignore
@@ -0,0 +1 @@
+/build
\ No newline at end of file
diff --git a/app/build.gradle.kts b/app/build.gradle.kts
new file mode 100644
index 0000000..1f6ec7f
--- /dev/null
+++ b/app/build.gradle.kts
@@ -0,0 +1,49 @@
+plugins {
+ alias(libs.plugins.android.application)
+ alias(libs.plugins.kotlin.android)
+}
+
+android {
+ namespace = "com.yutou.xboxcontrol"
+ compileSdk {
+ version = release(36)
+ }
+
+ defaultConfig {
+ applicationId = "com.yutou.xboxcontrol"
+ minSdk = 24
+ targetSdk = 36
+ versionCode = 1
+ versionName = "1.0"
+
+ testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
+ }
+
+ buildTypes {
+ release {
+ isMinifyEnabled = false
+ proguardFiles(
+ getDefaultProguardFile("proguard-android-optimize.txt"),
+ "proguard-rules.pro"
+ )
+ }
+ }
+ compileOptions {
+ sourceCompatibility = JavaVersion.VERSION_11
+ targetCompatibility = JavaVersion.VERSION_11
+ }
+ kotlinOptions {
+ jvmTarget = "11"
+ }
+}
+
+dependencies {
+ implementation(libs.androidx.core.ktx)
+ implementation(libs.androidx.appcompat)
+ implementation(libs.material)
+ implementation(libs.androidx.activity)
+ implementation(libs.androidx.constraintlayout)
+ testImplementation(libs.junit)
+ androidTestImplementation(libs.androidx.junit)
+ androidTestImplementation(libs.androidx.espresso.core)
+}
\ No newline at end of file
diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro
new file mode 100644
index 0000000..481bb43
--- /dev/null
+++ b/app/proguard-rules.pro
@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
\ No newline at end of file
diff --git a/app/src/androidTest/java/com/yutou/xboxcontrol/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/yutou/xboxcontrol/ExampleInstrumentedTest.kt
new file mode 100644
index 0000000..3997d1f
--- /dev/null
+++ b/app/src/androidTest/java/com/yutou/xboxcontrol/ExampleInstrumentedTest.kt
@@ -0,0 +1,24 @@
+package com.yutou.xboxcontrol
+
+import androidx.test.platform.app.InstrumentationRegistry
+import androidx.test.ext.junit.runners.AndroidJUnit4
+
+import org.junit.Test
+import org.junit.runner.RunWith
+
+import org.junit.Assert.*
+
+/**
+ * Instrumented test, which will execute on an Android device.
+ *
+ * See [testing documentation](http://d.android.com/tools/testing).
+ */
+@RunWith(AndroidJUnit4::class)
+class ExampleInstrumentedTest {
+ @Test
+ fun useAppContext() {
+ // Context of the app under test.
+ val appContext = InstrumentationRegistry.getInstrumentation().targetContext
+ assertEquals("com.yutou.xboxcontrol", appContext.packageName)
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..d9aad88
--- /dev/null
+++ b/app/src/main/AndroidManifest.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/com/yutou/xboxcontrol/MainActivity.kt b/app/src/main/java/com/yutou/xboxcontrol/MainActivity.kt
new file mode 100644
index 0000000..87d764a
--- /dev/null
+++ b/app/src/main/java/com/yutou/xboxcontrol/MainActivity.kt
@@ -0,0 +1,96 @@
+package com.yutou.xboxcontrol
+
+import android.app.PendingIntent
+import android.content.Intent
+import android.hardware.usb.UsbDevice
+import android.hardware.usb.UsbManager
+import android.os.Bundle
+import android.util.Log
+import android.view.InputDevice
+import android.widget.Button
+import androidx.activity.enableEdgeToEdge
+import androidx.appcompat.app.AppCompatActivity
+import androidx.core.view.ViewCompat
+import androidx.core.view.WindowInsetsCompat
+import com.google.android.material.textview.MaterialTextView
+
+class MainActivity : AppCompatActivity() {
+ //通过插拔USB设备并打印UsbDevice.getProductId()和UsbDevice.getVendorId()获取小鸡手柄的设备ID,实际你们应该有一套手柄常见vid和pid吧
+ val vid = 13623
+ val pid = 4114
+ lateinit var usbManager: UsbManager
+ val ACTION_USB_PERMISSION: String = "com.example.usbcontrol.USB_PERMISSION"
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ enableEdgeToEdge()
+ setContentView(R.layout.activity_main)
+ ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
+ val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
+ v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
+ insets
+ }
+ val textView=findViewById(R.id.text)
+ usbManager = getSystemService(USB_SERVICE) as UsbManager
+ findViewById