diff options
Diffstat (limited to 'system')
45 files changed, 1241 insertions, 430 deletions
diff --git a/system/include/EGL/eglplatform.h b/system/include/EGL/eglplatform.h index 2db2cc47..77e885a8 100644 --- a/system/include/EGL/eglplatform.h +++ b/system/include/EGL/eglplatform.h @@ -75,7 +75,7 @@ typedef HDC EGLNativeDisplayType; typedef HBITMAP EGLNativePixmapType; typedef HWND EGLNativeWindowType; -#elif defined(EMSCRIPTEN) +#elif defined(__EMSCRIPTEN__) typedef int EGLNativeDisplayType; typedef int EGLNativeWindowType; diff --git a/system/include/SDL/COPYING b/system/include/SDL/COPYING index 15639581..71cc7e42 100644 --- a/system/include/SDL/COPYING +++ b/system/include/SDL/COPYING @@ -17,3 +17,8 @@ freely, subject to the following restrictions: 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. + +--- + + Portions of these headers taken from SDL2 (where noted) + Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org> diff --git a/system/include/SDL/SDL_config_minimal.h b/system/include/SDL/SDL_config_minimal.h index ea0cec10..18951f18 100644 --- a/system/include/SDL/SDL_config_minimal.h +++ b/system/include/SDL/SDL_config_minimal.h @@ -33,7 +33,7 @@ #include <stddef.h> #include <stdarg.h> -#if !defined(EMSCRIPTEN) && !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H) +#if !defined(__EMSCRIPTEN__) && !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H) typedef unsigned int size_t; typedef signed char int8_t; typedef unsigned char uint8_t; diff --git a/system/include/SDL/SDL_events.h b/system/include/SDL/SDL_events.h index 8be00ceb..183ea4b2 100644 --- a/system/include/SDL/SDL_events.h +++ b/system/include/SDL/SDL_events.h @@ -2,6 +2,9 @@ Simple DirectMedia Layer Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org> + Portions of these headers taken from SDL2 (where noted) + Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org> + This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. @@ -182,33 +185,43 @@ typedef struct SDL_TextInputEvent /** * \brief Mouse motion event structure (event.motion.*) */ +/*================================= IMPORTANT ================================ + The version of SDL_MouseMotionEvent that comes in these (emscripten) + headers is taken from the finalized version of SDL2 + ============================================================================*/ + typedef struct SDL_MouseMotionEvent { Uint32 type; /**< ::SDL_MOUSEMOTION */ + Uint32 timestamp; Uint32 windowID; /**< The window with mouse focus, if any */ - Uint8 state; /**< The current button state */ - Uint8 padding1; - Uint8 padding2; - Uint8 padding3; - int x; /**< X coordinate, relative to window */ - int y; /**< Y coordinate, relative to window */ - int xrel; /**< The relative motion in the X direction */ - int yrel; /**< The relative motion in the Y direction */ + Uint32 which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */ + Uint32 state; /**< The current button state */ + Sint32 x; /**< X coordinate, relative to window */ + Sint32 y; /**< Y coordinate, relative to window */ + Sint32 xrel; /**< The relative motion in the X direction */ + Sint32 yrel; /**< The relative motion in the Y direction */ } SDL_MouseMotionEvent; /** * \brief Mouse button event structure (event.button.*) */ +/*================================= IMPORTANT ================================ + The version of SDL_MouseButtonEvent that comes in these (emscripten) + headers is taken from the finalized version of SDL2 + ============================================================================*/ typedef struct SDL_MouseButtonEvent { Uint32 type; /**< ::SDL_MOUSEBUTTONDOWN or ::SDL_MOUSEBUTTONUP */ + Uint32 timestamp; Uint32 windowID; /**< The window with mouse focus, if any */ + Uint32 which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */ Uint8 button; /**< The mouse button index */ Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */ Uint8 padding1; Uint8 padding2; - int x; /**< X coordinate, relative to window */ - int y; /**< Y coordinate, relative to window */ + Sint32 x; /**< X coordinate, relative to window */ + Sint32 y; /**< Y coordinate, relative to window */ } SDL_MouseButtonEvent; /** @@ -217,9 +230,11 @@ typedef struct SDL_MouseButtonEvent typedef struct SDL_MouseWheelEvent { Uint32 type; /**< ::SDL_MOUSEWHEEL */ + Uint32 timestamp; Uint32 windowID; /**< The window with mouse focus, if any */ - int x; /**< The amount scrolled horizontally */ - int y; /**< The amount scrolled vertically */ + Uint32 which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */ + Sint32 x; /**< The amount scrolled horizontally */ + Sint32 y; /**< The amount scrolled vertically */ } SDL_MouseWheelEvent; /** @@ -281,24 +296,25 @@ typedef struct SDL_JoyButtonEvent /** - * \brief Touch finger motion/finger event structure (event.tmotion.*) + * \brief Touch finger motion/finger event structure (event.tfinger.*) */ + +/*================================= IMPORTANT ================================ + The version of SDL_TouchFingerEvent that comes in these (emscripten) + headers is taken from the finalized version of SDL2 + ============================================================================*/ + typedef struct SDL_TouchFingerEvent { - Uint32 type; /**< ::SDL_FINGERMOTION OR - SDL_FINGERDOWN OR SDL_FINGERUP*/ - Uint32 windowID; /**< The window with mouse focus, if any */ - SDL_TouchID touchId; /**< The touch device id */ + Uint32 type; /**< ::SDL_FINGERMOTION or ::SDL_FINGERDOWN or ::SDL_FINGERUP */ + Uint32 timestamp; + SDL_TouchID touchId; /**< The touch device id */ SDL_FingerID fingerId; - Uint8 state; /**< The current button state */ - Uint8 padding1; - Uint8 padding2; - Uint8 padding3; - Uint16 x; - Uint16 y; - Sint16 dx; - Sint16 dy; - Uint16 pressure; + float x; /**< Normalized in the range 0...1 */ + float y; /**< Normalized in the range 0...1 */ + float dx; /**< Normalized in the range 0...1 */ + float dy; /**< Normalized in the range 0...1 */ + float pressure; /**< Normalized in the range 0...1 */ } SDL_TouchFingerEvent; @@ -434,7 +450,7 @@ typedef union SDL_Event SDL_QuitEvent quit; /**< Quit request event data */ SDL_UserEvent user; /**< Custom event data */ SDL_SysWMEvent syswm; /**< System dependent window event data */ - SDL_TouchFingerEvent tfinger; /**< Touch finger event data */ + SDL_TouchFingerEvent tfinger; /**< SDL2 Touch finger event data */ SDL_TouchButtonEvent tbutton; /**< Touch button event data */ SDL_MultiGestureEvent mgesture; /**< Multi Finger Gesture data */ SDL_DollarGestureEvent dgesture; /**< Multi Finger Gesture data */ diff --git a/system/include/SDL/SDL_stdinc.h b/system/include/SDL/SDL_stdinc.h index c4ce7ccd..508ecdb4 100644 --- a/system/include/SDL/SDL_stdinc.h +++ b/system/include/SDL/SDL_stdinc.h @@ -65,7 +65,7 @@ #endif #if defined(HAVE_INTTYPES_H) # include <inttypes.h> -#elif defined(EMSCRIPTEN) || defined(HAVE_STDINT_H) +#elif defined(__EMSCRIPTEN__) || defined(HAVE_STDINT_H) # include <stdint.h> #endif #ifdef HAVE_CTYPE_H diff --git a/system/include/SDL/SDL_touch.h b/system/include/SDL/SDL_touch.h index 587efcbf..fe238f10 100644 --- a/system/include/SDL/SDL_touch.h +++ b/system/include/SDL/SDL_touch.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org> + Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -19,9 +19,15 @@ 3. This notice may not be removed or altered from any source distribution. */ +/* + ================================= IMPORTANT ================================ + This header taken from SDL2 + ============================================================================ +*/ + /** * \file SDL_touch.h - * + * * Include file for SDL touch event handling. */ @@ -35,90 +41,52 @@ #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ extern "C" { -/* *INDENT-ON* */ #endif - typedef Sint64 SDL_TouchID; typedef Sint64 SDL_FingerID; +typedef struct SDL_Finger +{ + SDL_FingerID id; + float x; + float y; + float pressure; +} SDL_Finger; -struct SDL_Finger { - SDL_FingerID id; - Uint16 x; - Uint16 y; - Uint16 pressure; - Uint16 xdelta; - Uint16 ydelta; - Uint16 last_x, last_y,last_pressure; /* the last reported coordinates */ - SDL_bool down; -}; - -typedef struct SDL_Touch SDL_Touch; -typedef struct SDL_Finger SDL_Finger; - - -struct SDL_Touch { - - /* Free the touch when it's time */ - void (*FreeTouch) (SDL_Touch * touch); - - /* data common for tablets */ - float pressure_max, pressure_min; - float x_max,x_min; - float y_max,y_min; - Uint16 xres,yres,pressureres; - float native_xres,native_yres,native_pressureres; - float tilt; /* for future use */ - float rotation; /* for future use */ - - /* Data common to all touch */ - SDL_TouchID id; - SDL_Window *focus; - - char *name; - Uint8 buttonstate; - SDL_bool relative_mode; - SDL_bool flush_motion; - - int num_fingers; - int max_fingers; - SDL_Finger** fingers; - - void *driverdata; -}; - +/* Used as the device ID for mouse events simulated with touch input */ +#define SDL_TOUCH_MOUSEID ((Uint32)-1) /* Function prototypes */ /** - * \brief Get the touch object at the given id. - * - * + * \brief Get the number of registered touch devices. */ - extern DECLSPEC SDL_Touch* SDLCALL SDL_GetTouch(SDL_TouchID id); +extern DECLSPEC int SDLCALL SDL_GetNumTouchDevices(void); +/** + * \brief Get the touch ID with the given index, or 0 if the index is invalid. + */ +extern DECLSPEC SDL_TouchID SDLCALL SDL_GetTouchDevice(int index); +/** + * \brief Get the number of active fingers for a given touch device. + */ +extern DECLSPEC int SDLCALL SDL_GetNumTouchFingers(SDL_TouchID touchID); /** - * \brief Get the finger object of the given touch, at the given id. - * - * + * \brief Get the finger object of the given touch, with the given index. */ - extern - DECLSPEC SDL_Finger* SDLCALL SDL_GetFinger(SDL_Touch *touch, SDL_FingerID id); +extern DECLSPEC SDL_Finger * SDLCALL SDL_GetTouchFinger(SDL_TouchID touchID, int index); /* Ends C function definitions when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ } -/* *INDENT-ON* */ #endif #include "close_code.h" -#endif /* _SDL_mouse_h */ +#endif /* _SDL_touch_h */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/system/include/emscripten/bind.h b/system/include/emscripten/bind.h index 390533f3..0699715c 100644 --- a/system/include/emscripten/bind.h +++ b/system/include/emscripten/bind.h @@ -17,8 +17,6 @@ namespace emscripten { BY_EMVAL = 2, }; -#define EMSCRIPTEN_ALWAYS_INLINE __attribute__((always_inline)) - namespace internal { typedef long GenericEnumValue; @@ -35,18 +33,21 @@ namespace emscripten { void _embind_register_bool( TYPEID boolType, const char* name, + size_t size, bool trueValue, bool falseValue); void _embind_register_integer( TYPEID integerType, const char* name, + size_t size, long minRange, unsigned long maxRange); void _embind_register_float( TYPEID floatType, - const char* name); + const char* name, + size_t size); void _embind_register_std_string( TYPEID stringType, @@ -163,7 +164,9 @@ namespace emscripten { void _embind_register_enum( TYPEID enumType, - const char* name); + const char* name, + size_t size, + bool isSigned); void _embind_register_enum_value( TYPEID enumType, @@ -810,7 +813,7 @@ namespace emscripten { // NOTE: this returns the class type, not the pointer type template<typename T> inline TYPEID getActualType(T* ptr) { - return reinterpret_cast<TYPEID>(&typeid(*ptr)); + return getLightTypeID(*ptr); }; } @@ -848,15 +851,15 @@ namespace emscripten { template<typename T> struct SmartPtrIfNeeded { template<typename U> - SmartPtrIfNeeded(U& cls) { - cls.template smart_ptr<T>(); + SmartPtrIfNeeded(U& cls, const char* smartPtrName) { + cls.template smart_ptr<T>(smartPtrName); } }; template<typename T> struct SmartPtrIfNeeded<T*> { template<typename U> - SmartPtrIfNeeded(U&) { + SmartPtrIfNeeded(U&, const char*) { } }; }; @@ -887,7 +890,7 @@ namespace emscripten { } template<typename PointerType> - const class_& smart_ptr() const { + const class_& smart_ptr(const char* name) const { using namespace internal; typedef smart_ptr_trait<PointerType> PointerTrait; @@ -898,7 +901,7 @@ namespace emscripten { _embind_register_smart_ptr( TypeID<PointerType>::get(), TypeID<PointeeType>::get(), - typeid(PointerType).name(), + name, PointerTrait::get_sharing_policy(), reinterpret_cast<GenericFunction>(&PointerTrait::get), reinterpret_cast<GenericFunction>(&PointerTrait::construct_null), @@ -930,10 +933,10 @@ namespace emscripten { } template<typename SmartPtr, typename... Args, typename... Policies> - const class_& smart_ptr_constructor(SmartPtr (*factory)(Args...), Policies...) const { + const class_& smart_ptr_constructor(const char* smartPtrName, SmartPtr (*factory)(Args...), Policies...) const { using namespace internal; - smart_ptr<SmartPtr>(); + smart_ptr<SmartPtr>(smartPtrName); typename WithPolicies<Policies...>::template ArgTypeList<SmartPtr, Args...> args; _embind_register_class_constructor( @@ -946,12 +949,12 @@ namespace emscripten { } template<typename WrapperType, typename PointerType = WrapperType*> - const class_& allow_subclass() const { + const class_& allow_subclass(const char* wrapperClassName, const char* pointerName = "<UnknownPointerName>") const { using namespace internal; - auto cls = class_<WrapperType, base<ClassType>>(typeid(WrapperType).name()) + auto cls = class_<WrapperType, base<ClassType>>(wrapperClassName) ; - SmartPtrIfNeeded<PointerType> _(cls); + SmartPtrIfNeeded<PointerType> _(cls, pointerName); return class_function( "implement", @@ -1182,7 +1185,9 @@ namespace emscripten { enum_(const char* name) { _embind_register_enum( internal::TypeID<EnumType>::get(), - name); + name, + sizeof(EnumType), + std::is_signed<typename std::underlying_type<EnumType>::type>::value); } enum_& value(const char* name, EnumType value) { diff --git a/system/include/emscripten/emscripten.h b/system/include/emscripten/emscripten.h index b92d920c..73836018 100644 --- a/system/include/emscripten/emscripten.h +++ b/system/include/emscripten/emscripten.h @@ -14,7 +14,7 @@ extern "C" { #endif -#if !EMSCRIPTEN +#if !__EMSCRIPTEN__ #include <SDL/SDL.h> /* for SDL_Delay in async_call */ #endif @@ -40,10 +40,15 @@ extern "C" { #define EM_ASM(...) emscripten_asm_const(#__VA_ARGS__) /* - * Input-output versions of EM_ASM. EM_ASM_INT receives arguments of - * either int or double type and returns an int; EM_ASM_DOUBLE - * receives similar arguments (int or double) but returns a double. - * Arguments arrive as $0, $1 etc; output value should be returned: + * Input-output versions of EM_ASM. + * + * EM_ASM_ (an extra _ is added) or EM_ASM_ARGS allow sending values + * (ints or doubles) into the code. If you also want a return value, + * EM_ASM_INT receives arguments (of int or double type) + * and returns an int; EM_ASM_DOUBLE does the same and returns + * a double. + * + * Arguments arrive as $0, $1 etc. The output value should be returned: * * int x = EM_ASM_INT({ * console.log('I received: ' + [$0, $1]); @@ -54,18 +59,16 @@ extern "C" { * (int or double) but *not* to pass any values, you can use * EM_ASM_INT_V and EM_ASM_DOUBLE_V respectively. */ +#define EM_ASM_(code, ...) emscripten_asm_const_int(#code, __VA_ARGS__) +#define EM_ASM_ARGS(code, ...) emscripten_asm_const_int(#code, __VA_ARGS__) #define EM_ASM_INT(code, ...) emscripten_asm_const_int(#code, __VA_ARGS__) #define EM_ASM_DOUBLE(code, ...) emscripten_asm_const_double(#code, __VA_ARGS__) #define EM_ASM_INT_V(code) emscripten_asm_const_int(#code) #define EM_ASM_DOUBLE_V(code) emscripten_asm_const_double(#code) /* - * Forces LLVM to not dead-code-eliminate a function. Note that - * you still need to use EXPORTED_FUNCTIONS so it stays alive - * in JS, e.g. - * emcc -s EXPORTED_FUNCTIONS=["_main", "_myfunc"] - * and in the source file - * void EMSCRIPTEN_KEEPALIVE myfunc() {..} + * Forces LLVM to not dead-code-eliminate a function. This also + * exports the function, as if you added it to EXPORTED_FUNCTIONS. */ #define EMSCRIPTEN_KEEPALIVE __attribute__((used)) @@ -94,7 +97,7 @@ extern void emscripten_async_run_script(const char *script, int millis); * for this is to load an asset module, that is, the output of the * file packager. */ -extern void emscripten_async_load_script(const char *script, void (*onload)(), void (*onerror)()); +extern void emscripten_async_load_script(const char *script, void (*onload)(void), void (*onerror)(void)); /* * Set a C function as the main event loop. The JS environment @@ -135,12 +138,12 @@ extern void emscripten_async_load_script(const char *script, void (*onload)(), v * you created an object on the stack, it will be cleaned up * before the main loop will be called the first time. */ -#if EMSCRIPTEN -extern void emscripten_set_main_loop(void (*func)(), int fps, int simulate_infinite_loop); +#if __EMSCRIPTEN__ +extern void emscripten_set_main_loop(void (*func)(void), int fps, int simulate_infinite_loop); extern void emscripten_set_main_loop_arg(void (*func)(void*), void *arg, int fps, int simulate_infinite_loop); -extern void emscripten_pause_main_loop(); -extern void emscripten_resume_main_loop(); -extern void emscripten_cancel_main_loop(); +extern void emscripten_pause_main_loop(void); +extern void emscripten_resume_main_loop(void); +extern void emscripten_cancel_main_loop(void); #else #define emscripten_set_main_loop(func, fps, simulateInfiniteLoop) \ while (1) { func(); usleep(1000000/fps); } @@ -160,7 +163,7 @@ extern void emscripten_cancel_main_loop(); * are not counted, do not block the main loop, and can fire * at specific time in the future. */ -#if EMSCRIPTEN +#if __EMSCRIPTEN__ extern void _emscripten_push_main_loop_blocker(void (*func)(void *), void *arg, const char *name); extern void _emscripten_push_uncounted_main_loop_blocker(void (*func)(void *), void *arg, const char *name); #else @@ -182,7 +185,7 @@ inline void _emscripten_push_uncounted_main_loop_blocker(void (*func)(void *), v * to 10, then push 10 blockers, as they complete the user will * see x/10 and so forth. */ -#if EMSCRIPTEN +#if __EMSCRIPTEN__ extern void emscripten_set_main_loop_expected_blockers(int num); #else inline void emscripten_set_main_loop_expected_blockers(int num) {} @@ -197,7 +200,7 @@ inline void emscripten_set_main_loop_expected_blockers(int num) {} * If millis is negative, the browser's requestAnimationFrame * mechanism is used. */ -#if EMSCRIPTEN +#if __EMSCRIPTEN__ extern void emscripten_async_call(void (*func)(void *), void *arg, int millis); #else inline void emscripten_async_call(void (*func)(void *), void *arg, int millis) { @@ -212,7 +215,7 @@ inline void emscripten_async_call(void (*func)(void *), void *arg, int millis) { * etc. are not run). This is implicitly performed when you do * an asynchronous operation like emscripten_async_call. */ -extern void emscripten_exit_with_live_runtime(); +extern void emscripten_exit_with_live_runtime(void); /* * Hide the OS mouse cursor over the canvas. Note that SDL's @@ -220,7 +223,7 @@ extern void emscripten_exit_with_live_runtime(); * the OS one. This command is useful to hide the OS cursor * if your app draws its own cursor. */ -void emscripten_hide_mouse(); +void emscripten_hide_mouse(void); /* * Resizes the pixel width and height of the <canvas> element @@ -241,11 +244,11 @@ void emscripten_get_canvas_size(int *width, int *height, int *isFullscreen); * absolute time, and is only meaningful in comparison to * other calls to this function. The unit is ms. */ -#if EMSCRIPTEN -double emscripten_get_now(); +#if __EMSCRIPTEN__ +double emscripten_get_now(void); #else #include <time.h> -double emscripten_get_now() { +double emscripten_get_now(void) { return (1000*clock())/(double)CLOCKS |