From 0cf0235342f5e3ed9dfe3654aa39dbe14bab01f6 Mon Sep 17 00:00:00 2001 From: Octopus Octopus Date: Sat, 11 Jun 2022 11:13:59 -0500 Subject: [PATCH] rows.go -> clusters.go, change sdf.V2 to v2.Vec --- fightstick/{rows.go => clusters.go} | 36 ++++++++++++++++------------- 1 file changed, 20 insertions(+), 16 deletions(-) rename fightstick/{rows.go => clusters.go} (55%) diff --git a/fightstick/rows.go b/fightstick/clusters.go similarity index 55% rename from fightstick/rows.go rename to fightstick/clusters.go index 11e9865..41e5973 100644 --- a/fightstick/rows.go +++ b/fightstick/clusters.go @@ -1,6 +1,9 @@ package main -import "github.com/deadsy/sdfx/sdf" +import ( + "github.com/deadsy/sdfx/sdf" + v2 "github.com/deadsy/sdfx/vec/v2" +) const ( BUTTON30_DIAMETER = 30 @@ -9,54 +12,55 @@ const ( JOYSTICK_HOLE_DIAMETER = 24 ) -// referenced from http://www.slagcoin.com/joystick/layout.html - +// buttonRow is the face button cluster. +// referenced from http://www.slagcoin.com/joystick/layout.html, +// measurements are slant36_l.png, does not consider stick distance. func buttonRows() sdf.SDF2 { buttons := make([]sdf.SDF2, 4) for i := range buttons { buttons[i], _ = sdf.Circle2D(BUTTON30_DIAMETER / 2) } - buttons[1] = sdf.Transform2D(buttons[1], sdf.Translate2d(sdf.V2{X: 31.25, Y: 9 + 9})) - buttons[2] = sdf.Transform2D(buttons[2], sdf.Translate2d(sdf.V2{X: 31.25 + 35, Y: 9})) - buttons[3] = sdf.Transform2D(buttons[3], sdf.Translate2d(sdf.V2{X: 31.25 + 35 + 35, Y: 0})) + buttons[1] = sdf.Transform2D(buttons[1], sdf.Translate2d(v2.Vec{X: 31.25, Y: 9 + 9})) + buttons[2] = sdf.Transform2D(buttons[2], sdf.Translate2d(v2.Vec{X: 31.25 + 35, Y: 9})) + buttons[3] = sdf.Transform2D(buttons[3], sdf.Translate2d(v2.Vec{X: 31.25 + 35 + 35, Y: 0})) bottomRow := sdf.Union2D(buttons...) topRow := bottomRow - topRow = sdf.Transform2D(topRow, sdf.Translate2d(sdf.V2{X: 0, Y: 9 + 9 + 21})) + topRow = sdf.Transform2D(topRow, sdf.Translate2d(v2.Vec{X: 0, Y: 9 + 9 + 21})) buttonRows := sdf.Union2D(topRow, bottomRow) // this is done to recenter these parts for easier work on the topPlane - //buttonRows = sdf.Transform2D(buttonRows, sdf.Translate2d(sdf.V2{X: -(31.25 + 35 + 35) / 2, Y: -(9 + 9 + 21 + 9 + 9) / 2})) + //buttonRows = sdf.Transform2D(buttonRows, sdf.Translate2d(v2.Vec{X: -(31.25 + 35 + 35) / 2, Y: -(9 + 9 + 21 + 9 + 9) / 2})) buttonRows = sdf.Center2D(buttonRows) return buttonRows } +// functionRow is the start/select/home/capture cluster. func functionRow() sdf.SDF2 { spacing := 30.0 buttonCount := 4 buttons := make([]sdf.SDF2, buttonCount) for i := range buttons { buttons[i], _ = sdf.Circle2D(BUTTON24_DIAMETER / 2) - buttons[i] = sdf.Transform2D(buttons[i], sdf.Translate2d(sdf.V2{X: spacing * float64(i), Y: 0})) + buttons[i] = sdf.Transform2D(buttons[i], sdf.Translate2d(v2.Vec{X: spacing * float64(i), Y: 0})) } functionRow := sdf.Union2D(buttons...) - //functionRow = sdf.Transform2D(functionRow, sdf.Translate2d(sdf.V2{X: -(spacing * float64(buttonCount) / 2), Y: 0})) + //functionRow = sdf.Transform2D(functionRow, sdf.Translate2d(v2.Vec{X: -(spacing * float64(buttonCount) / 2), Y: 0})) functionRow = sdf.Center2D(functionRow) return functionRow } // https://support.focusattack.com/hc/en-us/articles/360015744451-Sanwa-JLF-P1-Mounting-Plate-Measurements // reference for screw hole mounting points - -func joystick(holeSpacing sdf.V2) sdf.SDF2 { +func joystick(holeSpacing v2.Vec) sdf.SDF2 { holes := make([]sdf.SDF2, 4) for i := range holes { holes[i], _ = sdf.Circle2D(M4_SCREW_DIAMETER / 2) } - holes[0] = sdf.Transform2D(holes[0], sdf.Translate2d(sdf.V2{X: holeSpacing.X / 2, Y: holeSpacing.Y / 2})) - holes[1] = sdf.Transform2D(holes[1], sdf.Translate2d(sdf.V2{X: -holeSpacing.X / 2, Y: holeSpacing.Y / 2})) - holes[2] = sdf.Transform2D(holes[2], sdf.Translate2d(sdf.V2{X: holeSpacing.X / 2, Y: -holeSpacing.Y / 2})) - holes[3] = sdf.Transform2D(holes[3], sdf.Translate2d(sdf.V2{X: -holeSpacing.X / 2, Y: -holeSpacing.Y / 2})) + holes[0] = sdf.Transform2D(holes[0], sdf.Translate2d(v2.Vec{X: holeSpacing.X / 2, Y: holeSpacing.Y / 2})) + holes[1] = sdf.Transform2D(holes[1], sdf.Translate2d(v2.Vec{X: -holeSpacing.X / 2, Y: holeSpacing.Y / 2})) + holes[2] = sdf.Transform2D(holes[2], sdf.Translate2d(v2.Vec{X: holeSpacing.X / 2, Y: -holeSpacing.Y / 2})) + holes[3] = sdf.Transform2D(holes[3], sdf.Translate2d(v2.Vec{X: -holeSpacing.X / 2, Y: -holeSpacing.Y / 2})) joystickHole, _ := sdf.Circle2D(JOYSTICK_HOLE_DIAMETER / 2) holes = append(holes, joystickHole) return sdf.Union2D(holes...)