Exemplo n.º 1
0
int main(int argc, char** argv)
{
  glutInit(&argc, argv);
  glutInitWindowSize(512, 512);
  glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
  glutCreateWindow("AGV example");
  
  glutVisibilityFunc(visible);

  if (Rotating)
    glutIdleFunc(rotatethering);
 
    /*
     * let AGV know if it can mess with the idle function (if we've
     * just installed an idle function, we tell AGV it can't touch it)
     */

  agvInit(!Rotating);
    
    /* 
     * agvInit() installs mouse, motion, and keyboard handles, but 
     * we don't care for this example cause we only use right button menu
     */

  agvMakeAxesList(AXES);  /* create AGV axes */

  myGLInit(); 
  MakeDisplayLists();
  MenuInit();

  glutDisplayFunc(display);

  glutMainLoop();
  return 0;             /* ANSI C requires main to return int. */
}
Exemplo n.º 2
0
/**
  * @brief  Apllication Initialisation Routine
  * @param  None
  * @retval : None
  */
void ApplicationInit(void)
{
  /* System Clocks Configuration */
  RCC_Configuration();
  /*Enables the clock to Backup and power interface peripherals    */
  RCC_APB1PeriphClockCmd(RCC_APB1Periph_BKP | RCC_APB1Periph_PWR,ENABLE);
  
  /* SysTick Configuration*/
  SysTickConfig();
  
  /*Initialisation of TFT LCD */
  STM3210B_LCD_Init();
  
  /* Unlock the Flash Program Erase controller */
  FLASH_Unlock();
  /*RTC_NVIC Configuration */
  RTC_NVIC_Configuration();
  
  /* RTC Configuration*/
  RTC_Configuration();
  BKP_RTCOutputConfig(BKP_RTCOutputSource_None);
  
  /* General Purpose I/O Configuration */
  GPIO_Configuration();
  
  /* Battery Removal Emulation   */
  GPIO_SetBits(GPIOC, GPIO_Pin_8);
  
  while(!(GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_13)))
  {
    TamperEvent = 1;
  }
  
  /* Joystick NVIC Configuration  */
  NVIC_JoyStickConfig();

  /* Tamper pin NVIC Configuration  */
  Tamper_NVIC_Configuration();

  /* Configure PVD Supervisor to disable the Tamper Interrupt when voltage drops 
  below 2.5 volts*/
  PWR_PVDCmd(ENABLE);
  PWR_PVDLevelConfig(PWR_PVDLevel_2V5);
  PWR_BackupAccessCmd(ENABLE);

  /* Only JoyStick Sel Interrupt is enabled on startup */
  SelIntExtOnOffConfig(ENABLE);

  /* Tamper FeatureRTC  -   Enable Tamper Interrupt and configure for Low level */
  BKP_ITConfig(ENABLE);

  /* Enable Tamper Pin for Active low level: Tamper level detected for low level*/
  BKP_TamperPinLevelConfig(BKP_TamperPinLevel_Low);

  /* Enable tamper Pin Interrupt */
  BKP_TamperPinCmd(ENABLE);

  /*  Menu Initialisation  */
  MenuInit();
}
Exemplo n.º 3
0
/**
* @description
* This function used for menu display is writed by HuangYuqing
* But it's not used in this system because of there another way to control.
* @param[in] arg pthread args
*/
void *thread_control_surface(void *arg) {
    int ret;
    int fd = -1;
    int err;

    ret = lcd192x64_init();/*init surface port*/
    if (ret) {
        printf("lcd192x64_init fail\n");
        exit(1);
    }

    MenuInit(); /*init menu*/

    fd = UART_File_Open(fd,UART4);/*control port is uart4*/
    if (fd == -1) {
        printf("Open Port Failed!\n");
    }

    do {  
        err = UART_File_Init(fd, 9600, 0, 8, 1, 'N');
        printf("Set Port Exactly!\n");
    }while( FALSE == err||FALSE == fd );

    gcontrol_sur_fd = fd;
    sem_init(&gsem_surface, 0, 0);

    while(1) {
        sem_wait(&gsem_surface);
        input_recv_pro(gcontrol_sur_recv_buf, gcontrol_sur_msg_len);
    }
}
Exemplo n.º 4
0
void MenuSelect(){
	if(MyMenu->Option[MyMenu->Current].Func != NULL){
		MenuChain[openedMenus++] = MyMenu;
		MyMenu->Option[MyMenu->Current].Func();
		MenuInit(MenuChain[--openedMenus]);
		MenuShow();
	}
}
Exemplo n.º 5
0
static int ModulesLoad(WPARAM, LPARAM)
{
	profilePath = Utils_ReplaceVarsT(_T("%miranda_userdata%"));

	MenuInit();
	FoldersInit();
	LoadOptions();

	if (options.backup_types & BT_START)
		mir_forkthread(BackupThread, NULL);
	return 0;
}
Exemplo n.º 6
0
void NandMenu(){
	f_mkdir ("nand");
	MenuInit(&NandOptions);
	MenuShow();

    while (true) {
        u32 pad_state = InputWait();
		if(pad_state & BUTTON_DOWN) MenuNextSelection();
		if(pad_state & BUTTON_UP)   MenuPrevSelection();
		if(pad_state & BUTTON_A)    MenuSelect();
		if(pad_state & BUTTON_B) 	break;
		TryScreenShot();
		MenuShow();
    }
}
Exemplo n.º 7
0
int main(int argc, char** argv) {

    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB);
    glutInitWindowSize(WinWid, WinHei);
    glutInitWindowPosition(100, 200);
    glutCreateWindow("Lesson 08");
    
    glutDisplayFunc(Draw);
    Initsialaize();
    MenuInit();
    glutMainLoop();
    
    return 0;
}
Exemplo n.º 8
0
BOOL
Init(VOID)
{
   USERCONNECT UserCon;
 
   /* Set PEB data */
   NtCurrentPeb()->KernelCallbackTable = apfnDispatch;
   NtCurrentPeb()->PostProcessInitRoutine = NULL;

   NtUserProcessConnect( NtCurrentProcess(),
                         &UserCon,
                         sizeof(USERCONNECT));

   g_ppi = GetWin32ClientInfo()->ppi; // Snapshot PI, used as pointer only!
   g_ulSharedDelta = UserCon.siClient.ulSharedDelta;
   gpsi = SharedPtrToUser(UserCon.siClient.psi);
   gHandleTable = SharedPtrToUser(UserCon.siClient.aheList);
   gHandleEntries = SharedPtrToUser(gHandleTable->handles);

   RtlInitializeCriticalSection(&gcsUserApiHook);
   gfServerProcess = FALSE; // FIXME HAX! Used in CsrClientConnectToServer(,,,,&gfServerProcess);

   //CsrClientConnectToServer(L"\\Windows", 0, NULL, 0, &gfServerProcess);
   //ERR("1 SI 0x%x : HT 0x%x : D 0x%x\n", UserCon.siClient.psi, UserCon.siClient.aheList,  g_ulSharedDelta);

   /* Allocate an index for user32 thread local data. */
   User32TlsIndex = TlsAlloc();
   if (User32TlsIndex != TLS_OUT_OF_INDEXES)
   {
      if (MessageInit())
      {
         if (MenuInit())
         {
            InitializeCriticalSection(&U32AccelCacheLock);
            GdiDllInitialize(NULL, DLL_PROCESS_ATTACH, NULL);
            LoadAppInitDlls();

            return TRUE;
         }
         MessageCleanup();
      }
      TlsFree(User32TlsIndex);
   }

   return FALSE;
}
Exemplo n.º 9
0
void ItemGainMenuInit(Window *window)
{
	int result = Random(100);
	int i = 0;
	int acc = 0;
	MenuInit(window);
	do
	{
		acc += randomItemTable[i];
		if(acc >= result)
		{
			typeGained = i;
			AddItem(i);
			break;
		}
		++i;      
	} while (i < ITEM_TYPE_COUNT);
}
Exemplo n.º 10
0
int main(){
	Initialize();
	DrawString(TOP_SCREEN, "SUPPORT THE ORIGINAL, NOT THE IMITATION!", 75, 240-10, GREY, BLACK);
	//7.X Keys stuff
	File KeyFile;
	if(FileOpen(&KeyFile, "/slot0x25KeyX.bin", 0)){
		u8 keyX[16];
		FileRead(&KeyFile, keyX, 16, 0);
		FileClose(&KeyFile);
		setup_aeskeyX(0x25, keyX);
		DrawString(TOP_SCREEN, " NewKeyX ", 0, 240-8, GREEN, BLACK);
	}else{
		if(GetSystemVersion() < 3){
			ConsoleInit();
			print("WARNING:\n\nCannot find slot0x25KeyX.bin.\nSome titles decryption will fail,\nand some some EmuNANDs will not boot.\n\nPress A to continue...\n");
			ConsoleShow();
			WaitForButton(BUTTON_A);
		}
		DrawString(TOP_SCREEN, " NewKeyX ", 0, 240-8, RED, BLACK);
	}
	DrawString(TOP_SCREEN, " EmuNAND ", 0, 240-16, checkEmuNAND() ? GREEN : RED, BLACK);

	//That's the Main Menu initialization, easy and cool
	MenuInit(&MainMenu);
	MenuShow();

    while (true) {
		DrawString(TOP_SCREEN,  "[SELECT] Reboot", 349-18*8, 181-24-8, RED, BLACK);
		DrawString(TOP_SCREEN,  "[START]  Shutdown", 349-18*8, 181-24, RED, BLACK);
        u32 pad_state = InputWait();
		if(pad_state & BUTTON_DOWN) 	MenuNextSelection();
		if(pad_state & BUTTON_UP)   	MenuPrevSelection();
		if(pad_state & BUTTON_A)    	MenuSelect();
		if(pad_state & BUTTON_SELECT)	returnHomeMenu();
		if(pad_state & BUTTON_START)	ShutDown();
		TryScreenShot();
		MenuShow();
    }

    FSDeInit();
    return 0;
}
Exemplo n.º 11
0
int main(){
	if (Initialize())
		while (1);

	//7.X Keys stuff
	File KeyFile;
	const char *keyfile = "/slot0x25KeyX.bin";
	if(FileOpen(&KeyFile, keyfile, 0)){
		uint8_t keyX[16];
		FileRead(&KeyFile, keyX, 16, 0);
		FileClose(&KeyFile);
		setup_aeskeyX(0x25, keyX);
	}else{
		if (sysver < 7) {
			ConsoleInit();
			ConsoleSetTitle(strings[STR_WARNING]);
			print(strings[STR_ERROR_OPENING], keyfile);
			print(strings[STR_WARNING_KEYFILE]);
			print(strings[STR_PRESS_BUTTON_ACTION], strings[STR_BUTTON_A], strings[STR_CONTINUE]);
			ConsoleShow();
			WaitForButton(BUTTON_A);
		}
	}

	//That's the Main Menu initialization, easy and cool
	OpenAnimation();
	MenuInit(&MainMenu);
	MenuShow();
	while (true) {
		uint32_t pad_state = InputWait();
		if (pad_state & (BUTTON_DOWN | BUTTON_RIGHT | BUTTON_R1)) MenuNextSelection(); //I try to support every theme style
		if (pad_state & (BUTTON_UP   | BUTTON_LEFT  | BUTTON_L1)) MenuPrevSelection();
		if (pad_state & BUTTON_A)    	{ OpenAnimation(); MenuSelect(); }
		if (pad_state & BUTTON_SELECT)	{ fadeOut(); ShutDown(); }
		if (pad_state & BUTTON_START)	{ fadeOut(); returnHomeMenu(); }
		TryScreenShot();
		MenuShow();
	}

	FSDeInit();
	return 0;
}
Exemplo n.º 12
0
/**
  * @brief  This function is executed after wakeup from STOP mode
  * @param  None
  * @retval : None
  */
