@@ -157,43 +157,35 @@ internal WasSub(Func<GamePadState> mapping)
157157 public bool Down ( params Buttons [ ] buttons )
158158 {
159159 foreach ( var button in buttons )
160- {
161160 if ( State ( ) . IsButtonUp ( button ) )
162161 return false ;
163- }
164162
165163 return true ;
166164 }
167165
168166 public bool OneDown ( params Buttons [ ] buttons )
169167 {
170168 foreach ( var button in buttons )
171- {
172169 if ( State ( ) . IsButtonDown ( button ) )
173170 return true ;
174- }
175171
176172 return false ;
177173 }
178174
179175 public bool Up ( params Buttons [ ] buttons )
180176 {
181177 foreach ( var button in buttons )
182- {
183178 if ( State ( ) . IsButtonDown ( button ) )
184179 return false ;
185- }
186180
187181 return true ;
188182 }
189183
190184 public bool OneUp ( params Buttons [ ] buttons )
191185 {
192186 foreach ( var button in buttons )
193- {
194187 if ( State ( ) . IsButtonUp ( button ) )
195188 return true ;
196- }
197189
198190 return false ;
199191 }
@@ -221,11 +213,37 @@ public DPadSub(Func<GamePadState> mapping, Func<GamePadState> oldMapping)
221213 OldState = oldMapping ;
222214 }
223215
224- public bool Press ( DPadDirection direction )
225- => Down ( State , direction ) && Up ( OldState , direction ) ;
216+ public bool Press ( params DPadDirection [ ] directions )
217+ {
218+ foreach ( var direction in directions )
219+ if ( Up ( State , direction ) || Down ( OldState , direction ) )
220+ return false ;
221+ return true ;
222+ }
223+
224+ public bool OnePress ( params DPadDirection [ ] directions )
225+ {
226+ foreach ( var direction in directions )
227+ if ( Down ( State , direction ) && Up ( OldState , direction ) )
228+ return true ;
229+ return false ;
230+ }
226231
227- public bool Release ( DPadDirection direction )
228- => Down ( OldState , direction ) && Up ( State , direction ) ;
232+ public bool Release ( params DPadDirection [ ] directions )
233+ {
234+ foreach ( var direction in directions )
235+ if ( Up ( OldState , direction ) || Down ( State , direction ) )
236+ return false ;
237+ return true ;
238+ }
239+
240+ public bool OneRelease ( params DPadDirection [ ] directions )
241+ {
242+ foreach ( var direction in directions )
243+ if ( Down ( OldState , direction ) && Up ( State , direction ) )
244+ return true ;
245+ return false ;
246+ }
229247 }
230248
231249 [ PublicAPI ]
@@ -238,11 +256,39 @@ internal DPadOldSub(Func<GamePadState> mapping)
238256 State = mapping ;
239257 }
240258
241- public bool Down ( DPadDirection direction ) => Down ( State , direction ) ;
242- public bool Up ( DPadDirection direction ) => Up ( State , direction ) ;
259+ public bool Down ( params DPadDirection [ ] directions )
260+ {
261+ foreach ( var direction in directions )
262+ if ( Up ( State , direction ) )
263+ return false ;
264+ return true ;
265+ }
243266
244- protected bool Down ( Func < GamePadState > mapping , DPadDirection direction ,
245- PlayerIndex p = PlayerIndex . One )
267+ public bool OneDown ( params DPadDirection [ ] directions )
268+ {
269+ foreach ( var direction in directions )
270+ if ( Down ( State , direction ) )
271+ return true ;
272+ return false ;
273+ }
274+
275+ public bool Up ( params DPadDirection [ ] directions )
276+ {
277+ foreach ( var direction in directions )
278+ if ( Down ( State , direction ) )
279+ return false ;
280+ return true ;
281+ }
282+
283+ public bool OneUp ( params DPadDirection [ ] directions )
284+ {
285+ foreach ( var direction in directions )
286+ if ( Up ( State , direction ) )
287+ return true ;
288+ return false ;
289+ }
290+
291+ protected bool Down ( Func < GamePadState > mapping , DPadDirection direction )
246292 {
247293 switch ( direction )
248294 {
@@ -254,9 +300,9 @@ protected bool Down(Func<GamePadState> mapping, DPadDirection direction,
254300 return mapping ( ) . DPad . Right == ButtonState . Pressed ;
255301 case DPadDirection . UP :
256302 return mapping ( ) . DPad . Up == ButtonState . Pressed ;
303+ default :
304+ return false ;
257305 }
258-
259- return false ;
260306 }
261307
262308 protected bool Up ( Func < GamePadState > mapping , DPadDirection direction )
@@ -271,9 +317,9 @@ protected bool Up(Func<GamePadState> mapping, DPadDirection direction)
271317 return mapping ( ) . DPad . Right == ButtonState . Released ;
272318 case DPadDirection . UP :
273319 return mapping ( ) . DPad . Up == ButtonState . Released ;
320+ default :
321+ return false ;
274322 }
275-
276- return false ;
277323 }
278324 }
279325
0 commit comments