@@ -25,9 +25,8 @@ const ThumbstickDeadzone = 10000
2525
2626// Controllers keeps track of hardware userinput options.
2727type Controllers struct {
28- inputHandler HandleInput
29- swappedPorts bool
30- swappedPaddles bool
28+ inputHandler HandleInput
29+ swappedPorts bool
3130}
3231
3332// Controllers is the preferred method of initialisation for the Controllers type.
@@ -42,12 +41,6 @@ func (c *Controllers) SwappedPorts(swapped bool) {
4241 c .swappedPorts = swapped
4342}
4443
45- // SwappedPaddles is similar to SwapperPorts but affects which paddle of a paddle pair is to be
46- // controlled by user input
47- func (c * Controllers ) SwappedPaddles (swapped bool ) {
48- c .swappedPaddles = swapped
49- }
50-
5144// handlePortSwap returns the required PortID relative to the supplied PortID if the
5245// controls have been swapped
5346func (c Controllers ) handlePortSwap (port plugging.PortID ) plugging.PortID {
@@ -62,14 +55,6 @@ func (c Controllers) handlePortSwap(port plugging.PortID) plugging.PortID {
6255 return port
6356}
6457
65- // handlePaddleSwap returns the required paddle number according to whether the player
66- func (c Controllers ) handlePaddleSwap () int {
67- if c .swappedPaddles {
68- return 1
69- }
70- return 0
71- }
72-
7358// handleEvents sends the port/event information to each HandleInput
7459// implementation.
7560//
@@ -102,7 +87,7 @@ func (c *Controllers) mouseMotion(ev EventMouseMotion) (bool, error) {
10287 }
10388
10489 return c .handleEvents (c .handlePortSwap (plugging .PortLeft ), ports .PaddleSet , ports.EventDataPaddle {
105- Paddle : c . handlePaddleSwap () ,
90+ Paddle : - 1 ,
10691 Motion : motion ,
10792 Relative : true ,
10893 })
@@ -112,17 +97,19 @@ func (c *Controllers) mouseButton(ev EventMouseButton) (bool, error) {
11297 switch ev .Button {
11398 case MouseButtonLeft :
11499 if ev .Down {
115- if c .swappedPaddles {
116- return c .handleEvents (c .handlePortSwap (plugging .PortLeft ), ports .SecondFire , true )
117- } else {
118- return c .handleEvents (c .handlePortSwap (plugging .PortLeft ), ports .Fire , true )
100+ a , err := c .handleEvents (c .handlePortSwap (plugging .PortLeft ), ports .Fire , true )
101+ if err != nil {
102+ return false , err
119103 }
104+ b , err := c .handleEvents (c .handlePortSwap (plugging .PortLeft ), ports .SecondFire , true )
105+ return a && b , err
120106 } else {
121- if c .swappedPaddles {
122- return c .handleEvents (c .handlePortSwap (plugging .PortLeft ), ports .SecondFire , false )
123- } else {
124- return c .handleEvents (c .handlePortSwap (plugging .PortLeft ), ports .Fire , false )
107+ a , err := c .handleEvents (c .handlePortSwap (plugging .PortLeft ), ports .Fire , false )
108+ if err != nil {
109+ return false , err
125110 }
111+ b , err := c .handleEvents (c .handlePortSwap (plugging .PortLeft ), ports .SecondFire , false )
112+ return a && b , err
126113 }
127114 }
128115
@@ -464,7 +451,7 @@ func (c *Controllers) stelladaptor(ev EventStelladaptor) (bool, error) {
464451
465452 case plugging .PeriphPaddles :
466453 return c .handleEvents (c .handlePortSwap (ev .ID ), ports .PaddleSet , ports.EventDataPaddle {
467- Paddle : c . handlePaddleSwap () ,
454+ Paddle : - 1 ,
468455 Motion : - ev .Horiz - 1 ,
469456 })
470457 }
0 commit comments