Exemple #1
0
void pspCtrlSetPollingMode(int mode)
{
  /* If autorepeat is being shut off, wait until it's "safe" */
  if (PollingMode == PSP_CTRL_AUTOREPEAT)
  {
    int i;
    SceCtrlData p;
    u64 tick;
    int wait;

    do
    {
      wait = 0;

      if (!sceCtrlPeekBufferPositive(&p, 1))
        break;

      /* Get current tick count */
      sceRtcGetCurrentTick(&tick);

      /* If at least one button is being held, wait until */
      /* next autorepeat interval, or until it's released */
      for (i = 0; i < PSP_CTRL_BUTTONS; i++)
        if (tick < PushTime[i] && (p.Buttons & ButtonMap[i]))
          { wait = 1; break; }
    }
    while (wait);
  }

  PollingMode = mode;

  /* If autorepeat is being turned on, initialize autorepeat data */
  if (mode == PSP_CTRL_AUTOREPEAT)
  {
    SceCtrlData p;
    int i;
    u64 tick;
    u32 tick_res;

    /* Poll the controls */
    if (sceCtrlPeekBufferPositive(&p, 1))
    {
      /* Get current tick count */
      sceRtcGetCurrentTick(&tick);
      tick_res = sceRtcGetTickResolution();

      /* Check each button */
      for (i = 0; i < PSP_CTRL_BUTTONS; i++)
        PushTime[i] = (p.Buttons & ButtonMap[i]) ? tick + PSP_CTRL_DELAY * (tick_res / 1000) : 0;
    }
  }
}
Exemple #2
0
//*************************************************************************************
//Panic button thread quits to the menu when pressed
//*************************************************************************************
static int PanicThread( SceSize args, void * argp )
{
	const u32 MASK = PSP_CTRL_LTRIGGER | PSP_CTRL_RTRIGGER | PSP_CTRL_START;

	u32 count = 0;

	//Loop 4 ever
	while(1)
	{
		SceCtrlData pad;
		sceCtrlPeekBufferPositive(&pad, 1);

		if( (pad.Buttons & MASK) == MASK )
		{
			 if(++count > 5)         //If button press for more that 2sec we return to main menu
			{
				count = 0;
				CGraphicsContext::Get()->ClearAllSurfaces();
				CPU_Halt("Panic");
				ThreadSleepMs(2000);
			}
		}
		else count = 0;

		//Idle here, only check button 3 times/sec not to hog CPU time from EMU
		ThreadSleepMs(300);
	}

	return 0;
}
Exemple #3
0
void testControllerTimmings() {
	u64 tick0, tick1;
	int n;
	SceCtrlData pad_data;
	SceCtrlLatch latch;
	
	// Test sceCtrlReadBufferPositive
	sceRtcGetCurrentTick(&tick0);
	for (n = 0; n < 5; n++) sceCtrlReadBufferPositive(&pad_data, 1);
	sceRtcGetCurrentTick(&tick1);
	printf("%d\n", (tick1 - tick0 > 5000));

	// Test sceCtrlReadLatch
	sceRtcGetCurrentTick(&tick0);
	for (n = 0; n < 5; n++) sceCtrlReadLatch(&latch);
	sceRtcGetCurrentTick(&tick1);
	printf("%d\n", (tick1 - tick0 > 5000));

	// Test sceCtrlPeekBufferPositive
	sceRtcGetCurrentTick(&tick0);
	for (n = 0; n < 5; n++) sceCtrlPeekBufferPositive(&pad_data, 1);
	sceRtcGetCurrentTick(&tick1);
	printf("%d\n", (tick1 - tick0 < 5000));

	// Test sceCtrlPeekLatch
	/*
	sceRtcGetCurrentTick(&tick0);
	for (n = 0; n < 5; n++) sceCtrlPeekLatch(&pad_data, 1);
	sceRtcGetCurrentTick(&tick1);
	printf("%d\n", (tick1 - tick0 < 5000));
	*/
}
Exemple #4
0
int run_emu(const char *path)
{
	SceCtrlData pad;
	unsigned int joypad1, joypad2;
	
	setup_audio();

	emu->set_sample_rate(44100);
	emu->set_equalizer(Nes_Emu::nes_eq);
	emu->set_palette_range(0);

	vita2d_texture *tex = vita2d_create_empty_texture(Nes_Emu::image_width, Nes_Emu::image_height);
	void *tex_data = vita2d_texture_get_datap(tex);

	static uint32_t video_buffer[Nes_Emu::image_width * Nes_Emu::image_height];
	emu->set_pixels(video_buffer, Nes_Emu::image_width);

	Auto_File_Reader freader(path);
	emu->load_ines(freader);

	int scale = 2;
	int pos_x = SCREEN_W/2 - (Nes_Emu::image_width/2)*scale;
	int pos_y = SCREEN_H/2 - (Nes_Emu::image_height/2)*scale;

	while (1) {
		sceCtrlPeekBufferPositive(0, &pad, 1);
		if ((pad.buttons & CHANGE_GAME_MASK) == CHANGE_GAME_MASK) break;

		joypad1 = joypad2 = update_input(&pad);

		emu->emulate_frame(joypad1, joypad2);
		const Nes_Emu::frame_t &frame = emu->frame();

		const uint8_t *in_pixels = frame.pixels;
		uint32_t *out_pixels = (uint32_t *)tex_data;

		for (unsigned h = 0; h < Nes_Emu::image_height;
			h++, in_pixels += frame.pitch, out_pixels += Nes_Emu::image_width) {
			for (unsigned w = 0; w < Nes_Emu::image_width; w++) {
				unsigned col = frame.palette[in_pixels[w]];
				const Nes_Emu::rgb_t& rgb = emu->nes_colors[col];
				unsigned r = rgb.red;
				unsigned g = rgb.green;
				unsigned b = rgb.blue;
				out_pixels[w] = 0xFF000000 | (r << 0) | (g << 8) | (b << 16);
			}
		}

		vita2d_start_drawing();
		vita2d_clear_screen();

		vita2d_draw_texture_scale(tex, pos_x, pos_y, scale, scale);
		show_fps();

		vita2d_end_drawing();
		vita2d_swap_buffers();
	}

	return 0;
}
Exemple #5
0
static int MainThread( SceSize args, void *argp )
{
	hookDisplay();

	sceKernelDcacheWritebackInvalidateAll();
	sceKernelIcacheInvalidateAll();

	unsigned int paddata_old = 0;
	SceCtrlData paddata;
	
	sceKernelDelayThread(10000);

	
	while(1)
	{
		sceCtrlPeekBufferPositive(&paddata, 1);
		
		if(paddata.Buttons != paddata_old)
		{
			//press "note" button and magick begin
			if(paddata.Buttons & PSP_CTRL_NOTE)
			{
				//can parse command list
				can_parse = 1;
				
			}
		}
		paddata_old = paddata.Buttons;
		sceKernelDelayThread(10000);
	}

	return( 0 );
}
void Psp2Ui::ProcessEvents() {
	
	SceCtrlData input;
	sceCtrlPeekBufferPositive(0, &input, 1);
	keys[Input::Keys::Z] = (input.buttons & SCE_CTRL_CROSS);
	keys[Input::Keys::X] = (input.buttons & SCE_CTRL_CIRCLE);
	keys[Input::Keys::N2] = (input.buttons & SCE_CTRL_TRIANGLE);
	keys[Input::Keys::LSHIFT] = (input.buttons & SCE_CTRL_SQUARE);
	keys[Input::Keys::F12] = (input.buttons & SCE_CTRL_SELECT);
	keys[Input::Keys::ESCAPE] = (input.buttons & SCE_CTRL_START);
	keys[Input::Keys::RIGHT] = (input.buttons & SCE_CTRL_RIGHT);
	keys[Input::Keys::LEFT] = (input.buttons & SCE_CTRL_LEFT);
	keys[Input::Keys::UP] = (input.buttons & SCE_CTRL_UP);
	keys[Input::Keys::DOWN] = (input.buttons & SCE_CTRL_DOWN);
	keys[Input::Keys::F2] = (input.buttons & SCE_CTRL_LTRIGGER);
	
	//Resolution changing support
	bool old_state = trigger_state;
	trigger_state = (input.buttons & SCE_CTRL_RTRIGGER);
	if ((trigger_state != old_state) && trigger_state) zoom_state = ((zoom_state + 1) % 3);
	
	// Left analog support
	keys[Input::Keys::JOY_AXIS_X_LEFT] = (input.lx < 50);
	keys[Input::Keys::JOY_AXIS_X_RIGHT] = (input.lx > 170);
	keys[Input::Keys::JOY_AXIS_Y_DOWN] = (input.ly > 170);
	keys[Input::Keys::JOY_AXIS_Y_UP] = (input.ly < 50);
	
	// Right analog support for extra buttons
	keys[Input::Keys::N1] = (input.ry > 170);
	keys[Input::Keys::N3] = (input.ry < 50);
	keys[Input::Keys::N5] = (input.rx > 170);
	keys[Input::Keys::N9] = (input.rx < 50);
	
}
Exemple #7
0
int cefiveui_update_controls(CEFiveUi* prUi) {
    static unsigned int last = 0;
    static int rpt = 0;
    SceCtrlData rCdata;
    unsigned int curr = 0;
    
    if (prUi == NULL) {
        return CEFIVEUI_NULLPTR;
    }
    sceCtrlPeekBufferPositive(&rCdata, 1);
    curr = rCdata.Buttons;
    if (curr == last && last != 0) {
        rpt++;
        if (rpt > 2) {
            cefiveui_buttoncallback(curr, last, prUi);
            rpt = 0;
        }
    }
    if ((rCdata.Lx > 0) || (rCdata.Ly > 0)) {
        analog_input(prUi, rCdata.Lx, rCdata.Ly);
    }
    last = curr;
    
    return CEFIVEUI_SUCCESS;
}
Exemple #8
0
/**
 * control_update:  Update the current controller status.
 *
 * [Parameters]
 *     None
 * [Return value]
 *     None
 */
