Capslock

Hello,

Is there anyway to query if the Capslock key id on?

Thanks,
Dave

Check for KMOD_CAPS in the mod field of the SDL_keysym?

There is also a keycode for the actual key: SDLK_CAPSLOCK. I suppose tracking
the state of that should work, but I’m not sure if you get the state of the
key or the keyboard/system capslock state… I would assume and hope for the
former. :-)On Saturday 03 April 2010, at 21.12.06, “Mars_999” wrote:

Hello,

Is there anyway to query if the Capslock key id on?


//David Olofson - Developer, Artist, Open Source Advocate

.— Games, examples, libraries, scripting, sound, music, graphics —.
| http://olofson.net http://kobodeluxe.com http://audiality.org |
| http://eel.olofson.net http://zeespace.net http://reologica.se |
’---------------------------------------------------------------------’

Yeah I am worried that if the user has the Caps lock on and he hits it
that will flip my bool value of the status of the caps lock key.

I would rather just test to see if the key is in fact activated…

I looked at SDL_GetModState() and checked the return value. I am getting
4096 and 12288? Isn’t Caps lock = 8912

ThanksOn 4/3/2010 2:42 PM, David Olofson wrote:

On Saturday 03 April 2010, at 21.12.06, “Mars_999”<@Mars_999> wrote:

Hello,

Is there anyway to query if the Capslock key id on?

Check for KMOD_CAPS in the mod field of the SDL_keysym?

There is also a keycode for the actual key: SDLK_CAPSLOCK. I suppose tracking
the state of that should work, but I’m not sure if you get the state of the
key or the keyboard/system capslock state… I would assume and hope for the
former. :slight_smile:

Nevermind I got it!

a bit of Bit math :wink:

 int temp = SDL_GetModState();
         temp = temp & KMOD_CAPS;
         if(temp == KMOD_CAPS)
             std::cout << "CAP ON";

ThanksOn 4/3/2010 3:51 PM, Mars_999 wrote:

Yeah I am worried that if the user has the Caps lock on and he hits it
that will flip my bool value of the status of the caps lock key.

I would rather just test to see if the key is in fact activated…

I looked at SDL_GetModState() and checked the return value. I am
getting 4096 and 12288? Isn’t Caps lock = 8912

Thanks
On 4/3/2010 2:42 PM, David Olofson wrote:

On Saturday 03 April 2010, at 21.12.06, “Mars_999”<@Mars_999> wrote:

Hello,

Is there anyway to query if the Capslock key id on?
Check for KMOD_CAPS in the mod field of the SDL_keysym?

There is also a keycode for the actual key: SDLK_CAPSLOCK. I suppose
tracking
the state of that should work, but I’m not sure if you get the state
of the
key or the keyboard/system capslock state… I would assume and
hope for the
former. :slight_smile:

Yeah I am worried that if the user has the Caps lock on and he hits it
that will flip my bool value of the status of the caps lock key.

I would rather just test to see if the key is in fact activated…

You shouldn’t just flip the bool, but rather check what the event says about
the new state.

However, there is still a risk of losing some events and getting ouf of sync
when you’re in a windowed environment. I’m not sure if SDL_WM_GrabInput() can
totally prevent that on all platforms either…

I looked at SDL_GetModState() and checked the return value. I am getting
4096 and 12288? Isn’t Caps lock = 8912

That would be 2^13 = 8192, and 12280 = 8192 + 4096, that is, bits 12 and 13
set. :-)On Saturday 03 April 2010, at 22.51.45, “Mars_999” wrote:


//David Olofson - Developer, Artist, Open Source Advocate

.— Games, examples, libraries, scripting, sound, music, graphics —.
| http://olofson.net http://kobodeluxe.com http://audiality.org |
| http://eel.olofson.net http://zeespace.net http://reologica.se |
’---------------------------------------------------------------------’