Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
donomii committed Sep 1, 2024
1 parent 0d22914 commit f889bb9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
4 changes: 3 additions & 1 deletion example/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"sort"
"time"
joystick "github.com/donomii/sceneCamera/joystick"
messages "github.com/donomii/sceneCamera/messages"
//messages "github.com/donomii/sceneCamera/messages"

"github.com/donomii/goof"

Expand Down Expand Up @@ -215,6 +215,7 @@ func main() {
}
}()
joystick.Setup_joystick()
/*
messages.Register("JoystickY", "JoystickY", func(name , id string, args interface{}) {
amount := args.(float64)
camera.Move(0, float32(amount))
Expand All @@ -223,6 +224,7 @@ func main() {
amount := args.(float64)
camera.Move(2, float32(amount))
})
*/
for !win.ShouldClose() {
joystick.DoJoystick()
mode := glfw.GetPrimaryMonitor().GetVideoMode()
Expand Down
20 changes: 10 additions & 10 deletions joystick/joystick.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package joystick

import (
messages "github.com/donomii/sceneCamera/messages"
//messages "github.com/donomii/sceneCamera/messages"

"github.com/donomii/goof"
"github.com/go-gl/glfw/v3.3/glfw"
Expand Down Expand Up @@ -56,7 +56,7 @@ func DoJoystick() {

if !latches[i] {
latches[i] = true
messages.SendMessage("Button", i)
//messages.SendMessage("Button", i)

}
} else {
Expand All @@ -68,18 +68,18 @@ func DoJoystick() {
if joystick_type == "steamdeck" {
for i := 0; i < len(joy.GetAxes()); i = i + 3 {
var ydeflect float64 = 0
var trigger float64 = 0
//var trigger float64 = 0
xdeflect := float64(joy.GetAxes()[i])
if i+1 < len(joy.GetAxes()) {
ydeflect = float64(joy.GetAxes()[i+1])
}
if i+2 < len(joy.GetAxes()) {
trigger = float64(joy.GetAxes()[i+2])
//trigger = float64(joy.GetAxes()[i+2])
}
if outOfDeadZone(deadZone, xdeflect, ydeflect) {
messages.SendMessage("JoystickY", ydeflect/-100)
/*messages.SendMessage("JoystickY", ydeflect/-100)
messages.SendMessage("JoystickX", xdeflect/-100)
messages.SendMessage("JoystickTrigger", trigger)
messages.SendMessage("JoystickTrigger", trigger)*/
}
/*
if xdeflect > deadZone || xdeflect < -deadZone || ydeflect > deadZone || ydeflect < -deadZone {
Expand All @@ -97,18 +97,18 @@ func DoJoystick() {
if joystick_type == "F310" {
for i := 0; i < len(joy.GetAxes()); i = i + 2 {
var ydeflect float64 = 0
var trigger float64 = 0
//var trigger float64 = 0
xdeflect := float64(joy.GetAxes()[i])
if i+1 < len(joy.GetAxes()) {
ydeflect = float64(joy.GetAxes()[i+1])
}
if i+2 < len(joy.GetAxes()) {
trigger = float64(joy.GetAxes()[i+2])
//trigger = float64(joy.GetAxes()[i+2])
}
if outOfDeadZone(deadZone, xdeflect, ydeflect) {
messages.SendMessage("JoystickY", ydeflect/-100)
/*messages.SendMessage("JoystickY", ydeflect/-100)
messages.SendMessage("JoystickX", xdeflect/-100)
messages.SendMessage("JoystickTrigger", trigger)
messages.SendMessage("JoystickTrigger", trigger)*/
}

/*
Expand Down

0 comments on commit f889bb9

Please sign in to comment.