Translations of this page:

device_getinfo

The device_getinfo functions are used by MESS to get additional info about the devices used in a system. They are generally located in the systems/<drivername>.c file.

Syntax

All data that you want to return must be copied into the info union. A switch is used to selected the info MESS wants. Possible states are:

DEVINFO_INT_TYPE

The type of the device. Possible values are:

  • IO_FLOPPY (Floppy drives)
  • IO_PRINTER (Printer)

DEVINFO_INT_READABLE

Boolean value whether this device can read data. Possible values:

  • 1 - Data can be read from the device (example: floppy drive)
  • 0 - Data cannot be read from the device (example: printer)

DEVINFO_INT_WRITEABLE

Boolean value whether this device can write data. Possible values:

  • 1 - Data can be written to the device (example: printer)
  • 0 - Data cannot be written to the device (example: CD-ROM)

DEVINFO_INT_CREATABLE

Boolean value whether new files can be created for use with this device or not. Possible values:

  • 1 - A new file can be created for use with this device (example: empty floppy)
  • 0 - New files cannot be created for the device (example: CD-ROM)

DEVINFO_INT_COUNT

The number of devices this system can possibly use.

DEVINFO_INT_MUST_BE_LOADED

Boolean value whether this system needs a file attached to this device to boot.

  • 1 - Device needs a valid file for this device and won't start without one
  • 0 - System can be started without a valid file attached to this device

DEVINFO_PTR_LOAD

This is a pointer to the function which is called when the user mounts a new file for use with this device.

DEVINFO_STR_FILE_EXTENSIONS

This is a comma separated list representing the possible file extensions for this device.

Example

This could be the function for a floppy drive:

static void mydriver_floppy_getinfo(const device_class *devclass, UINT32 state, union devinfo *info)
{
	/* floppy */
	switch(state)
	{
		/* --- the following bits of info are returned as 64-bit signed integers --- */
		case DEVINFO_INT_TYPE:            info->i = IO_FLOPPY; break;
		case DEVINFO_INT_READABLE:        info->i = 1; break;
		case DEVINFO_INT_WRITEABLE:       info->i = 1; break;
		case DEVINFO_INT_CREATABLE:       info->i = 1; break;
		case DEVINFO_INT_COUNT:           info->i = 2; break;
 
		/* --- the following bits of info are returned as pointers to data or functions --- */
		case DEVINFO_PTR_LOAD:            info->load = device_load_mydriver_floppy; break;
 
		/* --- the following bits of info are returned as NULL-terminated strings --- */
		case DEVINFO_STR_FILE_EXTENSIONS: strcpy(info->s = device_temp_str(), "dsk"); break;
	}
}

In this example, we create a device of type IO_FLOPPY, that is readable, writable and creatable. The system supports two floppy drives. The function device_load_mydriver_floppy is called when the user mounts a new file (we don't actually write this function as is, we use the macro DEVICE_LOAD). The file extension is just dsk.

See also

reference/device_getinfo.txt · Last modified: 2007-11-19 11:14 by duke