[SDL] SDL_GetKeyName on mac os x panther.

r3n3gad3 at mac.com r3n3gad3 at mac.com
Thu Oct 28 13:44:28 PDT 2004


thanks for your help, I knew I was missing  something somewhere.

matt.

On 28 Oct 2004, at 14:51, Iain Bethune wrote:

> You are better off (IMHO) using the Keysyms to identify keys as 
> follows:
>
>
> if (SDL_PollEvent(&event)){
>             switch (event.type) {
>                 case SDL_KEYDOWN:
>                     theController->HandleKeyPress(event);
>                     break;
> ...
> ...
> void Controller::HandleKeyPress(SDL_Event event){
>     if (event.key.keysym.sym == SDLK_SPACE)
> 		// Do stuff here
>
> You can find a full list of all the keysyms at 
> http://sdldoc.csn.ul.ie/sdlkey.php
>
> Cheers
>
> - Iain
>
>> Hi people, Im trying to use SDL_GetKeyName in a game Im developing, 
>> however, it doesnt seem to return the correct key. For example, I 
>> wanted to set it up to quit when I press q, however on pressing q, it 
>> actually returns '|'.   here is the snippet of code that Im using.
>>         SDL_Event event;  //the event structure.
>>
>> 	//Event Handling
>> 	SDL_PollEvent(&event); //check for events
>> 	switch (event.type) {  //find out what the event was and deal with it
>> 			case SDL_KEYDOWN:
>> 				DealWithKeyEvent(SDL_GetKeyName(event.key.keysym.sym));  //sdl 
>> get key name obviusly doesnt WORK!!!!!
>> 				break;
>> 			case SDL_QUIT:
>>  				SDL_Quit(); //quit sdl
>> 				cout << "reached SDL_QUIT" << endl; //output we are quitting
>> 				exit(0); //exit the program.
>> 				break;
>> 		}//switch
>>
>> I am fairly new to SDL its possible Ive done something very very 
>> stupid here. Anyhelp here would be appreciated.
>>
>> Matt.
>>
>> _______________________________________________
>> SDL mailing list
>> SDL at libsdl.org
>> http://www.libsdl.org/mailman/listinfo/sdl
>>
> _______________________________________________
> SDL mailing list
> SDL at libsdl.org
> http://www.libsdl.org/mailman/listinfo/sdl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/enriched
Size: 2140 bytes
Desc: not available
URL: <http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20041028/ec01d018/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 186 bytes
Desc: This is a digitally signed message part
URL: <http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20041028/ec01d018/attachment.pgp>


More information about the SDL mailing list