common

package
v0.3.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 8, 2021 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DeviceUnknown - unfamiliar with this device
	DeviceUnknown = "DeviceUnknown"
	// DeviceMissingInfo - only know the name of device
	DeviceMissingInfo = "DeviceMissingInfo"
	// ProfileDefault - the name of the default profile
	ProfileDefault = "default_metarefcard"
)
View Source
const (
	// InputPrimary - primary input
	InputPrimary = 0
	// InputSecondary - secondary input
	InputSecondary = 1
	// NumInputs - number of inputs.
	NumInputs = 2
)

Variables

This section is empty.

Functions

func GameBindsAsString

func GameBindsAsString(gameBindsByProfile GameBindsByProfile) string

GameBindsAsString returns the object as a printable string

func GenerateContextColours

func GenerateContextColours(contexts ContextToColours, config *Config)

GenerateContextColours - basic utility function to generate colours

func GenerateImageOverlays

func GenerateImageOverlays(overlaysByImage OverlaysByImage, input string, inputData InputData,
	gameData GameData, actionName string, context string, shortName string,
	image string, gameLabel string, log *Logger)

GenerateImageOverlays - creates the image overlays into overlaysByImage

func GenerateImages

func GenerateImages(overlaysByProfile OverlaysByProfile,
	categories map[string]string,
	gameLabel string, config *Config, log *Logger) ([]bytes.Buffer, int)

GenerateImages returns the generated images

func LoadDevicesInfo

func LoadDevicesInfo(file string, devices *Devices, log *Logger)

LoadDevicesInfo loads all the device information (across files) into "devices"

func LoadYaml

func LoadYaml(filename string, out interface{}, label string, log *Logger)

LoadYaml loads Yaml file and prints any errors

func YamlObjectAsString

func YamlObjectAsString(in interface{}, label string) string

YamlObjectAsString outputs contents of yaml object with a label

Types

type Config

type Config struct {
	AppName       string `yaml:"AppName"`
	Version       string `yaml:"Version"`
	DebugOutput   bool   `yaml:"DebugOutput"`
	VerboseOutput bool   `yaml:"VerboseOutput"`

	DevicesFile string `yaml:"DevicesFile"`
	Devices     Devices

	DefaultImage    Dimensions2d `yaml:"DefaultImage"`
	PixelMultiplier float64      `yaml:"PixelMultiplier"`
	HotasImagesDir  string       `yaml:"HotasImagesDir"`
	LogoImagesDir   string       `yaml:"LogoImagesDir"`
	JpgQuality      int          `yaml:"JpgQuality"`

	FontsDir          string  `yaml:"FontsDir"`
	InputFont         string  `yaml:"InputFont"`
	InputFontSize     float64 `yaml:"InputFontSize"`
	InputMinFontSize  int     `yaml:"InputMinFontSize"`
	DefaultLineHeight int     `yaml:"DefaultLineHeight"`
	InputPixelXInset  float64 `yaml:"InputPixelXInset"`
	InputPixelYInset  float64 `yaml:"InputPixelYInset"`

	ImageHeader HeaderData    `yaml:"ImageHeader"`
	Watermark   WatermarkData `yaml:"Watermark"`

	BackgroundColour string   `yaml:"BackgroundColour"`
	LightColour      string   `yaml:"LightColour"`
	DarkColour       string   `yaml:"DarkColour"`
	AlternateColours []string `yaml:"AlternateColours"`
}

Config contains all the configuration data for the app

type ContextToColours

type ContextToColours map[string]string

ContextToColours is a mapping of game contexts to colours that are used for visual grouping

func (ContextToColours) Keys

func (m ContextToColours) Keys() []string

Keys returns a MockSet as an array

type DeviceInputTypeMapping

type DeviceInputTypeMapping map[string]InputTypeMapping

DeviceInputTypeMapping contains a map of device short names to types of input maps (e.g. Slider, Axis, Rotaion)

type DeviceInputs

type DeviceInputs map[string]InputData

DeviceInputs - structure of inputs for a device. input -> input data

type DeviceMap

type DeviceMap map[string]DeviceInputs

DeviceMap - structure of devices. short name -> inputs

func FilterDevices

func FilterDevices(neededDevices Set, config *Config, log *Logger) DeviceMap

FilterDevices - Returns only the devices that the caller is asking for

type DeviceNameFullToShort

type DeviceNameFullToShort map[string]string

DeviceNameFullToShort maps game device full names to MetaRefCard short names

type Devices

type Devices struct {
	GeneratedFile        string                  `yaml:"GeneratedFile"`
	Index                DeviceMap               `yaml:"DeviceMap"`
	ImageMap             ImageMap                `yaml:"ImageMap"`
	DeviceToShortNameMap DeviceNameFullToShort   `yaml:"DeviceNameMap"`
	DeviceLabelsByImage  map[string]string       `yaml:"DeviceLabelsByImage"`
	ImageSizeOverride    map[string]Dimensions2d `yaml:"ImageSizeOverride"` // Device Name -> Dimensions2d
}

Devices holds all the device related data

type Dimensions2d

type Dimensions2d struct {
	W int `yaml:"w"` // Width
	H int `yaml:"h"` // Height
}

Dimensions2d contains width and height

type FuncMatchGameInputToModel

