mirror of
https://git.sr.ht/~thestr4ng3r/chiaki
synced 2025-07-06 04:52:09 -07:00
Refine LR Touch on Android
This commit is contained in:
parent
5699c06dd8
commit
35130b08b7
2 changed files with 20 additions and 11 deletions
|
@ -6,6 +6,7 @@ import android.content.Context
|
||||||
import android.graphics.Canvas
|
import android.graphics.Canvas
|
||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
|
import android.util.Log
|
||||||
import android.view.MotionEvent
|
import android.view.MotionEvent
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
@ -75,14 +76,16 @@ class ButtonView @JvmOverloads constructor(
|
||||||
|
|
||||||
override fun onTouchEvent(event: MotionEvent): Boolean
|
override fun onTouchEvent(event: MotionEvent): Boolean
|
||||||
{
|
{
|
||||||
when(event.action)
|
when(event.actionMasked)
|
||||||
{
|
{
|
||||||
MotionEvent.ACTION_DOWN -> {
|
MotionEvent.ACTION_DOWN, MotionEvent.ACTION_POINTER_DOWN -> {
|
||||||
if(bestFittingTouchView(event.x, event.y) != this)
|
if(bestFittingTouchView(event.getX(event.actionIndex), event.getY(event.actionIndex)) != this)
|
||||||
return false
|
return false
|
||||||
buttonPressed = true
|
buttonPressed = true
|
||||||
}
|
}
|
||||||
MotionEvent.ACTION_UP -> buttonPressed = false
|
MotionEvent.ACTION_UP, MotionEvent.ACTION_POINTER_UP -> {
|
||||||
|
buttonPressed = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,9 +173,12 @@
|
||||||
|
|
||||||
<com.metallic.chiaki.touchcontrols.ButtonView
|
<com.metallic.chiaki.touchcontrols.ButtonView
|
||||||
android:id="@+id/l2ButtonView"
|
android:id="@+id/l2ButtonView"
|
||||||
android:layout_width="80dp"
|
android:layout_width="88dp"
|
||||||
android:layout_height="80dp"
|
android:layout_height="80dp"
|
||||||
android:padding="8dp"
|
android:paddingTop="8dp"
|
||||||
|
android:paddingBottom="8dp"
|
||||||
|
android:paddingRight="8dp"
|
||||||
|
android:paddingLeft="16dp"
|
||||||
app:drawableIdle="@drawable/control_button_l2"
|
app:drawableIdle="@drawable/control_button_l2"
|
||||||
app:drawablePressed="@drawable/control_button_l2_pressed"
|
app:drawablePressed="@drawable/control_button_l2_pressed"
|
||||||
app:layout_constraintLeft_toLeftOf="parent"
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
|
@ -186,8 +189,8 @@
|
||||||
android:layout_width="80dp"
|
android:layout_width="80dp"
|
||||||
android:layout_height="80dp"
|
android:layout_height="80dp"
|
||||||
android:padding="8dp"
|
android:padding="8dp"
|
||||||
android:layout_marginTop="34dp"
|
android:layout_marginTop="32dp"
|
||||||
android:layout_marginLeft="34dp"
|
android:layout_marginLeft="40dp"
|
||||||
app:drawableIdle="@drawable/control_button_l1"
|
app:drawableIdle="@drawable/control_button_l1"
|
||||||
app:drawablePressed="@drawable/control_button_l1_pressed"
|
app:drawablePressed="@drawable/control_button_l1_pressed"
|
||||||
app:layout_constraintLeft_toLeftOf="parent"
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
|
@ -206,9 +209,12 @@
|
||||||
|
|
||||||
<com.metallic.chiaki.touchcontrols.ButtonView
|
<com.metallic.chiaki.touchcontrols.ButtonView
|
||||||
android:id="@+id/r2ButtonView"
|
android:id="@+id/r2ButtonView"
|
||||||
android:layout_width="80dp"
|
android:layout_width="88dp"
|
||||||
android:layout_height="80dp"
|
android:layout_height="80dp"
|
||||||
android:padding="8dp"
|
android:paddingTop="8dp"
|
||||||
|
android:paddingRight="16dp"
|
||||||
|
android:paddingLeft="8dp"
|
||||||
|
android:paddingBottom="8dp"
|
||||||
app:drawableIdle="@drawable/control_button_r2"
|
app:drawableIdle="@drawable/control_button_r2"
|
||||||
app:drawablePressed="@drawable/control_button_r2_pressed"
|
app:drawablePressed="@drawable/control_button_r2_pressed"
|
||||||
app:layout_constraintRight_toRightOf="parent"
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
|
@ -220,7 +226,7 @@
|
||||||
android:layout_height="80dp"
|
android:layout_height="80dp"
|
||||||
android:padding="8dp"
|
android:padding="8dp"
|
||||||
android:layout_marginTop="32dp"
|
android:layout_marginTop="32dp"
|
||||||
android:layout_marginRight="32dp"
|
android:layout_marginRight="40dp"
|
||||||
app:drawableIdle="@drawable/control_button_r1"
|
app:drawableIdle="@drawable/control_button_r1"
|
||||||
app:drawablePressed="@drawable/control_button_r1_pressed"
|
app:drawablePressed="@drawable/control_button_r1_pressed"
|
||||||
app:layout_constraintRight_toRightOf="parent"
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue