DEADSOFTWARE

Add tooltips
[cavedroid.git] / core / src / ru / deadsoftware / cavedroid / game / input / mapper / KeyboardInputActionMapper.kt
1 package ru.deadsoftware.cavedroid.game.input.mapper
3 import com.badlogic.gdx.Input
4 import ru.deadsoftware.cavedroid.game.GameScope
5 import ru.deadsoftware.cavedroid.game.input.action.KeyboardInputAction
6 import ru.deadsoftware.cavedroid.game.input.action.keys.KeyboardInputActionKey
7 import javax.inject.Inject
9 @GameScope
10 class KeyboardInputActionMapper @Inject constructor() {
12 fun map(key: Int, isKeyDown: Boolean): KeyboardInputAction? {
13 val actionKey = when (key) {
14 Input.Keys.A, Input.Keys.LEFT -> KeyboardInputActionKey.Left
15 Input.Keys.D, Input.Keys.RIGHT -> KeyboardInputActionKey.Right
16 Input.Keys.W, Input.Keys.SPACE -> KeyboardInputActionKey.Up
17 Input.Keys.S -> KeyboardInputActionKey.Down
19 Input.Keys.E -> KeyboardInputActionKey.OpenInventory
20 Input.Keys.ALT_LEFT -> KeyboardInputActionKey.SwitchControlsMode
22 Input.Keys.ESCAPE, Input.Keys.BACK -> KeyboardInputActionKey.Pause
24 Input.Keys.F1 -> KeyboardInputActionKey.ShowDebug
25 Input.Keys.GRAVE -> KeyboardInputActionKey.SwitchGameMode
26 Input.Keys.M -> KeyboardInputActionKey.ShowMap
28 Input.Keys.Q -> KeyboardInputActionKey.DropItem
30 Input.Keys.NUM_1 -> KeyboardInputActionKey.SelectHotbarSlot(0)
31 Input.Keys.NUM_2 -> KeyboardInputActionKey.SelectHotbarSlot(1)
32 Input.Keys.NUM_3 -> KeyboardInputActionKey.SelectHotbarSlot(2)
33 Input.Keys.NUM_4 -> KeyboardInputActionKey.SelectHotbarSlot(3)
34 Input.Keys.NUM_5 -> KeyboardInputActionKey.SelectHotbarSlot(4)
35 Input.Keys.NUM_6 -> KeyboardInputActionKey.SelectHotbarSlot(5)
36 Input.Keys.NUM_7 -> KeyboardInputActionKey.SelectHotbarSlot(6)
37 Input.Keys.NUM_8 -> KeyboardInputActionKey.SelectHotbarSlot(7)
38 Input.Keys.NUM_9 -> KeyboardInputActionKey.SelectHotbarSlot(8)
40 else -> null
41 }
43 return actionKey?.let { KeyboardInputAction(it, isKeyDown) }
44 }
46 }