package dev.photosync.platform.impl;

import com.mojang.blaze3d.platform.InputConstants;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.minecraft.client.KeyMapping;
import org.lwjgl.glfw.GLFW;

/**
 * The key that opens PhotoSync, bound to F6 until the player says otherwise.
 *
 * <p>F6 because it is unbound in vanilla and sits next to F2, which is the other
 * key this mod is about.
 */
public final class OpenKey {

    private final KeyMapping mapping;

    private OpenKey(KeyMapping mapping) {
        this.mapping = mapping;
    }

    /** Registers the binding. Called once, from the client entrypoint. */
    public static OpenKey register() {
        return new OpenKey(KeyBindingHelper.registerKeyBinding(new KeyMapping(
                "key.photosync.open",
                InputConstants.Type.KEYSYM,
                GLFW.GLFW_KEY_F6,
                "key.categories.photosync")));
    }

    /** Takes one queued press, or false if there are none left. */
    public boolean wasPressed() {
        return mapping.consumeClick();
    }
}
