mirror of
https://github.com/rommapp/grout.git
synced 2026-04-23 06:54:36 +00:00
feat(rocknix/rgds): native keymapping in grout
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"grout/cfw/minui"
|
||||
"grout/cfw/muos"
|
||||
"grout/cfw/onion"
|
||||
"grout/cfw/rocknix"
|
||||
"grout/cfw/spruce"
|
||||
"grout/internal"
|
||||
"grout/internal/environment"
|
||||
@@ -87,6 +88,8 @@ func setupInputMapping(currentCFW cfw.CFW) {
|
||||
mappingBytes, mappingErr = minui.GetInputMappingBytes()
|
||||
case cfw.Spruce:
|
||||
mappingBytes, mappingErr = spruce.GetInputMappingBytes()
|
||||
case cfw.ROCKNIX:
|
||||
mappingBytes, mappingErr = rocknix.GetInputMappingBytes()
|
||||
}
|
||||
|
||||
if mappingBytes != nil && mappingErr == nil {
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package rocknix
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
//go:embed input_mappings/*.json
|
||||
var embeddedInputMappings embed.FS
|
||||
|
||||
type Device string
|
||||
|
||||
const (
|
||||
DeviceAnbernicRGDS Device = "rgds"
|
||||
DeviceGeneric Device = "generic"
|
||||
)
|
||||
|
||||
func DetectDevice() Device {
|
||||
compatible, err := os.ReadFile("/sys/firmware/devicetree/base/compatible")
|
||||
if err == nil && strings.Contains(string(compatible), "anbernic,rg-ds") {
|
||||
return DeviceAnbernicRGDS
|
||||
}
|
||||
|
||||
return DeviceGeneric
|
||||
}
|
||||
|
||||
func GetInputMappingBytes() ([]byte, error) {
|
||||
device := DetectDevice()
|
||||
|
||||
var filename string
|
||||
switch device {
|
||||
case DeviceAnbernicRGDS:
|
||||
filename = "input_mappings/rgds.json"
|
||||
default:
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
overridePath := filepath.Join("overrides", "cfw", "rocknix", filename)
|
||||
data, err := os.ReadFile(overridePath)
|
||||
if err != nil {
|
||||
data, err = embeddedInputMappings.ReadFile(filename)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to read embedded input mapping %s: %w", filename, err)
|
||||
}
|
||||
}
|
||||
|
||||
return data, nil
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"keyboard_map": {},
|
||||
"controller_button_map": {
|
||||
"0": 6,
|
||||
"1": 5,
|
||||
"10": 11,
|
||||
"11": 1,
|
||||
"12": 2,
|
||||
"13": 3,
|
||||
"14": 4,
|
||||
"2": 7,
|
||||
"3": 8,
|
||||
"4": 14,
|
||||
"5": 15,
|
||||
"6": 13,
|
||||
"9": 9
|
||||
},
|
||||
"controller_hat_map": {},
|
||||
"joystick_axis_map": {},
|
||||
"joystick_button_map": {
|
||||
"6": 10,
|
||||
"7": 12
|
||||
},
|
||||
"joystick_hat_map": {}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ fi
|
||||
|
||||
export CFW=ROCKNIX
|
||||
export LD_LIBRARY_PATH="$CUR_DIR/Grout/lib:$LD_LIBRARY_PATH"
|
||||
export FLIP_FACE_BUTTONS=1
|
||||
#export FLIP_FACE_BUTTONS=1
|
||||
|
||||
./grout
|
||||
|
||||
|
||||
Reference in New Issue
Block a user