📄 uiser.c
字号:
////****************************************************************************static __inline voidHandleButtons(unsigned long ulButtons){ unsigned long ulIndex, ulTime; // // See if the play button has been pressed. // if(ulButtons & 0x01) { // // Indicate that the play button was pressed. This maps to both the // play and pause virtual keys. // sUI.ulKeys |= BUTTON_PLAY | BUTTON_PAUSE; } // // See if the power off button has been pressed. // ulTime = (sUI.usTickCount - sUI.usPressTime[0]) & 0xffff; if((sUI.ucState & 0x01) && (ulTime >= POWER_DELAY)) { // // Indicate that the power button was pressed. // sUI.ulKeys |= BUTTON_POWER; } // // See if the stop button has been pressed. // if(ulButtons & 0x02) { // // Indicate that the stop button was pressed. // sUI.ulKeys |= BUTTON_STOP; } // // See if the record button has been pressed. //#ifdef REQUIRE_RECORD ulTime = (sUI.usTickCount - sUI.usPressTime[1]) & 0xffff; if((sUI.ucState & 0x02) && (ulTime >= RECORD_DELAY)) { // // Indicate that the record button was pressed. // sUI.ulKeys |= BUTTON_RECORD; }#endif // // Get the current menu index. // ulIndex = (sUI.ulFlags & FLAG_MENU_ITEM_MASK) >> FLAG_MENU_ITEM_SHIFT; // // See if the menu left button has been pressed. // ulTime = (sUI.usTickCount - sUI.usPressTime[2]) & 0xffff; if((sUI.ucState & 0x04) && ((ulButtons & 0x040000) || ((ulTime >= MENU_DELAY) && ((ulTime % MENU_LR_ACCEL) == 0)))) { // // If the menu index is not already at zero, then decrement it. // if(ulIndex) { // // Decrement the menu index. // ulIndex--; // // Save the new menu item index. // sUI.ulFlags &= ~FLAG_MENU_ITEM_MASK; sUI.ulFlags |= ulIndex << FLAG_MENU_ITEM_SHIFT; // // Indicate that the menu needs to be updated. // sUI.ulFlags |= FLAG_UPDATE_MENU; } } // // See if the menu right button has been pressed. // ulTime = (sUI.usTickCount - sUI.usPressTime[3]) & 0xffff; if((sUI.ucState & 0x08) && ((ulButtons & 0x080000) || ((ulTime >= MENU_DELAY) && ((ulTime % MENU_LR_ACCEL) == 0)))) { // // If the menu index is not already at the end, then increment it. // if((ulIndex + 1) != (sizeof(sMenuItems) / sizeof(sMenuItems[0]))) { // // Increment the menu index. // ulIndex++; // // Save the new menu item index. // sUI.ulFlags &= ~FLAG_MENU_ITEM_MASK; sUI.ulFlags |= ulIndex << FLAG_MENU_ITEM_SHIFT; // // Indicate that the menu needs to be updated. // sUI.ulFlags |= FLAG_UPDATE_MENU; } } // // The next two buttons have special handling based on the current menu // index. See if we are in seek mode. // if(ulIndex == 0) { // // The handling of the fast forward and rewind buttons are dependent // upon the current mode of the player. See if we are plaing or // paused. // if(((sUI.ucMode & 0x1f) == MODE_PLAY) || ((sUI.ucMode & 0x1f) == MODE_PAUSE)) { // // See if the previous track button has been pressed. // if(ulButtons & 0x10) { // // Indicate that the previous track button was pressed. // sUI.ulKeys |= BUTTON_PREV; } // // If the rewind button is being held, then we should seek // backwards. // ulTime = (sUI.usTickCount - sUI.usPressTime[4]) & 0xffff; if((sUI.ucState & 0x10) && (ulTime >= SEEK_DELAY) && ((ulTime % SEEK_ACCEL) == 0)) { // // Indicate that the seek backwards button was pressed. // sUI.ulKeys |= BUTTON_REW; // // See if the rewind button has been held long enough to // accelerate the seek. // if(ulTime >= SEEK3_ACCEL) { // // The rewind button has been held long enough to bump up // to the third acceleration rate. // sUI.ulKeys |= BUTTON_SEEK_RATE_ACC3; } else if(ulTime >= SEEK2_ACCEL) { // // The rewind button has been held long enough to bump up // to the second acceleration rate. // sUI.ulKeys |= BUTTON_SEEK_RATE_ACC2; } else if(ulTime >= SEEK1_ACCEL) { // // The rewind button has been held long enough to bump up // to the first acceleration rate. // sUI.ulKeys |= BUTTON_SEEK_RATE_ACC1; } } // // See if the next track button has been pressed. // if(ulButtons & 0x20) { // // Indicate that the next track button was pressed. // sUI.ulKeys |= BUTTON_NEXT; } // // If the fast forward button is being held, then we should seek // forward. // ulTime = (sUI.usTickCount - sUI.usPressTime[5]) & 0xffff; if((sUI.ucState & 0x20) && (ulTime >= SEEK_DELAY) && ((ulTime % SEEK_ACCEL) == 0)) { // // Indicate that the seek forwards button was pressed. // sUI.ulKeys |= BUTTON_FFWD; // // See if the fast foward button has been held long enough to // accelerate the seek. // if(ulTime >= SEEK3_ACCEL) { // // The fast forward button has been held long enough to // bump up to the third acceleration rate. // sUI.ulKeys |= BUTTON_SEEK_RATE_ACC3; } else if(ulTime >= SEEK2_ACCEL) { // // The fast forward button has been held long enough to // bump up to the second acceleration rate. // sUI.ulKeys |= BUTTON_SEEK_RATE_ACC2; } else if(ulTime >= SEEK1_ACCEL) { // // The fast forward button has been held long enough to // bump up to the first acceleration rate. // sUI.ulKeys |= BUTTON_SEEK_RATE_ACC1; } } } // // Otherwise, see if we are stopped. // else if((sUI.ucMode & 0x1f) == MODE_STOP) { // // See if the previous track button has been pressed or is being // held. // ulTime = (sUI.usTickCount - sUI.usPressTime[4]) & 0xffff; if((sUI.ucState & 0x10) && ((ulButtons & 0x100000) || ((ulTime >= SEEK_DELAY) && ((ulTime % TRACK_ACCEL) == 0)))) { // // Indicate that the previous track button was pressed. // sUI.ulKeys |= BUTTON_PREV; } // // See if the next track button has been pressed or is being held. // ulTime = (sUI.usTickCount - sUI.usPressTime[5]) & 0xffff; if((sUI.ucState & 0x20) && ((ulButtons & 0x200000) || ((ulTime >= SEEK_DELAY) && ((ulTime % TRACK_ACCEL) == 0)))) { // // Indicate that the next track button was pressed. // sUI.ulKeys |= BUTTON_NEXT; } } } // // Otherwise, we are adjusting a menu item value. // else { // // See if the adjust down button was pressed. // ulTime = (sUI.usTickCount - sUI.usPressTime[4]) & 0xffff; if((sUI.ucState & 0x10) && ((ulButtons & 0x100000) || ((ulTime >= MENU_DELAY) && ((ulTime % MENU_UD_ACCEL) == 0)))) { unsigned long ulValue; // // Get the current value of this menu item. // ulValue = (*(sMenuItems[ulIndex].pulFlags) & sMenuItems[ulIndex].ulFlagMask) >> sMenuItems[ulIndex].ulFlagShift; // // If the current value is not zero, then we can decrement it. // if(ulValue > 0) { // // Decrement the current value. // ulValue--; // // Save the new value. // *(sMenuItems[ulIndex].pulFlags) &= ~sMenuItems[ulIndex].ulFlagMask; *(sMenuItems[ulIndex].pulFlags) |= ulValue << sMenuItems[ulIndex].ulFlagShift; // // See if the menu item has a routine for effecting the change // in other parts of the player. // if(sMenuItems[ulIndex].pfnUpdate) { // // Reflect the new menu item value in the rest of the // player. // (sMenuItems[ulIndex].pfnUpdate)(ulValue); } // // Indicate that we need to update the menu. // sUI.ulFlags |= FLAG_UPDATE_MENU; } } // // See if the adjust up button was pressed. // ulTime = (sUI.usTickCount - sUI.usPressTime[5]) & 0xffff; if((sUI.ucState & 0x20) && ((ulButtons & 0x200000) || ((ulTime >= MENU_DELAY) && ((ulTime % MENU_UD_ACCEL) == 0)))) { unsigned long ulValue; // // Get the current value of this menu item. // ulValue = (*(sMenuItems[ulIndex].pulFlags) & sMenuItems[ulIndex].ulFlagMask) >> sMenuItems[ulIndex].ulFlagShift; // // If the current value is not at the maximum, then we can // increment it. // if(ulValue < (sMenuItems[ulIndex].ulNumValues - 1)) { // // Increment the current value. // ulValue++; // // Save the new value. // *(sMenuItems[ulIndex].pulFlags) &= ~sMenuItems[ulIndex].ulFlagMask; *(sMenuItems[ulIndex].pulFlags) |= ulValue << sMenuItems[ulIndex].ulFlagShift; // // See if the menu item has a routine for effecting the change // in other parts of the player. // if(sMenuItems[ulIndex].pfnUpdate) { // // Reflect the new menu item value in the rest of the // player. // (sMenuItems[ulIndex].pfnUpdate)(ulValue); } // // Indicate that we need to update the menu. // sUI.ulFlags |= FLAG_UPDATE_MENU; } } } // // We need to move the target time so that we do not get an automatic // power off. // sUI.usTargetTime = sUI.usTickCount + (3000 * (((sUI.ulFlags & FLAG_SLEEP_MASK) >> FLAG_SLEEP_SHIFT) + 1));}//****************************************************************************//// UIISR is the user interface routine which is called approximately 50 times// per second to handle the periodic needs of the user interface.////****************************************************************************voidUIISR(void){ unsigned long ulButtons; // // Increment the number of timer ticks which have occurred. // sUI.usTickCount++; // // If the tick count has reached the target time, see what we need to do. // if((sUI.usTickCount == sUI.usTargetTime) && ((sUI.ucMode == MODE_STOP) || (sUI.ucMode == MODE_PAUSE))) { // // Fake a press of the power button. // sUI.ulKeys |= BUTTON_POWER; } // // Determine which buttons are pressed and which have been released. // ulButtons = ScanButtons(); // // See if any buttons are being pressed. // if(sUI.ucState || ulButtons) { // // See if more than one button is pressed. // if((sUI.ucState != 0x00) && (sUI.ucState != 0x01) && (sUI.ucState != 0x02) && (sUI.ucState != 0x04) && (sUI.ucState != 0x08) && (sUI.ucState != 0x10) && (sUI.ucState != 0x20) && (sUI.ucState != 0x40) && (sUI.ucState != 0x80)) { // // More than one button is currently pressed, so wait for all // buttons to be released before we handle any more button presses. // sUI.ulFlags |= FLAG_WAIT_FOR_ALL_UP; } // // See if we are supposed to wait for all buttons to be released. // if(!(sUI.ulFlags & FLAG_WAIT_FOR_ALL_UP)) { // // Handle the buttons. // HandleButtons(ulButtons); } } // // If there are no buttons pressed, then clear the flag indicating that we // should wait for all buttons to be released. // else { sUI.ulFlags &= ~FLAG_WAIT_FOR_ALL_UP; }}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -