/* =========== IN_Init =========== */ void IN_Init (void) { m_filter = gEngfuncs.pfnRegisterVariable ( "m_filter","0", FCVAR_ARCHIVE ); sensitivity = gEngfuncs.pfnRegisterVariable ( "sensitivity","3", FCVAR_ARCHIVE ); // user mouse sensitivity setting. in_joystick = gEngfuncs.pfnRegisterVariable ( "joystick","0", FCVAR_ARCHIVE ); joy_name = gEngfuncs.pfnRegisterVariable ( "joyname", "joystick", 0 ); joy_advanced = gEngfuncs.pfnRegisterVariable ( "joyadvanced", "0", 0 ); joy_advaxisx = gEngfuncs.pfnRegisterVariable ( "joyadvaxisx", "0", 0 ); joy_advaxisy = gEngfuncs.pfnRegisterVariable ( "joyadvaxisy", "0", 0 ); joy_advaxisz = gEngfuncs.pfnRegisterVariable ( "joyadvaxisz", "0", 0 ); joy_advaxisr = gEngfuncs.pfnRegisterVariable ( "joyadvaxisr", "0", 0 ); joy_advaxisu = gEngfuncs.pfnRegisterVariable ( "joyadvaxisu", "0", 0 ); joy_advaxisv = gEngfuncs.pfnRegisterVariable ( "joyadvaxisv", "0", 0 ); joy_forwardthreshold = gEngfuncs.pfnRegisterVariable ( "joyforwardthreshold", "0.15", 0 ); joy_sidethreshold = gEngfuncs.pfnRegisterVariable ( "joysidethreshold", "0.15", 0 ); joy_pitchthreshold = gEngfuncs.pfnRegisterVariable ( "joypitchthreshold", "0.15", 0 ); joy_yawthreshold = gEngfuncs.pfnRegisterVariable ( "joyyawthreshold", "0.15", 0 ); joy_forwardsensitivity = gEngfuncs.pfnRegisterVariable ( "joyforwardsensitivity", "-1.0", 0 ); joy_sidesensitivity = gEngfuncs.pfnRegisterVariable ( "joysidesensitivity", "-1.0", 0 ); joy_pitchsensitivity = gEngfuncs.pfnRegisterVariable ( "joypitchsensitivity", "1.0", 0 ); joy_yawsensitivity = gEngfuncs.pfnRegisterVariable ( "joyyawsensitivity", "-1.0", 0 ); joy_wwhack1 = gEngfuncs.pfnRegisterVariable ( "joywwhack1", "0.0", 0 ); joy_wwhack2 = gEngfuncs.pfnRegisterVariable ( "joywwhack2", "0.0", 0 ); gEngfuncs.pfnAddCommand ("force_centerview", Force_CenterView_f); gEngfuncs.pfnAddCommand ("joyadvancedupdate", Joy_AdvancedUpdate_f); IN_StartupMouse (); IN_StartupJoystick (); }
void IN_Init(void) { Com_Printf ("\n------- Input Initialization -------\n"); // mouse variables in_mouse = Cvar_Get ("in_mouse", "1", CVAR_ARCHIVE); // turn on-off sub-frame timing of X events in_subframe = Cvar_Get ("in_subframe", "1", CVAR_ARCHIVE); // developer feature, allows to break without loosing mouse pointer in_nograb = Cvar_Get ("in_nograb", "0", 0); // bk001130 - from cvs.17 (mkv), joystick variables in_joystick = Cvar_Get ("in_joystick", "0", CVAR_ARCHIVE|CVAR_LATCH); // bk001130 - changed this to match win32 in_joystickDebug = Cvar_Get ("in_debugjoystick", "0", CVAR_TEMP); joy_threshold = Cvar_Get ("joy_threshold", "0.15", CVAR_ARCHIVE); // FIXME: in_joythreshold #ifdef MACOS_X Cvar_Set( "cl_platformSensitivity", "1.0" ); #else Cvar_Set( "cl_platformSensitivity", "2.0" ); #endif if (in_mouse->value) mouse_avail = qtrue; else mouse_avail = qfalse; IN_StartupJoystick( ); // bk001130 - from cvs1.17 (mkv) Com_Printf ("------------------------------------\n"); }
void IN_Init (void) { // mouse variables Cvar_RegisterVariable (&m_filter); // joystick variables Cvar_RegisterVariable (&in_joystick); Cvar_RegisterVariable (&joy_name); Cvar_RegisterVariable (&joy_advanced); Cvar_RegisterVariable (&joy_advaxisx); Cvar_RegisterVariable (&joy_advaxisy); Cvar_RegisterVariable (&joy_advaxisz); Cvar_RegisterVariable (&joy_advaxisr); Cvar_RegisterVariable (&joy_advaxisu); Cvar_RegisterVariable (&joy_advaxisv); Cvar_RegisterVariable (&joy_forwardthreshold); Cvar_RegisterVariable (&joy_sidethreshold); Cvar_RegisterVariable (&joy_pitchthreshold); Cvar_RegisterVariable (&joy_yawthreshold); Cvar_RegisterVariable (&joy_forwardsensitivity); Cvar_RegisterVariable (&joy_sidesensitivity); Cvar_RegisterVariable (&joy_pitchsensitivity); Cvar_RegisterVariable (&joy_yawsensitivity); Cvar_RegisterVariable (&joy_wwhack1); Cvar_RegisterVariable (&joy_wwhack2); Cmd_AddCommand ("force_centerview", Force_CenterView_f); Cmd_AddCommand ("joyadvancedupdate", Joy_AdvancedUpdate_f); uiWheelMessage = RegisterWindowMessage ( "MSWHEEL_ROLLMSG" ); IN_StartupMouse (); IN_StartupJoystick (); }
void IN_Init (void) { textmode = Key_TextEntry(); if (textmode) SDL_StartTextInput(); else SDL_StopTextInput(); if (safemode || COM_CheckParm("-nomouse")) { no_mouse = true; /* discard all mouse events when input is deactivated */ IN_BeginIgnoringMouseEvents(); } Cvar_RegisterVariable(&in_debugkeys); Cvar_RegisterVariable(&joy_sensitivity_yaw); Cvar_RegisterVariable(&joy_sensitivity_pitch); Cvar_RegisterVariable(&joy_deadzone); Cvar_RegisterVariable(&joy_deadzone_trigger); Cvar_RegisterVariable(&joy_invert); Cvar_RegisterVariable(&joy_exponent); Cvar_RegisterVariable(&joy_swapmovelook); Cvar_RegisterVariable(&joy_enable); IN_Activate(); IN_StartupJoystick(); }
/* =========== IN_Init =========== */ void IN_Init (void) { m_filter = gEngfuncs.pfnRegisterVariable ( "m_filter","0", FCVAR_ARCHIVE ); sensitivity = gEngfuncs.pfnRegisterVariable ( "sensitivity","3", FCVAR_ARCHIVE ); // user mouse sensitivity setting. in_joystick = gEngfuncs.pfnRegisterVariable ( "joystick","0", FCVAR_ARCHIVE ); joy_name = gEngfuncs.pfnRegisterVariable ( "joyname", "joystick", 0 ); joy_advanced = gEngfuncs.pfnRegisterVariable ( "joyadvanced", "0", 0 ); joy_advaxisx = gEngfuncs.pfnRegisterVariable ( "joyadvaxisx", "0", 0 ); joy_advaxisy = gEngfuncs.pfnRegisterVariable ( "joyadvaxisy", "0", 0 ); joy_advaxisz = gEngfuncs.pfnRegisterVariable ( "joyadvaxisz", "0", 0 ); joy_advaxisr = gEngfuncs.pfnRegisterVariable ( "joyadvaxisr", "0", 0 ); joy_advaxisu = gEngfuncs.pfnRegisterVariable ( "joyadvaxisu", "0", 0 ); joy_advaxisv = gEngfuncs.pfnRegisterVariable ( "joyadvaxisv", "0", 0 ); joy_forwardthreshold = gEngfuncs.pfnRegisterVariable ( "joyforwardthreshold", "0.15", 0 ); joy_sidethreshold = gEngfuncs.pfnRegisterVariable ( "joysidethreshold", "0.15", 0 ); joy_pitchthreshold = gEngfuncs.pfnRegisterVariable ( "joypitchthreshold", "0.15", 0 ); joy_yawthreshold = gEngfuncs.pfnRegisterVariable ( "joyyawthreshold", "0.15", 0 ); joy_forwardsensitivity = gEngfuncs.pfnRegisterVariable ( "joyforwardsensitivity", "-1.0", 0 ); joy_sidesensitivity = gEngfuncs.pfnRegisterVariable ( "joysidesensitivity", "-1.0", 0 ); joy_pitchsensitivity = gEngfuncs.pfnRegisterVariable ( "joypitchsensitivity", "1.0", 0 ); joy_yawsensitivity = gEngfuncs.pfnRegisterVariable ( "joyyawsensitivity", "-1.0", 0 ); joy_wwhack1 = gEngfuncs.pfnRegisterVariable ( "joywwhack1", "0.0", 0 ); joy_wwhack2 = gEngfuncs.pfnRegisterVariable ( "joywwhack2", "0.0", 0 ); m_customaccel = gEngfuncs.pfnRegisterVariable ( "m_customaccel", "0", FCVAR_ARCHIVE ); m_customaccel_scale = gEngfuncs.pfnRegisterVariable ( "m_customaccel_scale", "0.04", FCVAR_ARCHIVE ); m_customaccel_max = gEngfuncs.pfnRegisterVariable ( "m_customaccel_max", "0", FCVAR_ARCHIVE ); m_customaccel_exponent = gEngfuncs.pfnRegisterVariable ( "m_customaccel_exponent", "1", FCVAR_ARCHIVE ); #ifdef _WIN32 m_bRawInput = CVAR_GET_FLOAT( "m_rawinput" ) != 0; m_bMouseThread = gEngfuncs.CheckParm ("-mousethread", NULL ) != NULL; m_mousethread_sleep = gEngfuncs.pfnRegisterVariable ( "m_mousethread_sleep", "1", FCVAR_ARCHIVE ); // default to less than 1000 Hz m_bMouseThread = m_bMouseThread && NULL != m_mousethread_sleep; if (m_bMouseThread) { s_hMouseQuitEvent = CreateEvent( NULL, FALSE, FALSE, NULL ); s_hMouseThreadActiveLock = CreateEvent( NULL, FALSE, TRUE, NULL ); if ( s_hMouseQuitEvent && s_hMouseThreadActiveLock) { s_hMouseThread = (HANDLE)_beginthreadex( NULL, 0, MouseThread_Function, NULL, 0, &s_hMouseThreadId ); } m_bMouseThread = NULL != s_hMouseThread; // at this early stage this won't print anything: // gEngfuncs.Con_DPrintf ("Mouse thread %s.\n", m_bMouseThread ? "initalized" : "failed to initalize"); } #endif gEngfuncs.pfnAddCommand ("force_centerview", Force_CenterView_f); gEngfuncs.pfnAddCommand ("joyadvancedupdate", Joy_AdvancedUpdate_f); IN_StartupMouse (); IN_StartupJoystick (); }
/** * \brief Initialize mouse and joy-stick. */ void IN_Init( void ) { // centering v_centermove = Cvar_Get( "v_centermove", "0.15", 0); v_centerspeed = Cvar_Get( "v_centerspeed", "500", 0); IN_StartupMouse(); IN_StartupJoystick(); }
/* =========== IN_Init =========== */ void IN_Init(void) { m_filter = gEngfuncs.pfnRegisterVariable("m_filter", "0", FCVAR_ARCHIVE); sensitivity = gEngfuncs.pfnRegisterVariable("sensitivity", "3", FCVAR_ARCHIVE); // user mouse sensitivity setting. in_joystick = gEngfuncs.pfnRegisterVariable("joystick", "0", FCVAR_ARCHIVE); joy_name = gEngfuncs.pfnRegisterVariable("joyname", "joystick", 0); joy_advanced = gEngfuncs.pfnRegisterVariable("joyadvanced", "0", 0); joy_advaxisx = gEngfuncs.pfnRegisterVariable("joyadvaxisx", "0", 0); joy_advaxisy = gEngfuncs.pfnRegisterVariable("joyadvaxisy", "0", 0); joy_advaxisz = gEngfuncs.pfnRegisterVariable("joyadvaxisz", "0", 0); joy_advaxisr = gEngfuncs.pfnRegisterVariable("joyadvaxisr", "0", 0); joy_advaxisu = gEngfuncs.pfnRegisterVariable("joyadvaxisu", "0", 0); joy_advaxisv = gEngfuncs.pfnRegisterVariable("joyadvaxisv", "0", 0); joy_forwardthreshold = gEngfuncs.pfnRegisterVariable("joyforwardthreshold", "0.15", 0); joy_sidethreshold = gEngfuncs.pfnRegisterVariable("joysidethreshold", "0.15", 0); joy_pitchthreshold = gEngfuncs.pfnRegisterVariable("joypitchthreshold", "0.15", 0); joy_yawthreshold = gEngfuncs.pfnRegisterVariable("joyyawthreshold", "0.15", 0); joy_forwardsensitivity = gEngfuncs.pfnRegisterVariable("joyforwardsensitivity", "-1.0", 0); joy_sidesensitivity = gEngfuncs.pfnRegisterVariable("joysidesensitivity", "-1.0", 0); joy_pitchsensitivity = gEngfuncs.pfnRegisterVariable("joypitchsensitivity", "1.0", 0); joy_yawsensitivity = gEngfuncs.pfnRegisterVariable("joyyawsensitivity", "-1.0", 0); joy_wwhack1 = gEngfuncs.pfnRegisterVariable("joywwhack1", "0.0", 0); joy_wwhack2 = gEngfuncs.pfnRegisterVariable("joywwhack2", "0.0", 0); m_customaccel = gEngfuncs.pfnRegisterVariable("m_customaccel", "0", FCVAR_ARCHIVE); m_customaccel_scale = gEngfuncs.pfnRegisterVariable("m_customaccel_scale", "0.04", FCVAR_ARCHIVE); m_customaccel_max = gEngfuncs.pfnRegisterVariable("m_customaccel_max", "0", FCVAR_ARCHIVE); m_customaccel_exponent = gEngfuncs.pfnRegisterVariable("m_customaccel_exponent", "1", FCVAR_ARCHIVE); #ifdef _WIN32 m_bRawInput = CVAR_GET_FLOAT("m_rawinput") > 0; m_bMouseThread = gEngfuncs.CheckParm("-mousethread", NULL) != NULL; m_mousethread_sleep = gEngfuncs.pfnRegisterVariable("m_mousethread_sleep", "10", FCVAR_ARCHIVE); if(!m_bRawInput && m_bMouseThread && m_mousethread_sleep) { s_mouseDeltaX = s_mouseDeltaY = 0; s_hMouseQuitEvent = CreateEvent(NULL, FALSE, FALSE, NULL); if(s_hMouseQuitEvent) { s_hMouseThread = CreateThread(NULL, 0, MousePos_ThreadFunction, NULL, 0, &s_hMouseThreadId); } } #endif gEngfuncs.pfnAddCommand("force_centerview", Force_CenterView_f); gEngfuncs.pfnAddCommand("joyadvancedupdate", Joy_AdvancedUpdate_f); IN_StartupMouse(); IN_StartupJoystick(); }
/* =========== IN_Startup =========== */ void IN_Startup( void ) { // TODO: no joystick support yet... // Com_Printf ("\n------- Input Initialization -------\n"); IN_StartupMouse(); IN_StartupJoystick(); IN_StartupMIDI(); // Com_Printf ("------------------------------------\n"); in_mouse->modified = qfalse; in_joystick->modified = qfalse; }
void IN_Init(void) { // mouse variables in_mouse = Cvar_Get ("in_mouse", "1", CVAR_ARCHIVE); in_dgamouse = Cvar_Get ("in_dgamouse", "1", CVAR_ARCHIVE); if (in_mouse->value) mouse_avail = qtrue; else mouse_avail = qfalse; #ifdef JOYSTICK in_joystick = Cvar_Get( "in_joystick", "0", CVAR_ARCHIVE | CVAR_LATCH ); in_joystickDebug = Cvar_Get( "in_debugjoystick", "0", CVAR_TEMP ); joy_threshold = Cvar_Get( "joy_threshold", "0.30", CVAR_ARCHIVE ); // FIXME: in_joythreshold IN_StartupJoystick(); #endif }
void IN_Init(void) { // mouse variables in_mouse = Cvar_Get ("in_mouse", "1", CVAR_ARCHIVE); in_dgamouse = Cvar_Get ("in_dgamouse", "1", CVAR_ARCHIVE); // bk001130 - from cvs.17 (mkv), joystick variables in_joystick = Cvar_Get ("in_joystick", "0", CVAR_ARCHIVE|CVAR_LATCH); // bk001130 - changed this to match win32 in_joystickDebug = Cvar_Get ("in_debugjoystick", "0", CVAR_TEMP); joy_threshold = Cvar_Get ("joy_threshold", "0.15", CVAR_ARCHIVE); // FIXME: in_joythreshold if (in_mouse->value) mouse_avail = qtrue; else mouse_avail = qfalse; IN_StartupJoystick( ); // bk001130 - from cvs1.17 (mkv) }
/* =========== IN_Init =========== */ void IN_Init (void) { // mouse variables m_filter = Cvar_Get ("m_filter", "0", 0); in_mouse = Cvar_Get ("in_mouse", "1", CVAR_ARCHIVE); // joystick variables in_joystick = Cvar_Get ("in_joystick", "0", CVAR_ARCHIVE); joy_name = Cvar_Get ("joy_name", "joystick", 0); joy_advanced = Cvar_Get ("joy_advanced", "0", 0); joy_advaxisx = Cvar_Get ("joy_advaxisx", "0", 0); joy_advaxisy = Cvar_Get ("joy_advaxisy", "0", 0); joy_advaxisz = Cvar_Get ("joy_advaxisz", "0", 0); joy_advaxisr = Cvar_Get ("joy_advaxisr", "0", 0); joy_advaxisu = Cvar_Get ("joy_advaxisu", "0", 0); joy_advaxisv = Cvar_Get ("joy_advaxisv", "0", 0); joy_forwardthreshold = Cvar_Get ("joy_forwardthreshold", "0.15", 0); joy_sidethreshold = Cvar_Get ("joy_sidethreshold", "0.15", 0); joy_upthreshold = Cvar_Get ("joy_upthreshold", "0.15", 0); joy_pitchthreshold = Cvar_Get ("joy_pitchthreshold", "0.15", 0); joy_yawthreshold = Cvar_Get ("joy_yawthreshold", "0.15", 0); joy_forwardsensitivity = Cvar_Get ("joy_forwardsensitivity", "-1", 0); joy_sidesensitivity = Cvar_Get ("joy_sidesensitivity", "-1", 0); joy_upsensitivity = Cvar_Get ("joy_upsensitivity", "-1", 0); joy_pitchsensitivity = Cvar_Get ("joy_pitchsensitivity", "1", 0); joy_yawsensitivity = Cvar_Get ("joy_yawsensitivity", "-1", 0); // centering v_centermove = Cvar_Get ("v_centermove", "0.15", 0); v_centerspeed = Cvar_Get ("v_centerspeed", "500", 0); Cmd_AddCommand ("+mlook", IN_MLookDown); Cmd_AddCommand ("-mlook", IN_MLookUp); Cmd_AddCommand ("joy_advancedupdate", Joy_AdvancedUpdate_f); IN_StartupMouse (); IN_StartupJoystick (); IN_MotionSensor_Init(); }
/* =========== IN_Init =========== */ void IN_Init (void) { // mouse variables Cvar_RegisterVariable (&m_filter); #if USE_JOYSTICK // joystick variables Cvar_RegisterVariable (&in_joystick); #endif /* USE_JOYSTICK */ Cmd_AddCommand ("force_centerview", Force_CenterView_f); IN_StartupMouse (); #if USE_JOYSTICK IN_StartupJoystick (); #endif /* USE_JOYSTICK */ SDL_EnableUNICODE (1); /* needed for input in console */ SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL*2); }
/* =========== IN_Init =========== */ void IN_Init (void) { m_filter = gEngfuncs.pfnRegisterVariable ( "m_filter","0", FCVAR_ARCHIVE ); sensitivity = gEngfuncs.pfnRegisterVariable ( "sensitivity","3", FCVAR_ARCHIVE ); // user mouse sensitivity setting. in_joystick = gEngfuncs.pfnRegisterVariable ( "joystick","0", FCVAR_ARCHIVE ); joy_name = gEngfuncs.pfnRegisterVariable ( "joyname", "joystick", 0 ); joy_advanced = gEngfuncs.pfnRegisterVariable ( "joyadvanced", "0", 0 ); joy_advaxisx = gEngfuncs.pfnRegisterVariable ( "joyadvaxisx", "0", 0 ); joy_advaxisy = gEngfuncs.pfnRegisterVariable ( "joyadvaxisy", "0", 0 ); joy_advaxisz = gEngfuncs.pfnRegisterVariable ( "joyadvaxisz", "0", 0 ); joy_advaxisr = gEngfuncs.pfnRegisterVariable ( "joyadvaxisr", "0", 0 ); joy_advaxisu = gEngfuncs.pfnRegisterVariable ( "joyadvaxisu", "0", 0 ); joy_advaxisv = gEngfuncs.pfnRegisterVariable ( "joyadvaxisv", "0", 0 ); joy_forwardthreshold = gEngfuncs.pfnRegisterVariable ( "joyforwardthreshold", "0.15", 0 ); joy_sidethreshold = gEngfuncs.pfnRegisterVariable ( "joysidethreshold", "0.15", 0 ); joy_pitchthreshold = gEngfuncs.pfnRegisterVariable ( "joypitchthreshold", "0.15", 0 ); joy_yawthreshold = gEngfuncs.pfnRegisterVariable ( "joyyawthreshold", "0.15", 0 ); joy_forwardsensitivity = gEngfuncs.pfnRegisterVariable ( "joyforwardsensitivity", "-1.0", 0 ); joy_sidesensitivity = gEngfuncs.pfnRegisterVariable ( "joysidesensitivity", "-1.0", 0 ); joy_pitchsensitivity = gEngfuncs.pfnRegisterVariable ( "joypitchsensitivity", "1.0", 0 ); joy_yawsensitivity = gEngfuncs.pfnRegisterVariable ( "joyyawsensitivity", "-1.0", 0 ); joy_wwhack1 = gEngfuncs.pfnRegisterVariable ( "joywwhack1", "0.0", 0 ); joy_wwhack2 = gEngfuncs.pfnRegisterVariable ( "joywwhack2", "0.0", 0 ); gEngfuncs.pfnAddCommand ("force_centerview", Force_CenterView_f); gEngfuncs.pfnAddCommand ("joyadvancedupdate", Joy_AdvancedUpdate_f); IN_StartupMouse (); IN_StartupJoystick (); // Install a keyboard hook so we can trap ESC before Steam gets it. DWORD threadID = GetCurrentThreadId(); gKeyboardHook = SetWindowsHookEx(WH_KEYBOARD, KeyboardHookProc, GetModuleHandle(NULL), threadID); if (gKeyboardHook == NULL) { ConsolePrint("Unable to install keyboard hook\n"); } }
static struct InputEvent *IN_KeyboardHandlerFunc() { struct InputEvent *moo = (struct InputEvent *)REG_A0; struct inputdata *id = (struct inputdata *)REG_A1; #else HANDLERPROTO(IN_KeyboardHandler, struct InputEvent *, struct InputEvent *moo, APTR id) { #endif struct InputEvent *coin; ULONG screeninfront; if (!window || !(window->Flags & WFLG_WINDOWACTIVE)) return moo; if (window->WScreen) { #ifdef __MORPHOS__ if (IntuitionBase->LibNode.lib_Version > 50 || (IntuitionBase->LibNode.lib_Version == 50 && IntuitionBase->LibNode.lib_Revision >= 56)) GetAttr(SA_Displayed, window->WScreen, &screeninfront); else #endif screeninfront = (window->WScreen == IntuitionBase->FirstScreen); } else screeninfront = 1; for (coin = moo; coin; coin = coin->ie_NextEvent) { if (coin->ie_Class == IECLASS_RAWKEY) { int code; // mouse button 4, mouse wheel and keyboard code = coin->ie_Code & ~IECODE_UP_PREFIX; if (code >= NM_WHEEL_UP && code <= NM_BUTTON_FOURTH) { // we don't need these, they will be handled under IECLASS_NEWMOUSE /*if (mouseactive && screeninfront) { IN_AddEvent(coin); coin->ie_Code = IECODE_NOBUTTON; }*/ } else { IN_AddEvent(coin); } } else if (coin->ie_Class == IECLASS_RAWMOUSE && mouseactive && screeninfront) { // mouse buttons 1-3 if (coin->ie_Code != IECODE_NOBUTTON) { IN_AddEvent(coin); coin->ie_Code = IECODE_NOBUTTON; } // mouse movement mx += coin->ie_position.ie_xy.ie_x; my += coin->ie_position.ie_xy.ie_y; coin->ie_position.ie_xy.ie_x = 0; coin->ie_position.ie_xy.ie_y = 0; } else if (coin->ie_Class == IECLASS_NEWMOUSE && mouseactive && screeninfront) { // mouse button 4, mouse wheel IN_AddEvent(coin); coin->ie_Code = IECODE_NOBUTTON; } } return moo; } //MakeHandlerPri(InputHandler, &IN_KeyboardHandler, "Hexen II input handler", NULL, 100); /* =========== IN_Init =========== */ void IN_Init (void) { static char handler_name[] = "Hexen II input handler"; /* mouse variables */ Cvar_RegisterVariable (&m_filter); /* joystick variables */ Cvar_RegisterVariable (&in_joystick); Cvar_RegisterVariable (&joy_index); Cvar_SetCallback (&in_joystick, IN_Callback_JoyEnable); Cvar_SetCallback (&joy_index, IN_Callback_JoyIndex); Cmd_AddCommand ("force_centerview", Force_CenterView_f); pointermem = (UWORD *) AllocVec(2 * 6, MEMF_CHIP | MEMF_CLEAR); IN_StartupMouse (); IN_StartupJoystick (); imsglow = imsghigh = 0; inputport = CreateMsgPort(); if (inputport) { //inputreq = (struct IOStdReq *) CreateIORequest(inputport, sizeof(*inputreq)); inputreq = CreateStdIO(inputport); if (inputreq) { if (!OpenDevice("input.device", 0, (struct IORequest *)inputreq, 0)) { InputHandler.is_Node.ln_Type = NT_INTERRUPT; InputHandler.is_Node.ln_Pri = 100; InputHandler.is_Node.ln_Name = handler_name; InputHandler.is_Code = (void (*)())&IN_KeyboardHandler; inputreq->io_Data = (void *)&InputHandler; inputreq->io_Command = IND_ADDHANDLER; DoIO((struct IORequest *)inputreq); return; } //DeleteIORequest(inputreq); DeleteStdIO(inputreq); } DeleteMsgPort(inputport); } Sys_Error ("Couldn't install input handler"); } /* =========== IN_Shutdown =========== */ void IN_Shutdown (void) { if (inputreq) { inputreq->io_Data = (void *)&InputHandler; inputreq->io_Command = IND_REMHANDLER; DoIO((struct IORequest *)inputreq); CloseDevice((struct IORequest *)inputreq); //DeleteIORequest(inputreq); DeleteStdIO(inputreq); } if (inputport) { DeleteMsgPort(inputport); } IN_DeactivateMouse (); /*IN_ShowMouse ();*/ if (pointermem) { FreeVec(pointermem); } mouseinitialized = false; if (LowLevelBase) { CloseLibrary(LowLevelBase); LowLevelBase = NULL; } joy_port = -1; joy_available = 0; oldjoyflag = 0; #ifdef __CLIB2__ if (KeymapBase) { CloseLibrary(KeymapBase); KeymapBase = NULL; } #endif } /* =========== IN_ReInit =========== */ void IN_ReInit (void) { IN_StartupMouse (); } /* =========== IN_MouseMove =========== */ static void IN_MouseMove (usercmd_t *cmd/*, int mx, int my*/) { if (m_filter.integer) { mouse_x = (mx + old_mouse_x) * 0.5; mouse_y = (my + old_mouse_y) * 0.5; } else { mouse_x = mx; mouse_y = my; } old_mouse_x = mx; old_mouse_y = my; mouse_x *= sensitivity.value; mouse_y *= sensitivity.value; /* add mouse X/Y movement to cmd */ if ( (in_strafe.state & 1) || (lookstrafe.integer && (in_mlook.state & 1) )) cmd->sidemove += m_side.value * mouse_x; else cl.viewangles[YAW] -= m_yaw.value * mouse_x; if (in_mlook.state & 1) { if (mx || my) V_StopPitchDrift (); } if ( (in_mlook.state & 1) && !(in_strafe.state & 1)) { 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; } else { if ((in_strafe.state & 1) && (cl.v.movetype == MOVETYPE_NOCLIP)) cmd->upmove -= m_forward.value * mouse_y; else cmd->forwardmove -= m_forward.value * mouse_y; } if (cl.idealroll == 0) /* Did keyboard set it already?? */ { if (cl.v.movetype == MOVETYPE_FLY) { if (mouse_x < 0) cl.idealroll = -10; else if (mouse_x > 0) cl.idealroll = 10; } } } static void IN_DiscardMove (void) { if (mouseinitialized) { mx = my = old_mouse_x = old_mouse_y = 0; } } /* =========== IN_Move =========== */ void IN_Move (usercmd_t *cmd) { if (cl.v.cameramode) { /* stuck in a different camera so don't move */ memset (cmd, 0, sizeof(*cmd)); /* ignore any mouse movements in camera mode */ IN_DiscardMove (); return; } if (mx != 0 || my != 0) { IN_MouseMove (cmd/*, x, y*/); mx = my = 0; } } static const char *JoystickName(int port) { ULONG joyflag = ReadJoyPort(port); switch (joyflag & JP_TYPE_MASK) { case JP_TYPE_GAMECTLR: return "game controller"; case JP_TYPE_JOYSTK: return "joystick controller"; case JP_TYPE_MOUSE: return "mouse"; case JP_TYPE_NOTAVAIL: return "not available"; case JP_TYPE_UNKNOWN: return "unknown device"; default: return "<unknown>"; } }
void IN_Init (void) { #ifdef GLQUAKE #ifdef WITH_EVDEV int i; #endif #endif Cvar_SetCurrentGroup (CVAR_GROUP_INPUT_MOUSE); Cvar_Register (&m_filter); Cvar_Register (&m_showrate); #ifndef _Soft_SVGA Cvar_Register (&_windowed_mouse); #endif Cvar_SetCurrentGroup (CVAR_GROUP_INPUT_KEYBOARD); Cvar_Register (&cl_keypad); Cvar_ResetCurrentGroup (); if (!host_initialized) { #ifdef GLQUAKE typedef enum { mt_none = 0, mt_dga, mt_normal, mt_evdev } mousetype_t; extern cvar_t in_mouse; #ifdef WITH_EVDEV extern cvar_t in_mmt; extern cvar_t in_evdevice; #endif /* !WITH_EVDEV */ if (COM_CheckParm ("-nodga") || COM_CheckParm ("-nomdga")) Cvar_LatchedSetValue (&in_mouse, mt_normal); #ifdef WITH_EVDEV if ((i = COM_CheckParm ("-mevdev")) && (i < COM_Argc() - 1)) { Cvar_LatchedSet (&in_evdevice, COM_Argv(i + 1)); Cvar_LatchedSetValue (&in_mouse, mt_evdev); } if (COM_CheckParm ("-mmt")) Cvar_LatchedSetValue (&in_mmt, 1); #endif /* !WITH_EVDEV */ if (COM_CheckParm ("-nomouse")) Cvar_LatchedSetValue (&in_mouse, mt_none); #ifdef WITH_EVDEV extern void IN_EvdevList_f(void); Cmd_AddCommand ("in_evdevlist", IN_EvdevList_f); #endif /* !WITH_EVDEV */ #endif /* !GLQUAKE */ #ifdef WITH_KEYMAP IN_StartupKeymap(); #endif // WITH_KEYMAP #ifdef GLQUAKE Cmd_AddCommand ("in_restart", IN_Restart_f); #endif } IN_StartupMouse (); #ifdef WITH_JOYSTICK IN_StartupJoystick (); #endif // WITH_JOYSTICK }
void IN_JoystickMove (void) { bool joy_pressed[lengthof(joy_keys)]; unsigned int axes = 0; unsigned int hats = 0; int total = 0; int i = 0; /* check whether a user has changed the joystick number */ if (in_joystickNo->modified) IN_StartupJoystick(); /* check whether joysticks are disabled */ if (!in_joystick->integer) return; if (!stick) return; SDL_JoystickUpdate(); OBJZERO(joy_pressed); /* update the ball state */ total = SDL_JoystickNumBalls(stick); if (total > 0) { int balldx = 0; int balldy = 0; for (i = 0; i < total; i++) { int dx = 0; int dy = 0; SDL_JoystickGetBall(stick, i, &dx, &dy); balldx += dx; balldy += dy; } if (balldx || balldy) { mousePosX = balldx / viddef.rx; mousePosY = balldy / viddef.ry; } } /* now query the stick buttons... */ total = SDL_JoystickNumButtons(stick); if (total > 0) { if (total > lengthof(stick_state.buttons)) total = lengthof(stick_state.buttons); for (i = 0; i < total; i++) { const bool pressed = (SDL_JoystickGetButton(stick, i) != 0); if (pressed != stick_state.buttons[i]) { IN_EventEnqueue(K_JOY1 + i, 0, pressed); stick_state.buttons[i] = pressed; } } } /* look at the hats... */ total = SDL_JoystickNumHats(stick); if (total > 0) { if (total > 4) total = 4; for (i = 0; i < total; i++) ((Uint8 *)&hats)[i] = SDL_JoystickGetHat(stick, i); } /* update hat state */ if (hats != stick_state.oldhats) { for (i = 0; i < 4; i++) { if (((Uint8 *)&hats)[i] != ((Uint8 *)&stick_state.oldhats)[i]) { /* release event */ switch (((Uint8 *)&stick_state.oldhats)[i]) { case SDL_HAT_UP: IN_EventEnqueue(hat_keys[4 * i + 0], 0, false); break; case SDL_HAT_RIGHT: IN_EventEnqueue(hat_keys[4 * i + 1], 0, false); break; case SDL_HAT_DOWN: IN_EventEnqueue(hat_keys[4 * i + 2], 0, false); break; case SDL_HAT_LEFT: IN_EventEnqueue(hat_keys[4 * i + 3], 0, false); break; case SDL_HAT_RIGHTUP: IN_EventEnqueue(hat_keys[4 * i + 0], 0, false); IN_EventEnqueue(hat_keys[4 * i + 1], 0, false); break; case SDL_HAT_RIGHTDOWN: IN_EventEnqueue(hat_keys[4 * i + 2], 0, false); IN_EventEnqueue(hat_keys[4 * i + 1], 0, false); break; case SDL_HAT_LEFTUP: IN_EventEnqueue(hat_keys[4 * i + 0], 0, false); IN_EventEnqueue(hat_keys[4 * i + 3], 0, false); break; case SDL_HAT_LEFTDOWN: IN_EventEnqueue(hat_keys[4 * i + 2], 0, false); IN_EventEnqueue(hat_keys[4 * i + 3], 0, false); break; default: break; } /* press event */ switch (((Uint8 *)&hats)[i]) { case SDL_HAT_UP: IN_EventEnqueue(hat_keys[4 * i + 0], 0, true); break; case SDL_HAT_RIGHT: IN_EventEnqueue(hat_keys[4 * i + 1], 0, true); break; case SDL_HAT_DOWN: IN_EventEnqueue(hat_keys[4 * i + 2], 0, true); break; case SDL_HAT_LEFT: IN_EventEnqueue(hat_keys[4 * i + 3], 0, true); break; case SDL_HAT_RIGHTUP: IN_EventEnqueue(hat_keys[4 * i + 0], 0, true); IN_EventEnqueue(hat_keys[4 * i + 1], 0, true); break; case SDL_HAT_RIGHTDOWN: IN_EventEnqueue(hat_keys[4 * i + 2], 0, true); IN_EventEnqueue(hat_keys[4 * i + 1], 0, true); break; case SDL_HAT_LEFTUP: IN_EventEnqueue(hat_keys[4 * i + 0], 0, true); IN_EventEnqueue(hat_keys[4 * i + 3], 0, true); break; case SDL_HAT_LEFTDOWN: IN_EventEnqueue(hat_keys[4 * i + 2], 0, true); IN_EventEnqueue(hat_keys[4 * i + 3], 0, true); break; default: break; } } } } /* save hat state */ stick_state.oldhats = hats; /* finally, look at the axes... */ total = SDL_JoystickNumAxes(stick); if (total >= 2) { /* the first two axes are used for the cursor movement */ for (i = 0; i < 2; i++) { const Sint16 axis = SDL_JoystickGetAxis(stick, i); const float velocity = ((float) axis) / 32767.0f; if (velocity > -in_joystickThreshold->value && velocity < in_joystickThreshold->value) continue; if (i & 1) { mousePosY += in_joystickSpeed->value * velocity; if (mousePosY > (int)viddef.context.height) mousePosY = (int)viddef.context.height; else if (mousePosY < 0) mousePosY = 0; } else { mousePosX += in_joystickSpeed->value * velocity; if (mousePosX > (int)viddef.context.width) mousePosX = (int)viddef.context.width; else if (mousePosX < 0) mousePosX = 0; } } } if (total > 2) { if (total > 16) total = 16; /* every axis except the first two can be normally bound to an action */ for (i = 2; i < total; i++) { const Sint16 axis = SDL_JoystickGetAxis(stick, i); const float f = ((float) axis) / 32767.0f; if (f < -in_joystickThreshold->value) { axes |= (1 << (i * 2)); } else if (f > in_joystickThreshold->value) { axes |= (1 << ((i * 2) + 1)); } } } /* Time to update axes state based on old vs. new. */ if (axes != stick_state.oldaxes) { for (i = 2; i < 16; i++) { if ((axes & (1 << i)) && !(stick_state.oldaxes & (1 << i))) IN_EventEnqueue(joy_keys[i], 0, true); if (!(axes & (1 << i)) && (stick_state.oldaxes & (1 << i))) IN_EventEnqueue(joy_keys[i], 0, false); } } /* Save for future generations. */ stick_state.oldaxes = axes; }
/** * @sa CL_InitLocal */ void IN_Init (void) { Com_Printf("\n------- input initialization -------\n"); /* cvars */ in_debug = Cvar_Get("in_debug", "0", 0, "Show input key codes on game console"); cl_isometric = Cvar_Get("r_isometric", "0", CVAR_ARCHIVE, "Draw the world in isometric mode"); /* commands */ Cmd_AddCommand("+turnleft", IN_TurnLeftDown_f, N_("Rotate battlescape camera anti-clockwise")); Cmd_AddCommand("-turnleft", IN_TurnLeftUp_f, NULL); Cmd_AddCommand("+turnright", IN_TurnRightDown_f, N_("Rotate battlescape camera clockwise")); Cmd_AddCommand("-turnright", IN_TurnRightUp_f, NULL); Cmd_AddCommand("+turnup", IN_TurnUpDown_f, N_("Tilt battlescape camera up")); Cmd_AddCommand("-turnup", IN_TurnUpUp_f, NULL); Cmd_AddCommand("+turndown", IN_TurnDownDown_f, N_("Tilt battlescape camera down")); Cmd_AddCommand("-turndown", IN_TurnDownUp_f, NULL); Cmd_AddCommand("+pantilt", IN_PanTiltDown_f, N_("Move battlescape camera")); Cmd_AddCommand("-pantilt", IN_PanTiltUp_f, NULL); Cmd_AddCommand("+shiftleft", IN_ShiftLeftDown_f, N_("Move battlescape camera left")); Cmd_AddCommand("-shiftleft", IN_ShiftLeftUp_f, NULL); Cmd_AddCommand("+shiftleftup", IN_ShiftLeftUpDown_f, N_("Move battlescape camera top left")); Cmd_AddCommand("-shiftleftup", IN_ShiftLeftUpUp_f, NULL); Cmd_AddCommand("+shiftleftdown", IN_ShiftLeftDownDown_f, N_("Move battlescape camera bottom left")); Cmd_AddCommand("-shiftleftdown", IN_ShiftLeftDownUp_f, NULL); Cmd_AddCommand("+shiftright", IN_ShiftRightDown_f, N_("Move battlescape camera right")); Cmd_AddCommand("-shiftright", IN_ShiftRightUp_f, NULL); Cmd_AddCommand("+shiftrightup", IN_ShiftRightUpDown_f, N_("Move battlescape camera top right")); Cmd_AddCommand("-shiftrightup", IN_ShiftRightUpUp_f, NULL); Cmd_AddCommand("+shiftrightdown", IN_ShiftRightDownDown_f, N_("Move battlescape camera bottom right")); Cmd_AddCommand("-shiftrightdown", IN_ShiftRightDownUp_f, NULL); Cmd_AddCommand("+shiftup", IN_ShiftUpDown_f, N_("Move battlescape camera forward")); Cmd_AddCommand("-shiftup", IN_ShiftUpUp_f, NULL); Cmd_AddCommand("+shiftdown", IN_ShiftDownDown_f, N_("Move battlescape camera backward")); Cmd_AddCommand("-shiftdown", IN_ShiftDownUp_f, NULL); Cmd_AddCommand("+zoomin", IN_ZoomInDown_f, N_("Zoom in")); Cmd_AddCommand("-zoomin", IN_ZoomInUp_f, NULL); Cmd_AddCommand("+zoomout", IN_ZoomOutDown_f, N_("Zoom out")); Cmd_AddCommand("-zoomout", IN_ZoomOutUp_f, NULL); Cmd_AddCommand("+leftmouse", CL_LeftClickDown_f, N_("Left mouse button click (menu)")); Cmd_AddCommand("-leftmouse", CL_LeftClickUp_f, NULL); Cmd_AddCommand("+middlemouse", CL_MiddleClickDown_f, N_("Middle mouse button click (menu)")); Cmd_AddCommand("-middlemouse", CL_MiddleClickUp_f, NULL); Cmd_AddCommand("+rightmouse", CL_RightClickDown_f, N_("Right mouse button click (menu)")); Cmd_AddCommand("-rightmouse", CL_RightClickUp_f, NULL); Cmd_AddCommand("wheelupmouse", CL_WheelUp_f, N_("Mouse wheel up")); Cmd_AddCommand("wheeldownmouse", CL_WheelDown_f, N_("Mouse wheel down")); Cmd_AddCommand("+select", CL_SelectDown_f, N_("Select objects/Walk to a square/In fire mode, fire etc")); Cmd_AddCommand("-select", CL_SelectUp_f, NULL); Cmd_AddCommand("+action", CL_ActionDown_f, N_("Rotate Battlescape/In fire mode, cancel action")); Cmd_AddCommand("-action", CL_ActionUp_f, NULL); Cmd_AddCommand("+turn", CL_TurnDown_f, N_("Turn soldier toward mouse pointer")); Cmd_AddCommand("-turn", CL_TurnUp_f, NULL); Cmd_AddCommand("+hudradar", CL_HudRadarDown_f, N_("Toggles the hud radar mode")); Cmd_AddCommand("-hudradar", CL_HudRadarUp_f, NULL); Cmd_AddCommand("levelup", CL_LevelUp_f, N_("Slice through terrain at a higher level")); Cmd_AddCommand("leveldown", CL_LevelDown_f, N_("Slice through terrain at a lower level")); Cmd_AddCommand("zoominquant", CL_ZoomInQuant_f, N_("Zoom in")); Cmd_AddCommand("zoomoutquant", CL_ZoomOutQuant_f, N_("Zoom out")); Cmd_AddCommand("press", CL_PressKey_f, "Press a key from a command"); mousePosX = mousePosY = 0.0; IN_StartupJoystick(); }