UNDER CONSTRUCTION
Reference
Home
Overview
Hardware
News
Download
License
Documentation
Reference
Help
FAQs
Contributing
Contact
Links

HaptikPlugin.hpp

Go to the documentation of this file.
00001 //---CREDITS
00002 // Name: Haptik Library
00003 // Desc: Plugin Development Header
00004 // Auto: Maurizio de Pascale
00005 // Date: July 17th 2005
00006 // Vers: 1.0.27
00007 // Tabs: tabbed at 3
00008 // Http: www.haptiklibrary.org
00009 //-------------------------------->
00010 #ifndef ___HAPTIK_PLUGIN___
00011 #define ___HAPTIK_PLUGIN___
00012  
00013  
00014  
00015 //---INCLUDE
00016 //------------------------>
00017 #include <RSLib\Haptik.hpp>
00018  
00019  
00020  
00021 //---NAMESPACE
00022 //------------->
00023 namespace RSLib {
00024  
00025  
00026  
00027 //---INTERFACE
00028 // Desc: Interface exposed by the library to the plugins. Used for 1) centralized services 2) reference counting 3) internal recursion
00029 //------------------------------------------------------------------------------------------------------------------------------------>
00030 typedef class IHaptikLibraryLower
00031 {
00032    public:
00033 // configuration file access  
00034    virtual PCHAR8 GetVariable(IN PCHAR8 name) PURE;
00035    virtual UINT32 SetVariable(IN PCHAR8 name,IN PCHAR8 value) PURE;
00036    
00037 // reference count management
00038    virtual UINT32 Lock() PURE;
00039    virtual UINT32 Unlock() PURE;
00040    
00041 // access to other devices for internal recursion
00042    virtual UINT32 GetNumberOfDevices() PURE;
00043    virtual UINT32 GetDeviceInfo(IN UINT32 deviceId,OUT HaptikDeviceInfoPtr pDev) PURE;
00044    virtual PVOID GetDeviceInterface(IN UINT32 deviceId,IN UINT32 interfaceId) PURE;
00045    
00046 // logging
00047    virtual UINT32 Log(IN PCHAR8 message) PURE;
00048 
00049 }*IHaptikLibraryLowerInterface;
00050  
00051  
00052  
00053 //---INTERFACE
00054 // Desc: Interface exposed by plugins and used by the library
00055 //----------------------------------------------------------->
00056 typedef class IHaptikPlugin
00057 {
00058    public:
00059    virtual UINT32 Init(IN IHaptikLibraryLowerInterface libraryInterface,IN UINT32 pluginId) PURE;
00060    virtual UINT32 Release() PURE;
00061    
00062    virtual UINT32 GetNumberOfDevices() PURE;
00063    virtual UINT32 GetDeviceInfo(IN UINT32 deviceId,OUT HaptikDeviceInfoPtr pDev) PURE;
00064    
00065    virtual PVOID GetDeviceInterface(IN UINT32 deviceId,IN UINT32 interfaceId) PURE;
00066    
00067    virtual UINT32 GetPluginInfo(OUT HaptikPluginInfoPtr pInfo) PURE;
00068    
00069 }*IHaptikPluginInterface;
00070  
00071  
00072  
00073 //---TYPEDEF
00074 // Desc: Plugin Dll entry point type
00075 //------------------------------------------------------------->
00076 extern "C" {typedef PVOID (*HAPTIK_PLUGIN_ENTRY_PROC) (UINT32);}
00077  
00078  
00079  
00080 //---UTILITIES
00081 // Desc: Asm code for method/procedure invocation
00082 // Note: A "dangerous" always restoring frame is implemented which gets identified as warning by the compiler
00083 //       It allows for invocation of methods with wrong number of arguments that do not mess the caller frame
00084 //----------------------------------------------------------------------------------------------------------->
00085 #pragma warning(push)
00086 #pragma warning( disable : 4731 )
00087 inline void InvokeCallback(PVOID method,PVOID object,PVOID argument1,PVOID argument2)
00088 {
00089    __asm
00090    {
00091       mov ecx,object    //mov input arguments to registers
00092       mov eax,method
00093       mov ebx,argument1
00094       mov edx,argument2
00095 
00096       push ebp       //save old ebp
00097       mov ebp,esp    //store before-call esp. LOCALS ARE NO MORE ACCESSIBLE!
00098 
00099       push edx       //push argument2
00100       push ebx       //push argument1
00101       call eax       //call method(procedure)
00102 
00103       mov esp,ebp    //restore before-call esp.
00104       pop ebp        //pop old ebp. LOCALS ARE ACCESSIBLE!
00105    }
00106 }
00107 #pragma warning( pop )
00108  
00109  
00110  
00111 };//namespace RSLib
00112  
00113  
00114  
00115 //---CONSTANTS
00116 //----------------------------------------------->
00117 #define HAPTIK_IHAPTIKLIBRARYLOWER     0x80008021
00118  
00119  
00120  
00121 //---MACROS
00122 //--------------------------------------------->
00123 #define IS_ORDINAL(id)     (!(id & 0x80000000))
00124 #define ISNT_ORDINAL(id)   (id & 0x80000000)
00125 
00126 #define HARDWAREID(id)     ((id & 0x0000FFFF)>>0)
00127 #define PLUGINID(id)       ((id & 0x00FF0000)>>16)
00128 #define NUMBER(id)         ((id & 0x1F000000)>>24)
00129 #define FLAGS(id)          ((id & 0xE0000000)>>29)
00130 
00131 #define MATCH_DEVICEID(a,b)         ( ((a & 0x0000FFFF) == 0xFFFF) || ((a & 0x1F00FFFF) == (b & 0x1F00FFFF)) )
00132 #define MATCH_PLUGINID(a,b)         ( ((a & 0x00FF0000) == 0x00FF0000) || (PLUGINID(a) == b) )
00133 #define UNMATCH_DEVICEID(a,b)       (!MATCH_DEVICEID(a,b))
00134 #define UNMATCH_PLUGINID(a,b)       (!MATCH_PLUGINID(a,b))
00135 
00136 #define FLAGGED_DEVICEID(flags,number,pluginid,hardwareid)  ( ((flags & 0x07)<<29) | ((number & 0x1F)<<24) | ((pluginid & 0xFF)<<16) | ((hardwareid& 0xFFFF)<<0) )
00137 #define DEVICEID(number,pluginid,hardwareid)                ( ((0x004 & 0x07)<<29) | ((number & 0x1F)<<24) | ((pluginid & 0xFF)<<16) | ((hardwareid& 0xFFFF)<<0) )
00138  
00139  
00140  
00141 #endif//___HAPTIK_PLUGIN___
Last Updated on 2006/02/01 09:53:39 UTC info@haptiklibrary.org