Skip to content

Commit b565ce2

Browse files
committed
sdl: events.go: Merge KeyUpEvent and KeyDownEvent to KeyboardEvent
Signed-off-by: Lilis Iskandar <[email protected]>
1 parent 4d1bcc3 commit b565ce2

File tree

1 file changed

+5
-18
lines changed

1 file changed

+5
-18
lines changed

sdl/events.go

+5-18
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,10 @@ type cWindowEvent C.SDL_WindowEvent
159159

160160
//TODO: Key{Up,Down}Event only differ in 'Type' - a boolean field would be enough to distinguish up/down events
161161

162-
// KeyDownEvent contains keyboard key down event information.
162+
// KeyboardEvent contains keyboard key down event information.
163163
// (https://wiki.libsdl.org/SDL_KeyboardEvent)
164-
type KeyDownEvent struct {
165-
Type uint32 // KEYDOWN
164+
type KeyboardEvent struct {
165+
Type uint32 // KEYUP / KEYDOWN
166166
Timestamp uint32 // timestamp of the event
167167
WindowID uint32 // the window with keyboard focus, if any
168168
State uint8 // PRESSED, RELEASED
@@ -173,19 +173,6 @@ type KeyDownEvent struct {
173173
}
174174
type cKeyboardEvent C.SDL_KeyboardEvent
175175

176-
// KeyUpEvent contains keyboard key up event information.
177-
// (https://wiki.libsdl.org/SDL_KeyboardEvent)
178-
type KeyUpEvent struct {
179-
Type uint32 // KEYUP
180-
Timestamp uint32 // timestamp of the event
181-
WindowID uint32 // the window with keyboard focus, if any
182-
State uint8 // PRESSED, RELEASED
183-
Repeat uint8 // non-zero if this is a key repeat
184-
_ uint8 // padding
185-
_ uint8 // padding
186-
Keysym Keysym // Keysym representing the key that was pressed or released
187-
}
188-
189176
// TextEditingEvent contains keyboard text editing event information.
190177
// (https://wiki.libsdl.org/SDL_TextEditingEvent)
191178
type TextEditingEvent struct {
@@ -560,9 +547,9 @@ func goEvent(cevent *CEvent) Event {
560547
case SYSWMEVENT:
561548
return (*SysWMEvent)(unsafe.Pointer(cevent))
562549
case KEYDOWN:
563-
return (*KeyDownEvent)(unsafe.Pointer(cevent))
550+
fallthrough
564551
case KEYUP:
565-
return (*KeyUpEvent)(unsafe.Pointer(cevent))
552+
return (*KeyboardEvent)(unsafe.Pointer(cevent))
566553
case TEXTEDITING:
567554
return (*TextEditingEvent)(unsafe.Pointer(cevent))
568555
case TEXTINPUT:

0 commit comments

Comments
 (0)