/
gdl.go
47 lines (37 loc) · 882 Bytes
/
gdl.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package gdl
import (
"github.com/elliotmr/gdl/event"
"github.com/elliotmr/gdl/ticker"
"github.com/pkg/errors"
)
const (
InitTimer = 1 << iota
InitAudio
InitVideo
InitJoystick
InitHaptic
InitGameController
InitEvents
InitNoParachute
)
const InitEverything = InitTimer | InitAudio | InitVideo | InitJoystick | InitHaptic | InitGameController | InitEvents | InitNoParachute
var EventLoop *event.Queue
func Init(flags uint32) error {
if flags&InitGameController > 0 {
// game controller implies joystick
flags |= InitJoystick
}
if flags&(InitVideo|InitJoystick) > 0 {
// video or joystick implies event
flags |= InitEvents
}
if flags&(InitHaptic|InitJoystick) > 0 {
if err := helperWindowCreate(); err != nil {
return errors.Wrap(err, "failed initializing joystick")
}
}
ticker.Initialize()
if flags&InitEvents > 0 {
EventLoop.Start()
}
}