Esempio n. 1
0
File: main.c Progetto: IUNIXI/LxNAND
void waitforexit(void)
{
        printf("Press A to get back to main menu.\n");
        struct controller_data_s controller;
        while(1)
        { 		
         struct controller_data_s button;
          if (get_controller_data(&button, 0))
          {
           if((button.a)&&(!controller.a))
             prompt(MAIN_MENU);
       										  
	   controller=button;
          }
 	  usb_do_poll();
 	}
}
Esempio n. 2
0
    void Browser::Alert(const char *message) {
        display_alert = 1;
        unsigned int color = ALERT_COLOR;

        memset(&old_ctrl, 0, sizeof (struct controller_data_s));
        memset(&ctrl, 0, sizeof (struct controller_data_s));

        while (display_alert == 1) {
            // Begin to draw
            Begin();

            RenderBg();

            Draw::DrawColoredRect(-0.5f, -0.5f, 1.0f, 1.0f, color);

            m_font.Begin();

            // need to fix that ..
            //m_font.DrawTextF("Error ?", SelectedColor, -0.55f, 0.3f);

            m_font.DrawTextF(message, SelectedColor, -0.55f, -0.5f);
            m_font.DrawTextF("Press B to continue", SelectedColor, -0.3f, 0.3f);

            m_font.End();

            // Draw all text + form
            Render();

            // Draw is finished
            End();

            // Update code ...
            {
                usb_do_poll();
                get_controller_data(&ctrl, 0);

                if (ctrl.b & !old_ctrl.b) {
                    display_alert = 0;
                    return;
                }
                // Save the old value
                old_ctrl = ctrl;
                memset(&ctrl, 0, sizeof (struct controller_data_s));
            }
        }
    }
Esempio n. 3
0
/**
 Effectue un printf rapide avec effaement de couleur/ et rafraichissement

 **/
