2020-06-16 06:41:01 +00:00
|
|
|
#include "ControllerSpec1.1.h"
|
2020-06-17 07:23:10 +00:00
|
|
|
#include "InputConfigUI.h"
|
2020-06-16 06:41:01 +00:00
|
|
|
#include "Version.h"
|
2020-06-23 07:47:46 +00:00
|
|
|
#include "CProject64Input.h"
|
2020-07-01 03:37:55 +00:00
|
|
|
#include "InputSettings.h"
|
2020-06-16 06:41:01 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2021-03-27 05:43:03 +00:00
|
|
|
/*
|
2020-06-16 06:41:01 +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:43:03 +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:43:03 +00:00
|
|
|
*/
|
|
|
|
|
2020-06-16 06:41:01 +00:00
|
|
|
EXPORT void CALL CloseDLL(void)
|
|
|
|
{
|
2020-07-01 03:37:55 +00:00
|
|
|
CleanupInputSettings();
|
2020-06-16 06:41:01 +00:00
|
|
|
}
|
|
|
|
|
2021-03-27 05:43:03 +00:00
|
|
|
/*
|
2020-06-16 06:41:01 +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
|
2020-06-16 06:41:01 +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:43:03 +00:00
|
|
|
processing the PIF RAM.
|
2020-06-16 06:41:01 +00:00
|
|
|
- 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.
|
|
|
|
The data that is being processed looks like this:
|
2021-03-27 05:43:03 +00:00
|
|
|
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:43:03 +00:00
|
|
|
*/
|
|
|
|
|
2020-06-16 06:41:01 +00:00
|
|
|
EXPORT void CALL ControllerCommand(int32_t /*Control*/, uint8_t * /*Command*/)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-03-27 05:43:03 +00:00
|
|
|
/*
|
2020-06-16 06:41:01 +00:00
|
|
|
Function: DllAbout
|
2021-05-18 11:51:36 +00:00
|
|
|
Purpose: This function is optional function that is provided
|
2020-06-16 06:41:01 +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
|
|
|
|
*/
|
|
|
|
|
|
|
|
//EXPORT void CALL DllAbout(void * hParent)
|
|
|
|
//{
|
|
|
|
//}
|
2020-06-16 06:41:01 +00:00
|
|
|
|
2021-05-18 11:51:36 +00:00
|
|
|
/*
|
2020-06-16 06:41:01 +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:43:03 +00:00
|
|
|
*/
|
|
|
|
|
2020-06-17 07:23:10 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
EXPORT void CALL DllConfig(void * hParent)
|
2020-06-16 06:41:01 +00:00
|
|
|
{
|
2020-06-17 07:23:10 +00:00
|
|
|
ConfigInput(hParent);
|
2020-06-16 06:41:01 +00:00
|
|
|
}
|
2020-06-17 07:23:10 +00:00
|
|
|
#endif
|
2020-06-16 06:41:01 +00:00
|
|
|
|
2021-03-27 05:43:03 +00:00
|
|
|
/*
|
2020-06-16 06:41:01 +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:43:03 +00:00
|
|
|
*/
|
|
|
|
|
2020-06-16 06:41:01 +00:00
|
|
|
EXPORT void CALL DllTest(void * /*hParent*/)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-03-27 05:43:03 +00:00
|
|
|
/*
|
2020-06-16 06:41:01 +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:43:03 +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
|
2020-06-16 06:41:01 +00:00
|
|
|
filled by the function. (see def above)
|
2021-05-18 11:51:36 +00:00
|
|
|
Output: None
|
2021-03-27 05:43:03 +00:00
|
|
|
*/
|
|
|
|
|
2020-06-16 06:41:01 +00:00
|
|
|
EXPORT void CALL GetDllInfo(PLUGIN_INFO * PluginInfo)
|
|
|
|
{
|
|
|
|
PluginInfo->Version = CONTROLLER_SPECS_VERSION;
|
|
|
|
PluginInfo->Type = PLUGIN_TYPE_CONTROLLER;
|
|
|
|
#ifdef _DEBUG
|
2021-03-27 05:43:03 +00:00
|
|
|
sprintf(PluginInfo->Name, "Project64 input plugin (Debug): %s", VER_FILE_VERSION_STR);
|
2020-06-16 06:41:01 +00:00
|
|
|
#else
|
2021-03-27 05:43:03 +00:00
|
|
|
sprintf(PluginInfo->Name, "Project64 input plugin: %s", VER_FILE_VERSION_STR);
|
2020-06-16 06:41:01 +00:00
|
|
|
#endif
|
|
|
|
PluginInfo->MemoryBswaped = true;
|
|
|
|
PluginInfo->NormalMemory = false;
|
|
|
|
}
|
|
|
|
|
2021-03-27 05:43:03 +00:00
|
|
|
/*
|
2020-06-16 06:41:01 +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)
|
2020-06-16 06:41:01 +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:43:03 +00:00
|
|
|
*/
|
|
|
|
|
2020-07-01 03:47:36 +00:00
|
|
|
EXPORT void CALL GetKeys(int32_t Control, BUTTONS * Keys)
|
2020-06-16 06:41:01 +00:00
|
|
|
{
|
2020-07-01 03:47:36 +00:00
|
|
|
g_InputPlugin->GetKeys(Control, Keys);
|
2020-06-16 06:41:01 +00:00
|
|
|
}
|
|
|
|
|
2021-03-27 05:43:03 +00:00
|
|
|
/*
|
2021-05-18 11:51:36 +00:00
|
|
|
Function: InitiateControllers
|
|
|
|
Purpose: This function initializes how each of the controllers
|
|
|
|
should be handled.
|
|
|
|
Input: A controller structure that needs to be filled for
|
|
|
|
the emulator to know how to handle each controller.
|
|
|
|
Output: None
|
2021-03-27 05:43:03 +00:00
|
|
|
*/
|
|
|
|
|
2020-06-23 07:47:46 +00:00
|
|
|
EXPORT void CALL InitiateControllers(CONTROL_INFO * ControlInfo)
|
2020-06-16 06:41:01 +00:00
|
|
|
{
|
2020-06-23 07:47:46 +00:00
|
|
|
if (g_InputPlugin != nullptr)
|
|
|
|
{
|
|
|
|
g_InputPlugin->InitiateControllers(ControlInfo);
|
|
|
|
}
|
2020-06-16 06:41:01 +00:00
|
|
|
}
|
|
|
|
|
2021-03-27 05:43:03 +00:00
|
|
|
/*
|
2020-06-16 06:41:01 +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
|
2020-06-16 06:41:01 +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:43:03 +00:00
|
|
|
processing the PIF RAM.
|
2020-06-16 06:41:01 +00:00
|
|
|
- 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
|
2020-06-16 06:41:01 +00:00
|
|
|
data.
|
2021-03-27 05:43:03 +00:00
|
|
|
*/
|
|
|
|
|
2020-06-16 06:41:01 +00:00
|
|
|
EXPORT void CALL ReadController(int /*Control*/, uint8_t * /*Command*/)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-03-27 05:43:03 +00:00
|
|
|
/*
|
2020-06-16 06:41:01 +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:43:03 +00:00
|
|
|
*/
|
|
|
|
|
2020-06-16 06:41:01 +00:00
|
|
|
EXPORT void CALL RomClosed(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-03-27 05:43:03 +00:00
|
|
|
/*
|
2020-06-16 06:41:01 +00:00
|
|
|
Function: RomOpen
|
2021-05-18 11:51:36 +00:00
|
|
|
Purpose: This function is called when a ROM is open. (from the
|
2020-06-16 06:41:01 +00:00
|
|
|
emulation thread)
|
2021-05-18 11:51:36 +00:00
|
|
|
Input: None
|
|
|
|
Output: None
|
2021-03-27 05:43:03 +00:00
|
|
|
*/
|
|
|
|
|
2020-06-16 06:41:01 +00:00
|
|
|
EXPORT void CALL RomOpen(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-03-27 05:43:03 +00:00
|
|
|
/*
|
2020-06-16 06:41:01 +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
|
2020-06-16 06:41:01 +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:43:03 +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:43:03 +00:00
|
|
|
/*
|
2020-06-16 06:41:01 +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
|
2020-06-16 06:41:01 +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:43:03 +00:00
|
|
|
*/
|
|
|
|
|
2020-06-16 06:41:01 +00:00
|
|
|
EXPORT void CALL WM_KeyUp(uint32_t /*wParam*/, uint32_t /*lParam*/)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-06-16 07:40:03 +00:00
|
|
|
EXPORT void CALL PluginLoaded(void)
|
|
|
|
{
|
2020-07-01 03:37:55 +00:00
|
|
|
SetupInputSettings();
|
2020-06-23 07:47:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#include <Windows.h>
|
|
|
|
|
|
|
|
extern "C" int WINAPI DllMain(HINSTANCE hinst, DWORD fdwReason, LPVOID /*lpReserved*/)
|
|
|
|
{
|
|
|
|
if (fdwReason == DLL_PROCESS_ATTACH)
|
|
|
|
{
|
|
|
|
g_InputPlugin = new CProject64Input(hinst);
|
|
|
|
}
|
|
|
|
else if (fdwReason == DLL_PROCESS_DETACH)
|
|
|
|
{
|
|
|
|
delete g_InputPlugin;
|
2021-04-12 11:35:39 +00:00
|
|
|
g_InputPlugin = nullptr;
|
2020-06-23 07:47:46 +00:00
|
|
|
}
|
|
|
|
return TRUE;
|
2021-03-27 05:43:03 +00:00
|
|
|
}
|