Example #1
0
Ps2FilesystemNode::Ps2FilesystemNode(const Common::String &path) {
	dbg_printf("NEW FSNODE(%s)\n", path.c_str());

	_path = path;

	if (path.empty()) {
		_isHere = true;
		_isDirectory = true; /* root is always a dir */
		_isRoot = true;
		_displayName = Common::String("PlayStation 2");
		_verified = true;
	} else if (path.lastChar() == ':') {
		_isHere = true;
		_isDirectory = true; /* devs are always a dir */
		_isRoot = false;
		_displayName = getDeviceDescription();
		_verified = true;
	} else {
		_verified = false;
		doverify();
		if (!_isHere)
			return;

		_displayName = _lastPathComponent(_path);

		if (_isDirectory && _path.lastChar() != '/')
			_path+= '/';

		_isRoot = false;
	}
}
Example #2
0
long HFSReadFile(CICell ih, char * filePath, void *base, uint64_t offset,  uint64_t length)
{
    char entry[512];
    char devStr[12];
    long dirID, result, flags;

    if (HFSInitPartition(ih) == -1) return -1;

    dirID = kHFSRootFolderID;
    // Skip a lead '\'.  Start in the system folder if there are two.
    if (filePath[0] == '/') {
        if (filePath[1] == '/') {
            if (gIsHFSPlus) dirID = SWAP_BE32(((long *)gHFSPlus->finderInfo)[5]);
            else dirID = SWAP_BE32(gHFSMDB->drFndrInfo[5]);
            if (dirID == 0) {
		return -1;
	    }
            filePath++;
        }
        filePath++;
    }

    result = ResolvePathToCatalogEntry(filePath, &flags, entry, dirID, 0);
    if ((result == -1) || ((flags & kFileTypeMask) != kFileTypeFlat)) {
	return -1;
    }

#if UNUSED
    // Not yet for Intel. System.config/Default.table will fail this check.
    // Check file owner and permissions.
    if (flags & (kOwnerNotRoot | kPermGroupWrite | kPermOtherWrite)) return -1;
#endif

    result = ReadFile(entry, &length, base, offset);
    if (result == -1) {
	return -1;
    }

    getDeviceDescription(ih, devStr);

    /*if (strstr(filePath, ".plist")) verbose("LoadConfig: [%s/%s] %d bytes.\n", devStr, filePath, (uint32_t)length);*/
    if (strstr(filePath, "com.apple.Boot.plist")) verbose("Config: [%s/%s] %d bytes.\n", devStr, filePath, (uint32_t)length);
    if (strstr(filePath, "theme.plist"))
    {
    	//valv: inspired from toitione's rtrim
    	int t_len = strlen(filePath) - 12;
    	char *themePath = strncpy(malloc(t_len + 1), filePath, t_len);
    	themePath[t_len+1] = '\0';
    	verbose("Theme: [%s]/%s\n", devStr, themePath);
    }
//    if (strstr(filePath, "theme.plist")) verbose("Theme: [%s].\n", devStr);
    if (strstr(filePath, "smbios.plist")) verbose("SMBios: [%s/%s] %d bytes.\n", devStr, filePath, (uint32_t)length);
    if (strstr(filePath, ".aml")) verbose("ACPI: [%s/%s] %d bytes.\n", devStr, filePath, (uint32_t)length);
    return length;
}
Example #3
0
long HFSReadFile(CICell ih, char * filePath, void *base, uint64_t offset,  uint64_t length)
{
    char entry[512];
    char devStr[12];
    long dirID, result, flags = 0;
	
    if (HFSInitPartition(ih) == -1) return -1;
    
    dirID = kHFSRootFolderID;
    // Skip a lead '\'.  Start in the system folder if there are two.
    if (filePath[0] == '/') {
        if (filePath[1] == '/') {
            if (gIsHFSPlus) dirID = SWAP_BE32(((long *)gHFSPlus->finderInfo)[5]);
            else dirID = SWAP_BE32(gHFSMDB->drFndrInfo[5]);
            if (dirID == 0) {
				return -1;
			}
            filePath++;
        }
        filePath++;
    }
	
    result = ResolvePathToCatalogEntry(filePath, &flags, entry, dirID, 0);
    if ((result == -1) || ((flags & kFileTypeMask) != kFileTypeFlat)) {
		return -1;
    }
	
#if UNUSED
    // Not yet for Intel. System.config/Default.table will fail this check.
    // Check file owner and permissions.
    if (flags & (kOwnerNotRoot | kPermGroupWrite | kPermOtherWrite)) return -1;
#endif
	
    result = ReadFile(entry, &length, base, offset);
    if (result == -1) {
		return -1;
    }
	
    getDeviceDescription(ih, devStr, sizeof(devStr));
	
	if (get_env(envHFSLoadVerbose)) {
		verbose("Read HFS%s file: [%s/%s] %d bytes.\n",
				(gIsHFSPlus ? "+" : ""), devStr, filePath, (uint32_t)length);
	} else if (get_env(envHFSLoadVerbose) == 0) {		
		safe_set_env(envHFSLoadVerbose, 1);
	}
    
    return length;
}
Example #4
0
void Gamepad_detectDevices() {
	unsigned int numPadsSupported;
	unsigned int deviceIndex, deviceIndex2;
	JOYINFOEX info;
	JOYCAPS caps;
	bool duplicate;
	struct Gamepad_device * deviceRecord;
	struct Gamepad_devicePrivate * deviceRecordPrivate;
	UINT joystickID;
	int axisIndex;
	
	if (!inited) {
		return;
	}
	
	numPadsSupported = joyGetNumDevs();
	for (deviceIndex = 0; deviceIndex < numPadsSupported; deviceIndex++) {
		info.dwSize = sizeof(info);
		info.dwFlags = JOY_RETURNALL;
		joystickID = JOYSTICKID1 + deviceIndex;
		if (joyGetPosEx(joystickID, &info) == JOYERR_NOERROR &&
		    joyGetDevCaps(joystickID, &caps, sizeof(JOYCAPS)) == JOYERR_NOERROR) {
			
			duplicate = false;
			for (deviceIndex2 = 0; deviceIndex2 < numDevices; deviceIndex2++) {
				if (((struct Gamepad_devicePrivate *) devices[deviceIndex2]->privateData)->joystickID == joystickID) {
					duplicate = true;
					break;
				}
			}
			if (duplicate) {
				continue;
			}
			
			deviceRecord = malloc(sizeof(struct Gamepad_device));
			deviceRecord->deviceID = nextDeviceID++;
			deviceRecord->description = getDeviceDescription(joystickID, caps);
			deviceRecord->vendorID = caps.wMid;
			deviceRecord->productID = caps.wPid;
			deviceRecord->numAxes = caps.wNumAxes + ((caps.wCaps & JOYCAPS_HASPOV) ? 2 : 0);
			deviceRecord->numButtons = caps.wNumButtons;
			deviceRecord->axisStates = calloc(sizeof(float), deviceRecord->numAxes);
			deviceRecord->buttonStates = calloc(sizeof(bool), deviceRecord->numButtons);
			deviceRecord->eventDispatcher = EventDispatcher_create(deviceRecord);
			devices = realloc(devices, sizeof(struct Gamepad_device *) * (numDevices + 1));
			devices[numDevices++] = deviceRecord;
			
			deviceRecordPrivate = malloc(sizeof(struct Gamepad_devicePrivate));
			deviceRecordPrivate->joystickID = joystickID;
			deviceRecordPrivate->lastState = info;
			
			deviceRecordPrivate->xAxisIndex = 0;
			deviceRecordPrivate->yAxisIndex = 1;
			axisIndex = 2;
			deviceRecordPrivate->zAxisIndex = (caps.wCaps & JOYCAPS_HASZ) ? axisIndex++ : -1;
			deviceRecordPrivate->rAxisIndex = (caps.wCaps & JOYCAPS_HASR) ? axisIndex++ : -1;
			deviceRecordPrivate->uAxisIndex = (caps.wCaps & JOYCAPS_HASU) ? axisIndex++ : -1;
			deviceRecordPrivate->vAxisIndex = (caps.wCaps & JOYCAPS_HASV) ? axisIndex++ : -1;
			
			deviceRecordPrivate->axisRanges = malloc(sizeof(UINT[2]) * axisIndex);
			deviceRecordPrivate->axisRanges[0][0] = caps.wXmin;
			deviceRecordPrivate->axisRanges[0][1] = caps.wXmax;
			deviceRecordPrivate->axisRanges[1][0] = caps.wYmin;
			deviceRecordPrivate->axisRanges[1][1] = caps.wYmax;
			if (deviceRecordPrivate->zAxisIndex != -1) {
				deviceRecordPrivate->axisRanges[deviceRecordPrivate->zAxisIndex][0] = caps.wZmin;
				deviceRecordPrivate->axisRanges[deviceRecordPrivate->zAxisIndex][1] = caps.wZmax;
			}
			if (deviceRecordPrivate->rAxisIndex != -1) {
				deviceRecordPrivate->axisRanges[deviceRecordPrivate->rAxisIndex][0] = caps.wRmin;
				deviceRecordPrivate->axisRanges[deviceRecordPrivate->rAxisIndex][1] = caps.wRmax;
			}
			if (deviceRecordPrivate->uAxisIndex != -1) {
				deviceRecordPrivate->axisRanges[deviceRecordPrivate->uAxisIndex][0] = caps.wUmin;
				deviceRecordPrivate->axisRanges[deviceRecordPrivate->uAxisIndex][1] = caps.wUmax;
			}
			if (deviceRecordPrivate->vAxisIndex != -1) {
				deviceRecordPrivate->axisRanges[deviceRecordPrivate->vAxisIndex][0] = caps.wVmin;
				deviceRecordPrivate->axisRanges[deviceRecordPrivate->vAxisIndex][1] = caps.wVmax;
			}
			
			deviceRecordPrivate->povXAxisIndex = (caps.wCaps & JOYCAPS_HASPOV) ? axisIndex++ : -1;
			deviceRecordPrivate->povYAxisIndex = (caps.wCaps & JOYCAPS_HASPOV) ? axisIndex++ : -1;
			
			deviceRecord->privateData = deviceRecordPrivate;
			
			Gamepad_eventDispatcher()->dispatchEvent(Gamepad_eventDispatcher(), Atom_fromString(GAMEPAD_EVENT_DEVICE_ATTACHED), deviceRecord);
		}
	}
}