2021-03-27 05:42:35 +00:00
|
|
|
// Project64 controller plugin spec, version 1.1
|
|
|
|
|
2020-06-16 06:41:01 +00:00
|
|
|
#pragma once
|
2021-04-12 06:34:26 +00:00
|
|
|
#include <stdint.h>
|
2020-06-16 06:41:01 +00:00
|
|
|
|
|
|
|
enum { PLUGIN_TYPE_CONTROLLER = 4 };
|
|
|
|
|
|
|
|
#if defined(_WIN32)
|
|
|
|
#define EXPORT extern "C" __declspec(dllexport)
|
|
|
|
#define CALL __cdecl
|
|
|
|
#else
|
|
|
|
#define EXPORT extern "C" __attribute__((visibility("default")))
|
|
|
|
#define CALL
|
|
|
|
#endif
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
CONTROLLER_SPECS_VERSION = 0x0102
|
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PLUGIN_NONE = 1,
|
|
|
|
PLUGIN_MEMPAK = 2,
|
|
|
|
PLUGIN_RUMBLE_PAK = 3,
|
|
|
|
PLUGIN_TRANSFER_PAK = 4,
|
|
|
|
PLUGIN_RAW = 5,
|
|
|
|
};
|
|
|
|
|
2022-01-09 11:13:12 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PRESENT_NONE = 0,
|
|
|
|
PRESENT_CONT = 1,
|
|
|
|
PRESENT_MOUSE = 2,
|
|
|
|
};
|
|
|
|
|
2021-03-27 05:42:35 +00:00
|
|
|
// Structures
|
|
|
|
|
2020-06-16 06:41:01 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
2021-03-27 05:42:35 +00:00
|
|
|
uint16_t Version; // Should be set to 0x0101
|
|
|
|
uint16_t Type; // Set to PLUGIN_TYPE_CONTROLLER
|
|
|
|
char Name[100]; // Name of the DLL
|
2020-06-16 06:41:01 +00:00
|
|
|
int32_t NormalMemory;
|
|
|
|
int32_t MemoryBswaped;
|
|
|
|
} PLUGIN_INFO;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int32_t Present;
|
|
|
|
int32_t RawData;
|
|
|
|
int32_t Plugin;
|
|
|
|
} CONTROL;
|
|
|
|
|
|
|
|
#pragma warning(push)
|
2021-03-27 05:42:35 +00:00
|
|
|
#pragma warning(disable : 4201) // warning C4201: nonstandard extension used: nameless struct/union
|
2020-06-16 06:41:01 +00:00
|
|
|
|
|
|
|
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 X_AXIS : 8;
|
2020-07-07 02:06:10 +00:00
|
|
|
|
|
|
|
signed Y_AXIS : 8;
|
2020-06-16 06:41:01 +00:00
|
|
|
};
|
|
|
|
} BUTTONS;
|
|
|
|
|
|
|
|
#pragma warning(pop)
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
void * hwnd;
|
|
|
|
void * hinst;
|
|
|
|
int32_t MemoryBswaped; // Set this to true
|
2021-03-27 05:42:35 +00:00
|
|
|
uint8_t * HEADER; // This is the ROM header (first 40h bytes of the ROM)
|
2021-05-18 11:51:36 +00:00
|
|
|
CONTROL * Controls; // A pointer to an array of 4 controllers
|
2020-06-16 06:41:01 +00:00
|
|
|
} CONTROL_INFO;
|
|
|
|
|
2021-03-27 05:42:35 +00:00
|
|
|
/*
|
|
|
|
Function: CloseDLL
|
2021-05-18 11:51:36 +00:00
|
|
|
Purpose: This function is called when the emulator is closing
|
2021-03-27 05:42:35 +00:00
|
|
|
down allowing the DLL to de-initialize.
|
2021-05-18 11:51:36 +00:00
|
|
|
Input: None
|
|
|
|
Output: None
|
2021-03-27 05:42:35 +00:00
|
|
|
*/
|
|
|
|
|
2020-06-16 06:41:01 +00:00
|
|
|
EXPORT void CALL CloseDLL(void);
|
|
|
|
|
2021-03-27 05:42:35 +00:00
|
|
|
/*
|
|
|
|
Function: ControllerCommand
|
2021-05-18 11:51:36 +00:00
|
|
|
Purpose: To process the raw data that has just been sent to a
|
2021-03-27 05:42:35 +00:00
|
|
|
specific controller.
|
2021-05-18 11:51:36 +00:00
|
|
|
Input: Controller number (0 to 3) and -1 signaling end of
|
2021-03-27 05:42:35 +00:00
|
|
|
processing the PIF RAM.
|
|
|
|
- Pointer of data to be processed.
|
2021-05-18 11:51:36 +00:00
|
|
|
Output: None
|
|
|
|
Note: This function is only needed if the DLL is allowing raw
|
|
|
|
data, or the plugin is set to raw.
|
2021-03-27 05:42:35 +00:00
|
|
|
The data that is being processed looks like this:
|
|
|
|
Initialize controller: 01 03 00 FF FF FF
|
2021-05-18 11:51:36 +00:00
|
|
|
Read controller: 01 04 01 FF FF FF FF
|
2021-03-27 05:42:35 +00:00
|
|
|
*/
|
|
|
|
|
2020-06-16 06:41:01 +00:00
|
|
|
EXPORT void CALL ControllerCommand(int32_t Control, uint8_t * Command);
|
|
|
|
|
2021-03-27 05:42:35 +00:00
|
|
|
/*
|
|
|
|
Function: DllAbout
|
2021-05-18 11:51:36 +00:00
|
|
|
Purpose: This function is optional function that is provided
|
2021-03-27 05:42:35 +00:00
|
|
|
to give further information about the DLL.
|
2021-05-18 11:51:36 +00:00
|
|
|
Input: A handle to the window that calls this function.
|
|
|
|
Output: None
|
2021-03-27 05:42:35 +00:00
|
|
|
*/
|
|
|
|
|
2020-06-16 06:41:01 +00:00
|
|
|
EXPORT void CALL DllAbout(void * hParent);
|
|
|
|
|
2021-03-27 05:42:35 +00:00
|
|
|
/*
|
|
|
|
Function: DllConfig
|
2021-05-18 11:51:36 +00:00
|
|
|
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
|
2021-03-27 05:42:35 +00:00
|
|
|
*/
|
|
|
|
|
2020-06-16 06:41:01 +00:00
|
|
|
EXPORT void CALL DllConfig(void * hParent);
|
|
|
|
|
2021-03-27 05:42:35 +00:00
|
|
|
/*
|
|
|
|
Function: DllTest
|
2021-05-18 11:51:36 +00:00
|
|
|
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
|
2021-03-27 05:42:35 +00:00
|
|
|
*/
|
|
|
|
|
2020-06-16 06:41:01 +00:00
|
|
|
EXPORT void CALL DllTest(void * hParent);
|
|
|
|
|
2021-03-27 05:42:35 +00:00
|
|
|
/*
|
|
|
|
Function: GetDllInfo
|
2021-05-18 11:51:36 +00:00
|
|
|
Purpose: This function allows the emulator to gather information
|
2021-03-27 05:42:35 +00:00
|
|
|
about the DLL by filling in the PluginInfo structure.
|
2021-05-18 11:51:36 +00:00
|
|
|
Input: A pointer to a PLUGIN_INFO structure that needs to be
|
2021-03-27 05:42:35 +00:00
|
|
|
filled by the function. (see def above)
|
2021-05-18 11:51:36 +00:00
|
|
|
Output: None
|
2021-03-27 05:42:35 +00:00
|
|
|
*/
|
|
|
|
|
2020-06-16 06:41:01 +00:00
|
|
|
EXPORT void CALL GetDllInfo(PLUGIN_INFO * PluginInfo);
|
|
|
|
|
2021-03-27 05:42:35 +00:00
|
|
|
/*
|
|
|
|
Function: GetKeys
|
2021-05-18 11:51:36 +00:00
|
|
|
Purpose: To get the current state of the controllers buttons.
|
|
|
|
Input: Controller number (0 to 3)
|
2021-03-27 05:42:35 +00:00
|
|
|
- A pointer to a BUTTONS structure to be filled with
|
|
|
|
the controller state.
|
2021-05-18 11:51:36 +00:00
|
|
|
Output: None
|
2021-03-27 05:42:35 +00:00
|
|
|
*/
|
|
|
|
|
2020-06-16 06:41:01 +00:00
|
|
|
EXPORT void CALL GetKeys(int32_t Control, BUTTONS * Keys);
|
|
|
|
|
2021-03-27 05:42:35 +00:00
|
|
|
/*
|
|
|
|
Function: InitiateControllers
|
2021-05-18 11:51:36 +00:00
|
|
|
Purpose: This function initializes how each of the controllers
|
2021-03-27 05:42:35 +00:00
|
|
|
should be handled.
|
2021-05-18 11:51:36 +00:00
|
|
|
Input: The handle to the main window.
|
2021-03-27 05:42:35 +00:00
|
|
|
- A controller structure that needs to be filled for
|
|
|
|
the emulator to know how to handle each controller.
|
2021-05-18 11:51:36 +00:00
|
|
|
Output: None
|
2021-03-27 05:42:35 +00:00
|
|
|
*/
|
|
|
|
|
2020-06-16 06:41:01 +00:00
|
|
|
EXPORT void CALL InitiateControllers(CONTROL_INFO * ControlInfo);
|
|
|
|
|
2021-03-27 05:42:35 +00:00
|
|
|
/*
|
|
|
|
Function: ReadController
|
2021-05-18 11:51:36 +00:00
|
|
|
Purpose: To process the raw data in the PIF RAM that is about to
|
2021-03-27 05:42:35 +00:00
|
|
|
be read.
|
2021-05-18 11:51:36 +00:00
|
|
|
Input: Controller number (0 to 3) and -1 signaling end of
|
2021-03-27 05:42:35 +00:00
|
|
|
processing the PIF RAM.
|
|
|
|
- Pointer of data to be processed.
|
2021-05-18 11:51:36 +00:00
|
|
|
Output: None
|
|
|
|
Note: This function is only needed if the DLL is allowing raw
|
2021-03-27 05:42:35 +00:00
|
|
|
data.
|
|
|
|
*/
|
|
|
|
|
2020-06-16 06:41:01 +00:00
|
|
|
EXPORT void CALL ReadController(int Control, uint8_t * Command);
|
|
|
|
|
2021-03-27 05:42:35 +00:00
|
|
|
/*
|
|
|
|
Function: RomClosed
|
2021-05-18 11:51:36 +00:00
|
|
|
Purpose: This function is called when a ROM is closed.
|
|
|
|
Input: None
|
|
|
|
Output: None
|
2021-03-27 05:42:35 +00:00
|
|
|
*/
|
|
|
|
|
2020-06-16 06:41:01 +00:00
|
|
|
EXPORT void CALL RomClosed(void);
|
|
|
|
|
2021-03-27 05:42:35 +00:00
|
|
|
/*
|
|
|
|
Function: RomOpen
|
2021-05-18 11:51:36 +00:00
|
|
|
Purpose: This function is called when a ROM is open. (from the
|
2021-03-27 05:42:35 +00:00
|
|
|
emulation thread)
|
2021-05-18 11:51:36 +00:00
|
|
|
Input: None
|
|
|
|
Output: None
|
2021-03-27 05:42:35 +00:00
|
|
|
*/
|
|
|
|
|
2020-06-16 06:41:01 +00:00
|
|
|
EXPORT void CALL RomOpen(void);
|
|
|
|
|
2022-01-09 11:13:12 +00:00
|
|
|
/*
|
|
|
|
Function: EmulationPaused
|
|
|
|
Purpose: This function is called when the emulation is paused. (from the
|
|
|
|
emulation thread)
|
|
|
|
Input: None
|
|
|
|
Output: None
|
|
|
|
*/
|
|
|
|
|
|
|
|
EXPORT void CALL EmulationPaused(void);
|
|
|
|
|
2021-03-27 05:42:35 +00:00
|
|
|
/*
|
|
|
|
Function: WM_KeyDown
|
2021-05-18 11:51:36 +00:00
|
|
|
Purpose: To pass the WM_KeyDown message from the emulator to the
|
2021-03-27 05:42:35 +00:00
|
|
|
plugin.
|
2021-05-18 11:51:36 +00:00
|
|
|
Input: wParam and lParam of the WM_KEYDOWN message.
|
|
|
|
Output: None
|
2021-03-27 05:42:35 +00:00
|
|
|
*/
|
|
|
|
|
2020-06-16 06:41:01 +00:00
|
|
|
EXPORT void CALL WM_KeyDown(uint32_t wParam, uint32_t lParam);
|
|
|
|
|
2021-03-27 05:42:35 +00:00
|
|
|
/*
|
|
|
|
Function: WM_KeyUp
|
2021-05-18 11:51:36 +00:00
|
|
|
Purpose: To pass the WM_KEYUP message from the emulator to the
|
2021-03-27 05:42:35 +00:00
|
|
|
plugin.
|
2021-05-18 11:51:36 +00:00
|
|
|
Input: wParam and lParam of the WM_KEYDOWN message.
|
|
|
|
Output: None
|
2021-03-27 05:42:35 +00:00
|
|
|
*/
|
2020-06-16 06:41:01 +00:00
|
|
|
|
2021-03-27 05:42:35 +00:00
|
|
|
EXPORT void CALL WM_KeyUp(uint32_t wParam, uint32_t lParam);
|
2022-01-09 11:13:12 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
Function: WM_KillFocus
|
|
|
|
Purpose: To pass the WM_KILLFOCUS message from the emulator to the
|
|
|
|
plugin.
|
|
|
|
Input: wParam and lParam of the WM_KILLFOCUS message.
|
|
|
|
Output: None
|
|
|
|
*/
|
|
|
|
|
|
|
|
EXPORT void CALL WM_KillFocus(uint32_t wParam, uint32_t lParam);
|