Game Development Reference
In-Depth Information
// in Natives.java
public static native int mouseMove(int deltaX, int deltaY);
// in jni_quake.c
extern int mouse_x, mouse_y;
JNIEXPORT jint JNICALL Java_quake_jni_Natives_mouseMove
(JNIEnv * env, jclass cls, jint mx, jint my)
{
// for pitch & yaw (look)
mouse_x = (int)mx;
mouse_y = (int)my;
/*
for forward or side movement use
mouse_side = (int)mx;
mouse_fwd = (int)my;
*/
}
// In gl_vidandroid.c (VIDEO DRIVER)
// Set PITCH & YAW
void IN_MouseLook (usercmd_t *cmd)
{
if (!mouse_avail)
return;
if (m_filter.value)
{
mouse_x = (mouse_x + old_mouse_x) * 0.5;
mouse_y = (mouse_y + old_mouse_y) * 0.5;
}
old_mouse_x = mouse_x;
old_mouse_y = mouse_y;
mouse_x *= sensitivity.value;
mouse_y *= sensitivity.value;
// Set PITCH and YAW based on mouse XY delta coordinates
cl.viewangles[YAW] -= m_yaw.value * mouse_x;
V_StopPitchDrift ();
cl.viewangles[PITCH] += m_pitch.value * mouse_y;
if (cl.viewangles[PITCH] > 80)
cl.viewangles[PITCH] = 80;
if (cl.viewangles[PITCH] < -70)
cl.viewangles[PITCH] = -70;
mouse_x = mouse_y = 0;
}
Search WWH ::




Custom Search