void control_update(void)
{
    SceCtrlData pad_data;
    sceCtrlPeekBufferPositive(&pad_data, 1);

    last_buttons = buttons;
    buttons = pad_data.Buttons;

    /* If the directional pad isn't being used, check the analog pad instead */
    if (!(buttons & 0x00F0)) {
        if (pad_data.Lx < 32) {
            buttons |= PSP_CTRL_LEFT;
        } else if (pad_data.Lx >= 224) {
            buttons |= PSP_CTRL_RIGHT;
        }
        if (pad_data.Ly < 32) {
            buttons |= PSP_CTRL_UP;
        } else if (pad_data.Ly >= 224) {
            buttons |= PSP_CTRL_DOWN;
        }
    }

    /* The OS doesn't seem to reset the screensaver timeout when the
     * analog pad is moved, so take care of that ourselves */
    if (pad_data.Lx < 32 || pad_data.Lx >= 224
     || pad_data.Ly < 32 || pad_data.Ly >= 224
    ) {
        scePowerTick(0);
    }
}
Exemple #9
0
int Ctrl_read(lua_State *L)
{
	SceCtrlData *pad = pushCtrl(L);
	
	sceCtrlPeekBufferPositive(pad, 1);
	
	return 1;
}
static int Controls_readPeek(lua_State *L)
{
	int argc = lua_gettop(L);
	if(argc) return luaL_error(L, "Argument error: Controls.read() cannot be called from an instance.");
	Controls* pad = pushControls(L);
	sceCtrlPeekBufferPositive(pad, 1); 
	return 1;
}
Exemple #11
0
void list_finish_callback(int id)
{
   if (id != GBA_DISPLAY_LIST_ID)
      return;

//   if (read_system_buttons()&PSP_CTRL_VOLUP)
   SceCtrlData pad;
   sceCtrlPeekBufferPositive(&pad,1);
   debug_setpos(0,0);
   debug_printf("palette_ram[0] :0x%04X\n", palette_ram[0]);
   if (pad.Ly > 200)
   {
      debug_setpos(0,0);

      debug_printf("frame :%u\n", frame_count);
      debug_printf("bg_mode : %u\n", current_status.bg_mode);
      debug_printf("obj_character_vram_mapping : %u\n", current_status.obj_character_vram_mapping);
      debug_printf("screen_display_BG0 : %u\n", current_status.screen_display_BG0);
      debug_printf("screen_display_BG1 : %u\n", current_status.screen_display_BG1);
      debug_printf("screen_display_BG2 : %u\n", current_status.screen_display_BG2);
      debug_printf("screen_display_BG3 : %u\n", current_status.screen_display_BG3);
      debug_printf("screen_display_OBJ : %u\n", current_status.screen_display_OBJ);
      debug_printf("window0_display_flag : %u\n", current_status.window0_display_flag);
      debug_printf("window1_display_flag : %u\n", current_status.window1_display_flag);
      debug_printf("obj_window_display_flag : %u\n", current_status.obj_window_display_flag);
      debug_printf("bg0_palette_mode_256 : %u\n", current_status.bg0_palette_mode_256);
      debug_printf("bg0_mosaic : %u\n", current_status.bg0_mosaic);
      debug_printf("bg0_screen_size : %u\n", current_status.bg0_screen_size);
      debug_printf("bg1_palette_mode_256 : %u\n", current_status.bg1_palette_mode_256);
      debug_printf("bg1_mosaic : %u\n", current_status.bg1_mosaic);
      debug_printf("bg1_screen_size : %u\n", current_status.bg1_screen_size);
      debug_printf("bg2_palette_mode_256 : %u\n", current_status.bg2_palette_mode_256);
      debug_printf("bg2_mosaic : %u\n", current_status.bg2_mosaic);
      debug_printf("bg2_screen_size : %u\n", current_status.bg2_screen_size);
      debug_printf("bg3_palette_mode_256 : %u\n", current_status.bg3_palette_mode_256);
      debug_printf("bg3_mosaic : %u\n", current_status.bg3_mosaic);
      debug_printf("blend_status : %u\n", current_status.blend_status);

      static char buffer[7];
      buffer[6] = '\0';
      unsigned i;

      for (i = 0; i < 6 ; i++)
          buffer[5 - i] = (current_status.blend_first & (1 << i))? '1' : '0';
      debug_printf("blend_first  : %s\n",buffer);

      for (i = 0; i < 6 ; i++)
          buffer[5 - i] = (current_status.blend_second & (1 << i))? '1' : '0';
      debug_printf("blend_second : %s\n",buffer);
   }

//   sceGuSetAllStatus(main_context_status);
   sceGeRestoreContext(&main_context_buffer);
//   sceGuClearColor(0x00000000);


}
Exemple #12
0
unsigned long Read_Key(void) {

    sceCtrlPeekBufferPositive(0, &ctl, 1);

	if (ctl.buttons == control_bef_ctl) {
		return 0;
	}
	control_bef_ctl  = ctl.buttons;
	return control_bef_ctl;
}
Exemple #13
0
int main(int argc, char*argv[])
{	
	(void)argc;
	(void)argv;
	
	int error = 0;

	char scriptpath[256];
	
	getcwd(initpath, 256);
		
	pgeLuaIniFile inifile;
	
	pgeLuaIniReadFile("pge.ini", &inifile);
	
	if(inifile.browserused)
		sce_newlib_heap_kb_size -= 7*1024;
	
	strcpy(scriptpath, initpath);
	strcat(scriptpath, "/script.lua");
	
	SceCtrlData pad;
	
	while(pgeRunning())
	{
		error = pgeLuaRunScript(scriptpath);
			
		if(error)
		{
			#ifdef __PSP__
			pgeLuaDebugOutput("\nPress START to restart.\n");
			#endif
		
			while(pgeRunning())
			{
				sceCtrlPeekBufferPositive(&pad, 1);
			
				if(pad.Buttons & PSP_CTRL_START)
				{
					pgeLuaRestart();
				}
				
				sceKernelDelayThread(1000);
			}
		
		}
		
		if(!error)
			break;
	}
	
	pgeExit();
	
	return 0;
}
Exemple #14
0
int main()
{
	SceCtrlData pad;
	vita2d_pgf *pgf;
	vita2d_texture *image;
	float rad = 0.0f;

	vita2d_init();
	vita2d_set_clear_color(RGBA8(0x40, 0x40, 0x40, 0xFF));

	pgf = vita2d_load_default_pgf();

	/*
	 * Load the statically compiled image.png file.
	 */
	image = vita2d_load_PNG_buffer(&_binary_image_png_start);

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

	while (1) {
		sceCtrlPeekBufferPositive(0, &pad, 1);

		if (pad.buttons & SCE_CTRL_START)
			break;

		vita2d_start_drawing();
		vita2d_clear_screen();

		vita2d_draw_rectangle(20, 20, 400, 250, RGBA8(255, 0, 0, 255));
		vita2d_draw_rectangle(680, 350, 100, 150, RGBA8(0, 0, 255, 255));
		vita2d_draw_fill_circle(200, 420, 100, RGBA8(0, 255,0 ,255));

		vita2d_draw_texture_rotate(image, 940/2, 544/2, rad);

		vita2d_draw_line(500, 30, 800, 300, RGBA8(255, 0, 255, 255));

		vita2d_pgf_draw_text(pgf, 700, 30, RGBA8(0,255,0,255), 1.0f, "PGF Font sample!");

		vita2d_end_drawing();
		vita2d_swap_buffers();

		rad += 0.1f;
	}

	/*
	 * vita2d_fini() waits until the GPU has finished rendering,
	 * then we can free the assets freely.
	 */
	vita2d_fini();
	vita2d_free_texture(image);
	vita2d_free_pgf(pgf);

	sceKernelExitProcess(0);
	return 0;
}
Exemple #15
0
/*
 * Collect pad data about once per frame
 */
