mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 05:09:34 -06:00
InputCommon/ControllerEmu: Break out functionality of EmulatedController
to eliminate redundant unused members in Wii Remote extension objects.
This commit is contained in:
@ -4,6 +4,19 @@ package org.dolphinemu.dolphinemu.features.input.model.controlleremu
|
||||
|
||||
import androidx.annotation.Keep
|
||||
|
||||
/**
|
||||
* Represents a C++ ControllerEmu::ControlGroupContainer.
|
||||
*
|
||||
* The lifetime of this class is managed by C++ code. Calling methods on it after it's destroyed
|
||||
* in C++ is undefined behavior!
|
||||
*/
|
||||
@Keep
|
||||
open class ControlGroupContainer constructor(private val pointer: Long) {
|
||||
external fun getGroupCount(): Int
|
||||
|
||||
external fun getGroup(index: Int): ControlGroup
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a C++ ControllerEmu::EmulatedController.
|
||||
*
|
||||
@ -11,15 +24,11 @@ import androidx.annotation.Keep
|
||||
* in C++ is undefined behavior!
|
||||
*/
|
||||
@Keep
|
||||
class EmulatedController private constructor(private val pointer: Long) {
|
||||
class EmulatedController private constructor(private val pointer: Long) : ControlGroupContainer(pointer) {
|
||||
external fun getDefaultDevice(): String
|
||||
|
||||
external fun setDefaultDevice(device: String)
|
||||
|
||||
external fun getGroupCount(): Int
|
||||
|
||||
external fun getGroup(index: Int): ControlGroup
|
||||
|
||||
external fun updateSingleControlReference(controlReference: ControlReference)
|
||||
|
||||
external fun loadDefaultSettings()
|
||||
@ -50,7 +59,7 @@ class EmulatedController private constructor(private val pointer: Long) {
|
||||
external fun getWiimoteAttachment(
|
||||
controllerIndex: Int,
|
||||
attachmentIndex: Int
|
||||
): EmulatedController
|
||||
): ControlGroupContainer
|
||||
|
||||
@JvmStatic
|
||||
external fun getSelectedWiimoteAttachment(controllerIndex: Int): Int
|
||||
|
@ -22,6 +22,7 @@ import org.dolphinemu.dolphinemu.features.input.model.InputMappingBooleanSetting
|
||||
import org.dolphinemu.dolphinemu.features.input.model.InputMappingDoubleSetting
|
||||
import org.dolphinemu.dolphinemu.features.input.model.InputMappingIntSetting
|
||||
import org.dolphinemu.dolphinemu.features.input.model.controlleremu.ControlGroup
|
||||
import org.dolphinemu.dolphinemu.features.input.model.controlleremu.ControlGroupContainer
|
||||
import org.dolphinemu.dolphinemu.features.input.model.controlleremu.EmulatedController
|
||||
import org.dolphinemu.dolphinemu.features.input.model.controlleremu.NumericSetting
|
||||
import org.dolphinemu.dolphinemu.features.input.model.view.InputDeviceSetting
|
||||
@ -2255,8 +2256,9 @@ class SettingsFragmentPresenter(
|
||||
wiimoteNumber: Int,
|
||||
extensionType: Int
|
||||
) {
|
||||
addControllerMappingSettings(
|
||||
addContainerMappingSettings(
|
||||
sl,
|
||||
EmulatedController.getWiimote(wiimoteNumber),
|
||||
EmulatedController.getWiimoteAttachment(wiimoteNumber, extensionType),
|
||||
null
|
||||
)
|
||||
@ -2404,15 +2406,32 @@ class SettingsFragmentPresenter(
|
||||
* @param groupTypeFilter If this is non-null, only groups whose types match this are considered.
|
||||
*/
|
||||
private fun addControllerMappingSettings(
|
||||
sl: ArrayList<SettingsItem>,
|
||||
controller: EmulatedController,
|
||||
groupTypeFilter: Set<Int>?
|
||||
) {
|
||||
addContainerMappingSettings(sl, controller, controller, groupTypeFilter)
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds mapping settings and other control-specific settings.
|
||||
*
|
||||
* @param sl The list to place controller settings into.
|
||||
* @param controller The encompassing controller.
|
||||
* @param container The container of control groups to add settings for.
|
||||
* @param groupTypeFilter If this is non-null, only groups whose types match this are considered.
|
||||
*/
|
||||
private fun addContainerMappingSettings(
|
||||
sl: ArrayList<SettingsItem>,
|
||||
controller: EmulatedController,
|
||||
container: ControlGroupContainer,
|
||||
groupTypeFilter: Set<Int>?
|
||||
) {
|
||||
updateOldControllerSettingsWarningVisibility(controller)
|
||||
|
||||
val groupCount = controller.getGroupCount()
|
||||
val groupCount = container.getGroupCount()
|
||||
for (i in 0 until groupCount) {
|
||||
val group = controller.getGroup(i)
|
||||
val group = container.getGroup(i)
|
||||
val groupType = group.getGroupType()
|
||||
if (groupTypeFilter != null && !groupTypeFilter.contains(groupType)) continue
|
||||
|
||||
|
Reference in New Issue
Block a user