コード例 #1
0
/**
 * Support repeated key presses for a platforms with no own support for it.
 *
 * One of the possible implementations is timer-based generation of MIDP
 * events for a keys pressed and not released for a certain time interval.
 *
 * @param midpKeyCode MIDP keycode of the pressed/released key
 * @param isPressed true if the key is pressed, false if released
 */
void handle_repeated_key_port(int midpKeyCode, jboolean isPressed) {
    if (isPressed) {
        jlong current_time = JVM_JavaMilliSeconds();
        new_timer(current_time + REPEAT_TIMEOUT,
            (void*)midpKeyCode, handle_repeat_key_timer_alarm);
    } else {
        delete_timer_by_userdata((void*)midpKeyCode);
    }
}
コード例 #2
0
ファイル: mastermode_export.c プロジェクト: sfsy1989/j2me
/*
 * This function is called by the VM periodically. It has to check if
 * system has sent a signal to MIDP and return the result in the
 * structs given.
 *
 * Values for the <timeout> paramater:
 *  >0 = Block until a signal sent to MIDP, or until <timeout> milliseconds
 *       has elapsed.
 *   0 = Check the system for a signal but do not block. Return to the
 *       caller immediately regardless of the if a signal was sent.
 *  -1 = Do not timeout. Block until a signal is sent to MIDP.
 *
 * IMPL NOTE: this function now is definitely not highlevelui-only. Redesign is
 * strongly recommended
 */
void checkForSystemSignal(MidpReentryData* pNewSignal,
    MidpEvent* pNewMidpEvent, jlong timeout) {

    jboolean pendingSignal = KNI_FALSE;
    jlong currentTime = JVM_JavaMilliSeconds();

    /* Pending event should be processed prior to other events */
    pendingSignal = checkForPendingSignals(
            pNewSignal, pNewMidpEvent, currentTime);

    if (!pendingSignal) {
        /* Adjust timeout regarding near timers */
        adjustTimeout(currentTime, &timeout);
        /* Call all registered signal checkers during timeout */
        checkForAllSignals(pNewSignal, pNewMidpEvent, timeout);
    }
}
コード例 #3
0
/**
 * Gets the current system time in milliseconds.
 *
 * @return The current system time in milliseconds
 */
jlong
midp_getCurrentTime(void) {
    return JVM_JavaMilliSeconds();
}