mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 12:21:52 +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
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,6 @@ import com.badlogic.gdx.graphics.*
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.badlogic.gdx.graphics.glutils.FrameBuffer
|
||||
import com.badlogic.gdx.utils.ScreenUtils
|
||||
import net.torvald.util.CircularArray
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
import net.torvald.terrarum.gamecontroller.KeyToggler
|
||||
@@ -16,6 +15,7 @@ import net.torvald.terrarum.modulebasegame.gameworld.GameWorldExtension
|
||||
import net.torvald.terrarum.modulebasegame.weather.WeatherMixer
|
||||
import net.torvald.terrarum.ui.UICanvas
|
||||
import net.torvald.terrarum.worlddrawer.*
|
||||
import net.torvald.util.CircularArray
|
||||
import javax.swing.JFileChooser
|
||||
|
||||
/**
|
||||
|
||||
@@ -13,6 +13,7 @@ import net.torvald.terrarum.ModMgr
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
import net.torvald.terrarum.gamecontroller.KeyToggler
|
||||
import net.torvald.terrarum.gdxSetBlendNormal
|
||||
import net.torvald.terrarum.modulebasegame.Ingame
|
||||
import net.torvald.terrarum.modulebasegame.RNGConsumer
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.ParticleMegaRain
|
||||
@@ -154,12 +155,13 @@ internal object WeatherMixer : RNGConsumer {
|
||||
val bottomCol = getGradientColour(skyboxColourMap, 1, timeNow)
|
||||
|
||||
//Terrarum.textureWhiteSquare.bind(0)
|
||||
gdxSetBlendNormal()
|
||||
|
||||
Terrarum.shaderSkyboxFill.begin()
|
||||
Terrarum.shaderSkyboxFill.setUniformMatrix("u_projTrans", camera.combined)
|
||||
Terrarum.shaderSkyboxFill.setUniformf("topColor", topCol.r, topCol.g, topCol.b)
|
||||
Terrarum.shaderSkyboxFill.setUniformf("bottomColor", bottomCol.r, bottomCol.g, bottomCol.b)
|
||||
Terrarum.shaderSkyboxFill.setUniformf("parallax", parallax)
|
||||
Terrarum.shaderSkyboxFill.setUniformf("parallax", parallax.coerceIn(-1f, 1f))
|
||||
Terrarum.shaderSkyboxFill.setUniformf("parallax_size", 1f/3f)
|
||||
Terrarum.fullscreenQuad.render(Terrarum.shaderSkyboxFill, GL20.GL_TRIANGLES)
|
||||
Terrarum.shaderSkyboxFill.end()
|
||||
|
||||
@@ -213,8 +213,9 @@ abstract class UICanvas(
|
||||
}
|
||||
/** Called by the screen's InputProcessor */
|
||||
open fun keyTyped(character: Char): Boolean {
|
||||
// TODO process key typing from the virtual keyboard?
|
||||
|
||||
return false
|
||||
//uiItems.forEach { it.keyT }
|
||||
}
|
||||
|
||||
open fun resize(width: Int, height: Int) {
|
||||
|
||||
BIN
work_files/UI/virtual_gamepad_keyboard.psd
LFS
Normal file
BIN
work_files/UI/virtual_gamepad_keyboard.psd
LFS
Normal file
Binary file not shown.
BIN
work_files/UI/virtual_gamepad_keyboard_2.psd
LFS
Normal file
BIN
work_files/UI/virtual_gamepad_keyboard_2.psd
LFS
Normal file
Binary file not shown.
Reference in New Issue
Block a user