Skip to content

Commit

Permalink
Added SDL hint to let Kivy handle the Android back button
Browse files Browse the repository at this point in the history
  • Loading branch information
inclement committed Jan 23, 2019
1 parent e437dfc commit 98da99e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions kivy/core/window/_window_sdl2.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ cdef class _WindowSDL2Storage:

SDL_SetHint(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, b'0')

SDL_SetHintWithPriority(b'SDL_ANDROID_TRAP_BACK_BUTTON', b'1',
SDL_HINT_OVERRIDE)

if SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0:
self.die()

Expand Down
7 changes: 7 additions & 0 deletions kivy/lib/sdl2.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,11 @@ cdef extern from "SDL.h":
SDL_WINDOWEVENT_CLOSE #< The window manager requests that the
# window be closed */

ctypedef enum SDL_HintPriority:
SDL_HINT_DEFAULT
SDL_HINT_NORMAL
SDL_HINT_OVERRIDE

ctypedef enum SDL_RendererFlip:
SDL_FLIP_NONE = 0x00000000
SDL_FLIP_HORIZONTAL = 0x00000001
Expand Down Expand Up @@ -440,6 +445,7 @@ cdef extern from "SDL.h":
cdef char *SDL_HINT_ORIENTATIONS
cdef char *SDL_HINT_VIDEO_WIN_D3DCOMPILER
cdef char *SDL_HINT_ACCELEROMETER_AS_JOYSTICK
cdef char *SDL_HINT_ANDROID_TRAP_BACK_BUTTON

cdef int SDL_QUERY = -1
cdef int SDL_IGNORE = 0
Expand Down Expand Up @@ -505,6 +511,7 @@ cdef extern from "SDL.h":
cdef int SDL_SetTextureAlphaMod(SDL_Texture * texture, Uint8 alpha)
cdef char * SDL_GetError()
cdef SDL_bool SDL_SetHint(char *name, char *value)
cdef SDL_bool SDL_SetHintWithPriority(char *name, char *value, SDL_HintPriority priority)
cdef Uint8 SDL_GetMouseState(int* x,int* y)
cdef SDL_GLContext SDL_GL_CreateContext(SDL_Window* window)
cdef int SDL_GetNumVideoDisplays()
Expand Down

0 comments on commit 98da99e

Please sign in to comment.