Hello!
Trying to figure out how to predefine gamepad keys for some events, like pressing Menu button in gamepad opens ingame menu or pressing B key returns player one step back. By default only A key (Select/Dismiss) and directional buttons are assigned.
I can configure it from layout.classic_joystick_preferences without problems but I want to deliver game to players with already predefined gamepad keys so they do not need to enter preferences and define keys
Any help?
Joystick keybind
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
- Desufagkun
- Newbie
- Posts: 11
- Joined: Mon Oct 20, 2008 9:35 am
- Projects: iichan erogame
- Location: Russia
- Contact:
- nyaatrap
- Crawling Chaos
- Posts: 1824
- Joined: Mon Feb 13, 2012 5:37 am
- Location: Kimashi Tower, Japan
- Contact:
Re: Joystick keybind
Coied form my game
Code: Select all
init python:
if persistent.firstboot is None:
_preferences.joymap['joy_dissmiss'] = "Button 0.0"
_preferences.joymap['joy_menu'] = "Button 0.1"
_preferences.joymap['joy_hide'] = "Button 0.2"
_preferences.joymap['joy_rollback'] = "Button 0.3"
_preferences.joymap['joy_skip'] = "Button 0.4"
persistent.firstboot=True- Desufagkun
- Newbie
- Posts: 11
- Joined: Mon Oct 20, 2008 9:35 am
- Projects: iichan erogame
- Location: Russia
- Contact:
Re: Joystick keybind
nyaatrap, thank you!
And another question. Is it possible to map Dpad buttons? Currently only navigation with left stick works. Tested with xbox 360 and generic DirectInput controllers.
And another question. Is it possible to map Dpad buttons? Currently only navigation with left stick works. Tested with xbox 360 and generic DirectInput controllers.
- Desufagkun
- Newbie
- Posts: 11
- Joined: Mon Oct 20, 2008 9:35 am
- Projects: iichan erogame
- Location: Russia
- Contact:
Re: Joystick keybind
Well. Figured that out by myself. Now I can bind D-Pad buttons. Modified \renpy\display\joystick.py
Added new section before if ev.type == pygame.JOYBUTTONDOWN::
P.S. Code is not perfect because I don't know python.. But it works for me.
Added new section before if ev.type == pygame.JOYBUTTONDOWN::
Code: Select all
if ev.type == pygame.JOYHATMOTION:
if not renpy.display.interface.focused:
return None
press = None
if (ev.value[0] == -1) and (ev.value[1] == 0):
press = "D-PAD Left"
if (ev.value[0] == 1) and (ev.value[1] == 0):
press = "D-PAD Right"
if (ev.value[0] == 0) and (ev.value[1] == 1):
press = "D-PAD Up"
if (ev.value[0] == 0) and (ev.value[1] == -1):
press = "D-PAD Down"
if not press:
return None
return pygame.event.Event(renpy.display.core.JOYEVENT,
press=press,
release=None)Who is online
Users browsing this forum: Google [Bot]
