|
1
|
|
package com.rox.input; |
|
2
|
|
|
|
3
|
|
import de.gurkenlabs.input4j.InputComponent; |
|
4
|
|
import de.gurkenlabs.input4j.InputDevice; |
|
5
|
|
|
|
6
|
|
/** |
|
7
|
|
* Binds one NES {@link Button} to a physical gamepad component, as resolved from a device's live |
|
8
|
|
* {@link InputComponent} data by {@link GamepadController}. A missing component (the bound device |
|
9
|
|
* doesn't actually have it) reads as not-pressed rather than throwing - the same "absent input never |
|
10
|
|
* blocks the emulator" spirit as {@link Controller#NONE}. |
|
11
|
|
*/ |
|
12
|
|
public sealed interface GamepadBinding { |
|
13
|
|
boolean isPressed(InputDevice device); |
|
14
|
|
|
|
15
|
|
/** |
|
16
|
|
* A digital button component (face buttons, shoulder buttons, and - per input4j's own per-platform |
|
17
|
|
* normalization - the D-pad, which every supported backend (XInput, DirectInput, Linux evdev, |
|
18
|
|
* macOS IOKit) already exposes as 4 discrete {@code DPAD_UP/DOWN/LEFT/RIGHT} button components |
|
19
|
|
* rather than a raw POV-hat axis, confirmed by reading input4j 1.3.1's own source rather than |
|
20
|
|
* assuming from its README). Pressed whenever the component's data is non-zero. |
|
21
|
|
*/ |
|
22
|
|
record ButtonBinding(InputComponent.ID componentId) implements GamepadBinding { |
|
23
|
|
@Override |
|
24
|
|
public boolean isPressed(final InputDevice device){ |
|
25
|
4
1. isPressed : replaced boolean return with false for com/rox/input/GamepadBinding$ButtonBinding::isPressed → KILLED
2. isPressed : replaced boolean return with true for com/rox/input/GamepadBinding$ButtonBinding::isPressed → KILLED
3. lambda$isPressed$0 : replaced Boolean return with True for com/rox/input/GamepadBinding$ButtonBinding::lambda$isPressed$0 → KILLED
4. lambda$isPressed$0 : negated conditional → KILLED
|
return device.getComponent(componentId).map(c -> c.getData() != 0).orElse(false); |
|
26
|
|
} |
|
27
|
|
} |
|
28
|
|
|
|
29
|
|
/** |
|
30
|
|
* An analog axis component (e.g. a stick used as a D-pad, or a trigger used as a button), |
|
31
|
|
* pressed once its value crosses {@code threshold} in the direction given by {@code positive}. |
|
32
|
|
*/ |
|
33
|
|
record AxisBinding(InputComponent.ID componentId, boolean positive, float threshold) implements GamepadBinding { |
|
34
|
|
@Override |
|
35
|
|
public boolean isPressed(final InputDevice device){ |
|
36
|
2
1. isPressed : replaced boolean return with true for com/rox/input/GamepadBinding$AxisBinding::isPressed → KILLED
2. isPressed : replaced boolean return with false for com/rox/input/GamepadBinding$AxisBinding::isPressed → KILLED
|
return device.getComponent(componentId) |
|
37
|
7
1. lambda$isPressed$0 : removed negation → KILLED
2. lambda$isPressed$0 : negated conditional → KILLED
3. lambda$isPressed$0 : changed conditional boundary → KILLED
4. lambda$isPressed$0 : replaced Boolean return with True for com/rox/input/GamepadBinding$AxisBinding::lambda$isPressed$0 → KILLED
5. lambda$isPressed$0 : negated conditional → KILLED
6. lambda$isPressed$0 : changed conditional boundary → KILLED
7. lambda$isPressed$0 : negated conditional → KILLED
|
.map(c -> positive ? c.getData() >= threshold : c.getData() <= -threshold) |
|
38
|
|
.orElse(false); |
|
39
|
|
} |
|
40
|
|
} |
|
41
|
|
} |
| | Mutations |
| 25 |
|
1.1 Location : isPressed Killed by : com.rox.input.GamepadControllerTest.[engine:junit-jupiter]/[class:com.rox.input.GamepadControllerTest]/[method:pollReadsABoundButtonComponentIntoPressedMask()] replaced boolean return with false for com/rox/input/GamepadBinding$ButtonBinding::isPressed → KILLED
2.2 Location : isPressed Killed by : com.rox.input.GamepadControllerTest.[engine:junit-jupiter]/[class:com.rox.input.GamepadControllerTest]/[method:aBindingForAComponentTheDeviceDoesNotHaveIsNeverPressedRatherThanThrowing()] replaced boolean return with true for com/rox/input/GamepadBinding$ButtonBinding::isPressed → KILLED
3.3 Location : lambda$isPressed$0 Killed by : com.rox.input.GamepadControllerTest.[engine:junit-jupiter]/[class:com.rox.input.GamepadControllerTest]/[method:pollClearsAPreviouslyPressedButtonOnceReleased()] replaced Boolean return with True for com/rox/input/GamepadBinding$ButtonBinding::lambda$isPressed$0 → KILLED
4.4 Location : lambda$isPressed$0 Killed by : com.rox.input.GamepadControllerTest.[engine:junit-jupiter]/[class:com.rox.input.GamepadControllerTest]/[method:pollReadsABoundButtonComponentIntoPressedMask()] negated conditional → KILLED
|
| 36 |
|
1.1 Location : isPressed Killed by : com.rox.input.GamepadControllerTest.[engine:junit-jupiter]/[class:com.rox.input.GamepadControllerTest]/[method:negativeAxisDirectionIsNotPressedByAPositiveValueWithinTheThreshold()] replaced boolean return with true for com/rox/input/GamepadBinding$AxisBinding::isPressed → KILLED
2.2 Location : isPressed Killed by : com.rox.input.GamepadControllerTest.[engine:junit-jupiter]/[class:com.rox.input.GamepadControllerTest]/[method:pollReadsABoundAxisComponentPastItsThreshold()] replaced boolean return with false for com/rox/input/GamepadBinding$AxisBinding::isPressed → KILLED
|
| 37 |
|
1.1 Location : lambda$isPressed$0 Killed by : com.rox.input.GamepadControllerTest.[engine:junit-jupiter]/[class:com.rox.input.GamepadControllerTest]/[method:negativeAxisDirectionIsNotPressedByAPositiveValueWithinTheThreshold()] removed negation → KILLED
2.2 Location : lambda$isPressed$0 Killed by : com.rox.input.GamepadControllerTest.[engine:junit-jupiter]/[class:com.rox.input.GamepadControllerTest]/[method:pollReadsABoundAxisComponentPastItsThreshold()] negated conditional → KILLED
3.3 Location : lambda$isPressed$0 Killed by : com.rox.input.GamepadControllerTest.[engine:junit-jupiter]/[class:com.rox.input.GamepadControllerTest]/[method:axisBindingIsPressedExactlyAtItsNegativeThreshold()] changed conditional boundary → KILLED
4.4 Location : lambda$isPressed$0 Killed by : com.rox.input.GamepadControllerTest.[engine:junit-jupiter]/[class:com.rox.input.GamepadControllerTest]/[method:negativeAxisDirectionIsNotPressedByAPositiveValueWithinTheThreshold()] replaced Boolean return with True for com/rox/input/GamepadBinding$AxisBinding::lambda$isPressed$0 → KILLED
5.5 Location : lambda$isPressed$0 Killed by : com.rox.input.GamepadControllerTest.[engine:junit-jupiter]/[class:com.rox.input.GamepadControllerTest]/[method:negativeAxisDirectionIsNotPressedByAPositiveValueWithinTheThreshold()] negated conditional → KILLED
6.6 Location : lambda$isPressed$0 Killed by : com.rox.input.GamepadControllerTest.[engine:junit-jupiter]/[class:com.rox.input.GamepadControllerTest]/[method:axisBindingIsPressedExactlyAtItsPositiveThreshold()] changed conditional boundary → KILLED
7.7 Location : lambda$isPressed$0 Killed by : com.rox.input.GamepadControllerTest.[engine:junit-jupiter]/[class:com.rox.input.GamepadControllerTest]/[method:pollReadsABoundAxisComponentPastItsThreshold()] negated conditional → KILLED
|