Question is: should i obtain interfaces for all opening devices in my library ? Why i ask, its because for example for timer.device i have no needs to do that by some reasons. I.e. that kind of code in os4 library works pretty well:
// Open timer
if (OpenDevice("timer.device",unit,&handle->req.tr_node,0))
{
if (handle->my_port) DeleteMsgPort(handle->my_port);
FreeVec(handle);
return 0;
}
// Initialise timer
handle->req.tr_node.io_Message.mn_ReplyPort=port;
handle->req.tr_node.io_Command=TR_ADDREQUEST;
return handle;
Through when i try to use console.device, i have crashes till a not add IFACE like this:
// Convert a key from the raw key code
BOOL LIBFUNC L_ConvertRawKey(
REG(d0, USHORT code),
REG(d1, USHORT qual),
REG(a0, char *key))
{
struct Device *ConsoleDevice;
#ifdef __amigaos4__
struct ConsoleIFace *IConsole;
#endif
struct IOStdReq console_req;
BOOL ret=0;
// Open console device
if (!OpenDevice("console.device",-1,(struct IORequest *)&console_req,0))
{
struct InputEvent event;
// Get device base pointer
ConsoleDevice=console_req.io_Device;
#ifdef __amigaos4__
IConsole = (struct ConsoleIFace *)GetInterface(ConsoleDevice,"main",1,NULL);
#endif
// Build fake input event
event.ie_NextEvent=0;
event.ie_Class=IECLASS_RAWKEY;
event.ie_SubClass=0;
event.ie_Code=code;
event.ie_Qualifier=qual;
event.ie_EventAddress=0;
// Convert key
if ((RawKeyConvert(&event,key,1,0))>0) ret=1;
#ifdef __amigaos4__
DropInterface((struct Interface *)IConsole);
#endif
// Close device
CloseDevice((struct IORequest *)&console_req);
}
return ret;
}
Question is: why for timer IFACE is not necessary, but necessary for console.device.
I know that answer will be "obtain IFACE for everything all the time", just interesting to know why there is no needs to do it for timer.device. Also in interest about those ones:
Quote:
clipboard.device
trackdisk.device
diskspare.device
floppy.device
mfm.device
diskspare.device