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"
33 _ecore_imf_event_commit_cb(void *data, Ecore_IMF_Context *ctx EINA_UNUSED, void *event_info)
35 char *commit_str = (char *)event_info;
36 SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "commit string : %s\n", commit_str);
37 SDL_SendKeyboardText(commit_str);
42 _ecore_imf_event_state_change_cb(void *data, Ecore_IMF_Context *ctx EINA_UNUSED, int value)
44 //ECORE_IMF_INPUT_PANEL_STATE_SHOW : 0
45 //ECORE_IMF_INPUT_PANEL_STATE_HIDE : 1
46 SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "Keyboard State : %d\n", value);
50 void Tizen_InitKeyboard(_THIS)
54 memset(&keyboard, 0, sizeof(keyboard));
56 const char *default_id = ecore_imf_context_default_id_get();
59 SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't create ecore_imf_context\n");
63 keyboard.imf_context = ecore_imf_context_add(default_id);
65 SDL_Window *window = _this->windows;
66 SDL_WindowData *wind = window->driverdata;
68 ecore_imf_context_client_window_set(keyboard.imf_context, (void*)wind->id);
70 ecore_imf_context_event_callback_add(keyboard.imf_context, ECORE_IMF_CALLBACK_COMMIT , _ecore_imf_event_commit_cb, NULL);
71 ecore_imf_context_input_panel_event_callback_add (keyboard.imf_context, ECORE_IMF_INPUT_PANEL_STATE_EVENT, _ecore_imf_event_state_change_cb, NULL);
73 ecore_imf_context_cursor_position_set(keyboard.imf_context, 0);
74 ecore_imf_context_focus_out(keyboard.imf_context);
75 ecore_imf_context_input_panel_hide(keyboard.imf_context);
79 void Tizen_FiniKeyboard(void)
81 if(keyboard.imf_context == NULL)
84 ecore_imf_context_del(keyboard.imf_context);
85 keyboard.imf_context = NULL;
91 Tizen_StartTextInput(_THIS)
94 return SDL_SetError("Video subsystem must be initialized");
97 if(keyboard.imf_context == NULL)
98 Tizen_InitKeyboard(_this);
100 Tizen_ShowScreenKeyboard(_this, NULL);
105 Tizen_StopTextInput(_THIS)
108 if (keyboard.imf_context)
110 Tizen_HideScreenKeyboard(_this, _this->windows);
114 void Tizen_SetTextInputRect(void)
120 Tizen_HasScreenKeyboardSupport(_THIS)
127 Tizen_ShowScreenKeyboard(_THIS, SDL_Window * window)
129 if (!keyboard.imf_context)
132 ecore_imf_context_focus_in(keyboard.imf_context);
133 ecore_imf_context_input_panel_show(keyboard.imf_context);
137 Tizen_HideScreenKeyboard(_THIS, SDL_Window * window)
139 if (!keyboard.imf_context)
142 ecore_imf_context_focus_out(keyboard.imf_context);
143 ecore_imf_context_input_panel_hide(keyboard.imf_context);
147 Tizen_IsScreenKeyboardShown(_THIS, SDL_Window * window)
149 if (!keyboard.imf_context)
151 //EAPI Ecore_IMF_Input_Panel_State ecore_imf_context_input_panel_state_get (Ecore_IMF_Context *ctx)
152 return ecore_imf_context_input_panel_state_get(keyboard.imf_context);