Controller Support Expansion for Ren’Py includes several features to improve controller and keyboard support in Ren’Py. Pick up the tool from itch.io if you haven’t already:
ControllerBar
ControllerBar is a controller- and keyboard-friendly bar variant which does not need to be grabbed to be adjusted. controller_bar
is horizontal and can be controlled immediately with left/right input, and controller_vbar
is vertical and can be controlled with up/down input. It is intended for bars which will be adjusted by the user; if a bar’s value is controlled by the game (e.g. a health bar), then a regular bar
/vbar
is sufficient.
ControllerBar takes all the same properties as a regular bar does; see https://www.renpy.org/doc/html/screens.html#bar for more information. It also functions identically to a regular bar when the mouse is used; the only changes are for when the bar gains focus with the arrow keys or controller directional inputs.
Examples
controller_bar
is for horizontal bars. It’s useful for most preferences screens.
vbox:
label _("Text Speed")
controller_bar value Preference("text speed")
controller_vbar
is similar, but creates a vertical bar rather than a horizontal one (like vbar
vs bar
). This can be used for preference screens or gameplay options as well. For scroll bars, I recommend using the Controller Viewport instead.
hbox:
label _("Music Volume")
controller_vbar value Preference("music volume") style "my_music_bar"
You can also provide your own adjustable values:
screen battle():
controller_bar:
value FieldValue(player, "health", range=100)
align (1.0, 0.0) ysize 50 xsize 200
Design Notes
ControllerBar is best used when the bar in question is part of a column (for controller_bar
) or row (for controller_vbar
) of other items. Due to how the bar is auto-selected once focused, you will be unable to use left/right input for controller_bar
to focus anything to the left or right of the bar, since it will adjust the value of the bar rather than focusing an item to the left/right. The same applies to up/down input for controller_vbar
. In more concrete terms, layouts like this work best with controller and keyboard navigation:
In this example, the bars are focused using the up/down inputs, and left/right is solely for adjusting the bar value. Other shortcuts are used to navigate to different pages or dismiss the menu.