ianpatt / f4se

Fallout 4 Script Extender
https://f4se.silverlock.org
120 stars 24 forks source link

Gamepad button events #16

Closed TommInfinite closed 2 years ago

TommInfinite commented 2 years ago

A modder asked for gamepad button event functions which return raw xInput button codes. This commit adds new 2 F4SE functions and 2 new events(can be copied to the end of "ScriptObject.psc"):

Function RegisterForGamepadButton(int key) native Function UnregisterForGamepadButton(int key) native

Event OnGamepadButtonDown(int keyCode) EndEvent

Event OnGamepadButtonUp(int keyCode, float time) EndEvent

Papyrys test code:

Event OnGamepadButtonDown(int keyCode) Debug.Notification("GAMEPAD buttonDOWN>>>" + keyCode ) EndEvent

Event OnGamepadButtonUp(int keyCode, float time) Debug.Notification("GAMEPAD buttonUP>>>" + keyCode + ", time is " + time ) EndEvent

Function FunctionInit() RegisterForGamepadButton(1) RegisterForGamepadButton(2) RegisterForGamepadButton(4) RegisterForGamepadButton(8) RegisterForGamepadButton(16) RegisterForGamepadButton(32) RegisterForGamepadButton(64) RegisterForGamepadButton(128) RegisterForGamepadButton(256) RegisterForGamepadButton(512) RegisterForGamepadButton(1024) RegisterForGamepadButton(4096) RegisterForGamepadButton(8192) RegisterForGamepadButton(16384) RegisterForGamepadButton(32768) EndFunction

Feel free to ask any questions, I'm TommInfinite on xSE Discord channel. Sorry for gitiignore in the pull request, I don't know how to get rid of it.

ianpatt commented 2 years ago

Looks cool, thanks for the submission. I need to figure out how to clean up commits before merging, will take a look this weekend.

TommInfinite commented 2 years ago

thanks! gitignore should be removed now.