Forum

Can't stop spinning

Discuss programming topics for the various GPL'd game engine sources.

Moderator: InsideQC Admins

Postby dreadlorde » Sat Feb 06, 2010 10:18 pm

The spinning only happens when I have forward, backward, left, right, strafe left, strafe right bound to keys that are letters. The spinning doesn't happen if I use the arrow keys..

:shock:
Ken Thompson wrote:One of my most productive days was throwing away 1000 lines of code.

Get off my lawn!
User avatar
dreadlorde
 
Posts: 268
Joined: Tue Nov 24, 2009 2:20 am

Postby Baker » Sun Feb 07, 2010 1:05 am

A good read ...

viewtopic.php?t=1257

Possibly related to your problem. If you are exiting and entering the focus of the Quake window, it is possible that Quake stupidly is doing a Keyup simulated keypress for every key on your keyboard.

It does on Windows, leading to annoying results on ALT-TAB.

If you really want to find out fast do this in config.cfg

alias +testkeys "say my key has been pressed"
alias -testkeys "say my key has been released"
bind x +testkeys

If you see "my key has been released" print in the console when you never even pressed the key, doing the tutorial linked in this post may very well solve your problems.
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Postby dreadlorde » Sun Feb 07, 2010 1:52 pm

The message never showed up. :(
Ken Thompson wrote:One of my most productive days was throwing away 1000 lines of code.

Get off my lawn!
User avatar
dreadlorde
 
Posts: 268
Joined: Tue Nov 24, 2009 2:20 am

Postby Baker » Sun Feb 07, 2010 2:06 pm

dreadlorde wrote:The spinning only happens when I have forward, backward, left, right, strafe left, strafe right bound to keys that are letters. The spinning doesn't happen if I use the arrow keys..

:shock:


dreadlorde wrote:The message never showed up. :(


Ok, but this still is enough information that you should be able to do some debug catching.

You are saying that the spinning is related to keypresses because of the top quote.

All keypresses flow through the Key_Event handler. Certainly you put some Con_Printfs in there to print to the console when that gets called.

Like Con_Printf("Key_Event ... key = %i", mykey); or whatever.

Whenever a situation has "only happens when" you have enough information to trap the problem and get more information about why it is happening.
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Postby dreadlorde » Sat Aug 14, 2010 10:10 pm

So I've learned more C, more about the engine and I've read Baker's ``Fixing annoying -alias keypress in standard Quake'' tutorial. But I'm still not sure where to call Key_ClearStates from. The Key_ClearStates I'm using is the same as Baker's version:
Code: Select all
void
Key_ClearStates(void) {
    int i;

    for(i = 0; i < 256; i++)
        if(keydown[i])
            Key_Event(i, false);
}
I currently call this from the end of vid_x.c:/^XLateKey/, which fixes my original problem, but now if I start walking and turn, I stop moving altogether. I'm almost certain this has to do with where Key_ClearStates is being called. I think I'll try calling it from vid_x.c:/^GetEvent/, and see how that works.
Ken Thompson wrote:One of my most productive days was throwing away 1000 lines of code.

Get off my lawn!
User avatar
dreadlorde
 
Posts: 268
Joined: Tue Nov 24, 2009 2:20 am

Postby dreadlorde » Sun Aug 15, 2010 4:09 am

Calling Key_ClearStates() from cl_input:/^CL_ParseServerInfo/, right after the call to CL_ClearState() seems to fix the issue.

:D
Ken Thompson wrote:One of my most productive days was throwing away 1000 lines of code.

Get off my lawn!
User avatar
dreadlorde
 
Posts: 268
Joined: Tue Nov 24, 2009 2:20 am

Postby Baker » Sun Aug 15, 2010 10:37 am

dreadlorde wrote:Calling Key_ClearStates() from cl_input:/^CL_ParseServerInfo/, right after the call to CL_ClearState() seems to fix the issue.

:D


Cool.

I wish I had a dedicated Linux machine. Had my Linux machine not gotten broke, ProQuake Linux would be entirely Windows equivalent in functionality. In fact, at the time my Linux machine broke I was ramping up revision after revision after revision.

Oh well ... eventually I'll have a dedicated Linux machine again. Virtual Box just doesn't cut it and I don't have a good candidate machine for dual booting.
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Postby mankrip » Mon Aug 16, 2010 5:54 pm

dreadlorde wrote:The spinning only happens when I have forward, backward, left, right, strafe left, strafe right bound to keys that are letters. The spinning doesn't happen if I use the arrow keys..

It seems to be related to the usage of the consolekeys array then. Search for all occurrences of "consolekeys" in all files to check it out.
Ph'nglui mglw'nafh mankrip Hell's end wgah'nagl fhtagn.
==-=-=-=-=-=-=-=-=-=-==
Dev blog / Twitter / YouTube
User avatar
mankrip
 
Posts: 915
Joined: Fri Jul 04, 2008 3:02 am

Postby dreadlorde » Tue Aug 17, 2010 8:15 pm

mk wrote:It seems to be related to the usage of the consolekeys array then. Search for all occurrences of "consolekeys" in all files to check it out.
``consolekeys'' is only used in keys.c:
Code: Select all
[~/src/proj/quake-hg]% grep consolekeys *
keys.c:qboolean consolekeys[256];       // if true, can't be rebound while in console
keys.c:     consolekeys[i] = true;
keys.c: consolekeys[K_ENTER] = true;
keys.c: consolekeys[K_TAB] = true;
keys.c: consolekeys[K_LEFTARROW] = true;
keys.c: consolekeys[K_RIGHTARROW] = true;
keys.c: consolekeys[K_UPARROW] = true;
keys.c: consolekeys[K_DOWNARROW] = true;
keys.c: consolekeys[K_BACKSPACE] = true;
keys.c: consolekeys[K_PGUP] = true;
keys.c: consolekeys[K_PGDN] = true;
keys.c: consolekeys[K_SHIFT] = true;
keys.c: consolekeys[K_MWHEELUP] = true;
keys.c: consolekeys[K_MWHEELDOWN] = true;
keys.c: consolekeys['`'] = false;
keys.c: consolekeys['~'] = false;
keys.c: if(cls.demoplayback && down && consolekeys[key] && key_dest == key_game) {
keys.c:    || (key_dest == key_console && !consolekeys[key])
keys.c:    || (key_dest == key_game && (!con_forcedup || !consolekeys[key]))) {

It's only referenced a few times. Once to initialize it:
Code: Select all
qboolean consolekeys[256];      // if true, can't be rebound while in console

A few more times to set what keys can be used in the console:
Code: Select all
// init ascii characters in console mode
    for(i = 32; i < 128; i++)
        consolekeys[i] = true;
    consolekeys[K_ENTER] = true;
    consolekeys[K_TAB] = true;
    consolekeys[K_LEFTARROW] = true;
    consolekeys[K_RIGHTARROW] = true;
    consolekeys[K_UPARROW] = true;
    consolekeys[K_DOWNARROW] = true;
    consolekeys[K_BACKSPACE] = true;
    consolekeys[K_PGUP] = true;
    consolekeys[K_PGDN] = true;
    consolekeys[K_SHIFT] = true;
    consolekeys[K_MWHEELUP] = true;
    consolekeys[K_MWHEELDOWN] = true;
    consolekeys['`'] = false;
    consolekeys['~'] = false;

And for checking to see if we're in a demo or if the key should be sent to the interpreter (in function Key_Event):
Code: Select all
// during demo playback, most keys bring up the main menu
    if(cls.demoplayback && down && consolekeys[key] && key_dest == key_game) {
        M_ToggleMenu_f();
        return;
    }
// if not a consolekey, send to the interpreter no matter what mode is
    if((key_dest == key_menu && menubound[key])
       || (key_dest == key_console && !consolekeys[key])
       || (key_dest == key_game && (!con_forcedup || !consolekeys[key]))) {
        kb = keybindings[key];
        if(kb) {
            if(kb[0] == '+') {  // button commands add keynum as a parm
                sprintf(cmd, "%s %i\n", kb, key);
                Cbuf_AddText(cmd);
            } else {
                Cbuf_AddText(kb);
                Cbuf_AddText("\n");
            }
        }
        return;
    }
Ken Thompson wrote:One of my most productive days was throwing away 1000 lines of code.

Get off my lawn!
User avatar
dreadlorde
 
Posts: 268
Joined: Tue Nov 24, 2009 2:20 am

Previous

Return to Engine Programming

Who is online

Users browsing this forum: No registered users and 1 guest