Skip to content

Commit

Permalink
switch to openstreetmap and implement teleport
Browse files Browse the repository at this point in the history
  • Loading branch information
lian committed Aug 26, 2020
1 parent 84f5d13 commit 2f4b190
Show file tree
Hide file tree
Showing 10 changed files with 709 additions and 73 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ program zips are uploaded [here](https://github.com/lian/msfs2020-go/releases)

## tools

* [vfrmap](vfrmap/) web server that shows your current MSFS2020 plane position in google maps inside the browser
* [vfrmap](vfrmap/) local web-server that will allow you to view your location, and some information about your trajectory including airspeed and altitude.

## examples

Expand Down
1 change: 1 addition & 0 deletions build-vfrmap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ set -e

go generate github.com/lian/msfs2020-go/simconnect
go generate github.com/lian/msfs2020-go/vfrmap
go generate github.com/lian/msfs2020-go/vfrmap/html/leafletjs

build_time=$(date -u +'%Y-%m-%d_%T')
set +e
Expand Down
1 change: 1 addition & 0 deletions simconnect/defs.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const E_FAIL uint32 = 0x80004005
type DWORD uint32

const UNUSED DWORD = 0xffffffff // special value to indicate unused event, ID
const OBJECT_ID_USER DWORD = 0 // proxy value for User vehicle ObjectID

const (
DATATYPE_INVALID DWORD = iota // invalid data type
Expand Down
35 changes: 35 additions & 0 deletions simconnect/simconnect.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ var proc_SimConnect_AddToDataDefinition *syscall.LazyProc
var proc_SimConnect_SubscribeToSystemEvent *syscall.LazyProc
var proc_SimConnect_GetNextDispatch *syscall.LazyProc
var proc_SimConnect_RequestDataOnSimObjectType *syscall.LazyProc
var proc_SimConnect_SetDataOnSimObject *syscall.LazyProc

type SimConnect struct {
handle unsafe.Pointer
Expand Down Expand Up @@ -58,6 +59,7 @@ func New(name string) (*SimConnect, error) {
proc_SimConnect_SubscribeToSystemEvent = mod.NewProc("SimConnect_SubscribeToSystemEvent")
proc_SimConnect_GetNextDispatch = mod.NewProc("SimConnect_GetNextDispatch")
proc_SimConnect_RequestDataOnSimObjectType = mod.NewProc("SimConnect_RequestDataOnSimObjectType")
proc_SimConnect_SetDataOnSimObject = mod.NewProc("SimConnect_SetDataOnSimObject")
}

// SimConnect_Open(
Expand Down Expand Up @@ -227,6 +229,39 @@ func (s *SimConnect) RequestDataOnSimObjectType(requestID, defineID, radius, sim
return nil
}

func (s *SimConnect) SetDataOnSimObject(defineID, simobjectType, flags, arrayCount, size DWORD, buf unsafe.Pointer) error {
//s.SetDataOnSimObject(defineID, simconnect.OBJECT_ID_USER, 0, 0, size, buf)

// SimConnect_SetDataOnSimObject(
// HANDLE hSimConnect,
// SIMCONNECT_DATA_DEFINITION_ID DefineID,
// SIMCONNECT_OBJECT_ID ObjectID,
// SIMCONNECT_DATA_SET_FLAG Flags,
// DWORD ArrayCount,
// DWORD cbUnitSize,
// void * pDataSet
// );
args := []uintptr{
uintptr(s.handle),
uintptr(defineID),
uintptr(simobjectType),
uintptr(flags),
uintptr(arrayCount),
uintptr(size),
uintptr(buf),
}

r1, _, err := proc_SimConnect_SetDataOnSimObject.Call(args...)
if int32(r1) < 0 {
return fmt.Errorf(
"SimConnect_SetDataOnSimObject for defineID %d error: %d %s",
defineID, r1, err,
)
}

return nil
}

func (s *SimConnect) GetNextDispatch() (unsafe.Pointer, int32, error) {
var ppData unsafe.Pointer
var ppDataLength DWORD
Expand Down
20 changes: 17 additions & 3 deletions vfrmap/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# msfs2020-go/vfrmap

web server that shows your current MSFS2020 plane position in google maps inside the browser
local web-server using msfs2020-go/simconnect that will allow you to view your location, and some information about your trajectory including airspeed and altitude.

also allows you to quickly teleport your plane to any location.

## install

Expand All @@ -10,21 +12,33 @@ web server that shows your current MSFS2020 plane position in google maps inside
## run
* run `vfrmap.exe`
* browse to http://localhost:9000
* or to `http://<computer-ip>:9000`

## arguments

* `-v` show program version
* `-api-key` use your own gmap api-key
* `-verbose` verbose output

## usage

click on your plane to see gps coordinates, follow or don't follow the plane, or open the current location on google maps in a new tab.

if you click on the map itself a new marker appears. clicking on that marker allows you to teleport to this location or enter your own gps coordinates.

esc key switching between following the plane or freely moving around on the map.

## change visualisation

if you want to change how the webpage looks then copy and change [index.html](html/index.html) to the same folder as `vfrmap.exe` and relaunch the program.

## openstreetmap

earlier versions of this app used google maps directly, but this was to expensive. openstreetmap is free to use and very good as well.

## compile

`GOOS=windows GOARCH=amd64 go build github.com/lian/msfs2020-go/vfrmap` or see [build-vfrmap.sh](https://github.com/lian/msfs2020-go/blob/master/build-vfrmap.sh)

## screenshots

![screenshot](https://i.imgur.com/YllMEvG.png)
![screenshot](https://i.imgur.com/5PZyKC8.png)
4 changes: 2 additions & 2 deletions vfrmap/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2f4b190

Please sign in to comment.