2 Simple DirectMedia Layer
3 Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
4 Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved.
6 This software is provided 'as-is', without any express or implied
7 warranty. In no event will the authors be held liable for any damages
8 arising from the use of this software.
10 Permission is granted to anyone to use this software for any purpose,
11 including commercial applications, and to alter it and redistribute it
12 freely, subject to the following restrictions:
14 1. The origin of this software must not be misrepresented; you must not
15 claim that you wrote the original software. If you use this software
16 in a product, an acknowledgment in the product documentation would be
17 appreciated but is not required.
18 2. Altered source versions must be plainly marked as such, and must not be
19 misrepresented as being the original software.
20 3. This notice may not be removed or altered from any source distribution.
23 #include "../../SDL_internal.h"
25 #include "SDL_tizenkeyboard.h"
27 #include "../../events/SDL_keyboard_c.h"
34 _ecore_imf_event_commit_cb(void *data, Ecore_IMF_Context *ctx EINA_UNUSED, void *event_info)
36 char *commit_str = (char *)event_info;
37 SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "commit string : %s\n", commit_str);
38 SDL_SendKeyboardText(commit_str);
43 _ecore_imf_event_state_change_cb(void *data, Ecore_IMF_Context *ctx EINA_UNUSED, int value)
45 //ECORE_IMF_INPUT_PANEL_STATE_SHOW : 0
46 //ECORE_IMF_INPUT_PANEL_STATE_HIDE : 1
47 SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "Keyboard State : %d\n", value);
51 void Tizen_InitKeyboard(_THIS)
55 memset(&keyboard, 0, sizeof(keyboard));
57 const char *default_id = ecore_imf_context_default_id_get();
60 SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't create ecore_imf_context\n");
64 keyboard.imf_context = ecore_imf_context_add(default_id);
66 SDL_Window *window = _this->windows;
67 SDL_WindowData *wind = window->driverdata;
69 ecore_imf_context_client_window_set(keyboard.imf_context, (void*)wind->id);
71 ecore_imf_context_event_callback_add(keyboard.imf_context, ECORE_IMF_CALLBACK_COMMIT , _ecore_imf_event_commit_cb, NULL);
72 ecore_imf_context_input_panel_event_callback_add (keyboard.imf_context, ECORE_IMF_INPUT_PANEL_STATE_EVENT, _ecore_imf_event_state_change_cb, NULL);
74 ecore_imf_context_cursor_position_set(keyboard.imf_context, 0);
75 ecore_imf_context_focus_out(keyboard.imf_context);
76 ecore_imf_context_input_panel_hide(keyboard.imf_context);
80 void Tizen_FiniKeyboard(void)
82 if(keyboard.imf_context == NULL)
85 ecore_imf_context_del(keyboard.imf_context);
86 keyboard.imf_context = NULL;
92 Tizen_StartTextInput(_THIS)
95 SDL_SetError("Video subsystem must be initialized");
99 if(keyboard.imf_context == NULL)
100 Tizen_InitKeyboard(_this);
102 Tizen_ShowScreenKeyboard(_this, NULL);
107 Tizen_StopTextInput(_THIS)
110 if (keyboard.imf_context)
112 Tizen_HideScreenKeyboard(_this, _this->windows);
116 void Tizen_SetTextInputRect(void)
122 Tizen_HasScreenKeyboardSupport(_THIS)
129 Tizen_ShowScreenKeyboard(_THIS, SDL_Window * window)
131 if (!keyboard.imf_context)
134 ecore_imf_context_focus_in(keyboard.imf_context);
135 ecore_imf_context_input_panel_show(keyboard.imf_context);
139 Tizen_HideScreenKeyboard(_THIS, SDL_Window * window)
141 if (!keyboard.imf_context)
144 ecore_imf_context_focus_out(keyboard.imf_context);
145 ecore_imf_context_input_panel_hide(keyboard.imf_context);
149 Tizen_IsScreenKeyboardShown(_THIS, SDL_Window * window)
151 if (!keyboard.imf_context)
153 //EAPI Ecore_IMF_Input_Panel_State ecore_imf_context_input_panel_state_get (Ecore_IMF_Context *ctx)
154 return ecore_imf_context_input_panel_state_get(keyboard.imf_context);