mirror of
https://git.sr.ht/~thestr4ng3r/chiaki
synced 2025-08-14 18:57:07 -07:00
Add Host Classes to Android
This commit is contained in:
parent
01798ad5c5
commit
e610d1bd60
7 changed files with 74 additions and 8 deletions
|
@ -38,6 +38,12 @@ android {
|
|||
}
|
||||
}
|
||||
|
||||
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
|
||||
kotlinOptions {
|
||||
freeCompilerArgs += "-Xuse-experimental=kotlin.ExperimentalUnsignedTypes"
|
||||
}
|
||||
}
|
||||
|
||||
androidExtensions {
|
||||
// for @Parcelize
|
||||
experimental = true
|
||||
|
|
|
@ -35,7 +35,6 @@ data class StreamStateCreateError(val error: SessionCreateError): StreamState()
|
|||
data class StreamStateQuit(val reason: QuitReason, val reasonString: String?): StreamState()
|
||||
data class StreamStateLoginPinRequest(val pinIncorrect: Boolean): StreamState()
|
||||
|
||||
@ExperimentalUnsignedTypes
|
||||
class StreamSession(val connectInfo: ConnectInfo)
|
||||
{
|
||||
var session: Session? = null
|
||||
|
@ -125,7 +124,6 @@ class StreamSession(val connectInfo: ConnectInfo)
|
|||
session?.setLoginPin(pin)
|
||||
}
|
||||
|
||||
@ExperimentalUnsignedTypes
|
||||
fun dispatchKeyEvent(event: KeyEvent): Boolean
|
||||
{
|
||||
Log.i("StreamSession", "key event $event")
|
||||
|
|
47
android/app/src/main/java/com/metallic/chiaki/common/Host.kt
Normal file
47
android/app/src/main/java/com/metallic/chiaki/common/Host.kt
Normal file
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* This file is part of Chiaki.
|
||||
*
|
||||
* Chiaki is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Chiaki is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Chiaki. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.metallic.chiaki.common
|
||||
|
||||
import android.net.MacAddress
|
||||
import com.metallic.chiaki.lib.DiscoveryHost
|
||||
|
||||
data class RegisteredHost(
|
||||
val apSsid: String?,
|
||||
val apBssid: String?,
|
||||
val apKey: String?,
|
||||
val apName: String?,
|
||||
val ps4Mac: MacAddress,
|
||||
val ps4Nickname: String?,
|
||||
val rpRegistKey: ByteArray, // CHIAKI_SESSION_AUTH_SIZE
|
||||
val rpKeyType: UInt,
|
||||
val rpKey: ByteArray // 0x10
|
||||
)
|
||||
|
||||
sealed class DisplayHost(
|
||||
val registeredHost: RegisteredHost?
|
||||
)
|
||||
|
||||
class DiscoveredDisplayServer(
|
||||
registeredHost: RegisteredHost?,
|
||||
val discoveredHost: DiscoveryHost
|
||||
): DisplayHost(registeredHost)
|
||||
|
||||
class ManualDisplayServer(
|
||||
registeredHost: RegisteredHost?,
|
||||
val manualHost: Int
|
||||
): DisplayHost(registeredHost)
|
|
@ -22,7 +22,7 @@ data class ConnectInfo(
|
|||
val videoProfile: ConnectVideoProfile
|
||||
): Parcelable
|
||||
|
||||
class ChiakiNative
|
||||
private class ChiakiNative
|
||||
{
|
||||
data class SessionCreateResult(var errorCode: Int, var sessionPtr: Long)
|
||||
companion object
|
||||
|
@ -53,7 +53,6 @@ class ErrorCode(val value: Int)
|
|||
|
||||
private fun maxAbs(a: Short, b: Short) = if(abs(a.toInt()) > abs(b.toInt())) a else b
|
||||
|
||||
@ExperimentalUnsignedTypes
|
||||
data class ControllerState constructor(
|
||||
var buttons: UInt = 0U,
|
||||
var l2State: UByte = 0U,
|
||||
|
@ -177,4 +176,24 @@ class Session(connectInfo: ConnectInfo)
|
|||
{
|
||||
ChiakiNative.sessionSetLoginPin(nativePtr, pin)
|
||||
}
|
||||
}
|
||||
|
||||
data class DiscoveryHost(
|
||||
val state: State,
|
||||
val hostRequestPort: UShort,
|
||||
val host_addr: String?,
|
||||
val system_version: String?,
|
||||
val device_discovery_protocol_version: String?,
|
||||
val host_name: String?,
|
||||
val host_type: String?,
|
||||
val host_id: String?,
|
||||
val running_app_titleid: String?,
|
||||
val running_app_name: String?)
|
||||
{
|
||||
enum class State
|
||||
{
|
||||
UNKNOWN,
|
||||
READY,
|
||||
STANDBY
|
||||
}
|
||||
}
|
|
@ -43,7 +43,6 @@ private object StreamQuitDialog: DialogContents()
|
|||
private object CreateErrorDialog: DialogContents()
|
||||
private object PinRequestDialog: DialogContents()
|
||||
|
||||
@ExperimentalUnsignedTypes
|
||||
class StreamActivity : AppCompatActivity()
|
||||
{
|
||||
companion object
|
||||
|
@ -80,7 +79,6 @@ class StreamActivity : AppCompatActivity()
|
|||
}
|
||||
}
|
||||
|
||||
@ExperimentalUnsignedTypes
|
||||
override fun onAttachFragment(fragment: Fragment)
|
||||
{
|
||||
super.onAttachFragment(fragment)
|
||||
|
|
|
@ -21,7 +21,6 @@ import androidx.lifecycle.ViewModel
|
|||
import com.metallic.chiaki.StreamSession
|
||||
import com.metallic.chiaki.lib.*
|
||||
|
||||
@ExperimentalUnsignedTypes
|
||||
class StreamViewModel: ViewModel()
|
||||
{
|
||||
private var connectInfo: ConnectInfo? = null
|
||||
|
|
|
@ -27,7 +27,6 @@ import com.metallic.chiaki.R
|
|||
import com.metallic.chiaki.lib.ControllerState
|
||||
import kotlinx.android.synthetic.main.fragment_controls.*
|
||||
|
||||
@ExperimentalUnsignedTypes
|
||||
class TouchControlsFragment : Fragment()
|
||||
{
|
||||
var controllerState = ControllerState()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue