/** * @function RotValRefresh * @brief rotary value task * @param void *_g_obj: generic object * @param void *_obj: rot val object * @return none */ static void RotValRefresh(void *_g_obj, void *_obj) { g_obj_st *g_obj; rot_val_st *rval; bool bRefresh = false; coord_t xt; uint8_t selectedDigit; /*retrieve generic & specific object*/ if(_g_obj != NULL && _obj != NULL) { g_obj = (g_obj_st *) _g_obj; rval = (rot_val_st*) _obj; /*handle user interaction, only if the value is unlocked*/ if(rval->lock == 0) { /*object pressed?*/ if(GUI_ObjIsPressed(g_obj) && GUI_ObjIsDisabled(g_obj) == false) { /*get the digit #id corresponding to the touchscreen*/ GUI_ReadTouchScreen(&xt, NULL); selectedDigit = GetSelectedDigit(rval, xt); /*different than the last one? -> refresh*/ if(selectedDigit != rval->selectedDigit) { rval->selectedDigit = selectedDigit; bRefresh = true; } } else { /*add the increment/decrement to the pVar, if any*/ *(rval->pVar) = SafeAdd( *(rval->pVar), *(rval->pStep), rval->selectedDigit, rval->min, rval->max); } } /*overall check (avoid UB if the user manually changes *pVar)*/ if( *(rval->pVar) < rval->min) *(rval->pVar) = rval->min; else if( *(rval->pVar) > rval->max) *(rval->pVar) = rval->max; /*changed pVar? -> refresh*/ if( *(rval->pVar) != rval->oldVal) { rval->oldVal = *(rval->pVar); bRefresh = true; } if(bRefresh) GUI_ObjSetNeedRefresh(g_obj, true); } }
// // P_Ticker // void P_Ticker(void) { // pause if in menu and at least one tic has been run if (paused || menuactive || consoleactive) return; P_PlayerThink(&players[0]); P_RunThinkers(); P_UpdateSpecials(); P_MapEnd(); // for par times leveltime++; stat_time = SafeAdd(stat_time, 1); }
/** * @function RotValRefresh * @brief rotary value task * @param void *_g_obj: generic object * @param void *_obj: rot val object * @return none */ static void RotValRefresh(void *_g_obj, void *_obj) { g_obj_st *g_obj; rot_val_st *rval; bool bRefresh = false; coord_t xt; uint8_t selectedDigit; /*retrieve generic & specific object*/ if(_g_obj != NULL && _obj != NULL) { g_obj = (g_obj_st *) _g_obj; rval = (rot_val_st*) _obj; /*handle user interaction, only if the value is unlocked*/ if(rval->lock == 0) { /*object pressed?*/ if(GUI_ObjIsPressed(g_obj) && GUI_ObjIsDisabled(g_obj) == false) { /*get the digit #id corresponding to the touchscreen*/ GUI_ReadTouchScreen(&xt, NULL); selectedDigit = GetSelectedDigit(rval, xt - g_obj->rec.x); /*different than the last one? -> refresh*/ if(selectedDigit != rval->selectedDigit) { rval->selectedDigit = selectedDigit; bRefresh = true; rval->fsm = 1; } /*same digit selected -> launch the keyboard*/ else { if(rval->fsm == 2) { pSelected = rval; /**can't start the keyboard now (widgets are being displayed)*/ /**RvalKbdStart() will hook the user task on next cycle*/ GUI_SetHookUserTask(RvalKbdStart); rval->selectedDigit = 0xFF; } } } else { /*add the increment/decrement to the pVar, if any*/ *(rval->pVar) = SafeAdd( *(rval->pVar), *(rval->pStep), rval->selectedDigit, rval->min, rval->max); if(rval->fsm == 1) rval->fsm = 2; } } else { rval->selectedDigit = 0xFF; } /*overall check (avoid UB if the user manually changes *pVar)*/ if( *(rval->pVar) < rval->min) *(rval->pVar) = rval->min; else if( *(rval->pVar) > rval->max) *(rval->pVar) = rval->max; /*changed pVar? -> refresh*/ if( *(rval->pVar) != rval->oldVal) { rval->oldVal = *(rval->pVar); bRefresh = true; } if(bRefresh) GUI_ObjSetNeedRefresh(g_obj, true); } }