Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patching SDL2 to enable keyboard selection #559

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions recipes/kivy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ class KivyRecipe(CythonRecipe):
pbx_frameworks = ["OpenGLES", "Accelerate", "CoreMedia", "CoreVideo"]
pre_build_ext = True

def prebuild_arch(self, arch):
if self.has_marker("patched"):
return
self.apply_patch("keyboard.patch")
self.set_marker("patched")

def get_recipe_env(self, arch):
env = super(KivyRecipe, self).get_recipe_env(arch)
env["KIVY_SDL2_PATH"] = ":".join([
Expand Down
5 changes: 5 additions & 0 deletions recipes/kivy/keyboard.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
--- kivy-38fcbd5b90c99a96d82682f14986836cde81412d/kivy/lib/sdl2.pxi
+++ kivy-38fcbd5b90c99a96d82682f14986836cde81412d/kivy/lib/sdl2.pxi
@@ -622,1 +622,1 @@
- cdef void SDL_StartTextInput()
+ cdef void SDL_StartTextInput(int keyboard_type)
107 changes: 107 additions & 0 deletions recipes/sdl2/uikit-transparent.patch
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,109 @@
--- slime73-sdl-experiments-618662dc9e82/src/video/uikit/SDL_uikitviewcontroller.m
+++ slime73-sdl-experiments-618662dc9e82/src/video/uikit/SDL_uikitviewcontroller.m
@@ -332,1 +332,1 @@
- [self showKeyboard];
+ [self showKeyboard:textField.keyboardType];
@@ -370,1 +370,1 @@
-- (void)showKeyboard
+- (void)showKeyboard:(NSInteger)UIKeyboardType
@@ -373,3 +373,5 @@
if (textField.window) {
showingKeyboard = YES;
+ [textField setKeyboardType:UIKeyboardType];
+ [textField reloadInputViews];
[textField becomeFirstResponder];
@@ -545,1 +545,1 @@
-UIKit_ShowScreenKeyboard(_THIS, SDL_Window *window)
+UIKit_ShowScreenKeyboard(_THIS, SDL_Window *window, int UIKeyboardType)
@@ -549,1 +549,2 @@
- [vc showKeyboard];
+ NSInteger _UIKeyboardType = (NSInteger) UIKeyboardType;
+ [vc showKeyboard:_UIKeyboardType];

--- slime73-sdl-experiments-618662dc9e82/src/video/uikit/SDL_uikitviewcontroller.h
+++ slime73-sdl-experiments-618662dc9e82/src/video/uikit/SDL_uikitviewcontroller.h
@@ -68,1 +68,1 @@
-- (void)showKeyboard;
+- (void)showKeyboard:(NSInteger)UIKeyboardType;
@@ -87,1 +87,1 @@
-void UIKit_ShowScreenKeyboard(_THIS, SDL_Window *window);
+void UIKit_ShowScreenKeyboard(_THIS, SDL_Window *window, int UIKeyboardType);

--- slime73-sdl-experiments-618662dc9e82/src/video/SDL_video.c
+++ slime73-sdl-experiments-618662dc9e82/src/video/SDL_video.c
@@ -568,1 +568,2 @@
- SDL_StartTextInput();
+ int keyboard_type = 0;
+ SDL_StartTextInput(keyboard_type);
@@ -3764,1 +3764,1 @@
-SDL_StartTextInput(void)
+SDL_StartTextInput(int keyboard_type)
@@ -3774,2 +3774,2 @@
- if (window && _this && _this->ShowScreenKeyboard) {
+ if (window && _this && _this->ShowScreenKeyboard) {
- _this->ShowScreenKeyboard(_this, window);
+ _this->ShowScreenKeyboard(_this, window, keyboard_type);
@@ -3781,2 +3781,2 @@
- if (_this && _this->StartTextInput) {
+ if (_this && _this->StartTextInput) {
- _this->StartTextInput(_this);
+ _this->StartTextInput(_this, keyboard_type);

--- slime73-sdl-experiments-618662dc9e82/src/video/SDL_sysvideo.h
+++ slime73-sdl-experiments-618662dc9e82/src/video/SDL_sysvideo.h
@@ -295,7 +295,7 @@
- void (*StartTextInput) (_THIS);
+ void (*StartTextInput) (_THIS, int keyboard_type);
void (*StopTextInput) (_THIS);
void (*SetTextInputRect) (_THIS, SDL_Rect *rect);

/* Screen keyboard */
SDL_bool (*HasScreenKeyboardSupport) (_THIS);
- void (*ShowScreenKeyboard) (_THIS, SDL_Window *window);
+ void (*ShowScreenKeyboard) (_THIS, SDL_Window *window, int keyboard_type);

--- slime73-sdl-experiments-618662dc9e82/src/video/winrt/SDL_winrtevents_c.h
+++ slime73-sdl-experiments-618662dc9e82/src/video/winrt/SDL_winrtevents_c.h
@@ -72,1 +72,1 @@
-extern void WINRT_ShowScreenKeyboard(_THIS, SDL_Window *window);
+extern void WINRT_ShowScreenKeyboard(_THIS, SDL_Window *window, int keyboard_type);

--- slime73-sdl-experiments-618662dc9e82/src/video/winrt/SDL_winrtkeyboard.cpp
+++ slime73-sdl-experiments-618662dc9e82/src/video/winrt/SDL_winrtkeyboard.cpp
@@ -394,1 +394,1 @@
-void WINRT_ShowScreenKeyboard(_THIS, SDL_Window *window)
+void WINRT_ShowScreenKeyboard(_THIS, SDL_Window *window, int keyboard_type)

--- slime73-sdl-experiments-618662dc9e82/src/video/psp/SDL_pspvideo.h
+++ slime73-sdl-experiments-618662dc9e82/src/video/psp/SDL_pspvideo.h
@@ -96,1 +96,1 @@
-void PSP_ShowScreenKeyboard(_THIS, SDL_Window *window);
+void PSP_ShowScreenKeyboard(_THIS, SDL_Window *window, int keyboard_type);

--- slime73-sdl-experiments-618662dc9e82/src/video/psp/SDL_pspvideo.c
+++ slime73-sdl-experiments-618662dc9e82/src/video/psp/SDL_pspvideo.c
@@ -319,1 +319,1 @@
-void PSP_ShowScreenKeyboard(_THIS, SDL_Window *window)
+void PSP_ShowScreenKeyboard(_THIS, SDL_Window *window, int keyboard_type)

--- slime73-sdl-experiments-618662dc9e82/include/SDL_keyboard.h
+++ slime73-sdl-experiments-618662dc9e82/include/SDL_keyboard.h
@@ -160,1 +160,1 @@
-extern DECLSPEC void SDLCALL SDL_StartTextInput(void);
+extern DECLSPEC void SDLCALL SDL_StartTextInput(int keyboard_type);

--- slime73-sdl-experiments-618662dc9e82/Xcode-iOS/Demos/src/keyboard.c
+++ slime73-sdl-experiments-618662dc9e82/Xcode-iOS/Demos/src/keyboard.c
@@ -246,1 +246,1 @@
- SDL_StartTextInput();
+ SDL_StartTextInput(0);

--- slime73-sdl-experiments-618662dc9e82/src/events/SDL_keyboard.c
+++ slime73-sdl-experiments-618662dc9e82/src/events/SDL_keyboard.c
@@ -672,1 +672,1 @@
- video->StartTextInput(video);
+ video->StartTextInput(video, 0);

--- slime73-sdl-experiments-618662dc9e82/src/video/uikit/SDL_uikitopenglview.m.orig 2015-08-20 16:09:59.000000000 +0200
+++ slime73-sdl-experiments-618662dc9e82/src/video/uikit/SDL_uikitopenglview.m 2015-08-20 16:11:25.000000000 +0200
@@ -99,7 +99,7 @@
Expand All @@ -9,3 +115,4 @@
eaglLayer.drawableProperties = @{
kEAGLDrawablePropertyRetainedBacking:@(retained),
kEAGLDrawablePropertyColorFormat:colorFormat