Search in sources :

Example 1 with BindAxisEvent

use of org.terasology.input.BindAxisEvent in project Terasology by MovingBlocks.

the class BindsSubsystem method registerRealAxisBinds.

private void registerRealAxisBinds(ModuleEnvironment environment) {
    Iterable<Class<?>> classes = environment.getTypesAnnotatedWith(RegisterRealBindAxis.class);
    for (Class<?> registerBindClass : classes) {
        RegisterRealBindAxis info = registerBindClass.getAnnotation(RegisterRealBindAxis.class);
        Name moduleId = environment.getModuleProviding(registerBindClass);
        SimpleUri id = new SimpleUri(moduleId, info.id());
        if (BindAxisEvent.class.isAssignableFrom(registerBindClass)) {
            try {
                BindAxisEvent instance = (BindAxisEvent) registerBindClass.newInstance();
                BindableAxis bindAxis = registerRealBindAxis(id.toString(), instance);
                bindAxis.setSendEventMode(info.eventMode());
                for (Input input : bindsConfiguration.getBinds(id)) {
                    linkAxisToInput(input, id);
                }
                logger.debug("Registered axis bind: {}", id);
            } catch (InstantiationException | IllegalAccessException e) {
                logger.error("Failed to register axis bind \"{}\"", id, e);
            }
        } else {
            logger.error("Failed to register axis bind \"{}\", does not extend BindAxisEvent", id);
        }
    }
}
Also used : RegisterRealBindAxis(org.terasology.input.RegisterRealBindAxis) ControllerInput(org.terasology.input.ControllerInput) Input(org.terasology.input.Input) MouseInput(org.terasology.input.MouseInput) SimpleUri(org.terasology.engine.SimpleUri) BindAxisEvent(org.terasology.input.BindAxisEvent) AbstractBindableAxis(org.terasology.input.internal.AbstractBindableAxis) BindableAxis(org.terasology.input.BindableAxis) Name(org.terasology.naming.Name)

Aggregations

SimpleUri (org.terasology.engine.SimpleUri)1 BindAxisEvent (org.terasology.input.BindAxisEvent)1 BindableAxis (org.terasology.input.BindableAxis)1 ControllerInput (org.terasology.input.ControllerInput)1 Input (org.terasology.input.Input)1 MouseInput (org.terasology.input.MouseInput)1 RegisterRealBindAxis (org.terasology.input.RegisterRealBindAxis)1 AbstractBindableAxis (org.terasology.input.internal.AbstractBindableAxis)1 Name (org.terasology.naming.Name)1