Skip to content

Commit

Permalink
Fix possible crash when removing gamepads. Bump versionCode.
Browse files Browse the repository at this point in the history
  • Loading branch information
Swordfish90 committed Oct 19, 2020
1 parent bc1eaba commit 3986b91
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lemuroid-app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ plugins {
android {
defaultConfig {
applicationId = "com.swordfish.lemuroid"
versionCode = 88
versionCode = 90
versionName = "1.7.1"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ abstract class BaseGameActivity : ImmersiveActivity() {
)
.map { (ports, bindings, event) ->
val port = ports(event.device)
val bindKeyCode = bindings[event.device]?.get(event.keyCode) ?: event.keyCode
val bindKeyCode = bindings(event.device)[event.keyCode] ?: event.keyCode
Triple(event.action, port, bindKeyCode)
}
.share()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,23 @@ class GamePadManager(context: Context) {
return PreferenceManager.getDefaultSharedPreferences(context)
}

fun getGamePadsBindingsObservable(): Observable<Map<InputDevice, Map<Int, Int>>> {
fun getGamePadsBindingsObservable(): Observable<(InputDevice?)->Map<Int, Int>> {
return getGamePadsObservable()
.flatMapSingle { inputDevices ->
Observable.fromIterable(inputDevices).flatMapSingle { inputDevice ->
getBindings(inputDevice).map { inputDevice to it }
}.toList()
}
.map { it.toMap() }
.map { bindings -> { bindings[it] ?: mapOf() } }
}

fun getGamePadsPortMapperObservable(): Observable<(InputDevice)->Int> {
fun getGamePadsPortMapperObservable(): Observable<(InputDevice?)->Int> {
return getGamePadsObservable().map { gamePads ->
val portMappings = gamePads
.mapIndexed { index, inputDevice -> inputDevice.controllerNumber to index }
.toMap()
return@map { inputDevice: InputDevice -> portMappings[inputDevice.controllerNumber] ?: 0 }
return@map { inputDevice -> portMappings[inputDevice?.controllerNumber] ?: 0 }
}
}

Expand Down

0 comments on commit 3986b91

Please sign in to comment.