Last active
October 22, 2018 19:24
-
-
Save Gikkman/53c0527c01289ff53e20e8ff125bbb7b to your computer and use it in GitHub Desktop.
BizHawk input lua
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- Pre-made array for resetting the P1 joypad | |
| local reset = joypad.get(1) | |
| for k,v in pairs(reset) do | |
| reset[k] = '' | |
| end | |
| event.onframestart( function() | |
| local p1 = joypad.get(1) | |
| local p2 = joypad.get(2) | |
| local consolidated = intersection(p1, p2) | |
| gui.drawText(0,10, 'P1: ' .. dump(p1)) | |
| gui.drawText(0,25, 'P2: ' .. dump(p2)) | |
| joypad.set(consolidated, 1) | |
| end ) | |
| event.onframeend( function() | |
| joypad.set(reset, 1) | |
| end ) | |
| -- Get intersection of P1 and P2 joypads | |
| function intersection(p1, p2) | |
| local ret = {} | |
| for k,v in pairs(p1) do | |
| ret[k] = p1[k] and p2[k] | |
| end | |
| return ret | |
| end | |
| -- Print all pressed buttons | |
| function dump(o) | |
| local s = '' | |
| for k,v in pairs(o) do | |
| if v then s = s .. tostring(k) .. ' ' end | |
| end | |
| return s | |
| end | |
| -------------------------------------- | |
| -- Main loop -- | |
| -------------------------------------- | |
| while true do | |
| emu.frameadvance() | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment