batocera-ES-onArch

Emulationstation from batocera with configs and scripts for integration as Arch-Linux package

This project is maintained by GB609

/opt/batocera-emulationstation/node_modules/controllers.js

Overview

This module contains some helper functions primarily used by btc-config.
It is meant to encapsulate logic revolving around handling of controller profiles to prevent btc-config from growing too large to be readable.

Index

equalizeStructure

The json structure created by xmltodict is not homogenous. Repeatable elements only appear as array properties when there’s actually more than one entry. Otherwise, they are simple objects. This requires context-sensitive implementations of for additions and lookups with a lot of ifs.
This method aims to equalize the structures: none-array object-type children will be converted to arrays.
As long as there is only one entry, the output is identical, but processing it becomes easier.

locateIndexed

Aimed at *.amgp files. Searches the given element array for one entry with index as value for the xml tag attribute ‘index’.
Assumes regular *.amgp format where the index attribute has unique values across siblings of the same nesting level.

[@returns first found element or defaultValue]

class ProfileDescriber

This is a helper class to parse the content of an amx profile and extract human readable button-mappings from it.

applyGuideProfile

Applies the content of the GUIDE profile to the base given here. This translates to the following actions:

When baseProfileFile is given as object, it will be mutated for easier processing.
The mutation will still result in identical XML when the object is converted to XML as per ‘xmltodict’ spec, but all none-simple key-value entries in all sub-trees will be replaced by key:[value]. E.g:

profileToImage

Takes an amx profile and reads names/keycodes to put them into a template svg to produce controller mapping images. Will generate one image per set.
Resulting files will be named after profile and set name (or number): ProfileName(SetNumber) - SetName.svg.
Regardless of there being a set name or not, its number will always be appended to the constant name part to ensure proper ls order.

Generated with shdoc from /opt/batocera-emulationstation/node_modules/controllers.js