Standard keyboard input functions of the curses library – like wgetch() – only return key codes for keys pressed that are within the alpha-numeric range of ASCII characters (plus standard ASCII specials 0 --> 32). Keyboard buttons like arrow key, SHIFT, CTRL, ALT, Function keys, numeric keypad, etc all produce keycodes outside the standard ASCII range. So wgetch() and the like won’t return / responds to them being pressed. This is where the KEYPAD() function comes in. For the specified curses window it turns ON (or OFF) the curses input functions ability to return keystrokes outside the normal range. 

 

Normally keypad() is an initialisation function rather than a per-call operation function, which is why I move them into the init() function. And since I couldn’t see why to limit it to just one window, I turned it on for all input windows/regions. 

 

As to why it was limited to WIN32, I have no idea. It is a standard curses function for every version of curses I’ve ever seen. If anything it is LESS likely to be implemented in the windows version of pdcurses library rather than more.

 

 

From: Cameron Currie [mailto:notifications@github.com] 
Sent: Wednesday, 14 August 2013 4:23 a.m.
To: cwc/OmegaRPG
Cc: SouthernLlama
Subject: Re: [OmegaRPG] VS project file updates and arrow key support (#23)

 

In Omega/src/scr.cpp:

> @@ -575,6 +641,15 @@ void initgraf(void)
>  
>      clear();
>      touchwin(stdscr);
> +
> +     // SL: Allow input of extended characters
> +     keypad(Msgw, TRUE);
> +     keypad(Menuw, TRUE);
> +     keypad(Levelw, TRUE);
> +     keypad(Msg1w, TRUE);
> +     keypad(Msg2w, TRUE);
> +     keypad(stdscr, TRUE);

So I see on line 204 <https://github.com/cwc/OmegaRPG/pull/23/files#L7L204>  that the keypad function call was protected by #if defined(WIN32). I admit I have no idea what this function call does, but presumably it still needs to only be called on Windows, right?

—
Reply to this email directly or view it on GitHub <https://github.com/cwc/OmegaRPG/pull/23/files#r5740480> .  <https://github.com/notifications/beacon/QqluQeBZBdUFi5uPWVyu3dFAovqkSh0QJq9YDqu4_vfVFJ_sdZWxXATFRHAoxWcF.gif>