Loading README.md +1 −1 Original line number Diff line number Diff line Loading @@ -63,6 +63,6 @@ Example: play a note when pressing button #1. hat position changes frequency, y Note: "jstest-gtk" - system wide mapping and calibration. Note: "jstest-gtk" - system wide mapping and calibration for joysticks. joysticks.go +12 −1 Original line number Diff line number Diff line Loading @@ -158,7 +158,7 @@ func (d HID) OnClose(button uint8) chan event { return c } // button goes open and last event on it, closed, wasn't recent. (within 1 second) // button goes open and the previous event, closed, was more than LongPressDelay ago. func (d HID) OnLong(button uint8) chan event { c := make(chan event) d.buttonLongPressEvents[button] = c Loading Loading @@ -213,6 +213,17 @@ func (d HID) HatExists(hat uint8) (ok bool) { return } // Hat current position. (coords slice needs to be long enough to hold all axis.) func (d HID) ReadHatPosition(hat uint8, coords []float32) { for _, h := range d.HatAxes { if h.number == hat { coords[h.axis-1]=h.value } } return } // insert events as if from hardware. func (d HID) InsertSyntheticEvent(v int16, t uint8, i uint8) { d.OSEvents <- osEventRecord{Value: v, Type: t, Index: i} Loading joysticks_test.go +5 −3 Original line number Diff line number Diff line Loading @@ -85,8 +85,9 @@ func TestHIDsAdvanced(t *testing.T) { b2 := js1.OnClose(2) b3 := js1.OnClose(3) b4 := js1.OnClose(4) b5 := js1.OnClose(5) coord:=make([]float32,2) quit := js1.OnOpen(10) h1 := js1.OnMove(1) h4 := js1.OnPanX(2) h5 := js1.OnPanY(2) h3 := js1.OnMove(3) Loading @@ -105,8 +106,9 @@ func TestHIDsAdvanced(t *testing.T) { play(NewSound(NewTone(time.Second/250, 1), time.Second/3)) case <-b4: play(NewSound(NewTone(time.Second/150, 1), time.Second/3)) case h := <-h1: fmt.Println("hat 1 moved", h) case <-b5: js1.ReadHatPosition(1,coord) fmt.Println(coord) case h := <-h3: fmt.Println("hat 3 moved", h) case h := <-h4: Loading Loading
README.md +1 −1 Original line number Diff line number Diff line Loading @@ -63,6 +63,6 @@ Example: play a note when pressing button #1. hat position changes frequency, y Note: "jstest-gtk" - system wide mapping and calibration. Note: "jstest-gtk" - system wide mapping and calibration for joysticks.
joysticks.go +12 −1 Original line number Diff line number Diff line Loading @@ -158,7 +158,7 @@ func (d HID) OnClose(button uint8) chan event { return c } // button goes open and last event on it, closed, wasn't recent. (within 1 second) // button goes open and the previous event, closed, was more than LongPressDelay ago. func (d HID) OnLong(button uint8) chan event { c := make(chan event) d.buttonLongPressEvents[button] = c Loading Loading @@ -213,6 +213,17 @@ func (d HID) HatExists(hat uint8) (ok bool) { return } // Hat current position. (coords slice needs to be long enough to hold all axis.) func (d HID) ReadHatPosition(hat uint8, coords []float32) { for _, h := range d.HatAxes { if h.number == hat { coords[h.axis-1]=h.value } } return } // insert events as if from hardware. func (d HID) InsertSyntheticEvent(v int16, t uint8, i uint8) { d.OSEvents <- osEventRecord{Value: v, Type: t, Index: i} Loading
joysticks_test.go +5 −3 Original line number Diff line number Diff line Loading @@ -85,8 +85,9 @@ func TestHIDsAdvanced(t *testing.T) { b2 := js1.OnClose(2) b3 := js1.OnClose(3) b4 := js1.OnClose(4) b5 := js1.OnClose(5) coord:=make([]float32,2) quit := js1.OnOpen(10) h1 := js1.OnMove(1) h4 := js1.OnPanX(2) h5 := js1.OnPanY(2) h3 := js1.OnMove(3) Loading @@ -105,8 +106,9 @@ func TestHIDsAdvanced(t *testing.T) { play(NewSound(NewTone(time.Second/250, 1), time.Second/3)) case <-b4: play(NewSound(NewTone(time.Second/150, 1), time.Second/3)) case h := <-h1: fmt.Println("hat 1 moved", h) case <-b5: js1.ReadHatPosition(1,coord) fmt.Println(coord) case h := <-h3: fmt.Println("hat 3 moved", h) case h := <-h4: Loading