int PERLIBRETROInit(void) { void *controller; uint32_t i, j; PortData_struct* portdata = NULL; //1 multitap + 1 peripherial players = 7; if(!multitap[0] && !multitap[1]) players = 2; else if(multitap[0] && multitap[1]) players = 12; PerPortReset(); for(i = 0; i < players; i++) { //Ports can handle 6 peripherals, fill port 1 first. if((players > 2 && i < 6) || i == 0) portdata = &PORTDATA1; else portdata = &PORTDATA2; switch(pad_type[i]) { case RETRO_DEVICE_NONE: controller = NULL; break; case RETRO_DEVICE_ANALOG: controller = (void*)Per3DPadAdd(portdata); for(j = PERPAD_UP; j <= PERPAD_Z; j++) PerSetKey((i << 8) + j, j, controller); for(j = PERANALOG_AXIS1; j <= PERANALOG_AXIS7; j++) PerSetKey((i << 8) + j, j, controller); break; case RETRO_DEVICE_JOYPAD: default: controller = (void*)PerPadAdd(portdata); for(j = PERPAD_UP; j <= PERPAD_Z; j++) PerSetKey((i << 8) + j, j, controller); break; } } return 0; }
void YabauseThread::reloadControllers() { PerPortReset(); QtYabause::clearPadsBits(); Settings* settings = QtYabause::settings(); for ( uint port = 1; port < 3; port++ ) { settings->beginGroup( QString( "Input/Port/%1/Id" ).arg( port ) ); QStringList ids = settings->childGroups(); settings->endGroup(); ids.sort(); foreach ( const QString& id, ids ) { uint type = settings->value( QString( UIPortManager::mSettingsType ).arg( port ).arg( id ) ).toUInt(); switch ( type ) { case PERPAD: { PerPad_struct* padbits = PerPadAdd( port == 1 ? &PORTDATA1 : &PORTDATA2 ); settings->beginGroup( QString( "Input/Port/%1/Id/%2/Controller/%3/Key" ).arg( port ).arg( id ).arg( type ) ); QStringList padKeys = settings->childKeys(); settings->endGroup(); padKeys.sort(); foreach ( const QString& padKey, padKeys ) { const QString key = settings->value( QString( UIPortManager::mSettingsKey ).arg( port ).arg( id ).arg( type ).arg( padKey ) ).toString(); PerSetKey( key.toUInt(), padKey.toUInt(), padbits ); } break; } case PERMOUSE: QtYabause::mainWindow()->appendLog( "Mouse controller type is not yet supported" ); break; default: QtYabause::mainWindow()->appendLog( "Invalid controller type" ); break; } } }
void YabauseThread::reloadControllers() { PerPortReset(); QtYabause::clearPadsBits(); Settings* settings = QtYabause::settings(); for ( uint port = 1; port < 3; port++ ) { settings->beginGroup( QString( "Input/Port/%1/Id" ).arg( port ) ); QStringList ids = settings->childGroups(); settings->endGroup(); ids.sort(); foreach ( const QString& id, ids ) { uint type = settings->value( QString( UIPortManager::mSettingsType ).arg( port ).arg( id ) ).toUInt(); switch ( type ) { case PERPAD: { PerPad_struct* padbits = PerPadAdd( port == 1 ? &PORTDATA1 : &PORTDATA2 ); settings->beginGroup( QString( "Input/Port/%1/Id/%2/Controller/%3/Key" ).arg( port ).arg( id ).arg( type ) ); QStringList padKeys = settings->childKeys(); settings->endGroup(); padKeys.sort(); foreach ( const QString& padKey, padKeys ) { const QString key = settings->value( QString( UIPortManager::mSettingsKey ).arg( port ).arg( id ).arg( type ).arg( padKey ) ).toString(); PerSetKey( key.toUInt(), padKey.toUInt(), padbits ); } break; } case PERWHEEL: QtYabause::mainWindow()->appendLog( "Wheel controller type is not yet supported" ); break; case PER3DPAD: { PerAnalog_struct* analogbits = Per3DPadAdd( port == 1 ? &PORTDATA1 : &PORTDATA2 ); settings->beginGroup( QString( "Input/Port/%1/Id/%2/Controller/%3/Key" ).arg( port ).arg( id ).arg( type ) ); QStringList analogKeys = settings->childKeys(); settings->endGroup(); analogKeys.sort(); foreach ( const QString& analogKey, analogKeys ) { const QString key = settings->value( QString( UIPortManager::mSettingsKey ).arg( port ).arg( id ).arg( type ).arg( analogKey ) ).toString(); PerSetKey( key.toUInt(), analogKey.toUInt(), analogbits ); } break; } case PERGUN: QtYabause::mainWindow()->appendLog( "Gun controller type is not yet supported" ); break; case PERKEYBOARD: QtYabause::mainWindow()->appendLog( "Keyboard controller type is not yet supported" ); break; case PERMOUSE: { PerMouse_struct* mousebits = PerMouseAdd( port == 1 ? &PORTDATA1 : &PORTDATA2 ); settings->beginGroup( QString( "Input/Port/%1/Id/%2/Controller/%3/Key" ).arg( port ).arg( id ).arg( type ) ); QStringList mouseKeys = settings->childKeys(); settings->endGroup(); mouseKeys.sort(); foreach ( const QString& mouseKey, mouseKeys ) { const QString key = settings->value( QString( UIPortManager::mSettingsKey ).arg( port ).arg( id ).arg( type ).arg( mouseKey ) ).toString(); PerSetKey( key.toUInt(), mouseKey.toUInt(), mousebits ); } break; } case 0: // Unconnected break; default: QtYabause::mainWindow()->appendLog( "Invalid controller type" ); break; } } }
jint Java_org_yabause_android_YabauseRunnable_init( JNIEnv* env, jobject obj, jobject yab ) { yabauseinit_struct yinit; int res; void * padbits; if( initEGLFunc() == -1 ) return -1; yabause = (*env)->NewGlobalRef(env, yab); yinit.m68kcoretype = M68KCORE_C68K; yinit.percoretype = PERCORE_DUMMY; #ifdef SH2_DYNAREC yinit.sh2coretype = 2; #else yinit.sh2coretype = SH2CORE_DEFAULT; #endif yinit.vidcoretype = VIDCORE_SOFT; #ifdef HAVE_OPENSL yinit.sndcoretype = SNDCORE_OPENSL; #else yinit.sndcoretype = SNDCORE_AUDIOTRACK; #endif yinit.cdcoretype = CDCORE_ISO; yinit.carttype = GetCartridgeType(); yinit.regionid = 0; yinit.biospath = GetBiosPath(); yinit.cdpath = GetGamePath(); yinit.buppath = GetMemoryPath(); yinit.mpegpath = mpegpath; yinit.cartpath = GetCartridgePath(); yinit.videoformattype = VIDEOFORMATTYPE_NTSC; yinit.frameskip = 0; yinit.skip_load = 0; res = YabauseInit(&yinit); OSDChangeCore(OSDCORE_SOFT); PerPortReset(); padbits = PerPadAdd(&PORTDATA1); PerSetKey(PERPAD_UP, PERPAD_UP, padbits); PerSetKey(PERPAD_RIGHT, PERPAD_RIGHT, padbits); PerSetKey(PERPAD_DOWN, PERPAD_DOWN, padbits); PerSetKey(PERPAD_LEFT, PERPAD_LEFT, padbits); PerSetKey(PERPAD_START, PERPAD_START, padbits); PerSetKey(PERPAD_A, PERPAD_A, padbits); PerSetKey(PERPAD_B, PERPAD_B, padbits); PerSetKey(PERPAD_C, PERPAD_C, padbits); PerSetKey(PERPAD_X, PERPAD_X, padbits); PerSetKey(PERPAD_Y, PERPAD_Y, padbits); PerSetKey(PERPAD_Z, PERPAD_Z, padbits); ScspSetFrameAccurate(1); return res; }
void PERDXLoadDevices(char *inifilename) { char tempstr[MAX_PATH]; char string1[20]; char string2[20]; GUID guid; DIDEVCAPS didc; u32 i; int j, i2; int buttonid; DIPROPDWORD dipdw; int id; DWORD coopflags=DISCL_FOREGROUND | DISCL_NONEXCLUSIVE; BOOL loaddefault=TRUE; int numpads; HRESULT hr; if (!PERCore) return; PerPortReset(); memset(pad, 0, sizeof(pad)); // Check Connection Type if (GetPrivateProfileStringA("Input", "Port1Type", "", tempstr, MAX_PATH, inifilename) == 0) { // Check if it's using the old ini settings for peripherals if (GetPrivateProfileStringA("Peripheral1", "GUID", "", tempstr, MAX_PATH, inifilename) != 0) { // Convert to the newer type of settings for (i = 0; i < 2; i++) { sprintf(string1, "Port%dType", (int)i+1); WritePrivateProfileStringA("Input", string1, "1", inifilename); sprintf(string1, "Peripheral%d", (int)i+1); sprintf(string2, "Peripheral%dA", (int)i+1); if (GetPrivateProfileStringA(string1, "GUID", "", tempstr, MAX_PATH, inifilename)) WritePrivateProfileStringA(string2, "GUID", tempstr, inifilename); if (GetPrivateProfileStringA(string1, "EmulateType", "", tempstr, MAX_PATH, inifilename)) WritePrivateProfileStringA(string2, "EmulateType", tempstr, inifilename); for (i2 = 0; i2 < 13; i2++) { if (GetPrivateProfileStringA(string1, PerPadNames[i2], "", tempstr, MAX_PATH, inifilename)) WritePrivateProfileStringA(string2, PerPadNames[i2], tempstr, inifilename); } } // Remove old ini entries for (i = 0; i < 12; i++) { sprintf(string1, "Peripheral%d", (int)i+1); WritePrivateProfileStringA(string1, NULL, NULL, inifilename); } loaddefault = FALSE; } } else loaddefault = FALSE; if (loaddefault) { LoadDefaultPort1A(); return; } // Load new type settings for (i = 0; i < 2; i++) { sprintf(string1, "Port%dType", (int)i+1); if (GetPrivateProfileStringA("Input", string1, "", tempstr, MAX_PATH, inifilename) != 0) { porttype[i] = atoi(tempstr); switch(porttype[i]) { case 1: numpads = 1; break; case 2: numpads = 6; break; default: numpads = 0; break; } // Load new type settings for (j = 0; j < numpads; j++) { int padindex=(6*i)+j; padconf_struct *curdevice=&paddevice[padindex]; sprintf(string1, "Peripheral%d%C", (int)i+1, 'A' + j); // Let's first fetch the guid of the device if (GetPrivateProfileStringA(string1, "GUID", "", tempstr, MAX_PATH, inifilename) == 0) continue; if (GetPrivateProfileStringA(string1, "EmulateType", "0", string2, MAX_PATH, inifilename)) { curdevice->emulatetype = atoi(string2); if (curdevice->emulatetype == 0) continue; } if (curdevice->lpDIDevice) { // Free the default keyboard, etc. IDirectInputDevice8_Unacquire(curdevice->lpDIDevice); IDirectInputDevice8_Release(curdevice->lpDIDevice); } StringToGUID(tempstr, &guid); // Ok, now that we've got the GUID of the device, let's set it up if (FAILED(IDirectInput8_CreateDevice(lpDI8, &guid, &lpDIDevice[padindex], NULL) )) { curdevice->lpDIDevice = NULL; curdevice->emulatetype = 0; continue; } curdevice->lpDIDevice = lpDIDevice[padindex]; didc.dwSize = sizeof(DIDEVCAPS); if (FAILED(IDirectInputDevice8_GetCapabilities(lpDIDevice[padindex], &didc) )) continue; if (GET_DIDEVICE_TYPE(didc.dwDevType) == DI8DEVTYPE_KEYBOARD) { if (FAILED(IDirectInputDevice8_SetDataFormat(lpDIDevice[padindex], &c_dfDIKeyboard) )) continue; curdevice->type = TYPE_KEYBOARD; coopflags |= DISCL_NOWINKEY; } else if (GET_DIDEVICE_TYPE(didc.dwDevType) == DI8DEVTYPE_GAMEPAD || GET_DIDEVICE_TYPE(didc.dwDevType) == DI8DEVTYPE_JOYSTICK) { if (FAILED(IDirectInputDevice8_SetDataFormat(lpDIDevice[padindex], &c_dfDIJoystick2) )) continue; curdevice->type = TYPE_JOYSTICK; } else if (GET_DIDEVICE_TYPE(didc.dwDevType) == DI8DEVTYPE_MOUSE) { if (FAILED(IDirectInputDevice8_SetDataFormat(lpDIDevice[padindex], &c_dfDIMouse2) )) continue; curdevice->type = TYPE_MOUSE; coopflags = DISCL_FOREGROUND | DISCL_EXCLUSIVE; } hr = IDirectInputDevice8_SetCooperativeLevel(lpDIDevice[i], DXGetWindow(), coopflags); if (FAILED(hr)) continue; dipdw.diph.dwSize = sizeof(DIPROPDWORD); dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER); dipdw.diph.dwObj = 0; dipdw.diph.dwHow = DIPH_DEVICE; dipdw.dwData = 8; // should be enough // Setup Buffered input if (FAILED(IDirectInputDevice8_SetProperty(lpDIDevice[padindex], DIPROP_BUFFERSIZE, &dipdw.diph))) continue; IDirectInputDevice8_Acquire(lpDIDevice[padindex]); switch(curdevice->emulatetype) { case 1: // Standard Pad id = PERPAD; break; case 2: // Analog Pad case 3: // Stunner case 5: // Keyboard id = 0; break; case 4: // Mouse id = PERMOUSE; break; default: break; } // Make sure we're added to the smpc list if (i == 0) pad[padindex] = PerAddPeripheral(&PORTDATA1, id); else pad[padindex] = PerAddPeripheral(&PORTDATA2, id); // Now that we're all setup, let's fetch the controls from the ini if (curdevice->emulatetype != 3 && curdevice->emulatetype != 4) { for (i2 = 0; i2 < 13; i2++) { buttonid = GetPrivateProfileIntA(string1, PerPadNames[i2], 0, inifilename); PerSetKey(buttonid, i2, pad[padindex]); } } else if (curdevice->emulatetype == 4) { for (i2 = 0; i2 < 4; i2++) { buttonid = GetPrivateProfileIntA(string1, mouse_names[i2], 0, inifilename); PerSetKey(buttonid, PERMOUSE_LEFT+i2, pad[padindex]); } } } } } }
void LoadDefaultPort1A(void) { porttype[0] = 1; porttype[1] = 0; pad[0] = PerPadAdd(&PORTDATA1); PerSetKey(DIK_UP, PERPAD_UP, pad[0]); PerSetKey(DIK_DOWN, PERPAD_DOWN, pad[0]); PerSetKey(DIK_LEFT, PERPAD_LEFT, pad[0]); PerSetKey(DIK_RIGHT, PERPAD_RIGHT, pad[0]); PerSetKey(DIK_K, PERPAD_A, pad[0]); PerSetKey(DIK_L, PERPAD_B, pad[0]); PerSetKey(DIK_M, PERPAD_C, pad[0]); PerSetKey(DIK_U, PERPAD_X, pad[0]); PerSetKey(DIK_I, PERPAD_Y, pad[0]); PerSetKey(DIK_O, PERPAD_Z, pad[0]); PerSetKey(DIK_X, PERPAD_LEFT_TRIGGER, pad[0]); PerSetKey(DIK_Z, PERPAD_RIGHT_TRIGGER, pad[0]); PerSetKey(DIK_J, PERPAD_START, pad[0]); }