private void registerAxisBinds( InputSystem inputSystem, ModuleEnvironment environment, Iterable<Class<?>> classes) { for (Class<?> registerBindClass : classes) { RegisterBindAxis info = registerBindClass.getAnnotation(RegisterBindAxis.class); Name moduleId = environment.getModuleProviding(registerBindClass); SimpleUri id = new SimpleUri(moduleId, info.id()); if (BindAxisEvent.class.isAssignableFrom(registerBindClass)) { BindableButton positiveButton = inputSystem.getBindButton(new SimpleUri(info.positiveButton())); BindableButton negativeButton = inputSystem.getBindButton(new SimpleUri(info.negativeButton())); if (positiveButton == null) { logger.warn( "Failed to register axis \"{}\", missing positive button \"{}\"", id, info.positiveButton()); continue; } if (negativeButton == null) { logger.warn( "Failed to register axis \"{}\", missing negative button \"{}\"", id, info.negativeButton()); continue; } try { BindableAxis bindAxis = inputSystem.registerBindAxis( id.toString(), (BindAxisEvent) registerBindClass.newInstance(), positiveButton, negativeButton); bindAxis.setSendEventMode(info.eventMode()); 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); } } }
private void registerRealAxisBinds( InputSystem inputSystem, ModuleEnvironment environment, Iterable<Class<?>> classes) { 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 = inputSystem.registerRealBindAxis(id.toString(), instance); bindAxis.setSendEventMode(info.eventMode()); for (Input input : getBinds(id)) { inputSystem.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); } } }