int JoystickUpdate(void *data)
{
    while (running) {
        SDL_SemWait(pad_sem);
        sceCtrlPeekBufferPositive(&pad, 1);
        SDL_SemPost(pad_sem);
        /* Delay 1/60th of a second */
        sceKernelDelayThread(1000000 / 60);
    }
    return 0;
}
Exemple #16
0
void Psp2Ui::ProcessEvents() {
	
	SceCtrlData input;
	sceCtrlPeekBufferPositive(0, &input, 1);
	keys[Input::Keys::Z] = (input.buttons & SCE_CTRL_CROSS);
	keys[Input::Keys::X] = (input.buttons & SCE_CTRL_CIRCLE);
	keys[Input::Keys::N2] = (input.buttons & SCE_CTRL_TRIANGLE);
	keys[Input::Keys::LSHIFT] = (input.buttons & SCE_CTRL_SQUARE);
	keys[Input::Keys::F12] = (input.buttons & SCE_CTRL_SELECT);
	keys[Input::Keys::ESCAPE] = (input.buttons & SCE_CTRL_START);
	keys[Input::Keys::RIGHT] = (input.buttons & SCE_CTRL_RIGHT);
	keys[Input::Keys::LEFT] = (input.buttons & SCE_CTRL_LEFT);
	keys[Input::Keys::UP] = (input.buttons & SCE_CTRL_UP);
	keys[Input::Keys::DOWN] = (input.buttons & SCE_CTRL_DOWN);
	keys[Input::Keys::F2] = (input.buttons & SCE_CTRL_LTRIGGER);
	
	//Resolution changing support
	bool old_state = trigger_state;
	trigger_state = (input.buttons & SCE_CTRL_RTRIGGER);
	if ((trigger_state != old_state) && trigger_state) zoom_state = ((zoom_state + 1) % 3);
	
	// Left analog support
	keys[Input::Keys::JOY_AXIS_X_LEFT] = (input.lx < 50);
	keys[Input::Keys::JOY_AXIS_X_RIGHT] = (input.lx > 170);
	keys[Input::Keys::JOY_AXIS_Y_DOWN] = (input.ly > 170);
	keys[Input::Keys::JOY_AXIS_Y_UP] = (input.ly < 50);
	
	// Right analog support for extra buttons
	keys[Input::Keys::N1] = (input.ry > 170);
	keys[Input::Keys::N3] = (input.ry < 50);
	keys[Input::Keys::N5] = (input.rx > 170);
	keys[Input::Keys::N9] = (input.rx < 50);
	
	// Touchpad support for shaders changes
	SceTouchData data;
	sceTouchPeek(SCE_TOUCH_PORT_FRONT, &data, 1);
	if (data.reportNum > 0){
		if (touch_x_start == -1) touch_x_start = data.report[0].x;
		}else if (touch_x_start > 0){
			int xdiff = data.report[0].x - touch_x_start;
			if (xdiff > 400){
				set_shader = true;
				touch_x_start = -2;
				in_use_shader++;
				if (in_use_shader >= SHADERS_NUM) in_use_shader = 0;
			}else if (xdiff < -400){
				set_shader = true;
				touch_x_start = -2;
				in_use_shader--;
				if (in_use_shader < 0) in_use_shader = SHADERS_NUM - 1;
			}
	}else touch_x_start = -1;
	
}
static int lua_readC(lua_State *L)
{
    int argc = lua_gettop(L);
    if (argc != 0 && argc != 1) return luaL_error(L, "wrong number of arguments.");
	int port = 0;
	if (argc == 1) port = luaL_checkinteger(L, 1); 
	SceCtrlData pad;
	sceCtrlPeekBufferPositive(port, &pad, 1);
	lua_pushinteger(L, pad.buttons);
	return 1;
}
Exemple #18
0
void do_menu(void)
{
	SceCtrlData pad;
	int selected = 0;
	unsigned int lastbut = TRIGGER;
	unsigned int curr = 0;

	redraw_menu(selected);
	while(1)
	{
		sceCtrlPeekBufferPositive(&pad, 1);

		curr = pad.Buttons & ~lastbut;
		
		if(curr & PSP_CTRL_UP)
		{
			if(selected > 0)
			{
				selected--;
			}
			else if(selected == 0)
			{
				selected = opt_count-1;
			}
			redraw_menu(selected);
		}
		if(curr & PSP_CTRL_DOWN)
		{
			if(selected < (opt_count-1))
			{
				selected++;
			}
			else if(selected == (opt_count-1))
			{
				selected = 0;
			}
			redraw_menu(selected);
		}
		if(curr & PSP_CTRL_CIRCLE)
		{
			options[selected].do_option();
		}
		else if(curr & PSP_CTRL_CROSS)
		{
			return;
		}
		lastbut = pad.Buttons;
		if(sceDisplayWaitVblankStart() < 0)
		{
			sceKernelExitDeleteThread(0);
		}
	}
}
Exemple #19
0
int main()
{
	vita2d_init();
	vita2d_set_clear_color(RGBA8(0x40, 0x40, 0x40, 0xFF));

	vita2d_pgf *pgf = vita2d_load_default_pgf();

	vita2d_texture *tex = vita2d_create_empty_texture(128, 128);
	unsigned int *tex_data = vita2d_texture_get_datap(tex);

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

	float rad = 0.0f;

	while (1) {
		sceCtrlPeekBufferPositive(0, &pad, 1);
		if (pad.buttons & SCE_CTRL_START) break;

		vita2d_start_drawing();
		vita2d_clear_screen();

		vita2d_draw_rectangle(20, 20, 400, 250, RGBA8(255, 0, 0, 255));
		vita2d_draw_rectangle(680, 350, 100, 150, RGBA8(0, 0, 255, 255));
		vita2d_draw_fill_circle(200, 420, 100, RGBA8(0, 255,0 ,255));

		/* Fill the texture with random data */
		int i, j;
		for (i = 0; i < 128; i++) {
			for (j = 0; j < 128; j++) {
				tex_data[j + i*128] = rand();
			}
		}

		vita2d_draw_texture_rotate(tex, 940/2, 544/2, rad);

		vita2d_draw_line(500, 30, 800, 300, RGBA8(255, 0, 255, 255));

		vita2d_pgf_draw_text(pgf, 700, 30, RGBA8(0,255,0,255), 1.0f, "PGF Font sample!");

		vita2d_end_drawing();
		vita2d_swap_buffers();

		rad += 0.1f;
	}

	vita2d_fini();
	vita2d_free_texture(tex);
	vita2d_free_pgf(pgf);

	sceKernelExitProcess(0);
	return 0;
}
Exemple #20
0
/**********
 * Retourne
 * La touche associee a l'event
 * -1 si il n'y a pas eu d'event
 * -2 si il y a eu un event dont on ne veut pas
 * -3 si il y a eu une touche non traitee
 **********/
