Imported Upstream version 2.81
[platform/upstream/libbullet.git] / Extras / CDTestFramework / AntTweakBar / src / TwEventSDL.c
1 //  ---------------------------------------------------------------------------
2 //
3 //  @file       TwEventSDL.c
4 //  @brief      Helper: 
5 //              translate and re-send mouse and keyboard events 
6 //              from SDL event loop to AntTweakBar
7 //  
8 //  @author     Philippe Decaudin - http://www.antisphere.com
9 //  @license    This file is part of the AntTweakBar library.
10 //              For conditions of distribution and use, see License.txt
11 //
12 //  note:       AntTweakBar.dll does not need to link with SDL, 
13 //              it just needs some definitions for its helper functions.
14 //
15 //  ---------------------------------------------------------------------------
16
17 #include <AntTweakBar.h>
18
19 int TW_CALL TwEventSDL12(const void *sdlEvent); // implemented in TwEventSDL12.c
20 int TW_CALL TwEventSDL13(const void *sdlEvent); // implmeneted in TwEventSDL13.c
21 #ifdef  __cplusplus
22     extern "C" { int TW_CALL TwSetLastError(const char *staticErrorMessage); }
23 #else
24     int TW_CALL TwSetLastError(const char *staticErrorMessage);
25 #endif  // __cplusplus
26
27
28 //  TwEventSDL returns zero if msg has not been handled or the SDL version 
29 //  is not supported, and a non-zero value if it has been handled by the 
30 //  AntTweakBar library.
31 int TW_CALL TwEventSDL(const void *sdlEvent, unsigned char majorVersion, unsigned char minorVersion)
32 {
33     if (majorVersion < 1 || (majorVersion == 1 && minorVersion < 2))
34     {
35         static const char *g_ErrBadSDLVersion = "Unsupported SDL version";
36         TwSetLastError(g_ErrBadSDLVersion);
37         return 0;
38     }
39     else if (majorVersion == 1 && minorVersion == 2)
40         return TwEventSDL12(sdlEvent);
41     else // if( majorVersion==1 && minorVersion==3 ) 
42         return TwEventSDL13(sdlEvent); // will probably not work for version > 1.3, but give it a chance
43 }