mirror of
https://git.sr.ht/~thestr4ng3r/chiaki
synced 2025-08-19 21:13:12 -07:00
Draw DPad on Android
This commit is contained in:
parent
b41bb3178a
commit
8b9dd17f64
7 changed files with 264 additions and 2 deletions
|
@ -20,8 +20,7 @@ android {
|
||||||
"-DCHIAKI_ENABLE_GUI=OFF",
|
"-DCHIAKI_ENABLE_GUI=OFF",
|
||||||
"-DCHIAKI_ENABLE_ANDROID=ON",
|
"-DCHIAKI_ENABLE_ANDROID=ON",
|
||||||
"-DCHIAKI_LIB_ENABLE_OPUS=OFF",
|
"-DCHIAKI_LIB_ENABLE_OPUS=OFF",
|
||||||
"-DCHIAKI_LIB_OPENSSL_EXTERNAL_PROJECT=ON",
|
"-DCHIAKI_LIB_OPENSSL_EXTERNAL_PROJECT=ON"
|
||||||
"-DCMAKE_VERBOSE_MAKEFILE=ON"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,20 @@
|
||||||
|
/*
|
||||||
|
* This file is part of Chiaki.
|
||||||
|
*
|
||||||
|
* Chiaki is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Chiaki is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Chiaki. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
package com.metallic.chiaki
|
package com.metallic.chiaki
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
/*
|
||||||
|
* This file is part of Chiaki.
|
||||||
|
*
|
||||||
|
* Chiaki is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Chiaki is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Chiaki. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.metallic.chiaki.touchcontrols
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.graphics.Canvas
|
||||||
|
import android.util.AttributeSet
|
||||||
|
import android.util.Log
|
||||||
|
import android.view.MotionEvent
|
||||||
|
import android.view.View
|
||||||
|
import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat
|
||||||
|
import com.metallic.chiaki.R
|
||||||
|
|
||||||
|
class DPadView @JvmOverloads constructor(
|
||||||
|
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
|
||||||
|
) : View(context, attrs, defStyleAttr)
|
||||||
|
{
|
||||||
|
private val colorPrimary = resources.getColor(R.color.control_primary, null)
|
||||||
|
private val dpadDrawable = VectorDrawableCompat.create(resources, R.drawable.control_dpad, null)
|
||||||
|
|
||||||
|
override fun onDraw(canvas: Canvas) {
|
||||||
|
super.onDraw(canvas)
|
||||||
|
dpadDrawable?.setBounds(0, 0, width, height)
|
||||||
|
dpadDrawable?.setTint(colorPrimary)
|
||||||
|
dpadDrawable?.draw(canvas)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onTouchEvent(event: MotionEvent): Boolean
|
||||||
|
{
|
||||||
|
Log.i("DPadView", "onTouchEvent $event")
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
34
android/app/src/main/res/drawable/control_dpad.xml
Normal file
34
android/app/src/main/res/drawable/control_dpad.xml
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="512dp"
|
||||||
|
android:height="512dp"
|
||||||
|
android:viewportWidth="135.46667"
|
||||||
|
android:viewportHeight="135.46667">
|
||||||
|
<path
|
||||||
|
android:pathData="M45.244,0L45.244,36.263L62.162,53.181l11.144,0L90.223,36.263L90.223,0Z"
|
||||||
|
android:strokeAlpha="1"
|
||||||
|
android:strokeWidth="30.92149353"
|
||||||
|
android:fillColor="#000000"
|
||||||
|
android:strokeColor="#00000000"
|
||||||
|
android:fillAlpha="1"/>
|
||||||
|
<path
|
||||||
|
android:pathData="M0,45.244L0,90.223L36.263,90.223L53.181,73.305L53.181,62.162L36.263,45.244Z"
|
||||||
|
android:strokeAlpha="1"
|
||||||
|
android:strokeWidth="30.92149353"
|
||||||
|
android:fillColor="#000000"
|
||||||
|
android:strokeColor="#00000000"
|
||||||
|
android:fillAlpha="1"/>
|
||||||
|
<path
|
||||||
|
android:pathData="M99.203,45.244 L82.285,62.162l0,11.144L99.203,90.223L135.467,90.223L135.467,45.244Z"
|
||||||
|
android:strokeAlpha="1"
|
||||||
|
android:strokeWidth="30.92149353"
|
||||||
|
android:fillColor="#000000"
|
||||||
|
android:strokeColor="#00000000"
|
||||||
|
android:fillAlpha="1"/>
|
||||||
|
<path
|
||||||
|
android:pathData="M62.162,82.285 L45.244,99.203L45.244,135.467L90.223,135.467L90.223,99.203L73.305,82.285Z"
|
||||||
|
android:strokeAlpha="1"
|
||||||
|
android:strokeWidth="30.92149353"
|
||||||
|
android:fillColor="#000000"
|
||||||
|
android:strokeColor="#00000000"
|
||||||
|
android:fillAlpha="1"/>
|
||||||
|
</vector>
|
|
@ -51,4 +51,12 @@
|
||||||
app:layout_constraintRight_toRightOf="parent"
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/morningEditText" />
|
app:layout_constraintTop_toBottomOf="@+id/morningEditText" />
|
||||||
|
|
||||||
|
<com.metallic.chiaki.touchcontrols.DPadView
|
||||||
|
android:layout_width="100dp"
|
||||||
|
android:layout_height="100dp"
|
||||||
|
android:layout_marginTop="32dp"
|
||||||
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -6,4 +6,6 @@
|
||||||
|
|
||||||
<color name="stream_text">@android:color/white</color>
|
<color name="stream_text">@android:color/white</color>
|
||||||
<color name="stream_background">@android:color/black</color>
|
<color name="stream_background">@android:color/black</color>
|
||||||
|
|
||||||
|
<color name="control_primary">@android:color/white</color>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
153
assets/controls/dpad.svg
Normal file
153
assets/controls/dpad.svg
Normal file
|
@ -0,0 +1,153 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||||
|
|
||||||
|
<svg
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
width="512"
|
||||||
|
height="512"
|
||||||
|
viewBox="0 0 135.46667 135.46667"
|
||||||
|
version="1.1"
|
||||||
|
id="svg8"
|
||||||
|
inkscape:version="0.92.4 5da689c313, 2019-01-14"
|
||||||
|
sodipodi:docname="dpad.svg">
|
||||||
|
<defs
|
||||||
|
id="defs2" />
|
||||||
|
<sodipodi:namedview
|
||||||
|
id="base"
|
||||||
|
pagecolor="#ffffff"
|
||||||
|
bordercolor="#666666"
|
||||||
|
borderopacity="1.0"
|
||||||
|
inkscape:pageopacity="0.0"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:zoom="0.76346102"
|
||||||
|
inkscape:cx="205.99427"
|
||||||
|
inkscape:cy="285.77124"
|
||||||
|
inkscape:document-units="mm"
|
||||||
|
inkscape:current-layer="g4598"
|
||||||
|
showgrid="false"
|
||||||
|
units="px"
|
||||||
|
showguides="true"
|
||||||
|
inkscape:guide-bbox="true"
|
||||||
|
inkscape:snap-intersection-paths="true"
|
||||||
|
inkscape:object-paths="false"
|
||||||
|
inkscape:snap-midpoints="true"
|
||||||
|
inkscape:snap-page="true"
|
||||||
|
inkscape:snap-object-midpoints="true"
|
||||||
|
inkscape:window-width="1918"
|
||||||
|
inkscape:window-height="1048"
|
||||||
|
inkscape:window-x="1920"
|
||||||
|
inkscape:window-y="15"
|
||||||
|
inkscape:window-maximized="1">
|
||||||
|
<sodipodi:guide
|
||||||
|
position="67.733335,67.733335"
|
||||||
|
orientation="0,1"
|
||||||
|
id="guide4518"
|
||||||
|
inkscape:locked="false"
|
||||||
|
inkscape:label=""
|
||||||
|
inkscape:color="rgb(0,0,255)" />
|
||||||
|
<sodipodi:guide
|
||||||
|
position="67.733335,67.733335"
|
||||||
|
orientation="1,0"
|
||||||
|
id="guide4520"
|
||||||
|
inkscape:locked="false" />
|
||||||
|
</sodipodi:namedview>
|
||||||
|
<metadata
|
||||||
|
id="metadata5">
|
||||||
|
<rdf:RDF>
|
||||||
|
<cc:Work
|
||||||
|
rdf:about="">
|
||||||
|
<dc:format>image/svg+xml</dc:format>
|
||||||
|
<dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||||
|
<dc:title></dc:title>
|
||||||
|
</cc:Work>
|
||||||
|
</rdf:RDF>
|
||||||
|
</metadata>
|
||||||
|
<g
|
||||||
|
inkscape:label="raw"
|
||||||
|
inkscape:groupmode="layer"
|
||||||
|
id="layer1"
|
||||||
|
transform="translate(0,-161.5333)"
|
||||||
|
style="display:none">
|
||||||
|
<g
|
||||||
|
id="g4582">
|
||||||
|
<rect
|
||||||
|
y="206.77705"
|
||||||
|
x="7.1207683e-06"
|
||||||
|
height="44.979168"
|
||||||
|
width="135.46666"
|
||||||
|
id="rect4561"
|
||||||
|
style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:8.18131161;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||||
|
<rect
|
||||||
|
transform="rotate(90)"
|
||||||
|
style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:8.18131161;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
id="rect4563"
|
||||||
|
width="135.46666"
|
||||||
|
height="44.979168"
|
||||||
|
x="161.53329"
|
||||||
|
y="-90.222916" />
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g4578">
|
||||||
|
<rect
|
||||||
|
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:8.18808365;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
id="rect4567"
|
||||||
|
width="12.7"
|
||||||
|
height="135.46666"
|
||||||
|
x="107.87129"
|
||||||
|
y="-277.74402"
|
||||||
|
transform="rotate(135)" />
|
||||||
|
<rect
|
||||||
|
transform="rotate(-135)"
|
||||||
|
y="-181.95462"
|
||||||
|
x="-216.36069"
|
||||||
|
height="135.46666"
|
||||||
|
width="12.7"
|
||||||
|
id="rect4571"
|
||||||
|
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:8.18808365;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||||
|
<rect
|
||||||
|
y="214.71455"
|
||||||
|
x="53.181248"
|
||||||
|
height="29.104166"
|
||||||
|
width="29.104166"
|
||||||
|
id="rect4573"
|
||||||
|
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:9.72143269;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
transform="translate(0,-161.5333)"
|
||||||
|
id="g4598"
|
||||||
|
inkscape:groupmode="layer"
|
||||||
|
inkscape:label="cut">
|
||||||
|
<path
|
||||||
|
style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:30.92149353;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="M 171,0 V 137.05859 L 234.94141,201 h 42.11718 L 341,137.05859 V 0 Z"
|
||||||
|
transform="matrix(0.26458333,0,0,0.26458333,0,161.5333)"
|
||||||
|
id="path4641"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
<path
|
||||||
|
style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:30.92149353;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="M 0,171 V 341 H 137.05859 L 201,277.05859 V 234.94141 L 137.05859,171 Z"
|
||||||
|
transform="matrix(0.26458333,0,0,0.26458333,0,161.5333)"
|
||||||
|
id="path4639"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
<path
|
||||||
|
style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:30.92149353;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="M 374.94141,171 311,234.94141 v 42.11718 L 374.94141,341 H 512 V 171 Z"
|
||||||
|
transform="matrix(0.26458333,0,0,0.26458333,0,161.5333)"
|
||||||
|
id="path4637"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
<path
|
||||||
|
style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:30.92149353;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="M 234.94141,311 171,374.94141 V 512 H 341 V 374.94141 L 277.05859,311 Z"
|
||||||
|
transform="matrix(0.26458333,0,0,0.26458333,0,161.5333)"
|
||||||
|
id="rect4584"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 5.3 KiB |
Loading…
Add table
Add a link
Reference in a new issue