void errorPrintf(int x, int y, int color, char *str)
{
	Xe_InvalidateState(xe);
	XePrintf(-0.5, 0, str, 0.6, 0x0000FF);//Red
#if 1
	//Blanc ....
	Xe_SetClearColor(xe, ~0);
	Xe_Resolve(xe);

	while (!Xe_IsVBlank(xe))
		;
	Xe_Sync(xe);
	//Attends qu'une touche soit presser
	while (1)
	{
		struct controller_data_s c;
		if (get_controller_data(&c, 0))
		{
			return;//Quit
		}
	}
#endif
}
Esempio n. 4
0
int igmInput()
{
	struct controller_data_s c;
	int ret=get_controller_data(&c, 0);

	//Que droite et gauche
	if(c.left&&!lastinputc.left)
	{
		isel--;
		nframe=0;
	}
	if(c.right&&!lastinputc.right)
	{
		isel++;
		nframe=0;
	}
	//Action
	if(c.a&&!lastinputc.a)
	{
		igmDoAction();
	}
	if(c.b&&!lastinputc.b)
	{
		resetAction();
	}
	if(c.logo&&!lastinputc.logo)
	{
		displayInfo=0;
		emulationPaused=0;
	}
	//fix le choix
	fixisel();
	lastinputc=c;
	//usb_do_poll();

	return ret;
}
Esempio n. 5
0
File: main.cpp Progetto: JQE/Tank360
void MyConsole::Update() {

    usb_do_poll();
       
    get_controller_data(&ctrl, 0);
    
    if (ctrl.up) {
        P1.setDirection(u);
    } else if (ctrl.down) {
        P1.setDirection(d);
    } else if (ctrl.left) {
        P1.setDirection(l);
    } else if (ctrl.right) {
        P1.setDirection(r);
    } else if (ctrl.s1_x > STICK_THRESHOLD) {
        P1.setDirection(r);
    } else if (ctrl.s1_x < -STICK_THRESHOLD) {
        P1.setDirection(l);
    } else if (ctrl.s1_y > STICK_THRESHOLD) {
        P1.setDirection(u);
    } else if (ctrl.s1_y < -STICK_THRESHOLD) {
        P1.setDirection(d);
    }
     
    if (ctrl.a && !old_ctrl.a) {
        P1.shoot();
    }  
    
    if (ctrl.x && !old_ctrl.x) {
        if (Warning("Reset Game stats?")) {
            P1.setTexture(bg);
            P2.setTexture(bg);
        }
    }
    
    
    get_controller_data(&ctrl1, 1);
    
    if (ctrl1.up) {
        P2.setDirection(u);
    } else if (ctrl1.down) {
        P2.setDirection(d);
    } else if (ctrl1.left) {
        P2.setDirection(l);
    } else if (ctrl1.right) {
        P2.setDirection(r);
    } else if (ctrl1.s1_x > STICK_THRESHOLD) {
        P2.setDirection(r);
    } else if (ctrl1.s1_x < -STICK_THRESHOLD) {
        P2.setDirection(l);
    } else if (ctrl1.s1_y > STICK_THRESHOLD) {
        P2.setDirection(u);
    } else if (ctrl1.s1_y < -STICK_THRESHOLD) {
        P2.setDirection(d);
    }
     
    if (ctrl1.a && !old_ctrl.a) {
        P2.shoot();
    }
    if (ctrl1.x && !old_ctrl1.x) {
        if (Warning("Reset Game stats?")) {
            P1.setTexture(bg);
            P1.spawn(P1.sPoint[P1.sCount].x, P1.sPoint[P1.sCount].y, P1.sPoint[P1.sCount].direction);
            P2.setTexture(bg);
            P2.sCount = rand()%4;
            while (P1.sCount == P2.sCount) {
                P2.sCount = rand()%4;
            }
            P2.spawn(P2.sPoint[P2.sCount].x, P2.sPoint[P2.sCount].y, P2.sPoint[P2.sCount].direction);
        }
    }
    
    old_ctrl = ctrl;
    old_ctrl1 = ctrl1;
    memset(&ctrl, 0, sizeof(struct controller_data_s));
    memset(&ctrl1, 0, sizeof(struct controller_data_s));
}
Esempio n. 6
0
int main(){
	const char * s;
	char path[256];
	
	int handle;
	struct controller_data_s pad;
	int pos=0,ppos=-1,start,count,i;

	xenos_init(VIDEO_MODE_AUTO);
	console_init();

	xenon_make_it_faster(XENON_SPEED_FULL);
	
	usb_init();
	usb_do_poll();
	
	xenon_ata_init();

	xenon_atapi_init();
	
	fatInitDefault();

	handle=-1;
    handle=bdev_enum(handle,&s);
    if(handle<0) return 0;

	strcpy(path,s);
	strcat(path,":/");	

	load_dir(path);
	
	for(;;){
 		usb_do_poll();		
 		get_controller_data(&pad, 0);
		
		if (pad.s1_y>STICK_THRESHOLD) --pos;
		if (pad.s1_y<-STICK_THRESHOLD) ++pos;
		
		if (entrycount && (pos<0 || pos>=entrycount)){
			pos=ppos;
			continue;
		}
		
		if (pad.logo) return 0;
		
		if (pad.a){
			if(entries[pos].d_type&DT_DIR){
				append_dir_to_path(path,entries[pos].d_name);
				load_dir(path);
				ppos=-1;
				pos=0;
			}else{
				char fn[256];
				strcpy(fn,path);
				strcat(fn,entries[pos].d_name);
				
				printf("%s\n",fn);

				if (strstr(entries[pos].d_name,".elf") || strstr(entries[pos].d_name,".elf32")) { // ugly
					elf_runFromDisk(fn);
				}else{
					FILE * f=fopen(fn,"rb");
					if(f){
						int size=1024*1024;
						int totred=0,red;

						void * buf=malloc(size);

						u64 beg=mftb();
						do{
							red=fread(buf,1,size,f);
							totred+=red;
							console_putch('.');
						}while(red==size);

						printf("\n%d bytes, %f KB/s\n",totred, (float)(totred/1024.0)/((float)(mftb()-beg)/PPC_TIMEBASE_FREQ));

						free(buf);

						fclose(f);
					}
				}
			}
		}
		
		if(pad.back){
			append_dir_to_path(path,"..");
			load_dir(path);
			ppos=-1;
			pos=0;
		}
		
		if(pad.b){
		    do{
				handle=bdev_enum(handle,&s);
			}while(handle<0);
			strcpy(path,s);
			strcat(path,":/");
			load_dir(path);
			ppos=-1;
			pos=0;
		}

		if (ppos==pos) continue;
		
		memset(&pad,0,sizeof(struct controller_data_s));
		
		console_set_colors(BG_COL,FG_COL);
		console_clrscr();
		printf("A: select, B: change disk, Back: parent dir, Logo: reload Xell\n\n%s\n\n",path);
		
		start=MAX(0,pos-MAX_DISPLAYED_ENTRIES/2);
		count=MIN(MAX_DISPLAYED_ENTRIES,entrycount-start);
		
		for(i=start;i<start+count;++i){
			struct dirent *de = &entries[i];

			if (i==pos){
				console_set_colors(FG_COL,BG_COL);
			}else{
				console_set_colors(BG_COL,FG_COL);
			}
			
			if (de->d_type&DT_DIR) console_putch('[');

			s=de->d_name;
			while(*s) console_putch(*s++);
			
			if (de->d_type&DT_DIR) console_putch(']');

			console_putch('\r');
			console_putch('\n');
		}
			
		ppos=pos;
		
		do{
	 		usb_do_poll();		
			get_controller_data(&pad, 0);
		}while(pad.a || pad.b || pad.back || pad.s1_y>STICK_THRESHOLD || pad.s1_y<-STICK_THRESHOLD);
	}
	
	
	return 0;
}
Esempio n. 7
0
    void Browser::Update() {
        
#ifdef WIN32
        W32Update();
#endif
        Hw::SystemPoll();

        get_controller_data(&ctrl, 0);
        {
            int up = 0;
            int down = 0;
            
            // button pressed
            if(ctrl.up && !old_ctrl.up){
                up++;
                lChange[0]=mftb();
            }
            else if (ctrl.down && !old_ctrl.down){
                down++;
                lChange[1]=mftb();
            }
            // button released
            if(!ctrl.up){
                lChange[0]=0;
            }
            if(!ctrl.down){
                lChange[1]=0;
            }
            
            uint64_t now = mftb();

            if(lChange[0]>0)
            if(tb_diff_msec(now,lChange[0])>250){
                static int uh=0;
                uh=!uh;
                if (uh) up++;
            }
            if(lChange[1]>0)
            if(tb_diff_msec(now,lChange[1])>250){
                static int dh=0;
                dh=!dh;
                if (dh) down++;
            }
            
            
            //if (get_controller_data(&ctrl, 0)) {
            if (up) {
                switch (panelSelected) {
                    case PANEL_FILE_LIST:
                        entrySelected--;
                        break;
                    case PANEL_ACTION:
                        actionSelected--;
                        break;
                }
            }

            if (down) {
                switch (panelSelected) {
                    case PANEL_FILE_LIST:
                        entrySelected++;
                        break;
                    case PANEL_ACTION:
                        actionSelected++;
                        break;
                }
            }
            if (ctrl.b && !old_ctrl.b) {
                switch (panelSelected) {
                    case PANEL_FILE_LIST:
                        append_dir_to_path(currentPath, "..");
                        ScanDir();
                        break;
                }
            }
            if (ctrl.back && !old_ctrl.back) {
#ifdef LIBXENON
                switch (panelSelected) {
                    case PANEL_FILE_LIST:
                        char path[2048];
                        
                        handle = get_devices(handle, path);

                        strcpy(currentPath, path);
                        ScanDir();
                        break;
                }
#endif
            }
            if
                (
                    (ctrl.start && !old_ctrl.start) || (ctrl.a && !old_ctrl.a)
                    ) {
                switch (panelSelected) {
                    case PANEL_FILE_LIST:
                    {
                        if (vEntry.size() == 0)
                            break;

                        FileEntry currentEntry = vEntry.at(entrySelected);

                        if (currentEntry.type == 1) {
                            append_dir_to_path(currentPath, (char*) currentEntry.name.c_str());
                            ScanDir();
                        } else {
                            sprintf(currentFile, "%s/%s", currentPath, currentEntry.name.c_str());
                            if (ActionLaunchFile != NULL)
                                ActionLaunchFile(currentFile);
                        }
                        break;
                    }
                    case PANEL_ACTION:
                    {
                        if (nbAction == 0)
                            break;

                        // Exec action ...
                        //FileEntry currentEntry = vEntry.at(entrySelected);
                        lpBrowserActionEntry currentAction = vAction[actionSelected];
                        if (currentAction != NULL && currentAction->action != NULL) {
                            currentAction->param = (void*) currentPath;
                            //currentAction->param = 
                            currentAction->action(currentAction);
                        }
                        break;
                    }
                }
            }

            if (ctrl.left && !old_ctrl.left) {
                //if(panelSelected!=PANEL_PROGRESS)
                panelSelected--;
            }
            if (ctrl.right && !old_ctrl.right) {
                //if(panelSelected!=PANEL_PROGRESS)
                panelSelected++;
            }

            // clamp ...
            CLAMP(entrySelected, 0, vEntry.size() - 1);
            CLAMP(actionSelected, 0, nbAction - 1);
            CLAMP(panelSelected, 0, 1);


            // Save the old value
            old_ctrl = ctrl;

            // Erase for the big loop
            memset(&ctrl, 0, sizeof (struct controller_data_s));
        }


    }
