gamepad keyboard mockup

This commit is contained in:
minjaesong
2019-04-15 12:26:54 +09:00
parent bda58ecebd
commit 62b687c86b
8 changed files with 63 additions and 5 deletions

View File

@@ -0,0 +1,27 @@
package net.torvald.terrarum.controller
/**
* Created by minjaesong on 2019-04-10.
*/
object GamepadVirtualKeyboard : VirtualKeyboard(20) {
val keyLayoutAlph = arrayOf(
"abcdef", "ghijkl", "mnopqr", "stuvwx", "yzçñßı", "æøþð˚,", "´`ˆ¨ˇ~˛", ".-,/!?", // normal
"ABCDEF", "GHIJKL", "MNOPQR", "STUVWX", "YZÇÑẞİ", "ÆØÞÐ˚,", "´`ˆ¨ˇ~˛", ".-,/!?" // shift
)
// note: aeiou-cedila must produce ogonek instead.
// aeiouszc-caron must be produced as-is. Otherwise breve is produced instead.
val keyLayoutSym = arrayOf(
"12345,", "67890.", "-/:;()", "&@?!'\"", "—#%^*+", "=_\\|<>", "·¤[]{}", "«»•"
)
override fun takeFromInputBuffer() {
TODO("not implemented")
}
}
/*class GamepadVirtualKeyboardUI : UICanvas {
}*/

View File

@@ -50,9 +50,10 @@ interface TerrarumController {
fun getAxis(index:Int): Float {
val raw = getAxisRaw(index)
val zero = if (index < 4) getConfigFloatArray("gamepadaxiszeropoints")[index] else 0f
val inDeadzone = Math.abs(raw - zero) < gamepadDeadzone
val compensatedRaw = raw - zero
val inDeadzone = Math.abs(compensatedRaw) < gamepadDeadzone
return if (inDeadzone) 0f else raw
return if (inDeadzone) 0f else raw//compensatedRaw // returning raw makes more sense
}
fun inDeadzone(axis: Int): Boolean {

View File

@@ -0,0 +1,21 @@
package net.torvald.terrarum.controller
import net.torvald.util.CircularArray
/**
* Created by minjaesong on 2019-04-10.
*/
abstract class VirtualKeyboard(val BUFFER_SIZE: Int = DEFAULT_BUFFER_SIZE) {
val inputBuffer = CircularArray<Char>(BUFFER_SIZE)
abstract fun takeFromInputBuffer()
fun addToBuffer(char: Char) {
inputBuffer.add(char)
}
companion object {
const val DEFAULT_BUFFER_SIZE = 20
}
}