feat: add guided manual controller mapping
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
# NESLite
|
# NESLite
|
||||||
|
|
||||||
NESLite 是一个面向 Android 的轻量 NES/FC 模拟器前端。它使用固定版本的
|
NESLite 是一个面向 Android 的轻量 NES/FC 模拟器前端。它使用固定版本的
|
||||||
FCEUmm libretro 内核。当前仓库已准备 0.9.6 候选基线的冻结样本、输入延迟指标、升级架构、原生对齐审计
|
FCEUmm libretro 内核。当前仓库已准备 0.9.7 候选基线的冻结样本、输入延迟指标、升级架构、原生对齐审计
|
||||||
和候选交付脚本;荣耀 Magic8 与 X5 Lite 已由截图确认枚举,但手机未开放 ADB,且发布签名和可观察
|
和候选交付脚本;荣耀 Magic8 与 X5 Lite 已由截图确认枚举,但手机未开放 ADB,且发布签名和可观察
|
||||||
玩法的合法 ROM 样本尚未提供,因此 M2~M8 的完整实机验收及 G8 仍待补齐。
|
玩法的合法 ROM 样本尚未提供,因此 M2~M8 的完整实机验收及 G8 仍待补齐。
|
||||||
|
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ android {
|
|||||||
applicationId = "org.neslite.app"
|
applicationId = "org.neslite.app"
|
||||||
minSdk = 28
|
minSdk = 28
|
||||||
targetSdk = 36
|
targetSdk = 36
|
||||||
versionCode = 9006
|
versionCode = 9007
|
||||||
versionName = "0.9.6"
|
versionName = "0.9.7"
|
||||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
|
||||||
ndk {
|
ndk {
|
||||||
|
|||||||
@@ -150,6 +150,8 @@ class MainActivity : ComponentActivity(), InputManager.InputDeviceListener {
|
|||||||
private var selectedControllerId: Int? = null
|
private var selectedControllerId: Int? = null
|
||||||
private var draftProfile: ControllerProfile? = null
|
private var draftProfile: ControllerProfile? = null
|
||||||
private var pendingBindingAction: GameAction? = null
|
private var pendingBindingAction: GameAction? = null
|
||||||
|
private var manualMappingIndex: Int? = null
|
||||||
|
private var bindingCaptureWaitForNeutral = false
|
||||||
private var controllerSettingsMessage = "选择动作后按一个手柄键或推动一个轴。"
|
private var controllerSettingsMessage = "选择动作后按一个手柄键或推动一个轴。"
|
||||||
private var settingsReturnToPause = false
|
private var settingsReturnToPause = false
|
||||||
private var controllerReturnToSettings = false
|
private var controllerReturnToSettings = false
|
||||||
@@ -557,6 +559,7 @@ class MainActivity : ComponentActivity(), InputManager.InputDeviceListener {
|
|||||||
repeatCount = event.repeatCount,
|
repeatCount = event.repeatCount,
|
||||||
)
|
)
|
||||||
if (pendingBindingAction != null && event.action == KeyEvent.ACTION_DOWN && event.repeatCount == 0) {
|
if (pendingBindingAction != null && event.action == KeyEvent.ACTION_DOWN && event.repeatCount == 0) {
|
||||||
|
bindingCaptureWaitForNeutral = false
|
||||||
captureBinding(InputBinding(BindingKind.KEY, event.keyCode))
|
captureBinding(InputBinding(BindingKind.KEY, event.keyCode))
|
||||||
renderInputState()
|
renderInputState()
|
||||||
return true
|
return true
|
||||||
@@ -607,11 +610,24 @@ class MainActivity : ComponentActivity(), InputManager.InputDeviceListener {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (pendingBindingAction != null) {
|
if (pendingBindingAction != null) {
|
||||||
|
if (bindingCaptureWaitForNeutral) {
|
||||||
|
val released = ranges.all { range ->
|
||||||
|
kotlin.math.abs(event.getAxisValue(range.axis)) <= profile.releaseThreshold
|
||||||
|
}
|
||||||
|
if (released) {
|
||||||
|
bindingCaptureWaitForNeutral = false
|
||||||
|
controllerSettingsMessage = manualMappingPrompt()
|
||||||
|
renderControllerSettings()
|
||||||
|
}
|
||||||
|
renderInputState()
|
||||||
|
return true
|
||||||
|
}
|
||||||
ranges
|
ranges
|
||||||
.map { range -> range to event.getAxisValue(range.axis) }
|
.map { range -> range to event.getAxisValue(range.axis) }
|
||||||
.filter { (_, value) -> kotlin.math.abs(value) >= profile.pressThreshold }
|
.filter { (_, value) -> kotlin.math.abs(value) >= profile.pressThreshold }
|
||||||
.maxByOrNull { (_, value) -> kotlin.math.abs(value) }
|
.maxByOrNull { (_, value) -> kotlin.math.abs(value) }
|
||||||
?.let { (range, value) ->
|
?.let { (range, value) ->
|
||||||
|
bindingCaptureWaitForNeutral = true
|
||||||
captureBinding(
|
captureBinding(
|
||||||
InputBinding(
|
InputBinding(
|
||||||
if (value < 0f) BindingKind.AXIS_NEGATIVE else BindingKind.AXIS_POSITIVE,
|
if (value < 0f) BindingKind.AXIS_NEGATIVE else BindingKind.AXIS_POSITIVE,
|
||||||
@@ -1052,7 +1068,7 @@ class MainActivity : ComponentActivity(), InputManager.InputDeviceListener {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
settingsPanel.addView(Button(this).apply {
|
settingsPanel.addView(Button(this).apply {
|
||||||
text = "手柄映射、A/B 交换与死区"
|
text = "手动设置手柄按键、摇杆与功能键"
|
||||||
setOnClickListener {
|
setOnClickListener {
|
||||||
showControllerSettings(returnToPause = false, returnToSettings = true)
|
showControllerSettings(returnToPause = false, returnToSettings = true)
|
||||||
}
|
}
|
||||||
@@ -1210,7 +1226,9 @@ class MainActivity : ComponentActivity(), InputManager.InputDeviceListener {
|
|||||||
currentOverlayPage == OverlayPage.DIAGNOSTICS
|
currentOverlayPage == OverlayPage.DIAGNOSTICS
|
||||||
draftProfile = selectedControllerId?.let(controllerProfiles::get)
|
draftProfile = selectedControllerId?.let(controllerProfiles::get)
|
||||||
pendingBindingAction = null
|
pendingBindingAction = null
|
||||||
controllerSettingsMessage = "选择动作后按一个手柄键或推动一个轴。"
|
manualMappingIndex = null
|
||||||
|
bindingCaptureWaitForNeutral = false
|
||||||
|
controllerSettingsMessage = "可逐项设置全部按键,也可以点击任意动作单独修改。"
|
||||||
showOverlayPage(OverlayPage.CONTROLLER_SETTINGS, "手柄按键设置")
|
showOverlayPage(OverlayPage.CONTROLLER_SETTINGS, "手柄按键设置")
|
||||||
renderControllerSettings()
|
renderControllerSettings()
|
||||||
}
|
}
|
||||||
@@ -1219,6 +1237,8 @@ class MainActivity : ComponentActivity(), InputManager.InputDeviceListener {
|
|||||||
val returnToSettings = showPreviousMenu && controllerReturnToSettings && ::settingsPanel.isInitialized
|
val returnToSettings = showPreviousMenu && controllerReturnToSettings && ::settingsPanel.isInitialized
|
||||||
val settingsShouldReturnToPause = settingsReturnToPause
|
val settingsShouldReturnToPause = settingsReturnToPause
|
||||||
pendingBindingAction = null
|
pendingBindingAction = null
|
||||||
|
manualMappingIndex = null
|
||||||
|
bindingCaptureWaitForNeutral = false
|
||||||
draftProfile = null
|
draftProfile = null
|
||||||
clearControllerState()
|
clearControllerState()
|
||||||
if (returnToSettings) showSettingsPage()
|
if (returnToSettings) showSettingsPage()
|
||||||
@@ -1248,6 +1268,9 @@ class MainActivity : ComponentActivity(), InputManager.InputDeviceListener {
|
|||||||
controllerSettingsPanel.addView(
|
controllerSettingsPanel.addView(
|
||||||
body("${controller.name}\n档案:${profile.origin} · ${profile.fingerprint.take(12)};不使用临时 deviceId 持久化"),
|
body("${controller.name}\n档案:${profile.origin} · ${profile.fingerprint.take(12)};不使用临时 deviceId 持久化"),
|
||||||
)
|
)
|
||||||
|
controllerSettingsPanel.addView(
|
||||||
|
body("设置方法:点击一个动作,然后按下希望使用的手柄按键,或将摇杆/方向轴推到对应方向。修改完成后点击保存。"),
|
||||||
|
)
|
||||||
if (controllers.size > 1) {
|
if (controllers.size > 1) {
|
||||||
controllerSettingsPanel.addView(Button(this).apply {
|
controllerSettingsPanel.addView(Button(this).apply {
|
||||||
text = "切换到下一个手柄"
|
text = "切换到下一个手柄"
|
||||||
@@ -1256,11 +1279,42 @@ class MainActivity : ComponentActivity(), InputManager.InputDeviceListener {
|
|||||||
selectedControllerId = controllers[(index + 1).mod(controllers.size)].deviceId
|
selectedControllerId = controllers[(index + 1).mod(controllers.size)].deviceId
|
||||||
draftProfile = selectedControllerId?.let(controllerProfiles::get)
|
draftProfile = selectedControllerId?.let(controllerProfiles::get)
|
||||||
pendingBindingAction = null
|
pendingBindingAction = null
|
||||||
|
manualMappingIndex = null
|
||||||
|
bindingCaptureWaitForNeutral = false
|
||||||
renderControllerSettings()
|
renderControllerSettings()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
controllerSettingsPanel.addView(body(controllerSettingsMessage))
|
val hasUnsavedChanges = profile != controllerProfiles[deviceId]
|
||||||
|
controllerSettingsPanel.addView(
|
||||||
|
body(
|
||||||
|
controllerSettingsMessage +
|
||||||
|
if (hasUnsavedChanges) "\n● 有尚未保存的修改" else "\n当前设置已保存",
|
||||||
|
).apply {
|
||||||
|
setTextColor(Color.WHITE)
|
||||||
|
setPadding(dp(14), dp(10), dp(14), dp(10))
|
||||||
|
background = roundedBackground(Color.rgb(72, 55, 126), dp(10).toFloat())
|
||||||
|
},
|
||||||
|
)
|
||||||
|
controllerSettingsPanel.addView(Button(this).apply {
|
||||||
|
text = manualMappingIndex?.let { "逐项设置中:${it + 1}/${MANUAL_MAPPING_ACTIONS.size}" }
|
||||||
|
?: "开始逐项手动设置全部按键"
|
||||||
|
isEnabled = manualMappingIndex == null
|
||||||
|
setOnClickListener { startManualMapping() }
|
||||||
|
})
|
||||||
|
if (manualMappingIndex != null) {
|
||||||
|
controllerSettingsPanel.addView(LinearLayout(this).apply {
|
||||||
|
orientation = LinearLayout.HORIZONTAL
|
||||||
|
addView(Button(context).apply {
|
||||||
|
text = "跳过此项"
|
||||||
|
setOnClickListener { advanceManualMapping(skipped = true) }
|
||||||
|
})
|
||||||
|
addView(Button(context).apply {
|
||||||
|
text = "停止逐项设置"
|
||||||
|
setOnClickListener { stopManualMapping() }
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
controllerSettingsPanel.addView(Button(this).apply {
|
controllerSettingsPanel.addView(Button(this).apply {
|
||||||
text = if (profile.swapAB) "A/B 交换:开" else "A/B 交换:关"
|
text = if (profile.swapAB) "A/B 交换:开" else "A/B 交换:关"
|
||||||
setOnClickListener {
|
setOnClickListener {
|
||||||
@@ -1291,27 +1345,23 @@ class MainActivity : ComponentActivity(), InputManager.InputDeviceListener {
|
|||||||
renderControllerSettings()
|
renderControllerSettings()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
GameAction.entries.forEach { action ->
|
addMappingGroup("方向", listOf(GameAction.UP, GameAction.DOWN, GameAction.LEFT, GameAction.RIGHT), profile)
|
||||||
val description = profile.bindings[action].orEmpty().joinToString { binding ->
|
addMappingGroup(
|
||||||
binding.displayName(KeyEvent::keyCodeToString) { axis ->
|
"游戏按键",
|
||||||
MotionEvent.axisToString(axis) ?: "AXIS_$axis"
|
listOf(GameAction.NES_A, GameAction.NES_B, GameAction.TURBO_A, GameAction.TURBO_B),
|
||||||
}
|
profile,
|
||||||
}.ifEmpty { "未绑定" }
|
)
|
||||||
|
addMappingGroup(
|
||||||
|
"功能按键",
|
||||||
|
listOf(GameAction.START, GameAction.SELECT, GameAction.PAUSE_MENU, GameAction.FAST_FORWARD),
|
||||||
|
profile,
|
||||||
|
)
|
||||||
|
if (pendingBindingAction != null && manualMappingIndex == null) {
|
||||||
controllerSettingsPanel.addView(Button(this).apply {
|
controllerSettingsPanel.addView(Button(this).apply {
|
||||||
text = "${action.label}:$description"
|
text = "取消本次按键设置"
|
||||||
setOnClickListener {
|
|
||||||
clearControllerState()
|
|
||||||
pendingBindingAction = action
|
|
||||||
controllerSettingsMessage = "正在捕获“${action.label}”;按键、推动轴,或点击取消。"
|
|
||||||
renderControllerSettings()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if (pendingBindingAction != null) {
|
|
||||||
controllerSettingsPanel.addView(Button(this).apply {
|
|
||||||
text = "取消捕获"
|
|
||||||
setOnClickListener {
|
setOnClickListener {
|
||||||
pendingBindingAction = null
|
pendingBindingAction = null
|
||||||
|
bindingCaptureWaitForNeutral = false
|
||||||
controllerSettingsMessage = "已取消捕获,当前映射未改变。"
|
controllerSettingsMessage = "已取消捕获,当前映射未改变。"
|
||||||
clearControllerState()
|
clearControllerState()
|
||||||
renderControllerSettings()
|
renderControllerSettings()
|
||||||
@@ -1333,7 +1383,113 @@ class MainActivity : ComponentActivity(), InputManager.InputDeviceListener {
|
|||||||
setOnClickListener { resetControllerProfile() }
|
setOnClickListener { resetControllerProfile() }
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
focusFirstButton(controllerSettingsPanel)
|
if (pendingBindingAction == null) {
|
||||||
|
focusFirstButton(controllerSettingsPanel)
|
||||||
|
} else {
|
||||||
|
contentScroll.post { contentScroll.scrollTo(0, 0) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun addMappingGroup(title: String, actions: List<GameAction>, profile: ControllerProfile) {
|
||||||
|
controllerSettingsPanel.addView(section(title))
|
||||||
|
actions.forEach { action ->
|
||||||
|
val currentBindings = profile.bindings[action].orEmpty()
|
||||||
|
val description = currentBindings.joinToString { binding ->
|
||||||
|
binding.displayName(KeyEvent::keyCodeToString) { axis ->
|
||||||
|
MotionEvent.axisToString(axis) ?: "AXIS_$axis"
|
||||||
|
}
|
||||||
|
}.ifEmpty { "未绑定" }
|
||||||
|
controllerSettingsPanel.addView(LinearLayout(this).apply {
|
||||||
|
orientation = LinearLayout.HORIZONTAL
|
||||||
|
addView(
|
||||||
|
Button(context).apply {
|
||||||
|
text = if (pendingBindingAction == action) {
|
||||||
|
"${action.label}\n等待手柄输入…"
|
||||||
|
} else {
|
||||||
|
"${action.label}\n当前:$description\n点击修改"
|
||||||
|
}
|
||||||
|
setOnClickListener { beginSingleBinding(action) }
|
||||||
|
},
|
||||||
|
LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1f),
|
||||||
|
)
|
||||||
|
addView(Button(context).apply {
|
||||||
|
text = "清除"
|
||||||
|
isEnabled = currentBindings.isNotEmpty()
|
||||||
|
setOnClickListener { clearActionBinding(action) }
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun beginSingleBinding(action: GameAction) {
|
||||||
|
clearControllerState()
|
||||||
|
manualMappingIndex = null
|
||||||
|
bindingCaptureWaitForNeutral = false
|
||||||
|
pendingBindingAction = action
|
||||||
|
controllerSettingsMessage = "正在设置“${action.label}”:请按一个手柄键,或推动一个摇杆/方向轴。"
|
||||||
|
renderControllerSettings()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun clearActionBinding(action: GameAction) {
|
||||||
|
val profile = draftProfile ?: return
|
||||||
|
clearControllerState()
|
||||||
|
manualMappingIndex = null
|
||||||
|
pendingBindingAction = null
|
||||||
|
bindingCaptureWaitForNeutral = false
|
||||||
|
draftProfile = profile.clearBinding(action)
|
||||||
|
controllerSettingsMessage = "已清除“${action.label}”的映射;点击保存后生效。"
|
||||||
|
renderControllerSettings()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun startManualMapping() {
|
||||||
|
clearControllerState()
|
||||||
|
manualMappingIndex = 0
|
||||||
|
bindingCaptureWaitForNeutral = false
|
||||||
|
pendingBindingAction = MANUAL_MAPPING_ACTIONS.first()
|
||||||
|
controllerSettingsMessage = manualMappingPrompt()
|
||||||
|
renderControllerSettings()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun advanceManualMapping(skipped: Boolean = false) {
|
||||||
|
val current = manualMappingIndex ?: return
|
||||||
|
val completedAction = MANUAL_MAPPING_ACTIONS[current]
|
||||||
|
val next = current + 1
|
||||||
|
bindingCaptureWaitForNeutral = !skipped && bindingCaptureWaitForNeutral
|
||||||
|
if (next >= MANUAL_MAPPING_ACTIONS.size) {
|
||||||
|
manualMappingIndex = null
|
||||||
|
pendingBindingAction = null
|
||||||
|
bindingCaptureWaitForNeutral = false
|
||||||
|
controllerSettingsMessage = "逐项手动设置已完成;请检查映射并点击保存。"
|
||||||
|
} else {
|
||||||
|
manualMappingIndex = next
|
||||||
|
pendingBindingAction = MANUAL_MAPPING_ACTIONS[next]
|
||||||
|
controllerSettingsMessage = (if (skipped) "已跳过“${completedAction.label}”。\n" else "") +
|
||||||
|
manualMappingPrompt()
|
||||||
|
}
|
||||||
|
clearControllerState()
|
||||||
|
renderControllerSettings()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun stopManualMapping() {
|
||||||
|
val changed = draftProfile != selectedControllerId?.let(controllerProfiles::get)
|
||||||
|
manualMappingIndex = null
|
||||||
|
pendingBindingAction = null
|
||||||
|
bindingCaptureWaitForNeutral = false
|
||||||
|
clearControllerState()
|
||||||
|
controllerSettingsMessage = if (changed) {
|
||||||
|
"已停止逐项设置;已完成的修改仍可保存。"
|
||||||
|
} else {
|
||||||
|
"已停止逐项设置,当前映射未改变。"
|
||||||
|
}
|
||||||
|
renderControllerSettings()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun manualMappingPrompt(): String {
|
||||||
|
val index = manualMappingIndex ?: return "选择动作后按一个手柄键或推动一个轴。"
|
||||||
|
val action = MANUAL_MAPPING_ACTIONS[index]
|
||||||
|
val neutralHint = if (bindingCaptureWaitForNeutral) "请先松开摇杆/方向轴,再设置下一项。\n" else ""
|
||||||
|
return neutralHint +
|
||||||
|
"第 ${index + 1}/${MANUAL_MAPPING_ACTIONS.size} 项:正在设置“${action.label}”。请按对应手柄键或推动对应轴。"
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun focusFirstButton(container: ViewGroup) {
|
private fun focusFirstButton(container: ViewGroup) {
|
||||||
@@ -1369,7 +1525,12 @@ class MainActivity : ComponentActivity(), InputManager.InputDeviceListener {
|
|||||||
.setMessage("该输入已用于 ${conflicts.joinToString { it.label }}。是否移除旧绑定并改为 ${action.label}?")
|
.setMessage("该输入已用于 ${conflicts.joinToString { it.label }}。是否移除旧绑定并改为 ${action.label}?")
|
||||||
.setPositiveButton("替换") { _, _ -> finishBinding(profile, action, binding, replace = true) }
|
.setPositiveButton("替换") { _, _ -> finishBinding(profile, action, binding, replace = true) }
|
||||||
.setNegativeButton("取消") { _, _ ->
|
.setNegativeButton("取消") { _, _ ->
|
||||||
controllerSettingsMessage = "冲突未替换,映射保持不变。"
|
pendingBindingAction = action.takeIf { manualMappingIndex != null }
|
||||||
|
controllerSettingsMessage = if (manualMappingIndex != null) {
|
||||||
|
"冲突未替换。请换一个输入,或跳过当前项目。\n${manualMappingPrompt()}"
|
||||||
|
} else {
|
||||||
|
"冲突未替换,映射保持不变。"
|
||||||
|
}
|
||||||
clearControllerState()
|
clearControllerState()
|
||||||
renderControllerSettings()
|
renderControllerSettings()
|
||||||
}
|
}
|
||||||
@@ -1387,7 +1548,11 @@ class MainActivity : ComponentActivity(), InputManager.InputDeviceListener {
|
|||||||
) {
|
) {
|
||||||
val withoutConflict = if (replace) profile.removeBinding(binding, action) else profile
|
val withoutConflict = if (replace) profile.removeBinding(binding, action) else profile
|
||||||
draftProfile = withoutConflict.replaceBinding(action, binding)
|
draftProfile = withoutConflict.replaceBinding(action, binding)
|
||||||
controllerSettingsMessage = "已捕获 ${action.label};点击保存后生效。"
|
if (manualMappingIndex != null) {
|
||||||
|
advanceManualMapping()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
controllerSettingsMessage = "已设置 ${action.label};点击保存后生效。"
|
||||||
clearControllerState()
|
clearControllerState()
|
||||||
renderControllerSettings()
|
renderControllerSettings()
|
||||||
}
|
}
|
||||||
@@ -1395,9 +1560,12 @@ class MainActivity : ComponentActivity(), InputManager.InputDeviceListener {
|
|||||||
private fun saveControllerProfile() {
|
private fun saveControllerProfile() {
|
||||||
val deviceId = selectedControllerId ?: return
|
val deviceId = selectedControllerId ?: return
|
||||||
val profile = draftProfile?.copy(origin = ProfileOrigin.CUSTOM) ?: return
|
val profile = draftProfile?.copy(origin = ProfileOrigin.CUSTOM) ?: return
|
||||||
|
val previousProfile = controllerProfiles[deviceId]
|
||||||
controllerProfileRevisions[deviceId] = (controllerProfileRevisions[deviceId] ?: 0) + 1
|
controllerProfileRevisions[deviceId] = (controllerProfileRevisions[deviceId] ?: 0) + 1
|
||||||
controllerProfiles[deviceId] = profile
|
controllerProfiles[deviceId] = profile
|
||||||
pendingBindingAction = null
|
pendingBindingAction = null
|
||||||
|
manualMappingIndex = null
|
||||||
|
bindingCaptureWaitForNeutral = false
|
||||||
clearControllerState()
|
clearControllerState()
|
||||||
controllerScope.launch {
|
controllerScope.launch {
|
||||||
val result = runCatching { profileStore.save(profile) }
|
val result = runCatching { profileStore.save(profile) }
|
||||||
@@ -1406,7 +1574,9 @@ class MainActivity : ComponentActivity(), InputManager.InputDeviceListener {
|
|||||||
controllerSettingsMessage = if (result.isSuccess) {
|
controllerSettingsMessage = if (result.isSuccess) {
|
||||||
"设置已保存;重连和重启后按设备特征恢复。"
|
"设置已保存;重连和重启后按设备特征恢复。"
|
||||||
} else {
|
} else {
|
||||||
"保存失败:${result.exceptionOrNull()?.message ?: "未知错误"}"
|
if (previousProfile == null) controllerProfiles.remove(deviceId)
|
||||||
|
else controllerProfiles[deviceId] = previousProfile
|
||||||
|
"保存失败:${result.exceptionOrNull()?.message ?: "未知错误"};修改仍保留在页面,可重试保存。"
|
||||||
}
|
}
|
||||||
draftProfile = profile
|
draftProfile = profile
|
||||||
renderControllerSettings()
|
renderControllerSettings()
|
||||||
@@ -1422,6 +1592,8 @@ class MainActivity : ComponentActivity(), InputManager.InputDeviceListener {
|
|||||||
controllerProfiles[deviceId] = defaultProfile
|
controllerProfiles[deviceId] = defaultProfile
|
||||||
draftProfile = defaultProfile
|
draftProfile = defaultProfile
|
||||||
pendingBindingAction = null
|
pendingBindingAction = null
|
||||||
|
manualMappingIndex = null
|
||||||
|
bindingCaptureWaitForNeutral = false
|
||||||
clearControllerState()
|
clearControllerState()
|
||||||
controllerScope.launch {
|
controllerScope.launch {
|
||||||
val result = runCatching { profileStore.reset(identity) }
|
val result = runCatching { profileStore.reset(identity) }
|
||||||
@@ -2306,6 +2478,20 @@ class MainActivity : ComponentActivity(), InputManager.InputDeviceListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
private val MANUAL_MAPPING_ACTIONS = listOf(
|
||||||
|
GameAction.UP,
|
||||||
|
GameAction.DOWN,
|
||||||
|
GameAction.LEFT,
|
||||||
|
GameAction.RIGHT,
|
||||||
|
GameAction.NES_A,
|
||||||
|
GameAction.NES_B,
|
||||||
|
GameAction.TURBO_A,
|
||||||
|
GameAction.TURBO_B,
|
||||||
|
GameAction.START,
|
||||||
|
GameAction.SELECT,
|
||||||
|
GameAction.PAUSE_MENU,
|
||||||
|
GameAction.FAST_FORWARD,
|
||||||
|
)
|
||||||
private const val EVENT_LINES = 30
|
private const val EVENT_LINES = 30
|
||||||
private const val STATE_SESSION_ID = "active_session_id"
|
private const val STATE_SESSION_ID = "active_session_id"
|
||||||
private const val STATE_GAME_HASH = "active_game_hash"
|
private const val STATE_GAME_HASH = "active_game_hash"
|
||||||
|
|||||||
@@ -67,6 +67,11 @@ data class ControllerProfile(
|
|||||||
bindings = bindings + (action to setOf(binding)),
|
bindings = bindings + (action to setOf(binding)),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
fun clearBinding(action: GameAction): ControllerProfile = copy(
|
||||||
|
origin = ProfileOrigin.CUSTOM,
|
||||||
|
bindings = bindings + (action to emptySet()),
|
||||||
|
)
|
||||||
|
|
||||||
fun removeBinding(binding: InputBinding, except: GameAction): ControllerProfile = copy(
|
fun removeBinding(binding: InputBinding, except: GameAction): ControllerProfile = copy(
|
||||||
bindings = bindings.mapValues { (action, values) ->
|
bindings = bindings.mapValues { (action, values) ->
|
||||||
if (action == except) values else values - binding
|
if (action == except) values else values - binding
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ class BuildIdentityTest {
|
|||||||
@Test
|
@Test
|
||||||
fun debugBuildUsesTheDocumentedIdentity() {
|
fun debugBuildUsesTheDocumentedIdentity() {
|
||||||
assertEquals("org.neslite.app.debug", BuildConfig.APPLICATION_ID)
|
assertEquals("org.neslite.app.debug", BuildConfig.APPLICATION_ID)
|
||||||
assertEquals("0.9.6-debug", BuildConfig.VERSION_NAME)
|
assertEquals("0.9.7-debug", BuildConfig.VERSION_NAME)
|
||||||
assertEquals(9006, BuildConfig.VERSION_CODE)
|
assertEquals(9007, BuildConfig.VERSION_CODE)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,4 +54,15 @@ class ControllerProfileTest {
|
|||||||
assertEquals(swapped, decoded)
|
assertEquals(swapped, decoded)
|
||||||
assertFalse(JSONObject(ControllerProfileJson.encode(swapped)).has("deviceId"))
|
assertFalse(JSONObject(ControllerProfileJson.encode(swapped)).has("deviceId"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun manualMappingCanReplaceAndClearEachAction() {
|
||||||
|
val original = ControllerProfileResolver().resolve(identity)
|
||||||
|
val custom = InputBinding(BindingKind.KEY, 188)
|
||||||
|
val replaced = original.replaceBinding(GameAction.NES_A, custom)
|
||||||
|
|
||||||
|
assertEquals(setOf(custom), replaced.bindings[GameAction.NES_A])
|
||||||
|
assertEquals(ProfileOrigin.CUSTOM, replaced.origin)
|
||||||
|
assertTrue(replaced.clearBinding(GameAction.NES_A).bindings[GameAction.NES_A].orEmpty().isEmpty())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# NESLite 架构(0.9.6 候选基线)
|
# NESLite 架构(0.9.7 候选基线)
|
||||||
|
|
||||||
## 边界与线程
|
## 边界与线程
|
||||||
|
|
||||||
@@ -101,11 +101,15 @@ DataStore 保存,渲染线程只读取整数缩放和过滤快照,音频及
|
|||||||
按 pointerId 维护触摸来源并送入与物理手柄相同的 `InputRouter`,因此多来源去重、相反方向和释放规则
|
按 pointerId 维护触摸来源并送入与物理手柄相同的 `InputRouter`,因此多来源去重、相反方向和释放规则
|
||||||
一致;取消、滑出、失焦与暂停清空所有虚拟来源。首次使用状态也存于设置 DataStore,不接触用户存档。
|
一致;取消、滑出、失焦与暂停清空所有虚拟来源。首次使用状态也存于设置 DataStore,不接触用户存档。
|
||||||
|
|
||||||
0.9.6 将游戏入口收敛为单一横屏主画面:中央 `AspectRatioFrameLayout` 只按 4:3 测量,左右剩余安全
|
0.9.7 将游戏入口收敛为单一横屏主画面:中央 `AspectRatioFrameLayout` 只按 4:3 测量,左右剩余安全
|
||||||
区域绘制虚拟手柄;左侧固定入口打开游戏列表、导入和设置的全屏独立页面。X/Y 复用 M4 的 A/B 软件
|
区域绘制虚拟手柄;左侧固定入口打开游戏列表、导入和设置的全屏独立页面。X/Y 复用 M4 的 A/B 软件
|
||||||
连发动作;重置要求持续按住 650 ms。游戏页沉浸式隐藏系统栏,管理页恢复系统栏;页面打开前先等待
|
连发动作;重置要求持续按住 650 ms。游戏页沉浸式隐藏系统栏,管理页恢复系统栏;页面打开前先等待
|
||||||
运行会话进入暂停态,页面关闭后不自动恢复,避免文件选择或设置过程中游戏在后台继续。
|
运行会话进入暂停态,页面关闭后不自动恢复,避免文件选择或设置过程中游戏在后台继续。
|
||||||
|
|
||||||
|
手柄设置支持逐项向导和单项修改/清除。捕获目标动作后,物理 KeyEvent 或超过按下阈值的轴方向成为
|
||||||
|
该动作的唯一绑定;冲突必须由用户确认替换。轴捕获后必须先回到释放阈值内才进入下一项,防止同一
|
||||||
|
持续轴值误绑多个动作。草稿与正在使用的档案分离,仅保存成功后替换运行档案并按设备指纹持久化。
|
||||||
|
|
||||||
## M7 系统交接与诊断
|
## M7 系统交接与诊断
|
||||||
|
|
||||||
AndroidX 返回分发先把当前页面和会话状态归一成单一决策:设置/存档页回上级,暂停菜单返回会在
|
AndroidX 返回分发先把当前页面和会话状态归一成单一决策:设置/存档页回上级,暂停菜单返回会在
|
||||||
|
|||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
# NESLite 可复现构建说明
|
# NESLite 可复现构建说明
|
||||||
|
|
||||||
本说明对应 0.9.6 候选基线。命令使用系统默认 PowerShell 7.6.6(`pwsh`)从仓库根目录执行;不需要手工复制 `.so`、
|
本说明对应 0.9.7 候选基线。命令使用系统默认 PowerShell 7.6.6(`pwsh`)从仓库根目录执行;不需要手工复制 `.so`、
|
||||||
FCEUmm 或 Oboe 文件。
|
FCEUmm 或 Oboe 文件。
|
||||||
|
|
||||||
## 前置条件
|
## 前置条件
|
||||||
@@ -50,7 +50,7 @@ pwsh -NoProfile -ExecutionPolicy Bypass -File .\tools\package-rc.ps1
|
|||||||
|
|
||||||
脚本重跑 Stage 和 release lint,生成 `org.neslite.app` 的未签名 release APK、完整原生符号、应用及
|
脚本重跑 Stage 和 release lint,生成 `org.neslite.app` 的未签名 release APK、完整原生符号、应用及
|
||||||
三个固定第三方依赖的源码包、许可证/说明、静态原生审计、候选清单和 SHA-256。输出位于
|
三个固定第三方依赖的源码包、许可证/说明、静态原生审计、候选清单和 SHA-256。输出位于
|
||||||
`.build/rc-0.9.6/`。静态审计逐个检查 APK 内 `.so` 的 ELF LOAD 段和 APK 16 KB 对齐,并拒绝非
|
`.build/rc-0.9.7/`。静态审计逐个检查 APK 内 `.so` 的 ELF LOAD 段和 APK 16 KB 对齐,并拒绝非
|
||||||
arm64-v8a 库。
|
arm64-v8a 库。
|
||||||
|
|
||||||
默认 APK 刻意保持未签名;发布私钥和口令不得传入仓库或写入脚本。获得受保护的发布密钥后,在隔离
|
默认 APK 刻意保持未签名;发布私钥和口令不得传入仓库或写入脚本。获得受保护的发布密钥后,在隔离
|
||||||
|
|||||||
@@ -5,6 +5,10 @@
|
|||||||
ABXY、视图/菜单键及左右肩键。随后在荣耀 Magic8 页面取得了 Android 设备身份和静态轴范围;
|
ABXY、视图/菜单键及左右肩键。随后在荣耀 Magic8 页面取得了 Android 设备身份和静态轴范围;
|
||||||
实际 KeyEvent、动态轴采样、手柄模式及拔出重连仍待诊断 JSON 回填。
|
实际 KeyEvent、动态轴采样、手柄模式及拔出重连仍待诊断 JSON 回填。
|
||||||
|
|
||||||
|
在 0.9.7-debug 中可从“设置 → 手动设置手柄按键、摇杆与功能键”进入编辑页。可选择“开始逐项手动
|
||||||
|
设置全部按键”,按页面顺序操作 X5 Lite;也可点击任一动作单独修改或清除。轴方向捕获后先松回中位,
|
||||||
|
冲突时确认是否替换,最后点击“保存”。配置按下表设备指纹保存,不依赖临时 deviceId。
|
||||||
|
|
||||||
## 固定测试条件
|
## 固定测试条件
|
||||||
|
|
||||||
- 手柄模式:原生安卓模式,实际切换方法待随设备说明和实测确认。
|
- 手柄模式:原生安卓模式,实际切换方法待随设备说明和实测确认。
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@
|
|||||||
| --- | --- |
|
| --- | --- |
|
||||||
| 显示名称 | `NESLite` |
|
| 显示名称 | `NESLite` |
|
||||||
| 正式 application ID/namespace | `org.neslite.app` |
|
| 正式 application ID/namespace | `org.neslite.app` |
|
||||||
| 当前候选版本 | `0.9.6`,`versionCode = 9006` |
|
| 当前候选版本 | `0.9.7`,`versionCode = 9007` |
|
||||||
| 调试 application ID | `org.neslite.app.debug` |
|
| 调试 application ID | `org.neslite.app.debug` |
|
||||||
| 发布 ABI | `arm64-v8a` |
|
| 发布 ABI | `arm64-v8a` |
|
||||||
| min/target SDK | 28/36 |
|
| min/target SDK | 28/36 |
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# 已知问题与候选版限制
|
# 已知问题与候选版限制
|
||||||
|
|
||||||
本清单对应 0.9.6 候选源码。优先级含义:阻断表示 G8 不可通过;高表示发布前必须处理;中/低需有
|
本清单对应 0.9.7 候选源码。优先级含义:阻断表示 G8 不可通过;高表示发布前必须处理;中/低需有
|
||||||
明确接受或修复结论。
|
明确接受或修复结论。
|
||||||
|
|
||||||
| 编号 | 优先级 | 状态 | 问题与处理条件 |
|
| 编号 | 优先级 | 状态 | 问题与处理条件 |
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
| RC-B02 | 阻断 | 开放 | 尚无满足动作/滚屏、声音和可观察电池进度要求的合法游戏样本;冻结的 12 个 CC0 最小样本只能用于加载冒烟。 |
|
| RC-B02 | 阻断 | 开放 | 尚无满足动作/滚屏、声音和可观察电池进度要求的合法游戏样本;冻结的 12 个 CC0 最小样本只能用于加载冒烟。 |
|
||||||
| RC-B03 | 阻断 | 开放 | H-LONG、H-INPUT、4 KB/16 KB 运行、API 28 冒烟及 H-UPGRADE 尚未在设备执行。 |
|
| RC-B03 | 阻断 | 开放 | H-LONG、H-INPUT、4 KB/16 KB 运行、API 28 冒烟及 H-UPGRADE 尚未在设备执行。 |
|
||||||
| RC-B04 | 阻断 | 开放 | 尚未提供受保护的发布签名密钥及同 ID/同签名旧版数据集;当前 RC 静态审计包为未签名 APK。 |
|
| RC-B04 | 阻断 | 开放 | 尚未提供受保护的发布签名密钥及同 ID/同签名旧版数据集;当前 RC 静态审计包为未签名 APK。 |
|
||||||
| RC-M01 | 中 | 开放 | Debug lint 有 46 个非阻断警告,主要是动态界面文本国际化、依赖版本提示和 Android 16 固定横屏兼容提醒;无 lint 错误。 |
|
| RC-M01 | 中 | 开放 | Debug lint 有 45 个非阻断警告,主要是动态界面文本国际化、依赖版本提示和 Android 16 固定横屏兼容提醒;无 lint 错误。 |
|
||||||
|
|
||||||
不得通过删除失败 ROM、缩短规定轮数/时长、用 x86_64 替代 arm64,或用桌面原生测试替代 Android
|
不得通过删除失败 ROM、缩短规定轮数/时长、用 x86_64 替代 arm64,或用桌面原生测试替代 Android
|
||||||
实机运行来关闭阻断项。每项关闭时应在 M8 报告登记设备、包哈希、ROM 哈希、命令、原始日志和结论。
|
实机运行来关闭阻断项。每项关闭时应在 M8 报告登记设备、包哈希、ROM 哈希、命令、原始日志和结论。
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# M8 0.9.4 发布候选记录
|
# M8 0.9.4 发布候选记录
|
||||||
|
|
||||||
> 此文件保留 0.9.4 的历史候选证据。0.9.6 改动了主界面、触屏输入路径和页面/会话交接,不能直接
|
> 此文件保留 0.9.4 的历史候选证据。0.9.7 改动了主界面、触屏与手柄输入路径和页面/会话交接,不能
|
||||||
> 继承本记录作为最终 G8 结论;完成 Magic8 实机复核后需生成新的 0.9.6 候选记录。
|
> 直接继承本记录作为最终 G8 结论;完成 Magic8 实机复核后需生成新的 0.9.7 候选记录。
|
||||||
|
|
||||||
日期:2026-09-12
|
日期:2026-09-12
|
||||||
|
|
||||||
|
|||||||
+3
-2
@@ -8,8 +8,9 @@
|
|||||||
内容会恢复关联。
|
内容会恢复关联。
|
||||||
3. 点左侧“列表”,再点游戏条目;加载完成后会自动开始。连接外接手柄后仍可按设置选择是否显示
|
3. 点左侧“列表”,再点游戏条目;加载完成后会自动开始。连接外接手柄后仍可按设置选择是否显示
|
||||||
屏幕按键。多点触控支持方向与动作同时按住,滑出、取消、失焦或暂停都会释放输入。
|
屏幕按键。多点触控支持方向与动作同时按住,滑出、取消、失焦或暂停都会释放输入。
|
||||||
4. 点左侧“设置”可切换 4:3/整数缩放、最近邻/线性过滤、音量、静音、软件连发和 RB 快进,并进入
|
4. 点左侧“设置”可切换 4:3/整数缩放、最近邻/线性过滤、音量、静音、软件连发和 RB 快进。进入
|
||||||
手柄按键设置、A/B 交换、死区调整及设备诊断。设置会在重启后恢复。
|
“手动设置手柄按键、摇杆与功能键”后,可启动逐项向导,也可单独点击动作修改或清除;按下物理键
|
||||||
|
或推动轴完成捕获,检查无误后点“保存”。冲突会要求确认,设置按设备特征在重启和重连后恢复。
|
||||||
5. 游戏中点右侧“暂停”或按手柄右摇杆进入暂停菜单;“重置”需要持续按住约 650 ms,滑出会取消。
|
5. 游戏中点右侧“暂停”或按手柄右摇杆进入暂停菜单;“重置”需要持续按住约 650 ms,滑出会取消。
|
||||||
“存档管理”显示十个手动槽、三个自动恢复点、
|
“存档管理”显示十个手动槽、三个自动恢复点、
|
||||||
提交时间和缩略图。只有原生层确认安全落盘后才显示保存成功。
|
提交时间和缩略图。只有原生层确认安全落盘后才显示保存成功。
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ $env:JAVA_HOME = if ($env:JAVA_HOME -and (Test-Path (Join-Path $env:JAVA_HOME 'b
|
|||||||
}
|
}
|
||||||
$env:ANDROID_HOME = $sdkRoot
|
$env:ANDROID_HOME = $sdkRoot
|
||||||
$env:ANDROID_SDK_ROOT = $sdkRoot
|
$env:ANDROID_SDK_ROOT = $sdkRoot
|
||||||
$versionName = '0.9.6'
|
$versionName = '0.9.7'
|
||||||
$versionCode = 9006
|
$versionCode = 9007
|
||||||
$gitStatus = @(& git -C $root status --porcelain)
|
$gitStatus = @(& git -C $root status --porcelain)
|
||||||
if ($LASTEXITCODE -ne 0) { throw 'Cannot inspect the Git worktree.' }
|
if ($LASTEXITCODE -ne 0) { throw 'Cannot inspect the Git worktree.' }
|
||||||
if ($gitStatus.Count -ne 0) { throw 'RC packaging requires a clean committed worktree.' }
|
if ($gitStatus.Count -ne 0) { throw 'RC packaging requires a clean committed worktree.' }
|
||||||
|
|||||||
Reference in New Issue
Block a user