Commit 8880449d authored by simon's avatar simon
Browse files

example: joystick ->hid

parent 2019a497
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -28,9 +28,9 @@ Example: play a note when pressing button #1. hat position changes frequency, y

	func main() {
		jsevents := Capture(
			Channel{10, Joystick.OnLong}, // events[0] button #10 long pressed
			Channel{1, Joystick.OnClose}, // events[1] button #1 closes
			Channel{1, Joystick.OnMove},  // events[2] hat #1 moves
			Channel{10, HID.OnLong}, // events[0] button #10 long pressed
			Channel{1, HID.OnClose}, // events[1] button #1 closes
			Channel{1, HID.OnMove},  // events[2] hat #1 moves
		)
		var x float32 = .5
		var f time.Duration = time.Second / 440
+3 −3
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@ usage:

or (more flexible)

'Connect' to a joystick by index number, then use methods to add event channels, one for each button or hat, and start running by calling 'ParcelOutEvents'.
'Connect' to a HID by index number, then use methods to add event channels, one for each button or hat, and start running by calling 'ParcelOutEvents'.

event, an interface with a 'Moment' method, provides a time.Duration. Moment() returns whatever the underlying Linux driver provides as the events timestamp, in time.Duration.

@@ -17,9 +17,9 @@ hat channel event provides current position, (x,y) the event will need casting t

or (DIY)

'Connect' to a joystick by index number
'Connect' to a HID by index number

handle all events directly using the returned Joystick's OSEvent channel.
handle all events directly using the returned HID's OSEvent channel.

*/
package joysticks
+3 −3
Original line number Diff line number Diff line
@@ -13,9 +13,9 @@ import . "github.com/splace/sounds"

func main() {
	jsevents := Capture(
		Channel{10, Joystick.OnLong}, // events[0] button #10 long pressed
		Channel{1, Joystick.OnClose}, // events[1] button #1 closes
		Channel{1, Joystick.OnMove},  // events[2] hat #1 moves
		Channel{10, HID.OnLong}, // events[0] button #10 long pressed
		Channel{1, HID.OnClose}, // events[1] button #1 closes
		Channel{1, HID.OnMove},  // events[2] hat #1 moves
	)
	var x float32 = .5
	var f time.Duration = time.Second / 440