Add remaining Controls to Android for Testing

This commit is contained in:
Florian Märkl 2019-09-29 12:30:59 +02:00
commit 8f2275c6ab
No known key found for this signature in database
GPG key ID: 125BC8A5A6A1E857
4 changed files with 141 additions and 5 deletions

View file

@ -25,7 +25,7 @@
#include <oboe/Oboe.h>
#define BUFFER_CHUNK_SIZE 512
#define BUFFER_CHUNKS_COUNT 128
#define BUFFER_CHUNKS_COUNT 32
using AudioBuffer = CircularBuffer<BUFFER_CHUNKS_COUNT, BUFFER_CHUNK_SIZE>;

View file

@ -51,7 +51,41 @@ class TouchControlsFragment : Fragment()
moonButtonView.buttonPressedCallback = buttonStateChanged(ControllerState.BUTTON_MOON)
pyramidButtonView.buttonPressedCallback = buttonStateChanged(ControllerState.BUTTON_PYRAMID)
boxButtonView.buttonPressedCallback = buttonStateChanged(ControllerState.BUTTON_BOX)
l1ButtonView.buttonPressedCallback = buttonStateChanged(ControllerState.BUTTON_L1)
r1ButtonView.buttonPressedCallback = buttonStateChanged(ControllerState.BUTTON_R1)
optionsButtonView.buttonPressedCallback = buttonStateChanged(ControllerState.BUTTON_OPTIONS)
shareButtonView.buttonPressedCallback = buttonStateChanged(ControllerState.BUTTON_SHARE)
psButtonView.buttonPressedCallback = buttonStateChanged(ControllerState.BUTTON_PS)
touchpadButtonView.buttonPressedCallback = buttonStateChanged(ControllerState.BUTTON_TOUCHPAD)
l2ButtonView.buttonPressedCallback = { controllerState = controllerState.copy().apply { l2State = if(it) 255U else 0U } }
r2ButtonView.buttonPressedCallback = { controllerState = controllerState.copy().apply { r2State = if(it) 255U else 0U } }
leftDpadView.stateChangeCallback = { controllerState = controllerState.copy().apply {
val pos: Pair<Short, Short> = when(it)
{
DPadView.Direction.UP -> Pair(0, Short.MIN_VALUE)
DPadView.Direction.DOWN -> Pair(0, Short.MAX_VALUE)
DPadView.Direction.LEFT -> Pair(Short.MIN_VALUE, 0)
DPadView.Direction.RIGHT -> Pair(Short.MAX_VALUE, 0)
null -> Pair(0, 0)
}
leftX = pos.first
leftY = pos.second
}}
rightDpadView.stateChangeCallback = { controllerState = controllerState.copy().apply {
val pos: Pair<Short, Short> = when(it)
{
DPadView.Direction.UP -> Pair(0, Short.MIN_VALUE)
DPadView.Direction.DOWN -> Pair(0, Short.MAX_VALUE)
DPadView.Direction.LEFT -> Pair(Short.MIN_VALUE, 0)
DPadView.Direction.RIGHT -> Pair(Short.MAX_VALUE, 0)
null -> Pair(0, 0)
}
rightX = pos.first
rightY = pos.second
}}
}
private fun dpadStateChanged(direction: DPadView.Direction?)

View file

