private static void IN_MouseMove(client.usercmd_t cmd) { int mx, my; int i; //DIDEVICEOBJECTDATA od; //DWORD dwElements; //HRESULT hr; //if (!mouseactive) // return; //if (dinput) //{ mx = 0; my = 0; //for (; ; ) //{ // dwElements = 1; // hr = IDirectInputDevice_GetDeviceData(g_pMouse, // sizeof(DIDEVICEOBJECTDATA), od, dwElements, 0); // if ((hr == DIERR_INPUTLOST) || (hr == DIERR_NOTACQUIRED)) // { // dinput_acquired = true; // IDirectInputDevice_Acquire(g_pMouse); // break; // } // /* Unable to read data or no data available */ // if (FAILED(hr) || dwElements == 0) // { // break; // } // /* Look at the element to see what happened */ // switch (od.dwOfs) // { // case DIMOFS_X: // mx += od.dwData; // break; // case DIMOFS_Y: // my += od.dwData; // break; // case DIMOFS_BUTTON0: // if (od.dwData & 0x80) // mstate_di |= 1; // else // mstate_di &= ~1; // break; // case DIMOFS_BUTTON1: // if (od.dwData & 0x80) // mstate_di |= (1 << 1); // else // mstate_di &= ~(1 << 1); // break; // case DIMOFS_BUTTON2: // if (od.dwData & 0x80) // mstate_di |= (1 << 2); // else // mstate_di &= ~(1 << 2); // break; // } //} //// perform button actions //for (i = 0; i < mouse_buttons; i++) //{ // if ((mstate_di & (1 << i)) != 0 && (mouse_oldbuttonstate & (1 << i)) == 0) // { // keys.Key_Event(keys.K_MOUSE1 + i, true); // } // if ((mstate_di & (1 << i)) == 0 && (mouse_oldbuttonstate & (1 << i)) != 0) // { // keys.Key_Event(keys.K_MOUSE1 + i, false); // } //} //mouse_oldbuttonstate = mstate_di; //} //else //{ // GetCursorPos(current_pos); // mx = current_pos.x - window_center_x + mx_accum; // my = current_pos.y - window_center_y + my_accum; // mx_accum = 0; // my_accum = 0; //} mx = mouseMovedX; my = mouseMovedY; //if (mx || my) // Con_DPrintf("mx=%d, my=%d\n", mx, my); if (m_filter.value != 0) { mouse_x = (int)((mx + old_mouse_x) * 0.5); mouse_y = (int)((my + old_mouse_y) * 0.5); } else { mouse_x = mx; mouse_y = my; } old_mouse_x = mx; old_mouse_y = my; mouse_x *= (int)client.sensitivity.value; mouse_y *= (int)client.sensitivity.value; // add mouse X/Y movement to cmd if ((client.in_strafe.state & 1) != 0 || (client.lookstrafe.value != 0 && ((client.in_mlook.state & 1) != 0))) cmd.sidemove += client.m_side.value * mouse_x; else client.cl.viewangles[quakedef.YAW] -= client.m_yaw.value * mouse_x; if ((client.in_mlook.state & 1) != 0) view.V_StopPitchDrift(); if ((client.in_mlook.state & 1) != 0 && (client.in_strafe.state & 1) == 0) { client.cl.viewangles[quakedef.PITCH] += client.m_pitch.value * mouse_y; if (client.cl.viewangles[quakedef.PITCH] > 80) client.cl.viewangles[quakedef.PITCH] = 80; if (client.cl.viewangles[quakedef.PITCH] < -70) client.cl.viewangles[quakedef.PITCH] = -70; } else { if ((client.in_strafe.state & 1) != 0 && host.noclip_anglehack) cmd.upmove -= client.m_forward.value * mouse_y; else cmd.forwardmove -= client.m_forward.value * mouse_y; } //// if the mouse has moved, force it to the center, so there's room to move //if (mx || my) //{ // SetCursorPos(window_center_x, window_center_y); //} mouseMovedX = 0; mouseMovedY = 0; }
/* =================== SV_ReadClientMove =================== */ static void SV_ReadClientMove(client.usercmd_t move) { int i; double[] angle = new double[3]; int bits; // read ping time host.host_client.ping_times[host.host_client.num_pings % NUM_PING_TIMES] = sv.time - common.MSG_ReadFloat (); host.host_client.num_pings++; // read current angles for (i=0 ; i<3 ; i++) angle[i] = common.MSG_ReadAngle (); mathlib.VectorCopy (angle, ref host.host_client.edict.v.v_angle); // read movement move.forwardmove = common.MSG_ReadShort(); move.sidemove = common.MSG_ReadShort(); move.upmove = common.MSG_ReadShort(); // read buttons bits = common.MSG_ReadByte(); host.host_client.edict.v.button0 = bits & 1; host.host_client.edict.v.button2 = (bits & 2) >> 1; i = common.MSG_ReadByte(); if (i != 0) host.host_client.edict.v.impulse = i; }
/* =========== IN_Move =========== */ public static void IN_Move(client.usercmd_t cmd) { //if (ActiveApp && !Minimized) //{ IN_MouseMove (cmd); //IN_JoyMove (cmd); // todo - html5 gamepad api (pointless for fps!!!) //} }