mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-12-29 14:25:30 +03:00
Favor a predefined "click" over system vibration
This commit is contained in:
parent
cfd3bfecba
commit
b08fcd7027
@ -91,7 +91,7 @@ class ControllerActivity : AppCompatActivity() {
|
|||||||
adapter.notifyItemChanged(position)
|
adapter.notifyItemChanged(position)
|
||||||
})
|
})
|
||||||
|
|
||||||
items.add(ControllerCheckBoxViewItem(getString(R.string.osc_feedback), "", preferenceSettings.onScreenControlFeedback) { item, position ->
|
items.add(ControllerCheckBoxViewItem(getString(R.string.osc_feedback), getString(R.string.osc_feedback_description), preferenceSettings.onScreenControlFeedback) { item, position ->
|
||||||
preferenceSettings.onScreenControlFeedback = item.checked
|
preferenceSettings.onScreenControlFeedback = item.checked
|
||||||
adapter.notifyItemChanged(position)
|
adapter.notifyItemChanged(position)
|
||||||
})
|
})
|
||||||
|
@ -66,6 +66,13 @@ class OnScreenControllerView @JvmOverloads constructor(context : Context, attrs
|
|||||||
field = value
|
field = value
|
||||||
(controls.circularButtons + controls.rectangularButtons + controls.triggerButtons).forEach { it.hapticFeedback = hapticFeedback }
|
(controls.circularButtons + controls.rectangularButtons + controls.triggerButtons).forEach { it.hapticFeedback = hapticFeedback }
|
||||||
}
|
}
|
||||||
|
private val vibrator: Vibrator =
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||||
|
(context.getSystemService(VIBRATOR_MANAGER_SERVICE) as VibratorManager).defaultVibrator
|
||||||
|
} else {
|
||||||
|
@Suppress("DEPRECATION") (context.getSystemService(VIBRATOR_SERVICE) as Vibrator)
|
||||||
|
}
|
||||||
|
private val effectClick = VibrationEffect.createPredefined(VibrationEffect.EFFECT_CLICK)
|
||||||
|
|
||||||
override fun onDraw(canvas : Canvas) {
|
override fun onDraw(canvas : Canvas) {
|
||||||
super.onDraw(canvas)
|
super.onDraw(canvas)
|
||||||
@ -84,16 +91,6 @@ class OnScreenControllerView @JvmOverloads constructor(context : Context, attrs
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val vibrationEffect = VibrationEffect.createOneShot(20, VibrationEffect.DEFAULT_AMPLITUDE)
|
|
||||||
private val vibrate = {
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
|
||||||
(context.getSystemService(VIBRATOR_MANAGER_SERVICE) as VibratorManager).defaultVibrator.vibrate(vibrationEffect)
|
|
||||||
} else {
|
|
||||||
@Suppress("DEPRECATION")
|
|
||||||
(context.getSystemService(VIBRATOR_SERVICE) as Vibrator).vibrate(vibrationEffect)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private val playingTouchHandler = OnTouchListener { _, event ->
|
private val playingTouchHandler = OnTouchListener { _, event ->
|
||||||
var handled = false
|
var handled = false
|
||||||
val actionIndex = event.actionIndex
|
val actionIndex = event.actionIndex
|
||||||
@ -123,7 +120,7 @@ class OnScreenControllerView @JvmOverloads constructor(context : Context, attrs
|
|||||||
if (button.config.enabled && button.isTouched(x, y)) {
|
if (button.config.enabled && button.isTouched(x, y)) {
|
||||||
button.touchPointerId = pointerId
|
button.touchPointerId = pointerId
|
||||||
button.onFingerDown(x, y)
|
button.onFingerDown(x, y)
|
||||||
if (hapticFeedback) vibrate()
|
if (hapticFeedback) vibrator.vibrate(effectClick)
|
||||||
performClick()
|
performClick()
|
||||||
onButtonStateChangedListener?.invoke(button.buttonId, ButtonState.Pressed)
|
onButtonStateChangedListener?.invoke(button.buttonId, ButtonState.Pressed)
|
||||||
handled = true
|
handled = true
|
||||||
|
@ -111,6 +111,7 @@
|
|||||||
<string name="osc_not_shown">On-Screen Controls won\'t be shown</string>
|
<string name="osc_not_shown">On-Screen Controls won\'t be shown</string>
|
||||||
<string name="osc_shown">On-Screen Controls will be shown</string>
|
<string name="osc_shown">On-Screen Controls will be shown</string>
|
||||||
<string name="osc_feedback">Enable Haptic Feedback</string>
|
<string name="osc_feedback">Enable Haptic Feedback</string>
|
||||||
|
<string name="osc_feedback_description">Excludes joysticks and hardware controls</string>
|
||||||
<string name="osc_edit">Edit On-Screen Controls layout</string>
|
<string name="osc_edit">Edit On-Screen Controls layout</string>
|
||||||
<string name="setup_guide">Setup Guide</string>
|
<string name="setup_guide">Setup Guide</string>
|
||||||
<string name="setup_guide_description">Sequentially map every stick and button</string>
|
<string name="setup_guide_description">Sequentially map every stick and button</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user