2022-06-27 10:02:38 +00:00
|
|
|
#include <Project64-plugin-spec/Input.h>
|
2022-07-18 12:56:29 +00:00
|
|
|
#include "Version.h"
|
2016-06-05 01:34:12 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#ifdef ANDROID
|
|
|
|
#include <jni.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static CONTROL_INFO g_control_info;
|
|
|
|
BUTTONS g_buttons;
|
|
|
|
|
|
|
|
void ShowAboutWindow (void * hParent);
|
|
|
|
|
2021-05-18 11:51:36 +00:00
|
|
|
/*
|
2016-06-05 01:34:12 +00:00
|
|
|
Function: CloseDLL
|
2022-07-18 12:56:29 +00:00
|
|
|
Purpose: This function is called when the emulator is closing
|
2021-03-16 05:04:30 +00:00
|
|
|
down allowing the DLL to de-initialize.
|
2022-07-18 12:56:29 +00:00
|
|
|
Input: None
|
|
|
|
Output: None
|
2021-05-18 11:51:36 +00:00
|
|
|
*/
|
2021-03-16 05:04:30 +00:00
|
|
|
|
2022-07-18 12:56:29 +00:00
|
|
|
EXPORT void CALL CloseDLL(void)
|
2016-06-05 01:34:12 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-05-18 11:51:36 +00:00
|
|
|
/*
|
2016-06-05 01:34:12 +00:00
|
|
|
Function: ControllerCommand
|
2022-07-18 12:56:29 +00:00
|
|
|
Purpose: To process the raw data that has just been sent to a
|
2016-06-05 01:34:12 +00:00
|
|
|
specific controller.
|
2022-07-18 12:56:29 +00:00
|
|
|
Input: Controller number (0 to 3) and -1 signaling end of
|
2021-03-16 05:04:30 +00:00
|
|
|
processing the PIF RAM.
|
2016-06-05 01:34:12 +00:00
|
|
|
- Pointer of data to be processed.
|
2022-07-18 12:56:29 +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-05-18 11:51:36 +00:00
|
|
|
The data that is being processed looks like this:
|
|
|
|
Initialize controller: 01 03 00 FF FF FF
|
2022-07-18 12:56:29 +00:00
|
|
|
Read controller: 01 04 01 FF FF FF FF
|
2021-05-18 11:51:36 +00:00
|
|
|
*/
|
2021-03-16 05:04:30 +00:00
|
|
|
|
2022-07-18 12:56:29 +00:00
|
|
|
EXPORT void CALL ControllerCommand(int32_t /*Control*/, uint8_t * /*Command*/)
|
2016-06-05 01:34:12 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-05-18 11:51:36 +00:00
|
|
|
/*
|
2016-06-05 01:34:12 +00:00
|
|
|
Function: DllAbout
|
2022-07-18 12:56:29 +00:00
|
|
|
Purpose: This function is optional function that is provided
|
2016-06-05 01:34:12 +00:00
|
|
|
to give further information about the DLL.
|
2022-07-18 12:56:29 +00:00
|
|
|
Input: A handle to the window that calls this function.
|
|
|
|
Output: None
|
2021-05-18 11:51:36 +00:00
|
|
|
*/
|
2021-03-16 05:04:30 +00:00
|
|
|
|
2016-06-05 01:34:12 +00:00
|
|
|
EXPORT void CALL DllAbout ( void * hParent )
|
|
|
|
{
|
|
|
|
#ifdef _WIN32
|
|
|
|
ShowAboutWindow(hParent);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2021-05-18 11:51:36 +00:00
|
|
|
/*
|
2016-06-05 01:34:12 +00:00
|
|
|
Function: DllConfig
|
2022-07-18 12:56:29 +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-05-18 11:51:36 +00:00
|
|
|
*/
|
2021-03-16 05:04:30 +00:00
|
|
|
|
2016-06-05 01:34:12 +00:00
|
|
|
EXPORT void CALL DllConfig ( void * /*hParent*/ )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-05-18 11:51:36 +00:00
|
|
|
/*
|
2016-06-05 01:34:12 +00:00
|
|
|
Function: DllTest
|
2022-07-18 12:56:29 +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-05-18 11:51:36 +00:00
|
|
|
*/
|
2021-03-16 05:04:30 +00:00
|
|
|
|
2022-07-18 12:56:29 +00:00
|
|
|
EXPORT void CALL DllTest(void * /*hParent*/)
|
2016-06-05 01:34:12 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-05-18 11:51:36 +00:00
|
|
|
/*
|
2016-06-05 01:34:12 +00:00
|
|
|
Function: GetDllInfo
|
2022-07-18 12:56:29 +00:00
|
|
|
Purpose: This function allows the emulator to gather information
|
2021-03-16 05:04:30 +00:00
|
|
|
about the DLL by filling in the PluginInfo structure.
|
2022-07-18 12:56:29 +00:00
|
|
|
Input: A pointer to a PLUGIN_INFO structure that needs to be
|
2016-06-05 01:34:12 +00:00
|
|
|
filled by the function. (see def above)
|
2022-07-18 12:56:29 +00:00
|
|
|
Output: None
|
2021-05-18 11:51:36 +00:00
|
|
|
*/
|
2021-03-16 05:04:30 +00:00
|
|
|
|
2022-07-18 12:56:29 +00:00
|
|
|
EXPORT void CALL GetDllInfo(PLUGIN_INFO * PluginInfo)
|
2016-06-05 01:34:12 +00:00
|
|
|
{
|
2022-07-18 12:56:29 +00:00
|
|
|
PluginInfo->Version = CONTROLLER_SPECS_VERSION;
|
2016-06-05 01:34:12 +00:00
|
|
|
PluginInfo->Type = PLUGIN_TYPE_CONTROLLER;
|
|
|
|
#ifdef _DEBUG
|
2021-03-16 05:04:30 +00:00
|
|
|
sprintf(PluginInfo->Name, "Android input debug plugin %s", VER_FILE_VERSION_STR);
|
2016-06-05 01:34:12 +00:00
|
|
|
#else
|
2021-03-16 05:04:30 +00:00
|
|
|
sprintf(PluginInfo->Name, "Android input plugin %s", VER_FILE_VERSION_STR);
|
2016-06-05 01:34:12 +00:00
|
|
|
#endif
|
2022-07-18 12:56:29 +00:00
|
|
|
PluginInfo->Reserved2 = true;
|
|
|
|
PluginInfo->Reserved1 = false;
|
2016-06-05 01:34:12 +00:00
|
|
|
}
|
|
|
|
|
2021-05-18 11:51:36 +00:00
|
|
|
/*
|
2016-06-05 01:34:12 +00:00
|
|
|
Function: GetKeys
|
2022-07-18 12:56:29 +00:00
|
|
|
Purpose: To get the current state of the controllers buttons.
|
|
|
|
Input: Controller number (0 to 3)
|
2016-06-05 01:34:12 +00:00
|
|
|
- A pointer to a BUTTONS structure to be filled with
|
|
|
|
the controller state.
|
2022-07-18 12:56:29 +00:00
|
|
|
Output: None
|
2021-05-18 11:51:36 +00:00
|
|
|
*/
|
2021-03-16 05:04:30 +00:00
|
|
|
|
2022-07-18 12:56:29 +00:00
|
|
|
EXPORT void CALL GetKeys(int32_t Control, BUTTONS * Keys)
|
2016-06-05 01:34:12 +00:00
|
|
|
{
|
|
|
|
if (Control == 0)
|
|
|
|
{
|
|
|
|
*Keys = g_buttons;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-18 11:51:36 +00:00
|
|
|
/*
|
2016-06-05 01:34:12 +00:00
|
|
|
Function: InitiateControllers
|
2022-07-18 12:56:29 +00:00
|
|
|
Purpose: This function initializes how each of the controllers
|
2016-06-05 01:34:12 +00:00
|
|
|
should be handled.
|
2022-07-18 12:56:29 +00:00
|
|
|
Input: A controller structure that needs to be filled for
|
2016-06-05 01:34:12 +00:00
|
|
|
the emulator to know how to handle each controller.
|
2022-07-18 12:56:29 +00:00
|
|
|
Output: None
|
2021-05-18 11:51:36 +00:00
|
|
|
*/
|
2021-03-16 05:04:30 +00:00
|
|
|
|
2022-07-18 12:56:29 +00:00
|
|
|
EXPORT void CALL InitiateControllers(CONTROL_INFO * ControlInfo)
|
2016-06-05 01:34:12 +00:00
|
|
|
{
|
2022-06-27 10:02:38 +00:00
|
|
|
g_control_info = *ControlInfo;
|
2016-06-05 01:34:12 +00:00
|
|
|
g_control_info.Controls[0].Present = true;
|
|
|
|
g_control_info.Controls[0].Plugin = PLUGIN_MEMPAK;
|
|
|
|
}
|
|
|
|
|
2021-05-18 11:51:36 +00:00
|
|
|
/*
|
2016-06-05 01:34:12 +00:00
|
|
|
Function: ReadController
|
2022-07-18 12:56:29 +00:00
|
|
|
Purpose: To process the raw data in the PIF RAM that is about to
|
2016-06-05 01:34:12 +00:00
|
|
|
be read.
|
2022-07-18 12:56:29 +00:00
|
|
|
Input: Controller number (0 to 3) and -1 signaling end of
|
2021-03-16 05:04:30 +00:00
|
|
|
processing the PIF RAM.
|
2016-06-05 01:34:12 +00:00
|
|
|
- Pointer of data to be processed.
|
2022-07-18 12:56:29 +00:00
|
|
|
Output: None
|
|
|
|
Note: This function is only needed if the DLL is allowing raw
|
2016-06-05 01:34:12 +00:00
|
|
|
data.
|
2021-05-18 11:51:36 +00:00
|
|
|
*/
|
2021-03-16 05:04:30 +00:00
|
|
|
|
2022-07-18 12:56:29 +00:00
|
|
|
EXPORT void CALL ReadController(int /*Control*/, uint8_t * /*Command*/)
|
2016-06-05 01:34:12 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-05-18 11:51:36 +00:00
|
|
|
/*
|
2016-06-05 01:34:12 +00:00
|
|
|
Function: RomClosed
|
2022-07-18 12:56:29 +00:00
|
|
|
Purpose: This function is called when a ROM is closed.
|
|
|
|
Input: None
|
|
|
|
Output: None
|
2021-05-18 11:51:36 +00:00
|
|
|
*/
|
2021-03-16 05:04:30 +00:00
|
|
|
|
2022-07-18 12:56:29 +00:00
|
|
|
EXPORT void CALL RomClosed(void)
|
2016-06-05 01:34:12 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-05-18 11:51:36 +00:00
|
|
|
/*
|
2016-06-05 01:34:12 +00:00
|
|
|
Function: RomOpen
|
2022-07-18 12:56:29 +00:00
|
|
|
Purpose: This function is called when a ROM is open. (from the
|
2016-06-05 01:34:12 +00:00
|
|
|
emulation thread)
|
2022-07-18 12:56:29 +00:00
|
|
|
Input: None
|
|
|
|
Output: None
|
2021-05-18 11:51:36 +00:00
|
|
|
*/
|
2021-03-16 05:04:30 +00:00
|
|
|
|
2022-07-18 12:56:29 +00:00
|
|
|
EXPORT void CALL RomOpen(void)
|
2016-06-05 01:34:12 +00:00
|
|
|
{
|
|
|
|
memset(&g_buttons, 0, sizeof(g_buttons));
|
|
|
|
}
|
|
|
|
|
2021-05-18 11:51:36 +00:00
|
|
|
/*
|
2016-06-05 01:34:12 +00:00
|
|
|
Function: WM_KeyDown
|
2022-07-18 12:56:29 +00:00
|
|
|
Purpose: To pass the WM_KeyDown message from the emulator to the
|
2016-06-05 01:34:12 +00:00
|
|
|
plugin.
|
2022-07-18 12:56:29 +00:00
|
|
|
Input: wParam and lParam of the WM_KEYDOWN message.
|
|
|
|
Output: None
|
2021-05-18 11:51:36 +00:00
|
|
|
*/
|
2021-03-16 05:04:30 +00:00
|
|
|
|
2022-07-18 12:56:29 +00:00
|
|
|
EXPORT void CALL WM_KeyDown(uint32_t /*wParam*/, uint32_t /*lParam*/)
|
2016-06-05 01:34:12 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-05-18 11:51:36 +00:00
|
|
|
/*
|
2016-06-05 01:34:12 +00:00
|
|
|
Function: WM_KeyUp
|
2022-07-18 12:56:29 +00:00
|
|
|
Purpose: To pass the WM_KEYUP message from the emulator to the
|
2016-06-05 01:34:12 +00:00
|
|
|
plugin.
|
2022-07-18 12:56:29 +00:00
|
|
|
Input: wParam and lParam of the WM_KEYDOWN message.
|
|
|
|
Output: None
|
2021-05-18 11:51:36 +00:00
|
|
|
*/
|
2021-03-16 05:04:30 +00:00
|
|
|
|
2022-07-18 12:56:29 +00:00
|
|
|
EXPORT void CALL WM_KeyUp(uint32_t /*wParam*/, uint32_t /*lParam*/)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
EXPORT void CALL PluginLoaded(void)
|
2016-06-05 01:34:12 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef ANDROID
|
|
|
|
EXPORT void CALL Java_emu_project64_jni_NativeInput_setState(JNIEnv* env, jclass jcls, jint controllerNum, jbooleanArray Buttons, jint pXAxis, jint pYAxis)
|
|
|
|
{
|
|
|
|
jboolean* elements = env->GetBooleanArrayElements(Buttons, NULL);
|
|
|
|
if (controllerNum == 0)
|
|
|
|
{
|
|
|
|
g_buttons.R_DPAD = elements[0];
|
|
|
|
g_buttons.L_DPAD = elements[1];
|
|
|
|
g_buttons.D_DPAD = elements[2];
|
|
|
|
g_buttons.U_DPAD = elements[3];
|
|
|
|
g_buttons.START_BUTTON = elements[4];
|
|
|
|
g_buttons.Z_TRIG = elements[5];
|
|
|
|
g_buttons.B_BUTTON = elements[6];
|
|
|
|
g_buttons.A_BUTTON = elements[7];
|
|
|
|
g_buttons.R_CBUTTON = elements[8];
|
|
|
|
g_buttons.L_CBUTTON = elements[9];
|
|
|
|
g_buttons.D_CBUTTON = elements[10];
|
|
|
|
g_buttons.U_CBUTTON = elements[11];
|
|
|
|
g_buttons.R_TRIG = elements[12];
|
|
|
|
g_buttons.L_TRIG = elements[13];
|
|
|
|
g_buttons.Reserved1 = elements[14];
|
|
|
|
g_buttons.Reserved2 = elements[15];
|
|
|
|
g_buttons.Y_AXIS = pXAxis;
|
|
|
|
g_buttons.X_AXIS = pYAxis;
|
|
|
|
}
|
|
|
|
env->ReleaseBooleanArrayElements(Buttons, elements, 0);
|
|
|
|
}
|
2021-03-16 05:04:30 +00:00
|
|
|
#endif
|