Controller Support Expansion for Ren’Py is a set of tools that can be added to an existing Ren’Py project to improve support for controllers (and keyboard navigation). It can be found on itch.io for free:
Below are some common questions about the tool and what it can do!
What features does the controller support expansion have?
There are several major features, as well as many quality-of-life (QoL) upgrades. The main features are:
- Controller-friendly viewport (Controller Viewport). It can be scrolled smoothly with the controller sticks, and if you navigate to items inside the viewport with a controller or arrow keys, it will automatically scroll the viewport to keep those items in view.
- By default, if you want to focus an out-of-view item in a viewport in default Ren’Py, you’d need to navigate to a scroll bar, scroll so the item is visible, and then navigate over to it.
- A virtual cursor that can be moved around with the controller sticks and keyboard arrow keys. It can be used like a regular mouse is to highlight and activate buttons, bars, drag and drop, and more. (Virtual Cursor)
- Controller-friendly bars (Controller Bar).
- By default, when you navigate to a bar with a controller or the arrow keys, you have to press the confirm button to “activate” the bar before it can be adjusted, and then press the select button again to deactivate the bar.
- The controller-friendly version skips this activate/deactivate step and makes the bar immediately available to adjust when it’s focused.
- An on-screen keyboard that will optionally show up if the player is using a controller to handle input, so players with a controller can type their name without needing a keyboard. (Virtual Keyboard)
- A method to specify an action that should happen if a key is pressed while a particular button is focused. This includes instructions like “if the dresser is focused and the player hits ‘up’, focus the mirror” to help solve focus issues, and also more complex gameplay features like “if the player hovers ‘Eileen’ and hits ‘i’, bring up the ‘investigate’ dialogue”. (KeyController and focused_on)
- A displayable that follows the currently focused item to help highlight it. This can be something like a pointer finger or a frame surrounding the currently focused button. It’s particularly helpful when turning a UI made for a mouse & keyboard setup into a controller-friendly one, as it helps the player see where the focus currently is. (FocusDisplayable)
- The ability for players to remap controller buttons to different actions, and for developers to add custom controller events. (Remapping Controls)
- A robust system for displaying button icons to the player based on the current input type (mouse/keyboard/controller, with 5 different controller icon sets). (Controller and Keyboard Icons)
- A displayable that can be used to assign actions to a controller stick. (StickEvent)
- Many, many other quality of life features for things like saving and restoring focus on menu screens, callbacks for when controllers are disconnected and reconnected, several preferences to customize stick sensitivity and dead zones, and more.
Where would I use this?
The controller support expansion is designed to be dropped into existing or new Ren’Py projects to improve controller and keyboard support. The various tools are designed to work with both controllers and with a mouse, and often have features to switch functionality on the fly depending on the input type (e.g. hiding the Virtual Cursor when a mouse is used, or only showing the Virtual Keyboard when the last input was with a controller).
With a few exceptions, most of the included tools do require you to update your screens to add the new features (e.g. swapping a bar
for a controller_bar
(Controller Bar)). See the next question for more on that.
What do I need to do to improve controller support with this addon?
There are a few major pitfalls when it comes to controller support for games which can be solved with tools from this expansion:
- Viewports (Controller Viewport)
- Swap out your
viewport
code forcontroller_viewport
so that either the sticks can freely scroll the viewport or focusing items inside it will automatically scroll the viewport - Make any of your scrollbars
keyboard_focus False
so they don’t get in the way of navigation
- Swap out your
- Bars (Controller Bar)
- Swap out your
bar
forcontroller_bar
andvbar
forcontroller_vbar
(except for scrollbars; see above) - Note that this may require some adjustments to your UI layout; see the section on Design in the Controller Bar page.
- Swap out your
- Menu screens
- Add Controller and Keyboard Icons to your screens to make navigating them more understandable
- Check if your screen buttons can be easily navigated with just the arrow keys/a controller stick. If some buttons don’t have the focus relationship you want, use KeyController and focused_on to fix it, or consider using the Virtual Cursor.
- If it’s hard to see what’s focused, update your hover states or use the FocusDisplayable.
- Input
- If you use
renpy.input
, you can leave it as-is, since it’s automatically overwritten to use theuniversal_input
function instead. - If you have a screen with an InputValue on it, swap it out for UniversalInputToggle.
- Optional – update the styling for the virtual keyboard to match your game.
- If you use
- Other
- Add a section to your preferences screen to adjust things like controller stick inversion, sensitivity, and icon set selection. The pack comes with an example template that has a preferences screen with these options. See also Screen Actions and Values.
- Add a way to get to the button remapping screen included in the pack, so players can remap the controller button. See also Remapping Controls.
- If you’ve got any drag and drop features in your game, use the Virtual Cursor.
- Consider making controller-specific variants of screens, such as the quick menu, which have Controller and Keyboard Icons instead of a set of buttons to navigate to and press. Function calls like
pad_config.is_using_controller()
will help here – see Helper Functions and Classes.
Above all, be sure to test your game with a controller and keyboard as much as possible to make sure it is simple and intuitive to navigate!
Does this work with the Steam Deck?
Yes, it will work with a Steam Deck! It helps improve the usability of all non-mouse/touchscreen input types; the Steam Deck, being a device with analogue sticks, benefits from these usability improvements.
Of note for Steam releases as well are the controller connect/disconnect callbacks (see Configuration Variables) which can be used to pause the game when a controller is disconnected for better Steam controller support compliance.
Does this expansion only support controllers? What about keyboards?
The Controller Support Expansion improves focus issues for any non-mouse/touch input type, including keyboards. Tools such as the Virtual Cursor include the option to use the keyboard keys to move the cursor, as well as the analogue sticks. Players can readily switch between mouse, keyboard, and controller input at any time during gameplay and the tool has features designed to handle these changes seamlessly.