ebiten/event/chan.go
2019-09-12 22:01:09 +09:00

79 lines
2.1 KiB
Go

// Copyright 2013 The Ebiten Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Code generated by genevents.go using 'go generate'. DO NOT EDIT.
package event
import (
"fmt"
"github.com/hajimehoshi/ebiten/internal/driver"
)
func convertCh(driverCh chan driver.Event) chan Event {
ch := make(chan Event)
go func() {
defer close(ch)
for v := range driverCh {
switch v := v.(type) {
case driver.KeyboardKeyCharacter:
ch <- KeyboardKeyCharacter(v)
case driver.KeyboardKeyDown:
ch <- KeyboardKeyDown(v)
case driver.KeyboardKeyUp:
ch <- KeyboardKeyUp(v)
case driver.GamepadAxis:
ch <- GamepadAxis(v)
case driver.GamepadButtonDown:
ch <- GamepadButtonDown(v)
case driver.GamepadButtonUp:
ch <- GamepadButtonUp(v)
case driver.GamepadAttach:
ch <- GamepadAttach(v)
case driver.GamepadDetach:
ch <- GamepadDetach(v)
case driver.MouseMove:
ch <- MouseMove(v)
case driver.MouseWheel:
ch <- MouseWheel(v)
case driver.MouseButtonDown:
ch <- MouseButtonDown(v)
case driver.MouseButtonUp:
ch <- MouseButtonUp(v)
case driver.MouseEnter:
ch <- MouseEnter(v)
case driver.MouseLeave:
ch <- MouseLeave(v)
case driver.TouchBegin:
ch <- TouchBegin(v)
case driver.TouchMove:
ch <- TouchMove(v)
case driver.TouchEnd:
ch <- TouchEnd(v)
case driver.TouchCancel:
ch <- TouchCancel(v)
case driver.ViewUpdate:
ch <- ViewUpdate(v)
case driver.ViewSize:
ch <- ViewSize(v)
default:
panic(fmt.Sprintf("event: unknown event: %v", v))
}
}
}()
return ch
}