@ -13,6 +13,7 @@
android:layout_width="128dp"
android:layout_height="128dp"
android:layout_marginLeft="32dp"
android:layout_marginBottom="32dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />
@ -22,7 +23,8 @@
android:layout_height="144dp"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent">
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginBottom="32dp">
<com.metallic.chiaki.touchcontrols.ButtonView
android:id="@+id/crossButtonView"
@ -73,8 +75,8 @@
<com.metallic.chiaki.touchcontrols.ButtonView
android:id="@+id/psButtonView"
android:layout_width="@dimen/control_face_button_size"
android:layout_height="@dimen/control_face_button_size"
android:layout_width="32dp"
android:layout_height="32dp"
android:padding="8dp"
android:layout_marginTop="8dp"
app:drawableIdle="@drawable/control_button_pyramid"
@ -83,4 +85,104 @@
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<com.metallic.chiaki.touchcontrols.ButtonView
android:id="@+id/touchpadButtonView"
android:layout_width="32dp"
android:layout_height="32dp"
android:padding="8dp"
android:layout_marginTop="8dp"
app:drawableIdle="@drawable/control_button_pyramid"
app:drawablePressed="@drawable/control_button_pyramid_pressed"
app:layout_constraintLeft_toRightOf="@id/psButtonView"
app:layout_constraintRight_toLeftOf="@id/optionsButtonView"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<com.metallic.chiaki.touchcontrols.ButtonView
android:id="@+id/l2ButtonView"
android:layout_width="32dp"
android:layout_height="32dp"
android:padding="8dp"
android:layout_marginTop="8dp"
app:drawableIdle="@drawable/control_button_pyramid"
app:drawablePressed="@drawable/control_button_pyramid_pressed"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<com.metallic.chiaki.touchcontrols.ButtonView
android:id="@+id/l1ButtonView"
android:layout_width="32dp"
android:layout_height="32dp"
android:padding="8dp"
android:layout_marginTop="8dp"
app:drawableIdle="@drawable/control_button_pyramid"
app:drawablePressed="@drawable/control_button_pyramid_pressed"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/l2ButtonView"/>
<com.metallic.chiaki.touchcontrols.ButtonView
android:id="@+id/shareButtonView"
android:layout_width="32dp"
android:layout_height="32dp"
android:padding="8dp"
android:layout_marginTop="8dp"
android:layout_marginLeft="8dp"
app:drawableIdle="@drawable/control_button_pyramid"
app:drawablePressed="@drawable/control_button_pyramid_pressed"
app:layout_constraintLeft_toRightOf="@id/l2ButtonView"
app:layout_constraintTop_toTopOf="parent"/>
<com.metallic.chiaki.touchcontrols.ButtonView
android:id="@+id/r2ButtonView"
android:layout_width="32dp"
android:layout_height="32dp"
android:padding="8dp"
android:layout_marginTop="8dp"
app:drawableIdle="@drawable/control_button_pyramid"
app:drawablePressed="@drawable/control_button_pyramid_pressed"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<com.metallic.chiaki.touchcontrols.ButtonView
android:id="@+id/r1ButtonView"
android:layout_width="32dp"
android:layout_height="32dp"
android:padding="8dp"
android:layout_marginTop="8dp"
app:drawableIdle="@drawable/control_button_pyramid"
app:drawablePressed="@drawable/control_button_pyramid_pressed"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/r2ButtonView"/>
<com.metallic.chiaki.touchcontrols.ButtonView
android:id="@+id/optionsButtonView"
android:layout_width="32dp"
android:layout_height="32dp"
android:padding="8dp"
android:layout_marginTop="8dp"
android:layout_marginRight="8dp"
app:drawableIdle="@drawable/control_button_pyramid"
app:drawablePressed="@drawable/control_button_pyramid_pressed"
app:layout_constraintRight_toLeftOf="@id/r2ButtonView"
app:layout_constraintTop_toTopOf="parent" />
<com.metallic.chiaki.touchcontrols.DPadView
android:id="@+id/leftDpadView"
android:layout_width="128dp"
android:layout_height="128dp"
android:layout_marginLeft="32dp"
android:layout_marginBottom="8dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />
<com.metallic.chiaki.touchcontrols.DPadView
android:id="@+id/rightDpadView"
android:layout_width="128dp"
android:layout_height="128dp"
android:layout_marginLeft="32dp"
android:layout_marginBottom="8dp"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -7,6 +7,6 @@
<color name="stream_text">@android:color/white</color>
<color name="stream_background">@android:color/black</color>
<color name="control_primary">#44ffffff</color>
<color name="control_primary">#22ffffff</color>
<color name="control_pressed">#88ffffff</color>
</resources>