int lireTouche() {
    static SceCtrlData pad, oldPad;
    sceCtrlPeekBufferPositive(&pad, 1);
    
    if (pad.Buttons & PSP_CTRL_UP) { return KEY_UP; }
    if (pad.Buttons & PSP_CTRL_DOWN) { return KEY_DOWN; }
    if (pad.Buttons & PSP_CTRL_LEFT) { return KEY_LEFT; }
    if (pad.Buttons & PSP_CTRL_RIGHT) { return KEY_RIGHT; }
    if (pad.Buttons & PSP_CTRL_START) { return KEY_QUIT; }
    if (pad.Buttons) { return -3; } /*Il y a eu une touche enfoncee, mais qui n'est pas connue*/
    
    return -1;
}
int main_thread(SceSize args, void *argp)
{
	int exit = 0, init_key = 0, model = 0, light = 0;
	SceCtrlData pad;
	sceCtrlPeekBufferPositive(&pad, 1);

	if(pad.Buttons & PSP_CTRL_LTRIGGER)
	{
		exit = 1;
	}
	else if(pad.Buttons & PSP_CTRL_RTRIGGER)
	{
		light = 1;
	}

	if(!exit)
	{
		init_key = sceKernelInitKeyConfig();

		if(init_key == PSP_INIT_KEYCONFIG_VSH) // VSH MODE SPOTTED
		{
			loadStartModuleWithArgs("ms0:/seplugins/cfe/cfe_vsh.prx", 1, 0, NULL);
		}
		else
		{
			model = sceKernelGetModel();

			if(model == PSP_MODEL_SLIM_AND_LITE) // PSP SLIM SPOTTED
			{
				if(sceKernelInitApitype() == PSP_INIT_APITYPE_DISC) 
				{
					if(!light) loadStartModuleWithArgs("ms0:/seplugins/cfe/cfe_game.prx", 8, 0, NULL);
						else loadStartModuleWithArgs("ms0:/seplugins/cfe/cfe_light.prx", 1, 0, NULL);
				}
				else
				{
					loadStartModuleWithArgs("ms0:/seplugins/cfe/cfe_light.prx", 1, 0, NULL);
				}
			}
			else // PSP FAT SPOTTED
			{
				loadStartModuleWithArgs("ms0:/seplugins/cfe/cfe_light.prx", 1, 0, NULL);
			}
		}
	}

	sceKernelStopUnloadSelfModule(0, NULL, NULL, NULL);
	return 0;
}
Exemple #22
0
unsigned long Read_Key3(void) {

    sceCtrlPeekBufferPositive(0, &ctl, 1);

    if (ctl.ly >= 0xD0) ctl.buttons |= SCE_CTRL_DOWN;  // DOWN
    if (ctl.ly <= 0x30) ctl.buttons |= SCE_CTRL_UP;    // UP
    if (ctl.lx <= 0x30) ctl.buttons |= SCE_CTRL_LEFT;  // LEFT
    if (ctl.lx >= 0xD0) ctl.buttons |= SCE_CTRL_RIGHT; // RIGHT 

    if (ctl.buttons == control_bef_ctl) {
		return 0;
	}
    control_bef_ctl = ctl.buttons;
	return control_bef_ctl;
}
Exemple #23
0
static int main_thread(SceSize args, void *argp)
{
   SceCtrlData paddata;

   thread_active = 1;

   while (thread_active)
   {
      sceCtrlPeekBufferPositive(&paddata, 1);
      buttons = paddata.Buttons;
      sceKernelDelayThread(1000000/60);
   }

   sceKernelExitThread(0);

   return 0;
}
Exemple #24
0
unsigned int psp_pad_read(int blocking)
{
	unsigned int buttons;
	SceCtrlData pad;
	if (blocking)
	     sceCtrlReadBufferPositive(&pad, 1);
	else sceCtrlPeekBufferPositive(&pad, 1);
	buttons = pad.Buttons;

	// analog..
	buttons &= ~(BTN_NUB_UP|BTN_NUB_DOWN|BTN_NUB_LEFT|BTN_NUB_RIGHT);
	if (pad.Lx < 128 - ANALOG_DEADZONE) buttons |= BTN_NUB_LEFT;
	if (pad.Lx > 128 + ANALOG_DEADZONE) buttons |= BTN_NUB_RIGHT;
	if (pad.Ly < 128 - ANALOG_DEADZONE) buttons |= BTN_NUB_UP;
	if (pad.Ly > 128 + ANALOG_DEADZONE) buttons |= BTN_NUB_DOWN;

	return buttons;
}
Exemple #25
0
/***
 * Callback for polling for new input.
 */
