mirror of
https://git.ryujinx.app/kenji-nx/ryujinx.git
synced 2025-12-14 07:37:04 +00:00
Small Kotlin changes
* Use Delegation for KenjinxNative jnaInstance * rework KenjiNative.updateUiHandler + remove needless companion object * Small syntactic niceties, general cleanups & code style fixes
This commit is contained in:
parent
6f13e04a24
commit
fc2f1588d5
17 changed files with 186 additions and 220 deletions
|
|
@ -36,9 +36,9 @@ typealias GamePadConfig = RadialGamePadConfig
|
|||
class GameController(var activity: Activity) {
|
||||
|
||||
companion object {
|
||||
private fun Create(context: Context, controller: GameController): View {
|
||||
val inflator = LayoutInflater.from(context)
|
||||
val view = inflator.inflate(R.layout.game_layout, null)
|
||||
private fun init(context: Context, controller: GameController): View {
|
||||
val inflater = LayoutInflater.from(context)
|
||||
val view = inflater.inflate(R.layout.game_layout, null)
|
||||
view.findViewById<FrameLayout>(R.id.leftcontainer)!!.addView(controller.leftGamePad)
|
||||
view.findViewById<FrameLayout>(R.id.rightcontainer)!!.addView(controller.rightGamePad)
|
||||
|
||||
|
|
@ -50,7 +50,7 @@ class GameController(var activity: Activity) {
|
|||
AndroidView(
|
||||
modifier = Modifier.fillMaxSize(), factory = { context ->
|
||||
val controller = GameController(viewModel.activity)
|
||||
val c = Create(context, controller)
|
||||
val c = init(context, controller)
|
||||
viewModel.activity.lifecycleScope.apply {
|
||||
viewModel.activity.lifecycleScope.launch {
|
||||
val events = merge(
|
||||
|
|
@ -108,12 +108,12 @@ class GameController(var activity: Activity) {
|
|||
|
||||
fun connect() {
|
||||
if (controllerId == -1)
|
||||
controllerId = KenjinxNative.jnaInstance.inputConnectGamepad(0)
|
||||
controllerId = KenjinxNative.inputConnectGamepad(0)
|
||||
}
|
||||
|
||||
private fun handleEvent(ev: Event) {
|
||||
if (controllerId == -1)
|
||||
controllerId = KenjinxNative.jnaInstance.inputConnectGamepad(0)
|
||||
controllerId = KenjinxNative.inputConnectGamepad(0)
|
||||
|
||||
controllerId.apply {
|
||||
when (ev) {
|
||||
|
|
@ -121,11 +121,11 @@ class GameController(var activity: Activity) {
|
|||
val action = ev.action
|
||||
when (action) {
|
||||
KeyEvent.ACTION_UP -> {
|
||||
KenjinxNative.jnaInstance.inputSetButtonReleased(ev.id, this)
|
||||
KenjinxNative.inputSetButtonReleased(ev.id, this)
|
||||
}
|
||||
|
||||
KeyEvent.ACTION_DOWN -> {
|
||||
KenjinxNative.jnaInstance.inputSetButtonPressed(ev.id, this)
|
||||
KenjinxNative.inputSetButtonPressed(ev.id, this)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -136,57 +136,57 @@ class GameController(var activity: Activity) {
|
|||
when (direction) {
|
||||
GamePadButtonInputId.DpadUp.ordinal -> {
|
||||
if (ev.xAxis > 0) {
|
||||
KenjinxNative.jnaInstance.inputSetButtonPressed(
|
||||
KenjinxNative.inputSetButtonPressed(
|
||||
GamePadButtonInputId.DpadRight.ordinal,
|
||||
this
|
||||
)
|
||||
KenjinxNative.jnaInstance.inputSetButtonReleased(
|
||||
KenjinxNative.inputSetButtonReleased(
|
||||
GamePadButtonInputId.DpadLeft.ordinal,
|
||||
this
|
||||
)
|
||||
} else if (ev.xAxis < 0) {
|
||||
KenjinxNative.jnaInstance.inputSetButtonPressed(
|
||||
KenjinxNative.inputSetButtonPressed(
|
||||
GamePadButtonInputId.DpadLeft.ordinal,
|
||||
this
|
||||
)
|
||||
KenjinxNative.jnaInstance.inputSetButtonReleased(
|
||||
KenjinxNative.inputSetButtonReleased(
|
||||
GamePadButtonInputId.DpadRight.ordinal,
|
||||
this
|
||||
)
|
||||
} else {
|
||||
KenjinxNative.jnaInstance.inputSetButtonReleased(
|
||||
KenjinxNative.inputSetButtonReleased(
|
||||
GamePadButtonInputId.DpadLeft.ordinal,
|
||||
this
|
||||
)
|
||||
KenjinxNative.jnaInstance.inputSetButtonReleased(
|
||||
KenjinxNative.inputSetButtonReleased(
|
||||
GamePadButtonInputId.DpadRight.ordinal,
|
||||
this
|
||||
)
|
||||
}
|
||||
if (ev.yAxis < 0) {
|
||||
KenjinxNative.jnaInstance.inputSetButtonPressed(
|
||||
KenjinxNative.inputSetButtonPressed(
|
||||
GamePadButtonInputId.DpadUp.ordinal,
|
||||
this
|
||||
)
|
||||
KenjinxNative.jnaInstance.inputSetButtonReleased(
|
||||
KenjinxNative.inputSetButtonReleased(
|
||||
GamePadButtonInputId.DpadDown.ordinal,
|
||||
this
|
||||
)
|
||||
} else if (ev.yAxis > 0) {
|
||||
KenjinxNative.jnaInstance.inputSetButtonPressed(
|
||||
KenjinxNative.inputSetButtonPressed(
|
||||
GamePadButtonInputId.DpadDown.ordinal,
|
||||
this
|
||||
)
|
||||
KenjinxNative.jnaInstance.inputSetButtonReleased(
|
||||
KenjinxNative.inputSetButtonReleased(
|
||||
GamePadButtonInputId.DpadUp.ordinal,
|
||||
this
|
||||
)
|
||||
} else {
|
||||
KenjinxNative.jnaInstance.inputSetButtonReleased(
|
||||
KenjinxNative.inputSetButtonReleased(
|
||||
GamePadButtonInputId.DpadDown.ordinal,
|
||||
this
|
||||
)
|
||||
KenjinxNative.jnaInstance.inputSetButtonReleased(
|
||||
KenjinxNative.inputSetButtonReleased(
|
||||
GamePadButtonInputId.DpadUp.ordinal,
|
||||
this
|
||||
)
|
||||
|
|
@ -197,7 +197,7 @@ class GameController(var activity: Activity) {
|
|||
val setting = QuickSettings(activity)
|
||||
val x = MathUtils.clamp(ev.xAxis * setting.controllerStickSensitivity, -1f, 1f)
|
||||
val y = MathUtils.clamp(ev.yAxis * setting.controllerStickSensitivity, -1f, 1f)
|
||||
KenjinxNative.jnaInstance.inputSetStickAxis(
|
||||
KenjinxNative.inputSetStickAxis(
|
||||
1,
|
||||
x,
|
||||
-y,
|
||||
|
|
@ -209,7 +209,7 @@ class GameController(var activity: Activity) {
|
|||
val setting = QuickSettings(activity)
|
||||
val x = MathUtils.clamp(ev.xAxis * setting.controllerStickSensitivity, -1f, 1f)
|
||||
val y = MathUtils.clamp(ev.yAxis * setting.controllerStickSensitivity, -1f, 1f)
|
||||
KenjinxNative.jnaInstance.inputSetStickAxis(
|
||||
KenjinxNative.inputSetStickAxis(
|
||||
2,
|
||||
x,
|
||||
-y,
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ import kotlin.concurrent.thread
|
|||
@SuppressLint("ViewConstructor")
|
||||
class GameHost(context: Context?, private val mainViewModel: MainViewModel) : SurfaceView(context),
|
||||
SurfaceHolder.Callback {
|
||||
private var _currentWindow: Long = -1
|
||||
private var isProgressHidden: Boolean = false
|
||||
private var progress: MutableState<String>? = null
|
||||
private var progressValue: MutableState<Float>? = null
|
||||
|
|
@ -28,12 +27,10 @@ class GameHost(context: Context?, private val mainViewModel: MainViewModel) : Su
|
|||
private var _isStarted: Boolean = false
|
||||
private val _nativeWindow: NativeWindow
|
||||
|
||||
val currentSurface:Long
|
||||
get() {
|
||||
return _currentWindow
|
||||
}
|
||||
var currentSurface: Long = -1
|
||||
private set
|
||||
|
||||
val currentWindowhandle: Long
|
||||
val currentWindowHandle: Long
|
||||
get() {
|
||||
return _nativeWindow.nativePointer
|
||||
}
|
||||
|
|
@ -67,7 +64,7 @@ class GameHost(context: Context?, private val mainViewModel: MainViewModel) : Su
|
|||
return
|
||||
|
||||
if (_width != width || _height != height) {
|
||||
_currentWindow = _nativeWindow.requeryWindowHandle()
|
||||
currentSurface = _nativeWindow.requeryWindowHandle()
|
||||
|
||||
_nativeWindow.swapInterval = 0
|
||||
}
|
||||
|
|
@ -77,13 +74,13 @@ class GameHost(context: Context?, private val mainViewModel: MainViewModel) : Su
|
|||
|
||||
start(holder)
|
||||
|
||||
KenjinxNative.jnaInstance.graphicsRendererSetSize(
|
||||
KenjinxNative.graphicsRendererSetSize(
|
||||
width,
|
||||
height
|
||||
)
|
||||
|
||||
if (_isStarted) {
|
||||
KenjinxNative.jnaInstance.inputSetClientSize(width, height)
|
||||
KenjinxNative.inputSetClientSize(width, height)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -96,7 +93,7 @@ class GameHost(context: Context?, private val mainViewModel: MainViewModel) : Su
|
|||
_isInit = false
|
||||
_isStarted = false
|
||||
|
||||
KenjinxNative.jnaInstance.uiHandlerSetResponse(false, "")
|
||||
KenjinxNative.uiHandlerSetResponse(false, "")
|
||||
|
||||
_updateThread?.join()
|
||||
_renderingThreadWatcher?.join()
|
||||
|
|
@ -110,12 +107,12 @@ class GameHost(context: Context?, private val mainViewModel: MainViewModel) : Su
|
|||
|
||||
game = if (mainViewModel.isMiiEditorLaunched) null else mainViewModel.gameModel
|
||||
|
||||
KenjinxNative.jnaInstance.inputInitialize(width, height)
|
||||
KenjinxNative.inputInitialize(width, height)
|
||||
|
||||
val id = mainViewModel.physicalControllerManager?.connect()
|
||||
mainViewModel.motionSensorManager?.setControllerId(id ?: -1)
|
||||
|
||||
KenjinxNative.jnaInstance.graphicsRendererSetSize(
|
||||
KenjinxNative.graphicsRendererSetSize(
|
||||
surfaceHolder.surfaceFrame.width(),
|
||||
surfaceHolder.surfaceFrame.height()
|
||||
)
|
||||
|
|
@ -130,7 +127,7 @@ class GameHost(context: Context?, private val mainViewModel: MainViewModel) : Su
|
|||
var c = 0
|
||||
val helper = NativeHelpers.instance
|
||||
while (_isStarted) {
|
||||
KenjinxNative.jnaInstance.inputUpdate()
|
||||
KenjinxNative.inputUpdate()
|
||||
Thread.sleep(1)
|
||||
c++
|
||||
if (c >= 1000) {
|
||||
|
|
@ -141,9 +138,9 @@ class GameHost(context: Context?, private val mainViewModel: MainViewModel) : Su
|
|||
}
|
||||
c = 0
|
||||
mainViewModel.updateStats(
|
||||
KenjinxNative.jnaInstance.deviceGetGameFifo(),
|
||||
KenjinxNative.jnaInstance.deviceGetGameFrameRate(),
|
||||
KenjinxNative.jnaInstance.deviceGetGameFrameTime()
|
||||
KenjinxNative.deviceGetGameFifo(),
|
||||
KenjinxNative.deviceGetGameFrameRate(),
|
||||
KenjinxNative.deviceGetGameFrameTime()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -151,7 +148,7 @@ class GameHost(context: Context?, private val mainViewModel: MainViewModel) : Su
|
|||
}
|
||||
|
||||
private fun runGame() {
|
||||
KenjinxNative.jnaInstance.graphicsRendererRunLoop()
|
||||
KenjinxNative.graphicsRendererRunLoop()
|
||||
|
||||
game?.close()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import kotlinx.coroutines.CoroutineScope
|
|||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import java.io.File
|
||||
import androidx.core.net.toUri
|
||||
|
||||
class Helpers {
|
||||
companion object {
|
||||
|
|
@ -31,11 +32,10 @@ class Helpers {
|
|||
if ("primary".equals(type, ignoreCase = true)) {
|
||||
return Environment.getExternalStorageDirectory().toString() + "/" + split[1]
|
||||
}
|
||||
|
||||
} else if (isDownloadsDocument(uri)) {
|
||||
val id = DocumentsContract.getDocumentId(uri)
|
||||
val contentUri = ContentUris.withAppendedId(
|
||||
Uri.parse("content://downloads/public_downloads"),
|
||||
"content://downloads/public_downloads".toUri(),
|
||||
java.lang.Long.valueOf(id)
|
||||
)
|
||||
return getDataColumn(context, contentUri, null, null)
|
||||
|
|
|
|||
|
|
@ -87,77 +87,53 @@ interface KenjinxNativeJna : Library {
|
|||
fun loggingEnabledGraphicsLog(enabled: Boolean)
|
||||
}
|
||||
|
||||
class KenjinxNative {
|
||||
val jnaInstance: KenjinxNativeJna = Native.load(
|
||||
"kenjinx",
|
||||
KenjinxNativeJna::class.java,
|
||||
Collections.singletonMap(Library.OPTION_ALLOW_OBJECTS, true)
|
||||
)
|
||||
|
||||
companion object {
|
||||
val jnaInstance: KenjinxNativeJna = Native.load(
|
||||
"kenjinx",
|
||||
KenjinxNativeJna::class.java,
|
||||
Collections.singletonMap(Library.OPTION_ALLOW_OBJECTS, true)
|
||||
object KenjinxNative : KenjinxNativeJna by jnaInstance {
|
||||
|
||||
fun loggingSetEnabled(logLevel: LogLevel, enabled: Boolean) = loggingSetEnabled(logLevel.ordinal, enabled)
|
||||
|
||||
@JvmStatic
|
||||
fun frameEnded() = MainActivity.frameEnded()
|
||||
|
||||
@JvmStatic
|
||||
fun getSurfacePtr(): Long = MainActivity.mainViewModel?.gameHost?.currentSurface ?: -1
|
||||
|
||||
@JvmStatic
|
||||
fun getWindowHandle(): Long =
|
||||
MainActivity.mainViewModel?.gameHost?.currentWindowHandle ?: -1
|
||||
|
||||
@JvmStatic
|
||||
fun updateProgress(infoPtr: Long, progress: Float) =
|
||||
MainActivity.mainViewModel?.gameHost?.setProgress(
|
||||
NativeHelpers.instance.getStringJava(infoPtr),
|
||||
progress
|
||||
)
|
||||
|
||||
@JvmStatic
|
||||
fun test()
|
||||
{
|
||||
val i = 0
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun frameEnded()
|
||||
{
|
||||
MainActivity.frameEnded()
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getSurfacePtr() : Long
|
||||
{
|
||||
return MainActivity.mainViewModel?.gameHost?.currentSurface ?: -1
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getWindowHandle() : Long
|
||||
{
|
||||
return MainActivity.mainViewModel?.gameHost?.currentWindowhandle ?: -1
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun updateProgress(infoPtr : Long, progress: Float)
|
||||
{
|
||||
val info = NativeHelpers.instance.getStringJava(infoPtr);
|
||||
MainActivity.mainViewModel?.gameHost?.setProgress(info, progress)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun updateUiHandler(
|
||||
newTitlePointer: Long,
|
||||
newMessagePointer: Long,
|
||||
newWatermarkPointer: Long,
|
||||
newType: Int,
|
||||
min: Int,
|
||||
max: Int,
|
||||
nMode: Int,
|
||||
newSubtitlePointer: Long,
|
||||
newInitialTextPointer: Long
|
||||
)
|
||||
{
|
||||
var uiHandler = MainActivity.mainViewModel?.activity?.uiHandler
|
||||
uiHandler?.apply {
|
||||
val newTitle = NativeHelpers.instance.getStringJava(newTitlePointer)
|
||||
val newMessage = NativeHelpers.instance.getStringJava(newMessagePointer)
|
||||
val newWatermark = NativeHelpers.instance.getStringJava(newWatermarkPointer)
|
||||
val newSubtitle = NativeHelpers.instance.getStringJava(newSubtitlePointer)
|
||||
val newInitialText = NativeHelpers.instance.getStringJava(newInitialTextPointer)
|
||||
val newMode = KeyboardMode.entries[nMode]
|
||||
update(newTitle,
|
||||
newMessage,
|
||||
newWatermark,
|
||||
newType,
|
||||
min,
|
||||
max,
|
||||
newMode,
|
||||
newSubtitle,
|
||||
newInitialText);
|
||||
}
|
||||
}
|
||||
}
|
||||
@JvmStatic
|
||||
fun updateUiHandler(
|
||||
newTitlePointer: Long,
|
||||
newMessagePointer: Long,
|
||||
newWatermarkPointer: Long,
|
||||
newType: Int,
|
||||
min: Int,
|
||||
max: Int,
|
||||
nMode: Int,
|
||||
newSubtitlePointer: Long,
|
||||
newInitialTextPointer: Long
|
||||
) = MainActivity.mainViewModel?.activity?.uiHandler?.update(
|
||||
newTitle = NativeHelpers.instance.getStringJava(newTitlePointer),
|
||||
newMessage = NativeHelpers.instance.getStringJava(newMessagePointer),
|
||||
newWatermark = NativeHelpers.instance.getStringJava(newWatermarkPointer),
|
||||
newType,
|
||||
min,
|
||||
max,
|
||||
newMode = KeyboardMode.entries[nMode],
|
||||
newSubtitle = NativeHelpers.instance.getStringJava(newSubtitlePointer),
|
||||
NativeHelpers.instance.getStringJava(newInitialTextPointer)
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,6 +58,6 @@ class Logging(private var viewModel: MainViewModel) {
|
|||
}
|
||||
}
|
||||
|
||||
internal enum class LogLevel {
|
||||
enum class LogLevel {
|
||||
Debug, Stub, Info, Warning, Error, Guest, AccessLog, Notice, Trace
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import org.kenjinx.android.viewmodels.MainViewModel
|
|||
import org.kenjinx.android.viewmodels.QuickSettings
|
||||
import org.kenjinx.android.viewmodels.GameModel
|
||||
import org.kenjinx.android.views.MainView
|
||||
import androidx.core.net.toUri
|
||||
|
||||
class MainActivity : BaseActivity() {
|
||||
private var physicalControllerManager: PhysicalControllerManager =
|
||||
|
|
@ -47,7 +48,6 @@ class MainActivity : BaseActivity() {
|
|||
var mainViewModel: MainViewModel? = null
|
||||
var AppPath: String = ""
|
||||
var StorageHelper: SimpleStorageHelper? = null
|
||||
val performanceMonitor = PerformanceMonitor()
|
||||
|
||||
@JvmStatic
|
||||
fun frameEnded() {
|
||||
|
|
@ -76,45 +76,43 @@ class MainActivity : BaseActivity() {
|
|||
val appPath: String = AppPath
|
||||
|
||||
var quickSettings = QuickSettings(this)
|
||||
KenjinxNative.jnaInstance.loggingSetEnabled(
|
||||
LogLevel.Info.ordinal,
|
||||
KenjinxNative.loggingSetEnabled(
|
||||
LogLevel.Info,
|
||||
quickSettings.enableInfoLogs
|
||||
)
|
||||
KenjinxNative.jnaInstance.loggingSetEnabled(
|
||||
LogLevel.Stub.ordinal,
|
||||
KenjinxNative.loggingSetEnabled(
|
||||
LogLevel.Stub,
|
||||
quickSettings.enableStubLogs
|
||||
)
|
||||
KenjinxNative.jnaInstance.loggingSetEnabled(
|
||||
LogLevel.Warning.ordinal,
|
||||
KenjinxNative.loggingSetEnabled(
|
||||
LogLevel.Warning,
|
||||
quickSettings.enableWarningLogs
|
||||
)
|
||||
KenjinxNative.jnaInstance.loggingSetEnabled(
|
||||
LogLevel.Error.ordinal,
|
||||
KenjinxNative.loggingSetEnabled(
|
||||
LogLevel.Error,
|
||||
quickSettings.enableErrorLogs
|
||||
)
|
||||
KenjinxNative.jnaInstance.loggingSetEnabled(
|
||||
LogLevel.AccessLog.ordinal,
|
||||
KenjinxNative.loggingSetEnabled(
|
||||
LogLevel.AccessLog,
|
||||
quickSettings.enableFsAccessLogs
|
||||
)
|
||||
KenjinxNative.jnaInstance.loggingSetEnabled(
|
||||
LogLevel.Guest.ordinal,
|
||||
KenjinxNative.loggingSetEnabled(
|
||||
LogLevel.Guest,
|
||||
quickSettings.enableGuestLogs
|
||||
)
|
||||
KenjinxNative.jnaInstance.loggingSetEnabled(
|
||||
LogLevel.Trace.ordinal,
|
||||
KenjinxNative.loggingSetEnabled(
|
||||
LogLevel.Trace,
|
||||
quickSettings.enableTraceLogs
|
||||
)
|
||||
KenjinxNative.jnaInstance.loggingSetEnabled(
|
||||
LogLevel.Debug.ordinal,
|
||||
KenjinxNative.loggingSetEnabled(
|
||||
LogLevel.Debug,
|
||||
quickSettings.enableDebugLogs
|
||||
)
|
||||
KenjinxNative.jnaInstance.loggingEnabledGraphicsLog(
|
||||
KenjinxNative.loggingEnabledGraphicsLog(
|
||||
quickSettings.enableGraphicsLogs
|
||||
)
|
||||
val success =
|
||||
KenjinxNative.jnaInstance.javaInitialize(appPath, JNIEnv.CURRENT)
|
||||
|
||||
_isInit = success
|
||||
_isInit = KenjinxNative.javaInitialize(appPath, JNIEnv.CURRENT)
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
|
@ -235,7 +233,7 @@ class MainActivity : BaseActivity() {
|
|||
val forceNceAndPptc = storedIntent.getBooleanExtra("forceNceAndPptc",false)
|
||||
|
||||
if (bootPath != null) {
|
||||
val uri = android.net.Uri.parse(bootPath)
|
||||
val uri = bootPath.toUri()
|
||||
val documentFile = DocumentFile.fromSingleUri(this, uri)
|
||||
|
||||
if (documentFile != null) {
|
||||
|
|
|
|||
|
|
@ -92,8 +92,8 @@ class MotionSensorManager(val activity: MainActivity) : SensorEventListener2 {
|
|||
isRegistered = false
|
||||
|
||||
if (controllerId != -1) {
|
||||
KenjinxNative.jnaInstance.inputSetAccelerometerData(0.0F, 0.0F, 0.0F, controllerId)
|
||||
KenjinxNative.jnaInstance.inputSetGyroData(0.0F, 0.0F, 0.0F, controllerId)
|
||||
KenjinxNative.inputSetAccelerometerData(0.0F, 0.0F, 0.0F, controllerId)
|
||||
KenjinxNative.inputSetGyroData(0.0F, 0.0F, 0.0F, controllerId)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -107,7 +107,7 @@ class MotionSensorManager(val activity: MainActivity) : SensorEventListener2 {
|
|||
val y = motionAcelOrientation[1] * event.values[0]
|
||||
val z = motionAcelOrientation[2] * event.values[2]
|
||||
|
||||
KenjinxNative.jnaInstance.inputSetAccelerometerData(
|
||||
KenjinxNative.inputSetAccelerometerData(
|
||||
x,
|
||||
y,
|
||||
z,
|
||||
|
|
@ -119,13 +119,13 @@ class MotionSensorManager(val activity: MainActivity) : SensorEventListener2 {
|
|||
val x = motionGyroOrientation[0] * event.values[1]
|
||||
val y = motionGyroOrientation[1] * event.values[0]
|
||||
val z = motionGyroOrientation[2] * event.values[2]
|
||||
KenjinxNative.jnaInstance.inputSetGyroData(x, y, z, controllerId)
|
||||
KenjinxNative.inputSetGyroData(x, y, z, controllerId)
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
KenjinxNative.jnaInstance.inputSetAccelerometerData(0.0F, 0.0F, 0.0F, controllerId)
|
||||
KenjinxNative.jnaInstance.inputSetGyroData(0.0F, 0.0F, 0.0F, controllerId)
|
||||
KenjinxNative.inputSetAccelerometerData(0.0F, 0.0F, 0.0F, controllerId)
|
||||
KenjinxNative.inputSetGyroData(0.0F, 0.0F, 0.0F, controllerId)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,12 +7,12 @@ class NativeWindow(val surface: SurfaceView) {
|
|||
private val nativeHelpers: NativeHelpers = NativeHelpers.instance
|
||||
private var _swapInterval: Int = 0
|
||||
|
||||
var maxSwapInterval: Int = 0
|
||||
val maxSwapInterval: Int
|
||||
get() {
|
||||
return if (nativePointer == -1L) 0 else nativeHelpers.getMaxSwapInterval(nativePointer)
|
||||
}
|
||||
|
||||
var minSwapInterval: Int = 0
|
||||
val minSwapInterval: Int
|
||||
get() {
|
||||
return if (nativePointer == -1L) 0 else nativeHelpers.getMinSwapInterval(nativePointer)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,23 +6,17 @@ import android.util.Log
|
|||
import androidx.compose.runtime.MutableState
|
||||
import java.io.RandomAccessFile
|
||||
|
||||
class PerformanceMonitor {
|
||||
val numberOfCores = Runtime.getRuntime().availableProcessors()
|
||||
|
||||
object PerformanceMonitor {
|
||||
fun getFrequencies(frequencies: MutableList<Double>){
|
||||
frequencies.clear()
|
||||
for (i in 0 until numberOfCores) {
|
||||
var freq = 0.0
|
||||
try {
|
||||
RandomAccessFile("/sys/devices/system/cpu/cpu${i}/cpufreq/scaling_cur_freq", "r").use { reader->
|
||||
val f = reader.readLine()
|
||||
freq = f.toDouble() / 1000.0
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.e("Performance Monitor", "Failed to read CPU freq", e);
|
||||
}
|
||||
for (i in 0 until Runtime.getRuntime().availableProcessors()) {
|
||||
runCatching {
|
||||
val raf = RandomAccessFile("/sys/devices/system/cpu/cpu$i/cpufreq/scaling_cur_freq", "r")
|
||||
|
||||
frequencies.add(freq)
|
||||
frequencies.add(raf.use { it.readLine().toDouble() / 1000.0 })
|
||||
}.onFailure {
|
||||
Log.e("Performance Monitor", "Failed to read frequency of CPU core $i", it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -40,4 +34,4 @@ class PerformanceMonitor {
|
|||
totalMem.value = totalMemory.toInt()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,11 +15,11 @@ class PhysicalControllerManager(val activity: MainActivity) {
|
|||
if (/*controllerId != -1 &&*/ isNotFallback) {
|
||||
when (event.action) {
|
||||
KeyEvent.ACTION_UP -> {
|
||||
KenjinxNative.jnaInstance.inputSetButtonReleased(id.ordinal, controllerId)
|
||||
KenjinxNative.inputSetButtonReleased(id.ordinal, controllerId)
|
||||
}
|
||||
|
||||
KeyEvent.ACTION_DOWN -> {
|
||||
KenjinxNative.jnaInstance.inputSetButtonPressed(id.ordinal, controllerId)
|
||||
KenjinxNative.inputSetButtonPressed(id.ordinal, controllerId)
|
||||
}
|
||||
}
|
||||
return true
|
||||
|
|
@ -38,13 +38,13 @@ class PhysicalControllerManager(val activity: MainActivity) {
|
|||
val leftStickY = ev.getAxisValue(MotionEvent.AXIS_Y)
|
||||
val rightStickX = ev.getAxisValue(MotionEvent.AXIS_Z)
|
||||
val rightStickY = ev.getAxisValue(MotionEvent.AXIS_RZ)
|
||||
KenjinxNative.jnaInstance.inputSetStickAxis(
|
||||
KenjinxNative.inputSetStickAxis(
|
||||
1,
|
||||
leftStickX,
|
||||
-leftStickY,
|
||||
controllerId
|
||||
)
|
||||
KenjinxNative.jnaInstance.inputSetStickAxis(
|
||||
KenjinxNative.inputSetStickAxis(
|
||||
2,
|
||||
rightStickX,
|
||||
-rightStickY,
|
||||
|
|
@ -57,63 +57,63 @@ class PhysicalControllerManager(val activity: MainActivity) {
|
|||
val dPadHor = ev.getAxisValue(MotionEvent.AXIS_HAT_X)
|
||||
val dPadVert = ev.getAxisValue(MotionEvent.AXIS_HAT_Y)
|
||||
if (dPadVert == 0.0f) {
|
||||
KenjinxNative.jnaInstance.inputSetButtonReleased(
|
||||
KenjinxNative.inputSetButtonReleased(
|
||||
GamePadButtonInputId.DpadUp.ordinal,
|
||||
controllerId
|
||||
)
|
||||
KenjinxNative.jnaInstance.inputSetButtonReleased(
|
||||
KenjinxNative.inputSetButtonReleased(
|
||||
GamePadButtonInputId.DpadDown.ordinal,
|
||||
controllerId
|
||||
)
|
||||
}
|
||||
if (dPadHor == 0.0f) {
|
||||
KenjinxNative.jnaInstance.inputSetButtonReleased(
|
||||
KenjinxNative.inputSetButtonReleased(
|
||||
GamePadButtonInputId.DpadLeft.ordinal,
|
||||
controllerId
|
||||
)
|
||||
KenjinxNative.jnaInstance.inputSetButtonReleased(
|
||||
KenjinxNative.inputSetButtonReleased(
|
||||
GamePadButtonInputId.DpadRight.ordinal,
|
||||
controllerId
|
||||
)
|
||||
}
|
||||
|
||||
if (dPadVert < 0.0f) {
|
||||
KenjinxNative.jnaInstance.inputSetButtonPressed(
|
||||
KenjinxNative.inputSetButtonPressed(
|
||||
GamePadButtonInputId.DpadUp.ordinal,
|
||||
controllerId
|
||||
)
|
||||
KenjinxNative.jnaInstance.inputSetButtonReleased(
|
||||
KenjinxNative.inputSetButtonReleased(
|
||||
GamePadButtonInputId.DpadDown.ordinal,
|
||||
controllerId
|
||||
)
|
||||
}
|
||||
if (dPadHor < 0.0f) {
|
||||
KenjinxNative.jnaInstance.inputSetButtonPressed(
|
||||
KenjinxNative.inputSetButtonPressed(
|
||||
GamePadButtonInputId.DpadLeft.ordinal,
|
||||
controllerId
|
||||
)
|
||||
KenjinxNative.jnaInstance.inputSetButtonReleased(
|
||||
KenjinxNative.inputSetButtonReleased(
|
||||
GamePadButtonInputId.DpadRight.ordinal,
|
||||
controllerId
|
||||
)
|
||||
}
|
||||
|
||||
if (dPadVert > 0.0f) {
|
||||
KenjinxNative.jnaInstance.inputSetButtonReleased(
|
||||
KenjinxNative.inputSetButtonReleased(
|
||||
GamePadButtonInputId.DpadUp.ordinal,
|
||||
controllerId
|
||||
)
|
||||
KenjinxNative.jnaInstance.inputSetButtonPressed(
|
||||
KenjinxNative.inputSetButtonPressed(
|
||||
GamePadButtonInputId.DpadDown.ordinal,
|
||||
controllerId
|
||||
)
|
||||
}
|
||||
if (dPadHor > 0.0f) {
|
||||
KenjinxNative.jnaInstance.inputSetButtonReleased(
|
||||
KenjinxNative.inputSetButtonReleased(
|
||||
GamePadButtonInputId.DpadLeft.ordinal,
|
||||
controllerId
|
||||
)
|
||||
KenjinxNative.jnaInstance.inputSetButtonPressed(
|
||||
KenjinxNative.inputSetButtonPressed(
|
||||
GamePadButtonInputId.DpadRight.ordinal,
|
||||
controllerId
|
||||
)
|
||||
|
|
@ -125,7 +125,7 @@ class PhysicalControllerManager(val activity: MainActivity) {
|
|||
}
|
||||
|
||||
fun connect(): Int {
|
||||
controllerId = KenjinxNative.jnaInstance.inputConnectGamepad(0)
|
||||
controllerId = KenjinxNative.inputConnectGamepad(0)
|
||||
return controllerId
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ class UiHandler {
|
|||
var message: String = ""
|
||||
|
||||
init {
|
||||
KenjinxNative.jnaInstance.uiHandlerSetup()
|
||||
KenjinxNative.uiHandlerSetup()
|
||||
}
|
||||
|
||||
fun update(
|
||||
|
|
@ -96,7 +96,7 @@ class UiHandler {
|
|||
|
||||
fun validate(): Boolean {
|
||||
if (inputText.value.isEmpty()) {
|
||||
validation.value = "Must be between ${minLength} and ${maxLength} characters"
|
||||
validation.value = "Must be between $minLength and $maxLength characters"
|
||||
} else {
|
||||
return inputText.value.length < minLength || inputText.value.length > maxLength
|
||||
}
|
||||
|
|
@ -120,7 +120,7 @@ class UiHandler {
|
|||
if (inputListener.value.length < minLength || inputListener.value.length > maxLength)
|
||||
return
|
||||
}
|
||||
KenjinxNative.jnaInstance.uiHandlerSetResponse(
|
||||
KenjinxNative.uiHandlerSetResponse(
|
||||
true,
|
||||
if (type == 2) inputListener.value else ""
|
||||
)
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ class DlcViewModel(val titleId: String) {
|
|||
|
||||
if (!isDuplicate) {
|
||||
val contents =
|
||||
KenjinxNative.jnaInstance.deviceGetDlcContentList(
|
||||
KenjinxNative.deviceGetDlcContentList(
|
||||
path,
|
||||
titleId.toLong(16)
|
||||
)
|
||||
|
|
@ -118,7 +118,7 @@ class DlcViewModel(val titleId: String) {
|
|||
container.dlc_nca_list.add(
|
||||
DlcContainer(
|
||||
true,
|
||||
KenjinxNative.jnaInstance.deviceGetDlcTitleId(
|
||||
KenjinxNative.deviceGetDlcTitleId(
|
||||
contentPath,
|
||||
content
|
||||
).toLong(16),
|
||||
|
|
@ -172,7 +172,7 @@ class DlcViewModel(val titleId: String) {
|
|||
enabled,
|
||||
containerPath,
|
||||
dlc.path,
|
||||
KenjinxNative.jnaInstance.deviceGetDlcTitleId(
|
||||
KenjinxNative.deviceGetDlcTitleId(
|
||||
containerPath,
|
||||
dlc.path
|
||||
)
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ class GameModel(var file: DocumentFile, val context: Context) {
|
|||
fun getGameInfo() {
|
||||
val pid = open()
|
||||
val gameInfo = GameInfo()
|
||||
KenjinxNative.jnaInstance.deviceGetGameInfo(pid, file.extension, gameInfo)
|
||||
KenjinxNative.deviceGetGameInfo(pid, file.extension, gameInfo)
|
||||
close()
|
||||
|
||||
fileSize = gameInfo.FileSize
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import org.kenjinx.android.PerformanceManager
|
|||
import org.kenjinx.android.PhysicalControllerManager
|
||||
import org.kenjinx.android.RegionCode
|
||||
import org.kenjinx.android.KenjinxNative
|
||||
import org.kenjinx.android.PerformanceMonitor
|
||||
import org.kenjinx.android.SystemLanguage
|
||||
import org.kenjinx.android.UiHandler
|
||||
import java.io.File
|
||||
|
|
@ -62,20 +63,20 @@ class MainViewModel(val activity: MainActivity) {
|
|||
}
|
||||
|
||||
fun refreshFirmwareVersion() {
|
||||
firmwareVersion = KenjinxNative.jnaInstance.deviceGetInstalledFirmwareVersion()
|
||||
firmwareVersion = KenjinxNative.deviceGetInstalledFirmwareVersion()
|
||||
}
|
||||
|
||||
fun closeGame() {
|
||||
KenjinxNative.jnaInstance.deviceSignalEmulationClose()
|
||||
KenjinxNative.deviceSignalEmulationClose()
|
||||
gameHost?.close()
|
||||
KenjinxNative.jnaInstance.deviceCloseEmulation()
|
||||
KenjinxNative.deviceCloseEmulation()
|
||||
motionSensorManager?.unregister()
|
||||
physicalControllerManager?.disconnect()
|
||||
motionSensorManager?.setControllerId(-1)
|
||||
}
|
||||
|
||||
fun loadGame(game: GameModel, overrideSettings: Boolean? = false, forceNceAndPptc: Boolean? = false): Int {
|
||||
KenjinxNative.jnaInstance.deviceReinitEmulation()
|
||||
KenjinxNative.deviceReinitEmulation()
|
||||
MainActivity.mainViewModel?.activity?.uiHandler = UiHandler()
|
||||
|
||||
val descriptor = game.open()
|
||||
|
|
@ -100,7 +101,7 @@ class MainViewModel(val activity: MainActivity) {
|
|||
settings.overrideSettings(forceNceAndPptc);
|
||||
}
|
||||
|
||||
var success = KenjinxNative.jnaInstance.graphicsInitialize(
|
||||
var success = KenjinxNative.graphicsInitialize(
|
||||
enableMacroHLE = settings.enableMacroHLE,
|
||||
enableShaderCache = settings.enableShaderCache,
|
||||
enableTextureRecompression = settings.enableTextureRecompression,
|
||||
|
|
@ -156,7 +157,7 @@ class MainViewModel(val activity: MainActivity) {
|
|||
|
||||
val extensions = nativeInterop.VkRequiredExtensions
|
||||
|
||||
success = KenjinxNative.jnaInstance.graphicsInitializeRenderer(
|
||||
success = KenjinxNative.graphicsInitializeRenderer(
|
||||
extensions!!,
|
||||
extensions.size,
|
||||
driverHandle
|
||||
|
|
@ -169,7 +170,7 @@ class MainViewModel(val activity: MainActivity) {
|
|||
semaphore.acquire()
|
||||
launchOnUiThread {
|
||||
// We are only able to initialize the emulation context on the main thread
|
||||
success = KenjinxNative.jnaInstance.deviceInitialize(
|
||||
success = KenjinxNative.deviceInitialize(
|
||||
settings.memoryManagerMode.ordinal,
|
||||
settings.useNce,
|
||||
settings.memoryConfiguration.ordinal,
|
||||
|
|
@ -194,7 +195,7 @@ class MainViewModel(val activity: MainActivity) {
|
|||
if (!success)
|
||||
return 0
|
||||
|
||||
success = KenjinxNative.jnaInstance.deviceLoadDescriptor(descriptor, game.type.ordinal, update)
|
||||
success = KenjinxNative.deviceLoadDescriptor(descriptor, game.type.ordinal, update)
|
||||
|
||||
return if (success) 1 else 0
|
||||
}
|
||||
|
|
@ -205,7 +206,7 @@ class MainViewModel(val activity: MainActivity) {
|
|||
|
||||
val settings = QuickSettings(activity)
|
||||
|
||||
var success = KenjinxNative.jnaInstance.graphicsInitialize(
|
||||
var success = KenjinxNative.graphicsInitialize(
|
||||
enableMacroHLE = settings.enableMacroHLE,
|
||||
enableShaderCache = settings.enableShaderCache,
|
||||
enableTextureRecompression = settings.enableTextureRecompression,
|
||||
|
|
@ -262,7 +263,7 @@ class MainViewModel(val activity: MainActivity) {
|
|||
|
||||
val extensions = nativeInterop.VkRequiredExtensions
|
||||
|
||||
success = KenjinxNative.jnaInstance.graphicsInitializeRenderer(
|
||||
success = KenjinxNative.graphicsInitializeRenderer(
|
||||
extensions!!,
|
||||
extensions.size,
|
||||
driverHandle
|
||||
|
|
@ -275,7 +276,7 @@ class MainViewModel(val activity: MainActivity) {
|
|||
semaphore.acquire()
|
||||
launchOnUiThread {
|
||||
// We are only able to initialize the emulation context on the main thread
|
||||
success = KenjinxNative.jnaInstance.deviceInitialize(
|
||||
success = KenjinxNative.deviceInitialize(
|
||||
settings.memoryManagerMode.ordinal,
|
||||
settings.useNce,
|
||||
settings.memoryConfiguration.ordinal,
|
||||
|
|
@ -300,7 +301,7 @@ class MainViewModel(val activity: MainActivity) {
|
|||
if (!success)
|
||||
return false
|
||||
|
||||
success = KenjinxNative.jnaInstance.deviceLaunchMiiEditor()
|
||||
success = KenjinxNative.deviceLaunchMiiEditor()
|
||||
|
||||
return success
|
||||
}
|
||||
|
|
@ -399,13 +400,13 @@ class MainViewModel(val activity: MainActivity) {
|
|||
}
|
||||
usedMemState?.let { usedMem ->
|
||||
totalMemState?.let { totalMem ->
|
||||
MainActivity.performanceMonitor.getMemoryUsage(
|
||||
PerformanceMonitor.getMemoryUsage(
|
||||
usedMem,
|
||||
totalMem
|
||||
)
|
||||
}
|
||||
}
|
||||
frequenciesState?.let { MainActivity.performanceMonitor.getFrequencies(it) }
|
||||
frequenciesState?.let { PerformanceMonitor.getFrequencies(it) }
|
||||
}
|
||||
|
||||
fun setGameController(controller: GameController) {
|
||||
|
|
|
|||
|
|
@ -173,15 +173,15 @@ class SettingsViewModel(val activity: MainActivity) {
|
|||
editor.apply()
|
||||
activity.storageHelper!!.onFolderSelected = previousFolderCallback
|
||||
|
||||
KenjinxNative.jnaInstance.loggingSetEnabled(LogLevel.Info.ordinal, enableInfoLogs.value)
|
||||
KenjinxNative.jnaInstance.loggingSetEnabled(LogLevel.Stub.ordinal, enableStubLogs.value)
|
||||
KenjinxNative.jnaInstance.loggingSetEnabled(LogLevel.Warning.ordinal, enableWarningLogs.value)
|
||||
KenjinxNative.jnaInstance.loggingSetEnabled(LogLevel.Error.ordinal, enableErrorLogs.value)
|
||||
KenjinxNative.jnaInstance.loggingSetEnabled(LogLevel.AccessLog.ordinal, enableFsAccessLogs.value)
|
||||
KenjinxNative.jnaInstance.loggingSetEnabled(LogLevel.Guest.ordinal, enableGuestLogs.value)
|
||||
KenjinxNative.jnaInstance.loggingSetEnabled(LogLevel.Trace.ordinal, enableTraceLogs.value)
|
||||
KenjinxNative.jnaInstance.loggingSetEnabled(LogLevel.Debug.ordinal, enableDebugLogs.value)
|
||||
KenjinxNative.jnaInstance.loggingEnabledGraphicsLog(enableGraphicsLogs.value)
|
||||
KenjinxNative.loggingSetEnabled(LogLevel.Info, enableInfoLogs.value)
|
||||
KenjinxNative.loggingSetEnabled(LogLevel.Stub, enableStubLogs.value)
|
||||
KenjinxNative.loggingSetEnabled(LogLevel.Warning, enableWarningLogs.value)
|
||||
KenjinxNative.loggingSetEnabled(LogLevel.Error, enableErrorLogs.value)
|
||||
KenjinxNative.loggingSetEnabled(LogLevel.AccessLog, enableFsAccessLogs.value)
|
||||
KenjinxNative.loggingSetEnabled(LogLevel.Guest, enableGuestLogs.value)
|
||||
KenjinxNative.loggingSetEnabled(LogLevel.Trace, enableTraceLogs.value)
|
||||
KenjinxNative.loggingSetEnabled(LogLevel.Debug, enableDebugLogs.value)
|
||||
KenjinxNative.loggingEnabledGraphicsLog(enableGraphicsLogs.value)
|
||||
}
|
||||
|
||||
fun openGameFolder() {
|
||||
|
|
@ -236,7 +236,7 @@ class SettingsViewModel(val activity: MainActivity) {
|
|||
outputFolder,
|
||||
callback = object : FileCallback() {
|
||||
override fun onCompleted(result: Any) {
|
||||
KenjinxNative.jnaInstance.deviceReloadFilesystem()
|
||||
KenjinxNative.deviceReloadFilesystem()
|
||||
installState.value = KeyInstallState.Done
|
||||
}
|
||||
}
|
||||
|
|
@ -264,7 +264,7 @@ class SettingsViewModel(val activity: MainActivity) {
|
|||
Thread.sleep(1000)
|
||||
val descriptor = activity.contentResolver.openFileDescriptor(file.uri, "rw")
|
||||
descriptor?.use { d ->
|
||||
selectedFirmwareVersion = KenjinxNative.jnaInstance.deviceVerifyFirmware(d.fd, extension == "xci")
|
||||
selectedFirmwareVersion = KenjinxNative.deviceVerifyFirmware(d.fd, extension == "xci")
|
||||
selectedFirmwareFile = file
|
||||
if (!selectedFirmwareVersion.isEmpty()) {
|
||||
installState.value = FirmwareInstallState.Query
|
||||
|
|
@ -299,7 +299,7 @@ class SettingsViewModel(val activity: MainActivity) {
|
|||
Thread.sleep(1000)
|
||||
|
||||
try {
|
||||
KenjinxNative.jnaInstance.deviceInstallFirmware(descriptor.fd,extension == "xci")
|
||||
KenjinxNative.deviceInstallFirmware(descriptor.fd,extension == "xci")
|
||||
} finally {
|
||||
MainActivity.mainViewModel?.refreshFirmwareVersion()
|
||||
installState.value = FirmwareInstallState.Done
|
||||
|
|
@ -361,7 +361,7 @@ class SettingsViewModel(val activity: MainActivity) {
|
|||
}
|
||||
} finally {
|
||||
dataImportState.value = DataImportState.Done
|
||||
KenjinxNative.jnaInstance.deviceReloadFilesystem()
|
||||
KenjinxNative.deviceReloadFilesystem()
|
||||
MainActivity.mainViewModel?.refreshFirmwareVersion()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,24 +15,24 @@ class UserViewModel {
|
|||
userList.clear()
|
||||
val decoder = Base64.getDecoder()
|
||||
openedUser = UserModel()
|
||||
openedUser.id = KenjinxNative.jnaInstance.userGetOpenedUser()
|
||||
openedUser.id = KenjinxNative.userGetOpenedUser()
|
||||
if (openedUser.id.isNotEmpty()) {
|
||||
openedUser.username = KenjinxNative.jnaInstance.userGetUserName(openedUser.id)
|
||||
openedUser.username = KenjinxNative.userGetUserName(openedUser.id)
|
||||
openedUser.userPicture = decoder.decode(
|
||||
KenjinxNative.jnaInstance.userGetUserPicture(
|
||||
KenjinxNative.userGetUserPicture(
|
||||
openedUser.id
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
val users = KenjinxNative.jnaInstance.userGetAllUsers()
|
||||
val users = KenjinxNative.userGetAllUsers()
|
||||
for (user in users) {
|
||||
userList.add(
|
||||
UserModel(
|
||||
user,
|
||||
KenjinxNative.jnaInstance.userGetUserName(user),
|
||||
KenjinxNative.userGetUserName(user),
|
||||
decoder.decode(
|
||||
KenjinxNative.jnaInstance.userGetUserPicture(user)
|
||||
KenjinxNative.userGetUserPicture(user)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
|
@ -40,7 +40,7 @@ class UserViewModel {
|
|||
}
|
||||
|
||||
fun openUser(userModel: UserModel) {
|
||||
KenjinxNative.jnaInstance.userOpenUser(userModel.id)
|
||||
KenjinxNative.userOpenUser(userModel.id)
|
||||
|
||||
refreshUsers()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -130,19 +130,19 @@ class GameViews {
|
|||
|
||||
when (event.type) {
|
||||
PointerEventType.Press -> {
|
||||
KenjinxNative.jnaInstance.inputSetTouchPoint(
|
||||
KenjinxNative.inputSetTouchPoint(
|
||||
position.x.roundToInt(),
|
||||
position.y.roundToInt()
|
||||
)
|
||||
}
|
||||
|
||||
PointerEventType.Release -> {
|
||||
KenjinxNative.jnaInstance.inputReleaseTouchPoint()
|
||||
KenjinxNative.inputReleaseTouchPoint()
|
||||
|
||||
}
|
||||
|
||||
PointerEventType.Move -> {
|
||||
KenjinxNative.jnaInstance.inputSetTouchPoint(
|
||||
KenjinxNative.inputSetTouchPoint(
|
||||
position.x.roundToInt(),
|
||||
position.y.roundToInt()
|
||||
)
|
||||
|
|
@ -188,7 +188,7 @@ class GameViews {
|
|||
IconButton(modifier = Modifier.padding(4.dp), onClick = {
|
||||
showMore.value = false
|
||||
showController.value = !showController.value
|
||||
KenjinxNative.jnaInstance.inputReleaseTouchPoint()
|
||||
KenjinxNative.inputReleaseTouchPoint()
|
||||
mainViewModel.controller?.setVisible(showController.value)
|
||||
}) {
|
||||
Icon(
|
||||
|
|
@ -207,7 +207,7 @@ class GameViews {
|
|||
{
|
||||
vSyncMode.value= VSyncMode.Switch
|
||||
}
|
||||
KenjinxNative.jnaInstance.graphicsRendererSetVsync(
|
||||
KenjinxNative.graphicsRendererSetVsync(
|
||||
vSyncMode.value.ordinal
|
||||
)
|
||||
}) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue