Commit 5fe797d1 authored by simon's avatar simon
Browse files

fix by using range over channel

parent 188e2b8b
Loading
Loading
Loading
Loading
+80 −81
Original line number Diff line number Diff line
@@ -113,10 +113,9 @@ type RadiusEvent struct {
	Radius float32
}

// ParcelOutEvents waits on the HID.OSEvent channel (so is blocking), then puts the required event(s), on any registered channel(s).
// ParcelOutEvents waits on the HID.OSEvent channel (so blocks until OSEvent is closed), then puts the required event(s), on any registered channel(s).
func (d HID) ParcelOutEvents() {
	for {
		if evt, ok := <-d.OSEvents; ok {
	for evt := range(d.OSEvents){
		switch evt.Type {
		case 1:
			b := d.Buttons[evt.Index]
@@ -222,9 +221,7 @@ func (d HID) ParcelOutEvents() {
		default:
			// log.Println("unknown input type. ",evt.Type & 0x7f)
		}
		} else {
			break
		}

	}
}

@@ -391,3 +388,5 @@ func (d HID) HatCoords(hat uint8, coords []float32) {
func (d HID) InsertSyntheticEvent(v int16, t uint8, i uint8) {
	d.OSEvents <- osEventRecord{Value: v, Type: t, Index: i}
}