void ReturnFromStopMode(void)
{
  /* RCC Configuration has to be called after waking from STOP Mode*/
  RCC_Configuration();
  /*Enables the clock to Backup and power interface peripherals after Wake Up */
  RCC_APB1PeriphClockCmd(RCC_APB1Periph_BKP | RCC_APB1Periph_PWR,ENABLE);
  /* Enable access to Backup Domain */
  PWR_BackupAccessCmd(ENABLE);
  /* LCD Reinitialisation */
  STM3210B_LCD_Init();
  /* LED D2 goes off */
  GPIO_ResetBits(GPIOC, GPIO_Pin_9); 
  /* Enable Sel interrupt */
  SelIntExtOnOffConfig(ENABLE);
  /* Menu initialisation */
  MenuInit();
  /* Time display enable */
  TimeDateDisplay=0;
  /* Since Sel is used to exit from STOP mode, hence when STOP mode is exited
  initial value of MenuLevelPointer is 0 */
  MenuLevelPointer=0xFF;
}
Exemplo n.º 13
0
Arquivo: main.c Projeto: Golui/rxTools
int main(){
	Initialize();
	//7.X Keys stuff
	File KeyFile;
	if(FileOpen(&KeyFile, "/slot0x25KeyX.bin", 0)){
		u8 keyX[16];
		FileRead(&KeyFile, keyX, 16, 0);
		FileClose(&KeyFile);
		setup_aeskeyX(0x25, keyX);
	}else{
		if(GetSystemVersion() < 3){
			ConsoleInit();
			ConsoleSetTitle("          WARNING");
			print("WARNING:\n\nCannot find slot0x25KeyX.bin. If\nyour firmware version is less than\n7.X, some titles decryption will\nfail, and some EmuNANDs will not\nboot.\n\nPress A to continue...\n");
			ConsoleShow();
			WaitForButton(BUTTON_A);
		}
	}

	//That's the Main Menu initialization, easy and cool
	MenuInit(&MainMenu);
	MenuShow();

	while (true) {
		u32 pad_state = InputWait();
		if (pad_state & (BUTTON_DOWN | BUTTON_RIGHT | BUTTON_R1)) MenuNextSelection(); //I try to support every theme style
		if (pad_state & (BUTTON_UP   | BUTTON_LEFT  | BUTTON_L1)) MenuPrevSelection();
		if(pad_state & BUTTON_A)    	MenuSelect();
		if(pad_state & BUTTON_SELECT)	ShutDown();
		if(pad_state & BUTTON_START)	returnHomeMenu();
		TryScreenShot();
		MenuShow();
	}

	FSDeInit();
	return 0;
}
Exemplo n.º 14
0
void restoreCoolFiles(){
    int nandtype = NandSwitch();
    if(nandtype == -1){
        return;
    }
    selectedFile = -1;
    MenuInit(&CoolFilesMenu);
    MenuShow();
    while (true) {
        u32 pad_state = InputWait();
		if(pad_state & BUTTON_DOWN) MenuNextSelection();
		if(pad_state & BUTTON_UP)   MenuPrevSelection();
		if(pad_state & BUTTON_A)    { MenuSelect(); break; }
		if(pad_state & BUTTON_B) 	break;
		TryScreenShot();
		MenuShow();
    }
    if(selectedFile == -1) return;
    ConsoleInit();
    ConsoleSetTitle("File Inject : %s", CoolFiles[selectedFile].name);
    char dest[256];
    sprintf(tmpstr, "rxTools/%s", CoolFiles[selectedFile].name);
    sprintf(dest, "%d:%s", nandtype + 1, CoolFiles[selectedFile].path);
    print("Injecting...\n"); ConsoleShow();
    int res = FileCopy(dest, tmpstr);
    char* showres;
    switch(res){
        case 1 : showres = "Success!"; break;
        case -1 : showres = "Cannot write to file!"; break;
        case -2 : showres = "Cannot read from file!"; break;
        default : showres = "Failure!"; break;
    }
    print(showres); print("\n");
    print("\nPress A to exit\n");
	ConsoleShow();
	WaitForButton(BUTTON_A);
}
Exemplo n.º 15
0
void NewFloorMenuInit(Window *window)
{
	MenuInit(window);
	IncrementFloor();
}
Exemplo n.º 16
0
//*****************************************************************************
//
// Initialize and operate the data logger.
//
//*****************************************************************************
int
main(void)
{
    tContext sDisplayContext, sBufferContext;
    uint32_t ui32HibIntStatus, ui32SysClock, ui32LastTickCount;
    bool bSkipSplash;
    uint8_t ui8ButtonState, ui8ButtonChanged;
    uint_fast8_t ui8X, ui8Y;


    //
    // Enable lazy stacking for interrupt handlers.  This allows floating-point
    // instructions to be used within interrupt handlers, but at the expense of
    // extra stack usage.
    //
    MAP_FPULazyStackingEnable();

    //
    // Set the clocking to run at 50 MHz.
    //
    MAP_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ |
                       SYSCTL_OSC_MAIN);
    ui32SysClock = MAP_SysCtlClockGet();

    //
    // Initialize locals.
    //
    bSkipSplash = false;
    ui32LastTickCount = 0;

    //
    // Initialize the data acquisition module.  This initializes the ADC
    // hardware.
    //
    AcquireInit();

    //
    // Enable access to  the hibernate peripheral.  If the hibernate peripheral
    // was already running then this will have no effect.
    //
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_HIBERNATE);

    //
    // Check to see if the hiberate module is already active and if so then
    // read the saved configuration state.  If both are okay, then proceed
    // to check and see if we are logging data using sleep mode.
    //
    if(HibernateIsActive() && !GetSavedState(&g_sConfigState))
    {
        //
        // Read the status of the hibernate module.
        //
        ui32HibIntStatus = HibernateIntStatus(1);

        //
        // If this is a pin wake, that means the user pressed the select
        // button and we should terminate the sleep logging.  In this case
        // we will fall out of this conditional section, and go through the
        // normal startup below, but skipping the splash screen so the user
        // gets immediate response.
        //
        if(ui32HibIntStatus & HIBERNATE_INT_PIN_WAKE)
        {
            //
            // Clear the interrupt flag so it is not seen again until another
            // wake.
            //
            HibernateIntClear(HIBERNATE_INT_PIN_WAKE);
            bSkipSplash = true;
        }

        //
        // Otherwise if we are waking from hibernate and it was not a pin
        // wake, then it must be from RTC match.  Check to see if we are
        // sleep logging and if so then go through an abbreviated startup
        // in order to collect the data and go back to sleep.
        //
        else if(g_sConfigState.ui32SleepLogging &&
                (ui32HibIntStatus & HIBERNATE_INT_RTC_MATCH_0))
        {
            //
            // Start logger and pass the configuration.  The logger should
            // configure itself to take one sample.
            //
            AcquireStart(&g_sConfigState);
            g_iLoggerState = eSTATE_LOGGING;

            //
            // Enter a forever loop to run the acquisition.  This will run
            // until a new sample has been taken and stored.
            //
            while(!AcquireRun())
            {
            }

            //
            // Getting here means that a data acquisition was performed and we
            // can now go back to sleep.  Save the configuration and then
            // activate the hibernate.
            //
            SetSavedState(&g_sConfigState);

            //
            // Set wake condition on pin-wake or RTC match.  Then put the
            // processor in hibernation.
            //
            HibernateWakeSet(HIBERNATE_WAKE_PIN | HIBERNATE_WAKE_RTC);
            HibernateRequest();

            //
            // Hibernating takes a finite amount of time to occur, so wait
            // here forever until hibernate activates and the processor
            // power is removed.
            //
            for(;;)
            {
            }
        }

        //
        // Otherwise, this was not a pin wake, and we were not sleep logging,
        // so just fall out of this conditional and go through the normal
        // startup below.
        //
    }
    else
    {
        //
        // In this case, either the hibernate module was not already active, or
        // the saved configuration was not valid.  Initialize the configuration
        // to the default state and then go through the normal startup below.
        //
        GetDefaultState(&g_sConfigState);
    }

    //
    // Enable the Hibernate module to run.
    //
    HibernateEnableExpClk(SysCtlClockGet());

    //
    // The hibernate peripheral trim register must be set per silicon
    // erratum 2.1
    //
    HibernateRTCTrimSet(0x7FFF);

    //
    // Start the RTC running.  If it was already running then this will have
    // no effect.
    //
    HibernateRTCEnable();

    //
    // In case we were sleep logging and are now finished (due to user
    // pressing select button), then disable sleep logging so it doesnt
    // try to start up again.
    //
    g_sConfigState.ui32SleepLogging = 0;
    SetSavedState(&g_sConfigState);

    //
    // Initialize the display driver.
    //
    CFAL96x64x16Init();

    //
    // Initialize the buttons driver.
    //
    ButtonsInit();

    //
    // Pass the restored state to the menu system.
    //
    MenuSetState(&g_sConfigState);

    //
    // Enable the USB peripheral
    //
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_USB0);

    //
    // Configure the required pins for USB operation.
    //
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
    MAP_GPIOPinConfigure(GPIO_PG4_USB0EPEN);
    MAP_GPIOPinTypeUSBDigital(GPIO_PORTG_BASE, GPIO_PIN_4);
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOL);
    MAP_GPIOPinTypeUSBAnalog(GPIO_PORTL_BASE, GPIO_PIN_6 | GPIO_PIN_7);
    MAP_GPIOPinTypeUSBAnalog(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1);

    //
    // Erratum workaround for silicon revision A1.  VBUS must have pull-down.
    //
    if(CLASS_IS_BLIZZARD && REVISION_IS_A1)
    {
        HWREG(GPIO_PORTB_BASE + GPIO_O_PDR) |= GPIO_PIN_1;
    }

    //
    // Initialize the USB stack mode and pass in a mode callback.
    //
    USBStackModeSet(0, eUSBModeOTG, ModeCallback);

    //
    // Initialize the stack to be used with USB stick.
    //
    USBStickInit();

    //
    // Initialize the stack to be used as a serial device.
    //
    USBSerialInit();

    //
    // Initialize the USB controller for dual mode operation with a 2ms polling
    // rate.
    //
    USBOTGModeInit(0, 2000, g_pui8HCDPool, HCD_MEMORY_SIZE);

    //
    // Initialize the menus module.  This module will control the user
    // interface menuing system.
    //
    MenuInit(WidgetActivated);

    //
    // Configure SysTick to periodically interrupt.
    //
    g_ui32TickCount = 0;
    MAP_SysTickPeriodSet(ui32SysClock / CLOCK_RATE);
    MAP_SysTickIntEnable();
    MAP_SysTickEnable();

    //
    // Initialize the display context and another context that is used
    // as an offscreen drawing buffer for display animation effect
    //
    GrContextInit(&sDisplayContext, &g_sCFAL96x64x16);
    GrContextInit(&sBufferContext, &g_sOffscreenDisplayA);

    //
    // Show the splash screen if we are not skipping it.  The only reason to
    // skip it is if the application was in sleep-logging mode and the user
    // just waked it up with the select button.
    //
    if(!bSkipSplash)
    {
        const uint8_t *pui8SplashLogo = g_pui8Image_TI_Black;

        //
        // Draw the TI logo on the display.  Use an animation effect where the
        // logo will "slide" onto the screen.  Allow select button to break
        // out of animation.
        //
        for(ui8X = 0; ui8X < 96; ui8X++)
        {
            if(ButtonsPoll(0, 0) & SELECT_BUTTON)
            {
                break;
            }
            GrImageDraw(&sDisplayContext, pui8SplashLogo, 95 - ui8X, 0);
        }

        //
        // Leave the logo on the screen for a long duration.  Monitor the
        // buttons so that if the user presses the select button, the logo
        // display is terminated and the application starts immediately.
        //
        while(g_ui32TickCount < 400)
        {
            if(ButtonsPoll(0, 0) & SELECT_BUTTON)
            {
                break;
            }
        }

        //
        // Extended splash sequence
        //
        if(ButtonsPoll(0, 0) & UP_BUTTON)
        {
            for(ui8X = 0; ui8X < 96; ui8X += 4)
            {
                GrImageDraw(&sDisplayContext,
                            g_ppui8Image_Splash[(ui8X / 4) & 3],
                            (int32_t)ui8X - 96L, 0);
                GrImageDraw(&sDisplayContext, pui8SplashLogo, ui8X, 0);
                MAP_SysCtlDelay(ui32SysClock / 12);
            }
            MAP_SysCtlDelay(ui32SysClock / 3);
            pui8SplashLogo = g_ppui8Image_Splash[4];
            GrImageDraw(&sDisplayContext, pui8SplashLogo, 0, 0);
            MAP_SysCtlDelay(ui32SysClock / 12);
        }

        //
        // Draw the initial menu into the offscreen buffer.
        //
        SlideMenuDraw(&g_sMenuWidget, &sBufferContext, 0);

        //
        // Now, draw both the TI logo splash screen (from above) and the initial
        // menu on the screen at the same time, moving the coordinates so that
        // the logo "slides" off the display and the menu "slides" onto the
        // display.
        //
        for(ui8Y = 0; ui8Y < 64; ui8Y++)
        {
            GrImageDraw(&sDisplayContext, pui8SplashLogo, 0, -ui8Y);
            GrImageDraw(&sDisplayContext, g_pui8OffscreenBufA, 0, 63 - ui8Y);
        }
    }

    //
    // Add the menu widget to the widget tree and send an initial paint
    // request.
    //
    WidgetAdd(WIDGET_ROOT, (tWidget *)&g_sMenuWidget);
    WidgetPaint(WIDGET_ROOT);

    //
    // Set the focus handle to the menu widget.  Any button events will be
    // sent to this widget
    //
    g_ui32KeyFocusWidgetHandle = (uint32_t)&g_sMenuWidget;

    //
    // Forever loop to run the application
    //
    while(1)
    {

        //
        // Each time the timer tick occurs, process any button events.
        //
        if(g_ui32TickCount != ui32LastTickCount)
        {
            //
            // Remember last tick count
            //
            ui32LastTickCount = g_ui32TickCount;

            //
            // Read the debounced state of the buttons.
            //
            ui8ButtonState = ButtonsPoll(&ui8ButtonChanged, 0);

            //
            // Pass any button presses through to the widget message
            // processing mechanism.  The widget that has the button event
            // focus (probably the menu widget) will catch these button events.
            //
            if(BUTTON_PRESSED(SELECT_BUTTON, ui8ButtonState, ui8ButtonChanged))
            {
                SendWidgetKeyMessage(WIDGET_MSG_KEY_SELECT);
            }
            if(BUTTON_PRESSED(UP_BUTTON, ui8ButtonState, ui8ButtonChanged))
            {
                SendWidgetKeyMessage(WIDGET_MSG_KEY_UP);
            }
            if(BUTTON_PRESSED(DOWN_BUTTON, ui8ButtonState, ui8ButtonChanged))
            {
                SendWidgetKeyMessage(WIDGET_MSG_KEY_DOWN);
            }
            if(BUTTON_PRESSED(LEFT_BUTTON, ui8ButtonState, ui8ButtonChanged))
            {
                SendWidgetKeyMessage(WIDGET_MSG_KEY_LEFT);
            }
            if(BUTTON_PRESSED(RIGHT_BUTTON, ui8ButtonState, ui8ButtonChanged))
            {
                SendWidgetKeyMessage(WIDGET_MSG_KEY_RIGHT);
            }
        }

        //
        // Tell the OTG library code how much time has passed in milliseconds
        // since the last call.
        //
        USBOTGMain(GetTickms());

        //
        // Call functions as needed to keep the host or device mode running.
        //
        if(g_iCurrentUSBMode == eUSBModeDevice)
        {
            USBSerialRun();
        }
        else if(g_iCurrentUSBMode == eUSBModeHost)
        {
            USBStickRun();
        }

        //
        // If in the logging state, then call the logger run function.  This
        // keeps the data acquisition running.
        //
        if((g_iLoggerState == eSTATE_LOGGING) ||
           (g_iLoggerState == eSTATE_VIEWING))
        {
            if(AcquireRun() && g_sConfigState.ui32SleepLogging)
            {
                //
                // If sleep logging is enabled, then at this point we have
                // stored the first data item, now save the state and start
                // hibernation.  Wait for the power to be cut.
                //
                SetSavedState(&g_sConfigState);
                HibernateWakeSet(HIBERNATE_WAKE_PIN | HIBERNATE_WAKE_RTC);
                HibernateRequest();
                for(;;)
                {
                }
            }

            //
            // If viewing instead of logging then request a repaint to keep
            // the viewing window updated.
            //
            if(g_iLoggerState == eSTATE_VIEWING)
            {
                WidgetPaint(WIDGET_ROOT);
            }
        }

        //
        // If in the saving state, then save data from flash storage to
        // USB stick.
        //
        if(g_iLoggerState == eSTATE_SAVING)
        {
            //
            // Save data from flash to USB
            //
            FlashStoreSave();

            //
            // Return to idle state
            //
            g_iLoggerState = eSTATE_IDLE;
        }

        //
        // If in the erasing state, then erase the data stored in flash.
        //
        if(g_iLoggerState == eSTATE_ERASING)
        {
            //
            // Save data from flash to USB
            //
            FlashStoreErase();

            //
            // Return to idle state
            //
            g_iLoggerState = eSTATE_IDLE;
        }

        //
        // If in the flash reporting state, then show the report of the amount
        // of used and free flash memory.
        //
        if(g_iLoggerState == eSTATE_FREEFLASH)
        {
            //
            // Report free flash space
            //
            FlashStoreReport();

            //
            // Return to idle state
            //
            g_iLoggerState = eSTATE_IDLE;
        }

        //
        // If we are exiting the clock setting widget, that means that control
        // needs to be given back to the menu system.
        //
        if(g_iLoggerState == eSTATE_CLOCKEXIT)
        {
            //
            // Give the button event focus back to the menu system
            //
            g_ui32KeyFocusWidgetHandle = (uint32_t)&g_sMenuWidget;

            //
            // Send a button event to the menu widget that means the left
            // key was pressed.  This signals the menu widget to deactivate
            // the current child widget (which was the clock setting wigdet).
            // This will cause the menu widget to slide the clock set widget
            // off the screen and resume control of the display.
            //
            SendWidgetKeyMessage(WIDGET_MSG_KEY_LEFT);
            g_iLoggerState = eSTATE_IDLE;
        }

        //
        // Process any new messages that are in the widget queue.  This keeps
        // the user interface running.
        //
        WidgetMessageQueueProcess();
    }
}
Exemplo n.º 17
0
void dumpCoolFiles()
{
	int nandtype = NandSwitch();
	if (nandtype == UNK_NAND) return;

	selectedFile = -1;
	MenuInit(&CoolFilesMenu);
	MenuShow();

	while (true)
	{
		uint32_t pad_state = InputWait();
		if (pad_state & BUTTON_DOWN) MenuNextSelection();
		if (pad_state & BUTTON_UP) MenuPrevSelection();
		if (pad_state & BUTTON_A) { MenuSelect(); break; }
		if (pad_state & BUTTON_B) break;
		TryScreenShot();
		MenuShow();
	}

	if (selectedFile == -1) return;
	ConsoleInit();
	ConsoleSetTitle(strings[STR_DUMP], strings[STR_FILES]);

	char dest[256], tmpstr[sizeof(dest)];
	wchar_t wsrc[sizeof(tmpstr)];
	sprintf(dest, "rxTools/%s", CoolFiles[selectedFile].name);
	sprintf(tmpstr, "%d:%s/%s", nandtype, CoolFiles[selectedFile].path, CoolFiles[selectedFile].name);
	mbstowcs(wsrc, tmpstr, sizeof(tmpstr));
	print(strings[STR_DUMPING], wsrc, dest);
	ConsoleShow();

	unsigned int res = FSFileCopy(dest, tmpstr);
	if (res != 0 && (selectedFile == 1 || selectedFile == 2)){
		if (selectedFile == 1)
		{
			/* Fix for SecureInfo_B */
			sprintf(dest, "rxTools/%.11s%c", CoolFiles[selectedFile].name, 'B');
			sprintf(tmpstr, "%d:%s/%.11s%c", nandtype, CoolFiles[selectedFile].path, CoolFiles[selectedFile].name, 'B');
		}
		else if (selectedFile == 2)
		{
			/* Fix for LocalFriendCodeSeed_A */
			sprintf(dest, "rxTools/%.20s%c", CoolFiles[selectedFile].name, 'A');
			sprintf(tmpstr, "%d:%s/%.20s%c", nandtype, CoolFiles[selectedFile].path, CoolFiles[selectedFile].name, 'A');
		}
		mbstowcs(wsrc, tmpstr, sizeof(tmpstr));
		print(strings[STR_FAILED]);
		print(strings[STR_DUMPING], wsrc, dest);
		ConsoleShow();
		res = FSFileCopy(dest, tmpstr);
	}

	switch ((res >> 8) & 0xFF)
	{
		case 0:
			print(strings[STR_COMPLETED]);
			break;
		case 1:
			print(strings[STR_ERROR_OPENING], tmpstr);
			break;
		case 2:
			print(strings[STR_ERROR_CREATING], dest);
			break;
		case 3:
		case 4:
			print(strings[STR_ERROR_READING], tmpstr);
			break;
		case 5:
		case 6:
			print(strings[STR_ERROR_WRITING], dest);
			break;
		default:
			print(strings[STR_FAILED]);
			break;
	}

	print(strings[STR_PRESS_BUTTON_ACTION], strings[STR_BUTTON_A], strings[STR_CONTINUE]);
	ConsoleShow();
	WaitForButton(BUTTON_A);
}
Exemplo n.º 18
0
__attribute__((section(".text.start"), noreturn)) void _start()
{
	static const TCHAR fontPath[] = _T("") SYS_PATH "/" FONT_NAME;
	void *fontBuf;
	UINT btr, br;
	int r;
	FIL f;

	// Enable TMIO IRQ
	*(volatile uint32_t *)0x10001000 = 0x00010000;

	preloadStringsA();

	if (!FSInit()) {
		DrawString(BOT_SCREEN, strings[STR_FAILED],
			BOT_SCREEN_WIDTH / 2, SCREEN_HEIGHT - FONT_HEIGHT, RED, BLACK);
		while (1);
	}

	/*
	set_loglevel(ll_info);
	log(ll_info, "Initializing rxTools...");
	*/

	setConsole();

	fontIsLoaded = 0;
	r = f_open(&f, fontPath, FA_READ);
	if (r == FR_OK) {
		btr = f_size(&f);
		fontBuf = __builtin_alloca(btr);
		r = f_read(&f, fontBuf, btr, &br);
		if (r == FR_OK)
			fontIsLoaded = 1;

		f_close(&f);
		fontaddr = fontBuf;
	}

	if (fontIsLoaded)
		preloadStringsU();
	else
		warn(L"Failed to load " FONT_NAME ": %d\n", r);

	install();
	readCfg();

	r = loadStrings();
	if (r)
		warn(L"Failed to load strings: %d\n", r);

	drawTop();

	if (!cfgs[CFG_GUI].val.i && HID_STATE & BUTTON_L1)
		rxMode(cfgs[CFG_ABSYSN].val.i ? 0 : 1);

	if (sysver < 7) {
		r = initKeyX();
		if (r != FR_OK)
			warn(L"Failed to load key X for slot 0x25\n"
				"  Code: %d\n"
				"  If your firmware version is less\n"
				"  than 7.X, some titles decryption\n"
				"  will fail, and some EmuNANDs\n"
				"  will not boot.\n", r);
	}

	if (warned) {
		warn(strings[STR_PRESS_BUTTON_ACTION],
			strings[STR_BUTTON_A], strings[STR_CONTINUE]);
		WaitForButton(BUTTON_A);
	}

	OpenAnimation();
	MenuInit(&MainMenu);
	MenuShow();
	mainLoop();
}
Exemplo n.º 19
0
void menu()
{
	MenuInit();
	//MusicInit("./textures/musicOn.jpg");
	g_Input.gameOff();
	MenuRender();
	MusicRender();

	while(!g_Input.getGame())
	{
		int64 start = s3eTimerGetMs();
		while ((s3eTimerGetMs() - start) < MS_PER_FRAME)
        {
			
            int32 yield = (int32) (MS_PER_FRAME - (s3eTimerGetMs() - start));
            if (yield<0)
                break;
            s3eDeviceYield(yield);
        }
		if (g_Input.getTouchCount() != 0)
		{
			int x = g_Input.getTouch(0)->x;
			int y = g_Input.getTouch(0)->y;

			if (x <= 750 && x >= 500 && y <= 400 && y >= 200)
			{
				if (g_Input.getSound())
				{
					MusicShutDown();
					MusicInit("./textures/musicOf.jpg");
					MusicRender();
					g_Input.soundOff();
				}
				else
				{
					MusicShutDown();
					MusicInit("./textures/musicOn.jpg");
					MusicRender();
					g_Input.soundOn();
				}
			}

			if (x <= 1270 && x >= 500 && y <= 190 && y >= 10)
				g_Input.gameOn();
		}
	}
	//MusicShutDown();
	//MenuShutDown();
    IwGxSetColClear(0xff, 0xff, 0xff, 0xff);
    IwGxPrintSetColour(128, 128, 128);
	g_Input.initTimer();	
	g_Input.setTotalTime();
	g_Input.setPosInitY(g_Input.getAccelerometerY());
	
	SplashInit();
	SplashUpdate("loading");
	SplashRender();
	MenuShutDown();
	if (initMenu)
	{
		//Creating objects
		corazon = new corazones("corazones", 64, 64, -100, 1,2,false);
		for (int i=0; i<10; i++)
		{
			garras[i] = new claws("claws", 128, 128, -150,1,2,false);
		}
		maxiCoin = new Coin("./textures/monedas200pts.png", 128, 128, -150,1,2,false);
		for (int j=0; j<20; j++)
		{
			miniCoins[j] = new MiniCoin("coins", 64, 64, -100,1,2,true);
		}
		for (int i=0; i<10; i++)
		{
			tnts[i] = new Tnt("tnts", 128, 128, -150,1,2,false);
		}
		tank = new Tank();
		tank->Init("./textures/tank.png", 256, 256, -300,1,2,false);
		chuletas = new Chuletas();
		chuletas->Init("./textures/chuletas.png", 512, 512, -600,1,2,false);
	}
	SplashShutDown();
	//SplashInit();
	//SplashUpdate("go");
	ciclo();
}
Exemplo n.º 20
0
BOOL
WINAPI
ClientThreadSetupHelper(BOOL IsCallback)
{
    /*
     * Normally we are called by win32k so the win32 thread pointers
     * should be valid as they are set in win32k::InitThreadCallback.
     */
    PCLIENTINFO ClientInfo = GetWin32ClientInfo();
    BOOLEAN IsFirstThread = _InterlockedExchange8((PCHAR)&gfFirstThread, FALSE);

    TRACE("In ClientThreadSetup(IsCallback == %s, gfServerProcess = %s, IsFirstThread = %s)\n",
          IsCallback ? "TRUE" : "FALSE", gfServerProcess ? "TRUE" : "FALSE", IsFirstThread ? "TRUE" : "FALSE");

    if (IsFirstThread)
        GdiProcessSetup();

    /* Check for already initialized thread, and bail out if so */
    if (ClientInfo->CI_flags & CI_INITTHREAD)
    {
        ERR("ClientThreadSetup: Thread already initialized.\n");
        return FALSE;
    }

    /*
     * CSRSS couldn't use user32::DllMain CSR server-to-server call to connect
     * to win32k. So it is delayed to a manually-call to ClientThreadSetup.
     * Also this needs to be done only for the first thread (since the connection
     * is per-process).
     */
    if (gfServerProcess && IsFirstThread)
    {
        NTSTATUS Status;
        USERCONNECT UserCon;

        RtlZeroMemory(&UserCon, sizeof(UserCon));

        /* Minimal setup of the connect info structure */
        UserCon.ulVersion = USER_VERSION;

        /* Connect to win32k */
        Status = NtUserProcessConnect(NtCurrentProcess(),
                                      &UserCon,
                                      sizeof(UserCon));
        if (!NT_SUCCESS(Status)) return FALSE;

        /* Retrieve data */
        g_ppi = ClientInfo->ppi; // Snapshot PI, used as pointer only!
        g_ulSharedDelta = UserCon.siClient.ulSharedDelta;
        gpsi = SharedPtrToUser(UserCon.siClient.psi);
        gHandleTable = SharedPtrToUser(UserCon.siClient.aheList);
        gHandleEntries = SharedPtrToUser(gHandleTable->handles);
        gSharedInfo = UserCon.siClient;

        // ERR("1 SI 0x%x : HT 0x%x : D 0x%x\n", UserCon.siClient.psi, UserCon.siClient.aheList,  g_ulSharedDelta);
    }

    TRACE("Checkpoint (register PFN)\n");
    if (!RegisterClientPFN())
    {
        ERR("RegisterClientPFN failed\n");
        return FALSE;
    }

    /* Mark this thread as initialized */
    ClientInfo->CI_flags |= CI_INITTHREAD;

    /* Initialization that should be done once per process */
    if (IsFirstThread)
    {
        TRACE("Checkpoint (Allocating TLS)\n");

        /* Allocate an index for user32 thread local data */
        User32TlsIndex = TlsAlloc();
        if (User32TlsIndex == TLS_OUT_OF_INDEXES)
            return FALSE;

        // HAAAAAAAAAACK!!!!!!
        // ASSERT(gpsi);
        if (!gpsi) ERR("AAAAAAAAAAAHHHHHHHHHHHHHH!!!!!!!! gpsi == NULL !!!!\n");
        if (gpsi)
        {
        TRACE("Checkpoint (MessageInit)\n");

        if (MessageInit())
        {
            TRACE("Checkpoint (MenuInit)\n");
            if (MenuInit())
            {
                TRACE("Checkpoint initialization done OK\n");
                InitializeCriticalSection(&U32AccelCacheLock);
                LoadAppInitDlls();
                return TRUE;
            }
            MessageCleanup();
        }

        TlsFree(User32TlsIndex);
        return FALSE;
        }
    }

    return TRUE;
}
Exemplo n.º 21
0
/**
  * @brief  Calibration of External crystal oscillator auto(through Timer
  *   
  * @param  None
  * @retval : None
  */
