|
|
@ -668,136 +668,136 @@ class InputOverlay(context: Context, attrs: AttributeSet?) : SurfaceView(context
|
|
|
|
R.integer.SWITCH_STICK_L_Y_FOLDABLE
|
|
|
|
R.integer.SWITCH_STICK_L_Y_FOLDABLE
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
private fun getResourceValue(descriptor: String, position: Int) : Float {
|
|
|
|
private fun getResourceValue(orientation: String, position: Int) : Float {
|
|
|
|
return when (descriptor) {
|
|
|
|
return when (orientation) {
|
|
|
|
PORTRAIT -> resources.getInteger(portraitResources[position]).toFloat() / 1000
|
|
|
|
PORTRAIT -> resources.getInteger(portraitResources[position]).toFloat() / 1000
|
|
|
|
FOLDABLE -> resources.getInteger(foldableResources[position]).toFloat() / 1000
|
|
|
|
FOLDABLE -> resources.getInteger(foldableResources[position]).toFloat() / 1000
|
|
|
|
else -> resources.getInteger(landscapeResources[position]).toFloat() / 1000
|
|
|
|
else -> resources.getInteger(landscapeResources[position]).toFloat() / 1000
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private fun defaultOverlayByLayout(descriptor: String) {
|
|
|
|
private fun defaultOverlayByLayout(orientation: String) {
|
|
|
|
// Each value represents the position of the button in relation to the screen size without insets.
|
|
|
|
// Each value represents the position of the button in relation to the screen size without insets.
|
|
|
|
preferences.edit()
|
|
|
|
preferences.edit()
|
|
|
|
.putFloat(
|
|
|
|
.putFloat(
|
|
|
|
ButtonType.BUTTON_A.toString() + "$descriptor-X",
|
|
|
|
ButtonType.BUTTON_A.toString() + "-X$orientation",
|
|
|
|
getResourceValue(descriptor, 0)
|
|
|
|
getResourceValue(orientation, 0)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.putFloat(
|
|
|
|
.putFloat(
|
|
|
|
ButtonType.BUTTON_A.toString() + "$descriptor-Y",
|
|
|
|
ButtonType.BUTTON_A.toString() + "-Y$orientation",
|
|
|
|
getResourceValue(descriptor, 1)
|
|
|
|
getResourceValue(orientation, 1)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.putFloat(
|
|
|
|
.putFloat(
|
|
|
|
ButtonType.BUTTON_B.toString() + "$descriptor-X",
|
|
|
|
ButtonType.BUTTON_B.toString() + "-X$orientation",
|
|
|
|
getResourceValue(descriptor, 2)
|
|
|
|
getResourceValue(orientation, 2)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.putFloat(
|
|
|
|
.putFloat(
|
|
|
|
ButtonType.BUTTON_B.toString() + "$descriptor-Y",
|
|
|
|
ButtonType.BUTTON_B.toString() + "-Y$orientation",
|
|
|
|
getResourceValue(descriptor, 3)
|
|
|
|
getResourceValue(orientation, 3)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.putFloat(
|
|
|
|
.putFloat(
|
|
|
|
ButtonType.BUTTON_X.toString() + "$descriptor-X",
|
|
|
|
ButtonType.BUTTON_X.toString() + "-X$orientation",
|
|
|
|
getResourceValue(descriptor, 4)
|
|
|
|
getResourceValue(orientation, 4)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.putFloat(
|
|
|
|
.putFloat(
|
|
|
|
ButtonType.BUTTON_X.toString() + "$descriptor-Y",
|
|
|
|
ButtonType.BUTTON_X.toString() + "-Y$orientation",
|
|
|
|
getResourceValue(descriptor, 5)
|
|
|
|
getResourceValue(orientation, 5)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.putFloat(
|
|
|
|
.putFloat(
|
|
|
|
ButtonType.BUTTON_Y.toString() + "$descriptor-X",
|
|
|
|
ButtonType.BUTTON_Y.toString() + "-X$orientation",
|
|
|
|
getResourceValue(descriptor, 6)
|
|
|
|
getResourceValue(orientation, 6)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.putFloat(
|
|
|
|
.putFloat(
|
|
|
|
ButtonType.BUTTON_Y.toString() + "$descriptor-Y",
|
|
|
|
ButtonType.BUTTON_Y.toString() + "-Y$orientation",
|
|
|
|
getResourceValue(descriptor, 7)
|
|
|
|
getResourceValue(orientation, 7)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.putFloat(
|
|
|
|
.putFloat(
|
|
|
|
ButtonType.TRIGGER_ZL.toString() + "$descriptor-X",
|
|
|
|
ButtonType.TRIGGER_ZL.toString() + "-X$orientation",
|
|
|
|
getResourceValue(descriptor, 8)
|
|
|
|
getResourceValue(orientation, 8)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.putFloat(
|
|
|
|
.putFloat(
|
|
|
|
ButtonType.TRIGGER_ZL.toString() + "$descriptor-Y",
|
|
|
|
ButtonType.TRIGGER_ZL.toString() + "-Y$orientation",
|
|
|
|
getResourceValue(descriptor, 9)
|
|
|
|
getResourceValue(orientation, 9)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.putFloat(
|
|
|
|
.putFloat(
|
|
|
|
ButtonType.TRIGGER_ZR.toString() + "$descriptor-X",
|
|
|
|
ButtonType.TRIGGER_ZR.toString() + "-X$orientation",
|
|
|
|
getResourceValue(descriptor, 10)
|
|
|
|
getResourceValue(orientation, 10)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.putFloat(
|
|
|
|
.putFloat(
|
|
|
|
ButtonType.TRIGGER_ZR.toString() + "$descriptor-Y",
|
|
|
|
ButtonType.TRIGGER_ZR.toString() + "-Y$orientation",
|
|
|
|
getResourceValue(descriptor, 11)
|
|
|
|
getResourceValue(orientation, 11)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.putFloat(
|
|
|
|
.putFloat(
|
|
|
|
ButtonType.DPAD_UP.toString() + "$descriptor-X",
|
|
|
|
ButtonType.DPAD_UP.toString() + "-X$orientation",
|
|
|
|
getResourceValue(descriptor, 12)
|
|
|
|
getResourceValue(orientation, 12)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.putFloat(
|
|
|
|
.putFloat(
|
|
|
|
ButtonType.DPAD_UP.toString() + "$descriptor-Y",
|
|
|
|
ButtonType.DPAD_UP.toString() + "-Y$orientation",
|
|
|
|
getResourceValue(descriptor, 13)
|
|
|
|
getResourceValue(orientation, 13)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.putFloat(
|
|
|
|
.putFloat(
|
|
|
|
ButtonType.TRIGGER_L.toString() + "$descriptor-X",
|
|
|
|
ButtonType.TRIGGER_L.toString() + "-X$orientation",
|
|
|
|
getResourceValue(descriptor, 14)
|
|
|
|
getResourceValue(orientation, 14)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.putFloat(
|
|
|
|
.putFloat(
|
|
|
|
ButtonType.TRIGGER_L.toString() + "$descriptor-Y",
|
|
|
|
ButtonType.TRIGGER_L.toString() + "-Y$orientation",
|
|
|
|
getResourceValue(descriptor, 15)
|
|
|
|
getResourceValue(orientation, 15)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.putFloat(
|
|
|
|
.putFloat(
|
|
|
|
ButtonType.TRIGGER_R.toString() + "$descriptor-X",
|
|
|
|
ButtonType.TRIGGER_R.toString() + "-X$orientation",
|
|
|
|
getResourceValue(descriptor, 16)
|
|
|
|
getResourceValue(orientation, 16)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.putFloat(
|
|
|
|
.putFloat(
|
|
|
|
ButtonType.TRIGGER_R.toString() + "$descriptor-Y",
|
|
|
|
ButtonType.TRIGGER_R.toString() + "-Y$orientation",
|
|
|
|
getResourceValue(descriptor, 17)
|
|
|
|
getResourceValue(orientation, 17)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.putFloat(
|
|
|
|
.putFloat(
|
|
|
|
ButtonType.BUTTON_PLUS.toString() + "$descriptor-X",
|
|
|
|
ButtonType.BUTTON_PLUS.toString() + "-X$orientation",
|
|
|
|
getResourceValue(descriptor, 18)
|
|
|
|
getResourceValue(orientation, 18)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.putFloat(
|
|
|
|
.putFloat(
|
|
|
|
ButtonType.BUTTON_PLUS.toString() + "$descriptor-Y",
|
|
|
|
ButtonType.BUTTON_PLUS.toString() + "-Y$orientation",
|
|
|
|
getResourceValue(descriptor, 19)
|
|
|
|
getResourceValue(orientation, 19)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.putFloat(
|
|
|
|
.putFloat(
|
|
|
|
ButtonType.BUTTON_MINUS.toString() + "$descriptor-X",
|
|
|
|
ButtonType.BUTTON_MINUS.toString() + "-X$orientation",
|
|
|
|
getResourceValue(descriptor, 20)
|
|
|
|
getResourceValue(orientation, 20)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.putFloat(
|
|
|
|
.putFloat(
|
|
|
|
ButtonType.BUTTON_MINUS.toString() + "$descriptor-Y",
|
|
|
|
ButtonType.BUTTON_MINUS.toString() + "-Y$orientation",
|
|
|
|
getResourceValue(descriptor, 21)
|
|
|
|
getResourceValue(orientation, 21)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.putFloat(
|
|
|
|
.putFloat(
|
|
|
|
ButtonType.BUTTON_HOME.toString() + "$descriptor-X",
|
|
|
|
ButtonType.BUTTON_HOME.toString() + "-X$orientation",
|
|
|
|
getResourceValue(descriptor, 22)
|
|
|
|
getResourceValue(orientation, 22)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.putFloat(
|
|
|
|
.putFloat(
|
|
|
|
ButtonType.BUTTON_HOME.toString() + "$descriptor-Y",
|
|
|
|
ButtonType.BUTTON_HOME.toString() + "-Y$orientation",
|
|
|
|
getResourceValue(descriptor, 23)
|
|
|
|
getResourceValue(orientation, 23)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.putFloat(
|
|
|
|
.putFloat(
|
|
|
|
ButtonType.BUTTON_CAPTURE.toString() + "$descriptor-X",
|
|
|
|
ButtonType.BUTTON_CAPTURE.toString() + "-X$orientation",
|
|
|
|
getResourceValue(descriptor, 24)
|
|
|
|
getResourceValue(orientation, 24)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.putFloat(
|
|
|
|
.putFloat(
|
|
|
|
ButtonType.BUTTON_CAPTURE.toString() + "$descriptor-Y",
|
|
|
|
ButtonType.BUTTON_CAPTURE.toString() + "-Y$orientation",
|
|
|
|
getResourceValue(descriptor, 25)
|
|
|
|
getResourceValue(orientation, 25)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.putFloat(
|
|
|
|
.putFloat(
|
|
|
|
ButtonType.STICK_R.toString() + "$descriptor-X",
|
|
|
|
ButtonType.STICK_R.toString() + "-X$orientation",
|
|
|
|
getResourceValue(descriptor, 26)
|
|
|
|
getResourceValue(orientation, 26)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.putFloat(
|
|
|
|
.putFloat(
|
|
|
|
ButtonType.STICK_R.toString() + "$descriptor-Y",
|
|
|
|
ButtonType.STICK_R.toString() + "-Y$orientation",
|
|
|
|
getResourceValue(descriptor, 27)
|
|
|
|
getResourceValue(orientation, 27)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.putFloat(
|
|
|
|
.putFloat(
|
|
|
|
ButtonType.STICK_L.toString() + "$descriptor-X",
|
|
|
|
ButtonType.STICK_L.toString() + "-X$orientation",
|
|
|
|
getResourceValue(descriptor, 28)
|
|
|
|
getResourceValue(orientation, 28)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.putFloat(
|
|
|
|
.putFloat(
|
|
|
|
ButtonType.STICK_L.toString() + "$descriptor-Y",
|
|
|
|
ButtonType.STICK_L.toString() + "-Y$orientation",
|
|
|
|
getResourceValue(descriptor, 29)
|
|
|
|
getResourceValue(orientation, 29)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.apply()
|
|
|
|
.apply()
|
|
|
|
}
|
|
|
|
}
|
|
|
|