type FuncMatchGameInputToModel func(deviceName string, actionData GameInput,
	deviceInputs DeviceInputs, gameInputMap InputTypeMapping, log *Logger) (GameInput, string)

FuncMatchGameInputToModel takes the game provided bindings with the device map to build a list of image overlays.

type FuncRequestHandler

type FuncRequestHandler func(files [][]byte, config *Config, log *Logger) (GameData,
	GameBindsByProfile, Set, ContextToColours, string)

FuncRequestHandler - handles incoming requests and returns game data, game binds, neededDevices and a context to colour mapping

type GameActions

type GameActions map[string]GameInput

GameActions - Action -> Input

type GameBindsByProfile

type GameBindsByProfile map[string]GameDeviceContextActions

GameBindsByProfile - Profile -> Short name -> Context -> Action -> Primary/Secondary -> Key

type GameContextActions

type GameContextActions map[string]GameActions

GameContextActions - Context -> Action

type GameData

type GameData struct {
	Regexes     map[string]string      `yaml:"Regexes"`
	InputMap    DeviceInputTypeMapping `yaml:"InputMap"`
	InputLabels map[string]string      `yaml:"InputLabels"`
}

GameData holds the game's parsed data

func LoadGameModel

func LoadGameModel(filename string, label string, debugOutput bool, log *Logger) GameData

LoadGameModel - load game specific data from our model. Update the device names (map game device name to our model names)

type GameDeviceContextActions

type GameDeviceContextActions map[string]GameContextActions

GameDeviceContextActions - Short name -> Context -> Action -> Primary/Secondary -> Key

type GameInput

type GameInput []string

GameInput - Array of inputs. Index of InputPrimary and InputSecondary

type GeneratedDevices

type GeneratedDevices struct {
	Index    DeviceMap `yaml:"DeviceMap"`
	ImageMap ImageMap  `yaml:"ImageMap"`
}

GeneratedDevices holds structure from the generated config

type HeaderData

type HeaderData struct {
	Font             string  `yaml:"Font"`
	FontSize         float64 `yaml:"FontSize"`
	Inset            Point2d `yaml:"Inset"`
	TextHeight       float64 `yaml:"TextHeight"`
	TextColour       string  `yaml:"TextColour"`
	BackgroundHeight float64 `yaml:"BackgroundHeight"`
	BackgroundColour string  `yaml:"BackgroundColour"`
}

HeaderData contains necessary data to generate header

type ImageMap

type ImageMap map[string]string

ImageMap - contains device short name -> image name

type InputData

type InputData struct {
	X int `yaml:"x"` // X location
	Y int `yaml:"y"` // Y location
	W int `yaml:"w"` // Width
	H int `yaml:"h"` // Height
}

InputData - data relating to a given input

type InputTypeMapping

type InputTypeMapping map[string]map[string]string // Device -> Type (Axis/Slider) -> axisInputMap/sliderInputMap

InputTypeMapping maps the type of input (e.g Slider, Axis, Rotation) to a map of game input to MetaRefCard input (e.g. X-Axis -> U-Axis)

type LogEntry

type LogEntry struct {
	IsError bool
	Msg     string
}

LogEntry contains the message and metadata

type Logger

type Logger []*LogEntry

Logger is a log utility to log to

func NewLog

func NewLog() *Logger

NewLog creates a new logger

func (*Logger) Dbg

func (l *Logger) Dbg(format string, v ...interface{})

Dbg prints an informational message

func (*Logger) Err

func (l *Logger) Err(format string, v ...interface{})

Err logs an error message

func (*Logger) Fatal

func (l *Logger) Fatal(format string, v ...interface{})

Fatal calls log.Fatalf

func (*Logger) Msg

func (l *Logger) Msg(format string, v ...interface{})

Msg logs an informational message

type OverlayData

type OverlayData struct {
	ContextToTexts map[string][]string
	PosAndSize     InputData
}

OverlayData - data about what to put in overlay, grouping and location

type OverlaysByImage

type OverlaysByImage map[string]map[string]OverlayData

OverlaysByImage - image overlay data indexed by image name Image -> Device:Input -> OverlayData

type OverlaysByProfile

type OverlaysByProfile map[string]OverlaysByImage

OverlaysByProfile - image overlay object indexed by profile Profile -> OverlaysByImage

func PopulateImageOverlays

func PopulateImageOverlays(neededDevices Set, config *Config, log *Logger,
	gameBindsByProfile GameBindsByProfile, gameData GameData, matchFunc FuncMatchGameInputToModel) OverlaysByProfile

PopulateImageOverlays returns a list of image overlays to put on device images

type Point2d

type Point2d struct {
	X float64 `yaml:"x"`
	Y float64 `yaml:"y"`
}

Point2d contains x and y

type RegexByName

type RegexByName map[string]*regexp.Regexp

RegexByName - map of named regex strings

type Set

type Set map[string]bool

Set is a map masquerading as a set

func (Set) Keys

func (m Set) Keys() []string

Keys returns a MockSet as an array

type WatermarkData

type WatermarkData struct {
	Text             string  `yaml:"Text"`
	TextColour       string  `yaml:"TextColour"`
	BackgroundColour string  `yaml:"BackgroundColour"`
	Font             string  `yaml:"Font"`
	FontSize         float64 `yaml:"FontSize"`
	Location         Point2d `yaml:"Location"`
}

WatermarkData contains necessary data to generate watermark

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL