Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
157 user(s) are online (148 user(s) are browsing Forums)

Members: 2
Guests: 155

vagappc, Mr_byte, more...

Support us!

Headlines

 
  Register To Post  

IFACE for devices in a library
Home away from home
Home away from home


See User information
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_portDeleteMsgPort(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(d0USHORT code),
    
REG(d1USHORT qual),
    
REG(a0char *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))>0ret=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


Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: IFACE for devices in a library
Just popping in
Just popping in


See User information
Quote:
Question is: why for timer IFACE is not necessary, but necessary for console.device.


Obtaining an interface is only necessary if you are calling one of the library functions of a device later. RawKeyConvert() is one of console.device's library functions. If you are using device IO only then obtaining the interface is not necessary.

As a thumb rule you must obtain the interface if there is something like this in the code (for m68k):

Quote:

// Get device base pointer
ConsoleDevice=console_req.io_Device;


For m68k the device base is the same as a library base to be able to call these functions. If you need to call timer.device functions like AddTime() or GetSysTime() then you must obtain the interface for timer.device, too.

Quote:

clipboard.device
trackdisk.device
diskspare.device
floppy.device
mfm.device


None of these devices offers any directly callable functions, only regular device IO via DoIO/SendIO/BeginIO is possible.

Go to top
Re: IFACE for devices in a library
Not too shy to talk
Not too shy to talk


See User information

Let the compiler help you:

#define __NOGLOBALIFACE__
#define __NOLIBBASE__

before

#include <proto/xxx.h>

Then the compiler will give you a "unknown symbol xxxBase" and "unknown symbol Ixxx" error for every required library base and interface.

Go to top
Re: IFACE for devices in a library
Just can't stay away
Just can't stay away


See User information
@thomas

Quote:

#define __NOGLOBALIFACE__
#define __NOLIBBASE__


Or rather just add "-D__NOGLOBALIFACE__ -D__NOLIBBASE__" to the compiler flags. Then you won't have to worry about where to place them in your source code files.

Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project