Skip to content

Commit

Permalink
Release v0.8.3
Browse files Browse the repository at this point in the history
* FA-18C: fix COMM1 and COMM2 channel preset displays when the first digit is "1" or "2"
* FA-18C: right-justify UFC scratchpad display
* Fix control reference communication in Edge browser
* The automatic setup now detects DCS: World if it was installed via Steam
  • Loading branch information
jboecker committed Oct 30, 2019
2 parents 3704ec3 + 27f3441 commit 2819b40
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 39 deletions.
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: v0.8.2+{build}
version: v0.8.3+{build}
pull_requests:
do_not_increment_build_number: true
image: Visual Studio 2017
Expand Down
38 changes: 8 additions & 30 deletions src/control-reference-json/FA-18C_hornet.json
Original file line number Diff line number Diff line change
Expand Up @@ -9636,26 +9636,15 @@
"physical_variant": "push_button"
},
"UFC_COMM1_CHANNEL_SELECT": {
"api_variant": "multiturn",
"category": "Up Front Controller (UFC)",
"control_type": "analog_dial",
"control_type": "fixed_step_dial",
"description": "COMM 1 Channel Select Knob",
"identifier": "UFC_COMM1_CHANNEL_SELECT",
"inputs": [ {
"description": "turn the dial left or right",
"interface": "variable_step",
"max_value": 65535,
"suggested_step": 3200
"description": "turn left or right",
"interface": "fixed_step"
} ],
"outputs": [ {
"address": 29728,
"description": "the rotation of the knob in the cockpit (not the value that is controlled by this knob!)",
"mask": 65535,
"max_value": 65535,
"shift_by": 0,
"suffix": "_KNOB_POS",
"type": "integer"
} ]
"outputs": [ ]
},
"UFC_COMM1_DISPLAY": {
"category": "Up Front Controller (UFC)",
Expand Down Expand Up @@ -9727,26 +9716,15 @@
} ]
},
"UFC_COMM2_CHANNEL_SELECT": {
"api_variant": "multiturn",
"category": "Up Front Controller (UFC)",
"control_type": "analog_dial",
"control_type": "fixed_step_dial",
"description": "COMM 2 Channel Select Knob",
"identifier": "UFC_COMM2_CHANNEL_SELECT",
"inputs": [ {
"description": "turn the dial left or right",
"interface": "variable_step",
"max_value": 65535,
"suggested_step": 3200
"description": "turn left or right",
"interface": "fixed_step"
} ],
"outputs": [ {
"address": 29730,
"description": "the rotation of the knob in the cockpit (not the value that is controlled by this knob!)",
"mask": 65535,
"max_value": 65535,
"shift_by": 0,
"suffix": "_KNOB_POS",
"type": "integer"
} ]
"outputs": [ ]
},
"UFC_COMM2_DISPLAY": {
"category": "Up Front Controller (UFC)",
Expand Down
20 changes: 20 additions & 0 deletions src/dcs-lua/lib/FA-18C_hornet.lua
Original file line number Diff line number Diff line change
Expand Up @@ -522,8 +522,11 @@ definePushButton("UFC_ENT", 25, 3029, 122, "Up Front Controller (UFC)", "Keyboar
definePotentiometer("UFC_COMM1_VOL", 25, 3030, 108, {0, 1}, "Up Front Controller (UFC)", "COMM 1 Volume Control Knob")
definePotentiometer("UFC_COMM2_VOL", 25, 3031, 123, {0, 1}, "Up Front Controller (UFC)", "COMM 2 Volume Control Knob")
definePotentiometer("UFC_BRT", 25, 3032, 109, {0, 1}, "Up Front Controller (UFC)", "Brightness Control Knob")

defineRotary("UFC_COMM1_CHANNEL_SELECT", 25, 3033, 124, "Up Front Controller (UFC)", "COMM 1 Channel Select Knob")
defineRotary("UFC_COMM2_CHANNEL_SELECT", 25, 3034, 126, "Up Front Controller (UFC)", "COMM 2 Channel Select Knob")
BIOS.util.defineFixedStepInput("UFC_COMM1_CHANNEL_SELECT", 25, 3033, {-0.2, 0.2}, "Up Front Controller (UFC)", "COMM 1 Channel Select Knob")
BIOS.util.defineFixedStepInput("UFC_COMM2_CHANNEL_SELECT", 25, 3034, {-0.2, 0.2}, "Up Front Controller (UFC)", "COMM 2 Channel Select Knob")

local UFC_Comm1Display = ""
local UFC_Comm2Display = ""
Expand All @@ -541,6 +544,18 @@ local UFC_ScratchPadNumberDisplay = ""
local UFC_ScratchPadString1Display = ""
local UFC_ScratchPadString2Display = ""

local function processUfcTwoDigitDisplay(s)
if s == "_" then
s = "--"
end
s = s:gsub("^`", "1")
s = s:gsub("^~", "2")
if s:len() == 1 then
s = " " .. s
end
return s
end

moduleBeingDefined.exportHooks[#moduleBeingDefined.exportHooks+1] = function()
local ufc = parse_indication(6)
UFC_Comm1Display = " "
Expand All @@ -562,7 +577,9 @@ moduleBeingDefined.exportHooks[#moduleBeingDefined.exportHooks+1] = function()
return
end
UFC_Comm1Display = coerce_nil_to_string(ufc.UFC_Comm1Display)
UFC_Comm1Display = processUfcTwoDigitDisplay(UFC_Comm1Display)
UFC_Comm2Display = coerce_nil_to_string(ufc.UFC_Comm2Display)
UFC_Comm2Display = processUfcTwoDigitDisplay(UFC_Comm2Display)
UFC_OptionCueing1 = coerce_nil_to_string(ufc.UFC_OptionCueing1)
UFC_OptionCueing2 = coerce_nil_to_string(ufc.UFC_OptionCueing2)
UFC_OptionCueing3 = coerce_nil_to_string(ufc.UFC_OptionCueing3)
Expand All @@ -574,8 +591,11 @@ moduleBeingDefined.exportHooks[#moduleBeingDefined.exportHooks+1] = function()
UFC_OptionDisplay4 = coerce_nil_to_string(ufc.UFC_OptionDisplay4)
UFC_OptionDisplay5 = coerce_nil_to_string(ufc.UFC_OptionDisplay5)
UFC_ScratchPadNumberDisplay = coerce_nil_to_string(ufc.UFC_ScratchPadNumberDisplay)
UFC_ScratchPadNumberDisplay = (" "):rep(8-UFC_ScratchPadNumberDisplay:len())..UFC_ScratchPadNumberDisplay
UFC_ScratchPadString1Display = coerce_nil_to_string(ufc.UFC_ScratchPadString1Display)
UFC_ScratchPadString1Display = processUfcTwoDigitDisplay(UFC_ScratchPadString1Display)
UFC_ScratchPadString2Display = coerce_nil_to_string(ufc.UFC_ScratchPadString2Display)
UFC_ScratchPadString2Display = processUfcTwoDigitDisplay(UFC_ScratchPadString2Display)
end

defineString("UFC_COMM1_DISPLAY", function() return UFC_Comm1Display end, 2, "Up Front Controller (UFC)", "Comm 1 Display")
Expand Down
54 changes: 54 additions & 0 deletions src/hub-backend/dcssetup/dcssetup_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ import (
"os"
"path/filepath"
"sort"
"strconv"
"strings"

"github.com/andygrunwald/vdf"
"golang.org/x/sys/windows/registry"

"dcs-bios.a10c.de/dcs-bios-hub/jsonapi"
Expand Down Expand Up @@ -191,10 +193,62 @@ func GetDcsInstallations() []DcsInstallation {

scanRegistryPath(registry.CURRENT_USER, "Software\\Eagle Dynamics\\DCS World")
scanRegistryPath(registry.CURRENT_USER, "Software\\Eagle Dynamics\\DCS World OpenBeta")
for _, dir := range getSteamInstallDirs() {
addInstallPath(dir)
}

return installs
}

func getSteamInstallDirs() (foundDirectories []string) {
// find Steam installation directory
d, err := registry.OpenKey(registry.CURRENT_USER, "Software\\Valve\\Steam", registry.QUERY_VALUE)
if err != nil {
return
}
defer d.Close()

steamPath, _, err := d.GetStringValue("SteamPath")
if err != nil {
return
}

scanSteamLibrary := func(path string) {
dcsInstallPath := filepath.Join(path, "steamapps", "common", "DCSWorld")
stat, err := os.Stat(dcsInstallPath)
if err == nil && stat.IsDir() {
foundDirectories = append(foundDirectories, dcsInstallPath)
}
}

scanSteamLibrary(steamPath)

// check for additional steam libraries
file, err := os.Open(filepath.Join(steamPath, "steamapps", "libraryfolders.vdf"))
if err == nil {
defer file.Close()
p := vdf.NewParser(file)
libraryFoldersVdf, err := p.Parse()
if err == nil {
libraryFoldersInterface, ok := libraryFoldersVdf["LibraryFolders"]
if ok {
libraryFolders := libraryFoldersInterface.(map[string]interface{})
for i := 1; true; i++ {
steamLibraryPath, ok := libraryFolders[strconv.Itoa(i)]
if ok {
scanSteamLibrary(steamLibraryPath.(string))
} else {
break
}
}
}
}

}

return
}

func GetExportLuaSetupLine() (string, error) {
executableFile, err := os.Executable()
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions src/hub-backend/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module dcs-bios.a10c.de/dcs-bios-hub

require (
github.com/andygrunwald/vdf v1.0.0
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/getlantern/context v0.0.0-20190109183933-c447772a6520 // indirect
github.com/getlantern/errors v0.0.0-20180829142810-e24b7f4ff7c7 // indirect
Expand Down
2 changes: 2 additions & 0 deletions src/hub-backend/go.sum
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
github.com/andygrunwald/vdf v1.0.0 h1:2HuC85EVF1Sm1bwKH8tiyucny2qzf9GSjB3flsdqoM4=
github.com/andygrunwald/vdf v1.0.0/go.mod h1:qi5jZfY3lrHXbibKeC2MCEge1tOsLODBgOHoS+RbRLk=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down
2 changes: 1 addition & 1 deletion src/hub-backend/jsonapi/jsonapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func (api *JsonApi) HandleApiCall(envelopeJsonData []byte, followupMessagesJson
handlerFunc, ok := api.handlerFunctions[envelope.DataType]
if !ok {
close(responseJsonChannel)
return responseJsonChannel, errors.New("jsonapi: HandleApiCall: no handlerFunc for message type" + envelope.DataType)
return responseJsonChannel, errors.New("jsonapi: HandleApiCall: no handlerFunc for message type " + envelope.DataType)
}
// we know that handlerFunc expects 3 parameters and has Kind reflect.Func
// assert that the first argument type matches the type of the inital message
Expand Down
19 changes: 12 additions & 7 deletions src/hub-frontend/src/ControlReference.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import './ControlReference.css';
import ExportDataParser from './ExportDataParser'

import { apiPost, getApiConnection } from './ApiConnection';
import { w3cwebsocket } from 'websocket';

type TIOElement = {
name: string
Expand Down Expand Up @@ -67,39 +66,45 @@ function ControlReference() {

let [moduleToCategory, setModuleToCategory] = useState<any>({});
let exportDataParser = useState<ExportDataParser>(() => new ExportDataParser())[0]
let liveDataWebsocket = useState<w3cwebsocket>(getApiConnection)[0]
const dummySend = (msg:any ) => console.log
let [ sendWebsocketMsg, setSendWebsocketMsg ] = useState<(msg: any)=>void>(dummySend)

const liveDataCallbacks: TLiveDataContext = {
subscribeExportCallback: exportDataParser.registerExportDataListener.bind(exportDataParser),
unsubscribeExportCallback: exportDataParser.unregisterExportDataListener.bind(exportDataParser),
subscribeEndOfUpdateCallback: exportDataParser.registerEndOfUpdateCallback.bind(exportDataParser),
unsubscribeEndOfUpdateCallback: exportDataParser.unregisterEndOfUpdateListener.bind(exportDataParser),
sendInputData: (msg) => {
liveDataWebsocket.send(JSON.stringify({
sendWebsocketMsg(JSON.stringify({
"datatype": "input_command",
"data": msg
}))
}
}

useEffect(() => {
const liveDataWebsocket = getApiConnection()
liveDataWebsocket.onopen = () => {
const foo = (msg: any) => liveDataWebsocket.send(msg)
setSendWebsocketMsg(() => foo)
liveDataWebsocket.binaryType = "arraybuffer"
liveDataWebsocket.send(JSON.stringify({
datatype: "live_data",
data: {}
}))
}
liveDataWebsocket.onmessage = async (data) => {
data = await data.data.arrayBuffer()
liveDataWebsocket.onmessage = async (response) => {
let data = response.data
//console.log("wsresponse", data)
let a = new Uint8Array(data)
for (let i = 0; i < a.length; i++) {
exportDataParser.processByte(a[i])
}
}
}
return () => {
if (liveDataWebsocket) liveDataWebsocket.close();
}
}, [liveDataWebsocket, exportDataParser])
}, [exportDataParser])


useEffect(() => {
Expand Down

0 comments on commit 2819b40

Please sign in to comment.