Esempio n. 1
0
func (c *Controller) handleEvents() {
	// read all events
	for event := sdl.PollEvent(); event != nil; event = sdl.PollEvent() {
		switch et := event.(type) {
		case *sdl.QuitEvent:
			log.Println("Want to quit, but how do we apply this... ?")
			/*
				c.Destroy()
				return
				// NOTE: caller keeps calling Iterate because it doesn't know we're done... how to fix?
			*/
		case *sdl.KeyDownEvent:
			c.sendKeyEvents(sdl.GetKeyName(et.Keysym.Sym), true)
		case *sdl.KeyUpEvent:
			c.sendKeyEvents(sdl.GetKeyName(et.Keysym.Sym), false)
		// these are events we know but currently don't use FIXME implement
		case *sdl.WindowEvent:
		case *sdl.TextInputEvent:
		case *sdl.TextEditingEvent:
		case *sdl.MouseButtonEvent:
		case *sdl.MouseMotionEvent:
		case *sdl.MouseWheelEvent:
		default:
			log.Printf("Unknown event: %T\n", et)
		}
	}
}
Esempio n. 2
0
func (gui *Gui) handleKeyDown(ev *sdl.KeyDownEvent) {
	sym := ev.Keysym.Sym

	switch sdl.GetKeyName(sym) {
	case "F":
		gui.chCmd <- ToggleFullscreen{}
	case "W":
		gui.chCmd <- MoveCamera{Direction: UP}
	case "A":
		gui.chCmd <- MoveCamera{Direction: LEFT}
	case "S":
		gui.chCmd <- MoveCamera{Direction: DOWN}
	case "D":
		gui.chCmd <- MoveCamera{Direction: RIGHT}
	case "J":
		gui.chCmd <- Zoom{Direction: IN}
	case "K":
		gui.chCmd <- Zoom{Direction: OUT}
	}
}
Esempio n. 3
0
File: keys.go Progetto: eandre/drip
func (k Key) Name() string {
	return sdl.GetKeyName(sdl.Keycode(k))
}