#include "../../events/scancodes_tizen.h"
#include "SDL_tizenkeyboard.h"
+extern TizenKeyboard tizen_keyboard;
+
static SDL_Scancode
TranslateKeycode(int keycode)
{
ecore_main_loop_iterate();
}
+Ecore_IMF_Keyboard_Modifiers EcoreInputModifierToEcoreIMFModifier(unsigned int ecoreModifier)
+{
+ int modifier = ECORE_IMF_KEYBOARD_MODIFIER_NONE; // If no other matches returns NONE.
+
+
+ if ( ecoreModifier & ECORE_EVENT_MODIFIER_SHIFT ) // enums from ecore_input/Ecore_Input.h
+ {
+ modifier |= ECORE_IMF_KEYBOARD_MODIFIER_SHIFT; // enums from ecore_imf/ecore_imf.h
+ }
+
+ if ( ecoreModifier & ECORE_EVENT_MODIFIER_ALT )
+ {
+ modifier |= ECORE_IMF_KEYBOARD_MODIFIER_ALT;
+ }
+
+ if ( ecoreModifier & ECORE_EVENT_MODIFIER_CTRL )
+ {
+ modifier |= ECORE_IMF_KEYBOARD_MODIFIER_CTRL;
+ }
+
+ if ( ecoreModifier & ECORE_EVENT_MODIFIER_WIN )
+ {
+ modifier |= ECORE_IMF_KEYBOARD_MODIFIER_WIN;
+ }
+
+ if ( ecoreModifier & ECORE_EVENT_MODIFIER_ALTGR )
+ {
+ modifier |= ECORE_IMF_KEYBOARD_MODIFIER_ALTGR;
+ }
+
+ return (Ecore_IMF_Keyboard_Modifiers)modifier;
+}
+
Eina_Bool
_tizen_cb_event_keyup_change(void *data, int type, void *event)
{
if (!event) return ECORE_CALLBACK_PASS_ON;
Ecore_Event_Key * e = event;
- SDL_Scancode scancode = TranslateKeycode(e->keycode);
- SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "key up: %d", scancode);
- SDL_SendKeyboardKey(SDL_RELEASED, scancode);
+ SDL_Scancode scancode = SDL_SCANCODE_UNKNOWN;
+ if (!e->key) return ECORE_CALLBACK_PASS_ON;
+
+ if (tizen_keyboard.imf_context) {
+ Ecore_IMF_Event_Key_Up ecore_ev;
+
+ ecore_ev.keyname = e->keyname;
+ ecore_ev.key = e->key;
+ ecore_ev.string = e->string;
+ ecore_ev.compose = e->compose;
+ ecore_ev.timestamp = e->timestamp;
+ ecore_ev.modifiers = EcoreInputModifierToEcoreIMFModifier ( e->modifiers );
+ ecore_ev.locks = (Ecore_IMF_Keyboard_Locks) ECORE_IMF_KEYBOARD_LOCK_NONE;
+
+ if (ecore_imf_context_filter_event(tizen_keyboard.imf_context,
+ ECORE_IMF_EVENT_KEY_UP,
+ (Ecore_IMF_Event *)&ecore_ev)) {
+ return ECORE_CALLBACK_PASS_ON;
+ }
+ }
+
+ if (SDL_GetEventState(SDL_TEXTINPUT)) {
+ if (!strcmp(e->key, "BackSpace")) {
+ scancode = SDL_GetScancodeFromName(e->key);
+ SDL_SendKeyboardKey(SDL_RELEASED, scancode);
+ }
+ else if (!strcmp(e->key, "Delete") ||
+ (!strcmp(e->key, "KP_Delete") && !e->string)) {
+ scancode = SDL_GetScancodeFromName(e->key);
+ SDL_SendKeyboardKey(SDL_RELEASED, scancode);
+ }
+ else if ((!strcmp(e->key, "Return")) || (!strcmp(e->key, "KP_Enter"))) {
+ scancode = SDL_GetScancodeFromName(e->key);
+ SDL_SendKeyboardKey(SDL_RELEASED, scancode);
+ }
+ else if (e->string) {
+ // Nothing
+ }
+ else {
+ scancode = TranslateKeycode(e->keycode);
+ SDL_SendKeyboardKey(SDL_RELEASED, scancode);
+ }
+ } else {
+ scancode = TranslateKeycode(e->keycode);
+ SDL_SendKeyboardKey(SDL_RELEASED, scancode);
+ }
return ECORE_CALLBACK_PASS_ON;
}
if (!event) return ECORE_CALLBACK_PASS_ON;
Ecore_Event_Key * e = event;
- SDL_Scancode scancode = TranslateKeycode(e->keycode);
- SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "key down: %d", scancode);
- SDL_SendKeyboardKey(SDL_PRESSED, scancode);
+ SDL_Scancode scancode = SDL_SCANCODE_UNKNOWN;
+ if (!e->key) return ECORE_CALLBACK_PASS_ON;
+
+ if (tizen_keyboard.imf_context) {
+ Ecore_IMF_Event_Key_Down ecore_ev;
+
+ ecore_ev.keyname = e->keyname;
+ ecore_ev.key = e->key;
+ ecore_ev.string = e->string;
+ ecore_ev.compose = e->compose;
+ ecore_ev.timestamp = e->timestamp;
+ ecore_ev.modifiers = EcoreInputModifierToEcoreIMFModifier ( e->modifiers );
+ ecore_ev.locks = (Ecore_IMF_Keyboard_Locks) ECORE_IMF_KEYBOARD_LOCK_NONE;
+
+ if (ecore_imf_context_filter_event(tizen_keyboard.imf_context,
+ ECORE_IMF_EVENT_KEY_DOWN,
+ (Ecore_IMF_Event *)&ecore_ev)) {
+ return ECORE_CALLBACK_PASS_ON;
+ }
+ }
+
+ if (SDL_GetEventState(SDL_TEXTINPUT)) {
+ if (!strcmp(e->key, "BackSpace")) {
+ scancode = SDL_GetScancodeFromName(e->key);
+ SDL_SendKeyboardKey(SDL_PRESSED, scancode);
+ }
+ else if (!strcmp(e->key, "Delete") ||
+ (!strcmp(e->key, "KP_Delete") && !e->string)) {
+ scancode = SDL_GetScancodeFromName(e->key);
+ SDL_SendKeyboardKey(SDL_PRESSED, scancode);
+ }
+ else if ((!strcmp(e->key, "Return")) || (!strcmp(e->key, "KP_Enter"))) {
+ scancode = SDL_GetScancodeFromName(e->key);
+ SDL_SendKeyboardKey(SDL_PRESSED, scancode);
+ }
+ else if (e->string) {
+ SDL_SendKeyboardText(e->string);
+ }
+ else {
+ scancode = TranslateKeycode(e->keycode);
+ SDL_SendKeyboardKey(SDL_PRESSED, scancode);
+ }
+ } else {
+ scancode = TranslateKeycode(e->keycode);
+ SDL_SendKeyboardKey(SDL_PRESSED, scancode);
+ }
return ECORE_CALLBACK_PASS_ON;
}
/*
Tizen Keyboard
*/
-static TizenKeyboard tizen_keyboard;
+TizenKeyboard tizen_keyboard;
void
_ecore_imf_event_commit_cb(void *data, Ecore_IMF_Context *ctx EINA_UNUSED, void *event_info)
}
void
+_ecore_imf_event_preedit_changed_cb(void *data, Ecore_IMF_Context *ctx, void *event_info EINA_UNUSED)
+{
+ char *preedit_string;
+ int cursor_pos;
+ Ecore_IMF_Context *imf_context = ctx;
+
+ // get preedit string and attributes
+ ecore_imf_context_preedit_string_with_attributes_get(imf_context, &preedit_string, NULL, &cursor_pos);
+ SDL_Log("preedit string : %s, %d", preedit_string, cursor_pos);
+
+ SDL_SendEditingText(preedit_string, 0, cursor_pos);
+ free(preedit_string);
+}
+
+void
_ecore_imf_event_state_change_cb(void *data, Ecore_IMF_Context *ctx EINA_UNUSED, int value)
{
//ECORE_IMF_INPUT_PANEL_STATE_SHOW : 0
ecore_imf_context_client_window_set(tizen_keyboard.imf_context, (void*)wind->id);
ecore_imf_context_event_callback_add(tizen_keyboard.imf_context, ECORE_IMF_CALLBACK_COMMIT , _ecore_imf_event_commit_cb, NULL);
+
+ ecore_imf_context_event_callback_add(tizen_keyboard.imf_context, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, _ecore_imf_event_preedit_changed_cb, NULL);
+
ecore_imf_context_input_panel_event_callback_add (tizen_keyboard.imf_context, ECORE_IMF_INPUT_PANEL_STATE_EVENT, _ecore_imf_event_state_change_cb, NULL);
ecore_imf_context_cursor_position_set(tizen_keyboard.imf_context, 0);