public void applyBinds(InputSystem inputSystem, ModuleManager moduleManager) { inputSystem.clearBinds(); ModuleEnvironment env = moduleManager.getEnvironment(); registerButtonBinds(inputSystem, env, env.getTypesAnnotatedWith(RegisterBindButton.class)); registerAxisBinds(inputSystem, env, env.getTypesAnnotatedWith(RegisterBindAxis.class)); registerRealAxisBinds(inputSystem, env, env.getTypesAnnotatedWith(RegisterRealBindAxis.class)); }
/** * Updates a config with any binds that it may be missing, through reflection over * RegisterBindButton annotations */ public void updateForChangedMods(Context context) { ModuleManager moduleManager = context.get(ModuleManager.class); DependencyResolver resolver = new DependencyResolver(moduleManager.getRegistry()); for (Name moduleId : moduleManager.getRegistry().getModuleIds()) { if (moduleManager.getRegistry().getLatestModuleVersion(moduleId).isCodeModule()) { ResolutionResult result = resolver.resolve(moduleId); if (result.isSuccess()) { try (ModuleEnvironment environment = moduleManager.loadEnvironment(result.getModules(), false)) { FromModule filter = new FromModule(environment, moduleId); Iterable<Class<?>> buttons = environment.getTypesAnnotatedWith(RegisterBindButton.class, filter); Iterable<Class<?>> axes = environment.getTypesAnnotatedWith(RegisterRealBindAxis.class, filter); updateButtonInputsFor(moduleId, buttons); updateAxisInputsFor(moduleId, axes); } } } } }
/** * @return A new BindsConfig, with inputs set from the DefaultBinding annotations on bind classes */ public static BindsConfig createDefault(Context context) { ModuleManager moduleManager = context.get(ModuleManager.class); BindsConfig config = new BindsConfig(); DependencyResolver resolver = new DependencyResolver(moduleManager.getRegistry()); for (Name moduleId : moduleManager.getRegistry().getModuleIds()) { if (moduleManager.getRegistry().getLatestModuleVersion(moduleId).isCodeModule()) { ResolutionResult result = resolver.resolve(moduleId); if (result.isSuccess()) { try (ModuleEnvironment environment = moduleManager.loadEnvironment(result.getModules(), false)) { FromModule filter = new FromModule(environment, moduleId); Iterable<Class<?>> buttons = environment.getTypesAnnotatedWith(RegisterBindButton.class, filter); Iterable<Class<?>> axes = environment.getTypesAnnotatedWith(RegisterRealBindAxis.class, filter); config.addButtonDefaultsFor(moduleId, buttons); config.addAxisDefaultsFor(moduleId, axes); } } } } return config; }
/** * Updates a config with any binds that it may be missing, through reflection over * RegisterBindButton annotations */ public void updateForChangedMods(Context context) { ModuleManager moduleManager = context.get(ModuleManager.class); DependencyResolver resolver = new DependencyResolver(moduleManager.getRegistry()); for (Name moduleId : moduleManager.getRegistry().getModuleIds()) { if (moduleManager.getRegistry().getLatestModuleVersion(moduleId).isCodeModule()) { ResolutionResult result = resolver.resolve(moduleId); if (result.isSuccess()) { try (ModuleEnvironment environment = moduleManager.loadEnvironment(result.getModules(), false)) { updateInputsFor( moduleId, environment.getTypesAnnotatedWith( RegisterBindButton.class, new FromModule(environment, moduleId))); } } } } }