void AutoClockCalibration(void)
{
  RCC_ClocksTypeDef ClockValue;
  uint16_t TimerPrescalerValue=0x0003;
  uint16_t CountWait;
  uint16_t DeviationInteger;
  uint32_t CalibrationTimer;
  float f32_Deviation;
  TIM_ICInitTypeDef  TIM_ICInitStructure;
  
  TIM_DeInit(TIM2);
  BKP_TamperPinCmd(DISABLE);
  BKP_RTCOutputConfig(BKP_RTCOutputSource_CalibClock);
  
  /* TIM2 configuration: PWM Input mode ------------------------
     The external signal is connected to TIM2 CH2 pin (PA.01),
     The Rising edge is used as active edge,
     The TIM2 CCR2 is used to compute the frequency value
     The TIM2 CCR1 is used to compute the duty cycle value
  ------------------------------------------------------------ */
  TIM_PrescalerConfig(TIM2,TimerPrescalerValue,TIM_PSCReloadMode_Immediate);
  TIM_ICInitStructure.TIM_Channel = TIM_Channel_2;
  TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Rising;
  TIM_ICInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI;
  TIM_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV1;
  TIM_ICInitStructure.TIM_ICFilter = 0x00;
  TIM_PWMIConfig(TIM2, &TIM_ICInitStructure);
  TIM_ICInit(TIM2, &TIM_ICInitStructure);
  /* Select the TIM2 Input Trigger: TI2FP2 */
  TIM_SelectInputTrigger(TIM2, TIM_TS_TI2FP2);
  /* Select the slave Mode: Reset Mode */
  TIM_SelectSlaveMode(TIM2, TIM_SlaveMode_Reset);
  /* Enable the Master/Slave Mode */
  TIM_SelectMasterSlaveMode(TIM2, TIM_MasterSlaveMode_Enable);
  /* TIM enable Counter */
  TIM_Cmd(TIM2, ENABLE);
  LCD_Clear(Blue2);
  LCD_DisplayString(Line4,Column1,"Please Wait.....");
  /* Wait for 2 seconds */
  CalibrationTimer = RTC_GetCounter();
 
  while((RTC_GetCounter() - CalibrationTimer) < 2)
  {
  }
  
  RCC_GetClocksFreq(&ClockValue);
  TimerFrequency=(ClockValue.PCLK1_Frequency * 2)/(TimerPrescalerValue+1);
   /* Enable the CC2 Interrupt Request */
  TIM_ITConfig(TIM2, TIM_IT_CC2, ENABLE);
   /* Wait for 2 seconds */
  CalibrationTimer = RTC_GetCounter();
  
  while((RTC_GetCounter() - CalibrationTimer) < 2)
  {
  }

  if(!(TIM_GetFlagStatus(TIM2, TIM_FLAG_CC1)))
   /* There is no signal at the timer TIM2 peripheral input */
  {
    LCD_Clear(Blue2);
    LCD_DisplayString(Line3,Column0,"Please connect wire");
    LCD_DisplayString(Line4,Column0,"link between PC13");
    LCD_DisplayString(Line5,Column0,"and PA1");
    LCD_DisplayString(Line7,Column0,"No calibration done");
  }
  else
  {
    /* Calulate Deviation in ppm  using the formula :
    Deviation in ppm = (Deviation from 511.968/511.968)*1 million*/
    if(f32_Frequency > 511.968)
    {
      f32_Deviation=((f32_Frequency-511.968)/511.968)*1000000;
    }
    else
    {
      f32_Deviation=((511.968-f32_Frequency)/511.968)*1000000;
    }
     DeviationInteger = (uint16_t)f32_Deviation;
    
    if(f32_Deviation >= (DeviationInteger + 0.5))
    {
      DeviationInteger = ((uint16_t)f32_Deviation)+1;
    }
    
   CountWait=0;

   /* Frequency deviation in ppm should be les than equal to 121 ppm*/
   if(DeviationInteger <= 121)
   {
     while(CountWait<128)
     {
       if(CalibrationPpm[CountWait] == DeviationInteger)
       break;
       CountWait++;
     }

     BKP_SetRTCCalibrationValue(CountWait);
     LCD_Clear(Blue2);
     LCD_DisplayString(Line4,Column1,"Calibration Value");
     LCD_DisplayChar(Line5,Column10,(CountWait%10)+0x30);
     CountWait=CountWait/10;
     LCD_DisplayChar(Line5,Column9,(CountWait%10)+0x30);
     CountWait=CountWait/10;
   
     if(CountWait>0)
     {
       LCD_DisplayChar(Line5,Column8,(CountWait%10)+0x30);
     }
   }
   else /* Frequency deviation in ppm is more than 121 ppm, hence calibration
           can not be done */
   {
     LCD_Clear(Blue2);
     LCD_DisplayString(Line3,Column1,"Out Of Calibration");
     LCD_DisplayString(Line4,Column4,"Range");
   }
  }
  
  BKP_RTCOutputConfig(BKP_RTCOutputSource_None);
  TIM_ITConfig(TIM2, TIM_IT_CC2, DISABLE);
  TIM_Cmd(TIM2, DISABLE);
  TIM_DeInit(TIM2);
  CalibrationTimer=RTC_GetCounter();
  
  /*  Wait for 2 seconds  */
  while((RTC_GetCounter() - CalibrationTimer) < 5)
  {
  }
  
  MenuInit();
}
Exemplo n.º 22
0
BOOL
Init(VOID)
{
   USERCONNECT UserCon;
   PVOID *KernelCallbackTable;
 
   /* Set up the kernel callbacks. */
   KernelCallbackTable = NtCurrentPeb()->KernelCallbackTable;
   KernelCallbackTable[USER32_CALLBACK_WINDOWPROC] =
      (PVOID)User32CallWindowProcFromKernel;
   KernelCallbackTable[USER32_CALLBACK_SENDASYNCPROC] =
      (PVOID)User32CallSendAsyncProcForKernel;
   KernelCallbackTable[USER32_CALLBACK_LOADSYSMENUTEMPLATE] =
      (PVOID)User32LoadSysMenuTemplateForKernel;
   KernelCallbackTable[USER32_CALLBACK_LOADDEFAULTCURSORS] =
      (PVOID)User32SetupDefaultCursors;
   KernelCallbackTable[USER32_CALLBACK_HOOKPROC] =
      (PVOID)User32CallHookProcFromKernel;
   KernelCallbackTable[USER32_CALLBACK_EVENTPROC] =
      (PVOID)User32CallEventProcFromKernel;
   KernelCallbackTable[USER32_CALLBACK_LOADMENU] =
      (PVOID)User32CallLoadMenuFromKernel;
   KernelCallbackTable[USER32_CALLBACK_CLIENTTHREADSTARTUP] =
      (PVOID)User32CallClientThreadSetupFromKernel;
   KernelCallbackTable[USER32_CALLBACK_CLIENTLOADLIBRARY] =
      (PVOID)User32CallClientLoadLibraryFromKernel;
   KernelCallbackTable[USER32_CALLBACK_GETCHARSETINFO] =
      (PVOID)User32CallGetCharsetInfo;

   NtUserProcessConnect( NtCurrentProcess(),
                         &UserCon,
                         sizeof(USERCONNECT));

   g_ppi = GetWin32ClientInfo()->ppi; // Snapshot PI, used as pointer only!
   g_ulSharedDelta = UserCon.siClient.ulSharedDelta;
   gpsi = SharedPtrToUser(UserCon.siClient.psi);
   gHandleTable = SharedPtrToUser(UserCon.siClient.aheList);
   gHandleEntries = SharedPtrToUser(gHandleTable->handles);

   RtlInitializeCriticalSection(&gcsUserApiHook);
   gfServerProcess = FALSE; // FIXME HAX! Used in CsrClientConnectToServer(,,,,&gfServerProcess);

   //CsrClientConnectToServer(L"\\Windows", 0, NULL, 0, &gfServerProcess);
   //ERR("1 SI 0x%x : HT 0x%x : D 0x%x\n", UserCon.siClient.psi, UserCon.siClient.aheList,  g_ulSharedDelta);

   /* Allocate an index for user32 thread local data. */
   User32TlsIndex = TlsAlloc();
   if (User32TlsIndex != TLS_OUT_OF_INDEXES)
   {
      if (MessageInit())
      {
         if (MenuInit())
         {
            InitializeCriticalSection(&U32AccelCacheLock);
            GdiDllInitialize(NULL, DLL_PROCESS_ATTACH, NULL);
            LoadAppInitDlls();

            return TRUE;
         }
         MessageCleanup();
      }
      TlsFree(User32TlsIndex);
   }

   return FALSE;
}
Exemplo n.º 23
0
/**
  * @brief  RTC Application runs in while loop
  * @param  None
  * @retval : None
  */
