diff --git a/engine/client/client.h b/engine/client/client.h index ffd1bd136..69c1ffaac 100644 --- a/engine/client/client.h +++ b/engine/client/client.h @@ -1210,6 +1210,7 @@ qboolean CSQC_ConsoleCommand(char *cmd); qboolean CSQC_KeyPress(int key, int unicode, qboolean down, int devid); qboolean CSQC_MouseMove(float xdelta, float ydelta, int devid); qboolean CSQC_MousePosition(float xabs, float yabs, int devid); +qboolean CSQC_JoystickAxis(int axis, float value, int devid); qboolean CSQC_Accelerometer(float x, float y, float z); int CSQC_StartSound(int entnum, int channel, char *soundname, vec3_t pos, float vol, float attenuation, float pitchmod); void CSQC_ParseEntities(void); diff --git a/engine/client/in_generic.c b/engine/client/in_generic.c index d6107ec47..21a17cbfa 100644 --- a/engine/client/in_generic.c +++ b/engine/client/in_generic.c @@ -205,7 +205,10 @@ void IN_Commands(void) Key_Event(ev->devid, ev->keyboard.scancode, ev->keyboard.unicode, ev->type == IEV_KEYDOWN); break; case IEV_JOYAXIS: - joy[ev->devid].axis[ev->joy.axis] = ev->joy.value; + if (CSQC_JoystickAxis(ev->joy.axis, ev->joy.value, ev->devid)) + joy[ev->devid].axis[ev->joy.axis] = 0; + else + joy[ev->devid].axis[ev->joy.axis] = ev->joy.value; break; case IEV_MOUSEDELTA: if (ev->devid < MAXPOINTERS) diff --git a/engine/client/in_win.c b/engine/client/in_win.c index 703087933..6c4dbf3dc 100644 --- a/engine/client/in_win.c +++ b/engine/client/in_win.c @@ -1869,6 +1869,9 @@ void INS_JoyMove (float *movements, int pnum) // convert range from -32768..32767 to -1..1 fAxisValue /= 32768.0; + if (CSQC_JoystickAxis(i, fAxisValue, 0)) + continue; + switch (dwAxisMap[i]) { case AxisForward: diff --git a/engine/client/pr_csqc.c b/engine/client/pr_csqc.c index 7a57f9ce2..f1f77aaa2 100644 --- a/engine/client/pr_csqc.c +++ b/engine/client/pr_csqc.c @@ -5996,6 +5996,21 @@ qboolean CSQC_MouseMove(float xdelta, float ydelta, int devid) return G_FLOAT(OFS_RETURN); } +qboolean CSQC_JoystickAxis(int axis, float value, int devid) +{ + void *pr_globals; + if (!csqcprogs || !csqcg.input_event) + return false; + pr_globals = PR_globals(csqcprogs, PR_CURRENT); + + G_FLOAT(OFS_PARM0) = CSIE_JOYAXIS; + G_FLOAT(OFS_PARM1) = axis; + G_FLOAT(OFS_PARM2) = value; + G_FLOAT(OFS_PARM3) = devid; + PR_ExecuteProgram (csqcprogs, csqcg.input_event); + return G_FLOAT(OFS_RETURN); +} + qboolean CSQC_Accelerometer(float x, float y, float z) { void *pr_globals; diff --git a/engine/client/sys_droid.c b/engine/client/sys_droid.c index b332adade..7adac5bb8 100644 --- a/engine/client/sys_droid.c +++ b/engine/client/sys_droid.c @@ -159,7 +159,7 @@ JNIEXPORT void JNICALL Java_com_fteqw_FTEDroidEngine_newglcontext(JNIEnv *env, j if (sys_running) sys_running = 2; - //fixme: wipe image handles + //fixme: wipe image handles, and vbos } //called when the user tries to use us to open one of our file types diff --git a/engine/common/pr_common.h b/engine/common/pr_common.h index 82c7d48a8..0d9f6ae96 100644 --- a/engine/common/pr_common.h +++ b/engine/common/pr_common.h @@ -632,6 +632,7 @@ enum csqc_input_event CSIE_MOUSEABS = 3, /*x, y, devid */ CSIE_ACCELEROMETER = 4, /*x, y, z*/ CSIE_FOCUS = 5, /*mouse, key, devid. if has, the game window has focus. (true/false/-1)*/ + CSIE_JOYAXIS = 6, /*axis, value, devid*/ }; enum terrainedit_e diff --git a/engine/server/pr_cmds.c b/engine/server/pr_cmds.c index 92e9b3947..1db9f06d0 100644 --- a/engine/server/pr_cmds.c +++ b/engine/server/pr_cmds.c @@ -10612,6 +10612,7 @@ void PR_DumpPlatform_f(void) {"IE_MOUSEABS", "const float", CS, "Specifies that a mouse cursor or touch event was moved to a specific location relative to the virtual screen space. Second argument is the new X position, third argument is the new Y position. Fourth argument is which mouse or touch event triggered the event.", CSIE_MOUSEABS}, {"IE_ACCELEROMETER", "const float", CS, NULL, CSIE_ACCELEROMETER}, {"IE_FOCUS", "const float", CS, "Specifies that input focus was given. parama says mouse focus, paramb says keyboard focus. If either are -1, then it is unchanged.", CSIE_FOCUS}, + {"IE_JOYAXIS", "const float", CS, "Specifies that what value a joystick/controller axis currently specifies. x=axis, y=value. Will be called multiple times, once for each axis of each active controller.", CSIE_JOYAXIS}, {"CLIENTTYPE_DISCONNECTED","const float", QW|NQ, "Return value from clienttype() builtin. This entity is a player slot that is currently empty.", CLIENTTYPE_DISCONNECTED}, {"CLIENTTYPE_REAL", "const float", QW|NQ, "This is a real player, and not a bot.", CLIENTTYPE_REAL},