package frc.team5333.driver.control.mapper.xbox;

import frc.team5333.driver.control.ControllerManager;
import frc.team5333.driver.control.PollData;
import frc.team5333.driver.control.drive.DriveController;
import frc.team5333.driver.control.drive.ThrottleScale;
import frc.team5333.driver.control.mapper.AbstractControlMapper;
import net.java.games.input.Component;
import net.java.games.input.Controller;

public class XMapperSplit extends AbstractControlMapper {

    float z;

    @Override
    public String getFriendlyName() {
        return "Xbox - Split";
    }

    @Override
    public String getFriendlyDescription() {
        return "Uses the two analog sticks separately to control both sides of the Tank Drive";
    }

    @Override
    public void handleInput(PollData data, Component component, Controller controller, ControllerManager manager) {
        switch (component.getIdentifier().getName()) {
            case "y":
                if (!DriveController.isLocked())
            	    DriveController.setLeft(-data.lastPollData);
                break;
            case "ry":
                if (!DriveController.isLocked())
            	    DriveController.setRight(-data.lastPollData);
                break;
            case "0":
                if (data.lastPollData > 0.5)
                    DriveController.toggleLock();
                break;
            case "1":
                if (data.lastPollData > 0.5) {
                    DriveController.setRight(0);
                    DriveController.setLeft(0);
                    DriveController.toggleLock();
                }
                break;
            case "2":
                if (data.lastPollData > 0.5)
                    ThrottleScale.setScale(50);
                break;
        }
    }

    public void finalizeInput(ControllerManager manager) {
        if (manager.getData("z").changed || (manager.getData("rz") != null && manager.getData("rz").changed)) {
            z = manager.getData("z").lastPollData;
            if (System.getProperty("os.name").toUpperCase().contains("MAC")) {
                z = -(z + 1) / 2;
                z += (manager.getData("rz").lastPollData + 1) / 2;
            }
            DriveController.setLift(z);
        }

        if (manager.getData("6").changed || manager.getData("7").changed) {
            float clamp = 0F;
            clamp += manager.getData("6").lastPollData;
            clamp -= manager.getData("7").lastPollData;
            DriveController.setClamp(clamp);
        }
    }

}

@@ -2238,24 +2238,227 @@
 );%0A        %7D
+%0A        %0A        String laxis = %226%22;%0A        String raxis = %227%22;%0A        %0A        if (System.getProperty(%22os.name%22).toUpperCase().contains(%22WIN%22)) %7B%0A        %09laxis = %228%22;%0A        %09raxis = %229%22;%0A        %7D
 %0A%0A        if
@@ -2475,19 +2475,21 @@
 getData(
-%226%22
+laxis
 ).change
@@ -2509,19 +2509,21 @@
 getData(
-%227%22
+raxis
 ).change
@@ -2594,19 +2594,21 @@
 getData(
-%226%22
+laxis
 ).lastPo
@@ -2652,19 +2652,21 @@
 getData(
-%227%22
+raxis
 ).lastPo

Update axis buttons