From c83f9d87006c9501da394b72f8ae2a46a3305373 Mon Sep 17 00:00:00 2001 From: bel Date: Sat, 25 Mar 2023 00:30:13 -0600 Subject: [PATCH] load v01 config --- go.mod | 1 + go.sum | 3 +++ src/device/input/button/v01.go | 10 ++++++++++ 3 files changed, 14 insertions(+) diff --git a/go.mod b/go.mod index 06f7383..f384d19 100644 --- a/go.mod +++ b/go.mod @@ -5,4 +5,5 @@ go 1.19 require ( github.com/go-yaml/yaml v2.1.0+incompatible // indirect github.com/micmonay/keybd_event v1.1.1 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect ) diff --git a/go.sum b/go.sum index 33758c8..6625d75 100644 --- a/go.sum +++ b/go.sum @@ -2,3 +2,6 @@ github.com/go-yaml/yaml v2.1.0+incompatible h1:RYi2hDdss1u4YE7GwixGzWwVo47T8UQwn github.com/go-yaml/yaml v2.1.0+incompatible/go.mod h1:w2MrLa16VYP0jy6N7M5kHaCkaLENm+P+Tv+MfurjSw0= github.com/micmonay/keybd_event v1.1.1 h1:rv7omwXWYL9Lgf3PUq6uBgJI2k1yGkL/GD6dxc6nmSs= github.com/micmonay/keybd_event v1.1.1/go.mod h1:CGMWMDNgsfPljzrAWoybUOSKafQPZpv+rLigt2LzNGI= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= diff --git a/src/device/input/button/v01.go b/src/device/input/button/v01.go index 2e82f74..1483ba6 100644 --- a/src/device/input/button/v01.go +++ b/src/device/input/button/v01.go @@ -2,10 +2,13 @@ package button import ( "encoding/json" + "io/ioutil" "log" "mayhem-party/src/device/input/raw" "os" "time" + + "gopkg.in/yaml.v2" ) var debugging = os.Getenv("DEBUG") == "true" @@ -13,6 +16,7 @@ var debugging = os.Getenv("DEBUG") == "true" type ( V01 struct { src raw.Raw + cfg v01Cfg } v01Msg struct { T int64 @@ -20,11 +24,17 @@ type ( Y string N string } + v01Cfg struct { + } ) func NewV01(src raw.Raw) V01 { + var cfg v01Cfg + b, _ := ioutil.ReadFile(os.Getenv("BUTTON_PARSER_V01_CONFIG")) + yaml.Unmarshal(b, &cfg) return V01{ src: src, + cfg: cfg, } }