Exemple #1
0
void
psp_irkeyb_exit()
{
  if (psp_irda_is_kbd_mode()) {
    if (loc_psp_irkeyb_mode) {
      loc_psp_irkeyb_mode = 0;
      pspIrKeybFinish();
    }
  }
}
void PSP_EventQuit(_THIS)
{
    running = 0;
    SDL_WaitThread(thread, NULL);
    SDL_DestroySemaphore(event_sem);
#ifdef PSPIRKEYB
    if (irkbd_ready) {
            pspIrKeybFinish();
        irkbd_ready = 0;
    }
#endif
}
Exemple #3
0
int main(int argc, char *argv[])
{
    SceCtrlData pad;
    u32 buttonsold = 0;
    int ret;
    int outputmode = PSP_IRKBD_OUTPUT_MODE_VT100;

    /*
        possible output modes
                PSP_IRKBD_OUTPUT_MODE_ASCII
                PSP_IRKBD_OUTPUT_MODE_RAW
                PSP_IRKBD_OUTPUT_MODE_SCANCODE
                PSP_IRKBD_OUTPUT_MODE_VT100    
    */

	SetupCallbacks();
	pspDebugScreenInit();
    printf("PSP Irda Keyboard test\n");

    ret = pspIrKeybInit( CONFIG_FILE, KERNELMODE );
    if( ret == PSP_IRKBD_RESULT_OK )
    {
        pspIrKeybOutputMode( outputmode );

        if( outputmode == PSP_IRKBD_OUTPUT_MODE_ASCII )
            outputAsciiTest();
        else if( outputmode == PSP_IRKBD_OUTPUT_MODE_RAW )
            outputRawTest();
        else if( outputmode == PSP_IRKBD_OUTPUT_MODE_SCANCODE )
            outputScanCodeTest();
        else if( outputmode == PSP_IRKBD_OUTPUT_MODE_VT100 )
            outputVT100Test();

        if( pspIrKeybFinish() == 0 )
            printf( "\nclosed IR keyboard\n" );
        else
            printf( "\nerror: closing IR keyboard\n" );
    } else {
        switch( ret )
        {
            case PSP_IRKBD_RESULT_CANT_OPEN_DEVICE:
                printf( "error: can't open device\n" );
                break;
            case PSP_IRKBD_RESULT_CANT_OPEN_MAPFILE:
                printf( "error: can't open mapfile\n" );
                break;
            case PSP_IRKBD_RESULT_MAPFILE_MAXDEPTHLEVEL:
                printf( "error: mapfile max include level reached - recursion?\n" );
                break;
            case PSP_IRKBD_RESULT_CANT_OPEN_MAPFILE_INCLUDE:
                printf( "error: can't open include in mapfile\n" );
                break;
            case PSP_IRKBD_RESULT_CANT_SET_BAUDTATE:
                printf( "error: can't set baudrate - you need kernel support\n" );
                break; 
            case PSP_IRKBD_RESULT_CONFIG_FILE_NOT_FOUND:
                printf( "error: can't read config file\n" );
                break; 
            case PSP_IRKBD_RESULT_UNKNOW_KEYBOARD:
                printf( "error: unknown keyboard\n" );
                break;
            case PSP_IRKBD_RESULT_FAILED:
            default:
                printf( "error: init failed\n" );
                break;
        }
    }

    printf( "\n bye... (PRESS psp button to quit)\n" );

    while (1) {
        sceCtrlReadBufferPositive(&pad, 1);
        if (pad.Buttons != buttonsold) {
            /* Exit */
            sceKernelExitGame();
        }
    }


	return 0;
}
Exemple #4
0
int main(int argc, char *argv[])
{
    SceCtrlData pad;
    u32 buttonsold = 0;
    int kernelmode = 0;       /* only 0 works for now - some keyboards need baud change */
    const char *config_file = NULL; /* this will force ms0:/seplugins/pspirkeyb.ini */

	SetupCallbacks();

    pspDebugScreenInit();
    printf("PSP Irda Keyboard test - ASCii input \n");

	if (sceKernelDevkitVersion() >= 0x03080010)
	{
        /* Load irda PRX for CFW >= 3.80 - Thanks, ZX81! */
        u32 mod_id = sceKernelLoadModule("flash0:/kd/irda.prx", 0, NULL);
        sceKernelStartModule(mod_id, 0, NULL, NULL, NULL);
	}

    if( pspIrKeybInit( config_file, kernelmode ) != 0 )
    {
        printf( "error: can't inialize the keyboard\n" );
        printf( "       check keyboard type/map in ms0:/seplugins/pspirkeyb.ini\n" );
    }
    else
    {
        unsigned char termchar = 'X';
        unsigned char buffer[255];
        int i, length=0;

        printf("\npress %c on keyboard or any PSP button to exit\n", termchar );

        /* setup output method to ASCii */
        pspIrKeybOutputMode( PSP_IRKBD_OUTPUT_MODE_ASCII );

        while(1) {
            length = 0;
            /* non blocking read */
            if( pspIrKeybReadinput(buffer, &length) >= 0 )
            {
                for( i=0; i < length; i++ )
                    printf( "%c", buffer[i] );
                if( length == 1 && buffer[0] == termchar )
                    break;
            }
            else
            {
                sceKernelDelayThread(10*1000);
                sceCtrlReadBufferPositive(&pad, 1);
                if (pad.Buttons != buttonsold)
                    break;
            }
        }

        /* bye keyboard */
        pspIrKeybFinish();
    }

    printf( "\n bye... (PRESS psp button to quit)\n" );

    buttonsold = 0;
    while (1) {
        sceCtrlReadBufferPositive(&pad, 1);
        if (pad.Buttons != buttonsold) {
            /* Exit */
            sceKernelExitGame();
        }
    }

	return 0;
}