void retro_input_poll_callback()
{
	sceCtrlPeekBufferPositive(0, pad, 1);
    uint32_t keys_down = pad->buttons;

    // first, handle (single) physical button presses
    unsigned int i;

    for (i = MAP_BUTTON_UP; i <= MAP_BUTTON_START; i++)
    {
        handle_button_press(ActiveConfig.ButtonMap[i], keys_down & PhysicalButtonMap[i]);
    }

    // next, handle multi-button presses (L + R or start + select)
    if ((keys_down & SCE_CTRL_LTRIGGER) && (keys_down & SCE_CTRL_RTRIGGER))
    {
        handle_button_press(ActiveConfig.ButtonMap[MAP_BUTTON_LRTRIGGERS], true);
    }

    if ((keys_down & SCE_CTRL_START) && (keys_down & SCE_CTRL_SELECT))
    {
        handle_button_press(ActiveConfig.ButtonMap[MAP_BUTTON_STARTSELECT], true);
    }

    // finally, handle analog sticks
    if (pad->ly < 128 - JOY_THRESHOLD) // analog up
    {
        handle_button_press(ActiveConfig.ButtonMap[MAP_ANALOG_UP], true);
    }
    else if (pad->ly > 128 + JOY_THRESHOLD) // analog down
    {
        handle_button_press(ActiveConfig.ButtonMap[MAP_ANALOG_DOWN], true);
    }

    if (pad->lx < 128 - JOY_THRESHOLD) // analog left
    {
        handle_button_press(ActiveConfig.ButtonMap[MAP_ANALOG_LEFT], true);
    }
    else if (pad->lx > 128 + JOY_THRESHOLD) // analog right
    {
        handle_button_press(ActiveConfig.ButtonMap[MAP_ANALOG_RIGHT], true);
    }
}
Exemple #26
0
void JGE::Run()
{

	u64 curr;

	while (!mDone)
	{
		if (!mPaused)
		{
			sceRtcGetCurrentTick(&curr);
			
			
			mDelta = (curr-mLastTime) / (float)mTickFrequency;// * 1000.0f; 
			mLastTime = curr;
			
			sceCtrlPeekBufferPositive(&mCtrlPad, 1);	// using sceCtrlPeekBufferPositive is faster than sceCtrlReadBufferPositive
														// because sceCtrlReadBufferPositive waits for vsync internally
		
			Update();

			mClicked = false;

			Render();

			if (mDebug)
			{
				if (strlen(mDebuggingMsg)>0)
				{
					pspDebugScreenSetXY(0, 0);
					pspDebugScreenPrintf(mDebuggingMsg);
				}
			}

			mOldButtons = mCtrlPad.Buttons;
		


		}

	}
	
}
Exemple #27
0
/* psp_joy_poll:
 *  Polls the active joystick devices and updates internal states.
 */
