mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2026-09-28 13:22:58 -05:00
Android/overlay-haptics: Rename HapticEffects
This commit is contained in:
@@ -745,7 +745,7 @@ class EmulationActivity : AppCompatActivity(), ThemeProvider {
|
||||
value = FloatSetting.MAIN_OVERLAY_HAPTICS_SCALE.float.also { setValueText(it) }
|
||||
addOnChangeListener { _: Slider, value: Float, _: Boolean ->
|
||||
setValueText(value)
|
||||
hapticsProvider.provideFeedback(HapticEffect.LOW_TICK, value)
|
||||
hapticsProvider.provideFeedback(HapticEffect.JOYSTICK, value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ class InputOverlay(context: Context?, attrs: AttributeSet?) : SurfaceView(contex
|
||||
button.setPressedState(false)
|
||||
if (hapticsOnRelease) {
|
||||
hapticsProvider.provideFeedback(
|
||||
HapticEffect.QUICK_RISE,
|
||||
HapticEffect.RELEASE,
|
||||
hapticsScale
|
||||
)
|
||||
}
|
||||
@@ -173,7 +173,7 @@ class InputOverlay(context: Context?, attrs: AttributeSet?) : SurfaceView(contex
|
||||
button.setPressedState(true)
|
||||
if (hapticsOnPress) {
|
||||
hapticsProvider.provideFeedback(
|
||||
HapticEffect.QUICK_FALL,
|
||||
HapticEffect.PRESS,
|
||||
hapticsScale
|
||||
)
|
||||
}
|
||||
@@ -200,7 +200,7 @@ class InputOverlay(context: Context?, attrs: AttributeSet?) : SurfaceView(contex
|
||||
button.setPressedState(false)
|
||||
if (hapticsOnRelease) {
|
||||
hapticsProvider.provideFeedback(
|
||||
HapticEffect.QUICK_RISE,
|
||||
HapticEffect.RELEASE,
|
||||
hapticsScale
|
||||
)
|
||||
}
|
||||
@@ -259,7 +259,7 @@ class InputOverlay(context: Context?, attrs: AttributeSet?) : SurfaceView(contex
|
||||
if (!dpadPressed[i]) {
|
||||
if (hapticsOnRelease && dpad.isPressed(i)) {
|
||||
hapticsProvider.provideFeedback(
|
||||
HapticEffect.QUICK_RISE,
|
||||
HapticEffect.RELEASE,
|
||||
hapticsScale
|
||||
)
|
||||
}
|
||||
@@ -271,7 +271,7 @@ class InputOverlay(context: Context?, attrs: AttributeSet?) : SurfaceView(contex
|
||||
} else {
|
||||
if (hapticsOnPress && !dpad.isPressed(i)) {
|
||||
hapticsProvider.provideFeedback(
|
||||
HapticEffect.QUICK_FALL,
|
||||
HapticEffect.PRESS,
|
||||
hapticsScale
|
||||
)
|
||||
}
|
||||
@@ -298,7 +298,7 @@ class InputOverlay(context: Context?, attrs: AttributeSet?) : SurfaceView(contex
|
||||
for (i in 0 until 4) {
|
||||
if (hapticsOnRelease && dpad.isPressed(i)) {
|
||||
hapticsProvider.provideFeedback(
|
||||
HapticEffect.QUICK_RISE,
|
||||
HapticEffect.RELEASE,
|
||||
hapticsScale
|
||||
)
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ class InputOverlayDrawableJoystick(
|
||||
pressed = true
|
||||
pressedState = true
|
||||
if (BooleanSetting.MAIN_OVERLAY_HAPTICS_ON_PRESS.boolean) {
|
||||
hapticsProvider.provideFeedback(HapticEffect.QUICK_FALL, hapticsScale)
|
||||
hapticsProvider.provideFeedback(HapticEffect.PRESS, hapticsScale)
|
||||
}
|
||||
outerBitmap.alpha = 0
|
||||
boundsBoxBitmap.alpha = opacity
|
||||
@@ -144,7 +144,7 @@ class InputOverlayDrawableJoystick(
|
||||
pressed = true
|
||||
pressedState = false
|
||||
if (BooleanSetting.MAIN_OVERLAY_HAPTICS_ON_RELEASE.boolean) {
|
||||
hapticsProvider.provideFeedback(HapticEffect.QUICK_RISE, hapticsScale)
|
||||
hapticsProvider.provideFeedback(HapticEffect.RELEASE, hapticsScale)
|
||||
}
|
||||
y = 0f
|
||||
x = y
|
||||
@@ -184,7 +184,7 @@ class InputOverlayDrawableJoystick(
|
||||
val deltaX = x - hapticsPreviousX
|
||||
val deltaY = y - hapticsPreviousY
|
||||
if (deltaX.pow(2) + deltaY.pow(2) > radiusThreshold.pow(2)) {
|
||||
hapticsProvider.provideFeedback(HapticEffect.LOW_TICK, hapticsScale)
|
||||
hapticsProvider.provideFeedback(HapticEffect.JOYSTICK, hapticsScale)
|
||||
hapticsPreviousX = x
|
||||
hapticsPreviousY = y
|
||||
}
|
||||
|
||||
@@ -68,9 +68,9 @@ class HapticsProvider(
|
||||
// so the difference in the duration of the vibration can be easily perceived.
|
||||
// Lower-end vibrators can't vibrate at all if the duration is too short.
|
||||
return when (effect) {
|
||||
HapticEffect.QUICK_FALL -> longArrayOf(0L, (100f * scale).toLong())
|
||||
HapticEffect.QUICK_RISE -> longArrayOf(0L, (70f * scale).toLong())
|
||||
HapticEffect.LOW_TICK -> longArrayOf(0L, (50f * scale).toLong())
|
||||
HapticEffect.PRESS -> longArrayOf(0L, (100f * scale).toLong())
|
||||
HapticEffect.RELEASE -> longArrayOf(0L, (70f * scale).toLong())
|
||||
HapticEffect.JOYSTICK -> longArrayOf(0L, (50f * scale).toLong())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,18 +89,18 @@ class HapticsProvider(
|
||||
// so the difference in the amplitude of the vibration can be easily perceived.
|
||||
// Value range is between 0 and 255 (VibrationEffect.MAX_AMPLITUDE).
|
||||
return when (effect) {
|
||||
HapticEffect.QUICK_FALL -> intArrayOf(0, (255f * scale).toInt())
|
||||
HapticEffect.QUICK_RISE -> intArrayOf(0, (180f * scale).toInt())
|
||||
HapticEffect.LOW_TICK -> intArrayOf(0, (128f * scale).toInt())
|
||||
HapticEffect.PRESS -> intArrayOf(0, (255f * scale).toInt())
|
||||
HapticEffect.RELEASE -> intArrayOf(0, (180f * scale).toInt())
|
||||
HapticEffect.JOYSTICK -> intArrayOf(0, (128f * scale).toInt())
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.S)
|
||||
private fun getPrimitive(effect: HapticEffect): Int {
|
||||
return when (effect) {
|
||||
HapticEffect.QUICK_FALL -> VibrationEffect.Composition.PRIMITIVE_QUICK_FALL
|
||||
HapticEffect.QUICK_RISE -> VibrationEffect.Composition.PRIMITIVE_QUICK_RISE
|
||||
HapticEffect.LOW_TICK -> VibrationEffect.Composition.PRIMITIVE_LOW_TICK
|
||||
HapticEffect.PRESS -> VibrationEffect.Composition.PRIMITIVE_QUICK_FALL
|
||||
HapticEffect.RELEASE -> VibrationEffect.Composition.PRIMITIVE_QUICK_RISE
|
||||
HapticEffect.JOYSTICK -> VibrationEffect.Composition.PRIMITIVE_LOW_TICK
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ class HapticsProvider(
|
||||
}
|
||||
|
||||
enum class HapticEffect {
|
||||
QUICK_FALL,
|
||||
QUICK_RISE,
|
||||
LOW_TICK
|
||||
PRESS,
|
||||
RELEASE,
|
||||
JOYSTICK
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user