Package darkyenus.dipt.binding

Examples of darkyenus.dipt.binding.Binding


public class bind implements Command{

    @Override
    public String execute(Reference reference, String[] arguments) {
        try {
            Binding binding = null;
            if(arguments[0].equalsIgnoreCase("key") || arguments[0].equalsIgnoreCase("+key")){
                final int identifier = Integer.parseInt(arguments[1]);
                binding = new Binding(reference,arguments[2]) {

                    boolean keyPressed = false;

                    @Override
                    public boolean isValid(BindManager.InputSnapshot snapshot) {
                        if(snapshot.isKeyPressed(identifier)){
                            if(!keyPressed){
                                keyPressed = true;
                                return true;
                            }
                        }else{
                            keyPressed = false;
                        }
                        return false;
                    }
                };
            }else if(arguments[0].equalsIgnoreCase("-key")){
                final int identifier = Integer.parseInt(arguments[1]);
                binding = new Binding(reference,arguments[2]) {

                    boolean keyPressed = false;

                    @Override
                    public boolean isValid(BindManager.InputSnapshot snapshot) {
                        if(!snapshot.isKeyPressed(identifier)){
                            if(keyPressed){
                                keyPressed = false;
                                return true;
                            }
                        }else{
                            keyPressed = true;
                        }
                        return false;
                    }
                };
            }else if(arguments[0].equalsIgnoreCase("mouse") || arguments[0].equalsIgnoreCase("+mouse")){
                final int identifier = Integer.parseInt(arguments[1]);
                binding = new Binding(reference,arguments[2]) {

                    boolean buttonPressed = false;

                    @Override
                    public boolean isValid(BindManager.InputSnapshot snapshot) {
                        if(snapshot.isMouseButtonPressed(identifier)){
                            if(!buttonPressed){
                                buttonPressed = true;
                                return true;
                            }
                        }
                        return false;
                    }
                };
            }else if(arguments[0].equalsIgnoreCase("-mouse")){
                final int identifier = Integer.parseInt(arguments[1]);
                binding = new Binding(reference,arguments[2]) {

                    boolean buttonPressed = false;

                    @Override
                    public boolean isValid(BindManager.InputSnapshot snapshot) {
                        if(!snapshot.isMouseButtonPressed(identifier)){
                            if(buttonPressed){
                                buttonPressed = false;
                                return true;
                            }
                        }else{
                            buttonPressed = true;
                        }
                        return false;
                    }
                };
            }else if(arguments[0].equalsIgnoreCase("wheel")){
                final boolean positiveTrigger = "+".equals(arguments[1]);
                final boolean negativeTrigger = "-".equals(arguments[1]);
                int exactValueTemp = 0;
                if(!positiveTrigger && !negativeTrigger){
                    exactValueTemp = Integer.parseInt(arguments[1]);
                }
                final int exactValue = exactValueTemp;

                binding = new Binding(reference,arguments[2]) {

                    @Override
                    public boolean isValid(BindManager.InputSnapshot snapshot) {
                        if(snapshot.isWheelEvent()){
                            if(positiveTrigger){
View Full Code Here

TOP

Related Classes of darkyenus.dipt.binding.Binding

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.