Esempio n. 1
0
unsigned page_change_cb(u32 buttons, unsigned flags, void *data)
{
    (void)data;
    (void)flags;
    if (ActionCB != NULL)
        return ActionCB(buttons, flags, data);
    if (flags & BUTTON_LONGPRESS) {
        if (flags & BUTTON_REPEAT)
            return 0;
        if(CHAN_ButtonIsPressed(buttons, BUT_ENTER) && enter_cmd) {
            void (*cmd)(guiObject_t *obj, const void *data) = enter_cmd;
            PAGE_RemoveAllObjects();
            cmd(NULL, enter_data);
            return 1;
        }
        if(CHAN_ButtonIsPressed(buttons, BUT_EXIT) && exit_cmd) {
            void (*cmd)(guiObject_t *obj, const void *data) = exit_cmd;
            PAGE_RemoveAllObjects();
            cmd(NULL, exit_data);
            return 1;
        }
        return 0;
    }
    if(PAGE_QuickPage(buttons, flags, data))
        return 1;
    if(CHAN_ButtonIsPressed(buttons, BUT_RIGHT)) {
        PAGE_Change(1);
        return 1;
    } else if(CHAN_ButtonIsPressed(buttons, BUT_LEFT)) {
        PAGE_Change(-1);
        return 1;
    }
    return 0;
}
Esempio n. 2
0
int PAGE_QuickPage(u32 buttons, u8 flags, void *data)
{
    (void)data;
    (void)flags;
    //static s8 press = 0;
    if(cur_section != 0)
        return 0;

/*    if (press) {
        if (flags & BUTTON_RELEASE) {
            PAGE_ChangeQuick(press);
            press = 0;
        }
        return 1;
    }
*/
    int i;
    for(i = 0; i < NUM_QUICKPAGES; i++)
        if(Model.pagecfg2.quickpage[i])
            break;
    if(i == NUM_QUICKPAGES)
        return 0;
    if(CHAN_ButtonIsPressed(buttons, BUT_RIGHT)) {
        //press = 1;
        PAGE_ChangeQuick(1);
        return 1;
    } else if (CHAN_ButtonIsPressed(buttons, BUT_LEFT)) {
        //press = -1;
        PAGE_ChangeQuick(-1);
        return 1;
    }
    return 0;
}
Esempio n. 3
0
static unsigned _action_cb(u32 button, unsigned flags, void *data)
{
    if (CHAN_ButtonIsPressed(button, BUT_RIGHT) || CHAN_ButtonIsPressed(button, BUT_LEFT)) {
        if (flags & BUTTON_RELEASE) {
            _navigate_pages(CHAN_ButtonIsPressed(button, BUT_RIGHT) ? 1 : -1);
        }
        return 1;
    }
    return default_button_action_cb(button, flags, data);
}
Esempio n. 4
0
void GUI_PressTextSelect(struct guiObject *obj, u32 button, u8 press_type)
{
    struct touch coords;
    coords.y = obj->box.y + KEY_ADJUST_Y;
    if (CHAN_ButtonIsPressed(button, BUT_RIGHT)) {
        coords.x = obj->box.x + obj->box.width + KEY_ADJUST_X - ARROW_WIDTH;
    } else if(CHAN_ButtonIsPressed(button, BUT_LEFT)) {
        coords.x = obj->box.x + KEY_ADJUST_X;
    } else if(CHAN_ButtonIsPressed(button, BUT_ENTER)) {
        coords.x = obj->box.x + (obj->box.width >> 1);
    } else {
        return;
Esempio n. 5
0
static unsigned _action_cb(u32 button, unsigned flags, void *data)
{
    if (current_page != telemetry_off && (CHAN_ButtonIsPressed(button, BUT_RIGHT) || CHAN_ButtonIsPressed(button, BUT_LEFT))) {
        if (flags & BUTTON_RELEASE) {
            _navigate_pages(CHAN_ButtonIsPressed(button, BUT_RIGHT) ? 1 : -1);
        }
        return 1;
    }
    if (flags & BUTTON_PRESS && (CHAN_ButtonIsPressed(button, BUT_ENTER) || CHAN_ButtonIsPressed(button, BUT_EXIT))) {
        TELEMETRY_MuteAlarm();
    }
    return default_button_action_cb(button, flags, data);
}
Esempio n. 6
0
static unsigned _action_cb_calibrate(u32 button, unsigned flags, void *data)
{
    (void)data;
    u8 i;
    if (flags & BUTTON_PRESS)
        return 1;
    if (flags & BUTTON_RELEASE) {
        if (CHAN_ButtonIsPressed(button, BUT_EXIT)) {
            // bug fix: when most users see the "Calibration done", it is very likely tha they will press ext to exit,
            // then all calibration data are rollback, and cause the calibration failed -- what a tough bug!!
            if (calibrate_state == CALI_SUCCESS)
                calibrate_state = CALI_SUCCESSEXIT;
            else
                calibrate_state = CALI_EXIT;
        } else if (CHAN_ButtonIsPressed(button, BUT_ENTER)) {
            switch (calibrate_state){
            case CALI_CENTER:
                for (i = 0; i < INP_HAS_CALIBRATION; i++) {
                    s32 value = CHAN_ReadRawInput(i + 1);
                    Transmitter.calibration[i].max = 0x0000;
                    Transmitter.calibration[i].min = 0xFFFF;
                    Transmitter.calibration[i].zero = value;
                }
                snprintf(tempstring, sizeof(tempstring), "%s", _tr("Move sticks and knobs\nto max & min positions\nthen press ENT"));
                GUI_Redraw(&guic->msg);
                calibrate_state = CALI_MAXMIN;
                break;
            case CALI_MAXMIN:
                for (i = 0; i < INP_HAS_CALIBRATION; i++) {
                    printf("Input %d: Max: %d Min: %d Zero: %d\n", i+1, Transmitter.calibration[i].max, Transmitter.calibration[i].min, Transmitter.calibration[i].zero);
                }
                GUI_DrawBackground(0, 0, LCD_WIDTH, LCD_HEIGHT);
                snprintf(tempstring, sizeof(tempstring), "%s", _tr("Calibration done.\n \nPress ENT."));
                GUI_Redraw(&guic->msg);
                calibrate_state = CALI_SUCCESS;
                break;
            case CALI_SUCCESS:
                calibrate_state = CALI_SUCCESSEXIT;
                break;
            default: break;
            }
        }else {
            // only one callback can handle a button press, so we don't handle BUT_ENTER here, let it handled by press cb
            return 0;
        }
    }
    return 1;
}
Esempio n. 7
0
unsigned action_cb(u32 button, unsigned flags, void *data)
{
    if ((flags & BUTTON_LONGPRESS) && CHAN_ButtonIsPressed(button, BUT_RIGHT)) {
        reorder_cb(NULL, NULL);
        return 1;
    }
    return default_button_action_cb(button, flags, data);
}
Esempio n. 8
0
static unsigned _action_cb(u32 button, unsigned flags, void *data)
{
    u8 i;
    if ((flags & BUTTON_PRESS) && CHAN_ButtonIsPressed(button, BUT_ENTER)) {
        u8 page = (0 << 4) | MENUTYPE_MAINMENU;
        PAGE_ChangeByID(PAGEID_MENU, page);
    } else if ((flags & BUTTON_PRESS) && CHAN_ButtonIsPressed(button, BUT_RIGHT)) {
	for ( i=0; i< NUM_TIMERS; i++) 
            TIMER_StartStop(i);
    } else if ((flags & BUTTON_PRESS) && CHAN_ButtonIsPressed(button, BUT_LEFT)) {
        for ( i=0; i< NUM_TIMERS; i++)
            TIMER_Reset(i);
    } else if (! PAGE_QuickPage(button, flags, data)) {
        MIXER_UpdateTrim(button, flags, data);
    }
    return 1;
}
Esempio n. 9
0
static unsigned _action_cb(u32 button, unsigned flags, void *data)
{
    (void)data;
    if ((flags & BUTTON_PRESS) || (flags & BUTTON_LONGPRESS)) {
        if (CHAN_ButtonIsPressed(button, BUT_EXIT)) {
            PAGE_ChangeByID(PAGEID_MENU, PREVIOUS_ITEM);
        } else if (CHAN_ButtonIsPressed(button, BUT_ENTER)) {
            MUSIC_Play(MUSIC_SAVING);
            save_changes();
        }
        else {
            // only one callback can handle a button press, so we don't handle BUT_ENTER here, let it handled by press cb
            return 0;
        }
    }
    return 1;
}
Esempio n. 10
0
static unsigned _action_cb(u32 button, unsigned flags, void *data)
{
    u8 i;
    if ((flags & BUTTON_PRESS) && CHAN_ButtonIsPressed(button, BUT_ENTER)) {
        //see pagelist.h for mapping of 'page' to menu_id 
        PAGE_PushByID(PAGEID_MENU, 0);
    } else if ((flags & BUTTON_PRESS) && CHAN_ButtonIsPressed(button, BUT_RIGHT)) {
	for ( i=0; i< NUM_TIMERS; i++) 
            TIMER_StartStop(i);
    } else if ((flags & BUTTON_PRESS) && CHAN_ButtonIsPressed(button, BUT_LEFT)) {
        for ( i=0; i< NUM_TIMERS; i++)
            TIMER_Reset(i);
    } else if (! PAGE_QuickPage(button, flags, data)) {
        MIXER_UpdateTrim(button, flags, data);
    }
    return 1;
}
Esempio n. 11
0
static unsigned _action_cb(u32 button, unsigned flags, void *data)
{
    if (CHAN_ButtonIsPressed(button, BUT_ENTER)) {
        MUSIC_Play(MUSIC_SAVING);
        save_changes();
        return 1;
    }
    return default_button_action_cb(button, flags, data);
}
Esempio n. 12
0
static unsigned _action_cb(u32 button, unsigned flags, void *data)
{
    (void)data;
    if (CHAN_ButtonIsPressed(button, BUT_ENTER) &&(flags & BUTTON_LONGPRESS)) {
        PAGE_PushByID(PAGEID_LAYOUT, 0);
        return 1;
    }
    return default_button_action_cb(button, flags, data);
}
Esempio n. 13
0
static u8 _action_cb(u32 button, u8 flags, void *data)
{
    (void)data;
    if ((flags & BUTTON_PRESS) || (flags & BUTTON_LONGPRESS)) {
        if (CHAN_ButtonIsPressed(button, BUT_EXIT)) {
            PAGE_ChangeByID(PAGEID_MENU, PREVIOUS_ITEM);
        }
    }
    return 1;
}
Esempio n. 14
0
int PAGE_QuickPage(u32 buttons, u8 flags, void *data)
{
    (void)data;
    (void)flags;
    int i;
    for(i = 0; i < NUM_QUICKPAGES; i++)
        if(Model.pagecfg2.quickpage[i])
            break;
    if(i == NUM_QUICKPAGES)
        return 0;
    if(CHAN_ButtonIsPressed(buttons, BUT_RIGHT)) {
        PAGE_ChangeQuick(1);
        return 1;
    } else if (CHAN_ButtonIsPressed(buttons, BUT_LEFT)) {
        PAGE_ChangeQuick(-1);
        return 1;
    }
    return 0;
}
Esempio n. 15
0
unsigned page_change_cb(u32 buttons, unsigned flags, void *data)
{
    (void)data;
    if (PAGE_GetID() == PAGEID_TELEMMON) {
        if(CHAN_ButtonIsPressed(buttons, BUT_ENTER) || CHAN_ButtonIsPressed(buttons, BUT_EXIT))
            TELEMETRY_MuteAlarm();
        if(flags & BUTTON_LONGPRESS && CHAN_ButtonIsPressed(buttons, BUT_UP))
            TELEMETRY_ResetValues();
    }
    if (flags & BUTTON_LONGPRESS) {
        if (flags & BUTTON_REPEAT)
            return 0;
        if(quick_page_enabled) { // let the quickpage over other pages
            if(PAGE_QuickPage(buttons, flags, data))
                return 1;
        }        
        if(CHAN_ButtonIsPressed(buttons, BUT_ENTER) && enter_cmd) {
            void (*cmd)(guiObject_t *obj, const void *data) = enter_cmd;
            PAGE_RemoveAllObjects();
            cmd(NULL, enter_data);
            return 1;
        }
        if(CHAN_ButtonIsPressed(buttons, BUT_EXIT) && exit_cmd) {
            void (*cmd)(guiObject_t *obj, const void *data) = exit_cmd;
            PAGE_RemoveAllObjects();
            cmd(NULL, exit_data);
            return 1;
        }
        return 0;
    }
    if (ActionCB != NULL)
        return ActionCB(buttons, flags, data);
//    if(CHAN_ButtonIsPressed(buttons, BUT_RIGHT)) {
//        PAGE_Change(1);
//        return 1;
//    } else if(CHAN_ButtonIsPressed(buttons, BUT_LEFT)) {
//        PAGE_Change(-1);
//        return 1;
//    }
    return 0;
}
Esempio n. 16
0
static unsigned action_cb(u32 button, unsigned flags, void *data)
{
    (void)data;
    if ((flags & BUTTON_PRESS) || (flags & BUTTON_LONGPRESS)) {
        if (CHAN_ButtonIsPressed(button, BUT_EXIT)) {
            PAGE_Pop();
        } else if (CHAN_ButtonIsPressed(button, BUT_ENTER) && (flags & BUTTON_LONGPRESS)) {
            // long press enter = save without exiting
            if (edit->pointnum < 0)
                edit->curve.points[1] = edit->curve.points[0];
            *edit->curveptr = edit->curve;
            struct mixer_page * const mp = &pagemem.u.mixer_page;
            PAGE_SaveMixerSetup(mp);
        }
        else {
            // only one callback can handle a button press, so we don't handle BUT_ENTER here, let it handled by press cb
            return 0;
        }
    }
    return 1;
}
Esempio n. 17
0
static u8 _handle_modalbuttons_devo10(u32 button, u8 flags, void *data)
{
    (void)data;
    if ((flags & BUTTON_PRESS) || (flags & BUTTON_LONGPRESS)) {
        if (CHAN_ButtonIsPressed(button, BUT_EXIT) ) {
            objTOUCHED = objModalButton;  // assume the cancel button is the default/modal button
            GUI_TouchRelease();
        } else if (CHAN_ButtonIsPressed(button, BUT_ENTER)) {
            if (objSELECTED)
                objTOUCHED = objSELECTED;
            else
                objTOUCHED = objModalButton;
            GUI_TouchRelease();
        }
        else {
            // only one callback can handle a button press, so we don't handle BUT_ENTER here, let it handled by press cb
            return 0;
        }
    }
    return 1;
}
Esempio n. 18
0
static unsigned press_cb(u32 button, unsigned flags, void *data)
{
    struct guiObject *obj = (struct guiObject *)data;
    struct guiKeyboard *keyboard = (struct guiKeyboard *)obj;
    (void)data;
    if (flags & BUTTON_PRESS || flags & BUTTON_LONGPRESS) {
        if ( flags & BUTTON_LONGPRESS && CHAN_ButtonIsPressed(button, BUT_ENTER) && keyboard->lastchar == '\x08') {
            //DEL Long Press erases whole string
            keyboard->text[0] = '\0';
            _kb_draw_text(keyboard->text);
        }
        else if (CHAN_ButtonIsPressed(button, BUT_EXIT)) { // allow user to press the EXT key to discard changes
            if (keyboard->CallBack) {
                if (keyboard->cb_data != NULL) {
                    int *result = (int *) keyboard->cb_data;
                    *result = 0;
                }
                BUTTON_UnregisterCallback(&keyboard->action);
                keyboard->CallBack(obj, keyboard->cb_data );
            }
            //After DONE it is possible that obj and keyboard are invalid
        } else if (CHAN_ButtonIsPressed(button, BUT_RIGHT)) {
            navigate_item(keyboard, 1 , 0);
        }  else if (CHAN_ButtonIsPressed(button, BUT_LEFT)) {
            navigate_item(keyboard, -1, 0);
        } else if (CHAN_ButtonIsPressed(button, BUT_UP)) {
            navigate_item(keyboard, 0 , -1);
        }  else if (CHAN_ButtonIsPressed(button, BUT_DOWN)) {
            navigate_item(keyboard, 0, 1);
        } else if (CHAN_ButtonIsPressed(button, BUT_ENTER)) {
            if (keyboard->lastchar == '\x09') { //CAPS
                keyboard->flags ^= FLAG_CAPS;
                keyboard_cmd(KB_DRAW, keyboard, NULL);
            } else if (keyboard->lastchar == '\x01' || keyboard->lastchar == '\x02') { //Numpad
                keyboard->type = keyboard->type == KEYBOARD_ALPHA ? KEYBOARD_SPECIAL : KEYBOARD_ALPHA;
                OBJ_SET_DIRTY(obj, 1);
            } else if (keyboard->lastchar == '\x06') { //DONE
                if (keyboard->CallBack) {
                    if (keyboard->cb_data != NULL) {
                        int *result = (int *) keyboard->cb_data;
                        if (*result <= 0) // to avoid loosing the channel number when renaming virtual channels on b/w-screens
                        	*result = 1;
                    }
                    BUTTON_UnregisterCallback(&keyboard->action);
                    keyboard->CallBack(obj, keyboard->cb_data );
                }
                //After DONE it is possible that obj and keyboard are invalid
            } else {
                kb_update_string(keyboard, keyboard->lastchar);
            }
        }
        return 1;
    }
    return 1;
}
Esempio n. 19
0
unsigned _action_cb(u32 button, unsigned flags, void *data)
{
    (void)data;
    if (CHAN_ButtonIsPressed(button, BUT_ENTER))
        return 0;
    if (! (flags & BUTTON_RELEASE))
        return 1;
    {
        if (CHAN_ButtonIsPressed(button, BUT_EXIT))
            PAGE_Pop();
        else if (CHAN_ButtonIsPressed(button, BUT_UP))
            navigate_toggleicons(-1);
        else if (CHAN_ButtonIsPressed(button, BUT_DOWN))
            navigate_toggleicons(1);
        else if (CHAN_ButtonIsPressed(button, BUT_LEFT))
            navigate_symbolicons(-1);
        else if (CHAN_ButtonIsPressed(button, BUT_RIGHT))
            navigate_symbolicons(1);
        else {
            // only one callback can handle a button press, so we don't handle BUT_ENTER here, let it handled by press cb
            return 0;
        }
    }
    return 1;
}
Esempio n. 20
0
static unsigned _action_cb(u32 button, unsigned flags, void *data)
{
    (void)data;

    if(! GUI_GetSelected() || lp->selected_for_move < 0 || GUI_IsModal())
        return 0;
    if(CHAN_ButtonIsPressed(button, BUT_EXIT)) {
        gui->elem[lp->selected_for_move].desc.font_color ^= 0xffff;
        gui->elem[lp->selected_for_move].desc.fill_color ^= 0xffff;
        GUI_Redraw((guiObject_t *)&gui->elem[lp->selected_for_move]);
        set_selected_for_move(-1);
        return 1;
    }
    if(CHAN_ButtonIsPressed(button, BUT_ENTER)) {
        show_config();
        return 1;
    }
    if(CHAN_ButtonIsPressed(button, BUT_LEFT)) {
        xpos_cb(NULL, (flags & BUTTON_LONGPRESS) ? -2 : -1, NULL);
        return 1;
    }
    if(CHAN_ButtonIsPressed(button, BUT_RIGHT)) {
        xpos_cb(NULL, (flags & BUTTON_LONGPRESS) ? 2 : 1, NULL);
        return 1;
    }
    if(CHAN_ButtonIsPressed(button, BUT_UP)) {
        ypos_cb(NULL, (flags & BUTTON_LONGPRESS) ? -2 : -1, NULL);
        return 1;
    }
    if(CHAN_ButtonIsPressed(button, BUT_DOWN)) {
        ypos_cb(NULL, (flags & BUTTON_LONGPRESS) ? 2 : 1, NULL);
        return 1;
    }
    return 0;
}
Esempio n. 21
0
static u8 _action_cb(u32 button, u8 flags, void *data)
{
    (void)data;
    if (flags & BUTTON_PRESS) {
        if (CHAN_ButtonIsPressed(button, BUT_EXIT)) {
            labelDesc.font = DEFAULT_FONT.font;
            if (cp->return_val == 2) // indicating this page is entered from calibration page, so back to its parent page
                PAGE_ChangeByID(PAGEID_TXCFG, -1);
            else
                PAGE_ChangeByID(PAGEID_MENU, PREVIOUS_ITEM);
        } else if (CHAN_ButtonIsPressed(button, BUT_RIGHT)) {
            _navigate_pages(1);
        }  else if (CHAN_ButtonIsPressed(button,BUT_LEFT)) {
            _navigate_pages(-1);
        }
        else {
            // only one callback can handle a button press, so we don't handle BUT_ENTER here, let it handled by press cb
            return 0;
        }
    }
    return 1;
}
Esempio n. 22
0
static void wait_release()
{
    printf("Wait Release\n");
    while(1) {
        CLOCK_ResetWatchdog();
        u32 buttons = ScanButtons();
        if (! CHAN_ButtonIsPressed(buttons, BUT_ENTER))
            break;
        if(PWR_CheckPowerSwitch())
            PWR_Shutdown();
    }
    printf("Released\n");
}
Esempio n. 23
0
static u8 _action_cb(u32 button, u8 flags, void *data)
{
    (void)data;
    if (flags & BUTTON_PRESS || (flags & BUTTON_LONGPRESS)) {
        if (CHAN_ButtonIsPressed(button, BUT_EXIT)) {
            PAGE_ChangeByID(PAGEID_MENU, PREVIOUS_ITEM);
        } else {
            // only one callback can handle a button press, so we don't handle BUT_ENTER here, let it handled by press cb
            return 0;
        }
    }
    return 1;
}
Esempio n. 24
0
static unsigned _sub_action_cb(u32 button, unsigned flags, void *data)
{
    (void)data;
    if (flags & BUTTON_PRESS || (flags & BUTTON_LONGPRESS)) {
        if (CHAN_ButtonIsPressed(button, BUT_EXIT)) {
            PAGE_TrimInit(0);
        }
        else {
            // only one callback can handle a button press, so we don't handle BUT_ENTER here, let it handled by press cb
            return 0;
        }
    }
    return 1;
}
Esempio n. 25
0
static unsigned _action_cb(u32 button, unsigned flags, void *data)
{
    (void)data;
    if ((flags & BUTTON_PRESS) || (flags & BUTTON_LONGPRESS)) {
        if (CHAN_ButtonIsPressed(button, BUT_EXIT) || load_save == LOAD_LAYOUT) {
            okcancel_cb(NULL, 0);
        }
        else {
            // only one callback can handle a button press, so we don't handle BUT_ENTER here, let it handled by press cb
            return 0;
        }
    }
    return 1;
}
Esempio n. 26
0
static unsigned action_cb(u32 button, unsigned flags, void *data)
{
    (void)data;
    if ((flags & BUTTON_PRESS) || (flags & BUTTON_LONGPRESS)) {
        if (CHAN_ButtonIsPressed(button, BUT_EXIT)) {
            PAGE_RemoveAllObjects();  // Discard unsaved items and exit to upper page
            PAGE_MixerInit(mp->top_channel);
        } else {
            // only one callback can handle a button press, so we don't handle BUT_ENTER here, let it handled by press cb
            return 0;
        }
    }
    return 1;
}
Esempio n. 27
0
static unsigned _action_cb(u32 button, unsigned flags, void *data)
{
    (void)data;
    if ((flags & BUTTON_PRESS) || (flags & BUTTON_LONGPRESS)) {
        if (CHAN_ButtonIsPressed(button, BUT_EXIT)) {
            labelDesc.font = DEFAULT_FONT.font;  // set it back to 12x12 font
            PAGE_ChangeByID(PAGEID_MENU, PREVIOUS_ITEM);
        } else if (current_page != telemetry_off) {
            // this indicates whether telem is off or not supported
            if (CHAN_ButtonIsPressed(button, BUT_RIGHT)) {
                _navigate_pages(1);
            }  else if (CHAN_ButtonIsPressed(button,BUT_LEFT)) {
                _navigate_pages(-1);
            } else {
                return 0;
            }
        }
        else {
            // only one callback can handle a button press, so we don't handle BUT_ENTER here, let it handled by press cb
            return 0;
        }
    }
    return 1;
}
Esempio n. 28
0
static unsigned _action_cb(u32 button, unsigned flags, void *data)
{
    (void)data;
    if ((flags & BUTTON_PRESS) || (flags & BUTTON_LONGPRESS)) {
        if (CHAN_ButtonIsPressed(button, BUT_EXIT)) {
            BUTTON_UnregisterCallback(&action);
            PAGE_RemoveAllObjects();
            rl.return_page(NULL);
        } else if (CHAN_ButtonIsPressed(button, BUT_LEFT) && ((guiObject_t *)&gui->value == GUI_GetSelected())) {
            // catch the left/right keys when r1.textsel is selected
            copy_val_cb(NULL, 1, NULL);
            GUI_Redraw(&gui->value);

        } else if (CHAN_ButtonIsPressed(button, BUT_RIGHT)&& ((guiObject_t *)&gui->value == GUI_GetSelected())) {
            copy_val_cb(NULL, -1, NULL);
            GUI_Redraw(&gui->value);
        }
        else {
            // only one callback can handle a button press, so we don't handle BUT_ENTER here, let it handled by press cb
            return 0;
        }
    }
    return 1;
}
Esempio n. 29
0
unsigned GUI_ObjButton(struct guiObject *obj, u32 button, unsigned flags)
{
    //These objects dont handle buttons
    switch (obj->Type) {
      case UnknownGUI:
      case Dialog:
      case CheckBox:
      case Dropdown:
      case BarGraph:
      case Rect:
        return 0;
      default:
        break;
    }
    unsigned is_release = flags & BUTTON_RELEASE;
    unsigned is_longpress = flags & BUTTON_LONGPRESS;
    int press_type = is_release ? -1 : is_longpress ? 1 : 0;
    //TextSelect can handle Left, Right, and Enter
    if (obj->Type == TextSelect) {
        GUI_PressTextSelect(obj, button, press_type);
        return 1;
    }
    //These objects handle ENTER only
    if (CHAN_ButtonIsPressed(button, BUT_ENTER)) {
        switch (obj->Type) {
          case Button:
            objTOUCHED = obj;
            return GUI_TouchButton(obj, press_type);
          case Image:
            objTOUCHED = obj;
            GUI_TouchImage(obj, NULL, press_type);
            return 1;
          case Label:
            objTOUCHED = obj;
            GUI_TouchLabel(obj, NULL, press_type);
            return 1;
          default:
            break;
        }
    }
    return 0;
}
Esempio n. 30
0
static unsigned _layaction_cb(u32 button, unsigned flags, void *data)
{
    (void)data;
    if(CHAN_ButtonIsPressed(button, BUT_EXIT)) {
        if (flags & BUTTON_RELEASE) {
            if (lp->selected_for_move >= 0) {
                set_selected_for_move(-1);
            } else {
                PAGE_Pop();
            }
        }
        return 1;
    }
    if (! GUI_GetSelected() || flags & BUTTON_RELEASE)
        return 0;
    if (CHAN_ButtonIsPressed(button, BUT_ENTER) && lp->selected_for_move < 0) {
        select_for_move((guiLabel_t *)GUI_GetSelected());
        return 1;
    }
    if (lp->selected_for_move < 0)
        return 0;
    if(CHAN_ButtonIsPressed(button, BUT_LEFT)) {
        xpos_cb(NULL, (flags & BUTTON_LONGPRESS) ? -2 : -1, NULL);
        return 1;
    }
    if(CHAN_ButtonIsPressed(button, BUT_RIGHT)) {
        xpos_cb(NULL, (flags & BUTTON_LONGPRESS) ? 2 : 1, NULL);
        return 1;
    }
    if(CHAN_ButtonIsPressed(button, BUT_UP)) {
        ypos_cb(NULL, (flags & BUTTON_LONGPRESS) ? -2 : -1, NULL);
        return 1;
    }
    if(CHAN_ButtonIsPressed(button, BUT_DOWN)) {
        ypos_cb(NULL, (flags & BUTTON_LONGPRESS) ? 2 : 1, NULL);
        return 1;
    }
    return 0;
}