mirror of
https://github.com/OrbTools/OrbCommon
synced 2024-11-18 03:25:32 +00:00
io load/save changes
This commit is contained in:
parent
3e5f9691e0
commit
7531ccd5ca
@ -8,7 +8,6 @@ import (
|
||||
"encoding/json"
|
||||
"io"
|
||||
"io/fs"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@ -27,18 +26,16 @@ func init() {
|
||||
}
|
||||
|
||||
//LoadKM Load Orbmap KM structure
|
||||
func LoadKeymap(file string, dev *DeviceDef) *KeyMap {
|
||||
func LoadKeymap(file io.ReadCloser, dev *DeviceDef) *KeyMap {
|
||||
mapped := new(KeyMap)
|
||||
of, _ := os.Open(file)
|
||||
defer of.Close()
|
||||
mapped.Keymap = make([]uint16, dev.NumKeys)
|
||||
binary.Read(of, binary.LittleEndian, mapped.Keymap)
|
||||
binary.Read(of, binary.LittleEndian, mapped.Color)
|
||||
binary.Read(file, binary.LittleEndian, mapped.Keymap)
|
||||
binary.Read(file, binary.LittleEndian, mapped.Color)
|
||||
return mapped
|
||||
}
|
||||
|
||||
//SavePKMKeymap saves an orb after edit
|
||||
func SaveKeymap(mapped interface{}, file io.WriteCloser) {
|
||||
func SaveKeymap(file io.WriteCloser, mapped interface{}) {
|
||||
binary.Write(file, binary.LittleEndian, mapped)
|
||||
file.Close()
|
||||
}
|
||||
|
@ -27,15 +27,14 @@ func init() {
|
||||
}
|
||||
|
||||
//LoadKeymap Load Orbmap KM structure
|
||||
func LoadKeymap(file string, dev *DeviceDef) *KeyMap {
|
||||
func LoadKeymap(file io.ReadCloser, dev *DeviceDef) *KeyMap {
|
||||
mapped := new(KeyMap)
|
||||
of, _ := os.Open(file)
|
||||
xdr.Unmarshal(of, mapped)
|
||||
return mapped
|
||||
}
|
||||
|
||||
//SavePKMKeymap saves an orb after edit
|
||||
func SaveKeymap(mapped interface{}, file io.WriteCloser) {
|
||||
func SaveKeymap(file io.WriteCloser, mapped interface{}) {
|
||||
xdr.Marshal(file, mapped)
|
||||
file.Close()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user