mirror of
https://github.com/JetSetIlly/Gopher2600.git
synced 2024-06-02 12:08:01 -04:00
simplified input package by removing AllowPushedEvents()
pushed events are always available and do not have the same performance impact as orignally thought
This commit is contained in:
parent
fdafaa855f
commit
395a0785a9
|
@ -39,7 +39,6 @@ type TV interface {
|
|||
// Input defines the Input functions required by a bot.
|
||||
type Input interface {
|
||||
PushEvent(ports.InputEvent) error
|
||||
AllowPushedEvents(bool)
|
||||
}
|
||||
|
||||
// Diagnostic instances are sent over the Feedback Diagnostic channel.
|
||||
|
|
|
@ -56,7 +56,6 @@ func (b *Bots) ActivateBot(cartHash string) (*bots.Feedback, error) {
|
|||
return nil, fmt.Errorf("bots: %w", err)
|
||||
}
|
||||
logger.Logf("bots", "%s started", b.running.BotID())
|
||||
b.input.AllowPushedEvents(true)
|
||||
|
||||
case "5bdd8af54020fa43065750bd4239a497695d403b":
|
||||
// NTSC version of SpaceJockey
|
||||
|
@ -65,10 +64,8 @@ func (b *Bots) ActivateBot(cartHash string) (*bots.Feedback, error) {
|
|||
return nil, fmt.Errorf("bots: %w", err)
|
||||
}
|
||||
logger.Logf("bots", "%s started", b.running.BotID())
|
||||
b.input.AllowPushedEvents(true)
|
||||
|
||||
default:
|
||||
b.input.AllowPushedEvents(false)
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
|
@ -81,6 +78,5 @@ func (b *Bots) Quit() {
|
|||
b.running.Quit()
|
||||
logger.Logf("bots", "%s finished", b.running.BotID())
|
||||
b.running = nil
|
||||
b.input.AllowPushedEvents(false)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,9 +49,4 @@
|
|||
// Lastly, pushed events, as refered to in point 4, are events that have
|
||||
// arrived from a different goroutine. For an example of pushed events see the
|
||||
// various bot implementations in the bots package.
|
||||
//
|
||||
// Note that for performance reasons, pushed events will not be serviced unless
|
||||
// AllowPushedEvents(true) has been called. Also, pushed events will only be
|
||||
// serviced at the beginning of every frame. (This might change depending on
|
||||
// need in the future).
|
||||
package input
|
||||
|
|
|
@ -40,8 +40,7 @@ type Input struct {
|
|||
recorder []EventRecorder
|
||||
|
||||
// events pushed onto the input queue
|
||||
pushed chan ports.InputEvent
|
||||
pushedBrake int
|
||||
pushed chan ports.InputEvent
|
||||
|
||||
// the following fields all relate to driven input, for either the driver
|
||||
// or for the passenger (the driven)
|
||||
|
@ -61,12 +60,15 @@ func NewInput(tv TV, p *ports.Ports) *Input {
|
|||
pushed: make(chan ports.InputEvent, 64),
|
||||
}
|
||||
inp.setHandleFunc()
|
||||
inp.tv.AddFrameTrigger(inp)
|
||||
return inp
|
||||
}
|
||||
|
||||
// Plumb a new ports instances into the Input.
|
||||
func (inp *Input) Plumb(ports *ports.Ports) {
|
||||
func (inp *Input) Plumb(tv TV, ports *ports.Ports) {
|
||||
inp.tv = tv
|
||||
inp.ports = ports
|
||||
inp.tv.AddFrameTrigger(inp)
|
||||
}
|
||||
|
||||
// PeripheralID forwards a request of the PeripheralID of the PortID to VCS Ports.
|
||||
|
|
|
@ -21,15 +21,6 @@ import (
|
|||
"github.com/jetsetilly/gopher2600/hardware/riot/ports"
|
||||
)
|
||||
|
||||
// AllowPushedEvents or not. Should not be allowed unless absolutely necessary.
|
||||
func (inp *Input) AllowPushedEvents(allow bool) {
|
||||
if allow {
|
||||
inp.tv.AddFrameTrigger(inp)
|
||||
} else {
|
||||
inp.tv.RemoveFrameTrigger(inp)
|
||||
}
|
||||
}
|
||||
|
||||
// PushEvent pushes an InputEvent onto the queue. Will drop the event and
|
||||
// return an error if queue is full.
|
||||
func (inp *Input) PushEvent(ev ports.InputEvent) error {
|
||||
|
|
|
@ -148,7 +148,7 @@ func (vcs *VCS) Plumb(fromDifferentEmulation bool) {
|
|||
// in a latched state
|
||||
vcs.RIOT.Ports.ResetPeripherals()
|
||||
|
||||
vcs.Input.Plumb(vcs.RIOT.Ports)
|
||||
vcs.Input.Plumb(vcs.TV, vcs.RIOT.Ports)
|
||||
}
|
||||
|
||||
// AttachCartridge to this VCS. While this function can be called directly it
|
||||
|
|
|
@ -38,7 +38,6 @@ type Emulation interface {
|
|||
|
||||
type Input interface {
|
||||
PushEvent(ports.InputEvent) error
|
||||
AllowPushedEvents(bool)
|
||||
}
|
||||
|
||||
type TV interface {
|
||||
|
@ -111,8 +110,7 @@ func NewMacro(filename string, emulation Emulation, input Input, tv TV, gui GUI)
|
|||
// we no longer need the header
|
||||
mcr.instructions = mcr.instructions[headerNumLines:]
|
||||
|
||||
// allow pushed events to the VCS input system
|
||||
mcr.input.AllowPushedEvents(true)
|
||||
// attach TV to macro
|
||||
mcr.tv.AddFrameTrigger(mcr)
|
||||
|
||||
return mcr, nil
|
||||
|
|
Loading…
Reference in a new issue