Made changes for SDL2 to work on Android

This commit is contained in:
Alexander Taylor 2015-09-22 22:08:51 +01:00
parent 06bd284067
commit 4422f5e24c
5 changed files with 22 additions and 8 deletions

View File

@ -326,6 +326,7 @@ from kivy.resources import resource_find
from kivy.utils import platform as core_platform
from kivy.uix.widget import Widget
from kivy.properties import ObjectProperty, StringProperty
from kivy.setupconfig import USE_SDL2
platform = core_platform
@ -1023,7 +1024,7 @@ class App(EventDispatcher):
setting_key = 282 # F1
# android hack, if settings key is pygame K_MENU
if platform == 'android':
if platform == 'android' and not USE_SDL2:
import pygame
setting_key = pygame.K_MENU

View File

@ -497,6 +497,8 @@ class WindowBase(EventDispatcher):
return 0
def _get_android_kheight(self):
if USE_SDL2: # Placeholder until the SDL2 bootstrap supports this
return 0
global android
if not android:
import android

View File

@ -393,7 +393,7 @@ class WindowSDL(WindowBase):
# We have a conflict of using either the mouse or the finger.
# Right now, we have no mechanism that we could use to know
# which is the preferred one for the application.
if platform == "ios":
if platform in ('ios', 'android'):
SDL2MotionEventProvider.q.appendleft(event)
pass

View File

@ -104,6 +104,7 @@ __all__ = ('Metrics', 'MetricsBase', 'pt', 'inch', 'cm', 'mm', 'dp', 'sp',
from os import environ
from kivy.utils import reify, platform
from kivy.properties import dpi2px
from kivy.setupconfig import USE_SDL2
def pt(value):
@ -158,8 +159,13 @@ class MetricsBase(object):
return float(custom_dpi)
if platform == 'android':
import android
return android.get_dpi()
if USE_SDL2:
import jnius
Hardware = jnius.autoclass('org.renpy.android.Hardware')
return Hardware.getDPI()
else:
import android
return android.get_dpi()
elif platform == 'ios':
import ios
return ios.get_dpi()
@ -217,8 +223,12 @@ class MetricsBase(object):
if platform == 'android':
from jnius import autoclass
PythonActivity = autoclass('org.renpy.android.PythonActivity')
config = PythonActivity.mActivity.getResources().getConfiguration()
if USE_SDL2:
PythonActivity = autoclass('org.kivy.android.PythonActivity')
config = PythonActivity.mActivity.getResources().getConfiguration()
else:
PythonActivity = autoclass('org.renpy.android.PythonActivity')
config = PythonActivity.mActivity.getResources().getConfiguration()
return config.fontScale
return 1.0

View File

@ -373,10 +373,11 @@ if platform not in ('ios', 'android') and (c_options['use_gstreamer']
c_options['use_gstreamer'] = True
# detect SDL2, only on desktop and iOS
# detect SDL2, only on desktop and iOS, or android if explicitly enabled
# works if we forced the options or in autodetection
sdl2_flags = {}
if platform not in ('android',) and c_options['use_sdl2'] in (None, True):
if c_options['use_sdl2'] or (
platform not in ('android',) and c_options['use_sdl2'] is None):
if c_options['use_osx_frameworks'] and platform == 'darwin':
# check the existence of frameworks