void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick)
{        
        static int prev_buttons[4] = {0};
        static Sint16 nX = 0, nY = 0;
        static Sint16 nXR = 0, nYR = 0;
        unsigned long b=0; 
        int hat=0, changed=0;

        /* Theres a bug with the current libXenon controller implementation
           that sometimes causes analog values to 'stick' and retain the same x/y values
           after release back to origin.
           */
        
        usb_do_poll();
        
        get_controller_data(&joystick->hwdata->curpad, joystick->index);
    
        if (joystick->hwdata->curpad.a)
        {
                if (!joystick->buttons[0])
                        SDL_PrivateJoystickButton(joystick, (Uint8)0, SDL_PRESSED);
        }
        else
        {
                if (joystick->buttons[0])
                        SDL_PrivateJoystickButton(joystick, (Uint8)0, SDL_RELEASED);
        }

        if (joystick->hwdata->curpad.b)
        {
                if (!joystick->buttons[1])
                        SDL_PrivateJoystickButton(joystick, (Uint8)1, SDL_PRESSED);
        }
        else
        {
                if (joystick->buttons[1])
                        SDL_PrivateJoystickButton(joystick, (Uint8)1, SDL_RELEASED);
        }

        if (joystick->hwdata->curpad.x)
        {
                if (!joystick->buttons[2])
                        SDL_PrivateJoystickButton(joystick, (Uint8)2, SDL_PRESSED);
        }
        else
        {
                if (joystick->buttons[2])
                        SDL_PrivateJoystickButton(joystick, (Uint8)2, SDL_RELEASED);
        }

        if (joystick->hwdata->curpad.y)
        {
                if (!joystick->buttons[3])
                        SDL_PrivateJoystickButton(joystick, (Uint8)3, SDL_PRESSED);
        }
        else
        {
                if (joystick->buttons[3])
                        SDL_PrivateJoystickButton(joystick, (Uint8)3, SDL_RELEASED);
        }

        if (joystick->hwdata->curpad.lb)
        {
                if (!joystick->buttons[4])
                        SDL_PrivateJoystickButton(joystick, (Uint8)4, SDL_PRESSED);
        }
        else
        {
                if (joystick->buttons[4])
                        SDL_PrivateJoystickButton(joystick, (Uint8)4, SDL_RELEASED);
        }

        if (joystick->hwdata->curpad.rb)
        {
                if (!joystick->buttons[5])
                        SDL_PrivateJoystickButton(joystick, (Uint8)5, SDL_PRESSED);
        }
        else
        {
                if (joystick->buttons[5])
                        SDL_PrivateJoystickButton(joystick, (Uint8)5, SDL_RELEASED);
        }

        if (joystick->hwdata->curpad.s1_z)
        {
                if (!joystick->buttons[6])
                        SDL_PrivateJoystickButton(joystick, (Uint8)6, SDL_PRESSED);
        }
        else
        {
                if (joystick->buttons[6])
                        SDL_PrivateJoystickButton(joystick, (Uint8)6, SDL_RELEASED);
        }

        if (joystick->hwdata->curpad.s2_z)
        {
                if (!joystick->buttons[7])
                        SDL_PrivateJoystickButton(joystick, (Uint8)7, SDL_PRESSED);
        }
        else
        {
                if (joystick->buttons[7])
                        SDL_PrivateJoystickButton(joystick, (Uint8)7, SDL_RELEASED);
        }

        if (joystick->hwdata->curpad.start)
        {
                if (!joystick->buttons[8])
                        SDL_PrivateJoystickButton(joystick, (Uint8)8, SDL_PRESSED);
        }
        else
        {
                if (joystick->buttons[8])
                        SDL_PrivateJoystickButton(joystick, (Uint8)8, SDL_RELEASED);
        }

        if (joystick->hwdata->curpad.back)
        {
                if (!joystick->buttons[9])
                        SDL_PrivateJoystickButton(joystick, (Uint8)9, SDL_PRESSED);
        }
        else
        {
                if (joystick->buttons[9])
                        SDL_PrivateJoystickButton(joystick, (Uint8)9, SDL_RELEASED);
        }

        if (joystick->hwdata->curpad.lt > 200)
        {
                if (!joystick->buttons[10])
                        SDL_PrivateJoystickButton(joystick, (Uint8)10, SDL_PRESSED);
        }
        else
        {
                if (joystick->buttons[10])
                        SDL_PrivateJoystickButton(joystick, (Uint8)10, SDL_RELEASED);
        }

        if (joystick->hwdata->curpad.rt > 200)
        {
                if (!joystick->buttons[11])
                        SDL_PrivateJoystickButton(joystick, (Uint8)11, SDL_PRESSED);
        }
        else
        {
                if (joystick->buttons[11])
                        SDL_PrivateJoystickButton(joystick, (Uint8)11, SDL_RELEASED);
        }


        // do the HATS baby

        hat = SDL_HAT_CENTERED;
        
        if (joystick->hwdata->curpad.down)
                hat|=SDL_HAT_DOWN;
        if (joystick->hwdata->curpad.up)
                hat|=SDL_HAT_UP;
        if (joystick->hwdata->curpad.left)
                hat|=SDL_HAT_LEFT;
        if (joystick->hwdata->curpad.right)
                hat|=SDL_HAT_RIGHT;


        changed = hat^prev_buttons[joystick->index];

        if ( changed ) {
                SDL_PrivateJoystickHat(joystick, 0, hat);
        }

        prev_buttons[joystick->index] = hat;

        // Axis - LStick

        if ((joystick->hwdata->curpad.s1_x <= -14000) ||
                (joystick->hwdata->curpad.s1_x >= 14000))
        {
                if (joystick->hwdata->curpad.s1_x < 0)
                        joystick->hwdata->curpad.s1_x++;
                nX = ((Sint16)joystick->hwdata->curpad.s1_x);
        }
        else
                nX = 0;

        if ( nX != joystick->axes[0] )
                SDL_PrivateJoystickAxis(joystick, (Uint8)0, (Sint16)nX);


        if ((joystick->hwdata->curpad.s1_y <= -14000) ||
                (joystick->hwdata->curpad.s1_y >= 14000))
        {
                if (joystick->hwdata->curpad.s1_y < 0)
                        joystick->hwdata->curpad.s1_y++;
                nY = -((Sint16)(joystick->hwdata->curpad.s1_y));
        }
        else
                nY = 0;

        if ( nY != joystick->axes[1] )
                SDL_PrivateJoystickAxis(joystick, (Uint8)1, (Sint16)nY);


        // Axis - RStick

        if ((joystick->hwdata->curpad.s2_x <= -14000) ||
                (joystick->hwdata->curpad.s2_x >= 14000))
        {
                if (joystick->hwdata->curpad.s2_x < 0)
                        joystick->hwdata->curpad.s2_x++;
                nXR = ((Sint16)joystick->hwdata->curpad.s2_x);
        }
        else
                nXR = 0;

        if ( nXR != joystick->axes[2] )
                SDL_PrivateJoystickAxis(joystick, (Uint8)2, (Sint16)nXR);


        if ((joystick->hwdata->curpad.s2_y <= -14000) ||
                (joystick->hwdata->curpad.s2_y >= 14000))
        {
                if (joystick->hwdata->curpad.s2_y < 0)
                        joystick->hwdata->curpad.s2_y++;
                nYR = -((Sint16)joystick->hwdata->curpad.s2_y);
        }
        else
                nYR = 0;

        if ( nYR != joystick->axes[3] )
                SDL_PrivateJoystickAxis(joystick, (Uint8)3, (Sint16)nYR);    
        
}
Esempio n. 9
0
File: main.c Progetto: IUNIXI/LxNAND
void prompt(int menu)
{
    	console_clrscr();
        
        switch (menu)
        {
            case MAIN_MENU:{            
                printf("\n  LibXenon NANDFlasher v%s  \n",version);
                printf("  **************************\n\n");
                printf("Flashconfig 0x%08X\n",flashconfig);
                printf("NAND-Size %i MB\n\n",sfc.size_mb);
                printf("Press A to save NAND to file on USB.\n");
                printf("Press X to write file from USB to NAND.\n");
                printf("Press B to analyze NAND.\n");
                printf("Press Y to update XeLL.\n");
                printf("Press START for DMA test.\n");
                printf("Press GUIDE to return to XeLL.\n");
        
                struct controller_data_s controller;
                while(1)
                { 		
                struct controller_data_s button;
                
                if (get_controller_data(&button, 0))
                  {
                    if((button.a)&&(!controller.a))
                        prompt(DUMP_SUBMENU);

                    if((button.x)&&(!controller.x))
                        writeNand("uda:/updflash.bin");

                    if((button.b)&&(!controller.b))
                        prompt(ANALYZE_SUBMENU);
                               
                    if((button.y)&&(!controller.y))
                        updateXeLL("uda:/updxell.bin");
                    
                    if((button.start)&&(!controller.start))                    
                        dmatest();
                    
                    if((button.logo)&&(!controller.logo))
                        break;
                                
                    controller=button;
		   }
 		usb_do_poll();
                }
            }
            case DUMP_SUBMENU:{
                
                int nand_sz = sfc.size_bytes;
                
                if (nand_sz != NAND_SIZE_256MB && nand_sz != NAND_SIZE_512MB)
                    readNand("uda:/flashdmp.bin", FULL_DUMP);
                
                printf("\n         DUMP MENU          \n");
                printf("  **************************\n\n");
                printf("Press A to dump whole NAND.\n");
                printf("Press B to dump only flash-partition.\n");
                printf("Press BACK to go back to main menu.\n");
                
                struct controller_data_s controller;
                while(1)
                { 		
                struct controller_data_s button;
                
                if (get_controller_data(&button, 0))
                  {
                    if((button.a)&&(!controller.a))
                        readNand("uda:/flashdmp.bin", FULL_DUMP);

                    if((button.b)&&(!controller.b))
                        readNand("uda:/flashdmp.bin", BB64MB_ONLY);
                               
                    if((button.select)&&(!controller.select))
                        prompt(MAIN_MENU);
                                
                    controller=button;
		   }
 		usb_do_poll();
                }
            }
            case ANALYZE_SUBMENU:{
                
                printf("\n       ANALYZE MENU        \n");
                printf("  **************************\n\n");
                printf("Press A to analyze physical NAND.\n");
                printf("Press B to analyze file updflash.bin.\n");
                printf("Press BACK to go back to main menu.\n");
                
                struct controller_data_s controller;
                while(1)
                { 		
                struct controller_data_s button;
                
                if (get_controller_data(&button, 0))
                  {
                    if((button.a)&&(!controller.a))
                        prompt(ANALYZE_PHYS_SUBMENU);

                    if((button.b)&&(!controller.b))
                        prompt(ANALYZE_FILE_SUBMENU);
                               
                    if((button.select)&&(!controller.select))
                        prompt(MAIN_MENU);
                                
                    controller=button;
		   }
 		usb_do_poll();
                }
            }
            case ANALYZE_PHYS_SUBMENU:{
                
                int nand_sz = sfc.size_bytes;
                int blocks = sfc.size_blocks;
                if (nand_sz == NAND_SIZE_256MB || nand_sz == NAND_SIZE_512MB)
                    blocks = 0x200;
                
                printf("\n       ANALYZE NAND       \n");
                printf("  **************************\n\n");
                printf("Press A to scan for Bad Blocks.\n");
                printf("Press B to scan for Bad Blocks and EDC errors.\n");
                printf("Press BACK to go back to main menu.\n");
                
                struct controller_data_s controller;
                while(1)
                { 		
                struct controller_data_s button;
                
                if (get_controller_data(&button, 0))
                  {
                    if((button.a)&&(!controller.a)){
                        analyzeNand(0,blocks,0);
                        printReport(BBMnand);
                        waitforexit();
                    }

                    if((button.b)&&(!controller.b)){
                        analyzeNand(0,blocks,1);
                        printReport(BBMnand);
                        waitforexit();
                    }
                               
                    if((button.select)&&(!controller.select))
                        prompt(MAIN_MENU);
                                
                    controller=button;
		   }
 		usb_do_poll();
                }
            }
            case ANALYZE_FILE_SUBMENU:{
                
                int nand_sz = sfc.size_bytes;
                int blocks = sfc.size_blocks;
                if (nand_sz == NAND_SIZE_256MB || nand_sz == NAND_SIZE_512MB)
                    blocks = 0x200;
                
                printf("\n       ANALYZE FILE        \n");
                printf("  **************************\n\n");
                printf("Press A to scan for Bad Blocks.\n");
                printf("Press B to scan for Bad Blocks and EDC errors.\n");
                printf("Press BACK to go back to main menu.\n");
                
                struct controller_data_s controller;
                while(1)
                { 		
                struct controller_data_s button;
                
                if (get_controller_data(&button, 0))
                  {
                    if((button.a)&&(!controller.a)){
                        analyzeFile("uda:/updflash.bin",0,blocks, 0);
                        printReport(BBMfile);
                        waitforexit();
                    }

                    if((button.b)&&(!controller.b)){
                        analyzeFile("uda:/updflash.bin",0,blocks, 1);
                        printReport(BBMfile);
                        waitforexit();
                    }
                               
                    if((button.select)&&(!controller.select))
                        prompt(MAIN_MENU);
                                
                    controller=button;
		   }
 		usb_do_poll();
                }
            }
        }
        return 0;
}
Esempio n. 10
0
void getKeys(int Control, BUTTONS *Keys)
{
    static struct controller_data_s cdata[4],*c;
    BUTTONS b;

	usb_do_poll();

	get_controller_data(&cdata[Control], Control);
	c=&cdata[Control];

    b.START_BUTTON=c->start;
        
    b.A_BUTTON=c->a;
    b.B_BUTTON=c->b;
    b.Z_TRIG=c->x || c->y || (c->rt>TRIGGER_THRESHOLD) || (c->lt>TRIGGER_THRESHOLD);
        
    b.L_TRIG=c->lb;
    b.R_TRIG=c->rb;
     
	
	switch(pad_mode)
	{
		case PADMODE_SDC:
			b.X_AXIS=handleStickDeadZone(c->s1_x)/256;
			b.Y_AXIS=handleStickDeadZone(c->s1_y)/256;

			b.U_DPAD=c->up;
			b.D_DPAD=c->down;
			b.L_DPAD=c->left;
			b.R_DPAD=c->right;

			b.U_CBUTTON=c->s2_y>STICK_THRESHOLD;
			b.D_CBUTTON=c->s2_y<-STICK_THRESHOLD;
			b.L_CBUTTON=c->s2_x<-STICK_THRESHOLD;
			b.R_CBUTTON=c->s2_x>STICK_THRESHOLD;
			break;
		case PADMODE_SCD:
			b.X_AXIS=handleStickDeadZone(c->s1_x)/256;
			b.Y_AXIS=handleStickDeadZone(c->s1_y)/256;

			b.U_CBUTTON=c->up;
			b.D_CBUTTON=c->down;
			b.L_CBUTTON=c->left;
			b.R_CBUTTON=c->right;

			b.U_DPAD=c->s2_y>STICK_THRESHOLD;
			b.D_DPAD=c->s2_y<-STICK_THRESHOLD;
			b.L_DPAD=c->s2_x<-STICK_THRESHOLD;
			b.R_DPAD=c->s2_x>STICK_THRESHOLD;
			break;
		case PADMODE_DSC:
			b.U_DPAD=c->s1_y>STICK_THRESHOLD;
			b.D_DPAD=c->s1_y<-STICK_THRESHOLD;
			b.L_DPAD=c->s1_x<-STICK_THRESHOLD;
			b.R_DPAD=c->s1_x>STICK_THRESHOLD;

			b.X_AXIS=(c->left?-128:0) + (c->right?127:0);
			b.Y_AXIS=(c->up?127:0) + (c->down?-128:0);

			b.U_CBUTTON=c->s2_y>STICK_THRESHOLD;
			b.D_CBUTTON=c->s2_y<-STICK_THRESHOLD;
			b.L_CBUTTON=c->s2_x<-STICK_THRESHOLD;
			b.R_CBUTTON=c->s2_x>STICK_THRESHOLD;
			break;
		case PADMODE_DCS:
			b.U_DPAD=c->s1_y>STICK_THRESHOLD;
			b.D_DPAD=c->s1_y<-STICK_THRESHOLD;
			b.L_DPAD=c->s1_x<-STICK_THRESHOLD;
			b.R_DPAD=c->s1_x>STICK_THRESHOLD;

			b.U_CBUTTON=c->up;
			b.D_CBUTTON=c->down;
			b.L_CBUTTON=c->left;
			b.R_CBUTTON=c->right;

			b.X_AXIS=handleStickDeadZone(c->s2_x)/256;
			b.Y_AXIS=handleStickDeadZone(c->s2_y)/256;
			break;
		case PADMODE_CDS:
			b.U_CBUTTON=c->s1_y>STICK_THRESHOLD;
			b.D_CBUTTON=c->s1_y<-STICK_THRESHOLD;
			b.L_CBUTTON=c->s1_x<-STICK_THRESHOLD;
			b.R_CBUTTON=c->s1_x>STICK_THRESHOLD;

			b.U_DPAD=c->up;
			b.D_DPAD=c->down;
			b.L_DPAD=c->left;
			b.R_DPAD=c->right;

			b.X_AXIS=handleStickDeadZone(c->s2_x)/256;
			b.Y_AXIS=handleStickDeadZone(c->s2_y)/256;
			break;
		case PADMODE_CSD:
			b.U_CBUTTON=c->s1_y>STICK_THRESHOLD;
			b.D_CBUTTON=c->s1_y<-STICK_THRESHOLD;
			b.L_CBUTTON=c->s1_x<-STICK_THRESHOLD;
			b.R_CBUTTON=c->s1_x>STICK_THRESHOLD;

			b.X_AXIS=(c->left?-128:0) + (c->right?127:0);
			b.Y_AXIS=(c->up?127:0) + (c->down?-128:0);

			b.U_DPAD=c->s2_y>STICK_THRESHOLD;
			b.D_DPAD=c->s2_y<-STICK_THRESHOLD;
			b.L_DPAD=c->s2_x<-STICK_THRESHOLD;
			b.R_DPAD=c->s2_x>STICK_THRESHOLD;
			break;
	}

    Keys->Value = b.Value;
}
Esempio n. 11
0
void SDL_JoystickUpdate(void) {
    //TR
    usb_do_poll();
    get_controller_data(&controller_data[0], 0);
    get_controller_data(&controller_data[1], 1);
}
Esempio n. 12
0
int main(void)
{
   const char *s = NULL;
   char path[256];

   int handle;
   struct controller_data_s pad;
   int pos = 0, ppos = -1;

   xenos_init(VIDEO_MODE_AUTO);
   console_init();
   xenon_make_it_faster(XENON_SPEED_FULL);
   usb_init();
   usb_do_poll();
   xenon_ata_init();
   dvd_init();

   handle = -1;
   handle = bdev_enum(handle, &s);
   if (handle < 0)
      return 0;

   strcpy(path, s);
   strcat(path, ":/");	

   load_dir(path);

   for (;;)
   {
      usb_do_poll();		
      get_controller_data(&pad, 0);

      if (pad.s1_y > STICK_THRESHOLD || pad.up)
         pos--;
      if (pad.s1_y < -STICK_THRESHOLD || pad.down)
         pos++;

      if (entrycount && (pos < 0 || pos >= entrycount))
      {
         pos = ppos;
         continue;
      }

      if (pad.logo)
         return 0;

      if (pad.a)
      {
         if (entries[pos].d_type & DT_DIR)
         {
            append_dir_to_path(path,entries[pos].d_name);
            load_dir(path);
            ppos = -1;
            pos = 0;
         }
         else
         {
            char fn[256];
            strcpy(fn, path);
            strcat(fn, entries[pos].d_name);

            printf("%s\n", fn);

            start_ssnes(fn);
         }
      }

      if (pad.select)
      {
         append_dir_to_path(path, "..");
         load_dir(path);
         ppos = -1;
         pos = 0;
      }

      if (pad.b)
      {
         do
         {
            handle = bdev_enum(handle, &s);
         } while (handle < 0);

         strcpy(path, s);
         strcat(path, ":/");
         load_dir(path);
         ppos = -1;
         pos = 0;
      }

      if (ppos == pos)
         continue;

      memset(&pad, 0, sizeof(pad));

      console_set_colors(BG_COL, FG_COL);
      console_clrscr();
      printf("A: select, B: change disk, Back: parent dir, Logo: reload Xell\n\n%s\n\n", path);

      int start = MAX(0, pos - MAX_DISPLAYED_ENTRIES / 2);
      int count = MIN(MAX_DISPLAYED_ENTRIES, entrycount - start);

      for (int i = start; i < start + count; i++)
      {
         struct dirent *de = &entries[i];

         if (i == pos)
            console_set_colors(FG_COL, BG_COL);
         else
            console_set_colors(BG_COL, FG_COL);

         if (de->d_type & DT_DIR)
            console_putch('[');

         s = de->d_name;
         while (*s)
            console_putch(*s++);

         if (de->d_type & DT_DIR)
            console_putch(']');

         console_putch('\r');
         console_putch('\n');
      }

      ppos = pos;

      do
      {
         usb_do_poll();		
         get_controller_data(&pad, 0);
      } while (pad.a || pad.b || pad.select || pad.s1_y > STICK_THRESHOLD || pad.s1_y < -STICK_THRESHOLD);
   }

   return 0;
}