Interesting Error For Unicode SDL Function

Basically, I've been dealing with a String Input Problem in SDL for some time now, I was browsing the forums for help on gamedev.net and I found this function, which makes sure a key is some printable char and then returns the actual char associated with this unicode number, upon compilation in Code Blocks 10.04 I get the following compilation error: cannot convert 'const SDL_KeyboardEvent' to 'SDLKey' for argument 1 to 'char*..... Any help would be very appreciated.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
char getUnicodeValue( const SDL_KeyboardEvent &key )
{
	assert( SDL_EnableUNICODE(SDL_QUERY) == SDL_ENABLE );
	// magic numbers courtesy of SDL docs :)

	const int INTERNATIONAL_MASK = 0xFF80, UNICODE_MASK = 0x7F;

	int uni = key.keysym.unicode;

	if( uni == 0 ) // not translatable key (like up or down arrows)
	{
		// probably not useful as string input
		// we could optionally use this to get some value
		// for it:

		SDL_GetKeyName( key );

		return 0;
	}

	else if( ( uni & INTERNATIONAL_MASK ) == 0 )
	{
		return static_cast<char>(uni & UNICODE_MASK);
	}

	else
	// we have a funky international character. one we can't read :(

	{
		// return 0 to inform the caller that we can't deal with this key.

		return 0;
	}

}
Topic archived. No new replies allowed.