mirror of
https://github.com/TeamMidnightDust/MidnightControls.git
synced 2025-12-14 07:35:10 +01:00
Sensible screen scrolling speeds
This commit is contained in:
@@ -86,7 +86,7 @@ public class MidnightControlsClient extends MidnightControls {
|
|||||||
int period = 1; // repeat every 0.001 sec. (1000 times a second)
|
int period = 1; // repeat every 0.001 sec. (1000 times a second)
|
||||||
Timer timer = new Timer();
|
Timer timer = new Timer();
|
||||||
timer.scheduleAtFixedRate(new TimerTask() {
|
timer.scheduleAtFixedRate(new TimerTask() {
|
||||||
public void run() {
|
public void run() { // TODO: Add a try/catch here after the alpha testing period
|
||||||
if (lateInitDone && client.isRunning()) {
|
if (lateInitDone && client.isRunning()) {
|
||||||
input.tickJoysticks();
|
input.tickJoysticks();
|
||||||
input.updateCamera();
|
input.updateCamera();
|
||||||
|
|||||||
@@ -505,7 +505,7 @@ public class MidnightInput {
|
|||||||
}
|
}
|
||||||
|
|
||||||
axisValue = (float) Math.min(axisValue / MidnightControlsConfig.getAxisMaxValue(storage.axis), 1);
|
axisValue = (float) Math.min(axisValue / MidnightControlsConfig.getAxisMaxValue(storage.axis), 1);
|
||||||
if (AxisStorage.isLeftAxis(storage.axis) && MidnightControlsCompat.handleMovement(storage, axisValue)) return;
|
if (AxisStorage.isLeftAxis(storage.axis)) MidnightControlsCompat.handleMovement(storage, axisValue);
|
||||||
InputManager.BUTTON_VALUES.put(ButtonBinding.axisAsButton(storage.axis, true), storage.polarity == AxisStorage.Polarity.PLUS ? axisValue : 0.f);
|
InputManager.BUTTON_VALUES.put(ButtonBinding.axisAsButton(storage.axis, true), storage.polarity == AxisStorage.Polarity.PLUS ? axisValue : 0.f);
|
||||||
InputManager.BUTTON_VALUES.put(ButtonBinding.axisAsButton(storage.axis, false), storage.polarity == AxisStorage.Polarity.MINUS ? axisValue : 0.f);
|
InputManager.BUTTON_VALUES.put(ButtonBinding.axisAsButton(storage.axis, false), storage.polarity == AxisStorage.Polarity.MINUS ? axisValue : 0.f);
|
||||||
}
|
}
|
||||||
@@ -532,25 +532,22 @@ public class MidnightInput {
|
|||||||
if (storage.axis == preferredAxis) {
|
if (storage.axis == preferredAxis) {
|
||||||
var accessor = (CreativeInventoryScreenAccessor) creativeInventoryScreen;
|
var accessor = (CreativeInventoryScreenAccessor) creativeInventoryScreen;
|
||||||
if (accessor.midnightcontrols$hasScrollbar() && storage.absValue >= storage.deadZone) {
|
if (accessor.midnightcontrols$hasScrollbar() && storage.absValue >= storage.deadZone) {
|
||||||
creativeInventoryScreen.mouseScrolled(0.0, 0.0, 0, -storage.value);
|
creativeInventoryScreen.mouseScrolled(0.0, 0.0, 0, -(storage.value * 0.0175f));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (screen instanceof MerchantScreen || screen instanceof StonecutterScreen) {
|
|
||||||
if (storage.axis == preferredAxis) {
|
|
||||||
screen.mouseScrolled(0.0, 0.0, 0, -(storage.value * 1.5f));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} else if (screen instanceof AdvancementsScreen advancementsScreen) {
|
} else if (screen instanceof AdvancementsScreen advancementsScreen) {
|
||||||
if (storage.axis == GLFW_GAMEPAD_AXIS_RIGHT_X || storage.axis == GLFW_GAMEPAD_AXIS_RIGHT_Y) {
|
if (storage.axis == GLFW_GAMEPAD_AXIS_RIGHT_X || storage.axis == GLFW_GAMEPAD_AXIS_RIGHT_Y) {
|
||||||
var accessor = (AdvancementsScreenAccessor) advancementsScreen;
|
var accessor = (AdvancementsScreenAccessor) advancementsScreen;
|
||||||
AdvancementTab tab = accessor.getSelectedTab();
|
AdvancementTab tab = accessor.getSelectedTab();
|
||||||
tab.move(storage.axis == GLFW_GAMEPAD_AXIS_RIGHT_X ? -storage.value * 5.0 : 0.0, storage.axis == GLFW_GAMEPAD_AXIS_RIGHT_Y ? -storage.value * 5.0 : 0.0);
|
tab.move(storage.axis == GLFW_GAMEPAD_AXIS_RIGHT_X ? -storage.value * 1.0 : 0.0, storage.axis == GLFW_GAMEPAD_AXIS_RIGHT_Y ? -storage.value * 5.0 : 0.0);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (screen != null) {
|
} else if (screen != null) {
|
||||||
if (storage.axis == preferredAxis && !handleListWidgetScrolling(screen.children(), storage.value)) {
|
if (storage.axis == preferredAxis && !handleListWidgetScrolling(screen.children(), storage.value)) {
|
||||||
screen.mouseScrolled(0.0, 0.0, 0, -(storage.value * 1.5f));
|
try {
|
||||||
|
screen.mouseScrolled(0.0, 0.0, 0, -(storage.value * 0.0175f));
|
||||||
|
} catch (NullPointerException ignored) {}
|
||||||
} else if (isScreenInteractive(screen)) {
|
} else if (isScreenInteractive(screen)) {
|
||||||
if (joystickCooldown == 0) {
|
if (joystickCooldown == 0) {
|
||||||
switch (storage.axis) {
|
switch (storage.axis) {
|
||||||
|
|||||||
@@ -55,9 +55,7 @@ public interface CompatHandler {
|
|||||||
* @param storage the storage containing info about the current axis
|
* @param storage the storage containing info about the current axis
|
||||||
* @param adjustedValue the value of the axis, adjusted for max values and non-analogue movement, recommended for player movement
|
* @param adjustedValue the value of the axis, adjusted for max values and non-analogue movement, recommended for player movement
|
||||||
*/
|
*/
|
||||||
default boolean handleMovement(@NotNull MinecraftClient client, AxisStorage storage, float adjustedValue) {
|
default void handleMovement(@NotNull MinecraftClient client, AxisStorage storage, float adjustedValue) {}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles custom tab behavior
|
* Handles custom tab behavior
|
||||||
|
|||||||
@@ -193,9 +193,8 @@ public class MidnightControlsCompat {
|
|||||||
*
|
*
|
||||||
* @param storage the storage containing info about the current axis
|
* @param storage the storage containing info about the current axis
|
||||||
* @param adjustedValue the value of the axis, adjusted for max values and non-analogue movement, recommended for player movement
|
* @param adjustedValue the value of the axis, adjusted for max values and non-analogue movement, recommended for player movement
|
||||||
* @return true if the handle was fired and succeed, else false
|
|
||||||
*/
|
*/
|
||||||
public static boolean handleMovement(AxisStorage storage, float adjustedValue) {
|
public static void handleMovement(AxisStorage storage, float adjustedValue) {
|
||||||
return streamCompatHandlers().anyMatch(handler -> handler.handleMovement(client, storage, adjustedValue));
|
streamCompatHandlers().forEach(handler -> handler.handleMovement(client, storage, adjustedValue));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user