void RTC_Application(void)
{
  uint8_t ReturnValue;

  CalculateTime();
  
  if(TimeDateDisplay==0)
  {
    DisplayTime();
  }

  if(DisplayDateFlag==1 && TimeDateDisplay==0)
  {
    DisplayDate();
    DisplayDateFlag=0;
  }

  if(AlarmStatus==1)
  {
    DisplayAlarm();
    GPIO_SetBits(GPIOC, GPIO_Pin_6);
    Dummy=RTC_GetCounter();
    AlarmStatus=2;
  }
  if(((RTC_GetCounter()-Dummy) == 4) && (AlarmStatus==2))
  {
    GPIO_ResetBits(GPIOC, GPIO_Pin_6);
    SelIntExtOnOffConfig(ENABLE);
    RightLeftIntExtOnOffConfig(ENABLE);
    UpDownIntOnOffConfig(ENABLE);
    MenuInit();
    Dummy=0;
    AlarmStatus = 0;
  }

  if(TamperEvent == 1) /* Tamper event is detected */
  {
    TamperNumber = TamperNumber + 1;
    BKP_WriteBackupRegister(BKP_DR5,TamperNumber);
    BKP_WriteBackupRegister(BKP_DR1, CONFIGURATION_DONE);
    BKP_WriteBackupRegister(BKP_DR2,s_DateStructVar.Month);
    BKP_WriteBackupRegister(BKP_DR3,s_DateStructVar.Day);
    BKP_WriteBackupRegister(BKP_DR4,s_DateStructVar.Year);
    BKP_WriteBackupRegister(BKP_DR9,s_AlarmDateStructVar.Day);
    BKP_WriteBackupRegister(BKP_DR8,s_AlarmDateStructVar.Month);
    BKP_WriteBackupRegister(BKP_DR10,s_AlarmDateStructVar.Year);
    BKP_WriteBackupRegister(BKP_DR6,ClockSource);
    BKP_WriteBackupRegister(BKP_DR7,SummerTimeCorrect);
    ReturnValue=EE_WriteVariable(TamperNumber);
    
    if(ReturnValue==PAGE_FULL)
    {
      ReturnValue=EE_WriteVariable(TamperNumber);
    }
    
    ReturnValue=EE_WriteVariable(s_DateStructVar.Day);
    ReturnValue=EE_WriteVariable(s_DateStructVar.Month);
    ReturnValue=EE_WriteVariable((s_DateStructVar.Year)/100);
    ReturnValue=EE_WriteVariable((s_DateStructVar.Year)%100);
    ReturnValue=EE_WriteVariable((s_TimeStructVar.HourHigh*10)+\
                    s_TimeStructVar.HourLow);
    ReturnValue=EE_WriteVariable((s_TimeStructVar.MinHigh*10)+\
                    s_TimeStructVar.MinLow);
    ReturnValue=EE_WriteVariable((s_TimeStructVar.SecHigh*10)+\
                    s_TimeStructVar.SecLow);
    while(!(GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_13)))
    {
    }
    
    TamperEvent=0;
    BKP_TamperPinCmd(ENABLE);
  }
  
  if(BatteryRemoved != 0) /* Battery tamper is detected */
  {
    TamperNumber = TamperNumber + 1;
    BKP_WriteBackupRegister(BKP_DR5,TamperNumber);
    ReturnValue=EE_WriteVariable(TamperNumber);
    
    if(ReturnValue==PAGE_FULL)
    {
      ReturnValue=EE_WriteVariable(TamperNumber);
    }
    
    ReturnValue=EE_WriteVariable(s_DateStructVar.Day);
    ReturnValue=EE_WriteVariable(s_DateStructVar.Month);
    ReturnValue=EE_WriteVariable((s_DateStructVar.Year)/100);
    ReturnValue=EE_WriteVariable((s_DateStructVar.Year)%100);
    ReturnValue=EE_WriteVariable((s_TimeStructVar.HourHigh*10)\
                    +s_TimeStructVar.HourLow);
    ReturnValue=EE_WriteVariable((s_TimeStructVar.MinHigh*10)\
                    +s_TimeStructVar.MinLow);
    if(BatteryRemoved==1)
    {
      ReturnValue=EE_WriteVariable(BATTERY_REMOVED);
      BatteryRemoved=0;
    }
    else if(BatteryRemoved==2)
    {
      ReturnValue=EE_WriteVariable(BATTERY_RESTORED);
      BatteryRemoved=0;
    }

    BKP_TamperPinCmd(ENABLE);
  }
}
Exemplo n.º 24
0
int main( void ) {
    SysInit();
    EeepromInit();
    TimerInit();
    ComInit();
    Ds1302Init();
    HtlcdInit();
    BottonInit();
    LedInit();
    MenuInit();
    INTEN
    while(1) {
        u8 botton_bit = 0;
        if(TimerGetSec() > 20) {
            TimerSetSec(0);
            SysSleep();
        }
        if(TimerGetTimeFlag() > 0x01) {
            TimerSetTimeFlag(0);
            MenuRefreshTime();
        }
        MenuFlickerServerTime();
        botton_bit = BottonRead();
        if(botton_bit > 0x01) {
            TimerSetSec(0);
            SysOpen();
        }
        switch(botton_bit) {
            case 0x01:
                MenuSetFeatures(7);
            break;//后减档
            case 0x02:
                MenuSetFeatures(5);
            break;//后加档
            case 0x03:
                MenuSetFeatures(4);
            break;//前换挡
            case 0x11:
                MenuSetFeatures(1);
            break;//区域3
            case 0x12:
                MenuSetFeatures(6);//1
            break;//区域2
            case 0x13:
                MenuSetFeatures(8);
            break;//区域1
            case 0x14:
                MenuSetFeatures(2);
            break;//区域1
            case 0x15:
                MenuSetFeatures(3);
            break;//放开信号
        }
        
        if(ComGetFlag() == 0x80) {
            ComClearFlag();
            LedSet(0);
            switch(ComGetData(0)) {
                case front:
                    switch(ComGetData(1)) {
                        case dce_gear:
                            MenuSetStalls(front,ComGetData(2)+1);
                            MenuSetBattery(ComGetData(3));
                        break;
                    }
                break;
                case behind: 
                    switch(ComGetData(1)) {
                        case dce_gear:
                            MenuSetStalls(behind,ComGetData(2));
                            MenuSetBattery(ComGetData(3));
                        break;
                    }
                break;
                case dce_powe:
                    MenuSetBattery(ComGetData(1));
                break;
            }
        }
    }
}
Exemplo n.º 25
0
void NewFloorMenuInit(Window *window)
{
	MenuInit(window);
}
Exemplo n.º 26
0
INT32
main (
  IN INT32  Argc,
  IN CHAR8  **Argv
  )
{
  EFI_STATUS                          Status;
  MENU_ENTRY                          *Entry;

  // get LKAPi
  mLKApi = GetLKApi();

  // init fastboot
#if defined (MDE_CPU_ARM)
  FastbootCommandsAdd();
#endif

  // init libboot
  libboot_init();

  Status = gBS->LocateProtocol (
                  &gEfiDevicePathToTextProtocolGuid,
                  NULL,
                  (VOID **)&gEfiDevicePathToTextProtocol
                  );
  if (EFI_ERROR (Status)) {
    return -1;
  }

  Status = gBS->LocateProtocol (
                  &gEfiDevicePathFromTextProtocolGuid,
                  NULL,
                  (VOID **)&gEfiDevicePathFromTextProtocol
                  );
  if (EFI_ERROR (Status)) {
    return -1;
  }

  // set default values
  if(!UtilVariableExists(L"multiboot-debuglevel", &gEFIDroidVariableGuid))
    UtilSetEFIDroidVariable("multiboot-debuglevel", "4");
  if(!UtilVariableExists(L"fastboot-enable-boot-patch", &gEFIDroidVariableGuid))
    UtilSetEFIDroidVariable("fastboot-enable-boot-patch", "1");
  if(!UtilVariableExists(L"ui-show-file-explorer", &gEFIDroidVariableGuid))
    SettingBoolSet("ui-show-file-explorer", FALSE);
  if(!UtilVariableExists(L"ui-show-uefi-options", &gEFIDroidVariableGuid))
    SettingBoolSet("ui-show-uefi-options", FALSE);
  if(!UtilVariableExists(L"ui-show-fastboot", &gEFIDroidVariableGuid))
    SettingBoolSet("ui-show-fastboot", TRUE);
  if(!UtilVariableExists(L"boot-force-permissive", &gEFIDroidVariableGuid))
    SettingBoolSet("boot-force-permissive", FALSE);

  // init UI
  Status = MenuInit();
  if (EFI_ERROR (Status)) {
#if defined (MDE_CPU_ARM)
    FastbootInit();
#endif
    return -1;
  }

  // create menus
  mBootMenuMain = MenuCreate();

  mPowerMenu = MenuCreate();
  mPowerMenu->BackCallback = PowerMenuBackCallback;
  mPowerMenu->HideBackIcon = TRUE;

#if defined (MDE_CPU_ARM)
  mFastbootMenu = MenuCreate();
  mFastbootMenu->Title = AsciiStrDup("Please Select OS");
  mFastbootMenu->BackCallback = FastbootBackCallback;
#endif

  mBootMenuMain->Title = AsciiStrDup("Please Select OS");
  mBootMenuMain->ActionIcon = libaroma_stream_ramdisk("icons/ic_settings_black_24dp.png");
  mBootMenuMain->ActionCallback = MainMenuActionCallback;
  mBootMenuMain->ItemFlags = MENU_ITEM_FLAG_SEPARATOR_ALIGN_TEXT;

#if defined (MDE_CPU_ARM)
  // add android options
  AndroidLocatorInit();
  AndroidLocatorAddItems();
#endif

  // add default EFI options
  AddEfiBootOptions();

  // GROUP: Tools
  Entry = MenuCreateGroupEntry();
  Entry->Name = AsciiStrDup("Tools");
  MenuAddEntry(mBootMenuMain, Entry);

  // add file explorer option
  Entry = MenuCreateEntry();
  Entry->Icon = libaroma_stream_ramdisk("icons/fileexplorer.png");
  Entry->Name = AsciiStrDup("File Explorer");
  Entry->Callback = FileExplorerCallback;
  Entry->HideBootMessage = TRUE;
  Entry->Update = FileExplorerUpdate;
  MenuAddEntry(mBootMenuMain, Entry);

#if defined (MDE_CPU_ARM)
  // add fastboot option
  Entry = MenuCreateEntry();
  Entry->Icon = libaroma_stream_ramdisk("icons/android.png");
  Entry->Name = AsciiStrDup("Fastboot");
  Entry->Callback = FastbootCallback;
  Entry->HideBootMessage = TRUE;
  Entry->Update = FastbootMenuEntryUpdate;
  MenuAddEntry(mBootMenuMain, Entry);
#endif

  // add reboot option
  Entry = MenuCreateEntry();
  Entry->Icon = libaroma_stream_ramdisk("icons/reboot.png");
  Entry->Name = AsciiStrDup("Reboot");
  Entry->Callback = RebootCallback;
  Entry->Private = NULL;
  Entry->LongPressCallback = RebootLongPressCallback;
  MenuAddEntry(mBootMenuMain, Entry);

  Entry = MenuCreateEntry();
  Entry->Icon = libaroma_stream_ramdisk("icons/power_off.png");
  Entry->Name = AsciiStrDup("Power Off");
  Entry->Callback = PowerOffCallback;
  MenuAddEntry(mPowerMenu, Entry);

  Entry = MenuCreateEntry();
  Entry->Icon = libaroma_stream_ramdisk("icons/reboot.png");
  Entry->Name = AsciiStrDup("Reboot");
  Entry->Callback = RebootCallback;
  Entry->Private = NULL;
  MenuAddEntry(mPowerMenu, Entry);

  Entry = MenuCreateEntry();
  Entry->Icon = libaroma_stream_ramdisk("icons/reboot_recovery.png");
  Entry->Name = AsciiStrDup("Reboot to Recovery");
  Entry->Callback = RebootCallback;
  Entry->Private = UnicodeStrDup(L"recovery");
  MenuAddEntry(mPowerMenu, Entry);

  Entry = MenuCreateEntry();
  Entry->Icon = libaroma_stream_ramdisk("icons/reboot_bootloader.png");
  Entry->Name = AsciiStrDup("Reboot to Bootloader");
  Entry->Callback = RebootCallback;
  Entry->Private = UnicodeStrDup(L"bootloader");
  MenuAddEntry(mPowerMenu, Entry);

  Entry = MenuCreateEntry();
  Entry->Icon = libaroma_stream_ramdisk("icons/download_mode.png");
  Entry->Name = AsciiStrDup("Enter Download Mode");
  Entry->Callback = RebootCallback;
  Entry->Private = UnicodeStrDup(L"download");
  MenuAddEntry(mPowerMenu, Entry);

  // show previous boot error
  CHAR8* EFIDroidErrorStr = UtilGetEFIDroidVariable("EFIDroidErrorStr");
  if (EFIDroidErrorStr != NULL) {
    MenuShowMessage("Previous boot failed", EFIDroidErrorStr);

    // delete variable
    UtilSetEFIDroidVariable("EFIDroidErrorStr", NULL);

    // backup variable
    UtilSetEFIDroidVariable("EFIDroidErrorStrPrev", EFIDroidErrorStr);

    // free pool
    FreePool(EFIDroidErrorStr);
  }

  // get last boot entry
  LAST_BOOT_ENTRY* LastBootEntry = UtilGetEFIDroidDataVariable(L"LastBootEntry");
  if(LastBootEntry)
   UtilSetEFIDroidDataVariable(L"LastBootEntry", NULL, 0);

#if defined (MDE_CPU_ARM)
  // run recovery mode handler
  if (mLKApi) {
    if(!AsciiStrCmp(mLKApi->platform_get_uefi_bootpart(), "recovery") || mLKApi->platform_get_uefi_bootmode()==LKAPI_UEFI_BM_RECOVERY) {
      AndroidLocatorHandleRecoveryMode(LastBootEntry);
    }
  }
#endif

  // free last boot entry
  if(LastBootEntry)
    FreePool(LastBootEntry);

  // clear the watchdog timer
  gBS->SetWatchdogTimer (0, 0, 0, NULL);

  // first boot?
  UINTN* LastBootVersion = UtilGetEFIDroidDataVariable(L"last-boot-version");
  if(LastBootVersion==NULL) {
    UINTN NewValue = 1;
    UtilSetEFIDroidDataVariable(L"last-boot-version", &NewValue, sizeof(NewValue));
    MenuShowTutorial();
  }

  // show main menu
  MenuStackPush(mBootMenuMain);
  MenuEnter (0, TRUE);
  MenuDeInit();

  return 0;
}
Exemplo n.º 27
0
void BattleWindowInit(Window *window)
{
	MenuInit(window);
	BattleInit();
}
Exemplo n.º 28
0
BOOL FASTCALL
co_IntInitializeDesktopGraphics(VOID)
{
    TEXTMETRICW tmw;
    UNICODE_STRING DriverName = RTL_CONSTANT_STRING(L"DISPLAY");
    PDESKTOP pdesk;

    ScreenDeviceContext = IntGdiCreateDC(&DriverName, NULL, NULL, NULL, FALSE);
    if (NULL == ScreenDeviceContext)
    {
        IntDestroyPrimarySurface();
        return FALSE;
    }
    GreSetDCOwner(ScreenDeviceContext, GDI_OBJ_HMGR_PUBLIC);

    if (! IntCreatePrimarySurface())
    {
        return FALSE;
    }

    hSystemBM = NtGdiCreateCompatibleDC(ScreenDeviceContext);

    NtGdiSelectFont(hSystemBM, NtGdiGetStockObject(SYSTEM_FONT));
    GreSetDCOwner(hSystemBM, GDI_OBJ_HMGR_PUBLIC);

    /* Update the SERVERINFO */
    gpsi->aiSysMet[SM_CXSCREEN] = gppdevPrimary->gdiinfo.ulHorzRes;
    gpsi->aiSysMet[SM_CYSCREEN] = gppdevPrimary->gdiinfo.ulVertRes;
    gpsi->Planes        = NtGdiGetDeviceCaps(ScreenDeviceContext, PLANES);
    gpsi->BitsPixel     = NtGdiGetDeviceCaps(ScreenDeviceContext, BITSPIXEL);
    gpsi->BitCount      = gpsi->Planes * gpsi->BitsPixel;
    gpsi->dmLogPixels   = NtGdiGetDeviceCaps(ScreenDeviceContext, LOGPIXELSY);
    if (NtGdiGetDeviceCaps(ScreenDeviceContext, RASTERCAPS) & RC_PALETTE)
    {
        gpsi->PUSIFlags |= PUSIF_PALETTEDISPLAY;
    }
    else
        gpsi->PUSIFlags &= ~PUSIF_PALETTEDISPLAY;
    // Font is realized and this dc was previously set to internal DC_ATTR.
    gpsi->cxSysFontChar = IntGetCharDimensions(hSystemBM, &tmw, (DWORD*)&gpsi->cySysFontChar);
    gpsi->tmSysFont     = tmw;

    /* Put the pointer in the center of the screen */
    gpsi->ptCursor.x = gpsi->aiSysMet[SM_CXSCREEN] / 2;
    gpsi->ptCursor.y = gpsi->aiSysMet[SM_CYSCREEN] / 2;

    /* Attach monitor */
    UserAttachMonitor((HDEV)gppdevPrimary);

    /* Setup the cursor */
    co_IntLoadDefaultCursors();

    /* Setup the icons */
    co_IntSetWndIcons();

    /* Setup Menu */
    MenuInit();

    /* Show the desktop */
    pdesk = IntGetActiveDesktop();
    ASSERT(pdesk);
    co_IntShowDesktop(pdesk, gpsi->aiSysMet[SM_CXSCREEN], gpsi->aiSysMet[SM_CYSCREEN], TRUE);

    return TRUE;
}
Exemplo n.º 29
0
int mainEntry(int argc, char* argv[])
{
	int ref = 0;

	s32 event=EVENT_NONE;

	sal_Init();
	sal_VideoInit(16,SAL_RGB(0,0,0),Memory.ROMFramesPerSecond);

	mRomName[0]=0;
	if (argc >= 2) 
 		strcpy(mRomName, argv[1]); // Record ROM name

	MenuInit(sal_DirectoryGetHome(), &mMenuOptions);


	if(SnesInit() == SAL_ERROR)
	{
		sal_Reset();
		return 0;
	}

	while(1)
	{
		mInMenu=1;
		event=MenuRun(mRomName);
		mInMenu=0;

		if(event==EVENT_LOAD_ROM)
		{
			if(mTempState) free(mTempState);
			mTempState=NULL;
			if(SnesRomLoad() == SAL_ERROR) 
			{
				MenuMessageBox("Failed to load rom",mRomName,"Press any button to continue", MENU_MESSAGE_BOX_MODE_PAUSE);
				sal_Reset();
		    		return 0;
			}
			else
			{
				event=EVENT_RUN_ROM;
		  	}
		}

		if(event==EVENT_RESET_ROM)
		{
			S9xReset();
			event=EVENT_RUN_ROM;
		}

		if(event==EVENT_RUN_ROM)
		{
			if(mMenuOptions.fullScreen)
			{
				sal_VideoSetScaling(SNES_WIDTH,SNES_HEIGHT);
			}

			if(mMenuOptions.transparency)	Settings.Transparency = TRUE;
			else Settings.Transparency = FALSE;

			sal_AudioSetVolume(mMenuOptions.volume,mMenuOptions.volume);
			sal_CpuSpeedSet(mMenuOptions.cpuSpeed);	
			sal_VideoClear(0);
			sal_VideoFlip(1);
			sal_VideoClear(0);
			sal_VideoFlip(1);
			if(mMenuOptions.soundEnabled) 	
				RunSound();
			else	RunNoSound();

			event=EVENT_NONE;
		}

		if(event==EVENT_EXIT_APP) break;	
	}

	if(mTempState) free(mTempState);
	mTempState=NULL;
	
	S9xGraphicsDeinit();
	S9xDeinitAPU();
	Memory.Deinit();

	free(GFX.SubZBuffer);
	free(GFX.ZBuffer);
	free(GFX.SubScreen);
	GFX.SubZBuffer=NULL;
	GFX.ZBuffer=NULL;
	GFX.SubScreen=NULL;

	sal_Reset();
  	return 0;
}
Exemplo n.º 30
0
void MenuClose(){
	if(openedMenus > 0){
		MenuInit(MenuChain[--openedMenus]);
		MenuShow();
	}
}