Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Enable multitap #130

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,10 @@ func LoadGame(gamePath string) error {
state.Global.Unlock()

state.Global.Core.SetControllerPortDevice(0, libretro.DeviceJoypad)
state.Global.Core.SetControllerPortDevice(1, libretro.DeviceJoypad)
state.Global.Core.SetControllerPortDevice(1, (1<<8)|libretro.DeviceJoypad)
state.Global.Core.SetControllerPortDevice(2, libretro.DeviceJoypad)
state.Global.Core.SetControllerPortDevice(3, libretro.DeviceJoypad)
state.Global.Core.SetControllerPortDevice(4, libretro.DeviceJoypad)

log.Println("[Core]: Game loaded: " + gamePath)
savefiles.LoadSRAM()
Expand Down
4 changes: 2 additions & 2 deletions input/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

// MaxPlayers is the maximum number of players to poll input for
const MaxPlayers = 5
const MaxPlayers = 12

type joybinds map[bind]uint32

Expand Down Expand Up @@ -135,7 +135,7 @@ func Poll() {
// State is a callback passed to core.SetInputState
// It returns 1 if the button corresponding to the parameters is pressed
func State(port uint, device uint32, index uint, id uint) int16 {
if id >= 255 || index > 0 || device != libretro.DeviceJoypad {
if id >= 255 || index > 0 || port >= MaxPlayers || device&libretro.DeviceJoypad != 1 {
return 0
}

Expand Down
2 changes: 2 additions & 0 deletions libretro/libretro.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ const (
// real input device, and not having to worry about binding input
// correctly to arbitrary controller layouts.
const (
DeviceMask = uint32(C.RETRO_DEVICE_MASK)

// DeviceNone means that input is disabled.
DeviceNone = uint32(C.RETRO_DEVICE_NONE)

Expand Down