sdl: events.go: Merge KeyUpEvent and KeyDownEvent to KeyboardEvent
@@ -159,10 +159,10 @@ type cWindowEvent C.SDL_WindowEvent
//TODO: Key{Up,Down}Event only differ in 'Type' - a boolean field would be enough to distinguish up/down events
-// KeyDownEvent contains keyboard key down event information.
+// KeyboardEvent contains keyboard key down event information.
// (https://wiki.libsdl.org/SDL_KeyboardEvent)
-type KeyDownEvent struct {
- Type uint32 // KEYDOWN
+type KeyboardEvent struct {
+ Type uint32 // KEYUP / KEYDOWN
Timestamp uint32 // timestamp of the event
WindowID uint32 // the window with keyboard focus, if any
State uint8 // PRESSED, RELEASED
@@ -173,19 +173,6 @@ type KeyDownEvent struct {
}
type cKeyboardEvent C.SDL_KeyboardEvent
-// KeyUpEvent contains keyboard key up event information.
-// (https://wiki.libsdl.org/SDL_KeyboardEvent)
-type KeyUpEvent struct {
- Type uint32 // KEYUP
- Timestamp uint32 // timestamp of the event
- WindowID uint32 // the window with keyboard focus, if any
- State uint8 // PRESSED, RELEASED
- Repeat uint8 // non-zero if this is a key repeat
- _ uint8 // padding
- _ uint8 // padding
- Keysym Keysym // Keysym representing the key that was pressed or released
-}
-
// TextEditingEvent contains keyboard text editing event information.
// (https://wiki.libsdl.org/SDL_TextEditingEvent)
type TextEditingEvent struct {
@@ -560,9 +547,9 @@ func goEvent(cevent *CEvent) Event {
case SYSWMEVENT:
return (*SysWMEvent)(unsafe.Pointer(cevent))
case KEYDOWN:
- return (*KeyDownEvent)(unsafe.Pointer(cevent))
+ fallthrough
case KEYUP:
- return (*KeyUpEvent)(unsafe.Pointer(cevent))
+ return (*KeyboardEvent)(unsafe.Pointer(cevent))
case TEXTEDITING:
return (*TextEditingEvent)(unsafe.Pointer(cevent))
case TEXTINPUT:
