gptokeyb2
was written with the idea of it running in a state machine. Wheras the old one was fixed keybindings the new one supports multiple control states which can be moved between.
Original gptokeyb
support _hk
suffix for keys. This allowed you to hold the hotkey
and press the key for an additional keybinding.
This can be replicated in gptokeyb2
by writing a hotkey state, the example below is the .gptk file from Augustus:
back = esc
start = p # Pause
a = mouse_left
b = mouse_right
x = q # Clone building under mouse cursor
l1_hk = u # Decrease game speed
l2 = end # Rotate counter clock wise
l2_hk = f1 # Save Quicksave
l2_hk = add_ctrl
r1 = mouse_slow
r1_hk = + # Increase game speed
r2 = home # Rotate clock wise
r2_hk = f1 # Load Quicksave
up = up
down = down
left = left
right = right
left_analog_up = mouse_movement_up
left_analog_down = mouse_movement_down
left_analog_left = mouse_movement_left
left_analog_right = mouse_movement_right
right_analog_up = up
right_analog_up = repeat
right_analog_down = down
right_analog_down = repeat
right_analog_left = left
right_analog_left = repeat
right_analog_right = right
right_analog_right = repeat
deadzone_triggers = 3000
mouse_scale = 6114
mouse_delay = 16
deadzone_mode = axial
deadzone = 1000
deadzone_scale = 7
deadzone_delay = 16
In gptokeyb2
this can be achieved by writing.
[config]
repeat_delay = 500
repeat_rate = 60
mouse_slow_scale = 50
deadzone_mode = axial
deadzone_scale = 7
deadzone_x = 1000
deadzone_y = 1000
deadzone_triggers = 3000
dpad_mouse_normalize = true
[controls]
a = "mouse_left"
b = "mouse_right"
x = "q" # Clone building under mouse cursor
y =
l1 =
l2 = "end" # Rotate counter clock wise
l3 =
r1 = mouse_slow
r2 = "home" # Rotate clock wise
r3 =
start = "p" # Pause
back = "esc"
guide =
dpad = mouse_movement
left_analog = mouse_movement
right_analog = arrow_keys repeat
hotkey = hold_state hotkey
[controls:hotkey]
l1 = u # Decrease game speed
l2 = f1 add_ctrl # Save Quicksave
r1 = + # Increase game speed
r2 = f1 # Load Quicksave
Ever needed an abundance of buttons for a roguelike?
In the example below you can see that abxy has different bindings using hold_state
layering. With that you can create keybindings for different buttons depending on whether the l2
, r2
, or l2
& r2
are held down.
[controls]
overlay = clear
x = i
b = k
y = j
a = l
l2 = hold_state hotkey1
r2 = hold_state hotkey2
[controls:hotkey1]
overlay = parent
r2 = hold_state hotkey_both
x = g
b = h
y = y
a = t
[controls:hotkey2]
overlay = parent
l2 = hold_state hotkey_both
x = e
b = 6
y = 7
a = 8
[controls:hotkey_both]
overlay = parent
x = p
b = o
y = m
a = n
Here it is broken down:
-
Initial Controls:
- The initial configuration defines the mappings for the gamepad buttons to keyboard keys.
l2
andr2
are mapped to switch between different states (hotkey1
,hotkey2
, andhotkey_both
).x
,b
,y
, anda
are mapped to the keysi
,k
,j
, andl
respectively.
-
State:
hotkey1
:- This state defines a sub-layer where the mappings change when
hotkey1
is held. - The
overlay
directive specifies that this state inherits mappings from the parent state (clear
in this case). - The mappings for
x
,b
,y
, anda
change tog
,h
,y
, andt
respectively whenhotkey1
is held. r2
changes the state tohotkey_both
when held.
- This state defines a sub-layer where the mappings change when
-
State:
hotkey2
:- Similar to
hotkey1
, this state defines a sub-layer with different mappings whenhotkey2
is held. - Again, it inherits mappings from the parent state.
- The mappings for
x
,b
,y
, anda
change toe
,6
,7
, and8
respectively whenhotkey2
is held. l2
changes the state tohotkey_both
when held.
- Similar to
-
State:
hotkey_both
:- This state represents a situation where both
hotkey1
andhotkey2
are held simultaneously. - It inherits mappings from the parent state.
- The mappings for
x
,b
,y
, anda
change top
,o
,m
, andn
respectively when bothhotkey1
andhotkey2
are held.
- This state represents a situation where both