/**
 * Map MIDP keycode value into proper MIDP event parameters
 * and platform signal attributes to unblock Java threads
 * waiting for this input event
 *
 * IMPL_NOTE: In general it is not specific for frame buffer application,
 *   however applications of other type can use rather different events
 *   mappings not based on MIDP keycodes or input keyboard events at all.
 *
 * @param pNewSignal reentry data to unblock threads waiting for a signal
 * @param pNewMidpEvent a native MIDP event to be stored to Java event queue
 * @param midpKeyCode MIDP keycode of the input event
 * @param isPressed true if the key is pressed, false if released
 * @param repeatedKeySupport true if MIDP should support repeated key
 *   presses on its own, false if platform supports repeated keys itself
 */
void fbapp_map_keycode_to_event(
        MidpReentryData* pNewSignal, MidpEvent* pNewMidpEvent,
        int midpKeyCode, jboolean isPressed, jboolean repeatedKeySupport) {

    switch(midpKeyCode) {
    case KEYMAP_MD_KEY_HOME:
        if (isPressed) {
            pNewMidpEvent->type = SELECT_FOREGROUND_EVENT;
            pNewMidpEvent->intParam1 = 0;
            pNewSignal->waitingFor = AMS_SIGNAL;
        } else {
            /* ignore it */
        }
        break;

    case KEYMAP_MD_KEY_SWITCH_APP:
        if (isPressed) {
            pNewMidpEvent->type = SELECT_FOREGROUND_EVENT;
            pNewMidpEvent->intParam1 = 1;
            pNewSignal->waitingFor = AMS_SIGNAL;
        } else {
            /* ignore it */
        }
        break;

    case KEYMAP_KEY_SCREEN_ROT:
        if (isPressed) {
            pNewMidpEvent->type = ROTATION_EVENT;
            pNewSignal->waitingFor = UI_SIGNAL;
        } else {
            /* ignore it */
        }
        break;

    case KEYMAP_KEY_VIRT_KEYB:
        if (isPressed) {
            pNewMidpEvent->type = VIRTUAL_KEYBOARD_EVENT;
            pNewSignal->waitingFor = UI_SIGNAL;
        } else {
            /* ignore it */
        }
        break;

    case KEYMAP_KEY_END:
        if (isPressed) {
            pNewSignal->waitingFor = AMS_SIGNAL;
            pNewMidpEvent->type = MIDLET_DESTROY_REQUEST_EVENT;

#if ENABLE_MULTIPLE_DISPLAYS  
            pNewMidpEvent->DISPLAY = gForegroundDisplayIds[lcdlf_get_current_hardwareId()];  
#else  
            pNewMidpEvent->DISPLAY = gForegroundDisplayId;  
#endif /* ENABLE_MULTIPLE_DISPLAYS */  
            pNewMidpEvent->intParam1 = gForegroundIsolateId;
        } else {
            /* ignore it */
        }
        break;

    case KEYMAP_KEY_INVALID:
        /* ignore it */
        break;

    default:
#if ENABLE_ON_DEVICE_DEBUG
        if (isPressed) {
            /* assert(posInSequence == sizeof(pStartOddKeySequence) - 1) */
            if (pStartOddKeySequence[posInSequence] == midpKeyCode) {
                posInSequence++;
                if (posInSequence == sizeof(pStartOddKeySequence) - 1) {
                    posInSequence = 0;
                    pNewSignal->waitingFor = AMS_SIGNAL;
                    pNewMidpEvent->type = MIDP_ENABLE_ODD_EVENT;
                    break;
                }
            } else {
                posInSequence = 0;
            }
        }
#endif
        pNewSignal->waitingFor = UI_SIGNAL;
        pNewMidpEvent->type = MIDP_KEY_EVENT;
        pNewMidpEvent->CHR = midpKeyCode;
        pNewMidpEvent->ACTION = isPressed ? 
            KEYMAP_STATE_PRESSED : KEYMAP_STATE_RELEASED;
        if (repeatedKeySupport) {
            handle_repeated_key_port(midpKeyCode, isPressed);
        }
        break;
    }
}
/*  private native int _getFullDisplayHeight () ;
    returns the full display height
*/
KNIEXPORT KNI_RETURNTYPE_INT
Java_javax_microedition_khronos_egl_EGL10Impl__1getFullDisplayHeight() {
    /* Revisit: multiple displays support. Obtain Id of display render surfane is
       bound to. Consider recalculations when display got changed */
    KNI_ReturnInt(lcdlf_get_screen_height(lcdlf_get_current_hardwareId()));
}
示例#3
0
/* Copy engine buffer back to MIDP */
void
JSR239_putWindowContents(jobject graphicsHandle,
                         jint delta_height,
                         JSR239_Pixmap *src, 
                         jint clipX, jint clipY, 
                         jint clipWidth, jint clipHeight,
                         jint flipY) {

    void* s;
    void* d;

    KNI_StartHandles(1);
    KNI_DeclareHandle(GraphicsClassHandle);

#ifdef DEBUG
    printf("JSR239_putWindowContents >>\n");
#endif

    KNI_FindClass("javax/microedition/lcdui/Graphics", GraphicsClassHandle);
    if (!KNI_IsInstanceOf(graphicsHandle, GraphicsClassHandle)) {
#ifdef DEBUG
        printf("JSR239_putWindowContents only implemented for graphicsHandle "
               "instanceof Graphics!\n");
#endif
    } else {
        gxj_screen_buffer sbuf;
        gxj_screen_buffer* gimg;

        // Obtain the dimensions of the destination.
        // Revisit: multiple displays support. Obtain Id of display render surfane is
        // bound to. Consider recalculations when display got changed.
        int displayId    = lcdlf_get_current_hardwareId();
        jint dest_width  = lcdlf_get_screen_width(displayId);
        jint dest_height = lcdlf_get_screen_height(displayId);
        jint min_height  = 0;
        gxj_pixel_type* srcPtr;
        gxj_pixel_type* dstPtr;
        
        gimg = GXJ_GET_GRAPHICS_SCREEN_BUFFER(graphicsHandle, &sbuf);
        if (gimg != NULL) {
            dest_width = gimg->width;
            dest_height= gimg->height;
        }                

        /* src->screen_buffer is an output of copyToScreenBuffer function. */
        s = (void*)src->screen_buffer;
        d = (void*)getGraphicsBuffer(graphicsHandle);

        min_height = (dest_height > src->height) ? src->height : dest_height;

#ifdef DEBUG
        printf("JSR239_putWindowContents:\n"); 
        printf("  src        = %d\n", src->pixels);
        printf("  src Bpp    = %d\n", src->pixelBytes);
        printf("  src width  = %d\n", src->width);
        printf("  src height = %d\n", src->height);
        printf("  min height = %d\n", min_height);
        printf("  dst        = %d\n", d);     
        printf("  dst width  = %d\n", clipWidth);
        printf("  dst height = %d\n", clipHeight);
#endif

        srcPtr = (gxj_pixel_type *)s;
        dstPtr = (gxj_pixel_type *)d;

        if ((dest_width * min_height <= src->width * src->height) && 
            (sizeof(gxj_pixel_type) == 2)) {
            /* Source data must be in 16bit 565 format. */
           JSR239_memcpy(s, d,
               dest_width * min_height * sizeof(gxj_pixel_type));

           /* IMPL_NOTE: get clip sizes into account. */
           copyToScreenBuffer(src, delta_height, 
                              clipX, clipY, clipWidth, clipHeight,
                              dest_width, dest_height,
                              flipY);

            /* Source data must be in 16bit 565 format. */
           JSR239_memcpy(d, s,
               dest_width * min_height * sizeof(gxj_pixel_type));        
        } else {
#ifdef DEBUG
        printf("JSR239: offscreen buffer data is incorrect.\n");
#endif
        }
    }

#ifdef DEBUG
    printf("JSR239_putWindowContents <<\n");
#endif

    KNI_EndHandles();
}