mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-09 18:14:06 +09:00
pov for gdxcontrolleradapter (untested)
This commit is contained in:
@@ -1,67 +0,0 @@
|
|||||||
{
|
|
||||||
"displayfps": 0,
|
|
||||||
"usevsync": true,
|
|
||||||
|
|
||||||
"imtooyoungtodie": false,
|
|
||||||
"language": "enUS",
|
|
||||||
"notificationshowuptime": 6500,
|
|
||||||
"multithread": true,
|
|
||||||
|
|
||||||
|
|
||||||
"gamepadkeyn": 4,
|
|
||||||
"gamepadkeyw": 1,
|
|
||||||
"gamepadkeys": 2,
|
|
||||||
"gamepadkeye": 3,
|
|
||||||
|
|
||||||
"gamepadlup": 4,
|
|
||||||
"gamepadrup": 5,
|
|
||||||
"gamepadldown": 6,
|
|
||||||
"gamepadrdown": 7,
|
|
||||||
|
|
||||||
"gamepadlstickx": 0,
|
|
||||||
"gamepadlsticky": 1,
|
|
||||||
"gamepadrstickx": 2,
|
|
||||||
"gamepadrsticky": 3,
|
|
||||||
|
|
||||||
"gamepadlabelstyle": "msxb360",
|
|
||||||
|
|
||||||
|
|
||||||
"keyup": 33,
|
|
||||||
"keyleft": 47,
|
|
||||||
"keydown": 32,
|
|
||||||
"keyright": 34,
|
|
||||||
|
|
||||||
"keymovementaux": 29,
|
|
||||||
"keyinventory": 45,
|
|
||||||
"keyinteract": 46,
|
|
||||||
"keyclose": 31,
|
|
||||||
|
|
||||||
"keygamemenu": 61,
|
|
||||||
"keyquicksel": 59,
|
|
||||||
|
|
||||||
"keyquickselalt": [4, 129, 73],
|
|
||||||
|
|
||||||
"keyjump": 62,
|
|
||||||
|
|
||||||
"keyquickbars": [145, 146, 147, 148, 149, 150, 151, 152, 153, 144],
|
|
||||||
|
|
||||||
"mouseprimary": 0,
|
|
||||||
"mousesecondary": 1,
|
|
||||||
|
|
||||||
|
|
||||||
"pcgamepadenv": "console",
|
|
||||||
|
|
||||||
"safetywarning": true,
|
|
||||||
|
|
||||||
|
|
||||||
"maxparticles": 768,
|
|
||||||
|
|
||||||
|
|
||||||
"fullframelightupdate": false,
|
|
||||||
|
|
||||||
"useamericanunit": false,
|
|
||||||
|
|
||||||
|
|
||||||
"fxdither": true,
|
|
||||||
"fx3dlut": false
|
|
||||||
}
|
|
||||||
@@ -42,13 +42,16 @@ object DefaultConfig {
|
|||||||
|
|
||||||
jsonObject.addProperty("gamepadltrigger", 8)
|
jsonObject.addProperty("gamepadltrigger", 8)
|
||||||
jsonObject.addProperty("gamepadrtrigger", 9)
|
jsonObject.addProperty("gamepadrtrigger", 9)
|
||||||
|
jsonObject.addProperty("gamepadlthumb", 10)
|
||||||
|
jsonObject.addProperty("gamepadrthumb", 11)
|
||||||
|
|
||||||
jsonObject.addProperty("gamepadlstickx", 1)
|
|
||||||
jsonObject.addProperty("gamepadlsticky", 0)
|
jsonObject.addProperty("gamepadaxislx", 1)
|
||||||
jsonObject.addProperty("gamepadrstickx", 3)
|
jsonObject.addProperty("gamepadaxisly", 0)
|
||||||
jsonObject.addProperty("gamepadrsticky", 2) // 0-1-2-3 but sometimes 3-2-1-0 ?! what the actual fuck?
|
jsonObject.addProperty("gamepadaxisrx", 3)
|
||||||
|
jsonObject.addProperty("gamepadaxisry", 2) // 0-1-2-3 but sometimes 3-2-1-0 ?! what the actual fuck?
|
||||||
jsonObject.addProperty("gamepadtriggeraxis", 4) // positive: LT, negative: RT (xbox pad)
|
jsonObject.addProperty("gamepadtriggeraxis", 4) // positive: LT, negative: RT (xbox pad)
|
||||||
|
jsonObject.addProperty("gamepadtriggeraxis2", 5) // just in case... (RT)
|
||||||
|
|
||||||
jsonObject.addProperty("gamepadlabelstyle", "msxb360") // "nwii", "logitech", "sonyps", "msxb360", "generic"
|
jsonObject.addProperty("gamepadlabelstyle", "msxb360") // "nwii", "logitech", "sonyps", "msxb360", "generic"
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package net.torvald.terrarum.controller
|
package net.torvald.terrarum.controller
|
||||||
|
|
||||||
import com.badlogic.gdx.controllers.Controller
|
import com.badlogic.gdx.controllers.Controller
|
||||||
|
import com.badlogic.gdx.controllers.PovDirection
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2019-02-09.
|
* Created by minjaesong on 2019-02-09.
|
||||||
@@ -16,11 +17,21 @@ class GdxControllerAdapter(val c: Controller): TerrarumController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun getPov(): Int {
|
override fun getPov(): Int {
|
||||||
TODO()
|
return when(c.getPov(0)) {
|
||||||
|
PovDirection.north -> TerrarumController.POV_N
|
||||||
|
PovDirection.northEast -> TerrarumController.POV_NE
|
||||||
|
PovDirection.northWest -> TerrarumController.POV_NW
|
||||||
|
PovDirection.east -> TerrarumController.POV_E
|
||||||
|
PovDirection.west -> TerrarumController.POV_W
|
||||||
|
PovDirection.south -> TerrarumController.POV_S
|
||||||
|
PovDirection.southEast -> TerrarumController.POV_SE
|
||||||
|
PovDirection.southWest -> TerrarumController.POV_SW
|
||||||
|
else -> 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getName(): String {
|
override fun getName(): String {
|
||||||
return c.name
|
return "DI:"+c.name
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setRumble(left: Float, right: Float) {
|
override fun setRumble(left: Float, right: Float) {
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ interface TerrarumController {
|
|||||||
*
|
*
|
||||||
* 8, 9 : L/R Trigger
|
* 8, 9 : L/R Trigger
|
||||||
*
|
*
|
||||||
|
* 10, 11 : L/R Stick
|
||||||
|
*
|
||||||
* DirectInput devices may need external Index-to-button mapping (just a config file)
|
* DirectInput devices may need external Index-to-button mapping (just a config file)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -50,6 +52,10 @@ interface TerrarumController {
|
|||||||
fun getPov(): Int
|
fun getPov(): Int
|
||||||
fun getName(): String
|
fun getName(): String
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param left left rumble motor, 0f..1f
|
||||||
|
* @param right right rumble moter, 0f..1f
|
||||||
|
*/
|
||||||
fun setRumble(left: Float, right: Float)
|
fun setRumble(left: Float, right: Float)
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|||||||
@@ -6,6 +6,9 @@ import net.torvald.terrarum.AppLoader
|
|||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Note: XInput is a basically a XBOX 360 pad. XBOX One pad and any other compatible pads can be used,
|
||||||
|
* but any additional features (e.g. Impulse Trigger on XBOne) cannot be supported.
|
||||||
|
*
|
||||||
* Created by minjaesong on 2019-02-09.
|
* Created by minjaesong on 2019-02-09.
|
||||||
*/
|
*/
|
||||||
class XinputControllerAdapter(val c: XInputDevice): TerrarumController {
|
class XinputControllerAdapter(val c: XInputDevice): TerrarumController {
|
||||||
@@ -25,6 +28,8 @@ class XinputControllerAdapter(val c: XInputDevice): TerrarumController {
|
|||||||
7 -> button.start
|
7 -> button.start
|
||||||
8 -> getAxis(4) >= AppLoader.gamepadDeadzone
|
8 -> getAxis(4) >= AppLoader.gamepadDeadzone
|
||||||
9 -> getAxis(5) >= AppLoader.gamepadDeadzone
|
9 -> getAxis(5) >= AppLoader.gamepadDeadzone
|
||||||
|
10 -> button.lThumb
|
||||||
|
11 -> button.rThumb
|
||||||
else -> throw UnsupportedOperationException("Unknown button: $index")
|
else -> throw UnsupportedOperationException("Unknown button: $index")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -62,14 +67,14 @@ class XinputControllerAdapter(val c: XInputDevice): TerrarumController {
|
|||||||
XInputAxes.DPAD_DOWN -> TerrarumController.POV_S
|
XInputAxes.DPAD_DOWN -> TerrarumController.POV_S
|
||||||
XInputAxes.DPAD_DOWN_LEFT -> TerrarumController.POV_SW
|
XInputAxes.DPAD_DOWN_LEFT -> TerrarumController.POV_SW
|
||||||
XInputAxes.DPAD_LEFT -> TerrarumController.POV_W
|
XInputAxes.DPAD_LEFT -> TerrarumController.POV_W
|
||||||
else -> throw UnsupportedOperationException("Unknown pov: ${axes.dpad}")
|
else -> 0//throw UnsupportedOperationException("Unknown pov: ${axes.dpad}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getName(): String {
|
override fun getName(): String {
|
||||||
return "(XInput Compatible)"
|
return "(XB360 Compatible)"
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setRumble(left: Float, right: Float) {
|
override fun setRumble(left: Float, right: Float) {
|
||||||
|
|||||||
@@ -228,10 +228,10 @@ open class ActorHumanoid(
|
|||||||
val gamepad = (Terrarum.ingame as Ingame).ingameController.gamepad
|
val gamepad = (Terrarum.ingame as Ingame).ingameController.gamepad
|
||||||
|
|
||||||
if (gamepad != null) {
|
if (gamepad != null) {
|
||||||
axisX = gamepad.getAxis(AppLoader.getConfigInt("gamepadlstickx"))
|
axisX = gamepad.getAxis(AppLoader.getConfigInt("gamepadaxislx"))
|
||||||
axisY = gamepad.getAxis(AppLoader.getConfigInt("gamepadlsticky"))
|
axisY = gamepad.getAxis(AppLoader.getConfigInt("gamepadaxisly"))
|
||||||
axisRX = gamepad.getAxis(AppLoader.getConfigInt("gamepadrstickx"))
|
axisRX = gamepad.getAxis(AppLoader.getConfigInt("gamepadaxisrx"))
|
||||||
axisRY = gamepad.getAxis(AppLoader.getConfigInt("gamepadrsticky"))
|
axisRY = gamepad.getAxis(AppLoader.getConfigInt("gamepadaxisry"))
|
||||||
|
|
||||||
// deadzonning
|
// deadzonning
|
||||||
if (Math.abs(axisX) < AppLoader.gamepadDeadzone) axisX = 0f
|
if (Math.abs(axisX) < AppLoader.gamepadDeadzone) axisX = 0f
|
||||||
|
|||||||
@@ -195,8 +195,8 @@ class BasicDebugInfoWindow : UICanvas() {
|
|||||||
val gamepad = (Terrarum.ingame as? Ingame)?.ingameController?.gamepad
|
val gamepad = (Terrarum.ingame as? Ingame)?.ingameController?.gamepad
|
||||||
if (gamepad != null) {
|
if (gamepad != null) {
|
||||||
drawGamepadAxis(gamepad, batch,
|
drawGamepadAxis(gamepad, batch,
|
||||||
gamepad.getAxis(AppLoader.getConfigInt("gamepadlstickx")),
|
gamepad.getAxis(AppLoader.getConfigInt("gamepadaxislx")),
|
||||||
gamepad.getAxis(AppLoader.getConfigInt("gamepadlsticky")),
|
gamepad.getAxis(AppLoader.getConfigInt("gamepadaxisly")),
|
||||||
Terrarum.WIDTH - 135,
|
Terrarum.WIDTH - 135,
|
||||||
40
|
40
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user