Skip to content

Commit d92b02f

Browse files
Add Thumbs of Controller on Controller Mapper
1 parent 9f7dcf7 commit d92b02f

File tree

7 files changed

+152
-15
lines changed

7 files changed

+152
-15
lines changed

app/src/main/java/com/micewine/emu/activities/ControllerMapper.kt

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,8 @@ class ControllerMapper : AppCompatActivity() {
198198
const val BUTTON_R2_KEY = "buttonR2"
199199
const val BUTTON_L1_KEY = "buttonL1"
200200
const val BUTTON_L2_KEY = "buttonL2"
201+
const val BUTTON_THUMBL_KEY = "thumbLKey"
202+
const val BUTTON_THUMBR_KEY = "thumbRKey"
201203
const val AXIS_X_PLUS_KEY = "axisX+"
202204
const val AXIS_X_MINUS_KEY = "axisX-"
203205
const val AXIS_Y_PLUS_KEY = "axisY+"
@@ -227,20 +229,22 @@ class ControllerMapper : AppCompatActivity() {
227229
BUTTON_R2_KEY to 8,
228230
BUTTON_L1_KEY to 9,
229231
BUTTON_L2_KEY to 10,
230-
AXIS_X_PLUS_KEY to 11,
231-
AXIS_X_MINUS_KEY to 12,
232-
AXIS_Y_PLUS_KEY to 13,
233-
AXIS_Y_MINUS_KEY to 14,
234-
AXIS_Z_PLUS_KEY to 15,
235-
AXIS_Z_MINUS_KEY to 16,
236-
AXIS_RZ_PLUS_KEY to 17,
237-
AXIS_RZ_MINUS_KEY to 18,
238-
AXIS_HAT_X_PLUS_KEY to 19,
239-
AXIS_HAT_X_MINUS_KEY to 20,
240-
AXIS_HAT_Y_PLUS_KEY to 21,
241-
AXIS_HAT_Y_MINUS_KEY to 22,
242-
DEAD_ZONE to 23,
243-
MOUSE_SENSIBILITY to 24
232+
BUTTON_THUMBL_KEY to 11,
233+
BUTTON_THUMBR_KEY to 12,
234+
AXIS_X_PLUS_KEY to 13,
235+
AXIS_X_MINUS_KEY to 14,
236+
AXIS_Y_PLUS_KEY to 15,
237+
AXIS_Y_MINUS_KEY to 16,
238+
AXIS_Z_PLUS_KEY to 17,
239+
AXIS_Z_MINUS_KEY to 18,
240+
AXIS_RZ_PLUS_KEY to 19,
241+
AXIS_RZ_MINUS_KEY to 20,
242+
AXIS_HAT_X_PLUS_KEY to 21,
243+
AXIS_HAT_X_MINUS_KEY to 22,
244+
AXIS_HAT_Y_PLUS_KEY to 23,
245+
AXIS_HAT_Y_MINUS_KEY to 24,
246+
DEAD_ZONE to 25,
247+
MOUSE_SENSIBILITY to 26
244248
)
245249

246250
fun putDeadZone(context: Context, name: String, value: Int) {
@@ -400,7 +404,7 @@ class ControllerMapper : AppCompatActivity() {
400404
val json = preferences.getString("controllerPresetList", "")
401405
val listType = object : TypeToken<MutableList<List<String>>>() {}.type
402406

403-
return gson.fromJson(json, listType) ?: mutableListOf(ArrayList(Collections.nCopies(25, ":")).apply {
407+
return gson.fromJson(json, listType) ?: mutableListOf(ArrayList(Collections.nCopies(mappingMap.size, ":")).apply {
404408
this[0] = "default"
405409
this[mappingMap[DEAD_ZONE]!!] = "25"
406410
this[mappingMap[MOUSE_SENSIBILITY]!!] = "100"

app/src/main/java/com/micewine/emu/controller/ControllerUtils.kt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import android.view.KeyEvent.KEYCODE_BUTTON_R1
1111
import android.view.KeyEvent.KEYCODE_BUTTON_R2
1212
import android.view.KeyEvent.KEYCODE_BUTTON_SELECT
1313
import android.view.KeyEvent.KEYCODE_BUTTON_START
14+
import android.view.KeyEvent.KEYCODE_BUTTON_THUMBL
15+
import android.view.KeyEvent.KEYCODE_BUTTON_THUMBR
1416
import android.view.KeyEvent.KEYCODE_BUTTON_X
1517
import android.view.KeyEvent.KEYCODE_BUTTON_Y
1618
import android.view.MotionEvent
@@ -43,6 +45,8 @@ import com.micewine.emu.activities.ControllerMapper.Companion.BUTTON_R1_KEY
4345
import com.micewine.emu.activities.ControllerMapper.Companion.BUTTON_R2_KEY
4446
import com.micewine.emu.activities.ControllerMapper.Companion.BUTTON_SELECT_KEY
4547
import com.micewine.emu.activities.ControllerMapper.Companion.BUTTON_START_KEY
48+
import com.micewine.emu.activities.ControllerMapper.Companion.BUTTON_THUMBL_KEY
49+
import com.micewine.emu.activities.ControllerMapper.Companion.BUTTON_THUMBR_KEY
4650
import com.micewine.emu.activities.ControllerMapper.Companion.BUTTON_X_KEY
4751
import com.micewine.emu.activities.ControllerMapper.Companion.BUTTON_Y_KEY
4852
import com.micewine.emu.activities.ControllerMapper.Companion.SELECTED_CONTROLLER_PRESET_KEY
@@ -83,6 +87,8 @@ object ControllerUtils {
8387
private lateinit var axisHatY_plus_mapping: List<Int>
8488
private lateinit var axisHatX_minus_mapping: List<Int>
8589
private lateinit var axisHatY_minus_mapping: List<Int>
90+
private lateinit var buttonThumbR_mapping: List<Int>
91+
private lateinit var buttonThumbL_mapping: List<Int>
8692

8793
private var deadZone: Float = 0F
8894
private var moveVMouse: Int? = null
@@ -144,6 +150,9 @@ object ControllerUtils {
144150
buttonL1_mapping = detectKey(context, BUTTON_L1_KEY)
145151
buttonL2_mapping = detectKey(context, BUTTON_L2_KEY)
146152

153+
buttonThumbL_mapping = detectKey(context, BUTTON_THUMBL_KEY)
154+
buttonThumbR_mapping = detectKey(context, BUTTON_THUMBR_KEY)
155+
147156
buttonStart_mapping = detectKey(context, BUTTON_START_KEY)
148157
buttonSelect_mapping = detectKey(context, BUTTON_SELECT_KEY)
149158

@@ -267,6 +276,18 @@ object ControllerUtils {
267276
true
268277
}
269278

279+
KEYCODE_BUTTON_THUMBR -> {
280+
handleKey(lorieView, pressed, buttonThumbR_mapping)
281+
282+
true
283+
}
284+
285+
KEYCODE_BUTTON_THUMBL -> {
286+
handleKey(lorieView, pressed, buttonThumbL_mapping)
287+
288+
true
289+
}
290+
270291
else -> false
271292
}
272293
}

app/src/main/java/com/micewine/emu/fragments/ControllerMapperFragment.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ import com.micewine.emu.activities.ControllerMapper.Companion.BUTTON_R1_KEY
2828
import com.micewine.emu.activities.ControllerMapper.Companion.BUTTON_R2_KEY
2929
import com.micewine.emu.activities.ControllerMapper.Companion.BUTTON_SELECT_KEY
3030
import com.micewine.emu.activities.ControllerMapper.Companion.BUTTON_START_KEY
31+
import com.micewine.emu.activities.ControllerMapper.Companion.BUTTON_THUMBL_KEY
32+
import com.micewine.emu.activities.ControllerMapper.Companion.BUTTON_THUMBR_KEY
3133
import com.micewine.emu.activities.ControllerMapper.Companion.BUTTON_X_KEY
3234
import com.micewine.emu.activities.ControllerMapper.Companion.BUTTON_Y_KEY
3335
import com.micewine.emu.adapters.AdapterSettingsController
@@ -69,6 +71,8 @@ class ControllerMapperFragment : Fragment() {
6971
addToAdapter(R.drawable.lt_button, BUTTON_L2_KEY)
7072
addToAdapter(R.drawable.start_button, BUTTON_START_KEY)
7173
addToAdapter(R.drawable.select_button, BUTTON_SELECT_KEY)
74+
addToAdapter(R.drawable.l_thumb, BUTTON_THUMBL_KEY)
75+
addToAdapter(R.drawable.r_thumb, BUTTON_THUMBR_KEY)
7276
addToAdapter(R.drawable.l_right, AXIS_X_PLUS_KEY)
7377
addToAdapter(R.drawable.l_left, AXIS_X_MINUS_KEY)
7478
addToAdapter(R.drawable.l_down, AXIS_Y_PLUS_KEY)
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="32dp"
3+
android:height="32dp"
4+
android:viewportWidth="6.35"
5+
android:viewportHeight="6.35">
6+
7+
<path
8+
android:fillColor="@color/white"
9+
android:pathData="M3.175,3.175m-3.175,0a3.175,3.175 0,1 1,6.35 0a3.175,3.175 0,1 1,-6.35 0"
10+
android:strokeWidth="0.264583" />
11+
12+
<path
13+
android:fillColor="@color/black"
14+
android:pathData="M3.175,3.175m-2.9308,0a2.9308,2.9308 0,1 1,5.8615 0a2.9308,2.9308 0,1 1,-5.8615 0"
15+
android:strokeWidth="0.264583" />
16+
17+
<path
18+
android:fillColor="@color/white"
19+
android:pathData="M3.175,3.175m-2.6865,0a2.6865,2.6865 0,1 1,5.3731 0a2.6865,2.6865 0,1 1,-5.3731 0"
20+
android:strokeWidth="0.264583" />
21+
22+
<path
23+
android:fillColor="@color/black"
24+
android:pathData="m4.3524,4.7625h-1.8756v-3.1493h0.7093v2.5739h1.1663z"
25+
android:strokeWidth="0.264583" />
26+
27+
</vector>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="32dp"
3+
android:height="32dp"
4+
android:viewportWidth="6.35"
5+
android:viewportHeight="6.35">
6+
7+
<path
8+
android:fillColor="#ffffff"
9+
android:pathData="M3.175,3.175m-3.175,0a3.175,3.175 0,1 1,6.35 0a3.175,3.175 0,1 1,-6.35 0"
10+
android:strokeWidth="0.264583" />
11+
12+
<path
13+
android:fillColor="#000000"
14+
android:pathData="M3.175,3.175m-2.9308,0a2.9308,2.9308 0,1 1,5.8615 0a2.9308,2.9308 0,1 1,-5.8615 0"
15+
android:strokeWidth="0.264583" />
16+
17+
<path
18+
android:fillColor="#ffffff"
19+
android:pathData="M3.175,3.175m-2.6865,0a2.6865,2.6865 0,1 1,5.3731 0a2.6865,2.6865 0,1 1,-5.3731 0"
20+
android:strokeWidth="0.264583" />
21+
22+
<path
23+
android:fillColor="#040405"
24+
android:pathData="m4.722,4.7625h-0.8147l-0.4897,-0.8104c-0.0368,-0.0614 -0.072,-0.1164 -0.1056,-0.1648 -0.0336,-0.0481 -0.068,-0.0892 -0.1032,-0.1228 -0.0336,-0.0352 -0.0696,-0.0617 -0.1077,-0.0791 -0.0365,-0.0191 -0.0767,-0.0286 -0.1207,-0.0286h-0.1913v1.2057h-0.7093v-3.1493h1.1245c0.7644,0 1.1464,0.2855 1.1464,0.8565 0,0.1098 -0.0167,0.2117 -0.0505,0.3053 -0.0336,0.0921 -0.0812,0.1757 -0.1426,0.2503 -0.0617,0.0746 -0.1363,0.1392 -0.2241,0.1934 -0.0863,0.054 -0.1831,0.0966 -0.29,0.1273v0.0087c0.0471,0.0148 0.0923,0.0389 0.1363,0.0725 0.0439,0.0323 0.0865,0.0704 0.1275,0.1143 0.041,0.0439 0.0796,0.0916 0.1164,0.1426 0.0378,0.0497 0.0722,0.0989 0.1032,0.1471zM2.7892,2.1445v0.8763h0.3077c0.1521,0 0.2744,-0.0439 0.3667,-0.1318 0.0937,-0.0892 0.1405,-0.1998 0.1405,-0.3315 0,-0.2752 -0.1646,-0.413 -0.4942,-0.413z"
25+
android:strokeWidth="0.264583" />
26+
27+
</vector>

app/src/main/res/drawable/l_thumb.xml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="32dp"
3+
android:height="32dp"
4+
android:viewportWidth="6.35"
5+
android:viewportHeight="6.35">
6+
7+
<path
8+
android:fillColor="@color/black"
9+
android:pathData="M3.175,3.175m-3.175,0a3.175,3.175 0,1 1,6.35 0a3.175,3.175 0,1 1,-6.35 0"
10+
android:strokeWidth="0.264583" />
11+
12+
<path
13+
android:fillColor="@color/white"
14+
android:pathData="M3.175,3.175m-2.9308,0a2.9308,2.9308 0,1 1,5.8615 0a2.9308,2.9308 0,1 1,-5.8615 0"
15+
android:strokeWidth="0.264583" />
16+
17+
<path
18+
android:fillColor="@color/black"
19+
android:pathData="M3.175,3.175m-2.6865,0a2.6865,2.6865 0,1 1,5.3731 0a2.6865,2.6865 0,1 1,-5.3731 0"
20+
android:strokeWidth="0.264583" />
21+
22+
<path
23+
android:fillColor="@color/white"
24+
android:pathData="m4.3524,4.7625h-1.8756v-3.1493h0.7093v2.5739h1.1663z"
25+
android:strokeWidth="0.264583" />
26+
27+
</vector>

app/src/main/res/drawable/r_thumb.xml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="32dp"
3+
android:height="32dp"
4+
android:viewportWidth="6.35"
5+
android:viewportHeight="6.35">
6+
7+
<path
8+
android:fillColor="@color/black"
9+
android:pathData="M3.175,3.175m-3.175,0a3.175,3.175 0,1 1,6.35 0a3.175,3.175 0,1 1,-6.35 0"
10+
android:strokeWidth="0.264583" />
11+
12+
<path
13+
android:fillColor="@color/white"
14+
android:pathData="M3.175,3.175m-2.9308,0a2.9308,2.9308 0,1 1,5.8615 0a2.9308,2.9308 0,1 1,-5.8615 0"
15+
android:strokeWidth="0.264583" />
16+
17+
<path
18+
android:fillColor="@color/black"
19+
android:pathData="M3.175,3.175m-2.6865,0a2.6865,2.6865 0,1 1,5.3731 0a2.6865,2.6865 0,1 1,-5.3731 0"
20+
android:strokeWidth="0.264583" />
21+
22+
<path
23+
android:fillColor="@color/white"
24+
android:pathData="m4.722,4.7625h-0.8147l-0.4897,-0.8104c-0.0368,-0.0614 -0.072,-0.1164 -0.1056,-0.1648 -0.0336,-0.0481 -0.068,-0.0892 -0.1032,-0.1228 -0.0336,-0.0352 -0.0696,-0.0617 -0.1077,-0.0791 -0.0365,-0.0191 -0.0767,-0.0286 -0.1207,-0.0286h-0.1913v1.2057h-0.7093v-3.1493h1.1245c0.7644,0 1.1464,0.2855 1.1464,0.8565 0,0.1098 -0.0167,0.2117 -0.0505,0.3053 -0.0336,0.0921 -0.0812,0.1757 -0.1426,0.2503 -0.0617,0.0746 -0.1363,0.1392 -0.2241,0.1934 -0.0863,0.054 -0.1831,0.0966 -0.29,0.1273v0.0087c0.0471,0.0148 0.0923,0.0389 0.1363,0.0725 0.0439,0.0323 0.0865,0.0704 0.1275,0.1143 0.041,0.0439 0.0796,0.0916 0.1164,0.1426 0.0378,0.0497 0.0722,0.0989 0.1032,0.1471zM2.7892,2.1445v0.8763h0.3077c0.1521,0 0.2744,-0.0439 0.3667,-0.1318 0.0937,-0.0892 0.1405,-0.1998 0.1405,-0.3315 0,-0.2752 -0.1646,-0.413 -0.4942,-0.413z"
25+
android:strokeWidth="0.264583" />
26+
27+
</vector>

0 commit comments

Comments
 (0)