project64/Source/Project64/Plugins/Controller Plugin.h

109 lines
3.2 KiB
C
Raw Normal View History

#ifndef CONTROL_STRUCTS
#define CONTROL_STRUCTS
typedef union {
DWORD Value;
struct {
unsigned R_DPAD : 1;
unsigned L_DPAD : 1;
unsigned D_DPAD : 1;
unsigned U_DPAD : 1;
unsigned START_BUTTON : 1;
unsigned Z_TRIG : 1;
unsigned B_BUTTON : 1;
unsigned A_BUTTON : 1;
unsigned R_CBUTTON : 1;
unsigned L_CBUTTON : 1;
unsigned D_CBUTTON : 1;
unsigned U_CBUTTON : 1;
unsigned R_TRIG : 1;
unsigned L_TRIG : 1;
unsigned Reserved1 : 1;
unsigned Reserved2 : 1;
signed Y_AXIS : 8;
signed X_AXIS : 8;
};
} BUTTONS;
typedef struct {
DWORD Present;
DWORD RawData;
int Plugin;
} CONTROL;
#endif
enum PluginType {
PLUGIN_NONE = 1,
PLUGIN_MEMPAK = 2,
PLUGIN_RUMBLE_PAK = 3,
PLUGIN_TANSFER_PAK = 4, // not implemeted for non raw data
PLUGIN_RAW = 5, // the controller plugin is passed in raw data
};
class CCONTROL {
friend CControl_Plugin; //controller plugin class has full access
DWORD & m_Present;
DWORD & m_RawData;
int & m_PlugType;
BUTTONS m_Buttons;
public:
CCONTROL (DWORD &Present,DWORD &RawData, int &PlugType );
inline bool Present (void) const { return m_Present != 0; }
inline DWORD Buttons (void) const { return m_Buttons.Value; }
inline PluginType Plugin (void) const { return static_cast<PluginType>(m_PlugType); }
};
class CControl_Plugin {
friend CC_Core;
CNotification * _Notify;
void * hDll;
bool m_Initilized, m_RomOpen, m_AllocatedControllers;
PLUGIN_INFO m_PluginInfo;
//What the diffent controls are set up as
CONTROL m_PluginControllers[4];
void UnloadPlugin ( void );
bool ValidPluginVersion ( PLUGIN_INFO * PluginInfo );
void (__cdecl *CloseDLL) ( void );
void (__cdecl *RomOpen) ( void );
void (__cdecl *RomClosed) ( void );
void (__cdecl *PluginOpened) ( void );
void (__cdecl *SetSettingInfo) ( PLUGIN_SETTINGS * info );
void (__cdecl *SetSettingInfo2) ( PLUGIN_SETTINGS2 * info );
CCONTROL * m_Controllers[4];
public:
CControl_Plugin ( const char * FileName );
~CControl_Plugin ( void );
bool Initiate ( CN64System * System, CMainGui * RenderWindow );
void SetControl ( CControl_Plugin const * const Plugin );
void UpdateKeys ( void );
void Close ( void );
void RomOpened ( void );
void GameReset ( void );
stdstr PluginName ( void ) const { return m_PluginInfo.Name; }
void (__cdecl *Config) ( DWORD hParent );
void (__cdecl *WM_KeyDown) ( DWORD wParam, DWORD lParam );
void (__cdecl *WM_KeyUp) ( DWORD wParam, DWORD lParam );
void (__cdecl *RumbleCommand) ( int Control, BOOL bRumble );
void (__cdecl *GetKeys) ( int Control, BUTTONS * Keys );
void (__cdecl *ReadController) ( int Control, BYTE * Command );
void (__cdecl *ControllerCommand)( int Control, BYTE * Command );
inline bool Initilized ( void ) const { return m_Initilized; }
inline CCONTROL const * Controller (int control) { return m_Controllers[control]; }
inline CONTROL * PluginControllers ( void ) { return m_PluginControllers; }
};