Add Host Classes to Android

This commit is contained in:
Florian Märkl 2019-10-02 20:06:13 +02:00
commit e610d1bd60
No known key found for this signature in database
GPG key ID: 125BC8A5A6A1E857
7 changed files with 74 additions and 8 deletions

View file

@ -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

View file

@ -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")

View 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)

View file

@ -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
}
}

View file

@ -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)

View file

@ -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

View file

@ -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()