Skip to content

Instantly share code, notes, and snippets.

@scottferg
Last active December 22, 2015 23:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scottferg/6545670 to your computer and use it in GitHub Desktop.
Save scottferg/6545670 to your computer and use it in GitHub Desktop.
package main
import (
"github.com/scottferg/Go-SDL/sdl"
)
func GetKey(ev interface{}) int {
if k, ok := ev.(sdl.KeyboardEvent); ok {
switch k.Keysym.Sym {
case sdl.K_z: // A
return nes.ButtonA
case sdl.K_x: // B
return nes.ButtonB
case sdl.K_RSHIFT: // Select
return nes.ButtonSelect
case sdl.K_RETURN: // Start
return nes.ButtonStart
case sdl.K_UP: // Up
return nes.ButtonUp
case sdl.K_DOWN: // Down
return nes.ButtonDown
case sdl.K_LEFT: // Left
return nes.ButtonLeft
case sdl.K_RIGHT: // Right
return nes.ButtonRight
}
}
return -1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment