mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-10 10:34:06 +09:00
gamepad keyboard mockup
This commit is contained in:
@@ -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 {
|
||||
|
||||
}*/
|
||||
@@ -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 {
|
||||
|
||||
21
src/net/torvald/terrarum/controller/VirtualKeyboard.kt
Normal file
21
src/net/torvald/terrarum/controller/VirtualKeyboard.kt
Normal 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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user