2012-12-19 09:30:18 +00:00
|
|
|
/****************************************************************************
|
|
|
|
* *
|
2015-11-10 05:21:49 +00:00
|
|
|
* Project64 - A Nintendo 64 emulator. *
|
2012-12-19 09:30:18 +00:00
|
|
|
* http://www.pj64-emu.com/ *
|
|
|
|
* Copyright (C) 2012 Project64. All rights reserved. *
|
|
|
|
* *
|
|
|
|
* License: *
|
|
|
|
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
|
|
|
|
* *
|
|
|
|
****************************************************************************/
|
|
|
|
#pragma once
|
|
|
|
|
2015-11-08 06:08:15 +00:00
|
|
|
#pragma warning(push)
|
|
|
|
#pragma warning(disable : 4201) // warning C4201: nonstandard extension used : nameless struct/union
|
|
|
|
|
|
|
|
typedef union
|
|
|
|
{
|
|
|
|
uint32_t 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;
|
|
|
|
};
|
2008-09-18 03:15:49 +00:00
|
|
|
} BUTTONS;
|
2015-11-08 06:08:15 +00:00
|
|
|
#pragma warning(pop)
|
2008-09-18 03:15:49 +00:00
|
|
|
|
2015-11-08 06:08:15 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
2015-11-10 00:17:43 +00:00
|
|
|
int32_t Present;
|
|
|
|
int32_t RawData;
|
|
|
|
int32_t Plugin;
|
2008-09-18 03:15:49 +00:00
|
|
|
} CONTROL;
|
|
|
|
|
2015-11-08 06:08:15 +00:00
|
|
|
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
|
2008-09-18 03:15:49 +00:00
|
|
|
};
|
|
|
|
|
2015-11-08 06:08:15 +00:00
|
|
|
class CControl_Plugin;
|
2008-09-18 03:15:49 +00:00
|
|
|
|
2015-11-08 06:08:15 +00:00
|
|
|
class CCONTROL
|
|
|
|
{
|
2008-09-18 03:15:49 +00:00
|
|
|
public:
|
2015-11-10 07:13:49 +00:00
|
|
|
CCONTROL(int32_t &Present, int32_t &RawData, int32_t &PlugType);
|
2015-11-08 06:08:15 +00:00
|
|
|
inline bool Present(void) const { return m_Present != 0; }
|
|
|
|
inline uint32_t Buttons(void) const { return m_Buttons.Value; }
|
|
|
|
inline PluginType Plugin(void) const { return static_cast<PluginType>(m_PlugType); }
|
|
|
|
private:
|
|
|
|
friend CControl_Plugin; //controller plugin class has full access
|
|
|
|
|
2015-11-10 21:21:51 +00:00
|
|
|
int32_t & m_Present;
|
|
|
|
int32_t & m_RawData;
|
2015-11-08 06:08:15 +00:00
|
|
|
int32_t & m_PlugType;
|
|
|
|
BUTTONS m_Buttons;
|
|
|
|
|
|
|
|
CCONTROL(void); // Disable default constructor
|
|
|
|
CCONTROL(const CCONTROL&); // Disable copy constructor
|
|
|
|
CCONTROL& operator=(const CCONTROL&); // Disable assignment
|
2008-09-18 03:15:49 +00:00
|
|
|
};
|
|
|
|
|
2015-01-30 21:01:21 +00:00
|
|
|
class CControl_Plugin : public CPlugin
|
2012-10-04 01:45:30 +00:00
|
|
|
{
|
2008-09-18 03:15:49 +00:00
|
|
|
public:
|
2015-11-08 06:08:15 +00:00
|
|
|
CControl_Plugin(void);
|
|
|
|
~CControl_Plugin();
|
2015-01-30 21:01:21 +00:00
|
|
|
|
|
|
|
bool Initiate(CN64System * System, CMainGui * RenderWindow);
|
2015-11-08 06:08:15 +00:00
|
|
|
void SetControl(CControl_Plugin const * const Plugin);
|
|
|
|
void UpdateKeys(void);
|
2015-01-30 21:01:21 +00:00
|
|
|
|
2015-11-08 06:08:15 +00:00
|
|
|
void(__cdecl *WM_KeyDown) (uint32_t wParam, uint32_t lParam);
|
|
|
|
void(__cdecl *WM_KeyUp) (uint32_t wParam, uint32_t lParam);
|
|
|
|
void(__cdecl *RumbleCommand) (int32_t Control, int32_t bRumble);
|
|
|
|
void(__cdecl *GetKeys) (int32_t Control, BUTTONS * Keys);
|
|
|
|
void(__cdecl *ReadController) (int32_t Control, uint8_t * Command);
|
|
|
|
void(__cdecl *ControllerCommand)(int32_t Control, uint8_t * Command);
|
2015-01-30 21:01:21 +00:00
|
|
|
|
2015-11-08 06:08:15 +00:00
|
|
|
inline CCONTROL const * Controller(int32_t control) { return m_Controllers[control]; }
|
|
|
|
inline CONTROL * PluginControllers(void) { return m_PluginControllers; }
|
2012-10-04 01:45:30 +00:00
|
|
|
|
|
|
|
private:
|
2015-11-08 06:08:15 +00:00
|
|
|
CControl_Plugin(const CControl_Plugin&); // Disable copy constructor
|
|
|
|
CControl_Plugin& operator=(const CControl_Plugin&); // Disable assignment
|
2012-10-04 01:45:30 +00:00
|
|
|
|
2015-11-08 06:08:15 +00:00
|
|
|
virtual int32_t GetDefaultSettingStartRange() const { return FirstCtrlDefaultSet; }
|
|
|
|
virtual int32_t GetSettingStartRange() const { return FirstCtrlSettings; }
|
|
|
|
PLUGIN_TYPE type() { return PLUGIN_TYPE_CONTROLLER; }
|
|
|
|
bool LoadFunctions(void);
|
|
|
|
void UnloadPluginDetails(void);
|
2012-10-04 01:45:30 +00:00
|
|
|
|
2015-11-08 06:08:15 +00:00
|
|
|
bool m_AllocatedControllers;
|
2012-10-04 01:45:30 +00:00
|
|
|
|
2015-11-08 06:08:15 +00:00
|
|
|
// What the different controls are set up as
|
|
|
|
CONTROL m_PluginControllers[4];
|
|
|
|
CCONTROL * m_Controllers[4];
|
2008-09-18 03:15:49 +00:00
|
|
|
};
|