static int psp_joy_poll(void)
{
   SceCtrlData pad;
   int buffers_to_read = 1;
   uint8_t b;

   sceCtrlPeekBufferPositive(&pad, buffers_to_read);

   /* Report the status of the no directional buttons. */
   for (b=0; b<NBUTTONS; b++)
      joy[0].button[b].b = pad.Buttons & psp_controller_buttons[b].code;

   /* Report the status of the directional buttons. */
   joy[0].stick[0].axis[0].d1 = pad.Buttons & PSP_CTRL_LEFT;
   joy[0].stick[0].axis[0].d2 = pad.Buttons & PSP_CTRL_RIGHT;
   joy[0].stick[0].axis[1].d1 = pad.Buttons & PSP_CTRL_UP;
   joy[0].stick[0].axis[1].d2 = pad.Buttons & PSP_CTRL_DOWN;

   return 0;
}
Exemple #28
0
int main() {
	SceCtrlData pad;
	vita2d_pgf *pgf;
	vita2d_texture *image;
	float rad = 0.0f;
  
	vita2d_init();
	vita2d_set_clear_color(RGBA8(0x40, 0x40, 0x40, 0xFF));
  
	pgf = vita2d_load_default_pgf();
  
	image = vita2d_load_PNG_buffer(&_binary_image_png_start);
  
	memset(&pad, 0, sizeof(pad));
  
	while (1) {
		sceCtrlPeekBufferPositive(0, &pad, 1);
	
		if (pad.buttons & SCE_CTRL_START)
			break;
	
		vita2d_start_drawing();
		vita2d_clear_screen();
	
		vita2d_draw_texture_rotate(image, 940/2, 544/2, rad);
	
		vita2d_pgf_draw_text(pgf, 50, 50, RGBA8(255,255,255,255), 1.0f, "ミクのおっぱい柔かぁい。柔軟剤使ったのか?");
	
		vita2d_end_drawing();
		vita2d_swap_buffers();
	
		rad += 0.1f;
	}
  
	vita2d_fini();
	vita2d_free_texture(image);
	vita2d_free_pgf(pgf);
  
	sceKernelExitProcess(0);
	return 0;
}
Exemple #29
0
static void update_input(void)
{
	unsigned int i;
	unsigned int pressed;
	unsigned int released;

	sceCtrlPeekBufferPositive(0, &pad, 1);

	if (pad.lx < (128 - JOY_THRESHOLD))
		pad.buttons |= SCE_CTRL_LEFT;
	else if (pad.lx > (128 + JOY_THRESHOLD))
		pad.buttons |= SCE_CTRL_RIGHT;

	if (pad.ly < (128 - JOY_THRESHOLD))
		pad.buttons |= SCE_CTRL_UP;
	else if (pad.ly > (128 + JOY_THRESHOLD))
		pad.buttons |= SCE_CTRL_DOWN;

	pressed = pad.buttons & ~old_pad.buttons;
	released = ~pad.buttons & old_pad.buttons;

	if ((pad.buttons & EXIT_MASK) == EXIT_MASK) {
		running = false;
	} else if ((pressed & FULLSCREEN_MASK) == FULLSCREEN_MASK) {
		fullscreen = !fullscreen;
	} else if ((pressed & TURBO_MASK) == TURBO_MASK) {
		vita2d_set_vblank_wait(0);
	} else if ((released & TURBO_MASK) == TURBO_MASK) {
		vita2d_set_vblank_wait(1);
	}

	for (i = 0; i < KEY_MAP_SIZE; i++) {
		if (pressed & key_map[i].vita)
			theGearboyCore->KeyPressed(key_map[i].gb);
		else if (released & key_map[i].vita)
			theGearboyCore->KeyReleased(key_map[i].gb);
	}

	old_pad = pad;
}
Exemple #30
0
void joy_Update() {
    SceCtrlData pad;
    //why does read slow us down to something terrible?
    //now i am having to use peek
    sceCtrlPeekBufferPositive(&pad, 1);


    sticks[0].button[0] = (pad.Buttons & PSP_CTRL_CROSS)!=0;
    sticks[0].button[1] = (pad.Buttons & PSP_CTRL_CIRCLE)!=0;
    sticks[0].button[2] = (pad.Buttons & PSP_CTRL_SQUARE)!=0;
    sticks[0].button[3] = (pad.Buttons & PSP_CTRL_TRIANGLE)!=0;
    sticks[0].button[4] = (pad.Buttons & PSP_CTRL_SELECT)!=0;
    sticks[0].button[5] = (pad.Buttons & PSP_CTRL_START)!=0;
    sticks[0].button[6] = (pad.Buttons & PSP_CTRL_LTRIGGER)!=0;
    sticks[0].button[7] = (pad.Buttons & PSP_CTRL_RTRIGGER)!=0;
    sticks[0].up = (pad.Buttons & PSP_CTRL_UP)!=0;
    sticks[0].down = (pad.Buttons & PSP_CTRL_DOWN)!=0;
    sticks[0].left = (pad.Buttons & PSP_CTRL_LEFT)!=0;
    sticks[0].right = (pad.Buttons & PSP_CTRL_RIGHT)!=0;
    sticks[0].analog_x = pad.Lx;
    sticks[0].analog_y = pad.Ly;
}