add joystick csqc event stuff.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4700 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2014-06-27 16:10:10 +00:00
parent ceb32ec494
commit 51baf65e9b
7 changed files with 26 additions and 2 deletions

View file

@ -1210,6 +1210,7 @@ qboolean CSQC_ConsoleCommand(char *cmd);
qboolean CSQC_KeyPress(int key, int unicode, qboolean down, int devid); qboolean CSQC_KeyPress(int key, int unicode, qboolean down, int devid);
qboolean CSQC_MouseMove(float xdelta, float ydelta, int devid); qboolean CSQC_MouseMove(float xdelta, float ydelta, int devid);
qboolean CSQC_MousePosition(float xabs, float yabs, 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); 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); int CSQC_StartSound(int entnum, int channel, char *soundname, vec3_t pos, float vol, float attenuation, float pitchmod);
void CSQC_ParseEntities(void); void CSQC_ParseEntities(void);

View file

@ -205,7 +205,10 @@ void IN_Commands(void)
Key_Event(ev->devid, ev->keyboard.scancode, ev->keyboard.unicode, ev->type == IEV_KEYDOWN); Key_Event(ev->devid, ev->keyboard.scancode, ev->keyboard.unicode, ev->type == IEV_KEYDOWN);
break; break;
case IEV_JOYAXIS: 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; break;
case IEV_MOUSEDELTA: case IEV_MOUSEDELTA:
if (ev->devid < MAXPOINTERS) if (ev->devid < MAXPOINTERS)

View file

@ -1869,6 +1869,9 @@ void INS_JoyMove (float *movements, int pnum)
// convert range from -32768..32767 to -1..1 // convert range from -32768..32767 to -1..1
fAxisValue /= 32768.0; fAxisValue /= 32768.0;
if (CSQC_JoystickAxis(i, fAxisValue, 0))
continue;
switch (dwAxisMap[i]) switch (dwAxisMap[i])
{ {
case AxisForward: case AxisForward:

View file

@ -5996,6 +5996,21 @@ qboolean CSQC_MouseMove(float xdelta, float ydelta, int devid)
return G_FLOAT(OFS_RETURN); 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) qboolean CSQC_Accelerometer(float x, float y, float z)
{ {
void *pr_globals; void *pr_globals;

View file

@ -159,7 +159,7 @@ JNIEXPORT void JNICALL Java_com_fteqw_FTEDroidEngine_newglcontext(JNIEnv *env, j
if (sys_running) if (sys_running)
sys_running = 2; 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 //called when the user tries to use us to open one of our file types

View file

@ -632,6 +632,7 @@ enum csqc_input_event
CSIE_MOUSEABS = 3, /*x, y, devid */ CSIE_MOUSEABS = 3, /*x, y, devid */
CSIE_ACCELEROMETER = 4, /*x, y, z*/ CSIE_ACCELEROMETER = 4, /*x, y, z*/
CSIE_FOCUS = 5, /*mouse, key, devid. if has, the game window has focus. (true/false/-1)*/ 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 enum terrainedit_e

View file

@ -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_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_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_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_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}, {"CLIENTTYPE_REAL", "const float", QW|NQ, "This is a real player, and not a bot.", CLIENTTYPE_REAL},