2021-05-18 11:51:36 +00:00
|
|
|
// Common controller plugin specification, version 1.1 maintained by Zilmar
|
|
|
|
|
|
|
|
// All questions or suggestions should go through the emutalk plugin forum.
|
|
|
|
// http://www.emutalk.net/cgi-bin/ikonboard/ikonboard.cgi?s=3bd272222f66ffff;act=SF;f=20
|
2016-01-27 09:39:06 +00:00
|
|
|
|
|
|
|
#ifndef _CONTR_H_INCLUDED__
|
|
|
|
#define _CONTR_H_INCLUDED__
|
|
|
|
|
|
|
|
#if defined(__cplusplus)
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2021-05-18 11:51:36 +00:00
|
|
|
// Note: BOOL, BYTE, WORD, DWORD, TRUE, FALSE are defined in windows.h
|
2016-01-27 09:39:06 +00:00
|
|
|
|
2020-02-09 11:36:49 +00:00
|
|
|
#define PLUGIN_TYPE_CONTROLLER 4
|
2016-01-27 09:39:06 +00:00
|
|
|
|
|
|
|
#ifndef SPECS_VERSION
|
|
|
|
#define SPECS_VERSION 0x0101
|
|
|
|
#endif
|
|
|
|
|
2021-05-18 11:51:36 +00:00
|
|
|
// Controller plugins
|
2020-02-09 11:36:49 +00:00
|
|
|
#define PLUGIN_NONE 1
|
|
|
|
#define PLUGIN_MEMPAK 2
|
2021-05-18 11:51:36 +00:00
|
|
|
// not implemented for non-raw data
|
2020-02-09 11:36:49 +00:00
|
|
|
#define PLUGIN_RUMBLE_PAK 3
|
2021-05-18 11:51:36 +00:00
|
|
|
// not implemented for non-raw data
|
2020-02-09 11:36:49 +00:00
|
|
|
#define PLUGIN_TRANSFER_PAK 4
|
2021-05-18 11:51:36 +00:00
|
|
|
// The controller plugin is passed in raw data
|
2020-02-09 11:36:49 +00:00
|
|
|
#define PLUGIN_RAW 5
|
|
|
|
|
2021-05-18 11:51:36 +00:00
|
|
|
/*
|
|
|
|
Note about controller plugin's:
|
|
|
|
The rumble pak needs a function for the force feedback joystick and transfer pak
|
|
|
|
probably needs a function for the plugin to be able to select the Game Boy ROM and
|
|
|
|
EEPROM...maybe this should be done by the emu instead of the plugin, but I think
|
|
|
|
it probably should be done by the plugin. I will see about adding these functions
|
|
|
|
in the next specification.
|
|
|
|
*/
|
2020-02-09 11:36:49 +00:00
|
|
|
|
|
|
|
#define EXPORT __declspec(dllexport)
|
|
|
|
#define CALL _cdecl
|
|
|
|
|
2021-05-18 11:51:36 +00:00
|
|
|
// Structures
|
2020-02-09 11:36:49 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
2021-05-18 11:51:36 +00:00
|
|
|
WORD Version; // Should be set to 0x0101
|
|
|
|
WORD Type; // Set to PLUGIN_TYPE_CONTROLLER
|
|
|
|
char Name[100]; // Name of the DLL
|
2020-02-09 11:36:49 +00:00
|
|
|
BOOL Reserved1;
|
|
|
|
BOOL Reserved2;
|
|
|
|
} PLUGIN_INFO;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
BOOL Present;
|
|
|
|
BOOL RawData;
|
|
|
|
int Plugin;
|
|
|
|
} CONTROL;
|
|
|
|
|
|
|
|
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 X_AXIS : 8;
|
2020-07-07 02:06:10 +00:00
|
|
|
|
|
|
|
signed Y_AXIS : 8;
|
2020-02-09 11:36:49 +00:00
|
|
|
};
|
|
|
|
} BUTTONS;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
HWND hMainWindow;
|
|
|
|
HINSTANCE hinst;
|
|
|
|
|
2021-05-18 11:51:36 +00:00
|
|
|
BOOL MemoryBswaped; // If this is set to TRUE, then the memory has been pre-bswap'd on a DWORD (32-bit) boundary, only effects header.
|
2020-02-09 11:36:49 +00:00
|
|
|
// eg. the first 8 bytes are stored like this:
|
2021-05-18 11:51:36 +00:00
|
|
|
// 4 3 2 1 8 7 6 5
|
|
|
|
BYTE * HEADER; // This is the ROM header (first 40h bytes of the ROM)
|
|
|
|
CONTROL *Controls; // A pointer to an array of 4 controllers. eg:
|
2020-02-09 11:36:49 +00:00
|
|
|
// CONTROL Controls[4];
|
|
|
|
} CONTROL_INFO;
|
|
|
|
|
2021-05-18 11:51:36 +00:00
|
|
|
/*
|
|
|
|
Function: CloseDLL
|
|
|
|
Purpose: This function is called when the emulator is closing
|
|
|
|
down allowing the DLL to de-initialize.
|
|
|
|
Input: None
|
|
|
|
Output: None
|
|
|
|
*/
|
|
|
|
|
2020-02-09 11:36:49 +00:00
|
|
|
EXPORT void CALL CloseDLL(void);
|
|
|
|
|
2021-05-18 11:51:36 +00:00
|
|
|
/*
|
|
|
|
Function: ControllerCommand
|
|
|
|
Purpose: To process the raw data that has just been sent to a
|
|
|
|
specific controller.
|
|
|
|
Input: Controller number (0 to 3) and -1 signaling end of
|
|
|
|
processing the PIF RAM.
|
|
|
|
- Pointer of data to be processed.
|
|
|
|
Output: None
|
|
|
|
|
|
|
|
Note: This function is only needed if the DLL is allowing raw
|
|
|
|
data, or the plugin is set to raw.
|
|
|
|
|
|
|
|
The data that is being processed looks like this:
|
|
|
|
Initialize controller: 01 03 00 FF FF FF
|
|
|
|
Read controller: 01 04 01 FF FF FF FF
|
|
|
|
*/
|
|
|
|
|
2020-02-09 11:36:49 +00:00
|
|
|
EXPORT void CALL ControllerCommand(int Control, BYTE * Command);
|
|
|
|
|
2021-05-18 11:51:36 +00:00
|
|
|
/*
|
|
|
|
Function: DllAbout
|
|
|
|
Purpose: This function is optional function that is provided
|
|
|
|
to give further information about the DLL.
|
|
|
|
Input: A handle to the window that calls this function
|
|
|
|
Output: None
|
|
|
|
*/
|
|
|
|
|
2020-02-09 11:36:49 +00:00
|
|
|
EXPORT void CALL DllAbout(HWND hParent);
|
|
|
|
|
2021-05-18 11:51:36 +00:00
|
|
|
/*
|
|
|
|
Function: DllConfig
|
|
|
|
Purpose: This function is optional function that is provided
|
|
|
|
to allow the user to configure the DLL.
|
|
|
|
Input: A handle to the window that calls this function
|
|
|
|
Output: None
|
|
|
|
*/
|
|
|
|
|
2020-02-09 11:36:49 +00:00
|
|
|
EXPORT void CALL DllConfig(HWND hParent);
|
|
|
|
|
2021-05-18 11:51:36 +00:00
|
|
|
/*
|
|
|
|
Function: DllTest
|
|
|
|
Purpose: This function is optional function that is provided
|
|
|
|
to allow the user to test the DLL.
|
|
|
|
Input: A handle to the window that calls this function
|
|
|
|
Output: None
|
|
|
|
*/
|
|
|
|
|
2020-02-09 11:36:49 +00:00
|
|
|
EXPORT void CALL DllTest(HWND hParent);
|
|
|
|
|
2021-05-18 11:51:36 +00:00
|
|
|
/*
|
|
|
|
Function: GetDllInfo
|
|
|
|
Purpose: This function allows the emulator to gather information
|
|
|
|
about the DLL by filling in the PluginInfo structure.
|
|
|
|
Input: A pointer to a PLUGIN_INFO structure that needs to be
|
|
|
|
filled by the function. (see def above)
|
|
|
|
Output: None
|
|
|
|
*/
|
|
|
|
|
2020-02-09 11:36:49 +00:00
|
|
|
EXPORT void CALL GetDllInfo(PLUGIN_INFO * PluginInfo);
|
|
|
|
|
2021-05-18 11:51:36 +00:00
|
|
|
/*
|
|
|
|
Function: GetKeys
|
|
|
|
Purpose: To get the current state of the controllers buttons.
|
|
|
|
Input: Controller number (0 to 3)
|
|
|
|
- A pointer to a BUTTONS structure to be filled with
|
|
|
|
the controller state.
|
|
|
|
Output: None
|
|
|
|
*/
|
|
|
|
|
2020-02-09 11:36:49 +00:00
|
|
|
EXPORT void CALL GetKeys(int Control, BUTTONS * Keys);
|
|
|
|
|
2021-05-18 11:51:36 +00:00
|
|
|
/*
|
|
|
|
Function: InitiateControllers
|
|
|
|
Purpose: This function initializes how each of the controllers
|
|
|
|
should be handled.
|
|
|
|
Input: The handle to the main window.
|
|
|
|
- A controller structure that needs to be filled for
|
|
|
|
the emulator to know how to handle each controller.
|
|
|
|
Output: None
|
|
|
|
*/
|
|
|
|
|
2016-01-27 09:39:06 +00:00
|
|
|
#if (SPECS_VERSION < 0x0101)
|
|
|
|
EXPORT void CALL InitiateControllers(void * hMainWindow, CONTROL Controls[4]);
|
|
|
|
#elif (SPECS_VERSION == 0x0101)
|
|
|
|
EXPORT void CALL InitiateControllers(CONTROL_INFO ControlInfo);
|
2021-05-18 11:51:36 +00:00
|
|
|
// Typo in the official specs, but it works!
|
2016-01-27 09:39:06 +00:00
|
|
|
#else
|
|
|
|
EXPORT void CALL InitiateControllers(CONTROL_INFO * ControlInfo);
|
|
|
|
#endif
|
|
|
|
|
2021-05-18 11:51:36 +00:00
|
|
|
/*
|
|
|
|
Function: ReadController
|
|
|
|
Purpose: To process the raw data in the PIF RAM that is about to
|
|
|
|
be read.
|
|
|
|
Input: Controller Number (0 to 3) and -1 signaling end of
|
|
|
|
processing the PIF RAM.
|
|
|
|
- Pointer of data to be processed.
|
|
|
|
Output: None
|
|
|
|
Note: This function is only needed if the DLL is allowing raw
|
|
|
|
data.
|
|
|
|
*/
|
|
|
|
|
2020-02-09 11:36:49 +00:00
|
|
|
EXPORT void CALL ReadController(int Control, BYTE * Command);
|
|
|
|
|
2021-05-18 11:51:36 +00:00
|
|
|
/*
|
|
|
|
Function: RomClosed
|
|
|
|
Purpose: This function is called when a rom is closed.
|
|
|
|
Input: None
|
|
|
|
Output: None
|
|
|
|
*/
|
|
|
|
|
2020-02-09 11:36:49 +00:00
|
|
|
EXPORT void CALL RomClosed(void);
|
|
|
|
|
2021-05-18 11:51:36 +00:00
|
|
|
/*
|
|
|
|
Function: RomOpen
|
|
|
|
Purpose: This function is called when a rom is open. (from the
|
|
|
|
emulation thread)
|
|
|
|
Input: None
|
|
|
|
Output: None
|
|
|
|
*/
|
|
|
|
|
2020-02-09 11:36:49 +00:00
|
|
|
EXPORT void CALL RomOpen(void);
|
|
|
|
|
2021-05-18 11:51:36 +00:00
|
|
|
/*
|
|
|
|
Function: WM_KeyDown
|
|
|
|
Purpose: To pass the WM_KeyDown message from the emulator to the
|
|
|
|
plugin.
|
|
|
|
Input: wParam and lParam of the WM_KEYDOWN message.
|
|
|
|
Output: None
|
|
|
|
*/
|
|
|
|
|
2020-02-09 11:36:49 +00:00
|
|
|
EXPORT void CALL WM_KeyDown(WPARAM wParam, LPARAM lParam);
|
|
|
|
|
2021-05-18 11:51:36 +00:00
|
|
|
/*
|
|
|
|
Function: WM_KeyUp
|
|
|
|
Purpose: To pass the WM_KEYUP message from the emulator to the
|
|
|
|
plugin.
|
|
|
|
Input: wParam and lParam of the WM_KEYDOWN message.
|
|
|
|
Output: None
|
|
|
|
*/
|
|
|
|
|
2020-02-09 11:36:49 +00:00
|
|
|
EXPORT void CALL WM_KeyUp(WPARAM wParam, LPARAM lParam);
|
2016-01-27 09:39:06 +00:00
|
|
|
|
|
|
|
#if defined(__cplusplus)
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|