comparison android/dw.cpp @ 2596:60ec91d23746

Android: Add initial keyboard support for Android. Any keycodes I couldn't find equivalents for in Android I put at value 1000 or above, since the highest Android KEYCODE constant was around 300.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sat, 29 May 2021 21:42:59 +0000
parents 2acc7ba5dea0
children 3b9bbd69bb9c
comparison
equal deleted inserted replaced
2595:6b5057dd6b8e 2596:60ec91d23746
298 break; 298 break;
299 } 299 }
300 case 2: 300 case 2:
301 { 301 {
302 int (*keypressfunc)(HWND, char, int, int, void *, char *) = (int (* API)(HWND, char, int, int, void *, char *))handler->signalfunction; 302 int (*keypressfunc)(HWND, char, int, int, void *, char *) = (int (* API)(HWND, char, int, int, void *, char *))handler->signalfunction;
303 char *utf8 = (char *)params[1], ch = utf8 ? utf8[0] : '\0'; 303 char *utf8 = (char *)params[1], ch = (char)DW_POINTER_TO_INT(params[3]);
304 int vk = 0, special = 0; 304 int vk = DW_POINTER_TO_INT(params[4]), special = DW_POINTER_TO_INT(params[5]);
305 305
306 retval = keypressfunc(handler->window, ch, (int)vk, special, handler->data, utf8); 306 retval = keypressfunc(handler->window, ch, (int)vk, special, handler->data, utf8);
307 break; 307 break;
308 } 308 }
309 /* Button press and release event */ 309 /* Button press and release event */
618 #else 618 #else
619 const char *title = jtitle ? env->GetStringUTFChars(jtitle, nullptr) : nullptr; 619 const char *title = jtitle ? env->GetStringUTFChars(jtitle, nullptr) : nullptr;
620 #endif 620 #endif
621 void *params[_DW_EVENT_PARAM_SIZE] = { nullptr, DW_POINTER(title), nullptr, DW_INT_TO_POINTER(x), DW_INT_TO_POINTER(y), 621 void *params[_DW_EVENT_PARAM_SIZE] = { nullptr, DW_POINTER(title), nullptr, DW_INT_TO_POINTER(x), DW_INT_TO_POINTER(y),
622 nullptr, nullptr, (void *)data, DW_INT_TO_POINTER(message), nullptr }; 622 nullptr, nullptr, (void *)data, DW_INT_TO_POINTER(message), nullptr };
623
624 _dw_event_handler(obj1, params);
625 }
626
627 JNIEXPORT void JNICALL
628 Java_org_dbsoft_dwindows_DWindows_eventHandlerKey(JNIEnv *env, jobject obj, jobject obj1, jint message, jint ch,
629 jint vk, jint modifiers, jstring str) {
630 #ifdef _DW_EVENT_THREADING
631 char *cstr = str ? strdup(env->GetStringUTFChars(str, nullptr)) : nullptr;
632 #else
633 const char *cstr = str ? env->GetStringUTFChars(str, nullptr) : nullptr;
634 #endif
635 void *params[_DW_EVENT_PARAM_SIZE] = { nullptr, DW_POINTER(cstr), nullptr, DW_INT_TO_POINTER(ch), DW_INT_TO_POINTER(vk),
636 DW_INT_TO_POINTER(modifiers), nullptr, nullptr, DW_INT_TO_POINTER(message), nullptr };
623 637
624 _dw_event_handler(obj1, params); 638 _dw_event_handler(obj1, params);
625 } 639 }
626 640
627 /* Handler for Timer events */ 641 /* Handler for Timer events */