48#if !defined(_WIN32) && !defined (ANDROID)
59AInputQueue* AndroidInputQueue;
78 Joypad* joypad = MMgetPointer<Joypad*>(m, MTOP(handscol));
81 MMsetPointer<Joypad*>(m, MTOP(handscol), 0);
84 MMechostr(MSKDEBUG,
"Joypad object destroyed.\n");
108#if defined(_WIN32) || defined (ANDROID)
115 MMechostr(0,
"_OpenJoypad\n");
121 int pUser = MMget(m, 0);
122 int cbfun = MMget(m, 1);
123 int channel = MMget(m, 2);
126 if (channel == NIL || cbfun == NIL)
128 MMechostr(MSKDEBUG,
"Channel NIL\n");
129 SEDROP(m, 2); MMset(m, 0, NIL);
134 if (joypad == NULL || (joypad->
IsRunning() ==
false))
136 MMechostr(MSKDEBUG,
"joypad failed\n");
138 SEDROP(m, 2); MMset(m, 0, NIL);
143 if ((k = MMpush(m, MMget(m, 2))))
147 if ((MMpushPointer(m, joypad) != 0))
158 if ((k = MMpush(m, MMget(m, 2))))
160 if ((k = MMpush(m, MMget(m, 2))))
195#if defined(_WIN32) || defined (ANDROID)
202 MMechostr(0,
"_OpenJoypadEx\n");
208 int pUser = MMpull(m);
209 int cbfun = MMpull(m);
210 int sIndex = MTOI(MMpull(m));
211 int channel = MMget(m, 0);
214 if (channel == NIL || cbfun == NIL)
216 MMechostr(MSKDEBUG,
"Channel NIL\n");
222 if (joypad == NULL || (joypad->
IsRunning() ==
false))
224 MMechostr(MSKDEBUG,
"joypad failed\n");
235 if ((k = MMpush(m, MMget(m, 2))))
239 if ((MMpushPointer(m, joypad) != 0))
250 if ((k = MMpush(m, MMget(m, 2))))
252 if ((k = MMpush(m, MMget(m, 2))))
261 MMechostr(0,
"ok\n");
267#if !defined(_WIN32) && !defined (ANDROID)
289 MMechostr(MSKDEBUG,
"_CloseJoypad\n");
292 int joypad = MMget(m, 0);
300 MMset(m, 0, ITOM(0));
303 MMechostr(MSKDEBUG,
"ok\n");
320 MMechostr(MSKDEBUG,
"_StartJoypadRumble\n");
323 int iintensity = MMpull(m);
324 int idevice = MMget(m, 0);
331 Joypad* joypad = MMgetPointer<Joypad*>(m, MTOP(idevice));
338 float intensity = 0.5f;
339 if (intensity != NIL)
340 intensity = MTOF(iintensity);
343 MMset(m, 0, ITOM(0));
346 MMechostr(MSKDEBUG,
"ok\n");
361 MMechostr(MSKDEBUG,
"_StopJoypadRumble\n");
364 int idevice = MMget(m, 0);
371 Joypad* joypad = MMgetPointer<Joypad*>(m, MTOP(idevice));
379 MMset(m, 0, ITOM(0));
382 MMechostr(MSKDEBUG,
"ok\n");
407 MMechostr(MSKDEBUG,
"Joypad not found\n");
411 int tuple = MMmalloc(m, 2, TYPETAB);
418 MMstore(m, tuple, 0, ITOM(ndata->
lX));
419 MMstore(m, tuple, 1, ITOM(ndata->
lY));
421 MMpush(m, PTOM(tuple));
422 MMpush(m, ITOM(ndata->
lZ));
424 int tuple2 = MMmalloc(m, 2, TYPETAB);
430 MMstore(m, tuple2, 0, ITOM(ndata->
lRx));
431 MMstore(m, tuple2, 1, ITOM(ndata->
lRy));
433 MMpush(m,PTOM(tuple2));
434 MMpush(m,ITOM(ndata->
lRz));
436 int tuple3 = MMmalloc(m, 4, TYPETAB);
442 MMstore(m, tuple3, 0, ITOM(ndata->
rgdwPOV[0]));
443 MMstore(m, tuple3, 1, ITOM(ndata->
rgdwPOV[1]));
444 MMstore(m, tuple3, 2, ITOM(ndata->
rgdwPOV[2]));
445 MMstore(m, tuple3, 3, ITOM(ndata->
rgdwPOV[3]));
447 MMpush(m,PTOM(tuple3));
449 int tuple4 = MMmalloc(m, 2, TYPETAB);
455 MMstore(m, tuple4, 0, ITOM(ndata->
rglSlider[0]));
456 MMstore(m, tuple4, 1, ITOM(ndata->
rglSlider[1]));
458 MMpush(m,PTOM(tuple4));
461 for (
int i = 0; i < 16; i++)
469 if(MMpush(m,ITOM(1)))
474 if(MMpush(m,ITOM(0)))
482 for(
int i = 0; i < 16; i++)
491 k = OBJcallreflex(m, 7 );
496static NativeDefinition sJoypadDef[] =
498 {
"ObjJoypad", TYPTYPE, NULL, NULL },
499 {
"_OpenJoypad", 3,
"fun [Chn fun [ObjJoypad u0 [I I] I [I I] I [I I I I] [I I] [I r1]] u1 u0] ObjJoypad",
_OpenJoypad },
500 {
"_OpenJoypadEx", 4,
"fun [Chn I fun [ObjJoypad u0 [I I] I [I I] I [I I I I] [I I] [I r1]] u1 u0] ObjJoypad",
_OpenJoypadEx },
501 {
"_CloseJoypad", 1,
"fun [ObjJoypad] I",
_CloseJoypad },
513int LoadJoypad(mmachine m)
515 MMechostr(MSKDEBUG,
"\n" );
516 MMechostr(MSKDEBUG,
" > Loading Joypad Support\n");
518#if !defined(_WIN32) && !defined (ANDROID)
519 CallMainThread=(int (__cdecl *)(
void*, mmachine))SCgetExtra(
"callMainThread");
531 int k = PKhardpak2(m,
"JoypadEngine.pkg-1.0",
sizeof(sJoypadDef) /
sizeof(sJoypadDef[0]), sJoypadDef);
534 AndroidInputQueue = (AInputQueue*)SCgetExtra(
"inputQueue");
537 MMechostr(MSKDEBUG,
" > Successfully Loaded\n\n");
554 return LoadJoypad(m);
578 Joypad::updateInputEvent((AInputEvent*)event);
bool StartRumble(float intensity)
int _CloseJoypad(mmachine m)
_CloseJoypad : Destroy joypad object
int _OpenJoypadSync(mmachine m)
_OpenJoypad : This function open a joypad and init the data callback
int _StartJoypadRumble(mmachine m)
_StartJoypadRumble : Start joypad rumble
int _OpenJoypadExSync(mmachine m)
_OpenJoypadEx : This function open a joypad and init the data callback
int _StopJoypadRumble(mmachine m)
_StopJoypadRumble : Stop the joypad rumble
SCOL_EXPORT int ScolJoypadUnloadPlugin()
SCOL_EXPORT void ScolJoypadHandleWindowEventPlugin(mmachine m, SCOL_PTR_TYPE event, int wparam, int lparam)
SCOL_EXPORT int ScolJoypadLoadPlugin(mmachine m, cbmachine w)
int _OpenJoypadEx(mmachine m)
SCOL_EXPORT int ScolLoadPlugin(mmachine m, cbmachine w)
Starting point of the DLL Function to add in Scol usm.ini for loading dll.
int _OpenJoypad(mmachine m)
int destroyJoypadObj(mmachine m, SCOL_PTR_TYPE handsys, int handscol)
Destroys a joypad Object in scol.
cbmachine ww
Scol machine declaration for MM macros.
SCOL_EXPORT int ScolUnloadPlugin()
Ending point of the DLL Function to add in Scol usm.ini for free dll.
SCOL_EXPORT void ScolHandleWindowEventPlugin(mmachine m, SCOL_PTR_TYPE event, int wparam, int lparam)
int(* CallMainThread)(void *, mmachine m)
int getJoypadData(mmachine m, SCOL_PTR_TYPE id, SCOL_PTR_TYPE param)