From e81108dd27225918dd10e88417d65a2755f445e8 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 18 May 2013 14:17:52 -0700 Subject: [PATCH] File style cleanup for the SDL 2.0 release --- Xcode-iOS/Demos/src/accelerometer.c | 12 +- Xcode-iOS/Demos/src/common.c | 14 +- Xcode-iOS/Demos/src/common.h | 6 +- Xcode-iOS/Demos/src/fireworks.c | 40 +- Xcode-iOS/Demos/src/happy.c | 14 +- Xcode-iOS/Demos/src/keyboard.c | 26 +- Xcode-iOS/Demos/src/mixer.c | 20 +- Xcode-iOS/Demos/src/rectangles.c | 10 +- Xcode-iOS/Demos/src/touch.c | 14 +- Xcode-iOS/Template/SDL iOS Application/main.c | 6 +- .../SDL Application/main.c | 82 +- .../SDL Cocoa Application/main.c | 82 +- .../atlantis/atlantis.c | 276 +- .../SDL OpenGL Application/main.c | 104 +- .../SDL Application/main.c | 82 +- .../SDL Cocoa Application/main.c | 82 +- .../atlantis/atlantis.c | 276 +- .../SDL OpenGL Application/main.c | 46 +- .../SDL Application/main.c | 82 +- .../SDL Cocoa Application/main.c | 82 +- .../atlantis/atlantis.c | 276 +- .../SDL OpenGL Application/main.c | 104 +- include/SDL.h | 34 +- include/SDL_assert.h | 6 +- include/SDL_atomic.h | 20 +- include/SDL_audio.h | 126 +- include/SDL_bits.h | 4 - include/SDL_blendmode.h | 6 +- include/SDL_clipboard.h | 4 - include/SDL_config.h | 4 +- include/SDL_config_android.h | 156 +- include/SDL_config_iphoneos.h | 158 +- include/SDL_config_macosx.h | 162 +- include/SDL_config_minimal.h | 16 +- include/SDL_config_pandora.h | 2 +- include/SDL_config_psp.h | 148 +- include/SDL_config_windows.h | 40 +- include/SDL_config_wiz.h | 2 +- include/SDL_cpuinfo.h | 6 +- include/SDL_endian.h | 46 +- include/SDL_error.h | 16 +- include/SDL_events.h | 136 +- include/SDL_gamecontroller.h | 102 +- include/SDL_gesture.h | 6 +- include/SDL_haptic.h | 308 +- include/SDL_hints.h | 22 +- include/SDL_joystick.h | 56 +- include/SDL_keyboard.h | 54 +- include/SDL_keycode.h | 16 +- include/SDL_loadso.h | 6 +- include/SDL_log.h | 8 +- include/SDL_main.h | 10 +- include/SDL_messagebox.h | 4 - include/SDL_mouse.h | 62 +- include/SDL_mutex.h | 52 +- include/SDL_name.h | 2 +- include/SDL_opengl.h | 20 +- include/SDL_opengles.h | 2 +- include/SDL_opengles2.h | 2 +- include/SDL_pixels.h | 50 +- include/SDL_platform.h | 44 +- include/SDL_power.h | 12 +- include/SDL_quit.h | 8 +- include/SDL_rect.h | 14 +- include/SDL_render.h | 224 +- include/SDL_rwops.h | 56 +- include/SDL_scancode.h | 114 +- include/SDL_shape.h | 50 +- include/SDL_stdinc.h | 28 +- include/SDL_surface.h | 150 +- include/SDL_system.h | 6 +- include/SDL_syswm.h | 20 +- include/SDL_test.h | 14 +- include/SDL_test_assert.h | 12 +- include/SDL_test_common.h | 6 +- include/SDL_test_compare.h | 12 +- include/SDL_test_crc32.h | 30 +- include/SDL_test_font.h | 6 +- include/SDL_test_fuzzer.h | 16 +- include/SDL_test_harness.h | 60 +- include/SDL_test_images.h | 12 +- include/SDL_test_log.h | 8 +- include/SDL_test_md5.h | 28 +- include/SDL_test_random.h | 24 +- include/SDL_thread.h | 22 +- include/SDL_timer.h | 10 +- include/SDL_touch.h | 6 +- include/SDL_types.h | 2 +- include/SDL_version.h | 50 +- include/SDL_video.h | 250 +- include/begin_code.h | 12 +- include/close_code.h | 2 +- src/SDL.c | 26 +- src/SDL_error.c | 6 +- src/SDL_error_c.h | 4 +- src/SDL_hints.c | 4 +- src/SDL_hints_c.h | 6 +- src/SDL_log.c | 25 +- src/atomic/SDL_atomic.c | 6 +- src/atomic/SDL_spinlock.c | 10 +- src/audio/SDL_audiocvt.c | 2 +- src/audio/SDL_audiodev.c | 4 +- src/audio/SDL_audiomem.h | 4 +- src/audio/SDL_mixer.c | 4 +- src/audio/SDL_sysaudio.h | 2 +- src/audio/SDL_wave.h | 31 +- src/audio/alsa/SDL_alsa_audio.c | 2 +- src/audio/alsa/SDL_alsa_audio.h | 2 +- src/audio/android/SDL_androidaudio.c | 40 +- src/audio/android/SDL_androidaudio.h | 2 +- src/audio/arts/SDL_artsaudio.h | 4 +- src/audio/baudio/SDL_beaudio.h | 2 +- src/audio/bsd/SDL_bsdaudio.h | 4 +- src/audio/coreaudio/SDL_coreaudio.c | 6 +- src/audio/coreaudio/SDL_coreaudio.h | 2 +- src/audio/directsound/SDL_directsound.h | 2 +- src/audio/directsound/directx.h | 24 +- src/audio/disk/SDL_diskaudio.h | 2 +- src/audio/dsp/SDL_dspaudio.c | 2 +- src/audio/dsp/SDL_dspaudio.h | 4 +- src/audio/dummy/SDL_dummyaudio.h | 2 +- src/audio/esd/SDL_esdaudio.c | 4 +- src/audio/esd/SDL_esdaudio.h | 4 +- src/audio/fusionsound/SDL_fsaudio.c | 6 +- src/audio/fusionsound/SDL_fsaudio.h | 2 +- src/audio/nas/SDL_nasaudio.h | 2 +- src/audio/paudio/SDL_paudio.c | 6 +- src/audio/paudio/SDL_paudio.h | 4 +- src/audio/psp/SDL_pspaudio.c | 154 +- src/audio/psp/SDL_pspaudio.h | 18 +- src/audio/pulseaudio/SDL_pulseaudio.c | 2 +- src/audio/sun/SDL_sunaudio.c | 4 +- src/audio/sun/SDL_sunaudio.h | 2 +- src/audio/winmm/SDL_winmm.h | 2 +- src/audio/xaudio2/SDL_xaudio2.c | 10 +- src/core/android/SDL_android.cpp | 20 +- src/events/SDL_events.c | 2 +- src/events/SDL_gesture.c | 5 +- src/events/SDL_keyboard.c | 124 +- src/events/SDL_mouse.c | 16 +- src/events/SDL_mouse_c.h | 2 +- src/events/SDL_touch.c | 10 +- src/events/SDL_touch_c.h | 8 +- src/events/SDL_windowevents.c | 16 +- src/events/blank_cursor.h | 10 +- src/events/default_cursor.h | 10 +- src/file/SDL_rwops.c | 12 +- src/file/cocoa/SDL_rwopsbundlesupport.m | 40 +- src/haptic/SDL_syshaptic.h | 2 +- src/haptic/darwin/SDL_syshaptic.c | 6 +- src/haptic/linux/SDL_syshaptic.c | 68 +- src/haptic/windows/SDL_syshaptic.c | 28 +- src/joystick/SDL_gamecontroller.c | 1279 ++-- src/joystick/SDL_joystick.c | 303 +- src/joystick/SDL_joystick_c.h | 2 +- src/joystick/android/SDL_sysjoystick.c | 12 +- src/joystick/beos/SDL_bejoystick.cc | 4 +- src/joystick/bsd/SDL_sysjoystick.c | 10 +- src/joystick/darwin/SDL_sysjoystick.c | 556 +- src/joystick/darwin/SDL_sysjoystick_c.h | 14 +- src/joystick/dummy/SDL_sysjoystick.c | 4 +- .../iphoneos/SDLUIAccelerationDelegate.m | 138 +- src/joystick/iphoneos/SDL_sysjoystick.m | 40 +- src/joystick/linux/SDL_sysjoystick.c | 10 +- src/joystick/psp/SDL_sysjoystick.c | 212 +- src/joystick/windows/SDL_dxjoystick.c | 1704 ++--- src/joystick/windows/SDL_dxjoystick_c.h | 60 +- src/joystick/windows/SDL_mmjoystick.c | 16 +- src/main/beos/SDL_BApp.h | 594 +- src/main/psp/SDL_psp_main.c | 42 +- src/power/beos/SDL_syspower.c | 4 +- src/power/linux/SDL_syspower.c | 4 +- src/power/psp/SDL_syspower.c | 32 +- src/power/uikit/SDL_syspower.m | 15 +- src/render/SDL_render.c | 2 +- src/render/SDL_yuv_mmx.c | 426 +- src/render/SDL_yuv_sw.c | 22 +- src/render/direct3d/SDL_render_d3d.c | 50 +- src/render/opengl/SDL_render_gl.c | 30 +- src/render/opengl/SDL_shaders_gl.c | 4 +- src/render/opengles/SDL_render_gles.c | 14 +- src/render/opengles2/SDL_render_gles2.c | 8 +- src/render/opengles2/SDL_shaders_gles2.c | 12 +- src/render/psp/SDL_render_psp.c | 1182 +-- src/render/software/SDL_drawline.c | 1 - src/render/software/SDL_rotate.c | 4 +- src/stdlib/SDL_malloc.c | 20 +- src/test/SDL_test_assert.c | 128 +- src/test/SDL_test_common.c | 18 +- src/test/SDL_test_compare.c | 6 +- src/test/SDL_test_crc32.c | 40 +- src/test/SDL_test_font.c | 6370 ++++++++--------- src/test/SDL_test_fuzzer.c | 480 +- src/test/SDL_test_harness.c | 1008 +-- src/test/SDL_test_imageBlit.c | 22 +- src/test/SDL_test_imageBlitBlend.c | 40 +- src/test/SDL_test_imageFace.c | 8 +- src/test/SDL_test_imagePrimitives.c | 6 +- src/test/SDL_test_imagePrimitivesBlend.c | 8 +- src/test/SDL_test_log.c | 58 +- src/test/SDL_test_md5.c | 170 +- src/test/SDL_test_random.c | 14 +- src/thread/SDL_thread.c | 2 +- src/thread/psp/SDL_syssem.c | 136 +- src/thread/psp/SDL_systhread.c | 58 +- src/thread/pthread/SDL_systhread.c | 2 +- src/thread/windows/SDL_systhread.c | 6 +- src/timer/SDL_timer.c | 2 +- src/timer/SDL_timer_c.h | 4 +- src/timer/psp/SDL_systimer.c | 20 +- src/timer/unix/SDL_systimer.c | 2 +- src/timer/windows/SDL_systimer.c | 4 +- src/video/SDL_RLEaccel.c | 938 +-- src/video/SDL_blit.h | 602 +- src/video/SDL_bmp.c | 14 +- src/video/SDL_pixels.c | 10 +- src/video/SDL_rect.c | 26 +- src/video/SDL_shape.c | 49 +- src/video/SDL_surface.c | 14 +- src/video/SDL_sysvideo.h | 14 +- src/video/SDL_video.c | 144 +- src/video/android/SDL_androidkeyboard.c | 2 +- src/video/android/SDL_androidtouch.c | 6 +- src/video/android/SDL_androidvideo.c | 6 +- src/video/android/SDL_androidwindow.c | 2 +- src/video/bwindow/SDL_BWin.h | 742 +- src/video/bwindow/SDL_bevents.h | 2 +- src/video/bwindow/SDL_bmodes.cc | 2 +- src/video/bwindow/SDL_bmodes.h | 4 +- src/video/bwindow/SDL_bopengl.h | 10 +- src/video/cocoa/SDL_cocoaclipboard.m | 4 +- src/video/cocoa/SDL_cocoaevents.m | 16 +- src/video/cocoa/SDL_cocoakeyboard.m | 117 +- src/video/cocoa/SDL_cocoamodes.m | 8 +- src/video/cocoa/SDL_cocoamouse.m | 2 +- src/video/cocoa/SDL_cocoashape.h | 8 +- src/video/cocoa/SDL_cocoashape.m | 22 +- src/video/cocoa/SDL_cocoavideo.m | 6 +- src/video/cocoa/SDL_cocoawindow.m | 87 +- src/video/directfb/SDL_DirectFB_WM.c | 138 +- src/video/directfb/SDL_DirectFB_dyn.c | 2 +- src/video/directfb/SDL_DirectFB_dyn.h | 18 +- src/video/directfb/SDL_DirectFB_events.c | 98 +- src/video/directfb/SDL_DirectFB_modes.c | 6 +- src/video/directfb/SDL_DirectFB_modes.h | 18 +- src/video/directfb/SDL_DirectFB_mouse.c | 12 +- src/video/directfb/SDL_DirectFB_mouse.h | 4 +- src/video/directfb/SDL_DirectFB_opengl.c | 71 +- src/video/directfb/SDL_DirectFB_opengl.h | 10 +- src/video/directfb/SDL_DirectFB_render.c | 38 +- src/video/directfb/SDL_DirectFB_shape.c | 58 +- src/video/directfb/SDL_DirectFB_shape.h | 4 +- src/video/directfb/SDL_DirectFB_video.c | 82 +- src/video/directfb/SDL_DirectFB_video.h | 72 +- src/video/directfb/SDL_DirectFB_window.c | 58 +- src/video/directfb/SDL_DirectFB_window.h | 36 +- src/video/pandora/SDL_pandora.c | 28 +- src/video/psp/SDL_pspevents.c | 388 +- src/video/psp/SDL_pspevents_c.h | 2 +- src/video/psp/SDL_pspgl.c | 162 +- src/video/psp/SDL_pspgl_c.h | 6 +- src/video/psp/SDL_pspmouse.c | 2 +- src/video/psp/SDL_pspvideo.c | 59 +- src/video/psp/SDL_pspvideo.h | 6 +- src/video/uikit/SDL_uikitappdelegate.m | 15 +- src/video/uikit/SDL_uikitmessagebox.m | 16 +- src/video/uikit/SDL_uikitmodes.m | 96 +- src/video/uikit/SDL_uikitopengles.m | 6 +- src/video/uikit/SDL_uikitopenglview.m | 9 +- src/video/uikit/SDL_uikitvideo.h | 4 +- src/video/uikit/SDL_uikitview.m | 11 +- src/video/uikit/SDL_uikitviewcontroller.m | 18 +- src/video/uikit/SDL_uikitwindow.m | 68 +- src/video/windows/SDL_vkeys.h | 98 +- src/video/windows/SDL_windowsclipboard.c | 2 +- src/video/windows/SDL_windowsevents.c | 642 +- src/video/windows/SDL_windowsframebuffer.c | 2 +- src/video/windows/SDL_windowskeyboard.c | 10 +- src/video/windows/SDL_windowsmessagebox.c | 162 +- src/video/windows/SDL_windowsmouse.c | 62 +- src/video/windows/SDL_windowsopengl.c | 36 +- src/video/windows/SDL_windowsshape.c | 24 +- src/video/windows/SDL_windowsshape.h | 2 +- src/video/windows/SDL_windowsvideo.c | 22 +- src/video/windows/SDL_windowsvideo.h | 38 +- src/video/windows/SDL_windowswindow.c | 56 +- src/video/windows/wmmsg.h | 2 +- src/video/x11/SDL_x11clipboard.c | 4 +- src/video/x11/SDL_x11dyn.c | 6 +- src/video/x11/SDL_x11events.c | 42 +- src/video/x11/SDL_x11framebuffer.c | 4 +- src/video/x11/SDL_x11messagebox.c | 4 +- src/video/x11/SDL_x11modes.c | 2 +- src/video/x11/SDL_x11mouse.c | 10 +- src/video/x11/SDL_x11opengl.c | 44 +- src/video/x11/SDL_x11opengles.c | 16 +- src/video/x11/SDL_x11shape.c | 14 +- src/video/x11/SDL_x11shape.h | 6 +- src/video/x11/SDL_x11video.c | 2 +- src/video/x11/SDL_x11video.h | 4 +- src/video/x11/SDL_x11window.c | 22 +- src/video/x11/SDL_x11xinput2.c | 22 +- src/video/x11/SDL_x11xinput2.h | 4 +- test/automated/common/common.h | 6 +- test/automated/rwops/TestSupportRWops_Cocoa.m | 92 +- .../rwops/TestSupportRWops_Generic.c | 10 +- test/automated/surface/surface.c | 6 +- test/checkkeys.c | 2 +- test/loopwave.c | 4 +- test/test-automation/include/SDL_test.h | 32 +- .../test-automation/src/libSDLtest/SDL_test.c | 56 +- .../src/libSDLtest/common/common.h | 6 +- .../src/libSDLtest/fuzzer/fuzzer.c | 676 +- .../src/libSDLtest/fuzzer/fuzzer.h | 2 +- .../src/libSDLtest/fuzzer/utl_crc32.c | 30 +- .../src/libSDLtest/fuzzer/utl_crc32.h | 16 +- .../src/libSDLtest/fuzzer/utl_md5.c | 170 +- .../src/libSDLtest/fuzzer/utl_md5.h | 22 +- .../src/libSDLtest/fuzzer/utl_random.c | 10 +- .../src/libSDLtest/fuzzer/utl_random.h | 26 +- .../src/libSDLtest/logger_helpers.c | 94 +- .../src/libSDLtest/plain_logger.c | 216 +- .../src/libSDLtest/plain_logger.h | 8 +- test/test-automation/src/libSDLtest/xml.c | 436 +- test/test-automation/src/libSDLtest/xml.h | 4 +- .../src/libSDLtest/xml_logger.c | 812 +-- .../src/libSDLtest/xml_logger.h | 10 +- test/test-automation/src/runner/logger.h | 50 +- test/test-automation/src/runner/runner.c | 1688 ++--- test/test-automation/src/runner/support.c | 20 +- .../tests/testaudio/testaudio.c | 52 +- .../tests/testclipboard/testclipboard.c | 148 +- .../tests/testdummy/testdummy.c | 120 +- .../tests/testevents/testevents.c | 8 +- .../tests/testkeyboard/testkeyboard.c | 8 +- .../tests/testplatform/testplatform.c | 188 +- .../test-automation/tests/testrect/testrect.c | 236 +- .../tests/testrender/testrender.c | 30 +- .../tests/testrwops/testrwops.c | 36 +- .../tests/testsurface/testsurface.c | 310 +- .../tests/testsyswm/testsyswm.c | 8 +- .../tests/testvideo/testvideo.c | 8 +- test/testatomic.c | 80 +- test/testautomation.c | 22 +- test/testautomation_audio.c | 380 +- test/testautomation_clipboard.c | 158 +- test/testautomation_events.c | 44 +- test/testautomation_keyboard.c | 174 +- test/testautomation_main.c | 26 +- test/testautomation_mouse.c | 456 +- test/testautomation_pixels.c | 168 +- test/testautomation_platform.c | 54 +- test/testautomation_rect.c | 336 +- test/testautomation_render.c | 56 +- test/testautomation_rwops.c | 206 +- test/testautomation_sdltest.c | 230 +- test/testautomation_suites.h | 34 +- test/testautomation_surface.c | 456 +- test/testautomation_syswm.c | 26 +- test/testautomation_timer.c | 62 +- test/testautomation_video.c | 608 +- test/testdraw2.c | 2 +- test/testfile.c | 16 +- test/testgamecontroller.c | 4 +- test/testgesture.c | 186 +- test/testime.c | 6 +- test/testintersections.c | 2 +- test/testjoystick.c | 8 +- test/testlock.c | 2 +- test/testnative.c | 2 +- test/testrelative.c | 2 +- test/testsem.c | 2 +- test/testshader.c | 16 +- test/testshape.c | 16 +- test/testtimer.c | 2 +- test/testwm2.c | 4 +- 376 files changed, 18163 insertions(+), 18374 deletions(-) diff --git a/Xcode-iOS/Demos/src/accelerometer.c b/Xcode-iOS/Demos/src/accelerometer.c index 339febc11..78d42041b 100644 --- a/Xcode-iOS/Demos/src/accelerometer.c +++ b/Xcode-iOS/Demos/src/accelerometer.c @@ -1,7 +1,7 @@ /* - * accelerometer.c - * written by Holmes Futrell - * use however you want + * accelerometer.c + * written by Holmes Futrell + * use however you want */ #include "SDL.h" @@ -13,7 +13,7 @@ #define FRICTION 0.0008f /* coefficient of acceleration that opposes direction of motion */ #define GRAVITY_CONSTANT 0.004f /* how sensitive the ship is to the accelerometer */ -/* If we aren't on an iPhone, then this definition ought to yield reasonable behavior */ +/* If we aren't on an iPhone, then this definition ought to yield reasonable behavior */ #ifndef SDL_IPHONE_MAX_GFORCE #define SDL_IPHONE_MAX_GFORCE 5.0f #endif @@ -48,7 +48,7 @@ render(SDL_Renderer *renderer) #define SINT16_MAX ((float)(0x7FFF)) /* update velocity from accelerometer - the factor SDL_IPHONE_MAX_G_FORCE / SINT16_MAX converts between + the factor SDL_IPHONE_MAX_G_FORCE / SINT16_MAX converts between SDL's units reported from the joytick, and units of g-force, as reported by the accelerometer */ shipData.vx += @@ -159,7 +159,7 @@ main(int argc, char *argv[]) { SDL_Window *window; /* main window */ - SDL_Renderer *renderer; + SDL_Renderer *renderer; Uint32 startFrame; /* time frame began to process */ Uint32 endFrame; /* time frame ended processing */ Uint32 delay; /* time to pause waiting to draw next frame */ diff --git a/Xcode-iOS/Demos/src/common.c b/Xcode-iOS/Demos/src/common.c index fd3a176db..b2d963456 100644 --- a/Xcode-iOS/Demos/src/common.c +++ b/Xcode-iOS/Demos/src/common.c @@ -1,7 +1,7 @@ /* - * common.c - * written by Holmes Futrell - * use however you want + * common.c + * written by Holmes Futrell + * use however you want */ #include "common.h" @@ -9,8 +9,8 @@ #include /* - Produces a random int x, min <= x <= max - following a uniform distribution + Produces a random int x, min <= x <= max + following a uniform distribution */ int randomInt(int min, int max) @@ -19,8 +19,8 @@ randomInt(int min, int max) } /* - Produces a random float x, min <= x <= max - following a uniform distribution + Produces a random float x, min <= x <= max + following a uniform distribution */ float randomFloat(float min, float max) diff --git a/Xcode-iOS/Demos/src/common.h b/Xcode-iOS/Demos/src/common.h index 9aa01a23e..3e0d94ecf 100644 --- a/Xcode-iOS/Demos/src/common.h +++ b/Xcode-iOS/Demos/src/common.h @@ -1,7 +1,7 @@ /* - * common.h - * written by Holmes Futrell - * use however you want + * common.h + * written by Holmes Futrell + * use however you want */ #define SCREEN_WIDTH 320 diff --git a/Xcode-iOS/Demos/src/fireworks.c b/Xcode-iOS/Demos/src/fireworks.c index fa39abff5..5b4c4118c 100644 --- a/Xcode-iOS/Demos/src/fireworks.c +++ b/Xcode-iOS/Demos/src/fireworks.c @@ -1,7 +1,7 @@ /* - * fireworks.c - * written by Holmes Futrell - * use however you want + * fireworks.c + * written by Holmes Futrell + * use however you want */ #include "SDL.h" @@ -17,11 +17,11 @@ static GLuint particleTextureID; /* OpenGL particle texture id */ static SDL_bool pointSizeExtensionSupported; /* is GL_OES_point_size_array supported ? */ -/* - used to describe what type of particle a given struct particle is. - emitter - this particle flies up, shooting off trail particles, then finally explodes into dust particles. - trail - shoots off, following emitter particle - dust - radiates outwards from emitter explosion +/* + used to describe what type of particle a given struct particle is. + emitter - this particle flies up, shooting off trail particles, then finally explodes into dust particles. + trail - shoots off, following emitter particle + dust - radiates outwards from emitter explosion */ enum particleType { @@ -30,7 +30,7 @@ enum particleType dust }; /* - struct particle is used to describe each particle displayed on screen + struct particle is used to describe each particle displayed on screen */ struct particle { @@ -57,8 +57,8 @@ int nextPowerOfTwo(int x); void drawParticles(); void stepParticles(void); -/* helper function (used in texture loading) - returns next power of two greater than or equal to x +/* helper function (used in texture loading) + returns next power of two greater than or equal to x */ int nextPowerOfTwo(int x) @@ -70,8 +70,8 @@ nextPowerOfTwo(int x) return val; } -/* - steps each active particle by timestep MILLESECONDS_PER_FRAME +/* + steps each active particle by timestep MILLESECONDS_PER_FRAME */ void stepParticles(void) @@ -145,13 +145,13 @@ stepParticles(void) curr++; } /* the number of active particles is computed as the difference between - old number of active particles, where slot points, and the + old number of active particles, where slot points, and the new size of the array, where particles points */ num_active_particles = slot - particles; } /* - This draws all the particles shown on screen + This draws all the particles shown on screen */ void drawParticles() @@ -177,7 +177,7 @@ drawParticles() } /* - This causes an emitter to explode in a circular bloom of dust particles + This causes an emitter to explode in a circular bloom of dust particles */ void explodeEmitter(struct particle *emitter) @@ -219,7 +219,7 @@ explodeEmitter(struct particle *emitter) } /* - This spawns a trail particle from an emitter + This spawns a trail particle from an emitter */ void spawnTrailFromEmitter(struct particle *emitter) @@ -254,7 +254,7 @@ spawnTrailFromEmitter(struct particle *emitter) } /* - spawns a new emitter particle at the bottom of the screen + spawns a new emitter particle at the bottom of the screen destined for the point (x,y). */ void @@ -313,7 +313,7 @@ initializeParticles(void) } /* - loads the particle texture + loads the particle texture */ void initializeTexture() @@ -375,7 +375,7 @@ main(int argc, char *argv[]) } /* seed the random number generator */ srand(time(NULL)); - /* + /* request some OpenGL parameters that may speed drawing */ diff --git a/Xcode-iOS/Demos/src/happy.c b/Xcode-iOS/Demos/src/happy.c index c1731b879..7a524c0e4 100644 --- a/Xcode-iOS/Demos/src/happy.c +++ b/Xcode-iOS/Demos/src/happy.c @@ -1,7 +1,7 @@ /* - * happy.c - * written by Holmes Futrell - * use however you want + * happy.c + * written by Holmes Futrell + * use however you want */ #include "SDL.h" @@ -20,8 +20,8 @@ static struct } faces[NUM_HAPPY_FACES]; /* - Sets initial positions and velocities of happyfaces - units of velocity are pixels per millesecond + Sets initial positions and velocities of happyfaces + units of velocity are pixels per millesecond */ void initializeHappyFaces() @@ -94,7 +94,7 @@ render(SDL_Renderer *renderer) } /* - loads the happyface graphic into a texture + loads the happyface graphic into a texture */ void initializeTexture(SDL_Renderer *renderer) @@ -125,7 +125,7 @@ main(int argc, char *argv[]) { SDL_Window *window; - SDL_Renderer *renderer; + SDL_Renderer *renderer; Uint32 startFrame; Uint32 endFrame; Uint32 delay; diff --git a/Xcode-iOS/Demos/src/keyboard.c b/Xcode-iOS/Demos/src/keyboard.c index 3e2bc5459..4b55c7be4 100644 --- a/Xcode-iOS/Demos/src/keyboard.c +++ b/Xcode-iOS/Demos/src/keyboard.c @@ -1,7 +1,7 @@ /* - * keyboard.c - * written by Holmes Futrell - * use however you want + * keyboard.c + * written by Holmes Futrell + * use however you want */ #import "SDL.h" @@ -97,14 +97,14 @@ fontMapping map[TABLE_SIZE] = { }; /* - This function maps an SDL_KeySym to an index in the bitmap font. - It does so by scanning through the font mapping table one entry - at a time. - - If a match is found (scancode and allowed modifiers), the proper - index is returned. - - If there is no entry for the key, -1 is returned + This function maps an SDL_KeySym to an index in the bitmap font. + It does so by scanning through the font mapping table one entry + at a time. + + If a match is found (scancode and allowed modifiers), the proper + index is returned. + + If there is no entry for the key, -1 is returned */ int keyToIndex(SDL_Keysym key) @@ -125,8 +125,8 @@ keyToIndex(SDL_Keysym key) return index; } -/* - This function returns and x,y position for a given character number. +/* + This function returns and x,y position for a given character number. It is used for positioning each character of text */ void diff --git a/Xcode-iOS/Demos/src/mixer.c b/Xcode-iOS/Demos/src/mixer.c index 893361f9a..526abb07b 100644 --- a/Xcode-iOS/Demos/src/mixer.c +++ b/Xcode-iOS/Demos/src/mixer.c @@ -1,7 +1,7 @@ /* - * mixer.c - * written by Holmes Futrell - * use however you want + * mixer.c + * written by Holmes Futrell + * use however you want */ #import "SDL.h" @@ -100,7 +100,7 @@ loadSound(const char *file, struct sound *s) if (result == -1) { fatalError("could not build audio CVT"); } else if (result != 0) { - /* + /* this happens when the .wav format differs from the output format. we convert the .wav buffer here */ @@ -179,8 +179,8 @@ render(SDL_Renderer *renderer) } /* - finds a sound channel in the mixer for a sound - and sets it up to start playing + finds a sound channel in the mixer for a sound + and sets it up to start playing */ int playSound(struct sound *s) @@ -225,9 +225,9 @@ playSound(struct sound *s) return selected_channel; } -/* - Called from SDL's audio system. Supplies sound input with data by mixing together all - currently playing sound effects. +/* + Called from SDL's audio system. Supplies sound input with data by mixing together all + currently playing sound effects. */ void audioCallback(void *userdata, Uint8 * stream, int len) @@ -273,7 +273,7 @@ main(int argc, char *argv[]) int done; /* has user tried to quit ? */ SDL_Window *window; /* main window */ - SDL_Renderer *renderer; + SDL_Renderer *renderer; SDL_Event event; Uint32 startFrame; /* holds when frame started processing */ Uint32 endFrame; /* holds when frame ended processing */ diff --git a/Xcode-iOS/Demos/src/rectangles.c b/Xcode-iOS/Demos/src/rectangles.c index 4dcb32035..11e5f135c 100644 --- a/Xcode-iOS/Demos/src/rectangles.c +++ b/Xcode-iOS/Demos/src/rectangles.c @@ -1,7 +1,7 @@ /* - * rectangles.c - * written by Holmes Futrell - * use however you want + * rectangles.c + * written by Holmes Futrell + * use however you want */ #include "SDL.h" @@ -39,7 +39,7 @@ main(int argc, char *argv[]) { SDL_Window *window; - SDL_Renderer *renderer; + SDL_Renderer *renderer; int done; SDL_Event event; @@ -59,7 +59,7 @@ main(int argc, char *argv[]) fatalError("Could not initialize Window"); } renderer = SDL_CreateRenderer(window, -1, 0); - if (!renderer) { + if (!renderer) { fatalError("Could not create renderer"); } diff --git a/Xcode-iOS/Demos/src/touch.c b/Xcode-iOS/Demos/src/touch.c index 8ce8006a0..b5065b10a 100644 --- a/Xcode-iOS/Demos/src/touch.c +++ b/Xcode-iOS/Demos/src/touch.c @@ -1,7 +1,7 @@ /* - * touch.c - * written by Holmes Futrell - * use however you want + * touch.c + * written by Holmes Futrell + * use however you want */ #include "SDL.h" @@ -14,8 +14,8 @@ static SDL_Texture *brush = 0; /* texture for the brush */ /* - draws a line from (startx, starty) to (startx + dx, starty + dy) - this is accomplished by drawing several blots spaced PIXELS_PER_ITERATION apart + draws a line from (startx, starty) to (startx + dx, starty + dy) + this is accomplished by drawing several blots spaced PIXELS_PER_ITERATION apart */ void drawLine(SDL_Renderer *renderer, float startx, float starty, float dx, float dy) @@ -48,7 +48,7 @@ drawLine(SDL_Renderer *renderer, float startx, float starty, float dx, float dy) } /* - loads the brush texture + loads the brush texture */ void initializeTexture(SDL_Renderer *renderer) @@ -78,7 +78,7 @@ main(int argc, char *argv[]) Uint8 state; /* mouse (touch) state */ SDL_Event event; SDL_Window *window; /* main window */ - SDL_Renderer *renderer; + SDL_Renderer *renderer; int done; /* does user want to quit? */ /* initialize SDL */ diff --git a/Xcode-iOS/Template/SDL iOS Application/main.c b/Xcode-iOS/Template/SDL iOS Application/main.c index 2a5d3f2ac..ca05e0083 100644 --- a/Xcode-iOS/Template/SDL iOS Application/main.c +++ b/Xcode-iOS/Template/SDL iOS Application/main.c @@ -1,7 +1,7 @@ /* - * rectangles.c - * written by Holmes Futrell - * use however you want + * rectangles.c + * written by Holmes Futrell + * use however you want */ #include "SDL.h" diff --git a/Xcode/TemplatesForXcodeLeopard/SDL Application/main.c b/Xcode/TemplatesForXcodeLeopard/SDL Application/main.c index 7115de989..47af3765d 100644 --- a/Xcode/TemplatesForXcodeLeopard/SDL Application/main.c +++ b/Xcode/TemplatesForXcodeLeopard/SDL Application/main.c @@ -4,7 +4,7 @@ Please see the SDL documentation for details on using the SDL API: /Developer/Documentation/SDL/docs.html */ - + #include #include #include @@ -14,52 +14,52 @@ int main(int argc, char *argv[]) { - Uint32 initflags = SDL_INIT_VIDEO; /* See documentation for details */ - SDL_Surface *screen; - Uint8 video_bpp = 0; - Uint32 videoflags = SDL_SWSURFACE; - int done; + Uint32 initflags = SDL_INIT_VIDEO; /* See documentation for details */ + SDL_Surface *screen; + Uint8 video_bpp = 0; + Uint32 videoflags = SDL_SWSURFACE; + int done; SDL_Event event; - /* Initialize the SDL library */ - if ( SDL_Init(initflags) < 0 ) { - fprintf(stderr, "Couldn't initialize SDL: %s\n", - SDL_GetError()); - exit(1); - } + /* Initialize the SDL library */ + if ( SDL_Init(initflags) < 0 ) { + fprintf(stderr, "Couldn't initialize SDL: %s\n", + SDL_GetError()); + exit(1); + } - /* Set 640x480 video mode */ - screen=SDL_SetVideoMode(640,480, video_bpp, videoflags); + /* Set 640x480 video mode */ + screen=SDL_SetVideoMode(640,480, video_bpp, videoflags); if (screen == NULL) { - fprintf(stderr, "Couldn't set 640x480x%d video mode: %s\n", + fprintf(stderr, "Couldn't set 640x480x%d video mode: %s\n", video_bpp, SDL_GetError()); - SDL_Quit(); - exit(2); - } + SDL_Quit(); + exit(2); + } + + done = 0; + while ( !done ) { - done = 0; - while ( !done ) { + /* Check for events */ + while ( SDL_PollEvent(&event) ) { + switch (event.type) { - /* Check for events */ - while ( SDL_PollEvent(&event) ) { - switch (event.type) { + case SDL_MOUSEMOTION: + break; + case SDL_MOUSEBUTTONDOWN: + break; + case SDL_KEYDOWN: + /* Any keypress quits the app... */ + case SDL_QUIT: + done = 1; + break; + default: + break; + } + } + } - case SDL_MOUSEMOTION: - break; - case SDL_MOUSEBUTTONDOWN: - break; - case SDL_KEYDOWN: - /* Any keypress quits the app... */ - case SDL_QUIT: - done = 1; - break; - default: - break; - } - } - } - - /* Clean up the SDL library */ - SDL_Quit(); - return(0); + /* Clean up the SDL library */ + SDL_Quit(); + return(0); } diff --git a/Xcode/TemplatesForXcodeLeopard/SDL Cocoa Application/main.c b/Xcode/TemplatesForXcodeLeopard/SDL Cocoa Application/main.c index 7115de989..47af3765d 100644 --- a/Xcode/TemplatesForXcodeLeopard/SDL Cocoa Application/main.c +++ b/Xcode/TemplatesForXcodeLeopard/SDL Cocoa Application/main.c @@ -4,7 +4,7 @@ Please see the SDL documentation for details on using the SDL API: /Developer/Documentation/SDL/docs.html */ - + #include #include #include @@ -14,52 +14,52 @@ int main(int argc, char *argv[]) { - Uint32 initflags = SDL_INIT_VIDEO; /* See documentation for details */ - SDL_Surface *screen; - Uint8 video_bpp = 0; - Uint32 videoflags = SDL_SWSURFACE; - int done; + Uint32 initflags = SDL_INIT_VIDEO; /* See documentation for details */ + SDL_Surface *screen; + Uint8 video_bpp = 0; + Uint32 videoflags = SDL_SWSURFACE; + int done; SDL_Event event; - /* Initialize the SDL library */ - if ( SDL_Init(initflags) < 0 ) { - fprintf(stderr, "Couldn't initialize SDL: %s\n", - SDL_GetError()); - exit(1); - } + /* Initialize the SDL library */ + if ( SDL_Init(initflags) < 0 ) { + fprintf(stderr, "Couldn't initialize SDL: %s\n", + SDL_GetError()); + exit(1); + } - /* Set 640x480 video mode */ - screen=SDL_SetVideoMode(640,480, video_bpp, videoflags); + /* Set 640x480 video mode */ + screen=SDL_SetVideoMode(640,480, video_bpp, videoflags); if (screen == NULL) { - fprintf(stderr, "Couldn't set 640x480x%d video mode: %s\n", + fprintf(stderr, "Couldn't set 640x480x%d video mode: %s\n", video_bpp, SDL_GetError()); - SDL_Quit(); - exit(2); - } + SDL_Quit(); + exit(2); + } + + done = 0; + while ( !done ) { - done = 0; - while ( !done ) { + /* Check for events */ + while ( SDL_PollEvent(&event) ) { + switch (event.type) { - /* Check for events */ - while ( SDL_PollEvent(&event) ) { - switch (event.type) { + case SDL_MOUSEMOTION: + break; + case SDL_MOUSEBUTTONDOWN: + break; + case SDL_KEYDOWN: + /* Any keypress quits the app... */ + case SDL_QUIT: + done = 1; + break; + default: + break; + } + } + } - case SDL_MOUSEMOTION: - break; - case SDL_MOUSEBUTTONDOWN: - break; - case SDL_KEYDOWN: - /* Any keypress quits the app... */ - case SDL_QUIT: - done = 1; - break; - default: - break; - } - } - } - - /* Clean up the SDL library */ - SDL_Quit(); - return(0); + /* Clean up the SDL library */ + SDL_Quit(); + return(0); } diff --git a/Xcode/TemplatesForXcodeLeopard/SDL OpenGL Application/atlantis/atlantis.c b/Xcode/TemplatesForXcodeLeopard/SDL OpenGL Application/atlantis/atlantis.c index 4efdf6ce8..debed809d 100644 --- a/Xcode/TemplatesForXcodeLeopard/SDL OpenGL Application/atlantis/atlantis.c +++ b/Xcode/TemplatesForXcodeLeopard/SDL OpenGL Application/atlantis/atlantis.c @@ -63,37 +63,37 @@ static double mtime(void) { struct timeval tk_time; struct timezone tz; - + gettimeofday(&tk_time, &tz); - + return 4294.967296 * tk_time.tv_sec + 0.000001 * tk_time.tv_usec; } static double filter(double in, double *save) { - static double k1 = 0.9; - static double k2 = 0.05; + static double k1 = 0.9; + static double k2 = 0.05; - save[3] = in; - save[1] = save[0]*k1 + k2*(save[3] + save[2]); + save[3] = in; + save[1] = save[0]*k1 + k2*(save[3] + save[2]); - save[0]=save[1]; - save[2]=save[3]; + save[0]=save[1]; + save[2]=save[3]; - return(save[1]); + return(save[1]); } void DrawStr(const char *str) { - GLint i = 0; - - if(!str) return; - - while(str[i]) - { - glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, str[i]); - i++; - } + GLint i = 0; + + if(!str) return; + + while(str[i]) + { + glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, str[i]); + i++; + } } void @@ -168,9 +168,9 @@ Atlantis_Init(void) InitFishs(); glEnable(GL_FOG); - glFogi(GL_FOG_MODE, GL_EXP); - glFogf(GL_FOG_DENSITY, 0.0000025); - glFogfv(GL_FOG_COLOR, fog_color); + glFogi(GL_FOG_MODE, GL_EXP); + glFogf(GL_FOG_DENSITY, 0.0000025); + glFogfv(GL_FOG_COLOR, fog_color); glClearColor(0.0, 0.5, 0.9, 1.0); } @@ -178,9 +178,9 @@ Atlantis_Init(void) void Atlantis_Reshape(int width, int height) { - w_win = width; - h_win = height; - + w_win = width; + h_win = height; + glViewport(0, 0, width, height); glMatrixMode(GL_PROJECTION); @@ -212,37 +212,37 @@ Atlantis_Key(unsigned char key, int x, int y) { switch (key) { case 't': - Timing = !Timing; + Timing = !Timing; break; case ' ': - switch(StrMode) - { - case GL_EXTENSIONS: - StrMode = GL_VENDOR; - break; - case GL_VENDOR: - StrMode = GL_RENDERER; - break; - case GL_RENDERER: - StrMode = GL_VERSION; - break; - case GL_VERSION: - StrMode = GL_EXTENSIONS; - break; - } - break; + switch(StrMode) + { + case GL_EXTENSIONS: + StrMode = GL_VENDOR; + break; + case GL_VENDOR: + StrMode = GL_RENDERER; + break; + case GL_RENDERER: + StrMode = GL_VERSION; + break; + case GL_VERSION: + StrMode = GL_EXTENSIONS; + break; + } + break; case 27: /* Esc will quit */ exit(1); break; - case 's': /* "s" start animation */ + case 's': /* "s" start animation */ moving = GL_TRUE; //glutIdleFunc(Animate); break; - case 'a': /* "a" stop animation */ + case 'a': /* "a" stop animation */ moving = GL_FALSE; //glutIdleFunc(NULL); break; - case '.': /* "." will advance frame */ + case '.': /* "." will advance frame */ if (!moving) { Atlantis_Animate(); } @@ -251,21 +251,21 @@ Atlantis_Key(unsigned char key, int x, int y) /* void Display(void) { - static float P123[3] = {-448.94, -203.14, 9499.60}; - static float P124[3] = {-442.64, -185.20, 9528.07}; - static float P125[3] = {-441.07, -148.05, 9528.07}; - static float P126[3] = {-443.43, -128.84, 9499.60}; - static float P127[3] = {-456.87, -146.78, 9466.67}; - static float P128[3] = {-453.68, -183.93, 9466.67}; - - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - glPushMatrix(); + static float P123[3] = {-448.94, -203.14, 9499.60}; + static float P124[3] = {-442.64, -185.20, 9528.07}; + static float P125[3] = {-441.07, -148.05, 9528.07}; + static float P126[3] = {-443.43, -128.84, 9499.60}; + static float P127[3] = {-456.87, -146.78, 9466.67}; + static float P128[3] = {-453.68, -183.93, 9466.67}; + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glPushMatrix(); FishTransform(&dolph); DrawDolphin(&dolph); glPopMatrix(); - - glutSwapBuffers(); + + glutSwapBuffers(); } */ @@ -274,9 +274,9 @@ Atlantis_Display(void) { int i; static double th[4] = {0.0, 0.0, 0.0, 0.0}; - static double t1 = 0.0, t2 = 0.0, t; - char num_str[128]; - + static double t1 = 0.0, t2 = 0.0, t; + char num_str[128]; + t1 = t2; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -303,56 +303,56 @@ Atlantis_Display(void) glScalef(0.45, 0.45, 0.3); DrawWhale(&babyWhale); glPopMatrix(); - + if(Timing) { - t2 = mtime(); - t = t2 - t1; - if(t > 0.0001) t = 1.0 / t; - - glDisable(GL_LIGHTING); - //glDisable(GL_DEPTH_TEST); - - glColor3f(1.0, 0.0, 0.0); - - glMatrixMode (GL_PROJECTION); - glPushMatrix(); - glLoadIdentity(); - glOrtho(0, w_win, 0, h_win, -10.0, 10.0); - - glRasterPos2f(5.0, 5.0); - - switch(StrMode) - { - case GL_VENDOR: - sprintf(num_str, "%0.2f Hz, %dx%d, VENDOR: ", filter(t, th), w_win, h_win); - DrawStr(num_str); - DrawStr(glGetString(GL_VENDOR)); - break; - case GL_RENDERER: - sprintf(num_str, "%0.2f Hz, %dx%d, RENDERER: ", filter(t, th), w_win, h_win); - DrawStr(num_str); - DrawStr(glGetString(GL_RENDERER)); - break; - case GL_VERSION: - sprintf(num_str, "%0.2f Hz, %dx%d, VERSION: ", filter(t, th), w_win, h_win); - DrawStr(num_str); - DrawStr(glGetString(GL_VERSION)); - break; - case GL_EXTENSIONS: - sprintf(num_str, "%0.2f Hz, %dx%d, EXTENSIONS: ", filter(t, th), w_win, h_win); - DrawStr(num_str); - DrawStr(glGetString(GL_EXTENSIONS)); - break; - } - - glPopMatrix(); - glMatrixMode(GL_MODELVIEW); - - glEnable(GL_LIGHTING); - //glEnable(GL_DEPTH_TEST); - } - + t2 = mtime(); + t = t2 - t1; + if(t > 0.0001) t = 1.0 / t; + + glDisable(GL_LIGHTING); + //glDisable(GL_DEPTH_TEST); + + glColor3f(1.0, 0.0, 0.0); + + glMatrixMode (GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + glOrtho(0, w_win, 0, h_win, -10.0, 10.0); + + glRasterPos2f(5.0, 5.0); + + switch(StrMode) + { + case GL_VENDOR: + sprintf(num_str, "%0.2f Hz, %dx%d, VENDOR: ", filter(t, th), w_win, h_win); + DrawStr(num_str); + DrawStr(glGetString(GL_VENDOR)); + break; + case GL_RENDERER: + sprintf(num_str, "%0.2f Hz, %dx%d, RENDERER: ", filter(t, th), w_win, h_win); + DrawStr(num_str); + DrawStr(glGetString(GL_RENDERER)); + break; + case GL_VERSION: + sprintf(num_str, "%0.2f Hz, %dx%d, VERSION: ", filter(t, th), w_win, h_win); + DrawStr(num_str); + DrawStr(glGetString(GL_VERSION)); + break; + case GL_EXTENSIONS: + sprintf(num_str, "%0.2f Hz, %dx%d, EXTENSIONS: ", filter(t, th), w_win, h_win); + DrawStr(num_str); + DrawStr(glGetString(GL_EXTENSIONS)); + break; + } + + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); + + glEnable(GL_LIGHTING); + //glEnable(GL_DEPTH_TEST); + } + count++; glutSwapBuffers(); @@ -377,18 +377,18 @@ timingSelect(int value) { switch(value) { - case 1: - StrMode = GL_VENDOR; - break; - case 2: - StrMode = GL_RENDERER; - break; - case 3: - StrMode = GL_VERSION; - break; - case 4: - StrMode = GL_EXTENSIONS; - break; + case 1: + StrMode = GL_VENDOR; + break; + case 2: + StrMode = GL_RENDERER; + break; + case 3: + StrMode = GL_VERSION; + break; + case 4: + StrMode = GL_EXTENSIONS; + break; } } @@ -413,24 +413,24 @@ menuSelect(int value) int main(int argc, char **argv) { - GLboolean fullscreen = GL_FALSE; - GLint time_menu; - - srand(0); + GLboolean fullscreen = GL_FALSE; + GLint time_menu; + + srand(0); glutInit(&argc, argv); - if (argc > 1 && !strcmp(argv[1], "-w")) - fullscreen = GL_FALSE; - - //glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH); - glutInitDisplayString("rgba double depth=24"); - if (fullscreen) { - glutGameModeString("1024x768:32"); - glutEnterGameMode(); - } else { - glutInitWindowSize(320, 240); - glutCreateWindow("Atlantis Timing"); - } + if (argc > 1 && !strcmp(argv[1], "-w")) + fullscreen = GL_FALSE; + + //glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH); + glutInitDisplayString("rgba double depth=24"); + if (fullscreen) { + glutGameModeString("1024x768:32"); + glutEnterGameMode(); + } else { + glutInitWindowSize(320, 240); + glutCreateWindow("Atlantis Timing"); + } Init(); glutDisplayFunc(Display); glutReshapeFunc(Reshape); @@ -438,19 +438,19 @@ main(int argc, char **argv) moving = GL_TRUE; glutIdleFunc(Animate); glutVisibilityFunc(Visible); - + time_menu = glutCreateMenu(timingSelect); glutAddMenuEntry("GL_VENDOR", 1); glutAddMenuEntry("GL_RENDERER", 2); glutAddMenuEntry("GL_VERSION", 3); glutAddMenuEntry("GL_EXTENSIONS", 4); - + glutCreateMenu(menuSelect); glutAddMenuEntry("Start motion", 1); glutAddMenuEntry("Stop motion", 2); glutAddSubMenu("Timing Mode", time_menu); glutAddMenuEntry("Quit", 4); - + //glutAttachMenu(GLUT_RIGHT_BUTTON); glutAttachMenu(GLUT_RIGHT_BUTTON); glutMainLoop(); diff --git a/Xcode/TemplatesForXcodeLeopard/SDL OpenGL Application/main.c b/Xcode/TemplatesForXcodeLeopard/SDL OpenGL Application/main.c index b7794b3b6..3bc4d33b1 100644 --- a/Xcode/TemplatesForXcodeLeopard/SDL OpenGL Application/main.c +++ b/Xcode/TemplatesForXcodeLeopard/SDL OpenGL Application/main.c @@ -4,7 +4,7 @@ Please see the SDL documentation for details on using the SDL API: /Developer/Documentation/SDL/docs.html */ - + #include #include #include @@ -22,18 +22,18 @@ static SDL_Surface *gScreen; static void initAttributes () { // Setup attributes we want for the OpenGL context - + int value; - + // Don't set color bit sizes (SDL_GL_RED_SIZE, etc) // Mac OS X will always use 8-8-8-8 ARGB for 32-bit screens and // 5-5-5 RGB for 16-bit screens - + // Request a 16-bit depth buffer (without this, there is no depth buffer) value = 16; SDL_GL_SetAttribute (SDL_GL_DEPTH_SIZE, value); - - + + // Request double-buffered OpenGL // The fact that windows are double-buffered on Mac OS X has no effect // on OpenGL double buffering. @@ -46,41 +46,41 @@ static void printAttributes () // Print out attributes of the context we created int nAttr; int i; - + int attr[] = { SDL_GL_RED_SIZE, SDL_GL_BLUE_SIZE, SDL_GL_GREEN_SIZE, SDL_GL_ALPHA_SIZE, SDL_GL_BUFFER_SIZE, SDL_GL_DEPTH_SIZE }; - + char *desc[] = { "Red size: %d bits\n", "Blue size: %d bits\n", "Green size: %d bits\n", - "Alpha size: %d bits\n", "Color buffer size: %d bits\n", + "Alpha size: %d bits\n", "Color buffer size: %d bits\n", "Depth bufer size: %d bits\n" }; nAttr = sizeof(attr) / sizeof(int); - + for (i = 0; i < nAttr; i++) { - + int value; SDL_GL_GetAttribute (attr[i], &value); printf (desc[i], value); - } + } } static void createSurface (int fullscreen) { Uint32 flags = 0; - + flags = SDL_OPENGL; if (fullscreen) flags |= SDL_FULLSCREEN; - + // Create window gScreen = SDL_SetVideoMode (640, 480, 0, flags); if (gScreen == NULL) { - + fprintf (stderr, "Couldn't set 640x480 OpenGL video mode: %s\n", SDL_GetError()); - SDL_Quit(); - exit(2); - } + SDL_Quit(); + exit(2); + } } static void initGL () @@ -100,30 +100,30 @@ static void mainLoop () SDL_Event event; int done = 0; int fps = 24; - int delay = 1000/fps; + int delay = 1000/fps; int thenTicks = -1; int nowTicks; - + while ( !done ) { - /* Check for events */ - while ( SDL_PollEvent (&event) ) { - switch (event.type) { - - case SDL_MOUSEMOTION: - break; - case SDL_MOUSEBUTTONDOWN: - break; - case SDL_KEYDOWN: - /* Any keypress quits the app... */ - case SDL_QUIT: - done = 1; - break; - default: - break; - } - } - + /* Check for events */ + while ( SDL_PollEvent (&event) ) { + switch (event.type) { + + case SDL_MOUSEMOTION: + break; + case SDL_MOUSEBUTTONDOWN: + break; + case SDL_KEYDOWN: + /* Any keypress quits the app... */ + case SDL_QUIT: + done = 1; + break; + default: + break; + } + } + // Draw at 24 hz // This approach is not normally recommended - it is better to // use time-based animation and run as fast as possible @@ -144,36 +144,36 @@ static void mainLoop () } SDL_Delay (delay); - } + } } int main(int argc, char *argv[]) { - // Init SDL video subsystem - if ( SDL_Init (SDL_INIT_VIDEO) < 0 ) { - + // Init SDL video subsystem + if ( SDL_Init (SDL_INIT_VIDEO) < 0 ) { + fprintf(stderr, "Couldn't initialize SDL: %s\n", - SDL_GetError()); - exit(1); - } + SDL_GetError()); + exit(1); + } // Set GL context attributes initAttributes (); - + // Create GL context createSurface (0); - + // Get GL context attributes printAttributes (); - + // Init GL state initGL (); - + // Draw, get events... mainLoop (); - + // Cleanup - SDL_Quit(); - + SDL_Quit(); + return 0; } diff --git a/Xcode/TemplatesForXcodeSnowLeopard/SDL Application/main.c b/Xcode/TemplatesForXcodeSnowLeopard/SDL Application/main.c index 7115de989..47af3765d 100644 --- a/Xcode/TemplatesForXcodeSnowLeopard/SDL Application/main.c +++ b/Xcode/TemplatesForXcodeSnowLeopard/SDL Application/main.c @@ -4,7 +4,7 @@ Please see the SDL documentation for details on using the SDL API: /Developer/Documentation/SDL/docs.html */ - + #include #include #include @@ -14,52 +14,52 @@ int main(int argc, char *argv[]) { - Uint32 initflags = SDL_INIT_VIDEO; /* See documentation for details */ - SDL_Surface *screen; - Uint8 video_bpp = 0; - Uint32 videoflags = SDL_SWSURFACE; - int done; + Uint32 initflags = SDL_INIT_VIDEO; /* See documentation for details */ + SDL_Surface *screen; + Uint8 video_bpp = 0; + Uint32 videoflags = SDL_SWSURFACE; + int done; SDL_Event event; - /* Initialize the SDL library */ - if ( SDL_Init(initflags) < 0 ) { - fprintf(stderr, "Couldn't initialize SDL: %s\n", - SDL_GetError()); - exit(1); - } + /* Initialize the SDL library */ + if ( SDL_Init(initflags) < 0 ) { + fprintf(stderr, "Couldn't initialize SDL: %s\n", + SDL_GetError()); + exit(1); + } - /* Set 640x480 video mode */ - screen=SDL_SetVideoMode(640,480, video_bpp, videoflags); + /* Set 640x480 video mode */ + screen=SDL_SetVideoMode(640,480, video_bpp, videoflags); if (screen == NULL) { - fprintf(stderr, "Couldn't set 640x480x%d video mode: %s\n", + fprintf(stderr, "Couldn't set 640x480x%d video mode: %s\n", video_bpp, SDL_GetError()); - SDL_Quit(); - exit(2); - } + SDL_Quit(); + exit(2); + } + + done = 0; + while ( !done ) { - done = 0; - while ( !done ) { + /* Check for events */ + while ( SDL_PollEvent(&event) ) { + switch (event.type) { - /* Check for events */ - while ( SDL_PollEvent(&event) ) { - switch (event.type) { + case SDL_MOUSEMOTION: + break; + case SDL_MOUSEBUTTONDOWN: + break; + case SDL_KEYDOWN: + /* Any keypress quits the app... */ + case SDL_QUIT: + done = 1; + break; + default: + break; + } + } + } - case SDL_MOUSEMOTION: - break; - case SDL_MOUSEBUTTONDOWN: - break; - case SDL_KEYDOWN: - /* Any keypress quits the app... */ - case SDL_QUIT: - done = 1; - break; - default: - break; - } - } - } - - /* Clean up the SDL library */ - SDL_Quit(); - return(0); + /* Clean up the SDL library */ + SDL_Quit(); + return(0); } diff --git a/Xcode/TemplatesForXcodeSnowLeopard/SDL Cocoa Application/main.c b/Xcode/TemplatesForXcodeSnowLeopard/SDL Cocoa Application/main.c index 7115de989..47af3765d 100644 --- a/Xcode/TemplatesForXcodeSnowLeopard/SDL Cocoa Application/main.c +++ b/Xcode/TemplatesForXcodeSnowLeopard/SDL Cocoa Application/main.c @@ -4,7 +4,7 @@ Please see the SDL documentation for details on using the SDL API: /Developer/Documentation/SDL/docs.html */ - + #include #include #include @@ -14,52 +14,52 @@ int main(int argc, char *argv[]) { - Uint32 initflags = SDL_INIT_VIDEO; /* See documentation for details */ - SDL_Surface *screen; - Uint8 video_bpp = 0; - Uint32 videoflags = SDL_SWSURFACE; - int done; + Uint32 initflags = SDL_INIT_VIDEO; /* See documentation for details */ + SDL_Surface *screen; + Uint8 video_bpp = 0; + Uint32 videoflags = SDL_SWSURFACE; + int done; SDL_Event event; - /* Initialize the SDL library */ - if ( SDL_Init(initflags) < 0 ) { - fprintf(stderr, "Couldn't initialize SDL: %s\n", - SDL_GetError()); - exit(1); - } + /* Initialize the SDL library */ + if ( SDL_Init(initflags) < 0 ) { + fprintf(stderr, "Couldn't initialize SDL: %s\n", + SDL_GetError()); + exit(1); + } - /* Set 640x480 video mode */ - screen=SDL_SetVideoMode(640,480, video_bpp, videoflags); + /* Set 640x480 video mode */ + screen=SDL_SetVideoMode(640,480, video_bpp, videoflags); if (screen == NULL) { - fprintf(stderr, "Couldn't set 640x480x%d video mode: %s\n", + fprintf(stderr, "Couldn't set 640x480x%d video mode: %s\n", video_bpp, SDL_GetError()); - SDL_Quit(); - exit(2); - } + SDL_Quit(); + exit(2); + } + + done = 0; + while ( !done ) { - done = 0; - while ( !done ) { + /* Check for events */ + while ( SDL_PollEvent(&event) ) { + switch (event.type) { - /* Check for events */ - while ( SDL_PollEvent(&event) ) { - switch (event.type) { + case SDL_MOUSEMOTION: + break; + case SDL_MOUSEBUTTONDOWN: + break; + case SDL_KEYDOWN: + /* Any keypress quits the app... */ + case SDL_QUIT: + done = 1; + break; + default: + break; + } + } + } - case SDL_MOUSEMOTION: - break; - case SDL_MOUSEBUTTONDOWN: - break; - case SDL_KEYDOWN: - /* Any keypress quits the app... */ - case SDL_QUIT: - done = 1; - break; - default: - break; - } - } - } - - /* Clean up the SDL library */ - SDL_Quit(); - return(0); + /* Clean up the SDL library */ + SDL_Quit(); + return(0); } diff --git a/Xcode/TemplatesForXcodeSnowLeopard/SDL OpenGL Application/atlantis/atlantis.c b/Xcode/TemplatesForXcodeSnowLeopard/SDL OpenGL Application/atlantis/atlantis.c index 4efdf6ce8..debed809d 100644 --- a/Xcode/TemplatesForXcodeSnowLeopard/SDL OpenGL Application/atlantis/atlantis.c +++ b/Xcode/TemplatesForXcodeSnowLeopard/SDL OpenGL Application/atlantis/atlantis.c @@ -63,37 +63,37 @@ static double mtime(void) { struct timeval tk_time; struct timezone tz; - + gettimeofday(&tk_time, &tz); - + return 4294.967296 * tk_time.tv_sec + 0.000001 * tk_time.tv_usec; } static double filter(double in, double *save) { - static double k1 = 0.9; - static double k2 = 0.05; + static double k1 = 0.9; + static double k2 = 0.05; - save[3] = in; - save[1] = save[0]*k1 + k2*(save[3] + save[2]); + save[3] = in; + save[1] = save[0]*k1 + k2*(save[3] + save[2]); - save[0]=save[1]; - save[2]=save[3]; + save[0]=save[1]; + save[2]=save[3]; - return(save[1]); + return(save[1]); } void DrawStr(const char *str) { - GLint i = 0; - - if(!str) return; - - while(str[i]) - { - glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, str[i]); - i++; - } + GLint i = 0; + + if(!str) return; + + while(str[i]) + { + glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, str[i]); + i++; + } } void @@ -168,9 +168,9 @@ Atlantis_Init(void) InitFishs(); glEnable(GL_FOG); - glFogi(GL_FOG_MODE, GL_EXP); - glFogf(GL_FOG_DENSITY, 0.0000025); - glFogfv(GL_FOG_COLOR, fog_color); + glFogi(GL_FOG_MODE, GL_EXP); + glFogf(GL_FOG_DENSITY, 0.0000025); + glFogfv(GL_FOG_COLOR, fog_color); glClearColor(0.0, 0.5, 0.9, 1.0); } @@ -178,9 +178,9 @@ Atlantis_Init(void) void Atlantis_Reshape(int width, int height) { - w_win = width; - h_win = height; - + w_win = width; + h_win = height; + glViewport(0, 0, width, height); glMatrixMode(GL_PROJECTION); @@ -212,37 +212,37 @@ Atlantis_Key(unsigned char key, int x, int y) { switch (key) { case 't': - Timing = !Timing; + Timing = !Timing; break; case ' ': - switch(StrMode) - { - case GL_EXTENSIONS: - StrMode = GL_VENDOR; - break; - case GL_VENDOR: - StrMode = GL_RENDERER; - break; - case GL_RENDERER: - StrMode = GL_VERSION; - break; - case GL_VERSION: - StrMode = GL_EXTENSIONS; - break; - } - break; + switch(StrMode) + { + case GL_EXTENSIONS: + StrMode = GL_VENDOR; + break; + case GL_VENDOR: + StrMode = GL_RENDERER; + break; + case GL_RENDERER: + StrMode = GL_VERSION; + break; + case GL_VERSION: + StrMode = GL_EXTENSIONS; + break; + } + break; case 27: /* Esc will quit */ exit(1); break; - case 's': /* "s" start animation */ + case 's': /* "s" start animation */ moving = GL_TRUE; //glutIdleFunc(Animate); break; - case 'a': /* "a" stop animation */ + case 'a': /* "a" stop animation */ moving = GL_FALSE; //glutIdleFunc(NULL); break; - case '.': /* "." will advance frame */ + case '.': /* "." will advance frame */ if (!moving) { Atlantis_Animate(); } @@ -251,21 +251,21 @@ Atlantis_Key(unsigned char key, int x, int y) /* void Display(void) { - static float P123[3] = {-448.94, -203.14, 9499.60}; - static float P124[3] = {-442.64, -185.20, 9528.07}; - static float P125[3] = {-441.07, -148.05, 9528.07}; - static float P126[3] = {-443.43, -128.84, 9499.60}; - static float P127[3] = {-456.87, -146.78, 9466.67}; - static float P128[3] = {-453.68, -183.93, 9466.67}; - - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - glPushMatrix(); + static float P123[3] = {-448.94, -203.14, 9499.60}; + static float P124[3] = {-442.64, -185.20, 9528.07}; + static float P125[3] = {-441.07, -148.05, 9528.07}; + static float P126[3] = {-443.43, -128.84, 9499.60}; + static float P127[3] = {-456.87, -146.78, 9466.67}; + static float P128[3] = {-453.68, -183.93, 9466.67}; + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glPushMatrix(); FishTransform(&dolph); DrawDolphin(&dolph); glPopMatrix(); - - glutSwapBuffers(); + + glutSwapBuffers(); } */ @@ -274,9 +274,9 @@ Atlantis_Display(void) { int i; static double th[4] = {0.0, 0.0, 0.0, 0.0}; - static double t1 = 0.0, t2 = 0.0, t; - char num_str[128]; - + static double t1 = 0.0, t2 = 0.0, t; + char num_str[128]; + t1 = t2; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -303,56 +303,56 @@ Atlantis_Display(void) glScalef(0.45, 0.45, 0.3); DrawWhale(&babyWhale); glPopMatrix(); - + if(Timing) { - t2 = mtime(); - t = t2 - t1; - if(t > 0.0001) t = 1.0 / t; - - glDisable(GL_LIGHTING); - //glDisable(GL_DEPTH_TEST); - - glColor3f(1.0, 0.0, 0.0); - - glMatrixMode (GL_PROJECTION); - glPushMatrix(); - glLoadIdentity(); - glOrtho(0, w_win, 0, h_win, -10.0, 10.0); - - glRasterPos2f(5.0, 5.0); - - switch(StrMode) - { - case GL_VENDOR: - sprintf(num_str, "%0.2f Hz, %dx%d, VENDOR: ", filter(t, th), w_win, h_win); - DrawStr(num_str); - DrawStr(glGetString(GL_VENDOR)); - break; - case GL_RENDERER: - sprintf(num_str, "%0.2f Hz, %dx%d, RENDERER: ", filter(t, th), w_win, h_win); - DrawStr(num_str); - DrawStr(glGetString(GL_RENDERER)); - break; - case GL_VERSION: - sprintf(num_str, "%0.2f Hz, %dx%d, VERSION: ", filter(t, th), w_win, h_win); - DrawStr(num_str); - DrawStr(glGetString(GL_VERSION)); - break; - case GL_EXTENSIONS: - sprintf(num_str, "%0.2f Hz, %dx%d, EXTENSIONS: ", filter(t, th), w_win, h_win); - DrawStr(num_str); - DrawStr(glGetString(GL_EXTENSIONS)); - break; - } - - glPopMatrix(); - glMatrixMode(GL_MODELVIEW); - - glEnable(GL_LIGHTING); - //glEnable(GL_DEPTH_TEST); - } - + t2 = mtime(); + t = t2 - t1; + if(t > 0.0001) t = 1.0 / t; + + glDisable(GL_LIGHTING); + //glDisable(GL_DEPTH_TEST); + + glColor3f(1.0, 0.0, 0.0); + + glMatrixMode (GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + glOrtho(0, w_win, 0, h_win, -10.0, 10.0); + + glRasterPos2f(5.0, 5.0); + + switch(StrMode) + { + case GL_VENDOR: + sprintf(num_str, "%0.2f Hz, %dx%d, VENDOR: ", filter(t, th), w_win, h_win); + DrawStr(num_str); + DrawStr(glGetString(GL_VENDOR)); + break; + case GL_RENDERER: + sprintf(num_str, "%0.2f Hz, %dx%d, RENDERER: ", filter(t, th), w_win, h_win); + DrawStr(num_str); + DrawStr(glGetString(GL_RENDERER)); + break; + case GL_VERSION: + sprintf(num_str, "%0.2f Hz, %dx%d, VERSION: ", filter(t, th), w_win, h_win); + DrawStr(num_str); + DrawStr(glGetString(GL_VERSION)); + break; + case GL_EXTENSIONS: + sprintf(num_str, "%0.2f Hz, %dx%d, EXTENSIONS: ", filter(t, th), w_win, h_win); + DrawStr(num_str); + DrawStr(glGetString(GL_EXTENSIONS)); + break; + } + + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); + + glEnable(GL_LIGHTING); + //glEnable(GL_DEPTH_TEST); + } + count++; glutSwapBuffers(); @@ -377,18 +377,18 @@ timingSelect(int value) { switch(value) { - case 1: - StrMode = GL_VENDOR; - break; - case 2: - StrMode = GL_RENDERER; - break; - case 3: - StrMode = GL_VERSION; - break; - case 4: - StrMode = GL_EXTENSIONS; - break; + case 1: + StrMode = GL_VENDOR; + break; + case 2: + StrMode = GL_RENDERER; + break; + case 3: + StrMode = GL_VERSION; + break; + case 4: + StrMode = GL_EXTENSIONS; + break; } } @@ -413,24 +413,24 @@ menuSelect(int value) int main(int argc, char **argv) { - GLboolean fullscreen = GL_FALSE; - GLint time_menu; - - srand(0); + GLboolean fullscreen = GL_FALSE; + GLint time_menu; + + srand(0); glutInit(&argc, argv); - if (argc > 1 && !strcmp(argv[1], "-w")) - fullscreen = GL_FALSE; - - //glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH); - glutInitDisplayString("rgba double depth=24"); - if (fullscreen) { - glutGameModeString("1024x768:32"); - glutEnterGameMode(); - } else { - glutInitWindowSize(320, 240); - glutCreateWindow("Atlantis Timing"); - } + if (argc > 1 && !strcmp(argv[1], "-w")) + fullscreen = GL_FALSE; + + //glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH); + glutInitDisplayString("rgba double depth=24"); + if (fullscreen) { + glutGameModeString("1024x768:32"); + glutEnterGameMode(); + } else { + glutInitWindowSize(320, 240); + glutCreateWindow("Atlantis Timing"); + } Init(); glutDisplayFunc(Display); glutReshapeFunc(Reshape); @@ -438,19 +438,19 @@ main(int argc, char **argv) moving = GL_TRUE; glutIdleFunc(Animate); glutVisibilityFunc(Visible); - + time_menu = glutCreateMenu(timingSelect); glutAddMenuEntry("GL_VENDOR", 1); glutAddMenuEntry("GL_RENDERER", 2); glutAddMenuEntry("GL_VERSION", 3); glutAddMenuEntry("GL_EXTENSIONS", 4); - + glutCreateMenu(menuSelect); glutAddMenuEntry("Start motion", 1); glutAddMenuEntry("Stop motion", 2); glutAddSubMenu("Timing Mode", time_menu); glutAddMenuEntry("Quit", 4); - + //glutAttachMenu(GLUT_RIGHT_BUTTON); glutAttachMenu(GLUT_RIGHT_BUTTON); glutMainLoop(); diff --git a/Xcode/TemplatesForXcodeSnowLeopard/SDL OpenGL Application/main.c b/Xcode/TemplatesForXcodeSnowLeopard/SDL OpenGL Application/main.c index 1ef49c0c9..3bc4d33b1 100644 --- a/Xcode/TemplatesForXcodeSnowLeopard/SDL OpenGL Application/main.c +++ b/Xcode/TemplatesForXcodeSnowLeopard/SDL OpenGL Application/main.c @@ -4,7 +4,7 @@ Please see the SDL documentation for details on using the SDL API: /Developer/Documentation/SDL/docs.html */ - + #include #include #include @@ -22,18 +22,18 @@ static SDL_Surface *gScreen; static void initAttributes () { // Setup attributes we want for the OpenGL context - + int value; - + // Don't set color bit sizes (SDL_GL_RED_SIZE, etc) // Mac OS X will always use 8-8-8-8 ARGB for 32-bit screens and // 5-5-5 RGB for 16-bit screens - + // Request a 16-bit depth buffer (without this, there is no depth buffer) value = 16; SDL_GL_SetAttribute (SDL_GL_DEPTH_SIZE, value); - - + + // Request double-buffered OpenGL // The fact that windows are double-buffered on Mac OS X has no effect // on OpenGL double buffering. @@ -46,36 +46,36 @@ static void printAttributes () // Print out attributes of the context we created int nAttr; int i; - + int attr[] = { SDL_GL_RED_SIZE, SDL_GL_BLUE_SIZE, SDL_GL_GREEN_SIZE, SDL_GL_ALPHA_SIZE, SDL_GL_BUFFER_SIZE, SDL_GL_DEPTH_SIZE }; - + char *desc[] = { "Red size: %d bits\n", "Blue size: %d bits\n", "Green size: %d bits\n", - "Alpha size: %d bits\n", "Color buffer size: %d bits\n", + "Alpha size: %d bits\n", "Color buffer size: %d bits\n", "Depth bufer size: %d bits\n" }; nAttr = sizeof(attr) / sizeof(int); - + for (i = 0; i < nAttr; i++) { - + int value; SDL_GL_GetAttribute (attr[i], &value); printf (desc[i], value); - } + } } static void createSurface (int fullscreen) { Uint32 flags = 0; - + flags = SDL_OPENGL; if (fullscreen) flags |= SDL_FULLSCREEN; - + // Create window gScreen = SDL_SetVideoMode (640, 480, 0, flags); if (gScreen == NULL) { - + fprintf (stderr, "Couldn't set 640x480 OpenGL video mode: %s\n", SDL_GetError()); SDL_Quit(); @@ -103,7 +103,7 @@ static void mainLoop () int delay = 1000/fps; int thenTicks = -1; int nowTicks; - + while ( !done ) { /* Check for events */ @@ -123,7 +123,7 @@ static void mainLoop () break; } } - + // Draw at 24 hz // This approach is not normally recommended - it is better to // use time-based animation and run as fast as possible @@ -151,7 +151,7 @@ int main(int argc, char *argv[]) { // Init SDL video subsystem if ( SDL_Init (SDL_INIT_VIDEO) < 0 ) { - + fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); exit(1); @@ -159,19 +159,19 @@ int main(int argc, char *argv[]) // Set GL context attributes initAttributes (); - + // Create GL context createSurface (0); - + // Get GL context attributes printAttributes (); - + // Init GL state initGL (); - + // Draw, get events... mainLoop (); - + // Cleanup SDL_Quit(); diff --git a/Xcode/TemplatesForXcodeTiger/SDL Application/main.c b/Xcode/TemplatesForXcodeTiger/SDL Application/main.c index 7115de989..47af3765d 100644 --- a/Xcode/TemplatesForXcodeTiger/SDL Application/main.c +++ b/Xcode/TemplatesForXcodeTiger/SDL Application/main.c @@ -4,7 +4,7 @@ Please see the SDL documentation for details on using the SDL API: /Developer/Documentation/SDL/docs.html */ - + #include #include #include @@ -14,52 +14,52 @@ int main(int argc, char *argv[]) { - Uint32 initflags = SDL_INIT_VIDEO; /* See documentation for details */ - SDL_Surface *screen; - Uint8 video_bpp = 0; - Uint32 videoflags = SDL_SWSURFACE; - int done; + Uint32 initflags = SDL_INIT_VIDEO; /* See documentation for details */ + SDL_Surface *screen; + Uint8 video_bpp = 0; + Uint32 videoflags = SDL_SWSURFACE; + int done; SDL_Event event; - /* Initialize the SDL library */ - if ( SDL_Init(initflags) < 0 ) { - fprintf(stderr, "Couldn't initialize SDL: %s\n", - SDL_GetError()); - exit(1); - } + /* Initialize the SDL library */ + if ( SDL_Init(initflags) < 0 ) { + fprintf(stderr, "Couldn't initialize SDL: %s\n", + SDL_GetError()); + exit(1); + } - /* Set 640x480 video mode */ - screen=SDL_SetVideoMode(640,480, video_bpp, videoflags); + /* Set 640x480 video mode */ + screen=SDL_SetVideoMode(640,480, video_bpp, videoflags); if (screen == NULL) { - fprintf(stderr, "Couldn't set 640x480x%d video mode: %s\n", + fprintf(stderr, "Couldn't set 640x480x%d video mode: %s\n", video_bpp, SDL_GetError()); - SDL_Quit(); - exit(2); - } + SDL_Quit(); + exit(2); + } + + done = 0; + while ( !done ) { - done = 0; - while ( !done ) { + /* Check for events */ + while ( SDL_PollEvent(&event) ) { + switch (event.type) { - /* Check for events */ - while ( SDL_PollEvent(&event) ) { - switch (event.type) { + case SDL_MOUSEMOTION: + break; + case SDL_MOUSEBUTTONDOWN: + break; + case SDL_KEYDOWN: + /* Any keypress quits the app... */ + case SDL_QUIT: + done = 1; + break; + default: + break; + } + } + } - case SDL_MOUSEMOTION: - break; - case SDL_MOUSEBUTTONDOWN: - break; - case SDL_KEYDOWN: - /* Any keypress quits the app... */ - case SDL_QUIT: - done = 1; - break; - default: - break; - } - } - } - - /* Clean up the SDL library */ - SDL_Quit(); - return(0); + /* Clean up the SDL library */ + SDL_Quit(); + return(0); } diff --git a/Xcode/TemplatesForXcodeTiger/SDL Cocoa Application/main.c b/Xcode/TemplatesForXcodeTiger/SDL Cocoa Application/main.c index 7115de989..47af3765d 100644 --- a/Xcode/TemplatesForXcodeTiger/SDL Cocoa Application/main.c +++ b/Xcode/TemplatesForXcodeTiger/SDL Cocoa Application/main.c @@ -4,7 +4,7 @@ Please see the SDL documentation for details on using the SDL API: /Developer/Documentation/SDL/docs.html */ - + #include #include #include @@ -14,52 +14,52 @@ int main(int argc, char *argv[]) { - Uint32 initflags = SDL_INIT_VIDEO; /* See documentation for details */ - SDL_Surface *screen; - Uint8 video_bpp = 0; - Uint32 videoflags = SDL_SWSURFACE; - int done; + Uint32 initflags = SDL_INIT_VIDEO; /* See documentation for details */ + SDL_Surface *screen; + Uint8 video_bpp = 0; + Uint32 videoflags = SDL_SWSURFACE; + int done; SDL_Event event; - /* Initialize the SDL library */ - if ( SDL_Init(initflags) < 0 ) { - fprintf(stderr, "Couldn't initialize SDL: %s\n", - SDL_GetError()); - exit(1); - } + /* Initialize the SDL library */ + if ( SDL_Init(initflags) < 0 ) { + fprintf(stderr, "Couldn't initialize SDL: %s\n", + SDL_GetError()); + exit(1); + } - /* Set 640x480 video mode */ - screen=SDL_SetVideoMode(640,480, video_bpp, videoflags); + /* Set 640x480 video mode */ + screen=SDL_SetVideoMode(640,480, video_bpp, videoflags); if (screen == NULL) { - fprintf(stderr, "Couldn't set 640x480x%d video mode: %s\n", + fprintf(stderr, "Couldn't set 640x480x%d video mode: %s\n", video_bpp, SDL_GetError()); - SDL_Quit(); - exit(2); - } + SDL_Quit(); + exit(2); + } + + done = 0; + while ( !done ) { - done = 0; - while ( !done ) { + /* Check for events */ + while ( SDL_PollEvent(&event) ) { + switch (event.type) { - /* Check for events */ - while ( SDL_PollEvent(&event) ) { - switch (event.type) { + case SDL_MOUSEMOTION: + break; + case SDL_MOUSEBUTTONDOWN: + break; + case SDL_KEYDOWN: + /* Any keypress quits the app... */ + case SDL_QUIT: + done = 1; + break; + default: + break; + } + } + } - case SDL_MOUSEMOTION: - break; - case SDL_MOUSEBUTTONDOWN: - break; - case SDL_KEYDOWN: - /* Any keypress quits the app... */ - case SDL_QUIT: - done = 1; - break; - default: - break; - } - } - } - - /* Clean up the SDL library */ - SDL_Quit(); - return(0); + /* Clean up the SDL library */ + SDL_Quit(); + return(0); } diff --git a/Xcode/TemplatesForXcodeTiger/SDL OpenGL Application/atlantis/atlantis.c b/Xcode/TemplatesForXcodeTiger/SDL OpenGL Application/atlantis/atlantis.c index 4efdf6ce8..debed809d 100644 --- a/Xcode/TemplatesForXcodeTiger/SDL OpenGL Application/atlantis/atlantis.c +++ b/Xcode/TemplatesForXcodeTiger/SDL OpenGL Application/atlantis/atlantis.c @@ -63,37 +63,37 @@ static double mtime(void) { struct timeval tk_time; struct timezone tz; - + gettimeofday(&tk_time, &tz); - + return 4294.967296 * tk_time.tv_sec + 0.000001 * tk_time.tv_usec; } static double filter(double in, double *save) { - static double k1 = 0.9; - static double k2 = 0.05; + static double k1 = 0.9; + static double k2 = 0.05; - save[3] = in; - save[1] = save[0]*k1 + k2*(save[3] + save[2]); + save[3] = in; + save[1] = save[0]*k1 + k2*(save[3] + save[2]); - save[0]=save[1]; - save[2]=save[3]; + save[0]=save[1]; + save[2]=save[3]; - return(save[1]); + return(save[1]); } void DrawStr(const char *str) { - GLint i = 0; - - if(!str) return; - - while(str[i]) - { - glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, str[i]); - i++; - } + GLint i = 0; + + if(!str) return; + + while(str[i]) + { + glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, str[i]); + i++; + } } void @@ -168,9 +168,9 @@ Atlantis_Init(void) InitFishs(); glEnable(GL_FOG); - glFogi(GL_FOG_MODE, GL_EXP); - glFogf(GL_FOG_DENSITY, 0.0000025); - glFogfv(GL_FOG_COLOR, fog_color); + glFogi(GL_FOG_MODE, GL_EXP); + glFogf(GL_FOG_DENSITY, 0.0000025); + glFogfv(GL_FOG_COLOR, fog_color); glClearColor(0.0, 0.5, 0.9, 1.0); } @@ -178,9 +178,9 @@ Atlantis_Init(void) void Atlantis_Reshape(int width, int height) { - w_win = width; - h_win = height; - + w_win = width; + h_win = height; + glViewport(0, 0, width, height); glMatrixMode(GL_PROJECTION); @@ -212,37 +212,37 @@ Atlantis_Key(unsigned char key, int x, int y) { switch (key) { case 't': - Timing = !Timing; + Timing = !Timing; break; case ' ': - switch(StrMode) - { - case GL_EXTENSIONS: - StrMode = GL_VENDOR; - break; - case GL_VENDOR: - StrMode = GL_RENDERER; - break; - case GL_RENDERER: - StrMode = GL_VERSION; - break; - case GL_VERSION: - StrMode = GL_EXTENSIONS; - break; - } - break; + switch(StrMode) + { + case GL_EXTENSIONS: + StrMode = GL_VENDOR; + break; + case GL_VENDOR: + StrMode = GL_RENDERER; + break; + case GL_RENDERER: + StrMode = GL_VERSION; + break; + case GL_VERSION: + StrMode = GL_EXTENSIONS; + break; + } + break; case 27: /* Esc will quit */ exit(1); break; - case 's': /* "s" start animation */ + case 's': /* "s" start animation */ moving = GL_TRUE; //glutIdleFunc(Animate); break; - case 'a': /* "a" stop animation */ + case 'a': /* "a" stop animation */ moving = GL_FALSE; //glutIdleFunc(NULL); break; - case '.': /* "." will advance frame */ + case '.': /* "." will advance frame */ if (!moving) { Atlantis_Animate(); } @@ -251,21 +251,21 @@ Atlantis_Key(unsigned char key, int x, int y) /* void Display(void) { - static float P123[3] = {-448.94, -203.14, 9499.60}; - static float P124[3] = {-442.64, -185.20, 9528.07}; - static float P125[3] = {-441.07, -148.05, 9528.07}; - static float P126[3] = {-443.43, -128.84, 9499.60}; - static float P127[3] = {-456.87, -146.78, 9466.67}; - static float P128[3] = {-453.68, -183.93, 9466.67}; - - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - glPushMatrix(); + static float P123[3] = {-448.94, -203.14, 9499.60}; + static float P124[3] = {-442.64, -185.20, 9528.07}; + static float P125[3] = {-441.07, -148.05, 9528.07}; + static float P126[3] = {-443.43, -128.84, 9499.60}; + static float P127[3] = {-456.87, -146.78, 9466.67}; + static float P128[3] = {-453.68, -183.93, 9466.67}; + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glPushMatrix(); FishTransform(&dolph); DrawDolphin(&dolph); glPopMatrix(); - - glutSwapBuffers(); + + glutSwapBuffers(); } */ @@ -274,9 +274,9 @@ Atlantis_Display(void) { int i; static double th[4] = {0.0, 0.0, 0.0, 0.0}; - static double t1 = 0.0, t2 = 0.0, t; - char num_str[128]; - + static double t1 = 0.0, t2 = 0.0, t; + char num_str[128]; + t1 = t2; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -303,56 +303,56 @@ Atlantis_Display(void) glScalef(0.45, 0.45, 0.3); DrawWhale(&babyWhale); glPopMatrix(); - + if(Timing) { - t2 = mtime(); - t = t2 - t1; - if(t > 0.0001) t = 1.0 / t; - - glDisable(GL_LIGHTING); - //glDisable(GL_DEPTH_TEST); - - glColor3f(1.0, 0.0, 0.0); - - glMatrixMode (GL_PROJECTION); - glPushMatrix(); - glLoadIdentity(); - glOrtho(0, w_win, 0, h_win, -10.0, 10.0); - - glRasterPos2f(5.0, 5.0); - - switch(StrMode) - { - case GL_VENDOR: - sprintf(num_str, "%0.2f Hz, %dx%d, VENDOR: ", filter(t, th), w_win, h_win); - DrawStr(num_str); - DrawStr(glGetString(GL_VENDOR)); - break; - case GL_RENDERER: - sprintf(num_str, "%0.2f Hz, %dx%d, RENDERER: ", filter(t, th), w_win, h_win); - DrawStr(num_str); - DrawStr(glGetString(GL_RENDERER)); - break; - case GL_VERSION: - sprintf(num_str, "%0.2f Hz, %dx%d, VERSION: ", filter(t, th), w_win, h_win); - DrawStr(num_str); - DrawStr(glGetString(GL_VERSION)); - break; - case GL_EXTENSIONS: - sprintf(num_str, "%0.2f Hz, %dx%d, EXTENSIONS: ", filter(t, th), w_win, h_win); - DrawStr(num_str); - DrawStr(glGetString(GL_EXTENSIONS)); - break; - } - - glPopMatrix(); - glMatrixMode(GL_MODELVIEW); - - glEnable(GL_LIGHTING); - //glEnable(GL_DEPTH_TEST); - } - + t2 = mtime(); + t = t2 - t1; + if(t > 0.0001) t = 1.0 / t; + + glDisable(GL_LIGHTING); + //glDisable(GL_DEPTH_TEST); + + glColor3f(1.0, 0.0, 0.0); + + glMatrixMode (GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + glOrtho(0, w_win, 0, h_win, -10.0, 10.0); + + glRasterPos2f(5.0, 5.0); + + switch(StrMode) + { + case GL_VENDOR: + sprintf(num_str, "%0.2f Hz, %dx%d, VENDOR: ", filter(t, th), w_win, h_win); + DrawStr(num_str); + DrawStr(glGetString(GL_VENDOR)); + break; + case GL_RENDERER: + sprintf(num_str, "%0.2f Hz, %dx%d, RENDERER: ", filter(t, th), w_win, h_win); + DrawStr(num_str); + DrawStr(glGetString(GL_RENDERER)); + break; + case GL_VERSION: + sprintf(num_str, "%0.2f Hz, %dx%d, VERSION: ", filter(t, th), w_win, h_win); + DrawStr(num_str); + DrawStr(glGetString(GL_VERSION)); + break; + case GL_EXTENSIONS: + sprintf(num_str, "%0.2f Hz, %dx%d, EXTENSIONS: ", filter(t, th), w_win, h_win); + DrawStr(num_str); + DrawStr(glGetString(GL_EXTENSIONS)); + break; + } + + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); + + glEnable(GL_LIGHTING); + //glEnable(GL_DEPTH_TEST); + } + count++; glutSwapBuffers(); @@ -377,18 +377,18 @@ timingSelect(int value) { switch(value) { - case 1: - StrMode = GL_VENDOR; - break; - case 2: - StrMode = GL_RENDERER; - break; - case 3: - StrMode = GL_VERSION; - break; - case 4: - StrMode = GL_EXTENSIONS; - break; + case 1: + StrMode = GL_VENDOR; + break; + case 2: + StrMode = GL_RENDERER; + break; + case 3: + StrMode = GL_VERSION; + break; + case 4: + StrMode = GL_EXTENSIONS; + break; } } @@ -413,24 +413,24 @@ menuSelect(int value) int main(int argc, char **argv) { - GLboolean fullscreen = GL_FALSE; - GLint time_menu; - - srand(0); + GLboolean fullscreen = GL_FALSE; + GLint time_menu; + + srand(0); glutInit(&argc, argv); - if (argc > 1 && !strcmp(argv[1], "-w")) - fullscreen = GL_FALSE; - - //glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH); - glutInitDisplayString("rgba double depth=24"); - if (fullscreen) { - glutGameModeString("1024x768:32"); - glutEnterGameMode(); - } else { - glutInitWindowSize(320, 240); - glutCreateWindow("Atlantis Timing"); - } + if (argc > 1 && !strcmp(argv[1], "-w")) + fullscreen = GL_FALSE; + + //glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH); + glutInitDisplayString("rgba double depth=24"); + if (fullscreen) { + glutGameModeString("1024x768:32"); + glutEnterGameMode(); + } else { + glutInitWindowSize(320, 240); + glutCreateWindow("Atlantis Timing"); + } Init(); glutDisplayFunc(Display); glutReshapeFunc(Reshape); @@ -438,19 +438,19 @@ main(int argc, char **argv) moving = GL_TRUE; glutIdleFunc(Animate); glutVisibilityFunc(Visible); - + time_menu = glutCreateMenu(timingSelect); glutAddMenuEntry("GL_VENDOR", 1); glutAddMenuEntry("GL_RENDERER", 2); glutAddMenuEntry("GL_VERSION", 3); glutAddMenuEntry("GL_EXTENSIONS", 4); - + glutCreateMenu(menuSelect); glutAddMenuEntry("Start motion", 1); glutAddMenuEntry("Stop motion", 2); glutAddSubMenu("Timing Mode", time_menu); glutAddMenuEntry("Quit", 4); - + //glutAttachMenu(GLUT_RIGHT_BUTTON); glutAttachMenu(GLUT_RIGHT_BUTTON); glutMainLoop(); diff --git a/Xcode/TemplatesForXcodeTiger/SDL OpenGL Application/main.c b/Xcode/TemplatesForXcodeTiger/SDL OpenGL Application/main.c index b7794b3b6..3bc4d33b1 100644 --- a/Xcode/TemplatesForXcodeTiger/SDL OpenGL Application/main.c +++ b/Xcode/TemplatesForXcodeTiger/SDL OpenGL Application/main.c @@ -4,7 +4,7 @@ Please see the SDL documentation for details on using the SDL API: /Developer/Documentation/SDL/docs.html */ - + #include #include #include @@ -22,18 +22,18 @@ static SDL_Surface *gScreen; static void initAttributes () { // Setup attributes we want for the OpenGL context - + int value; - + // Don't set color bit sizes (SDL_GL_RED_SIZE, etc) // Mac OS X will always use 8-8-8-8 ARGB for 32-bit screens and // 5-5-5 RGB for 16-bit screens - + // Request a 16-bit depth buffer (without this, there is no depth buffer) value = 16; SDL_GL_SetAttribute (SDL_GL_DEPTH_SIZE, value); - - + + // Request double-buffered OpenGL // The fact that windows are double-buffered on Mac OS X has no effect // on OpenGL double buffering. @@ -46,41 +46,41 @@ static void printAttributes () // Print out attributes of the context we created int nAttr; int i; - + int attr[] = { SDL_GL_RED_SIZE, SDL_GL_BLUE_SIZE, SDL_GL_GREEN_SIZE, SDL_GL_ALPHA_SIZE, SDL_GL_BUFFER_SIZE, SDL_GL_DEPTH_SIZE }; - + char *desc[] = { "Red size: %d bits\n", "Blue size: %d bits\n", "Green size: %d bits\n", - "Alpha size: %d bits\n", "Color buffer size: %d bits\n", + "Alpha size: %d bits\n", "Color buffer size: %d bits\n", "Depth bufer size: %d bits\n" }; nAttr = sizeof(attr) / sizeof(int); - + for (i = 0; i < nAttr; i++) { - + int value; SDL_GL_GetAttribute (attr[i], &value); printf (desc[i], value); - } + } } static void createSurface (int fullscreen) { Uint32 flags = 0; - + flags = SDL_OPENGL; if (fullscreen) flags |= SDL_FULLSCREEN; - + // Create window gScreen = SDL_SetVideoMode (640, 480, 0, flags); if (gScreen == NULL) { - + fprintf (stderr, "Couldn't set 640x480 OpenGL video mode: %s\n", SDL_GetError()); - SDL_Quit(); - exit(2); - } + SDL_Quit(); + exit(2); + } } static void initGL () @@ -100,30 +100,30 @@ static void mainLoop () SDL_Event event; int done = 0; int fps = 24; - int delay = 1000/fps; + int delay = 1000/fps; int thenTicks = -1; int nowTicks; - + while ( !done ) { - /* Check for events */ - while ( SDL_PollEvent (&event) ) { - switch (event.type) { - - case SDL_MOUSEMOTION: - break; - case SDL_MOUSEBUTTONDOWN: - break; - case SDL_KEYDOWN: - /* Any keypress quits the app... */ - case SDL_QUIT: - done = 1; - break; - default: - break; - } - } - + /* Check for events */ + while ( SDL_PollEvent (&event) ) { + switch (event.type) { + + case SDL_MOUSEMOTION: + break; + case SDL_MOUSEBUTTONDOWN: + break; + case SDL_KEYDOWN: + /* Any keypress quits the app... */ + case SDL_QUIT: + done = 1; + break; + default: + break; + } + } + // Draw at 24 hz // This approach is not normally recommended - it is better to // use time-based animation and run as fast as possible @@ -144,36 +144,36 @@ static void mainLoop () } SDL_Delay (delay); - } + } } int main(int argc, char *argv[]) { - // Init SDL video subsystem - if ( SDL_Init (SDL_INIT_VIDEO) < 0 ) { - + // Init SDL video subsystem + if ( SDL_Init (SDL_INIT_VIDEO) < 0 ) { + fprintf(stderr, "Couldn't initialize SDL: %s\n", - SDL_GetError()); - exit(1); - } + SDL_GetError()); + exit(1); + } // Set GL context attributes initAttributes (); - + // Create GL context createSurface (0); - + // Get GL context attributes printAttributes (); - + // Init GL state initGL (); - + // Draw, get events... mainLoop (); - + // Cleanup - SDL_Quit(); - + SDL_Quit(); + return 0; } diff --git a/include/SDL.h b/include/SDL.h index 0cfcdc71a..878ab1d3c 100644 --- a/include/SDL.h +++ b/include/SDL.h @@ -21,42 +21,42 @@ /** * \file SDL.h - * + * * Main include header for the SDL library */ /** * \mainpage Simple DirectMedia Layer (SDL) - * + * * http://www.libsdl.org/ - * + * * \section intro_sec Introduction - * + * * This is the Simple DirectMedia Layer, a general API that provides low * level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL, * and 2D framebuffer across multiple platforms. - * + * * SDL is written in C, but works with C++ natively, and has bindings to * several other languages, including Ada, C#, Eiffel, Erlang, Euphoria, * Guile, Haskell, Java, Lisp, Lua, ML, Objective C, Pascal, Perl, PHP, * Pike, Pliant, Python, Ruby, and Smalltalk. - * + * * This library is distributed under the zlib license, which can be * found in the file "COPYING". This license allows you to use SDL * freely for any purpose as long as you retain the copyright notice. - * + * * The best way to learn how to use SDL is to check out the header files in * the "include" subdirectory and the programs in the "test" subdirectory. * The header files and test programs are well commented and always up to date. * More documentation and FAQs are available online at: - * http://wiki.libsdl.org/ - * + * http://wiki.libsdl.org/ + * * If you need help with the library, or just want to discuss SDL related * issues, you can join the developers mailing list: - * http://www.libsdl.org/mailing-list.php - * + * http://www.libsdl.org/mailing-list.php + * * Enjoy! - * Sam Lantinga (slouken@libsdl.org) + * Sam Lantinga (slouken@libsdl.org) */ #ifndef _SDL_H @@ -92,16 +92,14 @@ #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ extern "C" { -/* *INDENT-ON* */ #endif /* As of version 0.5, SDL is loaded dynamically into the application */ /** * \name SDL_INIT_* - * + * * These are the flags which may be passed to SDL_Init(). You should * specify the subsystems which you will be using in your application. */ @@ -111,7 +109,7 @@ extern "C" { #define SDL_INIT_VIDEO 0x00000020 #define SDL_INIT_JOYSTICK 0x00000200 #define SDL_INIT_HAPTIC 0x00001000 -#define SDL_INIT_GAMECONTROLLER 0x00002000 /**< turn on game controller also implicitly does JOYSTICK */ +#define SDL_INIT_GAMECONTROLLER 0x00002000 /**< turn on game controller also implicitly does JOYSTICK */ #define SDL_INIT_NOPARACHUTE 0x00100000 /**< Don't catch fatal signals */ #define SDL_INIT_EVERYTHING ( \ SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO | \ @@ -139,7 +137,7 @@ extern DECLSPEC void SDLCALL SDL_QuitSubSystem(Uint32 flags); /** * This function returns a mask of the specified subsystems which have * previously been initialized. - * + * * If \c flags is 0, it returns a mask of all initialized subsystems. */ extern DECLSPEC Uint32 SDLCALL SDL_WasInit(Uint32 flags); @@ -152,9 +150,7 @@ extern DECLSPEC void SDLCALL SDL_Quit(void); /* Ends C function definitions when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ } -/* *INDENT-ON* */ #endif #include "close_code.h" diff --git a/include/SDL_assert.h b/include/SDL_assert.h index e4620aee2..5a6afc5e2 100644 --- a/include/SDL_assert.h +++ b/include/SDL_assert.h @@ -27,9 +27,7 @@ #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ extern "C" { -/* *INDENT-ON* */ #endif #ifndef SDL_ASSERT_LEVEL @@ -187,7 +185,7 @@ typedef SDL_assert_state (SDLCALL *SDL_AssertionHandler)( * This callback is NOT reset to SDL's internal handler upon SDL_Quit()! * * \return SDL_assert_state value of how to handle the assertion failure. - * + * * \param handler Callback function, called when an assertion fails. * \param userdata A pointer passed to the callback as-is. */ @@ -230,9 +228,7 @@ extern DECLSPEC void SDLCALL SDL_ResetAssertionReport(void); /* Ends C function definitions when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ } -/* *INDENT-ON* */ #endif #include "close_code.h" diff --git a/include/SDL_atomic.h b/include/SDL_atomic.h index be60f9916..78498ff9d 100644 --- a/include/SDL_atomic.h +++ b/include/SDL_atomic.h @@ -21,25 +21,25 @@ /** * \file SDL_atomic.h - * + * * Atomic operations. - * + * * IMPORTANT: * If you are not an expert in concurrent lockless programming, you should * only be using the atomic lock and reference counting functions in this * file. In all other cases you should be protecting your data structures * with full mutexes. - * + * * The list of "safe" functions to use are: * SDL_AtomicLock() * SDL_AtomicUnlock() * SDL_AtomicIncRef() * SDL_AtomicDecRef() - * + * * Seriously, here be dragons! * ^^^^^^^^^^^^^^^^^^^^^^^^^^^ * - * You can find out a little more about lockless programming and the + * You can find out a little more about lockless programming and the * subtle issues that can arise here: * http://msdn.microsoft.com/en-us/library/ee418650%28v=vs.85%29.aspx * @@ -72,14 +72,12 @@ /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ extern "C" { -/* *INDENT-ON* */ #endif /** * \name SDL AtomicLock - * + * * The atomic locks are efficient spinlocks using CPU instructions, * but are vulnerable to starvation and can spin forever if a thread * holding a lock has been terminated. For this reason you should @@ -98,7 +96,7 @@ typedef int SDL_SpinLock; /** * \brief Try to lock a spin lock by setting it to a non-zero value. - * + * * \param lock Points to the lock. * * \return SDL_TRUE if the lock succeeded, SDL_FALSE if the lock is already held. @@ -107,7 +105,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_AtomicTryLock(SDL_SpinLock *lock); /** * \brief Lock a spin lock by setting it to a non-zero value. - * + * * \param lock Points to the lock. */ extern DECLSPEC void SDLCALL SDL_AtomicLock(SDL_SpinLock *lock); @@ -304,9 +302,7 @@ SDL_FORCE_INLINE void* SDL_AtomicGetPtr(void* *a) /* Ends C function definitions when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ } -/* *INDENT-ON* */ #endif #include "close_code.h" diff --git a/include/SDL_audio.h b/include/SDL_audio.h index 8a1bb7067..9e5a997ae 100644 --- a/include/SDL_audio.h +++ b/include/SDL_audio.h @@ -21,7 +21,7 @@ /** * \file SDL_audio.h - * + * * Access to the raw audio mixing buffer for the SDL library. */ @@ -38,17 +38,15 @@ #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ extern "C" { -/* *INDENT-ON* */ #endif /** * \brief Audio format flags. - * + * * These are what the 16 bits in SDL_AudioFormat currently mean... * (Unspecified bits are always zero). - * + * * \verbatim ++-----------------------sample is signed if set || @@ -60,7 +58,7 @@ extern "C" { || || || | | 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00 \endverbatim - * + * * There are macros in SDL 2.0 and later to query these bits. */ typedef Uint16 SDL_AudioFormat; @@ -82,42 +80,38 @@ typedef Uint16 SDL_AudioFormat; #define SDL_AUDIO_ISLITTLEENDIAN(x) (!SDL_AUDIO_ISBIGENDIAN(x)) #define SDL_AUDIO_ISUNSIGNED(x) (!SDL_AUDIO_ISSIGNED(x)) -/** +/** * \name Audio format flags * * Defaults to LSB byte order. */ /*@{*/ -#define AUDIO_U8 0x0008 /**< Unsigned 8-bit samples */ -#define AUDIO_S8 0x8008 /**< Signed 8-bit samples */ -#define AUDIO_U16LSB 0x0010 /**< Unsigned 16-bit samples */ -#define AUDIO_S16LSB 0x8010 /**< Signed 16-bit samples */ -#define AUDIO_U16MSB 0x1010 /**< As above, but big-endian byte order */ -#define AUDIO_S16MSB 0x9010 /**< As above, but big-endian byte order */ -#define AUDIO_U16 AUDIO_U16LSB -#define AUDIO_S16 AUDIO_S16LSB +#define AUDIO_U8 0x0008 /**< Unsigned 8-bit samples */ +#define AUDIO_S8 0x8008 /**< Signed 8-bit samples */ +#define AUDIO_U16LSB 0x0010 /**< Unsigned 16-bit samples */ +#define AUDIO_S16LSB 0x8010 /**< Signed 16-bit samples */ +#define AUDIO_U16MSB 0x1010 /**< As above, but big-endian byte order */ +#define AUDIO_S16MSB 0x9010 /**< As above, but big-endian byte order */ +#define AUDIO_U16 AUDIO_U16LSB +#define AUDIO_S16 AUDIO_S16LSB /*@}*/ /** * \name int32 support - * - * New to SDL 1.3. */ /*@{*/ -#define AUDIO_S32LSB 0x8020 /**< 32-bit integer samples */ -#define AUDIO_S32MSB 0x9020 /**< As above, but big-endian byte order */ -#define AUDIO_S32 AUDIO_S32LSB +#define AUDIO_S32LSB 0x8020 /**< 32-bit integer samples */ +#define AUDIO_S32MSB 0x9020 /**< As above, but big-endian byte order */ +#define AUDIO_S32 AUDIO_S32LSB /*@}*/ /** * \name float32 support - * - * New to SDL 1.3. */ /*@{*/ -#define AUDIO_F32LSB 0x8120 /**< 32-bit floating point samples */ -#define AUDIO_F32MSB 0x9120 /**< As above, but big-endian byte order */ -#define AUDIO_F32 AUDIO_F32LSB +#define AUDIO_F32LSB 0x8120 /**< 32-bit floating point samples */ +#define AUDIO_F32MSB 0x9120 /**< As above, but big-endian byte order */ +#define AUDIO_F32 AUDIO_F32LSB /*@}*/ /** @@ -125,21 +119,21 @@ typedef Uint16 SDL_AudioFormat; */ /*@{*/ #if SDL_BYTEORDER == SDL_LIL_ENDIAN -#define AUDIO_U16SYS AUDIO_U16LSB -#define AUDIO_S16SYS AUDIO_S16LSB -#define AUDIO_S32SYS AUDIO_S32LSB -#define AUDIO_F32SYS AUDIO_F32LSB +#define AUDIO_U16SYS AUDIO_U16LSB +#define AUDIO_S16SYS AUDIO_S16LSB +#define AUDIO_S32SYS AUDIO_S32LSB +#define AUDIO_F32SYS AUDIO_F32LSB #else -#define AUDIO_U16SYS AUDIO_U16MSB -#define AUDIO_S16SYS AUDIO_S16MSB -#define AUDIO_S32SYS AUDIO_S32MSB -#define AUDIO_F32SYS AUDIO_F32MSB +#define AUDIO_U16SYS AUDIO_U16MSB +#define AUDIO_S16SYS AUDIO_S16MSB +#define AUDIO_S32SYS AUDIO_S32MSB +#define AUDIO_F32SYS AUDIO_F32MSB #endif /*@}*/ -/** +/** * \name Allow change flags - * + * * Which audio format changes are allowed when opening a device. */ /*@{*/ @@ -209,7 +203,7 @@ typedef struct SDL_AudioCVT /** * \name Driver discovery functions - * + * * These functions return the list of built in audio drivers, in the * order that they are normally initialized by default. */ @@ -220,9 +214,9 @@ extern DECLSPEC const char *SDLCALL SDL_GetAudioDriver(int index); /** * \name Initialization and cleanup - * + * * \internal These functions are used internally, and should not be used unless - * you have a specific need to specify the audio driver you want to + * you have a specific need to specify the audio driver you want to * use. You should normally use SDL_Init() or SDL_InitSubSystem(). */ /*@{*/ @@ -242,20 +236,20 @@ extern DECLSPEC const char *SDLCALL SDL_GetCurrentAudioDriver(void); * structure pointed to by \c obtained. If \c obtained is NULL, the audio * data passed to the callback function will be guaranteed to be in the * requested format, and will be automatically converted to the hardware - * audio format if necessary. This function returns -1 if it failed + * audio format if necessary. This function returns -1 if it failed * to open the audio device, or couldn't set up the audio thread. - * + * * When filling in the desired audio spec structure, * - \c desired->freq should be the desired audio frequency in samples-per- * second. * - \c desired->format should be the desired audio format. - * - \c desired->samples is the desired size of the audio buffer, in - * samples. This number should be a power of two, and may be adjusted by + * - \c desired->samples is the desired size of the audio buffer, in + * samples. This number should be a power of two, and may be adjusted by * the audio driver to a value more suitable for the hardware. Good values - * seem to range between 512 and 8096 inclusive, depending on the - * application and CPU speed. Smaller values yield faster response time, - * but can lead to underflow if the application is doing heavy processing - * and cannot fill the audio buffer in time. A stereo sample consists of + * seem to range between 512 and 8096 inclusive, depending on the + * application and CPU speed. Smaller values yield faster response time, + * but can lead to underflow if the application is doing heavy processing + * and cannot fill the audio buffer in time. A stereo sample consists of * both right and left channels in LR ordering. * Note that the number of samples is directly related to time by the * following formula: \code ms = (samples*1000)/freq \endcode @@ -271,7 +265,7 @@ extern DECLSPEC const char *SDLCALL SDL_GetCurrentAudioDriver(void); * and SDL_UnlockAudio() in your code. * - \c desired->userdata is passed as the first parameter to your callback * function. - * + * * The audio device starts out playing silence when it's opened, and should * be enabled for playing by calling \c SDL_PauseAudio(0) when you are ready * for your audio callback function to be called. Since the audio driver @@ -283,7 +277,7 @@ extern DECLSPEC int SDLCALL SDL_OpenAudio(SDL_AudioSpec * desired, /** * SDL Audio Device IDs. - * + * * A successful call to SDL_OpenAudio() is always device id 1, and legacy * SDL audio APIs assume you want this device ID. SDL_OpenAudioDevice() calls * always returns devices >= 2 on success. The legacy calls are good both @@ -299,7 +293,7 @@ typedef Uint32 SDL_AudioDeviceID; * not an error. For example, if SDL is set up to talk to a remote audio * server, it can't list every one available on the Internet, but it will * still allow a specific host to be specified to SDL_OpenAudioDevice(). - * + * * In many common cases, when this function returns a value <= 0, it can still * successfully open the default device (NULL for first argument of * SDL_OpenAudioDevice()). @@ -313,7 +307,7 @@ extern DECLSPEC int SDLCALL SDL_GetNumAudioDevices(int iscapture); * The values returned by this function reflect the latest call to * SDL_GetNumAudioDevices(); recall that function to redetect available * hardware. - * + * * The string returned by this function is UTF-8 encoded, read-only, and * managed internally. You are not to free it. If you need to keep the * string for any length of time, you should make your own copy of it, as it @@ -326,14 +320,14 @@ extern DECLSPEC const char *SDLCALL SDL_GetAudioDeviceName(int index, /** * Open a specific audio device. Passing in a device name of NULL requests * the most reasonable default (and is equivalent to calling SDL_OpenAudio()). - * + * * The device name is a UTF-8 string reported by SDL_GetAudioDeviceName(), but * some drivers allow arbitrary and driver-specific strings, such as a * hostname/IP address for a remote audio server, or a filename in the * diskaudio driver. - * + * * \return 0 on error, a valid device ID that is >= 2 on success. - * + * * SDL_OpenAudio(), unlike this function, always acts on device ID 1. */ extern DECLSPEC SDL_AudioDeviceID SDLCALL SDL_OpenAudioDevice(const char @@ -351,7 +345,7 @@ extern DECLSPEC SDL_AudioDeviceID SDLCALL SDL_OpenAudioDevice(const char /** * \name Audio state - * + * * Get the current audio state. */ /*@{*/ @@ -369,7 +363,7 @@ SDL_GetAudioDeviceStatus(SDL_AudioDeviceID dev); /** * \name Pause audio functions - * + * * These functions pause and unpause the audio callback processing. * They should be called with a parameter of 0 after opening the audio * device to start playing sound. This is so you can safely initialize @@ -387,18 +381,18 @@ extern DECLSPEC void SDLCALL SDL_PauseAudioDevice(SDL_AudioDeviceID dev, * that source if \c freesrc is non-zero. For example, to load a WAVE file, * you could do: * \code - * SDL_LoadWAV_RW(SDL_RWFromFile("sample.wav", "rb"), 1, ...); + * SDL_LoadWAV_RW(SDL_RWFromFile("sample.wav", "rb"), 1, ...); * \endcode * * If this function succeeds, it returns the given SDL_AudioSpec, * filled with the audio data format of the wave data, and sets * \c *audio_buf to a malloc()'d buffer containing the audio data, * and sets \c *audio_len to the length of that audio buffer, in bytes. - * You need to free the audio buffer with SDL_FreeWAV() when you are + * You need to free the audio buffer with SDL_FreeWAV() when you are * done with it. * - * This function returns NULL and sets the SDL error message if the - * wave file cannot be opened, uses an unknown data format, or is + * This function returns NULL and sets the SDL error message if the + * wave file cannot be opened, uses an unknown data format, or is * corrupt. Currently raw and MS-ADPCM WAVE files are supported. */ extern DECLSPEC SDL_AudioSpec *SDLCALL SDL_LoadWAV_RW(SDL_RWops * src, @@ -407,12 +401,12 @@ extern DECLSPEC SDL_AudioSpec *SDLCALL SDL_LoadWAV_RW(SDL_RWops * src, Uint8 ** audio_buf, Uint32 * audio_len); -/** +/** * Loads a WAV from a file. * Compatibility convenience function. */ #define SDL_LoadWAV(file, spec, audio_buf, audio_len) \ - SDL_LoadWAV_RW(SDL_RWFromFile(file, "rb"),1, spec,audio_buf,audio_len) + SDL_LoadWAV_RW(SDL_RWFromFile(file, "rb"),1, spec,audio_buf,audio_len) /** * This function frees data previously allocated with SDL_LoadWAV_RW() @@ -424,7 +418,7 @@ extern DECLSPEC void SDLCALL SDL_FreeWAV(Uint8 * audio_buf); * and rate, and initializes the \c cvt structure with information needed * by SDL_ConvertAudio() to convert a buffer of audio data from one format * to the other. - * + * * \return -1 if the format conversion is not supported, 0 if there's * no conversion needed, or 1 if the audio filter is set up. */ @@ -441,7 +435,7 @@ extern DECLSPEC int SDLCALL SDL_BuildAudioCVT(SDL_AudioCVT * cvt, * created an audio buffer \c cvt->buf, and filled it with \c cvt->len bytes of * audio data in the source format, this function will convert it in-place * to the desired format. - * + * * The data conversion may expand the size of the audio data, so the buffer * \c cvt->buf should be allocated after the \c cvt structure is initialized by * SDL_BuildAudioCVT(), and should be \c cvt->len*cvt->len_mult bytes long. @@ -471,9 +465,9 @@ extern DECLSPEC void SDLCALL SDL_MixAudioFormat(Uint8 * dst, /** * \name Audio lock functions - * + * * The lock manipulated by these functions protects the callback function. - * During a SDL_LockAudio()/SDL_UnlockAudio() pair, you can be guaranteed that + * During a SDL_LockAudio()/SDL_UnlockAudio() pair, you can be guaranteed that * the callback function is not running. Do not call these from the callback * function or you will cause deadlock. */ @@ -498,9 +492,7 @@ extern DECLSPEC int SDLCALL SDL_AudioDeviceConnected(SDL_AudioDeviceID dev); /* Ends C function definitions when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ } -/* *INDENT-ON* */ #endif #include "close_code.h" diff --git a/include/SDL_bits.h b/include/SDL_bits.h index d678b7822..942bc1744 100644 --- a/include/SDL_bits.h +++ b/include/SDL_bits.h @@ -33,9 +33,7 @@ #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ extern "C" { -/* *INDENT-ON* */ #endif /** @@ -83,9 +81,7 @@ SDL_MostSignificantBitIndex32(Uint32 x) /* Ends C function definitions when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ } -/* *INDENT-ON* */ #endif #include "close_code.h" diff --git a/include/SDL_blendmode.h b/include/SDL_blendmode.h index 64a3530e3..37c475aef 100644 --- a/include/SDL_blendmode.h +++ b/include/SDL_blendmode.h @@ -21,7 +21,7 @@ /** * \file SDL_blendmode.h - * + * * Header file declaring the SDL_BlendMode enumeration */ @@ -31,9 +31,7 @@ #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ extern "C" { -/* *INDENT-ON* */ #endif /** @@ -49,9 +47,7 @@ typedef enum /* Ends C function definitions when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ } -/* *INDENT-ON* */ #endif #include "close_code.h" diff --git a/include/SDL_clipboard.h b/include/SDL_clipboard.h index 9d86b6b49..1f5742d16 100644 --- a/include/SDL_clipboard.h +++ b/include/SDL_clipboard.h @@ -33,9 +33,7 @@ #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ extern "C" { -/* *INDENT-ON* */ #endif /* Function prototypes */ @@ -64,9 +62,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_HasClipboardText(void); /* Ends C function definitions when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ } -/* *INDENT-ON* */ #endif #include "close_code.h" diff --git a/include/SDL_config.h b/include/SDL_config.h index 951a77d27..7440940ad 100644 --- a/include/SDL_config.h +++ b/include/SDL_config.h @@ -27,13 +27,13 @@ /** * \file SDL_config.h */ - + /* Add any platform that doesn't build using the configure system. */ #if defined(__WIN32__) #include "SDL_config_windows.h" #elif defined(__MACOSX__) #include "SDL_config_macosx.h" -#elif defined(__IPHONEOS__) +#elif defined(__IPHONEOS__) #include "SDL_config_iphoneos.h" #elif defined(__ANDROID__) #include "SDL_config_android.h" diff --git a/include/SDL_config_android.h b/include/SDL_config_android.h index 1676eb429..2541a73dc 100644 --- a/include/SDL_config_android.h +++ b/include/SDL_config_android.h @@ -26,109 +26,109 @@ /** * \file SDL_config_android.h - * + * * This is a configuration that can be used to build SDL for Android */ #include -#define HAVE_ALLOCA_H 1 -#define HAVE_SYS_TYPES_H 1 -#define HAVE_STDIO_H 1 -#define STDC_HEADERS 1 -#define HAVE_STRING_H 1 -#define HAVE_INTTYPES_H 1 -#define HAVE_STDINT_H 1 -#define HAVE_CTYPE_H 1 -#define HAVE_MATH_H 1 -#define HAVE_SIGNAL_H 1 +#define HAVE_ALLOCA_H 1 +#define HAVE_SYS_TYPES_H 1 +#define HAVE_STDIO_H 1 +#define STDC_HEADERS 1 +#define HAVE_STRING_H 1 +#define HAVE_INTTYPES_H 1 +#define HAVE_STDINT_H 1 +#define HAVE_CTYPE_H 1 +#define HAVE_MATH_H 1 +#define HAVE_SIGNAL_H 1 /* C library functions */ -#define HAVE_MALLOC 1 -#define HAVE_CALLOC 1 -#define HAVE_REALLOC 1 -#define HAVE_FREE 1 -#define HAVE_ALLOCA 1 -#define HAVE_GETENV 1 -#define HAVE_SETENV 1 -#define HAVE_PUTENV 1 -#define HAVE_SETENV 1 -#define HAVE_UNSETENV 1 -#define HAVE_QSORT 1 -#define HAVE_ABS 1 -#define HAVE_BCOPY 1 -#define HAVE_MEMSET 1 -#define HAVE_MEMCPY 1 -#define HAVE_MEMMOVE 1 -#define HAVE_MEMCMP 1 -#define HAVE_STRLEN 1 -#define HAVE_STRLCPY 1 -#define HAVE_STRLCAT 1 -#define HAVE_STRDUP 1 -#define HAVE_STRCHR 1 -#define HAVE_STRRCHR 1 -#define HAVE_STRSTR 1 -#define HAVE_STRTOL 1 -#define HAVE_STRTOUL 1 -#define HAVE_STRTOLL 1 -#define HAVE_STRTOULL 1 -#define HAVE_STRTOD 1 -#define HAVE_ATOI 1 -#define HAVE_ATOF 1 -#define HAVE_STRCMP 1 -#define HAVE_STRNCMP 1 -#define HAVE_STRCASECMP 1 +#define HAVE_MALLOC 1 +#define HAVE_CALLOC 1 +#define HAVE_REALLOC 1 +#define HAVE_FREE 1 +#define HAVE_ALLOCA 1 +#define HAVE_GETENV 1 +#define HAVE_SETENV 1 +#define HAVE_PUTENV 1 +#define HAVE_SETENV 1 +#define HAVE_UNSETENV 1 +#define HAVE_QSORT 1 +#define HAVE_ABS 1 +#define HAVE_BCOPY 1 +#define HAVE_MEMSET 1 +#define HAVE_MEMCPY 1 +#define HAVE_MEMMOVE 1 +#define HAVE_MEMCMP 1 +#define HAVE_STRLEN 1 +#define HAVE_STRLCPY 1 +#define HAVE_STRLCAT 1 +#define HAVE_STRDUP 1 +#define HAVE_STRCHR 1 +#define HAVE_STRRCHR 1 +#define HAVE_STRSTR 1 +#define HAVE_STRTOL 1 +#define HAVE_STRTOUL 1 +#define HAVE_STRTOLL 1 +#define HAVE_STRTOULL 1 +#define HAVE_STRTOD 1 +#define HAVE_ATOI 1 +#define HAVE_ATOF 1 +#define HAVE_STRCMP 1 +#define HAVE_STRNCMP 1 +#define HAVE_STRCASECMP 1 #define HAVE_STRNCASECMP 1 -#define HAVE_SSCANF 1 -#define HAVE_SNPRINTF 1 -#define HAVE_VSNPRINTF 1 -#define HAVE_M_PI 1 -#define HAVE_ATAN 1 -#define HAVE_ATAN2 1 -#define HAVE_CEIL 1 -#define HAVE_COPYSIGN 1 -#define HAVE_COS 1 -#define HAVE_COSF 1 -#define HAVE_FABS 1 -#define HAVE_FLOOR 1 -#define HAVE_LOG 1 -#define HAVE_POW 1 -#define HAVE_SCALBN 1 -#define HAVE_SIN 1 -#define HAVE_SINF 1 -#define HAVE_SQRT 1 -#define HAVE_SIGACTION 1 -#define HAVE_SETJMP 1 -#define HAVE_NANOSLEEP 1 -#define HAVE_SYSCONF 1 +#define HAVE_SSCANF 1 +#define HAVE_SNPRINTF 1 +#define HAVE_VSNPRINTF 1 +#define HAVE_M_PI 1 +#define HAVE_ATAN 1 +#define HAVE_ATAN2 1 +#define HAVE_CEIL 1 +#define HAVE_COPYSIGN 1 +#define HAVE_COS 1 +#define HAVE_COSF 1 +#define HAVE_FABS 1 +#define HAVE_FLOOR 1 +#define HAVE_LOG 1 +#define HAVE_POW 1 +#define HAVE_SCALBN 1 +#define HAVE_SIN 1 +#define HAVE_SINF 1 +#define HAVE_SQRT 1 +#define HAVE_SIGACTION 1 +#define HAVE_SETJMP 1 +#define HAVE_NANOSLEEP 1 +#define HAVE_SYSCONF 1 #define SIZEOF_VOIDP 4 /* Enable various audio drivers */ -#define SDL_AUDIO_DRIVER_ANDROID 1 -#define SDL_AUDIO_DRIVER_DUMMY 1 +#define SDL_AUDIO_DRIVER_ANDROID 1 +#define SDL_AUDIO_DRIVER_DUMMY 1 /* Enable various input drivers */ -#define SDL_JOYSTICK_ANDROID 1 -#define SDL_HAPTIC_DUMMY 1 +#define SDL_JOYSTICK_ANDROID 1 +#define SDL_HAPTIC_DUMMY 1 /* Enable various shared object loading systems */ -#define SDL_LOADSO_DLOPEN 1 +#define SDL_LOADSO_DLOPEN 1 /* Enable various threading systems */ -#define SDL_THREAD_PTHREAD 1 -#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1 +#define SDL_THREAD_PTHREAD 1 +#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1 /* Enable various timer systems */ -#define SDL_TIMER_UNIX 1 +#define SDL_TIMER_UNIX 1 /* Enable various video drivers */ #define SDL_VIDEO_DRIVER_ANDROID 1 /* Enable OpenGL ES */ -#define SDL_VIDEO_OPENGL_ES 1 -#define SDL_VIDEO_RENDER_OGL_ES 1 -#define SDL_VIDEO_RENDER_OGL_ES2 1 +#define SDL_VIDEO_OPENGL_ES 1 +#define SDL_VIDEO_RENDER_OGL_ES 1 +#define SDL_VIDEO_RENDER_OGL_ES2 1 /* Enable system power support */ #define SDL_POWER_ANDROID 1 diff --git a/include/SDL_config_iphoneos.h b/include/SDL_config_iphoneos.h index f7925d468..b27b18973 100644 --- a/include/SDL_config_iphoneos.h +++ b/include/SDL_config_iphoneos.h @@ -30,109 +30,109 @@ #define SIZEOF_VOIDP 4 #endif -#define HAVE_GCC_ATOMICS 1 - -#define HAVE_ALLOCA_H 1 -#define HAVE_SYS_TYPES_H 1 -#define HAVE_STDIO_H 1 -#define STDC_HEADERS 1 -#define HAVE_STRING_H 1 -#define HAVE_INTTYPES_H 1 -#define HAVE_STDINT_H 1 -#define HAVE_CTYPE_H 1 -#define HAVE_MATH_H 1 -#define HAVE_SIGNAL_H 1 +#define HAVE_GCC_ATOMICS 1 + +#define HAVE_ALLOCA_H 1 +#define HAVE_SYS_TYPES_H 1 +#define HAVE_STDIO_H 1 +#define STDC_HEADERS 1 +#define HAVE_STRING_H 1 +#define HAVE_INTTYPES_H 1 +#define HAVE_STDINT_H 1 +#define HAVE_CTYPE_H 1 +#define HAVE_MATH_H 1 +#define HAVE_SIGNAL_H 1 /* C library functions */ -#define HAVE_MALLOC 1 -#define HAVE_CALLOC 1 -#define HAVE_REALLOC 1 -#define HAVE_FREE 1 -#define HAVE_ALLOCA 1 -#define HAVE_GETENV 1 -#define HAVE_SETENV 1 -#define HAVE_PUTENV 1 -#define HAVE_SETENV 1 -#define HAVE_UNSETENV 1 -#define HAVE_QSORT 1 -#define HAVE_ABS 1 -#define HAVE_BCOPY 1 -#define HAVE_MEMSET 1 -#define HAVE_MEMCPY 1 -#define HAVE_MEMMOVE 1 -#define HAVE_MEMCMP 1 -#define HAVE_STRLEN 1 -#define HAVE_STRLCPY 1 -#define HAVE_STRLCAT 1 -#define HAVE_STRDUP 1 -#define HAVE_STRCHR 1 -#define HAVE_STRRCHR 1 -#define HAVE_STRSTR 1 -#define HAVE_STRTOL 1 -#define HAVE_STRTOUL 1 -#define HAVE_STRTOLL 1 -#define HAVE_STRTOULL 1 -#define HAVE_STRTOD 1 -#define HAVE_ATOI 1 -#define HAVE_ATOF 1 -#define HAVE_STRCMP 1 -#define HAVE_STRNCMP 1 -#define HAVE_STRCASECMP 1 +#define HAVE_MALLOC 1 +#define HAVE_CALLOC 1 +#define HAVE_REALLOC 1 +#define HAVE_FREE 1 +#define HAVE_ALLOCA 1 +#define HAVE_GETENV 1 +#define HAVE_SETENV 1 +#define HAVE_PUTENV 1 +#define HAVE_SETENV 1 +#define HAVE_UNSETENV 1 +#define HAVE_QSORT 1 +#define HAVE_ABS 1 +#define HAVE_BCOPY 1 +#define HAVE_MEMSET 1 +#define HAVE_MEMCPY 1 +#define HAVE_MEMMOVE 1 +#define HAVE_MEMCMP 1 +#define HAVE_STRLEN 1 +#define HAVE_STRLCPY 1 +#define HAVE_STRLCAT 1 +#define HAVE_STRDUP 1 +#define HAVE_STRCHR 1 +#define HAVE_STRRCHR 1 +#define HAVE_STRSTR 1 +#define HAVE_STRTOL 1 +#define HAVE_STRTOUL 1 +#define HAVE_STRTOLL 1 +#define HAVE_STRTOULL 1 +#define HAVE_STRTOD 1 +#define HAVE_ATOI 1 +#define HAVE_ATOF 1 +#define HAVE_STRCMP 1 +#define HAVE_STRNCMP 1 +#define HAVE_STRCASECMP 1 #define HAVE_STRNCASECMP 1 -#define HAVE_SSCANF 1 -#define HAVE_SNPRINTF 1 -#define HAVE_VSNPRINTF 1 -#define HAVE_M_PI 1 -#define HAVE_ATAN 1 -#define HAVE_ATAN2 1 -#define HAVE_CEIL 1 -#define HAVE_COPYSIGN 1 -#define HAVE_COS 1 -#define HAVE_COSF 1 -#define HAVE_FABS 1 -#define HAVE_FLOOR 1 -#define HAVE_LOG 1 -#define HAVE_POW 1 -#define HAVE_SCALBN 1 -#define HAVE_SIN 1 -#define HAVE_SINF 1 -#define HAVE_SQRT 1 -#define HAVE_SIGACTION 1 -#define HAVE_SETJMP 1 -#define HAVE_NANOSLEEP 1 -#define HAVE_SYSCONF 1 +#define HAVE_SSCANF 1 +#define HAVE_SNPRINTF 1 +#define HAVE_VSNPRINTF 1 +#define HAVE_M_PI 1 +#define HAVE_ATAN 1 +#define HAVE_ATAN2 1 +#define HAVE_CEIL 1 +#define HAVE_COPYSIGN 1 +#define HAVE_COS 1 +#define HAVE_COSF 1 +#define HAVE_FABS 1 +#define HAVE_FLOOR 1 +#define HAVE_LOG 1 +#define HAVE_POW 1 +#define HAVE_SCALBN 1 +#define HAVE_SIN 1 +#define HAVE_SINF 1 +#define HAVE_SQRT 1 +#define HAVE_SIGACTION 1 +#define HAVE_SETJMP 1 +#define HAVE_NANOSLEEP 1 +#define HAVE_SYSCONF 1 #define HAVE_SYSCTLBYNAME 1 /* enable iPhone version of Core Audio driver */ #define SDL_AUDIO_DRIVER_COREAUDIO 1 /* Enable the dummy audio driver (src/audio/dummy/\*.c) */ -#define SDL_AUDIO_DRIVER_DUMMY 1 +#define SDL_AUDIO_DRIVER_DUMMY 1 /* Enable the stub haptic driver (src/haptic/dummy/\*.c) */ -#define SDL_HAPTIC_DISABLED 1 +#define SDL_HAPTIC_DISABLED 1 /* Enable Unix style SO loading */ /* Technically this works, but it violates the iPhone developer agreement */ /* #define SDL_LOADSO_DLOPEN 1 */ /* Enable the stub shared object loader (src/loadso/dummy/\*.c) */ -#define SDL_LOADSO_DISABLED 1 +#define SDL_LOADSO_DISABLED 1 /* Enable various threading systems */ -#define SDL_THREAD_PTHREAD 1 -#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1 +#define SDL_THREAD_PTHREAD 1 +#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1 /* Enable various timer systems */ -#define SDL_TIMER_UNIX 1 +#define SDL_TIMER_UNIX 1 /* Supported video drivers */ -#define SDL_VIDEO_DRIVER_UIKIT 1 -#define SDL_VIDEO_DRIVER_DUMMY 1 +#define SDL_VIDEO_DRIVER_UIKIT 1 +#define SDL_VIDEO_DRIVER_DUMMY 1 /* enable OpenGL ES */ -#define SDL_VIDEO_OPENGL_ES 1 -#define SDL_VIDEO_RENDER_OGL_ES 1 -#define SDL_VIDEO_RENDER_OGL_ES2 1 +#define SDL_VIDEO_OPENGL_ES 1 +#define SDL_VIDEO_RENDER_OGL_ES 1 +#define SDL_VIDEO_RENDER_OGL_ES2 1 /* Enable system power support */ #define SDL_POWER_UIKIT 1 diff --git a/include/SDL_config_macosx.h b/include/SDL_config_macosx.h index fece7fb5c..a2d227478 100644 --- a/include/SDL_config_macosx.h +++ b/include/SDL_config_macosx.h @@ -30,106 +30,106 @@ /* This is a set of defines to configure the SDL features */ #ifdef __LP64__ - #define SIZEOF_VOIDP 8 + #define SIZEOF_VOIDP 8 #else - #define SIZEOF_VOIDP 4 + #define SIZEOF_VOIDP 4 #endif /* Useful headers */ /* If we specified an SDK or have a post-PowerPC chip, then alloca.h exists. */ #if ( (MAC_OS_X_VERSION_MIN_REQUIRED >= 1030) || (!defined(__POWERPC__)) ) -#define HAVE_ALLOCA_H 1 +#define HAVE_ALLOCA_H 1 #endif -#define HAVE_SYS_TYPES_H 1 -#define HAVE_STDIO_H 1 -#define STDC_HEADERS 1 -#define HAVE_STRING_H 1 -#define HAVE_INTTYPES_H 1 -#define HAVE_STDINT_H 1 -#define HAVE_CTYPE_H 1 -#define HAVE_MATH_H 1 -#define HAVE_SIGNAL_H 1 +#define HAVE_SYS_TYPES_H 1 +#define HAVE_STDIO_H 1 +#define STDC_HEADERS 1 +#define HAVE_STRING_H 1 +#define HAVE_INTTYPES_H 1 +#define HAVE_STDINT_H 1 +#define HAVE_CTYPE_H 1 +#define HAVE_MATH_H 1 +#define HAVE_SIGNAL_H 1 /* C library functions */ -#define HAVE_MALLOC 1 -#define HAVE_CALLOC 1 -#define HAVE_REALLOC 1 -#define HAVE_FREE 1 -#define HAVE_ALLOCA 1 -#define HAVE_GETENV 1 -#define HAVE_SETENV 1 -#define HAVE_PUTENV 1 -#define HAVE_UNSETENV 1 -#define HAVE_QSORT 1 -#define HAVE_ABS 1 -#define HAVE_BCOPY 1 -#define HAVE_MEMSET 1 -#define HAVE_MEMCPY 1 -#define HAVE_MEMMOVE 1 -#define HAVE_MEMCMP 1 -#define HAVE_STRLEN 1 -#define HAVE_STRLCPY 1 -#define HAVE_STRLCAT 1 -#define HAVE_STRDUP 1 -#define HAVE_STRCHR 1 -#define HAVE_STRRCHR 1 -#define HAVE_STRSTR 1 -#define HAVE_STRTOL 1 -#define HAVE_STRTOUL 1 -#define HAVE_STRTOLL 1 -#define HAVE_STRTOULL 1 -#define HAVE_STRTOD 1 -#define HAVE_ATOI 1 -#define HAVE_ATOF 1 -#define HAVE_STRCMP 1 -#define HAVE_STRNCMP 1 -#define HAVE_STRCASECMP 1 +#define HAVE_MALLOC 1 +#define HAVE_CALLOC 1 +#define HAVE_REALLOC 1 +#define HAVE_FREE 1 +#define HAVE_ALLOCA 1 +#define HAVE_GETENV 1 +#define HAVE_SETENV 1 +#define HAVE_PUTENV 1 +#define HAVE_UNSETENV 1 +#define HAVE_QSORT 1 +#define HAVE_ABS 1 +#define HAVE_BCOPY 1 +#define HAVE_MEMSET 1 +#define HAVE_MEMCPY 1 +#define HAVE_MEMMOVE 1 +#define HAVE_MEMCMP 1 +#define HAVE_STRLEN 1 +#define HAVE_STRLCPY 1 +#define HAVE_STRLCAT 1 +#define HAVE_STRDUP 1 +#define HAVE_STRCHR 1 +#define HAVE_STRRCHR 1 +#define HAVE_STRSTR 1 +#define HAVE_STRTOL 1 +#define HAVE_STRTOUL 1 +#define HAVE_STRTOLL 1 +#define HAVE_STRTOULL 1 +#define HAVE_STRTOD 1 +#define HAVE_ATOI 1 +#define HAVE_ATOF 1 +#define HAVE_STRCMP 1 +#define HAVE_STRNCMP 1 +#define HAVE_STRCASECMP 1 #define HAVE_STRNCASECMP 1 -#define HAVE_SSCANF 1 -#define HAVE_SNPRINTF 1 -#define HAVE_VSNPRINTF 1 -#define HAVE_CEIL 1 -#define HAVE_COPYSIGN 1 -#define HAVE_COS 1 -#define HAVE_COSF 1 -#define HAVE_FABS 1 -#define HAVE_FLOOR 1 -#define HAVE_LOG 1 -#define HAVE_POW 1 -#define HAVE_SCALBN 1 -#define HAVE_SIN 1 -#define HAVE_SINF 1 -#define HAVE_SQRT 1 -#define HAVE_SIGACTION 1 -#define HAVE_SETJMP 1 -#define HAVE_NANOSLEEP 1 -#define HAVE_SYSCONF 1 +#define HAVE_SSCANF 1 +#define HAVE_SNPRINTF 1 +#define HAVE_VSNPRINTF 1 +#define HAVE_CEIL 1 +#define HAVE_COPYSIGN 1 +#define HAVE_COS 1 +#define HAVE_COSF 1 +#define HAVE_FABS 1 +#define HAVE_FLOOR 1 +#define HAVE_LOG 1 +#define HAVE_POW 1 +#define HAVE_SCALBN 1 +#define HAVE_SIN 1 +#define HAVE_SINF 1 +#define HAVE_SQRT 1 +#define HAVE_SIGACTION 1 +#define HAVE_SETJMP 1 +#define HAVE_NANOSLEEP 1 +#define HAVE_SYSCONF 1 #define HAVE_SYSCTLBYNAME 1 #define HAVE_ATAN 1 #define HAVE_ATAN2 1 /* Enable various audio drivers */ -#define SDL_AUDIO_DRIVER_COREAUDIO 1 -#define SDL_AUDIO_DRIVER_DISK 1 -#define SDL_AUDIO_DRIVER_DUMMY 1 +#define SDL_AUDIO_DRIVER_COREAUDIO 1 +#define SDL_AUDIO_DRIVER_DISK 1 +#define SDL_AUDIO_DRIVER_DUMMY 1 /* Enable various input drivers */ -#define SDL_JOYSTICK_IOKIT 1 -#define SDL_HAPTIC_IOKIT 1 +#define SDL_JOYSTICK_IOKIT 1 +#define SDL_HAPTIC_IOKIT 1 /* Enable various shared object loading systems */ -#define SDL_LOADSO_DLOPEN 1 +#define SDL_LOADSO_DLOPEN 1 /* Enable various threading systems */ -#define SDL_THREAD_PTHREAD 1 -#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1 +#define SDL_THREAD_PTHREAD 1 +#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1 /* Enable various timer systems */ -#define SDL_TIMER_UNIX 1 +#define SDL_TIMER_UNIX 1 /* Enable various video drivers */ -#define SDL_VIDEO_DRIVER_COCOA 1 -#define SDL_VIDEO_DRIVER_DUMMY 1 +#define SDL_VIDEO_DRIVER_COCOA 1 +#define SDL_VIDEO_DRIVER_DUMMY 1 #undef SDL_VIDEO_DRIVER_X11 #define SDL_VIDEO_DRIVER_X11_DYNAMIC "/usr/X11R6/lib/libX11.6.dylib" #define SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT "/usr/X11R6/lib/libXext.6.dylib" @@ -157,27 +157,27 @@ #endif #ifndef SDL_VIDEO_RENDER_OGL -#define SDL_VIDEO_RENDER_OGL 1 +#define SDL_VIDEO_RENDER_OGL 1 #endif /* Enable OpenGL support */ #ifndef SDL_VIDEO_OPENGL -#define SDL_VIDEO_OPENGL 1 +#define SDL_VIDEO_OPENGL 1 #endif #ifndef SDL_VIDEO_OPENGL_CGL -#define SDL_VIDEO_OPENGL_CGL 1 +#define SDL_VIDEO_OPENGL_CGL 1 #endif #ifndef SDL_VIDEO_OPENGL_GLX -#define SDL_VIDEO_OPENGL_GLX 1 +#define SDL_VIDEO_OPENGL_GLX 1 #endif /* Enable system power support */ #define SDL_POWER_MACOSX 1 /* Enable assembly routines */ -#define SDL_ASSEMBLY_ROUTINES 1 +#define SDL_ASSEMBLY_ROUTINES 1 #ifdef __ppc__ -#define SDL_ALTIVEC_BLITTERS 1 +#define SDL_ALTIVEC_BLITTERS 1 #endif #endif /* _SDL_config_macosx_h */ diff --git a/include/SDL_config_minimal.h b/include/SDL_config_minimal.h index a8a699fa0..cadfcaa5e 100644 --- a/include/SDL_config_minimal.h +++ b/include/SDL_config_minimal.h @@ -26,7 +26,7 @@ /** * \file SDL_config_minimal.h - * + * * This is the minimal configuration that can be used to build SDL. */ @@ -51,24 +51,24 @@ typedef unsigned long uintptr_t; #endif /* Enable the dummy audio driver (src/audio/dummy/\*.c) */ -#define SDL_AUDIO_DRIVER_DUMMY 1 +#define SDL_AUDIO_DRIVER_DUMMY 1 /* Enable the stub joystick driver (src/joystick/dummy/\*.c) */ -#define SDL_JOYSTICK_DISABLED 1 +#define SDL_JOYSTICK_DISABLED 1 /* Enable the stub haptic driver (src/haptic/dummy/\*.c) */ -#define SDL_HAPTIC_DISABLED 1 +#define SDL_HAPTIC_DISABLED 1 /* Enable the stub shared object loader (src/loadso/dummy/\*.c) */ -#define SDL_LOADSO_DISABLED 1 +#define SDL_LOADSO_DISABLED 1 /* Enable the stub thread support (src/thread/generic/\*.c) */ -#define SDL_THREADS_DISABLED 1 +#define SDL_THREADS_DISABLED 1 /* Enable the stub timer support (src/timer/dummy/\*.c) */ -#define SDL_TIMERS_DISABLED 1 +#define SDL_TIMERS_DISABLED 1 /* Enable the dummy video driver (src/video/dummy/\*.c) */ -#define SDL_VIDEO_DRIVER_DUMMY 1 +#define SDL_VIDEO_DRIVER_DUMMY 1 #endif /* _SDL_config_minimal_h */ diff --git a/include/SDL_config_pandora.h b/include/SDL_config_pandora.h index ebd9b6754..b93a1bc1a 100644 --- a/include/SDL_config_pandora.h +++ b/include/SDL_config_pandora.h @@ -57,7 +57,7 @@ #define HAVE_FREE 1 #define HAVE_ALLOCA 1 #define HAVE_GETENV 1 -#define HAVE_SETENV 1 +#define HAVE_SETENV 1 #define HAVE_PUTENV 1 #define HAVE_UNSETENV 1 #define HAVE_QSORT 1 diff --git a/include/SDL_config_psp.h b/include/SDL_config_psp.h index dc1797b4e..bf456f688 100644 --- a/include/SDL_config_psp.h +++ b/include/SDL_config_psp.h @@ -30,93 +30,93 @@ #define HAVE_GCC_SYNC_LOCK_TEST_AND_SET 1 #endif -#define HAVE_GCC_ATOMICS 1 - -#define HAVE_ALLOCA_H 1 -#define HAVE_SYS_TYPES_H 1 -#define HAVE_STDIO_H 1 -#define STDC_HEADERS 1 -#define HAVE_STRING_H 1 -#define HAVE_INTTYPES_H 1 -#define HAVE_STDINT_H 1 -#define HAVE_CTYPE_H 1 -#define HAVE_MATH_H 1 -#define HAVE_SIGNAL_H 1 +#define HAVE_GCC_ATOMICS 1 + +#define HAVE_ALLOCA_H 1 +#define HAVE_SYS_TYPES_H 1 +#define HAVE_STDIO_H 1 +#define STDC_HEADERS 1 +#define HAVE_STRING_H 1 +#define HAVE_INTTYPES_H 1 +#define HAVE_STDINT_H 1 +#define HAVE_CTYPE_H 1 +#define HAVE_MATH_H 1 +#define HAVE_SIGNAL_H 1 /* C library functions */ -#define HAVE_MALLOC 1 -#define HAVE_CALLOC 1 -#define HAVE_REALLOC 1 -#define HAVE_FREE 1 -#define HAVE_ALLOCA 1 -#define HAVE_GETENV 1 -#define HAVE_SETENV 1 -#define HAVE_PUTENV 1 -#define HAVE_SETENV 1 -#define HAVE_UNSETENV 1 -#define HAVE_QSORT 1 -#define HAVE_ABS 1 -#define HAVE_BCOPY 1 -#define HAVE_MEMSET 1 -#define HAVE_MEMCPY 1 -#define HAVE_MEMMOVE 1 -#define HAVE_MEMCMP 1 -#define HAVE_STRLEN 1 -#define HAVE_STRLCPY 1 -#define HAVE_STRLCAT 1 -#define HAVE_STRDUP 1 -#define HAVE_STRCHR 1 -#define HAVE_STRRCHR 1 -#define HAVE_STRSTR 1 -#define HAVE_STRTOL 1 -#define HAVE_STRTOUL 1 -#define HAVE_STRTOLL 1 -#define HAVE_STRTOULL 1 -#define HAVE_STRTOD 1 -#define HAVE_ATOI 1 -#define HAVE_ATOF 1 -#define HAVE_STRCMP 1 -#define HAVE_STRNCMP 1 -#define HAVE_STRCASECMP 1 +#define HAVE_MALLOC 1 +#define HAVE_CALLOC 1 +#define HAVE_REALLOC 1 +#define HAVE_FREE 1 +#define HAVE_ALLOCA 1 +#define HAVE_GETENV 1 +#define HAVE_SETENV 1 +#define HAVE_PUTENV 1 +#define HAVE_SETENV 1 +#define HAVE_UNSETENV 1 +#define HAVE_QSORT 1 +#define HAVE_ABS 1 +#define HAVE_BCOPY 1 +#define HAVE_MEMSET 1 +#define HAVE_MEMCPY 1 +#define HAVE_MEMMOVE 1 +#define HAVE_MEMCMP 1 +#define HAVE_STRLEN 1 +#define HAVE_STRLCPY 1 +#define HAVE_STRLCAT 1 +#define HAVE_STRDUP 1 +#define HAVE_STRCHR 1 +#define HAVE_STRRCHR 1 +#define HAVE_STRSTR 1 +#define HAVE_STRTOL 1 +#define HAVE_STRTOUL 1 +#define HAVE_STRTOLL 1 +#define HAVE_STRTOULL 1 +#define HAVE_STRTOD 1 +#define HAVE_ATOI 1 +#define HAVE_ATOF 1 +#define HAVE_STRCMP 1 +#define HAVE_STRNCMP 1 +#define HAVE_STRCASECMP 1 #define HAVE_STRNCASECMP 1 -#define HAVE_SSCANF 1 -#define HAVE_SNPRINTF 1 -#define HAVE_VSNPRINTF 1 -#define HAVE_M_PI 1 -#define HAVE_ATAN 1 -#define HAVE_ATAN2 1 -#define HAVE_CEIL 1 -#define HAVE_COPYSIGN 1 -#define HAVE_COS 1 -#define HAVE_COSF 1 -#define HAVE_FABS 1 -#define HAVE_FLOOR 1 -#define HAVE_LOG 1 -#define HAVE_POW 1 -#define HAVE_SCALBN 1 -#define HAVE_SIN 1 -#define HAVE_SINF 1 -#define HAVE_SQRT 1 -#define HAVE_SETJMP 1 -#define HAVE_NANOSLEEP 1 -//#define HAVE_SYSCONF 1 -//#define HAVE_SIGACTION 1 +#define HAVE_SSCANF 1 +#define HAVE_SNPRINTF 1 +#define HAVE_VSNPRINTF 1 +#define HAVE_M_PI 1 +#define HAVE_ATAN 1 +#define HAVE_ATAN2 1 +#define HAVE_CEIL 1 +#define HAVE_COPYSIGN 1 +#define HAVE_COS 1 +#define HAVE_COSF 1 +#define HAVE_FABS 1 +#define HAVE_FLOOR 1 +#define HAVE_LOG 1 +#define HAVE_POW 1 +#define HAVE_SCALBN 1 +#define HAVE_SIN 1 +#define HAVE_SINF 1 +#define HAVE_SQRT 1 +#define HAVE_SETJMP 1 +#define HAVE_NANOSLEEP 1 +//#define HAVE_SYSCONF 1 +//#define HAVE_SIGACTION 1 /* PSP isn't that sophisticated */ #define LACKS_SYS_MMAN_H 1 /* Enable the stub thread support (src/thread/psp/\*.c) */ -#define SDL_THREAD_PSP 1 +#define SDL_THREAD_PSP 1 /* Enable the stub timer support (src/timer/psp/\*.c) */ -#define SDL_TIMERS_PSP 1 +#define SDL_TIMERS_PSP 1 /* Enable the stub joystick driver (src/joystick/psp/\*.c) */ -#define SDL_JOYSTICK_PSP 1 +#define SDL_JOYSTICK_PSP 1 /* Enable the stub audio driver (src/audio/psp/\*.c) */ -#define SDL_AUDIO_DRIVER_PSP 1 +#define SDL_AUDIO_DRIVER_PSP 1 /* PSP video dirver */ #define SDL_VIDEO_DRIVER_PSP 1 @@ -127,10 +127,10 @@ #define SDL_POWER_PSP 1 /* PSP doesn't have haptic device (src/haptic/dummy/\*.c) */ -#define SDL_HAPTIC_DISABLED 1 +#define SDL_HAPTIC_DISABLED 1 /* PSP can't load shared object (src/loadso/dummy/\*.c) */ -#define SDL_LOADSO_DISABLED 1 +#define SDL_LOADSO_DISABLED 1 #endif /* _SDL_config_psp_h */ diff --git a/include/SDL_config_windows.h b/include/SDL_config_windows.h index c3f229f0c..e63e531a5 100644 --- a/include/SDL_config_windows.h +++ b/include/SDL_config_windows.h @@ -28,7 +28,7 @@ #if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H) #if defined(__GNUC__) || defined(__DMC__) || defined(__WATCOMC__) -#define HAVE_STDINT_H 1 +#define HAVE_STDINT_H 1 #elif defined(_MSC_VER) typedef signed __int8 int8_t; typedef unsigned __int8 uint8_t; @@ -136,49 +136,49 @@ typedef unsigned int uintptr_t; #define HAVE_SINF 1 #define HAVE_SQRT 1 #else -#define HAVE_STDARG_H 1 -#define HAVE_STDDEF_H 1 +#define HAVE_STDARG_H 1 +#define HAVE_STDDEF_H 1 #endif /* Enable various audio drivers */ -#define SDL_AUDIO_DRIVER_DSOUND 1 +#define SDL_AUDIO_DRIVER_DSOUND 1 #ifndef __GNUC__ -#define SDL_AUDIO_DRIVER_XAUDIO2 1 +#define SDL_AUDIO_DRIVER_XAUDIO2 1 #endif -#define SDL_AUDIO_DRIVER_WINMM 1 -#define SDL_AUDIO_DRIVER_DISK 1 -#define SDL_AUDIO_DRIVER_DUMMY 1 +#define SDL_AUDIO_DRIVER_WINMM 1 +#define SDL_AUDIO_DRIVER_DISK 1 +#define SDL_AUDIO_DRIVER_DUMMY 1 /* Enable various input drivers */ -#define SDL_JOYSTICK_DINPUT 1 -#define SDL_HAPTIC_DINPUT 1 +#define SDL_JOYSTICK_DINPUT 1 +#define SDL_HAPTIC_DINPUT 1 /* Enable various shared object loading systems */ -#define SDL_LOADSO_WINDOWS 1 +#define SDL_LOADSO_WINDOWS 1 /* Enable various threading systems */ -#define SDL_THREAD_WINDOWS 1 +#define SDL_THREAD_WINDOWS 1 /* Enable various timer systems */ -#define SDL_TIMER_WINDOWS 1 +#define SDL_TIMER_WINDOWS 1 /* Enable various video drivers */ -#define SDL_VIDEO_DRIVER_DUMMY 1 -#define SDL_VIDEO_DRIVER_WINDOWS 1 +#define SDL_VIDEO_DRIVER_DUMMY 1 +#define SDL_VIDEO_DRIVER_WINDOWS 1 #ifndef SDL_VIDEO_RENDER_D3D -#define SDL_VIDEO_RENDER_D3D 1 +#define SDL_VIDEO_RENDER_D3D 1 #endif /* Enable OpenGL support */ #ifndef SDL_VIDEO_OPENGL -#define SDL_VIDEO_OPENGL 1 +#define SDL_VIDEO_OPENGL 1 #endif #ifndef SDL_VIDEO_OPENGL_WGL -#define SDL_VIDEO_OPENGL_WGL 1 +#define SDL_VIDEO_OPENGL_WGL 1 #endif #ifndef SDL_VIDEO_RENDER_OGL -#define SDL_VIDEO_RENDER_OGL 1 +#define SDL_VIDEO_RENDER_OGL 1 #endif /* Enable system power support */ @@ -186,7 +186,7 @@ typedef unsigned int uintptr_t; /* Enable assembly routines (Win64 doesn't have inline asm) */ #ifndef _WIN64 -#define SDL_ASSEMBLY_ROUTINES 1 +#define SDL_ASSEMBLY_ROUTINES 1 #endif #endif /* _SDL_config_windows_h */ diff --git a/include/SDL_config_wiz.h b/include/SDL_config_wiz.h index 2c7295816..9be04d92a 100644 --- a/include/SDL_config_wiz.h +++ b/include/SDL_config_wiz.h @@ -51,7 +51,7 @@ #define HAVE_FREE 1 #define HAVE_ALLOCA 1 #define HAVE_GETENV 1 -#define HAVE_SETENV 1 +#define HAVE_SETENV 1 #define HAVE_PUTENV 1 #define HAVE_UNSETENV 1 #define HAVE_QSORT 1 diff --git a/include/SDL_cpuinfo.h b/include/SDL_cpuinfo.h index a3b1012a7..dde3074f0 100644 --- a/include/SDL_cpuinfo.h +++ b/include/SDL_cpuinfo.h @@ -21,7 +21,7 @@ /** * \file SDL_cpuinfo.h - * + * * CPU feature detection for SDL. */ @@ -66,9 +66,7 @@ #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ extern "C" { -/* *INDENT-ON* */ #endif /* This is a guess for the cacheline size used for padding. @@ -139,9 +137,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE42(void); /* Ends C function definitions when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ } -/* *INDENT-ON* */ #endif #include "close_code.h" diff --git a/include/SDL_endian.h b/include/SDL_endian.h index a1a11df09..c58edcca0 100644 --- a/include/SDL_endian.h +++ b/include/SDL_endian.h @@ -21,7 +21,7 @@ /** * \file SDL_endian.h - * + * * Functions for reading and writing endian-specific values */ @@ -34,8 +34,8 @@ * \name The two types of endianness */ /*@{*/ -#define SDL_LIL_ENDIAN 1234 -#define SDL_BIG_ENDIAN 4321 +#define SDL_LIL_ENDIAN 1234 +#define SDL_BIG_ENDIAN 4321 /*@}*/ #ifndef SDL_BYTEORDER /* Not defined in SDL_config.h? */ @@ -48,9 +48,9 @@ (defined(__MIPS__) && defined(__MISPEB__)) || \ defined(__ppc__) || defined(__POWERPC__) || defined(_M_PPC) || \ defined(__sparc__) -#define SDL_BYTEORDER SDL_BIG_ENDIAN +#define SDL_BYTEORDER SDL_BIG_ENDIAN #else -#define SDL_BYTEORDER SDL_LIL_ENDIAN +#define SDL_BYTEORDER SDL_LIL_ENDIAN #endif #endif /* __linux __ */ #endif /* !SDL_BYTEORDER */ @@ -59,9 +59,7 @@ #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ extern "C" { -/* *INDENT-ON* */ #endif /** @@ -210,31 +208,29 @@ SDL_SwapFloat(float x) */ /*@{*/ #if SDL_BYTEORDER == SDL_LIL_ENDIAN -#define SDL_SwapLE16(X) (X) -#define SDL_SwapLE32(X) (X) -#define SDL_SwapLE64(X) (X) -#define SDL_SwapFloatLE(X) (X) -#define SDL_SwapBE16(X) SDL_Swap16(X) -#define SDL_SwapBE32(X) SDL_Swap32(X) -#define SDL_SwapBE64(X) SDL_Swap64(X) -#define SDL_SwapFloatBE(X) SDL_SwapFloat(X) +#define SDL_SwapLE16(X) (X) +#define SDL_SwapLE32(X) (X) +#define SDL_SwapLE64(X) (X) +#define SDL_SwapFloatLE(X) (X) +#define SDL_SwapBE16(X) SDL_Swap16(X) +#define SDL_SwapBE32(X) SDL_Swap32(X) +#define SDL_SwapBE64(X) SDL_Swap64(X) +#define SDL_SwapFloatBE(X) SDL_SwapFloat(X) #else -#define SDL_SwapLE16(X) SDL_Swap16(X) -#define SDL_SwapLE32(X) SDL_Swap32(X) -#define SDL_SwapLE64(X) SDL_Swap64(X) -#define SDL_SwapFloatLE(X) SDL_SwapFloat(X) -#define SDL_SwapBE16(X) (X) -#define SDL_SwapBE32(X) (X) -#define SDL_SwapBE64(X) (X) -#define SDL_SwapFloatBE(X) (X) +#define SDL_SwapLE16(X) SDL_Swap16(X) +#define SDL_SwapLE32(X) SDL_Swap32(X) +#define SDL_SwapLE64(X) SDL_Swap64(X) +#define SDL_SwapFloatLE(X) SDL_SwapFloat(X) +#define SDL_SwapBE16(X) (X) +#define SDL_SwapBE32(X) (X) +#define SDL_SwapBE64(X) (X) +#define SDL_SwapFloatBE(X) (X) #endif /*@}*//*Swap to native*/ /* Ends C function definitions when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ } -/* *INDENT-ON* */ #endif #include "close_code.h" diff --git a/include/SDL_error.h b/include/SDL_error.h index 81c64da66..229b26802 100644 --- a/include/SDL_error.h +++ b/include/SDL_error.h @@ -21,7 +21,7 @@ /** * \file SDL_error.h - * + * * Simple error message routines for SDL. */ @@ -33,9 +33,7 @@ #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ extern "C" { -/* *INDENT-ON* */ #endif /* Public functions */ @@ -46,14 +44,14 @@ extern DECLSPEC void SDLCALL SDL_ClearError(void); /** * \name Internal error functions - * - * \internal + * + * \internal * Private error reporting function - used internally. */ /*@{*/ -#define SDL_OutOfMemory() SDL_Error(SDL_ENOMEM) -#define SDL_Unsupported() SDL_Error(SDL_UNSUPPORTED) -#define SDL_InvalidParamError(param) SDL_SetError("Parameter '%s' is invalid", (param)) +#define SDL_OutOfMemory() SDL_Error(SDL_ENOMEM) +#define SDL_Unsupported() SDL_Error(SDL_UNSUPPORTED) +#define SDL_InvalidParamError(param) SDL_SetError("Parameter '%s' is invalid", (param)) typedef enum { SDL_ENOMEM, @@ -69,9 +67,7 @@ extern DECLSPEC int SDLCALL SDL_Error(SDL_errorcode code); /* Ends C function definitions when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ } -/* *INDENT-ON* */ #endif #include "close_code.h" diff --git a/include/SDL_events.h b/include/SDL_events.h index 65ba6b158..c2265bae6 100644 --- a/include/SDL_events.h +++ b/include/SDL_events.h @@ -21,7 +21,7 @@ /** * \file SDL_events.h - * + * * Include file for SDL event handling. */ @@ -42,14 +42,12 @@ #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ extern "C" { -/* *INDENT-ON* */ #endif /* General keyboard/mouse state definitions */ -#define SDL_RELEASED 0 -#define SDL_PRESSED 1 +#define SDL_RELEASED 0 +#define SDL_PRESSED 1 /** * \brief The types of events that can be delivered. @@ -62,27 +60,27 @@ typedef enum SDL_QUIT = 0x100, /**< User-requested quit */ /* These application events have special meaning on iOS, see README.iOS for details */ - SDL_APP_TERMINATING, /**< The application is being terminated by the OS + SDL_APP_TERMINATING, /**< The application is being terminated by the OS Called on iOS in applicationWillTerminate() Called on Android in onDestroy() */ - SDL_APP_LOWMEMORY, /**< The application is low on memory, free memory if possible. + SDL_APP_LOWMEMORY, /**< The application is low on memory, free memory if possible. Called on iOS in applicationDidReceiveMemoryWarning() Called on Android in onLowMemory() */ - SDL_APP_WILLENTERBACKGROUND, /**< The application is about to enter the background + SDL_APP_WILLENTERBACKGROUND, /**< The application is about to enter the background Called on iOS in applicationWillResignActive() Called on Android in onPause() */ - SDL_APP_DIDENTERBACKGROUND, /**< The application did enter the background and may not get CPU for some time + SDL_APP_DIDENTERBACKGROUND, /**< The application did enter the background and may not get CPU for some time Called on iOS in applicationDidEnterBackground() Called on Android in onPause() */ - SDL_APP_WILLENTERFOREGROUND, /**< The application is about to enter the foreground + SDL_APP_WILLENTERFOREGROUND, /**< The application is about to enter the foreground Called on iOS in applicationWillEnterForeground() Called on Android in onResume() */ - SDL_APP_DIDENTERFOREGROUND, /**< The application is now interactive + SDL_APP_DIDENTERFOREGROUND, /**< The application is now interactive Called on iOS in applicationDidBecomeActive() Called on Android in onResume() */ @@ -112,13 +110,13 @@ typedef enum SDL_JOYDEVICEADDED, /**< A new joystick has been inserted into the system */ SDL_JOYDEVICEREMOVED, /**< An opened joystick has been removed */ - /* Game controller events */ - SDL_CONTROLLERAXISMOTION = 0x650, /**< Game controller axis motion */ - SDL_CONTROLLERBUTTONDOWN, /**< Game controller button pressed */ - SDL_CONTROLLERBUTTONUP, /**< Game controller button released */ - SDL_CONTROLLERDEVICEADDED, /**< A new Game controller has been inserted into the system */ - SDL_CONTROLLERDEVICEREMOVED, /**< An opened Game controller has been removed */ - SDL_CONTROLLERDEVICEREMAPPED, /**< The controller mapping was updated */ + /* Game controller events */ + SDL_CONTROLLERAXISMOTION = 0x650, /**< Game controller axis motion */ + SDL_CONTROLLERBUTTONDOWN, /**< Game controller button pressed */ + SDL_CONTROLLERBUTTONUP, /**< Game controller button released */ + SDL_CONTROLLERDEVICEADDED, /**< A new Game controller has been inserted into the system */ + SDL_CONTROLLERDEVICEREMOVED, /**< An opened Game controller has been removed */ + SDL_CONTROLLERDEVICEREMAPPED, /**< The controller mapping was updated */ /* Touch events */ SDL_FINGERDOWN = 0x700, @@ -135,7 +133,7 @@ typedef enum /* Drag and drop events */ SDL_DROPFILE = 0x1000, /**< The system requests a file open */ - + /** Events ::SDL_USEREVENT through ::SDL_LASTEVENT are for your use, * and should be allocated with SDL_RegisterEvents() */ @@ -155,7 +153,7 @@ typedef struct SDL_CommonEvent Uint32 type; Uint32 timestamp; } SDL_CommonEvent; - + /** * \brief Window state change event data (event.window.*) */ @@ -285,7 +283,7 @@ typedef struct SDL_JoyAxisEvent typedef struct SDL_JoyBallEvent { Uint32 type; /**< ::SDL_JOYBALLMOTION */ - Uint32 timestamp; + Uint32 timestamp; SDL_JoystickID which; /**< The joystick instance id */ Uint8 ball; /**< The joystick trackball index */ Uint8 padding1; @@ -301,14 +299,14 @@ typedef struct SDL_JoyBallEvent typedef struct SDL_JoyHatEvent { Uint32 type; /**< ::SDL_JOYHATMOTION */ - Uint32 timestamp; + Uint32 timestamp; SDL_JoystickID which; /**< The joystick instance id */ Uint8 hat; /**< The joystick hat index */ Uint8 value; /**< The hat position value. * \sa ::SDL_HAT_LEFTUP ::SDL_HAT_UP ::SDL_HAT_RIGHTUP * \sa ::SDL_HAT_LEFT ::SDL_HAT_CENTERED ::SDL_HAT_RIGHT * \sa ::SDL_HAT_LEFTDOWN ::SDL_HAT_DOWN ::SDL_HAT_RIGHTDOWN - * + * * Note that zero means the POV is centered. */ Uint8 padding1; @@ -321,7 +319,7 @@ typedef struct SDL_JoyHatEvent typedef struct SDL_JoyButtonEvent { Uint32 type; /**< ::SDL_JOYBUTTONDOWN or ::SDL_JOYBUTTONUP */ - Uint32 timestamp; + Uint32 timestamp; SDL_JoystickID which; /**< The joystick instance id */ Uint8 button; /**< The joystick button index */ Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */ @@ -334,9 +332,9 @@ typedef struct SDL_JoyButtonEvent */ typedef struct SDL_JoyDeviceEvent { - Uint32 type; /**< ::SDL_JOYDEVICEADDED or ::SDL_JOYDEVICEREMOVED */ - Uint32 timestamp; - Sint32 which; /**< The joystick device index for the ADDED event, instance id for the REMOVED event */ + Uint32 type; /**< ::SDL_JOYDEVICEADDED or ::SDL_JOYDEVICEREMOVED */ + Uint32 timestamp; + Sint32 which; /**< The joystick device index for the ADDED event, instance id for the REMOVED event */ } SDL_JoyDeviceEvent; @@ -346,7 +344,7 @@ typedef struct SDL_JoyDeviceEvent typedef struct SDL_ControllerAxisEvent { Uint32 type; /**< ::SDL_CONTROLLERAXISMOTION */ - Uint32 timestamp; + Uint32 timestamp; SDL_JoystickID which; /**< The joystick instance id */ Uint8 axis; /**< The controller axis (SDL_GameControllerAxis) */ Uint8 padding1; @@ -363,7 +361,7 @@ typedef struct SDL_ControllerAxisEvent typedef struct SDL_ControllerButtonEvent { Uint32 type; /**< ::SDL_CONTROLLERBUTTONDOWN or ::SDL_CONTROLLERBUTTONUP */ - Uint32 timestamp; + Uint32 timestamp; SDL_JoystickID which; /**< The joystick instance id */ Uint8 button; /**< The controller button (SDL_GameControllerButton) */ Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */ @@ -377,9 +375,9 @@ typedef struct SDL_ControllerButtonEvent */ typedef struct SDL_ControllerDeviceEvent { - Uint32 type; /**< ::SDL_CONTROLLERDEVICEADDED, ::SDL_CONTROLLERDEVICEREMOVED, or ::SDL_CONTROLLERDEVICEREMAPPED */ - Uint32 timestamp; - Sint32 which; /**< The joystick device index for the ADDED event, instance id for the REMOVED or REMAPPED event */ + Uint32 type; /**< ::SDL_CONTROLLERDEVICEADDED, ::SDL_CONTROLLERDEVICEREMOVED, or ::SDL_CONTROLLERDEVICEREMAPPED */ + Uint32 timestamp; + Sint32 which; /**< The joystick device index for the ADDED event, instance id for the REMOVED or REMAPPED event */ } SDL_ControllerDeviceEvent; @@ -411,7 +409,7 @@ typedef struct SDL_MultiGestureEvent float dTheta; float dDist; float x; - float y; + float y; Uint16 numFingers; Uint16 padding; } SDL_MultiGestureEvent; @@ -511,9 +509,9 @@ typedef union SDL_Event SDL_JoyHatEvent jhat; /**< Joystick hat event data */ SDL_JoyButtonEvent jbutton; /**< Joystick button event data */ SDL_JoyDeviceEvent jdevice; /**< Joystick device change event data */ - SDL_ControllerAxisEvent caxis; /**< Game Controller axis event data */ - SDL_ControllerButtonEvent cbutton; /**< Game Controller button event data */ - SDL_ControllerDeviceEvent cdevice; /**< Game Controller device event data */ + SDL_ControllerAxisEvent caxis; /**< Game Controller axis event data */ + SDL_ControllerButtonEvent cbutton; /**< Game Controller button event data */ + SDL_ControllerDeviceEvent cdevice; /**< Game Controller device event data */ SDL_QuitEvent quit; /**< Quit request event data */ SDL_UserEvent user; /**< Custom event data */ SDL_SysWMEvent syswm; /**< System dependent window event data */ @@ -537,9 +535,9 @@ typedef union SDL_Event /** * Pumps the event loop, gathering events from the input devices. - * + * * This function updates the event queue and internal input device state. - * + * * This should only be run in the thread that sets the video mode. */ extern DECLSPEC void SDLCALL SDL_PumpEvents(void); @@ -554,20 +552,20 @@ typedef enum /** * Checks the event queue for messages and optionally returns them. - * + * * If \c action is ::SDL_ADDEVENT, up to \c numevents events will be added to * the back of the event queue. - * + * * If \c action is ::SDL_PEEKEVENT, up to \c numevents events at the front * of the event queue, within the specified minimum and maximum type, * will be returned and will not be removed from the queue. - * - * If \c action is ::SDL_GETEVENT, up to \c numevents events at the front + * + * If \c action is ::SDL_GETEVENT, up to \c numevents events at the front * of the event queue, within the specified minimum and maximum type, * will be returned and will be removed from the queue. - * + * * \return The number of events actually stored, or -1 if there was an error. - * + * * This function is thread-safe. */ extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event * events, int numevents, @@ -589,31 +587,31 @@ extern DECLSPEC void SDLCALL SDL_FlushEvents(Uint32 minType, Uint32 maxType); /** * \brief Polls for currently pending events. - * + * * \return 1 if there are any pending events, or 0 if there are none available. - * - * \param event If not NULL, the next event is removed from the queue and + * + * \param event If not NULL, the next event is removed from the queue and * stored in that area. */ extern DECLSPEC int SDLCALL SDL_PollEvent(SDL_Event * event); /** * \brief Waits indefinitely for the next available event. - * + * * \return 1, or 0 if there was an error while waiting for events. - * - * \param event If not NULL, the next event is removed from the queue and + * + * \param event If not NULL, the next event is removed from the queue and * stored in that area. */ extern DECLSPEC int SDLCALL SDL_WaitEvent(SDL_Event * event); /** - * \brief Waits until the specified timeout (in milliseconds) for the next + * \brief Waits until the specified timeout (in milliseconds) for the next * available event. - * + * * \return 1, or 0 if there was an error while waiting for events. - * - * \param event If not NULL, the next event is removed from the queue and + * + * \param event If not NULL, the next event is removed from the queue and * stored in that area. * \param timeout The timeout (in milliseconds) to wait for next event. */ @@ -622,8 +620,8 @@ extern DECLSPEC int SDLCALL SDL_WaitEventTimeout(SDL_Event * event, /** * \brief Add an event to the event queue. - * - * \return 1 on success, 0 if the event was filtered, or -1 if the event queue + * + * \return 1 on success, 0 if the event was filtered, or -1 if the event queue * was full or there was some other error. */ extern DECLSPEC int SDLCALL SDL_PushEvent(SDL_Event * event); @@ -633,20 +631,20 @@ typedef int (SDLCALL * SDL_EventFilter) (void *userdata, SDL_Event * event); /** * Sets up a filter to process all events before they change internal state and * are posted to the internal event queue. - * + * * The filter is prototyped as: * \code * int SDL_EventFilter(void *userdata, SDL_Event * event); * \endcode * * If the filter returns 1, then the event will be added to the internal queue. - * If it returns 0, then the event will be dropped from the queue, but the + * If it returns 0, then the event will be dropped from the queue, but the * internal state will still be updated. This allows selective filtering of * dynamically arriving events. - * - * \warning Be very careful of what you do in the event filter function, as + * + * \warning Be very careful of what you do in the event filter function, as * it may run in a different thread! - * + * * There is one caveat when dealing with the ::SDL_QUITEVENT event type. The * event filter is only called when the window manager desires to close the * application window. If the event filter returns 1, then the window will @@ -685,18 +683,18 @@ extern DECLSPEC void SDLCALL SDL_FilterEvents(SDL_EventFilter filter, void *userdata); /*@{*/ -#define SDL_QUERY -1 -#define SDL_IGNORE 0 -#define SDL_DISABLE 0 -#define SDL_ENABLE 1 +#define SDL_QUERY -1 +#define SDL_IGNORE 0 +#define SDL_DISABLE 0 +#define SDL_ENABLE 1 /** * This function allows you to set the state of processing certain events. - * - If \c state is set to ::SDL_IGNORE, that event will be automatically + * - If \c state is set to ::SDL_IGNORE, that event will be automatically * dropped from the event queue and will not event be filtered. - * - If \c state is set to ::SDL_ENABLE, that event will be processed + * - If \c state is set to ::SDL_ENABLE, that event will be processed * normally. - * - If \c state is set to ::SDL_QUERY, SDL_EventState() will return the + * - If \c state is set to ::SDL_QUERY, SDL_EventState() will return the * current processing state of the specified event. */ extern DECLSPEC Uint8 SDLCALL SDL_EventState(Uint32 type, int state); @@ -714,9 +712,7 @@ extern DECLSPEC Uint32 SDLCALL SDL_RegisterEvents(int numevents); /* Ends C function definitions when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ } -/* *INDENT-ON* */ #endif #include "close_code.h" diff --git a/include/SDL_gamecontroller.h b/include/SDL_gamecontroller.h index 263f196fb..b2e35fb89 100644 --- a/include/SDL_gamecontroller.h +++ b/include/SDL_gamecontroller.h @@ -35,9 +35,7 @@ #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ extern "C" { -/* *INDENT-ON* */ #endif /** @@ -55,10 +53,10 @@ typedef struct _SDL_GameController SDL_GameController; typedef enum { - SDL_CONTROLLER_BINDTYPE_NONE = 0, - SDL_CONTROLLER_BINDTYPE_BUTTON, - SDL_CONTROLLER_BINDTYPE_AXIS, - SDL_CONTROLLER_BINDTYPE_HAT + SDL_CONTROLLER_BINDTYPE_NONE = 0, + SDL_CONTROLLER_BINDTYPE_BUTTON, + SDL_CONTROLLER_BINDTYPE_AXIS, + SDL_CONTROLLER_BINDTYPE_HAT } SDL_GameControllerBindType; /** @@ -66,43 +64,43 @@ typedef enum */ typedef struct SDL_GameControllerButtonBind { - SDL_GameControllerBindType bindType; - union - { - int button; - int axis; - struct { + SDL_GameControllerBindType bindType; + union + { + int button; + int axis; + struct { int hat; int hat_mask; } hat; - } value; + } value; } SDL_GameControllerButtonBind; /** * To count the number of game controllers in the system for the following: - * int nJoysticks = SDL_NumJoysticks(); - * int nGameControllers = 0; - * for ( int i = 0; i < nJoysticks; i++ ) { - * if ( SDL_IsGameController(i) ) { - * nGameControllers++; - * } + * int nJoysticks = SDL_NumJoysticks(); + * int nGameControllers = 0; + * for ( int i = 0; i < nJoysticks; i++ ) { + * if ( SDL_IsGameController(i) ) { + * nGameControllers++; + * } * } * * Using the SDL_HINT_GAMECONTROLLERCONFIG hint or the SDL_GameControllerAddMapping you can add support for controllers SDL is unaware of or cause an existing controller to have a different binding. The format is: - * guid,name,mappings + * guid,name,mappings * * Where GUID is the string value from SDL_JoystickGetGUIDString(), name is the human readable string for the device and mappings are controller mappings to joystick ones. * Under Windows there is a reserved GUID of "xinput" that covers any XInput devices. - * The mapping format for joystick is: - * bX - a joystick button, index X - * hX.Y - hat X with value Y - * aX - axis X of the joystick + * The mapping format for joystick is: + * bX - a joystick button, index X + * hX.Y - hat X with value Y + * aX - axis X of the joystick * Buttons can be used as a controller axis and vice versa. * * This string shows an example of a valid mapping for a controller - * "341a3608000000000000504944564944,Afterglow PS3 Controller,a:b1,b:b2,y:b3,x:b0,start:b9,guide:b12,back:b8,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftshoulder:b4,rightshoulder:b5,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7", + * "341a3608000000000000504944564944,Afterglow PS3 Controller,a:b1,b:b2,y:b3,x:b0,start:b9,guide:b12,back:b8,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftshoulder:b4,rightshoulder:b5,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7", * */ @@ -179,7 +177,7 @@ extern DECLSPEC int SDLCALL SDL_GameControllerEventState(int state); /** * Update the current state of the open game controllers. - * + * * This is called automatically by the event loop if any game controller * events are enabled. */ @@ -191,14 +189,14 @@ extern DECLSPEC void SDLCALL SDL_GameControllerUpdate(void); */ typedef enum { - SDL_CONTROLLER_AXIS_INVALID = -1, - SDL_CONTROLLER_AXIS_LEFTX, - SDL_CONTROLLER_AXIS_LEFTY, - SDL_CONTROLLER_AXIS_RIGHTX, - SDL_CONTROLLER_AXIS_RIGHTY, - SDL_CONTROLLER_AXIS_TRIGGERLEFT, - SDL_CONTROLLER_AXIS_TRIGGERRIGHT, - SDL_CONTROLLER_AXIS_MAX + SDL_CONTROLLER_AXIS_INVALID = -1, + SDL_CONTROLLER_AXIS_LEFTX, + SDL_CONTROLLER_AXIS_LEFTY, + SDL_CONTROLLER_AXIS_RIGHTX, + SDL_CONTROLLER_AXIS_RIGHTY, + SDL_CONTROLLER_AXIS_TRIGGERLEFT, + SDL_CONTROLLER_AXIS_TRIGGERRIGHT, + SDL_CONTROLLER_AXIS_MAX } SDL_GameControllerAxis; /** @@ -234,23 +232,23 @@ SDL_GameControllerGetAxis(SDL_GameController *gamecontroller, */ typedef enum { - SDL_CONTROLLER_BUTTON_INVALID = -1, - SDL_CONTROLLER_BUTTON_A, - SDL_CONTROLLER_BUTTON_B, - SDL_CONTROLLER_BUTTON_X, - SDL_CONTROLLER_BUTTON_Y, - SDL_CONTROLLER_BUTTON_BACK, - SDL_CONTROLLER_BUTTON_GUIDE, - SDL_CONTROLLER_BUTTON_START, - SDL_CONTROLLER_BUTTON_LEFTSTICK, - SDL_CONTROLLER_BUTTON_RIGHTSTICK, - SDL_CONTROLLER_BUTTON_LEFTSHOULDER, - SDL_CONTROLLER_BUTTON_RIGHTSHOULDER, - SDL_CONTROLLER_BUTTON_DPAD_UP, - SDL_CONTROLLER_BUTTON_DPAD_DOWN, - SDL_CONTROLLER_BUTTON_DPAD_LEFT, - SDL_CONTROLLER_BUTTON_DPAD_RIGHT, - SDL_CONTROLLER_BUTTON_MAX + SDL_CONTROLLER_BUTTON_INVALID = -1, + SDL_CONTROLLER_BUTTON_A, + SDL_CONTROLLER_BUTTON_B, + SDL_CONTROLLER_BUTTON_X, + SDL_CONTROLLER_BUTTON_Y, + SDL_CONTROLLER_BUTTON_BACK, + SDL_CONTROLLER_BUTTON_GUIDE, + SDL_CONTROLLER_BUTTON_START, + SDL_CONTROLLER_BUTTON_LEFTSTICK, + SDL_CONTROLLER_BUTTON_RIGHTSTICK, + SDL_CONTROLLER_BUTTON_LEFTSHOULDER, + SDL_CONTROLLER_BUTTON_RIGHTSHOULDER, + SDL_CONTROLLER_BUTTON_DPAD_UP, + SDL_CONTROLLER_BUTTON_DPAD_DOWN, + SDL_CONTROLLER_BUTTON_DPAD_LEFT, + SDL_CONTROLLER_BUTTON_DPAD_RIGHT, + SDL_CONTROLLER_BUTTON_MAX } SDL_GameControllerButton; /** @@ -287,9 +285,7 @@ extern DECLSPEC void SDLCALL SDL_GameControllerClose(SDL_GameController *gamecon /* Ends C function definitions when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ } -/* *INDENT-ON* */ #endif #include "close_code.h" diff --git a/include/SDL_gesture.h b/include/SDL_gesture.h index 458c36775..21f10ead7 100644 --- a/include/SDL_gesture.h +++ b/include/SDL_gesture.h @@ -21,7 +21,7 @@ /** * \file SDL_gesture.h - * + * * Include file for SDL gesture event handling. */ @@ -38,9 +38,7 @@ #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_GestureID; @@ -80,9 +78,7 @@ extern DECLSPEC int SDLCALL SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWo /* Ends C function definitions when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ } -/* *INDENT-ON* */ #endif #include "close_code.h" diff --git a/include/SDL_haptic.h b/include/SDL_haptic.h index 5ea2affd4..6548ad616 100644 --- a/include/SDL_haptic.h +++ b/include/SDL_haptic.h @@ -21,10 +21,10 @@ /** * \file SDL_haptic.h - * + * * \brief The SDL Haptic subsystem allows you to control haptic (force feedback) * devices. - * + * * The basic usage is as follows: * - Initialize the Subsystem (::SDL_INIT_HAPTIC). * - Open a Haptic Device. @@ -119,16 +119,14 @@ #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ extern "C" { - /* *INDENT-ON* */ #endif /* __cplusplus */ /** * \typedef SDL_Haptic - * + * * \brief The haptic structure used to identify an SDL haptic. - * + * * \sa SDL_HapticOpen * \sa SDL_HapticOpenFromJoystick * \sa SDL_HapticClose @@ -139,7 +137,7 @@ typedef struct _SDL_Haptic SDL_Haptic; /** * \name Haptic features - * + * * Different haptic features a device can have. */ /*@{*/ @@ -153,68 +151,68 @@ typedef struct _SDL_Haptic SDL_Haptic; * \brief Constant effect supported. * * Constant haptic effect. - * + * * \sa SDL_HapticCondition */ #define SDL_HAPTIC_CONSTANT (1<<0) /** * \brief Sine wave effect supported. - * + * * Periodic haptic effect that simulates sine waves. - * + * * \sa SDL_HapticPeriodic */ #define SDL_HAPTIC_SINE (1<<1) /** * \brief Square wave effect supported. - * + * * Periodic haptic effect that simulates square waves. - * + * * \sa SDL_HapticPeriodic */ #define SDL_HAPTIC_SQUARE (1<<2) /** * \brief Triangle wave effect supported. - * + * * Periodic haptic effect that simulates triangular waves. - * + * * \sa SDL_HapticPeriodic */ #define SDL_HAPTIC_TRIANGLE (1<<3) /** * \brief Sawtoothup wave effect supported. - * + * * Periodic haptic effect that simulates saw tooth up waves. - * + * * \sa SDL_HapticPeriodic */ #define SDL_HAPTIC_SAWTOOTHUP (1<<4) /** * \brief Sawtoothdown wave effect supported. - * + * * Periodic haptic effect that simulates saw tooth down waves. - * + * * \sa SDL_HapticPeriodic */ #define SDL_HAPTIC_SAWTOOTHDOWN (1<<5) /** * \brief Ramp effect supported. - * + * * Ramp haptic effect. - * + * * \sa SDL_HapticRamp */ #define SDL_HAPTIC_RAMP (1<<6) /** * \brief Spring effect supported - uses axes position. - * + * * Condition haptic effect that simulates a spring. Effect is based on the * axes position. * @@ -224,17 +222,17 @@ typedef struct _SDL_Haptic SDL_Haptic; /** * \brief Damper effect supported - uses axes velocity. - * + * * Condition haptic effect that simulates dampening. Effect is based on the * axes velocity. - * + * * \sa SDL_HapticCondition */ #define SDL_HAPTIC_DAMPER (1<<8) /** * \brief Inertia effect supported - uses axes acceleration. - * + * * Condition haptic effect that simulates inertia. Effect is based on the axes * acceleration. * @@ -244,17 +242,17 @@ typedef struct _SDL_Haptic SDL_Haptic; /** * \brief Friction effect supported - uses axes movement. - * - * Condition haptic effect that simulates friction. Effect is based on the + * + * Condition haptic effect that simulates friction. Effect is based on the * axes movement. - * + * * \sa SDL_HapticCondition */ #define SDL_HAPTIC_FRICTION (1<<10) /** * \brief Custom effect is supported. - * + * * User defined custom haptic effect. */ #define SDL_HAPTIC_CUSTOM (1<<11) @@ -265,34 +263,34 @@ typedef struct _SDL_Haptic SDL_Haptic; /** * \brief Device can set global gain. - * + * * Device supports setting the global gain. - * + * * \sa SDL_HapticSetGain */ #define SDL_HAPTIC_GAIN (1<<12) /** * \brief Device can set autocenter. - * + * * Device supports setting autocenter. - * + * * \sa SDL_HapticSetAutocenter */ #define SDL_HAPTIC_AUTOCENTER (1<<13) /** * \brief Device can be queried for effect status. - * + * * Device can be queried for effect status. - * + * * \sa SDL_HapticGetEffectStatus */ #define SDL_HAPTIC_STATUS (1<<14) /** * \brief Device can be paused. - * + * * \sa SDL_HapticPause * \sa SDL_HapticUnpause */ @@ -306,21 +304,21 @@ typedef struct _SDL_Haptic SDL_Haptic; /** * \brief Uses polar coordinates for the direction. - * + * * \sa SDL_HapticDirection */ #define SDL_HAPTIC_POLAR 0 /** * \brief Uses cartesian coordinates for the direction. - * + * * \sa SDL_HapticDirection */ #define SDL_HAPTIC_CARTESIAN 1 /** * \brief Uses spherical coordinates for the direction. - * + * * \sa SDL_HapticDirection */ #define SDL_HAPTIC_SPHERICAL 2 @@ -343,7 +341,7 @@ typedef struct _SDL_Haptic SDL_Haptic; /** * \brief Structure that represents a haptic direction. - * + * * Directions can be specified by: * - ::SDL_HAPTIC_POLAR : Specified by polar coordinates. * - ::SDL_HAPTIC_CARTESIAN : Specified by cartesian coordinates. @@ -361,8 +359,8 @@ typedef struct _SDL_Haptic SDL_Haptic; | | |'-----'| |__|~')_____(' [ COMPUTER ] - - + + North (0,-1) ^ | @@ -372,22 +370,22 @@ typedef struct _SDL_Haptic SDL_Haptic; | v South (0,1) - - + + [ USER ] \|||/ (o o) ---ooO-(_)-Ooo--- \endverbatim - * - * If type is ::SDL_HAPTIC_POLAR, direction is encoded by hundredths of a + * + * If type is ::SDL_HAPTIC_POLAR, direction is encoded by hundredths of a * degree starting north and turning clockwise. ::SDL_HAPTIC_POLAR only uses * the first \c dir parameter. The cardinal directions would be: * - North: 0 (0 degrees) * - East: 9000 (90 degrees) * - South: 18000 (180 degrees) * - West: 27000 (270 degrees) - * + * * If type is ::SDL_HAPTIC_CARTESIAN, direction is encoded by three positions * (X axis, Y axis and Z axis (with 3 axes)). ::SDL_HAPTIC_CARTESIAN uses * the first three \c dir parameters. The cardinal directions would be: @@ -395,13 +393,13 @@ typedef struct _SDL_Haptic SDL_Haptic; * - East: -1, 0, 0 * - South: 0, 1, 0 * - West: 1, 0, 0 - * + * * The Z axis represents the height of the effect if supported, otherwise * it's unused. In cartesian encoding (1, 2) would be the same as (2, 4), you * can use any multiple you want, only the direction matters. - * + * * If type is ::SDL_HAPTIC_SPHERICAL, direction is encoded by two rotations. - * The first two \c dir parameters are used. The \c dir parameters are as + * The first two \c dir parameters are used. The \c dir parameters are as * follows (all values are in hundredths of degrees): * - Degrees from (1, 0) rotated towards (0, 1). * - Degrees towards (0, 0, 1) (device needs at least 3 axes). @@ -411,17 +409,17 @@ typedef struct _SDL_Haptic SDL_Haptic; * from the south means the user will have to pull the stick to counteract): * \code * SDL_HapticDirection direction; - * + * * // Cartesian directions * direction.type = SDL_HAPTIC_CARTESIAN; // Using cartesian direction encoding. * direction.dir[0] = 0; // X position * direction.dir[1] = 1; // Y position * // Assuming the device has 2 axes, we don't need to specify third parameter. - * + * * // Polar directions * direction.type = SDL_HAPTIC_POLAR; // We'll be using polar direction encoding. * direction.dir[0] = 18000; // Polar only uses first parameter - * + * * // Spherical coordinates * direction.type = SDL_HAPTIC_SPHERICAL; // Spherical encoding * direction.dir[0] = 9000; // Since we only have two axes we don't need more parameters. @@ -442,12 +440,12 @@ typedef struct SDL_HapticDirection /** * \brief A structure containing a template for a Constant effect. - * + * * The struct is exclusive to the ::SDL_HAPTIC_CONSTANT effect. - * + * * A constant effect applies a constant force in the specified direction * to the joystick. - * + * * \sa SDL_HAPTIC_CONSTANT * \sa SDL_HapticEffect */ @@ -477,18 +475,18 @@ typedef struct SDL_HapticConstant /** * \brief A structure containing a template for a Periodic effect. - * + * * The struct handles the following effects: * - ::SDL_HAPTIC_SINE * - ::SDL_HAPTIC_SQUARE * - ::SDL_HAPTIC_TRIANGLE * - ::SDL_HAPTIC_SAWTOOTHUP * - ::SDL_HAPTIC_SAWTOOTHDOWN - * + * * A periodic effect consists in a wave-shaped effect that repeats itself * over time. The type determines the shape of the wave and the parameters * determine the dimensions of the wave. - * + * * Phase is given by hundredth of a cycle meaning that giving the phase a value * of 9000 will displace it 25% of its period. Here are sample values: * - 0: No phase displacement. @@ -503,28 +501,28 @@ typedef struct SDL_HapticConstant __ __ __ __ / \ / \ / \ / / \__/ \__/ \__/ - + SDL_HAPTIC_SQUARE __ __ __ __ __ | | | | | | | | | | | |__| |__| |__| |__| | - + SDL_HAPTIC_TRIANGLE /\ /\ /\ /\ /\ / \ / \ / \ / \ / / \/ \/ \/ \/ - + SDL_HAPTIC_SAWTOOTHUP /| /| /| /| /| /| /| / | / | / | / | / | / | / | / |/ |/ |/ |/ |/ |/ | - + SDL_HAPTIC_SAWTOOTHDOWN \ |\ |\ |\ |\ |\ |\ | \ | \ | \ | \ | \ | \ | \ | \| \| \| \| \| \| \| \endverbatim - * + * * \sa SDL_HAPTIC_SINE * \sa SDL_HAPTIC_SQUARE * \sa SDL_HAPTIC_TRIANGLE @@ -563,21 +561,21 @@ typedef struct SDL_HapticPeriodic /** * \brief A structure containing a template for a Condition effect. - * + * * The struct handles the following effects: * - ::SDL_HAPTIC_SPRING: Effect based on axes position. * - ::SDL_HAPTIC_DAMPER: Effect based on axes velocity. * - ::SDL_HAPTIC_INERTIA: Effect based on axes acceleration. * - ::SDL_HAPTIC_FRICTION: Effect based on axes movement. - * + * * Direction is handled by condition internals instead of a direction member. * The condition effect specific members have three parameters. The first * refers to the X axis, the second refers to the Y axis and the third * refers to the Z axis. The right terms refer to the positive side of the - * axis and the left terms refer to the negative side of the axis. Please + * axis and the left terms refer to the negative side of the axis. Please * refer to the ::SDL_HapticDirection diagram for which side is positive and * which is negative. - * + * * \sa SDL_HapticDirection * \sa SDL_HAPTIC_SPRING * \sa SDL_HAPTIC_DAMPER @@ -611,14 +609,14 @@ typedef struct SDL_HapticCondition /** * \brief A structure containing a template for a Ramp effect. - * + * * This struct is exclusively for the ::SDL_HAPTIC_RAMP effect. - * + * * The ramp effect starts at start strength and ends at end strength. * It augments in linear fashion. If you use attack and fade with a ramp * they effects get added to the ramp effect making the effect become * quadratic instead of linear. - * + * * \sa SDL_HAPTIC_RAMP * \sa SDL_HapticEffect */ @@ -649,14 +647,14 @@ typedef struct SDL_HapticRamp /** * \brief A structure containing a template for the ::SDL_HAPTIC_CUSTOM effect. - * + * * A custom force feedback effect is much like a periodic effect, where the * application can define its exact shape. You will have to allocate the * data yourself. Data should consist of channels * samples Uint16 samples. - * + * * If channels is one, the effect is rotated using the defined direction. * Otherwise it uses the samples in data for the different axes. - * + * * \sa SDL_HAPTIC_CUSTOM * \sa SDL_HapticEffect */ @@ -689,34 +687,34 @@ typedef struct SDL_HapticCustom /** * \brief The generic template for any haptic effect. - * + * * All values max at 32767 (0x7FFF). Signed values also can be negative. * Time values unless specified otherwise are in milliseconds. - * - * You can also pass ::SDL_HAPTIC_INFINITY to length instead of a 0-32767 - * value. Neither delay, interval, attack_length nor fade_length support + * + * You can also pass ::SDL_HAPTIC_INFINITY to length instead of a 0-32767 + * value. Neither delay, interval, attack_length nor fade_length support * ::SDL_HAPTIC_INFINITY. Fade will also not be used since effect never ends. - * + * * Additionally, the ::SDL_HAPTIC_RAMP effect does not support a duration of * ::SDL_HAPTIC_INFINITY. - * + * * Button triggers may not be supported on all devices, it is advised to not * use them if possible. Buttons start at index 1 instead of index 0 like * they joystick. - * + * * If both attack_length and fade_level are 0, the envelope is not used, * otherwise both values are used. - * + * * Common parts: * \code * // Replay - All effects have this * Uint32 length; // Duration of effect (ms). * Uint16 delay; // Delay before starting effect. - * + * * // Trigger - All effects have this * Uint16 button; // Button that triggers effect. * Uint16 interval; // How soon before effect can be triggered again. - * + * * // Envelope - All effects except condition effects have this * Uint16 attack_length; // Duration of the attack (ms). * Uint16 attack_level; // Level at the start of the attack. @@ -734,18 +732,18 @@ typedef struct SDL_HapticCustom | / \ | / \ | / \ - | / \ + | / \ | attack_level --> | \ | | | <--- fade_level | +--------------------------------------------------> Time [--] [---] attack_length fade_length - + [------------------][-----------------------] delay length \endverbatim - * + * * Note either the attack_level or the fade_level may be above the actual * effect level. * @@ -770,17 +768,17 @@ typedef union SDL_HapticEffect /* Function prototypes */ /** * \brief Count the number of joysticks attached to the system. - * + * * \return Number of haptic devices detected on the system. */ extern DECLSPEC int SDLCALL SDL_NumHaptics(void); /** * \brief Get the implementation dependent name of a Haptic device. - * + * * This can be called before any joysticks are opened. * If no name can be found, this function returns NULL. - * + * * \param device_index Index of the device to get its name. * \return Name of the device or NULL on error. * @@ -790,8 +788,8 @@ extern DECLSPEC const char *SDLCALL SDL_HapticName(int device_index); /** * \brief Opens a Haptic device for usage. - * - * The index passed as an argument refers to the N'th Haptic device on this + * + * The index passed as an argument refers to the N'th Haptic device on this * system. * * When opening a haptic device, its gain will be set to maximum and @@ -814,10 +812,10 @@ extern DECLSPEC SDL_Haptic *SDLCALL SDL_HapticOpen(int device_index); /** * \brief Checks if the haptic device at index has been opened. - * + * * \param device_index Index to check to see if it has been opened. * \return 1 if it has been opened or 0 if it hasn't. - * + * * \sa SDL_HapticOpen * \sa SDL_HapticIndex */ @@ -825,10 +823,10 @@ extern DECLSPEC int SDLCALL SDL_HapticOpened(int device_index); /** * \brief Gets the index of a haptic device. - * + * * \param haptic Haptic device to get the index of. * \return The index of the haptic device or -1 on error. - * + * * \sa SDL_HapticOpen * \sa SDL_HapticOpened */ @@ -836,18 +834,18 @@ extern DECLSPEC int SDLCALL SDL_HapticIndex(SDL_Haptic * haptic); /** * \brief Gets whether or not the current mouse has haptic capabilities. - * + * * \return SDL_TRUE if the mouse is haptic, SDL_FALSE if it isn't. - * + * * \sa SDL_HapticOpenFromMouse */ extern DECLSPEC int SDLCALL SDL_MouseIsHaptic(void); /** * \brief Tries to open a haptic device from the current mouse. - * + * * \return The haptic device identifier or NULL on error. - * + * * \sa SDL_MouseIsHaptic * \sa SDL_HapticOpen */ @@ -855,29 +853,29 @@ extern DECLSPEC SDL_Haptic *SDLCALL SDL_HapticOpenFromMouse(void); /** * \brief Checks to see if a joystick has haptic features. - * + * * \param joystick Joystick to test for haptic capabilities. * \return 1 if the joystick is haptic, 0 if it isn't * or -1 if an error ocurred. - * + * * \sa SDL_HapticOpenFromJoystick */ extern DECLSPEC int SDLCALL SDL_JoystickIsHaptic(SDL_Joystick * joystick); /** * \brief Opens a Haptic device for usage from a Joystick device. - * - * You must still close the haptic device seperately. It will not be closed + * + * You must still close the haptic device seperately. It will not be closed * with the joystick. - * + * * When opening from a joystick you should first close the haptic device before * closing the joystick device. If not, on some implementations the haptic * device will also get unallocated and you'll be unable to use force feedback * on that device. - * + * * \param joystick Joystick to create a haptic device from. * \return A valid haptic device identifier on success or NULL on error. - * + * * \sa SDL_HapticOpen * \sa SDL_HapticClose */ @@ -886,34 +884,34 @@ extern DECLSPEC SDL_Haptic *SDLCALL SDL_HapticOpenFromJoystick(SDL_Joystick * /** * \brief Closes a Haptic device previously opened with SDL_HapticOpen(). - * + * * \param haptic Haptic device to close. */ extern DECLSPEC void SDLCALL SDL_HapticClose(SDL_Haptic * haptic); /** * \brief Returns the number of effects a haptic device can store. - * + * * On some platforms this isn't fully supported, and therefore is an * approximation. Always check to see if your created effect was actually * created and do not rely solely on SDL_HapticNumEffects(). - * + * * \param haptic The haptic device to query effect max. * \return The number of effects the haptic device can store or * -1 on error. - * + * * \sa SDL_HapticNumEffectsPlaying * \sa SDL_HapticQuery */ extern DECLSPEC int SDLCALL SDL_HapticNumEffects(SDL_Haptic * haptic); /** - * \brief Returns the number of effects a haptic device can play at the same + * \brief Returns the number of effects a haptic device can play at the same * time. - * - * This is not supported on all platforms, but will always return a value. + * + * This is not supported on all platforms, but will always return a value. * Added here for the sake of completeness. - * + * * \param haptic The haptic device to query maximum playing effects. * \return The number of effects the haptic device can play at the same time * or -1 on error. @@ -925,17 +923,17 @@ extern DECLSPEC int SDLCALL SDL_HapticNumEffectsPlaying(SDL_Haptic * haptic); /** * \brief Gets the haptic devices supported features in bitwise matter. - * - * Example: + * + * Example: * \code * if (SDL_HapticQueryEffects(haptic) & SDL_HAPTIC_CONSTANT) { * printf("We have constant haptic effect!"); * } * \endcode - * + * * \param haptic The haptic device to query. * \return Haptic features in bitwise manner (OR'd). - * + * * \sa SDL_HapticNumEffects * \sa SDL_HapticEffectSupported */ @@ -944,18 +942,18 @@ extern DECLSPEC unsigned int SDLCALL SDL_HapticQuery(SDL_Haptic * haptic); /** * \brief Gets the number of haptic axes the device has. - * + * * \sa SDL_HapticDirection */ extern DECLSPEC int SDLCALL SDL_HapticNumAxes(SDL_Haptic * haptic); /** * \brief Checks to see if effect is supported by haptic. - * + * * \param haptic Haptic device to check on. * \param effect Effect to check to see if it is supported. * \return SDL_TRUE if effect is supported, SDL_FALSE if it isn't or -1 on error. - * + * * \sa SDL_HapticQuery * \sa SDL_HapticNewEffect */ @@ -965,11 +963,11 @@ extern DECLSPEC int SDLCALL SDL_HapticEffectSupported(SDL_Haptic * haptic, /** * \brief Creates a new haptic effect on the device. - * + * * \param haptic Haptic device to create the effect on. * \param effect Properties of the effect to create. * \return The id of the effect on success or -1 on error. - * + * * \sa SDL_HapticUpdateEffect * \sa SDL_HapticRunEffect * \sa SDL_HapticDestroyEffect @@ -979,17 +977,17 @@ extern DECLSPEC int SDLCALL SDL_HapticNewEffect(SDL_Haptic * haptic, /** * \brief Updates the properties of an effect. - * + * * Can be used dynamically, although behaviour when dynamically changing * direction may be strange. Specifically the effect may reupload itself * and start playing from the start. You cannot change the type either when * running SDL_HapticUpdateEffect(). - * + * * \param haptic Haptic device that has the effect. * \param effect Effect to update. * \param data New effect properties to use. * \return The id of the effect on success or -1 on error. - * + * * \sa SDL_HapticNewEffect * \sa SDL_HapticRunEffect * \sa SDL_HapticDestroyEffect @@ -1000,18 +998,18 @@ extern DECLSPEC int SDLCALL SDL_HapticUpdateEffect(SDL_Haptic * haptic, /** * \brief Runs the haptic effect on its associated haptic device. - * + * * If iterations are ::SDL_HAPTIC_INFINITY, it'll run the effect over and over * repeating the envelope (attack and fade) every time. If you only want the * effect to last forever, set ::SDL_HAPTIC_INFINITY in the effect's length * parameter. - * + * * \param haptic Haptic device to run the effect on. * \param effect Identifier of the haptic effect to run. * \param iterations Number of iterations to run the effect. Use * ::SDL_HAPTIC_INFINITY for infinity. * \return 0 on success or -1 on error. - * + * * \sa SDL_HapticStopEffect * \sa SDL_HapticDestroyEffect * \sa SDL_HapticGetEffectStatus @@ -1022,11 +1020,11 @@ extern DECLSPEC int SDLCALL SDL_HapticRunEffect(SDL_Haptic * haptic, /** * \brief Stops the haptic effect on its associated haptic device. - * + * * \param haptic Haptic device to stop the effect on. * \param effect Identifier of the effect to stop. * \return 0 on success or -1 on error. - * + * * \sa SDL_HapticRunEffect * \sa SDL_HapticDestroyEffect */ @@ -1035,13 +1033,13 @@ extern DECLSPEC int SDLCALL SDL_HapticStopEffect(SDL_Haptic * haptic, /** * \brief Destroys a haptic effect on the device. - * - * This will stop the effect if it's running. Effects are automatically + * + * This will stop the effect if it's running. Effects are automatically * destroyed when the device is closed. - * + * * \param haptic Device to destroy the effect on. * \param effect Identifier of the effect to destroy. - * + * * \sa SDL_HapticNewEffect */ extern DECLSPEC void SDLCALL SDL_HapticDestroyEffect(SDL_Haptic * haptic, @@ -1049,14 +1047,14 @@ extern DECLSPEC void SDLCALL SDL_HapticDestroyEffect(SDL_Haptic * haptic, /** * \brief Gets the status of the current effect on the haptic device. - * + * * Device must support the ::SDL_HAPTIC_STATUS feature. - * + * * \param haptic Haptic device to query the effect status on. * \param effect Identifier of the effect to query its status. * \return 0 if it isn't playing, ::SDL_HAPTIC_PLAYING if it is playing * or -1 on error. - * + * * \sa SDL_HapticRunEffect * \sa SDL_HapticStopEffect */ @@ -1065,26 +1063,26 @@ extern DECLSPEC int SDLCALL SDL_HapticGetEffectStatus(SDL_Haptic * haptic, /** * \brief Sets the global gain of the device. - * + * * Device must support the ::SDL_HAPTIC_GAIN feature. - * + * * The user may specify the maximum gain by setting the environment variable * ::SDL_HAPTIC_GAIN_MAX which should be between 0 and 100. All calls to * SDL_HapticSetGain() will scale linearly using ::SDL_HAPTIC_GAIN_MAX as the * maximum. - * + * * \param haptic Haptic device to set the gain on. * \param gain Value to set the gain to, should be between 0 and 100. * \return 0 on success or -1 on error. - * + * * \sa SDL_HapticQuery */ extern DECLSPEC int SDLCALL SDL_HapticSetGain(SDL_Haptic * haptic, int gain); /** * \brief Sets the global autocenter of the device. - * - * Autocenter should be between 0 and 100. Setting it to 0 will disable + * + * Autocenter should be between 0 and 100. Setting it to 0 will disable * autocentering. * * Device must support the ::SDL_HAPTIC_AUTOCENTER feature. @@ -1092,7 +1090,7 @@ extern DECLSPEC int SDLCALL SDL_HapticSetGain(SDL_Haptic * haptic, int gain); * \param haptic Haptic device to set autocentering on. * \param autocenter Value to set autocenter to, 0 disables autocentering. * \return 0 on success or -1 on error. - * + * * \sa SDL_HapticQuery */ extern DECLSPEC int SDLCALL SDL_HapticSetAutocenter(SDL_Haptic * haptic, @@ -1100,35 +1098,35 @@ extern DECLSPEC int SDLCALL SDL_HapticSetAutocenter(SDL_Haptic * haptic, /** * \brief Pauses a haptic device. - * - * Device must support the ::SDL_HAPTIC_PAUSE feature. Call + * + * Device must support the ::SDL_HAPTIC_PAUSE feature. Call * SDL_HapticUnpause() to resume playback. - * + * * Do not modify the effects nor add new ones while the device is paused. * That can cause all sorts of weird errors. - * + * * \param haptic Haptic device to pause. * \return 0 on success or -1 on error. - * + * * \sa SDL_HapticUnpause */ extern DECLSPEC int SDLCALL SDL_HapticPause(SDL_Haptic * haptic); /** * \brief Unpauses a haptic device. - * + * * Call to unpause after SDL_HapticPause(). - * + * * \param haptic Haptic device to pause. * \return 0 on success or -1 on error. - * + * * \sa SDL_HapticPause */ extern DECLSPEC int SDLCALL SDL_HapticUnpause(SDL_Haptic * haptic); /** * \brief Stops all the currently playing effects on a haptic device. - * + * * \param haptic Haptic device to stop. * \return 0 on success or -1 on error. */ @@ -1189,9 +1187,7 @@ extern DECLSPEC int SDLCALL SDL_HapticRumbleStop(SDL_Haptic * haptic); /* Ends C function definitions when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ } -/* *INDENT-ON* */ #endif #include "close_code.h" diff --git a/include/SDL_hints.h b/include/SDL_hints.h index 315a33133..c96d88745 100644 --- a/include/SDL_hints.h +++ b/include/SDL_hints.h @@ -21,7 +21,7 @@ /** * \file SDL_hints.h - * + * * Official documentation for SDL configuration variables * * This file contains functions to set and get configuration hints, @@ -44,13 +44,11 @@ #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ extern "C" { -/* *INDENT-ON* */ #endif /** - * \brief A variable controlling how 3D acceleration is used to accelerate the SDL 1.2 screen surface. + * \brief A variable controlling how 3D acceleration is used to accelerate the SDL 1.2 screen surface. * * SDL can try to accelerate the SDL 1.2 screen surface by using streaming * textures with a 3D rendering engine. This variable controls whether and @@ -169,7 +167,7 @@ extern "C" { */ #define SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS "SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS" - + /** * \brief A variable controlling whether the idle timer is disabled on iOS. * @@ -183,7 +181,7 @@ extern "C" { * "1" - Disable idle timer */ #define SDL_HINT_IDLE_TIMER_DISABLED "SDL_IOS_IDLE_TIMER_DISABLED" - + /** * \brief A variable controlling which orientations are allowed on iOS. * @@ -208,7 +206,7 @@ extern "C" { /** * \brief A variable that lets you manually hint extra gamecontroller db entries - * + * * The variable should be newline delimited rows of gamecontroller config data, see SDL_gamecontroller.h * * This hint must be set before calling SDL_Init(SDL_INIT_GAMECONTROLLER) @@ -219,7 +217,7 @@ extern "C" { /** * \brief If set to 0 then never set the top most bit on a SDL Window, even if the video mode expects it. - * This is a debugging aid for developers and not expected to be used by end users. The default is "1" + * This is a debugging aid for developers and not expected to be used by end users. The default is "1" * * This variable can be set to the following values: * "0" - don't allow topmost @@ -246,7 +244,7 @@ typedef enum * The priority controls the behavior when setting a hint that already * has a value. Hints will replace existing hints of their priority and * lower. Environment variables are considered to have override priority. - * + * * \return SDL_TRUE if the hint was set, SDL_FALSE otherwise */ extern DECLSPEC SDL_bool SDLCALL SDL_SetHintWithPriority(const char *name, @@ -255,7 +253,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_SetHintWithPriority(const char *name, /** * \brief Set a hint with normal priority - * + * * \return SDL_TRUE if the hint was set, SDL_FALSE otherwise */ extern DECLSPEC SDL_bool SDLCALL SDL_SetHint(const char *name, @@ -264,7 +262,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_SetHint(const char *name, /** * \brief Get a hint - * + * * \return The string value of a hint variable. */ extern DECLSPEC const char * SDLCALL SDL_GetHint(const char *name); @@ -279,9 +277,7 @@ extern DECLSPEC void SDLCALL SDL_ClearHints(void); /* Ends C function definitions when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ } -/* *INDENT-ON* */ #endif #include "close_code.h" diff --git a/include/SDL_joystick.h b/include/SDL_joystick.h index c948c05b3..f568f9bd8 100644 --- a/include/SDL_joystick.h +++ b/include/SDL_joystick.h @@ -21,7 +21,7 @@ /** * \file SDL_joystick.h - * + * * Include file for SDL joystick event handling * * The term "device_index" identifies currently plugged in joystick devices between 0 and SDL_NumJoysticks, with the exact joystick @@ -30,7 +30,7 @@ * The term "instance_id" is the current instantiation of a joystick device in the system, if the joystick is removed and then re-inserted * then it will get a new instance_id, instance_id's are monotonically increasing identifiers of a joystick plugged in. * - * The term JoystickGUID is a stable 128-bit identifier for a joystick device that does not change over time, it identifies class of + * The term JoystickGUID is a stable 128-bit identifier for a joystick device that does not change over time, it identifies class of * the device (a X360 wired controller for example). This identifier is platform dependent. * * @@ -45,9 +45,7 @@ #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ extern "C" { -/* *INDENT-ON* */ #endif /** @@ -64,7 +62,7 @@ typedef struct _SDL_Joystick SDL_Joystick; /* A structure that encodes the stable unique id for a joystick device */ typedef struct { - Uint8 data[16]; + Uint8 data[16]; } SDL_JoystickGUID; typedef Sint32 SDL_JoystickID; @@ -84,11 +82,11 @@ extern DECLSPEC int SDLCALL SDL_NumJoysticks(void); extern DECLSPEC const char *SDLCALL SDL_JoystickNameForIndex(int device_index); /** - * Open a joystick for use. - * The index passed as an argument refers tothe N'th joystick on the system. + * Open a joystick for use. + * The index passed as an argument refers tothe N'th joystick on the system. * This index is the value which will identify this joystick in future joystick * events. - * + * * \return A joystick identifier, or NULL if an error occurred. */ extern DECLSPEC SDL_Joystick *SDLCALL SDL_JoystickOpen(int device_index); @@ -98,7 +96,7 @@ extern DECLSPEC SDL_Joystick *SDLCALL SDL_JoystickOpen(int device_index); * If no name can be found, this function returns NULL. */ extern DECLSPEC const char *SDLCALL SDL_JoystickName(SDL_Joystick * joystick); - + /** * Return the GUID for the joystick at this index */ @@ -137,7 +135,7 @@ extern DECLSPEC int SDLCALL SDL_JoystickNumAxes(SDL_Joystick * joystick); /** * Get the number of trackballs on a joystick. - * + * * Joystick trackballs have only relative motion events associated * with them and their state cannot be polled. */ @@ -155,7 +153,7 @@ extern DECLSPEC int SDLCALL SDL_JoystickNumButtons(SDL_Joystick * joystick); /** * Update the current state of the open joysticks. - * + * * This is called automatically by the event loop if any joystick * events are enabled. */ @@ -163,20 +161,20 @@ extern DECLSPEC void SDLCALL SDL_JoystickUpdate(void); /** * Enable/disable joystick event polling. - * + * * If joystick events are disabled, you must call SDL_JoystickUpdate() * yourself and check the state of the joystick when you want joystick * information. - * + * * The state can be one of ::SDL_QUERY, ::SDL_ENABLE or ::SDL_IGNORE. */ extern DECLSPEC int SDLCALL SDL_JoystickEventState(int state); /** * Get the current state of an axis control on a joystick. - * + * * The state is a value ranging from -32768 to 32767. - * + * * The axis indices start at index 0. */ extern DECLSPEC Sint16 SDLCALL SDL_JoystickGetAxis(SDL_Joystick * joystick, @@ -186,22 +184,22 @@ extern DECLSPEC Sint16 SDLCALL SDL_JoystickGetAxis(SDL_Joystick * joystick, * \name Hat positions */ /*@{*/ -#define SDL_HAT_CENTERED 0x00 -#define SDL_HAT_UP 0x01 -#define SDL_HAT_RIGHT 0x02 -#define SDL_HAT_DOWN 0x04 -#define SDL_HAT_LEFT 0x08 -#define SDL_HAT_RIGHTUP (SDL_HAT_RIGHT|SDL_HAT_UP) -#define SDL_HAT_RIGHTDOWN (SDL_HAT_RIGHT|SDL_HAT_DOWN) -#define SDL_HAT_LEFTUP (SDL_HAT_LEFT|SDL_HAT_UP) -#define SDL_HAT_LEFTDOWN (SDL_HAT_LEFT|SDL_HAT_DOWN) +#define SDL_HAT_CENTERED 0x00 +#define SDL_HAT_UP 0x01 +#define SDL_HAT_RIGHT 0x02 +#define SDL_HAT_DOWN 0x04 +#define SDL_HAT_LEFT 0x08 +#define SDL_HAT_RIGHTUP (SDL_HAT_RIGHT|SDL_HAT_UP) +#define SDL_HAT_RIGHTDOWN (SDL_HAT_RIGHT|SDL_HAT_DOWN) +#define SDL_HAT_LEFTUP (SDL_HAT_LEFT|SDL_HAT_UP) +#define SDL_HAT_LEFTDOWN (SDL_HAT_LEFT|SDL_HAT_DOWN) /*@}*/ /** * Get the current state of a POV hat on a joystick. * * The hat indices start at index 0. - * + * * \return The return value is one of the following positions: * - ::SDL_HAT_CENTERED * - ::SDL_HAT_UP @@ -218,9 +216,9 @@ extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetHat(SDL_Joystick * joystick, /** * Get the ball axis change since the last poll. - * + * * \return 0, or -1 if you passed it invalid parameters. - * + * * The ball indices start at index 0. */ extern DECLSPEC int SDLCALL SDL_JoystickGetBall(SDL_Joystick * joystick, @@ -228,7 +226,7 @@ extern DECLSPEC int SDLCALL SDL_JoystickGetBall(SDL_Joystick * joystick, /** * Get the current state of a button on a joystick. - * + * * The button indices start at index 0. */ extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetButton(SDL_Joystick * joystick, @@ -242,9 +240,7 @@ extern DECLSPEC void SDLCALL SDL_JoystickClose(SDL_Joystick * joystick); /* Ends C function definitions when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ } -/* *INDENT-ON* */ #endif #include "close_code.h" diff --git a/include/SDL_keyboard.h b/include/SDL_keyboard.h index e6aa484ec..9b44df322 100644 --- a/include/SDL_keyboard.h +++ b/include/SDL_keyboard.h @@ -21,7 +21,7 @@ /** * \file SDL_keyboard.h - * + * * Include file for SDL keyboard event handling */ @@ -36,9 +36,7 @@ #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ extern "C" { -/* *INDENT-ON* */ #endif /** @@ -61,11 +59,11 @@ extern DECLSPEC SDL_Window * SDLCALL SDL_GetKeyboardFocus(void); /** * \brief Get a snapshot of the current state of the keyboard. - * + * * \param numkeys if non-NULL, receives the length of the returned array. - * + * * \return An array of key states. Indexes into this array are obtained by using ::SDL_Scancode values. - * + * * \b Example: * \code * Uint8 *state = SDL_GetKeyboardState(NULL); @@ -83,7 +81,7 @@ extern DECLSPEC SDL_Keymod SDLCALL SDL_GetModState(void); /** * \brief Set the current key modifier state for the keyboard. - * + * * \note This does not change the keyboard state, only the key modifier flags. */ extern DECLSPEC void SDLCALL SDL_SetModState(SDL_Keymod modstate); @@ -91,9 +89,9 @@ extern DECLSPEC void SDLCALL SDL_SetModState(SDL_Keymod modstate); /** * \brief Get the key code corresponding to the given scancode according * to the current keyboard layout. - * + * * See ::SDL_Keycode for details. - * + * * \sa SDL_GetKeyName() */ extern DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromScancode(SDL_Scancode scancode); @@ -101,16 +99,16 @@ extern DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromScancode(SDL_Scancode scancode /** * \brief Get the scancode corresponding to the given key code according to the * current keyboard layout. - * + * * See ::SDL_Scancode for details. - * + * * \sa SDL_GetScancodeName() */ extern DECLSPEC SDL_Scancode SDLCALL SDL_GetScancodeFromKey(SDL_Keycode key); /** * \brief Get a human-readable name for a scancode. - * + * * \return A pointer to the name for the scancode. * If the scancode doesn't have a name, this function returns * an empty string (""). @@ -121,7 +119,7 @@ extern DECLSPEC const char *SDLCALL SDL_GetScancodeName(SDL_Scancode scancode); /** * \brief Get a scancode from a human-readable name - * + * * \return scancode, or SDL_SCANCODE_UNKNOWN if the name wasn't recognized * * \sa SDL_Scancode @@ -130,19 +128,19 @@ extern DECLSPEC SDL_Scancode SDLCALL SDL_GetScancodeFromName(const char *name); /** * \brief Get a human-readable name for a key. - * + * * \return A pointer to a UTF-8 string that stays valid at least until the next - * call to this function. If you need it around any longer, you must - * copy it. If the key doesn't have a name, this function returns an + * call to this function. If you need it around any longer, you must + * copy it. If the key doesn't have a name, this function returns an * empty string (""). - * + * * \sa SDL_Key */ extern DECLSPEC const char *SDLCALL SDL_GetKeyName(SDL_Keycode key); /** * \brief Get a key code from a human-readable name - * + * * \return key code, or SDLK_UNKNOWN if the name wasn't recognized * * \sa SDL_Keycode @@ -152,7 +150,7 @@ extern DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromName(const char *name); /** * \brief Start accepting Unicode text input events. * This function will show the on-screen keyboard if supported. - * + * * \sa SDL_StopTextInput() * \sa SDL_SetTextInputRect() * \sa SDL_HasScreenKeyboardSupport() @@ -170,7 +168,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_IsTextInputActive(void); /** * \brief Stop receiving any text input events. * This function will hide the on-screen keyboard if supported. - * + * * \sa SDL_StartTextInput() * \sa SDL_HasScreenKeyboardSupport() */ @@ -179,38 +177,36 @@ extern DECLSPEC void SDLCALL SDL_StopTextInput(void); /** * \brief Set the rectangle used to type Unicode text inputs. * This is used as a hint for IME and on-screen keyboard placement. - * + * * \sa SDL_StartTextInput() */ extern DECLSPEC void SDLCALL SDL_SetTextInputRect(SDL_Rect *rect); /** * \brief Returns whether the platform has some screen keyboard support. - * + * * \return SDL_TRUE if some keyboard support is available else SDL_FALSE. - * + * * \note Not all screen keyboard functions are supported on all platforms. - * + * * \sa SDL_IsScreenKeyboardShown() */ extern DECLSPEC SDL_bool SDLCALL SDL_HasScreenKeyboardSupport(void); /** * \brief Returns whether the screen keyboard is shown for given window. - * + * * \param window The window for which screen keyboard should be queried. - * + * * \return SDL_TRUE if screen keyboard is shown else SDL_FALSE. - * + * * \sa SDL_HasScreenKeyboardSupport() */ extern DECLSPEC SDL_bool SDLCALL SDL_IsScreenKeyboardShown(SDL_Window *window); /* Ends C function definitions when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ } -/* *INDENT-ON* */ #endif #include "close_code.h" diff --git a/include/SDL_keycode.h b/include/SDL_keycode.h index 70742b1e5..de584e126 100644 --- a/include/SDL_keycode.h +++ b/include/SDL_keycode.h @@ -21,7 +21,7 @@ /** * \file SDL_keycode.h - * + * * Defines constants which identify keyboard keys and modifiers. */ @@ -33,7 +33,7 @@ /** * \brief The SDL virtual key representation. - * + * * Values of this type are used to represent keyboard keys using the current * layout of the keyboard. These values include Unicode values representing * the unmodified character that would be generated by pressing the key, or @@ -42,7 +42,7 @@ typedef Sint32 SDL_Keycode; #define SDLK_SCANCODE_MASK (1<<30) -#define SDL_SCANCODE_TO_KEYCODE(X) (X | SDLK_SCANCODE_MASK) +#define SDL_SCANCODE_TO_KEYCODE(X) (X | SDLK_SCANCODE_MASK) enum { @@ -85,7 +85,7 @@ enum SDLK_GREATER = '>', SDLK_QUESTION = '?', SDLK_AT = '@', - /* + /* Skip uppercase letters */ SDLK_LEFTBRACKET = '[', @@ -331,10 +331,10 @@ typedef enum KMOD_RESERVED = 0x8000 } SDL_Keymod; -#define KMOD_CTRL (KMOD_LCTRL|KMOD_RCTRL) -#define KMOD_SHIFT (KMOD_LSHIFT|KMOD_RSHIFT) -#define KMOD_ALT (KMOD_LALT|KMOD_RALT) -#define KMOD_GUI (KMOD_LGUI|KMOD_RGUI) +#define KMOD_CTRL (KMOD_LCTRL|KMOD_RCTRL) +#define KMOD_SHIFT (KMOD_LSHIFT|KMOD_RSHIFT) +#define KMOD_ALT (KMOD_LALT|KMOD_RALT) +#define KMOD_GUI (KMOD_LGUI|KMOD_RGUI) #endif /* _SDL_keycode_h */ diff --git a/include/SDL_loadso.h b/include/SDL_loadso.h index edd32d5a0..790d0a724 100644 --- a/include/SDL_loadso.h +++ b/include/SDL_loadso.h @@ -24,7 +24,7 @@ * * System dependent library loading routines * - * Some things to keep in mind: + * Some things to keep in mind: * \li These functions only work on C function names. Other languages may * have name mangling and intrinsic language support that varies from * compiler to compiler. @@ -47,9 +47,7 @@ #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ extern "C" { -/* *INDENT-ON* */ #endif /** @@ -74,9 +72,7 @@ extern DECLSPEC void SDLCALL SDL_UnloadObject(void *handle); /* Ends C function definitions when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ } -/* *INDENT-ON* */ #endif #include "close_code.h" diff --git a/include/SDL_log.h b/include/SDL_log.h index ba56e40e7..79ae4cde4 100644 --- a/include/SDL_log.h +++ b/include/SDL_log.h @@ -21,7 +21,7 @@ /** * \file SDL_log.h - * + * * Simple log messages with categories and priorities. * * By default logs are quiet, but if you're debugging SDL you might want: @@ -42,9 +42,7 @@ #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ extern "C" { -/* *INDENT-ON* */ #endif @@ -60,7 +58,7 @@ extern "C" { * * By default the application category is enabled at the INFO level, * the assert category is enabled at the WARN level, test is enabled - * at the VERBOSE level and all other categories are enabled at the + * at the VERBOSE level and all other categories are enabled at the * CRITICAL level. */ enum @@ -204,9 +202,7 @@ extern DECLSPEC void SDLCALL SDL_LogSetOutputFunction(SDL_LogOutputFunction call /* Ends C function definitions when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ } -/* *INDENT-ON* */ #endif #include "close_code.h" diff --git a/include/SDL_main.h b/include/SDL_main.h index 8a7859fb3..59bd20167 100644 --- a/include/SDL_main.h +++ b/include/SDL_main.h @@ -26,7 +26,7 @@ /** * \file SDL_main.h - * + * * Redefine main() on some platforms so that it is called by SDL. */ @@ -37,7 +37,7 @@ #endif #ifdef __cplusplus -#define C_LINKAGE "C" +#define C_LINKAGE "C" #else #define C_LINKAGE #endif /* __cplusplus */ @@ -58,7 +58,7 @@ */ #ifdef SDL_MAIN_NEEDED -#define main SDL_main +#define main SDL_main #endif /** @@ -69,9 +69,7 @@ extern C_LINKAGE int SDL_main(int argc, char *argv[]); #include "begin_code.h" #ifdef __cplusplus -/* *INDENT-OFF* */ extern "C" { -/* *INDENT-ON* */ #endif #ifdef __WIN32__ @@ -87,9 +85,7 @@ extern DECLSPEC void SDLCALL SDL_UnregisterApp(void); #ifdef __cplusplus -/* *INDENT-OFF* */ } -/* *INDENT-ON* */ #endif #include "close_code.h" diff --git a/include/SDL_messagebox.h b/include/SDL_messagebox.h index c037466ce..cb1a1ccff 100644 --- a/include/SDL_messagebox.h +++ b/include/SDL_messagebox.h @@ -28,9 +28,7 @@ #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ extern "C" { -/* *INDENT-ON* */ #endif /** @@ -137,9 +135,7 @@ extern DECLSPEC int SDLCALL SDL_ShowSimpleMessageBox(Uint32 flags, const char *t /* Ends C function definitions when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ } -/* *INDENT-ON* */ #endif #include "close_code.h" diff --git a/include/SDL_mouse.h b/include/SDL_mouse.h index c91dfbdeb..36c29e90a 100644 --- a/include/SDL_mouse.h +++ b/include/SDL_mouse.h @@ -21,7 +21,7 @@ /** * \file SDL_mouse.h - * + * * Include file for SDL mouse event handling. */ @@ -35,9 +35,7 @@ #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ extern "C" { -/* *INDENT-ON* */ #endif typedef struct SDL_Cursor SDL_Cursor; /* Implementation dependent */ @@ -71,7 +69,7 @@ extern DECLSPEC SDL_Window * SDLCALL SDL_GetMouseFocus(void); /** * \brief Retrieve the current state of the mouse. - * + * * The current button state is returned as a button bitmask, which can * be tested using the SDL_BUTTON(X) macros, and x and y are set to the * mouse cursor position relative to the focus window for the currently @@ -90,11 +88,11 @@ extern DECLSPEC Uint32 SDLCALL SDL_GetRelativeMouseState(int *x, int *y); /** * \brief Moves the mouse to the given position within the window. - * + * * \param window The window to move the mouse into, or NULL for the current mouse focus * \param x The x coordinate within the window * \param y The y coordinate within the window - * + * * \note This function generates a mouse motion event */ extern DECLSPEC void SDLCALL SDL_WarpMouseInWindow(SDL_Window * window, @@ -102,25 +100,25 @@ extern DECLSPEC void SDLCALL SDL_WarpMouseInWindow(SDL_Window * window, /** * \brief Set relative mouse mode. - * + * * \param enabled Whether or not to enable relative mode * * \return 0 on success, or -1 if relative mode is not supported. - * + * * While the mouse is in relative mode, the cursor is hidden, and the * driver will try to report continuous motion in the current window. * Only relative motion events will be delivered, the mouse position * will not change. - * + * * \note This function will flush any pending mouse motion. - * + * * \sa SDL_GetRelativeMouseMode() */ extern DECLSPEC int SDLCALL SDL_SetRelativeMouseMode(SDL_bool enabled); /** * \brief Query whether relative mouse mode is enabled. - * + * * \sa SDL_SetRelativeMouseMode() */ extern DECLSPEC SDL_bool SDLCALL SDL_GetRelativeMouseMode(void); @@ -128,19 +126,19 @@ extern DECLSPEC SDL_bool SDLCALL SDL_GetRelativeMouseMode(void); /** * \brief Create a cursor, using the specified bitmap data and * mask (in MSB format). - * + * * The cursor width must be a multiple of 8 bits. - * + * * The cursor is created in black and white according to the following: * * * * * - * *
data mask resulting pixel on screen
0 1 White
1 1 Black
0 0 Transparent
1 0 Inverted color if possible, black + *
1 0 Inverted color if possible, black * if not.
- * + * * \sa SDL_FreeCursor() */ extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateCursor(const Uint8 * data, @@ -150,7 +148,7 @@ extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateCursor(const Uint8 * data, /** * \brief Create a color cursor. - * + * * \sa SDL_FreeCursor() */ extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateColorCursor(SDL_Surface *surface, @@ -181,17 +179,17 @@ extern DECLSPEC SDL_Cursor *SDLCALL SDL_GetDefaultCursor(void); /** * \brief Frees a cursor created with SDL_CreateCursor(). - * + * * \sa SDL_CreateCursor() */ extern DECLSPEC void SDLCALL SDL_FreeCursor(SDL_Cursor * cursor); /** * \brief Toggle whether or not the cursor is shown. - * - * \param toggle 1 to show the cursor, 0 to hide it, -1 to query the current + * + * \param toggle 1 to show the cursor, 0 to hide it, -1 to query the current * state. - * + * * \return 1 if the cursor is shown, or 0 if the cursor is hidden. */ extern DECLSPEC int SDLCALL SDL_ShowCursor(int toggle); @@ -202,24 +200,22 @@ extern DECLSPEC int SDLCALL SDL_ShowCursor(int toggle); * - Button 2: Middle mouse button * - Button 3: Right mouse button */ -#define SDL_BUTTON(X) (1 << ((X)-1)) -#define SDL_BUTTON_LEFT 1 -#define SDL_BUTTON_MIDDLE 2 -#define SDL_BUTTON_RIGHT 3 -#define SDL_BUTTON_X1 4 -#define SDL_BUTTON_X2 5 -#define SDL_BUTTON_LMASK SDL_BUTTON(SDL_BUTTON_LEFT) -#define SDL_BUTTON_MMASK SDL_BUTTON(SDL_BUTTON_MIDDLE) -#define SDL_BUTTON_RMASK SDL_BUTTON(SDL_BUTTON_RIGHT) -#define SDL_BUTTON_X1MASK SDL_BUTTON(SDL_BUTTON_X1) -#define SDL_BUTTON_X2MASK SDL_BUTTON(SDL_BUTTON_X2) +#define SDL_BUTTON(X) (1 << ((X)-1)) +#define SDL_BUTTON_LEFT 1 +#define SDL_BUTTON_MIDDLE 2 +#define SDL_BUTTON_RIGHT 3 +#define SDL_BUTTON_X1 4 +#define SDL_BUTTON_X2 5 +#define SDL_BUTTON_LMASK SDL_BUTTON(SDL_BUTTON_LEFT) +#define SDL_BUTTON_MMASK SDL_BUTTON(SDL_BUTTON_MIDDLE) +#define SDL_BUTTON_RMASK SDL_BUTTON(SDL_BUTTON_RIGHT) +#define SDL_BUTTON_X1MASK SDL_BUTTON(SDL_BUTTON_X1) +#define SDL_BUTTON_X2MASK SDL_BUTTON(SDL_BUTTON_X2) /* Ends C function definitions when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ } -/* *INDENT-ON* */ #endif #include "close_code.h" diff --git a/include/SDL_mutex.h b/include/SDL_mutex.h index 30519b87f..3efc4a890 100644 --- a/include/SDL_mutex.h +++ b/include/SDL_mutex.h @@ -24,7 +24,7 @@ /** * \file SDL_mutex.h - * + * * Functions to provide thread synchronization primitives. */ @@ -34,21 +34,19 @@ #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ extern "C" { -/* *INDENT-ON* */ #endif /** * Synchronization functions which can time out return this value * if they time out. */ -#define SDL_MUTEX_TIMEDOUT 1 +#define SDL_MUTEX_TIMEDOUT 1 /** * This is the timeout value which corresponds to never time out. */ -#define SDL_MUTEX_MAXWAIT (~(Uint32)0) +#define SDL_MUTEX_MAXWAIT (~(Uint32)0) /** @@ -67,31 +65,31 @@ extern DECLSPEC SDL_mutex *SDLCALL SDL_CreateMutex(void); /** * Lock the mutex. - * + * * \return 0, or -1 on error. */ -#define SDL_mutexP(m) SDL_LockMutex(m) +#define SDL_mutexP(m) SDL_LockMutex(m) extern DECLSPEC int SDLCALL SDL_LockMutex(SDL_mutex * mutex); /** * Try to lock the mutex - * + * * \return 0, SDL_MUTEX_TIMEDOUT, or -1 on error */ extern DECLSPEC int SDLCALL SDL_TryLockMutex(SDL_mutex * mutex); /** * Unlock the mutex. - * + * * \return 0, or -1 on error. - * + * * \warning It is an error to unlock a mutex that has not been locked by * the current thread, and doing so results in undefined behavior. */ -#define SDL_mutexV(m) SDL_UnlockMutex(m) +#define SDL_mutexV(m) SDL_UnlockMutex(m) extern DECLSPEC int SDLCALL SDL_UnlockMutex(SDL_mutex * mutex); -/** +/** * Destroy a mutex. */ extern DECLSPEC void SDLCALL SDL_DestroyMutex(SDL_mutex * mutex); @@ -119,34 +117,34 @@ extern DECLSPEC SDL_sem *SDLCALL SDL_CreateSemaphore(Uint32 initial_value); extern DECLSPEC void SDLCALL SDL_DestroySemaphore(SDL_sem * sem); /** - * This function suspends the calling thread until the semaphore pointed - * to by \c sem has a positive count. It then atomically decreases the + * This function suspends the calling thread until the semaphore pointed + * to by \c sem has a positive count. It then atomically decreases the * semaphore count. */ extern DECLSPEC int SDLCALL SDL_SemWait(SDL_sem * sem); /** * Non-blocking variant of SDL_SemWait(). - * - * \return 0 if the wait succeeds, ::SDL_MUTEX_TIMEDOUT if the wait would + * + * \return 0 if the wait succeeds, ::SDL_MUTEX_TIMEDOUT if the wait would * block, and -1 on error. */ extern DECLSPEC int SDLCALL SDL_SemTryWait(SDL_sem * sem); /** * Variant of SDL_SemWait() with a timeout in milliseconds. - * - * \return 0 if the wait succeeds, ::SDL_MUTEX_TIMEDOUT if the wait does not + * + * \return 0 if the wait succeeds, ::SDL_MUTEX_TIMEDOUT if the wait does not * succeed in the allotted time, and -1 on error. - * - * \warning On some platforms this function is implemented by looping with a + * + * \warning On some platforms this function is implemented by looping with a * delay of 1 ms, and so should be avoided if possible. */ extern DECLSPEC int SDLCALL SDL_SemWaitTimeout(SDL_sem * sem, Uint32 ms); /** * Atomically increases the semaphore's count (not blocking). - * + * * \return 0, or -1 on error. */ extern DECLSPEC int SDLCALL SDL_SemPost(SDL_sem * sem); @@ -205,7 +203,7 @@ extern DECLSPEC void SDLCALL SDL_DestroyCond(SDL_cond * cond); /** * Restart one of the threads that are waiting on the condition variable. - * + * * \return 0 or -1 on error. */ extern DECLSPEC int SDLCALL SDL_CondSignal(SDL_cond * cond); @@ -219,11 +217,11 @@ extern DECLSPEC int SDLCALL SDL_CondBroadcast(SDL_cond * cond); /** * Wait on the condition variable, unlocking the provided mutex. - * + * * \warning The mutex must be locked before entering this function! - * + * * The mutex is re-locked once the condition variable is signaled. - * + * * \return 0 when it is signaled, or -1 on error. */ extern DECLSPEC int SDLCALL SDL_CondWait(SDL_cond * cond, SDL_mutex * mutex); @@ -233,7 +231,7 @@ extern DECLSPEC int SDLCALL SDL_CondWait(SDL_cond * cond, SDL_mutex * mutex); * variable is signaled, ::SDL_MUTEX_TIMEDOUT if the condition is not * signaled in the allotted time, and -1 on error. * - * \warning On some platforms this function is implemented by looping with a + * \warning On some platforms this function is implemented by looping with a * delay of 1 ms, and so should be avoided if possible. */ extern DECLSPEC int SDLCALL SDL_CondWaitTimeout(SDL_cond * cond, @@ -244,9 +242,7 @@ extern DECLSPEC int SDLCALL SDL_CondWaitTimeout(SDL_cond * cond, /* Ends C function definitions when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ } -/* *INDENT-ON* */ #endif #include "close_code.h" diff --git a/include/SDL_name.h b/include/SDL_name.h index 511619af5..d0469e1f2 100644 --- a/include/SDL_name.h +++ b/include/SDL_name.h @@ -6,6 +6,6 @@ #define NeedFunctionPrototypes 1 #endif -#define SDL_NAME(X) SDL_##X +#define SDL_NAME(X) SDL_##X #endif /* _SDLname_h_ */ diff --git a/include/SDL_opengl.h b/include/SDL_opengl.h index 079ed74e1..fecaca0c2 100644 --- a/include/SDL_opengl.h +++ b/include/SDL_opengl.h @@ -21,7 +21,7 @@ /** * \file SDL_opengl.h - * + * * This is a simple file to encapsulate the OpenGL API headers. */ @@ -63,23 +63,22 @@ /** * \file SDL_opengl.h - * + * * This file is included because glext.h is not available on some systems. * If you don't want this version included, simply define ::NO_SDL_GLEXT. - * + * * The latest version is available from: - * http://www.opengl.org/registry/ + * http://www.opengl.org/registry/ */ /** * \def NO_SDL_GLEXT - * - * Define this if you have your own version of glext.h and want to disable the + * + * Define this if you have your own version of glext.h and want to disable the * version included in SDL_opengl.h. */ #if !defined(NO_SDL_GLEXT) && !defined(GL_GLEXT_LEGACY) -/* *INDENT-OFF* */ #ifndef __glext_h_ #define __glext_h_ @@ -89,7 +88,7 @@ extern "C" { /* ** Copyright (c) 2007-2010 The Khronos Group Inc. -** +** ** Permission is hereby granted, free of charge, to any person obtaining a ** copy of this software and/or associated documentation files (the ** "Materials"), to deal in the Materials without restriction, including @@ -97,10 +96,10 @@ extern "C" { ** distribute, sublicense, and/or sell copies of the Materials, and to ** permit persons to whom the Materials are furnished to do so, subject to ** the following conditions: -** +** ** The above copyright notice and this permission notice shall be included ** in all copies or substantial portions of the Materials. -** +** ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. @@ -11122,7 +11121,6 @@ typedef void (APIENTRYP PFNGLVDPAUUNMAPSURFACESNVPROC) (GLsizei numSurface, cons #endif #endif -/* *INDENT-ON* */ #endif /* NO_SDL_GLEXT */ #endif /* !__IPHONEOS__ */ diff --git a/include/SDL_opengles.h b/include/SDL_opengles.h index f33e190d9..00e60f5c1 100644 --- a/include/SDL_opengles.h +++ b/include/SDL_opengles.h @@ -21,7 +21,7 @@ /** * \file SDL_opengles.h - * + * * This is a simple file to encapsulate the OpenGL ES 1.X API headers. */ diff --git a/include/SDL_opengles2.h b/include/SDL_opengles2.h index 3d172c3f1..7697626f4 100644 --- a/include/SDL_opengles2.h +++ b/include/SDL_opengles2.h @@ -21,7 +21,7 @@ /** * \file SDL_opengles.h - * + * * This is a simple file to encapsulate the OpenGL ES 2.0 API headers. */ diff --git a/include/SDL_pixels.h b/include/SDL_pixels.h index e73215260..5e17cba53 100644 --- a/include/SDL_pixels.h +++ b/include/SDL_pixels.h @@ -21,7 +21,7 @@ /** * \file SDL_pixels.h - * + * * Header for the enumerated pixel format definitions. */ @@ -31,14 +31,12 @@ #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ extern "C" { -/* *INDENT-ON* */ #endif /** * \name Transparency definitions - * + * * These define alpha as the opacity of a surface. */ /*@{*/ @@ -117,11 +115,11 @@ enum ((1 << 28) | ((type) << 24) | ((order) << 20) | ((layout) << 16) | \ ((bits) << 8) | ((bytes) << 0)) -#define SDL_PIXELFLAG(X) (((X) >> 28) & 0x0F) -#define SDL_PIXELTYPE(X) (((X) >> 24) & 0x0F) -#define SDL_PIXELORDER(X) (((X) >> 20) & 0x0F) -#define SDL_PIXELLAYOUT(X) (((X) >> 16) & 0x0F) -#define SDL_BITSPERPIXEL(X) (((X) >> 8) & 0xFF) +#define SDL_PIXELFLAG(X) (((X) >> 28) & 0x0F) +#define SDL_PIXELTYPE(X) (((X) >> 24) & 0x0F) +#define SDL_PIXELORDER(X) (((X) >> 20) & 0x0F) +#define SDL_PIXELLAYOUT(X) (((X) >> 16) & 0x0F) +#define SDL_BITSPERPIXEL(X) (((X) >> 8) & 0xFF) #define SDL_BYTESPERPIXEL(X) \ (SDL_ISPIXELFORMAT_FOURCC(X) ? \ ((((X) == SDL_PIXELFORMAT_YUY2) || \ @@ -301,9 +299,9 @@ extern DECLSPEC const char* SDLCALL SDL_GetPixelFormatName(Uint32 format); /** * \brief Convert one of the enumerated pixel formats to a bpp and RGBA masks. - * + * * \return SDL_TRUE, or SDL_FALSE if the conversion wasn't possible. - * + * * \sa SDL_MasksToPixelFormatEnum() */ extern DECLSPEC SDL_bool SDLCALL SDL_PixelFormatEnumToMasks(Uint32 format, @@ -315,10 +313,10 @@ extern DECLSPEC SDL_bool SDLCALL SDL_PixelFormatEnumToMasks(Uint32 format, /** * \brief Convert a bpp and RGBA masks to an enumerated pixel format. - * - * \return The pixel format, or ::SDL_PIXELFORMAT_UNKNOWN if the conversion + * + * \return The pixel format, or ::SDL_PIXELFORMAT_UNKNOWN if the conversion * wasn't possible. - * + * * \sa SDL_PixelFormatEnumToMasks() */ extern DECLSPEC Uint32 SDLCALL SDL_MasksToPixelFormatEnum(int bpp, @@ -338,13 +336,13 @@ extern DECLSPEC SDL_PixelFormat * SDLCALL SDL_AllocFormat(Uint32 pixel_format); extern DECLSPEC void SDLCALL SDL_FreeFormat(SDL_PixelFormat *format); /** - * \brief Create a palette structure with the specified number of color + * \brief Create a palette structure with the specified number of color * entries. - * + * * \return A new palette, or NULL if there wasn't enough memory. - * + * * \note The palette entries are initialized to white. - * + * * \sa SDL_FreePalette() */ extern DECLSPEC SDL_Palette *SDLCALL SDL_AllocPalette(int ncolors); @@ -357,12 +355,12 @@ extern DECLSPEC int SDLCALL SDL_SetPixelFormatPalette(SDL_PixelFormat * format, /** * \brief Set a range of colors in a palette. - * + * * \param palette The palette to modify. * \param colors An array of colors to copy into the palette. * \param firstcolor The index of the first palette entry to modify. * \param ncolors The number of entries to modify. - * + * * \return 0 on success, or -1 if not all of the colors could be set. */ extern DECLSPEC int SDLCALL SDL_SetPaletteColors(SDL_Palette * palette, @@ -371,14 +369,14 @@ extern DECLSPEC int SDLCALL SDL_SetPaletteColors(SDL_Palette * palette, /** * \brief Free a palette created with SDL_AllocPalette(). - * + * * \sa SDL_AllocPalette() */ extern DECLSPEC void SDLCALL SDL_FreePalette(SDL_Palette * palette); /** * \brief Maps an RGB triple to an opaque pixel value for a given pixel format. - * + * * \sa SDL_MapRGBA */ extern DECLSPEC Uint32 SDLCALL SDL_MapRGB(const SDL_PixelFormat * format, @@ -386,7 +384,7 @@ extern DECLSPEC Uint32 SDLCALL SDL_MapRGB(const SDL_PixelFormat * format, /** * \brief Maps an RGBA quadruple to a pixel value for a given pixel format. - * + * * \sa SDL_MapRGB */ extern DECLSPEC Uint32 SDLCALL SDL_MapRGBA(const SDL_PixelFormat * format, @@ -395,7 +393,7 @@ extern DECLSPEC Uint32 SDLCALL SDL_MapRGBA(const SDL_PixelFormat * format, /** * \brief Get the RGB components from a pixel of the specified format. - * + * * \sa SDL_GetRGBA */ extern DECLSPEC void SDLCALL SDL_GetRGB(Uint32 pixel, @@ -404,7 +402,7 @@ extern DECLSPEC void SDLCALL SDL_GetRGB(Uint32 pixel, /** * \brief Get the RGBA components from a pixel of the specified format. - * + * * \sa SDL_GetRGB */ extern DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixel, @@ -420,9 +418,7 @@ extern DECLSPEC void SDLCALL SDL_CalculateGammaRamp(float gamma, Uint16 * ramp); /* Ends C function definitions when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ } -/* *INDENT-ON* */ #endif #include "close_code.h" diff --git a/include/SDL_platform.h b/include/SDL_platform.h index d03bd3866..77ee437cb 100644 --- a/include/SDL_platform.h +++ b/include/SDL_platform.h @@ -21,7 +21,7 @@ /** * \file SDL_platform.h - * + * * Try to get a standard set of platform defines. */ @@ -30,39 +30,39 @@ #if defined(_AIX) #undef __AIX__ -#define __AIX__ 1 +#define __AIX__ 1 #endif #if defined(__BEOS__) #undef __BEOS__ -#define __BEOS__ 1 +#define __BEOS__ 1 #endif #if defined(__HAIKU__) #undef __HAIKU__ -#define __HAIKU__ 1 +#define __HAIKU__ 1 #endif #if defined(bsdi) || defined(__bsdi) || defined(__bsdi__) #undef __BSDI__ -#define __BSDI__ 1 +#define __BSDI__ 1 #endif #if defined(_arch_dreamcast) #undef __DREAMCAST__ -#define __DREAMCAST__ 1 +#define __DREAMCAST__ 1 #endif #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) #undef __FREEBSD__ -#define __FREEBSD__ 1 +#define __FREEBSD__ 1 #endif #if defined(hpux) || defined(__hpux) || defined(__hpux__) #undef __HPUX__ -#define __HPUX__ 1 +#define __HPUX__ 1 #endif #if defined(sgi) || defined(__sgi) || defined(__sgi__) || defined(_SGI_SOURCE) #undef __IRIX__ -#define __IRIX__ 1 +#define __IRIX__ 1 #endif #if defined(linux) || defined(__linux) || defined(__linux__) #undef __LINUX__ -#define __LINUX__ 1 +#define __LINUX__ 1 #endif #if defined(ANDROID) #undef __ANDROID__ @@ -82,53 +82,51 @@ #else /* if not compiling for iPhone */ #undef __MACOSX__ -#define __MACOSX__ 1 +#define __MACOSX__ 1 #endif /* TARGET_OS_IPHONE */ #endif /* defined(__APPLE__) */ #if defined(__NetBSD__) #undef __NETBSD__ -#define __NETBSD__ 1 +#define __NETBSD__ 1 #endif #if defined(__OpenBSD__) #undef __OPENBSD__ -#define __OPENBSD__ 1 +#define __OPENBSD__ 1 #endif #if defined(__OS2__) #undef __OS2__ -#define __OS2__ 1 +#define __OS2__ 1 #endif #if defined(osf) || defined(__osf) || defined(__osf__) || defined(_OSF_SOURCE) #undef __OSF__ -#define __OSF__ 1 +#define __OSF__ 1 #endif #if defined(__QNXNTO__) #undef __QNXNTO__ -#define __QNXNTO__ 1 +#define __QNXNTO__ 1 #endif #if defined(riscos) || defined(__riscos) || defined(__riscos__) #undef __RISCOS__ -#define __RISCOS__ 1 +#define __RISCOS__ 1 #endif #if defined(__SVR4) #undef __SOLARIS__ -#define __SOLARIS__ 1 +#define __SOLARIS__ 1 #endif #if defined(WIN32) || defined(_WIN32) #undef __WIN32__ -#define __WIN32__ 1 +#define __WIN32__ 1 #endif #if defined(__PSP__) #undef __PSP__ -#define __PSP__ 1 +#define __PSP__ 1 #endif #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ extern "C" { -/* *INDENT-ON* */ #endif /** @@ -138,9 +136,7 @@ extern DECLSPEC const char * SDLCALL SDL_GetPlatform (void); /* Ends C function definitions when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ } -/* *INDENT-ON* */ #endif #include "close_code.h" diff --git a/include/SDL_power.h b/include/SDL_power.h index d796aee28..4f70c5bb1 100644 --- a/include/SDL_power.h +++ b/include/SDL_power.h @@ -24,7 +24,7 @@ /** * \file SDL_power.h - * + * * Header for the SDL power management routines. */ @@ -33,9 +33,7 @@ #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ extern "C" { -/* *INDENT-ON* */ #endif /** @@ -53,24 +51,22 @@ typedef enum /** * \brief Get the current power supply details. - * + * * \param secs Seconds of battery life left. You can pass a NULL here if * you don't care. Will return -1 if we can't determine a * value, or we're not running on a battery. - * + * * \param pct Percentage of battery life left, between 0 and 100. You can * pass a NULL here if you don't care. Will return -1 if we * can't determine a value, or we're not running on a battery. - * + * * \return The state of the battery (if any). */ extern DECLSPEC SDL_PowerState SDLCALL SDL_GetPowerInfo(int *secs, int *pct); /* Ends C function definitions when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ } -/* *INDENT-ON* */ #endif #include "close_code.h" diff --git a/include/SDL_quit.h b/include/SDL_quit.h index 5c7d343bd..485e42db0 100644 --- a/include/SDL_quit.h +++ b/include/SDL_quit.h @@ -21,7 +21,7 @@ /** * \file SDL_quit.h - * + * * Include file for SDL quit event handling. */ @@ -33,11 +33,11 @@ /** * \file SDL_quit.h - * + * * An ::SDL_QUIT event is generated when the user tries to close the application * window. If it is ignored or filtered out, the window will remain open. * If it is not ignored or filtered, it is queued normally and the window - * is allowed to close. When the window is closed, screen updates will + * is allowed to close. When the window is closed, screen updates will * complete, but have no effect. * * SDL_Init() installs signal handlers for SIGINT (keyboard interrupt) @@ -46,7 +46,7 @@ * to determine the cause of an ::SDL_QUIT event, but setting a signal * handler in your application will override the default generation of * quit events for that signal. - * + * * \sa SDL_Quit() */ diff --git a/include/SDL_rect.h b/include/SDL_rect.h index 26621a50c..c8af7c197 100644 --- a/include/SDL_rect.h +++ b/include/SDL_rect.h @@ -21,7 +21,7 @@ /** * \file SDL_rect.h - * + * * Header file for SDL_rect definition and management functions. */ @@ -36,9 +36,7 @@ #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ extern "C" { -/* *INDENT-ON* */ #endif /** @@ -54,7 +52,7 @@ typedef struct /** * \brief A rectangle, with the origin at the upper left. - * + * * \sa SDL_RectEmpty * \sa SDL_RectEquals * \sa SDL_HasIntersection @@ -87,7 +85,7 @@ SDL_FORCE_INLINE SDL_bool SDL_RectEquals(const SDL_Rect *a, const SDL_Rect *b) /** * \brief Determine whether two rectangles intersect. - * + * * \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise. */ extern DECLSPEC SDL_bool SDLCALL SDL_HasIntersection(const SDL_Rect * A, @@ -95,7 +93,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_HasIntersection(const SDL_Rect * A, /** * \brief Calculate the intersection of two rectangles. - * + * * \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise. */ extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRect(const SDL_Rect * A, @@ -121,7 +119,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_EnclosePoints(const SDL_Point * points, /** * \brief Calculate the intersection of a rectangle and line segment. - * + * * \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise. */ extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRectAndLine(const SDL_Rect * @@ -131,9 +129,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRectAndLine(const SDL_Rect * /* Ends C function definitions when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ } -/* *INDENT-ON* */ #endif #include "close_code.h" diff --git a/include/SDL_render.h b/include/SDL_render.h index 8ec365a85..aa92559a3 100644 --- a/include/SDL_render.h +++ b/include/SDL_render.h @@ -21,7 +21,7 @@ /** * \file SDL_render.h - * + * * Header file for SDL 2D rendering functions. * * This API supports the following features: @@ -52,9 +52,7 @@ #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ extern "C" { -/* *INDENT-ON* */ #endif /** @@ -62,10 +60,10 @@ extern "C" { */ typedef enum { - SDL_RENDERER_SOFTWARE = 0x00000001, /**< The renderer is a software fallback */ - SDL_RENDERER_ACCELERATED = 0x00000002, /**< The renderer uses hardware + SDL_RENDERER_SOFTWARE = 0x00000001, /**< The renderer is a software fallback */ + SDL_RENDERER_ACCELERATED = 0x00000002, /**< The renderer uses hardware acceleration */ - SDL_RENDERER_PRESENTVSYNC = 0x00000004, /**< Present is synchronized + SDL_RENDERER_PRESENTVSYNC = 0x00000004, /**< Present is synchronized with the refresh rate */ SDL_RENDERER_TARGETTEXTURE = 0x00000008 /**< The renderer supports rendering to texture */ @@ -130,28 +128,28 @@ typedef struct SDL_Texture SDL_Texture; /* Function prototypes */ /** - * \brief Get the number of 2D rendering drivers available for the current + * \brief Get the number of 2D rendering drivers available for the current * display. - * + * * A render driver is a set of code that handles rendering and texture * management on a particular display. Normally there is only one, but * some drivers may have several available with different capabilities. - * + * * \sa SDL_GetRenderDriverInfo() * \sa SDL_CreateRenderer() */ extern DECLSPEC int SDLCALL SDL_GetNumRenderDrivers(void); /** - * \brief Get information about a specific 2D rendering driver for the current + * \brief Get information about a specific 2D rendering driver for the current * display. - * + * * \param index The index of the driver to query information about. - * \param info A pointer to an SDL_RendererInfo struct to be filled with + * \param info A pointer to an SDL_RendererInfo struct to be filled with * information on the rendering driver. - * + * * \return 0 on success, -1 if the index was out of range. - * + * * \sa SDL_CreateRenderer() */ extern DECLSPEC int SDLCALL SDL_GetRenderDriverInfo(int index, @@ -175,14 +173,14 @@ extern DECLSPEC int SDLCALL SDL_CreateWindowAndRenderer( /** * \brief Create a 2D rendering context for a window. - * + * * \param window The window where rendering is displayed. - * \param index The index of the rendering driver to initialize, or -1 to + * \param index The index of the rendering driver to initialize, or -1 to * initialize the first one supporting the requested flags. * \param flags ::SDL_RendererFlags. - * + * * \return A valid rendering context or NULL if there was an error. - * + * * \sa SDL_CreateSoftwareRenderer() * \sa SDL_GetRendererInfo() * \sa SDL_DestroyRenderer() @@ -192,11 +190,11 @@ extern DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRenderer(SDL_Window * window, /** * \brief Create a 2D software rendering context for a surface. - * + * * \param surface The surface where rendering is done. - * + * * \return A valid rendering context or NULL if there was an error. - * + * * \sa SDL_CreateRenderer() * \sa SDL_DestroyRenderer() */ @@ -215,17 +213,17 @@ extern DECLSPEC int SDLCALL SDL_GetRendererInfo(SDL_Renderer * renderer, /** * \brief Create a texture for a rendering context. - * + * * \param renderer The renderer. * \param format The format of the texture. * \param access One of the enumerated values in ::SDL_TextureAccess. * \param w The width of the texture in pixels. * \param h The height of the texture in pixels. - * - * \return The created texture is returned, or 0 if no rendering context was + * + * \return The created texture is returned, or 0 if no rendering context was * active, the format was unsupported, or the width or height were out * of range. - * + * * \sa SDL_QueryTexture() * \sa SDL_UpdateTexture() * \sa SDL_DestroyTexture() @@ -237,14 +235,14 @@ extern DECLSPEC SDL_Texture * SDLCALL SDL_CreateTexture(SDL_Renderer * renderer, /** * \brief Create a texture from an existing surface. - * + * * \param renderer The renderer. * \param surface The surface containing pixel data used to fill the texture. - * + * * \return The created texture is returned, or 0 on error. - * + * * \note The surface is not modified or freed by this function. - * + * * \sa SDL_QueryTexture() * \sa SDL_DestroyTexture() */ @@ -252,15 +250,15 @@ extern DECLSPEC SDL_Texture * SDLCALL SDL_CreateTextureFromSurface(SDL_Renderer /** * \brief Query the attributes of a texture - * + * * \param texture A texture to be queried. - * \param format A pointer filled in with the raw format of the texture. The - * actual format may differ, but pixel transfers will use this + * \param format A pointer filled in with the raw format of the texture. The + * actual format may differ, but pixel transfers will use this * format. * \param access A pointer filled in with the actual access to the texture. * \param w A pointer filled in with the width of the texture in pixels. * \param h A pointer filled in with the height of the texture in pixels. - * + * * \return 0 on success, or -1 if the texture is not valid. */ extern DECLSPEC int SDLCALL SDL_QueryTexture(SDL_Texture * texture, @@ -269,15 +267,15 @@ extern DECLSPEC int SDLCALL SDL_QueryTexture(SDL_Texture * texture, /** * \brief Set an additional color value used in render copy operations. - * + * * \param texture The texture to update. * \param r The red color value multiplied into copy operations. * \param g The green color value multiplied into copy operations. * \param b The blue color value multiplied into copy operations. - * - * \return 0 on success, or -1 if the texture is not valid or color modulation + * + * \return 0 on success, or -1 if the texture is not valid or color modulation * is not supported. - * + * * \sa SDL_GetTextureColorMod() */ extern DECLSPEC int SDLCALL SDL_SetTextureColorMod(SDL_Texture * texture, @@ -286,14 +284,14 @@ extern DECLSPEC int SDLCALL SDL_SetTextureColorMod(SDL_Texture * texture, /** * \brief Get the additional color value used in render copy operations. - * + * * \param texture The texture to query. * \param r A pointer filled in with the current red color value. * \param g A pointer filled in with the current green color value. * \param b A pointer filled in with the current blue color value. - * + * * \return 0 on success, or -1 if the texture is not valid. - * + * * \sa SDL_SetTextureColorMod() */ extern DECLSPEC int SDLCALL SDL_GetTextureColorMod(SDL_Texture * texture, @@ -302,13 +300,13 @@ extern DECLSPEC int SDLCALL SDL_GetTextureColorMod(SDL_Texture * texture, /** * \brief Set an additional alpha value used in render copy operations. - * + * * \param texture The texture to update. * \param alpha The alpha value multiplied into copy operations. - * - * \return 0 on success, or -1 if the texture is not valid or alpha modulation + * + * \return 0 on success, or -1 if the texture is not valid or alpha modulation * is not supported. - * + * * \sa SDL_GetTextureAlphaMod() */ extern DECLSPEC int SDLCALL SDL_SetTextureAlphaMod(SDL_Texture * texture, @@ -316,12 +314,12 @@ extern DECLSPEC int SDLCALL SDL_SetTextureAlphaMod(SDL_Texture * texture, /** * \brief Get the additional alpha value used in render copy operations. - * + * * \param texture The texture to query. * \param alpha A pointer filled in with the current alpha value. - * + * * \return 0 on success, or -1 if the texture is not valid. - * + * * \sa SDL_SetTextureAlphaMod() */ extern DECLSPEC int SDLCALL SDL_GetTextureAlphaMod(SDL_Texture * texture, @@ -329,16 +327,16 @@ extern DECLSPEC int SDLCALL SDL_GetTextureAlphaMod(SDL_Texture * texture, /** * \brief Set the blend mode used for texture copy operations. - * + * * \param texture The texture to update. * \param blendMode ::SDL_BlendMode to use for texture blending. - * + * * \return 0 on success, or -1 if the texture is not valid or the blend mode is * not supported. - * + * * \note If the blend mode is not supported, the closest supported mode is * chosen. - * + * * \sa SDL_GetTextureBlendMode() */ extern DECLSPEC int SDLCALL SDL_SetTextureBlendMode(SDL_Texture * texture, @@ -346,12 +344,12 @@ extern DECLSPEC int SDLCALL SDL_SetTextureBlendMode(SDL_Texture * texture, /** * \brief Get the blend mode used for texture copy operations. - * + * * \param texture The texture to query. * \param blendMode A pointer filled in with the current blend mode. - * + * * \return 0 on success, or -1 if the texture is not valid. - * + * * \sa SDL_SetTextureBlendMode() */ extern DECLSPEC int SDLCALL SDL_GetTextureBlendMode(SDL_Texture * texture, @@ -359,15 +357,15 @@ extern DECLSPEC int SDLCALL SDL_GetTextureBlendMode(SDL_Texture * texture, /** * \brief Update the given texture rectangle with new pixel data. - * + * * \param texture The texture to update - * \param rect A pointer to the rectangle of pixels to update, or NULL to + * \param rect A pointer to the rectangle of pixels to update, or NULL to * update the entire texture. * \param pixels The raw pixel data. * \param pitch The number of bytes between rows of pixel data. - * + * * \return 0 on success, or -1 if the texture is not valid. - * + * * \note This is a fairly slow function. */ extern DECLSPEC int SDLCALL SDL_UpdateTexture(SDL_Texture * texture, @@ -376,17 +374,17 @@ extern DECLSPEC int SDLCALL SDL_UpdateTexture(SDL_Texture * texture, /** * \brief Lock a portion of the texture for write-only pixel access. - * - * \param texture The texture to lock for access, which was created with + * + * \param texture The texture to lock for access, which was created with * ::SDL_TEXTUREACCESS_STREAMING. - * \param rect A pointer to the rectangle to lock for access. If the rect + * \param rect A pointer to the rectangle to lock for access. If the rect * is NULL, the entire texture will be locked. - * \param pixels This is filled in with a pointer to the locked pixels, + * \param pixels This is filled in with a pointer to the locked pixels, * appropriately offset by the locked area. * \param pitch This is filled in with the pitch of the locked pixels. - * + * * \return 0 on success, or -1 if the texture is not valid or was not created with ::SDL_TEXTUREACCESS_STREAMING. - * + * * \sa SDL_UnlockTexture() */ extern DECLSPEC int SDLCALL SDL_LockTexture(SDL_Texture * texture, @@ -395,7 +393,7 @@ extern DECLSPEC int SDLCALL SDL_LockTexture(SDL_Texture * texture, /** * \brief Unlock a texture, uploading the changes to video memory, if needed. - * + * * \sa SDL_LockTexture() */ extern DECLSPEC void SDLCALL SDL_UnlockTexture(SDL_Texture * texture); @@ -446,7 +444,7 @@ extern DECLSPEC SDL_Texture * SDLCALL SDL_GetRenderTarget(SDL_Renderer *renderer * If the output display is a window, mouse events in the window will be filtered * and scaled so they seem to arrive within the logical resolution. * - * \note If this function results in scaling or subpixel drawing by the + * \note If this function results in scaling or subpixel drawing by the * rendering backend, it will be handled using the appropriate * quality hints. * @@ -496,7 +494,7 @@ extern DECLSPEC void SDLCALL SDL_RenderGetViewport(SDL_Renderer * renderer, /** * \brief Set the clip rectangle for the current target. - * + * * \param renderer The renderer for which clip rectangle should be set. * \param rect A pointer to the rectangle to set as the clip rectangle, or * NULL to disable clipping. @@ -510,7 +508,7 @@ extern DECLSPEC int SDLCALL SDL_RenderSetClipRect(SDL_Renderer * renderer, /** * \brief Get the clip rectangle for the current target. - * + * * \param renderer The renderer from which clip rectangle should be queried. * \param rect A pointer filled in with the current clip rectangle, or * an empty rectangle if clipping is disabled. @@ -531,7 +529,7 @@ extern DECLSPEC void SDLCALL SDL_RenderGetClipRect(SDL_Renderer * renderer, * before they are used by the renderer. This allows resolution * independent drawing with a single coordinate system. * - * \note If this results in scaling or subpixel drawing by the + * \note If this results in scaling or subpixel drawing by the * rendering backend, it will be handled using the appropriate * quality hints. For best results use integer scaling factors. * @@ -555,14 +553,14 @@ extern DECLSPEC void SDLCALL SDL_RenderGetScale(SDL_Renderer * renderer, /** * \brief Set the color used for drawing operations (Rect, Line and Clear). - * + * * \param renderer The renderer for which drawing color should be set. * \param r The red value used to draw on the rendering target. * \param g The green value used to draw on the rendering target. * \param b The blue value used to draw on the rendering target. - * \param a The alpha value used to draw on the rendering target, usually + * \param a The alpha value used to draw on the rendering target, usually * ::SDL_ALPHA_OPAQUE (255). - * + * * \return 0 on success, or -1 on error */ extern DECLSPEC int SDL_SetRenderDrawColor(SDL_Renderer * renderer, @@ -571,14 +569,14 @@ extern DECLSPEC int SDL_SetRenderDrawColor(SDL_Renderer * renderer, /** * \brief Get the color used for drawing operations (Rect, Line and Clear). - * + * * \param renderer The renderer from which drawing color should be queried. * \param r A pointer to the red value used to draw on the rendering target. * \param g A pointer to the green value used to draw on the rendering target. * \param b A pointer to the blue value used to draw on the rendering target. - * \param a A pointer to the alpha value used to draw on the rendering target, + * \param a A pointer to the alpha value used to draw on the rendering target, * usually ::SDL_ALPHA_OPAQUE (255). - * + * * \return 0 on success, or -1 on error */ extern DECLSPEC int SDL_GetRenderDrawColor(SDL_Renderer * renderer, @@ -587,15 +585,15 @@ extern DECLSPEC int SDL_GetRenderDrawColor(SDL_Renderer * renderer, /** * \brief Set the blend mode used for drawing operations (Fill and Line). - * + * * \param renderer The renderer for which blend mode should be set. * \param blendMode ::SDL_BlendMode to use for blending. - * + * * \return 0 on success, or -1 on error - * - * \note If the blend mode is not supported, the closest supported mode is + * + * \note If the blend mode is not supported, the closest supported mode is * chosen. - * + * * \sa SDL_GetRenderDrawBlendMode() */ extern DECLSPEC int SDLCALL SDL_SetRenderDrawBlendMode(SDL_Renderer * renderer, @@ -603,12 +601,12 @@ extern DECLSPEC int SDLCALL SDL_SetRenderDrawBlendMode(SDL_Renderer * renderer, /** * \brief Get the blend mode used for drawing operations. - * + * * \param renderer The renderer from which blend mode should be queried. * \param blendMode A pointer filled in with the current blend mode. - * + * * \return 0 on success, or -1 on error - * + * * \sa SDL_SetRenderDrawBlendMode() */ extern DECLSPEC int SDLCALL SDL_GetRenderDrawBlendMode(SDL_Renderer * renderer, @@ -625,11 +623,11 @@ extern DECLSPEC int SDLCALL SDL_RenderClear(SDL_Renderer * renderer); /** * \brief Draw a point on the current rendering target. - * + * * \param renderer The renderer which should draw a point. * \param x The x coordinate of the point. * \param y The y coordinate of the point. - * + * * \return 0 on success, or -1 on error */ extern DECLSPEC int SDLCALL SDL_RenderDrawPoint(SDL_Renderer * renderer, @@ -637,11 +635,11 @@ extern DECLSPEC int SDLCALL SDL_RenderDrawPoint(SDL_Renderer * renderer, /** * \brief Draw multiple points on the current rendering target. - * + * * \param renderer The renderer which should draw multiple points. * \param points The points to draw * \param count The number of points to draw - * + * * \return 0 on success, or -1 on error */ extern DECLSPEC int SDLCALL SDL_RenderDrawPoints(SDL_Renderer * renderer, @@ -650,13 +648,13 @@ extern DECLSPEC int SDLCALL SDL_RenderDrawPoints(SDL_Renderer * renderer, /** * \brief Draw a line on the current rendering target. - * + * * \param renderer The renderer which should draw a line. * \param x1 The x coordinate of the start point. * \param y1 The y coordinate of the start point. * \param x2 The x coordinate of the end point. * \param y2 The y coordinate of the end point. - * + * * \return 0 on success, or -1 on error */ extern DECLSPEC int SDLCALL SDL_RenderDrawLine(SDL_Renderer * renderer, @@ -664,11 +662,11 @@ extern DECLSPEC int SDLCALL SDL_RenderDrawLine(SDL_Renderer * renderer, /** * \brief Draw a series of connected lines on the current rendering target. - * + * * \param renderer The renderer which should draw multiple lines. * \param points The points along the lines * \param count The number of points, drawing count-1 lines - * + * * \return 0 on success, or -1 on error */ extern DECLSPEC int SDLCALL SDL_RenderDrawLines(SDL_Renderer * renderer, @@ -677,10 +675,10 @@ extern DECLSPEC int SDLCALL SDL_RenderDrawLines(SDL_Renderer * renderer, /** * \brief Draw a rectangle on the current rendering target. - * + * * \param renderer The renderer which should draw a rectangle. * \param rect A pointer to the destination rectangle, or NULL to outline the entire rendering target. - * + * * \return 0 on success, or -1 on error */ extern DECLSPEC int SDLCALL SDL_RenderDrawRect(SDL_Renderer * renderer, @@ -688,11 +686,11 @@ extern DECLSPEC int SDLCALL SDL_RenderDrawRect(SDL_Renderer * renderer, /** * \brief Draw some number of rectangles on the current rendering target. - * + * * \param renderer The renderer which should draw multiple rectangles. * \param rects A pointer to an array of destination rectangles. * \param count The number of rectangles. - * + * * \return 0 on success, or -1 on error */ extern DECLSPEC int SDLCALL SDL_RenderDrawRects(SDL_Renderer * renderer, @@ -701,11 +699,11 @@ extern DECLSPEC int SDLCALL SDL_RenderDrawRects(SDL_Renderer * renderer, /** * \brief Fill a rectangle on the current rendering target with the drawing color. - * + * * \param renderer The renderer which should fill a rectangle. - * \param rect A pointer to the destination rectangle, or NULL for the entire + * \param rect A pointer to the destination rectangle, or NULL for the entire * rendering target. - * + * * \return 0 on success, or -1 on error */ extern DECLSPEC int SDLCALL SDL_RenderFillRect(SDL_Renderer * renderer, @@ -713,11 +711,11 @@ extern DECLSPEC int SDLCALL SDL_RenderFillRect(SDL_Renderer * renderer, /** * \brief Fill some number of rectangles on the current rendering target with the drawing color. - * + * * \param renderer The renderer which should fill multiple rectangles. * \param rects A pointer to an array of destination rectangles. * \param count The number of rectangles. - * + * * \return 0 on success, or -1 on error */ extern DECLSPEC int SDLCALL SDL_RenderFillRects(SDL_Renderer * renderer, @@ -726,14 +724,14 @@ extern DECLSPEC int SDLCALL SDL_RenderFillRects(SDL_Renderer * renderer, /** * \brief Copy a portion of the texture to the current rendering target. - * + * * \param renderer The renderer which should copy parts of a texture. * \param texture The source texture. - * \param srcrect A pointer to the source rectangle, or NULL for the entire + * \param srcrect A pointer to the source rectangle, or NULL for the entire * texture. - * \param dstrect A pointer to the destination rectangle, or NULL for the + * \param dstrect A pointer to the destination rectangle, or NULL for the * entire rendering target. - * + * * \return 0 on success, or -1 on error */ extern DECLSPEC int SDLCALL SDL_RenderCopy(SDL_Renderer * renderer, @@ -742,7 +740,7 @@ extern DECLSPEC int SDLCALL SDL_RenderCopy(SDL_Renderer * renderer, const SDL_Rect * dstrect); /** - * \brief Copy a portion of the source texture to the current rendering target, rotating it by angle around the given center + * \brief Copy a portion of the source texture to the current rendering target, rotating it by angle around the given center * * \param renderer The renderer which should copy parts of a texture. * \param texture The source texture. @@ -753,7 +751,7 @@ extern DECLSPEC int SDLCALL SDL_RenderCopy(SDL_Renderer * renderer, * \param angle An angle in degrees that indicates the rotation that will be applied to dstrect * \param center A pointer to a point indicating the point around which dstrect will be rotated (if NULL, rotation will be done aroud dstrect.w/2, dstrect.h/2) * \param flip An SDL_RendererFlip value stating which flipping actions should be performed on the texture - * + * * \return 0 on success, or -1 on error */ extern DECLSPEC int SDLCALL SDL_RenderCopyEx(SDL_Renderer * renderer, @@ -766,17 +764,17 @@ extern DECLSPEC int SDLCALL SDL_RenderCopyEx(SDL_Renderer * renderer, /** * \brief Read pixels from the current rendering target. - * + * * \param renderer The renderer from which pixels should be read. - * \param rect A pointer to the rectangle to read, or NULL for the entire + * \param rect A pointer to the rectangle to read, or NULL for the entire * render target. * \param format The desired format of the pixel data, or 0 to use the format * of the rendering target * \param pixels A pointer to be filled in with the pixel data * \param pitch The pitch of the pixels parameter. - * + * * \return 0 on success, or -1 if pixel reading is not supported. - * + * * \warning This is a very slow operation, and should not be used frequently. */ extern DECLSPEC int SDLCALL SDL_RenderReadPixels(SDL_Renderer * renderer, @@ -791,7 +789,7 @@ extern DECLSPEC void SDLCALL SDL_RenderPresent(SDL_Renderer * renderer); /** * \brief Destroy the specified texture. - * + * * \sa SDL_CreateTexture() * \sa SDL_CreateTextureFromSurface() */ @@ -800,7 +798,7 @@ extern DECLSPEC void SDLCALL SDL_DestroyTexture(SDL_Texture * texture); /** * \brief Destroy the rendering context for a window and free associated * textures. - * + * * \sa SDL_CreateRenderer() */ extern DECLSPEC void SDLCALL SDL_DestroyRenderer(SDL_Renderer * renderer); @@ -830,9 +828,7 @@ extern DECLSPEC int SDLCALL SDL_GL_UnbindTexture(SDL_Texture *texture); /* Ends C function definitions when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ } -/* *INDENT-ON* */ #endif #include "close_code.h" diff --git a/include/SDL_rwops.h b/include/SDL_rwops.h index 3ad1ae4b8..0461ff782 100644 --- a/include/SDL_rwops.h +++ b/include/SDL_rwops.h @@ -21,7 +21,7 @@ /** * \file SDL_rwops.h - * + * * This file provides a general interface for SDL to read and write * data streams. It can easily be extended to files, memory, etc. */ @@ -35,18 +35,16 @@ #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ extern "C" { -/* *INDENT-ON* */ #endif /* RWops Types */ -#define SDL_RWOPS_UNKNOWN 0 /* Unknown stream type */ -#define SDL_RWOPS_WINFILE 1 /* Win32 file */ -#define SDL_RWOPS_STDFILE 2 /* Stdio file */ -#define SDL_RWOPS_JNIFILE 3 /* Android asset */ -#define SDL_RWOPS_MEMORY 4 /* Memory stream */ -#define SDL_RWOPS_MEMORY_RO 5 /* Read-Only memory stream */ +#define SDL_RWOPS_UNKNOWN 0 /* Unknown stream type */ +#define SDL_RWOPS_WINFILE 1 /* Win32 file */ +#define SDL_RWOPS_STDFILE 2 /* Stdio file */ +#define SDL_RWOPS_JNIFILE 3 /* Android asset */ +#define SDL_RWOPS_MEMORY 4 /* Memory stream */ +#define SDL_RWOPS_MEMORY_RO 5 /* Read-Only memory stream */ /** * This is the read/write operation structure -- very basic. @@ -61,7 +59,7 @@ typedef struct SDL_RWops /** * Seek to \c offset relative to \c whence, one of stdio's whence values: * RW_SEEK_SET, RW_SEEK_CUR, RW_SEEK_END - * + * * \return the final offset in the data stream, or -1 on error. */ Sint64 (SDLCALL * seek) (struct SDL_RWops * context, Sint64 offset, @@ -70,7 +68,7 @@ typedef struct SDL_RWops /** * Read up to \c maxnum objects each of size \c size from the data * stream to the area pointed at by \c ptr. - * + * * \return the number of objects read, or 0 at error or end of file. */ size_t (SDLCALL * read) (struct SDL_RWops * context, void *ptr, @@ -79,7 +77,7 @@ typedef struct SDL_RWops /** * Write exactly \c num objects each of size \c size from the area * pointed at by \c ptr to data stream. - * + * * \return the number of objects written, or 0 at error or end of file. */ size_t (SDLCALL * write) (struct SDL_RWops * context, const void *ptr, @@ -87,7 +85,7 @@ typedef struct SDL_RWops /** * Close and free an allocated SDL_RWops structure. - * + * * \return 0 if successful or -1 on write error when flushing data. */ int (SDLCALL * close) (struct SDL_RWops * context); @@ -147,7 +145,7 @@ typedef struct SDL_RWops /** * \name RWFrom functions - * + * * Functions to create SDL_RWops structures from various data streams. */ /*@{*/ @@ -173,28 +171,28 @@ extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromConstMem(const void *mem, extern DECLSPEC SDL_RWops *SDLCALL SDL_AllocRW(void); extern DECLSPEC void SDLCALL SDL_FreeRW(SDL_RWops * area); -#define RW_SEEK_SET 0 /**< Seek from the beginning of data */ -#define RW_SEEK_CUR 1 /**< Seek relative to current read point */ -#define RW_SEEK_END 2 /**< Seek relative to the end of data */ +#define RW_SEEK_SET 0 /**< Seek from the beginning of data */ +#define RW_SEEK_CUR 1 /**< Seek relative to current read point */ +#define RW_SEEK_END 2 /**< Seek relative to the end of data */ /** * \name Read/write macros - * + * * Macros to easily read and write from an SDL_RWops structure. */ /*@{*/ -#define SDL_RWsize(ctx) (ctx)->size(ctx) -#define SDL_RWseek(ctx, offset, whence) (ctx)->seek(ctx, offset, whence) -#define SDL_RWtell(ctx) (ctx)->seek(ctx, 0, RW_SEEK_CUR) -#define SDL_RWread(ctx, ptr, size, n) (ctx)->read(ctx, ptr, size, n) -#define SDL_RWwrite(ctx, ptr, size, n) (ctx)->write(ctx, ptr, size, n) -#define SDL_RWclose(ctx) (ctx)->close(ctx) +#define SDL_RWsize(ctx) (ctx)->size(ctx) +#define SDL_RWseek(ctx, offset, whence) (ctx)->seek(ctx, offset, whence) +#define SDL_RWtell(ctx) (ctx)->seek(ctx, 0, RW_SEEK_CUR) +#define SDL_RWread(ctx, ptr, size, n) (ctx)->read(ctx, ptr, size, n) +#define SDL_RWwrite(ctx, ptr, size, n) (ctx)->write(ctx, ptr, size, n) +#define SDL_RWclose(ctx) (ctx)->close(ctx) /*@}*//*Read/write macros*/ -/** +/** * \name Read endian functions - * + * * Read an item of the specified endianness and return in native format. */ /*@{*/ @@ -207,9 +205,9 @@ extern DECLSPEC Uint64 SDLCALL SDL_ReadLE64(SDL_RWops * src); extern DECLSPEC Uint64 SDLCALL SDL_ReadBE64(SDL_RWops * src); /*@}*//*Read endian functions*/ -/** +/** * \name Write endian functions - * + * * Write an item of native format to the specified endianness. */ /*@{*/ @@ -225,9 +223,7 @@ extern DECLSPEC size_t SDLCALL SDL_WriteBE64(SDL_RWops * dst, Uint64 value); /* Ends C function definitions when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ } -/* *INDENT-ON* */ #endif #include "close_code.h" diff --git a/include/SDL_scancode.h b/include/SDL_scancode.h index 26b8f36b5..d3f874811 100644 --- a/include/SDL_scancode.h +++ b/include/SDL_scancode.h @@ -21,7 +21,7 @@ /** * \file SDL_scancode.h - * + * * Defines keyboard scancodes. */ @@ -32,11 +32,11 @@ /** * \brief The SDL keyboard scancode representation. - * + * * Values of this type are used to represent keyboard keys, among other places * in the \link SDL_Keysym::scancode key.keysym.scancode \endlink field of the * SDL_Event structure. - * + * * The values in this enumeration are based on the USB usage page standard: * http://www.usb.org/developers/devclass_docs/Hut1_12v2.pdf */ @@ -44,9 +44,9 @@ typedef enum { SDL_SCANCODE_UNKNOWN = 0, - /** + /** * \name Usage page 0x07 - * + * * These values are from usage page 0x07 (USB keyboard page). */ /*@{*/ @@ -99,49 +99,49 @@ typedef enum SDL_SCANCODE_EQUALS = 46, SDL_SCANCODE_LEFTBRACKET = 47, SDL_SCANCODE_RIGHTBRACKET = 48, - SDL_SCANCODE_BACKSLASH = 49, /**< Located at the lower left of the return - * key on ISO keyboards and at the right end - * of the QWERTY row on ANSI keyboards. - * Produces REVERSE SOLIDUS (backslash) and - * VERTICAL LINE in a US layout, REVERSE - * SOLIDUS and VERTICAL LINE in a UK Mac - * layout, NUMBER SIGN and TILDE in a UK + SDL_SCANCODE_BACKSLASH = 49, /**< Located at the lower left of the return + * key on ISO keyboards and at the right end + * of the QWERTY row on ANSI keyboards. + * Produces REVERSE SOLIDUS (backslash) and + * VERTICAL LINE in a US layout, REVERSE + * SOLIDUS and VERTICAL LINE in a UK Mac + * layout, NUMBER SIGN and TILDE in a UK * Windows layout, DOLLAR SIGN and POUND SIGN - * in a Swiss German layout, NUMBER SIGN and - * APOSTROPHE in a German layout, GRAVE - * ACCENT and POUND SIGN in a French Mac - * layout, and ASTERISK and MICRO SIGN in a + * in a Swiss German layout, NUMBER SIGN and + * APOSTROPHE in a German layout, GRAVE + * ACCENT and POUND SIGN in a French Mac + * layout, and ASTERISK and MICRO SIGN in a * French Windows layout. */ - SDL_SCANCODE_NONUSHASH = 50, /**< ISO USB keyboards actually use this code - * instead of 49 for the same key, but all - * OSes I've seen treat the two codes + SDL_SCANCODE_NONUSHASH = 50, /**< ISO USB keyboards actually use this code + * instead of 49 for the same key, but all + * OSes I've seen treat the two codes * identically. So, as an implementor, unless - * your keyboard generates both of those + * your keyboard generates both of those * codes and your OS treats them differently, * you should generate SDL_SCANCODE_BACKSLASH - * instead of this code. As a user, you - * should not rely on this code because SDL - * will never generate it with most (all?) - * keyboards. + * instead of this code. As a user, you + * should not rely on this code because SDL + * will never generate it with most (all?) + * keyboards. */ SDL_SCANCODE_SEMICOLON = 51, SDL_SCANCODE_APOSTROPHE = 52, - SDL_SCANCODE_GRAVE = 53, /**< Located in the top left corner (on both ANSI - * and ISO keyboards). Produces GRAVE ACCENT and - * TILDE in a US Windows layout and in US and UK - * Mac layouts on ANSI keyboards, GRAVE ACCENT - * and NOT SIGN in a UK Windows layout, SECTION - * SIGN and PLUS-MINUS SIGN in US and UK Mac - * layouts on ISO keyboards, SECTION SIGN and - * DEGREE SIGN in a Swiss German layout (Mac: - * only on ISO keyboards), CIRCUMFLEX ACCENT and - * DEGREE SIGN in a German layout (Mac: only on + SDL_SCANCODE_GRAVE = 53, /**< Located in the top left corner (on both ANSI + * and ISO keyboards). Produces GRAVE ACCENT and + * TILDE in a US Windows layout and in US and UK + * Mac layouts on ANSI keyboards, GRAVE ACCENT + * and NOT SIGN in a UK Windows layout, SECTION + * SIGN and PLUS-MINUS SIGN in US and UK Mac + * layouts on ISO keyboards, SECTION SIGN and + * DEGREE SIGN in a Swiss German layout (Mac: + * only on ISO keyboards), CIRCUMFLEX ACCENT and + * DEGREE SIGN in a German layout (Mac: only on * ISO keyboards), SUPERSCRIPT TWO and TILDE in a - * French Windows layout, COMMERCIAL AT and - * NUMBER SIGN in a French Mac layout on ISO + * French Windows layout, COMMERCIAL AT and + * NUMBER SIGN in a French Mac layout on ISO * keyboards, and LESS-THAN SIGN and GREATER-THAN - * SIGN in a Swiss German, German, or French Mac + * SIGN in a Swiss German, German, or French Mac * layout on ANSI keyboards. */ SDL_SCANCODE_COMMA = 54, @@ -178,7 +178,7 @@ typedef enum SDL_SCANCODE_DOWN = 81, SDL_SCANCODE_UP = 82, - SDL_SCANCODE_NUMLOCKCLEAR = 83, /**< num lock on PC, clear on Mac keyboards + SDL_SCANCODE_NUMLOCKCLEAR = 83, /**< num lock on PC, clear on Mac keyboards */ SDL_SCANCODE_KP_DIVIDE = 84, SDL_SCANCODE_KP_MULTIPLY = 85, @@ -197,19 +197,19 @@ typedef enum SDL_SCANCODE_KP_0 = 98, SDL_SCANCODE_KP_PERIOD = 99, - SDL_SCANCODE_NONUSBACKSLASH = 100, /**< This is the additional key that ISO - * keyboards have over ANSI ones, - * located between left shift and Y. + SDL_SCANCODE_NONUSBACKSLASH = 100, /**< This is the additional key that ISO + * keyboards have over ANSI ones, + * located between left shift and Y. * Produces GRAVE ACCENT and TILDE in a * US or UK Mac layout, REVERSE SOLIDUS - * (backslash) and VERTICAL LINE in a - * US or UK Windows layout, and + * (backslash) and VERTICAL LINE in a + * US or UK Windows layout, and * LESS-THAN SIGN and GREATER-THAN SIGN * in a Swiss German, German, or French * layout. */ SDL_SCANCODE_APPLICATION = 101, /**< windows contextual menu, compose */ - SDL_SCANCODE_POWER = 102, /**< The USB document says this is a status flag, - * not a physical key - but some Mac keyboards + SDL_SCANCODE_POWER = 102, /**< The USB document says this is a status flag, + * not a physical key - but some Mac keyboards * do have a power key. */ SDL_SCANCODE_KP_EQUALS = 103, SDL_SCANCODE_F13 = 104, @@ -245,7 +245,7 @@ typedef enum SDL_SCANCODE_KP_COMMA = 133, SDL_SCANCODE_KP_EQUALSAS400 = 134, - SDL_SCANCODE_INTERNATIONAL1 = 135, /**< used on Asian keyboards, see + SDL_SCANCODE_INTERNATIONAL1 = 135, /**< used on Asian keyboards, see footnotes in USB doc */ SDL_SCANCODE_INTERNATIONAL2 = 136, SDL_SCANCODE_INTERNATIONAL3 = 137, /**< Yen */ @@ -334,16 +334,16 @@ typedef enum SDL_SCANCODE_RALT = 230, /**< alt gr, option */ SDL_SCANCODE_RGUI = 231, /**< windows, command (apple), meta */ - SDL_SCANCODE_MODE = 257, /**< I'm not sure if this is really not covered - * by any of the above, but since there's a + SDL_SCANCODE_MODE = 257, /**< I'm not sure if this is really not covered + * by any of the above, but since there's a * special KMOD_MODE for it I'm adding it here */ - + /*@}*//*Usage page 0x07*/ /** * \name Usage page 0x0C - * + * * These values are mapped from usage page 0x0C (USB consumer page). */ /*@{*/ @@ -365,34 +365,34 @@ typedef enum SDL_SCANCODE_AC_STOP = 272, SDL_SCANCODE_AC_REFRESH = 273, SDL_SCANCODE_AC_BOOKMARKS = 274, - + /*@}*//*Usage page 0x0C*/ /** * \name Walther keys - * + * * These are values that Christian Walther added (for mac keyboard?). */ /*@{*/ SDL_SCANCODE_BRIGHTNESSDOWN = 275, SDL_SCANCODE_BRIGHTNESSUP = 276, - SDL_SCANCODE_DISPLAYSWITCH = 277, /**< display mirroring/dual display + SDL_SCANCODE_DISPLAYSWITCH = 277, /**< display mirroring/dual display switch, video mode switch */ SDL_SCANCODE_KBDILLUMTOGGLE = 278, SDL_SCANCODE_KBDILLUMDOWN = 279, SDL_SCANCODE_KBDILLUMUP = 280, SDL_SCANCODE_EJECT = 281, SDL_SCANCODE_SLEEP = 282, - - SDL_SCANCODE_APP1 = 283, - SDL_SCANCODE_APP2 = 284, + + SDL_SCANCODE_APP1 = 283, + SDL_SCANCODE_APP2 = 284, /*@}*//*Walther keys*/ /* Add any other keys here. */ - SDL_NUM_SCANCODES = 512 /**< not a key, just marks the number of scancodes + SDL_NUM_SCANCODES = 512 /**< not a key, just marks the number of scancodes for array bounds */ } SDL_Scancode; diff --git a/include/SDL_shape.h b/include/SDL_shape.h index bd3724241..8aee96c85 100644 --- a/include/SDL_shape.h +++ b/include/SDL_shape.h @@ -31,9 +31,7 @@ #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ extern "C" { -/* *INDENT-ON* */ #endif /** \file SDL_shape.h @@ -47,28 +45,28 @@ extern "C" { /** * \brief Create a window that can be shaped with the specified position, dimensions, and flags. - * + * * \param title The title of the window, in UTF-8 encoding. - * \param x The x position of the window, ::SDL_WINDOWPOS_CENTERED, or + * \param x The x position of the window, ::SDL_WINDOWPOS_CENTERED, or * ::SDL_WINDOWPOS_UNDEFINED. - * \param y The y position of the window, ::SDL_WINDOWPOS_CENTERED, or + * \param y The y position of the window, ::SDL_WINDOWPOS_CENTERED, or * ::SDL_WINDOWPOS_UNDEFINED. * \param w The width of the window. * \param h The height of the window. - * \param flags The flags for the window, a mask of SDL_WINDOW_BORDERLESS with any of the following: + * \param flags The flags for the window, a mask of SDL_WINDOW_BORDERLESS with any of the following: * ::SDL_WINDOW_OPENGL, ::SDL_WINDOW_INPUT_GRABBED, * ::SDL_WINDOW_SHOWN, ::SDL_WINDOW_RESIZABLE, * ::SDL_WINDOW_MAXIMIZED, ::SDL_WINDOW_MINIMIZED, - * ::SDL_WINDOW_BORDERLESS is always set, and ::SDL_WINDOW_FULLSCREEN is always unset. - * + * ::SDL_WINDOW_BORDERLESS is always set, and ::SDL_WINDOW_FULLSCREEN is always unset. + * * \return The window created, or NULL if window creation failed. - * + * * \sa SDL_DestroyWindow() */ extern DECLSPEC SDL_Window * SDLCALL SDL_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags); /** - * \brief Return whether the given window is a shaped window. + * \brief Return whether the given window is a shaped window. * * \param window The window to query for being shaped. * @@ -79,31 +77,31 @@ extern DECLSPEC SDL_bool SDLCALL SDL_IsShapedWindow(const SDL_Window *window); /** \brief An enum denoting the specific type of contents present in an SDL_WindowShapeParams union. */ typedef enum { - /** \brief The default mode, a binarized alpha cutoff of 1. */ - ShapeModeDefault, - /** \brief A binarized alpha cutoff with a given integer value. */ - ShapeModeBinarizeAlpha, - /** \brief A binarized alpha cutoff with a given integer value, but with the opposite comparison. */ - ShapeModeReverseBinarizeAlpha, - /** \brief A color key is applied. */ - ShapeModeColorKey + /** \brief The default mode, a binarized alpha cutoff of 1. */ + ShapeModeDefault, + /** \brief A binarized alpha cutoff with a given integer value. */ + ShapeModeBinarizeAlpha, + /** \brief A binarized alpha cutoff with a given integer value, but with the opposite comparison. */ + ShapeModeReverseBinarizeAlpha, + /** \brief A color key is applied. */ + ShapeModeColorKey } WindowShapeMode; #define SDL_SHAPEMODEALPHA(mode) (mode == ShapeModeDefault || mode == ShapeModeBinarizeAlpha || mode == ShapeModeReverseBinarizeAlpha) /** \brief A union containing parameters for shaped windows. */ typedef union { - /** \brief a cutoff alpha value for binarization of the window shape's alpha channel. */ - Uint8 binarizationCutoff; - SDL_Color colorKey; + /** \brief a cutoff alpha value for binarization of the window shape's alpha channel. */ + Uint8 binarizationCutoff; + SDL_Color colorKey; } SDL_WindowShapeParams; /** \brief A struct that tags the SDL_WindowShapeParams union with an enum describing the type of its contents. */ typedef struct SDL_WindowShapeMode { - /** \brief The mode of these window-shape parameters. */ - WindowShapeMode mode; - /** \brief Window-shape parameters. */ - SDL_WindowShapeParams parameters; + /** \brief The mode of these window-shape parameters. */ + WindowShapeMode mode; + /** \brief Window-shape parameters. */ + SDL_WindowShapeParams parameters; } SDL_WindowShapeMode; /** @@ -138,9 +136,7 @@ extern DECLSPEC int SDLCALL SDL_GetShapedWindowMode(SDL_Window *window,SDL_Windo /* Ends C function definitions when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ } -/* *INDENT-ON* */ #endif #include "close_code.h" diff --git a/include/SDL_stdinc.h b/include/SDL_stdinc.h index b1ce99390..a53044517 100644 --- a/include/SDL_stdinc.h +++ b/include/SDL_stdinc.h @@ -21,7 +21,7 @@ /** * \file SDL_stdinc.h - * + * * This is a general header that includes C language support. */ @@ -80,12 +80,12 @@ /** * The number of elements in an array. */ -#define SDL_arraysize(array) (sizeof(array)/sizeof(array[0])) -#define SDL_TABLESIZE(table) SDL_arraysize(table) +#define SDL_arraysize(array) (sizeof(array)/sizeof(array[0])) +#define SDL_TABLESIZE(table) SDL_arraysize(table) /** * \name Cast operators - * + * * Use proper C++ casts when compiled as C++ to be compatible with the option * -Wold-style-cast of GCC (and -Werror=old-style-cast in GCC 4.2 and above). */ @@ -179,7 +179,7 @@ SDL_COMPILE_TIME_ASSERT(sint64, sizeof(Sint64) == 8); /** \cond */ #ifndef DOXYGEN_SHOULD_IGNORE_THIS -#if !defined(__ANDROID__) +#if !defined(__ANDROID__) /* TODO: include/SDL_stdinc.h:174: error: size of array 'SDL_dummy_enum' is negative */ typedef enum { @@ -194,9 +194,7 @@ SDL_COMPILE_TIME_ASSERT(enum, sizeof(SDL_DUMMY_ENUM) == sizeof(int)); #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ extern "C" { -/* *INDENT-ON* */ #endif #if defined(HAVE_ALLOCA) && !defined(alloca) @@ -758,10 +756,10 @@ SDL_FORCE_INLINE double SDL_sqrt_inline(double x) { return sqrt(x); } #endif /* The SDL implementation of iconv() returns these error codes */ -#define SDL_ICONV_ERROR (size_t)-1 -#define SDL_ICONV_E2BIG (size_t)-2 -#define SDL_ICONV_EILSEQ (size_t)-3 -#define SDL_ICONV_EINVAL (size_t)-4 +#define SDL_ICONV_ERROR (size_t)-1 +#define SDL_ICONV_E2BIG (size_t)-2 +#define SDL_ICONV_EILSEQ (size_t)-3 +#define SDL_ICONV_EINVAL (size_t)-4 /* SDL_iconv_* are now always real symbols/types, not macros or inlined. */ typedef struct _SDL_iconv_t *SDL_iconv_t; @@ -779,15 +777,13 @@ extern DECLSPEC char *SDLCALL SDL_iconv_string(const char *tocode, const char *fromcode, const char *inbuf, size_t inbytesleft); -#define SDL_iconv_utf8_locale(S) SDL_iconv_string("", "UTF-8", S, SDL_strlen(S)+1) -#define SDL_iconv_utf8_ucs2(S) (Uint16 *)SDL_iconv_string("UCS-2-INTERNAL", "UTF-8", S, SDL_strlen(S)+1) -#define SDL_iconv_utf8_ucs4(S) (Uint32 *)SDL_iconv_string("UCS-4-INTERNAL", "UTF-8", S, SDL_strlen(S)+1) +#define SDL_iconv_utf8_locale(S) SDL_iconv_string("", "UTF-8", S, SDL_strlen(S)+1) +#define SDL_iconv_utf8_ucs2(S) (Uint16 *)SDL_iconv_string("UCS-2-INTERNAL", "UTF-8", S, SDL_strlen(S)+1) +#define SDL_iconv_utf8_ucs4(S) (Uint32 *)SDL_iconv_string("UCS-4-INTERNAL", "UTF-8", S, SDL_strlen(S)+1) /* Ends C function definitions when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ } -/* *INDENT-ON* */ #endif #include "close_code.h" diff --git a/include/SDL_surface.h b/include/SDL_surface.h index a066b885c..4ebeadd8f 100644 --- a/include/SDL_surface.h +++ b/include/SDL_surface.h @@ -21,7 +21,7 @@ /** * \file SDL_surface.h - * + * * Header file for ::SDL_surface definition and management functions. */ @@ -37,16 +37,14 @@ #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ extern "C" { -/* *INDENT-ON* */ #endif /** * \name Surface flags - * + * * These are the currently supported flags for the ::SDL_surface. - * + * * \internal * Used internally (read-only). */ @@ -60,7 +58,7 @@ extern "C" { /** * Evaluates to true if the surface needs to be locked before access. */ -#define SDL_MUSTLOCK(S) (((S)->flags & SDL_RLEACCEL) != 0) +#define SDL_MUSTLOCK(S) (((S)->flags & SDL_RLEACCEL) != 0) /** * \brief A collection of pixels used in software blitting. @@ -101,13 +99,13 @@ typedef int (*SDL_blit) (struct SDL_Surface * src, SDL_Rect * srcrect, /** * Allocate and free an RGB surface. - * + * * If the depth is 4 or 8 bits, an empty palette is allocated for the surface. * If the depth is greater than 8 bits, the pixel format is set using the * flags '[RGB]mask'. - * + * * If the function runs out of memory, it will return NULL. - * + * * \param flags The \c flags are obsolete and should be set to 0. * \param width The width in pixels of the surface to create. * \param height The height in pixels of the surface to create. @@ -133,9 +131,9 @@ extern DECLSPEC void SDLCALL SDL_FreeSurface(SDL_Surface * surface); /** * \brief Set the palette used by a surface. - * + * * \return 0, or -1 if the surface format doesn't use a palette. - * + * * \note A single palette can be shared with many surfaces. */ extern DECLSPEC int SDLCALL SDL_SetSurfacePalette(SDL_Surface * surface, @@ -143,21 +141,21 @@ extern DECLSPEC int SDLCALL SDL_SetSurfacePalette(SDL_Surface * surface, /** * \brief Sets up a surface for directly accessing the pixels. - * + * * Between calls to SDL_LockSurface() / SDL_UnlockSurface(), you can write - * to and read from \c surface->pixels, using the pixel format stored in - * \c surface->format. Once you are done accessing the surface, you should + * to and read from \c surface->pixels, using the pixel format stored in + * \c surface->format. Once you are done accessing the surface, you should * use SDL_UnlockSurface() to release it. - * + * * Not all surfaces require locking. If SDL_MUSTLOCK(surface) evaluates * to 0, then you can read and write to the surface at any time, and the * pixel format of the surface will not change. - * + * * No operating system or library calls should be made between lock/unlock * pairs, as critical system locks may be held during this time. - * + * * SDL_LockSurface() returns 0, or -1 if the surface couldn't be locked. - * + * * \sa SDL_UnlockSurface() */ extern DECLSPEC int SDLCALL SDL_LockSurface(SDL_Surface * surface); @@ -166,11 +164,11 @@ extern DECLSPEC void SDLCALL SDL_UnlockSurface(SDL_Surface * surface); /** * Load a surface from a seekable SDL data stream (memory or file). - * + * * If \c freesrc is non-zero, the stream will be closed after being read. - * + * * The new surface should be freed with SDL_FreeSurface(). - * + * * \return the new surface, or NULL if there was an error. */ extern DECLSPEC SDL_Surface *SDLCALL SDL_LoadBMP_RW(SDL_RWops * src, @@ -178,34 +176,34 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_LoadBMP_RW(SDL_RWops * src, /** * Load a surface from a file. - * + * * Convenience macro. */ -#define SDL_LoadBMP(file) SDL_LoadBMP_RW(SDL_RWFromFile(file, "rb"), 1) +#define SDL_LoadBMP(file) SDL_LoadBMP_RW(SDL_RWFromFile(file, "rb"), 1) /** * Save a surface to a seekable SDL data stream (memory or file). - * + * * If \c freedst is non-zero, the stream will be closed after being written. - * + * * \return 0 if successful or -1 if there was an error. */ extern DECLSPEC int SDLCALL SDL_SaveBMP_RW (SDL_Surface * surface, SDL_RWops * dst, int freedst); -/** +/** * Save a surface to a file. - * + * * Convenience macro. */ #define SDL_SaveBMP(surface, file) \ - SDL_SaveBMP_RW(surface, SDL_RWFromFile(file, "wb"), 1) + SDL_SaveBMP_RW(surface, SDL_RWFromFile(file, "wb"), 1) /** * \brief Sets the RLE acceleration hint for a surface. - * + * * \return 0 on success, or -1 if the surface is not valid - * + * * \note If RLE is enabled, colorkey and alpha blending blits are much faster, * but the surface must be locked before directly accessing the pixels. */ @@ -214,11 +212,11 @@ extern DECLSPEC int SDLCALL SDL_SetSurfaceRLE(SDL_Surface * surface, /** * \brief Sets the color key (transparent pixel) in a blittable surface. - * + * * \param surface The surface to update * \param flag Non-zero to enable colorkey and 0 to disable colorkey * \param key The transparent pixel in the native surface format - * + * * \return 0 on success, or -1 if the surface is not valid * * You can pass SDL_RLEACCEL to enable RLE accelerated blits. @@ -228,12 +226,12 @@ extern DECLSPEC int SDLCALL SDL_SetColorKey(SDL_Surface * surface, /** * \brief Gets the color key (transparent pixel) in a blittable surface. - * + * * \param surface The surface to update - * \param key A pointer filled in with the transparent pixel in the native + * \param key A pointer filled in with the transparent pixel in the native * surface format - * - * \return 0 on success, or -1 if the surface is not valid or colorkey is not + * + * \return 0 on success, or -1 if the surface is not valid or colorkey is not * enabled. */ extern DECLSPEC int SDLCALL SDL_GetColorKey(SDL_Surface * surface, @@ -241,14 +239,14 @@ extern DECLSPEC int SDLCALL SDL_GetColorKey(SDL_Surface * surface, /** * \brief Set an additional color value used in blit operations. - * + * * \param surface The surface to update. * \param r The red color value multiplied into blit operations. * \param g The green color value multiplied into blit operations. * \param b The blue color value multiplied into blit operations. - * + * * \return 0 on success, or -1 if the surface is not valid. - * + * * \sa SDL_GetSurfaceColorMod() */ extern DECLSPEC int SDLCALL SDL_SetSurfaceColorMod(SDL_Surface * surface, @@ -257,14 +255,14 @@ extern DECLSPEC int SDLCALL SDL_SetSurfaceColorMod(SDL_Surface * surface, /** * \brief Get the additional color value used in blit operations. - * + * * \param surface The surface to query. * \param r A pointer filled in with the current red color value. * \param g A pointer filled in with the current green color value. * \param b A pointer filled in with the current blue color value. - * + * * \return 0 on success, or -1 if the surface is not valid. - * + * * \sa SDL_SetSurfaceColorMod() */ extern DECLSPEC int SDLCALL SDL_GetSurfaceColorMod(SDL_Surface * surface, @@ -273,12 +271,12 @@ extern DECLSPEC int SDLCALL SDL_GetSurfaceColorMod(SDL_Surface * surface, /** * \brief Set an additional alpha value used in blit operations. - * + * * \param surface The surface to update. * \param alpha The alpha value multiplied into blit operations. - * + * * \return 0 on success, or -1 if the surface is not valid. - * + * * \sa SDL_GetSurfaceAlphaMod() */ extern DECLSPEC int SDLCALL SDL_SetSurfaceAlphaMod(SDL_Surface * surface, @@ -286,12 +284,12 @@ extern DECLSPEC int SDLCALL SDL_SetSurfaceAlphaMod(SDL_Surface * surface, /** * \brief Get the additional alpha value used in blit operations. - * + * * \param surface The surface to query. * \param alpha A pointer filled in with the current alpha value. - * + * * \return 0 on success, or -1 if the surface is not valid. - * + * * \sa SDL_SetSurfaceAlphaMod() */ extern DECLSPEC int SDLCALL SDL_GetSurfaceAlphaMod(SDL_Surface * surface, @@ -299,12 +297,12 @@ extern DECLSPEC int SDLCALL SDL_GetSurfaceAlphaMod(SDL_Surface * surface, /** * \brief Set the blend mode used for blit operations. - * + * * \param surface The surface to update. * \param blendMode ::SDL_BlendMode to use for blit blending. - * + * * \return 0 on success, or -1 if the parameters are not valid. - * + * * \sa SDL_GetSurfaceBlendMode() */ extern DECLSPEC int SDLCALL SDL_SetSurfaceBlendMode(SDL_Surface * surface, @@ -312,12 +310,12 @@ extern DECLSPEC int SDLCALL SDL_SetSurfaceBlendMode(SDL_Surface * surface, /** * \brief Get the blend mode used for blit operations. - * + * * \param surface The surface to query. * \param blendMode A pointer filled in with the current blend mode. - * + * * \return 0 on success, or -1 if the surface is not valid. - * + * * \sa SDL_SetSurfaceBlendMode() */ extern DECLSPEC int SDLCALL SDL_GetSurfaceBlendMode(SDL_Surface * surface, @@ -325,14 +323,14 @@ extern DECLSPEC int SDLCALL SDL_GetSurfaceBlendMode(SDL_Surface * surface, /** * Sets the clipping rectangle for the destination surface in a blit. - * + * * If the clip rectangle is NULL, clipping will be disabled. - * + * * If the clip rectangle doesn't intersect the surface, the function will * return SDL_FALSE and blits will be completely clipped. Otherwise the * function returns SDL_TRUE and blits to the surface will be clipped to * the intersection of the surface area and the clipping rectangle. - * + * * Note that blits are automatically clipped to the edges of the source * and destination surfaces. */ @@ -341,7 +339,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_SetClipRect(SDL_Surface * surface, /** * Gets the clipping rectangle for the destination surface in a blit. - * + * * \c rect must be a pointer to a valid rectangle which will be filled * with the correct values. */ @@ -349,11 +347,11 @@ extern DECLSPEC void SDLCALL SDL_GetClipRect(SDL_Surface * surface, SDL_Rect * rect); /** - * Creates a new surface of the specified format, and then copies and maps - * the given surface to it so the blit of the converted surface will be as + * Creates a new surface of the specified format, and then copies and maps + * the given surface to it so the blit of the converted surface will be as * fast as possible. If this function fails, it returns NULL. - * - * The \c flags parameter is passed to SDL_CreateRGBSurface() and has those + * + * The \c flags parameter is passed to SDL_CreateRGBSurface() and has those * semantics. You can also pass ::SDL_RLEACCEL in the flags parameter and * SDL will try to RLE accelerate colorkey and alpha blits in the resulting * surface. @@ -365,7 +363,7 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurfaceFormat /** * \brief Copy a block of pixels of one format to another format - * + * * \return 0 on success, or -1 if there was an error */ extern DECLSPEC int SDLCALL SDL_ConvertPixels(int width, int height, @@ -376,12 +374,12 @@ extern DECLSPEC int SDLCALL SDL_ConvertPixels(int width, int height, /** * Performs a fast fill of the given rectangle with \c color. - * + * * If \c rect is NULL, the whole surface will be filled with \c color. - * - * The color should be a pixel of the format used by the surface, and + * + * The color should be a pixel of the format used by the surface, and * can be generated by the SDL_MapRGB() function. - * + * * \return 0 on success, or -1 on error. */ extern DECLSPEC int SDLCALL SDL_FillRect @@ -391,12 +389,12 @@ extern DECLSPEC int SDLCALL SDL_FillRects /** * Performs a fast blit from the source surface to the destination surface. - * + * * This assumes that the source and destination rectangles are * the same size. If either \c srcrect or \c dstrect are NULL, the entire * surface (\c src or \c dst) is copied. The final blit rectangles are saved * in \c srcrect and \c dstrect after all clipping is performed. - * + * * \return If the blit is successful, it returns 0, otherwise it returns -1. * * The blit function should not be called on a locked surface. @@ -413,7 +411,7 @@ extern DECLSPEC int SDLCALL SDL_FillRects if SDL_SRCCOLORKEY set, only copy the pixels matching the RGB values of the source color key, ignoring alpha in the comparison. - + RGB->RGBA: SDL_SRCALPHA set: alpha-blend (using the source per-surface alpha value); @@ -423,7 +421,7 @@ extern DECLSPEC int SDLCALL SDL_FillRects both: if SDL_SRCCOLORKEY set, only copy the pixels matching the source color key. - + RGBA->RGBA: SDL_SRCALPHA set: alpha-blend (using the source alpha channel) the RGB values; @@ -434,8 +432,8 @@ extern DECLSPEC int SDLCALL SDL_FillRects if SDL_SRCCOLORKEY set, only copy the pixels matching the RGB values of the source color key, ignoring alpha in the comparison. - - RGB->RGB: + + RGB->RGB: SDL_SRCALPHA set: alpha-blend (using the source per-surface alpha value). SDL_SRCALPHA not set: @@ -444,7 +442,7 @@ extern DECLSPEC int SDLCALL SDL_FillRects if SDL_SRCCOLORKEY set, only copy the pixels matching the source color key. \endverbatim - * + * * You should call SDL_BlitSurface() unless you know exactly how SDL * blitting works internally and how to use the other blit functions. */ @@ -469,7 +467,7 @@ extern DECLSPEC int SDLCALL SDL_LowerBlit /** * \brief Perform a fast, low quality, stretch blit between two surfaces of the * same pixel format. - * + * * \note This function uses a static buffer, and is not thread-safe. */ extern DECLSPEC int SDLCALL SDL_SoftStretch(SDL_Surface * src, @@ -498,9 +496,7 @@ extern DECLSPEC int SDLCALL SDL_LowerBlitScaled /* Ends C function definitions when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ } -/* *INDENT-ON* */ #endif #include "close_code.h" diff --git a/include/SDL_system.h b/include/SDL_system.h index d5db78fd5..5a6126157 100644 --- a/include/SDL_system.h +++ b/include/SDL_system.h @@ -21,7 +21,7 @@ /** * \file SDL_system.h - * + * * Include file for platform specific SDL API functions */ @@ -38,9 +38,7 @@ #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ extern "C" { -/* *INDENT-ON* */ #endif /* Platform specific functions for iOS */ @@ -98,9 +96,7 @@ extern DECLSPEC const char * SDLCALL SDL_AndroidGetExternalStoragePath(); /* Ends C function definitions when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ } -/* *INDENT-ON* */ #endif #include "close_code.h" diff --git a/include/SDL_syswm.h b/include/SDL_syswm.h index 786e12e5c..3ea026b44 100644 --- a/include/SDL_syswm.h +++ b/include/SDL_syswm.h @@ -21,7 +21,7 @@ /** * \file SDL_syswm.h - * + * * Include file for SDL custom system window manager hooks. */ @@ -36,14 +36,12 @@ #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ extern "C" { -/* *INDENT-ON* */ #endif /** * \file SDL_syswm.h - * + * * Your application has access to a special type of event ::SDL_SYSWMEVENT, * which contains window-manager specific information and arrives whenever * an unhandled window event occurs. This event is ignored by default, but @@ -95,7 +93,7 @@ typedef struct _UIWindow UIWindow; #endif #endif -/** +/** * These are the various supported windowing subsystems */ typedef enum @@ -209,14 +207,14 @@ typedef struct SDL_SysWMinfo SDL_SysWMinfo; /* Function prototypes */ /** * \brief This function allows access to driver-dependent window information. - * + * * \param window The window about which information is being requested - * \param info This structure must be initialized with the SDL version, and is + * \param info This structure must be initialized with the SDL version, and is * then filled in with information about the given window. - * - * \return SDL_TRUE if the function is implemented and the version member of + * + * \return SDL_TRUE if the function is implemented and the version member of * the \c info struct is valid, SDL_FALSE otherwise. - * + * * You typically use this function like this: * \code * SDL_SysWMinfo info; @@ -230,9 +228,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowWMInfo(SDL_Window * window, /* Ends C function definitions when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ } -/* *INDENT-ON* */ #endif #include "close_code.h" diff --git a/include/SDL_test.h b/include/SDL_test.h index 15e7689f0..7e0de0894 100644 --- a/include/SDL_test.h +++ b/include/SDL_test.h @@ -21,7 +21,7 @@ /** * \file SDL_test.h - * + * * Include file for SDL test framework. * * This code is a part of the SDL2_test library, not the main SDL library. @@ -46,24 +46,20 @@ #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ extern "C" { -/* *INDENT-ON* */ #endif /* Global definitions */ -/* - * Note: Maximum size of SDLTest log message is less than SDLs limit - * to ensure we can fit additional information such as the timestamp. +/* + * Note: Maximum size of SDLTest log message is less than SDLs limit + * to ensure we can fit additional information such as the timestamp. */ -#define SDLTEST_MAX_LOGMESSAGE_LENGTH 3584 +#define SDLTEST_MAX_LOGMESSAGE_LENGTH 3584 /* Ends C function definitions when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ } -/* *INDENT-ON* */ #endif #include "close_code.h" diff --git a/include/SDL_test_assert.h b/include/SDL_test_assert.h index 17b6d26b6..beba16f5e 100644 --- a/include/SDL_test_assert.h +++ b/include/SDL_test_assert.h @@ -21,13 +21,13 @@ /** * \file SDL_test_assert.h - * + * * Include file for SDL test framework. * * This code is a part of the SDL2_test library, not the main SDL library. */ -/* +/* * * Assert API for test code and test cases * @@ -39,20 +39,18 @@ #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ extern "C" { -/* *INDENT-ON* */ #endif /** * \brief Fails the assert. */ -#define ASSERT_FAIL 0 +#define ASSERT_FAIL 0 /** * \brief Passes the assert. */ -#define ASSERT_PASS 1 +#define ASSERT_PASS 1 /** * \brief Assert that logs and break execution flow on failures. @@ -98,9 +96,7 @@ void SDLTest_LogAssertSummary(); int SDLTest_AssertSummaryToTestResult(); #ifdef __cplusplus -/* *INDENT-OFF* */ } -/* *INDENT-ON* */ #endif #include "close_code.h" diff --git a/include/SDL_test_common.h b/include/SDL_test_common.h index 9e9122f1b..76ad87781 100644 --- a/include/SDL_test_common.h +++ b/include/SDL_test_common.h @@ -21,7 +21,7 @@ /** * \file SDL_test_common.h - * + * * Include file for SDL test framework. * * This code is a part of the SDL2_test library, not the main SDL library. @@ -109,9 +109,7 @@ typedef struct #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ extern "C" { -/* *INDENT-ON* */ #endif /* Function prototypes */ @@ -175,9 +173,7 @@ void SDLTest_CommonQuit(SDLTest_CommonState * state); /* Ends C function definitions when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ } -/* *INDENT-ON* */ #endif #include "close_code.h" diff --git a/include/SDL_test_compare.h b/include/SDL_test_compare.h index e145f6908..98ca8ce81 100644 --- a/include/SDL_test_compare.h +++ b/include/SDL_test_compare.h @@ -21,16 +21,16 @@ /** * \file SDL_test_compare.h - * + * * Include file for SDL test framework. * * This code is a part of the SDL2_test library, not the main SDL library. */ -/* +/* Defines comparison functions (i.e. for surfaces). - + */ #ifndef _SDL_test_compare_h @@ -43,9 +43,7 @@ #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ extern "C" { -/* *INDENT-ON* */ #endif /** @@ -58,13 +56,11 @@ extern "C" { * \returns 0 if comparison succeeded, >0 (=number of pixels where comparison failed) if comparison failed, -1 if any of the surfaces were NULL, -2 if the surface sizes differ. */ int SDLTest_CompareSurfaces(SDL_Surface *surface, SDL_Surface *referenceSurface, int allowable_error); - + /* Ends C function definitions when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ } -/* *INDENT-ON* */ #endif #include "close_code.h" diff --git a/include/SDL_test_crc32.h b/include/SDL_test_crc32.h index 0685a37f4..f0a84a48c 100644 --- a/include/SDL_test_crc32.h +++ b/include/SDL_test_crc32.h @@ -21,16 +21,16 @@ /** * \file SDL_test_crc32.h - * + * * Include file for SDL test framework. * * This code is a part of the SDL2_test library, not the main SDL library. */ -/* +/* Implements CRC32 calculations (default output is Perl String::CRC32 compatible). - + */ #ifndef _SDL_test_crc32_h @@ -39,9 +39,7 @@ #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ extern "C" { -/* *INDENT-ON* */ #endif @@ -50,20 +48,20 @@ extern "C" { /* Definition shared by all CRC routines */ #ifndef CrcUint32 - #define CrcUint32 unsigned int + #define CrcUint32 unsigned int #endif #ifndef CrcUint8 - #define CrcUint8 unsigned char + #define CrcUint8 unsigned char #endif #ifdef ORIGINAL_METHOD - #define CRC32_POLY 0x04c11db7 /* AUTODIN II, Ethernet, & FDDI */ + #define CRC32_POLY 0x04c11db7 /* AUTODIN II, Ethernet, & FDDI */ #else #define CRC32_POLY 0xEDB88320 /* Perl String::CRC32 compatible */ #endif -/** - * Data structure for CRC32 (checksum) computation +/** + * Data structure for CRC32 (checksum) computation */ typedef struct { CrcUint32 crc32_table[256]; /* CRC table */ @@ -71,12 +69,12 @@ extern "C" { /* ---------- Function Prototypes ------------- */ -/** +/** * /brief Initialize the CRC context * * Note: The function initializes the crc table required for all crc calculations. * - * /param crcContext pointer to context variable + * /param crcContext pointer to context variable * * /returns 0 for OK, -1 on error * @@ -86,8 +84,8 @@ extern "C" { /** * /brief calculate a crc32 from a data block - * - * /param crcContext pointer to context variable + * + * /param crcContext pointer to context variable * /param inBuf input buffer to checksum * /param inLen length of input buffer * /param crc32 pointer to Uint32 to store the final CRC into @@ -106,7 +104,7 @@ int SDLTest_Crc32CalcBuffer(SDLTest_Crc32Context * crcContext, CrcUint8 *inBuf, /** * /brief clean up CRC context * - * /param crcContext pointer to context variable + * /param crcContext pointer to context variable * * /returns 0 for OK, -1 on error * @@ -117,9 +115,7 @@ int SDLTest_Crc32Done(SDLTest_Crc32Context * crcContext); /* Ends C function definitions when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ } -/* *INDENT-ON* */ #endif #include "close_code.h" diff --git a/include/SDL_test_font.h b/include/SDL_test_font.h index d894601f1..aa9286b4a 100644 --- a/include/SDL_test_font.h +++ b/include/SDL_test_font.h @@ -21,7 +21,7 @@ /** * \file SDL_test_font.h - * + * * Include file for SDL test framework. * * This code is a part of the SDL2_test library, not the main SDL library. @@ -33,9 +33,7 @@ #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ extern "C" { -/* *INDENT-ON* */ #endif /* Function prototypes */ @@ -55,9 +53,7 @@ int SDLTest_DrawString(SDL_Renderer * renderer, int x, int y, const char *s); /* Ends C function definitions when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ } -/* *INDENT-ON* */ #endif #include "close_code.h" diff --git a/include/SDL_test_fuzzer.h b/include/SDL_test_fuzzer.h index db30a1dfb..a528ddc5e 100644 --- a/include/SDL_test_fuzzer.h +++ b/include/SDL_test_fuzzer.h @@ -21,16 +21,16 @@ /** * \file SDL_test_fuzzer.h - * + * * Include file for SDL test framework. * * This code is a part of the SDL2_test library, not the main SDL library. */ -/* +/* Data generators for fuzzing test data in a reproducible way. - + */ #ifndef _SDL_test_fuzzer_h @@ -39,9 +39,7 @@ #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ extern "C" { -/* *INDENT-ON* */ #endif @@ -131,7 +129,7 @@ Sint64 SDLTest_RandomSint64(); float SDLTest_RandomUnitFloat(); /** - * \returns random double in range [0.0 - 1.0[ + * \returns random double in range [0.0 - 1.0[ */ double SDLTest_RandomUnitDouble(); @@ -333,7 +331,7 @@ Sint32 SDLTest_RandomIntegerInRange(Sint32 min, Sint32 max); /** * Generates random null-terminated string. The minimum length for - * the string is 1 character, maximum length for the string is 255 + * the string is 1 character, maximum length for the string is 255 * characters and it can contain ASCII characters from 32 to 126. * * Note: Returned string needs to be deallocated. @@ -352,7 +350,7 @@ char * SDLTest_RandomAsciiString(); * * \param maxLength The maximum length of the generated string. * - * \returns Newly allocated random string; or NULL if maxLength was invalid or string could not be allocated. + * \returns Newly allocated random string; or NULL if maxLength was invalid or string could not be allocated. */ char * SDLTest_RandomAsciiStringWithMaximumLength(int maxLength); @@ -377,9 +375,7 @@ int SDLTest_GetFuzzerInvocationCount(); /* Ends C function definitions when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ } -/* *INDENT-ON* */ #endif #include "close_code.h" diff --git a/include/SDL_test_harness.h b/include/SDL_test_harness.h index f2c553cb2..d2da04f1e 100644 --- a/include/SDL_test_harness.h +++ b/include/SDL_test_harness.h @@ -21,7 +21,7 @@ /** * \file SDL_test_harness.h - * + * * Include file for SDL test framework. * * This code is a part of the SDL2_test library, not the main SDL library. @@ -29,7 +29,7 @@ /* Defines types for test case definitions and the test execution harness API. - + Based on original GSOC code by Markus Kauppila */ @@ -39,9 +39,7 @@ #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ extern "C" { -/* *INDENT-ON* */ #endif @@ -50,17 +48,17 @@ extern "C" { #define TEST_DISABLED 0 //! Definition of all the possible test return values of the test case method -#define TEST_ABORTED -1 -#define TEST_STARTED 0 -#define TEST_COMPLETED 1 -#define TEST_SKIPPED 2 +#define TEST_ABORTED -1 +#define TEST_STARTED 0 +#define TEST_COMPLETED 1 +#define TEST_SKIPPED 2 //! Definition of all the possible test results for the harness -#define TEST_RESULT_PASSED 0 -#define TEST_RESULT_FAILED 1 -#define TEST_RESULT_NO_ASSERT 2 -#define TEST_RESULT_SKIPPED 3 -#define TEST_RESULT_SETUP_FAILURE 4 +#define TEST_RESULT_PASSED 0 +#define TEST_RESULT_FAILED 1 +#define TEST_RESULT_NO_ASSERT 2 +#define TEST_RESULT_SKIPPED 3 +#define TEST_RESULT_SETUP_FAILURE 4 //!< Function pointer to a test case setup function (run before every test) typedef void (*SDLTest_TestCaseSetUpFp)(void *arg); @@ -75,28 +73,28 @@ typedef void (*SDLTest_TestCaseTearDownFp)(void *arg); * Holds information about a single test case. */ typedef struct SDLTest_TestCaseReference { - /*!< Func2Stress */ - SDLTest_TestCaseFp testCase; - /*!< Short name (or function name) "Func2Stress" */ - char *name; - /*!< Long name or full description "This test pushes func2() to the limit." */ - char *description; - /*!< Set to TEST_ENABLED or TEST_DISABLED (test won't be run) */ - int enabled; + /*!< Func2Stress */ + SDLTest_TestCaseFp testCase; + /*!< Short name (or function name) "Func2Stress" */ + char *name; + /*!< Long name or full description "This test pushes func2() to the limit." */ + char *description; + /*!< Set to TEST_ENABLED or TEST_DISABLED (test won't be run) */ + int enabled; } SDLTest_TestCaseReference; /** * Holds information about a test suite (multiple test cases). */ typedef struct SDLTest_TestSuiteReference { - /*!< "PlatformSuite" */ - char *name; - /*!< The function that is run before each test. NULL skips. */ - SDLTest_TestCaseSetUpFp testSetUp; - /*!< The test cases that are run as part of the suite. Last item should be NULL. */ - const SDLTest_TestCaseReference **testCases; - /*!< The function that is run after each test. NULL skips. */ - SDLTest_TestCaseTearDownFp testTearDown; + /*!< "PlatformSuite" */ + char *name; + /*!< The function that is run before each test. NULL skips. */ + SDLTest_TestCaseSetUpFp testSetUp; + /*!< The test cases that are run as part of the suite. Last item should be NULL. */ + const SDLTest_TestCaseReference **testCases; + /*!< The function that is run after each test. NULL skips. */ + SDLTest_TestCaseTearDownFp testTearDown; } SDLTest_TestSuiteReference; @@ -112,13 +110,11 @@ typedef struct SDLTest_TestSuiteReference { * \returns Test run result; 0 when all tests passed, 1 if any tests failed. */ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *userRunSeed, Uint64 userExecKey, const char *filter, int testIterations); - + /* Ends C function definitions when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ } -/* *INDENT-ON* */ #endif #include "close_code.h" diff --git a/include/SDL_test_images.h b/include/SDL_test_images.h index ea7222928..21cf39ff7 100644 --- a/include/SDL_test_images.h +++ b/include/SDL_test_images.h @@ -21,16 +21,16 @@ /** * \file SDL_test_images.h - * + * * Include file for SDL test framework. * * This code is a part of the SDL2_test library, not the main SDL library. */ -/* +/* Defines some images for tests. - + */ #ifndef _SDL_test_images_h @@ -41,9 +41,7 @@ #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ extern "C" { -/* *INDENT-ON* */ #endif /** @@ -52,7 +50,7 @@ extern "C" { typedef struct SDLTest_SurfaceImage_s { int width; int height; - unsigned int bytes_per_pixel; /* 3:RGB, 4:RGBA */ + unsigned int bytes_per_pixel; /* 3:RGB, 4:RGBA */ const char *pixel_data; } SDLTest_SurfaceImage_t; @@ -71,9 +69,7 @@ SDL_Surface *SDLTest_ImagePrimitivesBlend(); /* Ends C function definitions when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ } -/* *INDENT-ON* */ #endif #include "close_code.h" diff --git a/include/SDL_test_log.h b/include/SDL_test_log.h index c6dbad653..a581d2e75 100644 --- a/include/SDL_test_log.h +++ b/include/SDL_test_log.h @@ -21,13 +21,13 @@ /** * \file SDL_test_log.h - * + * * Include file for SDL test framework. * * This code is a part of the SDL2_test library, not the main SDL library. */ -/* +/* * * Wrapper to log in the TEST category * @@ -39,9 +39,7 @@ #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ extern "C" { -/* *INDENT-ON* */ #endif /** @@ -60,9 +58,7 @@ void SDLTest_LogError(const char *fmt, ...); /* Ends C function definitions when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ } -/* *INDENT-ON* */ #endif #include "close_code.h" diff --git a/include/SDL_test_md5.h b/include/SDL_test_md5.h index 8949f4b0e..b0d4b7b04 100644 --- a/include/SDL_test_md5.h +++ b/include/SDL_test_md5.h @@ -21,7 +21,7 @@ /** * \file SDL_test_md5.h - * + * * Include file for SDL test framework. * * This code is a part of the SDL2_test library, not the main SDL library. @@ -59,9 +59,7 @@ #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ extern "C" { -/* *INDENT-ON* */ #endif /* ------------ Definitions --------- */ @@ -71,21 +69,21 @@ extern "C" { /* Data structure for MD5 (Message-Digest) computation */ typedef struct { - MD5UINT4 i[2]; /* number of _bits_ handled mod 2^64 */ - MD5UINT4 buf[4]; /* scratch buffer */ - unsigned char in[64]; /* input buffer */ - unsigned char digest[16]; /* actual digest after Md5Final call */ + MD5UINT4 i[2]; /* number of _bits_ handled mod 2^64 */ + MD5UINT4 buf[4]; /* scratch buffer */ + unsigned char in[64]; /* input buffer */ + unsigned char digest[16]; /* actual digest after Md5Final call */ } SDLTest_Md5Context; /* ---------- Function Prototypes ------------- */ -/** +/** * /brief initialize the context * - * /param mdContext pointer to context variable + * /param mdContext pointer to context variable * * Note: The function initializes the message-digest context - * mdContext. Call before each new use of the context - + * mdContext. Call before each new use of the context - * all fields are set to zero. */ void SDLTest_Md5Init(SDLTest_Md5Context * mdContext); @@ -93,24 +91,24 @@ extern "C" { /** * /brief update digest from variable length data - * + * * /param mdContext pointer to context variable * /param inBuf pointer to data array/string * /param inLen length of data array/string * - * Note: The function updates the message-digest context to account + * Note: The function updates the message-digest context to account * for the presence of each of the characters inBuf[0..inLen-1] * in the message whose digest is being computed. */ void SDLTest_Md5Update(SDLTest_Md5Context * mdContext, unsigned char *inBuf, - unsigned int inLen); + unsigned int inLen); /* * /brief complete digest computation * - * /param mdContext pointer to context variable + * /param mdContext pointer to context variable * * Note: The function terminates the message-digest computation and * ends with the desired message digest in mdContext.digest[0..15]. @@ -122,9 +120,7 @@ extern "C" { /* Ends C function definitions when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ } -/* *INDENT-ON* */ #endif #include "close_code.h" diff --git a/include/SDL_test_random.h b/include/SDL_test_random.h index 8b20b6ade..ce6192c25 100644 --- a/include/SDL_test_random.h +++ b/include/SDL_test_random.h @@ -21,20 +21,20 @@ /** * \file SDL_test_random.h - * + * * Include file for SDL test framework. * * This code is a part of the SDL2_test library, not the main SDL library. */ -/* +/* - A "32-bit Multiply with carry random number generator. Very fast. - Includes a list of recommended multipliers. + A "32-bit Multiply with carry random number generator. Very fast. + Includes a list of recommended multipliers. multiply-with-carry generator: x(n) = a*x(n-1) + carry mod 2^32. period: (a*2^31)-1 - + */ #ifndef _SDL_test_random_h @@ -43,9 +43,7 @@ #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ extern "C" { -/* *INDENT-ON* */ #endif /* --- Definitions */ @@ -53,7 +51,7 @@ extern "C" { /* * Macros that return a random number in a specific format. */ -#define SDLTest_RandomInt(c) ((int)SDLTest_Random(c)) +#define SDLTest_RandomInt(c) ((int)SDLTest_Random(c)) /* * Context structure for the random number generator state. @@ -70,7 +68,7 @@ extern "C" { /* --- Function prototypes */ /** - * \brief Initialize random number generator with two integers. + * \brief Initialize random number generator with two integers. * * Note: The random sequence of numbers returned by ...Random() is the * same for the same two integers and has a period of 2^31. @@ -81,10 +79,10 @@ extern "C" { * */ void SDLTest_RandomInit(SDLTest_RandomContext * rndContext, unsigned int xi, - unsigned int ci); + unsigned int ci); /** - * \brief Initialize random number generator based on current system time. + * \brief Initialize random number generator based on current system time. * * \param rndContext pointer to context structure * @@ -93,7 +91,7 @@ extern "C" { /** - * \brief Initialize random number generator based on current system time. + * \brief Initialize random number generator based on current system time. * * Note: ...RandomInit() or ...RandomInitTime() must have been called * before using this function. @@ -108,9 +106,7 @@ extern "C" { /* Ends C function definitions when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ } -/* *INDENT-ON* */ #endif #include "close_code.h" diff --git a/include/SDL_thread.h b/include/SDL_thread.h index 273419b22..6015a071e 100644 --- a/include/SDL_thread.h +++ b/include/SDL_thread.h @@ -24,7 +24,7 @@ /** * \file SDL_thread.h - * + * * Header for the SDL thread management routines. */ @@ -37,9 +37,7 @@ #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ extern "C" { -/* *INDENT-ON* */ #endif /* The SDL thread structure, defined in SDL_thread.c */ @@ -67,22 +65,22 @@ typedef int (SDLCALL * SDL_ThreadFunction) (void *data); #if defined(__WIN32__) && !defined(HAVE_LIBC) /** * \file SDL_thread.h - * + * * We compile SDL into a DLL. This means, that it's the DLL which * creates a new thread for the calling process with the SDL_CreateThread() * API. There is a problem with this, that only the RTL of the SDL.DLL will - * be initialized for those threads, and not the RTL of the calling + * be initialized for those threads, and not the RTL of the calling * application! - * + * * To solve this, we make a little hack here. - * + * * We'll always use the caller's _beginthread() and _endthread() APIs to * start a new thread. This way, if it's the SDL.DLL which uses this API, * then the RTL of SDL.DLL will be used to create the new thread, and if it's * the application, then the RTL of the application will be used. - * + * * So, in short: - * Always use the _beginthread() and _endthread() of the calling runtime + * Always use the _beginthread() and _endthread() of the calling runtime * library! */ #define SDL_PASSED_BEGINTHREAD_ENDTHREAD @@ -150,7 +148,7 @@ extern DECLSPEC SDL_threadID SDLCALL SDL_ThreadID(void); /** * Get the thread identifier for the specified thread. - * + * * Equivalent to SDL_ThreadID() if the specified thread is NULL. */ extern DECLSPEC SDL_threadID SDLCALL SDL_GetThreadID(SDL_Thread * thread); @@ -162,7 +160,7 @@ extern DECLSPEC int SDLCALL SDL_SetThreadPriority(SDL_ThreadPriority priority); /** * Wait for a thread to finish. - * + * * The return code for the thread function is placed in the area * pointed to by \c status, if \c status is not NULL. */ @@ -171,9 +169,7 @@ extern DECLSPEC void SDLCALL SDL_WaitThread(SDL_Thread * thread, int *status); /* Ends C function definitions when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ } -/* *INDENT-ON* */ #endif #include "close_code.h" diff --git a/include/SDL_timer.h b/include/SDL_timer.h index 4a2a27251..e065cf4f9 100644 --- a/include/SDL_timer.h +++ b/include/SDL_timer.h @@ -24,7 +24,7 @@ /** * \file SDL_timer.h - * + * * Header for the SDL time management routines. */ @@ -34,14 +34,12 @@ #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ extern "C" { -/* *INDENT-ON* */ #endif /** * \brief Get the number of milliseconds since the SDL library initialization. - * + * * \note This value wraps if the program runs for more than ~49 days. */ extern DECLSPEC Uint32 SDLCALL SDL_GetTicks(void); @@ -63,7 +61,7 @@ extern DECLSPEC void SDLCALL SDL_Delay(Uint32 ms); /** * Function prototype for the timer callback function. - * + * * The callback function is passed the current timer interval and returns * the next timer interval. If the returned value is the same as the one * passed in, the periodic alarm continues, otherwise a new alarm is @@ -97,9 +95,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_RemoveTimer(SDL_TimerID id); /* Ends C function definitions when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ } -/* *INDENT-ON* */ #endif #include "close_code.h" diff --git a/include/SDL_touch.h b/include/SDL_touch.h index 0b014d6bd..9e6d7c65f 100644 --- a/include/SDL_touch.h +++ b/include/SDL_touch.h @@ -21,7 +21,7 @@ /** * \file SDL_touch.h - * + * * Include file for SDL touch event handling. */ @@ -35,9 +35,7 @@ #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; @@ -79,9 +77,7 @@ extern DECLSPEC SDL_Finger * SDLCALL SDL_GetTouchFinger(SDL_TouchID touchID, int /* Ends C function definitions when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ } -/* *INDENT-ON* */ #endif #include "close_code.h" diff --git a/include/SDL_types.h b/include/SDL_types.h index 636df1e9e..bb485cdb0 100644 --- a/include/SDL_types.h +++ b/include/SDL_types.h @@ -21,7 +21,7 @@ /** * \file SDL_types.h - * + * * \deprecated */ diff --git a/include/SDL_version.h b/include/SDL_version.h index e32ea20b2..a9ced804d 100644 --- a/include/SDL_version.h +++ b/include/SDL_version.h @@ -21,7 +21,7 @@ /** * \file SDL_version.h - * + * * This header defines the current SDL version. */ @@ -33,20 +33,18 @@ #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ extern "C" { -/* *INDENT-ON* */ #endif /** * \brief Information the version of SDL in use. - * + * * Represents the library's version as three levels: major revision * (increments with massive changes, additions, and enhancements), * minor revision (increments with backwards-compatible changes to the * major revision), and patchlevel (increments with fixes to the minor * revision). - * + * * \sa SDL_VERSION * \sa SDL_GetVersion */ @@ -59,30 +57,30 @@ typedef struct SDL_version /* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL */ -#define SDL_MAJOR_VERSION 2 -#define SDL_MINOR_VERSION 0 -#define SDL_PATCHLEVEL 0 +#define SDL_MAJOR_VERSION 2 +#define SDL_MINOR_VERSION 0 +#define SDL_PATCHLEVEL 0 /** * \brief Macro to determine SDL version program was compiled against. - * + * * This macro fills in a SDL_version structure with the version of the * library you compiled against. This is determined by what header the * compiler uses. Note that if you dynamically linked the library, you might * have a slightly newer or older version at runtime. That version can be * determined with SDL_GetVersion(), which, unlike SDL_VERSION(), * is not a macro. - * + * * \param x A pointer to a SDL_version struct to initialize. - * + * * \sa SDL_version * \sa SDL_GetVersion */ -#define SDL_VERSION(x) \ -{ \ - (x)->major = SDL_MAJOR_VERSION; \ - (x)->minor = SDL_MINOR_VERSION; \ - (x)->patch = SDL_PATCHLEVEL; \ +#define SDL_VERSION(x) \ +{ \ + (x)->major = SDL_MAJOR_VERSION; \ + (x)->minor = SDL_MINOR_VERSION; \ + (x)->patch = SDL_PATCHLEVEL; \ } /** @@ -90,23 +88,23 @@ typedef struct SDL_version * \verbatim (1,2,3) -> (1203) \endverbatim - * + * * This assumes that there will never be more than 100 patchlevels. */ -#define SDL_VERSIONNUM(X, Y, Z) \ - ((X)*1000 + (Y)*100 + (Z)) +#define SDL_VERSIONNUM(X, Y, Z) \ + ((X)*1000 + (Y)*100 + (Z)) /** * This is the version number macro for the current SDL version. */ #define SDL_COMPILEDVERSION \ - SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL) + SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL) /** * This macro will evaluate to true if compiled with SDL at least X.Y.Z. */ #define SDL_VERSION_ATLEAST(X, Y, Z) \ - (SDL_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z)) + (SDL_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z)) /** * \brief Get the version of SDL that is linked against your program. @@ -115,11 +113,11 @@ typedef struct SDL_version * current version will be different than the version you compiled against. * This function returns the current version, while SDL_VERSION() is a * macro that tells you what version you compiled with. - * + * * \code * SDL_version compiled; * SDL_version linked; - * + * * SDL_VERSION(&compiled); * SDL_GetVersion(&linked); * printf("We compiled against SDL version %d.%d.%d ...\n", @@ -127,9 +125,9 @@ typedef struct SDL_version * printf("But we linked against SDL version %d.%d.%d.\n", * linked.major, linked.minor, linked.patch); * \endcode - * + * * This function may be called safely at any time, even before SDL_Init(). - * + * * \sa SDL_VERSION */ extern DECLSPEC void SDLCALL SDL_GetVersion(SDL_version * ver); @@ -155,9 +153,7 @@ extern DECLSPEC int SDLCALL SDL_GetRevisionNumber(void); /* Ends C function definitions when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ } -/* *INDENT-ON* */ #endif #include "close_code.h" diff --git a/include/SDL_video.h b/include/SDL_video.h index d51da4d6b..66815197c 100644 --- a/include/SDL_video.h +++ b/include/SDL_video.h @@ -21,7 +21,7 @@ /** * \file SDL_video.h - * + * * Header file for SDL video functions. */ @@ -36,14 +36,12 @@ #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ extern "C" { -/* *INDENT-ON* */ #endif /** * \brief The structure that defines a display mode - * + * * \sa SDL_GetNumDisplayModes() * \sa SDL_GetDisplayMode() * \sa SDL_GetDesktopDisplayMode() @@ -63,7 +61,7 @@ typedef struct /** * \brief The type used to identify a window - * + * * \sa SDL_CreateWindow() * \sa SDL_CreateWindowFrom() * \sa SDL_DestroyWindow() @@ -92,7 +90,7 @@ typedef struct SDL_Window SDL_Window; /** * \brief The flags on a window - * + * * \sa SDL_GetWindowFlags() */ typedef enum @@ -108,7 +106,7 @@ typedef enum SDL_WINDOW_INPUT_GRABBED = 0x00000100, /**< window has grabbed input focus */ SDL_WINDOW_INPUT_FOCUS = 0x00000200, /**< window has input focus */ SDL_WINDOW_MOUSE_FOCUS = 0x00000400, /**< window has mouse focus */ - SDL_WINDOW_FULLSCREEN_DESKTOP = ( SDL_WINDOW_FULLSCREEN | 0x00001000 ), + SDL_WINDOW_FULLSCREEN_DESKTOP = ( SDL_WINDOW_FULLSCREEN | 0x00001000 ), SDL_WINDOW_FOREIGN = 0x00000800 /**< window not created by SDL */ } SDL_WindowFlags; @@ -138,9 +136,9 @@ typedef enum SDL_WINDOWEVENT_NONE, /**< Never used */ SDL_WINDOWEVENT_SHOWN, /**< Window has been shown */ SDL_WINDOWEVENT_HIDDEN, /**< Window has been hidden */ - SDL_WINDOWEVENT_EXPOSED, /**< Window has been exposed and should be + SDL_WINDOWEVENT_EXPOSED, /**< Window has been exposed and should be redrawn */ - SDL_WINDOWEVENT_MOVED, /**< Window has been moved to data1, data2 + SDL_WINDOWEVENT_MOVED, /**< Window has been moved to data1, data2 */ SDL_WINDOWEVENT_RESIZED, /**< Window has been resized to data1xdata2 */ SDL_WINDOWEVENT_SIZE_CHANGED, /**< The window size has changed, either as a result of an API call or through the system or user changing the window size. */ @@ -152,7 +150,7 @@ typedef enum SDL_WINDOWEVENT_LEAVE, /**< Window has lost mouse focus */ SDL_WINDOWEVENT_FOCUS_GAINED, /**< Window has gained keyboard focus */ SDL_WINDOWEVENT_FOCUS_LOST, /**< Window has lost keyboard focus */ - SDL_WINDOWEVENT_CLOSE /**< The window manager requests that the + SDL_WINDOWEVENT_CLOSE /**< The window manager requests that the window be closed */ } SDL_WindowEventID; @@ -211,52 +209,52 @@ typedef enum /** * \brief Get the number of video drivers compiled into SDL - * + * * \sa SDL_GetVideoDriver() */ extern DECLSPEC int SDLCALL SDL_GetNumVideoDrivers(void); /** * \brief Get the name of a built in video driver. - * + * * \note The video drivers are presented in the order in which they are * normally checked during initialization. - * + * * \sa SDL_GetNumVideoDrivers() */ extern DECLSPEC const char *SDLCALL SDL_GetVideoDriver(int index); /** * \brief Initialize the video subsystem, optionally specifying a video driver. - * - * \param driver_name Initialize a specific driver by name, or NULL for the + * + * \param driver_name Initialize a specific driver by name, or NULL for the * default video driver. - * + * * \return 0 on success, -1 on error - * + * * This function initializes the video subsystem; setting up a connection * to the window manager, etc, and determines the available display modes * and pixel formats, but does not initialize a window or graphics mode. - * + * * \sa SDL_VideoQuit() */ extern DECLSPEC int SDLCALL SDL_VideoInit(const char *driver_name); /** * \brief Shuts down the video subsystem. - * + * * This function closes all windows, and restores the original video mode. - * + * * \sa SDL_VideoInit() */ extern DECLSPEC void SDLCALL SDL_VideoQuit(void); /** * \brief Returns the name of the currently initialized video driver. - * + * * \return The name of the current video driver or NULL if no driver * has been initialized - * + * * \sa SDL_GetNumVideoDrivers() * \sa SDL_GetVideoDriver() */ @@ -264,16 +262,16 @@ extern DECLSPEC const char *SDLCALL SDL_GetCurrentVideoDriver(void); /** * \brief Returns the number of available video displays. - * + * * \sa SDL_GetDisplayBounds() */ extern DECLSPEC int SDLCALL SDL_GetNumVideoDisplays(void); /** * \brief Get the name of a display in UTF-8 encoding - * + * * \return The name of a display, or NULL for an invalid display index. - * + * * \sa SDL_GetNumVideoDisplays() */ extern DECLSPEC const char * SDLCALL SDL_GetDisplayName(int displayIndex); @@ -281,29 +279,29 @@ extern DECLSPEC const char * SDLCALL SDL_GetDisplayName(int displayIndex); /** * \brief Get the desktop area represented by a display, with the primary * display located at 0,0 - * + * * \return 0 on success, or -1 if the index is out of range. - * + * * \sa SDL_GetNumVideoDisplays() */ extern DECLSPEC int SDLCALL SDL_GetDisplayBounds(int displayIndex, SDL_Rect * rect); /** * \brief Returns the number of available display modes. - * + * * \sa SDL_GetDisplayMode() */ extern DECLSPEC int SDLCALL SDL_GetNumDisplayModes(int displayIndex); /** * \brief Fill in information about a specific display mode. - * + * * \note The display modes are sorted in this priority: * \li bits per pixel -> more colors to fewer colors * \li width -> largest to smallest * \li height -> largest to smallest * \li refresh rate -> highest to lowest - * + * * \sa SDL_GetNumDisplayModes() */ extern DECLSPEC int SDLCALL SDL_GetDisplayMode(int displayIndex, int modeIndex, @@ -322,22 +320,22 @@ extern DECLSPEC int SDLCALL SDL_GetCurrentDisplayMode(int displayIndex, SDL_Disp /** * \brief Get the closest match to the requested display mode. - * + * * \param displayIndex The index of display from which mode should be queried. * \param mode The desired display mode - * \param closest A pointer to a display mode to be filled in with the closest + * \param closest A pointer to a display mode to be filled in with the closest * match of the available display modes. - * - * \return The passed in value \c closest, or NULL if no matching video mode + * + * \return The passed in value \c closest, or NULL if no matching video mode * was available. - * + * * The available display modes are scanned, and \c closest is filled in with the - * closest mode matching the requested mode and returned. The mode format and - * refresh_rate default to the desktop mode if they are 0. The modes are - * scanned with size being first priority, format being second priority, and - * finally checking the refresh_rate. If all the available modes are too + * closest mode matching the requested mode and returned. The mode format and + * refresh_rate default to the desktop mode if they are 0. The modes are + * scanned with size being first priority, format being second priority, and + * finally checking the refresh_rate. If all the available modes are too * small, then NULL is returned. - * + * * \sa SDL_GetNumDisplayModes() * \sa SDL_GetDisplayMode() */ @@ -345,7 +343,7 @@ extern DECLSPEC SDL_DisplayMode * SDLCALL SDL_GetClosestDisplayMode(int displayI /** * \brief Get the display index associated with a window. - * + * * \return the display index of the display containing the center of the * window, or -1 on error. */ @@ -356,12 +354,12 @@ extern DECLSPEC int SDLCALL SDL_GetWindowDisplayIndex(SDL_Window * window); * * By default the window's dimensions and the desktop format and refresh rate * are used. - * + * * \param window The window for which the display mode should be set. * \param mode The mode to use, or NULL for the default mode. - * + * * \return 0 on success, or -1 if setting the display mode failed. - * + * * \sa SDL_GetWindowDisplayMode() * \sa SDL_SetWindowFullscreen() */ @@ -386,22 +384,22 @@ extern DECLSPEC Uint32 SDLCALL SDL_GetWindowPixelFormat(SDL_Window * window); /** * \brief Create a window with the specified position, dimensions, and flags. - * + * * \param title The title of the window, in UTF-8 encoding. - * \param x The x position of the window, ::SDL_WINDOWPOS_CENTERED, or + * \param x The x position of the window, ::SDL_WINDOWPOS_CENTERED, or * ::SDL_WINDOWPOS_UNDEFINED. - * \param y The y position of the window, ::SDL_WINDOWPOS_CENTERED, or + * \param y The y position of the window, ::SDL_WINDOWPOS_CENTERED, or * ::SDL_WINDOWPOS_UNDEFINED. * \param w The width of the window. * \param h The height of the window. - * \param flags The flags for the window, a mask of any of the following: - * ::SDL_WINDOW_FULLSCREEN, ::SDL_WINDOW_OPENGL, - * ::SDL_WINDOW_SHOWN, ::SDL_WINDOW_BORDERLESS, - * ::SDL_WINDOW_RESIZABLE, ::SDL_WINDOW_MAXIMIZED, + * \param flags The flags for the window, a mask of any of the following: + * ::SDL_WINDOW_FULLSCREEN, ::SDL_WINDOW_OPENGL, + * ::SDL_WINDOW_SHOWN, ::SDL_WINDOW_BORDERLESS, + * ::SDL_WINDOW_RESIZABLE, ::SDL_WINDOW_MAXIMIZED, * ::SDL_WINDOW_MINIMIZED, ::SDL_WINDOW_INPUT_GRABBED. - * + * * \return The id of the window created, or zero if window creation failed. - * + * * \sa SDL_DestroyWindow() */ extern DECLSPEC SDL_Window * SDLCALL SDL_CreateWindow(const char *title, @@ -410,11 +408,11 @@ extern DECLSPEC SDL_Window * SDLCALL SDL_CreateWindow(const char *title, /** * \brief Create an SDL window from an existing native window. - * + * * \param data A pointer to driver-dependent window creation data - * + * * \return The id of the window created, or zero if window creation failed. - * + * * \sa SDL_DestroyWindow() */ extern DECLSPEC SDL_Window * SDLCALL SDL_CreateWindowFrom(const void *data); @@ -436,7 +434,7 @@ extern DECLSPEC Uint32 SDLCALL SDL_GetWindowFlags(SDL_Window * window); /** * \brief Set the title of a window, in UTF-8 format. - * + * * \sa SDL_GetWindowTitle() */ extern DECLSPEC void SDLCALL SDL_SetWindowTitle(SDL_Window * window, @@ -444,14 +442,14 @@ extern DECLSPEC void SDLCALL SDL_SetWindowTitle(SDL_Window * window, /** * \brief Get the title of a window, in UTF-8 format. - * + * * \sa SDL_SetWindowTitle() */ extern DECLSPEC const char *SDLCALL SDL_GetWindowTitle(SDL_Window * window); /** * \brief Set the icon for a window. - * + * * \param window The window for which the icon should be set. * \param icon The icon for the window. */ @@ -460,7 +458,7 @@ extern DECLSPEC void SDLCALL SDL_SetWindowIcon(SDL_Window * window, /** * \brief Associate an arbitrary named pointer with a window. - * + * * \param window The window to associate with the pointer. * \param name The name of the pointer. * \param userdata The associated pointer. @@ -477,12 +475,12 @@ extern DECLSPEC void* SDLCALL SDL_SetWindowData(SDL_Window * window, /** * \brief Retrieve the data pointer associated with a window. - * + * * \param window The window to query. * \param name The name of the pointer. * * \return The value associated with 'name' - * + * * \sa SDL_SetWindowData() */ extern DECLSPEC void *SDLCALL SDL_GetWindowData(SDL_Window * window, @@ -490,15 +488,15 @@ extern DECLSPEC void *SDLCALL SDL_GetWindowData(SDL_Window * window, /** * \brief Set the position of a window. - * + * * \param window The window to reposition. * \param x The x coordinate of the window, ::SDL_WINDOWPOS_CENTERED, or ::SDL_WINDOWPOS_UNDEFINED. * \param y The y coordinate of the window, ::SDL_WINDOWPOS_CENTERED, or ::SDL_WINDOWPOS_UNDEFINED. - * + * * \note The window coordinate origin is the upper left of the display. - * + * * \sa SDL_GetWindowPosition() */ extern DECLSPEC void SDLCALL SDL_SetWindowPosition(SDL_Window * window, @@ -506,7 +504,7 @@ extern DECLSPEC void SDLCALL SDL_SetWindowPosition(SDL_Window * window, /** * \brief Get the position of a window. - * + * * \param window The window to query. * \param x Pointer to variable for storing the x position, may be NULL * \param y Pointer to variable for storing the y position, may be NULL @@ -518,14 +516,14 @@ extern DECLSPEC void SDLCALL SDL_GetWindowPosition(SDL_Window * window, /** * \brief Set the size of a window's client area. - * + * * \param window The window to resize. * \param w The width of the window, must be >0 * \param h The height of the window, must be >0 * * \note You can't change the size of a fullscreen window, it automatically * matches the size of the display mode. - * + * * \sa SDL_GetWindowSize() */ extern DECLSPEC void SDLCALL SDL_SetWindowSize(SDL_Window * window, int w, @@ -533,19 +531,19 @@ extern DECLSPEC void SDLCALL SDL_SetWindowSize(SDL_Window * window, int w, /** * \brief Get the size of a window's client area. - * + * * \param window The window to query. * \param w Pointer to variable for storing the width, may be NULL * \param h Pointer to variable for storing the height, may be NULL - * + * * \sa SDL_SetWindowSize() */ extern DECLSPEC void SDLCALL SDL_GetWindowSize(SDL_Window * window, int *w, int *h); - + /** * \brief Set the minimum size of a window's client area. - * + * * \param window The window to set a new minimum size. * \param min_w The minimum width of the window, must be >0 * \param min_h The minimum height of the window, must be >0 @@ -558,14 +556,14 @@ extern DECLSPEC void SDLCALL SDL_GetWindowSize(SDL_Window * window, int *w, */ extern DECLSPEC void SDLCALL SDL_SetWindowMinimumSize(SDL_Window * window, int min_w, int min_h); - + /** * \brief Get the minimum size of a window's client area. - * + * * \param window The window to query. * \param w Pointer to variable for storing the minimum width, may be NULL * \param h Pointer to variable for storing the minimum height, may be NULL - * + * * \sa SDL_GetWindowMaximumSize() * \sa SDL_SetWindowMinimumSize() */ @@ -587,10 +585,10 @@ extern DECLSPEC void SDLCALL SDL_GetWindowMinimumSize(SDL_Window * window, */ extern DECLSPEC void SDLCALL SDL_SetWindowMaximumSize(SDL_Window * window, int max_w, int max_h); - + /** * \brief Get the maximum size of a window's client area. - * + * * \param window The window to query. * \param w Pointer to variable for storing the maximum width, may be NULL * \param h Pointer to variable for storing the maximum height, may be NULL @@ -612,7 +610,7 @@ extern DECLSPEC void SDLCALL SDL_GetWindowMaximumSize(SDL_Window * window, * \param bordered SDL_FALSE to remove border, SDL_TRUE to add border. * * \note You can't change the border state of a fullscreen window. - * + * * \sa SDL_GetWindowFlags() */ extern DECLSPEC void SDLCALL SDL_SetWindowBordered(SDL_Window * window, @@ -620,14 +618,14 @@ extern DECLSPEC void SDLCALL SDL_SetWindowBordered(SDL_Window * window, /** * \brief Show a window. - * + * * \sa SDL_HideWindow() */ extern DECLSPEC void SDLCALL SDL_ShowWindow(SDL_Window * window); /** * \brief Hide a window. - * + * * \sa SDL_ShowWindow() */ extern DECLSPEC void SDLCALL SDL_HideWindow(SDL_Window * window); @@ -639,21 +637,21 @@ extern DECLSPEC void SDLCALL SDL_RaiseWindow(SDL_Window * window); /** * \brief Make a window as large as possible. - * + * * \sa SDL_RestoreWindow() */ extern DECLSPEC void SDLCALL SDL_MaximizeWindow(SDL_Window * window); /** * \brief Minimize a window to an iconic representation. - * + * * \sa SDL_RestoreWindow() */ extern DECLSPEC void SDLCALL SDL_MinimizeWindow(SDL_Window * window); /** * \brief Restore the size and position of a minimized or maximized window. - * + * * \sa SDL_MaximizeWindow() * \sa SDL_MinimizeWindow() */ @@ -661,9 +659,9 @@ extern DECLSPEC void SDLCALL SDL_RestoreWindow(SDL_Window * window); /** * \brief Set a window's fullscreen state. - * + * * \return 0 on success, or -1 if setting the display mode failed. - * + * * \sa SDL_SetWindowDisplayMode() * \sa SDL_GetWindowDisplayMode() */ @@ -673,7 +671,7 @@ extern DECLSPEC int SDLCALL SDL_SetWindowFullscreen(SDL_Window * window, /** * \brief Get the SDL surface associated with the window. * - * \return The window's framebuffer surface, or NULL on error. + * \return The window's framebuffer surface, or NULL on error. * * A new surface will be created with the optimal format for the window, * if necessary. This surface will be freed when the window is destroyed. @@ -709,10 +707,10 @@ extern DECLSPEC int SDLCALL SDL_UpdateWindowSurfaceRects(SDL_Window * window, /** * \brief Set a window's input grab mode. - * + * * \param window The window for which the input grab mode should be set. * \param grabbed This is SDL_TRUE to grab input, and SDL_FALSE to release input. - * + * * \sa SDL_GetWindowGrab() */ extern DECLSPEC void SDLCALL SDL_SetWindowGrab(SDL_Window * window, @@ -720,18 +718,18 @@ extern DECLSPEC void SDLCALL SDL_SetWindowGrab(SDL_Window * window, /** * \brief Get a window's input grab mode. - * + * * \return This returns SDL_TRUE if input is grabbed, and SDL_FALSE otherwise. - * + * * \sa SDL_SetWindowGrab() */ extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowGrab(SDL_Window * window); /** * \brief Set the brightness (gamma correction) for a window. - * + * * \return 0 on success, or -1 if setting the brightness isn't supported. - * + * * \sa SDL_GetWindowBrightness() * \sa SDL_SetWindowGammaRamp() */ @@ -739,23 +737,23 @@ extern DECLSPEC int SDLCALL SDL_SetWindowBrightness(SDL_Window * window, float b /** * \brief Get the brightness (gamma correction) for a window. - * + * * \return The last brightness value passed to SDL_SetWindowBrightness() - * + * * \sa SDL_SetWindowBrightness() */ extern DECLSPEC float SDLCALL SDL_GetWindowBrightness(SDL_Window * window); /** * \brief Set the gamma ramp for a window. - * + * * \param window The window for which the gamma ramp should be set. * \param red The translation table for the red channel, or NULL. * \param green The translation table for the green channel, or NULL. * \param blue The translation table for the blue channel, or NULL. - * + * * \return 0 on success, or -1 if gamma ramps are unsupported. - * + * * Set the gamma translation table for the red, green, and blue channels * of the video hardware. Each table is an array of 256 16-bit quantities, * representing a mapping between the input and output for that channel. @@ -771,17 +769,17 @@ extern DECLSPEC int SDLCALL SDL_SetWindowGammaRamp(SDL_Window * window, /** * \brief Get the gamma ramp for a window. - * + * * \param window The window from which the gamma ramp should be queried. - * \param red A pointer to a 256 element array of 16-bit quantities to hold + * \param red A pointer to a 256 element array of 16-bit quantities to hold * the translation table for the red channel, or NULL. - * \param green A pointer to a 256 element array of 16-bit quantities to hold + * \param green A pointer to a 256 element array of 16-bit quantities to hold * the translation table for the green channel, or NULL. - * \param blue A pointer to a 256 element array of 16-bit quantities to hold + * \param blue A pointer to a 256 element array of 16-bit quantities to hold * the translation table for the blue channel, or NULL. - * + * * \return 0 on success, or -1 if gamma ramps are unsupported. - * + * * \sa SDL_SetWindowGammaRamp() */ extern DECLSPEC int SDLCALL SDL_GetWindowGammaRamp(SDL_Window * window, @@ -797,7 +795,7 @@ extern DECLSPEC void SDLCALL SDL_DestroyWindow(SDL_Window * window); /** * \brief Returns whether the screensaver is currently enabled (default on). - * + * * \sa SDL_EnableScreenSaver() * \sa SDL_DisableScreenSaver() */ @@ -805,7 +803,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_IsScreenSaverEnabled(void); /** * \brief Allow the screen to be blanked by a screensaver - * + * * \sa SDL_IsScreenSaverEnabled() * \sa SDL_DisableScreenSaver() */ @@ -813,7 +811,7 @@ extern DECLSPEC void SDLCALL SDL_EnableScreenSaver(void); /** * \brief Prevent the screen from being blanked by a screensaver - * + * * \sa SDL_IsScreenSaverEnabled() * \sa SDL_EnableScreenSaver() */ @@ -827,19 +825,19 @@ extern DECLSPEC void SDLCALL SDL_DisableScreenSaver(void); /** * \brief Dynamically load an OpenGL library. - * - * \param path The platform dependent OpenGL library name, or NULL to open the + * + * \param path The platform dependent OpenGL library name, or NULL to open the * default OpenGL library. - * + * * \return 0 on success, or -1 if the library couldn't be loaded. - * + * * This should be done after initializing the video driver, but before * creating any OpenGL windows. If no OpenGL library is loaded, the default * library will be loaded upon creation of the first OpenGL window. - * + * * \note If you do this, you need to retrieve all of the GL functions used in * your program from the dynamic library using SDL_GL_GetProcAddress(). - * + * * \sa SDL_GL_GetProcAddress() * \sa SDL_GL_UnloadLibrary() */ @@ -852,13 +850,13 @@ extern DECLSPEC void *SDLCALL SDL_GL_GetProcAddress(const char *proc); /** * \brief Unload the OpenGL library previously loaded by SDL_GL_LoadLibrary(). - * + * * \sa SDL_GL_LoadLibrary() */ extern DECLSPEC void SDLCALL SDL_GL_UnloadLibrary(void); /** - * \brief Return true if an OpenGL extension is supported for the current + * \brief Return true if an OpenGL extension is supported for the current * context. */ extern DECLSPEC SDL_bool SDLCALL SDL_GL_ExtensionSupported(const char @@ -875,9 +873,9 @@ extern DECLSPEC int SDLCALL SDL_GL_SetAttribute(SDL_GLattr attr, int value); extern DECLSPEC int SDLCALL SDL_GL_GetAttribute(SDL_GLattr attr, int *value); /** - * \brief Create an OpenGL context for use with an OpenGL window, and make it + * \brief Create an OpenGL context for use with an OpenGL window, and make it * current. - * + * * \sa SDL_GL_DeleteContext() */ extern DECLSPEC SDL_GLContext SDLCALL SDL_GL_CreateContext(SDL_Window * @@ -885,7 +883,7 @@ extern DECLSPEC SDL_GLContext SDLCALL SDL_GL_CreateContext(SDL_Window * /** * \brief Set up an OpenGL context for rendering into an OpenGL window. - * + * * \note The context must have been created with a compatible window. */ extern DECLSPEC int SDLCALL SDL_GL_MakeCurrent(SDL_Window * window, @@ -893,40 +891,40 @@ extern DECLSPEC int SDLCALL SDL_GL_MakeCurrent(SDL_Window * window, /** * \brief Set the swap interval for the current OpenGL context. - * + * * \param interval 0 for immediate updates, 1 for updates synchronized with the * vertical retrace. If the system supports it, you may * specify -1 to allow late swaps to happen immediately * instead of waiting for the next retrace. - * + * * \return 0 on success, or -1 if setting the swap interval is not supported. - * + * * \sa SDL_GL_GetSwapInterval() */ extern DECLSPEC int SDLCALL SDL_GL_SetSwapInterval(int interval); /** * \brief Get the swap interval for the current OpenGL context. - * - * \return 0 if there is no vertical retrace synchronization, 1 if the buffer + * + * \return 0 if there is no vertical retrace synchronization, 1 if the buffer * swap is synchronized with the vertical retrace, and -1 if late * swaps happen immediately instead of waiting for the next retrace. * If the system can't determine the swap interval, or there isn't a * valid current context, this will return 0 as a safe default. - * + * * \sa SDL_GL_SetSwapInterval() */ extern DECLSPEC int SDLCALL SDL_GL_GetSwapInterval(void); /** - * \brief Swap the OpenGL buffers for a window, if double-buffering is + * \brief Swap the OpenGL buffers for a window, if double-buffering is * supported. */ extern DECLSPEC void SDLCALL SDL_GL_SwapWindow(SDL_Window * window); /** * \brief Delete an OpenGL context. - * + * * \sa SDL_GL_CreateContext() */ extern DECLSPEC void SDLCALL SDL_GL_DeleteContext(SDL_GLContext context); @@ -936,9 +934,7 @@ extern DECLSPEC void SDLCALL SDL_GL_DeleteContext(SDL_GLContext context); /* Ends C function definitions when using C++ */ #ifdef __cplusplus -/* *INDENT-OFF* */ } -/* *INDENT-ON* */ #endif #include "close_code.h" diff --git a/include/begin_code.h b/include/begin_code.h index 4e613f94e..dd1f0616d 100644 --- a/include/begin_code.h +++ b/include/begin_code.h @@ -37,23 +37,23 @@ #ifndef DECLSPEC # if defined(__BEOS__) || defined(__HAIKU__) # if defined(__GNUC__) -# define DECLSPEC __declspec(dllexport) +# define DECLSPEC __declspec(dllexport) # else -# define DECLSPEC __declspec(export) +# define DECLSPEC __declspec(export) # endif # elif defined(__WIN32__) # ifdef __BORLANDC__ # ifdef BUILD_SDL # define DECLSPEC # else -# define DECLSPEC __declspec(dllimport) +# define DECLSPEC __declspec(dllimport) # endif # else -# define DECLSPEC __declspec(dllexport) +# define DECLSPEC __declspec(dllexport) # endif # else # if defined(__GNUC__) && __GNUC__ >= 4 -# define DECLSPEC __attribute__ ((visibility("default"))) +# define DECLSPEC __attribute__ ((visibility("default"))) # else # define DECLSPEC # endif @@ -106,7 +106,7 @@ defined(__WATCOMC__) || defined(__LCC__) || \ defined(__DECC) #ifndef __inline__ -#define __inline__ __inline +#define __inline__ __inline #endif #define SDL_INLINE_OKAY #else diff --git a/include/close_code.h b/include/close_code.h index 410060370..4901482d5 100644 --- a/include/close_code.h +++ b/include/close_code.h @@ -21,7 +21,7 @@ /** * \file close_code.h - * + * * This file reverses the effects of begin_code.h and should be included * after you finish any function and structure declarations in your headers */ diff --git a/src/SDL.c b/src/SDL.c index a61c710a7..5f28373a1 100644 --- a/src/SDL.c +++ b/src/SDL.c @@ -138,7 +138,7 @@ SDL_InitSubSystem(Uint32 flags) } if ((flags & SDL_INIT_GAMECONTROLLER)) { - // Game controller implies Joystick. + /* Game controller implies Joystick. */ flags |= SDL_INIT_JOYSTICK; } @@ -221,19 +221,19 @@ SDL_QuitSubSystem(Uint32 flags) /* Shut down requested initialized subsystems */ #if !SDL_JOYSTICK_DISABLED if ((flags & SDL_INIT_GAMECONTROLLER)) { - // Game controller implies Joystick. + /* Game controller implies Joystick. */ flags |= SDL_INIT_JOYSTICK; if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_GAMECONTROLLER)) { SDL_GameControllerQuit(); - } + } SDL_PrivateSubsystemRefCountDecr(SDL_INIT_GAMECONTROLLER); } if ((flags & SDL_INIT_JOYSTICK)) { if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_JOYSTICK)) { - SDL_JoystickQuit(); - } + SDL_JoystickQuit(); + } SDL_PrivateSubsystemRefCountDecr(SDL_INIT_JOYSTICK); } #endif @@ -241,8 +241,8 @@ SDL_QuitSubSystem(Uint32 flags) #if !SDL_HAPTIC_DISABLED if ((flags & SDL_INIT_HAPTIC)) { if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_HAPTIC)) { - SDL_HapticQuit(); - } + SDL_HapticQuit(); + } SDL_PrivateSubsystemRefCountDecr(SDL_INIT_HAPTIC); } #endif @@ -250,8 +250,8 @@ SDL_QuitSubSystem(Uint32 flags) #if !SDL_AUDIO_DISABLED if ((flags & SDL_INIT_AUDIO)) { if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_AUDIO)) { - SDL_AudioQuit(); - } + SDL_AudioQuit(); + } SDL_PrivateSubsystemRefCountDecr(SDL_INIT_AUDIO); } #endif @@ -259,8 +259,8 @@ SDL_QuitSubSystem(Uint32 flags) #if !SDL_VIDEO_DISABLED if ((flags & SDL_INIT_VIDEO)) { if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_VIDEO)) { - SDL_VideoQuit(); - } + SDL_VideoQuit(); + } SDL_PrivateSubsystemRefCountDecr(SDL_INIT_VIDEO); } #endif @@ -268,8 +268,8 @@ SDL_QuitSubSystem(Uint32 flags) #if !SDL_TIMERS_DISABLED if ((flags & SDL_INIT_TIMER)) { if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_TIMER)) { - SDL_TimerQuit(); - } + SDL_TimerQuit(); + } SDL_PrivateSubsystemRefCountDecr(SDL_INIT_TIMER); } #endif diff --git a/src/SDL_error.c b/src/SDL_error.c index 40388124b..98ef84ac6 100644 --- a/src/SDL_error.c +++ b/src/SDL_error.c @@ -31,12 +31,12 @@ #if SDL_THREADS_DISABLED /* The default (non-thread-safe) global error variable */ static SDL_error SDL_global_error; -#define SDL_GetErrBuf() (&SDL_global_error) +#define SDL_GetErrBuf() (&SDL_global_error) #else extern SDL_error *SDL_GetErrBuf(void); #endif /* SDL_THREADS_DISABLED */ -#define SDL_ERRBUFIZE 1024 +#define SDL_ERRBUFIZE 1024 /* Private functions */ @@ -57,7 +57,7 @@ SDL_SetError(const char *fmt, ...) /* Ignore call if invalid format pointer was passed */ if (fmt == NULL) return -1; - + /* Copy in the key, mark error as valid */ error = SDL_GetErrBuf(); error->error = 1; diff --git a/src/SDL_error_c.h b/src/SDL_error_c.h index 1277b086d..2014cc1e7 100644 --- a/src/SDL_error_c.h +++ b/src/SDL_error_c.h @@ -27,8 +27,8 @@ #ifndef _SDL_error_c_h #define _SDL_error_c_h -#define ERR_MAX_STRLEN 128 -#define ERR_MAX_ARGS 5 +#define ERR_MAX_STRLEN 128 +#define ERR_MAX_ARGS 5 typedef struct SDL_error { diff --git a/src/SDL_hints.c b/src/SDL_hints.c index ed635c76d..bd9404d46 100644 --- a/src/SDL_hints.c +++ b/src/SDL_hints.c @@ -41,14 +41,14 @@ SDL_bool SDL_RegisterHintChangedCb(const char *name, SDL_HintChangedCb hintCb) { SDL_Hint *hint; - + for (hint = SDL_hints; hint; hint = hint->next) { if (SDL_strcmp(name, hint->name) == 0) { hint->callback = hintCb; return SDL_TRUE; } } - + return SDL_FALSE; } diff --git a/src/SDL_hints_c.h b/src/SDL_hints_c.h index 74830c30c..232e26384 100644 --- a/src/SDL_hints_c.h +++ b/src/SDL_hints_c.h @@ -1,15 +1,15 @@ /* Simple DirectMedia Layer Copyright (C) 1997-2013 Sam Lantinga - + 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. - + Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - + 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be diff --git a/src/SDL_log.c b/src/SDL_log.c index b62f7fd5a..fd9545e4c 100644 --- a/src/SDL_log.c +++ b/src/SDL_log.c @@ -138,7 +138,7 @@ SDL_LogGetPriority(int category) } if (category == SDL_LOG_CATEGORY_TEST) { - return SDL_test_priority; + return SDL_test_priority; } else if (category == SDL_LOG_CATEGORY_APPLICATION) { return SDL_application_priority; } else if (category == SDL_LOG_CATEGORY_ASSERT) { @@ -328,19 +328,18 @@ SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority, } } #elif defined(__PSP__) -//Simple Log System for PSP - { - unsigned int length; - char* output; - FILE* pFile; - length = SDL_strlen(SDL_priority_prefixes[priority]) + 2 + SDL_strlen(message) + 1; + { + unsigned int length; + char* output; + FILE* pFile; + length = SDL_strlen(SDL_priority_prefixes[priority]) + 2 + SDL_strlen(message) + 1; output = SDL_stack_alloc(char, length); - SDL_snprintf(output, length, "%s: %s", SDL_priority_prefixes[priority], message); - pFile = fopen ("SDL_Log.txt", "a"); - fwrite (output, strlen (output), 1, pFile); - SDL_stack_free(output); - fclose (pFile); - } + SDL_snprintf(output, length, "%s: %s", SDL_priority_prefixes[priority], message); + pFile = fopen ("SDL_Log.txt", "a"); + fwrite (output, strlen (output), 1, pFile); + SDL_stack_free(output); + fclose (pFile); + } #endif #if HAVE_STDIO_H fprintf(stderr, "%s: %s\n", SDL_priority_prefixes[priority], message); diff --git a/src/atomic/SDL_atomic.c b/src/atomic/SDL_atomic.c index 6cf2384a5..cd799dea7 100644 --- a/src/atomic/SDL_atomic.c +++ b/src/atomic/SDL_atomic.c @@ -29,8 +29,8 @@ */ #undef SDL_AtomicCAS #undef SDL_AtomicCASPtr - -/* + +/* If any of the operations are not provided then we must emulate some of them. That means we need a nice implementation of spin locks that avoids the "one big lock" problem. We use a vector of spin @@ -40,7 +40,7 @@ To generate the index of the lock we first shift by 3 bits to get rid on the zero bits that result from 32 and 64 bit allignment of data. We then mask off all but 5 bits and use those 5 bits as an - index into the table. + index into the table. Picking the lock this way insures that accesses to the same data at the same time will go to the same lock. OTOH, accesses to different diff --git a/src/atomic/SDL_spinlock.c b/src/atomic/SDL_spinlock.c index 12c06a33e..f3aeea0e2 100644 --- a/src/atomic/SDL_spinlock.c +++ b/src/atomic/SDL_spinlock.c @@ -76,11 +76,11 @@ SDL_AtomicTryLock(SDL_SpinLock *lock) return (result == 0); #elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) - int result; - __asm__ __volatile__( + int result; + __asm__ __volatile__( "lock ; xchgl %0, (%1)\n" : "=r" (result) : "r" (lock), "0" (1) : "cc", "memory"); - return (result == 0); + return (result == 0); #elif defined(__MACOSX__) || defined(__IPHONEOS__) /* Maybe used for PowerPC, but the Intel asm or gcc atomics are favored. */ @@ -114,10 +114,10 @@ SDL_AtomicUnlock(SDL_SpinLock *lock) #elif HAVE_GCC_ATOMICS || HAVE_GCC_SYNC_LOCK_TEST_AND_SET __sync_lock_release(lock); - + #elif HAVE_PTHREAD_SPINLOCK pthread_spin_unlock(lock); - + #else *lock = 0; #endif diff --git a/src/audio/SDL_audiocvt.c b/src/audio/SDL_audiocvt.c index 2d067e779..1ccd83d74 100644 --- a/src/audio/SDL_audiocvt.c +++ b/src/audio/SDL_audiocvt.c @@ -972,7 +972,7 @@ SDL_BuildAudioCVT(SDL_AudioCVT * cvt, if (cvt == NULL) { return SDL_InvalidParamError("cvt"); } - + /* there are no unsigned types over 16 bits, so catch this up front. */ if ((SDL_AUDIO_BITSIZE(src_fmt) > 16) && (!SDL_AUDIO_ISSIGNED(src_fmt))) { return SDL_SetError("Invalid source format"); diff --git a/src/audio/SDL_audiodev.c b/src/audio/SDL_audiodev.c index 048a8a54e..91b60c376 100644 --- a/src/audio/SDL_audiodev.c +++ b/src/audio/SDL_audiodev.c @@ -40,10 +40,10 @@ #endif #endif #ifndef _PATH_DEV_DSP24 -#define _PATH_DEV_DSP24 "/dev/sound/dsp" +#define _PATH_DEV_DSP24 "/dev/sound/dsp" #endif #ifndef _PATH_DEV_AUDIO -#define _PATH_DEV_AUDIO "/dev/audio" +#define _PATH_DEV_AUDIO "/dev/audio" #endif static inline void diff --git a/src/audio/SDL_audiomem.h b/src/audio/SDL_audiomem.h index 558ea4985..8c027c3a5 100644 --- a/src/audio/SDL_audiomem.h +++ b/src/audio/SDL_audiomem.h @@ -20,6 +20,6 @@ */ #include "SDL_config.h" -#define SDL_AllocAudioMem SDL_malloc -#define SDL_FreeAudioMem SDL_free +#define SDL_AllocAudioMem SDL_malloc +#define SDL_FreeAudioMem SDL_free /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/audio/SDL_mixer.c b/src/audio/SDL_mixer.c index b45102daa..37907596f 100644 --- a/src/audio/SDL_mixer.c +++ b/src/audio/SDL_mixer.c @@ -82,8 +82,8 @@ static const Uint8 mix8[] = { }; /* The volume ranges from 0 - 128 */ -#define ADJUST_VOLUME(s, v) (s = (s*v)/SDL_MIX_MAXVOLUME) -#define ADJUST_VOLUME_U8(s, v) (s = (((s-128)*v)/SDL_MIX_MAXVOLUME)+128) +#define ADJUST_VOLUME(s, v) (s = (s*v)/SDL_MIX_MAXVOLUME) +#define ADJUST_VOLUME_U8(s, v) (s = (((s-128)*v)/SDL_MIX_MAXVOLUME)+128) void diff --git a/src/audio/SDL_sysaudio.h b/src/audio/SDL_sysaudio.h index 13c82045e..83919c6e4 100644 --- a/src/audio/SDL_sysaudio.h +++ b/src/audio/SDL_sysaudio.h @@ -28,7 +28,7 @@ /* The SDL audio driver */ typedef struct SDL_AudioDevice SDL_AudioDevice; -#define _THIS SDL_AudioDevice *_this +#define _THIS SDL_AudioDevice *_this /* Used by audio targets during DetectDevices() */ typedef void (*SDL_AddAudioDevice)(const char *name); diff --git a/src/audio/SDL_wave.h b/src/audio/SDL_wave.h index d66e684d2..d82399cb8 100644 --- a/src/audio/SDL_wave.h +++ b/src/audio/SDL_wave.h @@ -25,26 +25,26 @@ /*******************************************/ /* Define values for Microsoft WAVE format */ /*******************************************/ -#define RIFF 0x46464952 /* "RIFF" */ -#define WAVE 0x45564157 /* "WAVE" */ -#define FACT 0x74636166 /* "fact" */ -#define LIST 0x5453494c /* "LIST" */ -#define FMT 0x20746D66 /* "fmt " */ -#define DATA 0x61746164 /* "data" */ -#define PCM_CODE 0x0001 -#define MS_ADPCM_CODE 0x0002 -#define IEEE_FLOAT_CODE 0x0003 -#define IMA_ADPCM_CODE 0x0011 -#define MP3_CODE 0x0055 -#define WAVE_MONO 1 -#define WAVE_STEREO 2 +#define RIFF 0x46464952 /* "RIFF" */ +#define WAVE 0x45564157 /* "WAVE" */ +#define FACT 0x74636166 /* "fact" */ +#define LIST 0x5453494c /* "LIST" */ +#define FMT 0x20746D66 /* "fmt " */ +#define DATA 0x61746164 /* "data" */ +#define PCM_CODE 0x0001 +#define MS_ADPCM_CODE 0x0002 +#define IEEE_FLOAT_CODE 0x0003 +#define IMA_ADPCM_CODE 0x0011 +#define MP3_CODE 0x0055 +#define WAVE_MONO 1 +#define WAVE_STEREO 2 /* Normally, these three chunks come consecutively in a WAVE file */ typedef struct WaveFMT { /* Not saved in the chunk we read: - Uint32 FMTchunk; - Uint32 fmtlen; + Uint32 FMTchunk; + Uint32 fmtlen; */ Uint16 encoding; Uint16 channels; /* 1 = mono, 2 = stereo */ @@ -61,4 +61,5 @@ typedef struct Chunk Uint32 length; Uint8 *data; } Chunk; + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/audio/alsa/SDL_alsa_audio.c b/src/audio/alsa/SDL_alsa_audio.c index 9b5e75624..180064f31 100644 --- a/src/audio/alsa/SDL_alsa_audio.c +++ b/src/audio/alsa/SDL_alsa_audio.c @@ -155,7 +155,7 @@ static void UnloadALSALibrary(void) { if (alsa_handle != NULL) { - SDL_UnloadObject(alsa_handle); + SDL_UnloadObject(alsa_handle); alsa_handle = NULL; } } diff --git a/src/audio/alsa/SDL_alsa_audio.h b/src/audio/alsa/SDL_alsa_audio.h index 50acd5a33..5a4bf7fcf 100644 --- a/src/audio/alsa/SDL_alsa_audio.h +++ b/src/audio/alsa/SDL_alsa_audio.h @@ -28,7 +28,7 @@ #include "../SDL_sysaudio.h" /* Hidden "this" pointer for the audio functions */ -#define _THIS SDL_AudioDevice *this +#define _THIS SDL_AudioDevice *this struct SDL_PrivateAudioData { diff --git a/src/audio/android/SDL_androidaudio.c b/src/audio/android/SDL_androidaudio.c index a1df47512..45c128282 100644 --- a/src/audio/android/SDL_androidaudio.c +++ b/src/audio/android/SDL_androidaudio.c @@ -40,12 +40,12 @@ AndroidAUD_OpenDevice(_THIS, const char *devname, int iscapture) SDL_AudioFormat test_format; if (iscapture) { - //TODO: implement capture - return SDL_SetError("Capture not supported on Android"); + /* TODO: implement capture */ + return SDL_SetError("Capture not supported on Android"); } if (audioDevice != NULL) { - return SDL_SetError("Only one audio device at a time please!"); + return SDL_SetError("Only one audio device at a time please!"); } audioDevice = this; @@ -57,39 +57,39 @@ AndroidAUD_OpenDevice(_THIS, const char *devname, int iscapture) SDL_memset(this->hidden, 0, (sizeof *this->hidden)); test_format = SDL_FirstAudioFormat(this->spec.format); - while (test_format != 0) { // no "UNKNOWN" constant + while (test_format != 0) { /* no "UNKNOWN" constant */ if ((test_format == AUDIO_U8) || (test_format == AUDIO_S16LSB)) { this->spec.format = test_format; break; } test_format = SDL_NextAudioFormat(); } - + if (test_format == 0) { - // Didn't find a compatible format :( - return SDL_SetError("No compatible audio format!"); + /* Didn't find a compatible format :( */ + return SDL_SetError("No compatible audio format!"); } if (this->spec.channels > 1) { - this->spec.channels = 2; + this->spec.channels = 2; } else { - this->spec.channels = 1; + this->spec.channels = 1; } if (this->spec.freq < 8000) { - this->spec.freq = 8000; + this->spec.freq = 8000; } if (this->spec.freq > 48000) { - this->spec.freq = 48000; + this->spec.freq = 48000; } - // TODO: pass in/return a (Java) device ID, also whether we're opening for input or output + /* TODO: pass in/return a (Java) device ID, also whether we're opening for input or output */ this->spec.samples = Android_JNI_OpenAudioDevice(this->spec.freq, this->spec.format == AUDIO_U8 ? 0 : 1, this->spec.channels, this->spec.samples); SDL_CalculateAudioSpec(&this->spec); if (this->spec.samples == 0) { - // Init failed? - return SDL_SetError("Java-side initialization failed!"); + /* Init failed? */ + return SDL_SetError("Java-side initialization failed!"); } return 0; @@ -111,13 +111,13 @@ static void AndroidAUD_CloseDevice(_THIS) { if (this->hidden != NULL) { - SDL_free(this->hidden); - this->hidden = NULL; + SDL_free(this->hidden); + this->hidden = NULL; } - Android_JNI_CloseAudioDevice(); + Android_JNI_CloseAudioDevice(); if (audioDevice == this) { - audioDevice = NULL; + audioDevice = NULL; } } @@ -132,7 +132,7 @@ AndroidAUD_Init(SDL_AudioDriverImpl * impl) /* and the capabilities */ impl->ProvidesOwnCallbackThread = 1; - impl->HasCaptureSupport = 0; //TODO + impl->HasCaptureSupport = 0; /* TODO */ impl->OnlyHasDefaultOutputDevice = 1; impl->OnlyHasDefaultInputDevice = 1; @@ -147,7 +147,7 @@ AudioBootStrap ANDROIDAUD_bootstrap = { void Android_RunAudioThread() { - SDL_RunAudio(audioDevice); + SDL_RunAudio(audioDevice); } #endif /* SDL_AUDIO_DRIVER_ANDROID */ diff --git a/src/audio/android/SDL_androidaudio.h b/src/audio/android/SDL_androidaudio.h index fbadcfc71..383c708b7 100644 --- a/src/audio/android/SDL_androidaudio.h +++ b/src/audio/android/SDL_androidaudio.h @@ -26,7 +26,7 @@ #include "../SDL_sysaudio.h" /* Hidden "this" pointer for the audio functions */ -#define _THIS SDL_AudioDevice *this +#define _THIS SDL_AudioDevice *this struct SDL_PrivateAudioData { diff --git a/src/audio/arts/SDL_artsaudio.h b/src/audio/arts/SDL_artsaudio.h index 8b3f290b1..1387cc5c0 100644 --- a/src/audio/arts/SDL_artsaudio.h +++ b/src/audio/arts/SDL_artsaudio.h @@ -28,7 +28,7 @@ #include "../SDL_sysaudio.h" /* Hidden "this" pointer for the audio functions */ -#define _THIS SDL_AudioDevice *this +#define _THIS SDL_AudioDevice *this struct SDL_PrivateAudioData { @@ -46,7 +46,7 @@ struct SDL_PrivateAudioData float frame_ticks; float next_frame; }; -#define FUDGE_TICKS 10 /* The scheduler overhead ticks per frame */ +#define FUDGE_TICKS 10 /* The scheduler overhead ticks per frame */ #endif /* _SDL_artscaudio_h */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/audio/baudio/SDL_beaudio.h b/src/audio/baudio/SDL_beaudio.h index 9ce5af235..61f9dec83 100644 --- a/src/audio/baudio/SDL_beaudio.h +++ b/src/audio/baudio/SDL_beaudio.h @@ -26,7 +26,7 @@ #include "../SDL_sysaudio.h" /* Hidden "this" pointer for the audio functions */ -#define _THIS SDL_AudioDevice *_this +#define _THIS SDL_AudioDevice *_this struct SDL_PrivateAudioData { diff --git a/src/audio/bsd/SDL_bsdaudio.h b/src/audio/bsd/SDL_bsdaudio.h index b06aca9c9..b64be31b2 100644 --- a/src/audio/bsd/SDL_bsdaudio.h +++ b/src/audio/bsd/SDL_bsdaudio.h @@ -25,7 +25,7 @@ #include "../SDL_sysaudio.h" -#define _THIS SDL_AudioDevice *this +#define _THIS SDL_AudioDevice *this struct SDL_PrivateAudioData { @@ -44,7 +44,7 @@ struct SDL_PrivateAudioData float next_frame; }; -#define FUDGE_TICKS 10 /* The scheduler overhead ticks per frame */ +#define FUDGE_TICKS 10 /* The scheduler overhead ticks per frame */ #endif /* _SDL_bsdaudio_h */ diff --git a/src/audio/coreaudio/SDL_coreaudio.c b/src/audio/coreaudio/SDL_coreaudio.c index 8f83d0b39..a35135a2f 100644 --- a/src/audio/coreaudio/SDL_coreaudio.c +++ b/src/audio/coreaudio/SDL_coreaudio.c @@ -308,8 +308,8 @@ inputCallback(void *inRefCon, UInt32 inBusNumber, UInt32 inNumberFrames, AudioBufferList * ioData) { - //err = AudioUnitRender(afr->fAudioUnit, ioActionFlags, inTimeStamp, inBusNumber, inNumberFrames, afr->fAudioBuffer); - // !!! FIXME: write me! + /* err = AudioUnitRender(afr->fAudioUnit, ioActionFlags, inTimeStamp, inBusNumber, inNumberFrames, afr->fAudioBuffer); */ + /* !!! FIXME: write me! */ return noErr; } @@ -380,7 +380,7 @@ prepare_audiounit(_THIS, const char *devname, int iscapture, return 0; } #endif - + SDL_zero(desc); desc.componentType = kAudioUnitType_Output; desc.componentManufacturer = kAudioUnitManufacturer_Apple; diff --git a/src/audio/coreaudio/SDL_coreaudio.h b/src/audio/coreaudio/SDL_coreaudio.h index 31057557e..a05d4504f 100644 --- a/src/audio/coreaudio/SDL_coreaudio.h +++ b/src/audio/coreaudio/SDL_coreaudio.h @@ -42,7 +42,7 @@ #include /* Hidden "this" pointer for the audio functions */ -#define _THIS SDL_AudioDevice *this +#define _THIS SDL_AudioDevice *this struct SDL_PrivateAudioData { diff --git a/src/audio/directsound/SDL_directsound.h b/src/audio/directsound/SDL_directsound.h index 37a6ee133..758299f14 100644 --- a/src/audio/directsound/SDL_directsound.h +++ b/src/audio/directsound/SDL_directsound.h @@ -28,7 +28,7 @@ #include "../SDL_sysaudio.h" /* Hidden "this" pointer for the audio functions */ -#define _THIS SDL_AudioDevice *this +#define _THIS SDL_AudioDevice *this /* The DirectSound objects */ struct SDL_PrivateAudioData diff --git a/src/audio/directsound/directx.h b/src/audio/directsound/directx.h index 8ddfa00cb..963d2b88e 100644 --- a/src/audio/directsound/directx.h +++ b/src/audio/directsound/directx.h @@ -19,47 +19,47 @@ /* Error codes not yet included in Win32 API header files */ #ifndef MAKE_HRESULT #define MAKE_HRESULT(sev,fac,code) \ - ((HRESULT)(((unsigned long)(sev)<<31) | ((unsigned long)(fac)<<16) | ((unsigned long)(code)))) + ((HRESULT)(((unsigned long)(sev)<<31) | ((unsigned long)(fac)<<16) | ((unsigned long)(code)))) #endif #ifndef S_OK -#define S_OK (HRESULT)0x00000000L +#define S_OK (HRESULT)0x00000000L #endif #ifndef SUCCEEDED -#define SUCCEEDED(x) ((HRESULT)(x) >= 0) +#define SUCCEEDED(x) ((HRESULT)(x) >= 0) #endif #ifndef FAILED -#define FAILED(x) ((HRESULT)(x)<0) +#define FAILED(x) ((HRESULT)(x)<0) #endif #ifndef E_FAIL -#define E_FAIL (HRESULT)0x80000008L +#define E_FAIL (HRESULT)0x80000008L #endif #ifndef E_NOINTERFACE -#define E_NOINTERFACE (HRESULT)0x80004002L +#define E_NOINTERFACE (HRESULT)0x80004002L #endif #ifndef E_OUTOFMEMORY -#define E_OUTOFMEMORY (HRESULT)0x8007000EL +#define E_OUTOFMEMORY (HRESULT)0x8007000EL #endif #ifndef E_INVALIDARG -#define E_INVALIDARG (HRESULT)0x80070057L +#define E_INVALIDARG (HRESULT)0x80070057L #endif #ifndef E_NOTIMPL -#define E_NOTIMPL (HRESULT)0x80004001L +#define E_NOTIMPL (HRESULT)0x80004001L #endif #ifndef REGDB_E_CLASSNOTREG -#define REGDB_E_CLASSNOTREG (HRESULT)0x80040154L +#define REGDB_E_CLASSNOTREG (HRESULT)0x80040154L #endif /* Severity codes */ #ifndef SEVERITY_ERROR -#define SEVERITY_ERROR 1 +#define SEVERITY_ERROR 1 #endif /* Error facility codes */ #ifndef FACILITY_WIN32 -#define FACILITY_WIN32 7 +#define FACILITY_WIN32 7 #endif #ifndef FIELD_OFFSET diff --git a/src/audio/disk/SDL_diskaudio.h b/src/audio/disk/SDL_diskaudio.h index 3869bd145..7e5b48406 100644 --- a/src/audio/disk/SDL_diskaudio.h +++ b/src/audio/disk/SDL_diskaudio.h @@ -27,7 +27,7 @@ #include "../SDL_sysaudio.h" /* Hidden "this" pointer for the audio functions */ -#define _THIS SDL_AudioDevice *this +#define _THIS SDL_AudioDevice *this struct SDL_PrivateAudioData { diff --git a/src/audio/dsp/SDL_dspaudio.c b/src/audio/dsp/SDL_dspaudio.c index f868e874a..c62a22f8a 100644 --- a/src/audio/dsp/SDL_dspaudio.c +++ b/src/audio/dsp/SDL_dspaudio.c @@ -161,7 +161,7 @@ DSP_OpenDevice(_THIS, const char *devname, int iscapture) break; #if 0 /* - * These formats are not used by any real life systems so they are not + * These formats are not used by any real life systems so they are not * needed here. */ case AUDIO_S8: diff --git a/src/audio/dsp/SDL_dspaudio.h b/src/audio/dsp/SDL_dspaudio.h index 9f7df71c5..62ed45f18 100644 --- a/src/audio/dsp/SDL_dspaudio.h +++ b/src/audio/dsp/SDL_dspaudio.h @@ -26,7 +26,7 @@ #include "../SDL_sysaudio.h" /* Hidden "this" pointer for the audio functions */ -#define _THIS SDL_AudioDevice *this +#define _THIS SDL_AudioDevice *this struct SDL_PrivateAudioData { @@ -37,7 +37,7 @@ struct SDL_PrivateAudioData Uint8 *mixbuf; int mixlen; }; -#define FUDGE_TICKS 10 /* The scheduler overhead ticks per frame */ +#define FUDGE_TICKS 10 /* The scheduler overhead ticks per frame */ #endif /* _SDL_dspaudio_h */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/audio/dummy/SDL_dummyaudio.h b/src/audio/dummy/SDL_dummyaudio.h index 22a4cd242..c0015a54d 100644 --- a/src/audio/dummy/SDL_dummyaudio.h +++ b/src/audio/dummy/SDL_dummyaudio.h @@ -26,7 +26,7 @@ #include "../SDL_sysaudio.h" /* Hidden "this" pointer for the audio functions */ -#define _THIS SDL_AudioDevice *this +#define _THIS SDL_AudioDevice *this struct SDL_PrivateAudioData { diff --git a/src/audio/esd/SDL_esdaudio.c b/src/audio/esd/SDL_esdaudio.c index cdc12120f..92716f39b 100644 --- a/src/audio/esd/SDL_esdaudio.c +++ b/src/audio/esd/SDL_esdaudio.c @@ -40,7 +40,7 @@ #include "SDL_name.h" #include "SDL_loadso.h" #else -#define SDL_NAME(X) X +#define SDL_NAME(X) X #endif #ifdef SDL_AUDIO_DRIVER_ESD_DYNAMIC @@ -123,7 +123,7 @@ ESD_WaitDevice(_THIS) /* Check to see if the thread-parent process is still alive */ { static int cnt = 0; - /* Note that this only works with thread implementations + /* Note that this only works with thread implementations that use a different process id for each thread. */ /* Check every 10 loops */ diff --git a/src/audio/esd/SDL_esdaudio.h b/src/audio/esd/SDL_esdaudio.h index ab0e25217..26bea9cf0 100644 --- a/src/audio/esd/SDL_esdaudio.h +++ b/src/audio/esd/SDL_esdaudio.h @@ -26,7 +26,7 @@ #include "../SDL_sysaudio.h" /* Hidden "this" pointer for the audio functions */ -#define _THIS SDL_AudioDevice *this +#define _THIS SDL_AudioDevice *this struct SDL_PrivateAudioData { @@ -44,7 +44,7 @@ struct SDL_PrivateAudioData float frame_ticks; float next_frame; }; -#define FUDGE_TICKS 10 /* The scheduler overhead ticks per frame */ +#define FUDGE_TICKS 10 /* The scheduler overhead ticks per frame */ #endif /* _SDL_esdaudio_h */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/audio/fusionsound/SDL_fsaudio.c b/src/audio/fusionsound/SDL_fsaudio.c index bc279fec6..2e468d5c6 100644 --- a/src/audio/fusionsound/SDL_fsaudio.c +++ b/src/audio/fusionsound/SDL_fsaudio.c @@ -37,13 +37,13 @@ #include -//#define SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC "libfusionsound.so" +/* #define SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC "libfusionsound.so" */ #ifdef SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC #include "SDL_name.h" #include "SDL_loadso.h" #else -#define SDL_NAME(X) X +#define SDL_NAME(X) X #endif #if (FUSIONSOUND_MAJOR_VERSION == 1) && (FUSIONSOUND_MINOR_VERSION < 1) @@ -51,7 +51,7 @@ typedef DFBResult DirectResult; #endif /* Buffers to use - more than 2 gives a lot of latency */ -#define FUSION_BUFFERS (2) +#define FUSION_BUFFERS (2) #ifdef SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC diff --git a/src/audio/fusionsound/SDL_fsaudio.h b/src/audio/fusionsound/SDL_fsaudio.h index 0c313d666..7f2277501 100644 --- a/src/audio/fusionsound/SDL_fsaudio.h +++ b/src/audio/fusionsound/SDL_fsaudio.h @@ -28,7 +28,7 @@ #include "../SDL_sysaudio.h" /* Hidden "this" pointer for the audio functions */ -#define _THIS SDL_AudioDevice *this +#define _THIS SDL_AudioDevice *this struct SDL_PrivateAudioData { diff --git a/src/audio/nas/SDL_nasaudio.h b/src/audio/nas/SDL_nasaudio.h index 65739cdf7..85bd761dd 100644 --- a/src/audio/nas/SDL_nasaudio.h +++ b/src/audio/nas/SDL_nasaudio.h @@ -33,7 +33,7 @@ #include "../SDL_sysaudio.h" /* Hidden "this" pointer for the audio functions */ -#define _THIS SDL_AudioDevice *this +#define _THIS SDL_AudioDevice *this struct SDL_PrivateAudioData { diff --git a/src/audio/paudio/SDL_paudio.c b/src/audio/paudio/SDL_paudio.c index 3966d1e7a..5a18b45e5 100644 --- a/src/audio/paudio/SDL_paudio.c +++ b/src/audio/paudio/SDL_paudio.c @@ -48,13 +48,13 @@ #include /* Open the audio device for playback, and don't block if busy */ -/* #define OPEN_FLAGS (O_WRONLY|O_NONBLOCK) */ -#define OPEN_FLAGS O_WRONLY +/* #define OPEN_FLAGS (O_WRONLY|O_NONBLOCK) */ +#define OPEN_FLAGS O_WRONLY /* Get the name of the audio device we use for output */ #ifndef _PATH_DEV_DSP -#define _PATH_DEV_DSP "/dev/%caud%c/%c" +#define _PATH_DEV_DSP "/dev/%caud%c/%c" #endif static char devsettings[][3] = { diff --git a/src/audio/paudio/SDL_paudio.h b/src/audio/paudio/SDL_paudio.h index 0aa0e2be9..7be1ed651 100644 --- a/src/audio/paudio/SDL_paudio.h +++ b/src/audio/paudio/SDL_paudio.h @@ -26,7 +26,7 @@ #include "../SDL_sysaudio.h" /* Hidden "this" pointer for the audio functions */ -#define _THIS SDL_AudioDevice *this +#define _THIS SDL_AudioDevice *this struct SDL_PrivateAudioData { @@ -41,7 +41,7 @@ struct SDL_PrivateAudioData float frame_ticks; float next_frame; }; -#define FUDGE_TICKS 10 /* The scheduler overhead ticks per frame */ +#define FUDGE_TICKS 10 /* The scheduler overhead ticks per frame */ #endif /* _SDL_paudaudio_h */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/audio/psp/SDL_pspaudio.c b/src/audio/psp/SDL_pspaudio.c index fc03a8754..4b5534a3c 100644 --- a/src/audio/psp/SDL_pspaudio.c +++ b/src/audio/psp/SDL_pspaudio.c @@ -42,28 +42,28 @@ static int PSPAUD_OpenDevice(_THIS, const char *devname, int iscapture) { - int format, mixlen, i; + int format, mixlen, i; this->hidden = (struct SDL_PrivateAudioData *) SDL_malloc(sizeof(*this->hidden)); if (this->hidden == NULL) { return SDL_OutOfMemory(); } SDL_memset(this->hidden, 0, sizeof(*this->hidden)); - switch (this->spec.format & 0xff) { - case 8: - case 16: - this->spec.format = AUDIO_S16LSB; - break; - default: - return SDL_SetError("Unsupported audio format"); - } - - /* The sample count must be a multiple of 64. */ - this->spec.samples = PSP_AUDIO_SAMPLE_ALIGN(this->spec.samples); - this->spec.freq = 44100; - - /* Update the fragment size as size in bytes. */ -// SDL_CalculateAudioSpec(this->spec); MOD + switch (this->spec.format & 0xff) { + case 8: + case 16: + this->spec.format = AUDIO_S16LSB; + break; + default: + return SDL_SetError("Unsupported audio format"); + } + + /* The sample count must be a multiple of 64. */ + this->spec.samples = PSP_AUDIO_SAMPLE_ALIGN(this->spec.samples); + this->spec.freq = 44100; + + /* Update the fragment size as size in bytes. */ +// SDL_CalculateAudioSpec(this->spec); MOD switch (this->spec.format) { case AUDIO_U8: this->spec.silence = 0x80; @@ -75,86 +75,86 @@ PSPAUD_OpenDevice(_THIS, const char *devname, int iscapture) this->spec.size = SDL_AUDIO_BITSIZE(this->spec.format) / 8; this->spec.size *= this->spec.channels; this->spec.size *= this->spec.samples; - + //========================================== - /* Allocate the mixing buffer. Its size and starting address must - be a multiple of 64 bytes. Our sample count is already a multiple of - 64, so spec->size should be a multiple of 64 as well. */ - mixlen = this->spec.size * NUM_BUFFERS; - this->hidden->rawbuf = (Uint8 *) memalign(64, mixlen); - if (this->hidden->rawbuf == NULL) { - return SDL_SetError("Couldn't allocate mixing buffer"); - } - - /* Setup the hardware channel. */ - if (this->spec.channels == 1) { - format = PSP_AUDIO_FORMAT_MONO; - } else { - format = PSP_AUDIO_FORMAT_STEREO; - } - this->hidden->channel = sceAudioChReserve(PSP_AUDIO_NEXT_CHANNEL, this->spec.samples, format); - if (this->hidden->channel < 0) { - free(this->hidden->rawbuf); - this->hidden->rawbuf = NULL; - return SDL_SetError("Couldn't reserve hardware channel"); - } - - memset(this->hidden->rawbuf, 0, mixlen); - for (i = 0; i < NUM_BUFFERS; i++) { - this->hidden->mixbufs[i] = &this->hidden->rawbuf[i * this->spec.size]; - } - - this->hidden->next_buffer = 0; - return 0; + /* Allocate the mixing buffer. Its size and starting address must + be a multiple of 64 bytes. Our sample count is already a multiple of + 64, so spec->size should be a multiple of 64 as well. */ + mixlen = this->spec.size * NUM_BUFFERS; + this->hidden->rawbuf = (Uint8 *) memalign(64, mixlen); + if (this->hidden->rawbuf == NULL) { + return SDL_SetError("Couldn't allocate mixing buffer"); + } + + /* Setup the hardware channel. */ + if (this->spec.channels == 1) { + format = PSP_AUDIO_FORMAT_MONO; + } else { + format = PSP_AUDIO_FORMAT_STEREO; + } + this->hidden->channel = sceAudioChReserve(PSP_AUDIO_NEXT_CHANNEL, this->spec.samples, format); + if (this->hidden->channel < 0) { + free(this->hidden->rawbuf); + this->hidden->rawbuf = NULL; + return SDL_SetError("Couldn't reserve hardware channel"); + } + + memset(this->hidden->rawbuf, 0, mixlen); + for (i = 0; i < NUM_BUFFERS; i++) { + this->hidden->mixbufs[i] = &this->hidden->rawbuf[i * this->spec.size]; + } + + this->hidden->next_buffer = 0; + return 0; } static void PSPAUD_PlayDevice(_THIS) { - Uint8 *mixbuf = this->hidden->mixbufs[this->hidden->next_buffer]; + Uint8 *mixbuf = this->hidden->mixbufs[this->hidden->next_buffer]; - if (this->spec.channels == 1) { - sceAudioOutputBlocking(this->hidden->channel, PSP_AUDIO_VOLUME_MAX, mixbuf); - } else { - sceAudioOutputPannedBlocking(this->hidden->channel, PSP_AUDIO_VOLUME_MAX, PSP_AUDIO_VOLUME_MAX, mixbuf); - } + if (this->spec.channels == 1) { + sceAudioOutputBlocking(this->hidden->channel, PSP_AUDIO_VOLUME_MAX, mixbuf); + } else { + sceAudioOutputPannedBlocking(this->hidden->channel, PSP_AUDIO_VOLUME_MAX, PSP_AUDIO_VOLUME_MAX, mixbuf); + } - this->hidden->next_buffer = (this->hidden->next_buffer + 1) % NUM_BUFFERS; + this->hidden->next_buffer = (this->hidden->next_buffer + 1) % NUM_BUFFERS; } /* This function waits until it is possible to write a full sound buffer */ static void PSPAUD_WaitDevice(_THIS) { - /* Because we block when sending audio, there's no need for this function to do anything. */ + /* Because we block when sending audio, there's no need for this function to do anything. */ } static Uint8 *PSPAUD_GetDeviceBuf(_THIS) { - return this->hidden->mixbufs[this->hidden->next_buffer]; + return this->hidden->mixbufs[this->hidden->next_buffer]; } static void PSPAUD_CloseDevice(_THIS) { - if (this->hidden->channel >= 0) { - sceAudioChRelease(this->hidden->channel); - this->hidden->channel = -1; - } - - if (this->hidden->rawbuf != NULL) { - free(this->hidden->rawbuf); - this->hidden->rawbuf = NULL; - } + if (this->hidden->channel >= 0) { + sceAudioChRelease(this->hidden->channel); + this->hidden->channel = -1; + } + + if (this->hidden->rawbuf != NULL) { + free(this->hidden->rawbuf); + this->hidden->rawbuf = NULL; + } } static void PSPAUD_ThreadInit(_THIS) { - /* Increase the priority of this audio thread by 1 to put it - ahead of other SDL threads. */ - SceUID thid; - SceKernelThreadInfo status; - thid = sceKernelGetThreadId(); - status.size = sizeof(SceKernelThreadInfo); - if (sceKernelReferThreadStatus(thid, &status) == 0) { - sceKernelChangeThreadPriority(thid, status.currentPriority - 1); - } + /* Increase the priority of this audio thread by 1 to put it + ahead of other SDL threads. */ + SceUID thid; + SceKernelThreadInfo status; + thid = sceKernelGetThreadId(); + status.size = sizeof(SceKernelThreadInfo); + if (sceKernelReferThreadStatus(thid, &status) == 0) { + sceKernelChangeThreadPriority(thid, status.currentPriority - 1); + } } @@ -162,17 +162,17 @@ static int PSPAUD_Init(SDL_AudioDriverImpl * impl) { - // Set the function pointers + // Set the function pointers impl->OpenDevice = PSPAUD_OpenDevice; impl->PlayDevice = PSPAUD_PlayDevice; impl->WaitDevice = PSPAUD_WaitDevice; - impl->GetDeviceBuf = PSPAUD_GetDeviceBuf; + impl->GetDeviceBuf = PSPAUD_GetDeviceBuf; impl->WaitDone = PSPAUD_WaitDevice; impl->CloseDevice = PSPAUD_CloseDevice; impl->ThreadInit = PSPAUD_ThreadInit; - + //PSP audio device - impl->OnlyHasDefaultOutputDevice = 1; + impl->OnlyHasDefaultOutputDevice = 1; /* impl->HasCaptureSupport = 1; diff --git a/src/audio/psp/SDL_pspaudio.h b/src/audio/psp/SDL_pspaudio.h index 22cf2d327..139476c6b 100644 --- a/src/audio/psp/SDL_pspaudio.h +++ b/src/audio/psp/SDL_pspaudio.h @@ -25,19 +25,19 @@ #include "../SDL_sysaudio.h" /* Hidden "this" pointer for the video functions */ -#define _THIS SDL_AudioDevice *this +#define _THIS SDL_AudioDevice *this #define NUM_BUFFERS 2 struct SDL_PrivateAudioData { - /* The hardware output channel. */ - int channel; - /* The raw allocated mixing buffer. */ - Uint8 *rawbuf; - /* Individual mixing buffers. */ - Uint8 *mixbufs[NUM_BUFFERS]; - /* Index of the next available mixing buffer. */ - int next_buffer; + /* The hardware output channel. */ + int channel; + /* The raw allocated mixing buffer. */ + Uint8 *rawbuf; + /* Individual mixing buffers. */ + Uint8 *mixbufs[NUM_BUFFERS]; + /* Index of the next available mixing buffer. */ + int next_buffer; }; #endif /* _SDL_pspaudio_h */ diff --git a/src/audio/pulseaudio/SDL_pulseaudio.c b/src/audio/pulseaudio/SDL_pulseaudio.c index 12021e6de..c8d25a800 100644 --- a/src/audio/pulseaudio/SDL_pulseaudio.c +++ b/src/audio/pulseaudio/SDL_pulseaudio.c @@ -131,7 +131,7 @@ static void UnloadPulseAudioLibrary(void) { if (pulseaudio_handle != NULL) { - SDL_UnloadObject(pulseaudio_handle); + SDL_UnloadObject(pulseaudio_handle); pulseaudio_handle = NULL; } } diff --git a/src/audio/sun/SDL_sunaudio.c b/src/audio/sun/SDL_sunaudio.c index 37e175e10..950ba444c 100644 --- a/src/audio/sun/SDL_sunaudio.c +++ b/src/audio/sun/SDL_sunaudio.c @@ -47,7 +47,7 @@ /* Open the audio device for playback, and don't block if busy */ -#if defined(AUDIO_GETINFO) && !defined(AUDIO_GETBUFINFO) +#if defined(AUDIO_GETINFO) && !defined(AUDIO_GETBUFINFO) #define AUDIO_GETBUFINFO AUDIO_GETINFO #endif @@ -82,7 +82,7 @@ static void SUNAUDIO_WaitDevice(_THIS) { #ifdef AUDIO_GETBUFINFO -#define SLEEP_FUDGE 10 /* 10 ms scheduling fudge factor */ +#define SLEEP_FUDGE 10 /* 10 ms scheduling fudge factor */ audio_info_t info; Sint32 left; diff --git a/src/audio/sun/SDL_sunaudio.h b/src/audio/sun/SDL_sunaudio.h index 1f2c0b4f2..9b92266fb 100644 --- a/src/audio/sun/SDL_sunaudio.h +++ b/src/audio/sun/SDL_sunaudio.h @@ -26,7 +26,7 @@ #include "../SDL_sysaudio.h" /* Hidden "this" pointer for the audio functions */ -#define _THIS SDL_AudioDevice *this +#define _THIS SDL_AudioDevice *this struct SDL_PrivateAudioData { diff --git a/src/audio/winmm/SDL_winmm.h b/src/audio/winmm/SDL_winmm.h index 8e67f2237..5a0574d1e 100644 --- a/src/audio/winmm/SDL_winmm.h +++ b/src/audio/winmm/SDL_winmm.h @@ -26,7 +26,7 @@ #include "../SDL_sysaudio.h" /* Hidden "this" pointer for the audio functions */ -#define _THIS SDL_AudioDevice *this +#define _THIS SDL_AudioDevice *this #define NUM_BUFFERS 2 /* -- Don't lower this! */ diff --git a/src/audio/xaudio2/SDL_xaudio2.c b/src/audio/xaudio2/SDL_xaudio2.c index 40d94086f..db29e8dbb 100644 --- a/src/audio/xaudio2/SDL_xaudio2.c +++ b/src/audio/xaudio2/SDL_xaudio2.c @@ -41,7 +41,7 @@ #include /* Hidden "this" pointer for the audio functions */ -#define _THIS SDL_AudioDevice *this +#define _THIS SDL_AudioDevice *this struct SDL_PrivateAudioData { @@ -232,17 +232,17 @@ XAUDIO2_OpenDevice(_THIS, const char *devname, int iscapture) IXAudio2SourceVoice *source = NULL; UINT32 devId = 0; /* 0 == system default device. */ - static IXAudio2VoiceCallbackVtbl callbacks_vtable = { - VoiceCBOnVoiceProcessPassStart, + static IXAudio2VoiceCallbackVtbl callbacks_vtable = { + VoiceCBOnVoiceProcessPassStart, VoiceCBOnVoiceProcessPassEnd, VoiceCBOnStreamEnd, VoiceCBOnBufferStart, VoiceCBOnBufferEnd, VoiceCBOnLoopEnd, VoiceCBOnVoiceError - }; + }; - static IXAudio2VoiceCallback callbacks = { &callbacks_vtable }; + static IXAudio2VoiceCallback callbacks = { &callbacks_vtable }; if (iscapture) { return SDL_SetError("XAudio2: capture devices unsupported."); diff --git a/src/core/android/SDL_android.cpp b/src/core/android/SDL_android.cpp index cf0e0c129..6fbb678fd 100644 --- a/src/core/android/SDL_android.cpp +++ b/src/core/android/SDL_android.cpp @@ -121,7 +121,7 @@ extern "C" void SDL_Android_Init(JNIEnv* mEnv, jclass cls) "createGLContext","(II[I)Z"); midFlipBuffers = mEnv->GetStaticMethodID(mActivityClass, "flipBuffers","()V"); - midAudioInit = mEnv->GetStaticMethodID(mActivityClass, + midAudioInit = mEnv->GetStaticMethodID(mActivityClass, "audioInit", "(IZZI)V"); midAudioWriteShortBuffer = mEnv->GetStaticMethodID(mActivityClass, "audioWriteShortBuffer", "([S)V"); @@ -184,14 +184,14 @@ extern "C" void Java_org_libsdl_app_SDLActivity_onNativeAccel( // Low memory extern "C" void Java_org_libsdl_app_SDLActivity_nativeLowMemory( JNIEnv* env, jclass cls) -{ +{ SDL_SendAppEvent(SDL_APP_LOWMEMORY); } // Quit extern "C" void Java_org_libsdl_app_SDLActivity_nativeQuit( JNIEnv* env, jclass cls) -{ +{ // Inject a SDL_QUIT event SDL_SendQuit(); SDL_SendAppEvent(SDL_APP_TERMINATING); @@ -348,7 +348,7 @@ extern "C" SDL_bool Android_JNI_CreateContext(int majorVersion, int minorVersion extern "C" void Android_JNI_SwapWindow() { JNIEnv *mEnv = Android_JNI_GetEnv(); - mEnv->CallStaticVoidMethod(mActivityClass, midFlipBuffers); + mEnv->CallStaticVoidMethod(mActivityClass, midFlipBuffers); } extern "C" void Android_JNI_SetActivityTitle(const char *title) @@ -453,7 +453,7 @@ extern "C" int Android_JNI_OpenAudioDevice(int sampleRate, int is16Bit, int chan /* Allocating the audio buffer from the Java side and passing it as the return value for audioInit no longer works on * Android >= 4.2 due to a "stale global reference" error. So now we allocate this buffer directly from this side. */ - + if (is16Bit) { jshortArray audioBufferLocal = env->NewShortArray(desiredBufferFrames * (audioBufferStereo ? 2 : 1)); if (audioBufferLocal) { @@ -513,7 +513,7 @@ extern "C" void Android_JNI_CloseAudioDevice() { JNIEnv *env = Android_JNI_GetEnv(); - env->CallStaticVoidMethod(mActivityClass, midAudioQuit); + env->CallStaticVoidMethod(mActivityClass, midAudioQuit); if (audioBuffer) { env->DeleteGlobalRef(audioBuffer); @@ -592,7 +592,7 @@ static int Android_JNI_FileOpen(SDL_RWops* ctx) mid = mEnv->GetStaticMethodID(mActivityClass, "getContext","()Landroid/content/Context;"); context = mEnv->CallStaticObjectMethod(mActivityClass, mid); - + // assetManager = context.getAssets(); mid = mEnv->GetMethodID(mEnv->GetObjectClass(context), @@ -779,7 +779,7 @@ extern "C" size_t Android_JNI_FileRead(SDL_RWops* ctx, void* buffer, ctx->hidden.androidio.position += result; } return bytesRead / size; - } + } } extern "C" size_t Android_JNI_FileWrite(SDL_RWops* ctx, const void* buffer, @@ -920,7 +920,7 @@ extern "C" Sint64 Android_JNI_FileSeek(SDL_RWops* ctx, Sint64 offset, int whence } return ctx->hidden.androidio.position; - + } extern "C" int Android_JNI_FileClose(SDL_RWops* ctx) @@ -1151,7 +1151,7 @@ extern "C" void *SDL_AndroidGetJNIEnv() extern "C" void *SDL_AndroidGetActivity() { /* See SDL_system.h for caveats on using this function. */ - + jmethodID mid; JNIEnv *env = Android_JNI_GetEnv(); diff --git a/src/events/SDL_events.c b/src/events/SDL_events.c index d6bb22e06..f27c3cb85 100644 --- a/src/events/SDL_events.c +++ b/src/events/SDL_events.c @@ -53,7 +53,7 @@ static SDL_DisabledEventBlock *SDL_disabled_events[256]; static Uint32 SDL_userevents = SDL_USEREVENT; /* Private data -- event queue */ -#define MAXEVENTS 128 +#define MAXEVENTS 128 static struct { SDL_mutex *lock; diff --git a/src/events/SDL_gesture.c b/src/events/SDL_gesture.c index a56aa3e55..f7c8c8932 100644 --- a/src/events/SDL_gesture.c +++ b/src/events/SDL_gesture.c @@ -35,13 +35,10 @@ #include #include -//TODO: Replace with malloc +/* TODO: Replace with malloc */ #define MAXPATHSIZE 1024 - - - #define DOLLARNPOINTS 64 #define DOLLARSIZE 256 diff --git a/src/events/SDL_keyboard.c b/src/events/SDL_keyboard.c index 3454bf8bb..680091f42 100644 --- a/src/events/SDL_keyboard.c +++ b/src/events/SDL_keyboard.c @@ -860,7 +860,7 @@ SDL_Keycode SDL_GetKeyFromScancode(SDL_Scancode scancode) { SDL_Keyboard *keyboard = &SDL_keyboard; - + if (scancode < SDL_SCANCODE_UNKNOWN || scancode >= SDL_NUM_SCANCODES) { SDL_InvalidParamError("scancode"); return 0; @@ -890,7 +890,7 @@ SDL_GetScancodeName(SDL_Scancode scancode) const char *name; if (scancode < SDL_SCANCODE_UNKNOWN || scancode >= SDL_NUM_SCANCODES) { SDL_InvalidParamError("scancode"); - return ""; + return ""; } name = SDL_scancode_names[scancode]; @@ -902,24 +902,24 @@ SDL_GetScancodeName(SDL_Scancode scancode) SDL_Scancode SDL_GetScancodeFromName(const char *name) { - int i; - - if (!name || !*name) { - SDL_InvalidParamError("name"); - return SDL_SCANCODE_UNKNOWN; - } - - for (i = 0; i < SDL_arraysize(SDL_scancode_names); ++i) { - if (!SDL_scancode_names[i]) { - continue; - } - if (SDL_strcasecmp(name, SDL_scancode_names[i]) == 0) { - return (SDL_Scancode)i; - } - } - - SDL_InvalidParamError("name"); - return SDL_SCANCODE_UNKNOWN; + int i; + + if (!name || !*name) { + SDL_InvalidParamError("name"); + return SDL_SCANCODE_UNKNOWN; + } + + for (i = 0; i < SDL_arraysize(SDL_scancode_names); ++i) { + if (!SDL_scancode_names[i]) { + continue; + } + if (SDL_strcasecmp(name, SDL_scancode_names[i]) == 0) { + return (SDL_Scancode)i; + } + } + + SDL_InvalidParamError("name"); + return SDL_SCANCODE_UNKNOWN; } const char * @@ -964,51 +964,51 @@ SDL_GetKeyName(SDL_Keycode key) SDL_Keycode SDL_GetKeyFromName(const char *name) { - SDL_Keycode key; + SDL_Keycode key; /* Check input */ if (name == NULL) return SDLK_UNKNOWN; - - /* If it's a single UTF-8 character, then that's the keycode itself */ - key = *(const unsigned char *)name; - if (key >= 0xF0) { - if (SDL_strlen(name) == 4) { - int i = 0; - key = (Uint16)(name[i]&0x07) << 18; - key |= (Uint16)(name[++i]&0x3F) << 12; - key |= (Uint16)(name[++i]&0x3F) << 6; - key |= (Uint16)(name[++i]&0x3F); - return key; - } - return SDLK_UNKNOWN; - } else if (key >= 0xE0) { - if (SDL_strlen(name) == 3) { - int i = 0; - key = (Uint16)(name[i]&0x0F) << 12; - key |= (Uint16)(name[++i]&0x3F) << 6; - key |= (Uint16)(name[++i]&0x3F); - return key; - } - return SDLK_UNKNOWN; - } else if (key >= 0xC0) { - if (SDL_strlen(name) == 2) { - int i = 0; - key = (Uint16)(name[i]&0x1F) << 6; - key |= (Uint16)(name[++i]&0x3F); - return key; - } - return SDLK_UNKNOWN; - } else { - if (SDL_strlen(name) == 1) { - if (key >= 'A' && key <= 'Z') { - key += 32; - } - return key; - } - - /* Get the scancode for this name, and the associated keycode */ - return SDL_default_keymap[SDL_GetScancodeFromName(name)]; - } + + /* If it's a single UTF-8 character, then that's the keycode itself */ + key = *(const unsigned char *)name; + if (key >= 0xF0) { + if (SDL_strlen(name) == 4) { + int i = 0; + key = (Uint16)(name[i]&0x07) << 18; + key |= (Uint16)(name[++i]&0x3F) << 12; + key |= (Uint16)(name[++i]&0x3F) << 6; + key |= (Uint16)(name[++i]&0x3F); + return key; + } + return SDLK_UNKNOWN; + } else if (key >= 0xE0) { + if (SDL_strlen(name) == 3) { + int i = 0; + key = (Uint16)(name[i]&0x0F) << 12; + key |= (Uint16)(name[++i]&0x3F) << 6; + key |= (Uint16)(name[++i]&0x3F); + return key; + } + return SDLK_UNKNOWN; + } else if (key >= 0xC0) { + if (SDL_strlen(name) == 2) { + int i = 0; + key = (Uint16)(name[i]&0x1F) << 6; + key |= (Uint16)(name[++i]&0x3F); + return key; + } + return SDLK_UNKNOWN; + } else { + if (SDL_strlen(name) == 1) { + if (key >= 'A' && key <= 'Z') { + key += 32; + } + return key; + } + + /* Get the scancode for this name, and the associated keycode */ + return SDL_default_keymap[SDL_GetScancodeFromName(name)]; + } } /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c index ede6a6c46..5536ab73b 100644 --- a/src/events/SDL_mouse.c +++ b/src/events/SDL_mouse.c @@ -397,12 +397,12 @@ void SDL_WarpMouseInWindow(SDL_Window * window, int x, int y) { SDL_Mouse *mouse = SDL_GetMouse(); - - if ( window == NULL ) - window = mouse->focus; - - if ( window == NULL ) - return; + + if ( window == NULL ) + window = mouse->focus; + + if ( window == NULL ) + return; if (mouse->WarpMouse) { mouse->WarpMouse(window, x, y); @@ -572,13 +572,13 @@ SDL_CreateSystemCursor(SDL_SystemCursor id) return NULL; } - cursor = mouse->CreateSystemCursor(id); + cursor = mouse->CreateSystemCursor(id); if (cursor) { cursor->next = mouse->cursors; mouse->cursors = cursor; } - return cursor; + return cursor; } /* SDL_SetCursor(NULL) can be used to force the cursor redraw, diff --git a/src/events/SDL_mouse_c.h b/src/events/SDL_mouse_c.h index 9994bc640..a8faa2e17 100644 --- a/src/events/SDL_mouse_c.h +++ b/src/events/SDL_mouse_c.h @@ -39,7 +39,7 @@ typedef struct SDL_Cursor *(*CreateCursor) (SDL_Surface * surface, int hot_x, int hot_y); /* Create a system cursor */ - SDL_Cursor *(*CreateSystemCursor) (SDL_SystemCursor id); + SDL_Cursor *(*CreateSystemCursor) (SDL_SystemCursor id); /* Show the specified cursor, or hide if cursor is NULL */ int (*ShowCursor) (SDL_Cursor * cursor); diff --git a/src/events/SDL_touch.c b/src/events/SDL_touch.c index 6fca4038d..3429b57d7 100644 --- a/src/events/SDL_touch.c +++ b/src/events/SDL_touch.c @@ -165,7 +165,7 @@ SDL_AddTouch(SDL_TouchID touchID, const char *name) return index; } -static int +static int SDL_AddFinger(SDL_Touch *touch, SDL_FingerID fingerid, float x, float y, float pressure) { SDL_Finger *finger; @@ -258,7 +258,7 @@ SDL_SendTouch(SDL_TouchID id, SDL_FingerID fingerid, event.tfinger.touchId = id; event.tfinger.fingerId = fingerid; /* I don't trust the coordinates passed on fingerUp */ - event.tfinger.x = finger->x; + event.tfinger.x = finger->x; event.tfinger.y = finger->y; event.tfinger.dx = 0; event.tfinger.dy = 0; @@ -287,7 +287,7 @@ SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid, finger = SDL_GetFinger(touch,fingerid); if (!finger) { - return SDL_SendTouch(id, fingerid, SDL_TRUE, x, y, pressure); + return SDL_SendTouch(id, fingerid, SDL_TRUE, x, y, pressure); } xrel = x - finger->x; @@ -306,7 +306,7 @@ SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid, finger->x = x; finger->y = y; finger->pressure = pressure; - + /* Post the event, if desired */ posted = 0; if (SDL_GetEventState(SDL_FINGERMOTION) == SDL_ENABLE) { @@ -317,7 +317,7 @@ SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid, event.tfinger.x = x; event.tfinger.y = y; event.tfinger.dx = xrel; - event.tfinger.dy = yrel; + event.tfinger.dy = yrel; event.tfinger.pressure = pressure; posted = (SDL_PushEvent(&event) > 0); } diff --git a/src/events/SDL_touch_c.h b/src/events/SDL_touch_c.h index 8961d74e5..d0a2cf2f7 100644 --- a/src/events/SDL_touch_c.h +++ b/src/events/SDL_touch_c.h @@ -38,17 +38,17 @@ extern int SDL_TouchInit(void); /* Add a touch, returning the index of the touch, or -1 if there was an error. */ extern int SDL_AddTouch(SDL_TouchID id, const char *name); - + /* Get the touch with a given id */ extern SDL_Touch *SDL_GetTouch(SDL_TouchID id); /* Send a touch down/up event for a touch */ -extern int SDL_SendTouch(SDL_TouchID id, SDL_FingerID fingerid, - SDL_bool down, float x, float y, float pressure); +extern int SDL_SendTouch(SDL_TouchID id, SDL_FingerID fingerid, + SDL_bool down, float x, float y, float pressure); /* Send a touch motion event for a touch */ extern int SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid, - float x, float y, float pressure); + float x, float y, float pressure); /* Remove a touch */ extern void SDL_DelTouch(SDL_TouchID id); diff --git a/src/events/SDL_windowevents.c b/src/events/SDL_windowevents.c index 60d65ae57..9011f68e1 100644 --- a/src/events/SDL_windowevents.c +++ b/src/events/SDL_windowevents.c @@ -155,7 +155,7 @@ SDL_SendWindowEvent(SDL_Window * window, Uint8 windowevent, int data1, return 0; } window->flags &= ~SDL_WINDOW_MOUSE_FOCUS; - SDL_OnWindowLeave(window); + SDL_OnWindowLeave(window); break; case SDL_WINDOWEVENT_FOCUS_GAINED: if (window->flags & SDL_WINDOW_INPUT_FOCUS) { @@ -196,13 +196,13 @@ SDL_SendWindowEvent(SDL_Window * window, Uint8 windowevent, int data1, posted = (SDL_PushEvent(&event) > 0); } - - if (windowevent == SDL_WINDOWEVENT_CLOSE) { - if ( !window->prev && !window->next ) { - // This is the last window in the list so send the SDL_QUIT event - SDL_SendQuit(); - } - } + + if (windowevent == SDL_WINDOWEVENT_CLOSE) { + if ( !window->prev && !window->next ) { + /* This is the last window in the list so send the SDL_QUIT event */ + SDL_SendQuit(); + } + } return (posted); } diff --git a/src/events/blank_cursor.h b/src/events/blank_cursor.h index 534d2e2d2..6efb4741e 100644 --- a/src/events/blank_cursor.h +++ b/src/events/blank_cursor.h @@ -19,13 +19,13 @@ 3. This notice may not be removed or altered from any source distribution. */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * A default blank 8x8 cursor */ -#define BLANK_CWIDTH 8 -#define BLANK_CHEIGHT 8 -#define BLANK_CHOTX 0 -#define BLANK_CHOTY 0 +#define BLANK_CWIDTH 8 +#define BLANK_CHEIGHT 8 +#define BLANK_CHOTX 0 +#define BLANK_CHOTY 0 static const unsigned char blank_cdata[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; static const unsigned char blank_cmask[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; diff --git a/src/events/default_cursor.h b/src/events/default_cursor.h index 8a7b2a9e3..8c2dcfcff 100644 --- a/src/events/default_cursor.h +++ b/src/events/default_cursor.h @@ -19,13 +19,13 @@ 3. This notice may not be removed or altered from any source distribution. */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Default cursor - it happens to be the Mac cursor, but could be anything */ -#define DEFAULT_CWIDTH 16 -#define DEFAULT_CHEIGHT 16 -#define DEFAULT_CHOTX 0 -#define DEFAULT_CHOTY 0 +#define DEFAULT_CWIDTH 16 +#define DEFAULT_CHEIGHT 16 +#define DEFAULT_CHOTX 0 +#define DEFAULT_CHOTY 0 /* Added a real MacOS cursor, at the request of Luc-Olivier de Charrière */ #define USE_MACOS_CURSOR diff --git a/src/file/SDL_rwops.c b/src/file/SDL_rwops.c index 44b0e8407..59e83c89a 100644 --- a/src/file/SDL_rwops.c +++ b/src/file/SDL_rwops.c @@ -47,7 +47,7 @@ #define INVALID_SET_FILE_POINTER 0xFFFFFFFF #endif -#define READAHEAD_BUFFER_SIZE 1024 +#define READAHEAD_BUFFER_SIZE 1024 static int SDLCALL windows_file_open(SDL_RWops * context, const char *filename, const char *mode) @@ -518,12 +518,12 @@ SDL_RWFromFile(const char *file, const char *mode) #elif HAVE_STDIO_H { - #ifdef __APPLE__ - FILE *fp = SDL_OpenFPFromBundleOrFallback(file, mode); + #ifdef __APPLE__ + FILE *fp = SDL_OpenFPFromBundleOrFallback(file, mode); #else - FILE *fp = fopen(file, mode); - #endif - if (fp == NULL) { + FILE *fp = fopen(file, mode); + #endif + if (fp == NULL) { SDL_SetError("Couldn't open %s", file); } else { rwops = SDL_RWFromFP(fp, 1); diff --git a/src/file/cocoa/SDL_rwopsbundlesupport.m b/src/file/cocoa/SDL_rwopsbundlesupport.m index 39b4c0e9c..8ec0220ec 100644 --- a/src/file/cocoa/SDL_rwopsbundlesupport.m +++ b/src/file/cocoa/SDL_rwopsbundlesupport.m @@ -14,32 +14,32 @@ { FILE* fp = NULL; - // If the file mode is writable, skip all the bundle stuff because generally the bundle is read-only. - if(strcmp("r", mode) && strcmp("rb", mode)) - { - return fopen(file, mode); - } + /* If the file mode is writable, skip all the bundle stuff because generally the bundle is read-only. */ + if(strcmp("r", mode) && strcmp("rb", mode)) + { + return fopen(file, mode); + } - NSAutoreleasePool* autorelease_pool = [[NSAutoreleasePool alloc] init]; + NSAutoreleasePool* autorelease_pool = [[NSAutoreleasePool alloc] init]; - NSFileManager* file_manager = [NSFileManager defaultManager]; - NSString* resource_path = [[NSBundle mainBundle] resourcePath]; + NSFileManager* file_manager = [NSFileManager defaultManager]; + NSString* resource_path = [[NSBundle mainBundle] resourcePath]; - NSString* ns_string_file_component = [file_manager stringWithFileSystemRepresentation:file length:strlen(file)]; + NSString* ns_string_file_component = [file_manager stringWithFileSystemRepresentation:file length:strlen(file)]; - NSString* full_path_with_file_to_try = [resource_path stringByAppendingPathComponent:ns_string_file_component]; - if([file_manager fileExistsAtPath:full_path_with_file_to_try]) - { - fp = fopen([full_path_with_file_to_try fileSystemRepresentation], mode); - } - else - { - fp = fopen(file, mode); - } + NSString* full_path_with_file_to_try = [resource_path stringByAppendingPathComponent:ns_string_file_component]; + if([file_manager fileExistsAtPath:full_path_with_file_to_try]) + { + fp = fopen([full_path_with_file_to_try fileSystemRepresentation], mode); + } + else + { + fp = fopen(file, mode); + } - [autorelease_pool drain]; + [autorelease_pool drain]; - return fp; + return fp; } #endif diff --git a/src/haptic/SDL_syshaptic.h b/src/haptic/SDL_syshaptic.h index affd5731f..28ef84399 100644 --- a/src/haptic/SDL_syshaptic.h +++ b/src/haptic/SDL_syshaptic.h @@ -56,7 +56,7 @@ struct _SDL_Haptic SDL_HapticEffect rumble_effect; /* Rumble effect. */ }; -/* +/* * Scans the system for haptic devices. * * Returns 0 on success, -1 on error. diff --git a/src/haptic/darwin/SDL_syshaptic.c b/src/haptic/darwin/SDL_syshaptic.c index a8b1d586f..53c5acddd 100644 --- a/src/haptic/darwin/SDL_syshaptic.c +++ b/src/haptic/darwin/SDL_syshaptic.c @@ -35,7 +35,7 @@ #include #ifndef IO_OBJECT_NULL -#define IO_OBJECT_NULL ((io_service_t)0) +#define IO_OBJECT_NULL ((io_service_t)0) #endif #define MAX_HAPTICS 32 @@ -83,7 +83,7 @@ static void SDL_SYS_HapticFreeFFEFFECT(FFEFFECT * effect, int type); static int HIDGetDeviceProduct(io_service_t dev, char *name); -/* +/* * Like strerror but for force feedback errors. */ static const char * @@ -562,7 +562,7 @@ SDL_SYS_HapticClose(SDL_Haptic * haptic) } -/* +/* * Clean up after system specific haptic stuff */ void diff --git a/src/haptic/linux/SDL_syshaptic.c b/src/haptic/linux/SDL_syshaptic.c index 23a373520..92705320a 100644 --- a/src/haptic/linux/SDL_syshaptic.c +++ b/src/haptic/linux/SDL_syshaptic.c @@ -155,7 +155,7 @@ SDL_SYS_HapticInit(void) numhaptics = 0; - /* + /* * Limit amount of checks to MAX_HAPTICS since we may or may not have * permission to some or all devices. */ @@ -446,7 +446,7 @@ SDL_SYS_HapticClose(SDL_Haptic * haptic) } -/* +/* * Clean up after system specific haptic stuff */ void @@ -498,44 +498,44 @@ SDL_SYS_ToDirection(SDL_HapticDirection * dir) switch (dir->type) { case SDL_HAPTIC_POLAR: /* Linux directions start from south. - (and range from 0 to 0xFFFF) - Quoting include/linux/input.h, line 926: - Direction of the effect is encoded as follows: - 0 deg -> 0x0000 (down) - 90 deg -> 0x4000 (left) - 180 deg -> 0x8000 (up) - 270 deg -> 0xC000 (right) - */ - tmp = (((18000 + dir->dir[0]) % 36000) * 0xFFFF) / 36000; // convert to range [0,0xFFFF] + (and range from 0 to 0xFFFF) + Quoting include/linux/input.h, line 926: + Direction of the effect is encoded as follows: + 0 deg -> 0x0000 (down) + 90 deg -> 0x4000 (left) + 180 deg -> 0x8000 (up) + 270 deg -> 0xC000 (right) + */ + tmp = (((18000 + dir->dir[0]) % 36000) * 0xFFFF) / 36000; /* convert to range [0,0xFFFF] */ return (Uint16) tmp; - case SDL_HAPTIC_SPHERICAL: - /* - We convert to polar, because that's the only supported direction on Linux. - The first value of a spherical direction is practically the same as a - Polar direction, except that we have to add 90 degrees. It is the angle - from EAST {1,0} towards SOUTH {0,1}. - --> add 9000 - --> finally add 18000 and convert to [0,0xFFFF] as in case SDL_HAPTIC_POLAR. - */ - tmp = ((dir->dir[0]) + 9000) % 36000; /* Convert to polars */ - tmp = (((18000 + tmp) % 36000) * 0xFFFF) / 36000; // convert to range [0,0xFFFF] + case SDL_HAPTIC_SPHERICAL: + /* + We convert to polar, because that's the only supported direction on Linux. + The first value of a spherical direction is practically the same as a + Polar direction, except that we have to add 90 degrees. It is the angle + from EAST {1,0} towards SOUTH {0,1}. + --> add 9000 + --> finally add 18000 and convert to [0,0xFFFF] as in case SDL_HAPTIC_POLAR. + */ + tmp = ((dir->dir[0]) + 9000) % 36000; /* Convert to polars */ + tmp = (((18000 + tmp) % 36000) * 0xFFFF) / 36000; /* convert to range [0,0xFFFF] */ return (Uint16) tmp; case SDL_HAPTIC_CARTESIAN: f = atan2(dir->dir[1], dir->dir[0]); - /* - atan2 takes the parameters: Y-axis-value and X-axis-value (in that order) - - Y-axis-value is the second coordinate (from center to SOUTH) - - X-axis-value is the first coordinate (from center to EAST) - We add 36000, because atan2 also returns negative values. Then we practically - have the first spherical value. Therefore we proceed as in case - SDL_HAPTIC_SPHERICAL and add another 9000 to get the polar value. - --> add 45000 in total - --> finally add 18000 and convert to [0,0xFFFF] as in case SDL_HAPTIC_POLAR. - */ - tmp = (((int) (f * 18000. / M_PI)) + 45000) % 36000; - tmp = (((18000 + tmp) % 36000) * 0xFFFF) / 36000; // convert to range [0,0xFFFF] + /* + atan2 takes the parameters: Y-axis-value and X-axis-value (in that order) + - Y-axis-value is the second coordinate (from center to SOUTH) + - X-axis-value is the first coordinate (from center to EAST) + We add 36000, because atan2 also returns negative values. Then we practically + have the first spherical value. Therefore we proceed as in case + SDL_HAPTIC_SPHERICAL and add another 9000 to get the polar value. + --> add 45000 in total + --> finally add 18000 and convert to [0,0xFFFF] as in case SDL_HAPTIC_POLAR. + */ + tmp = (((int) (f * 18000. / M_PI)) + 45000) % 36000; + tmp = (((18000 + tmp) % 36000) * 0xFFFF) / 36000; /* convert to range [0,0xFFFF] */ return (Uint16) tmp; default: diff --git a/src/haptic/windows/SDL_syshaptic.c b/src/haptic/windows/SDL_syshaptic.c index a41c68ea2..b567ed7d7 100644 --- a/src/haptic/windows/SDL_syshaptic.c +++ b/src/haptic/windows/SDL_syshaptic.c @@ -41,8 +41,8 @@ static struct char *name; SDL_Haptic *haptic; DIDEVCAPS capabilities; - Uint8 bXInputHaptic; // Supports force feedback via XInput. - Uint8 userid; // XInput userid index for this joystick + Uint8 bXInputHaptic; /* Supports force feedback via XInput. */ + Uint8 userid; /* XInput userid index for this joystick */ } SDL_hapticlist[MAX_HAPTICS]; @@ -54,8 +54,8 @@ struct haptic_hwdata LPDIRECTINPUTDEVICE8 device; DWORD axes[3]; /* Axes to use. */ int is_joystick; /* Device is loaded as joystick. */ - Uint8 bXInputHaptic; // Supports force feedback via XInput. - Uint8 userid; // XInput userid index for this joystick + Uint8 bXInputHaptic; /* Supports force feedback via XInput. */ + Uint8 userid; /* XInput userid index for this joystick */ }; @@ -107,7 +107,7 @@ static BOOL CALLBACK EnumHapticsCallback(const DIDEVICEINSTANCE * static BOOL CALLBACK DI_EffectCallback(LPCDIEFFECTINFO pei, LPVOID pv); -/* +/* * Like SDL_SetError but for DX error codes. */ static int @@ -732,7 +732,7 @@ SDL_SYS_HapticClose(SDL_Haptic * haptic) } -/* +/* * Clean up after system specific haptic stuff */ void @@ -1264,12 +1264,13 @@ SDL_SYS_HapticUpdateEffect(SDL_Haptic * haptic, DIEFFECT temp; if (haptic->hwdata->bXInputHaptic) { - // !!! FIXME: this isn't close to right. We only support "sine" effects, - // !!! FIXME: we ignore most of the parameters, and we probably get - // !!! FIXME: the ones we don't ignore wrong, too. - // !!! FIXME: if I had a better understanding of how the two motors - // !!! FIXME: could be used in unison, perhaps I could implement other - // !!! FIXME: effect types? + /* !!! FIXME: this isn't close to right. We only support "sine" effects, + * !!! FIXME: we ignore most of the parameters, and we probably get + * !!! FIXME: the ones we don't ignore wrong, too. + * !!! FIXME: if I had a better understanding of how the two motors + * !!! FIXME: could be used in unison, perhaps I could implement other + * !!! FIXME: effect types? + */ /* From MSDN: "Note that the right motor is the high-frequency motor, the left motor is the low-frequency motor. They do not always need to be @@ -1528,5 +1529,6 @@ SDL_SYS_HapticStopAll(SDL_Haptic * haptic) return 0; } - #endif /* SDL_HAPTIC_DINPUT */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/joystick/SDL_gamecontroller.c b/src/joystick/SDL_gamecontroller.c index fda506af7..b8718a190 100644 --- a/src/joystick/SDL_gamecontroller.c +++ b/src/joystick/SDL_gamecontroller.c @@ -39,8 +39,8 @@ static SDL_GameController *SDL_gamecontrollers = NULL; /* keep track of the hat and mask value that transforms this hat movement into a button/axis press */ struct _SDL_HatMapping { - int hat; - Uint8 mask; + int hat; + Uint8 mask; }; #define k_nMaxReverseEntries 20 @@ -54,24 +54,24 @@ struct _SDL_HatMapping /* our in memory mapping db between joystick objects and controller mappings*/ struct _SDL_ControllerMapping { - SDL_JoystickGUID guid; - const char *name; + SDL_JoystickGUID guid; + const char *name; - // mapping of axis/button id to controller version - int axes[SDL_CONTROLLER_AXIS_MAX]; - int buttonasaxis[SDL_CONTROLLER_AXIS_MAX]; + /* mapping of axis/button id to controller version */ + int axes[SDL_CONTROLLER_AXIS_MAX]; + int buttonasaxis[SDL_CONTROLLER_AXIS_MAX]; - int buttons[SDL_CONTROLLER_BUTTON_MAX]; - int axesasbutton[SDL_CONTROLLER_BUTTON_MAX]; - struct _SDL_HatMapping hatasbutton[SDL_CONTROLLER_BUTTON_MAX]; + int buttons[SDL_CONTROLLER_BUTTON_MAX]; + int axesasbutton[SDL_CONTROLLER_BUTTON_MAX]; + struct _SDL_HatMapping hatasbutton[SDL_CONTROLLER_BUTTON_MAX]; - // reverse mapping, joystick indices to buttons - SDL_GameControllerAxis raxes[k_nMaxReverseEntries]; - SDL_GameControllerAxis rbuttonasaxis[k_nMaxReverseEntries]; + /* reverse mapping, joystick indices to buttons */ + SDL_GameControllerAxis raxes[k_nMaxReverseEntries]; + SDL_GameControllerAxis rbuttonasaxis[k_nMaxReverseEntries]; - SDL_GameControllerButton rbuttons[k_nMaxReverseEntries]; - SDL_GameControllerButton raxesasbutton[k_nMaxReverseEntries]; - SDL_GameControllerButton rhatasbutton[k_nMaxHatEntries]; + SDL_GameControllerButton rbuttons[k_nMaxReverseEntries]; + SDL_GameControllerButton raxesasbutton[k_nMaxReverseEntries]; + SDL_GameControllerButton rhatasbutton[k_nMaxHatEntries]; }; @@ -79,10 +79,10 @@ struct _SDL_ControllerMapping /* our hard coded list of mapping support */ typedef struct _ControllerMapping_t { - SDL_JoystickGUID guid; - char *name; - char *mapping; - struct _ControllerMapping_t *next; + SDL_JoystickGUID guid; + char *name; + char *mapping; + struct _ControllerMapping_t *next; } ControllerMapping_t; @@ -90,33 +90,33 @@ typedef struct _ControllerMapping_t const char *s_ControllerMappings [] = { #ifdef SDL_JOYSTICK_DINPUT - "xinput,X360 Controller,a:b10,b:b11,y:b13,x:b12,start:b4,guide:b14,back:b5,dpup:b0,dpleft:b2,dpdown:b1,dpright:b3,leftshoulder:b8,rightshoulder:b9,leftstick:b6,rightstick:b7,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5", - "341a3608000000000000504944564944,Afterglow PS3 Controller,a:b1,b:b2,y:b3,x:b0,start:b9,guide:b12,back:b8,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftshoulder:b4,rightshoulder:b5,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7", - "88880803000000000000504944564944,PS3 Controller,a:b2,b:b1,x:b0,y:b3,start:b11,back:b8,leftstick:b9,rightstick:b10,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.4,dpdown:h0.8,dpright:h0.2,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:b6,righttrigger:b7,guide:b12", - "4c056802000000000000504944564944,PS3 Controller,a:b14,b:b13,y:b12,x:b15,start:b3,guide:b16,back:b0,leftstick:b1,rightstick:b2,leftshoulder:b10,rightshoulder:b11,dpup:b4,dpleft:b7,dpdown:b6,dpright:b5,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b8,righttrigger:b9,", - "25090500000000000000504944564944,PS3 DualShock,a:b2,b:b1,x:b0,y:b3,start:b8,guide:,back:b9,leftstick:b10,rightstick:b11,leftshoulder:b6,rightshoulder:b7,dpup:h0.1,dpleft:h0.4,dpdown:h0.8,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b4,righttrigger:b5", + "xinput,X360 Controller,a:b10,b:b11,y:b13,x:b12,start:b4,guide:b14,back:b5,dpup:b0,dpleft:b2,dpdown:b1,dpright:b3,leftshoulder:b8,rightshoulder:b9,leftstick:b6,rightstick:b7,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5", + "341a3608000000000000504944564944,Afterglow PS3 Controller,a:b1,b:b2,y:b3,x:b0,start:b9,guide:b12,back:b8,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftshoulder:b4,rightshoulder:b5,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7", + "88880803000000000000504944564944,PS3 Controller,a:b2,b:b1,x:b0,y:b3,start:b11,back:b8,leftstick:b9,rightstick:b10,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.4,dpdown:h0.8,dpright:h0.2,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:b6,righttrigger:b7,guide:b12", + "4c056802000000000000504944564944,PS3 Controller,a:b14,b:b13,y:b12,x:b15,start:b3,guide:b16,back:b0,leftstick:b1,rightstick:b2,leftshoulder:b10,rightshoulder:b11,dpup:b4,dpleft:b7,dpdown:b6,dpright:b5,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b8,righttrigger:b9,", + "25090500000000000000504944564944,PS3 DualShock,a:b2,b:b1,x:b0,y:b3,start:b8,guide:,back:b9,leftstick:b10,rightstick:b11,leftshoulder:b6,rightshoulder:b7,dpup:h0.1,dpleft:h0.4,dpdown:h0.8,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b4,righttrigger:b5", "ffff0000000000000000504944564944,GameStop Gamepad,a:b0,b:b1,y:b3,x:b2,start:b9,guide:,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,", "6d0416c2000000000000504944564944,Generic DirectInput Controller,a:b1,b:b2,y:b3,x:b0,start:b9,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,", #elif defined(__MACOSX__) - "5e040000000000008e02000000000000,X360 Controller,a:b0,b:b1,y:b3,x:b2,start:b8,guide:b10,back:b9,dpup:b11,dpleft:b13,dpdown:b12,dpright:b14,leftshoulder:b4,rightshoulder:b5,leftstick:b6,rightstick:b7,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:a2,righttrigger:a5", - "4c050000000000006802000000000000,PS3 Controller,a:b14,b:b13,x:b12,y:b15,start:b3,guide:b16,back:b0,leftstick:b1,rightstick:b2,leftshoulder:b10,rightshoulder:b11,dpup:b4,dpleft:b6,dpdown:b7,dpright:b5,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b8,righttrigger:b9", + "5e040000000000008e02000000000000,X360 Controller,a:b0,b:b1,y:b3,x:b2,start:b8,guide:b10,back:b9,dpup:b11,dpleft:b13,dpdown:b12,dpright:b14,leftshoulder:b4,rightshoulder:b5,leftstick:b6,rightstick:b7,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:a2,righttrigger:a5", + "4c050000000000006802000000000000,PS3 Controller,a:b14,b:b13,x:b12,y:b15,start:b3,guide:b16,back:b0,leftstick:b1,rightstick:b2,leftshoulder:b10,rightshoulder:b11,dpup:b4,dpleft:b6,dpdown:b7,dpright:b5,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b8,righttrigger:b9", "0500000047532047616d657061640000,GameStop Gamepad,a:b0,b:b1,y:b3,x:b2,start:b9,guide:,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,", "6d040000000000001fc2000000000000,Logitech F710 Gamepad Controller (XInput),a:b0,b:b1,y:b3,x:b2,start:b8,guide:b10,back:b9,leftstick:b6,rightstick:b7,leftshoulder:b4,rightshoulder:b5,dpup:b11,dpleft:b13,dpdown:b12,dpright:b14,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:a2,righttrigger:a5,", - "6d0400000000000016c2000000000000,Logitech F310 Gamepad Controller (DInput),a:b1,b:b2,y:b3,x:b0,start:b9,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,", // Guide button doesn't seem to be sent in DInput mode. - "6d0400000000000019c2000000000000,Logitech Wireless Gamepad Controller (DInput),a:b1,b:b2,y:b3,x:b0,start:b9,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,", // This includes F710 in DInput mode and the "Logitech Cordless RumblePad 2", at the very least. + "6d0400000000000016c2000000000000,Logitech F310 Gamepad Controller (DInput),a:b1,b:b2,y:b3,x:b0,start:b9,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,", /* Guide button doesn't seem to be sent in DInput mode. */ + "6d0400000000000019c2000000000000,Logitech Wireless Gamepad Controller (DInput),a:b1,b:b2,y:b3,x:b0,start:b9,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,", /* This includes F710 in DInput mode and the "Logitech Cordless RumblePad 2", at the very least. */ #elif defined(__LINUX__) - "030000005e0400008e02000014010000,X360 Controller,a:b0,b:b1,y:b3,x:b2,start:b7,guide:b8,back:b6,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftshoulder:b4,rightshoulder:b5,leftstick:b9,rightstick:b10,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:a2,righttrigger:a5", + "030000005e0400008e02000014010000,X360 Controller,a:b0,b:b1,y:b3,x:b2,start:b7,guide:b8,back:b6,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftshoulder:b4,rightshoulder:b5,leftstick:b9,rightstick:b10,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:a2,righttrigger:a5", "030000005e0400008e02000010010000,X360 Controller,a:b0,b:b1,y:b3,x:b2,start:b7,guide:b8,back:b6,leftstick:b9,rightstick:b10,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:a2,righttrigger:a5,", "030000005e0400001907000000010000,X360 Wireless Controller,a:b0,b:b1,y:b3,x:b2,start:b7,guide:b8,back:b6,leftstick:b9,rightstick:b10,leftshoulder:b4,rightshoulder:b5,dpup:b13,dpleft:b11,dpdown:b14,dpright:b12,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:a2,righttrigger:a5,", - "030000004c0500006802000011010000,PS3 Controller,a:b14,b:b13,x:b15,y:b12,start:b3,guide:b16,back:b0,leftstick:b1,rightstick:b2,leftshoulder:b10,rightshoulder:b11,dpup:b4,dpleft:b7,dpdown:b6,dpright:b5,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b8,righttrigger:b9", + "030000004c0500006802000011010000,PS3 Controller,a:b14,b:b13,x:b15,y:b12,start:b3,guide:b16,back:b0,leftstick:b1,rightstick:b2,leftshoulder:b10,rightshoulder:b11,dpup:b4,dpleft:b7,dpdown:b6,dpright:b5,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b8,righttrigger:b9", "030000006d0400001fc2000005030000,Logitech F710 Gamepad Controller (XInput),a:b0,b:b1,y:b3,x:b2,start:b7,guide:b8,back:b6,leftstick:b9,rightstick:b10,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:a2,righttrigger:a5,", - "030000006d04000019c2000011010000,Logitech F710 Gamepad Controller (DInput),a:b1,b:b2,y:b3,x:b0,start:b9,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,", // Guide button doesn't seem to be sent in DInput mode. + "030000006d04000019c2000011010000,Logitech F710 Gamepad Controller (DInput),a:b1,b:b2,y:b3,x:b0,start:b9,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,", /* Guide button doesn't seem to be sent in DInput mode. */ "030000006d0400001dc2000014400000,Logitech F310 Gamepad (XInput),a:b0,b:b1,y:b3,x:b2,start:b7,guide:b8,back:b6,leftstick:b9,rightstick:b10,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:a2,righttrigger:a5,", "030000006d04000019c2000010010000,Logitech Cordless RumblePad 2,a:b1,b:b2,y:b3,x:b0,start:b9,guide:,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,", "0500000047532047616d657061640000,GameStop Gamepad,a:b0,b:b1,y:b3,x:b2,start:b9,guide:,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,", "03000000ba2200002010000001010000,Jess Technology USB Game Controller,start:b9,a:b2,b:b1,x:b3,y:b0,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a3,righty:a2,lefttrigger:b6,righttrigger:b7,leftshoulder:b4,rightshoulder:b5,guide:,back:b8", #endif - NULL + NULL }; static ControllerMapping_t *s_pSupportedControllers = NULL; @@ -127,166 +127,166 @@ static ControllerMapping_t *s_pXInputMapping = NULL; /* The SDL game controller structure */ struct _SDL_GameController { - SDL_Joystick *joystick; /* underlying joystick device */ - int ref_count; - Uint8 hatState[4]; /* the current hat state for this controller */ - struct _SDL_ControllerMapping mapping; /* the mapping object for this controller */ - struct _SDL_GameController *next; /* pointer to next game controller we have allocated */ + SDL_Joystick *joystick; /* underlying joystick device */ + int ref_count; + Uint8 hatState[4]; /* the current hat state for this controller */ + struct _SDL_ControllerMapping mapping; /* the mapping object for this controller */ + struct _SDL_GameController *next; /* pointer to next game controller we have allocated */ }; int SDL_PrivateGameControllerAxis(SDL_GameController * gamecontroller, SDL_GameControllerAxis axis, Sint16 value); -int SDL_PrivateGameControllerButton(SDL_GameController * gamecontroller, SDL_GameControllerButton button, Uint8 state); +int SDL_PrivateGameControllerButton(SDL_GameController * gamecontroller, SDL_GameControllerButton button, Uint8 state); /* * Event filter to fire controller events from joystick ones */ int SDL_GameControllerEventWatcher(void *userdata, SDL_Event * event) { - switch( event->type ) - { - case SDL_JOYAXISMOTION: - { - SDL_GameController *controllerlist; - - if ( event->jaxis.axis >= k_nMaxReverseEntries ) break; - - controllerlist = SDL_gamecontrollers; - while ( controllerlist ) - { - if ( controllerlist->joystick->instance_id == event->jaxis.which ) - { - if ( controllerlist->mapping.raxes[event->jaxis.axis] >= 0 ) // simple axis to axis, send it through - { - SDL_GameControllerAxis axis = controllerlist->mapping.raxes[event->jaxis.axis]; + switch( event->type ) + { + case SDL_JOYAXISMOTION: + { + SDL_GameController *controllerlist; + + if ( event->jaxis.axis >= k_nMaxReverseEntries ) break; + + controllerlist = SDL_gamecontrollers; + while ( controllerlist ) + { + if ( controllerlist->joystick->instance_id == event->jaxis.which ) + { + if ( controllerlist->mapping.raxes[event->jaxis.axis] >= 0 ) /* simple axis to axis, send it through */ + { + SDL_GameControllerAxis axis = controllerlist->mapping.raxes[event->jaxis.axis]; Sint16 value = event->jaxis.value; - switch (axis) - { - case SDL_CONTROLLER_AXIS_TRIGGERLEFT: - case SDL_CONTROLLER_AXIS_TRIGGERRIGHT: - /* Shift it to be 0 - 32767. */ - value = value / 2 + 16384; - default: - break; - } - SDL_PrivateGameControllerAxis( controllerlist, axis, value ); - } - else if ( controllerlist->mapping.raxesasbutton[event->jaxis.axis] >= 0 ) // simulate an axis as a button - { - SDL_PrivateGameControllerButton( controllerlist, controllerlist->mapping.raxesasbutton[event->jaxis.axis], ABS(event->jaxis.value) > 32768/2 ? SDL_PRESSED : SDL_RELEASED ); - } - break; - } - controllerlist = controllerlist->next; - } - } - break; - case SDL_JOYBUTTONDOWN: - case SDL_JOYBUTTONUP: - { - SDL_GameController *controllerlist; - - if ( event->jbutton.button >= k_nMaxReverseEntries ) break; - - controllerlist = SDL_gamecontrollers; - while ( controllerlist ) - { - if ( controllerlist->joystick->instance_id == event->jbutton.which ) - { - if ( controllerlist->mapping.rbuttons[event->jbutton.button] >= 0 ) // simple button as button - { - SDL_PrivateGameControllerButton( controllerlist, controllerlist->mapping.rbuttons[event->jbutton.button], event->jbutton.state ); - } - else if ( controllerlist->mapping.rbuttonasaxis[event->jbutton.button] >= 0 ) // an button pretending to be an axis - { - SDL_PrivateGameControllerAxis( controllerlist, controllerlist->mapping.rbuttonasaxis[event->jbutton.button], event->jbutton.state > 0 ? 32767 : 0 ); - } - break; - } - controllerlist = controllerlist->next; - } - } - break; - case SDL_JOYHATMOTION: - { - SDL_GameController *controllerlist; - - if ( event->jhat.hat >= 4 ) break; - - controllerlist = SDL_gamecontrollers; - while ( controllerlist ) - { - if ( controllerlist->joystick->instance_id == event->jhat.which ) - { - Uint8 bSame = controllerlist->hatState[event->jhat.hat] & event->jhat.value; - // Get list of removed bits (button release) - Uint8 bChanged = controllerlist->hatState[event->jhat.hat] ^ bSame; - // the hat idx in the high nibble - int bHighHat = event->jhat.hat << 4; - - if ( bChanged & SDL_HAT_DOWN ) - SDL_PrivateGameControllerButton( controllerlist, controllerlist->mapping.rhatasbutton[bHighHat | SDL_HAT_DOWN], SDL_RELEASED ); - if ( bChanged & SDL_HAT_UP ) - SDL_PrivateGameControllerButton( controllerlist, controllerlist->mapping.rhatasbutton[bHighHat | SDL_HAT_UP], SDL_RELEASED ); - if ( bChanged & SDL_HAT_LEFT ) - SDL_PrivateGameControllerButton( controllerlist, controllerlist->mapping.rhatasbutton[bHighHat | SDL_HAT_LEFT], SDL_RELEASED ); - if ( bChanged & SDL_HAT_RIGHT ) - SDL_PrivateGameControllerButton( controllerlist, controllerlist->mapping.rhatasbutton[bHighHat | SDL_HAT_RIGHT], SDL_RELEASED ); - - // Get list of added bits (button press) - bChanged = event->jhat.value ^ bSame; - - if ( bChanged & SDL_HAT_DOWN ) - SDL_PrivateGameControllerButton( controllerlist, controllerlist->mapping.rhatasbutton[bHighHat | SDL_HAT_DOWN], SDL_PRESSED ); - if ( bChanged & SDL_HAT_UP ) - SDL_PrivateGameControllerButton( controllerlist, controllerlist->mapping.rhatasbutton[bHighHat | SDL_HAT_UP], SDL_PRESSED ); - if ( bChanged & SDL_HAT_LEFT ) - SDL_PrivateGameControllerButton( controllerlist, controllerlist->mapping.rhatasbutton[bHighHat | SDL_HAT_LEFT], SDL_PRESSED ); - if ( bChanged & SDL_HAT_RIGHT ) - SDL_PrivateGameControllerButton( controllerlist, controllerlist->mapping.rhatasbutton[bHighHat | SDL_HAT_RIGHT], SDL_PRESSED ); - - // update our state cache - controllerlist->hatState[event->jhat.hat] = event->jhat.value; - - break; - } - controllerlist = controllerlist->next; - } - } - break; - case SDL_JOYDEVICEADDED: - { - if ( SDL_IsGameController(event->jdevice.which ) ) - { - SDL_Event deviceevent; - deviceevent.type = SDL_CONTROLLERDEVICEADDED; - deviceevent.cdevice.which = event->jdevice.which; - SDL_PushEvent(&deviceevent); - } - } - break; - case SDL_JOYDEVICEREMOVED: - { - SDL_GameController *controllerlist = SDL_gamecontrollers; - while ( controllerlist ) - { - if ( controllerlist->joystick->instance_id == event->jdevice.which ) - { - SDL_Event deviceevent; - deviceevent.type = SDL_CONTROLLERDEVICEREMOVED; - deviceevent.cdevice.which = event->jdevice.which; - SDL_PushEvent(&deviceevent); - break; - } - controllerlist = controllerlist->next; - } - } - break; - default: - break; - } - - return 1; + switch (axis) + { + case SDL_CONTROLLER_AXIS_TRIGGERLEFT: + case SDL_CONTROLLER_AXIS_TRIGGERRIGHT: + /* Shift it to be 0 - 32767. */ + value = value / 2 + 16384; + default: + break; + } + SDL_PrivateGameControllerAxis( controllerlist, axis, value ); + } + else if ( controllerlist->mapping.raxesasbutton[event->jaxis.axis] >= 0 ) /* simulate an axis as a button */ + { + SDL_PrivateGameControllerButton( controllerlist, controllerlist->mapping.raxesasbutton[event->jaxis.axis], ABS(event->jaxis.value) > 32768/2 ? SDL_PRESSED : SDL_RELEASED ); + } + break; + } + controllerlist = controllerlist->next; + } + } + break; + case SDL_JOYBUTTONDOWN: + case SDL_JOYBUTTONUP: + { + SDL_GameController *controllerlist; + + if ( event->jbutton.button >= k_nMaxReverseEntries ) break; + + controllerlist = SDL_gamecontrollers; + while ( controllerlist ) + { + if ( controllerlist->joystick->instance_id == event->jbutton.which ) + { + if ( controllerlist->mapping.rbuttons[event->jbutton.button] >= 0 ) /* simple button as button */ + { + SDL_PrivateGameControllerButton( controllerlist, controllerlist->mapping.rbuttons[event->jbutton.button], event->jbutton.state ); + } + else if ( controllerlist->mapping.rbuttonasaxis[event->jbutton.button] >= 0 ) /* an button pretending to be an axis */ + { + SDL_PrivateGameControllerAxis( controllerlist, controllerlist->mapping.rbuttonasaxis[event->jbutton.button], event->jbutton.state > 0 ? 32767 : 0 ); + } + break; + } + controllerlist = controllerlist->next; + } + } + break; + case SDL_JOYHATMOTION: + { + SDL_GameController *controllerlist; + + if ( event->jhat.hat >= 4 ) break; + + controllerlist = SDL_gamecontrollers; + while ( controllerlist ) + { + if ( controllerlist->joystick->instance_id == event->jhat.which ) + { + Uint8 bSame = controllerlist->hatState[event->jhat.hat] & event->jhat.value; + /* Get list of removed bits (button release) */ + Uint8 bChanged = controllerlist->hatState[event->jhat.hat] ^ bSame; + /* the hat idx in the high nibble */ + int bHighHat = event->jhat.hat << 4; + + if ( bChanged & SDL_HAT_DOWN ) + SDL_PrivateGameControllerButton( controllerlist, controllerlist->mapping.rhatasbutton[bHighHat | SDL_HAT_DOWN], SDL_RELEASED ); + if ( bChanged & SDL_HAT_UP ) + SDL_PrivateGameControllerButton( controllerlist, controllerlist->mapping.rhatasbutton[bHighHat | SDL_HAT_UP], SDL_RELEASED ); + if ( bChanged & SDL_HAT_LEFT ) + SDL_PrivateGameControllerButton( controllerlist, controllerlist->mapping.rhatasbutton[bHighHat | SDL_HAT_LEFT], SDL_RELEASED ); + if ( bChanged & SDL_HAT_RIGHT ) + SDL_PrivateGameControllerButton( controllerlist, controllerlist->mapping.rhatasbutton[bHighHat | SDL_HAT_RIGHT], SDL_RELEASED ); + + /* Get list of added bits (button press) */ + bChanged = event->jhat.value ^ bSame; + + if ( bChanged & SDL_HAT_DOWN ) + SDL_PrivateGameControllerButton( controllerlist, controllerlist->mapping.rhatasbutton[bHighHat | SDL_HAT_DOWN], SDL_PRESSED ); + if ( bChanged & SDL_HAT_UP ) + SDL_PrivateGameControllerButton( controllerlist, controllerlist->mapping.rhatasbutton[bHighHat | SDL_HAT_UP], SDL_PRESSED ); + if ( bChanged & SDL_HAT_LEFT ) + SDL_PrivateGameControllerButton( controllerlist, controllerlist->mapping.rhatasbutton[bHighHat | SDL_HAT_LEFT], SDL_PRESSED ); + if ( bChanged & SDL_HAT_RIGHT ) + SDL_PrivateGameControllerButton( controllerlist, controllerlist->mapping.rhatasbutton[bHighHat | SDL_HAT_RIGHT], SDL_PRESSED ); + + /* update our state cache */ + controllerlist->hatState[event->jhat.hat] = event->jhat.value; + + break; + } + controllerlist = controllerlist->next; + } + } + break; + case SDL_JOYDEVICEADDED: + { + if ( SDL_IsGameController(event->jdevice.which ) ) + { + SDL_Event deviceevent; + deviceevent.type = SDL_CONTROLLERDEVICEADDED; + deviceevent.cdevice.which = event->jdevice.which; + SDL_PushEvent(&deviceevent); + } + } + break; + case SDL_JOYDEVICEREMOVED: + { + SDL_GameController *controllerlist = SDL_gamecontrollers; + while ( controllerlist ) + { + if ( controllerlist->joystick->instance_id == event->jdevice.which ) + { + SDL_Event deviceevent; + deviceevent.type = SDL_CONTROLLERDEVICEREMOVED; + deviceevent.cdevice.which = event->jdevice.which; + SDL_PushEvent(&deviceevent); + break; + } + controllerlist = controllerlist->next; + } + } + break; + default: + break; + } + + return 1; } /* @@ -294,15 +294,15 @@ int SDL_GameControllerEventWatcher(void *userdata, SDL_Event * event) */ ControllerMapping_t *SDL_PrivateGetControllerMappingForGUID(SDL_JoystickGUID *guid) { - ControllerMapping_t *pSupportedController = s_pSupportedControllers; - while ( pSupportedController ) - { - if ( !SDL_memcmp( guid, &pSupportedController->guid, sizeof(*guid) ) ) - { - return pSupportedController; - } - pSupportedController = pSupportedController->next; - } + ControllerMapping_t *pSupportedController = s_pSupportedControllers; + while ( pSupportedController ) + { + if ( !SDL_memcmp( guid, &pSupportedController->guid, sizeof(*guid) ) ) + { + return pSupportedController; + } + pSupportedController = pSupportedController->next; + } return NULL; } @@ -312,18 +312,18 @@ ControllerMapping_t *SDL_PrivateGetControllerMappingForGUID(SDL_JoystickGUID *gu ControllerMapping_t *SDL_PrivateGetControllerMapping(int device_index) { #ifdef SDL_JOYSTICK_DINPUT - if ( SDL_SYS_IsXInputDeviceIndex(device_index) && s_pXInputMapping ) - { - return s_pXInputMapping; - } - else + if ( SDL_SYS_IsXInputDeviceIndex(device_index) && s_pXInputMapping ) + { + return s_pXInputMapping; + } + else #endif - { - SDL_JoystickGUID jGUID = SDL_JoystickGetDeviceGUID( device_index ); - return SDL_PrivateGetControllerMappingForGUID(&jGUID); - } + { + SDL_JoystickGUID jGUID = SDL_JoystickGetDeviceGUID( device_index ); + return SDL_PrivateGetControllerMappingForGUID(&jGUID); + } - return NULL; + return NULL; } static const char* map_StringForControllerAxis[] = { @@ -342,8 +342,8 @@ static const char* map_StringForControllerAxis[] = { SDL_GameControllerAxis SDL_GameControllerGetAxisFromString( const char *pchString ) { int entry; - if ( !pchString || !pchString[0] ) - return SDL_CONTROLLER_AXIS_INVALID; + if ( !pchString || !pchString[0] ) + return SDL_CONTROLLER_AXIS_INVALID; for ( entry = 0; map_StringForControllerAxis[entry]; ++entry) { @@ -390,15 +390,15 @@ static const char* map_StringForControllerButton[] = { SDL_GameControllerButton SDL_GameControllerGetButtonFromString( const char *pchString ) { int entry; - if ( !pchString || !pchString[0] ) - return SDL_CONTROLLER_BUTTON_INVALID; + if ( !pchString || !pchString[0] ) + return SDL_CONTROLLER_BUTTON_INVALID; for ( entry = 0; map_StringForControllerButton[entry]; ++entry) - { - if ( !SDL_strcasecmp( pchString, map_StringForControllerButton[entry] ) ) - return entry; - } - return SDL_CONTROLLER_BUTTON_INVALID; + { + if ( !SDL_strcasecmp( pchString, map_StringForControllerButton[entry] ) ) + return entry; + } + return SDL_CONTROLLER_BUTTON_INVALID; } /* @@ -418,83 +418,83 @@ const char* SDL_GameControllerGetStringForButton( SDL_GameControllerButton axis */ void SDL_PrivateGameControllerParseButton( const char *szGameButton, const char *szJoystickButton, struct _SDL_ControllerMapping *pMapping ) { - int iSDLButton = 0; - SDL_GameControllerButton button; - SDL_GameControllerAxis axis; - button = SDL_GameControllerGetButtonFromString( szGameButton ); - axis = SDL_GameControllerGetAxisFromString( szGameButton ); - iSDLButton = SDL_atoi( &szJoystickButton[1] ); - - if ( szJoystickButton[0] == 'a' ) - { - if ( iSDLButton >= k_nMaxReverseEntries ) - { - SDL_SetError("Axis index too large: %d", iSDLButton ); - return; - } - if ( axis != SDL_CONTROLLER_AXIS_INVALID ) - { - pMapping->axes[ axis ] = iSDLButton; - pMapping->raxes[ iSDLButton ] = axis; - } - else if ( button != SDL_CONTROLLER_BUTTON_INVALID ) - { - pMapping->axesasbutton[ button ] = iSDLButton; - pMapping->raxesasbutton[ iSDLButton ] = button; - } - else - { - SDL_assert( !"How did we get here?" ); - } - - } - else if ( szJoystickButton[0] == 'b' ) - { - if ( iSDLButton >= k_nMaxReverseEntries ) - { - SDL_SetError("Button index too large: %d", iSDLButton ); - return; - } - if ( button != SDL_CONTROLLER_BUTTON_INVALID ) - { - pMapping->buttons[ button ] = iSDLButton; - pMapping->rbuttons[ iSDLButton ] = button; - } - else if ( axis != SDL_CONTROLLER_AXIS_INVALID ) - { - pMapping->buttonasaxis[ axis ] = iSDLButton; - pMapping->rbuttonasaxis[ iSDLButton ] = axis; - } - else - { - SDL_assert( !"How did we get here?" ); - } - } - else if ( szJoystickButton[0] == 'h' ) - { - int hat = SDL_atoi( &szJoystickButton[1] ); - int mask = SDL_atoi( &szJoystickButton[3] ); - if (hat >= 4) { - SDL_SetError("Hat index too large: %d", iSDLButton ); - } - - if ( button != SDL_CONTROLLER_BUTTON_INVALID ) - { + int iSDLButton = 0; + SDL_GameControllerButton button; + SDL_GameControllerAxis axis; + button = SDL_GameControllerGetButtonFromString( szGameButton ); + axis = SDL_GameControllerGetAxisFromString( szGameButton ); + iSDLButton = SDL_atoi( &szJoystickButton[1] ); + + if ( szJoystickButton[0] == 'a' ) + { + if ( iSDLButton >= k_nMaxReverseEntries ) + { + SDL_SetError("Axis index too large: %d", iSDLButton ); + return; + } + if ( axis != SDL_CONTROLLER_AXIS_INVALID ) + { + pMapping->axes[ axis ] = iSDLButton; + pMapping->raxes[ iSDLButton ] = axis; + } + else if ( button != SDL_CONTROLLER_BUTTON_INVALID ) + { + pMapping->axesasbutton[ button ] = iSDLButton; + pMapping->raxesasbutton[ iSDLButton ] = button; + } + else + { + SDL_assert( !"How did we get here?" ); + } + + } + else if ( szJoystickButton[0] == 'b' ) + { + if ( iSDLButton >= k_nMaxReverseEntries ) + { + SDL_SetError("Button index too large: %d", iSDLButton ); + return; + } + if ( button != SDL_CONTROLLER_BUTTON_INVALID ) + { + pMapping->buttons[ button ] = iSDLButton; + pMapping->rbuttons[ iSDLButton ] = button; + } + else if ( axis != SDL_CONTROLLER_AXIS_INVALID ) + { + pMapping->buttonasaxis[ axis ] = iSDLButton; + pMapping->rbuttonasaxis[ iSDLButton ] = axis; + } + else + { + SDL_assert( !"How did we get here?" ); + } + } + else if ( szJoystickButton[0] == 'h' ) + { + int hat = SDL_atoi( &szJoystickButton[1] ); + int mask = SDL_atoi( &szJoystickButton[3] ); + if (hat >= 4) { + SDL_SetError("Hat index too large: %d", iSDLButton ); + } + + if ( button != SDL_CONTROLLER_BUTTON_INVALID ) + { int ridx; - pMapping->hatasbutton[ button ].hat = hat; - pMapping->hatasbutton[ button ].mask = mask; - ridx = (hat << 4) | mask; - pMapping->rhatasbutton[ ridx ] = button; - } - else if ( axis != SDL_CONTROLLER_AXIS_INVALID ) - { - SDL_assert( !"Support hat as axis" ); - } - else - { - SDL_assert( !"How did we get here?" ); - } - } + pMapping->hatasbutton[ button ].hat = hat; + pMapping->hatasbutton[ button ].mask = mask; + ridx = (hat << 4) | mask; + pMapping->rhatasbutton[ ridx ] = button; + } + else if ( axis != SDL_CONTROLLER_AXIS_INVALID ) + { + SDL_assert( !"Support hat as axis" ); + } + else + { + SDL_assert( !"How did we get here?" ); + } + } } @@ -504,59 +504,59 @@ void SDL_PrivateGameControllerParseButton( const char *szGameButton, const char static void SDL_PrivateGameControllerParseControllerConfigString( struct _SDL_ControllerMapping *pMapping, const char *pchString ) { - char szGameButton[20]; - char szJoystickButton[20]; - SDL_bool bGameButton = SDL_TRUE; - int i = 0; - const char *pchPos = pchString; - - SDL_memset( szGameButton, 0x0, sizeof(szGameButton) ); - SDL_memset( szJoystickButton, 0x0, sizeof(szJoystickButton) ); - - while ( pchPos && *pchPos ) - { - if ( *pchPos == ':' ) - { - i = 0; - bGameButton = SDL_FALSE; - } - else if ( *pchPos == ' ' ) - { - - } - else if ( *pchPos == ',' ) - { - i = 0; - bGameButton = SDL_TRUE; - SDL_PrivateGameControllerParseButton( szGameButton, szJoystickButton, pMapping ); - SDL_memset( szGameButton, 0x0, sizeof(szGameButton) ); - SDL_memset( szJoystickButton, 0x0, sizeof(szJoystickButton) ); - - } - else if ( bGameButton ) - { - if ( i >= sizeof(szGameButton)) - { - SDL_SetError( "Button name too large: %s", szGameButton ); - return; - } - szGameButton[i] = *pchPos; - i++; - } - else - { - if ( i >= sizeof(szJoystickButton)) - { - SDL_SetError( "Joystick button name too large: %s", szJoystickButton ); - return; - } - szJoystickButton[i] = *pchPos; - i++; - } - pchPos++; - } - - SDL_PrivateGameControllerParseButton( szGameButton, szJoystickButton, pMapping ); + char szGameButton[20]; + char szJoystickButton[20]; + SDL_bool bGameButton = SDL_TRUE; + int i = 0; + const char *pchPos = pchString; + + SDL_memset( szGameButton, 0x0, sizeof(szGameButton) ); + SDL_memset( szJoystickButton, 0x0, sizeof(szJoystickButton) ); + + while ( pchPos && *pchPos ) + { + if ( *pchPos == ':' ) + { + i = 0; + bGameButton = SDL_FALSE; + } + else if ( *pchPos == ' ' ) + { + + } + else if ( *pchPos == ',' ) + { + i = 0; + bGameButton = SDL_TRUE; + SDL_PrivateGameControllerParseButton( szGameButton, szJoystickButton, pMapping ); + SDL_memset( szGameButton, 0x0, sizeof(szGameButton) ); + SDL_memset( szJoystickButton, 0x0, sizeof(szJoystickButton) ); + + } + else if ( bGameButton ) + { + if ( i >= sizeof(szGameButton)) + { + SDL_SetError( "Button name too large: %s", szGameButton ); + return; + } + szGameButton[i] = *pchPos; + i++; + } + else + { + if ( i >= sizeof(szJoystickButton)) + { + SDL_SetError( "Joystick button name too large: %s", szJoystickButton ); + return; + } + szJoystickButton[i] = *pchPos; + i++; + } + pchPos++; + } + + SDL_PrivateGameControllerParseButton( szGameButton, szJoystickButton, pMapping ); } @@ -565,38 +565,38 @@ SDL_PrivateGameControllerParseControllerConfigString( struct _SDL_ControllerMapp */ void SDL_PrivateLoadButtonMapping( struct _SDL_ControllerMapping *pMapping, SDL_JoystickGUID guid, const char *pchName, const char *pchMapping ) { - int j; - - pMapping->guid = guid; - pMapping->name = pchName; - - // set all the button mappings to non defaults - for ( j = 0; j < SDL_CONTROLLER_AXIS_MAX; j++ ) - { - pMapping->axes[j] = -1; - pMapping->buttonasaxis[j] = -1; - } - for ( j = 0; j < SDL_CONTROLLER_BUTTON_MAX; j++ ) - { - pMapping->buttons[j] = -1; - pMapping->axesasbutton[j] = -1; - pMapping->hatasbutton[j].hat = -1; - } - - for ( j = 0; j < k_nMaxReverseEntries; j++ ) - { - pMapping->raxes[j] = SDL_CONTROLLER_AXIS_INVALID; - pMapping->rbuttonasaxis[j] = SDL_CONTROLLER_AXIS_INVALID; - pMapping->rbuttons[j] = SDL_CONTROLLER_BUTTON_INVALID; - pMapping->raxesasbutton[j] = SDL_CONTROLLER_BUTTON_INVALID; - } - - for (j = 0; j < k_nMaxHatEntries; j++) - { - pMapping->rhatasbutton[j] = SDL_CONTROLLER_BUTTON_INVALID; - } - - SDL_PrivateGameControllerParseControllerConfigString( pMapping, pchMapping ); + int j; + + pMapping->guid = guid; + pMapping->name = pchName; + + /* set all the button mappings to non defaults */ + for ( j = 0; j < SDL_CONTROLLER_AXIS_MAX; j++ ) + { + pMapping->axes[j] = -1; + pMapping->buttonasaxis[j] = -1; + } + for ( j = 0; j < SDL_CONTROLLER_BUTTON_MAX; j++ ) + { + pMapping->buttons[j] = -1; + pMapping->axesasbutton[j] = -1; + pMapping->hatasbutton[j].hat = -1; + } + + for ( j = 0; j < k_nMaxReverseEntries; j++ ) + { + pMapping->raxes[j] = SDL_CONTROLLER_AXIS_INVALID; + pMapping->rbuttonasaxis[j] = SDL_CONTROLLER_AXIS_INVALID; + pMapping->rbuttons[j] = SDL_CONTROLLER_BUTTON_INVALID; + pMapping->raxesasbutton[j] = SDL_CONTROLLER_BUTTON_INVALID; + } + + for (j = 0; j < k_nMaxHatEntries; j++) + { + pMapping->rhatasbutton[j] = SDL_CONTROLLER_BUTTON_INVALID; + } + + SDL_PrivateGameControllerParseControllerConfigString( pMapping, pchMapping ); } @@ -605,20 +605,20 @@ void SDL_PrivateLoadButtonMapping( struct _SDL_ControllerMapping *pMapping, SDL_ */ char *SDL_PrivateGetControllerGUIDFromMappingString( const char *pMapping ) { - const char *pFirstComma = SDL_strchr( pMapping, ',' ); - if ( pFirstComma ) - { - char *pchGUID = SDL_malloc( pFirstComma - pMapping + 1 ); - if ( !pchGUID ) - { - SDL_OutOfMemory(); - return NULL; - } - SDL_memcpy( pchGUID, pMapping, pFirstComma - pMapping ); - pchGUID[ pFirstComma - pMapping ] = 0; - return pchGUID; - } - return NULL; + const char *pFirstComma = SDL_strchr( pMapping, ',' ); + if ( pFirstComma ) + { + char *pchGUID = SDL_malloc( pFirstComma - pMapping + 1 ); + if ( !pchGUID ) + { + SDL_OutOfMemory(); + return NULL; + } + SDL_memcpy( pchGUID, pMapping, pFirstComma - pMapping ); + pchGUID[ pFirstComma - pMapping ] = 0; + return pchGUID; + } + return NULL; } @@ -627,14 +627,14 @@ char *SDL_PrivateGetControllerGUIDFromMappingString( const char *pMapping ) */ char *SDL_PrivateGetControllerNameFromMappingString( const char *pMapping ) { - const char *pFirstComma, *pSecondComma; + const char *pFirstComma, *pSecondComma; char *pchName; pFirstComma = SDL_strchr( pMapping, ',' ); if ( !pFirstComma ) return NULL; - pSecondComma = SDL_strchr( pFirstComma + 1, ',' ); + pSecondComma = SDL_strchr( pFirstComma + 1, ',' ); if ( !pSecondComma ) return NULL; @@ -655,13 +655,13 @@ char *SDL_PrivateGetControllerNameFromMappingString( const char *pMapping ) */ char *SDL_PrivateGetControllerMappingFromMappingString( const char *pMapping ) { - const char *pFirstComma, *pSecondComma; + const char *pFirstComma, *pSecondComma; pFirstComma = SDL_strchr( pMapping, ',' ); if ( !pFirstComma ) return NULL; - pSecondComma = SDL_strchr( pFirstComma + 1, ',' ); + pSecondComma = SDL_strchr( pFirstComma + 1, ',' ); if ( !pSecondComma ) return NULL; @@ -679,11 +679,11 @@ void SDL_PrivateGameControllerRefreshMapping( ControllerMapping_t *pControllerMa event.type = SDL_CONTROLLERDEVICEREMAPPED; event.cdevice.which = gamecontrollerlist->joystick->instance_id; SDL_PushEvent(&event); - - // Not really threadsafe. Should this lock access within SDL_GameControllerEventWatcher? + + /* Not really threadsafe. Should this lock access within SDL_GameControllerEventWatcher? */ SDL_PrivateLoadButtonMapping(&gamecontrollerlist->mapping, pControllerMapping->guid, pControllerMapping->name, pControllerMapping->mapping); } - + gamecontrollerlist = gamecontrollerlist->next; } } @@ -694,9 +694,9 @@ void SDL_PrivateGameControllerRefreshMapping( ControllerMapping_t *pControllerMa int SDL_GameControllerAddMapping( const char *mappingString ) { - char *pchGUID; - char *pchName; - char *pchMapping; + char *pchGUID; + char *pchName; + char *pchMapping; SDL_JoystickGUID jGUID; ControllerMapping_t *pControllerMapping; #ifdef SDL_JOYSTICK_DINPUT @@ -715,46 +715,46 @@ SDL_GameControllerAddMapping( const char *mappingString ) jGUID = SDL_JoystickGetGUIDFromString(pchGUID); SDL_free(pchGUID); - pControllerMapping = SDL_PrivateGetControllerMappingForGUID(&jGUID); - - pchName = SDL_PrivateGetControllerNameFromMappingString( mappingString ); - if (!pchName) return -1; - - pchMapping = SDL_PrivateGetControllerMappingFromMappingString( mappingString ); - if (!pchMapping) { - SDL_free( pchName ); - return -1; - } - - if (pControllerMapping) { - // Update existing mapping - SDL_free( pControllerMapping->name ); - pControllerMapping->name = pchName; - SDL_free( pControllerMapping->mapping ); - pControllerMapping->mapping = pchMapping; - // refresh open controllers - SDL_PrivateGameControllerRefreshMapping( pControllerMapping ); - return 0; - } else { - pControllerMapping = SDL_malloc( sizeof(*pControllerMapping) ); - if (!pControllerMapping) { - SDL_free( pchName ); - SDL_free( pchMapping ); - return SDL_OutOfMemory(); - } + pControllerMapping = SDL_PrivateGetControllerMappingForGUID(&jGUID); + + pchName = SDL_PrivateGetControllerNameFromMappingString( mappingString ); + if (!pchName) return -1; + + pchMapping = SDL_PrivateGetControllerMappingFromMappingString( mappingString ); + if (!pchMapping) { + SDL_free( pchName ); + return -1; + } + + if (pControllerMapping) { + /* Update existing mapping */ + SDL_free( pControllerMapping->name ); + pControllerMapping->name = pchName; + SDL_free( pControllerMapping->mapping ); + pControllerMapping->mapping = pchMapping; + /* refresh open controllers */ + SDL_PrivateGameControllerRefreshMapping( pControllerMapping ); + return 0; + } else { + pControllerMapping = SDL_malloc( sizeof(*pControllerMapping) ); + if (!pControllerMapping) { + SDL_free( pchName ); + SDL_free( pchMapping ); + return SDL_OutOfMemory(); + } #ifdef SDL_JOYSTICK_DINPUT - if ( is_xinput_mapping ) - { - s_pXInputMapping = pControllerMapping; - } + if ( is_xinput_mapping ) + { + s_pXInputMapping = pControllerMapping; + } #endif - pControllerMapping->guid = jGUID; - pControllerMapping->name = pchName; - pControllerMapping->mapping = pchMapping; - pControllerMapping->next = s_pSupportedControllers; - s_pSupportedControllers = pControllerMapping; - return 1; - } + pControllerMapping->guid = jGUID; + pControllerMapping->name = pchName; + pControllerMapping->mapping = pchMapping; + pControllerMapping->next = s_pSupportedControllers; + s_pSupportedControllers = pControllerMapping; + return 1; + } } /* @@ -763,18 +763,18 @@ SDL_GameControllerAddMapping( const char *mappingString ) char * SDL_GameControllerMappingForGUID( SDL_JoystickGUID guid ) { - char *pMappingString = NULL; - ControllerMapping_t *mapping = SDL_PrivateGetControllerMappingForGUID(&guid); - if (mapping) { - char pchGUID[33]; + char *pMappingString = NULL; + ControllerMapping_t *mapping = SDL_PrivateGetControllerMappingForGUID(&guid); + if (mapping) { + char pchGUID[33]; size_t needed; - SDL_JoystickGetGUIDString(guid, pchGUID, sizeof(pchGUID)); - // allocate enough memory for GUID + ',' + name + ',' + mapping + \0 - needed = SDL_strlen(pchGUID) + 1 + SDL_strlen(mapping->name) + 1 + SDL_strlen(mapping->mapping) + 1; - pMappingString = SDL_malloc( needed ); - SDL_snprintf( pMappingString, needed, "%s,%s,%s", pchGUID, mapping->name, mapping->mapping ); - } - return pMappingString; + SDL_JoystickGetGUIDString(guid, pchGUID, sizeof(pchGUID)); + /* allocate enough memory for GUID + ',' + name + ',' + mapping + \0 */ + needed = SDL_strlen(pchGUID) + 1 + SDL_strlen(mapping->name) + 1 + SDL_strlen(mapping->mapping) + 1; + pMappingString = SDL_malloc( needed ); + SDL_snprintf( pMappingString, needed, "%s,%s,%s", pchGUID, mapping->name, mapping->mapping ); + } + return pMappingString; } /* @@ -783,7 +783,7 @@ SDL_GameControllerMappingForGUID( SDL_JoystickGUID guid ) char * SDL_GameControllerMapping( SDL_GameController * gamecontroller ) { - return SDL_GameControllerMappingForGUID( gamecontroller->mapping.guid ); + return SDL_GameControllerMappingForGUID( gamecontroller->mapping.guid ); } static void @@ -819,25 +819,25 @@ SDL_GameControllerLoadHints() int SDL_GameControllerInit(void) { - int i = 0; - const char *pMappingString = NULL; - s_pSupportedControllers = NULL; - pMappingString = s_ControllerMappings[i]; - while ( pMappingString ) - { - SDL_GameControllerAddMapping( pMappingString ); - - i++; - pMappingString = s_ControllerMappings[i]; - } - - // load in any user supplied config + int i = 0; + const char *pMappingString = NULL; + s_pSupportedControllers = NULL; + pMappingString = s_ControllerMappings[i]; + while ( pMappingString ) + { + SDL_GameControllerAddMapping( pMappingString ); + + i++; + pMappingString = s_ControllerMappings[i]; + } + + /* load in any user supplied config */ SDL_GameControllerLoadHints(); - /* watch for joy events and fire controller ones if needed */ - SDL_AddEventWatch( SDL_GameControllerEventWatcher, NULL ); + /* watch for joy events and fire controller ones if needed */ + SDL_AddEventWatch( SDL_GameControllerEventWatcher, NULL ); - return (0); + return (0); } @@ -847,11 +847,11 @@ SDL_GameControllerInit(void) const char * SDL_GameControllerNameForIndex(int device_index) { - ControllerMapping_t *pSupportedController = SDL_PrivateGetControllerMapping(device_index); - if ( pSupportedController ) - { - return pSupportedController->name; - } + ControllerMapping_t *pSupportedController = SDL_PrivateGetControllerMapping(device_index); + if ( pSupportedController ) + { + return pSupportedController->name; + } return NULL; } @@ -862,13 +862,13 @@ SDL_GameControllerNameForIndex(int device_index) SDL_bool SDL_IsGameController(int device_index) { - ControllerMapping_t *pSupportedController = SDL_PrivateGetControllerMapping(device_index); - if ( pSupportedController ) - { - return SDL_TRUE; - } + ControllerMapping_t *pSupportedController = SDL_PrivateGetControllerMapping(device_index); + if ( pSupportedController ) + { + return SDL_TRUE; + } - return SDL_FALSE; + return SDL_FALSE; } /* @@ -882,56 +882,56 @@ SDL_GameController * SDL_GameControllerOpen(int device_index) { SDL_GameController *gamecontroller; - SDL_GameController *gamecontrollerlist; - ControllerMapping_t *pSupportedController = NULL; + SDL_GameController *gamecontrollerlist; + ControllerMapping_t *pSupportedController = NULL; if ((device_index < 0) || (device_index >= SDL_NumJoysticks())) { SDL_SetError("There are %d joysticks available", SDL_NumJoysticks()); return (NULL); } - gamecontrollerlist = SDL_gamecontrollers; - // If the controller is already open, return it - while ( gamecontrollerlist ) - { - if ( SDL_SYS_GetInstanceIdOfDeviceIndex(device_index) == gamecontrollerlist->joystick->instance_id ) { - gamecontroller = gamecontrollerlist; - ++gamecontroller->ref_count; - return (gamecontroller); - } - gamecontrollerlist = gamecontrollerlist->next; + gamecontrollerlist = SDL_gamecontrollers; + /* If the controller is already open, return it */ + while ( gamecontrollerlist ) + { + if ( SDL_SYS_GetInstanceIdOfDeviceIndex(device_index) == gamecontrollerlist->joystick->instance_id ) { + gamecontroller = gamecontrollerlist; + ++gamecontroller->ref_count; + return (gamecontroller); + } + gamecontrollerlist = gamecontrollerlist->next; } - // Find a controller mapping - pSupportedController = SDL_PrivateGetControllerMapping(device_index); - if ( !pSupportedController ) { - SDL_SetError("Couldn't find mapping for device (%d)", device_index ); - return (NULL); - } + /* Find a controller mapping */ + pSupportedController = SDL_PrivateGetControllerMapping(device_index); + if ( !pSupportedController ) { + SDL_SetError("Couldn't find mapping for device (%d)", device_index ); + return (NULL); + } - // Create and initialize the joystick - gamecontroller = (SDL_GameController *) SDL_malloc((sizeof *gamecontroller)); - if (gamecontroller == NULL) { - SDL_OutOfMemory(); - return NULL; - } + /* Create and initialize the joystick */ + gamecontroller = (SDL_GameController *) SDL_malloc((sizeof *gamecontroller)); + if (gamecontroller == NULL) { + SDL_OutOfMemory(); + return NULL; + } SDL_memset(gamecontroller, 0, (sizeof *gamecontroller)); gamecontroller->joystick = SDL_JoystickOpen(device_index); - if ( !gamecontroller->joystick ) { + if ( !gamecontroller->joystick ) { SDL_free(gamecontroller); return NULL; } - SDL_PrivateLoadButtonMapping( &gamecontroller->mapping, pSupportedController->guid, pSupportedController->name, pSupportedController->mapping ); + SDL_PrivateLoadButtonMapping( &gamecontroller->mapping, pSupportedController->guid, pSupportedController->name, pSupportedController->mapping ); - // Add joystick to list + /* Add joystick to list */ ++gamecontroller->ref_count; - // Link the joystick in the list - gamecontroller->next = SDL_gamecontrollers; - SDL_gamecontrollers = gamecontroller; + /* Link the joystick in the list */ + gamecontroller->next = SDL_gamecontrollers; + SDL_gamecontrollers = gamecontroller; - SDL_SYS_JoystickUpdate( gamecontroller->joystick ); + SDL_SYS_JoystickUpdate( gamecontroller->joystick ); return (gamecontroller); } @@ -953,22 +953,22 @@ SDL_GameControllerUpdate(void) Sint16 SDL_GameControllerGetAxis(SDL_GameController * gamecontroller, SDL_GameControllerAxis axis) { - if ( !gamecontroller ) - return 0; - - if (gamecontroller->mapping.axes[axis] >= 0 ) - { - return ( SDL_JoystickGetAxis( gamecontroller->joystick, gamecontroller->mapping.axes[axis]) ); - } - else if (gamecontroller->mapping.buttonasaxis[axis] >= 0 ) - { - Uint8 value; - value = SDL_JoystickGetButton( gamecontroller->joystick, gamecontroller->mapping.buttonasaxis[axis] ); - if ( value > 0 ) - return 32767; - return 0; - } - return 0; + if ( !gamecontroller ) + return 0; + + if (gamecontroller->mapping.axes[axis] >= 0 ) + { + return ( SDL_JoystickGetAxis( gamecontroller->joystick, gamecontroller->mapping.axes[axis]) ); + } + else if (gamecontroller->mapping.buttonasaxis[axis] >= 0 ) + { + Uint8 value; + value = SDL_JoystickGetButton( gamecontroller->joystick, gamecontroller->mapping.buttonasaxis[axis] ); + if ( value > 0 ) + return 32767; + return 0; + } + return 0; } @@ -978,32 +978,32 @@ SDL_GameControllerGetAxis(SDL_GameController * gamecontroller, SDL_GameControlle Uint8 SDL_GameControllerGetButton(SDL_GameController * gamecontroller, SDL_GameControllerButton button) { - if ( !gamecontroller ) - return 0; - - if ( gamecontroller->mapping.buttons[button] >= 0 ) - { - return ( SDL_JoystickGetButton( gamecontroller->joystick, gamecontroller->mapping.buttons[button] ) ); - } - else if ( gamecontroller->mapping.axesasbutton[button] >= 0 ) - { - Sint16 value; - value = SDL_JoystickGetAxis( gamecontroller->joystick, gamecontroller->mapping.axesasbutton[button] ); - if ( ABS(value) > 32768/2 ) - return 1; - return 0; - } - else if ( gamecontroller->mapping.hatasbutton[button].hat >= 0 ) - { - Uint8 value; - value = SDL_JoystickGetHat( gamecontroller->joystick, gamecontroller->mapping.hatasbutton[button].hat ); - - if ( value & gamecontroller->mapping.hatasbutton[button].mask ) - return 1; - return 0; - } - - return 0; + if ( !gamecontroller ) + return 0; + + if ( gamecontroller->mapping.buttons[button] >= 0 ) + { + return ( SDL_JoystickGetButton( gamecontroller->joystick, gamecontroller->mapping.buttons[button] ) ); + } + else if ( gamecontroller->mapping.axesasbutton[button] >= 0 ) + { + Sint16 value; + value = SDL_JoystickGetAxis( gamecontroller->joystick, gamecontroller->mapping.axesasbutton[button] ); + if ( ABS(value) > 32768/2 ) + return 1; + return 0; + } + else if ( gamecontroller->mapping.hatasbutton[button].hat >= 0 ) + { + Uint8 value; + value = SDL_JoystickGetHat( gamecontroller->joystick, gamecontroller->mapping.hatasbutton[button].hat ); + + if ( value & gamecontroller->mapping.hatasbutton[button].mask ) + return 1; + return 0; + } + + return 0; } /* @@ -1013,10 +1013,10 @@ SDL_GameControllerGetButton(SDL_GameController * gamecontroller, SDL_GameControl SDL_bool SDL_GameControllerGetAttached( SDL_GameController * gamecontroller ) { - if ( !gamecontroller ) - return SDL_FALSE; + if ( !gamecontroller ) + return SDL_FALSE; - return SDL_JoystickGetAttached(gamecontroller->joystick); + return SDL_JoystickGetAttached(gamecontroller->joystick); } @@ -1026,8 +1026,8 @@ SDL_GameControllerGetAttached( SDL_GameController * gamecontroller ) const char * SDL_GameControllerName(SDL_GameController * gamecontroller) { - if ( !gamecontroller ) - return NULL; + if ( !gamecontroller ) + return NULL; return (gamecontroller->mapping.name); } @@ -1038,10 +1038,10 @@ SDL_GameControllerName(SDL_GameController * gamecontroller) */ SDL_Joystick *SDL_GameControllerGetJoystick(SDL_GameController * gamecontroller) { - if ( !gamecontroller ) - return NULL; + if ( !gamecontroller ) + return NULL; - return gamecontroller->joystick; + return gamecontroller->joystick; } /** @@ -1049,24 +1049,24 @@ SDL_Joystick *SDL_GameControllerGetJoystick(SDL_GameController * gamecontroller) */ SDL_GameControllerButtonBind SDL_GameControllerGetBindForAxis(SDL_GameController * gamecontroller, SDL_GameControllerAxis axis) { - SDL_GameControllerButtonBind bind; - SDL_memset( &bind, 0x0, sizeof(bind) ); - - if ( !gamecontroller || axis == SDL_CONTROLLER_AXIS_INVALID ) - return bind; - - if (gamecontroller->mapping.axes[axis] >= 0 ) - { - bind.bindType = SDL_CONTROLLER_BINDTYPE_AXIS; - bind.value.button = gamecontroller->mapping.axes[axis]; - } - else if (gamecontroller->mapping.buttonasaxis[axis] >= 0 ) - { - bind.bindType = SDL_CONTROLLER_BINDTYPE_BUTTON; - bind.value.button = gamecontroller->mapping.buttonasaxis[axis]; - } - - return bind; + SDL_GameControllerButtonBind bind; + SDL_memset( &bind, 0x0, sizeof(bind) ); + + if ( !gamecontroller || axis == SDL_CONTROLLER_AXIS_INVALID ) + return bind; + + if (gamecontroller->mapping.axes[axis] >= 0 ) + { + bind.bindType = SDL_CONTROLLER_BINDTYPE_AXIS; + bind.value.button = gamecontroller->mapping.axes[axis]; + } + else if (gamecontroller->mapping.buttonasaxis[axis] >= 0 ) + { + bind.bindType = SDL_CONTROLLER_BINDTYPE_BUTTON; + bind.value.button = gamecontroller->mapping.buttonasaxis[axis]; + } + + return bind; } @@ -1075,30 +1075,30 @@ SDL_GameControllerButtonBind SDL_GameControllerGetBindForAxis(SDL_GameController */ SDL_GameControllerButtonBind SDL_GameControllerGetBindForButton(SDL_GameController * gamecontroller, SDL_GameControllerButton button) { - SDL_GameControllerButtonBind bind; - SDL_memset( &bind, 0x0, sizeof(bind) ); - - if ( !gamecontroller || button == SDL_CONTROLLER_BUTTON_INVALID ) - return bind; - - if ( gamecontroller->mapping.buttons[button] >= 0 ) - { - bind.bindType = SDL_CONTROLLER_BINDTYPE_BUTTON; - bind.value.button = gamecontroller->mapping.buttons[button]; - } - else if ( gamecontroller->mapping.axesasbutton[button] >= 0 ) - { - bind.bindType = SDL_CONTROLLER_BINDTYPE_AXIS; - bind.value.axis = gamecontroller->mapping.axesasbutton[button]; - } - else if ( gamecontroller->mapping.hatasbutton[button].hat >= 0 ) - { - bind.bindType = SDL_CONTROLLER_BINDTYPE_HAT; - bind.value.hat.hat = gamecontroller->mapping.hatasbutton[button].hat; - bind.value.hat.hat_mask = gamecontroller->mapping.hatasbutton[button].mask; - } - - return bind; + SDL_GameControllerButtonBind bind; + SDL_memset( &bind, 0x0, sizeof(bind) ); + + if ( !gamecontroller || button == SDL_CONTROLLER_BUTTON_INVALID ) + return bind; + + if ( gamecontroller->mapping.buttons[button] >= 0 ) + { + bind.bindType = SDL_CONTROLLER_BINDTYPE_BUTTON; + bind.value.button = gamecontroller->mapping.buttons[button]; + } + else if ( gamecontroller->mapping.axesasbutton[button] >= 0 ) + { + bind.bindType = SDL_CONTROLLER_BINDTYPE_AXIS; + bind.value.axis = gamecontroller->mapping.axesasbutton[button]; + } + else if ( gamecontroller->mapping.hatasbutton[button].hat >= 0 ) + { + bind.bindType = SDL_CONTROLLER_BINDTYPE_HAT; + bind.value.hat.hat = gamecontroller->mapping.hatasbutton[button].hat; + bind.value.hat.hat_mask = gamecontroller->mapping.hatasbutton[button].mask; + } + + return bind; } @@ -1108,39 +1108,39 @@ SDL_GameControllerButtonBind SDL_GameControllerGetBindForButton(SDL_GameControll void SDL_GameControllerClose(SDL_GameController * gamecontroller) { - SDL_GameController *gamecontrollerlist, *gamecontrollerlistprev; + SDL_GameController *gamecontrollerlist, *gamecontrollerlistprev; - if ( !gamecontroller ) - return; + if ( !gamecontroller ) + return; - // First decrement ref count + /* First decrement ref count */ if (--gamecontroller->ref_count > 0) { return; } - SDL_JoystickClose( gamecontroller->joystick ); - - gamecontrollerlist = SDL_gamecontrollers; - gamecontrollerlistprev = NULL; - while ( gamecontrollerlist ) - { - if (gamecontroller == gamecontrollerlist) - { - if ( gamecontrollerlistprev ) - { - // unlink this entry - gamecontrollerlistprev->next = gamecontrollerlist->next; - } - else - { - SDL_gamecontrollers = gamecontroller->next; - } - - break; - } - gamecontrollerlistprev = gamecontrollerlist; - gamecontrollerlist = gamecontrollerlist->next; - } + SDL_JoystickClose( gamecontroller->joystick ); + + gamecontrollerlist = SDL_gamecontrollers; + gamecontrollerlistprev = NULL; + while ( gamecontrollerlist ) + { + if (gamecontroller == gamecontrollerlist) + { + if ( gamecontrollerlistprev ) + { + /* unlink this entry */ + gamecontrollerlistprev->next = gamecontrollerlist->next; + } + else + { + SDL_gamecontrollers = gamecontroller->next; + } + + break; + } + gamecontrollerlistprev = gamecontrollerlist; + gamecontrollerlist = gamecontrollerlist->next; + } SDL_free(gamecontroller); } @@ -1152,22 +1152,22 @@ SDL_GameControllerClose(SDL_GameController * gamecontroller) void SDL_GameControllerQuit(void) { - ControllerMapping_t *pControllerMap; - while ( SDL_gamecontrollers ) - { - SDL_gamecontrollers->ref_count = 1; + ControllerMapping_t *pControllerMap; + while ( SDL_gamecontrollers ) + { + SDL_gamecontrollers->ref_count = 1; SDL_GameControllerClose(SDL_gamecontrollers); - } + } - while ( s_pSupportedControllers ) - { - pControllerMap = s_pSupportedControllers; - s_pSupportedControllers = s_pSupportedControllers->next; - SDL_free( pControllerMap->name ); - SDL_free( pControllerMap ); - } + while ( s_pSupportedControllers ) + { + pControllerMap = s_pSupportedControllers; + s_pSupportedControllers = s_pSupportedControllers->next; + SDL_free( pControllerMap->name ); + SDL_free( pControllerMap ); + } - SDL_DelEventWatch( SDL_GameControllerEventWatcher, NULL ); + SDL_DelEventWatch( SDL_GameControllerEventWatcher, NULL ); } @@ -1177,7 +1177,7 @@ SDL_GameControllerQuit(void) int SDL_PrivateGameControllerAxis(SDL_GameController * gamecontroller, SDL_GameControllerAxis axis, Sint16 value) { - int posted; + int posted; /* translate the event, if desired */ posted = 0; @@ -1188,7 +1188,7 @@ SDL_PrivateGameControllerAxis(SDL_GameController * gamecontroller, SDL_GameContr event.caxis.which = gamecontroller->joystick->instance_id; event.caxis.axis = axis; event.caxis.value = value; - posted = SDL_PushEvent(&event) == 1; + posted = SDL_PushEvent(&event) == 1; } #endif /* !SDL_EVENTS_DISABLED */ return (posted); @@ -1203,7 +1203,7 @@ SDL_PrivateGameControllerButton(SDL_GameController * gamecontroller, SDL_GameCon { int posted; #if !SDL_EVENTS_DISABLED - SDL_Event event; + SDL_Event event; if ( button == SDL_CONTROLLER_BUTTON_INVALID ) return (0); @@ -1228,7 +1228,7 @@ SDL_PrivateGameControllerButton(SDL_GameController * gamecontroller, SDL_GameCon event.cbutton.which = gamecontroller->joystick->instance_id; event.cbutton.button = button; event.cbutton.state = state; - posted = SDL_PushEvent(&event) == 1; + posted = SDL_PushEvent(&event) == 1; } #endif /* !SDL_EVENTS_DISABLED */ return (posted); @@ -1269,5 +1269,4 @@ SDL_GameControllerEventState(int state) #endif /* SDL_EVENTS_DISABLED */ } - /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c index 53b465caa..0e9c3f74c 100644 --- a/src/joystick/SDL_joystick.c +++ b/src/joystick/SDL_joystick.c @@ -78,26 +78,26 @@ SDL_Joystick * SDL_JoystickOpen(int device_index) { SDL_Joystick *joystick; - SDL_Joystick *joysticklist; - const char *joystickname = NULL; + SDL_Joystick *joysticklist; + const char *joystickname = NULL; if ((device_index < 0) || (device_index >= SDL_NumJoysticks())) { SDL_SetError("There are %d joysticks available", SDL_NumJoysticks()); return (NULL); } - joysticklist = SDL_joysticks; - /* If the joystick is already open, return it - * it is important that we have a single joystick * for each instance id - */ - while ( joysticklist ) - { - if ( SDL_SYS_GetInstanceIdOfDeviceIndex(device_index) == joysticklist->instance_id ) { - joystick = joysticklist; - ++joystick->ref_count; - return (joystick); - } - joysticklist = joysticklist->next; + joysticklist = SDL_joysticks; + /* If the joystick is already open, return it + * it is important that we have a single joystick * for each instance id + */ + while ( joysticklist ) + { + if ( SDL_SYS_GetInstanceIdOfDeviceIndex(device_index) == joysticklist->instance_id ) { + joystick = joysticklist; + ++joystick->ref_count; + return (joystick); + } + joysticklist = joysticklist->next; } /* Create and initialize the joystick */ @@ -113,11 +113,11 @@ SDL_JoystickOpen(int device_index) return NULL; } - joystickname = SDL_SYS_JoystickNameForDeviceIndex( device_index ); - if ( joystickname ) - joystick->name = SDL_strdup( joystickname ); - else - joystick->name = NULL; + joystickname = SDL_SYS_JoystickNameForDeviceIndex( device_index ); + if ( joystickname ) + joystick->name = SDL_strdup( joystickname ); + else + joystick->name = NULL; if (joystick->naxes > 0) { joystick->axes = (Sint16 *) SDL_malloc @@ -159,11 +159,11 @@ SDL_JoystickOpen(int device_index) /* Add joystick to list */ ++joystick->ref_count; - /* Link the joystick in the list */ - joystick->next = SDL_joysticks; - SDL_joysticks = joystick; + /* Link the joystick in the list */ + joystick->next = SDL_joysticks; + SDL_joysticks = joystick; - SDL_SYS_JoystickUpdate( joystick ); + SDL_SYS_JoystickUpdate( joystick ); return (joystick); } @@ -183,12 +183,12 @@ SDL_PrivateJoystickValid(SDL_Joystick * joystick) } else { valid = 1; } - - if ( joystick && joystick->closed ) - { - valid = 0; - } - + + if ( joystick && joystick->closed ) + { + valid = 0; + } + return valid; } @@ -335,24 +335,24 @@ SDL_JoystickGetButton(SDL_Joystick * joystick, int button) SDL_bool SDL_JoystickGetAttached(SDL_Joystick * joystick) { - if (!SDL_PrivateJoystickValid(joystick)) { + if (!SDL_PrivateJoystickValid(joystick)) { return SDL_FALSE; } - return SDL_SYS_JoystickAttached(joystick); + return SDL_SYS_JoystickAttached(joystick); } /* * Get the instance id for this opened joystick */ -SDL_JoystickID +SDL_JoystickID SDL_JoystickInstanceID(SDL_Joystick * joystick) { - if (!SDL_PrivateJoystickValid(joystick)) { + if (!SDL_PrivateJoystickValid(joystick)) { return (-1); } - return (joystick->instance_id); + return (joystick->instance_id); } /* @@ -364,7 +364,7 @@ SDL_JoystickName(SDL_Joystick * joystick) if (!SDL_PrivateJoystickValid(joystick)) { return (NULL); } - + return (joystick->name); } @@ -374,8 +374,8 @@ SDL_JoystickName(SDL_Joystick * joystick) void SDL_JoystickClose(SDL_Joystick * joystick) { - SDL_Joystick *joysticklist; - SDL_Joystick *joysticklistprev; + SDL_Joystick *joysticklist; + SDL_Joystick *joysticklistprev; if (!joystick) { return; @@ -391,31 +391,31 @@ SDL_JoystickClose(SDL_Joystick * joystick) } SDL_SYS_JoystickClose(joystick); - - joysticklist = SDL_joysticks; - joysticklistprev = NULL; - while ( joysticklist ) - { - if (joystick == joysticklist) - { - if ( joysticklistprev ) - { - // unlink this entry - joysticklistprev->next = joysticklist->next; - } - else - { - SDL_joysticks = joystick->next; - } - - break; - } - joysticklistprev = joysticklist; - joysticklist = joysticklist->next; - } - - if (joystick->name) - SDL_free(joystick->name); + + joysticklist = SDL_joysticks; + joysticklistprev = NULL; + while ( joysticklist ) + { + if (joystick == joysticklist) + { + if ( joysticklistprev ) + { + /* unlink this entry */ + joysticklistprev->next = joysticklist->next; + } + else + { + SDL_joysticks = joystick->next; + } + + break; + } + joysticklistprev = joysticklist; + joysticklist = joysticklist->next; + } + + if (joystick->name) + SDL_free(joystick->name); /* Free the data associated with this joystick */ if (joystick->axes) { @@ -440,11 +440,11 @@ SDL_JoystickQuit(void) SDL_assert(!SDL_updating_joystick); /* Stop the event polling */ - while ( SDL_joysticks ) - { - SDL_joysticks->ref_count = 1; + while ( SDL_joysticks ) + { + SDL_joysticks->ref_count = 1; SDL_JoystickClose(SDL_joysticks); - } + } /* Quit the joystick setup */ SDL_SYS_JoystickQuit(); @@ -587,25 +587,25 @@ SDL_PrivateJoystickButton(SDL_Joystick * joystick, Uint8 button, Uint8 state) void SDL_JoystickUpdate(void) { - SDL_Joystick *joystick; - - joystick = SDL_joysticks; - while ( joystick ) - { - SDL_Joystick *joysticknext; - /* save off the next pointer, the Update call may cause a joystick removed event - * and cause our joystick pointer to be freed - */ - joysticknext = joystick->next; + SDL_Joystick *joystick; + + joystick = SDL_joysticks; + while ( joystick ) + { + SDL_Joystick *joysticknext; + /* save off the next pointer, the Update call may cause a joystick removed event + * and cause our joystick pointer to be freed + */ + joysticknext = joystick->next; SDL_updating_joystick = joystick; SDL_SYS_JoystickUpdate( joystick ); - if ( joystick->closed && joystick->uncentered ) - { - int i; - joystick->uncentered = 0; + if ( joystick->closed && joystick->uncentered ) + { + int i; + joystick->uncentered = 0; /* Tell the app that everything is centered/unpressed... */ for (i = 0; i < joystick->naxes; i++) @@ -617,7 +617,7 @@ SDL_JoystickUpdate(void) for (i = 0; i < joystick->nhats; i++) SDL_PrivateJoystickHat(joystick, i, SDL_HAT_CENTERED); - } + } SDL_updating_joystick = NULL; @@ -626,12 +626,13 @@ SDL_JoystickUpdate(void) SDL_JoystickClose(joystick); } - joystick = joysticknext; - } + joystick = joysticknext; + } - // this needs to happen AFTER walking the joystick list above, so that any - // dangling hardware data from removed devices can be free'd - SDL_SYS_JoystickDetect(); + /* this needs to happen AFTER walking the joystick list above, so that any + dangling hardware data from removed devices can be free'd + */ + SDL_SYS_JoystickDetect(); } int @@ -667,106 +668,106 @@ SDL_JoystickEventState(int state) } /* return 1 if you want to run the joystick update loop this frame, used by hotplug support */ -SDL_bool +SDL_bool SDL_PrivateJoystickNeedsPolling() { - if (SDL_joysticks != NULL) { - return SDL_TRUE; - } else { - return SDL_SYS_JoystickNeedsPolling(); - } + if (SDL_joysticks != NULL) { + return SDL_TRUE; + } else { + return SDL_SYS_JoystickNeedsPolling(); + } } /* return the guid for this index */ SDL_JoystickGUID SDL_JoystickGetDeviceGUID(int device_index) { - return SDL_SYS_JoystickGetDeviceGUID( device_index ); + return SDL_SYS_JoystickGetDeviceGUID( device_index ); } /* return the guid for this opened device */ SDL_JoystickGUID SDL_JoystickGetGUID(SDL_Joystick * joystick) { - return SDL_SYS_JoystickGetGUID( joystick ); + return SDL_SYS_JoystickGetGUID( joystick ); } /* convert the guid to a printable string */ void SDL_JoystickGetGUIDString( SDL_JoystickGUID guid, char *pszGUID, int cbGUID ) { - static const char k_rgchHexToASCII[] = "0123456789abcdef"; - int i; + static const char k_rgchHexToASCII[] = "0123456789abcdef"; + int i; if ((pszGUID == NULL) || (cbGUID <= 0)) { return; } - for ( i = 0; i < sizeof(guid.data) && i < (cbGUID-1); i++ ) - { - // each input byte writes 2 ascii chars, and might write a null byte. - // If we don't have room for next input byte, stop - unsigned char c = guid.data[i]; + for ( i = 0; i < sizeof(guid.data) && i < (cbGUID-1); i++ ) + { + /* each input byte writes 2 ascii chars, and might write a null byte. */ + /* If we don't have room for next input byte, stop */ + unsigned char c = guid.data[i]; - *pszGUID++ = k_rgchHexToASCII[ c >> 4 ]; - *pszGUID++ = k_rgchHexToASCII[ c & 0x0F ]; - } - *pszGUID = '\0'; + *pszGUID++ = k_rgchHexToASCII[ c >> 4 ]; + *pszGUID++ = k_rgchHexToASCII[ c & 0x0F ]; + } + *pszGUID = '\0'; } -//----------------------------------------------------------------------------- -// Purpose: Returns the 4 bit nibble for a hex character -// Input : c - -// Output : unsigned char -//----------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- + * Purpose: Returns the 4 bit nibble for a hex character + * Input : c - + * Output : unsigned char + *-----------------------------------------------------------------------------*/ static unsigned char nibble( char c ) { - if ( ( c >= '0' ) && - ( c <= '9' ) ) - { - return (unsigned char)(c - '0'); - } - - if ( ( c >= 'A' ) && - ( c <= 'F' ) ) - { - return (unsigned char)(c - 'A' + 0x0a); - } - - if ( ( c >= 'a' ) && - ( c <= 'f' ) ) - { - return (unsigned char)(c - 'a' + 0x0a); - } - - // received an invalid character, and no real way to return an error - // AssertMsg1( false, "Q_nibble invalid hex character '%c' ", c ); - return 0; + if ( ( c >= '0' ) && + ( c <= '9' ) ) + { + return (unsigned char)(c - '0'); + } + + if ( ( c >= 'A' ) && + ( c <= 'F' ) ) + { + return (unsigned char)(c - 'A' + 0x0a); + } + + if ( ( c >= 'a' ) && + ( c <= 'f' ) ) + { + return (unsigned char)(c - 'a' + 0x0a); + } + + /* received an invalid character, and no real way to return an error */ + /* AssertMsg1( false, "Q_nibble invalid hex character '%c' ", c ); */ + return 0; } /* convert the string version of a joystick guid to the struct */ SDL_JoystickGUID SDL_JoystickGetGUIDFromString(const char *pchGUID) { - SDL_JoystickGUID guid; - int maxoutputbytes= sizeof(guid); - int len = SDL_strlen( pchGUID ); - Uint8 *p; - int i; - - // Make sure it's even - len = ( len ) & ~0x1; - - SDL_memset( &guid, 0x00, sizeof(guid) ); - - p = (Uint8 *)&guid; - for ( i = 0; - ( i < len ) && ( ( p - (Uint8 *)&guid ) < maxoutputbytes ); - i+=2, p++ ) - { - *p = ( nibble( pchGUID[i] ) << 4 ) | nibble( pchGUID[i+1] ); - } - - return guid; + SDL_JoystickGUID guid; + int maxoutputbytes= sizeof(guid); + int len = SDL_strlen( pchGUID ); + Uint8 *p; + int i; + + /* Make sure it's even */ + len = ( len ) & ~0x1; + + SDL_memset( &guid, 0x00, sizeof(guid) ); + + p = (Uint8 *)&guid; + for ( i = 0; + ( i < len ) && ( ( p - (Uint8 *)&guid ) < maxoutputbytes ); + i+=2, p++ ) + { + *p = ( nibble( pchGUID[i] ) << 4 ) | nibble( pchGUID[i+1] ); + } + + return guid; } diff --git a/src/joystick/SDL_joystick_c.h b/src/joystick/SDL_joystick_c.h index 526cc4623..38bc78553 100644 --- a/src/joystick/SDL_joystick_c.h +++ b/src/joystick/SDL_joystick_c.h @@ -41,7 +41,7 @@ extern int SDL_PrivateJoystickHat(SDL_Joystick * joystick, Uint8 hat, Uint8 value); extern int SDL_PrivateJoystickButton(SDL_Joystick * joystick, Uint8 button, Uint8 state); - + /* Helper function to let lower sys layer tell the event system if the joystick code needs to think */ extern SDL_bool SDL_PrivateJoystickNeedsPolling(); diff --git a/src/joystick/android/SDL_sysjoystick.c b/src/joystick/android/SDL_sysjoystick.c index 2e2d98a02..adaca528e 100644 --- a/src/joystick/android/SDL_sysjoystick.c +++ b/src/joystick/android/SDL_sysjoystick.c @@ -87,10 +87,10 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index) joystick->nballs = 0; joystick->naxes = 3; return 0; - } else { - SDL_SetError("No joystick available with that index"); - return (-1); - } + } else { + SDL_SetError("No joystick available with that index"); + return (-1); + } } /* Function to determine is this joystick is attached to the system right now */ @@ -134,7 +134,7 @@ SDL_SYS_JoystickQuit(void) SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID( int device_index ) { SDL_JoystickGUID guid; - // the GUID is just the first 16 chars of the name for now + /* the GUID is just the first 16 chars of the name for now */ const char *name = SDL_SYS_JoystickNameForDeviceIndex( device_index ); SDL_zero( guid ); SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) ); @@ -144,7 +144,7 @@ SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID( int device_index ) SDL_JoystickGUID SDL_SYS_JoystickGetGUID(SDL_Joystick * joystick) { SDL_JoystickGUID guid; - // the GUID is just the first 16 chars of the name for now + /* the GUID is just the first 16 chars of the name for now */ const char *name = joystick->name; SDL_zero( guid ); SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) ); diff --git a/src/joystick/beos/SDL_bejoystick.cc b/src/joystick/beos/SDL_bejoystick.cc index f8a7f14a0..4e342ed41 100644 --- a/src/joystick/beos/SDL_bejoystick.cc +++ b/src/joystick/beos/SDL_bejoystick.cc @@ -261,7 +261,7 @@ extern "C" SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID( int device_index ) { SDL_JoystickGUID guid; - // the GUID is just the first 16 chars of the name for now + /* the GUID is just the first 16 chars of the name for now */ const char *name = SDL_SYS_JoystickNameForDeviceIndex( device_index ); SDL_zero( guid ); SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) ); @@ -271,7 +271,7 @@ extern "C" SDL_JoystickGUID SDL_SYS_JoystickGetGUID(SDL_Joystick * joystick) { SDL_JoystickGUID guid; - // the GUID is just the first 16 chars of the name for now + /* the GUID is just the first 16 chars of the name for now */ const char *name = joystick->name; SDL_zero( guid ); SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) ); diff --git a/src/joystick/bsd/SDL_sysjoystick.c b/src/joystick/bsd/SDL_sysjoystick.c index bbdae328c..6d35d91b5 100644 --- a/src/joystick/bsd/SDL_sysjoystick.c +++ b/src/joystick/bsd/SDL_sysjoystick.c @@ -76,9 +76,9 @@ #include "../SDL_sysjoystick.h" #include "../SDL_joystick_c.h" -#define MAX_UHID_JOYS 16 -#define MAX_JOY_JOYS 2 -#define MAX_JOYS (MAX_UHID_JOYS + MAX_JOY_JOYS) +#define MAX_UHID_JOYS 16 +#define MAX_JOY_JOYS 2 +#define MAX_JOYS (MAX_UHID_JOYS + MAX_JOY_JOYS) struct report @@ -589,7 +589,7 @@ SDL_SYS_JoystickQuit(void) SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID( int device_index ) { SDL_JoystickGUID guid; - // the GUID is just the first 16 chars of the name for now + /* the GUID is just the first 16 chars of the name for now */ const char *name = SDL_SYS_JoystickNameForDeviceIndex( device_index ); SDL_zero( guid ); SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) ); @@ -599,7 +599,7 @@ SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID( int device_index ) SDL_JoystickGUID SDL_SYS_JoystickGetGUID(SDL_Joystick * joystick) { SDL_JoystickGUID guid; - // the GUID is just the first 16 chars of the name for now + /* the GUID is just the first 16 chars of the name for now */ const char *name = joystick->name; SDL_zero( guid ); SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) ); diff --git a/src/joystick/darwin/SDL_sysjoystick.c b/src/joystick/darwin/SDL_sysjoystick.c index c97f47eb8..97f0e393b 100644 --- a/src/joystick/darwin/SDL_sysjoystick.c +++ b/src/joystick/darwin/SDL_sysjoystick.c @@ -127,7 +127,7 @@ HIDRemovalCallback(void *target, IOReturn result, void *refcon, void *sender) { recDevice *device = (recDevice *) refcon; device->removed = 1; - s_bDeviceRemoved = SDL_TRUE; + s_bDeviceRemoved = SDL_TRUE; } @@ -137,10 +137,10 @@ void JoystickDeviceWasRemovedCallback( void * refcon, io_service_t service, natu { if( messageType == kIOMessageServiceIsTerminated && refcon ) { - recDevice *device = (recDevice *) refcon; - device->removed = 1; - s_bDeviceRemoved = SDL_TRUE; - } + recDevice *device = (recDevice *) refcon; + device->removed = 1; + s_bDeviceRemoved = SDL_TRUE; + } } @@ -186,33 +186,33 @@ HIDCreateOpenDeviceInterface(io_object_t hidDevice, recDevice * pDevice) HIDReportErrorNum ("Failed to open pDevice->interface via open.", result); else - { - pDevice->portIterator = 0; + { + pDevice->portIterator = 0; - // It's okay if this fails, we have another detection method below + /* It's okay if this fails, we have another detection method below */ (*(pDevice->interface))->setRemovalCallback(pDevice->interface, HIDRemovalCallback, pDevice, pDevice); - - /* now connect notification for new devices */ - pDevice->notificationPort = IONotificationPortCreate(kIOMasterPortDefault); - - CFRunLoopAddSource(CFRunLoopGetCurrent(), - IONotificationPortGetRunLoopSource(pDevice->notificationPort), - kCFRunLoopDefaultMode); - - // Register for notifications when a serial port is added to the system - result = IOServiceAddInterestNotification(pDevice->notificationPort, - hidDevice, - kIOGeneralInterest, - JoystickDeviceWasRemovedCallback, - pDevice, - &pDevice->portIterator); - if (kIOReturnSuccess != result) { - HIDReportErrorNum - ("Failed to register for removal callback.", result); - } - } + + /* now connect notification for new devices */ + pDevice->notificationPort = IONotificationPortCreate(kIOMasterPortDefault); + + CFRunLoopAddSource(CFRunLoopGetCurrent(), + IONotificationPortGetRunLoopSource(pDevice->notificationPort), + kCFRunLoopDefaultMode); + + /* Register for notifications when a serial port is added to the system */ + result = IOServiceAddInterestNotification(pDevice->notificationPort, + hidDevice, + kIOGeneralInterest, + JoystickDeviceWasRemovedCallback, + pDevice, + &pDevice->portIterator); + if (kIOReturnSuccess != result) { + HIDReportErrorNum + ("Failed to register for removal callback.", result); + } + } } return result; @@ -243,12 +243,12 @@ HIDCloseReleaseInterface(recDevice * pDevice) HIDReportErrorNum("Failed to release IOHIDDeviceInterface.", result); pDevice->interface = NULL; - - if ( pDevice->portIterator ) - { - IOObjectRelease( pDevice->portIterator ); - pDevice->portIterator = 0; - } + + if ( pDevice->portIterator ) + { + IOObjectRelease( pDevice->portIterator ); + pDevice->portIterator = 0; + } } return result; } @@ -272,32 +272,32 @@ HIDGetElementInfo(CFTypeRef refElement, recElement * pElement) if (refType && CFNumberGetValue(refType, kCFNumberLongType, &number)) pElement->maxReport = pElement->max = number; /* - TODO: maybe should handle the following stuff somehow? - - refType = CFDictionaryGetValue (refElement, CFSTR(kIOHIDElementScaledMinKey)); - if (refType && CFNumberGetValue (refType, kCFNumberLongType, &number)) - pElement->scaledMin = number; - refType = CFDictionaryGetValue (refElement, CFSTR(kIOHIDElementScaledMaxKey)); - if (refType && CFNumberGetValue (refType, kCFNumberLongType, &number)) - pElement->scaledMax = number; - refType = CFDictionaryGetValue (refElement, CFSTR(kIOHIDElementSizeKey)); - if (refType && CFNumberGetValue (refType, kCFNumberLongType, &number)) - pElement->size = number; - refType = CFDictionaryGetValue (refElement, CFSTR(kIOHIDElementIsRelativeKey)); - if (refType) - pElement->relative = CFBooleanGetValue (refType); - refType = CFDictionaryGetValue (refElement, CFSTR(kIOHIDElementIsWrappingKey)); - if (refType) - pElement->wrapping = CFBooleanGetValue (refType); - refType = CFDictionaryGetValue (refElement, CFSTR(kIOHIDElementIsNonLinearKey)); - if (refType) - pElement->nonLinear = CFBooleanGetValue (refType); - refType = CFDictionaryGetValue (refElement, CFSTR(kIOHIDElementHasPreferedStateKey)); - if (refType) - pElement->preferredState = CFBooleanGetValue (refType); - refType = CFDictionaryGetValue (refElement, CFSTR(kIOHIDElementHasNullStateKey)); - if (refType) - pElement->nullState = CFBooleanGetValue (refType); + TODO: maybe should handle the following stuff somehow? + + refType = CFDictionaryGetValue (refElement, CFSTR(kIOHIDElementScaledMinKey)); + if (refType && CFNumberGetValue (refType, kCFNumberLongType, &number)) + pElement->scaledMin = number; + refType = CFDictionaryGetValue (refElement, CFSTR(kIOHIDElementScaledMaxKey)); + if (refType && CFNumberGetValue (refType, kCFNumberLongType, &number)) + pElement->scaledMax = number; + refType = CFDictionaryGetValue (refElement, CFSTR(kIOHIDElementSizeKey)); + if (refType && CFNumberGetValue (refType, kCFNumberLongType, &number)) + pElement->size = number; + refType = CFDictionaryGetValue (refElement, CFSTR(kIOHIDElementIsRelativeKey)); + if (refType) + pElement->relative = CFBooleanGetValue (refType); + refType = CFDictionaryGetValue (refElement, CFSTR(kIOHIDElementIsWrappingKey)); + if (refType) + pElement->wrapping = CFBooleanGetValue (refType); + refType = CFDictionaryGetValue (refElement, CFSTR(kIOHIDElementIsNonLinearKey)); + if (refType) + pElement->nonLinear = CFBooleanGetValue (refType); + refType = CFDictionaryGetValue (refElement, CFSTR(kIOHIDElementHasPreferedStateKey)); + if (refType) + pElement->preferredState = CFBooleanGetValue (refType); + refType = CFDictionaryGetValue (refElement, CFSTR(kIOHIDElementHasNullStateKey)); + if (refType) + pElement->nullState = CFBooleanGetValue (refType); */ } @@ -501,14 +501,14 @@ HIDGetDeviceInfo(io_object_t hidDevice, CFMutableDictionaryRef hidProperties, } } - refCF = CFDictionaryGetValue(hidProperties, CFSTR(kIOHIDVendorIDKey)); + refCF = CFDictionaryGetValue(hidProperties, CFSTR(kIOHIDVendorIDKey)); if (refCF) { if (!CFNumberGetValue(refCF, kCFNumberLongType, &pDevice->guid.data[0])) { SDL_SetError("CFNumberGetValue error retrieving pDevice->guid[0]"); } } - refCF = CFDictionaryGetValue(hidProperties, CFSTR(kIOHIDProductIDKey)); + refCF = CFDictionaryGetValue(hidProperties, CFSTR(kIOHIDProductIDKey)); if (refCF) { if (!CFNumberGetValue(refCF, kCFNumberLongType, &pDevice->guid.data[8])) { SDL_SetError("CFNumberGetValue error retrieving pDevice->guid[8]"); @@ -573,7 +573,7 @@ HIDBuildDevice(io_object_t hidDevice) if (kIOReturnSuccess == result) { HIDGetDeviceInfo(hidDevice, hidProperties, pDevice); /* hidDevice used to find parents in registry tree */ HIDGetCollectionElements(hidProperties, pDevice); - pDevice->instance_id = ++s_joystick_instance_id; + pDevice->instance_id = ++s_joystick_instance_id; } else { DisposePtr((Ptr) pDevice); pDevice = NULL; @@ -640,57 +640,57 @@ HIDDisposeDevice(recDevice ** ppDevice) /* Given an io_object_t from OSX adds a joystick device to our list if appropriate */ -int +int AddDeviceHelper( io_object_t ioHIDDeviceObject ) { recDevice *device; - - /* build a device record */ - device = HIDBuildDevice(ioHIDDeviceObject); - if (!device) - return 0; - - /* Filter device list to non-keyboard/mouse stuff */ - if ((device->usagePage != kHIDPage_GenericDesktop) || - ((device->usage != kHIDUsage_GD_Joystick && - device->usage != kHIDUsage_GD_GamePad && - device->usage != kHIDUsage_GD_MultiAxisController))) { - - /* release memory for the device */ - HIDDisposeDevice(&device); - DisposePtr((Ptr) device); - return 0; - } - - /* We have to do some storage of the io_service_t for - * SDL_HapticOpenFromJoystick */ - if (FFIsForceFeedback(ioHIDDeviceObject) == FF_OK) { - device->ffservice = ioHIDDeviceObject; - } else { - device->ffservice = 0; - } - - device->send_open_event = 1; - s_bDeviceAdded = SDL_TRUE; - - /* Add device to the end of the list */ - if ( !gpDeviceList ) - { - gpDeviceList = device; - } - else - { - recDevice *curdevice; - - curdevice = gpDeviceList; - while ( curdevice->pNext ) - { - curdevice = curdevice->pNext; - } - curdevice->pNext = device; - } - - return 1; + + /* build a device record */ + device = HIDBuildDevice(ioHIDDeviceObject); + if (!device) + return 0; + + /* Filter device list to non-keyboard/mouse stuff */ + if ((device->usagePage != kHIDPage_GenericDesktop) || + ((device->usage != kHIDUsage_GD_Joystick && + device->usage != kHIDUsage_GD_GamePad && + device->usage != kHIDUsage_GD_MultiAxisController))) { + + /* release memory for the device */ + HIDDisposeDevice(&device); + DisposePtr((Ptr) device); + return 0; + } + + /* We have to do some storage of the io_service_t for + * SDL_HapticOpenFromJoystick */ + if (FFIsForceFeedback(ioHIDDeviceObject) == FF_OK) { + device->ffservice = ioHIDDeviceObject; + } else { + device->ffservice = 0; + } + + device->send_open_event = 1; + s_bDeviceAdded = SDL_TRUE; + + /* Add device to the end of the list */ + if ( !gpDeviceList ) + { + gpDeviceList = device; + } + else + { + recDevice *curdevice; + + curdevice = gpDeviceList; + while ( curdevice->pNext ) + { + curdevice = curdevice->pNext; + } + curdevice->pNext = device; + } + + return 1; } @@ -700,16 +700,16 @@ AddDeviceHelper( io_object_t ioHIDDeviceObject ) void JoystickDeviceWasAddedCallback( void *refcon, io_iterator_t iterator ) { io_object_t ioHIDDeviceObject = 0; - - while ( ( ioHIDDeviceObject = IOIteratorNext(iterator) ) ) - { - if ( ioHIDDeviceObject ) - { - AddDeviceHelper( ioHIDDeviceObject ); - } - } + + while ( ( ioHIDDeviceObject = IOIteratorNext(iterator) ) ) + { + if ( ioHIDDeviceObject ) + { + AddDeviceHelper( ioHIDDeviceObject ); + } + } } - + /* Function to scan the system for joysticks. * Joystick 0 should be the system default joystick. @@ -724,7 +724,7 @@ SDL_SYS_JoystickInit(void) io_iterator_t hidObjectIterator = 0; CFMutableDictionaryRef hidMatchDictionary = NULL; io_object_t ioHIDDeviceObject = 0; - io_iterator_t portIterator = 0; + io_iterator_t portIterator = 0; if (gpDeviceList) { return SDL_SetError("Joystick: Device list already inited."); @@ -774,26 +774,26 @@ SDL_SYS_JoystickInit(void) gpDeviceList = NULL; while ((ioHIDDeviceObject = IOIteratorNext(hidObjectIterator))) { - AddDeviceHelper( ioHIDDeviceObject ); + AddDeviceHelper( ioHIDDeviceObject ); } result = IOObjectRelease(hidObjectIterator); /* release the iterator */ - - /* now connect notification for new devices */ - notificationPort = IONotificationPortCreate(masterPort); - hidMatchDictionary = IOServiceMatching(kIOHIDDeviceKey); - - CFRunLoopAddSource(CFRunLoopGetCurrent(), - IONotificationPortGetRunLoopSource(notificationPort), - kCFRunLoopDefaultMode); - - // Register for notifications when a serial port is added to the system - result = IOServiceAddMatchingNotification(notificationPort, - kIOFirstMatchNotification, - hidMatchDictionary, - JoystickDeviceWasAddedCallback, - NULL, - &portIterator); - while (IOIteratorNext(portIterator)) {}; // Run out the iterator or notifications won't start (you can also use it to iterate the available devices). + + /* now connect notification for new devices */ + notificationPort = IONotificationPortCreate(masterPort); + hidMatchDictionary = IOServiceMatching(kIOHIDDeviceKey); + + CFRunLoopAddSource(CFRunLoopGetCurrent(), + IONotificationPortGetRunLoopSource(notificationPort), + kCFRunLoopDefaultMode); + + /* Register for notifications when a serial port is added to the system */ + result = IOServiceAddMatchingNotification(notificationPort, + kIOFirstMatchNotification, + hidMatchDictionary, + JoystickDeviceWasAddedCallback, + NULL, + &portIterator); + while (IOIteratorNext(portIterator)) {}; /* Run out the iterator or notifications won't start (you can also use it to iterate the available devices). */ return SDL_SYS_NumJoysticks(); } @@ -802,17 +802,17 @@ SDL_SYS_JoystickInit(void) int SDL_SYS_NumJoysticks() { - recDevice *device = gpDeviceList; + recDevice *device = gpDeviceList; int nJoySticks = 0; - - while ( device ) - { - if ( !device->removed ) - nJoySticks++; + + while ( device ) + { + if ( !device->removed ) + nJoySticks++; device = device->pNext; - } + } - return nJoySticks; + return nJoySticks; } /* Function to cause any queued joystick insertions to be processed @@ -820,81 +820,81 @@ SDL_SYS_NumJoysticks() void SDL_SYS_JoystickDetect() { - if ( s_bDeviceAdded || s_bDeviceRemoved ) - { - recDevice *device = gpDeviceList; - s_bDeviceAdded = SDL_FALSE; - s_bDeviceRemoved = SDL_FALSE; - int device_index = 0; - // send notifications - while ( device ) - { - if ( device->send_open_event ) - { - device->send_open_event = 0; + if ( s_bDeviceAdded || s_bDeviceRemoved ) + { + recDevice *device = gpDeviceList; + s_bDeviceAdded = SDL_FALSE; + s_bDeviceRemoved = SDL_FALSE; + int device_index = 0; + /* send notifications */ + while ( device ) + { + if ( device->send_open_event ) + { + device->send_open_event = 0; #if !SDL_EVENTS_DISABLED - SDL_Event event; - event.type = SDL_JOYDEVICEADDED; - - if (SDL_GetEventState(event.type) == SDL_ENABLE) { - event.jdevice.which = device_index; - if ((SDL_EventOK == NULL) - || (*SDL_EventOK) (SDL_EventOKParam, &event)) { - SDL_PushEvent(&event); - } - } + SDL_Event event; + event.type = SDL_JOYDEVICEADDED; + + if (SDL_GetEventState(event.type) == SDL_ENABLE) { + event.jdevice.which = device_index; + if ((SDL_EventOK == NULL) + || (*SDL_EventOK) (SDL_EventOKParam, &event)) { + SDL_PushEvent(&event); + } + } #endif /* !SDL_EVENTS_DISABLED */ - - } - - if ( device->removed ) - { - recDevice *removeDevice = device; - if ( gpDeviceList == removeDevice ) - { - device = device->pNext; - gpDeviceList = device; - } - else - { - device = gpDeviceList; - while ( device->pNext != removeDevice ) - { - device = device->pNext; - } - - device->pNext = removeDevice->pNext; - } - + + } + + if ( device->removed ) + { + recDevice *removeDevice = device; + if ( gpDeviceList == removeDevice ) + { + device = device->pNext; + gpDeviceList = device; + } + else + { + device = gpDeviceList; + while ( device->pNext != removeDevice ) + { + device = device->pNext; + } + + device->pNext = removeDevice->pNext; + } + #if !SDL_EVENTS_DISABLED - SDL_Event event; - event.type = SDL_JOYDEVICEREMOVED; - - if (SDL_GetEventState(event.type) == SDL_ENABLE) { - event.jdevice.which = removeDevice->instance_id; - if ((SDL_EventOK == NULL) - || (*SDL_EventOK) (SDL_EventOKParam, &event)) { - SDL_PushEvent(&event); - } - } - - DisposePtr((Ptr) removeDevice); -#endif /* !SDL_EVENTS_DISABLED */ - - } - else - { - device = device->pNext; - device_index++; - } - } - } + SDL_Event event; + event.type = SDL_JOYDEVICEREMOVED; + + if (SDL_GetEventState(event.type) == SDL_ENABLE) { + event.jdevice.which = removeDevice->instance_id; + if ((SDL_EventOK == NULL) + || (*SDL_EventOK) (SDL_EventOKParam, &event)) { + SDL_PushEvent(&event); + } + } + + DisposePtr((Ptr) removeDevice); +#endif /* !SDL_EVENTS_DISABLED */ + + } + else + { + device = device->pNext; + device_index++; + } + } + } } SDL_bool SDL_SYS_JoystickNeedsPolling() { - return s_bDeviceAdded || s_bDeviceRemoved; + return s_bDeviceAdded || s_bDeviceRemoved; } /* Function to get the device-dependent name of a joystick */ @@ -906,7 +906,7 @@ SDL_SYS_JoystickNameForDeviceIndex(int device_index) for (; device_index > 0; device_index--) device = device->pNext; - return device->product; + return device->product; } /* Function to return the instance id of the joystick at device_index @@ -916,11 +916,11 @@ SDL_SYS_GetInstanceIdOfDeviceIndex(int device_index) { recDevice *device = gpDeviceList; int index; - + for (index = device_index; index > 0; index--) device = device->pNext; - return device->instance_id; + return device->instance_id; } /* Function to open a joystick for use. @@ -937,14 +937,14 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index) for (index = device_index; index > 0; index--) device = device->pNext; - joystick->instance_id = device->instance_id; + joystick->instance_id = device->instance_id; joystick->hwdata = device; - joystick->name = device->product; + joystick->name = device->product; - joystick->naxes = device->axes; - joystick->nhats = device->hats; - joystick->nballs = 0; - joystick->nbuttons = device->buttons; + joystick->naxes = device->axes; + joystick->nhats = device->hats; + joystick->nballs = 0; + joystick->nbuttons = device->buttons; return 0; } @@ -954,17 +954,17 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index) SDL_bool SDL_SYS_JoystickAttached(SDL_Joystick * joystick) { - recDevice *device = gpDeviceList; - - while ( device ) - { - if ( joystick->instance_id == device->instance_id ) - return SDL_TRUE; + recDevice *device = gpDeviceList; + + while ( device ) + { + if ( joystick->instance_id == device->instance_id ) + return SDL_TRUE; device = device->pNext; - } - - return SDL_FALSE; + } + + return SDL_FALSE; } /* Function to update the state of a joystick - called as a device poll. @@ -975,49 +975,49 @@ SDL_SYS_JoystickAttached(SDL_Joystick * joystick) void SDL_SYS_JoystickUpdate(SDL_Joystick * joystick) { - recDevice *device = joystick->hwdata; + recDevice *device = joystick->hwdata; recElement *element; SInt32 value, range; int i; - if ( !device ) - return; + if ( !device ) + return; if (device->removed) { /* device was unplugged; ignore it. */ - recDevice *devicelist = gpDeviceList; - joystick->closed = 1; - joystick->uncentered = 1; - - if ( devicelist == device ) - { - gpDeviceList = device->pNext; - } - else - { - while ( devicelist->pNext != device ) - { - devicelist = devicelist->pNext; - } - - devicelist->pNext = device->pNext; - } - - DisposePtr((Ptr) device); - joystick->hwdata = NULL; + recDevice *devicelist = gpDeviceList; + joystick->closed = 1; + joystick->uncentered = 1; + + if ( devicelist == device ) + { + gpDeviceList = device->pNext; + } + else + { + while ( devicelist->pNext != device ) + { + devicelist = devicelist->pNext; + } + + devicelist->pNext = device->pNext; + } + + DisposePtr((Ptr) device); + joystick->hwdata = NULL; #if !SDL_EVENTS_DISABLED - SDL_Event event; - event.type = SDL_JOYDEVICEREMOVED; - - if (SDL_GetEventState(event.type) == SDL_ENABLE) { - event.jdevice.which = joystick->instance_id; - if ((SDL_EventOK == NULL) - || (*SDL_EventOK) (SDL_EventOKParam, &event)) { - SDL_PushEvent(&event); - } - } + SDL_Event event; + event.type = SDL_JOYDEVICEREMOVED; + + if (SDL_GetEventState(event.type) == SDL_ENABLE) { + event.jdevice.which = joystick->instance_id; + if ((SDL_EventOK == NULL) + || (*SDL_EventOK) (SDL_EventOKParam, &event)) { + SDL_PushEvent(&event); + } + } #endif /* !SDL_EVENTS_DISABLED */ - + return; } @@ -1099,8 +1099,8 @@ SDL_SYS_JoystickUpdate(SDL_Joystick * joystick) /* Function to close a joystick after use */ void SDL_SYS_JoystickClose(SDL_Joystick * joystick) -{ - joystick->closed = 1; +{ + joystick->closed = 1; } /* Function to perform any system-specific joystick related cleanup */ @@ -1109,12 +1109,12 @@ SDL_SYS_JoystickQuit(void) { while (NULL != gpDeviceList) gpDeviceList = HIDDisposeDevice(&gpDeviceList); - - if ( notificationPort ) - { - IONotificationPortDestroy( notificationPort ); - notificationPort = 0; - } + + if ( notificationPort ) + { + IONotificationPortDestroy( notificationPort ); + notificationPort = 0; + } } @@ -1122,16 +1122,16 @@ SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID( int device_index ) { recDevice *device = gpDeviceList; int index; - + for (index = device_index; index > 0; index--) device = device->pNext; - - return device->guid; + + return device->guid; } SDL_JoystickGUID SDL_SYS_JoystickGetGUID(SDL_Joystick *joystick) { - return joystick->hwdata->guid; + return joystick->hwdata->guid; } #endif /* SDL_JOYSTICK_IOKIT */ diff --git a/src/joystick/darwin/SDL_sysjoystick_c.h b/src/joystick/darwin/SDL_sysjoystick_c.h index 21cf7e911..f99dbd8af 100644 --- a/src/joystick/darwin/SDL_sysjoystick_c.h +++ b/src/joystick/darwin/SDL_sysjoystick_c.h @@ -59,9 +59,9 @@ struct joystick_hwdata { io_service_t ffservice; /* Interface for force feedback, 0 = no ff */ IOHIDDeviceInterface **interface; /* interface to device, NULL = no interface */ - IONotificationPortRef notificationPort; /* port to be notified on joystick removal */ - io_iterator_t portIterator; /* iterator for removal callback */ - + IONotificationPortRef notificationPort; /* port to be notified on joystick removal */ + io_iterator_t portIterator; /* iterator for removal callback */ + char product[256]; /* name of product */ long usage; /* usage page from IOUSBHID Parser.h which defines general usage */ long usagePage; /* usage within above page from IOUSBHID Parser.h which defines specific usage */ @@ -77,10 +77,10 @@ struct joystick_hwdata int removed; int uncentered; - - int instance_id; - SDL_JoystickGUID guid; - Uint8 send_open_event; /* 1 if we need to send an Added event for this device */ + + int instance_id; + SDL_JoystickGUID guid; + Uint8 send_open_event; /* 1 if we need to send an Added event for this device */ struct joystick_hwdata *pNext; /* next device */ }; diff --git a/src/joystick/dummy/SDL_sysjoystick.c b/src/joystick/dummy/SDL_sysjoystick.c index 2f03e39c3..7dd9153b2 100644 --- a/src/joystick/dummy/SDL_sysjoystick.c +++ b/src/joystick/dummy/SDL_sysjoystick.c @@ -110,7 +110,7 @@ SDL_SYS_JoystickQuit(void) SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID( int device_index ) { SDL_JoystickGUID guid; - // the GUID is just the first 16 chars of the name for now + /* the GUID is just the first 16 chars of the name for now */ const char *name = SDL_SYS_JoystickNameForDeviceIndex( device_index ); SDL_zero( guid ); SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) ); @@ -121,7 +121,7 @@ SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID( int device_index ) SDL_JoystickGUID SDL_SYS_JoystickGetGUID(SDL_Joystick * joystick) { SDL_JoystickGUID guid; - // the GUID is just the first 16 chars of the name for now + /* the GUID is just the first 16 chars of the name for now */ const char *name = joystick->name; SDL_zero( guid ); SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) ); diff --git a/src/joystick/iphoneos/SDLUIAccelerationDelegate.m b/src/joystick/iphoneos/SDLUIAccelerationDelegate.m index 9865d364a..0037c585b 100644 --- a/src/joystick/iphoneos/SDLUIAccelerationDelegate.m +++ b/src/joystick/iphoneos/SDLUIAccelerationDelegate.m @@ -28,114 +28,114 @@ @implementation SDLUIAccelerationDelegate /* - Returns a shared instance of the SDLUIAccelerationDelegate, creating the shared delegate if it doesn't exist yet. + Returns a shared instance of the SDLUIAccelerationDelegate, creating the shared delegate if it doesn't exist yet. */ +(SDLUIAccelerationDelegate *)sharedDelegate { - if (sharedDelegate == nil) { - sharedDelegate = [[SDLUIAccelerationDelegate alloc] init]; - } - return sharedDelegate; + if (sharedDelegate == nil) { + sharedDelegate = [[SDLUIAccelerationDelegate alloc] init]; + } + return sharedDelegate; } /* - UIAccelerometerDelegate delegate method. Invoked by the UIAccelerometer instance when it has new data for us. - We just take the data and mark that we have new data available so that the joystick system will pump it to the - events system when SDL_SYS_JoystickUpdate is called. -*/ + UIAccelerometerDelegate delegate method. Invoked by the UIAccelerometer instance when it has new data for us. + We just take the data and mark that we have new data available so that the joystick system will pump it to the + events system when SDL_SYS_JoystickUpdate is called. +*/ -(void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration { - - x = acceleration.x; - y = acceleration.y; - z = acceleration.z; - - hasNewData = YES; + + x = acceleration.x; + y = acceleration.y; + z = acceleration.z; + + hasNewData = YES; } -/* - getLastOrientation -- put last obtained accelerometer data into Sint16 array - - Called from the joystick system when it needs the accelerometer data. - Function grabs the last data sent to the accelerometer and converts it - from floating point to Sint16, which is what the joystick system expects. - - To do the conversion, the data is first clamped onto the interval - [-SDL_IPHONE_MAX_G_FORCE, SDL_IPHONE_MAX_G_FORCE], then the data is multiplied - by MAX_SINT16 so that it is mapped to the full range of an Sint16. - - You can customize the clamped range of this function by modifying the - SDL_IPHONE_MAX_GFORCE macro in SDL_config_iphoneos.h. - - Once converted to Sint16, the accelerometer data no longer has coherent units. - You can convert the data back to units of g-force by multiplying it - in your application's code by SDL_IPHONE_MAX_GFORCE / 0x7FFF. +/* + getLastOrientation -- put last obtained accelerometer data into Sint16 array + + Called from the joystick system when it needs the accelerometer data. + Function grabs the last data sent to the accelerometer and converts it + from floating point to Sint16, which is what the joystick system expects. + + To do the conversion, the data is first clamped onto the interval + [-SDL_IPHONE_MAX_G_FORCE, SDL_IPHONE_MAX_G_FORCE], then the data is multiplied + by MAX_SINT16 so that it is mapped to the full range of an Sint16. + + You can customize the clamped range of this function by modifying the + SDL_IPHONE_MAX_GFORCE macro in SDL_config_iphoneos.h. + + Once converted to Sint16, the accelerometer data no longer has coherent units. + You can convert the data back to units of g-force by multiplying it + in your application's code by SDL_IPHONE_MAX_GFORCE / 0x7FFF. */ -(void)getLastOrientation:(Sint16 *)data { - #define MAX_SINT16 0x7FFF - - /* clamp the data */ - if (x > SDL_IPHONE_MAX_GFORCE) x = SDL_IPHONE_MAX_GFORCE; - else if (x < -SDL_IPHONE_MAX_GFORCE) x = -SDL_IPHONE_MAX_GFORCE; - if (y > SDL_IPHONE_MAX_GFORCE) y = SDL_IPHONE_MAX_GFORCE; - else if (y < -SDL_IPHONE_MAX_GFORCE) y = -SDL_IPHONE_MAX_GFORCE; - if (z > SDL_IPHONE_MAX_GFORCE) z = SDL_IPHONE_MAX_GFORCE; - else if (z < -SDL_IPHONE_MAX_GFORCE) z = -SDL_IPHONE_MAX_GFORCE; - - /* pass in data mapped to range of SInt16 */ - data[0] = (x / SDL_IPHONE_MAX_GFORCE) * MAX_SINT16; - data[1] = (y / SDL_IPHONE_MAX_GFORCE) * MAX_SINT16; - data[2] = (z / SDL_IPHONE_MAX_GFORCE) * MAX_SINT16; + #define MAX_SINT16 0x7FFF + + /* clamp the data */ + if (x > SDL_IPHONE_MAX_GFORCE) x = SDL_IPHONE_MAX_GFORCE; + else if (x < -SDL_IPHONE_MAX_GFORCE) x = -SDL_IPHONE_MAX_GFORCE; + if (y > SDL_IPHONE_MAX_GFORCE) y = SDL_IPHONE_MAX_GFORCE; + else if (y < -SDL_IPHONE_MAX_GFORCE) y = -SDL_IPHONE_MAX_GFORCE; + if (z > SDL_IPHONE_MAX_GFORCE) z = SDL_IPHONE_MAX_GFORCE; + else if (z < -SDL_IPHONE_MAX_GFORCE) z = -SDL_IPHONE_MAX_GFORCE; + + /* pass in data mapped to range of SInt16 */ + data[0] = (x / SDL_IPHONE_MAX_GFORCE) * MAX_SINT16; + data[1] = (y / SDL_IPHONE_MAX_GFORCE) * MAX_SINT16; + data[2] = (z / SDL_IPHONE_MAX_GFORCE) * MAX_SINT16; } /* - Initialize SDLUIAccelerationDelegate. Since we don't have any data yet, - just set our last received data to zero, and indicate we don't have any; + Initialize SDLUIAccelerationDelegate. Since we don't have any data yet, + just set our last received data to zero, and indicate we don't have any; */ -(id)init { - self = [super init]; - x = y = z = 0.0; - hasNewData = NO; - return self; + self = [super init]; + x = y = z = 0.0; + hasNewData = NO; + return self; } -(void)dealloc { - sharedDelegate = nil; - [self shutdown]; - [super dealloc]; + sharedDelegate = nil; + [self shutdown]; + [super dealloc]; } /* - Lets our delegate start receiving accelerometer updates. + Lets our delegate start receiving accelerometer updates. */ -(void)startup { - [UIAccelerometer sharedAccelerometer].delegate = self; - isRunning = YES; + [UIAccelerometer sharedAccelerometer].delegate = self; + isRunning = YES; } /* - Stops our delegate from receiving accelerometer updates. + Stops our delegate from receiving accelerometer updates. */ -(void)shutdown { - if ([UIAccelerometer sharedAccelerometer].delegate == self) { - [UIAccelerometer sharedAccelerometer].delegate = nil; - } - isRunning = NO; + if ([UIAccelerometer sharedAccelerometer].delegate == self) { + [UIAccelerometer sharedAccelerometer].delegate = nil; + } + isRunning = NO; } /* - Our we currently receiving accelerometer updates? + Our we currently receiving accelerometer updates? */ -(BOOL)isRunning { - return isRunning; + return isRunning; } /* - Do we have any data that hasn't been pumped into SDL's event system? + Do we have any data that hasn't been pumped into SDL's event system? */ -(BOOL)hasNewData { - return hasNewData; + return hasNewData; } /* - When the joystick system grabs the new data, it sets this to NO. + When the joystick system grabs the new data, it sets this to NO. */ -(void)setHasNewData:(BOOL)value { - hasNewData = value; + hasNewData = value; } @end diff --git a/src/joystick/iphoneos/SDL_sysjoystick.m b/src/joystick/iphoneos/SDL_sysjoystick.m index e93002576..231c851cf 100644 --- a/src/joystick/iphoneos/SDL_sysjoystick.m +++ b/src/joystick/iphoneos/SDL_sysjoystick.m @@ -97,20 +97,20 @@ SDL_bool SDL_SYS_JoystickAttached(SDL_Joystick *joystick) void SDL_SYS_JoystickUpdate(SDL_Joystick * joystick) { - - Sint16 orientation[3]; - - if ([[SDLUIAccelerationDelegate sharedDelegate] hasNewData]) { - - [[SDLUIAccelerationDelegate sharedDelegate] getLastOrientation: orientation]; - [[SDLUIAccelerationDelegate sharedDelegate] setHasNewData: NO]; - - SDL_PrivateJoystickAxis(joystick, 0, orientation[0]); - SDL_PrivateJoystickAxis(joystick, 1, orientation[1]); - SDL_PrivateJoystickAxis(joystick, 2, orientation[2]); - - } - + + Sint16 orientation[3]; + + if ([[SDLUIAccelerationDelegate sharedDelegate] hasNewData]) { + + [[SDLUIAccelerationDelegate sharedDelegate] getLastOrientation: orientation]; + [[SDLUIAccelerationDelegate sharedDelegate] setHasNewData: NO]; + + SDL_PrivateJoystickAxis(joystick, 0, orientation[0]); + SDL_PrivateJoystickAxis(joystick, 1, orientation[1]); + SDL_PrivateJoystickAxis(joystick, 2, orientation[2]); + + } + return; } @@ -118,10 +118,10 @@ SDL_bool SDL_SYS_JoystickAttached(SDL_Joystick *joystick) void SDL_SYS_JoystickClose(SDL_Joystick * joystick) { - if ([[SDLUIAccelerationDelegate sharedDelegate] isRunning]) { - [[SDLUIAccelerationDelegate sharedDelegate] shutdown]; - } - SDL_SetError("No joystick open with that index"); + if ([[SDLUIAccelerationDelegate sharedDelegate] isRunning]) { + [[SDLUIAccelerationDelegate sharedDelegate] shutdown]; + } + SDL_SetError("No joystick open with that index"); } /* Function to perform any system-specific joystick related cleanup */ @@ -133,7 +133,7 @@ SDL_bool SDL_SYS_JoystickAttached(SDL_Joystick *joystick) SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID( int device_index ) { SDL_JoystickGUID guid; - // the GUID is just the first 16 chars of the name for now + /* the GUID is just the first 16 chars of the name for now */ const char *name = SDL_SYS_JoystickNameForDeviceIndex( device_index ); SDL_zero( guid ); SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) ); @@ -143,7 +143,7 @@ SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID( int device_index ) SDL_JoystickGUID SDL_SYS_JoystickGetGUID(SDL_Joystick * joystick) { SDL_JoystickGUID guid; - // the GUID is just the first 16 chars of the name for now + /* the GUID is just the first 16 chars of the name for now */ const char *name = joystick->name; SDL_zero( guid ); SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) ); diff --git a/src/joystick/linux/SDL_sysjoystick.c b/src/joystick/linux/SDL_sysjoystick.c index 23915b45a..8582838a7 100644 --- a/src/joystick/linux/SDL_sysjoystick.c +++ b/src/joystick/linux/SDL_sysjoystick.c @@ -510,7 +510,7 @@ void SDL_SYS_JoystickDetect() SDL_PushEvent(&event); } } - #endif // !SDL_EVENTS_DISABLED + #endif /* !SDL_EVENTS_DISABLED */ } } else if (SDL_strcmp(action, "remove") == 0) { const int inst = MaybeRemoveDevice(devnode); @@ -527,7 +527,7 @@ void SDL_SYS_JoystickDetect() SDL_PushEvent(&event); } } - #endif // !SDL_EVENTS_DISABLED + #endif /* !SDL_EVENTS_DISABLED */ } } UDEV_udev_device_unref(dev); @@ -760,7 +760,7 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index) /* Get the number of buttons and axes on the joystick */ ConfigJoystick(joystick, fd); - // mark joystick as fresh and ready + /* mark joystick as fresh and ready */ joystick->hwdata->fresh = 1; return (0); @@ -840,7 +840,7 @@ PollAllValues(SDL_Joystick * joystick) struct input_absinfo absinfo; int a, b = 0; - // Poll all axis + /* Poll all axis */ for (a = ABS_X; b < ABS_MAX; a++) { switch (a) { case ABS_HAT0X: @@ -851,7 +851,7 @@ PollAllValues(SDL_Joystick * joystick) case ABS_HAT2Y: case ABS_HAT3X: case ABS_HAT3Y: - // ingore hats + /* ingore hats */ break; default: if (joystick->hwdata->abs_correct[b].used) { diff --git a/src/joystick/psp/SDL_sysjoystick.c b/src/joystick/psp/SDL_sysjoystick.c index a2c51a285..d6ca6989e 100644 --- a/src/joystick/psp/SDL_sysjoystick.c +++ b/src/joystick/psp/SDL_sysjoystick.c @@ -23,7 +23,7 @@ #include #include -#include /* For the definition of NULL */ +#include /* For the definition of NULL */ #include #include "../SDL_sysjoystick.h" @@ -41,10 +41,10 @@ static SDL_sem *pad_sem = NULL; static SDL_Thread *thread = NULL; static int running = 0; static const enum PspCtrlButtons button_map[] = { - PSP_CTRL_TRIANGLE, PSP_CTRL_CIRCLE, PSP_CTRL_CROSS, PSP_CTRL_SQUARE, - PSP_CTRL_LTRIGGER, PSP_CTRL_RTRIGGER, - PSP_CTRL_DOWN, PSP_CTRL_LEFT, PSP_CTRL_UP, PSP_CTRL_RIGHT, - PSP_CTRL_SELECT, PSP_CTRL_START, PSP_CTRL_HOME, PSP_CTRL_HOLD }; + PSP_CTRL_TRIANGLE, PSP_CTRL_CIRCLE, PSP_CTRL_CROSS, PSP_CTRL_SQUARE, + PSP_CTRL_LTRIGGER, PSP_CTRL_RTRIGGER, + PSP_CTRL_DOWN, PSP_CTRL_LEFT, PSP_CTRL_UP, PSP_CTRL_RIGHT, + PSP_CTRL_SELECT, PSP_CTRL_START, PSP_CTRL_HOME, PSP_CTRL_HOLD }; static int analog_map[256]; /* Map analog inputs to -32768 -> 32767 */ typedef struct @@ -53,30 +53,30 @@ typedef struct int y; } point; -// 4 points define the bezier-curve. +/* 4 points define the bezier-curve. */ static point a = { 0, 0 }; static point b = { 50, 0 }; static point c = { 78, 32767 }; static point d = { 128, 32767 }; -// simple linear interpolation between two points +/* simple linear interpolation between two points */ static __inline__ void lerp (point *dest, point *a, point *b, float t) { - dest->x = a->x + (b->x - a->x)*t; - dest->y = a->y + (b->y - a->y)*t; + dest->x = a->x + (b->x - a->x)*t; + dest->y = a->y + (b->y - a->y)*t; } -// evaluate a point on a bezier-curve. t goes from 0 to 1.0 +/* evaluate a point on a bezier-curve. t goes from 0 to 1.0 */ static int calc_bezier_y(float t) { - point ab, bc, cd, abbc, bccd, dest; - lerp (&ab, &a, &b, t); // point between a and b - lerp (&bc, &b, &c, t); // point between b and c - lerp (&cd, &c, &d, t); // point between c and d - lerp (&abbc, &ab, &bc, t); // point between ab and bc - lerp (&bccd, &bc, &cd, t); // point between bc and cd - lerp (&dest, &abbc, &bccd, t); // point on the bezier-curve - return dest.y; + point ab, bc, cd, abbc, bccd, dest; + lerp (&ab, &a, &b, t); /* point between a and b */ + lerp (&bc, &b, &c, t); /* point between b and c */ + lerp (&cd, &c, &d, t); /* point between c and d */ + lerp (&abbc, &ab, &bc, t); /* point between ab and bc */ + lerp (&bccd, &bc, &cd, t); /* point between bc and cd */ + lerp (&dest, &abbc, &bccd, t); /* point on the bezier-curve */ + return dest.y; } /* @@ -84,14 +84,14 @@ static int calc_bezier_y(float t) */ int JoystickUpdate(void *data) { - while (running) { - SDL_SemWait(pad_sem); - sceCtrlPeekBufferPositive(&pad, 1); - SDL_SemPost(pad_sem); - /* Delay 1/60th of a second */ - sceKernelDelayThread(1000000 / 60); - } - return 0; + while (running) { + SDL_SemWait(pad_sem); + sceCtrlPeekBufferPositive(&pad, 1); + SDL_SemPost(pad_sem); + /* Delay 1/60th of a second */ + sceKernelDelayThread(1000000 / 60); + } + return 0; } @@ -103,33 +103,33 @@ int JoystickUpdate(void *data) */ int SDL_SYS_JoystickInit(void) { - int i; - -// SDL_numjoysticks = 1; - - /* Setup input */ - sceCtrlSetSamplingCycle(0); - sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG); - - /* Start thread to read data */ - if((pad_sem = SDL_CreateSemaphore(1)) == NULL) { - return SDL_SetError("Can't create input semaphore"); - } - running = 1; - if((thread = SDL_CreateThread(JoystickUpdate, "JoySitckThread",NULL)) == NULL) { - return SDL_SetError("Can't create input thread"); - } - - /* Create an accurate map from analog inputs (0 to 255) - to SDL joystick positions (-32768 to 32767) */ - for (i = 0; i < 128; i++) - { - float t = (float)i/127.0f; - analog_map[i+128] = calc_bezier_y(t); - analog_map[127-i] = -1 * analog_map[i+128]; - } - - return 1; + int i; + +/* SDL_numjoysticks = 1; */ + + /* Setup input */ + sceCtrlSetSamplingCycle(0); + sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG); + + /* Start thread to read data */ + if((pad_sem = SDL_CreateSemaphore(1)) == NULL) { + return SDL_SetError("Can't create input semaphore"); + } + running = 1; + if((thread = SDL_CreateThread(JoystickUpdate, "JoySitckThread",NULL)) == NULL) { + return SDL_SetError("Can't create input thread"); + } + + /* Create an accurate map from analog inputs (0 to 255) + to SDL joystick positions (-32768 to 32767) */ + for (i = 0; i < 128; i++) + { + float t = (float)i/127.0f; + analog_map[i+128] = calc_bezier_y(t); + analog_map[127-i] = -1 * analog_map[i+128]; + } + + return 1; } int SDL_SYS_NumJoysticks() @@ -161,11 +161,11 @@ SDL_JoystickID SDL_SYS_GetInstanceIdOfDeviceIndex(int device_index) /* Function to get the device-dependent name of a joystick */ const char *SDL_SYS_JoystickName(int index) { - if (index == 0) - return "PSP controller"; + if (index == 0) + return "PSP controller"; - SDL_SetError("No joystick available with that index"); - return(NULL); + SDL_SetError("No joystick available with that index"); + return(NULL); } /* Function to open a joystick for use. @@ -175,11 +175,11 @@ const char *SDL_SYS_JoystickName(int index) */ int SDL_SYS_JoystickOpen(SDL_Joystick *joystick, int device_index) { - joystick->nbuttons = 14; - joystick->naxes = 2; - joystick->nhats = 0; + joystick->nbuttons = 14; + joystick->naxes = 2; + joystick->nhats = 0; - return 0; + return 0; } /* Function to determine is this joystick is attached to the system right now */ @@ -195,65 +195,65 @@ SDL_bool SDL_SYS_JoystickAttached(SDL_Joystick *joystick) void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick) { - int i; - enum PspCtrlButtons buttons; - enum PspCtrlButtons changed; - unsigned char x, y; - static enum PspCtrlButtons old_buttons = 0; - static unsigned char old_x = 0, old_y = 0; - - SDL_SemWait(pad_sem); - buttons = pad.Buttons; - x = pad.Lx; - y = pad.Ly; - SDL_SemPost(pad_sem); - - /* Axes */ - if(old_x != x) { - SDL_PrivateJoystickAxis(joystick, 0, analog_map[x]); - old_x = x; - } - if(old_y != y) { - SDL_PrivateJoystickAxis(joystick, 1, analog_map[y]); - old_y = y; - } - - /* Buttons */ - changed = old_buttons ^ buttons; - old_buttons = buttons; - if(changed) { - for(i=0; iname; SDL_zero( guid ); SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) ); diff --git a/src/joystick/windows/SDL_dxjoystick.c b/src/joystick/windows/SDL_dxjoystick.c index b61022004..9e86e2f0e 100644 --- a/src/joystick/windows/SDL_dxjoystick.c +++ b/src/joystick/windows/SDL_dxjoystick.c @@ -23,10 +23,10 @@ #ifdef SDL_JOYSTICK_DINPUT /* DirectInput joystick driver; written by Glenn Maynard, based on Andrei de - * A. Formiga's WINMM driver. + * A. Formiga's WINMM driver. * * Hats and sliders are completely untested; the app I'm writing this for mostly - * doesn't use them and I don't own any joysticks with them. + * doesn't use them and I don't own any joysticks with them. * * We don't bother to use event notification here. It doesn't seem to work * with polled devices, and it's fine to call IDirectInputDevice8_GetDeviceData and @@ -49,15 +49,15 @@ #endif #ifndef DIDFT_OPTIONAL -#define DIDFT_OPTIONAL 0x80000000 +#define DIDFT_OPTIONAL 0x80000000 #endif -#define INPUT_QSIZE 32 /* Buffer up to 32 input messages */ +#define INPUT_QSIZE 32 /* Buffer up to 32 input messages */ #define MAX_JOYSTICKS 8 -#define AXIS_MIN -32768 /* minimum value for axis coordinate */ -#define AXIS_MAX 32767 /* maximum value for axis coordinate */ -#define JOY_AXIS_THRESHOLD (((AXIS_MAX)-(AXIS_MIN))/100) /* 1% motion */ +#define AXIS_MIN -32768 /* minimum value for axis coordinate */ +#define AXIS_MAX 32767 /* maximum value for axis coordinate */ +#define JOY_AXIS_THRESHOLD (((AXIS_MAX)-(AXIS_MIN))/100) /* 1% motion */ /* external variables referenced. */ extern HWND SDL_HelperWindow; @@ -96,10 +96,10 @@ WIN_LoadXInputDLL(void) } version = (1 << 16) | 4; - s_pXInputDLL = LoadLibrary( L"XInput1_4.dll" ); // 1.4 Ships with Windows 8. + s_pXInputDLL = LoadLibrary( L"XInput1_4.dll" ); /* 1.4 Ships with Windows 8. */ if (!s_pXInputDLL) { version = (1 << 16) | 3; - s_pXInputDLL = LoadLibrary( L"XInput1_3.dll" ); // 1.3 Ships with Vista and Win7, can be installed as a redistributable component. + s_pXInputDLL = LoadLibrary( L"XInput1_3.dll" ); /* 1.3 Ships with Vista and Win7, can be installed as a redistributable component. */ } if (!s_pXInputDLL) { s_pXInputDLL = LoadLibrary( L"bin\\XInput1_3.dll" ); @@ -144,14 +144,14 @@ extern HRESULT(WINAPI * DInputCreate) (HINSTANCE hinst, DWORD dwVersion, LPUNKNOWN punkOuter); struct JoyStick_DeviceData_ { - SDL_JoystickGUID guid; - DIDEVICEINSTANCE dxdevice; - char *joystickname; - Uint8 send_add_event; - SDL_JoystickID nInstanceID; - SDL_bool bXInputDevice; - Uint8 XInputUserId; - struct JoyStick_DeviceData_ *pNext; + SDL_JoystickGUID guid; + DIDEVICEINSTANCE dxdevice; + char *joystickname; + Uint8 send_add_event; + SDL_JoystickID nInstanceID; + SDL_bool bXInputDevice; + Uint8 XInputUserId; + struct JoyStick_DeviceData_ *pNext; }; typedef struct JoyStick_DeviceData_ JoyStick_DeviceData; @@ -173,7 +173,7 @@ static int SDL_PrivateJoystickHat_Int(SDL_Joystick * joystick, Uint8 hat, static int SDL_PrivateJoystickButton_Int(SDL_Joystick * joystick, Uint8 button, Uint8 state); -// Taken from Wine - Thanks! +/* Taken from Wine - Thanks! */ DIOBJECTDATAFORMAT dfDIJoystick2[] = { { &GUID_XAxis,DIJOFS_X,DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0}, { &GUID_YAxis,DIJOFS_Y,DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0}, @@ -365,150 +365,150 @@ SetDIerror(const char *function, HRESULT code) #define SAFE_RELEASE(p) \ { \ - if (p) { \ - (p)->lpVtbl->Release((p)); \ - (p) = 0; \ - } \ + if (p) { \ + (p)->lpVtbl->Release((p)); \ + (p) = 0; \ + } \ } DEFINE_GUID(CLSID_WbemLocator, 0x4590f811,0x1d3a,0x11d0,0x89,0x1F,0x00,0xaa,0x00,0x4b,0x2e,0x24); DEFINE_GUID(IID_IWbemLocator, 0xdc12a687,0x737f,0x11cf,0x88,0x4d,0x00,0xaa,0x00,0x4b,0x2e,0x24); -//----------------------------------------------------------------------------- -// -// code from MSDN: http://msdn.microsoft.com/en-us/library/windows/desktop/ee417014(v=vs.85).aspx -// -// Enum each PNP device using WMI and check each device ID to see if it contains -// "IG_" (ex. "VID_045E&PID_028E&IG_00"). If it does, then it's an XInput device -// Unfortunately this information can not be found by just using DirectInput -//----------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- + * + * code from MSDN: http://msdn.microsoft.com/en-us/library/windows/desktop/ee417014(v=vs.85).aspx + * + * Enum each PNP device using WMI and check each device ID to see if it contains + * "IG_" (ex. "VID_045E&PID_028E&IG_00"). If it does, then it's an XInput device + * Unfortunately this information can not be found by just using DirectInput + *-----------------------------------------------------------------------------*/ BOOL IsXInputDevice( const GUID* pGuidProductFromDirectInput ) { - IWbemLocator* pIWbemLocator = NULL; - IEnumWbemClassObject* pEnumDevices = NULL; - IWbemClassObject* pDevices[20]; - IWbemServices* pIWbemServices = NULL; - DWORD uReturned = 0; - BSTR bstrNamespace = NULL; - BSTR bstrDeviceID = NULL; - BSTR bstrClassName = NULL; - SDL_bool bIsXinputDevice= SDL_FALSE; - UINT iDevice = 0; - VARIANT var; - HRESULT hr; - DWORD bCleanupCOM; + IWbemLocator* pIWbemLocator = NULL; + IEnumWbemClassObject* pEnumDevices = NULL; + IWbemClassObject* pDevices[20]; + IWbemServices* pIWbemServices = NULL; + DWORD uReturned = 0; + BSTR bstrNamespace = NULL; + BSTR bstrDeviceID = NULL; + BSTR bstrClassName = NULL; + SDL_bool bIsXinputDevice= SDL_FALSE; + UINT iDevice = 0; + VARIANT var; + HRESULT hr; + DWORD bCleanupCOM; if (!s_bXInputEnabled) { return SDL_FALSE; } - SDL_memset( pDevices, 0x0, sizeof(pDevices) ); - - // CoInit if needed - hr = CoInitialize(NULL); - bCleanupCOM = SUCCEEDED(hr); - - // Create WMI - hr = CoCreateInstance( &CLSID_WbemLocator, - NULL, - CLSCTX_INPROC_SERVER, - &IID_IWbemLocator, - (LPVOID*) &pIWbemLocator); - if( FAILED(hr) || pIWbemLocator == NULL ) - goto LCleanup; - - bstrNamespace = SysAllocString( L"\\\\.\\root\\cimv2" );if( bstrNamespace == NULL ) goto LCleanup; - bstrClassName = SysAllocString( L"Win32_PNPEntity" ); if( bstrClassName == NULL ) goto LCleanup; - bstrDeviceID = SysAllocString( L"DeviceID" ); if( bstrDeviceID == NULL ) goto LCleanup; - - // Connect to WMI - hr = IWbemLocator_ConnectServer( pIWbemLocator, bstrNamespace, NULL, NULL, 0L, - 0L, NULL, NULL, &pIWbemServices ); - if( FAILED(hr) || pIWbemServices == NULL ) - goto LCleanup; - - // Switch security level to IMPERSONATE. - CoSetProxyBlanket( (IUnknown *)pIWbemServices, RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_NONE, NULL, - RPC_C_AUTHN_LEVEL_CALL, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE ); - - hr = IWbemServices_CreateInstanceEnum( pIWbemServices, bstrClassName, 0, NULL, &pEnumDevices ); - if( FAILED(hr) || pEnumDevices == NULL ) - goto LCleanup; - - // Loop over all devices - for( ;; ) - { - // Get 20 at a time - hr = IEnumWbemClassObject_Next( pEnumDevices, 10000, 20, pDevices, &uReturned ); - if( FAILED(hr) ) - goto LCleanup; - if( uReturned == 0 ) - break; - - for( iDevice=0; iDeviceData1 ) - { - bIsXinputDevice = SDL_TRUE; - } - } - if ( pDeviceString ) - SDL_free( pDeviceString ); - - if ( bIsXinputDevice ) - break; - } - SAFE_RELEASE( pDevices[iDevice] ); - } - } - + SDL_memset( pDevices, 0x0, sizeof(pDevices) ); + + /* CoInit if needed */ + hr = CoInitialize(NULL); + bCleanupCOM = SUCCEEDED(hr); + + /* Create WMI */ + hr = CoCreateInstance( &CLSID_WbemLocator, + NULL, + CLSCTX_INPROC_SERVER, + &IID_IWbemLocator, + (LPVOID*) &pIWbemLocator); + if( FAILED(hr) || pIWbemLocator == NULL ) + goto LCleanup; + + bstrNamespace = SysAllocString( L"\\\\.\\root\\cimv2" );if( bstrNamespace == NULL ) goto LCleanup; + bstrClassName = SysAllocString( L"Win32_PNPEntity" ); if( bstrClassName == NULL ) goto LCleanup; + bstrDeviceID = SysAllocString( L"DeviceID" ); if( bstrDeviceID == NULL ) goto LCleanup; + + /* Connect to WMI */ + hr = IWbemLocator_ConnectServer( pIWbemLocator, bstrNamespace, NULL, NULL, 0L, + 0L, NULL, NULL, &pIWbemServices ); + if( FAILED(hr) || pIWbemServices == NULL ) + goto LCleanup; + + /* Switch security level to IMPERSONATE. */ + CoSetProxyBlanket( (IUnknown *)pIWbemServices, RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_NONE, NULL, + RPC_C_AUTHN_LEVEL_CALL, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE ); + + hr = IWbemServices_CreateInstanceEnum( pIWbemServices, bstrClassName, 0, NULL, &pEnumDevices ); + if( FAILED(hr) || pEnumDevices == NULL ) + goto LCleanup; + + /* Loop over all devices */ + for( ;; ) + { + /* Get 20 at a time */ + hr = IEnumWbemClassObject_Next( pEnumDevices, 10000, 20, pDevices, &uReturned ); + if( FAILED(hr) ) + goto LCleanup; + if( uReturned == 0 ) + break; + + for( iDevice=0; iDeviceData1 ) + { + bIsXinputDevice = SDL_TRUE; + } + } + if ( pDeviceString ) + SDL_free( pDeviceString ); + + if ( bIsXinputDevice ) + break; + } + SAFE_RELEASE( pDevices[iDevice] ); + } + } + LCleanup: - for( iDevice=0; iDevice<20; iDevice++ ) - SAFE_RELEASE( pDevices[iDevice] ); - SAFE_RELEASE( pEnumDevices ); - SAFE_RELEASE( pIWbemLocator ); - SAFE_RELEASE( pIWbemServices ); - - if ( bstrNamespace ) - SysFreeString( bstrNamespace ); - if ( bstrClassName ) - SysFreeString( bstrClassName ); - if ( bstrDeviceID ) - SysFreeString( bstrDeviceID ); - - if( bCleanupCOM ) - CoUninitialize(); - - return bIsXinputDevice; + for( iDevice=0; iDevice<20; iDevice++ ) + SAFE_RELEASE( pDevices[iDevice] ); + SAFE_RELEASE( pEnumDevices ); + SAFE_RELEASE( pIWbemLocator ); + SAFE_RELEASE( pIWbemServices ); + + if ( bstrNamespace ) + SysFreeString( bstrNamespace ); + if ( bstrClassName ) + SysFreeString( bstrClassName ); + if ( bstrDeviceID ) + SysFreeString( bstrDeviceID ); + + if( bCleanupCOM ) + CoUninitialize(); + + return bIsXinputDevice; } @@ -517,137 +517,137 @@ static SDL_bool s_bWindowsDeviceChanged = SDL_FALSE; /* windowproc for our joystick detect thread message only window, to detect any USB device addition/removal */ LRESULT CALLBACK SDL_PrivateJoystickDetectProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { - switch (message) { - case WM_DEVICECHANGE: - switch (wParam) { - case DBT_DEVICEARRIVAL: - if (((DEV_BROADCAST_HDR*)lParam)->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE) { - s_bWindowsDeviceChanged = SDL_TRUE; - } - break; - case DBT_DEVICEREMOVECOMPLETE: - if (((DEV_BROADCAST_HDR*)lParam)->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE) { - s_bWindowsDeviceChanged = SDL_TRUE; - } - break; - } - return 0; - } - - return DefWindowProc (hwnd, message, wParam, lParam); + switch (message) { + case WM_DEVICECHANGE: + switch (wParam) { + case DBT_DEVICEARRIVAL: + if (((DEV_BROADCAST_HDR*)lParam)->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE) { + s_bWindowsDeviceChanged = SDL_TRUE; + } + break; + case DBT_DEVICEREMOVECOMPLETE: + if (((DEV_BROADCAST_HDR*)lParam)->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE) { + s_bWindowsDeviceChanged = SDL_TRUE; + } + break; + } + return 0; + } + + return DefWindowProc (hwnd, message, wParam, lParam); } DEFINE_GUID(GUID_DEVINTERFACE_USB_DEVICE, 0xA5DCBF10L, 0x6530, 0x11D2, 0x90, 0x1F, 0x00, \ - 0xC0, 0x4F, 0xB9, 0x51, 0xED); + 0xC0, 0x4F, 0xB9, 0x51, 0xED); /* Function/thread to scan the system for joysticks. */ static int SDL_JoystickThread(void *_data) { - HRESULT result = S_OK; - HWND messageWindow = 0; - HDEVNOTIFY hNotify = 0; - DEV_BROADCAST_DEVICEINTERFACE dbh; - SDL_bool bOpenedXInputDevices[4]; - WNDCLASSEX wincl; - - SDL_memset( bOpenedXInputDevices, 0x0, sizeof(bOpenedXInputDevices) ); - - result = WIN_CoInitialize(); - - SDL_memset( &wincl, 0x0, sizeof(wincl) ); - wincl.hInstance = GetModuleHandle( NULL ); - wincl.lpszClassName = L"Message"; - wincl.lpfnWndProc = SDL_PrivateJoystickDetectProc; // This function is called by windows - wincl.cbSize = sizeof (WNDCLASSEX); - - if (!RegisterClassEx (&wincl)) - { - return SDL_SetError("Failed to create register class for joystick autodetect.", GetLastError()); - } - - messageWindow = (HWND)CreateWindowEx( 0, L"Message", NULL, 0, 0, 0, 0, 0, HWND_MESSAGE, NULL, NULL, NULL ); - if ( !messageWindow ) - { - return SDL_SetError("Failed to create message window for joystick autodetect.", GetLastError()); - } - - SDL_memset(&dbh, 0x0, sizeof(dbh)); - - dbh.dbcc_size = sizeof(dbh); - dbh.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE; - dbh.dbcc_classguid = GUID_DEVINTERFACE_USB_DEVICE; - - hNotify = RegisterDeviceNotification( messageWindow, &dbh, DEVICE_NOTIFY_WINDOW_HANDLE ); - if ( !hNotify ) - { - return SDL_SetError("Failed to create notify device for joystick autodetect.", GetLastError()); - } - - SDL_LockMutex( s_mutexJoyStickEnum ); - while ( s_bJoystickThreadQuit == SDL_FALSE ) - { - MSG messages; - Uint8 userId; - int nCurrentOpenedXInputDevices = 0; - int nNewOpenedXInputDevices = 0; - SDL_CondWaitTimeout( s_condJoystickThread, s_mutexJoyStickEnum, 300 ); - - while ( s_bJoystickThreadQuit == SDL_FALSE && PeekMessage(&messages, messageWindow, 0, 0, PM_NOREMOVE) ) - { - if ( GetMessage(&messages, messageWindow, 0, 0) != 0 ) { - TranslateMessage(&messages); - DispatchMessage(&messages); - } - } - - if ( s_bXInputEnabled && XINPUTGETCAPABILITIES ) - { - // scan for any change in XInput devices - for ( userId = 0; userId < 4; userId++ ) - { - XINPUT_CAPABILITIES capabilities; - DWORD result; - - if ( bOpenedXInputDevices[userId] == SDL_TRUE ) - nCurrentOpenedXInputDevices++; - - result = XINPUTGETCAPABILITIES( userId, XINPUT_FLAG_GAMEPAD, &capabilities ); - if ( result == ERROR_SUCCESS ) - { - bOpenedXInputDevices[userId] = SDL_TRUE; - nNewOpenedXInputDevices++; - } - else - { - bOpenedXInputDevices[userId] = SDL_FALSE; - } - } - } - - if ( s_pKnownJoystickGUIDs && ( s_bWindowsDeviceChanged || nNewOpenedXInputDevices != nCurrentOpenedXInputDevices ) ) - { - SDL_Delay( 300 ); // wait for direct input to find out about this device - - s_bDeviceRemoved = SDL_TRUE; - s_bDeviceAdded = SDL_TRUE; - s_bWindowsDeviceChanged = SDL_FALSE; - } - } - SDL_UnlockMutex( s_mutexJoyStickEnum ); - - if ( hNotify ) - UnregisterDeviceNotification( hNotify ); - - if ( messageWindow ) - DestroyWindow( messageWindow ); - - UnregisterClass( wincl.lpszClassName, wincl.hInstance ); - messageWindow = 0; - WIN_CoUninitialize(); - return 1; + HRESULT result = S_OK; + HWND messageWindow = 0; + HDEVNOTIFY hNotify = 0; + DEV_BROADCAST_DEVICEINTERFACE dbh; + SDL_bool bOpenedXInputDevices[4]; + WNDCLASSEX wincl; + + SDL_memset( bOpenedXInputDevices, 0x0, sizeof(bOpenedXInputDevices) ); + + result = WIN_CoInitialize(); + + SDL_memset( &wincl, 0x0, sizeof(wincl) ); + wincl.hInstance = GetModuleHandle( NULL ); + wincl.lpszClassName = L"Message"; + wincl.lpfnWndProc = SDL_PrivateJoystickDetectProc; /* This function is called by windows */ + wincl.cbSize = sizeof (WNDCLASSEX); + + if (!RegisterClassEx (&wincl)) + { + return SDL_SetError("Failed to create register class for joystick autodetect.", GetLastError()); + } + + messageWindow = (HWND)CreateWindowEx( 0, L"Message", NULL, 0, 0, 0, 0, 0, HWND_MESSAGE, NULL, NULL, NULL ); + if ( !messageWindow ) + { + return SDL_SetError("Failed to create message window for joystick autodetect.", GetLastError()); + } + + SDL_memset(&dbh, 0x0, sizeof(dbh)); + + dbh.dbcc_size = sizeof(dbh); + dbh.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE; + dbh.dbcc_classguid = GUID_DEVINTERFACE_USB_DEVICE; + + hNotify = RegisterDeviceNotification( messageWindow, &dbh, DEVICE_NOTIFY_WINDOW_HANDLE ); + if ( !hNotify ) + { + return SDL_SetError("Failed to create notify device for joystick autodetect.", GetLastError()); + } + + SDL_LockMutex( s_mutexJoyStickEnum ); + while ( s_bJoystickThreadQuit == SDL_FALSE ) + { + MSG messages; + Uint8 userId; + int nCurrentOpenedXInputDevices = 0; + int nNewOpenedXInputDevices = 0; + SDL_CondWaitTimeout( s_condJoystickThread, s_mutexJoyStickEnum, 300 ); + + while ( s_bJoystickThreadQuit == SDL_FALSE && PeekMessage(&messages, messageWindow, 0, 0, PM_NOREMOVE) ) + { + if ( GetMessage(&messages, messageWindow, 0, 0) != 0 ) { + TranslateMessage(&messages); + DispatchMessage(&messages); + } + } + + if ( s_bXInputEnabled && XINPUTGETCAPABILITIES ) + { + /* scan for any change in XInput devices */ + for ( userId = 0; userId < 4; userId++ ) + { + XINPUT_CAPABILITIES capabilities; + DWORD result; + + if ( bOpenedXInputDevices[userId] == SDL_TRUE ) + nCurrentOpenedXInputDevices++; + + result = XINPUTGETCAPABILITIES( userId, XINPUT_FLAG_GAMEPAD, &capabilities ); + if ( result == ERROR_SUCCESS ) + { + bOpenedXInputDevices[userId] = SDL_TRUE; + nNewOpenedXInputDevices++; + } + else + { + bOpenedXInputDevices[userId] = SDL_FALSE; + } + } + } + + if ( s_pKnownJoystickGUIDs && ( s_bWindowsDeviceChanged || nNewOpenedXInputDevices != nCurrentOpenedXInputDevices ) ) + { + SDL_Delay( 300 ); /* wait for direct input to find out about this device */ + + s_bDeviceRemoved = SDL_TRUE; + s_bDeviceAdded = SDL_TRUE; + s_bWindowsDeviceChanged = SDL_FALSE; + } + } + SDL_UnlockMutex( s_mutexJoyStickEnum ); + + if ( hNotify ) + UnregisterDeviceNotification( hNotify ); + + if ( messageWindow ) + DestroyWindow( messageWindow ); + + UnregisterClass( wincl.lpszClassName, wincl.hInstance ); + messageWindow = 0; + WIN_CoUninitialize(); + return 1; } @@ -661,10 +661,10 @@ SDL_SYS_JoystickInit(void) { HRESULT result; HINSTANCE instance; - const char *env = SDL_GetHint(SDL_HINT_XINPUT_ENABLED); - if (env && !SDL_atoi(env)) { - s_bXInputEnabled = SDL_FALSE; - } + const char *env = SDL_GetHint(SDL_HINT_XINPUT_ENABLED); + if (env && !SDL_atoi(env)) { + s_bXInputEnabled = SDL_FALSE; + } result = WIN_CoInitialize(); if (FAILED(result)) { @@ -696,238 +696,238 @@ SDL_SYS_JoystickInit(void) s_mutexJoyStickEnum = SDL_CreateMutex(); s_condJoystickThread = SDL_CreateCond(); - s_bDeviceAdded = SDL_TRUE; // force a scan of the system for joysticks this first time + s_bDeviceAdded = SDL_TRUE; /* force a scan of the system for joysticks this first time */ SDL_SYS_JoystickDetect(); if ((s_bXInputEnabled) && (WIN_LoadXInputDLL() == -1)) { s_bXInputEnabled = SDL_FALSE; /* oh well. */ } - if ( !s_threadJoystick ) - { - s_bJoystickThreadQuit = SDL_FALSE; - /* spin up the thread to detect hotplug of devices */ + if ( !s_threadJoystick ) + { + s_bJoystickThreadQuit = SDL_FALSE; + /* spin up the thread to detect hotplug of devices */ #if defined(__WIN32__) && !defined(HAVE_LIBC) #undef SDL_CreateThread - s_threadJoystick= SDL_CreateThread( SDL_JoystickThread, "SDL_joystick", NULL, NULL, NULL ); + s_threadJoystick= SDL_CreateThread( SDL_JoystickThread, "SDL_joystick", NULL, NULL, NULL ); #else - s_threadJoystick = SDL_CreateThread( SDL_JoystickThread, "SDL_joystick", NULL ); + s_threadJoystick = SDL_CreateThread( SDL_JoystickThread, "SDL_joystick", NULL ); #endif - } - return SDL_SYS_NumJoysticks(); + } + return SDL_SYS_NumJoysticks(); } /* return the number of joysticks that are connected right now */ int SDL_SYS_NumJoysticks() { - int nJoysticks = 0; - JoyStick_DeviceData *device = SYS_Joystick; - while ( device ) - { - nJoysticks++; - device = device->pNext; - } - - return nJoysticks; + int nJoysticks = 0; + JoyStick_DeviceData *device = SYS_Joystick; + while ( device ) + { + nJoysticks++; + device = device->pNext; + } + + return nJoysticks; } static int s_iNewGUID = 0; /* helper function for direct input, gets called for each connected joystick */ static BOOL CALLBACK - EnumJoysticksCallback(const DIDEVICEINSTANCE * pdidInstance, VOID * pContext) + EnumJoysticksCallback(const DIDEVICEINSTANCE * pdidInstance, VOID * pContext) { - JoyStick_DeviceData *pNewJoystick; - JoyStick_DeviceData *pPrevJoystick = NULL; - SDL_bool bXInputDevice; - pNewJoystick = *(JoyStick_DeviceData **)pContext; - while ( pNewJoystick ) - { - if ( !SDL_memcmp( &pNewJoystick->dxdevice.guidInstance, &pdidInstance->guidInstance, sizeof(pNewJoystick->dxdevice.guidInstance) ) ) - { - /* if we are replacing the front of the list then update it */ - if ( pNewJoystick == *(JoyStick_DeviceData **)pContext ) - { - *(JoyStick_DeviceData **)pContext = pNewJoystick->pNext; - } - else if ( pPrevJoystick ) - { - pPrevJoystick->pNext = pNewJoystick->pNext; - } - - pNewJoystick->pNext = SYS_Joystick; - SYS_Joystick = pNewJoystick; - - s_pKnownJoystickGUIDs[ s_iNewGUID ] = pdidInstance->guidInstance; - s_iNewGUID++; - if ( s_iNewGUID < MAX_JOYSTICKS ) - return DIENUM_CONTINUE; // already have this joystick loaded, just keep going - else - return DIENUM_STOP; - } - - pPrevJoystick = pNewJoystick; - pNewJoystick = pNewJoystick->pNext; - } - - s_bDeviceAdded = SDL_TRUE; - - bXInputDevice = IsXInputDevice( &pdidInstance->guidProduct ); - - pNewJoystick = (JoyStick_DeviceData *)SDL_malloc( sizeof(JoyStick_DeviceData) ); - - if ( bXInputDevice ) - { - pNewJoystick->bXInputDevice = SDL_TRUE; - pNewJoystick->XInputUserId = INVALID_XINPUT_USERID; - } - else - { - pNewJoystick->bXInputDevice = SDL_FALSE; - } - - SDL_memcpy(&(pNewJoystick->dxdevice), pdidInstance, - sizeof(DIDEVICEINSTANCE)); - - pNewJoystick->joystickname = WIN_StringToUTF8(pdidInstance->tszProductName); - pNewJoystick->send_add_event = 1; - pNewJoystick->nInstanceID = ++s_nInstanceID; - SDL_memcpy( &pNewJoystick->guid, &pdidInstance->guidProduct, sizeof(pNewJoystick->guid) ); - pNewJoystick->pNext = NULL; - - if ( SYS_Joystick ) - { - pNewJoystick->pNext = SYS_Joystick; - } - SYS_Joystick = pNewJoystick; - - s_pKnownJoystickGUIDs[ s_iNewGUID ] = pdidInstance->guidInstance; - s_iNewGUID++; - - if ( s_iNewGUID < MAX_JOYSTICKS ) - return DIENUM_CONTINUE; // already have this joystick loaded, just keep going - else - return DIENUM_STOP; + JoyStick_DeviceData *pNewJoystick; + JoyStick_DeviceData *pPrevJoystick = NULL; + SDL_bool bXInputDevice; + pNewJoystick = *(JoyStick_DeviceData **)pContext; + while ( pNewJoystick ) + { + if ( !SDL_memcmp( &pNewJoystick->dxdevice.guidInstance, &pdidInstance->guidInstance, sizeof(pNewJoystick->dxdevice.guidInstance) ) ) + { + /* if we are replacing the front of the list then update it */ + if ( pNewJoystick == *(JoyStick_DeviceData **)pContext ) + { + *(JoyStick_DeviceData **)pContext = pNewJoystick->pNext; + } + else if ( pPrevJoystick ) + { + pPrevJoystick->pNext = pNewJoystick->pNext; + } + + pNewJoystick->pNext = SYS_Joystick; + SYS_Joystick = pNewJoystick; + + s_pKnownJoystickGUIDs[ s_iNewGUID ] = pdidInstance->guidInstance; + s_iNewGUID++; + if ( s_iNewGUID < MAX_JOYSTICKS ) + return DIENUM_CONTINUE; /* already have this joystick loaded, just keep going */ + else + return DIENUM_STOP; + } + + pPrevJoystick = pNewJoystick; + pNewJoystick = pNewJoystick->pNext; + } + + s_bDeviceAdded = SDL_TRUE; + + bXInputDevice = IsXInputDevice( &pdidInstance->guidProduct ); + + pNewJoystick = (JoyStick_DeviceData *)SDL_malloc( sizeof(JoyStick_DeviceData) ); + + if ( bXInputDevice ) + { + pNewJoystick->bXInputDevice = SDL_TRUE; + pNewJoystick->XInputUserId = INVALID_XINPUT_USERID; + } + else + { + pNewJoystick->bXInputDevice = SDL_FALSE; + } + + SDL_memcpy(&(pNewJoystick->dxdevice), pdidInstance, + sizeof(DIDEVICEINSTANCE)); + + pNewJoystick->joystickname = WIN_StringToUTF8(pdidInstance->tszProductName); + pNewJoystick->send_add_event = 1; + pNewJoystick->nInstanceID = ++s_nInstanceID; + SDL_memcpy( &pNewJoystick->guid, &pdidInstance->guidProduct, sizeof(pNewJoystick->guid) ); + pNewJoystick->pNext = NULL; + + if ( SYS_Joystick ) + { + pNewJoystick->pNext = SYS_Joystick; + } + SYS_Joystick = pNewJoystick; + + s_pKnownJoystickGUIDs[ s_iNewGUID ] = pdidInstance->guidInstance; + s_iNewGUID++; + + if ( s_iNewGUID < MAX_JOYSTICKS ) + return DIENUM_CONTINUE; /* already have this joystick loaded, just keep going */ + else + return DIENUM_STOP; } /* detect any new joysticks being inserted into the system */ void SDL_SYS_JoystickDetect() { - HRESULT result; - JoyStick_DeviceData *pCurList = NULL; - /* only enum the devices if the joystick thread told us something changed */ - if ( s_bDeviceAdded || s_bDeviceRemoved ) - { - s_bDeviceAdded = SDL_FALSE; - s_bDeviceRemoved = SDL_FALSE; - - pCurList = SYS_Joystick; - SYS_Joystick = NULL; - s_iNewGUID = 0; - SDL_LockMutex( s_mutexJoyStickEnum ); - - if ( !s_pKnownJoystickGUIDs ) - s_pKnownJoystickGUIDs = SDL_malloc( sizeof(GUID)*MAX_JOYSTICKS ); - - SDL_memset( s_pKnownJoystickGUIDs, 0x0, sizeof(GUID)*MAX_JOYSTICKS ); - - /* Look for joysticks, wheels, head trackers, gamepads, etc.. */ - result = IDirectInput8_EnumDevices(dinput, - DI8DEVCLASS_GAMECTRL, - EnumJoysticksCallback, - &pCurList, DIEDFL_ATTACHEDONLY); - - SDL_UnlockMutex( s_mutexJoyStickEnum ); - } - - if ( pCurList ) - { - while ( pCurList ) - { - JoyStick_DeviceData *pListNext = NULL; + HRESULT result; + JoyStick_DeviceData *pCurList = NULL; + /* only enum the devices if the joystick thread told us something changed */ + if ( s_bDeviceAdded || s_bDeviceRemoved ) + { + s_bDeviceAdded = SDL_FALSE; + s_bDeviceRemoved = SDL_FALSE; + + pCurList = SYS_Joystick; + SYS_Joystick = NULL; + s_iNewGUID = 0; + SDL_LockMutex( s_mutexJoyStickEnum ); + + if ( !s_pKnownJoystickGUIDs ) + s_pKnownJoystickGUIDs = SDL_malloc( sizeof(GUID)*MAX_JOYSTICKS ); + + SDL_memset( s_pKnownJoystickGUIDs, 0x0, sizeof(GUID)*MAX_JOYSTICKS ); + + /* Look for joysticks, wheels, head trackers, gamepads, etc.. */ + result = IDirectInput8_EnumDevices(dinput, + DI8DEVCLASS_GAMECTRL, + EnumJoysticksCallback, + &pCurList, DIEDFL_ATTACHEDONLY); + + SDL_UnlockMutex( s_mutexJoyStickEnum ); + } + + if ( pCurList ) + { + while ( pCurList ) + { + JoyStick_DeviceData *pListNext = NULL; #if !SDL_EVENTS_DISABLED - SDL_Event event; - event.type = SDL_JOYDEVICEREMOVED; - - if (SDL_GetEventState(event.type) == SDL_ENABLE) { - event.jdevice.which = pCurList->nInstanceID; - if ((SDL_EventOK == NULL) - || (*SDL_EventOK) (SDL_EventOKParam, &event)) { - SDL_PushEvent(&event); - } - } -#endif // !SDL_EVENTS_DISABLED - - pListNext = pCurList->pNext; - SDL_free(pCurList->joystickname); - SDL_free( pCurList ); - pCurList = pListNext; - } - - } - - if ( s_bDeviceAdded ) - { - JoyStick_DeviceData *pNewJoystick; - int device_index = 0; - s_bDeviceAdded = SDL_FALSE; - pNewJoystick = SYS_Joystick; - while ( pNewJoystick ) - { - if ( pNewJoystick->send_add_event ) - { + SDL_Event event; + event.type = SDL_JOYDEVICEREMOVED; + + if (SDL_GetEventState(event.type) == SDL_ENABLE) { + event.jdevice.which = pCurList->nInstanceID; + if ((SDL_EventOK == NULL) + || (*SDL_EventOK) (SDL_EventOKParam, &event)) { + SDL_PushEvent(&event); + } + } +#endif /* !SDL_EVENTS_DISABLED */ + + pListNext = pCurList->pNext; + SDL_free(pCurList->joystickname); + SDL_free( pCurList ); + pCurList = pListNext; + } + + } + + if ( s_bDeviceAdded ) + { + JoyStick_DeviceData *pNewJoystick; + int device_index = 0; + s_bDeviceAdded = SDL_FALSE; + pNewJoystick = SYS_Joystick; + while ( pNewJoystick ) + { + if ( pNewJoystick->send_add_event ) + { #if !SDL_EVENTS_DISABLED - SDL_Event event; - event.type = SDL_JOYDEVICEADDED; - - if (SDL_GetEventState(event.type) == SDL_ENABLE) { - event.jdevice.which = device_index; - if ((SDL_EventOK == NULL) - || (*SDL_EventOK) (SDL_EventOKParam, &event)) { - SDL_PushEvent(&event); - } - } + SDL_Event event; + event.type = SDL_JOYDEVICEADDED; + + if (SDL_GetEventState(event.type) == SDL_ENABLE) { + event.jdevice.which = device_index; + if ((SDL_EventOK == NULL) + || (*SDL_EventOK) (SDL_EventOKParam, &event)) { + SDL_PushEvent(&event); + } + } #endif /* !SDL_EVENTS_DISABLED */ - pNewJoystick->send_add_event = 0; - } - device_index++; - pNewJoystick = pNewJoystick->pNext; - } - } + pNewJoystick->send_add_event = 0; + } + device_index++; + pNewJoystick = pNewJoystick->pNext; + } + } } /* we need to poll if we have pending hotplug device changes or connected devices */ SDL_bool SDL_SYS_JoystickNeedsPolling() { - /* we have a new device or one was pulled, we need to think this frame please */ - if ( s_bDeviceAdded || s_bDeviceRemoved ) - return SDL_TRUE; + /* we have a new device or one was pulled, we need to think this frame please */ + if ( s_bDeviceAdded || s_bDeviceRemoved ) + return SDL_TRUE; - return SDL_FALSE; + return SDL_FALSE; } /* Function to get the device-dependent name of a joystick */ const char * SDL_SYS_JoystickNameForDeviceIndex(int device_index) { - JoyStick_DeviceData *device = SYS_Joystick; + JoyStick_DeviceData *device = SYS_Joystick; - for (; device_index > 0; device_index--) - device = device->pNext; + for (; device_index > 0; device_index--) + device = device->pNext; - return device->joystickname; + return device->joystickname; } /* Function to perform the mapping between current device instance and this joysticks instance id */ SDL_JoystickID SDL_SYS_GetInstanceIdOfDeviceIndex(int device_index) { - JoyStick_DeviceData *device = SYS_Joystick; - int index; + JoyStick_DeviceData *device = SYS_Joystick; + int index; - for (index = device_index; index > 0; index--) - device = device->pNext; + for (index = device_index; index > 0; index--) + device = device->pNext; - return device->nInstanceID; + return device->nInstanceID; } /* Function to open a joystick for use. @@ -941,17 +941,17 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index) HRESULT result; LPDIRECTINPUTDEVICE8 device; DIPROPDWORD dipdw; - JoyStick_DeviceData *joystickdevice = SYS_Joystick; + JoyStick_DeviceData *joystickdevice = SYS_Joystick; - for (; device_index > 0; device_index--) - joystickdevice = joystickdevice->pNext; + for (; device_index > 0; device_index--) + joystickdevice = joystickdevice->pNext; SDL_memset(&dipdw, 0, sizeof(DIPROPDWORD)); dipdw.diph.dwSize = sizeof(DIPROPDWORD); dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER); /* allocate memory for system specific hardware data */ - joystick->instance_id = joystickdevice->nInstanceID; + joystick->instance_id = joystickdevice->nInstanceID; joystick->closed = 0; joystick->hwdata = (struct joystick_hwdata *) SDL_malloc(sizeof(struct joystick_hwdata)); @@ -960,194 +960,194 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index) } SDL_memset(joystick->hwdata, 0, sizeof(struct joystick_hwdata)); joystick->hwdata->buffered = 1; - joystick->hwdata->removed = 0; + joystick->hwdata->removed = 0; joystick->hwdata->Capabilities.dwSize = sizeof(DIDEVCAPS); - joystick->hwdata->guid = joystickdevice->guid; - - if ( joystickdevice->bXInputDevice ) - { - XINPUT_CAPABILITIES capabilities; - Uint8 userId = 0; - DWORD result; - JoyStick_DeviceData *joysticklist = SYS_Joystick; - // scan the opened joysticks and pick the next free xinput userid for this one - for( ; joysticklist; joysticklist = joysticklist->pNext) - { - if ( joysticklist->bXInputDevice && joysticklist->XInputUserId == userId ) - userId++; - } - - if ( s_bXInputEnabled && XINPUTGETCAPABILITIES ) - { - result = XINPUTGETCAPABILITIES( userId, XINPUT_FLAG_GAMEPAD, &capabilities ); - if ( result == ERROR_SUCCESS ) - { + joystick->hwdata->guid = joystickdevice->guid; + + if ( joystickdevice->bXInputDevice ) + { + XINPUT_CAPABILITIES capabilities; + Uint8 userId = 0; + DWORD result; + JoyStick_DeviceData *joysticklist = SYS_Joystick; + /* scan the opened joysticks and pick the next free xinput userid for this one */ + for( ; joysticklist; joysticklist = joysticklist->pNext) + { + if ( joysticklist->bXInputDevice && joysticklist->XInputUserId == userId ) + userId++; + } + + if ( s_bXInputEnabled && XINPUTGETCAPABILITIES ) + { + result = XINPUTGETCAPABILITIES( userId, XINPUT_FLAG_GAMEPAD, &capabilities ); + if ( result == ERROR_SUCCESS ) + { const SDL_bool bIs14OrLater = (SDL_XInputVersion >= ((1<<16)|4)); - SDL_bool bIsSupported = SDL_FALSE; - // Current version of XInput mistakenly returns 0 as the Type. Ignore it and ensure the subtype is a gamepad. - bIsSupported = ( capabilities.SubType == XINPUT_DEVSUBTYPE_GAMEPAD ); - - if ( !bIsSupported ) - { - joystickdevice->bXInputDevice = SDL_FALSE; - } - else - { - // valid - joystick->hwdata->bXInputDevice = SDL_TRUE; + SDL_bool bIsSupported = SDL_FALSE; + /* Current version of XInput mistakenly returns 0 as the Type. Ignore it and ensure the subtype is a gamepad. */ + bIsSupported = ( capabilities.SubType == XINPUT_DEVSUBTYPE_GAMEPAD ); + + if ( !bIsSupported ) + { + joystickdevice->bXInputDevice = SDL_FALSE; + } + else + { + /* valid */ + joystick->hwdata->bXInputDevice = SDL_TRUE; if ((!bIs14OrLater) || (capabilities.Flags & XINPUT_CAPS_FFB_SUPPORTED)) { - joystick->hwdata->bXInputHaptic = SDL_TRUE; + joystick->hwdata->bXInputHaptic = SDL_TRUE; } - SDL_memset( joystick->hwdata->XInputState, 0x0, sizeof(joystick->hwdata->XInputState) ); - joystickdevice->XInputUserId = userId; - joystick->hwdata->userid = userId; - joystick->hwdata->currentXInputSlot = 0; - // The XInput API has a hard coded button/axis mapping, so we just match it - joystick->naxes = 6; - joystick->nbuttons = 15; - joystick->nballs = 0; - joystick->nhats = 0; - } - } - else - { - joystickdevice->bXInputDevice = SDL_FALSE; - } - } - else - { - joystickdevice->bXInputDevice = SDL_FALSE; - } - } - - if ( joystickdevice->bXInputDevice == SDL_FALSE ) - { - joystick->hwdata->bXInputDevice = SDL_FALSE; - - result = - IDirectInput8_CreateDevice(dinput, - &(joystickdevice->dxdevice.guidInstance), &device, NULL); - if (FAILED(result)) { - return SetDIerror("IDirectInput::CreateDevice", result); - } - - /* Now get the IDirectInputDevice8 interface, instead. */ - result = IDirectInputDevice8_QueryInterface(device, - &IID_IDirectInputDevice8, - (LPVOID *) & joystick-> - hwdata->InputDevice); - /* We are done with this object. Use the stored one from now on. */ - IDirectInputDevice8_Release(device); - - if (FAILED(result)) { - return SetDIerror("IDirectInputDevice8::QueryInterface", result); - } - - /* Acquire shared access. Exclusive access is required for forces, - * though. */ - result = - IDirectInputDevice8_SetCooperativeLevel(joystick->hwdata-> - InputDevice, SDL_HelperWindow, - DISCL_NONEXCLUSIVE | - DISCL_BACKGROUND); - if (FAILED(result)) { - return SetDIerror("IDirectInputDevice8::SetCooperativeLevel", result); - } - - /* Use the extended data structure: DIJOYSTATE2. */ - result = - IDirectInputDevice8_SetDataFormat(joystick->hwdata->InputDevice, - &c_dfDIJoystick2); - if (FAILED(result)) { - return SetDIerror("IDirectInputDevice8::SetDataFormat", result); - } - - /* Get device capabilities */ - result = - IDirectInputDevice8_GetCapabilities(joystick->hwdata->InputDevice, - &joystick->hwdata->Capabilities); - - if (FAILED(result)) { - return SetDIerror("IDirectInputDevice8::GetCapabilities", result); - } - - /* Force capable? */ - if (joystick->hwdata->Capabilities.dwFlags & DIDC_FORCEFEEDBACK) { - - result = IDirectInputDevice8_Acquire(joystick->hwdata->InputDevice); - - if (FAILED(result)) { - return SetDIerror("IDirectInputDevice8::Acquire", result); - } - - /* reset all accuators. */ - result = - IDirectInputDevice8_SendForceFeedbackCommand(joystick->hwdata-> - InputDevice, - DISFFC_RESET); - - /* Not necessarily supported, ignore if not supported. - if (FAILED(result)) { - return SetDIerror("IDirectInputDevice8::SendForceFeedbackCommand", result); - } - */ - - result = IDirectInputDevice8_Unacquire(joystick->hwdata->InputDevice); - - if (FAILED(result)) { - return SetDIerror("IDirectInputDevice8::Unacquire", result); - } - - /* Turn on auto-centering for a ForceFeedback device (until told - * otherwise). */ - dipdw.diph.dwObj = 0; - dipdw.diph.dwHow = DIPH_DEVICE; - dipdw.dwData = DIPROPAUTOCENTER_ON; - - result = - IDirectInputDevice8_SetProperty(joystick->hwdata->InputDevice, - DIPROP_AUTOCENTER, &dipdw.diph); - - /* Not necessarily supported, ignore if not supported. - if (FAILED(result)) { - return SetDIerror("IDirectInputDevice8::SetProperty", result); - } - */ - } - - /* What buttons and axes does it have? */ - IDirectInputDevice8_EnumObjects(joystick->hwdata->InputDevice, - EnumDevObjectsCallback, joystick, - DIDFT_BUTTON | DIDFT_AXIS | DIDFT_POV); - - /* Reorder the input objects. Some devices do not report the X axis as - * the first axis, for example. */ - SortDevObjects(joystick); - - dipdw.diph.dwObj = 0; - dipdw.diph.dwHow = DIPH_DEVICE; - dipdw.dwData = INPUT_QSIZE; - - /* Set the buffer size */ - result = - IDirectInputDevice8_SetProperty(joystick->hwdata->InputDevice, - DIPROP_BUFFERSIZE, &dipdw.diph); - - if (result == DI_POLLEDDEVICE) { - /* This device doesn't support buffering, so we're forced - * to use less reliable polling. */ - joystick->hwdata->buffered = 0; - } else if (FAILED(result)) { - return SetDIerror("IDirectInputDevice8::SetProperty", result); - } - } + SDL_memset( joystick->hwdata->XInputState, 0x0, sizeof(joystick->hwdata->XInputState) ); + joystickdevice->XInputUserId = userId; + joystick->hwdata->userid = userId; + joystick->hwdata->currentXInputSlot = 0; + /* The XInput API has a hard coded button/axis mapping, so we just match it */ + joystick->naxes = 6; + joystick->nbuttons = 15; + joystick->nballs = 0; + joystick->nhats = 0; + } + } + else + { + joystickdevice->bXInputDevice = SDL_FALSE; + } + } + else + { + joystickdevice->bXInputDevice = SDL_FALSE; + } + } + + if ( joystickdevice->bXInputDevice == SDL_FALSE ) + { + joystick->hwdata->bXInputDevice = SDL_FALSE; + + result = + IDirectInput8_CreateDevice(dinput, + &(joystickdevice->dxdevice.guidInstance), &device, NULL); + if (FAILED(result)) { + return SetDIerror("IDirectInput::CreateDevice", result); + } + + /* Now get the IDirectInputDevice8 interface, instead. */ + result = IDirectInputDevice8_QueryInterface(device, + &IID_IDirectInputDevice8, + (LPVOID *) & joystick-> + hwdata->InputDevice); + /* We are done with this object. Use the stored one from now on. */ + IDirectInputDevice8_Release(device); + + if (FAILED(result)) { + return SetDIerror("IDirectInputDevice8::QueryInterface", result); + } + + /* Acquire shared access. Exclusive access is required for forces, + * though. */ + result = + IDirectInputDevice8_SetCooperativeLevel(joystick->hwdata-> + InputDevice, SDL_HelperWindow, + DISCL_NONEXCLUSIVE | + DISCL_BACKGROUND); + if (FAILED(result)) { + return SetDIerror("IDirectInputDevice8::SetCooperativeLevel", result); + } + + /* Use the extended data structure: DIJOYSTATE2. */ + result = + IDirectInputDevice8_SetDataFormat(joystick->hwdata->InputDevice, + &c_dfDIJoystick2); + if (FAILED(result)) { + return SetDIerror("IDirectInputDevice8::SetDataFormat", result); + } + + /* Get device capabilities */ + result = + IDirectInputDevice8_GetCapabilities(joystick->hwdata->InputDevice, + &joystick->hwdata->Capabilities); + + if (FAILED(result)) { + return SetDIerror("IDirectInputDevice8::GetCapabilities", result); + } + + /* Force capable? */ + if (joystick->hwdata->Capabilities.dwFlags & DIDC_FORCEFEEDBACK) { + + result = IDirectInputDevice8_Acquire(joystick->hwdata->InputDevice); + + if (FAILED(result)) { + return SetDIerror("IDirectInputDevice8::Acquire", result); + } + + /* reset all accuators. */ + result = + IDirectInputDevice8_SendForceFeedbackCommand(joystick->hwdata-> + InputDevice, + DISFFC_RESET); + + /* Not necessarily supported, ignore if not supported. + if (FAILED(result)) { + return SetDIerror("IDirectInputDevice8::SendForceFeedbackCommand", result); + } + */ + + result = IDirectInputDevice8_Unacquire(joystick->hwdata->InputDevice); + + if (FAILED(result)) { + return SetDIerror("IDirectInputDevice8::Unacquire", result); + } + + /* Turn on auto-centering for a ForceFeedback device (until told + * otherwise). */ + dipdw.diph.dwObj = 0; + dipdw.diph.dwHow = DIPH_DEVICE; + dipdw.dwData = DIPROPAUTOCENTER_ON; + + result = + IDirectInputDevice8_SetProperty(joystick->hwdata->InputDevice, + DIPROP_AUTOCENTER, &dipdw.diph); + + /* Not necessarily supported, ignore if not supported. + if (FAILED(result)) { + return SetDIerror("IDirectInputDevice8::SetProperty", result); + } + */ + } + + /* What buttons and axes does it have? */ + IDirectInputDevice8_EnumObjects(joystick->hwdata->InputDevice, + EnumDevObjectsCallback, joystick, + DIDFT_BUTTON | DIDFT_AXIS | DIDFT_POV); + + /* Reorder the input objects. Some devices do not report the X axis as + * the first axis, for example. */ + SortDevObjects(joystick); + + dipdw.diph.dwObj = 0; + dipdw.diph.dwHow = DIPH_DEVICE; + dipdw.dwData = INPUT_QSIZE; + + /* Set the buffer size */ + result = + IDirectInputDevice8_SetProperty(joystick->hwdata->InputDevice, + DIPROP_BUFFERSIZE, &dipdw.diph); + + if (result == DI_POLLEDDEVICE) { + /* This device doesn't support buffering, so we're forced + * to use less reliable polling. */ + joystick->hwdata->buffered = 0; + } else if (FAILED(result)) { + return SetDIerror("IDirectInputDevice8::SetProperty", result); + } + } return (0); } /* return true if this joystick is plugged in right now */ SDL_bool SDL_SYS_JoystickAttached( SDL_Joystick * joystick ) { - return joystick->closed == 0 && joystick->hwdata->removed == 0; + return joystick->closed == 0 && joystick->hwdata->removed == 0; } @@ -1156,48 +1156,48 @@ SDL_bool SDL_SYS_JoystickAttached( SDL_Joystick * joystick ) static int SortDevFunc(const void *a, const void *b) { - const input_t *inputA = (const input_t*)a; - const input_t *inputB = (const input_t*)b; - - if (inputA->ofs < inputB->ofs) - return -1; - if (inputA->ofs > inputB->ofs) - return 1; - return 0; + const input_t *inputA = (const input_t*)a; + const input_t *inputB = (const input_t*)b; + + if (inputA->ofs < inputB->ofs) + return -1; + if (inputA->ofs > inputB->ofs) + return 1; + return 0; } /* Sort the input objects and recalculate the indices for each input. */ static void SortDevObjects(SDL_Joystick *joystick) { - input_t *inputs = joystick->hwdata->Inputs; - int nButtons = 0; - int nHats = 0; - int nAxis = 0; - int n; - - SDL_qsort(inputs, joystick->hwdata->NumInputs, sizeof(input_t), SortDevFunc); - - for (n = 0; n < joystick->hwdata->NumInputs; n++) - { - switch (inputs[n].type) - { - case BUTTON: - inputs[n].num = nButtons; - nButtons++; - break; - - case HAT: - inputs[n].num = nHats; - nHats++; - break; - - case AXIS: - inputs[n].num = nAxis; - nAxis++; - break; - } - } + input_t *inputs = joystick->hwdata->Inputs; + int nButtons = 0; + int nHats = 0; + int nAxis = 0; + int n; + + SDL_qsort(inputs, joystick->hwdata->NumInputs, sizeof(input_t), SortDevFunc); + + for (n = 0; n < joystick->hwdata->NumInputs; n++) + { + switch (inputs[n].type) + { + case BUTTON: + inputs[n].num = nButtons; + nButtons++; + break; + + case HAT: + inputs[n].num = nHats; + nHats++; + break; + + case AXIS: + inputs[n].num = nAxis; + nAxis++; + break; + } + } } static BOOL CALLBACK @@ -1210,12 +1210,12 @@ EnumDevObjectsCallback(LPCDIDEVICEOBJECTINSTANCE dev, LPVOID pvRef) if (dev->dwType & DIDFT_BUTTON) { in->type = BUTTON; in->num = joystick->nbuttons; - in->ofs = DIJOFS_BUTTON( in->num ); + in->ofs = DIJOFS_BUTTON( in->num ); joystick->nbuttons++; } else if (dev->dwType & DIDFT_POV) { in->type = HAT; in->num = joystick->nhats; - in->ofs = DIJOFS_POV( in->num ); + in->ofs = DIJOFS_POV( in->num ); joystick->nhats++; } else if (dev->dwType & DIDFT_AXIS) { DIPROPRANGE diprg; @@ -1223,28 +1223,28 @@ EnumDevObjectsCallback(LPCDIDEVICEOBJECTINSTANCE dev, LPVOID pvRef) in->type = AXIS; in->num = joystick->naxes; - // work our the axis this guy maps too, thanks for the code icculus! - if ( !SDL_memcmp( &dev->guidType, &GUID_XAxis, sizeof(dev->guidType) ) ) - in->ofs = DIJOFS_X; - else if ( !SDL_memcmp( &dev->guidType, &GUID_YAxis, sizeof(dev->guidType) ) ) - in->ofs = DIJOFS_Y; - else if ( !SDL_memcmp( &dev->guidType, &GUID_ZAxis, sizeof(dev->guidType) ) ) - in->ofs = DIJOFS_Z; - else if ( !SDL_memcmp( &dev->guidType, &GUID_RxAxis, sizeof(dev->guidType) ) ) - in->ofs = DIJOFS_RX; - else if ( !SDL_memcmp( &dev->guidType, &GUID_RyAxis, sizeof(dev->guidType) ) ) - in->ofs = DIJOFS_RY; - else if ( !SDL_memcmp( &dev->guidType, &GUID_RzAxis, sizeof(dev->guidType) ) ) - in->ofs = DIJOFS_RZ; - else if ( !SDL_memcmp( &dev->guidType, &GUID_Slider, sizeof(dev->guidType) ) ) - { - in->ofs = DIJOFS_SLIDER( joystick->hwdata->NumSliders ); - ++joystick->hwdata->NumSliders; - } - else - { - return DIENUM_CONTINUE; // not an axis we can grok - } + /* work our the axis this guy maps too, thanks for the code icculus! */ + if ( !SDL_memcmp( &dev->guidType, &GUID_XAxis, sizeof(dev->guidType) ) ) + in->ofs = DIJOFS_X; + else if ( !SDL_memcmp( &dev->guidType, &GUID_YAxis, sizeof(dev->guidType) ) ) + in->ofs = DIJOFS_Y; + else if ( !SDL_memcmp( &dev->guidType, &GUID_ZAxis, sizeof(dev->guidType) ) ) + in->ofs = DIJOFS_Z; + else if ( !SDL_memcmp( &dev->guidType, &GUID_RxAxis, sizeof(dev->guidType) ) ) + in->ofs = DIJOFS_RX; + else if ( !SDL_memcmp( &dev->guidType, &GUID_RyAxis, sizeof(dev->guidType) ) ) + in->ofs = DIJOFS_RY; + else if ( !SDL_memcmp( &dev->guidType, &GUID_RzAxis, sizeof(dev->guidType) ) ) + in->ofs = DIJOFS_RZ; + else if ( !SDL_memcmp( &dev->guidType, &GUID_Slider, sizeof(dev->guidType) ) ) + { + in->ofs = DIJOFS_SLIDER( joystick->hwdata->NumSliders ); + ++joystick->hwdata->NumSliders; + } + else + { + return DIENUM_CONTINUE; /* not an axis we can grok */ + } diprg.diph.dwSize = sizeof(diprg); diprg.diph.dwHeaderSize = sizeof(diprg.diph); @@ -1310,12 +1310,12 @@ SDL_SYS_JoystickUpdate_Polled(SDL_Joystick * joystick) sizeof(DIJOYSTATE2), &state); } - if ( result != DI_OK ) - { - joystick->hwdata->send_remove_event = 1; - joystick->hwdata->removed = 1; - return; - } + if ( result != DI_OK ) + { + joystick->hwdata->send_remove_event = 1; + joystick->hwdata->removed = 1; + return; + } /* Set each known axis, button and POV. */ for (i = 0; i < joystick->hwdata->NumInputs; ++i) { @@ -1402,11 +1402,11 @@ SDL_SYS_JoystickUpdate_Buffered(SDL_Joystick * joystick) /* Handle the events or punt */ if (FAILED(result)) - { - joystick->hwdata->send_remove_event = 1; - joystick->hwdata->removed = 1; + { + joystick->hwdata->send_remove_event = 1; + joystick->hwdata->removed = 1; return; - } + } for (i = 0; i < (int) numevents; ++i) { int j; @@ -1443,7 +1443,7 @@ SDL_SYS_JoystickUpdate_Buffered(SDL_Joystick * joystick) */ int ButtonChanged( int ButtonsNow, int ButtonsPrev, int ButtonMask ) { - return ( ButtonsNow & ButtonMask ) != ( ButtonsPrev & ButtonMask ); + return ( ButtonsNow & ButtonMask ) != ( ButtonsPrev & ButtonMask ); } /* Function to update the state of a XInput style joystick. @@ -1451,67 +1451,67 @@ int ButtonChanged( int ButtonsNow, int ButtonsPrev, int ButtonMask ) void SDL_SYS_JoystickUpdate_XInput(SDL_Joystick * joystick) { - HRESULT result; - - if ( !XINPUTGETSTATE ) - return; - - result = XINPUTGETSTATE( joystick->hwdata->userid, &joystick->hwdata->XInputState[joystick->hwdata->currentXInputSlot] ); - if ( result == ERROR_DEVICE_NOT_CONNECTED ) - { - joystick->hwdata->send_remove_event = 1; - joystick->hwdata->removed = 1; - return; - } - - // only fire events if the data changed from last time - if ( joystick->hwdata->XInputState[joystick->hwdata->currentXInputSlot].dwPacketNumber != 0 - && joystick->hwdata->XInputState[joystick->hwdata->currentXInputSlot].dwPacketNumber != joystick->hwdata->XInputState[joystick->hwdata->currentXInputSlot^1].dwPacketNumber ) - { - XINPUT_STATE_EX *pXInputState = &joystick->hwdata->XInputState[joystick->hwdata->currentXInputSlot]; - XINPUT_STATE_EX *pXInputStatePrev = &joystick->hwdata->XInputState[joystick->hwdata->currentXInputSlot ^ 1]; - - SDL_PrivateJoystickAxis(joystick, 0, (Sint16)pXInputState->Gamepad.sThumbLX ); - SDL_PrivateJoystickAxis(joystick, 1, (Sint16)(-1*pXInputState->Gamepad.sThumbLY-1) ); - SDL_PrivateJoystickAxis(joystick, 2, (Sint16)pXInputState->Gamepad.sThumbRX ); - SDL_PrivateJoystickAxis(joystick, 3, (Sint16)(-1*pXInputState->Gamepad.sThumbRY-1) ); - SDL_PrivateJoystickAxis(joystick, 4, (Sint16)((int)pXInputState->Gamepad.bLeftTrigger*32767/255) ); - SDL_PrivateJoystickAxis(joystick, 5, (Sint16)((int)pXInputState->Gamepad.bRightTrigger*32767/255) ); - - if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_DPAD_UP ) ) - SDL_PrivateJoystickButton(joystick, 0, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_UP ? SDL_PRESSED : SDL_RELEASED ); - if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_DPAD_DOWN ) ) - SDL_PrivateJoystickButton(joystick, 1, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_DOWN ? SDL_PRESSED : SDL_RELEASED ); - if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_DPAD_LEFT ) ) - SDL_PrivateJoystickButton(joystick, 2, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_LEFT ? SDL_PRESSED : SDL_RELEASED ); - if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_DPAD_RIGHT ) ) - SDL_PrivateJoystickButton(joystick, 3, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_RIGHT ? SDL_PRESSED : SDL_RELEASED ); - if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_START ) ) - SDL_PrivateJoystickButton(joystick, 4, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_START ? SDL_PRESSED : SDL_RELEASED ); - if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_BACK ) ) - SDL_PrivateJoystickButton(joystick, 5, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_BACK ? SDL_PRESSED : SDL_RELEASED ); - if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_LEFT_THUMB ) ) - SDL_PrivateJoystickButton(joystick, 6, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_LEFT_THUMB ? SDL_PRESSED : SDL_RELEASED ); - if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_RIGHT_THUMB ) ) - SDL_PrivateJoystickButton(joystick, 7, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_THUMB ? SDL_PRESSED : SDL_RELEASED ); - if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_LEFT_SHOULDER ) ) - SDL_PrivateJoystickButton(joystick, 8, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_LEFT_SHOULDER ? SDL_PRESSED : SDL_RELEASED ); - if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_RIGHT_SHOULDER ) ) - SDL_PrivateJoystickButton(joystick, 9, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_SHOULDER ? SDL_PRESSED : SDL_RELEASED ); - if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_A ) ) - SDL_PrivateJoystickButton(joystick, 10, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_A ? SDL_PRESSED : SDL_RELEASED ); - if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_B ) ) - SDL_PrivateJoystickButton(joystick, 11, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_B ? SDL_PRESSED : SDL_RELEASED ); - if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_X ) ) - SDL_PrivateJoystickButton(joystick, 12, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_X ? SDL_PRESSED : SDL_RELEASED ); - if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_Y ) ) - SDL_PrivateJoystickButton(joystick, 13, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_Y ? SDL_PRESSED : SDL_RELEASED ); - if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, 0x400 ) ) - SDL_PrivateJoystickButton(joystick, 14, pXInputState->Gamepad.wButtons & 0x400 ? SDL_PRESSED : SDL_RELEASED ); // 0x400 is the undocumented code for the guide button - - joystick->hwdata->currentXInputSlot ^= 1; - - } + HRESULT result; + + if ( !XINPUTGETSTATE ) + return; + + result = XINPUTGETSTATE( joystick->hwdata->userid, &joystick->hwdata->XInputState[joystick->hwdata->currentXInputSlot] ); + if ( result == ERROR_DEVICE_NOT_CONNECTED ) + { + joystick->hwdata->send_remove_event = 1; + joystick->hwdata->removed = 1; + return; + } + + /* only fire events if the data changed from last time */ + if ( joystick->hwdata->XInputState[joystick->hwdata->currentXInputSlot].dwPacketNumber != 0 + && joystick->hwdata->XInputState[joystick->hwdata->currentXInputSlot].dwPacketNumber != joystick->hwdata->XInputState[joystick->hwdata->currentXInputSlot^1].dwPacketNumber ) + { + XINPUT_STATE_EX *pXInputState = &joystick->hwdata->XInputState[joystick->hwdata->currentXInputSlot]; + XINPUT_STATE_EX *pXInputStatePrev = &joystick->hwdata->XInputState[joystick->hwdata->currentXInputSlot ^ 1]; + + SDL_PrivateJoystickAxis(joystick, 0, (Sint16)pXInputState->Gamepad.sThumbLX ); + SDL_PrivateJoystickAxis(joystick, 1, (Sint16)(-1*pXInputState->Gamepad.sThumbLY-1) ); + SDL_PrivateJoystickAxis(joystick, 2, (Sint16)pXInputState->Gamepad.sThumbRX ); + SDL_PrivateJoystickAxis(joystick, 3, (Sint16)(-1*pXInputState->Gamepad.sThumbRY-1) ); + SDL_PrivateJoystickAxis(joystick, 4, (Sint16)((int)pXInputState->Gamepad.bLeftTrigger*32767/255) ); + SDL_PrivateJoystickAxis(joystick, 5, (Sint16)((int)pXInputState->Gamepad.bRightTrigger*32767/255) ); + + if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_DPAD_UP ) ) + SDL_PrivateJoystickButton(joystick, 0, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_UP ? SDL_PRESSED : SDL_RELEASED ); + if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_DPAD_DOWN ) ) + SDL_PrivateJoystickButton(joystick, 1, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_DOWN ? SDL_PRESSED : SDL_RELEASED ); + if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_DPAD_LEFT ) ) + SDL_PrivateJoystickButton(joystick, 2, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_LEFT ? SDL_PRESSED : SDL_RELEASED ); + if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_DPAD_RIGHT ) ) + SDL_PrivateJoystickButton(joystick, 3, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_RIGHT ? SDL_PRESSED : SDL_RELEASED ); + if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_START ) ) + SDL_PrivateJoystickButton(joystick, 4, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_START ? SDL_PRESSED : SDL_RELEASED ); + if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_BACK ) ) + SDL_PrivateJoystickButton(joystick, 5, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_BACK ? SDL_PRESSED : SDL_RELEASED ); + if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_LEFT_THUMB ) ) + SDL_PrivateJoystickButton(joystick, 6, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_LEFT_THUMB ? SDL_PRESSED : SDL_RELEASED ); + if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_RIGHT_THUMB ) ) + SDL_PrivateJoystickButton(joystick, 7, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_THUMB ? SDL_PRESSED : SDL_RELEASED ); + if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_LEFT_SHOULDER ) ) + SDL_PrivateJoystickButton(joystick, 8, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_LEFT_SHOULDER ? SDL_PRESSED : SDL_RELEASED ); + if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_RIGHT_SHOULDER ) ) + SDL_PrivateJoystickButton(joystick, 9, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_SHOULDER ? SDL_PRESSED : SDL_RELEASED ); + if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_A ) ) + SDL_PrivateJoystickButton(joystick, 10, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_A ? SDL_PRESSED : SDL_RELEASED ); + if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_B ) ) + SDL_PrivateJoystickButton(joystick, 11, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_B ? SDL_PRESSED : SDL_RELEASED ); + if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_X ) ) + SDL_PrivateJoystickButton(joystick, 12, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_X ? SDL_PRESSED : SDL_RELEASED ); + if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_Y ) ) + SDL_PrivateJoystickButton(joystick, 13, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_Y ? SDL_PRESSED : SDL_RELEASED ); + if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, 0x400 ) ) + SDL_PrivateJoystickButton(joystick, 14, pXInputState->Gamepad.wButtons & 0x400 ? SDL_PRESSED : SDL_RELEASED ); /* 0x400 is the undocumented code for the guide button */ + + joystick->hwdata->currentXInputSlot ^= 1; + + } } @@ -1575,94 +1575,94 @@ SDL_SYS_JoystickUpdate(SDL_Joystick * joystick) { HRESULT result; - if ( joystick->closed || !joystick->hwdata ) - return; - - if (joystick->hwdata->bXInputDevice) - { - SDL_SYS_JoystickUpdate_XInput(joystick); - } - else - { - result = IDirectInputDevice8_Poll(joystick->hwdata->InputDevice); - if (result == DIERR_INPUTLOST || result == DIERR_NOTACQUIRED) { - IDirectInputDevice8_Acquire(joystick->hwdata->InputDevice); - IDirectInputDevice8_Poll(joystick->hwdata->InputDevice); - } - - if (joystick->hwdata->buffered) - SDL_SYS_JoystickUpdate_Buffered(joystick); - else - SDL_SYS_JoystickUpdate_Polled(joystick); - } - - if ( joystick->hwdata->removed ) - { - joystick->closed = 1; - joystick->uncentered = 1; - } + if ( joystick->closed || !joystick->hwdata ) + return; + + if (joystick->hwdata->bXInputDevice) + { + SDL_SYS_JoystickUpdate_XInput(joystick); + } + else + { + result = IDirectInputDevice8_Poll(joystick->hwdata->InputDevice); + if (result == DIERR_INPUTLOST || result == DIERR_NOTACQUIRED) { + IDirectInputDevice8_Acquire(joystick->hwdata->InputDevice); + IDirectInputDevice8_Poll(joystick->hwdata->InputDevice); + } + + if (joystick->hwdata->buffered) + SDL_SYS_JoystickUpdate_Buffered(joystick); + else + SDL_SYS_JoystickUpdate_Polled(joystick); + } + + if ( joystick->hwdata->removed ) + { + joystick->closed = 1; + joystick->uncentered = 1; + } } /* Function to close a joystick after use */ void SDL_SYS_JoystickClose(SDL_Joystick * joystick) { - if ( joystick->hwdata->bXInputDevice ) - { - JoyStick_DeviceData *joysticklist = SYS_Joystick; - // scan the opened joysticks and clear the userid for this instance - for( ; joysticklist; joysticklist = joysticklist->pNext) - { - if ( joysticklist->bXInputDevice && joysticklist->nInstanceID == joystick->instance_id ) - { - joysticklist->XInputUserId = INVALID_XINPUT_USERID; - } - } - - } - else - { - IDirectInputDevice8_Unacquire(joystick->hwdata->InputDevice); - IDirectInputDevice8_Release(joystick->hwdata->InputDevice); - } + if ( joystick->hwdata->bXInputDevice ) + { + JoyStick_DeviceData *joysticklist = SYS_Joystick; + /* scan the opened joysticks and clear the userid for this instance */ + for( ; joysticklist; joysticklist = joysticklist->pNext) + { + if ( joysticklist->bXInputDevice && joysticklist->nInstanceID == joystick->instance_id ) + { + joysticklist->XInputUserId = INVALID_XINPUT_USERID; + } + } + + } + else + { + IDirectInputDevice8_Unacquire(joystick->hwdata->InputDevice); + IDirectInputDevice8_Release(joystick->hwdata->InputDevice); + } if (joystick->hwdata != NULL) { /* free system specific hardware data */ SDL_free(joystick->hwdata); } - joystick->closed = 1; + joystick->closed = 1; } /* Function to perform any system-specific joystick related cleanup */ void SDL_SYS_JoystickQuit(void) { - JoyStick_DeviceData *device = SYS_Joystick; - - while ( device ) - { - JoyStick_DeviceData *device_next = device->pNext; - SDL_free(device->joystickname); - SDL_free(device); - device = device_next; - } - SYS_Joystick = NULL; - - if ( s_threadJoystick ) - { - SDL_LockMutex( s_mutexJoyStickEnum ); - s_bJoystickThreadQuit = SDL_TRUE; - SDL_CondBroadcast( s_condJoystickThread ); // signal the joystick thread to quit - SDL_UnlockMutex( s_mutexJoyStickEnum ); - SDL_WaitThread( s_threadJoystick, NULL ); // wait for it to bugger off - - SDL_DestroyMutex( s_mutexJoyStickEnum ); - SDL_DestroyCond( s_condJoystickThread ); - s_condJoystickThread= NULL; - s_mutexJoyStickEnum = NULL; - s_threadJoystick = NULL; - } + JoyStick_DeviceData *device = SYS_Joystick; + + while ( device ) + { + JoyStick_DeviceData *device_next = device->pNext; + SDL_free(device->joystickname); + SDL_free(device); + device = device_next; + } + SYS_Joystick = NULL; + + if ( s_threadJoystick ) + { + SDL_LockMutex( s_mutexJoyStickEnum ); + s_bJoystickThreadQuit = SDL_TRUE; + SDL_CondBroadcast( s_condJoystickThread ); /* signal the joystick thread to quit */ + SDL_UnlockMutex( s_mutexJoyStickEnum ); + SDL_WaitThread( s_threadJoystick, NULL ); /* wait for it to bugger off */ + + SDL_DestroyMutex( s_mutexJoyStickEnum ); + SDL_DestroyCond( s_condJoystickThread ); + s_condJoystickThread= NULL; + s_mutexJoyStickEnum = NULL; + s_threadJoystick = NULL; + } if (dinput != NULL) { IDirectInput8_Release(dinput); @@ -1674,11 +1674,11 @@ SDL_SYS_JoystickQuit(void) coinitialized = SDL_FALSE; } - if ( s_pKnownJoystickGUIDs ) - { - SDL_free( s_pKnownJoystickGUIDs ); - s_pKnownJoystickGUIDs = NULL; - } + if ( s_pKnownJoystickGUIDs ) + { + SDL_free( s_pKnownJoystickGUIDs ); + s_pKnownJoystickGUIDs = NULL; + } if (s_bXInputEnabled) { WIN_UnloadXInputDLL(); @@ -1689,30 +1689,30 @@ SDL_SYS_JoystickQuit(void) /* return the stable device guid for this device index */ SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID( int device_index ) { - JoyStick_DeviceData *device = SYS_Joystick; - int index; + JoyStick_DeviceData *device = SYS_Joystick; + int index; - for (index = device_index; index > 0; index--) - device = device->pNext; + for (index = device_index; index > 0; index--) + device = device->pNext; - return device->guid; + return device->guid; } SDL_JoystickGUID SDL_SYS_JoystickGetGUID(SDL_Joystick * joystick) { - return joystick->hwdata->guid; + return joystick->hwdata->guid; } /* return SDL_TRUE if this device is using XInput */ SDL_bool SDL_SYS_IsXInputDeviceIndex(int device_index) { - JoyStick_DeviceData *device = SYS_Joystick; - int index; + JoyStick_DeviceData *device = SYS_Joystick; + int index; - for (index = device_index; index > 0; index--) - device = device->pNext; + for (index = device_index; index > 0; index--) + device = device->pNext; - return device->bXInputDevice; + return device->bXInputDevice; } #endif /* SDL_JOYSTICK_DINPUT */ diff --git a/src/joystick/windows/SDL_dxjoystick_c.h b/src/joystick/windows/SDL_dxjoystick_c.h index 564a566bb..01cfca970 100644 --- a/src/joystick/windows/SDL_dxjoystick_c.h +++ b/src/joystick/windows/SDL_dxjoystick_c.h @@ -23,10 +23,10 @@ #ifndef SDL_JOYSTICK_DINPUT_H /* DirectInput joystick driver; written by Glenn Maynard, based on Andrei de - * A. Formiga's WINMM driver. + * A. Formiga's WINMM driver. * * Hats and sliders are completely untested; the app I'm writing this for mostly - * doesn't use them and I don't own any joysticks with them. + * doesn't use them and I don't own any joysticks with them. * * We don't bother to use event notification here. It doesn't seem to work * with polled devices, and it's fine to call IDirectInputDevice2_GetDeviceData and @@ -57,7 +57,7 @@ typedef struct DWORD dwPaddingReserved; } XINPUT_GAMEPAD_EX; -typedef struct +typedef struct { DWORD dwPacketNumber; XINPUT_GAMEPAD_EX Gamepad; @@ -65,23 +65,23 @@ typedef struct /* Forward decl's for XInput API's we load dynamically and use if available */ typedef DWORD (WINAPI *XInputGetState_t) - ( - DWORD dwUserIndex, // [in] Index of the gamer associated with the device - XINPUT_STATE_EX* pState // [out] Receives the current state - ); + ( + DWORD dwUserIndex, /* [in] Index of the gamer associated with the device */ + XINPUT_STATE_EX* pState /* [out] Receives the current state */ + ); typedef DWORD (WINAPI *XInputSetState_t) - ( - DWORD dwUserIndex, // [in] Index of the gamer associated with the device - XINPUT_VIBRATION* pVibration // [in, out] The vibration information to send to the controller - ); + ( + DWORD dwUserIndex, /* [in] Index of the gamer associated with the device */ + XINPUT_VIBRATION* pVibration /* [in, out] The vibration information to send to the controller */ + ); typedef DWORD (WINAPI *XInputGetCapabilities_t) - ( - DWORD dwUserIndex, // [in] Index of the gamer associated with the device - DWORD dwFlags, // [in] Input flags that identify the device type - XINPUT_CAPABILITIES* pCapabilities // [out] Receives the capabilities - ); + ( + DWORD dwUserIndex, /* [in] Index of the gamer associated with the device */ + DWORD dwFlags, /* [in] Input flags that identify the device type */ + XINPUT_CAPABILITIES* pCapabilities /* [out] Receives the capabilities */ + ); extern int WIN_LoadXInputDLL(void); extern void WIN_UnloadXInputDLL(void); @@ -89,11 +89,11 @@ extern void WIN_UnloadXInputDLL(void); extern XInputGetState_t SDL_XInputGetState; extern XInputSetState_t SDL_XInputSetState; extern XInputGetCapabilities_t SDL_XInputGetCapabilities; -extern DWORD SDL_XInputVersion; // ((major << 16) & 0xFF00) | (minor & 0xFF) +extern DWORD SDL_XInputVersion; /* ((major << 16) & 0xFF00) | (minor & 0xFF) */ -#define XINPUTGETSTATE SDL_XInputGetState -#define XINPUTSETSTATE SDL_XInputSetState -#define XINPUTGETCAPABILITIES SDL_XInputGetCapabilities +#define XINPUTGETSTATE SDL_XInputGetState +#define XINPUTSETSTATE SDL_XInputSetState +#define XINPUTGETCAPABILITIES SDL_XInputGetCapabilities #define INVALID_XINPUT_USERID 255 #define SDL_XINPUT_MAX_DEVICES 4 @@ -102,7 +102,7 @@ extern DWORD SDL_XInputVersion; // ((major << 16) & 0xFF00) | (minor & 0xFF) #endif -#define MAX_INPUTS 256 /* each joystick can have up to 256 inputs */ +#define MAX_INPUTS 256 /* each joystick can have up to 256 inputs */ /* local types */ @@ -127,18 +127,18 @@ struct joystick_hwdata LPDIRECTINPUTDEVICE8 InputDevice; DIDEVCAPS Capabilities; int buffered; - SDL_JoystickGUID guid; + SDL_JoystickGUID guid; input_t Inputs[MAX_INPUTS]; int NumInputs; - int NumSliders; - Uint8 removed; - Uint8 send_remove_event; - Uint8 bXInputDevice; // 1 if this device supports using the xinput API rather than DirectInput - Uint8 bXInputHaptic; // Supports force feedback via XInput. - Uint8 userid; // XInput userid index for this joystick - Uint8 currentXInputSlot; // the current position to write to in XInputState below, used so we can compare old and new values - XINPUT_STATE_EX XInputState[2]; + int NumSliders; + Uint8 removed; + Uint8 send_remove_event; + Uint8 bXInputDevice; /* 1 if this device supports using the xinput API rather than DirectInput */ + Uint8 bXInputHaptic; /* Supports force feedback via XInput. */ + Uint8 userid; /* XInput userid index for this joystick */ + Uint8 currentXInputSlot; /* the current position to write to in XInputState below, used so we can compare old and new values */ + XINPUT_STATE_EX XInputState[2]; }; #endif /* SDL_JOYSTICK_DINPUT_H */ diff --git a/src/joystick/windows/SDL_mmjoystick.c b/src/joystick/windows/SDL_mmjoystick.c index 73ad7fb95..413053f14 100644 --- a/src/joystick/windows/SDL_mmjoystick.c +++ b/src/joystick/windows/SDL_mmjoystick.c @@ -33,14 +33,14 @@ #include "../SDL_sysjoystick.h" #include "../SDL_joystick_c.h" -#define MAX_JOYSTICKS 16 -#define MAX_AXES 6 /* each joystick can have up to 6 axes */ -#define MAX_BUTTONS 32 /* and 32 buttons */ -#define AXIS_MIN -32768 /* minimum value for axis coordinate */ -#define AXIS_MAX 32767 /* maximum value for axis coordinate */ +#define MAX_JOYSTICKS 16 +#define MAX_AXES 6 /* each joystick can have up to 6 axes */ +#define MAX_BUTTONS 32 /* and 32 buttons */ +#define AXIS_MIN -32768 /* minimum value for axis coordinate */ +#define AXIS_MAX 32767 /* maximum value for axis coordinate */ /* limit axis to 256 possible positions to filter out noise */ #define JOY_AXIS_THRESHOLD (((AXIS_MAX)-(AXIS_MIN))/256) -#define JOY_BUTTON_FLAG(n) (1<name; SDL_zero( guid ); SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) ); diff --git a/src/main/beos/SDL_BApp.h b/src/main/beos/SDL_BApp.h index 5bde94c18..2a64455b6 100644 --- a/src/main/beos/SDL_BApp.h +++ b/src/main/beos/SDL_BApp.h @@ -54,24 +54,24 @@ class SDL_BWin; /* Message constants */ enum ToSDL { - /* Intercepted by BWindow on its way to BView */ - BAPP_MOUSE_MOVED, - BAPP_MOUSE_BUTTON, - BAPP_MOUSE_WHEEL, - BAPP_KEY, - BAPP_REPAINT, /* from _UPDATE_ */ - /* From BWindow */ - BAPP_MAXIMIZE, /* from B_ZOOM */ - BAPP_MINIMIZE, - BAPP_RESTORE, /* TODO: IMPLEMENT! */ - BAPP_SHOW, - BAPP_HIDE, - BAPP_MOUSE_FOCUS, /* caused by MOUSE_MOVE */ - BAPP_KEYBOARD_FOCUS, /* from WINDOW_ACTIVATED */ - BAPP_WINDOW_CLOSE_REQUESTED, - BAPP_WINDOW_MOVED, - BAPP_WINDOW_RESIZED, - BAPP_SCREEN_CHANGED + /* Intercepted by BWindow on its way to BView */ + BAPP_MOUSE_MOVED, + BAPP_MOUSE_BUTTON, + BAPP_MOUSE_WHEEL, + BAPP_KEY, + BAPP_REPAINT, /* from _UPDATE_ */ + /* From BWindow */ + BAPP_MAXIMIZE, /* from B_ZOOM */ + BAPP_MINIMIZE, + BAPP_RESTORE, /* TODO: IMPLEMENT! */ + BAPP_SHOW, + BAPP_HIDE, + BAPP_MOUSE_FOCUS, /* caused by MOUSE_MOVE */ + BAPP_KEYBOARD_FOCUS, /* from WINDOW_ACTIVATED */ + BAPP_WINDOW_CLOSE_REQUESTED, + BAPP_WINDOW_MOVED, + BAPP_WINDOW_RESIZED, + BAPP_SCREEN_CHANGED }; @@ -79,302 +79,302 @@ enum ToSDL { /* Create a descendant of BApplication */ class SDL_BApp : public BApplication { public: - SDL_BApp(const char* signature) : - BApplication(signature) { - _current_context = NULL; - } - - - virtual ~SDL_BApp() { - } - - - - /* Event-handling functions */ - virtual void MessageReceived(BMessage* message) { - /* Sort out SDL-related messages */ + SDL_BApp(const char* signature) : + BApplication(signature) { + _current_context = NULL; + } + + + virtual ~SDL_BApp() { + } + + + + /* Event-handling functions */ + virtual void MessageReceived(BMessage* message) { + /* Sort out SDL-related messages */ switch ( message->what ) { case BAPP_MOUSE_MOVED: - _HandleMouseMove(message); - break; - - case BAPP_MOUSE_BUTTON: - _HandleMouseButton(message); - break; - - case BAPP_MOUSE_WHEEL: - _HandleMouseWheel(message); - break; - - case BAPP_KEY: - _HandleKey(message); - break; - - case BAPP_REPAINT: - _HandleBasicWindowEvent(message, SDL_WINDOWEVENT_EXPOSED); - break; - - case BAPP_MAXIMIZE: - _HandleBasicWindowEvent(message, SDL_WINDOWEVENT_MAXIMIZED); - break; - - case BAPP_MINIMIZE: - _HandleBasicWindowEvent(message, SDL_WINDOWEVENT_MINIMIZED); - break; - - case BAPP_SHOW: - _HandleBasicWindowEvent(message, SDL_WINDOWEVENT_SHOWN); - break; - - case BAPP_HIDE: - _HandleBasicWindowEvent(message, SDL_WINDOWEVENT_HIDDEN); - break; - - case BAPP_MOUSE_FOCUS: - _HandleMouseFocus(message); - break; - - case BAPP_KEYBOARD_FOCUS: - _HandleKeyboardFocus(message); - break; - - case BAPP_WINDOW_CLOSE_REQUESTED: - _HandleBasicWindowEvent(message, SDL_WINDOWEVENT_CLOSE); - break; - - case BAPP_WINDOW_MOVED: - _HandleWindowMoved(message); - break; - - case BAPP_WINDOW_RESIZED: - _HandleWindowResized(message); - break; - - case BAPP_SCREEN_CHANGED: - /* TODO: Handle screen resize or workspace change */ - break; + _HandleMouseMove(message); + break; + + case BAPP_MOUSE_BUTTON: + _HandleMouseButton(message); + break; + + case BAPP_MOUSE_WHEEL: + _HandleMouseWheel(message); + break; + + case BAPP_KEY: + _HandleKey(message); + break; + + case BAPP_REPAINT: + _HandleBasicWindowEvent(message, SDL_WINDOWEVENT_EXPOSED); + break; + + case BAPP_MAXIMIZE: + _HandleBasicWindowEvent(message, SDL_WINDOWEVENT_MAXIMIZED); + break; + + case BAPP_MINIMIZE: + _HandleBasicWindowEvent(message, SDL_WINDOWEVENT_MINIMIZED); + break; + + case BAPP_SHOW: + _HandleBasicWindowEvent(message, SDL_WINDOWEVENT_SHOWN); + break; + + case BAPP_HIDE: + _HandleBasicWindowEvent(message, SDL_WINDOWEVENT_HIDDEN); + break; + + case BAPP_MOUSE_FOCUS: + _HandleMouseFocus(message); + break; + + case BAPP_KEYBOARD_FOCUS: + _HandleKeyboardFocus(message); + break; + + case BAPP_WINDOW_CLOSE_REQUESTED: + _HandleBasicWindowEvent(message, SDL_WINDOWEVENT_CLOSE); + break; + + case BAPP_WINDOW_MOVED: + _HandleWindowMoved(message); + break; + + case BAPP_WINDOW_RESIZED: + _HandleWindowResized(message); + break; + + case BAPP_SCREEN_CHANGED: + /* TODO: Handle screen resize or workspace change */ + break; default: BApplication::MessageReceived(message); break; } } - + /* Window creation/destruction methods */ int32 GetID(SDL_Window *win) { - int32 i; - for(i = 0; i < _GetNumWindowSlots(); ++i) { - if( GetSDLWindow(i) == NULL ) { - _SetSDLWindow(win, i); - return i; - } - } - - /* Expand the vector if all slots are full */ - if( i == _GetNumWindowSlots() ) { - _PushBackWindow(win); - return i; - } - - /* TODO: error handling */ - return 0; + int32 i; + for(i = 0; i < _GetNumWindowSlots(); ++i) { + if( GetSDLWindow(i) == NULL ) { + _SetSDLWindow(win, i); + return i; + } + } + + /* Expand the vector if all slots are full */ + if( i == _GetNumWindowSlots() ) { + _PushBackWindow(win); + return i; + } + + /* TODO: error handling */ + return 0; } - + /* FIXME: Bad coding practice, but I can't include SDL_BWin.h here. Is there another way to do this? */ void ClearID(SDL_BWin *bwin); /* Defined in SDL_BeApp.cc */ - - - SDL_Window *GetSDLWindow(int32 winID) { - return _window_map[winID]; - } - + + + SDL_Window *GetSDLWindow(int32 winID) { + return _window_map[winID]; + } + void SetCurrentContext(BGLView *newContext) { - if(_current_context) - _current_context->UnlockGL(); - _current_context = newContext; - _current_context->LockGL(); + if(_current_context) + _current_context->UnlockGL(); + _current_context = newContext; + _current_context->LockGL(); } private: - /* Event management */ - void _HandleBasicWindowEvent(BMessage *msg, int32 sdlEventType) { - SDL_Window *win; - int32 winID; - if( - !_GetWinID(msg, &winID) - ) { - return; - } - win = GetSDLWindow(winID); - SDL_SendWindowEvent(win, sdlEventType, 0, 0); - } - - void _HandleMouseMove(BMessage *msg) { - SDL_Window *win; - int32 winID; - int32 x = 0, y = 0; - if( - !_GetWinID(msg, &winID) || - msg->FindInt32("x", &x) != B_OK || /* x movement */ - msg->FindInt32("y", &y) != B_OK /* y movement */ - ) { - return; - } - win = GetSDLWindow(winID); - SDL_SendMouseMotion(win, 0, 0, x, y); - - /* Tell the application that the mouse passed over, redraw needed */ - BE_UpdateWindowFramebuffer(NULL,win,NULL,-1); - } - - void _HandleMouseButton(BMessage *msg) { - SDL_Window *win; - int32 winID; - int32 button, state; /* left/middle/right, pressed/released */ - if( - !_GetWinID(msg, &winID) || - msg->FindInt32("button-id", &button) != B_OK || - msg->FindInt32("button-state", &state) != B_OK - ) { - return; - } - win = GetSDLWindow(winID); - SDL_SendMouseButton(win, 0, state, button); - } - - void _HandleMouseWheel(BMessage *msg) { - SDL_Window *win; - int32 winID; - int32 xTicks, yTicks; - if( - !_GetWinID(msg, &winID) || - msg->FindInt32("xticks", &xTicks) != B_OK || - msg->FindInt32("yticks", &yTicks) != B_OK - ) { - return; - } - win = GetSDLWindow(winID); - SDL_SendMouseWheel(win, 0, xTicks, yTicks); - } - - void _HandleKey(BMessage *msg) { - int32 scancode, state; /* scancode, pressed/released */ - if( - msg->FindInt32("key-state", &state) != B_OK || - msg->FindInt32("key-scancode", &scancode) != B_OK - ) { - return; - } - - /* Make sure this isn't a repeated event (key pressed and held) */ - if(state == SDL_PRESSED && BE_GetKeyState(scancode) == SDL_PRESSED) { - return; - } - BE_SetKeyState(scancode, state); - SDL_SendKeyboardKey(state, BE_GetScancodeFromBeKey(scancode)); - } - - void _HandleMouseFocus(BMessage *msg) { - SDL_Window *win; - int32 winID; - bool bSetFocus; /* If false, lose focus */ - if( - !_GetWinID(msg, &winID) || - msg->FindBool("focusGained", &bSetFocus) != B_OK - ) { - return; - } - win = GetSDLWindow(winID); - if(bSetFocus) { - SDL_SetMouseFocus(win); - } else if(SDL_GetMouseFocus() == win) { - /* Only lose all focus if this window was the current focus */ - SDL_SetMouseFocus(NULL); - } - } - - void _HandleKeyboardFocus(BMessage *msg) { - SDL_Window *win; - int32 winID; - bool bSetFocus; /* If false, lose focus */ - if( - !_GetWinID(msg, &winID) || - msg->FindBool("focusGained", &bSetFocus) != B_OK - ) { - return; - } - win = GetSDLWindow(winID); - if(bSetFocus) { - SDL_SetKeyboardFocus(win); - } else if(SDL_GetKeyboardFocus() == win) { - /* Only lose all focus if this window was the current focus */ - SDL_SetKeyboardFocus(NULL); - } - } - - void _HandleWindowMoved(BMessage *msg) { - SDL_Window *win; - int32 winID; - int32 xPos, yPos; - /* Get the window id and new x/y position of the window */ - if( - !_GetWinID(msg, &winID) || - msg->FindInt32("window-x", &xPos) != B_OK || - msg->FindInt32("window-y", &yPos) != B_OK - ) { - return; - } - win = GetSDLWindow(winID); - SDL_SendWindowEvent(win, SDL_WINDOWEVENT_MOVED, xPos, yPos); - } - - void _HandleWindowResized(BMessage *msg) { - SDL_Window *win; - int32 winID; - int32 w, h; - /* Get the window id ]and new x/y position of the window */ - if( - !_GetWinID(msg, &winID) || - msg->FindInt32("window-w", &w) != B_OK || - msg->FindInt32("window-h", &h) != B_OK - ) { - return; - } - win = GetSDLWindow(winID); - SDL_SendWindowEvent(win, SDL_WINDOWEVENT_RESIZED, w, h); - } - - bool _GetWinID(BMessage *msg, int32 *winID) { - return msg->FindInt32("window-id", winID) == B_OK; - } - - - - /* Vector functions: Wraps vector stuff in case we need to change - implementation */ - void _SetSDLWindow(SDL_Window *win, int32 winID) { - _window_map[winID] = win; - } - - int32 _GetNumWindowSlots() { - return _window_map.size(); - } - - - void _PopBackWindow() { - _window_map.pop_back(); - } - - void _PushBackWindow(SDL_Window *win) { - _window_map.push_back(win); - } - - - /* Members */ - vector _window_map; /* Keeps track of SDL_Windows by index-id*/ - - display_mode *_saved_mode; - BGLView *_current_context; + /* Event management */ + void _HandleBasicWindowEvent(BMessage *msg, int32 sdlEventType) { + SDL_Window *win; + int32 winID; + if( + !_GetWinID(msg, &winID) + ) { + return; + } + win = GetSDLWindow(winID); + SDL_SendWindowEvent(win, sdlEventType, 0, 0); + } + + void _HandleMouseMove(BMessage *msg) { + SDL_Window *win; + int32 winID; + int32 x = 0, y = 0; + if( + !_GetWinID(msg, &winID) || + msg->FindInt32("x", &x) != B_OK || /* x movement */ + msg->FindInt32("y", &y) != B_OK /* y movement */ + ) { + return; + } + win = GetSDLWindow(winID); + SDL_SendMouseMotion(win, 0, 0, x, y); + + /* Tell the application that the mouse passed over, redraw needed */ + BE_UpdateWindowFramebuffer(NULL,win,NULL,-1); + } + + void _HandleMouseButton(BMessage *msg) { + SDL_Window *win; + int32 winID; + int32 button, state; /* left/middle/right, pressed/released */ + if( + !_GetWinID(msg, &winID) || + msg->FindInt32("button-id", &button) != B_OK || + msg->FindInt32("button-state", &state) != B_OK + ) { + return; + } + win = GetSDLWindow(winID); + SDL_SendMouseButton(win, 0, state, button); + } + + void _HandleMouseWheel(BMessage *msg) { + SDL_Window *win; + int32 winID; + int32 xTicks, yTicks; + if( + !_GetWinID(msg, &winID) || + msg->FindInt32("xticks", &xTicks) != B_OK || + msg->FindInt32("yticks", &yTicks) != B_OK + ) { + return; + } + win = GetSDLWindow(winID); + SDL_SendMouseWheel(win, 0, xTicks, yTicks); + } + + void _HandleKey(BMessage *msg) { + int32 scancode, state; /* scancode, pressed/released */ + if( + msg->FindInt32("key-state", &state) != B_OK || + msg->FindInt32("key-scancode", &scancode) != B_OK + ) { + return; + } + + /* Make sure this isn't a repeated event (key pressed and held) */ + if(state == SDL_PRESSED && BE_GetKeyState(scancode) == SDL_PRESSED) { + return; + } + BE_SetKeyState(scancode, state); + SDL_SendKeyboardKey(state, BE_GetScancodeFromBeKey(scancode)); + } + + void _HandleMouseFocus(BMessage *msg) { + SDL_Window *win; + int32 winID; + bool bSetFocus; /* If false, lose focus */ + if( + !_GetWinID(msg, &winID) || + msg->FindBool("focusGained", &bSetFocus) != B_OK + ) { + return; + } + win = GetSDLWindow(winID); + if(bSetFocus) { + SDL_SetMouseFocus(win); + } else if(SDL_GetMouseFocus() == win) { + /* Only lose all focus if this window was the current focus */ + SDL_SetMouseFocus(NULL); + } + } + + void _HandleKeyboardFocus(BMessage *msg) { + SDL_Window *win; + int32 winID; + bool bSetFocus; /* If false, lose focus */ + if( + !_GetWinID(msg, &winID) || + msg->FindBool("focusGained", &bSetFocus) != B_OK + ) { + return; + } + win = GetSDLWindow(winID); + if(bSetFocus) { + SDL_SetKeyboardFocus(win); + } else if(SDL_GetKeyboardFocus() == win) { + /* Only lose all focus if this window was the current focus */ + SDL_SetKeyboardFocus(NULL); + } + } + + void _HandleWindowMoved(BMessage *msg) { + SDL_Window *win; + int32 winID; + int32 xPos, yPos; + /* Get the window id and new x/y position of the window */ + if( + !_GetWinID(msg, &winID) || + msg->FindInt32("window-x", &xPos) != B_OK || + msg->FindInt32("window-y", &yPos) != B_OK + ) { + return; + } + win = GetSDLWindow(winID); + SDL_SendWindowEvent(win, SDL_WINDOWEVENT_MOVED, xPos, yPos); + } + + void _HandleWindowResized(BMessage *msg) { + SDL_Window *win; + int32 winID; + int32 w, h; + /* Get the window id ]and new x/y position of the window */ + if( + !_GetWinID(msg, &winID) || + msg->FindInt32("window-w", &w) != B_OK || + msg->FindInt32("window-h", &h) != B_OK + ) { + return; + } + win = GetSDLWindow(winID); + SDL_SendWindowEvent(win, SDL_WINDOWEVENT_RESIZED, w, h); + } + + bool _GetWinID(BMessage *msg, int32 *winID) { + return msg->FindInt32("window-id", winID) == B_OK; + } + + + + /* Vector functions: Wraps vector stuff in case we need to change + implementation */ + void _SetSDLWindow(SDL_Window *win, int32 winID) { + _window_map[winID] = win; + } + + int32 _GetNumWindowSlots() { + return _window_map.size(); + } + + + void _PopBackWindow() { + _window_map.pop_back(); + } + + void _PushBackWindow(SDL_Window *win) { + _window_map.push_back(win); + } + + + /* Members */ + vector _window_map; /* Keeps track of SDL_Windows by index-id*/ + + display_mode *_saved_mode; + BGLView *_current_context; }; #endif diff --git a/src/main/psp/SDL_psp_main.c b/src/main/psp/SDL_psp_main.c index 0286eadec..c60e8441b 100644 --- a/src/main/psp/SDL_psp_main.c +++ b/src/main/psp/SDL_psp_main.c @@ -30,7 +30,7 @@ /* If application's main() is redefined as SDL_main, and libSDLmain is linked, then this file will create the standard exit callback, define the PSP_MODULE_INFO macro, and exit back to the browser when - the program is finished. + the program is finished. You can still override other parameters in your own code if you desire, such as PSP_HEAP_SIZE_KB, PSP_MAIN_THREAD_ATTR, @@ -43,38 +43,38 @@ PSP_MODULE_INFO("SDL App", 0, 1, 1); int sdl_psp_exit_callback(int arg1, int arg2, void *common) { - exit(0); - return 0; + exit(0); + return 0; } int sdl_psp_callback_thread(SceSize args, void *argp) { - int cbid; - cbid = sceKernelCreateCallback("Exit Callback", - sdl_psp_exit_callback, NULL); - sceKernelRegisterExitCallback(cbid); - sceKernelSleepThreadCB(); - return 0; + int cbid; + cbid = sceKernelCreateCallback("Exit Callback", + sdl_psp_exit_callback, NULL); + sceKernelRegisterExitCallback(cbid); + sceKernelSleepThreadCB(); + return 0; } int sdl_psp_setup_callbacks(void) { - int thid = 0; - thid = sceKernelCreateThread("update_thread", - sdl_psp_callback_thread, 0x11, 0xFA0, 0, 0); - if(thid >= 0) - sceKernelStartThread(thid, 0, 0); - return thid; + int thid = 0; + thid = sceKernelCreateThread("update_thread", + sdl_psp_callback_thread, 0x11, 0xFA0, 0, 0); + if(thid >= 0) + sceKernelStartThread(thid, 0, 0); + return thid; } int main(int argc, char *argv[]) { - pspDebugScreenInit(); - sdl_psp_setup_callbacks(); + pspDebugScreenInit(); + sdl_psp_setup_callbacks(); - /* Register sceKernelExitGame() to be called when we exit */ - atexit(sceKernelExitGame); + /* Register sceKernelExitGame() to be called when we exit */ + atexit(sceKernelExitGame); - (void)SDL_main(argc, argv); - return 0; + (void)SDL_main(argc, argv); + return 0; } diff --git a/src/power/beos/SDL_syspower.c b/src/power/beos/SDL_syspower.c index 5c7b47cd2..8f172cc0e 100644 --- a/src/power/beos/SDL_syspower.c +++ b/src/power/beos/SDL_syspower.c @@ -50,8 +50,8 @@ SDL_GetPowerInfo_BeOS(SDL_PowerState * state, int *seconds, int *percent) uint8 battery_flags; uint8 battery_life; uint32 battery_time; - int rc; - + int rc; + if (fd == -1) { return SDL_FALSE; /* maybe some other method will work? */ } diff --git a/src/power/linux/SDL_syspower.c b/src/power/linux/SDL_syspower.c index a019e3992..d9616de25 100644 --- a/src/power/linux/SDL_syspower.c +++ b/src/power/linux/SDL_syspower.c @@ -64,7 +64,7 @@ load_acpi_file(const char *base, const char *node, const char *key, if (br < 0) { return SDL_FALSE; } - buf[br] = '\0'; // null-terminate the string. + buf[br] = '\0'; /* null-terminate the string. */ return SDL_TRUE; } @@ -342,7 +342,7 @@ SDL_GetPowerInfo_Linux_proc_apm(SDL_PowerState * state, return SDL_FALSE; } - buf[br] = '\0'; // null-terminate the string. + buf[br] = '\0'; /* null-terminate the string. */ if (!next_string(&ptr, &str)) { /* driver version */ return SDL_FALSE; } diff --git a/src/power/psp/SDL_syspower.c b/src/power/psp/SDL_syspower.c index 363c952d0..8c791bba4 100644 --- a/src/power/psp/SDL_syspower.c +++ b/src/power/psp/SDL_syspower.c @@ -25,7 +25,7 @@ #if SDL_POWER_PSP #include "SDL_power.h" -#include +#include SDL_bool @@ -34,31 +34,31 @@ SDL_GetPowerInfo_PSP(SDL_PowerState * state, int *seconds, { int battery = scePowerIsBatteryExist(); int plugged = scePowerIsPowerOnline(); - int charging = scePowerIsBatteryCharging(); + int charging = scePowerIsBatteryCharging(); *state = SDL_POWERSTATE_UNKNOWN; - *seconds = -1; - *percent = -1; - - if (!battery) { - *state = SDL_POWERSTATE_NO_BATTERY; - *seconds = -1; - *percent = -1; + *seconds = -1; + *percent = -1; + + if (!battery) { + *state = SDL_POWERSTATE_NO_BATTERY; + *seconds = -1; + *percent = -1; } else if (charging) { *state = SDL_POWERSTATE_CHARGING; - *percent = scePowerGetBatteryLifePercent(); - *seconds = scePowerGetBatteryLifeTime()*60; + *percent = scePowerGetBatteryLifePercent(); + *seconds = scePowerGetBatteryLifeTime()*60; } else if (plugged) { *state = SDL_POWERSTATE_CHARGED; - *percent = scePowerGetBatteryLifePercent(); - *seconds = scePowerGetBatteryLifeTime()*60; + *percent = scePowerGetBatteryLifePercent(); + *seconds = scePowerGetBatteryLifeTime()*60; } else { *state = SDL_POWERSTATE_ON_BATTERY; - *percent = scePowerGetBatteryLifePercent(); - *seconds = scePowerGetBatteryLifeTime()*60; + *percent = scePowerGetBatteryLifePercent(); + *seconds = scePowerGetBatteryLifeTime()*60; } - + return SDL_TRUE; /* always the definitive answer on PSP. */ } diff --git a/src/power/uikit/SDL_syspower.m b/src/power/uikit/SDL_syspower.m index cb309fcb4..3364da56e 100644 --- a/src/power/uikit/SDL_syspower.m +++ b/src/power/uikit/SDL_syspower.m @@ -30,7 +30,7 @@ #include "SDL_assert.h" #include "SDL_syspower.h" -// turn off the battery monitor if it's been more than X ms since last check. +/* turn off the battery monitor if it's been more than X ms since last check. */ static const int BATTERY_MONITORING_TIMEOUT = 3000; static Uint32 SDL_UIKitLastPowerInfoQuery = 0; @@ -41,7 +41,7 @@ const Uint32 prev = SDL_UIKitLastPowerInfoQuery; const UInt32 now = SDL_GetTicks(); const UInt32 ticks = now - prev; - // if timer wrapped (now < prev), shut down, too. + /* if timer wrapped (now < prev), shut down, too. */ if ((now < prev) || (ticks >= BATTERY_MONITORING_TIMEOUT)) { UIDevice *uidev = [UIDevice currentDevice]; SDL_assert([uidev isBatteryMonitoringEnabled] == YES); @@ -61,13 +61,14 @@ [uidev setBatteryMonitoringEnabled:YES]; } - // UIKit_GL_SwapWindow() (etc) will check this and disable the battery - // monitoring if the app hasn't queried it in the last X seconds. - // Apparently monitoring the battery burns battery life. :) - // Apple's docs say not to monitor the battery unless you need it. + /* UIKit_GL_SwapWindow() (etc) will check this and disable the battery + * monitoring if the app hasn't queried it in the last X seconds. + * Apparently monitoring the battery burns battery life. :) + * Apple's docs say not to monitor the battery unless you need it. + */ SDL_UIKitLastPowerInfoQuery = SDL_GetTicks(); - *seconds = -1; // no API to estimate this in UIKit. + *seconds = -1; /* no API to estimate this in UIKit. */ switch ([uidev batteryState]) { diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c index 3a8666d77..785e0b905 100644 --- a/src/render/SDL_render.c +++ b/src/render/SDL_render.c @@ -1601,7 +1601,7 @@ SDL_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture, if (!renderer->RenderCopyEx) { return SDL_SetError("Renderer does not support RenderCopyEx"); } - + real_srcrect.x = 0; real_srcrect.y = 0; real_srcrect.w = texture->w; diff --git a/src/render/SDL_yuv_mmx.c b/src/render/SDL_yuv_mmx.c index 6d6c000f3..b223d2d28 100644 --- a/src/render/SDL_yuv_mmx.c +++ b/src/render/SDL_yuv_mmx.c @@ -63,10 +63,10 @@ static mmx_t MMX_grn565 = { .uw = {0x07e0, 0x07e0, 0x07e0, 0x07e0} }; The MMX routine calculates 256bit=8RGB values in each cycle (4 for row1 & 4 for row2) - The red/green/blue.. coefficents are taken from the mpeg_play + The red/green/blue.. coefficents are taken from the mpeg_play player. They look nice, but I dont know if you can have better values, to avoid integer rounding errors. - + IMPORTANT: ========== @@ -84,152 +84,152 @@ void ColorRGBDitherYV12MMX1X( int *colortab, Uint32 *rgb_2_pix, Uint32 *row1; Uint32 *row2; - unsigned char* y = lum +cols*rows; // Pointer to the end + unsigned char* y = lum +cols*rows; /* Pointer to the end */ int x = 0; - row1 = (Uint32 *)out; // 32 bit target - row2 = (Uint32 *)out+cols+mod; // start of second row - mod = (mod+cols+mod)*4; // increment for row1 in byte + row1 = (Uint32 *)out; /* 32 bit target */ + row2 = (Uint32 *)out+cols+mod; /* start of second row */ + mod = (mod+cols+mod)*4; /* increment for row1 in byte */ __asm__ __volatile__ ( - // tap dance to workaround the inability to use %%ebx at will... - // move one thing to the stack... - "pushl $0\n" // save a slot on the stack. - "pushl %%ebx\n" // save %%ebx. - "movl %0, %%ebx\n" // put the thing in ebx. - "movl %%ebx,4(%%esp)\n" // put the thing in the stack slot. - "popl %%ebx\n" // get back %%ebx (the PIC register). + /* tap dance to workaround the inability to use %%ebx at will... */ + /* move one thing to the stack... */ + "pushl $0\n" /* save a slot on the stack. */ + "pushl %%ebx\n" /* save %%ebx. */ + "movl %0, %%ebx\n" /* put the thing in ebx. */ + "movl %%ebx,4(%%esp)\n" /* put the thing in the stack slot. */ + "popl %%ebx\n" /* get back %%ebx (the PIC register). */ ".align 8\n" "1:\n" - // create Cr (result in mm1) + /* create Cr (result in mm1) */ "pushl %%ebx\n" "movl 4(%%esp),%%ebx\n" - "movd (%%ebx),%%mm1\n" // 0 0 0 0 v3 v2 v1 v0 + "movd (%%ebx),%%mm1\n" /* 0 0 0 0 v3 v2 v1 v0 */ "popl %%ebx\n" - "pxor %%mm7,%%mm7\n" // 00 00 00 00 00 00 00 00 - "movd (%2), %%mm2\n" // 0 0 0 0 l3 l2 l1 l0 - "punpcklbw %%mm7,%%mm1\n" // 0 v3 0 v2 00 v1 00 v0 - "punpckldq %%mm1,%%mm1\n" // 00 v1 00 v0 00 v1 00 v0 - "psubw %9,%%mm1\n" // mm1-128:r1 r1 r0 r0 r1 r1 r0 r0 - - // create Cr_g (result in mm0) - "movq %%mm1,%%mm0\n" // r1 r1 r0 r0 r1 r1 r0 r0 - "pmullw %10,%%mm0\n" // red*-46dec=0.7136*64 - "pmullw %11,%%mm1\n" // red*89dec=1.4013*64 - "psraw $6, %%mm0\n" // red=red/64 - "psraw $6, %%mm1\n" // red=red/64 - - // create L1 L2 (result in mm2,mm4) - // L2=lum+cols - "movq (%2,%4),%%mm3\n" // 0 0 0 0 L3 L2 L1 L0 - "punpckldq %%mm3,%%mm2\n" // L3 L2 L1 L0 l3 l2 l1 l0 - "movq %%mm2,%%mm4\n" // L3 L2 L1 L0 l3 l2 l1 l0 - "pand %12,%%mm2\n" // L3 0 L1 0 l3 0 l1 0 - "pand %13,%%mm4\n" // 0 L2 0 L0 0 l2 0 l0 - "psrlw $8,%%mm2\n" // 0 L3 0 L1 0 l3 0 l1 - - // create R (result in mm6) - "movq %%mm2,%%mm5\n" // 0 L3 0 L1 0 l3 0 l1 - "movq %%mm4,%%mm6\n" // 0 L2 0 L0 0 l2 0 l0 - "paddsw %%mm1, %%mm5\n" // lum1+red:x R3 x R1 x r3 x r1 - "paddsw %%mm1, %%mm6\n" // lum1+red:x R2 x R0 x r2 x r0 - "packuswb %%mm5,%%mm5\n" // R3 R1 r3 r1 R3 R1 r3 r1 - "packuswb %%mm6,%%mm6\n" // R2 R0 r2 r0 R2 R0 r2 r0 - "pxor %%mm7,%%mm7\n" // 00 00 00 00 00 00 00 00 - "punpcklbw %%mm5,%%mm6\n" // R3 R2 R1 R0 r3 r2 r1 r0 - - // create Cb (result in mm1) - "movd (%1), %%mm1\n" // 0 0 0 0 u3 u2 u1 u0 - "punpcklbw %%mm7,%%mm1\n" // 0 u3 0 u2 00 u1 00 u0 - "punpckldq %%mm1,%%mm1\n" // 00 u1 00 u0 00 u1 00 u0 - "psubw %9,%%mm1\n" // mm1-128:u1 u1 u0 u0 u1 u1 u0 u0 - - // create Cb_g (result in mm5) - "movq %%mm1,%%mm5\n" // u1 u1 u0 u0 u1 u1 u0 u0 - "pmullw %14,%%mm5\n" // blue*-109dec=1.7129*64 - "pmullw %15,%%mm1\n" // blue*114dec=1.78125*64 - "psraw $6, %%mm5\n" // blue=red/64 - "psraw $6, %%mm1\n" // blue=blue/64 - - // create G (result in mm7) - "movq %%mm2,%%mm3\n" // 0 L3 0 L1 0 l3 0 l1 - "movq %%mm4,%%mm7\n" // 0 L2 0 L0 0 l2 0 l1 - "paddsw %%mm5, %%mm3\n" // lum1+Cb_g:x G3t x G1t x g3t x g1t - "paddsw %%mm5, %%mm7\n" // lum1+Cb_g:x G2t x G0t x g2t x g0t - "paddsw %%mm0, %%mm3\n" // lum1+Cr_g:x G3 x G1 x g3 x g1 - "paddsw %%mm0, %%mm7\n" // lum1+blue:x G2 x G0 x g2 x g0 - "packuswb %%mm3,%%mm3\n" // G3 G1 g3 g1 G3 G1 g3 g1 - "packuswb %%mm7,%%mm7\n" // G2 G0 g2 g0 G2 G0 g2 g0 - "punpcklbw %%mm3,%%mm7\n" // G3 G2 G1 G0 g3 g2 g1 g0 - - // create B (result in mm5) - "movq %%mm2,%%mm3\n" // 0 L3 0 L1 0 l3 0 l1 - "movq %%mm4,%%mm5\n" // 0 L2 0 L0 0 l2 0 l1 - "paddsw %%mm1, %%mm3\n" // lum1+blue:x B3 x B1 x b3 x b1 - "paddsw %%mm1, %%mm5\n" // lum1+blue:x B2 x B0 x b2 x b0 - "packuswb %%mm3,%%mm3\n" // B3 B1 b3 b1 B3 B1 b3 b1 - "packuswb %%mm5,%%mm5\n" // B2 B0 b2 b0 B2 B0 b2 b0 - "punpcklbw %%mm3,%%mm5\n" // B3 B2 B1 B0 b3 b2 b1 b0 - - // fill destination row1 (needed are mm6=Rr,mm7=Gg,mm5=Bb) - - "pxor %%mm2,%%mm2\n" // 0 0 0 0 0 0 0 0 - "pxor %%mm4,%%mm4\n" // 0 0 0 0 0 0 0 0 - "movq %%mm6,%%mm1\n" // R3 R2 R1 R0 r3 r2 r1 r0 - "movq %%mm5,%%mm3\n" // B3 B2 B1 B0 b3 b2 b1 b0 - - // process lower lum - "punpcklbw %%mm4,%%mm1\n" // 0 r3 0 r2 0 r1 0 r0 - "punpcklbw %%mm4,%%mm3\n" // 0 b3 0 b2 0 b1 0 b0 - "movq %%mm1,%%mm2\n" // 0 r3 0 r2 0 r1 0 r0 - "movq %%mm3,%%mm0\n" // 0 b3 0 b2 0 b1 0 b0 - "punpcklwd %%mm1,%%mm3\n" // 0 r1 0 b1 0 r0 0 b0 - "punpckhwd %%mm2,%%mm0\n" // 0 r3 0 b3 0 r2 0 b2 - - "pxor %%mm2,%%mm2\n" // 0 0 0 0 0 0 0 0 - "movq %%mm7,%%mm1\n" // G3 G2 G1 G0 g3 g2 g1 g0 - "punpcklbw %%mm1,%%mm2\n" // g3 0 g2 0 g1 0 g0 0 - "punpcklwd %%mm4,%%mm2\n" // 0 0 g1 0 0 0 g0 0 - "por %%mm3, %%mm2\n" // 0 r1 g1 b1 0 r0 g0 b0 - "movq %%mm2,(%3)\n" // wrote out ! row1 - - "pxor %%mm2,%%mm2\n" // 0 0 0 0 0 0 0 0 - "punpcklbw %%mm1,%%mm4\n" // g3 0 g2 0 g1 0 g0 0 - "punpckhwd %%mm2,%%mm4\n" // 0 0 g3 0 0 0 g2 0 - "por %%mm0, %%mm4\n" // 0 r3 g3 b3 0 r2 g2 b2 - "movq %%mm4,8(%3)\n" // wrote out ! row1 - - // fill destination row2 (needed are mm6=Rr,mm7=Gg,mm5=Bb) - // this can be done "destructive" - "pxor %%mm2,%%mm2\n" // 0 0 0 0 0 0 0 0 - "punpckhbw %%mm2,%%mm6\n" // 0 R3 0 R2 0 R1 0 R0 - "punpckhbw %%mm1,%%mm5\n" // G3 B3 G2 B2 G1 B1 G0 B0 - "movq %%mm5,%%mm1\n" // G3 B3 G2 B2 G1 B1 G0 B0 - "punpcklwd %%mm6,%%mm1\n" // 0 R1 G1 B1 0 R0 G0 B0 - "movq %%mm1,(%5)\n" // wrote out ! row2 - "punpckhwd %%mm6,%%mm5\n" // 0 R3 G3 B3 0 R2 G2 B2 - "movq %%mm5,8(%5)\n" // wrote out ! row2 - - "addl $4,%2\n" // lum+4 - "leal 16(%3),%3\n" // row1+16 - "leal 16(%5),%5\n" // row2+16 - "addl $2,(%%esp)\n" // cr+2 - "addl $2,%1\n" // cb+2 - - "addl $4,%6\n" // x+4 + "pxor %%mm7,%%mm7\n" /* 00 00 00 00 00 00 00 00 */ + "movd (%2), %%mm2\n" /* 0 0 0 0 l3 l2 l1 l0 */ + "punpcklbw %%mm7,%%mm1\n" /* 0 v3 0 v2 00 v1 00 v0 */ + "punpckldq %%mm1,%%mm1\n" /* 00 v1 00 v0 00 v1 00 v0 */ + "psubw %9,%%mm1\n" /* mm1-128:r1 r1 r0 r0 r1 r1 r0 r0 */ + + /* create Cr_g (result in mm0) */ + "movq %%mm1,%%mm0\n" /* r1 r1 r0 r0 r1 r1 r0 r0 */ + "pmullw %10,%%mm0\n" /* red*-46dec=0.7136*64 */ + "pmullw %11,%%mm1\n" /* red*89dec=1.4013*64 */ + "psraw $6, %%mm0\n" /* red=red/64 */ + "psraw $6, %%mm1\n" /* red=red/64 */ + + /* create L1 L2 (result in mm2,mm4) */ + /* L2=lum+cols */ + "movq (%2,%4),%%mm3\n" /* 0 0 0 0 L3 L2 L1 L0 */ + "punpckldq %%mm3,%%mm2\n" /* L3 L2 L1 L0 l3 l2 l1 l0 */ + "movq %%mm2,%%mm4\n" /* L3 L2 L1 L0 l3 l2 l1 l0 */ + "pand %12,%%mm2\n" /* L3 0 L1 0 l3 0 l1 0 */ + "pand %13,%%mm4\n" /* 0 L2 0 L0 0 l2 0 l0 */ + "psrlw $8,%%mm2\n" /* 0 L3 0 L1 0 l3 0 l1 */ + + /* create R (result in mm6) */ + "movq %%mm2,%%mm5\n" /* 0 L3 0 L1 0 l3 0 l1 */ + "movq %%mm4,%%mm6\n" /* 0 L2 0 L0 0 l2 0 l0 */ + "paddsw %%mm1, %%mm5\n" /* lum1+red:x R3 x R1 x r3 x r1 */ + "paddsw %%mm1, %%mm6\n" /* lum1+red:x R2 x R0 x r2 x r0 */ + "packuswb %%mm5,%%mm5\n" /* R3 R1 r3 r1 R3 R1 r3 r1 */ + "packuswb %%mm6,%%mm6\n" /* R2 R0 r2 r0 R2 R0 r2 r0 */ + "pxor %%mm7,%%mm7\n" /* 00 00 00 00 00 00 00 00 */ + "punpcklbw %%mm5,%%mm6\n" /* R3 R2 R1 R0 r3 r2 r1 r0 */ + + /* create Cb (result in mm1) */ + "movd (%1), %%mm1\n" /* 0 0 0 0 u3 u2 u1 u0 */ + "punpcklbw %%mm7,%%mm1\n" /* 0 u3 0 u2 00 u1 00 u0 */ + "punpckldq %%mm1,%%mm1\n" /* 00 u1 00 u0 00 u1 00 u0 */ + "psubw %9,%%mm1\n" /* mm1-128:u1 u1 u0 u0 u1 u1 u0 u0 */ + + /* create Cb_g (result in mm5) */ + "movq %%mm1,%%mm5\n" /* u1 u1 u0 u0 u1 u1 u0 u0 */ + "pmullw %14,%%mm5\n" /* blue*-109dec=1.7129*64 */ + "pmullw %15,%%mm1\n" /* blue*114dec=1.78125*64 */ + "psraw $6, %%mm5\n" /* blue=red/64 */ + "psraw $6, %%mm1\n" /* blue=blue/64 */ + + /* create G (result in mm7) */ + "movq %%mm2,%%mm3\n" /* 0 L3 0 L1 0 l3 0 l1 */ + "movq %%mm4,%%mm7\n" /* 0 L2 0 L0 0 l2 0 l1 */ + "paddsw %%mm5, %%mm3\n" /* lum1+Cb_g:x G3t x G1t x g3t x g1t */ + "paddsw %%mm5, %%mm7\n" /* lum1+Cb_g:x G2t x G0t x g2t x g0t */ + "paddsw %%mm0, %%mm3\n" /* lum1+Cr_g:x G3 x G1 x g3 x g1 */ + "paddsw %%mm0, %%mm7\n" /* lum1+blue:x G2 x G0 x g2 x g0 */ + "packuswb %%mm3,%%mm3\n" /* G3 G1 g3 g1 G3 G1 g3 g1 */ + "packuswb %%mm7,%%mm7\n" /* G2 G0 g2 g0 G2 G0 g2 g0 */ + "punpcklbw %%mm3,%%mm7\n" /* G3 G2 G1 G0 g3 g2 g1 g0 */ + + /* create B (result in mm5) */ + "movq %%mm2,%%mm3\n" /* 0 L3 0 L1 0 l3 0 l1 */ + "movq %%mm4,%%mm5\n" /* 0 L2 0 L0 0 l2 0 l1 */ + "paddsw %%mm1, %%mm3\n" /* lum1+blue:x B3 x B1 x b3 x b1 */ + "paddsw %%mm1, %%mm5\n" /* lum1+blue:x B2 x B0 x b2 x b0 */ + "packuswb %%mm3,%%mm3\n" /* B3 B1 b3 b1 B3 B1 b3 b1 */ + "packuswb %%mm5,%%mm5\n" /* B2 B0 b2 b0 B2 B0 b2 b0 */ + "punpcklbw %%mm3,%%mm5\n" /* B3 B2 B1 B0 b3 b2 b1 b0 */ + + /* fill destination row1 (needed are mm6=Rr,mm7=Gg,mm5=Bb) */ + + "pxor %%mm2,%%mm2\n" /* 0 0 0 0 0 0 0 0 */ + "pxor %%mm4,%%mm4\n" /* 0 0 0 0 0 0 0 0 */ + "movq %%mm6,%%mm1\n" /* R3 R2 R1 R0 r3 r2 r1 r0 */ + "movq %%mm5,%%mm3\n" /* B3 B2 B1 B0 b3 b2 b1 b0 */ + + /* process lower lum */ + "punpcklbw %%mm4,%%mm1\n" /* 0 r3 0 r2 0 r1 0 r0 */ + "punpcklbw %%mm4,%%mm3\n" /* 0 b3 0 b2 0 b1 0 b0 */ + "movq %%mm1,%%mm2\n" /* 0 r3 0 r2 0 r1 0 r0 */ + "movq %%mm3,%%mm0\n" /* 0 b3 0 b2 0 b1 0 b0 */ + "punpcklwd %%mm1,%%mm3\n" /* 0 r1 0 b1 0 r0 0 b0 */ + "punpckhwd %%mm2,%%mm0\n" /* 0 r3 0 b3 0 r2 0 b2 */ + + "pxor %%mm2,%%mm2\n" /* 0 0 0 0 0 0 0 0 */ + "movq %%mm7,%%mm1\n" /* G3 G2 G1 G0 g3 g2 g1 g0 */ + "punpcklbw %%mm1,%%mm2\n" /* g3 0 g2 0 g1 0 g0 0 */ + "punpcklwd %%mm4,%%mm2\n" /* 0 0 g1 0 0 0 g0 0 */ + "por %%mm3, %%mm2\n" /* 0 r1 g1 b1 0 r0 g0 b0 */ + "movq %%mm2,(%3)\n" /* wrote out ! row1 */ + + "pxor %%mm2,%%mm2\n" /* 0 0 0 0 0 0 0 0 */ + "punpcklbw %%mm1,%%mm4\n" /* g3 0 g2 0 g1 0 g0 0 */ + "punpckhwd %%mm2,%%mm4\n" /* 0 0 g3 0 0 0 g2 0 */ + "por %%mm0, %%mm4\n" /* 0 r3 g3 b3 0 r2 g2 b2 */ + "movq %%mm4,8(%3)\n" /* wrote out ! row1 */ + + /* fill destination row2 (needed are mm6=Rr,mm7=Gg,mm5=Bb) */ + /* this can be done "destructive" */ + "pxor %%mm2,%%mm2\n" /* 0 0 0 0 0 0 0 0 */ + "punpckhbw %%mm2,%%mm6\n" /* 0 R3 0 R2 0 R1 0 R0 */ + "punpckhbw %%mm1,%%mm5\n" /* G3 B3 G2 B2 G1 B1 G0 B0 */ + "movq %%mm5,%%mm1\n" /* G3 B3 G2 B2 G1 B1 G0 B0 */ + "punpcklwd %%mm6,%%mm1\n" /* 0 R1 G1 B1 0 R0 G0 B0 */ + "movq %%mm1,(%5)\n" /* wrote out ! row2 */ + "punpckhwd %%mm6,%%mm5\n" /* 0 R3 G3 B3 0 R2 G2 B2 */ + "movq %%mm5,8(%5)\n" /* wrote out ! row2 */ + + "addl $4,%2\n" /* lum+4 */ + "leal 16(%3),%3\n" /* row1+16 */ + "leal 16(%5),%5\n" /* row2+16 */ + "addl $2,(%%esp)\n" /* cr+2 */ + "addl $2,%1\n" /* cb+2 */ + + "addl $4,%6\n" /* x+4 */ "cmpl %4,%6\n" "jl 1b\n" - "addl %4,%2\n" // lum += cols - "addl %8,%3\n" // row1+= mod - "addl %8,%5\n" // row2+= mod - "movl $0,%6\n" // x=0 + "addl %4,%2\n" /* lum += cols */ + "addl %8,%3\n" /* row1+= mod */ + "addl %8,%5\n" /* row2+= mod */ + "movl $0,%6\n" /* x=0 */ "cmpl %7,%2\n" "jl 1b\n" - "addl $4,%%esp\n" // get rid of the stack slot we reserved. - "emms\n" // reset MMX registers. + "addl $4,%%esp\n" /* get rid of the stack slot we reserved. */ + "emms\n" /* reset MMX registers. */ : : "m" (cr), "r"(cb),"r"(lum), "r"(row1),"r"(cols),"r"(row2),"m"(x),"m"(y),"m"(mod), @@ -254,125 +254,125 @@ void Color565DitherYV12MMX1X( int *colortab, Uint32 *rgb_2_pix, mod = (mod+cols+mod)*2; /* increment for row1 in byte */ __asm__ __volatile__( - // tap dance to workaround the inability to use %%ebx at will... - // move one thing to the stack... - "pushl $0\n" // save a slot on the stack. - "pushl %%ebx\n" // save %%ebx. - "movl %0, %%ebx\n" // put the thing in ebx. - "movl %%ebx, 4(%%esp)\n" // put the thing in the stack slot. - "popl %%ebx\n" // get back %%ebx (the PIC register). + /* tap dance to workaround the inability to use %%ebx at will... */ + /* move one thing to the stack... */ + "pushl $0\n" /* save a slot on the stack. */ + "pushl %%ebx\n" /* save %%ebx. */ + "movl %0, %%ebx\n" /* put the thing in ebx. */ + "movl %%ebx, 4(%%esp)\n" /* put the thing in the stack slot. */ + "popl %%ebx\n" /* get back %%ebx (the PIC register). */ ".align 8\n" "1:\n" - "movd (%1), %%mm0\n" // 4 Cb 0 0 0 0 u3 u2 u1 u0 + "movd (%1), %%mm0\n" /* 4 Cb 0 0 0 0 u3 u2 u1 u0 */ "pxor %%mm7, %%mm7\n" "pushl %%ebx\n" "movl 4(%%esp), %%ebx\n" - "movd (%%ebx), %%mm1\n" // 4 Cr 0 0 0 0 v3 v2 v1 v0 + "movd (%%ebx), %%mm1\n" /* 4 Cr 0 0 0 0 v3 v2 v1 v0 */ "popl %%ebx\n" - "punpcklbw %%mm7, %%mm0\n" // 4 W cb 0 u3 0 u2 0 u1 0 u0 - "punpcklbw %%mm7, %%mm1\n" // 4 W cr 0 v3 0 v2 0 v1 0 v0 + "punpcklbw %%mm7, %%mm0\n" /* 4 W cb 0 u3 0 u2 0 u1 0 u0 */ + "punpcklbw %%mm7, %%mm1\n" /* 4 W cr 0 v3 0 v2 0 v1 0 v0 */ "psubw %9, %%mm0\n" "psubw %9, %%mm1\n" - "movq %%mm0, %%mm2\n" // Cb 0 u3 0 u2 0 u1 0 u0 - "movq %%mm1, %%mm3\n" // Cr - "pmullw %10, %%mm2\n" // Cb2green 0 R3 0 R2 0 R1 0 R0 - "movq (%2), %%mm6\n" // L1 l7 L6 L5 L4 L3 L2 L1 L0 - "pmullw %11, %%mm0\n" // Cb2blue - "pand %12, %%mm6\n" // L1 00 L6 00 L4 00 L2 00 L0 - "pmullw %13, %%mm3\n" // Cr2green - "movq (%2), %%mm7\n" // L2 - "pmullw %14, %%mm1\n" // Cr2red - "psrlw $8, %%mm7\n" // L2 00 L7 00 L5 00 L3 00 L1 - "pmullw %15, %%mm6\n" // lum1 - "paddw %%mm3, %%mm2\n" // Cb2green + Cr2green == green - "pmullw %15, %%mm7\n" // lum2 - - "movq %%mm6, %%mm4\n" // lum1 - "paddw %%mm0, %%mm6\n" // lum1 +blue 00 B6 00 B4 00 B2 00 B0 - "movq %%mm4, %%mm5\n" // lum1 - "paddw %%mm1, %%mm4\n" // lum1 +red 00 R6 00 R4 00 R2 00 R0 - "paddw %%mm2, %%mm5\n" // lum1 +green 00 G6 00 G4 00 G2 00 G0 - "psraw $6, %%mm4\n" // R1 0 .. 64 - "movq %%mm7, %%mm3\n" // lum2 00 L7 00 L5 00 L3 00 L1 - "psraw $6, %%mm5\n" // G1 - .. + - "paddw %%mm0, %%mm7\n" // Lum2 +blue 00 B7 00 B5 00 B3 00 B1 - "psraw $6, %%mm6\n" // B1 0 .. 64 - "packuswb %%mm4, %%mm4\n" // R1 R1 - "packuswb %%mm5, %%mm5\n" // G1 G1 - "packuswb %%mm6, %%mm6\n" // B1 B1 + "movq %%mm0, %%mm2\n" /* Cb 0 u3 0 u2 0 u1 0 u0 */ + "movq %%mm1, %%mm3\n" /* Cr */ + "pmullw %10, %%mm2\n" /* Cb2green 0 R3 0 R2 0 R1 0 R0 */ + "movq (%2), %%mm6\n" /* L1 l7 L6 L5 L4 L3 L2 L1 L0 */ + "pmullw %11, %%mm0\n" /* Cb2blue */ + "pand %12, %%mm6\n" /* L1 00 L6 00 L4 00 L2 00 L0 */ + "pmullw %13, %%mm3\n" /* Cr2green */ + "movq (%2), %%mm7\n" /* L2 */ + "pmullw %14, %%mm1\n" /* Cr2red */ + "psrlw $8, %%mm7\n" /* L2 00 L7 00 L5 00 L3 00 L1 */ + "pmullw %15, %%mm6\n" /* lum1 */ + "paddw %%mm3, %%mm2\n" /* Cb2green + Cr2green == green */ + "pmullw %15, %%mm7\n" /* lum2 */ + + "movq %%mm6, %%mm4\n" /* lum1 */ + "paddw %%mm0, %%mm6\n" /* lum1 +blue 00 B6 00 B4 00 B2 00 B0 */ + "movq %%mm4, %%mm5\n" /* lum1 */ + "paddw %%mm1, %%mm4\n" /* lum1 +red 00 R6 00 R4 00 R2 00 R0 */ + "paddw %%mm2, %%mm5\n" /* lum1 +green 00 G6 00 G4 00 G2 00 G0 */ + "psraw $6, %%mm4\n" /* R1 0 .. 64 */ + "movq %%mm7, %%mm3\n" /* lum2 00 L7 00 L5 00 L3 00 L1 */ + "psraw $6, %%mm5\n" /* G1 - .. + */ + "paddw %%mm0, %%mm7\n" /* Lum2 +blue 00 B7 00 B5 00 B3 00 B1 */ + "psraw $6, %%mm6\n" /* B1 0 .. 64 */ + "packuswb %%mm4, %%mm4\n" /* R1 R1 */ + "packuswb %%mm5, %%mm5\n" /* G1 G1 */ + "packuswb %%mm6, %%mm6\n" /* B1 B1 */ "punpcklbw %%mm4, %%mm4\n" "punpcklbw %%mm5, %%mm5\n" "pand %16, %%mm4\n" - "psllw $3, %%mm5\n" // GREEN 1 + "psllw $3, %%mm5\n" /* GREEN 1 */ "punpcklbw %%mm6, %%mm6\n" "pand %17, %%mm5\n" "pand %16, %%mm6\n" - "por %%mm5, %%mm4\n" // - "psrlw $11, %%mm6\n" // BLUE 1 - "movq %%mm3, %%mm5\n" // lum2 - "paddw %%mm1, %%mm3\n" // lum2 +red 00 R7 00 R5 00 R3 00 R1 - "paddw %%mm2, %%mm5\n" // lum2 +green 00 G7 00 G5 00 G3 00 G1 - "psraw $6, %%mm3\n" // R2 - "por %%mm6, %%mm4\n" // MM4 - "psraw $6, %%mm5\n" // G2 - "movq (%2, %4), %%mm6\n" // L3 load lum2 + "por %%mm5, %%mm4\n" /* */ + "psrlw $11, %%mm6\n" /* BLUE 1 */ + "movq %%mm3, %%mm5\n" /* lum2 */ + "paddw %%mm1, %%mm3\n" /* lum2 +red 00 R7 00 R5 00 R3 00 R1 */ + "paddw %%mm2, %%mm5\n" /* lum2 +green 00 G7 00 G5 00 G3 00 G1 */ + "psraw $6, %%mm3\n" /* R2 */ + "por %%mm6, %%mm4\n" /* MM4 */ + "psraw $6, %%mm5\n" /* G2 */ + "movq (%2, %4), %%mm6\n" /* L3 load lum2 */ "psraw $6, %%mm7\n" "packuswb %%mm3, %%mm3\n" "packuswb %%mm5, %%mm5\n" "packuswb %%mm7, %%mm7\n" - "pand %12, %%mm6\n" // L3 + "pand %12, %%mm6\n" /* L3 */ "punpcklbw %%mm3, %%mm3\n" "punpcklbw %%mm5, %%mm5\n" - "pmullw %15, %%mm6\n" // lum3 + "pmullw %15, %%mm6\n" /* lum3 */ "punpcklbw %%mm7, %%mm7\n" - "psllw $3, %%mm5\n" // GREEN 2 + "psllw $3, %%mm5\n" /* GREEN 2 */ "pand %16, %%mm7\n" "pand %16, %%mm3\n" - "psrlw $11, %%mm7\n" // BLUE 2 + "psrlw $11, %%mm7\n" /* BLUE 2 */ "pand %17, %%mm5\n" "por %%mm7, %%mm3\n" - "movq (%2,%4), %%mm7\n" // L4 load lum2 - "por %%mm5, %%mm3\n" // - "psrlw $8, %%mm7\n" // L4 + "movq (%2,%4), %%mm7\n" /* L4 load lum2 */ + "por %%mm5, %%mm3\n" + "psrlw $8, %%mm7\n" /* L4 */ "movq %%mm4, %%mm5\n" "punpcklwd %%mm3, %%mm4\n" - "pmullw %15, %%mm7\n" // lum4 + "pmullw %15, %%mm7\n" /* lum4 */ "punpckhwd %%mm3, %%mm5\n" - "movq %%mm4, (%3)\n" // write row1 - "movq %%mm5, 8(%3)\n" // write row1 + "movq %%mm4, (%3)\n" /* write row1 */ + "movq %%mm5, 8(%3)\n" /* write row1 */ - "movq %%mm6, %%mm4\n" // Lum3 - "paddw %%mm0, %%mm6\n" // Lum3 +blue + "movq %%mm6, %%mm4\n" /* Lum3 */ + "paddw %%mm0, %%mm6\n" /* Lum3 +blue */ - "movq %%mm4, %%mm5\n" // Lum3 - "paddw %%mm1, %%mm4\n" // Lum3 +red - "paddw %%mm2, %%mm5\n" // Lum3 +green + "movq %%mm4, %%mm5\n" /* Lum3 */ + "paddw %%mm1, %%mm4\n" /* Lum3 +red */ + "paddw %%mm2, %%mm5\n" /* Lum3 +green */ "psraw $6, %%mm4\n" - "movq %%mm7, %%mm3\n" // Lum4 + "movq %%mm7, %%mm3\n" /* Lum4 */ "psraw $6, %%mm5\n" - "paddw %%mm0, %%mm7\n" // Lum4 +blue - "psraw $6, %%mm6\n" // Lum3 +blue - "movq %%mm3, %%mm0\n" // Lum4 + "paddw %%mm0, %%mm7\n" /* Lum4 +blue */ + "psraw $6, %%mm6\n" /* Lum3 +blue */ + "movq %%mm3, %%mm0\n" /* Lum4 */ "packuswb %%mm4, %%mm4\n" - "paddw %%mm1, %%mm3\n" // Lum4 +red + "paddw %%mm1, %%mm3\n" /* Lum4 +red */ "packuswb %%mm5, %%mm5\n" - "paddw %%mm2, %%mm0\n" // Lum4 +green + "paddw %%mm2, %%mm0\n" /* Lum4 +green */ "packuswb %%mm6, %%mm6\n" "punpcklbw %%mm4, %%mm4\n" "punpcklbw %%mm5, %%mm5\n" "punpcklbw %%mm6, %%mm6\n" - "psllw $3, %%mm5\n" // GREEN 3 + "psllw $3, %%mm5\n" /* GREEN 3 */ "pand %16, %%mm4\n" - "psraw $6, %%mm3\n" // psr 6 + "psraw $6, %%mm3\n" /* psr 6 */ "psraw $6, %%mm0\n" - "pand %16, %%mm6\n" // BLUE + "pand %16, %%mm6\n" /* BLUE */ "pand %17, %%mm5\n" - "psrlw $11, %%mm6\n" // BLUE 3 + "psrlw $11, %%mm6\n" /* BLUE 3 */ "por %%mm5, %%mm4\n" "psraw $6, %%mm7\n" "por %%mm6, %%mm4\n" @@ -383,8 +383,8 @@ void Color565DitherYV12MMX1X( int *colortab, Uint32 *rgb_2_pix, "punpcklbw %%mm0, %%mm0\n" "punpcklbw %%mm7, %%mm7\n" "pand %16, %%mm3\n" - "pand %16, %%mm7\n" // BLUE - "psllw $3, %%mm0\n" // GREEN 4 + "pand %16, %%mm7\n" /* BLUE */ + "psllw $3, %%mm0\n" /* GREEN 4 */ "psrlw $11, %%mm7\n" "pand %17, %%mm0\n" "por %%mm7, %%mm3\n" @@ -404,16 +404,16 @@ void Color565DitherYV12MMX1X( int *colortab, Uint32 *rgb_2_pix, "addl $4, %1\n" "cmpl %4, %6\n" "leal 16(%3), %3\n" - "leal 16(%5),%5\n" // row2+16 + "leal 16(%5),%5\n" /* row2+16 */ "jl 1b\n" - "addl %4, %2\n" // lum += cols - "addl %8, %3\n" // row1+= mod - "addl %8, %5\n" // row2+= mod - "movl $0, %6\n" // x=0 + "addl %4, %2\n" /* lum += cols */ + "addl %8, %3\n" /* row1+= mod */ + "addl %8, %5\n" /* row2+= mod */ + "movl $0, %6\n" /* x=0 */ "cmpl %7, %2\n" "jl 1b\n" - "addl $4, %%esp\n" // get rid of the stack slot we reserved. + "addl $4, %%esp\n" /* get rid of the stack slot we reserved. */ "emms\n" : : "m" (cr), "r"(cb),"r"(lum), diff --git a/src/render/SDL_yuv_sw.c b/src/render/SDL_yuv_sw.c index 9f04c21ca..1d7e024c2 100644 --- a/src/render/SDL_yuv_sw.c +++ b/src/render/SDL_yuv_sw.c @@ -26,17 +26,17 @@ * Copyright (c) 1995 The Regents of the University of California. * All rights reserved. - * + * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose, without fee, and without written agreement is * hereby granted, provided that the above copyright notice and the following * two paragraphs appear in all copies of this software. - * + * * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS @@ -45,17 +45,17 @@ * Copyright (c) 1995 Erik Corry * All rights reserved. - * + * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose, without fee, and without written agreement is * hereby granted, provided that the above copyright notice and the following * two paragraphs appear in all copies of this software. - * + * * IN NO EVENT SHALL ERIK CORRY BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, * SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF * THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF ERIK CORRY HAS BEEN ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * ERIK CORRY SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" @@ -64,17 +64,17 @@ * Portions of this software Copyright (c) 1995 Brown University. * All rights reserved. - * + * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose, without fee, and without written agreement * is hereby granted, provided that the above copyright notice and the * following two paragraphs appear in all copies of this software. - * + * * IN NO EVENT SHALL BROWN UNIVERSITY BE LIABLE TO ANY PARTY FOR * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF BROWN * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * BROWN UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" @@ -904,7 +904,7 @@ SDL_SW_SetupYUVDisplay(SDL_SW_YUVTexture * swdata, Uint32 target_format) g_2_pix_alloc = &swdata->rgb_2_pix[1 * 768]; b_2_pix_alloc = &swdata->rgb_2_pix[2 * 768]; - /* + /* * Set up entries 0-255 in rgb-to-pixel value tables. */ for (i = 0; i < 256; ++i) { @@ -922,7 +922,7 @@ SDL_SW_SetupYUVDisplay(SDL_SW_YUVTexture * swdata, Uint32 target_format) /* * If we have 16-bit output depth, then we double the value * in the top word. This means that we can write out both - * pixels in the pixel doubling mode with one op. It is + * pixels in the pixel doubling mode with one op. It is * harmless in the normal case as storing a 32-bit value * through a short pointer will lose the top bits anyway. */ diff --git a/src/render/direct3d/SDL_render_d3d.c b/src/render/direct3d/SDL_render_d3d.c index 55c313a6c..dea31f644 100644 --- a/src/render/direct3d/SDL_render_d3d.c +++ b/src/render/direct3d/SDL_render_d3d.c @@ -121,23 +121,23 @@ HRESULT WINAPI D3DXCreateMatrixStack(DWORD flags, LPD3DXMATRIXSTACK* ppstack); #endif #ifdef ASSEMBLE_SHADER -/////////////////////////////////////////////////////////////////////////// -// ID3DXBuffer: -// ------------ -// The buffer object is used by D3DX to return arbitrary size data. -// -// GetBufferPointer - -// Returns a pointer to the beginning of the buffer. -// -// GetBufferSize - -// Returns the size of the buffer, in bytes. -/////////////////////////////////////////////////////////////////////////// +/************************************************************************** + * ID3DXBuffer: + * ------------ + * The buffer object is used by D3DX to return arbitrary size data. + * + * GetBufferPointer - + * Returns a pointer to the beginning of the buffer. + * + * GetBufferSize - + * Returns the size of the buffer, in bytes. + **************************************************************************/ typedef interface ID3DXBuffer ID3DXBuffer; typedef interface ID3DXBuffer *LPD3DXBUFFER; -// {8BA5FB08-5195-40e2-AC58-0D989C3A0102} -DEFINE_GUID(IID_ID3DXBuffer, +/* {8BA5FB08-5195-40e2-AC58-0D989C3A0102} */ +DEFINE_GUID(IID_ID3DXBuffer, 0x8ba5fb08, 0x5195, 0x40e2, 0xac, 0x58, 0xd, 0x98, 0x9c, 0x3a, 0x1, 0x2); #undef INTERFACE @@ -149,12 +149,12 @@ typedef interface ID3DXBuffer { typedef const struct ID3DXBufferVtbl ID3DXBufferVtbl; const struct ID3DXBufferVtbl { - // IUnknown + /* IUnknown */ STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; STDMETHOD_(ULONG, AddRef)(THIS) PURE; STDMETHOD_(ULONG, Release)(THIS) PURE; - // ID3DXBuffer + /* ID3DXBuffer */ STDMETHOD_(LPVOID, GetBufferPointer)(THIS) PURE; STDMETHOD_(DWORD, GetBufferSize)(THIS) PURE; }; @@ -444,7 +444,7 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags) SDL_DisplayMode fullscreen_mode; D3DMATRIX matrix; int d3dxVersion; - char d3dxDLLFile[50]; + char d3dxDLLFile[50]; renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer)); if (!renderer) { @@ -496,7 +496,7 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags) } - + if (!data->d3d || !data->matrixStack) { SDL_free(renderer); SDL_free(data); @@ -548,14 +548,14 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags) pparams.SwapEffect = D3DSWAPEFFECT_DISCARD; if (window_flags & SDL_WINDOW_FULLSCREEN) { - if ( ( window_flags & SDL_WINDOW_FULLSCREEN_DESKTOP ) == SDL_WINDOW_FULLSCREEN_DESKTOP ) { - pparams.Windowed = TRUE; - pparams.FullScreen_RefreshRateInHz = 0; - } else { + if ( ( window_flags & SDL_WINDOW_FULLSCREEN_DESKTOP ) == SDL_WINDOW_FULLSCREEN_DESKTOP ) { + pparams.Windowed = TRUE; + pparams.FullScreen_RefreshRateInHz = 0; + } else { pparams.Windowed = FALSE; pparams.FullScreen_RefreshRateInHz = fullscreen_mode.refresh_rate; - } + } } else { pparams.Windowed = TRUE; pparams.FullScreen_RefreshRateInHz = 0; @@ -1338,7 +1338,7 @@ D3D_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture, D3D_SetBlendMode(data, texture->blendMode); - // Rotate and translate + /* Rotate and translate */ ID3DXMatrixStack_Push(data->matrixStack); ID3DXMatrixStack_LoadIdentity(data->matrixStack); ID3DXMatrixStack_RotateYawPitchRoll(data->matrixStack, 0.0, 0.0, (float)(M_PI * (float) angle / 180.0f)); @@ -1491,7 +1491,7 @@ D3D_DestroyRenderer(SDL_Renderer * renderer) D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; if (data) { - // Release the render target + /* Release the render target */ if (data->defaultRenderTarget) { IDirect3DSurface9_Release(data->defaultRenderTarget); data->defaultRenderTarget = NULL; @@ -1500,7 +1500,7 @@ D3D_DestroyRenderer(SDL_Renderer * renderer) IDirect3DSurface9_Release(data->currentRenderTarget); data->currentRenderTarget = NULL; } - + if (data->device) { IDirect3DDevice9_Release(data->device); } diff --git a/src/render/opengl/SDL_render_gl.c b/src/render/opengl/SDL_render_gl.c index 3b0f01f15..73ec0a8f8 100644 --- a/src/render/opengl/SDL_render_gl.c +++ b/src/render/opengl/SDL_render_gl.c @@ -106,7 +106,7 @@ typedef struct Uint32 color; int blendMode; } current; - + SDL_bool GL_EXT_framebuffer_object_supported; GL_FBOList *framebuffers; @@ -119,7 +119,7 @@ typedef struct SDL_bool GL_ARB_multitexture_supported; PFNGLACTIVETEXTUREARBPROC glActiveTextureARB; GLint num_texture_units; - + PFNGLGENFRAMEBUFFERSEXTPROC glGenFramebuffersEXT; PFNGLDELETEFRAMEBUFFERSEXTPROC glDeleteFramebuffersEXT; PFNGLFRAMEBUFFERTEXTURE2DEXTPROC glFramebufferTexture2DEXT; @@ -147,7 +147,7 @@ typedef struct SDL_bool yuv; GLuint utexture; GLuint vtexture; - + GL_FBOList *fbo; } GL_TextureData; @@ -408,7 +408,7 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags) renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_YV12; renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_IYUV; } - + if (SDL_GL_ExtensionSupported("GL_EXT_framebuffer_object")) { data->GL_EXT_framebuffer_object_supported = SDL_TRUE; data->glGenFramebuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC) @@ -527,7 +527,7 @@ GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) } texture->driverdata = data; - + if (texture->access == SDL_TEXTUREACCESS_TARGET) { data->fbo = GL_GetFBO(renderdata, texture->w, texture->h); } else { @@ -702,7 +702,7 @@ GL_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, GL_TextureData *data = (GL_TextureData *) texture->driverdata; data->locked_rect = *rect; - *pixels = + *pixels = (void *) ((Uint8 *) data->pixels + rect->y * data->pitch + rect->x * SDL_BYTESPERPIXEL(texture->format)); *pitch = data->pitch; @@ -717,7 +717,7 @@ GL_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture) void *pixels; rect = &data->locked_rect; - pixels = + pixels = (void *) ((Uint8 *) data->pixels + rect->y * data->pitch + rect->x * SDL_BYTESPERPIXEL(texture->format)); GL_UpdateTexture(renderer, texture, rect, pixels, data->pitch); @@ -726,12 +726,12 @@ GL_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture) static int GL_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture) { - GL_RenderData *data = (GL_RenderData *) renderer->driverdata; + GL_RenderData *data = (GL_RenderData *) renderer->driverdata; GL_TextureData *texturedata; GLenum status; GL_ActivateRenderer(renderer); - + if (texture == NULL) { data->glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); return 0; @@ -914,7 +914,7 @@ GL_RenderDrawLines(SDL_Renderer * renderer, const SDL_FPoint * points, GL_SetDrawingState(renderer); - if (count > 2 && + if (count > 2 && points[0].x == points[count-1].x && points[0].y == points[count-1].y) { data->glBegin(GL_LINE_LOOP); /* GL_LINE_LOOP takes care of the final segment */ @@ -1125,11 +1125,11 @@ GL_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture, maxv = (GLfloat) (srcrect->y + srcrect->h) / texture->h; maxv *= texturedata->texh; - // Translate to flip, rotate, translate to position + /* Translate to flip, rotate, translate to position */ data->glPushMatrix(); - data->glTranslatef((GLfloat)dstrect->x + centerx, (GLfloat)dstrect->y + centery, (GLfloat)0.0); + data->glTranslatef((GLfloat)dstrect->x + centerx, (GLfloat)dstrect->y + centery, (GLfloat)0.0); data->glRotated(angle, (GLdouble)0.0, (GLdouble)0.0, (GLdouble)1.0); - + data->glBegin(GL_TRIANGLE_STRIP); data->glTexCoord2f(minu, minv); data->glVertex2f(minx, miny); @@ -1141,7 +1141,7 @@ GL_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture, data->glVertex2f(maxx, maxy); data->glEnd(); data->glPopMatrix(); - + data->glDisable(texturedata->type); GL_CheckError("", renderer); @@ -1303,7 +1303,7 @@ static int GL_UnbindTexture (SDL_Renderer * renderer, SDL_Texture *texture) { data->glActiveTextureARB(GL_TEXTURE0_ARB); } - + data->glDisable(texturedata->type); return 0; diff --git a/src/render/opengl/SDL_shaders_gl.c b/src/render/opengl/SDL_shaders_gl.c index 9b75032ef..1e6262191 100644 --- a/src/render/opengl/SDL_shaders_gl.c +++ b/src/render/opengl/SDL_shaders_gl.c @@ -216,7 +216,7 @@ CompileShaderProgram(GL_ShaderContext *ctx, int index, GL_ShaderData *data) /* Make sure we use the correct sampler type for our texture type */ if (ctx->GL_ARB_texture_rectangle_supported) { - frag_defines = + frag_defines = "#define sampler2D sampler2DRect\n" "#define texture2D texture2DRect\n"; } @@ -252,7 +252,7 @@ CompileShaderProgram(GL_ShaderContext *ctx, int index, GL_ShaderData *data) } } ctx->glUseProgramObjectARB(0); - + return (ctx->glGetError() == GL_NO_ERROR); } diff --git a/src/render/opengles/SDL_render_gles.c b/src/render/opengles/SDL_render_gles.c index 37e32bfe7..bd3eedfea 100644 --- a/src/render/opengles/SDL_render_gles.c +++ b/src/render/opengles/SDL_render_gles.c @@ -189,7 +189,7 @@ static int GLES_LoadFunctions(GLES_RenderData * data) if ( ! data->func ) { \ return SDL_SetError("Couldn't load GLES function %s: %s\n", #func, SDL_GetError()); \ } \ - } while ( 0 ); + } while ( 0 ); #endif /* _SDL_NOGETPROCADDR_ */ #include "SDL_glesfuncs.h" @@ -270,11 +270,11 @@ GLES_CreateRenderer(SDL_Window * window, Uint32 flags) GLES_RenderData *data; GLint value; Uint32 windowFlags; - + SDL_GL_SetAttribute(SDL_GL_CONTEXT_EGL, 1); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 1); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1); - + windowFlags = SDL_GetWindowFlags(window); if (!(windowFlags & SDL_WINDOW_OPENGL)) { if (SDL_RecreateWindow(window, windowFlags | SDL_WINDOW_OPENGL) < 0) { @@ -386,7 +386,7 @@ static void GLES_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event) { GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; - + if (event->event == SDL_WINDOWEVENT_SIZE_CHANGED || event->event == SDL_WINDOWEVENT_SHOWN || event->event == SDL_WINDOWEVENT_HIDDEN) { @@ -765,7 +765,7 @@ GLES_RenderDrawLines(SDL_Renderer * renderer, const SDL_FPoint * points, GLES_SetDrawingState(renderer); data->glVertexPointer(2, GL_FLOAT, 0, points); - if (count > 2 && + if (count > 2 && points[0].x == points[count-1].x && points[0].y == points[count-1].y) { /* GL_LINE_LOOP takes care of the final segment */ --count; @@ -920,7 +920,7 @@ GLES_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture, GLfloat minx, miny, maxx, maxy; GLfloat minu, maxu, minv, maxv; GLfloat centerx, centery; - + GLES_ActivateRenderer(renderer); data->glEnable(GL_TEXTURE_2D); @@ -940,7 +940,7 @@ GLES_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture, centerx = center->x; centery = center->y; - // Rotate and translate + /* Rotate and translate */ data->glPushMatrix(); data->glTranslatef(dstrect->x + centerx, dstrect->y + centery, 0.0f); data->glRotatef((GLfloat)angle, 0.0f, 0.0f, 1.0f); diff --git a/src/render/opengles2/SDL_render_gles2.c b/src/render/opengles2/SDL_render_gles2.c index 0f74aeadc..3933100d6 100644 --- a/src/render/opengles2/SDL_render_gles2.c +++ b/src/render/opengles2/SDL_render_gles2.c @@ -1237,7 +1237,7 @@ GLES2_RenderCopy(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *s break; } } - else sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR; // Texture formats match, use the non color mapping shader (even if the formats are not ABGR) + else sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR; /* Texture formats match, use the non color mapping shader (even if the formats are not ABGR) */ } else { switch (texture->format) @@ -1334,7 +1334,7 @@ GLES2_RenderCopyEx(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect GLfloat tmp; GLES2_ActivateRenderer(renderer); - + rdata->glEnableVertexAttribArray(GLES2_ATTRIBUTE_CENTER); rdata->glEnableVertexAttribArray(GLES2_ATTRIBUTE_ANGLE); fAngle[0] = fAngle[1] = fAngle[2] = fAngle[3] = (GLfloat)(360.0f - angle); @@ -1403,7 +1403,7 @@ GLES2_RenderCopyEx(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect break; } } - else sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR; // Texture formats match, use the non color mapping shader (even if the formats are not ABGR) + else sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR; /* Texture formats match, use the non color mapping shader (even if the formats are not ABGR) */ } else { switch (texture->format) @@ -1476,7 +1476,7 @@ GLES2_RenderCopyEx(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect vertices[1] = vertices[3] = vertices[5]; vertices[5] = vertices[7] = tmp; } - + rdata->glVertexAttribPointer(GLES2_ATTRIBUTE_ANGLE, 1, GL_FLOAT, GL_FALSE, 0, &fAngle); rdata->glVertexAttribPointer(GLES2_ATTRIBUTE_CENTER, 2, GL_FLOAT, GL_FALSE, 0, translate); rdata->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); diff --git a/src/render/opengles2/SDL_shaders_gles2.c b/src/render/opengles2/SDL_shaders_gles2.c index 3d3a2416c..fb6921fd0 100644 --- a/src/render/opengles2/SDL_shaders_gles2.c +++ b/src/render/opengles2/SDL_shaders_gles2.c @@ -75,7 +75,7 @@ static const Uint8 GLES2_FragmentSrc_TextureABGRSrc_[] = " \ } \ "; -// ARGB to ABGR conversion +/* ARGB to ABGR conversion */ static const Uint8 GLES2_FragmentSrc_TextureARGBSrc_[] = " \ precision mediump float; \ uniform sampler2D u_texture; \ @@ -92,7 +92,7 @@ static const Uint8 GLES2_FragmentSrc_TextureARGBSrc_[] = " \ } \ "; -// RGB to ABGR conversion +/* RGB to ABGR conversion */ static const Uint8 GLES2_FragmentSrc_TextureRGBSrc_[] = " \ precision mediump float; \ uniform sampler2D u_texture; \ @@ -110,7 +110,7 @@ static const Uint8 GLES2_FragmentSrc_TextureRGBSrc_[] = " \ } \ "; -// BGR to ABGR conversion +/* BGR to ABGR conversion */ static const Uint8 GLES2_FragmentSrc_TextureBGRSrc_[] = " \ precision mediump float; \ uniform sampler2D u_texture; \ @@ -744,7 +744,7 @@ const GLES2_Shader *GLES2_GetShader(GLES2_ShaderType type, SDL_BlendMode blendMo default: return NULL; } - + case GLES2_SHADER_FRAGMENT_TEXTURE_RGB_SRC: switch (blendMode) { @@ -759,7 +759,7 @@ const GLES2_Shader *GLES2_GetShader(GLES2_ShaderType type, SDL_BlendMode blendMo default: return NULL; } - + case GLES2_SHADER_FRAGMENT_TEXTURE_BGR_SRC: switch (blendMode) { @@ -774,7 +774,7 @@ const GLES2_Shader *GLES2_GetShader(GLES2_ShaderType type, SDL_BlendMode blendMo default: return NULL; } - + default: return NULL; } diff --git a/src/render/psp/SDL_render_psp.c b/src/render/psp/SDL_render_psp.c index 4d8f33304..7ea536d14 100644 --- a/src/render/psp/SDL_render_psp.c +++ b/src/render/psp/SDL_render_psp.c @@ -20,7 +20,7 @@ */ #include "SDL_config.h" -#if SDL_VIDEO_RENDER_PSP +#if SDL_VIDEO_RENDER_PSP #include "SDL_hints.h" #include "../SDL_sysrender.h" @@ -93,94 +93,94 @@ SDL_RenderDriver PSP_RenderDriver = { }; */ SDL_RenderDriver PSP_RenderDriver = { - .CreateRenderer = PSP_CreateRenderer, + .CreateRenderer = PSP_CreateRenderer, .info = { - .name = "PSP", - .flags = SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE, - .num_texture_formats = 4, - .texture_formats = { [0] = SDL_PIXELFORMAT_BGR565, - [1] = SDL_PIXELFORMAT_ABGR1555, - [2] = SDL_PIXELFORMAT_ABGR4444, - [3] = SDL_PIXELFORMAT_ABGR8888, - }, - .max_texture_width = 512, - .max_texture_height = 512, + .name = "PSP", + .flags = SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE, + .num_texture_formats = 4, + .texture_formats = { [0] = SDL_PIXELFORMAT_BGR565, + [1] = SDL_PIXELFORMAT_ABGR1555, + [2] = SDL_PIXELFORMAT_ABGR4444, + [3] = SDL_PIXELFORMAT_ABGR8888, + }, + .max_texture_width = 512, + .max_texture_height = 512, } }; -#define PSP_SCREEN_WIDTH 480 -#define PSP_SCREEN_HEIGHT 272 +#define PSP_SCREEN_WIDTH 480 +#define PSP_SCREEN_HEIGHT 272 -#define PSP_FRAME_BUFFER_WIDTH 512 -#define PSP_FRAME_BUFFER_SIZE (PSP_FRAME_BUFFER_WIDTH*PSP_SCREEN_HEIGHT) +#define PSP_FRAME_BUFFER_WIDTH 512 +#define PSP_FRAME_BUFFER_SIZE (PSP_FRAME_BUFFER_WIDTH*PSP_SCREEN_HEIGHT) static unsigned int __attribute__((aligned(16))) DisplayList[262144]; - -#define COL5650(r,g,b,a) ((r>>3) | ((g>>2)<<5) | ((b>>3)<<11)) -#define COL5551(r,g,b,a) ((r>>3) | ((g>>3)<<5) | ((b>>3)<<10) | (a>0?0x7000:0)) -#define COL4444(r,g,b,a) ((r>>4) | ((g>>4)<<4) | ((b>>4)<<8) | ((a>>4)<<12)) -#define COL8888(r,g,b,a) ((r) | ((g)<<8) | ((b)<<16) | ((a)<<24)) - + +#define COL5650(r,g,b,a) ((r>>3) | ((g>>2)<<5) | ((b>>3)<<11)) +#define COL5551(r,g,b,a) ((r>>3) | ((g>>3)<<5) | ((b>>3)<<10) | (a>0?0x7000:0)) +#define COL4444(r,g,b,a) ((r>>4) | ((g>>4)<<4) | ((b>>4)<<8) | ((a>>4)<<12)) +#define COL8888(r,g,b,a) ((r) | ((g)<<8) | ((b)<<16) | ((a)<<24)) + typedef struct { - void* frontbuffer ; - void* backbuffer ; - SDL_bool initialized ; - SDL_bool displayListAvail ; - unsigned int psm ; - unsigned int bpp ; - - SDL_bool vsync; - unsigned int currentColor; - int currentBlendMode; - + void* frontbuffer ; + void* backbuffer ; + SDL_bool initialized ; + SDL_bool displayListAvail ; + unsigned int psm ; + unsigned int bpp ; + + SDL_bool vsync; + unsigned int currentColor; + int currentBlendMode; + } PSP_RenderData; typedef struct { - void *data; /**< Image data. */ - unsigned int size; /**< Size of data in bytes. */ - unsigned int width; /**< Image width. */ - unsigned int height; /**< Image height. */ - unsigned int textureWidth; /**< Texture width (power of two). */ - unsigned int textureHeight; /**< Texture height (power of two). */ - unsigned int bits; /**< Image bits per pixel. */ - unsigned int format; /**< Image format - one of ::pgePixelFormat. */ - unsigned int pitch; - SDL_bool swizzled; /**< Is image swizzled. */ + void *data; /**< Image data. */ + unsigned int size; /**< Size of data in bytes. */ + unsigned int width; /**< Image width. */ + unsigned int height; /**< Image height. */ + unsigned int textureWidth; /**< Texture width (power of two). */ + unsigned int textureHeight; /**< Texture height (power of two). */ + unsigned int bits; /**< Image bits per pixel. */ + unsigned int format; /**< Image format - one of ::pgePixelFormat. */ + unsigned int pitch; + SDL_bool swizzled; /**< Is image swizzled. */ } PSP_TextureData; typedef struct -{ - float x, y, z; +{ + float x, y, z; } VertV; typedef struct { - float u, v; - float x, y, z; - + float u, v; + float x, y, z; + } VertTV; -// Return next power of 2 -static int +/* Return next power of 2 */ +static int TextureNextPow2(unsigned int w) { - if(w == 0) - return 0; + if(w == 0) + return 0; - unsigned int n = 2; + unsigned int n = 2; - while(w > n) - n <<= 1; + while(w > n) + n <<= 1; - return n; + return n; } @@ -190,9 +190,9 @@ GetScaleQuality(void) const char *hint = SDL_GetHint(SDL_HINT_RENDER_SCALE_QUALITY); if (!hint || *hint == '0' || SDL_strcasecmp(hint, "nearest") == 0) { - return GU_NEAREST; // GU_NEAREST good for tile-map + return GU_NEAREST; /* GU_NEAREST good for tile-map */ } else { - return GU_LINEAR; // GU_LINEAR good for scaling + return GU_LINEAR; /* GU_LINEAR good for scaling */ } } @@ -207,133 +207,133 @@ PixelFormatToPSPFMT(Uint32 format) case SDL_PIXELFORMAT_ABGR4444: return GU_PSM_4444; case SDL_PIXELFORMAT_ABGR8888: - return GU_PSM_8888; - default: + return GU_PSM_8888; + default: return GU_PSM_8888; } } -void +void StartDrawing(SDL_Renderer * renderer) -{ - PSP_RenderData *data = (PSP_RenderData *) renderer->driverdata; - if(data->displayListAvail) - return; +{ + PSP_RenderData *data = (PSP_RenderData *) renderer->driverdata; + if(data->displayListAvail) + return; - sceGuStart(GU_DIRECT, DisplayList); - data->displayListAvail = SDL_TRUE; + sceGuStart(GU_DIRECT, DisplayList); + data->displayListAvail = SDL_TRUE; } -int +int TextureSwizzle(PSP_TextureData *psp_texture) { - if(psp_texture->swizzled) - return 1; - - int bytewidth = psp_texture->textureWidth*(psp_texture->bits>>3); - int height = psp_texture->size / bytewidth; + if(psp_texture->swizzled) + return 1; + + int bytewidth = psp_texture->textureWidth*(psp_texture->bits>>3); + int height = psp_texture->size / bytewidth; - int rowblocks = (bytewidth>>4); - int rowblocksadd = (rowblocks-1)<<7; - unsigned int blockaddress = 0; - unsigned int *src = (unsigned int*) psp_texture->data; + int rowblocks = (bytewidth>>4); + int rowblocksadd = (rowblocks-1)<<7; + unsigned int blockaddress = 0; + unsigned int *src = (unsigned int*) psp_texture->data; - unsigned char *data = NULL; - data = malloc(psp_texture->size); + unsigned char *data = NULL; + data = malloc(psp_texture->size); - int j; + int j; - for(j = 0; j < height; j++, blockaddress += 16) - { - unsigned int *block; + for(j = 0; j < height; j++, blockaddress += 16) + { + unsigned int *block; - block = (unsigned int*)&data[blockaddress]; + block = (unsigned int*)&data[blockaddress]; - int i; + int i; - for(i = 0; i < rowblocks; i++) - { - *block++ = *src++; - *block++ = *src++; - *block++ = *src++; - *block++ = *src++; - block += 28; - } + for(i = 0; i < rowblocks; i++) + { + *block++ = *src++; + *block++ = *src++; + *block++ = *src++; + *block++ = *src++; + block += 28; + } - if((j & 0x7) == 0x7) - blockaddress += rowblocksadd; - } + if((j & 0x7) == 0x7) + blockaddress += rowblocksadd; + } - free(psp_texture->data); - psp_texture->data = data; - psp_texture->swizzled = SDL_TRUE; + free(psp_texture->data); + psp_texture->data = data; + psp_texture->swizzled = SDL_TRUE; - return 1; + return 1; } int TextureUnswizzle(PSP_TextureData *psp_texture) { - if(!psp_texture->swizzled) - return 1; - - int blockx, blocky; - - int bytewidth = psp_texture->textureWidth*(psp_texture->bits>>3); - int height = psp_texture->size / bytewidth; - - int widthblocks = bytewidth/16; - int heightblocks = height/8; - - int dstpitch = (bytewidth - 16)/4; - int dstrow = bytewidth * 8; - - unsigned int *src = (unsigned int*) psp_texture->data; - - unsigned char *data = NULL; - - data = malloc(psp_texture->size); - - if(!data) - return 0; - - sceKernelDcacheWritebackAll(); - - int j; - - unsigned char *ydst = (unsigned char *)data; - - for(blocky = 0; blocky < heightblocks; ++blocky) - { - unsigned char *xdst = ydst; - - for(blockx = 0; blockx < widthblocks; ++blockx) - { - unsigned int *block; - - block = (unsigned int*)xdst; - - for(j = 0; j < 8; ++j) - { - *(block++) = *(src++); - *(block++) = *(src++); - *(block++) = *(src++); - *(block++) = *(src++); - block += dstpitch; - } - - xdst += 16; - } - - ydst += dstrow; - } - - free(psp_texture->data); - - psp_texture->data = data; - - psp_texture->swizzled = SDL_FALSE; - - return 1; + if(!psp_texture->swizzled) + return 1; + + int blockx, blocky; + + int bytewidth = psp_texture->textureWidth*(psp_texture->bits>>3); + int height = psp_texture->size / bytewidth; + + int widthblocks = bytewidth/16; + int heightblocks = height/8; + + int dstpitch = (bytewidth - 16)/4; + int dstrow = bytewidth * 8; + + unsigned int *src = (unsigned int*) psp_texture->data; + + unsigned char *data = NULL; + + data = malloc(psp_texture->size); + + if(!data) + return 0; + + sceKernelDcacheWritebackAll(); + + int j; + + unsigned char *ydst = (unsigned char *)data; + + for(blocky = 0; blocky < heightblocks; ++blocky) + { + unsigned char *xdst = ydst; + + for(blockx = 0; blockx < widthblocks; ++blockx) + { + unsigned int *block; + + block = (unsigned int*)xdst; + + for(j = 0; j < 8; ++j) + { + *(block++) = *(src++); + *(block++) = *(src++); + *(block++) = *(src++); + *(block++) = *(src++); + block += dstpitch; + } + + xdst += 16; + } + + ydst += dstrow; + } + + free(psp_texture->data); + + psp_texture->data = data; + + psp_texture->swizzled = SDL_FALSE; + + return 1; } SDL_Renderer * @@ -342,7 +342,7 @@ PSP_CreateRenderer(SDL_Window * window, Uint32 flags) SDL_Renderer *renderer; PSP_RenderData *data; - int pixelformat; + int pixelformat; renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer)); if (!renderer) { SDL_OutOfMemory(); @@ -355,8 +355,8 @@ PSP_CreateRenderer(SDL_Window * window, Uint32 flags) SDL_OutOfMemory(); return NULL; } - - + + renderer->WindowEvent = PSP_WindowEvent; renderer->CreateTexture = PSP_CreateTexture; renderer->UpdateTexture = PSP_UpdateTexture; @@ -378,73 +378,73 @@ PSP_CreateRenderer(SDL_Window * window, Uint32 flags) renderer->info.flags = SDL_RENDERER_ACCELERATED; renderer->driverdata = data; renderer->window = window; - - if (data->initialized != SDL_FALSE) - return 0; - data->initialized = SDL_TRUE; - + + if (data->initialized != SDL_FALSE) + return 0; + data->initialized = SDL_TRUE; + if (flags & SDL_RENDERER_PRESENTVSYNC) { data->vsync = SDL_TRUE; } else { data->vsync = SDL_FALSE; } - - pixelformat=PixelFormatToPSPFMT(SDL_GetWindowPixelFormat(window)); - switch(pixelformat) - { - case GU_PSM_4444: - case GU_PSM_5650: - case GU_PSM_5551: - data->frontbuffer = (unsigned int *)(PSP_FRAME_BUFFER_SIZE<<1); - data->backbuffer = (unsigned int *)(0); - data->bpp = 2; - data->psm = pixelformat; - break; - default: - data->frontbuffer = (unsigned int *)(PSP_FRAME_BUFFER_SIZE<<2); - data->backbuffer = (unsigned int *)(0); - data->bpp = 4; - data->psm = GU_PSM_8888; - break; - } - - sceGuInit(); - // setup GU - sceGuStart(GU_DIRECT, DisplayList); - sceGuDrawBuffer(data->psm, data->frontbuffer, PSP_FRAME_BUFFER_WIDTH); - sceGuDispBuffer(PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT, data->backbuffer, PSP_FRAME_BUFFER_WIDTH); - - - sceGuOffset(2048 - (PSP_SCREEN_WIDTH>>1), 2048 - (PSP_SCREEN_HEIGHT>>1)); - sceGuViewport(2048, 2048, PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT); + + pixelformat=PixelFormatToPSPFMT(SDL_GetWindowPixelFormat(window)); + switch(pixelformat) + { + case GU_PSM_4444: + case GU_PSM_5650: + case GU_PSM_5551: + data->frontbuffer = (unsigned int *)(PSP_FRAME_BUFFER_SIZE<<1); + data->backbuffer = (unsigned int *)(0); + data->bpp = 2; + data->psm = pixelformat; + break; + default: + data->frontbuffer = (unsigned int *)(PSP_FRAME_BUFFER_SIZE<<2); + data->backbuffer = (unsigned int *)(0); + data->bpp = 4; + data->psm = GU_PSM_8888; + break; + } + + sceGuInit(); + /* setup GU */ + sceGuStart(GU_DIRECT, DisplayList); + sceGuDrawBuffer(data->psm, data->frontbuffer, PSP_FRAME_BUFFER_WIDTH); + sceGuDispBuffer(PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT, data->backbuffer, PSP_FRAME_BUFFER_WIDTH); + + + sceGuOffset(2048 - (PSP_SCREEN_WIDTH>>1), 2048 - (PSP_SCREEN_HEIGHT>>1)); + sceGuViewport(2048, 2048, PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT); data->frontbuffer = vabsptr(data->frontbuffer); data->backbuffer = vabsptr(data->backbuffer); - - // Scissoring - sceGuScissor(0, 0, PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT); - sceGuEnable(GU_SCISSOR_TEST); - - // Backface culling - sceGuFrontFace(GU_CCW); - sceGuEnable(GU_CULL_FACE); - - // Texturing - sceGuEnable(GU_TEXTURE_2D); - sceGuShadeModel(GU_SMOOTH); - sceGuTexWrap(GU_REPEAT, GU_REPEAT); - - // Blending - sceGuEnable(GU_BLEND); - sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0); - - sceGuTexFilter(GU_LINEAR,GU_LINEAR); - - sceGuFinish(); - sceGuSync(0,0); - sceDisplayWaitVblankStartCB(); - sceGuDisplay(GU_TRUE); - + + /* Scissoring */ + sceGuScissor(0, 0, PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT); + sceGuEnable(GU_SCISSOR_TEST); + + /* Backface culling */ + sceGuFrontFace(GU_CCW); + sceGuEnable(GU_CULL_FACE); + + /* Texturing */ + sceGuEnable(GU_TEXTURE_2D); + sceGuShadeModel(GU_SMOOTH); + sceGuTexWrap(GU_REPEAT, GU_REPEAT); + + /* Blending */ + sceGuEnable(GU_BLEND); + sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0); + + sceGuTexFilter(GU_LINEAR,GU_LINEAR); + + sceGuFinish(); + sceGuSync(0,0); + sceDisplayWaitVblankStartCB(); + sceGuDisplay(GU_TRUE); + return renderer; } @@ -458,69 +458,69 @@ PSP_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event) static int PSP_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) { -// PSP_RenderData *renderdata = (PSP_RenderData *) renderer->driverdata; - PSP_TextureData* psp_texture = (PSP_TextureData*) SDL_calloc(1, sizeof(*psp_texture));; - - if(!psp_texture) - return -1; - - psp_texture->swizzled = SDL_FALSE; - psp_texture->width = texture->w; - psp_texture->height = texture->h; - psp_texture->textureHeight = TextureNextPow2(texture->h); - psp_texture->textureWidth = TextureNextPow2(texture->w); - psp_texture->format = PixelFormatToPSPFMT(texture->format); - - switch(psp_texture->format) - { - case GU_PSM_5650: - case GU_PSM_5551: - case GU_PSM_4444: - psp_texture->bits = 16; - break; - - case GU_PSM_8888: - psp_texture->bits = 32; - break; - - default: - return -1; - } - - psp_texture->pitch = psp_texture->textureWidth * SDL_BYTESPERPIXEL(texture->format); - psp_texture->size = psp_texture->textureHeight*psp_texture->pitch; - psp_texture->data = SDL_calloc(1, psp_texture->size); - - if(!psp_texture->data) - { - SDL_free(psp_texture); - return SDL_OutOfMemory(); - } +// PSP_RenderData *renderdata = (PSP_RenderData *) renderer->driverdata; + PSP_TextureData* psp_texture = (PSP_TextureData*) SDL_calloc(1, sizeof(*psp_texture));; + + if(!psp_texture) + return -1; + + psp_texture->swizzled = SDL_FALSE; + psp_texture->width = texture->w; + psp_texture->height = texture->h; + psp_texture->textureHeight = TextureNextPow2(texture->h); + psp_texture->textureWidth = TextureNextPow2(texture->w); + psp_texture->format = PixelFormatToPSPFMT(texture->format); + + switch(psp_texture->format) + { + case GU_PSM_5650: + case GU_PSM_5551: + case GU_PSM_4444: + psp_texture->bits = 16; + break; + + case GU_PSM_8888: + psp_texture->bits = 32; + break; + + default: + return -1; + } + + psp_texture->pitch = psp_texture->textureWidth * SDL_BYTESPERPIXEL(texture->format); + psp_texture->size = psp_texture->textureHeight*psp_texture->pitch; + psp_texture->data = SDL_calloc(1, psp_texture->size); + + if(!psp_texture->data) + { + SDL_free(psp_texture); + return SDL_OutOfMemory(); + } texture->driverdata = psp_texture; - + return 0; } -void +void TextureActivate(SDL_Texture * texture) -{ - PSP_TextureData *psp_texture = (PSP_TextureData *) texture->driverdata; - int scaleMode = GetScaleQuality(); - - // Swizzling is useless with small textures. +{ + PSP_TextureData *psp_texture = (PSP_TextureData *) texture->driverdata; + int scaleMode = GetScaleQuality(); + + /* Swizzling is useless with small textures. */ if (texture->w >= 16 || texture->h >= 16) { - TextureSwizzle(psp_texture); + TextureSwizzle(psp_texture); } - - sceGuEnable(GU_TEXTURE_2D); - sceGuTexWrap(GU_REPEAT, GU_REPEAT); - sceGuTexMode(psp_texture->format, 0, 0, psp_texture->swizzled); - sceGuTexFilter(scaleMode, scaleMode); // GU_NEAREST good for tile-map - // GU_LINEAR good for scaling - sceGuTexImage(0, psp_texture->textureWidth, psp_texture->textureHeight, psp_texture->textureWidth, psp_texture->data); - sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA); + + sceGuEnable(GU_TEXTURE_2D); + sceGuTexWrap(GU_REPEAT, GU_REPEAT); + sceGuTexMode(psp_texture->format, 0, 0, psp_texture->swizzled); + sceGuTexFilter(scaleMode, scaleMode); /* GU_NEAREST good for tile-map */ + /* GU_LINEAR good for scaling */ + sceGuTexImage(0, psp_texture->textureWidth, psp_texture->textureHeight, psp_texture->textureWidth, psp_texture->data); + sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA); } @@ -528,12 +528,12 @@ static int PSP_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Rect * rect, const void *pixels, int pitch) { -// PSP_TextureData *psp_texture = (PSP_TextureData *) texture->driverdata; +// PSP_TextureData *psp_texture = (PSP_TextureData *) texture->driverdata; const Uint8 *src; Uint8 *dst; int row, length,dpitch; src = pixels; - + PSP_LockTexture(renderer, texture,rect,(void **)&dst, &dpitch); length = rect->w * SDL_BYTESPERPIXEL(texture->format); if (length == pitch && length == dpitch) { @@ -545,8 +545,8 @@ PSP_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, dst += dpitch; } } - - sceKernelDcacheWritebackAll(); + + sceKernelDcacheWritebackAll(); return 0; } @@ -554,7 +554,7 @@ static int PSP_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Rect * rect, void **pixels, int *pitch) { - PSP_TextureData *psp_texture = (PSP_TextureData *) texture->driverdata; + PSP_TextureData *psp_texture = (PSP_TextureData *) texture->driverdata; *pixels = (void *) ((Uint8 *) psp_texture->data + rect->y * psp_texture->pitch + @@ -566,7 +566,7 @@ PSP_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, static void PSP_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture) { - PSP_TextureData *psp_texture = (PSP_TextureData *) texture->driverdata; + PSP_TextureData *psp_texture = (PSP_TextureData *) texture->driverdata; SDL_Rect rect; /* We do whole texture updates, at least for now */ @@ -595,27 +595,27 @@ PSP_UpdateViewport(SDL_Renderer * renderer) static void PSP_SetBlendMode(SDL_Renderer * renderer, int blendMode) { - PSP_RenderData *data = (PSP_RenderData *) renderer->driverdata; + PSP_RenderData *data = (PSP_RenderData *) renderer->driverdata; if (blendMode != data-> currentBlendMode) { switch (blendMode) { case SDL_BLENDMODE_NONE: - sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA); - sceGuDisable(GU_BLEND); + sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA); + sceGuDisable(GU_BLEND); break; case SDL_BLENDMODE_BLEND: - sceGuTexFunc(GU_TFX_MODULATE , GU_TCC_RGBA); - sceGuEnable(GU_BLEND); - sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0 ); + sceGuTexFunc(GU_TFX_MODULATE , GU_TCC_RGBA); + sceGuEnable(GU_BLEND); + sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0 ); break; case SDL_BLENDMODE_ADD: - sceGuTexFunc(GU_TFX_MODULATE , GU_TCC_RGBA); - sceGuEnable(GU_BLEND); - sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_FIX, 0, 0x00FFFFFF ); + sceGuTexFunc(GU_TFX_MODULATE , GU_TCC_RGBA); + sceGuEnable(GU_BLEND); + sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_FIX, 0, 0x00FFFFFF ); break; case SDL_BLENDMODE_MOD: - sceGuTexFunc(GU_TFX_MODULATE , GU_TCC_RGBA); - sceGuEnable(GU_BLEND); - sceGuBlendFunc( GU_ADD, GU_FIX, GU_SRC_COLOR, 0, 0); + sceGuTexFunc(GU_TFX_MODULATE , GU_TCC_RGBA); + sceGuEnable(GU_BLEND); + sceGuBlendFunc( GU_ADD, GU_FIX, GU_SRC_COLOR, 0, 0); break; } data->currentBlendMode = blendMode; @@ -626,13 +626,13 @@ PSP_SetBlendMode(SDL_Renderer * renderer, int blendMode) static int PSP_RenderClear(SDL_Renderer * renderer) -{ - //start list - StartDrawing(renderer); - int color = renderer->a << 24 | renderer->b << 16 | renderer->g << 8 | renderer->r; - sceGuClearColor(color); - sceGuClearDepth(0); - sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT|GU_FAST_CLEAR_BIT); +{ + /* start list */ + StartDrawing(renderer); + int color = renderer->a << 24 | renderer->b << 16 | renderer->g << 8 | renderer->r; + sceGuClearColor(color); + sceGuClearDepth(0); + sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT|GU_FAST_CLEAR_BIT); return 0; } @@ -641,22 +641,22 @@ static int PSP_RenderDrawPoints(SDL_Renderer * renderer, const SDL_FPoint * points, int count) { - int color = renderer->a << 24 | renderer->b << 16 | renderer->g << 8 | renderer->r; - int i; - StartDrawing(renderer); - VertV* vertices = (VertV*)sceGuGetMemory(count*sizeof(VertV)); - - for (i = 0; i < count; ++i) { - vertices[i].x = points[i].x; - vertices[i].y = points[i].y; - vertices[i].z = 0.0f; - } - sceGuDisable(GU_TEXTURE_2D); - sceGuColor(color); - sceGuShadeModel(GU_FLAT); - sceGuDrawArray(GU_POINTS, GU_VERTEX_32BITF|GU_TRANSFORM_2D, count, 0, vertices); - sceGuShadeModel(GU_SMOOTH); - sceGuEnable(GU_TEXTURE_2D); + int color = renderer->a << 24 | renderer->b << 16 | renderer->g << 8 | renderer->r; + int i; + StartDrawing(renderer); + VertV* vertices = (VertV*)sceGuGetMemory(count*sizeof(VertV)); + + for (i = 0; i < count; ++i) { + vertices[i].x = points[i].x; + vertices[i].y = points[i].y; + vertices[i].z = 0.0f; + } + sceGuDisable(GU_TEXTURE_2D); + sceGuColor(color); + sceGuShadeModel(GU_FLAT); + sceGuDrawArray(GU_POINTS, GU_VERTEX_32BITF|GU_TRANSFORM_2D, count, 0, vertices); + sceGuShadeModel(GU_SMOOTH); + sceGuEnable(GU_TEXTURE_2D); return 0; } @@ -665,24 +665,24 @@ static int PSP_RenderDrawLines(SDL_Renderer * renderer, const SDL_FPoint * points, int count) { - int color = renderer->a << 24 | renderer->b << 16 | renderer->g << 8 | renderer->r; - int i; - StartDrawing(renderer); - VertV* vertices = (VertV*)sceGuGetMemory(count*sizeof(VertV)); - - for (i = 0; i < count; ++i) { - vertices[i].x = points[i].x; - vertices[i].y = points[i].y; - vertices[i].z = 0.0f; - } - - sceGuDisable(GU_TEXTURE_2D); - sceGuColor(color); - sceGuShadeModel(GU_FLAT); - sceGuDrawArray(GU_LINE_STRIP, GU_VERTEX_32BITF|GU_TRANSFORM_2D, count, 0, vertices); - sceGuShadeModel(GU_SMOOTH); - sceGuEnable(GU_TEXTURE_2D); - + int color = renderer->a << 24 | renderer->b << 16 | renderer->g << 8 | renderer->r; + int i; + StartDrawing(renderer); + VertV* vertices = (VertV*)sceGuGetMemory(count*sizeof(VertV)); + + for (i = 0; i < count; ++i) { + vertices[i].x = points[i].x; + vertices[i].y = points[i].y; + vertices[i].z = 0.0f; + } + + sceGuDisable(GU_TEXTURE_2D); + sceGuColor(color); + sceGuShadeModel(GU_FLAT); + sceGuDrawArray(GU_LINE_STRIP, GU_VERTEX_32BITF|GU_TRANSFORM_2D, count, 0, vertices); + sceGuShadeModel(GU_SMOOTH); + sceGuEnable(GU_TEXTURE_2D); + return 0; } @@ -690,29 +690,29 @@ static int PSP_RenderFillRects(SDL_Renderer * renderer, const SDL_FRect * rects, int count) { - int color = renderer->a << 24 | renderer->b << 16 | renderer->g << 8 | renderer->r; - int i; - StartDrawing(renderer); - - for (i = 0; i < count; ++i) { - const SDL_FRect *rect = &rects[i]; - VertV* vertices = (VertV*)sceGuGetMemory((sizeof(VertV)<<1)); - vertices[0].x = rect->x; - vertices[0].y = rect->y; - vertices[0].z = 0.0f; - - vertices[1].x = rect->x + rect->w; - vertices[1].y = rect->y + rect->h; - vertices[1].z = 0.0f; - - sceGuDisable(GU_TEXTURE_2D); - sceGuColor(color); - sceGuShadeModel(GU_FLAT); - sceGuDrawArray(GU_SPRITES, GU_VERTEX_32BITF|GU_TRANSFORM_2D, 2, 0, vertices); - sceGuShadeModel(GU_SMOOTH); - sceGuEnable(GU_TEXTURE_2D); + int color = renderer->a << 24 | renderer->b << 16 | renderer->g << 8 | renderer->r; + int i; + StartDrawing(renderer); + + for (i = 0; i < count; ++i) { + const SDL_FRect *rect = &rects[i]; + VertV* vertices = (VertV*)sceGuGetMemory((sizeof(VertV)<<1)); + vertices[0].x = rect->x; + vertices[0].y = rect->y; + vertices[0].z = 0.0f; + + vertices[1].x = rect->x + rect->w; + vertices[1].y = rect->y + rect->h; + vertices[1].z = 0.0f; + + sceGuDisable(GU_TEXTURE_2D); + sceGuColor(color); + sceGuShadeModel(GU_FLAT); + sceGuDrawArray(GU_SPRITES, GU_VERTEX_32BITF|GU_TRANSFORM_2D, 2, 0, vertices); + sceGuShadeModel(GU_SMOOTH); + sceGuEnable(GU_TEXTURE_2D); } - + return 0; } @@ -724,127 +724,127 @@ PSP_RenderFillRects(SDL_Renderer * renderer, const SDL_FRect * rects, float MathAbs(float x) { - float result; + float result; - __asm__ volatile ( - "mtv %1, S000\n" - "vabs.s S000, S000\n" - "mfv %0, S000\n" - : "=r"(result) : "r"(x)); + __asm__ volatile ( + "mtv %1, S000\n" + "vabs.s S000, S000\n" + "mfv %0, S000\n" + : "=r"(result) : "r"(x)); - return result; + return result; } void MathSincos(float r, float *s, float *c) { - __asm__ volatile ( - "mtv %2, S002\n" - "vcst.s S003, VFPU_2_PI\n" - "vmul.s S002, S002, S003\n" - "vrot.p C000, S002, [s, c]\n" - "mfv %0, S000\n" - "mfv %1, S001\n" - : "=r"(*s), "=r"(*c): "r"(r)); + __asm__ volatile ( + "mtv %2, S002\n" + "vcst.s S003, VFPU_2_PI\n" + "vmul.s S002, S002, S003\n" + "vrot.p C000, S002, [s, c]\n" + "mfv %0, S000\n" + "mfv %1, S001\n" + : "=r"(*s), "=r"(*c): "r"(r)); } void Swap(float *a, float *b) { - float n=*a; - *a = *b; - *b = n; + float n=*a; + *a = *b; + *b = n; } static int PSP_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Rect * srcrect, const SDL_FRect * dstrect) { - float x, y, width, height; - float u0, v0, u1, v1; - unsigned char alpha; - - x = dstrect->x; - y = dstrect->y; - width = dstrect->w; - height = dstrect->h; - - u0 = srcrect->x; - v0 = srcrect->y; - u1 = srcrect->x + srcrect->w; - v1 = srcrect->y + srcrect->h; - - alpha = texture->a; - - StartDrawing(renderer); - TextureActivate(texture); - PSP_SetBlendMode(renderer, renderer->blendMode); - - if(alpha != 255) - { - sceGuTexFunc(GU_TFX_MODULATE, GU_TCC_RGBA); - sceGuColor(GU_RGBA(255, 255, 255, alpha)); - }else{ - sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA); - sceGuColor(0xFFFFFFFF); - } - - if((MathAbs(u1) - MathAbs(u0)) < 64.0f) - { - VertTV* vertices = (VertTV*)sceGuGetMemory((sizeof(VertTV))<<1); - - vertices[0].u = u0; - vertices[0].v = v0; - vertices[0].x = x; - vertices[0].y = y; - vertices[0].z = 0; - - vertices[1].u = u1; - vertices[1].v = v1; - vertices[1].x = x + width; - vertices[1].y = y + height; - vertices[1].z = 0; - - sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_2D, 2, 0, vertices); - } - else - { - float start, end; - float curU = u0; - float curX = x; - float endX = x + width; - float slice = 64.0f; - float ustep = (u1 - u0)/width * slice; - - if(ustep < 0.0f) - ustep = -ustep; - - for(start = 0, end = width; start < end; start += slice) - { - VertTV* vertices = (VertTV*)sceGuGetMemory((sizeof(VertTV))<<1); - - float polyWidth = ((curX + slice) > endX) ? (endX - curX) : slice; - float sourceWidth = ((curU + ustep) > u1) ? (u1 - curU) : ustep; - - vertices[0].u = curU; - vertices[0].v = v0; - vertices[0].x = curX; - vertices[0].y = y; - vertices[0].z = 0; - - curU += sourceWidth; - curX += polyWidth; - - vertices[1].u = curU; - vertices[1].v = v1; - vertices[1].x = curX; - vertices[1].y = (y + height); - vertices[1].z = 0; - - sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_2D, 2, 0, vertices); - } - } - - if(alpha != 255) - sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA); + float x, y, width, height; + float u0, v0, u1, v1; + unsigned char alpha; + + x = dstrect->x; + y = dstrect->y; + width = dstrect->w; + height = dstrect->h; + + u0 = srcrect->x; + v0 = srcrect->y; + u1 = srcrect->x + srcrect->w; + v1 = srcrect->y + srcrect->h; + + alpha = texture->a; + + StartDrawing(renderer); + TextureActivate(texture); + PSP_SetBlendMode(renderer, renderer->blendMode); + + if(alpha != 255) + { + sceGuTexFunc(GU_TFX_MODULATE, GU_TCC_RGBA); + sceGuColor(GU_RGBA(255, 255, 255, alpha)); + }else{ + sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA); + sceGuColor(0xFFFFFFFF); + } + + if((MathAbs(u1) - MathAbs(u0)) < 64.0f) + { + VertTV* vertices = (VertTV*)sceGuGetMemory((sizeof(VertTV))<<1); + + vertices[0].u = u0; + vertices[0].v = v0; + vertices[0].x = x; + vertices[0].y = y; + vertices[0].z = 0; + + vertices[1].u = u1; + vertices[1].v = v1; + vertices[1].x = x + width; + vertices[1].y = y + height; + vertices[1].z = 0; + + sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_2D, 2, 0, vertices); + } + else + { + float start, end; + float curU = u0; + float curX = x; + float endX = x + width; + float slice = 64.0f; + float ustep = (u1 - u0)/width * slice; + + if(ustep < 0.0f) + ustep = -ustep; + + for(start = 0, end = width; start < end; start += slice) + { + VertTV* vertices = (VertTV*)sceGuGetMemory((sizeof(VertTV))<<1); + + float polyWidth = ((curX + slice) > endX) ? (endX - curX) : slice; + float sourceWidth = ((curU + ustep) > u1) ? (u1 - curU) : ustep; + + vertices[0].u = curU; + vertices[0].v = v0; + vertices[0].x = curX; + vertices[0].y = y; + vertices[0].z = 0; + + curU += sourceWidth; + curX += polyWidth; + + vertices[1].u = curU; + vertices[1].v = v1; + vertices[1].x = curX; + vertices[1].y = (y + height); + vertices[1].z = 0; + + sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_2D, 2, 0, vertices); + } + } + + if(alpha != 255) + sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA); return 0; } @@ -853,7 +853,7 @@ PSP_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, Uint32 pixel_format, void * pixels, int pitch) { - return 0; + return 0; } @@ -862,98 +862,98 @@ PSP_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Rect * srcrect, const SDL_FRect * dstrect, const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip) { - float x, y, width, height; - float u0, v0, u1, v1; - unsigned char alpha; - float centerx, centery; - - x = dstrect->x; - y = dstrect->y; - width = dstrect->w; - height = dstrect->h; - - u0 = srcrect->x; - v0 = srcrect->y; - u1 = srcrect->x + srcrect->w; - v1 = srcrect->y + srcrect->h; - + float x, y, width, height; + float u0, v0, u1, v1; + unsigned char alpha; + float centerx, centery; + + x = dstrect->x; + y = dstrect->y; + width = dstrect->w; + height = dstrect->h; + + u0 = srcrect->x; + v0 = srcrect->y; + u1 = srcrect->x + srcrect->w; + v1 = srcrect->y + srcrect->h; + centerx = center->x; centery = center->y; - - alpha = texture->a; - - StartDrawing(renderer); - TextureActivate(texture); - PSP_SetBlendMode(renderer, renderer->blendMode); - - if(alpha != 255) - { - sceGuTexFunc(GU_TFX_MODULATE, GU_TCC_RGBA); - sceGuColor(GU_RGBA(255, 255, 255, alpha)); - }else{ - sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA); - sceGuColor(0xFFFFFFFF); - } - -// x += width * 0.5f; -// y += height * 0.5f; - x += centerx; - y += centery; - - float c, s; - - MathSincos(degToRad(angle), &s, &c); - -// width *= 0.5f; -// height *= 0.5f; - width -= centerx; - height -= centery; - - - float cw = c*width; - float sw = s*width; - float ch = c*height; - float sh = s*height; - - VertTV* vertices = (VertTV*)sceGuGetMemory(sizeof(VertTV)<<2); - - vertices[0].u = u0; - vertices[0].v = v0; - vertices[0].x = x - cw + sh; - vertices[0].y = y - sw - ch; - vertices[0].z = 0; - - vertices[1].u = u0; - vertices[1].v = v1; - vertices[1].x = x - cw - sh; - vertices[1].y = y - sw + ch; - vertices[1].z = 0; - - vertices[2].u = u1; - vertices[2].v = v1; - vertices[2].x = x + cw - sh; - vertices[2].y = y + sw + ch; - vertices[2].z = 0; - - vertices[3].u = u1; - vertices[3].v = v0; - vertices[3].x = x + cw + sh; - vertices[3].y = y + sw - ch; - vertices[3].z = 0; - - if (flip & SDL_FLIP_HORIZONTAL) { - Swap(&vertices[0].v, &vertices[2].v); - Swap(&vertices[1].v, &vertices[3].v); - } - if (flip & SDL_FLIP_VERTICAL) { - Swap(&vertices[0].u, &vertices[2].u); - Swap(&vertices[1].u, &vertices[3].u); - } - - sceGuDrawArray(GU_TRIANGLE_FAN, GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_2D, 4, 0, vertices); - - if(alpha != 255) - sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA); + + alpha = texture->a; + + StartDrawing(renderer); + TextureActivate(texture); + PSP_SetBlendMode(renderer, renderer->blendMode); + + if(alpha != 255) + { + sceGuTexFunc(GU_TFX_MODULATE, GU_TCC_RGBA); + sceGuColor(GU_RGBA(255, 255, 255, alpha)); + }else{ + sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA); + sceGuColor(0xFFFFFFFF); + } + +// x += width * 0.5f; +// y += height * 0.5f; + x += centerx; + y += centery; + + float c, s; + + MathSincos(degToRad(angle), &s, &c); + +// width *= 0.5f; +// height *= 0.5f; + width -= centerx; + height -= centery; + + + float cw = c*width; + float sw = s*width; + float ch = c*height; + float sh = s*height; + + VertTV* vertices = (VertTV*)sceGuGetMemory(sizeof(VertTV)<<2); + + vertices[0].u = u0; + vertices[0].v = v0; + vertices[0].x = x - cw + sh; + vertices[0].y = y - sw - ch; + vertices[0].z = 0; + + vertices[1].u = u0; + vertices[1].v = v1; + vertices[1].x = x - cw - sh; + vertices[1].y = y - sw + ch; + vertices[1].z = 0; + + vertices[2].u = u1; + vertices[2].v = v1; + vertices[2].x = x + cw - sh; + vertices[2].y = y + sw + ch; + vertices[2].z = 0; + + vertices[3].u = u1; + vertices[3].v = v0; + vertices[3].x = x + cw + sh; + vertices[3].y = y + sw - ch; + vertices[3].z = 0; + + if (flip & SDL_FLIP_HORIZONTAL) { + Swap(&vertices[0].v, &vertices[2].v); + Swap(&vertices[1].v, &vertices[3].v); + } + if (flip & SDL_FLIP_VERTICAL) { + Swap(&vertices[0].u, &vertices[2].u); + Swap(&vertices[1].u, &vertices[3].u); + } + + sceGuDrawArray(GU_TRIANGLE_FAN, GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_2D, 4, 0, vertices); + + if(alpha != 255) + sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA); return 0; } @@ -961,39 +961,39 @@ static void PSP_RenderPresent(SDL_Renderer * renderer) { PSP_RenderData *data = (PSP_RenderData *) renderer->driverdata; - if(!data->displayListAvail) - return; - - data->displayListAvail = SDL_FALSE; - sceGuFinish(); - sceGuSync(0,0); - -// if(data->vsync) - sceDisplayWaitVblankStart(); - + if(!data->displayListAvail) + return; + + data->displayListAvail = SDL_FALSE; + sceGuFinish(); + sceGuSync(0,0); + +// if(data->vsync) + sceDisplayWaitVblankStart(); + data->backbuffer = data->frontbuffer; data->frontbuffer = vabsptr(sceGuSwapBuffers()); - + } static void PSP_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) { - PSP_RenderData *renderdata = (PSP_RenderData *) renderer->driverdata; - PSP_TextureData *psp_texture = (PSP_TextureData *) texture->driverdata; - - if (renderdata == 0) - return; - - if(psp_texture == 0) - return; - - if(psp_texture->data != 0) - { - SDL_free(psp_texture->data); - } - SDL_free(psp_texture); - texture->driverdata = NULL; + PSP_RenderData *renderdata = (PSP_RenderData *) renderer->driverdata; + PSP_TextureData *psp_texture = (PSP_TextureData *) texture->driverdata; + + if (renderdata == 0) + return; + + if(psp_texture == 0) + return; + + if(psp_texture->data != 0) + { + SDL_free(psp_texture->data); + } + SDL_free(psp_texture); + texture->driverdata = NULL; } static void @@ -1001,17 +1001,17 @@ PSP_DestroyRenderer(SDL_Renderer * renderer) { PSP_RenderData *data = (PSP_RenderData *) renderer->driverdata; if (data) { - if (!data->initialized) - return; - - StartDrawing(renderer); - - sceGuTerm(); -// vfree(data->backbuffer); -// vfree(data->frontbuffer); - - data->initialized = SDL_FALSE; - data->displayListAvail = SDL_FALSE; + if (!data->initialized) + return; + + StartDrawing(renderer); + + sceGuTerm(); +// vfree(data->backbuffer); +// vfree(data->frontbuffer); + + data->initialized = SDL_FALSE; + data->displayListAvail = SDL_FALSE; SDL_free(data); } SDL_free(renderer); diff --git a/src/render/software/SDL_drawline.c b/src/render/software/SDL_drawline.c index 9f5da0ab6..5cda4ccca 100644 --- a/src/render/software/SDL_drawline.c +++ b/src/render/software/SDL_drawline.c @@ -32,7 +32,6 @@ SDL_DrawLine1(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color, SDL_bool draw_end) { if (y1 == y2) { - //HLINE(Uint8, DRAW_FASTSETPIXEL1, draw_end); int length; int pitch = (dst->pitch / dst->format->BytesPerPixel); Uint8 *pixel; diff --git a/src/render/software/SDL_rotate.c b/src/render/software/SDL_rotate.c index 2eae0393f..b31553587 100644 --- a/src/render/software/SDL_rotate.c +++ b/src/render/software/SDL_rotate.c @@ -398,7 +398,7 @@ SDL_Surface *_rotateSurface(SDL_Surface * src, double angle, int centerx, int ce /* Determine target size */ - //_rotozoomSurfaceSizeTrig(rz_src->w, rz_src->h, angle, &dstwidth, &dstheight, &cangle, &sangle); + /*_rotozoomSurfaceSizeTrig(rz_src->w, rz_src->h, angle, &dstwidth, &dstheight, &cangle, &sangle); */ /* * Calculate target factors from sin/cos and zoom @@ -459,7 +459,7 @@ SDL_Surface *_rotateSurface(SDL_Surface * src, double angle, int centerx, int ce /* * Turn on source-alpha support */ - //SDL_SetAlpha(rz_dst, SDL_SRCALPHA, 255); + /*SDL_SetAlpha(rz_dst, SDL_SRCALPHA, 255);*/ SDL_SetColorKey(rz_dst, /*SDL_SRCCOLORKEY*/ SDL_TRUE | SDL_RLEACCEL, _colorkey(rz_src)); } else { /* diff --git a/src/stdlib/SDL_malloc.c b/src/stdlib/SDL_malloc.c index 65d1e1d16..5f7882139 100644 --- a/src/stdlib/SDL_malloc.c +++ b/src/stdlib/SDL_malloc.c @@ -409,9 +409,9 @@ MALLINFO_FIELD_TYPE default: size_t size_t. The value is used only if HAVE_USR_INCLUDE_MALLOC_H is not set REALLOC_ZERO_BYTES_FREES default: not defined - This should be set if a call to realloc with zero bytes should - be the same as a call to free. Some people think it should. Otherwise, - since this malloc returns a unique pointer for malloc(0), so does + This should be set if a call to realloc with zero bytes should + be the same as a call to free. Some people think it should. Otherwise, + since this malloc returns a unique pointer for malloc(0), so does realloc(p, 0). LACKS_UNISTD_H, LACKS_FCNTL_H, LACKS_SYS_PARAM_H, LACKS_SYS_MMAN_H @@ -619,12 +619,12 @@ DEFAULT_MMAP_THRESHOLD default: 256K #define MALLINFO_FIELD_TYPE size_t #endif /* MALLINFO_FIELD_TYPE */ -#define memset SDL_memset -#define memcpy SDL_memcpy -#define malloc SDL_malloc -#define calloc SDL_calloc -#define realloc SDL_realloc -#define free SDL_free +#define memset SDL_memset +#define memcpy SDL_memcpy +#define malloc SDL_malloc +#define calloc SDL_calloc +#define realloc SDL_realloc +#define free SDL_free /* mallopt tuning options. SVID/XPG defines four standard parameter @@ -5239,7 +5239,7 @@ mspace_mallopt(int param_number, int value) Trial version Fri Aug 28 13:14:29 1992 Doug Lea (dl at g.oswego.edu) * Based loosely on libg++-1.2X malloc. (It retains some of the overall structure of old version, but most details differ.) - + */ #endif /* !HAVE_MALLOC */ diff --git a/src/test/SDL_test_assert.c b/src/test/SDL_test_assert.c index 4896bc0e5..41a3df68f 100644 --- a/src/test/SDL_test_assert.c +++ b/src/test/SDL_test_assert.c @@ -21,7 +21,7 @@ /* - Used by the test framework and test cases. + Used by the test framework and test cases. */ @@ -47,16 +47,16 @@ static Uint32 SDLTest_AssertsPassed = 0; void SDLTest_Assert(int assertCondition, const char *assertDescription, ...) { va_list list; - char logMessage[SDLTEST_MAX_LOGMESSAGE_LENGTH]; - - // Print assert description into a buffer - SDL_memset(logMessage, 0, SDLTEST_MAX_LOGMESSAGE_LENGTH); - va_start(list, assertDescription); - SDL_vsnprintf(logMessage, SDLTEST_MAX_LOGMESSAGE_LENGTH - 1, assertDescription, list); - va_end(list); - - // Log, then assert and break on failure - SDL_assert((SDLTest_AssertCheck(assertCondition, logMessage))); + char logMessage[SDLTEST_MAX_LOGMESSAGE_LENGTH]; + + /* Print assert description into a buffer */ + SDL_memset(logMessage, 0, SDLTEST_MAX_LOGMESSAGE_LENGTH); + va_start(list, assertDescription); + SDL_vsnprintf(logMessage, SDLTEST_MAX_LOGMESSAGE_LENGTH - 1, assertDescription, list); + va_end(list); + + /* Log, then assert and break on failure */ + SDL_assert((SDLTest_AssertCheck(assertCondition, logMessage))); } /* @@ -65,27 +65,27 @@ void SDLTest_Assert(int assertCondition, const char *assertDescription, ...) int SDLTest_AssertCheck(int assertCondition, const char *assertDescription, ...) { va_list list; - char logMessage[SDLTEST_MAX_LOGMESSAGE_LENGTH]; - - // Print assert description into a buffer - SDL_memset(logMessage, 0, SDLTEST_MAX_LOGMESSAGE_LENGTH); - va_start(list, assertDescription); - SDL_vsnprintf(logMessage, SDLTEST_MAX_LOGMESSAGE_LENGTH - 1, assertDescription, list); - va_end(list); - - // Log pass or fail message - if (assertCondition == ASSERT_FAIL) - { - SDLTest_AssertsFailed++; - SDLTest_LogError(SDLTest_AssertCheckFormat, logMessage, "Failed"); - } - else - { - SDLTest_AssertsPassed++; - SDLTest_Log(SDLTest_AssertCheckFormat, logMessage, "Passed"); - } - - return assertCondition; + char logMessage[SDLTEST_MAX_LOGMESSAGE_LENGTH]; + + /* Print assert description into a buffer */ + SDL_memset(logMessage, 0, SDLTEST_MAX_LOGMESSAGE_LENGTH); + va_start(list, assertDescription); + SDL_vsnprintf(logMessage, SDLTEST_MAX_LOGMESSAGE_LENGTH - 1, assertDescription, list); + va_end(list); + + /* Log pass or fail message */ + if (assertCondition == ASSERT_FAIL) + { + SDLTest_AssertsFailed++; + SDLTest_LogError(SDLTest_AssertCheckFormat, logMessage, "Failed"); + } + else + { + SDLTest_AssertsPassed++; + SDLTest_Log(SDLTest_AssertCheckFormat, logMessage, "Passed"); + } + + return assertCondition; } /* @@ -94,17 +94,17 @@ int SDLTest_AssertCheck(int assertCondition, const char *assertDescription, ...) void SDLTest_AssertPass(const char *assertDescription, ...) { va_list list; - char logMessage[SDLTEST_MAX_LOGMESSAGE_LENGTH]; - - // Print assert description into a buffer - SDL_memset(logMessage, 0, SDLTEST_MAX_LOGMESSAGE_LENGTH); - va_start(list, assertDescription); - SDL_vsnprintf(logMessage, SDLTEST_MAX_LOGMESSAGE_LENGTH - 1, assertDescription, list); - va_end(list); - - // Log pass message - SDLTest_AssertsPassed++; - SDLTest_Log(SDLTest_AssertCheckFormat, logMessage, "Pass"); + char logMessage[SDLTEST_MAX_LOGMESSAGE_LENGTH]; + + /* Print assert description into a buffer */ + SDL_memset(logMessage, 0, SDLTEST_MAX_LOGMESSAGE_LENGTH); + va_start(list, assertDescription); + SDL_vsnprintf(logMessage, SDLTEST_MAX_LOGMESSAGE_LENGTH - 1, assertDescription, list); + va_end(list); + + /* Log pass message */ + SDLTest_AssertsPassed++; + SDLTest_Log(SDLTest_AssertCheckFormat, logMessage, "Pass"); } /* @@ -112,25 +112,25 @@ void SDLTest_AssertPass(const char *assertDescription, ...) */ void SDLTest_ResetAssertSummary() { - SDLTest_AssertsPassed = 0; - SDLTest_AssertsFailed = 0; + SDLTest_AssertsPassed = 0; + SDLTest_AssertsFailed = 0; } /* - * Logs summary of all assertions (total, pass, fail) since last reset + * Logs summary of all assertions (total, pass, fail) since last reset * as INFO (failed==0) or ERROR (failed > 0). */ void SDLTest_LogAssertSummary() { - Uint32 totalAsserts = SDLTest_AssertsPassed + SDLTest_AssertsFailed; - if (SDLTest_AssertsFailed == 0) - { - SDLTest_Log(SDLTest_AssertSummaryFormat, totalAsserts, SDLTest_AssertsPassed, SDLTest_AssertsFailed); - } - else - { - SDLTest_LogError(SDLTest_AssertSummaryFormat, totalAsserts, SDLTest_AssertsPassed, SDLTest_AssertsFailed); - } + Uint32 totalAsserts = SDLTest_AssertsPassed + SDLTest_AssertsFailed; + if (SDLTest_AssertsFailed == 0) + { + SDLTest_Log(SDLTest_AssertSummaryFormat, totalAsserts, SDLTest_AssertsPassed, SDLTest_AssertsFailed); + } + else + { + SDLTest_LogError(SDLTest_AssertSummaryFormat, totalAsserts, SDLTest_AssertsPassed, SDLTest_AssertsFailed); + } } /* @@ -138,13 +138,13 @@ void SDLTest_LogAssertSummary() */ int SDLTest_AssertSummaryToTestResult() { - if (SDLTest_AssertsFailed > 0) { - return TEST_RESULT_FAILED; - } else { - if (SDLTest_AssertsPassed > 0) { - return TEST_RESULT_PASSED; - } else { - return TEST_RESULT_NO_ASSERT; - } - } + if (SDLTest_AssertsFailed > 0) { + return TEST_RESULT_FAILED; + } else { + if (SDLTest_AssertsPassed > 0) { + return TEST_RESULT_PASSED; + } else { + return TEST_RESULT_NO_ASSERT; + } + } } diff --git a/src/test/SDL_test_common.c b/src/test/SDL_test_common.c index b5fdc3f5b..cd028c7bf 100644 --- a/src/test/SDL_test_common.c +++ b/src/test/SDL_test_common.c @@ -405,7 +405,7 @@ SDLTest_CommonArg(SDLTest_CommonState * state, int index) return -1; } if (SDL_strcmp(argv[index], "-NSDocumentRevisionsDebugMode") == 0) { - /* Debug flag sent by Xcode */ + /* Debug flag sent by Xcode */ return 2; } return 0; @@ -892,7 +892,7 @@ SDLTest_PrintEvent(SDL_Event * event) { if (event->type == SDL_MOUSEMOTION) { /* Mouse motion is really spammy */ - //return; + return; } fprintf(stderr, "SDL EVENT: "); @@ -1097,7 +1097,7 @@ SDLTest_ScreenShot(SDL_Renderer *renderer) } } -static void +static void FullscreenTo(int index, int windowId) { Uint32 flags; @@ -1151,12 +1151,12 @@ SDLTest_CommonEvent(SDLTest_CommonState * state, SDL_Event * event, int *done) } break; case SDL_WINDOWEVENT_CLOSE: - { + { SDL_Window *window = SDL_GetWindowFromID(event->window.windowID); if (window) { - SDL_DestroyWindow(window); - } - } + SDL_DestroyWindow(window); + } + } break; } break; @@ -1298,7 +1298,7 @@ SDLTest_CommonEvent(SDLTest_CommonState * state, SDL_Event * event, int *done) } } break; - case SDLK_0: + case SDLK_0: if (event->key.keysym.mod & KMOD_CTRL) { SDL_Window *window = SDL_GetWindowFromID(event->key.windowID); SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION, "Test Message", "You're awesome!", window); @@ -1335,7 +1335,7 @@ SDLTest_CommonEvent(SDLTest_CommonState * state, SDL_Event * event, int *done) break; case SDL_MOUSEMOTION: lastEvent = event->motion; - break; + break; } } diff --git a/src/test/SDL_test_compare.c b/src/test/SDL_test_compare.c index e7ac424d9..33f237311 100644 --- a/src/test/SDL_test_compare.c +++ b/src/test/SDL_test_compare.c @@ -22,7 +22,7 @@ /* Based on automated SDL_Surface tests originally written by Edgar Simo 'bobbens'. - + Rewritten for test lib by Andreas Schiffler. */ @@ -62,7 +62,7 @@ int SDLTest_CompareSurfaces(SDL_Surface *surface, SDL_Surface *referenceSurface, if (allowable_error<0) { allowable_error = 0; } - + SDL_LockSurface( surface ); SDL_LockSurface( referenceSurface ); @@ -82,7 +82,7 @@ int SDLTest_CompareSurfaces(SDL_Surface *surface, SDL_Surface *referenceSurface, dist += (R-Rd)*(R-Rd); dist += (G-Gd)*(G-Gd); dist += (B-Bd)*(B-Bd); - + /* Allow some difference in blending accuracy */ if (dist > allowable_error) { ret++; diff --git a/src/test/SDL_test_crc32.c b/src/test/SDL_test_crc32.c index 5329319e6..d6685c347 100644 --- a/src/test/SDL_test_crc32.c +++ b/src/test/SDL_test_crc32.c @@ -21,7 +21,7 @@ /* - Used by the test execution component. + Used by the test execution component. Original source code contributed by A. Schiffler for GSOC project. */ @@ -39,10 +39,10 @@ int SDLTest_Crc32Init(SDLTest_Crc32Context *crcContext) /* Sanity check context pointer */ if (crcContext==NULL) { return -1; - } - + } + /* - * Build auxiliary table for parallel byte-at-a-time CRC-32 + * Build auxiliary table for parallel byte-at-a-time CRC-32 */ #ifdef ORIGINAL_METHOD for (i = 0; i < 256; ++i) { @@ -64,7 +64,7 @@ int SDLTest_Crc32Init(SDLTest_Crc32Context *crcContext) crcContext->crc32_table[i] = c; } #endif - + return 0; } @@ -75,15 +75,15 @@ int SDLTest_Crc32Calc(SDLTest_Crc32Context * crcContext, CrcUint8 *inBuf, CrcUin if (SDLTest_Crc32CalcStart(crcContext,crc32)) { return -1; } - + if (SDLTest_Crc32CalcBuffer(crcContext, inBuf, inLen, crc32)) { return -1; } - + if (SDLTest_Crc32CalcEnd(crcContext, crc32)) { return -1; } - + return 0; } @@ -95,10 +95,10 @@ int SDLTest_Crc32CalcStart(SDLTest_Crc32Context * crcContext, CrcUint32 *crc32) if (crcContext==NULL) { *crc32=0; return -1; - } + } /* - * Preload shift register, per CRC-32 spec + * Preload shift register, per CRC-32 spec */ *crc32 = 0xffffffff; @@ -113,10 +113,10 @@ int SDLTest_Crc32CalcEnd(SDLTest_Crc32Context * crcContext, CrcUint32 *crc32) if (crcContext==NULL) { *crc32=0; return -1; - } - + } + /* - * Return complement, per CRC-32 spec + * Return complement, per CRC-32 spec */ *crc32 = (~(*crc32)); @@ -134,24 +134,24 @@ int SDLTest_Crc32CalcBuffer(SDLTest_Crc32Context * crcContext, CrcUint8 *inBuf, *crc32=0; return -1; } - + if (inBuf==NULL) { return -1; } /* - * Calculate CRC from data + * Calculate CRC from data */ crc = *crc32; for (p = inBuf; inLen > 0; ++p, --inLen) { -#ifdef ORIGINAL_METHOD +#ifdef ORIGINAL_METHOD crc = (crc << 8) ^ crcContext->crc32_table[(crc >> 24) ^ *p]; #else crc = ((crc >> 8) & 0x00FFFFFF) ^ crcContext->crc32_table[ (crc ^ *p) & 0xFF ]; -#endif - } +#endif + } *crc32 = crc; - + return 0; } @@ -159,7 +159,7 @@ int SDLTest_Crc32Done(SDLTest_Crc32Context * crcContext) { if (crcContext==NULL) { return -1; - } + } return 0; } diff --git a/src/test/SDL_test_font.c b/src/test/SDL_test_font.c index dcb3f0464..144bcad02 100644 --- a/src/test/SDL_test_font.c +++ b/src/test/SDL_test_font.c @@ -32,3077 +32,3077 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { - /* - * 0 0x00 '^@' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 1 0x01 '^A' - */ - 0x7e, /* 01111110 */ - 0x81, /* 10000001 */ - 0xa5, /* 10100101 */ - 0x81, /* 10000001 */ - 0xbd, /* 10111101 */ - 0x99, /* 10011001 */ - 0x81, /* 10000001 */ - 0x7e, /* 01111110 */ - - /* - * 2 0x02 '^B' - */ - 0x7e, /* 01111110 */ - 0xff, /* 11111111 */ - 0xdb, /* 11011011 */ - 0xff, /* 11111111 */ - 0xc3, /* 11000011 */ - 0xe7, /* 11100111 */ - 0xff, /* 11111111 */ - 0x7e, /* 01111110 */ - - /* - * 3 0x03 '^C' - */ - 0x6c, /* 01101100 */ - 0xfe, /* 11111110 */ - 0xfe, /* 11111110 */ - 0xfe, /* 11111110 */ - 0x7c, /* 01111100 */ - 0x38, /* 00111000 */ - 0x10, /* 00010000 */ - 0x00, /* 00000000 */ - - /* - * 4 0x04 '^D' - */ - 0x10, /* 00010000 */ - 0x38, /* 00111000 */ - 0x7c, /* 01111100 */ - 0xfe, /* 11111110 */ - 0x7c, /* 01111100 */ - 0x38, /* 00111000 */ - 0x10, /* 00010000 */ - 0x00, /* 00000000 */ - - /* - * 5 0x05 '^E' - */ - 0x38, /* 00111000 */ - 0x7c, /* 01111100 */ - 0x38, /* 00111000 */ - 0xfe, /* 11111110 */ - 0xfe, /* 11111110 */ - 0xd6, /* 11010110 */ - 0x10, /* 00010000 */ - 0x38, /* 00111000 */ - - /* - * 6 0x06 '^F' - */ - 0x10, /* 00010000 */ - 0x38, /* 00111000 */ - 0x7c, /* 01111100 */ - 0xfe, /* 11111110 */ - 0xfe, /* 11111110 */ - 0x7c, /* 01111100 */ - 0x10, /* 00010000 */ - 0x38, /* 00111000 */ - - /* - * 7 0x07 '^G' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x18, /* 00011000 */ - 0x3c, /* 00111100 */ - 0x3c, /* 00111100 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 8 0x08 '^H' - */ - 0xff, /* 11111111 */ - 0xff, /* 11111111 */ - 0xe7, /* 11100111 */ - 0xc3, /* 11000011 */ - 0xc3, /* 11000011 */ - 0xe7, /* 11100111 */ - 0xff, /* 11111111 */ - 0xff, /* 11111111 */ - - /* - * 9 0x09 '^I' - */ - 0x00, /* 00000000 */ - 0x3c, /* 00111100 */ - 0x66, /* 01100110 */ - 0x42, /* 01000010 */ - 0x42, /* 01000010 */ - 0x66, /* 01100110 */ - 0x3c, /* 00111100 */ - 0x00, /* 00000000 */ - - /* - * 10 0x0a '^J' - */ - 0xff, /* 11111111 */ - 0xc3, /* 11000011 */ - 0x99, /* 10011001 */ - 0xbd, /* 10111101 */ - 0xbd, /* 10111101 */ - 0x99, /* 10011001 */ - 0xc3, /* 11000011 */ - 0xff, /* 11111111 */ - - /* - * 11 0x0b '^K' - */ - 0x0f, /* 00001111 */ - 0x07, /* 00000111 */ - 0x0f, /* 00001111 */ - 0x7d, /* 01111101 */ - 0xcc, /* 11001100 */ - 0xcc, /* 11001100 */ - 0xcc, /* 11001100 */ - 0x78, /* 01111000 */ - - /* - * 12 0x0c '^L' - */ - 0x3c, /* 00111100 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x3c, /* 00111100 */ - 0x18, /* 00011000 */ - 0x7e, /* 01111110 */ - 0x18, /* 00011000 */ - - /* - * 13 0x0d '^M' - */ - 0x3f, /* 00111111 */ - 0x33, /* 00110011 */ - 0x3f, /* 00111111 */ - 0x30, /* 00110000 */ - 0x30, /* 00110000 */ - 0x70, /* 01110000 */ - 0xf0, /* 11110000 */ - 0xe0, /* 11100000 */ - - /* - * 14 0x0e '^N' - */ - 0x7f, /* 01111111 */ - 0x63, /* 01100011 */ - 0x7f, /* 01111111 */ - 0x63, /* 01100011 */ - 0x63, /* 01100011 */ - 0x67, /* 01100111 */ - 0xe6, /* 11100110 */ - 0xc0, /* 11000000 */ - - /* - * 15 0x0f '^O' - */ - 0x18, /* 00011000 */ - 0xdb, /* 11011011 */ - 0x3c, /* 00111100 */ - 0xe7, /* 11100111 */ - 0xe7, /* 11100111 */ - 0x3c, /* 00111100 */ - 0xdb, /* 11011011 */ - 0x18, /* 00011000 */ - - /* - * 16 0x10 '^P' - */ - 0x80, /* 10000000 */ - 0xe0, /* 11100000 */ - 0xf8, /* 11111000 */ - 0xfe, /* 11111110 */ - 0xf8, /* 11111000 */ - 0xe0, /* 11100000 */ - 0x80, /* 10000000 */ - 0x00, /* 00000000 */ - - /* - * 17 0x11 '^Q' - */ - 0x02, /* 00000010 */ - 0x0e, /* 00001110 */ - 0x3e, /* 00111110 */ - 0xfe, /* 11111110 */ - 0x3e, /* 00111110 */ - 0x0e, /* 00001110 */ - 0x02, /* 00000010 */ - 0x00, /* 00000000 */ - - /* - * 18 0x12 '^R' - */ - 0x18, /* 00011000 */ - 0x3c, /* 00111100 */ - 0x7e, /* 01111110 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x7e, /* 01111110 */ - 0x3c, /* 00111100 */ - 0x18, /* 00011000 */ - - /* - * 19 0x13 '^S' - */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x00, /* 00000000 */ - 0x66, /* 01100110 */ - 0x00, /* 00000000 */ - - /* - * 20 0x14 '^T' - */ - 0x7f, /* 01111111 */ - 0xdb, /* 11011011 */ - 0xdb, /* 11011011 */ - 0x7b, /* 01111011 */ - 0x1b, /* 00011011 */ - 0x1b, /* 00011011 */ - 0x1b, /* 00011011 */ - 0x00, /* 00000000 */ - - /* - * 21 0x15 '^U' - */ - 0x3e, /* 00111110 */ - 0x61, /* 01100001 */ - 0x3c, /* 00111100 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x3c, /* 00111100 */ - 0x86, /* 10000110 */ - 0x7c, /* 01111100 */ - - /* - * 22 0x16 '^V' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x7e, /* 01111110 */ - 0x7e, /* 01111110 */ - 0x7e, /* 01111110 */ - 0x00, /* 00000000 */ - - /* - * 23 0x17 '^W' - */ - 0x18, /* 00011000 */ - 0x3c, /* 00111100 */ - 0x7e, /* 01111110 */ - 0x18, /* 00011000 */ - 0x7e, /* 01111110 */ - 0x3c, /* 00111100 */ - 0x18, /* 00011000 */ - 0xff, /* 11111111 */ - - /* - * 24 0x18 '^X' - */ - 0x18, /* 00011000 */ - 0x3c, /* 00111100 */ - 0x7e, /* 01111110 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - - /* - * 25 0x19 '^Y' - */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x7e, /* 01111110 */ - 0x3c, /* 00111100 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - - /* - * 26 0x1a '^Z' - */ - 0x00, /* 00000000 */ - 0x18, /* 00011000 */ - 0x0c, /* 00001100 */ - 0xfe, /* 11111110 */ - 0x0c, /* 00001100 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 27 0x1b '^[' - */ - 0x00, /* 00000000 */ - 0x30, /* 00110000 */ - 0x60, /* 01100000 */ - 0xfe, /* 11111110 */ - 0x60, /* 01100000 */ - 0x30, /* 00110000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 28 0x1c '^\' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xc0, /* 11000000 */ - 0xc0, /* 11000000 */ - 0xc0, /* 11000000 */ - 0xfe, /* 11111110 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 29 0x1d '^]' - */ - 0x00, /* 00000000 */ - 0x24, /* 00100100 */ - 0x66, /* 01100110 */ - 0xff, /* 11111111 */ - 0x66, /* 01100110 */ - 0x24, /* 00100100 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 30 0x1e '^^' - */ - 0x00, /* 00000000 */ - 0x18, /* 00011000 */ - 0x3c, /* 00111100 */ - 0x7e, /* 01111110 */ - 0xff, /* 11111111 */ - 0xff, /* 11111111 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 31 0x1f '^_' - */ - 0x00, /* 00000000 */ - 0xff, /* 11111111 */ - 0xff, /* 11111111 */ - 0x7e, /* 01111110 */ - 0x3c, /* 00111100 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 32 0x20 ' ' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 33 0x21 '!' - */ - 0x18, /* 00011000 */ - 0x3c, /* 00111100 */ - 0x3c, /* 00111100 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - - /* - * 34 0x22 '"' - */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x24, /* 00100100 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 35 0x23 '#' - */ - 0x6c, /* 01101100 */ - 0x6c, /* 01101100 */ - 0xfe, /* 11111110 */ - 0x6c, /* 01101100 */ - 0xfe, /* 11111110 */ - 0x6c, /* 01101100 */ - 0x6c, /* 01101100 */ - 0x00, /* 00000000 */ - - /* - * 36 0x24 '$' - */ - 0x18, /* 00011000 */ - 0x3e, /* 00111110 */ - 0x60, /* 01100000 */ - 0x3c, /* 00111100 */ - 0x06, /* 00000110 */ - 0x7c, /* 01111100 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - - /* - * 37 0x25 '%' - */ - 0x00, /* 00000000 */ - 0xc6, /* 11000110 */ - 0xcc, /* 11001100 */ - 0x18, /* 00011000 */ - 0x30, /* 00110000 */ - 0x66, /* 01100110 */ - 0xc6, /* 11000110 */ - 0x00, /* 00000000 */ - - /* - * 38 0x26 '&' - */ - 0x38, /* 00111000 */ - 0x6c, /* 01101100 */ - 0x38, /* 00111000 */ - 0x76, /* 01110110 */ - 0xdc, /* 11011100 */ - 0xcc, /* 11001100 */ - 0x76, /* 01110110 */ - 0x00, /* 00000000 */ - - /* - * 39 0x27 ''' - */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x30, /* 00110000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 40 0x28 '(' - */ - 0x0c, /* 00001100 */ - 0x18, /* 00011000 */ - 0x30, /* 00110000 */ - 0x30, /* 00110000 */ - 0x30, /* 00110000 */ - 0x18, /* 00011000 */ - 0x0c, /* 00001100 */ - 0x00, /* 00000000 */ - - /* - * 41 0x29 ')' - */ - 0x30, /* 00110000 */ - 0x18, /* 00011000 */ - 0x0c, /* 00001100 */ - 0x0c, /* 00001100 */ - 0x0c, /* 00001100 */ - 0x18, /* 00011000 */ - 0x30, /* 00110000 */ - 0x00, /* 00000000 */ - - /* - * 42 0x2a '*' - */ - 0x00, /* 00000000 */ - 0x66, /* 01100110 */ - 0x3c, /* 00111100 */ - 0xff, /* 11111111 */ - 0x3c, /* 00111100 */ - 0x66, /* 01100110 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 43 0x2b '+' - */ - 0x00, /* 00000000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x7e, /* 01111110 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 44 0x2c ',' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x30, /* 00110000 */ - - /* - * 45 0x2d '-' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x7e, /* 01111110 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 46 0x2e '.' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - - /* - * 47 0x2f '/' - */ - 0x06, /* 00000110 */ - 0x0c, /* 00001100 */ - 0x18, /* 00011000 */ - 0x30, /* 00110000 */ - 0x60, /* 01100000 */ - 0xc0, /* 11000000 */ - 0x80, /* 10000000 */ - 0x00, /* 00000000 */ - - /* - * 48 0x30 '0' - */ - 0x38, /* 00111000 */ - 0x6c, /* 01101100 */ - 0xc6, /* 11000110 */ - 0xd6, /* 11010110 */ - 0xc6, /* 11000110 */ - 0x6c, /* 01101100 */ - 0x38, /* 00111000 */ - 0x00, /* 00000000 */ - - /* - * 49 0x31 '1' - */ - 0x18, /* 00011000 */ - 0x38, /* 00111000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x7e, /* 01111110 */ - 0x00, /* 00000000 */ - - /* - * 50 0x32 '2' - */ - 0x7c, /* 01111100 */ - 0xc6, /* 11000110 */ - 0x06, /* 00000110 */ - 0x1c, /* 00011100 */ - 0x30, /* 00110000 */ - 0x66, /* 01100110 */ - 0xfe, /* 11111110 */ - 0x00, /* 00000000 */ - - /* - * 51 0x33 '3' - */ - 0x7c, /* 01111100 */ - 0xc6, /* 11000110 */ - 0x06, /* 00000110 */ - 0x3c, /* 00111100 */ - 0x06, /* 00000110 */ - 0xc6, /* 11000110 */ - 0x7c, /* 01111100 */ - 0x00, /* 00000000 */ - - /* - * 52 0x34 '4' - */ - 0x1c, /* 00011100 */ - 0x3c, /* 00111100 */ - 0x6c, /* 01101100 */ - 0xcc, /* 11001100 */ - 0xfe, /* 11111110 */ - 0x0c, /* 00001100 */ - 0x1e, /* 00011110 */ - 0x00, /* 00000000 */ - - /* - * 53 0x35 '5' - */ - 0xfe, /* 11111110 */ - 0xc0, /* 11000000 */ - 0xc0, /* 11000000 */ - 0xfc, /* 11111100 */ - 0x06, /* 00000110 */ - 0xc6, /* 11000110 */ - 0x7c, /* 01111100 */ - 0x00, /* 00000000 */ - - /* - * 54 0x36 '6' - */ - 0x38, /* 00111000 */ - 0x60, /* 01100000 */ - 0xc0, /* 11000000 */ - 0xfc, /* 11111100 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x7c, /* 01111100 */ - 0x00, /* 00000000 */ - - /* - * 55 0x37 '7' - */ - 0xfe, /* 11111110 */ - 0xc6, /* 11000110 */ - 0x0c, /* 00001100 */ - 0x18, /* 00011000 */ - 0x30, /* 00110000 */ - 0x30, /* 00110000 */ - 0x30, /* 00110000 */ - 0x00, /* 00000000 */ - - /* - * 56 0x38 '8' - */ - 0x7c, /* 01111100 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x7c, /* 01111100 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x7c, /* 01111100 */ - 0x00, /* 00000000 */ - - /* - * 57 0x39 '9' - */ - 0x7c, /* 01111100 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x7e, /* 01111110 */ - 0x06, /* 00000110 */ - 0x0c, /* 00001100 */ - 0x78, /* 01111000 */ - 0x00, /* 00000000 */ - - /* - * 58 0x3a ':' - */ - 0x00, /* 00000000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - - /* - * 59 0x3b ';' - */ - 0x00, /* 00000000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x30, /* 00110000 */ - - /* - * 60 0x3c '<' - */ - 0x06, /* 00000110 */ - 0x0c, /* 00001100 */ - 0x18, /* 00011000 */ - 0x30, /* 00110000 */ - 0x18, /* 00011000 */ - 0x0c, /* 00001100 */ - 0x06, /* 00000110 */ - 0x00, /* 00000000 */ - - /* - * 61 0x3d '=' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x7e, /* 01111110 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x7e, /* 01111110 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 62 0x3e '>' - */ - 0x60, /* 01100000 */ - 0x30, /* 00110000 */ - 0x18, /* 00011000 */ - 0x0c, /* 00001100 */ - 0x18, /* 00011000 */ - 0x30, /* 00110000 */ - 0x60, /* 01100000 */ - 0x00, /* 00000000 */ - - /* - * 63 0x3f '?' - */ - 0x7c, /* 01111100 */ - 0xc6, /* 11000110 */ - 0x0c, /* 00001100 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - - /* - * 64 0x40 '@' - */ - 0x7c, /* 01111100 */ - 0xc6, /* 11000110 */ - 0xde, /* 11011110 */ - 0xde, /* 11011110 */ - 0xde, /* 11011110 */ - 0xc0, /* 11000000 */ - 0x78, /* 01111000 */ - 0x00, /* 00000000 */ - - /* - * 65 0x41 'A' - */ - 0x38, /* 00111000 */ - 0x6c, /* 01101100 */ - 0xc6, /* 11000110 */ - 0xfe, /* 11111110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x00, /* 00000000 */ - - /* - * 66 0x42 'B' - */ - 0xfc, /* 11111100 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x7c, /* 01111100 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0xfc, /* 11111100 */ - 0x00, /* 00000000 */ - - /* - * 67 0x43 'C' - */ - 0x3c, /* 00111100 */ - 0x66, /* 01100110 */ - 0xc0, /* 11000000 */ - 0xc0, /* 11000000 */ - 0xc0, /* 11000000 */ - 0x66, /* 01100110 */ - 0x3c, /* 00111100 */ - 0x00, /* 00000000 */ - - /* - * 68 0x44 'D' - */ - 0xf8, /* 11111000 */ - 0x6c, /* 01101100 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x6c, /* 01101100 */ - 0xf8, /* 11111000 */ - 0x00, /* 00000000 */ - - /* - * 69 0x45 'E' - */ - 0xfe, /* 11111110 */ - 0x62, /* 01100010 */ - 0x68, /* 01101000 */ - 0x78, /* 01111000 */ - 0x68, /* 01101000 */ - 0x62, /* 01100010 */ - 0xfe, /* 11111110 */ - 0x00, /* 00000000 */ - - /* - * 70 0x46 'F' - */ - 0xfe, /* 11111110 */ - 0x62, /* 01100010 */ - 0x68, /* 01101000 */ - 0x78, /* 01111000 */ - 0x68, /* 01101000 */ - 0x60, /* 01100000 */ - 0xf0, /* 11110000 */ - 0x00, /* 00000000 */ - - /* - * 71 0x47 'G' - */ - 0x3c, /* 00111100 */ - 0x66, /* 01100110 */ - 0xc0, /* 11000000 */ - 0xc0, /* 11000000 */ - 0xce, /* 11001110 */ - 0x66, /* 01100110 */ - 0x3a, /* 00111010 */ - 0x00, /* 00000000 */ - - /* - * 72 0x48 'H' - */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xfe, /* 11111110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x00, /* 00000000 */ - - /* - * 73 0x49 'I' - */ - 0x3c, /* 00111100 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x3c, /* 00111100 */ - 0x00, /* 00000000 */ - - /* - * 74 0x4a 'J' - */ - 0x1e, /* 00011110 */ - 0x0c, /* 00001100 */ - 0x0c, /* 00001100 */ - 0x0c, /* 00001100 */ - 0xcc, /* 11001100 */ - 0xcc, /* 11001100 */ - 0x78, /* 01111000 */ - 0x00, /* 00000000 */ - - /* - * 75 0x4b 'K' - */ - 0xe6, /* 11100110 */ - 0x66, /* 01100110 */ - 0x6c, /* 01101100 */ - 0x78, /* 01111000 */ - 0x6c, /* 01101100 */ - 0x66, /* 01100110 */ - 0xe6, /* 11100110 */ - 0x00, /* 00000000 */ - - /* - * 76 0x4c 'L' - */ - 0xf0, /* 11110000 */ - 0x60, /* 01100000 */ - 0x60, /* 01100000 */ - 0x60, /* 01100000 */ - 0x62, /* 01100010 */ - 0x66, /* 01100110 */ - 0xfe, /* 11111110 */ - 0x00, /* 00000000 */ - - /* - * 77 0x4d 'M' - */ - 0xc6, /* 11000110 */ - 0xee, /* 11101110 */ - 0xfe, /* 11111110 */ - 0xfe, /* 11111110 */ - 0xd6, /* 11010110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x00, /* 00000000 */ - - /* - * 78 0x4e 'N' - */ - 0xc6, /* 11000110 */ - 0xe6, /* 11100110 */ - 0xf6, /* 11110110 */ - 0xde, /* 11011110 */ - 0xce, /* 11001110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x00, /* 00000000 */ - - /* - * 79 0x4f 'O' - */ - 0x7c, /* 01111100 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x7c, /* 01111100 */ - 0x00, /* 00000000 */ - - /* - * 80 0x50 'P' - */ - 0xfc, /* 11111100 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x7c, /* 01111100 */ - 0x60, /* 01100000 */ - 0x60, /* 01100000 */ - 0xf0, /* 11110000 */ - 0x00, /* 00000000 */ - - /* - * 81 0x51 'Q' - */ - 0x7c, /* 01111100 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xce, /* 11001110 */ - 0x7c, /* 01111100 */ - 0x0e, /* 00001110 */ - - /* - * 82 0x52 'R' - */ - 0xfc, /* 11111100 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x7c, /* 01111100 */ - 0x6c, /* 01101100 */ - 0x66, /* 01100110 */ - 0xe6, /* 11100110 */ - 0x00, /* 00000000 */ - - /* - * 83 0x53 'S' - */ - 0x3c, /* 00111100 */ - 0x66, /* 01100110 */ - 0x30, /* 00110000 */ - 0x18, /* 00011000 */ - 0x0c, /* 00001100 */ - 0x66, /* 01100110 */ - 0x3c, /* 00111100 */ - 0x00, /* 00000000 */ - - /* - * 84 0x54 'T' - */ - 0x7e, /* 01111110 */ - 0x7e, /* 01111110 */ - 0x5a, /* 01011010 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x3c, /* 00111100 */ - 0x00, /* 00000000 */ - - /* - * 85 0x55 'U' - */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x7c, /* 01111100 */ - 0x00, /* 00000000 */ - - /* - * 86 0x56 'V' - */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x6c, /* 01101100 */ - 0x38, /* 00111000 */ - 0x00, /* 00000000 */ - - /* - * 87 0x57 'W' - */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xd6, /* 11010110 */ - 0xd6, /* 11010110 */ - 0xfe, /* 11111110 */ - 0x6c, /* 01101100 */ - 0x00, /* 00000000 */ - - /* - * 88 0x58 'X' - */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x6c, /* 01101100 */ - 0x38, /* 00111000 */ - 0x6c, /* 01101100 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x00, /* 00000000 */ - - /* - * 89 0x59 'Y' - */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x3c, /* 00111100 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x3c, /* 00111100 */ - 0x00, /* 00000000 */ - - /* - * 90 0x5a 'Z' - */ - 0xfe, /* 11111110 */ - 0xc6, /* 11000110 */ - 0x8c, /* 10001100 */ - 0x18, /* 00011000 */ - 0x32, /* 00110010 */ - 0x66, /* 01100110 */ - 0xfe, /* 11111110 */ - 0x00, /* 00000000 */ - - /* - * 91 0x5b '[' - */ - 0x3c, /* 00111100 */ - 0x30, /* 00110000 */ - 0x30, /* 00110000 */ - 0x30, /* 00110000 */ - 0x30, /* 00110000 */ - 0x30, /* 00110000 */ - 0x3c, /* 00111100 */ - 0x00, /* 00000000 */ - - /* - * 92 0x5c '\' - */ - 0xc0, /* 11000000 */ - 0x60, /* 01100000 */ - 0x30, /* 00110000 */ - 0x18, /* 00011000 */ - 0x0c, /* 00001100 */ - 0x06, /* 00000110 */ - 0x02, /* 00000010 */ - 0x00, /* 00000000 */ - - /* - * 93 0x5d ']' - */ - 0x3c, /* 00111100 */ - 0x0c, /* 00001100 */ - 0x0c, /* 00001100 */ - 0x0c, /* 00001100 */ - 0x0c, /* 00001100 */ - 0x0c, /* 00001100 */ - 0x3c, /* 00111100 */ - 0x00, /* 00000000 */ - - /* - * 94 0x5e '^' - */ - 0x10, /* 00010000 */ - 0x38, /* 00111000 */ - 0x6c, /* 01101100 */ - 0xc6, /* 11000110 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 95 0x5f '_' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xff, /* 11111111 */ - - /* - * 96 0x60 '`' - */ - 0x30, /* 00110000 */ - 0x18, /* 00011000 */ - 0x0c, /* 00001100 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 97 0x61 'a' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x78, /* 01111000 */ - 0x0c, /* 00001100 */ - 0x7c, /* 01111100 */ - 0xcc, /* 11001100 */ - 0x76, /* 01110110 */ - 0x00, /* 00000000 */ - - /* - * 98 0x62 'b' - */ - 0xe0, /* 11100000 */ - 0x60, /* 01100000 */ - 0x7c, /* 01111100 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0xdc, /* 11011100 */ - 0x00, /* 00000000 */ - - /* - * 99 0x63 'c' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x7c, /* 01111100 */ - 0xc6, /* 11000110 */ - 0xc0, /* 11000000 */ - 0xc6, /* 11000110 */ - 0x7c, /* 01111100 */ - 0x00, /* 00000000 */ - - /* - * 100 0x64 'd' - */ - 0x1c, /* 00011100 */ - 0x0c, /* 00001100 */ - 0x7c, /* 01111100 */ - 0xcc, /* 11001100 */ - 0xcc, /* 11001100 */ - 0xcc, /* 11001100 */ - 0x76, /* 01110110 */ - 0x00, /* 00000000 */ - - /* - * 101 0x65 'e' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x7c, /* 01111100 */ - 0xc6, /* 11000110 */ - 0xfe, /* 11111110 */ - 0xc0, /* 11000000 */ - 0x7c, /* 01111100 */ - 0x00, /* 00000000 */ - - /* - * 102 0x66 'f' - */ - 0x3c, /* 00111100 */ - 0x66, /* 01100110 */ - 0x60, /* 01100000 */ - 0xf8, /* 11111000 */ - 0x60, /* 01100000 */ - 0x60, /* 01100000 */ - 0xf0, /* 11110000 */ - 0x00, /* 00000000 */ - - /* - * 103 0x67 'g' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x76, /* 01110110 */ - 0xcc, /* 11001100 */ - 0xcc, /* 11001100 */ - 0x7c, /* 01111100 */ - 0x0c, /* 00001100 */ - 0xf8, /* 11111000 */ - - /* - * 104 0x68 'h' - */ - 0xe0, /* 11100000 */ - 0x60, /* 01100000 */ - 0x6c, /* 01101100 */ - 0x76, /* 01110110 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0xe6, /* 11100110 */ - 0x00, /* 00000000 */ - - /* - * 105 0x69 'i' - */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - 0x38, /* 00111000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x3c, /* 00111100 */ - 0x00, /* 00000000 */ - - /* - * 106 0x6a 'j' - */ - 0x06, /* 00000110 */ - 0x00, /* 00000000 */ - 0x06, /* 00000110 */ - 0x06, /* 00000110 */ - 0x06, /* 00000110 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x3c, /* 00111100 */ - - /* - * 107 0x6b 'k' - */ - 0xe0, /* 11100000 */ - 0x60, /* 01100000 */ - 0x66, /* 01100110 */ - 0x6c, /* 01101100 */ - 0x78, /* 01111000 */ - 0x6c, /* 01101100 */ - 0xe6, /* 11100110 */ - 0x00, /* 00000000 */ - - /* - * 108 0x6c 'l' - */ - 0x38, /* 00111000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x3c, /* 00111100 */ - 0x00, /* 00000000 */ - - /* - * 109 0x6d 'm' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xec, /* 11101100 */ - 0xfe, /* 11111110 */ - 0xd6, /* 11010110 */ - 0xd6, /* 11010110 */ - 0xd6, /* 11010110 */ - 0x00, /* 00000000 */ - - /* - * 110 0x6e 'n' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xdc, /* 11011100 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x00, /* 00000000 */ - - /* - * 111 0x6f 'o' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x7c, /* 01111100 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x7c, /* 01111100 */ - 0x00, /* 00000000 */ - - /* - * 112 0x70 'p' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xdc, /* 11011100 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x7c, /* 01111100 */ - 0x60, /* 01100000 */ - 0xf0, /* 11110000 */ - - /* - * 113 0x71 'q' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x76, /* 01110110 */ - 0xcc, /* 11001100 */ - 0xcc, /* 11001100 */ - 0x7c, /* 01111100 */ - 0x0c, /* 00001100 */ - 0x1e, /* 00011110 */ - - /* - * 114 0x72 'r' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xdc, /* 11011100 */ - 0x76, /* 01110110 */ - 0x60, /* 01100000 */ - 0x60, /* 01100000 */ - 0xf0, /* 11110000 */ - 0x00, /* 00000000 */ - - /* - * 115 0x73 's' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x7e, /* 01111110 */ - 0xc0, /* 11000000 */ - 0x7c, /* 01111100 */ - 0x06, /* 00000110 */ - 0xfc, /* 11111100 */ - 0x00, /* 00000000 */ - - /* - * 116 0x74 't' - */ - 0x30, /* 00110000 */ - 0x30, /* 00110000 */ - 0xfc, /* 11111100 */ - 0x30, /* 00110000 */ - 0x30, /* 00110000 */ - 0x36, /* 00110110 */ - 0x1c, /* 00011100 */ - 0x00, /* 00000000 */ - - /* - * 117 0x75 'u' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xcc, /* 11001100 */ - 0xcc, /* 11001100 */ - 0xcc, /* 11001100 */ - 0xcc, /* 11001100 */ - 0x76, /* 01110110 */ - 0x00, /* 00000000 */ - - /* - * 118 0x76 'v' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x6c, /* 01101100 */ - 0x38, /* 00111000 */ - 0x00, /* 00000000 */ - - /* - * 119 0x77 'w' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xc6, /* 11000110 */ - 0xd6, /* 11010110 */ - 0xd6, /* 11010110 */ - 0xfe, /* 11111110 */ - 0x6c, /* 01101100 */ - 0x00, /* 00000000 */ - - /* - * 120 0x78 'x' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xc6, /* 11000110 */ - 0x6c, /* 01101100 */ - 0x38, /* 00111000 */ - 0x6c, /* 01101100 */ - 0xc6, /* 11000110 */ - 0x00, /* 00000000 */ - - /* - * 121 0x79 'y' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x7e, /* 01111110 */ - 0x06, /* 00000110 */ - 0xfc, /* 11111100 */ - - /* - * 122 0x7a 'z' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x7e, /* 01111110 */ - 0x4c, /* 01001100 */ - 0x18, /* 00011000 */ - 0x32, /* 00110010 */ - 0x7e, /* 01111110 */ - 0x00, /* 00000000 */ - - /* - * 123 0x7b '{' - */ - 0x0e, /* 00001110 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x70, /* 01110000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x0e, /* 00001110 */ - 0x00, /* 00000000 */ - - /* - * 124 0x7c '|' - */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - - /* - * 125 0x7d '}' - */ - 0x70, /* 01110000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x0e, /* 00001110 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x70, /* 01110000 */ - 0x00, /* 00000000 */ - - /* - * 126 0x7e '~' - */ - 0x76, /* 01110110 */ - 0xdc, /* 11011100 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 127 0x7f '' - */ - 0x00, /* 00000000 */ - 0x10, /* 00010000 */ - 0x38, /* 00111000 */ - 0x6c, /* 01101100 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xfe, /* 11111110 */ - 0x00, /* 00000000 */ - - /* - * 128 0x80 '€' - */ - 0x7c, /* 01111100 */ - 0xc6, /* 11000110 */ - 0xc0, /* 11000000 */ - 0xc0, /* 11000000 */ - 0xc6, /* 11000110 */ - 0x7c, /* 01111100 */ - 0x0c, /* 00001100 */ - 0x78, /* 01111000 */ - - /* - * 129 0x81 '' - */ - 0xcc, /* 11001100 */ - 0x00, /* 00000000 */ - 0xcc, /* 11001100 */ - 0xcc, /* 11001100 */ - 0xcc, /* 11001100 */ - 0xcc, /* 11001100 */ - 0x76, /* 01110110 */ - 0x00, /* 00000000 */ - - /* - * 130 0x82 '‚' - */ - 0x0c, /* 00001100 */ - 0x18, /* 00011000 */ - 0x7c, /* 01111100 */ - 0xc6, /* 11000110 */ - 0xfe, /* 11111110 */ - 0xc0, /* 11000000 */ - 0x7c, /* 01111100 */ - 0x00, /* 00000000 */ - - /* - * 131 0x83 'ƒ' - */ - 0x7c, /* 01111100 */ - 0x82, /* 10000010 */ - 0x78, /* 01111000 */ - 0x0c, /* 00001100 */ - 0x7c, /* 01111100 */ - 0xcc, /* 11001100 */ - 0x76, /* 01110110 */ - 0x00, /* 00000000 */ - - /* - * 132 0x84 '„' - */ - 0xc6, /* 11000110 */ - 0x00, /* 00000000 */ - 0x78, /* 01111000 */ - 0x0c, /* 00001100 */ - 0x7c, /* 01111100 */ - 0xcc, /* 11001100 */ - 0x76, /* 01110110 */ - 0x00, /* 00000000 */ - - /* - * 133 0x85 '…' - */ - 0x30, /* 00110000 */ - 0x18, /* 00011000 */ - 0x78, /* 01111000 */ - 0x0c, /* 00001100 */ - 0x7c, /* 01111100 */ - 0xcc, /* 11001100 */ - 0x76, /* 01110110 */ - 0x00, /* 00000000 */ - - /* - * 134 0x86 '†' - */ - 0x30, /* 00110000 */ - 0x30, /* 00110000 */ - 0x78, /* 01111000 */ - 0x0c, /* 00001100 */ - 0x7c, /* 01111100 */ - 0xcc, /* 11001100 */ - 0x76, /* 01110110 */ - 0x00, /* 00000000 */ - - /* - * 135 0x87 '‡' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x7e, /* 01111110 */ - 0xc0, /* 11000000 */ - 0xc0, /* 11000000 */ - 0x7e, /* 01111110 */ - 0x0c, /* 00001100 */ - 0x38, /* 00111000 */ - - /* - * 136 0x88 'ˆ' - */ - 0x7c, /* 01111100 */ - 0x82, /* 10000010 */ - 0x7c, /* 01111100 */ - 0xc6, /* 11000110 */ - 0xfe, /* 11111110 */ - 0xc0, /* 11000000 */ - 0x7c, /* 01111100 */ - 0x00, /* 00000000 */ - - /* - * 137 0x89 '‰' - */ - 0xc6, /* 11000110 */ - 0x00, /* 00000000 */ - 0x7c, /* 01111100 */ - 0xc6, /* 11000110 */ - 0xfe, /* 11111110 */ - 0xc0, /* 11000000 */ - 0x7c, /* 01111100 */ - 0x00, /* 00000000 */ - - /* - * 138 0x8a 'Š' - */ - 0x30, /* 00110000 */ - 0x18, /* 00011000 */ - 0x7c, /* 01111100 */ - 0xc6, /* 11000110 */ - 0xfe, /* 11111110 */ - 0xc0, /* 11000000 */ - 0x7c, /* 01111100 */ - 0x00, /* 00000000 */ - - /* - * 139 0x8b '‹' - */ - 0x66, /* 01100110 */ - 0x00, /* 00000000 */ - 0x38, /* 00111000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x3c, /* 00111100 */ - 0x00, /* 00000000 */ - - /* - * 140 0x8c 'Œ' - */ - 0x7c, /* 01111100 */ - 0x82, /* 10000010 */ - 0x38, /* 00111000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x3c, /* 00111100 */ - 0x00, /* 00000000 */ - - /* - * 141 0x8d '' - */ - 0x30, /* 00110000 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - 0x38, /* 00111000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x3c, /* 00111100 */ - 0x00, /* 00000000 */ - - /* - * 142 0x8e 'Ž' - */ - 0xc6, /* 11000110 */ - 0x38, /* 00111000 */ - 0x6c, /* 01101100 */ - 0xc6, /* 11000110 */ - 0xfe, /* 11111110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x00, /* 00000000 */ - - /* - * 143 0x8f '' - */ - 0x38, /* 00111000 */ - 0x6c, /* 01101100 */ - 0x7c, /* 01111100 */ - 0xc6, /* 11000110 */ - 0xfe, /* 11111110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x00, /* 00000000 */ - - /* - * 144 0x90 '' - */ - 0x18, /* 00011000 */ - 0x30, /* 00110000 */ - 0xfe, /* 11111110 */ - 0xc0, /* 11000000 */ - 0xf8, /* 11111000 */ - 0xc0, /* 11000000 */ - 0xfe, /* 11111110 */ - 0x00, /* 00000000 */ - - /* - * 145 0x91 '‘' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x7e, /* 01111110 */ - 0x18, /* 00011000 */ - 0x7e, /* 01111110 */ - 0xd8, /* 11011000 */ - 0x7e, /* 01111110 */ - 0x00, /* 00000000 */ - - /* - * 146 0x92 '’' - */ - 0x3e, /* 00111110 */ - 0x6c, /* 01101100 */ - 0xcc, /* 11001100 */ - 0xfe, /* 11111110 */ - 0xcc, /* 11001100 */ - 0xcc, /* 11001100 */ - 0xce, /* 11001110 */ - 0x00, /* 00000000 */ - - /* - * 147 0x93 '“' - */ - 0x7c, /* 01111100 */ - 0x82, /* 10000010 */ - 0x7c, /* 01111100 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x7c, /* 01111100 */ - 0x00, /* 00000000 */ - - /* - * 148 0x94 '”' - */ - 0xc6, /* 11000110 */ - 0x00, /* 00000000 */ - 0x7c, /* 01111100 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x7c, /* 01111100 */ - 0x00, /* 00000000 */ - - /* - * 149 0x95 '•' - */ - 0x30, /* 00110000 */ - 0x18, /* 00011000 */ - 0x7c, /* 01111100 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x7c, /* 01111100 */ - 0x00, /* 00000000 */ - - /* - * 150 0x96 '–' - */ - 0x78, /* 01111000 */ - 0x84, /* 10000100 */ - 0x00, /* 00000000 */ - 0xcc, /* 11001100 */ - 0xcc, /* 11001100 */ - 0xcc, /* 11001100 */ - 0x76, /* 01110110 */ - 0x00, /* 00000000 */ - - /* - * 151 0x97 '—' - */ - 0x60, /* 01100000 */ - 0x30, /* 00110000 */ - 0xcc, /* 11001100 */ - 0xcc, /* 11001100 */ - 0xcc, /* 11001100 */ - 0xcc, /* 11001100 */ - 0x76, /* 01110110 */ - 0x00, /* 00000000 */ - - /* - * 152 0x98 '˜' - */ - 0xc6, /* 11000110 */ - 0x00, /* 00000000 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x7e, /* 01111110 */ - 0x06, /* 00000110 */ - 0xfc, /* 11111100 */ - - /* - * 153 0x99 '™' - */ - 0xc6, /* 11000110 */ - 0x38, /* 00111000 */ - 0x6c, /* 01101100 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x6c, /* 01101100 */ - 0x38, /* 00111000 */ - 0x00, /* 00000000 */ - - /* - * 154 0x9a 'š' - */ - 0xc6, /* 11000110 */ - 0x00, /* 00000000 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x7c, /* 01111100 */ - 0x00, /* 00000000 */ - - /* - * 155 0x9b '›' - */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x7e, /* 01111110 */ - 0xc0, /* 11000000 */ - 0xc0, /* 11000000 */ - 0x7e, /* 01111110 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - - /* - * 156 0x9c 'œ' - */ - 0x38, /* 00111000 */ - 0x6c, /* 01101100 */ - 0x64, /* 01100100 */ - 0xf0, /* 11110000 */ - 0x60, /* 01100000 */ - 0x66, /* 01100110 */ - 0xfc, /* 11111100 */ - 0x00, /* 00000000 */ - - /* - * 157 0x9d '' - */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x3c, /* 00111100 */ - 0x7e, /* 01111110 */ - 0x18, /* 00011000 */ - 0x7e, /* 01111110 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - - /* - * 158 0x9e 'ž' - */ - 0xf8, /* 11111000 */ - 0xcc, /* 11001100 */ - 0xcc, /* 11001100 */ - 0xfa, /* 11111010 */ - 0xc6, /* 11000110 */ - 0xcf, /* 11001111 */ - 0xc6, /* 11000110 */ - 0xc7, /* 11000111 */ - - /* - * 159 0x9f 'Ÿ' - */ - 0x0e, /* 00001110 */ - 0x1b, /* 00011011 */ - 0x18, /* 00011000 */ - 0x3c, /* 00111100 */ - 0x18, /* 00011000 */ - 0xd8, /* 11011000 */ - 0x70, /* 01110000 */ - 0x00, /* 00000000 */ - - /* - * 160 0xa0 ' ' - */ - 0x18, /* 00011000 */ - 0x30, /* 00110000 */ - 0x78, /* 01111000 */ - 0x0c, /* 00001100 */ - 0x7c, /* 01111100 */ - 0xcc, /* 11001100 */ - 0x76, /* 01110110 */ - 0x00, /* 00000000 */ - - /* - * 161 0xa1 '¡' - */ - 0x0c, /* 00001100 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - 0x38, /* 00111000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x3c, /* 00111100 */ - 0x00, /* 00000000 */ - - /* - * 162 0xa2 '¢' - */ - 0x0c, /* 00001100 */ - 0x18, /* 00011000 */ - 0x7c, /* 01111100 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x7c, /* 01111100 */ - 0x00, /* 00000000 */ - - /* - * 163 0xa3 '£' - */ - 0x18, /* 00011000 */ - 0x30, /* 00110000 */ - 0xcc, /* 11001100 */ - 0xcc, /* 11001100 */ - 0xcc, /* 11001100 */ - 0xcc, /* 11001100 */ - 0x76, /* 01110110 */ - 0x00, /* 00000000 */ - - /* - * 164 0xa4 '¤' - */ - 0x76, /* 01110110 */ - 0xdc, /* 11011100 */ - 0x00, /* 00000000 */ - 0xdc, /* 11011100 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x00, /* 00000000 */ - - /* - * 165 0xa5 '¥' - */ - 0x76, /* 01110110 */ - 0xdc, /* 11011100 */ - 0x00, /* 00000000 */ - 0xe6, /* 11100110 */ - 0xf6, /* 11110110 */ - 0xde, /* 11011110 */ - 0xce, /* 11001110 */ - 0x00, /* 00000000 */ - - /* - * 166 0xa6 '¦' - */ - 0x3c, /* 00111100 */ - 0x6c, /* 01101100 */ - 0x6c, /* 01101100 */ - 0x3e, /* 00111110 */ - 0x00, /* 00000000 */ - 0x7e, /* 01111110 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 167 0xa7 '§' - */ - 0x38, /* 00111000 */ - 0x6c, /* 01101100 */ - 0x6c, /* 01101100 */ - 0x38, /* 00111000 */ - 0x00, /* 00000000 */ - 0x7c, /* 01111100 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 168 0xa8 '¨' - */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x30, /* 00110000 */ - 0x63, /* 01100011 */ - 0x3e, /* 00111110 */ - 0x00, /* 00000000 */ - - /* - * 169 0xa9 '©' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xfe, /* 11111110 */ - 0xc0, /* 11000000 */ - 0xc0, /* 11000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 170 0xaa 'ª' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xfe, /* 11111110 */ - 0x06, /* 00000110 */ - 0x06, /* 00000110 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 171 0xab '«' - */ - 0x63, /* 01100011 */ - 0xe6, /* 11100110 */ - 0x6c, /* 01101100 */ - 0x7e, /* 01111110 */ - 0x33, /* 00110011 */ - 0x66, /* 01100110 */ - 0xcc, /* 11001100 */ - 0x0f, /* 00001111 */ - - /* - * 172 0xac '¬' - */ - 0x63, /* 01100011 */ - 0xe6, /* 11100110 */ - 0x6c, /* 01101100 */ - 0x7a, /* 01111010 */ - 0x36, /* 00110110 */ - 0x6a, /* 01101010 */ - 0xdf, /* 11011111 */ - 0x06, /* 00000110 */ - - /* - * 173 0xad '­' - */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x3c, /* 00111100 */ - 0x3c, /* 00111100 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - - /* - * 174 0xae '®' - */ - 0x00, /* 00000000 */ - 0x33, /* 00110011 */ - 0x66, /* 01100110 */ - 0xcc, /* 11001100 */ - 0x66, /* 01100110 */ - 0x33, /* 00110011 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 175 0xaf '¯' - */ - 0x00, /* 00000000 */ - 0xcc, /* 11001100 */ - 0x66, /* 01100110 */ - 0x33, /* 00110011 */ - 0x66, /* 01100110 */ - 0xcc, /* 11001100 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 176 0xb0 '°' - */ - 0x22, /* 00100010 */ - 0x88, /* 10001000 */ - 0x22, /* 00100010 */ - 0x88, /* 10001000 */ - 0x22, /* 00100010 */ - 0x88, /* 10001000 */ - 0x22, /* 00100010 */ - 0x88, /* 10001000 */ - - /* - * 177 0xb1 '±' - */ - 0x55, /* 01010101 */ - 0xaa, /* 10101010 */ - 0x55, /* 01010101 */ - 0xaa, /* 10101010 */ - 0x55, /* 01010101 */ - 0xaa, /* 10101010 */ - 0x55, /* 01010101 */ - 0xaa, /* 10101010 */ - - /* - * 178 0xb2 '²' - */ - 0x77, /* 01110111 */ - 0xdd, /* 11011101 */ - 0x77, /* 01110111 */ - 0xdd, /* 11011101 */ - 0x77, /* 01110111 */ - 0xdd, /* 11011101 */ - 0x77, /* 01110111 */ - 0xdd, /* 11011101 */ - - /* - * 179 0xb3 '³' - */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - - /* - * 180 0xb4 '´' - */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0xf8, /* 11111000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - - /* - * 181 0xb5 'µ' - */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0xf8, /* 11111000 */ - 0x18, /* 00011000 */ - 0xf8, /* 11111000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - - /* - * 182 0xb6 '¶' - */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0xf6, /* 11110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - - /* - * 183 0xb7 '·' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xfe, /* 11111110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - - /* - * 184 0xb8 '¸' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xf8, /* 11111000 */ - 0x18, /* 00011000 */ - 0xf8, /* 11111000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - - /* - * 185 0xb9 '¹' - */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0xf6, /* 11110110 */ - 0x06, /* 00000110 */ - 0xf6, /* 11110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - - /* - * 186 0xba 'º' - */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - - /* - * 187 0xbb '»' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xfe, /* 11111110 */ - 0x06, /* 00000110 */ - 0xf6, /* 11110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - - /* - * 188 0xbc '¼' - */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0xf6, /* 11110110 */ - 0x06, /* 00000110 */ - 0xfe, /* 11111110 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 189 0xbd '½' - */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0xfe, /* 11111110 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 190 0xbe '¾' - */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0xf8, /* 11111000 */ - 0x18, /* 00011000 */ - 0xf8, /* 11111000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 191 0xbf '¿' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xf8, /* 11111000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - - /* - * 192 0xc0 'À' - */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x1f, /* 00011111 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 193 0xc1 'Á' - */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0xff, /* 11111111 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 194 0xc2 'Â' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xff, /* 11111111 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - - /* - * 195 0xc3 'Ã' - */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x1f, /* 00011111 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - - /* - * 196 0xc4 'Ä' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xff, /* 11111111 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 197 0xc5 'Å' - */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0xff, /* 11111111 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - - /* - * 198 0xc6 'Æ' - */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x1f, /* 00011111 */ - 0x18, /* 00011000 */ - 0x1f, /* 00011111 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - - /* - * 199 0xc7 'Ç' - */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x37, /* 00110111 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - - /* - * 200 0xc8 'È' - */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x37, /* 00110111 */ - 0x30, /* 00110000 */ - 0x3f, /* 00111111 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 201 0xc9 'É' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x3f, /* 00111111 */ - 0x30, /* 00110000 */ - 0x37, /* 00110111 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - - /* - * 202 0xca 'Ê' - */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0xf7, /* 11110111 */ - 0x00, /* 00000000 */ - 0xff, /* 11111111 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 203 0xcb 'Ë' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xff, /* 11111111 */ - 0x00, /* 00000000 */ - 0xf7, /* 11110111 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - - /* - * 204 0xcc 'Ì' - */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x37, /* 00110111 */ - 0x30, /* 00110000 */ - 0x37, /* 00110111 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - - /* - * 205 0xcd 'Í' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xff, /* 11111111 */ - 0x00, /* 00000000 */ - 0xff, /* 11111111 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 206 0xce 'Î' - */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0xf7, /* 11110111 */ - 0x00, /* 00000000 */ - 0xf7, /* 11110111 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - - /* - * 207 0xcf 'Ï' - */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0xff, /* 11111111 */ - 0x00, /* 00000000 */ - 0xff, /* 11111111 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 208 0xd0 'Ð' - */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0xff, /* 11111111 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 209 0xd1 'Ñ' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xff, /* 11111111 */ - 0x00, /* 00000000 */ - 0xff, /* 11111111 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - - /* - * 210 0xd2 'Ò' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xff, /* 11111111 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - - /* - * 211 0xd3 'Ó' - */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x3f, /* 00111111 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 212 0xd4 'Ô' - */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x1f, /* 00011111 */ - 0x18, /* 00011000 */ - 0x1f, /* 00011111 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 213 0xd5 'Õ' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x1f, /* 00011111 */ - 0x18, /* 00011000 */ - 0x1f, /* 00011111 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - - /* - * 214 0xd6 'Ö' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x3f, /* 00111111 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - - /* - * 215 0xd7 '×' - */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0xff, /* 11111111 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - - /* - * 216 0xd8 'Ø' - */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0xff, /* 11111111 */ - 0x18, /* 00011000 */ - 0xff, /* 11111111 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - - /* - * 217 0xd9 'Ù' - */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0xf8, /* 11111000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 218 0xda 'Ú' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x1f, /* 00011111 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - - /* - * 219 0xdb 'Û' - */ - 0xff, /* 11111111 */ - 0xff, /* 11111111 */ - 0xff, /* 11111111 */ - 0xff, /* 11111111 */ - 0xff, /* 11111111 */ - 0xff, /* 11111111 */ - 0xff, /* 11111111 */ - 0xff, /* 11111111 */ - - /* - * 220 0xdc 'Ü' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xff, /* 11111111 */ - 0xff, /* 11111111 */ - 0xff, /* 11111111 */ - 0xff, /* 11111111 */ - - /* - * 221 0xdd 'Ý' - */ - 0xf0, /* 11110000 */ - 0xf0, /* 11110000 */ - 0xf0, /* 11110000 */ - 0xf0, /* 11110000 */ - 0xf0, /* 11110000 */ - 0xf0, /* 11110000 */ - 0xf0, /* 11110000 */ - 0xf0, /* 11110000 */ - - /* - * 222 0xde 'Þ' - */ - 0x0f, /* 00001111 */ - 0x0f, /* 00001111 */ - 0x0f, /* 00001111 */ - 0x0f, /* 00001111 */ - 0x0f, /* 00001111 */ - 0x0f, /* 00001111 */ - 0x0f, /* 00001111 */ - 0x0f, /* 00001111 */ - - /* - * 223 0xdf 'ß' - */ - 0xff, /* 11111111 */ - 0xff, /* 11111111 */ - 0xff, /* 11111111 */ - 0xff, /* 11111111 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 224 0xe0 'à' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x76, /* 01110110 */ - 0xdc, /* 11011100 */ - 0xc8, /* 11001000 */ - 0xdc, /* 11011100 */ - 0x76, /* 01110110 */ - 0x00, /* 00000000 */ - - /* - * 225 0xe1 'á' - */ - 0x78, /* 01111000 */ - 0xcc, /* 11001100 */ - 0xcc, /* 11001100 */ - 0xd8, /* 11011000 */ - 0xcc, /* 11001100 */ - 0xc6, /* 11000110 */ - 0xcc, /* 11001100 */ - 0x00, /* 00000000 */ - - /* - * 226 0xe2 'â' - */ - 0xfe, /* 11111110 */ - 0xc6, /* 11000110 */ - 0xc0, /* 11000000 */ - 0xc0, /* 11000000 */ - 0xc0, /* 11000000 */ - 0xc0, /* 11000000 */ - 0xc0, /* 11000000 */ - 0x00, /* 00000000 */ - - /* - * 227 0xe3 'ã' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xfe, /* 11111110 */ - 0x6c, /* 01101100 */ - 0x6c, /* 01101100 */ - 0x6c, /* 01101100 */ - 0x6c, /* 01101100 */ - 0x00, /* 00000000 */ - - /* - * 228 0xe4 'ä' - */ - 0xfe, /* 11111110 */ - 0xc6, /* 11000110 */ - 0x60, /* 01100000 */ - 0x30, /* 00110000 */ - 0x60, /* 01100000 */ - 0xc6, /* 11000110 */ - 0xfe, /* 11111110 */ - 0x00, /* 00000000 */ - - /* - * 229 0xe5 'å' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x7e, /* 01111110 */ - 0xd8, /* 11011000 */ - 0xd8, /* 11011000 */ - 0xd8, /* 11011000 */ - 0x70, /* 01110000 */ - 0x00, /* 00000000 */ - - /* - * 230 0xe6 'æ' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x7c, /* 01111100 */ - 0xc0, /* 11000000 */ - - /* - * 231 0xe7 'ç' - */ - 0x00, /* 00000000 */ - 0x76, /* 01110110 */ - 0xdc, /* 11011100 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - - /* - * 232 0xe8 'è' - */ - 0x7e, /* 01111110 */ - 0x18, /* 00011000 */ - 0x3c, /* 00111100 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x3c, /* 00111100 */ - 0x18, /* 00011000 */ - 0x7e, /* 01111110 */ - - /* - * 233 0xe9 'é' - */ - 0x38, /* 00111000 */ - 0x6c, /* 01101100 */ - 0xc6, /* 11000110 */ - 0xfe, /* 11111110 */ - 0xc6, /* 11000110 */ - 0x6c, /* 01101100 */ - 0x38, /* 00111000 */ - 0x00, /* 00000000 */ - - /* - * 234 0xea 'ê' - */ - 0x38, /* 00111000 */ - 0x6c, /* 01101100 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x6c, /* 01101100 */ - 0x6c, /* 01101100 */ - 0xee, /* 11101110 */ - 0x00, /* 00000000 */ - - /* - * 235 0xeb 'ë' - */ - 0x0e, /* 00001110 */ - 0x18, /* 00011000 */ - 0x0c, /* 00001100 */ - 0x3e, /* 00111110 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x3c, /* 00111100 */ - 0x00, /* 00000000 */ - - /* - * 236 0xec 'ì' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x7e, /* 01111110 */ - 0xdb, /* 11011011 */ - 0xdb, /* 11011011 */ - 0x7e, /* 01111110 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 237 0xed 'í' - */ - 0x06, /* 00000110 */ - 0x0c, /* 00001100 */ - 0x7e, /* 01111110 */ - 0xdb, /* 11011011 */ - 0xdb, /* 11011011 */ - 0x7e, /* 01111110 */ - 0x60, /* 01100000 */ - 0xc0, /* 11000000 */ - - /* - * 238 0xee 'î' - */ - 0x1e, /* 00011110 */ - 0x30, /* 00110000 */ - 0x60, /* 01100000 */ - 0x7e, /* 01111110 */ - 0x60, /* 01100000 */ - 0x30, /* 00110000 */ - 0x1e, /* 00011110 */ - 0x00, /* 00000000 */ - - /* - * 239 0xef 'ï' - */ - 0x00, /* 00000000 */ - 0x7c, /* 01111100 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x00, /* 00000000 */ - - /* - * 240 0xf0 'ð' - */ - 0x00, /* 00000000 */ - 0xfe, /* 11111110 */ - 0x00, /* 00000000 */ - 0xfe, /* 11111110 */ - 0x00, /* 00000000 */ - 0xfe, /* 11111110 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 241 0xf1 'ñ' - */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x7e, /* 01111110 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - 0x7e, /* 01111110 */ - 0x00, /* 00000000 */ - - /* - * 242 0xf2 'ò' - */ - 0x30, /* 00110000 */ - 0x18, /* 00011000 */ - 0x0c, /* 00001100 */ - 0x18, /* 00011000 */ - 0x30, /* 00110000 */ - 0x00, /* 00000000 */ - 0x7e, /* 01111110 */ - 0x00, /* 00000000 */ - - /* - * 243 0xf3 'ó' - */ - 0x0c, /* 00001100 */ - 0x18, /* 00011000 */ - 0x30, /* 00110000 */ - 0x18, /* 00011000 */ - 0x0c, /* 00001100 */ - 0x00, /* 00000000 */ - 0x7e, /* 01111110 */ - 0x00, /* 00000000 */ - - /* - * 244 0xf4 'ô' - */ - 0x0e, /* 00001110 */ - 0x1b, /* 00011011 */ - 0x1b, /* 00011011 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - - /* - * 245 0xf5 'õ' - */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0xd8, /* 11011000 */ - 0xd8, /* 11011000 */ - 0x70, /* 01110000 */ - - /* - * 246 0xf6 'ö' - */ - 0x00, /* 00000000 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - 0x7e, /* 01111110 */ - 0x00, /* 00000000 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 247 0xf7 '÷' - */ - 0x00, /* 00000000 */ - 0x76, /* 01110110 */ - 0xdc, /* 11011100 */ - 0x00, /* 00000000 */ - 0x76, /* 01110110 */ - 0xdc, /* 11011100 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 248 0xf8 'ø' - */ - 0x38, /* 00111000 */ - 0x6c, /* 01101100 */ - 0x6c, /* 01101100 */ - 0x38, /* 00111000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 249 0xf9 'ù' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 250 0xfa 'ú' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 251 0xfb 'û' - */ - 0x0f, /* 00001111 */ - 0x0c, /* 00001100 */ - 0x0c, /* 00001100 */ - 0x0c, /* 00001100 */ - 0xec, /* 11101100 */ - 0x6c, /* 01101100 */ - 0x3c, /* 00111100 */ - 0x1c, /* 00011100 */ - - /* - * 252 0xfc 'ü' - */ - 0x6c, /* 01101100 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x36, /* 00110110 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 253 0xfd 'ý' - */ - 0x78, /* 01111000 */ - 0x0c, /* 00001100 */ - 0x18, /* 00011000 */ - 0x30, /* 00110000 */ - 0x7c, /* 01111100 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 254 0xfe 'þ' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x3c, /* 00111100 */ - 0x3c, /* 00111100 */ - 0x3c, /* 00111100 */ - 0x3c, /* 00111100 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* - * 255 0xff ' ' - */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ + /* + * 0 0x00 '^@' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 1 0x01 '^A' + */ + 0x7e, /* 01111110 */ + 0x81, /* 10000001 */ + 0xa5, /* 10100101 */ + 0x81, /* 10000001 */ + 0xbd, /* 10111101 */ + 0x99, /* 10011001 */ + 0x81, /* 10000001 */ + 0x7e, /* 01111110 */ + + /* + * 2 0x02 '^B' + */ + 0x7e, /* 01111110 */ + 0xff, /* 11111111 */ + 0xdb, /* 11011011 */ + 0xff, /* 11111111 */ + 0xc3, /* 11000011 */ + 0xe7, /* 11100111 */ + 0xff, /* 11111111 */ + 0x7e, /* 01111110 */ + + /* + * 3 0x03 '^C' + */ + 0x6c, /* 01101100 */ + 0xfe, /* 11111110 */ + 0xfe, /* 11111110 */ + 0xfe, /* 11111110 */ + 0x7c, /* 01111100 */ + 0x38, /* 00111000 */ + 0x10, /* 00010000 */ + 0x00, /* 00000000 */ + + /* + * 4 0x04 '^D' + */ + 0x10, /* 00010000 */ + 0x38, /* 00111000 */ + 0x7c, /* 01111100 */ + 0xfe, /* 11111110 */ + 0x7c, /* 01111100 */ + 0x38, /* 00111000 */ + 0x10, /* 00010000 */ + 0x00, /* 00000000 */ + + /* + * 5 0x05 '^E' + */ + 0x38, /* 00111000 */ + 0x7c, /* 01111100 */ + 0x38, /* 00111000 */ + 0xfe, /* 11111110 */ + 0xfe, /* 11111110 */ + 0xd6, /* 11010110 */ + 0x10, /* 00010000 */ + 0x38, /* 00111000 */ + + /* + * 6 0x06 '^F' + */ + 0x10, /* 00010000 */ + 0x38, /* 00111000 */ + 0x7c, /* 01111100 */ + 0xfe, /* 11111110 */ + 0xfe, /* 11111110 */ + 0x7c, /* 01111100 */ + 0x10, /* 00010000 */ + 0x38, /* 00111000 */ + + /* + * 7 0x07 '^G' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x3c, /* 00111100 */ + 0x3c, /* 00111100 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 8 0x08 '^H' + */ + 0xff, /* 11111111 */ + 0xff, /* 11111111 */ + 0xe7, /* 11100111 */ + 0xc3, /* 11000011 */ + 0xc3, /* 11000011 */ + 0xe7, /* 11100111 */ + 0xff, /* 11111111 */ + 0xff, /* 11111111 */ + + /* + * 9 0x09 '^I' + */ + 0x00, /* 00000000 */ + 0x3c, /* 00111100 */ + 0x66, /* 01100110 */ + 0x42, /* 01000010 */ + 0x42, /* 01000010 */ + 0x66, /* 01100110 */ + 0x3c, /* 00111100 */ + 0x00, /* 00000000 */ + + /* + * 10 0x0a '^J' + */ + 0xff, /* 11111111 */ + 0xc3, /* 11000011 */ + 0x99, /* 10011001 */ + 0xbd, /* 10111101 */ + 0xbd, /* 10111101 */ + 0x99, /* 10011001 */ + 0xc3, /* 11000011 */ + 0xff, /* 11111111 */ + + /* + * 11 0x0b '^K' + */ + 0x0f, /* 00001111 */ + 0x07, /* 00000111 */ + 0x0f, /* 00001111 */ + 0x7d, /* 01111101 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0x78, /* 01111000 */ + + /* + * 12 0x0c '^L' + */ + 0x3c, /* 00111100 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x3c, /* 00111100 */ + 0x18, /* 00011000 */ + 0x7e, /* 01111110 */ + 0x18, /* 00011000 */ + + /* + * 13 0x0d '^M' + */ + 0x3f, /* 00111111 */ + 0x33, /* 00110011 */ + 0x3f, /* 00111111 */ + 0x30, /* 00110000 */ + 0x30, /* 00110000 */ + 0x70, /* 01110000 */ + 0xf0, /* 11110000 */ + 0xe0, /* 11100000 */ + + /* + * 14 0x0e '^N' + */ + 0x7f, /* 01111111 */ + 0x63, /* 01100011 */ + 0x7f, /* 01111111 */ + 0x63, /* 01100011 */ + 0x63, /* 01100011 */ + 0x67, /* 01100111 */ + 0xe6, /* 11100110 */ + 0xc0, /* 11000000 */ + + /* + * 15 0x0f '^O' + */ + 0x18, /* 00011000 */ + 0xdb, /* 11011011 */ + 0x3c, /* 00111100 */ + 0xe7, /* 11100111 */ + 0xe7, /* 11100111 */ + 0x3c, /* 00111100 */ + 0xdb, /* 11011011 */ + 0x18, /* 00011000 */ + + /* + * 16 0x10 '^P' + */ + 0x80, /* 10000000 */ + 0xe0, /* 11100000 */ + 0xf8, /* 11111000 */ + 0xfe, /* 11111110 */ + 0xf8, /* 11111000 */ + 0xe0, /* 11100000 */ + 0x80, /* 10000000 */ + 0x00, /* 00000000 */ + + /* + * 17 0x11 '^Q' + */ + 0x02, /* 00000010 */ + 0x0e, /* 00001110 */ + 0x3e, /* 00111110 */ + 0xfe, /* 11111110 */ + 0x3e, /* 00111110 */ + 0x0e, /* 00001110 */ + 0x02, /* 00000010 */ + 0x00, /* 00000000 */ + + /* + * 18 0x12 '^R' + */ + 0x18, /* 00011000 */ + 0x3c, /* 00111100 */ + 0x7e, /* 01111110 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x7e, /* 01111110 */ + 0x3c, /* 00111100 */ + 0x18, /* 00011000 */ + + /* + * 19 0x13 '^S' + */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x00, /* 00000000 */ + 0x66, /* 01100110 */ + 0x00, /* 00000000 */ + + /* + * 20 0x14 '^T' + */ + 0x7f, /* 01111111 */ + 0xdb, /* 11011011 */ + 0xdb, /* 11011011 */ + 0x7b, /* 01111011 */ + 0x1b, /* 00011011 */ + 0x1b, /* 00011011 */ + 0x1b, /* 00011011 */ + 0x00, /* 00000000 */ + + /* + * 21 0x15 '^U' + */ + 0x3e, /* 00111110 */ + 0x61, /* 01100001 */ + 0x3c, /* 00111100 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x3c, /* 00111100 */ + 0x86, /* 10000110 */ + 0x7c, /* 01111100 */ + + /* + * 22 0x16 '^V' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x7e, /* 01111110 */ + 0x7e, /* 01111110 */ + 0x7e, /* 01111110 */ + 0x00, /* 00000000 */ + + /* + * 23 0x17 '^W' + */ + 0x18, /* 00011000 */ + 0x3c, /* 00111100 */ + 0x7e, /* 01111110 */ + 0x18, /* 00011000 */ + 0x7e, /* 01111110 */ + 0x3c, /* 00111100 */ + 0x18, /* 00011000 */ + 0xff, /* 11111111 */ + + /* + * 24 0x18 '^X' + */ + 0x18, /* 00011000 */ + 0x3c, /* 00111100 */ + 0x7e, /* 01111110 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + + /* + * 25 0x19 '^Y' + */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x7e, /* 01111110 */ + 0x3c, /* 00111100 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + + /* + * 26 0x1a '^Z' + */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x0c, /* 00001100 */ + 0xfe, /* 11111110 */ + 0x0c, /* 00001100 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 27 0x1b '^[' + */ + 0x00, /* 00000000 */ + 0x30, /* 00110000 */ + 0x60, /* 01100000 */ + 0xfe, /* 11111110 */ + 0x60, /* 01100000 */ + 0x30, /* 00110000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 28 0x1c '^\' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xc0, /* 11000000 */ + 0xc0, /* 11000000 */ + 0xc0, /* 11000000 */ + 0xfe, /* 11111110 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 29 0x1d '^]' + */ + 0x00, /* 00000000 */ + 0x24, /* 00100100 */ + 0x66, /* 01100110 */ + 0xff, /* 11111111 */ + 0x66, /* 01100110 */ + 0x24, /* 00100100 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 30 0x1e '^^' + */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x3c, /* 00111100 */ + 0x7e, /* 01111110 */ + 0xff, /* 11111111 */ + 0xff, /* 11111111 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 31 0x1f '^_' + */ + 0x00, /* 00000000 */ + 0xff, /* 11111111 */ + 0xff, /* 11111111 */ + 0x7e, /* 01111110 */ + 0x3c, /* 00111100 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 32 0x20 ' ' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 33 0x21 '!' + */ + 0x18, /* 00011000 */ + 0x3c, /* 00111100 */ + 0x3c, /* 00111100 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + + /* + * 34 0x22 '"' + */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x24, /* 00100100 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 35 0x23 '#' + */ + 0x6c, /* 01101100 */ + 0x6c, /* 01101100 */ + 0xfe, /* 11111110 */ + 0x6c, /* 01101100 */ + 0xfe, /* 11111110 */ + 0x6c, /* 01101100 */ + 0x6c, /* 01101100 */ + 0x00, /* 00000000 */ + + /* + * 36 0x24 '$' + */ + 0x18, /* 00011000 */ + 0x3e, /* 00111110 */ + 0x60, /* 01100000 */ + 0x3c, /* 00111100 */ + 0x06, /* 00000110 */ + 0x7c, /* 01111100 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + + /* + * 37 0x25 '%' + */ + 0x00, /* 00000000 */ + 0xc6, /* 11000110 */ + 0xcc, /* 11001100 */ + 0x18, /* 00011000 */ + 0x30, /* 00110000 */ + 0x66, /* 01100110 */ + 0xc6, /* 11000110 */ + 0x00, /* 00000000 */ + + /* + * 38 0x26 '&' + */ + 0x38, /* 00111000 */ + 0x6c, /* 01101100 */ + 0x38, /* 00111000 */ + 0x76, /* 01110110 */ + 0xdc, /* 11011100 */ + 0xcc, /* 11001100 */ + 0x76, /* 01110110 */ + 0x00, /* 00000000 */ + + /* + * 39 0x27 ''' + */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x30, /* 00110000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 40 0x28 '(' + */ + 0x0c, /* 00001100 */ + 0x18, /* 00011000 */ + 0x30, /* 00110000 */ + 0x30, /* 00110000 */ + 0x30, /* 00110000 */ + 0x18, /* 00011000 */ + 0x0c, /* 00001100 */ + 0x00, /* 00000000 */ + + /* + * 41 0x29 ')' + */ + 0x30, /* 00110000 */ + 0x18, /* 00011000 */ + 0x0c, /* 00001100 */ + 0x0c, /* 00001100 */ + 0x0c, /* 00001100 */ + 0x18, /* 00011000 */ + 0x30, /* 00110000 */ + 0x00, /* 00000000 */ + + /* + * 42 0x2a '*' + */ + 0x00, /* 00000000 */ + 0x66, /* 01100110 */ + 0x3c, /* 00111100 */ + 0xff, /* 11111111 */ + 0x3c, /* 00111100 */ + 0x66, /* 01100110 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 43 0x2b '+' + */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x7e, /* 01111110 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 44 0x2c ',' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x30, /* 00110000 */ + + /* + * 45 0x2d '-' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x7e, /* 01111110 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 46 0x2e '.' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + + /* + * 47 0x2f '/' + */ + 0x06, /* 00000110 */ + 0x0c, /* 00001100 */ + 0x18, /* 00011000 */ + 0x30, /* 00110000 */ + 0x60, /* 01100000 */ + 0xc0, /* 11000000 */ + 0x80, /* 10000000 */ + 0x00, /* 00000000 */ + + /* + * 48 0x30 '0' + */ + 0x38, /* 00111000 */ + 0x6c, /* 01101100 */ + 0xc6, /* 11000110 */ + 0xd6, /* 11010110 */ + 0xc6, /* 11000110 */ + 0x6c, /* 01101100 */ + 0x38, /* 00111000 */ + 0x00, /* 00000000 */ + + /* + * 49 0x31 '1' + */ + 0x18, /* 00011000 */ + 0x38, /* 00111000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x7e, /* 01111110 */ + 0x00, /* 00000000 */ + + /* + * 50 0x32 '2' + */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0x06, /* 00000110 */ + 0x1c, /* 00011100 */ + 0x30, /* 00110000 */ + 0x66, /* 01100110 */ + 0xfe, /* 11111110 */ + 0x00, /* 00000000 */ + + /* + * 51 0x33 '3' + */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0x06, /* 00000110 */ + 0x3c, /* 00111100 */ + 0x06, /* 00000110 */ + 0xc6, /* 11000110 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* + * 52 0x34 '4' + */ + 0x1c, /* 00011100 */ + 0x3c, /* 00111100 */ + 0x6c, /* 01101100 */ + 0xcc, /* 11001100 */ + 0xfe, /* 11111110 */ + 0x0c, /* 00001100 */ + 0x1e, /* 00011110 */ + 0x00, /* 00000000 */ + + /* + * 53 0x35 '5' + */ + 0xfe, /* 11111110 */ + 0xc0, /* 11000000 */ + 0xc0, /* 11000000 */ + 0xfc, /* 11111100 */ + 0x06, /* 00000110 */ + 0xc6, /* 11000110 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* + * 54 0x36 '6' + */ + 0x38, /* 00111000 */ + 0x60, /* 01100000 */ + 0xc0, /* 11000000 */ + 0xfc, /* 11111100 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* + * 55 0x37 '7' + */ + 0xfe, /* 11111110 */ + 0xc6, /* 11000110 */ + 0x0c, /* 00001100 */ + 0x18, /* 00011000 */ + 0x30, /* 00110000 */ + 0x30, /* 00110000 */ + 0x30, /* 00110000 */ + 0x00, /* 00000000 */ + + /* + * 56 0x38 '8' + */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* + * 57 0x39 '9' + */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x7e, /* 01111110 */ + 0x06, /* 00000110 */ + 0x0c, /* 00001100 */ + 0x78, /* 01111000 */ + 0x00, /* 00000000 */ + + /* + * 58 0x3a ':' + */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + + /* + * 59 0x3b ';' + */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x30, /* 00110000 */ + + /* + * 60 0x3c '<' + */ + 0x06, /* 00000110 */ + 0x0c, /* 00001100 */ + 0x18, /* 00011000 */ + 0x30, /* 00110000 */ + 0x18, /* 00011000 */ + 0x0c, /* 00001100 */ + 0x06, /* 00000110 */ + 0x00, /* 00000000 */ + + /* + * 61 0x3d '=' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x7e, /* 01111110 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x7e, /* 01111110 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 62 0x3e '>' + */ + 0x60, /* 01100000 */ + 0x30, /* 00110000 */ + 0x18, /* 00011000 */ + 0x0c, /* 00001100 */ + 0x18, /* 00011000 */ + 0x30, /* 00110000 */ + 0x60, /* 01100000 */ + 0x00, /* 00000000 */ + + /* + * 63 0x3f '?' + */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0x0c, /* 00001100 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + + /* + * 64 0x40 '@' + */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xde, /* 11011110 */ + 0xde, /* 11011110 */ + 0xde, /* 11011110 */ + 0xc0, /* 11000000 */ + 0x78, /* 01111000 */ + 0x00, /* 00000000 */ + + /* + * 65 0x41 'A' + */ + 0x38, /* 00111000 */ + 0x6c, /* 01101100 */ + 0xc6, /* 11000110 */ + 0xfe, /* 11111110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x00, /* 00000000 */ + + /* + * 66 0x42 'B' + */ + 0xfc, /* 11111100 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x7c, /* 01111100 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0xfc, /* 11111100 */ + 0x00, /* 00000000 */ + + /* + * 67 0x43 'C' + */ + 0x3c, /* 00111100 */ + 0x66, /* 01100110 */ + 0xc0, /* 11000000 */ + 0xc0, /* 11000000 */ + 0xc0, /* 11000000 */ + 0x66, /* 01100110 */ + 0x3c, /* 00111100 */ + 0x00, /* 00000000 */ + + /* + * 68 0x44 'D' + */ + 0xf8, /* 11111000 */ + 0x6c, /* 01101100 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x6c, /* 01101100 */ + 0xf8, /* 11111000 */ + 0x00, /* 00000000 */ + + /* + * 69 0x45 'E' + */ + 0xfe, /* 11111110 */ + 0x62, /* 01100010 */ + 0x68, /* 01101000 */ + 0x78, /* 01111000 */ + 0x68, /* 01101000 */ + 0x62, /* 01100010 */ + 0xfe, /* 11111110 */ + 0x00, /* 00000000 */ + + /* + * 70 0x46 'F' + */ + 0xfe, /* 11111110 */ + 0x62, /* 01100010 */ + 0x68, /* 01101000 */ + 0x78, /* 01111000 */ + 0x68, /* 01101000 */ + 0x60, /* 01100000 */ + 0xf0, /* 11110000 */ + 0x00, /* 00000000 */ + + /* + * 71 0x47 'G' + */ + 0x3c, /* 00111100 */ + 0x66, /* 01100110 */ + 0xc0, /* 11000000 */ + 0xc0, /* 11000000 */ + 0xce, /* 11001110 */ + 0x66, /* 01100110 */ + 0x3a, /* 00111010 */ + 0x00, /* 00000000 */ + + /* + * 72 0x48 'H' + */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xfe, /* 11111110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x00, /* 00000000 */ + + /* + * 73 0x49 'I' + */ + 0x3c, /* 00111100 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x3c, /* 00111100 */ + 0x00, /* 00000000 */ + + /* + * 74 0x4a 'J' + */ + 0x1e, /* 00011110 */ + 0x0c, /* 00001100 */ + 0x0c, /* 00001100 */ + 0x0c, /* 00001100 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0x78, /* 01111000 */ + 0x00, /* 00000000 */ + + /* + * 75 0x4b 'K' + */ + 0xe6, /* 11100110 */ + 0x66, /* 01100110 */ + 0x6c, /* 01101100 */ + 0x78, /* 01111000 */ + 0x6c, /* 01101100 */ + 0x66, /* 01100110 */ + 0xe6, /* 11100110 */ + 0x00, /* 00000000 */ + + /* + * 76 0x4c 'L' + */ + 0xf0, /* 11110000 */ + 0x60, /* 01100000 */ + 0x60, /* 01100000 */ + 0x60, /* 01100000 */ + 0x62, /* 01100010 */ + 0x66, /* 01100110 */ + 0xfe, /* 11111110 */ + 0x00, /* 00000000 */ + + /* + * 77 0x4d 'M' + */ + 0xc6, /* 11000110 */ + 0xee, /* 11101110 */ + 0xfe, /* 11111110 */ + 0xfe, /* 11111110 */ + 0xd6, /* 11010110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x00, /* 00000000 */ + + /* + * 78 0x4e 'N' + */ + 0xc6, /* 11000110 */ + 0xe6, /* 11100110 */ + 0xf6, /* 11110110 */ + 0xde, /* 11011110 */ + 0xce, /* 11001110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x00, /* 00000000 */ + + /* + * 79 0x4f 'O' + */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* + * 80 0x50 'P' + */ + 0xfc, /* 11111100 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x7c, /* 01111100 */ + 0x60, /* 01100000 */ + 0x60, /* 01100000 */ + 0xf0, /* 11110000 */ + 0x00, /* 00000000 */ + + /* + * 81 0x51 'Q' + */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xce, /* 11001110 */ + 0x7c, /* 01111100 */ + 0x0e, /* 00001110 */ + + /* + * 82 0x52 'R' + */ + 0xfc, /* 11111100 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x7c, /* 01111100 */ + 0x6c, /* 01101100 */ + 0x66, /* 01100110 */ + 0xe6, /* 11100110 */ + 0x00, /* 00000000 */ + + /* + * 83 0x53 'S' + */ + 0x3c, /* 00111100 */ + 0x66, /* 01100110 */ + 0x30, /* 00110000 */ + 0x18, /* 00011000 */ + 0x0c, /* 00001100 */ + 0x66, /* 01100110 */ + 0x3c, /* 00111100 */ + 0x00, /* 00000000 */ + + /* + * 84 0x54 'T' + */ + 0x7e, /* 01111110 */ + 0x7e, /* 01111110 */ + 0x5a, /* 01011010 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x3c, /* 00111100 */ + 0x00, /* 00000000 */ + + /* + * 85 0x55 'U' + */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* + * 86 0x56 'V' + */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x6c, /* 01101100 */ + 0x38, /* 00111000 */ + 0x00, /* 00000000 */ + + /* + * 87 0x57 'W' + */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xd6, /* 11010110 */ + 0xd6, /* 11010110 */ + 0xfe, /* 11111110 */ + 0x6c, /* 01101100 */ + 0x00, /* 00000000 */ + + /* + * 88 0x58 'X' + */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x6c, /* 01101100 */ + 0x38, /* 00111000 */ + 0x6c, /* 01101100 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x00, /* 00000000 */ + + /* + * 89 0x59 'Y' + */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x3c, /* 00111100 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x3c, /* 00111100 */ + 0x00, /* 00000000 */ + + /* + * 90 0x5a 'Z' + */ + 0xfe, /* 11111110 */ + 0xc6, /* 11000110 */ + 0x8c, /* 10001100 */ + 0x18, /* 00011000 */ + 0x32, /* 00110010 */ + 0x66, /* 01100110 */ + 0xfe, /* 11111110 */ + 0x00, /* 00000000 */ + + /* + * 91 0x5b '[' + */ + 0x3c, /* 00111100 */ + 0x30, /* 00110000 */ + 0x30, /* 00110000 */ + 0x30, /* 00110000 */ + 0x30, /* 00110000 */ + 0x30, /* 00110000 */ + 0x3c, /* 00111100 */ + 0x00, /* 00000000 */ + + /* + * 92 0x5c '\' + */ + 0xc0, /* 11000000 */ + 0x60, /* 01100000 */ + 0x30, /* 00110000 */ + 0x18, /* 00011000 */ + 0x0c, /* 00001100 */ + 0x06, /* 00000110 */ + 0x02, /* 00000010 */ + 0x00, /* 00000000 */ + + /* + * 93 0x5d ']' + */ + 0x3c, /* 00111100 */ + 0x0c, /* 00001100 */ + 0x0c, /* 00001100 */ + 0x0c, /* 00001100 */ + 0x0c, /* 00001100 */ + 0x0c, /* 00001100 */ + 0x3c, /* 00111100 */ + 0x00, /* 00000000 */ + + /* + * 94 0x5e '^' + */ + 0x10, /* 00010000 */ + 0x38, /* 00111000 */ + 0x6c, /* 01101100 */ + 0xc6, /* 11000110 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 95 0x5f '_' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xff, /* 11111111 */ + + /* + * 96 0x60 '`' + */ + 0x30, /* 00110000 */ + 0x18, /* 00011000 */ + 0x0c, /* 00001100 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 97 0x61 'a' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x78, /* 01111000 */ + 0x0c, /* 00001100 */ + 0x7c, /* 01111100 */ + 0xcc, /* 11001100 */ + 0x76, /* 01110110 */ + 0x00, /* 00000000 */ + + /* + * 98 0x62 'b' + */ + 0xe0, /* 11100000 */ + 0x60, /* 01100000 */ + 0x7c, /* 01111100 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0xdc, /* 11011100 */ + 0x00, /* 00000000 */ + + /* + * 99 0x63 'c' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xc0, /* 11000000 */ + 0xc6, /* 11000110 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* + * 100 0x64 'd' + */ + 0x1c, /* 00011100 */ + 0x0c, /* 00001100 */ + 0x7c, /* 01111100 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0x76, /* 01110110 */ + 0x00, /* 00000000 */ + + /* + * 101 0x65 'e' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xfe, /* 11111110 */ + 0xc0, /* 11000000 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* + * 102 0x66 'f' + */ + 0x3c, /* 00111100 */ + 0x66, /* 01100110 */ + 0x60, /* 01100000 */ + 0xf8, /* 11111000 */ + 0x60, /* 01100000 */ + 0x60, /* 01100000 */ + 0xf0, /* 11110000 */ + 0x00, /* 00000000 */ + + /* + * 103 0x67 'g' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x76, /* 01110110 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0x7c, /* 01111100 */ + 0x0c, /* 00001100 */ + 0xf8, /* 11111000 */ + + /* + * 104 0x68 'h' + */ + 0xe0, /* 11100000 */ + 0x60, /* 01100000 */ + 0x6c, /* 01101100 */ + 0x76, /* 01110110 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0xe6, /* 11100110 */ + 0x00, /* 00000000 */ + + /* + * 105 0x69 'i' + */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x38, /* 00111000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x3c, /* 00111100 */ + 0x00, /* 00000000 */ + + /* + * 106 0x6a 'j' + */ + 0x06, /* 00000110 */ + 0x00, /* 00000000 */ + 0x06, /* 00000110 */ + 0x06, /* 00000110 */ + 0x06, /* 00000110 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x3c, /* 00111100 */ + + /* + * 107 0x6b 'k' + */ + 0xe0, /* 11100000 */ + 0x60, /* 01100000 */ + 0x66, /* 01100110 */ + 0x6c, /* 01101100 */ + 0x78, /* 01111000 */ + 0x6c, /* 01101100 */ + 0xe6, /* 11100110 */ + 0x00, /* 00000000 */ + + /* + * 108 0x6c 'l' + */ + 0x38, /* 00111000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x3c, /* 00111100 */ + 0x00, /* 00000000 */ + + /* + * 109 0x6d 'm' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xec, /* 11101100 */ + 0xfe, /* 11111110 */ + 0xd6, /* 11010110 */ + 0xd6, /* 11010110 */ + 0xd6, /* 11010110 */ + 0x00, /* 00000000 */ + + /* + * 110 0x6e 'n' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xdc, /* 11011100 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x00, /* 00000000 */ + + /* + * 111 0x6f 'o' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* + * 112 0x70 'p' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xdc, /* 11011100 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x7c, /* 01111100 */ + 0x60, /* 01100000 */ + 0xf0, /* 11110000 */ + + /* + * 113 0x71 'q' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x76, /* 01110110 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0x7c, /* 01111100 */ + 0x0c, /* 00001100 */ + 0x1e, /* 00011110 */ + + /* + * 114 0x72 'r' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xdc, /* 11011100 */ + 0x76, /* 01110110 */ + 0x60, /* 01100000 */ + 0x60, /* 01100000 */ + 0xf0, /* 11110000 */ + 0x00, /* 00000000 */ + + /* + * 115 0x73 's' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x7e, /* 01111110 */ + 0xc0, /* 11000000 */ + 0x7c, /* 01111100 */ + 0x06, /* 00000110 */ + 0xfc, /* 11111100 */ + 0x00, /* 00000000 */ + + /* + * 116 0x74 't' + */ + 0x30, /* 00110000 */ + 0x30, /* 00110000 */ + 0xfc, /* 11111100 */ + 0x30, /* 00110000 */ + 0x30, /* 00110000 */ + 0x36, /* 00110110 */ + 0x1c, /* 00011100 */ + 0x00, /* 00000000 */ + + /* + * 117 0x75 'u' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0x76, /* 01110110 */ + 0x00, /* 00000000 */ + + /* + * 118 0x76 'v' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x6c, /* 01101100 */ + 0x38, /* 00111000 */ + 0x00, /* 00000000 */ + + /* + * 119 0x77 'w' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xc6, /* 11000110 */ + 0xd6, /* 11010110 */ + 0xd6, /* 11010110 */ + 0xfe, /* 11111110 */ + 0x6c, /* 01101100 */ + 0x00, /* 00000000 */ + + /* + * 120 0x78 'x' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xc6, /* 11000110 */ + 0x6c, /* 01101100 */ + 0x38, /* 00111000 */ + 0x6c, /* 01101100 */ + 0xc6, /* 11000110 */ + 0x00, /* 00000000 */ + + /* + * 121 0x79 'y' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x7e, /* 01111110 */ + 0x06, /* 00000110 */ + 0xfc, /* 11111100 */ + + /* + * 122 0x7a 'z' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x7e, /* 01111110 */ + 0x4c, /* 01001100 */ + 0x18, /* 00011000 */ + 0x32, /* 00110010 */ + 0x7e, /* 01111110 */ + 0x00, /* 00000000 */ + + /* + * 123 0x7b '{' + */ + 0x0e, /* 00001110 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x70, /* 01110000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x0e, /* 00001110 */ + 0x00, /* 00000000 */ + + /* + * 124 0x7c '|' + */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + + /* + * 125 0x7d '}' + */ + 0x70, /* 01110000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x0e, /* 00001110 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x70, /* 01110000 */ + 0x00, /* 00000000 */ + + /* + * 126 0x7e '~' + */ + 0x76, /* 01110110 */ + 0xdc, /* 11011100 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 127 0x7f '' + */ + 0x00, /* 00000000 */ + 0x10, /* 00010000 */ + 0x38, /* 00111000 */ + 0x6c, /* 01101100 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xfe, /* 11111110 */ + 0x00, /* 00000000 */ + + /* + * 128 0x80 '€' + */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xc0, /* 11000000 */ + 0xc0, /* 11000000 */ + 0xc6, /* 11000110 */ + 0x7c, /* 01111100 */ + 0x0c, /* 00001100 */ + 0x78, /* 01111000 */ + + /* + * 129 0x81 '' + */ + 0xcc, /* 11001100 */ + 0x00, /* 00000000 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0x76, /* 01110110 */ + 0x00, /* 00000000 */ + + /* + * 130 0x82 '‚' + */ + 0x0c, /* 00001100 */ + 0x18, /* 00011000 */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xfe, /* 11111110 */ + 0xc0, /* 11000000 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* + * 131 0x83 'ƒ' + */ + 0x7c, /* 01111100 */ + 0x82, /* 10000010 */ + 0x78, /* 01111000 */ + 0x0c, /* 00001100 */ + 0x7c, /* 01111100 */ + 0xcc, /* 11001100 */ + 0x76, /* 01110110 */ + 0x00, /* 00000000 */ + + /* + * 132 0x84 '„' + */ + 0xc6, /* 11000110 */ + 0x00, /* 00000000 */ + 0x78, /* 01111000 */ + 0x0c, /* 00001100 */ + 0x7c, /* 01111100 */ + 0xcc, /* 11001100 */ + 0x76, /* 01110110 */ + 0x00, /* 00000000 */ + + /* + * 133 0x85 '…' + */ + 0x30, /* 00110000 */ + 0x18, /* 00011000 */ + 0x78, /* 01111000 */ + 0x0c, /* 00001100 */ + 0x7c, /* 01111100 */ + 0xcc, /* 11001100 */ + 0x76, /* 01110110 */ + 0x00, /* 00000000 */ + + /* + * 134 0x86 '†' + */ + 0x30, /* 00110000 */ + 0x30, /* 00110000 */ + 0x78, /* 01111000 */ + 0x0c, /* 00001100 */ + 0x7c, /* 01111100 */ + 0xcc, /* 11001100 */ + 0x76, /* 01110110 */ + 0x00, /* 00000000 */ + + /* + * 135 0x87 '‡' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x7e, /* 01111110 */ + 0xc0, /* 11000000 */ + 0xc0, /* 11000000 */ + 0x7e, /* 01111110 */ + 0x0c, /* 00001100 */ + 0x38, /* 00111000 */ + + /* + * 136 0x88 'ˆ' + */ + 0x7c, /* 01111100 */ + 0x82, /* 10000010 */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xfe, /* 11111110 */ + 0xc0, /* 11000000 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* + * 137 0x89 '‰' + */ + 0xc6, /* 11000110 */ + 0x00, /* 00000000 */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xfe, /* 11111110 */ + 0xc0, /* 11000000 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* + * 138 0x8a 'Š' + */ + 0x30, /* 00110000 */ + 0x18, /* 00011000 */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xfe, /* 11111110 */ + 0xc0, /* 11000000 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* + * 139 0x8b '‹' + */ + 0x66, /* 01100110 */ + 0x00, /* 00000000 */ + 0x38, /* 00111000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x3c, /* 00111100 */ + 0x00, /* 00000000 */ + + /* + * 140 0x8c 'Œ' + */ + 0x7c, /* 01111100 */ + 0x82, /* 10000010 */ + 0x38, /* 00111000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x3c, /* 00111100 */ + 0x00, /* 00000000 */ + + /* + * 141 0x8d '' + */ + 0x30, /* 00110000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x38, /* 00111000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x3c, /* 00111100 */ + 0x00, /* 00000000 */ + + /* + * 142 0x8e 'Ž' + */ + 0xc6, /* 11000110 */ + 0x38, /* 00111000 */ + 0x6c, /* 01101100 */ + 0xc6, /* 11000110 */ + 0xfe, /* 11111110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x00, /* 00000000 */ + + /* + * 143 0x8f '' + */ + 0x38, /* 00111000 */ + 0x6c, /* 01101100 */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xfe, /* 11111110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x00, /* 00000000 */ + + /* + * 144 0x90 '' + */ + 0x18, /* 00011000 */ + 0x30, /* 00110000 */ + 0xfe, /* 11111110 */ + 0xc0, /* 11000000 */ + 0xf8, /* 11111000 */ + 0xc0, /* 11000000 */ + 0xfe, /* 11111110 */ + 0x00, /* 00000000 */ + + /* + * 145 0x91 '‘' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x7e, /* 01111110 */ + 0x18, /* 00011000 */ + 0x7e, /* 01111110 */ + 0xd8, /* 11011000 */ + 0x7e, /* 01111110 */ + 0x00, /* 00000000 */ + + /* + * 146 0x92 '’' + */ + 0x3e, /* 00111110 */ + 0x6c, /* 01101100 */ + 0xcc, /* 11001100 */ + 0xfe, /* 11111110 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0xce, /* 11001110 */ + 0x00, /* 00000000 */ + + /* + * 147 0x93 '“' + */ + 0x7c, /* 01111100 */ + 0x82, /* 10000010 */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* + * 148 0x94 '”' + */ + 0xc6, /* 11000110 */ + 0x00, /* 00000000 */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* + * 149 0x95 '•' + */ + 0x30, /* 00110000 */ + 0x18, /* 00011000 */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* + * 150 0x96 '–' + */ + 0x78, /* 01111000 */ + 0x84, /* 10000100 */ + 0x00, /* 00000000 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0x76, /* 01110110 */ + 0x00, /* 00000000 */ + + /* + * 151 0x97 '—' + */ + 0x60, /* 01100000 */ + 0x30, /* 00110000 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0x76, /* 01110110 */ + 0x00, /* 00000000 */ + + /* + * 152 0x98 '˜' + */ + 0xc6, /* 11000110 */ + 0x00, /* 00000000 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x7e, /* 01111110 */ + 0x06, /* 00000110 */ + 0xfc, /* 11111100 */ + + /* + * 153 0x99 '™' + */ + 0xc6, /* 11000110 */ + 0x38, /* 00111000 */ + 0x6c, /* 01101100 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x6c, /* 01101100 */ + 0x38, /* 00111000 */ + 0x00, /* 00000000 */ + + /* + * 154 0x9a 'š' + */ + 0xc6, /* 11000110 */ + 0x00, /* 00000000 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* + * 155 0x9b '›' + */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x7e, /* 01111110 */ + 0xc0, /* 11000000 */ + 0xc0, /* 11000000 */ + 0x7e, /* 01111110 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + + /* + * 156 0x9c 'œ' + */ + 0x38, /* 00111000 */ + 0x6c, /* 01101100 */ + 0x64, /* 01100100 */ + 0xf0, /* 11110000 */ + 0x60, /* 01100000 */ + 0x66, /* 01100110 */ + 0xfc, /* 11111100 */ + 0x00, /* 00000000 */ + + /* + * 157 0x9d '' + */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x3c, /* 00111100 */ + 0x7e, /* 01111110 */ + 0x18, /* 00011000 */ + 0x7e, /* 01111110 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + + /* + * 158 0x9e 'ž' + */ + 0xf8, /* 11111000 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0xfa, /* 11111010 */ + 0xc6, /* 11000110 */ + 0xcf, /* 11001111 */ + 0xc6, /* 11000110 */ + 0xc7, /* 11000111 */ + + /* + * 159 0x9f 'Ÿ' + */ + 0x0e, /* 00001110 */ + 0x1b, /* 00011011 */ + 0x18, /* 00011000 */ + 0x3c, /* 00111100 */ + 0x18, /* 00011000 */ + 0xd8, /* 11011000 */ + 0x70, /* 01110000 */ + 0x00, /* 00000000 */ + + /* + * 160 0xa0 ' ' + */ + 0x18, /* 00011000 */ + 0x30, /* 00110000 */ + 0x78, /* 01111000 */ + 0x0c, /* 00001100 */ + 0x7c, /* 01111100 */ + 0xcc, /* 11001100 */ + 0x76, /* 01110110 */ + 0x00, /* 00000000 */ + + /* + * 161 0xa1 '¡' + */ + 0x0c, /* 00001100 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x38, /* 00111000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x3c, /* 00111100 */ + 0x00, /* 00000000 */ + + /* + * 162 0xa2 '¢' + */ + 0x0c, /* 00001100 */ + 0x18, /* 00011000 */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* + * 163 0xa3 '£' + */ + 0x18, /* 00011000 */ + 0x30, /* 00110000 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0x76, /* 01110110 */ + 0x00, /* 00000000 */ + + /* + * 164 0xa4 '¤' + */ + 0x76, /* 01110110 */ + 0xdc, /* 11011100 */ + 0x00, /* 00000000 */ + 0xdc, /* 11011100 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x00, /* 00000000 */ + + /* + * 165 0xa5 '¥' + */ + 0x76, /* 01110110 */ + 0xdc, /* 11011100 */ + 0x00, /* 00000000 */ + 0xe6, /* 11100110 */ + 0xf6, /* 11110110 */ + 0xde, /* 11011110 */ + 0xce, /* 11001110 */ + 0x00, /* 00000000 */ + + /* + * 166 0xa6 '¦' + */ + 0x3c, /* 00111100 */ + 0x6c, /* 01101100 */ + 0x6c, /* 01101100 */ + 0x3e, /* 00111110 */ + 0x00, /* 00000000 */ + 0x7e, /* 01111110 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 167 0xa7 '§' + */ + 0x38, /* 00111000 */ + 0x6c, /* 01101100 */ + 0x6c, /* 01101100 */ + 0x38, /* 00111000 */ + 0x00, /* 00000000 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 168 0xa8 '¨' + */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x30, /* 00110000 */ + 0x63, /* 01100011 */ + 0x3e, /* 00111110 */ + 0x00, /* 00000000 */ + + /* + * 169 0xa9 '©' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xfe, /* 11111110 */ + 0xc0, /* 11000000 */ + 0xc0, /* 11000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 170 0xaa 'ª' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xfe, /* 11111110 */ + 0x06, /* 00000110 */ + 0x06, /* 00000110 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 171 0xab '«' + */ + 0x63, /* 01100011 */ + 0xe6, /* 11100110 */ + 0x6c, /* 01101100 */ + 0x7e, /* 01111110 */ + 0x33, /* 00110011 */ + 0x66, /* 01100110 */ + 0xcc, /* 11001100 */ + 0x0f, /* 00001111 */ + + /* + * 172 0xac '¬' + */ + 0x63, /* 01100011 */ + 0xe6, /* 11100110 */ + 0x6c, /* 01101100 */ + 0x7a, /* 01111010 */ + 0x36, /* 00110110 */ + 0x6a, /* 01101010 */ + 0xdf, /* 11011111 */ + 0x06, /* 00000110 */ + + /* + * 173 0xad '­' + */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x3c, /* 00111100 */ + 0x3c, /* 00111100 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + + /* + * 174 0xae '®' + */ + 0x00, /* 00000000 */ + 0x33, /* 00110011 */ + 0x66, /* 01100110 */ + 0xcc, /* 11001100 */ + 0x66, /* 01100110 */ + 0x33, /* 00110011 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 175 0xaf '¯' + */ + 0x00, /* 00000000 */ + 0xcc, /* 11001100 */ + 0x66, /* 01100110 */ + 0x33, /* 00110011 */ + 0x66, /* 01100110 */ + 0xcc, /* 11001100 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 176 0xb0 '°' + */ + 0x22, /* 00100010 */ + 0x88, /* 10001000 */ + 0x22, /* 00100010 */ + 0x88, /* 10001000 */ + 0x22, /* 00100010 */ + 0x88, /* 10001000 */ + 0x22, /* 00100010 */ + 0x88, /* 10001000 */ + + /* + * 177 0xb1 '±' + */ + 0x55, /* 01010101 */ + 0xaa, /* 10101010 */ + 0x55, /* 01010101 */ + 0xaa, /* 10101010 */ + 0x55, /* 01010101 */ + 0xaa, /* 10101010 */ + 0x55, /* 01010101 */ + 0xaa, /* 10101010 */ + + /* + * 178 0xb2 '²' + */ + 0x77, /* 01110111 */ + 0xdd, /* 11011101 */ + 0x77, /* 01110111 */ + 0xdd, /* 11011101 */ + 0x77, /* 01110111 */ + 0xdd, /* 11011101 */ + 0x77, /* 01110111 */ + 0xdd, /* 11011101 */ + + /* + * 179 0xb3 '³' + */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + + /* + * 180 0xb4 '´' + */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0xf8, /* 11111000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + + /* + * 181 0xb5 'µ' + */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0xf8, /* 11111000 */ + 0x18, /* 00011000 */ + 0xf8, /* 11111000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + + /* + * 182 0xb6 '¶' + */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0xf6, /* 11110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + + /* + * 183 0xb7 '·' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xfe, /* 11111110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + + /* + * 184 0xb8 '¸' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xf8, /* 11111000 */ + 0x18, /* 00011000 */ + 0xf8, /* 11111000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + + /* + * 185 0xb9 '¹' + */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0xf6, /* 11110110 */ + 0x06, /* 00000110 */ + 0xf6, /* 11110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + + /* + * 186 0xba 'º' + */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + + /* + * 187 0xbb '»' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xfe, /* 11111110 */ + 0x06, /* 00000110 */ + 0xf6, /* 11110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + + /* + * 188 0xbc '¼' + */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0xf6, /* 11110110 */ + 0x06, /* 00000110 */ + 0xfe, /* 11111110 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 189 0xbd '½' + */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0xfe, /* 11111110 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 190 0xbe '¾' + */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0xf8, /* 11111000 */ + 0x18, /* 00011000 */ + 0xf8, /* 11111000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 191 0xbf '¿' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xf8, /* 11111000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + + /* + * 192 0xc0 'À' + */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x1f, /* 00011111 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 193 0xc1 'Á' + */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0xff, /* 11111111 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 194 0xc2 'Â' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xff, /* 11111111 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + + /* + * 195 0xc3 'Ã' + */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x1f, /* 00011111 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + + /* + * 196 0xc4 'Ä' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xff, /* 11111111 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 197 0xc5 'Å' + */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0xff, /* 11111111 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + + /* + * 198 0xc6 'Æ' + */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x1f, /* 00011111 */ + 0x18, /* 00011000 */ + 0x1f, /* 00011111 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + + /* + * 199 0xc7 'Ç' + */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x37, /* 00110111 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + + /* + * 200 0xc8 'È' + */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x37, /* 00110111 */ + 0x30, /* 00110000 */ + 0x3f, /* 00111111 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 201 0xc9 'É' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x3f, /* 00111111 */ + 0x30, /* 00110000 */ + 0x37, /* 00110111 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + + /* + * 202 0xca 'Ê' + */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0xf7, /* 11110111 */ + 0x00, /* 00000000 */ + 0xff, /* 11111111 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 203 0xcb 'Ë' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xff, /* 11111111 */ + 0x00, /* 00000000 */ + 0xf7, /* 11110111 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + + /* + * 204 0xcc 'Ì' + */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x37, /* 00110111 */ + 0x30, /* 00110000 */ + 0x37, /* 00110111 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + + /* + * 205 0xcd 'Í' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xff, /* 11111111 */ + 0x00, /* 00000000 */ + 0xff, /* 11111111 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 206 0xce 'Î' + */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0xf7, /* 11110111 */ + 0x00, /* 00000000 */ + 0xf7, /* 11110111 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + + /* + * 207 0xcf 'Ï' + */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0xff, /* 11111111 */ + 0x00, /* 00000000 */ + 0xff, /* 11111111 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 208 0xd0 'Ð' + */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0xff, /* 11111111 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 209 0xd1 'Ñ' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xff, /* 11111111 */ + 0x00, /* 00000000 */ + 0xff, /* 11111111 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + + /* + * 210 0xd2 'Ò' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xff, /* 11111111 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + + /* + * 211 0xd3 'Ó' + */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x3f, /* 00111111 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 212 0xd4 'Ô' + */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x1f, /* 00011111 */ + 0x18, /* 00011000 */ + 0x1f, /* 00011111 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 213 0xd5 'Õ' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x1f, /* 00011111 */ + 0x18, /* 00011000 */ + 0x1f, /* 00011111 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + + /* + * 214 0xd6 'Ö' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x3f, /* 00111111 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + + /* + * 215 0xd7 '×' + */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0xff, /* 11111111 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + + /* + * 216 0xd8 'Ø' + */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0xff, /* 11111111 */ + 0x18, /* 00011000 */ + 0xff, /* 11111111 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + + /* + * 217 0xd9 'Ù' + */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0xf8, /* 11111000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 218 0xda 'Ú' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x1f, /* 00011111 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + + /* + * 219 0xdb 'Û' + */ + 0xff, /* 11111111 */ + 0xff, /* 11111111 */ + 0xff, /* 11111111 */ + 0xff, /* 11111111 */ + 0xff, /* 11111111 */ + 0xff, /* 11111111 */ + 0xff, /* 11111111 */ + 0xff, /* 11111111 */ + + /* + * 220 0xdc 'Ü' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xff, /* 11111111 */ + 0xff, /* 11111111 */ + 0xff, /* 11111111 */ + 0xff, /* 11111111 */ + + /* + * 221 0xdd 'Ý' + */ + 0xf0, /* 11110000 */ + 0xf0, /* 11110000 */ + 0xf0, /* 11110000 */ + 0xf0, /* 11110000 */ + 0xf0, /* 11110000 */ + 0xf0, /* 11110000 */ + 0xf0, /* 11110000 */ + 0xf0, /* 11110000 */ + + /* + * 222 0xde 'Þ' + */ + 0x0f, /* 00001111 */ + 0x0f, /* 00001111 */ + 0x0f, /* 00001111 */ + 0x0f, /* 00001111 */ + 0x0f, /* 00001111 */ + 0x0f, /* 00001111 */ + 0x0f, /* 00001111 */ + 0x0f, /* 00001111 */ + + /* + * 223 0xdf 'ß' + */ + 0xff, /* 11111111 */ + 0xff, /* 11111111 */ + 0xff, /* 11111111 */ + 0xff, /* 11111111 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 224 0xe0 'à' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x76, /* 01110110 */ + 0xdc, /* 11011100 */ + 0xc8, /* 11001000 */ + 0xdc, /* 11011100 */ + 0x76, /* 01110110 */ + 0x00, /* 00000000 */ + + /* + * 225 0xe1 'á' + */ + 0x78, /* 01111000 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0xd8, /* 11011000 */ + 0xcc, /* 11001100 */ + 0xc6, /* 11000110 */ + 0xcc, /* 11001100 */ + 0x00, /* 00000000 */ + + /* + * 226 0xe2 'â' + */ + 0xfe, /* 11111110 */ + 0xc6, /* 11000110 */ + 0xc0, /* 11000000 */ + 0xc0, /* 11000000 */ + 0xc0, /* 11000000 */ + 0xc0, /* 11000000 */ + 0xc0, /* 11000000 */ + 0x00, /* 00000000 */ + + /* + * 227 0xe3 'ã' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xfe, /* 11111110 */ + 0x6c, /* 01101100 */ + 0x6c, /* 01101100 */ + 0x6c, /* 01101100 */ + 0x6c, /* 01101100 */ + 0x00, /* 00000000 */ + + /* + * 228 0xe4 'ä' + */ + 0xfe, /* 11111110 */ + 0xc6, /* 11000110 */ + 0x60, /* 01100000 */ + 0x30, /* 00110000 */ + 0x60, /* 01100000 */ + 0xc6, /* 11000110 */ + 0xfe, /* 11111110 */ + 0x00, /* 00000000 */ + + /* + * 229 0xe5 'å' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x7e, /* 01111110 */ + 0xd8, /* 11011000 */ + 0xd8, /* 11011000 */ + 0xd8, /* 11011000 */ + 0x70, /* 01110000 */ + 0x00, /* 00000000 */ + + /* + * 230 0xe6 'æ' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x7c, /* 01111100 */ + 0xc0, /* 11000000 */ + + /* + * 231 0xe7 'ç' + */ + 0x00, /* 00000000 */ + 0x76, /* 01110110 */ + 0xdc, /* 11011100 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + + /* + * 232 0xe8 'è' + */ + 0x7e, /* 01111110 */ + 0x18, /* 00011000 */ + 0x3c, /* 00111100 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x3c, /* 00111100 */ + 0x18, /* 00011000 */ + 0x7e, /* 01111110 */ + + /* + * 233 0xe9 'é' + */ + 0x38, /* 00111000 */ + 0x6c, /* 01101100 */ + 0xc6, /* 11000110 */ + 0xfe, /* 11111110 */ + 0xc6, /* 11000110 */ + 0x6c, /* 01101100 */ + 0x38, /* 00111000 */ + 0x00, /* 00000000 */ + + /* + * 234 0xea 'ê' + */ + 0x38, /* 00111000 */ + 0x6c, /* 01101100 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x6c, /* 01101100 */ + 0x6c, /* 01101100 */ + 0xee, /* 11101110 */ + 0x00, /* 00000000 */ + + /* + * 235 0xeb 'ë' + */ + 0x0e, /* 00001110 */ + 0x18, /* 00011000 */ + 0x0c, /* 00001100 */ + 0x3e, /* 00111110 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x3c, /* 00111100 */ + 0x00, /* 00000000 */ + + /* + * 236 0xec 'ì' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x7e, /* 01111110 */ + 0xdb, /* 11011011 */ + 0xdb, /* 11011011 */ + 0x7e, /* 01111110 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 237 0xed 'í' + */ + 0x06, /* 00000110 */ + 0x0c, /* 00001100 */ + 0x7e, /* 01111110 */ + 0xdb, /* 11011011 */ + 0xdb, /* 11011011 */ + 0x7e, /* 01111110 */ + 0x60, /* 01100000 */ + 0xc0, /* 11000000 */ + + /* + * 238 0xee 'î' + */ + 0x1e, /* 00011110 */ + 0x30, /* 00110000 */ + 0x60, /* 01100000 */ + 0x7e, /* 01111110 */ + 0x60, /* 01100000 */ + 0x30, /* 00110000 */ + 0x1e, /* 00011110 */ + 0x00, /* 00000000 */ + + /* + * 239 0xef 'ï' + */ + 0x00, /* 00000000 */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x00, /* 00000000 */ + + /* + * 240 0xf0 'ð' + */ + 0x00, /* 00000000 */ + 0xfe, /* 11111110 */ + 0x00, /* 00000000 */ + 0xfe, /* 11111110 */ + 0x00, /* 00000000 */ + 0xfe, /* 11111110 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 241 0xf1 'ñ' + */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x7e, /* 01111110 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x7e, /* 01111110 */ + 0x00, /* 00000000 */ + + /* + * 242 0xf2 'ò' + */ + 0x30, /* 00110000 */ + 0x18, /* 00011000 */ + 0x0c, /* 00001100 */ + 0x18, /* 00011000 */ + 0x30, /* 00110000 */ + 0x00, /* 00000000 */ + 0x7e, /* 01111110 */ + 0x00, /* 00000000 */ + + /* + * 243 0xf3 'ó' + */ + 0x0c, /* 00001100 */ + 0x18, /* 00011000 */ + 0x30, /* 00110000 */ + 0x18, /* 00011000 */ + 0x0c, /* 00001100 */ + 0x00, /* 00000000 */ + 0x7e, /* 01111110 */ + 0x00, /* 00000000 */ + + /* + * 244 0xf4 'ô' + */ + 0x0e, /* 00001110 */ + 0x1b, /* 00011011 */ + 0x1b, /* 00011011 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + + /* + * 245 0xf5 'õ' + */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0xd8, /* 11011000 */ + 0xd8, /* 11011000 */ + 0x70, /* 01110000 */ + + /* + * 246 0xf6 'ö' + */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x7e, /* 01111110 */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 247 0xf7 '÷' + */ + 0x00, /* 00000000 */ + 0x76, /* 01110110 */ + 0xdc, /* 11011100 */ + 0x00, /* 00000000 */ + 0x76, /* 01110110 */ + 0xdc, /* 11011100 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 248 0xf8 'ø' + */ + 0x38, /* 00111000 */ + 0x6c, /* 01101100 */ + 0x6c, /* 01101100 */ + 0x38, /* 00111000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 249 0xf9 'ù' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 250 0xfa 'ú' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 251 0xfb 'û' + */ + 0x0f, /* 00001111 */ + 0x0c, /* 00001100 */ + 0x0c, /* 00001100 */ + 0x0c, /* 00001100 */ + 0xec, /* 11101100 */ + 0x6c, /* 01101100 */ + 0x3c, /* 00111100 */ + 0x1c, /* 00011100 */ + + /* + * 252 0xfc 'ü' + */ + 0x6c, /* 01101100 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 253 0xfd 'ý' + */ + 0x78, /* 01111000 */ + 0x0c, /* 00001100 */ + 0x18, /* 00011000 */ + 0x30, /* 00110000 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 254 0xfe 'þ' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x3c, /* 00111100 */ + 0x3c, /* 00111100 */ + 0x3c, /* 00111100 */ + 0x3c, /* 00111100 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 255 0xff ' ' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ }; @@ -3116,123 +3116,123 @@ static SDL_Texture *SDLTest_CharTextureCache[256]; int SDLTest_DrawCharacter(SDL_Renderer *renderer, int x, int y, char c) { - const Uint32 charWidth = 8; - const Uint32 charHeight = 8; - const Uint32 charSize = 8; - SDL_Rect srect; - SDL_Rect drect; - int result; - Uint32 ix, iy; - const unsigned char *charpos; - Uint8 *curpos; - Uint8 patt, mask; - Uint8 *linepos; - Uint32 pitch; - SDL_Surface *character; - Uint32 ci; - Uint8 r, g, b, a; - - /* - * Setup source rectangle - */ - srect.x = 0; - srect.y = 0; - srect.w = charWidth; - srect.h = charHeight; - - /* - * Setup destination rectangle - */ - drect.x = x; - drect.y = y; - drect.w = charWidth; - drect.h = charHeight; - - /* Character index in cache */ - ci = (unsigned char)c; - - /* - * Create new charWidth x charHeight bitmap surface if not already present. - */ - if (SDLTest_CharTextureCache[ci] == NULL) { - /* - * Redraw character into surface - */ - character = SDL_CreateRGBSurface(SDL_SWSURFACE, - charWidth, charHeight, 32, - 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF); - if (character == NULL) { - return (-1); - } - - charpos = SDLTest_FontData + ci * charSize; - linepos = (Uint8 *)character->pixels; - pitch = character->pitch; - - /* - * Drawing loop - */ - patt = 0; - for (iy = 0; iy < charWidth; iy++) { - mask = 0x00; - curpos = linepos; - for (ix = 0; ix < charWidth; ix++) { - if (!(mask >>= 1)) { - patt = *charpos++; - mask = 0x80; - } - if (patt & mask) { - *(Uint32 *)curpos = 0xffffffff; - } else { - *(Uint32 *)curpos = 0; - } - curpos += 4; - } - linepos += pitch; - } - - /* Convert temp surface into texture */ - SDLTest_CharTextureCache[ci] = SDL_CreateTextureFromSurface(renderer, character); - SDL_FreeSurface(character); - - /* - * Check pointer - */ - if (SDLTest_CharTextureCache[ci] == NULL) { - return (-1); - } - } - - /* - * Set color - */ - result = 0; - result |= SDL_GetRenderDrawColor(renderer, &r, &g, &b, &a); - result |= SDL_SetTextureColorMod(SDLTest_CharTextureCache[ci], r, g, b); - result |= SDL_SetTextureAlphaMod(SDLTest_CharTextureCache[ci], a); - - /* - * Draw texture onto destination - */ - result |= SDL_RenderCopy(renderer, SDLTest_CharTextureCache[ci], &srect, &drect); - - return (result); + const Uint32 charWidth = 8; + const Uint32 charHeight = 8; + const Uint32 charSize = 8; + SDL_Rect srect; + SDL_Rect drect; + int result; + Uint32 ix, iy; + const unsigned char *charpos; + Uint8 *curpos; + Uint8 patt, mask; + Uint8 *linepos; + Uint32 pitch; + SDL_Surface *character; + Uint32 ci; + Uint8 r, g, b, a; + + /* + * Setup source rectangle + */ + srect.x = 0; + srect.y = 0; + srect.w = charWidth; + srect.h = charHeight; + + /* + * Setup destination rectangle + */ + drect.x = x; + drect.y = y; + drect.w = charWidth; + drect.h = charHeight; + + /* Character index in cache */ + ci = (unsigned char)c; + + /* + * Create new charWidth x charHeight bitmap surface if not already present. + */ + if (SDLTest_CharTextureCache[ci] == NULL) { + /* + * Redraw character into surface + */ + character = SDL_CreateRGBSurface(SDL_SWSURFACE, + charWidth, charHeight, 32, + 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF); + if (character == NULL) { + return (-1); + } + + charpos = SDLTest_FontData + ci * charSize; + linepos = (Uint8 *)character->pixels; + pitch = character->pitch; + + /* + * Drawing loop + */ + patt = 0; + for (iy = 0; iy < charWidth; iy++) { + mask = 0x00; + curpos = linepos; + for (ix = 0; ix < charWidth; ix++) { + if (!(mask >>= 1)) { + patt = *charpos++; + mask = 0x80; + } + if (patt & mask) { + *(Uint32 *)curpos = 0xffffffff; + } else { + *(Uint32 *)curpos = 0; + } + curpos += 4; + } + linepos += pitch; + } + + /* Convert temp surface into texture */ + SDLTest_CharTextureCache[ci] = SDL_CreateTextureFromSurface(renderer, character); + SDL_FreeSurface(character); + + /* + * Check pointer + */ + if (SDLTest_CharTextureCache[ci] == NULL) { + return (-1); + } + } + + /* + * Set color + */ + result = 0; + result |= SDL_GetRenderDrawColor(renderer, &r, &g, &b, &a); + result |= SDL_SetTextureColorMod(SDLTest_CharTextureCache[ci], r, g, b); + result |= SDL_SetTextureAlphaMod(SDLTest_CharTextureCache[ci], a); + + /* + * Draw texture onto destination + */ + result |= SDL_RenderCopy(renderer, SDLTest_CharTextureCache[ci], &srect, &drect); + + return (result); } int SDLTest_DrawString(SDL_Renderer * renderer, int x, int y, const char *s) { - const Uint32 charWidth = 8; - int result = 0; - int curx = x; - int cury = y; - const char *curchar = s; - - while (*curchar && !result) { - result |= SDLTest_DrawCharacter(renderer, curx, cury, *curchar); - curx += charWidth; - curchar++; - } - - return (result); + const Uint32 charWidth = 8; + int result = 0; + int curx = x; + int cury = y; + const char *curchar = s; + + while (*curchar && !result) { + result |= SDLTest_DrawCharacter(renderer, curx, cury, *curchar); + curx += charWidth; + curchar++; + } + + return (result); } diff --git a/src/test/SDL_test_fuzzer.c b/src/test/SDL_test_fuzzer.c index dcbace68c..8a27fd011 100644 --- a/src/test/SDL_test_fuzzer.c +++ b/src/test/SDL_test_fuzzer.c @@ -19,10 +19,10 @@ 3. This notice may not be removed or altered from any source distribution. */ -/* +/* Data generators for fuzzing test data in a reproducible way. - + */ #include "SDL_config.h" @@ -43,7 +43,7 @@ #include "SDL_test.h" -/** +/** * Counter for fuzzer invocations */ static int fuzzerInvocationCounter = 0; @@ -60,93 +60,93 @@ static SDLTest_RandomContext rndContext; void SDLTest_FuzzerInit(Uint64 execKey) { - Uint32 a = (execKey >> 32) & 0x00000000FFFFFFFF; - Uint32 b = execKey & 0x00000000FFFFFFFF; - SDL_memset((void *)&rndContext, 0, sizeof(SDLTest_RandomContext)); - SDLTest_RandomInit(&rndContext, a, b); - fuzzerInvocationCounter = 0; + Uint32 a = (execKey >> 32) & 0x00000000FFFFFFFF; + Uint32 b = execKey & 0x00000000FFFFFFFF; + SDL_memset((void *)&rndContext, 0, sizeof(SDLTest_RandomContext)); + SDLTest_RandomInit(&rndContext, a, b); + fuzzerInvocationCounter = 0; } int SDLTest_GetFuzzerInvocationCount() { - return fuzzerInvocationCounter; + return fuzzerInvocationCounter; } Uint8 SDLTest_RandomUint8() { - fuzzerInvocationCounter++; + fuzzerInvocationCounter++; - return (Uint8) SDLTest_RandomInt(&rndContext) & 0x000000FF; + return (Uint8) SDLTest_RandomInt(&rndContext) & 0x000000FF; } Sint8 SDLTest_RandomSint8() { - fuzzerInvocationCounter++; + fuzzerInvocationCounter++; - return (Sint8) SDLTest_RandomInt(&rndContext) & 0x000000FF; + return (Sint8) SDLTest_RandomInt(&rndContext) & 0x000000FF; } Uint16 SDLTest_RandomUint16() { - fuzzerInvocationCounter++; + fuzzerInvocationCounter++; - return (Uint16) SDLTest_RandomInt(&rndContext) & 0x0000FFFF; + return (Uint16) SDLTest_RandomInt(&rndContext) & 0x0000FFFF; } Sint16 SDLTest_RandomSint16() { - fuzzerInvocationCounter++; + fuzzerInvocationCounter++; - return (Sint16) SDLTest_RandomInt(&rndContext) & 0x0000FFFF; + return (Sint16) SDLTest_RandomInt(&rndContext) & 0x0000FFFF; } Sint32 SDLTest_RandomSint32() { - fuzzerInvocationCounter++; + fuzzerInvocationCounter++; - return (Sint32) SDLTest_RandomInt(&rndContext); + return (Sint32) SDLTest_RandomInt(&rndContext); } Uint32 SDLTest_RandomUint32() { - fuzzerInvocationCounter++; + fuzzerInvocationCounter++; - return (Uint32) SDLTest_RandomInt(&rndContext); + return (Uint32) SDLTest_RandomInt(&rndContext); } Uint64 SDLTest_RandomUint64() { - Uint64 value = 0; - Uint32 *vp = (void *)&value; + Uint64 value = 0; + Uint32 *vp = (void *)&value; - fuzzerInvocationCounter++; + fuzzerInvocationCounter++; - vp[0] = SDLTest_RandomSint32(); - vp[1] = SDLTest_RandomSint32(); + vp[0] = SDLTest_RandomSint32(); + vp[1] = SDLTest_RandomSint32(); - return value; + return value; } Sint64 SDLTest_RandomSint64() { - Uint64 value = 0; - Uint32 *vp = (void *)&value; + Uint64 value = 0; + Uint32 *vp = (void *)&value; - fuzzerInvocationCounter++; + fuzzerInvocationCounter++; - vp[0] = SDLTest_RandomSint32(); - vp[1] = SDLTest_RandomSint32(); + vp[0] = SDLTest_RandomSint32(); + vp[1] = SDLTest_RandomSint32(); - return value; + return value; } @@ -154,23 +154,23 @@ SDLTest_RandomSint64() Sint32 SDLTest_RandomIntegerInRange(Sint32 pMin, Sint32 pMax) { - Sint64 min = pMin; - Sint64 max = pMax; - Sint64 temp; - Sint64 number; - - if(pMin > pMax) { - temp = min; - min = max; - max = temp; - } else if(pMin == pMax) { - return (Sint32)min; - } - - number = SDLTest_RandomUint32(); - /* invocation count increment in preceeding call */ - - return (Sint32)((number % ((max + 1) - min)) + min); + Sint64 min = pMin; + Sint64 max = pMax; + Sint64 temp; + Sint64 number; + + if(pMin > pMax) { + temp = min; + min = max; + max = temp; + } else if(pMin == pMax) { + return (Sint32)min; + } + + number = SDLTest_RandomUint32(); + /* invocation count increment in preceeding call */ + + return (Sint32)((number % ((max + 1) - min)) + min); } /*! @@ -189,7 +189,7 @@ SDLTest_RandomIntegerInRange(Sint32 pMin, Sint32 pMax) * Generator works the same for other types of unsigned integers. * * \param maxValue The biggest value that is acceptable for this data type. - * For instance, for Uint8 -> 255, Uint16 -> 65536 etc. + * For instance, for Uint8 -> 255, Uint16 -> 65536 etc. * \param boundary1 defines lower boundary * \param boundary2 defines upper boundary * \param validDomain Generate only for valid domain (for the data type) @@ -200,107 +200,107 @@ Uint64 SDLTest_GenerateUnsignedBoundaryValues(const Uint64 maxValue, Uint64 boundary1, Uint64 boundary2, SDL_bool validDomain) { Uint64 b1, b2; - Uint64 delta; - Uint64 tempBuf[4]; - Uint8 index; - + Uint64 delta; + Uint64 tempBuf[4]; + Uint8 index; + /* Maybe swap */ - if (boundary1 > boundary2) { - b1 = boundary2; - b2 = boundary1; - } else { - b1 = boundary1; - b2 = boundary2; + if (boundary1 > boundary2) { + b1 = boundary2; + b2 = boundary1; + } else { + b1 = boundary1; + b2 = boundary2; } - index = 0; - if (validDomain == SDL_TRUE) { - if (b1 == b2) { - return b1; - } - - /* Generate up to 4 values within bounds */ - delta = b2 - b1; - if (delta < 4) { - do { - tempBuf[index] = b1 + index; - index++; + index = 0; + if (validDomain == SDL_TRUE) { + if (b1 == b2) { + return b1; + } + + /* Generate up to 4 values within bounds */ + delta = b2 - b1; + if (delta < 4) { + do { + tempBuf[index] = b1 + index; + index++; } while (index < delta); - } else { - tempBuf[index] = b1; - index++; - tempBuf[index] = b1 + 1; - index++; - tempBuf[index] = b2 - 1; - index++; - tempBuf[index] = b2; - index++; - } - } else { - /* Generate up to 2 values outside of bounds */ - if (b1 > 0) { - tempBuf[index] = b1 - 1; - index++; - } - - if (b2 < maxValue) { - tempBuf[index] = b2 + 1; - index++; - } - } - - if (index == 0) { - /* There are no valid boundaries */ - SDL_Unsupported(); - return 0; - } - - return tempBuf[SDLTest_RandomUint8() % index]; + } else { + tempBuf[index] = b1; + index++; + tempBuf[index] = b1 + 1; + index++; + tempBuf[index] = b2 - 1; + index++; + tempBuf[index] = b2; + index++; + } + } else { + /* Generate up to 2 values outside of bounds */ + if (b1 > 0) { + tempBuf[index] = b1 - 1; + index++; + } + + if (b2 < maxValue) { + tempBuf[index] = b2 + 1; + index++; + } + } + + if (index == 0) { + /* There are no valid boundaries */ + SDL_Unsupported(); + return 0; + } + + return tempBuf[SDLTest_RandomUint8() % index]; } Uint8 SDLTest_RandomUint8BoundaryValue(Uint8 boundary1, Uint8 boundary2, SDL_bool validDomain) { - /* max value for Uint8 */ - const Uint64 maxValue = UCHAR_MAX; - return (Uint8)SDLTest_GenerateUnsignedBoundaryValues(maxValue, - (Uint64) boundary1, (Uint64) boundary2, - validDomain); + /* max value for Uint8 */ + const Uint64 maxValue = UCHAR_MAX; + return (Uint8)SDLTest_GenerateUnsignedBoundaryValues(maxValue, + (Uint64) boundary1, (Uint64) boundary2, + validDomain); } Uint16 SDLTest_RandomUint16BoundaryValue(Uint16 boundary1, Uint16 boundary2, SDL_bool validDomain) { - /* max value for Uint16 */ - const Uint64 maxValue = USHRT_MAX; - return (Uint16)SDLTest_GenerateUnsignedBoundaryValues(maxValue, - (Uint64) boundary1, (Uint64) boundary2, - validDomain); + /* max value for Uint16 */ + const Uint64 maxValue = USHRT_MAX; + return (Uint16)SDLTest_GenerateUnsignedBoundaryValues(maxValue, + (Uint64) boundary1, (Uint64) boundary2, + validDomain); } Uint32 SDLTest_RandomUint32BoundaryValue(Uint32 boundary1, Uint32 boundary2, SDL_bool validDomain) { - /* max value for Uint32 */ - #if ((ULONG_MAX) == (UINT_MAX)) - const Uint64 maxValue = ULONG_MAX; + /* max value for Uint32 */ + #if ((ULONG_MAX) == (UINT_MAX)) + const Uint64 maxValue = ULONG_MAX; #else - const Uint64 maxValue = UINT_MAX; + const Uint64 maxValue = UINT_MAX; #endif - return (Uint32)SDLTest_GenerateUnsignedBoundaryValues(maxValue, - (Uint64) boundary1, (Uint64) boundary2, - validDomain); + return (Uint32)SDLTest_GenerateUnsignedBoundaryValues(maxValue, + (Uint64) boundary1, (Uint64) boundary2, + validDomain); } Uint64 SDLTest_RandomUint64BoundaryValue(Uint64 boundary1, Uint64 boundary2, SDL_bool validDomain) { - /* max value for Uint64 */ - const Uint64 maxValue = ULLONG_MAX; - return SDLTest_GenerateUnsignedBoundaryValues(maxValue, - (Uint64) boundary1, (Uint64) boundary2, - validDomain); + /* max value for Uint64 */ + const Uint64 maxValue = ULLONG_MAX; + return SDLTest_GenerateUnsignedBoundaryValues(maxValue, + (Uint64) boundary1, (Uint64) boundary2, + validDomain); } /*! @@ -319,9 +319,9 @@ SDLTest_RandomUint64BoundaryValue(Uint64 boundary1, Uint64 boundary2, SDL_bool v * Generator works the same for other types of signed integers. * * \param minValue The smallest value that is acceptable for this data type. - * For instance, for Uint8 -> -127, etc. + * For instance, for Uint8 -> -127, etc. * \param maxValue The biggest value that is acceptable for this data type. - * For instance, for Uint8 -> 127, etc. + * For instance, for Uint8 -> 127, etc. * \param boundary1 defines lower boundary * \param boundary2 defines upper boundary * \param validDomain Generate only for valid domain (for the data type) @@ -332,118 +332,118 @@ Sint64 SDLTest_GenerateSignedBoundaryValues(const Sint64 minValue, const Sint64 maxValue, Sint64 boundary1, Sint64 boundary2, SDL_bool validDomain) { Sint64 b1, b2; - Sint64 delta; - Sint64 tempBuf[4]; - Uint8 index; - + Sint64 delta; + Sint64 tempBuf[4]; + Uint8 index; + /* Maybe swap */ - if (boundary1 > boundary2) { - b1 = boundary2; - b2 = boundary1; - } else { - b1 = boundary1; - b2 = boundary2; + if (boundary1 > boundary2) { + b1 = boundary2; + b2 = boundary1; + } else { + b1 = boundary1; + b2 = boundary2; } - index = 0; - if (validDomain == SDL_TRUE) { - if (b1 == b2) { - return b1; - } - - /* Generate up to 4 values within bounds */ - delta = b2 - b1; - if (delta < 4) { - do { - tempBuf[index] = b1 + index; - index++; + index = 0; + if (validDomain == SDL_TRUE) { + if (b1 == b2) { + return b1; + } + + /* Generate up to 4 values within bounds */ + delta = b2 - b1; + if (delta < 4) { + do { + tempBuf[index] = b1 + index; + index++; } while (index < delta); - } else { - tempBuf[index] = b1; - index++; - tempBuf[index] = b1 + 1; - index++; - tempBuf[index] = b2 - 1; - index++; - tempBuf[index] = b2; - index++; - } - } else { - /* Generate up to 2 values outside of bounds */ - if (b1 > minValue) { - tempBuf[index] = b1 - 1; - index++; - } - - if (b2 < maxValue) { - tempBuf[index] = b2 + 1; - index++; - } - } - - if (index == 0) { - /* There are no valid boundaries */ - SDL_Unsupported(); - return minValue; - } - - return tempBuf[SDLTest_RandomUint8() % index]; + } else { + tempBuf[index] = b1; + index++; + tempBuf[index] = b1 + 1; + index++; + tempBuf[index] = b2 - 1; + index++; + tempBuf[index] = b2; + index++; + } + } else { + /* Generate up to 2 values outside of bounds */ + if (b1 > minValue) { + tempBuf[index] = b1 - 1; + index++; + } + + if (b2 < maxValue) { + tempBuf[index] = b2 + 1; + index++; + } + } + + if (index == 0) { + /* There are no valid boundaries */ + SDL_Unsupported(); + return minValue; + } + + return tempBuf[SDLTest_RandomUint8() % index]; } Sint8 SDLTest_RandomSint8BoundaryValue(Sint8 boundary1, Sint8 boundary2, SDL_bool validDomain) { - /* min & max values for Sint8 */ - const Sint64 maxValue = SCHAR_MAX; - const Sint64 minValue = SCHAR_MIN; - return (Sint8)SDLTest_GenerateSignedBoundaryValues(minValue, maxValue, - (Sint64) boundary1, (Sint64) boundary2, - validDomain); + /* min & max values for Sint8 */ + const Sint64 maxValue = SCHAR_MAX; + const Sint64 minValue = SCHAR_MIN; + return (Sint8)SDLTest_GenerateSignedBoundaryValues(minValue, maxValue, + (Sint64) boundary1, (Sint64) boundary2, + validDomain); } Sint16 SDLTest_RandomSint16BoundaryValue(Sint16 boundary1, Sint16 boundary2, SDL_bool validDomain) { - /* min & max values for Sint16 */ - const Sint64 maxValue = SHRT_MAX; - const Sint64 minValue = SHRT_MIN; - return (Sint16)SDLTest_GenerateSignedBoundaryValues(minValue, maxValue, - (Sint64) boundary1, (Sint64) boundary2, - validDomain); + /* min & max values for Sint16 */ + const Sint64 maxValue = SHRT_MAX; + const Sint64 minValue = SHRT_MIN; + return (Sint16)SDLTest_GenerateSignedBoundaryValues(minValue, maxValue, + (Sint64) boundary1, (Sint64) boundary2, + validDomain); } Sint32 SDLTest_RandomSint32BoundaryValue(Sint32 boundary1, Sint32 boundary2, SDL_bool validDomain) { - /* min & max values for Sint32 */ - #if ((ULONG_MAX) == (UINT_MAX)) - const Sint64 maxValue = LONG_MAX; - const Sint64 minValue = LONG_MIN; + /* min & max values for Sint32 */ + #if ((ULONG_MAX) == (UINT_MAX)) + const Sint64 maxValue = LONG_MAX; + const Sint64 minValue = LONG_MIN; #else - const Sint64 maxValue = INT_MAX; - const Sint64 minValue = INT_MIN; + const Sint64 maxValue = INT_MAX; + const Sint64 minValue = INT_MIN; #endif - return (Sint32)SDLTest_GenerateSignedBoundaryValues(minValue, maxValue, - (Sint64) boundary1, (Sint64) boundary2, - validDomain); + return (Sint32)SDLTest_GenerateSignedBoundaryValues(minValue, maxValue, + (Sint64) boundary1, (Sint64) boundary2, + validDomain); } Sint64 SDLTest_RandomSint64BoundaryValue(Sint64 boundary1, Sint64 boundary2, SDL_bool validDomain) { - /* min & max values for Sint64 */ - const Sint64 maxValue = LLONG_MAX; - const Sint64 minValue = LLONG_MIN; - return SDLTest_GenerateSignedBoundaryValues(minValue, maxValue, - boundary1, boundary2, - validDomain); + /* min & max values for Sint64 */ + const Sint64 maxValue = LLONG_MAX; + const Sint64 minValue = LLONG_MIN; + return SDLTest_GenerateSignedBoundaryValues(minValue, maxValue, + boundary1, boundary2, + validDomain); } float SDLTest_RandomUnitFloat() { - return (float) SDLTest_RandomUint32() / UINT_MAX; + return (float) SDLTest_RandomUint32() / UINT_MAX; } float @@ -455,70 +455,70 @@ SDLTest_RandomFloat() double SDLTest_RandomUnitDouble() { - return (double) (SDLTest_RandomUint64() >> 11) * (1.0/9007199254740992.0); + return (double) (SDLTest_RandomUint64() >> 11) * (1.0/9007199254740992.0); } double SDLTest_RandomDouble() { - double r = 0.0; - double s = 1.0; - do { - s /= UINT_MAX + 1.0; - r += (double)SDLTest_RandomInt(&rndContext) * s; - } while (s > DBL_EPSILON); - - fuzzerInvocationCounter++; - - return r; + double r = 0.0; + double s = 1.0; + do { + s /= UINT_MAX + 1.0; + r += (double)SDLTest_RandomInt(&rndContext) * s; + } while (s > DBL_EPSILON); + + fuzzerInvocationCounter++; + + return r; } char * SDLTest_RandomAsciiString() { - return SDLTest_RandomAsciiStringWithMaximumLength(255); + return SDLTest_RandomAsciiStringWithMaximumLength(255); } char * SDLTest_RandomAsciiStringWithMaximumLength(int maxLength) { - int size; + int size; - if(maxLength < 1) { + if(maxLength < 1) { SDL_InvalidParamError("maxLength"); - return NULL; - } + return NULL; + } + + size = (SDLTest_RandomUint32() % (maxLength + 1)); - size = (SDLTest_RandomUint32() % (maxLength + 1)); - - return SDLTest_RandomAsciiStringOfSize(size); + return SDLTest_RandomAsciiStringOfSize(size); } char * SDLTest_RandomAsciiStringOfSize(int size) { - char *string; - int counter; + char *string; + int counter; - if(size < 1) { + if(size < 1) { SDL_InvalidParamError("size"); - return NULL; - } + return NULL; + } - string = (char *)SDL_malloc((size + 1) * sizeof(char)); - if (string==NULL) { - return NULL; + string = (char *)SDL_malloc((size + 1) * sizeof(char)); + if (string==NULL) { + return NULL; } - for(counter = 0; counter < size; ++counter) { - string[counter] = (char)SDLTest_RandomIntegerInRange(32, 126); - } + for(counter = 0; counter < size; ++counter) { + string[counter] = (char)SDLTest_RandomIntegerInRange(32, 126); + } - string[counter] = '\0'; + string[counter] = '\0'; - fuzzerInvocationCounter++; + fuzzerInvocationCounter++; - return string; + return string; } diff --git a/src/test/SDL_test_harness.c b/src/test/SDL_test_harness.c index d3c0266cf..291874566 100644 --- a/src/test/SDL_test_harness.c +++ b/src/test/SDL_test_harness.c @@ -53,45 +53,45 @@ static Uint32 SDLTest_TestCaseTimeout = 3600; char * SDLTest_GenerateRunSeed(const int length) { - char *seed = NULL; - SDLTest_RandomContext randomContext; - int counter; - - /* Sanity check input */ - if (length <= 0) { - SDLTest_LogError("The length of the harness seed must be >0."); - return NULL; - } - - /* Allocate output buffer */ - seed = (char *)SDL_malloc((length + 1) * sizeof(char)); - if (seed == NULL) { - SDLTest_LogError("SDL_malloc for run seed output buffer failed."); - return NULL; - } - - /* Generate a random string of alphanumeric characters */ - SDLTest_RandomInitTime(&randomContext); - for (counter = 0; counter < length - 1; ++counter) { - unsigned int number = SDLTest_Random(&randomContext); - char ch = (char) (number % (91 - 48)) + 48; - if (ch >= 58 && ch <= 64) { - ch = 65; - } - seed[counter] = ch; - } - seed[counter] = '\0'; - - return seed; + char *seed = NULL; + SDLTest_RandomContext randomContext; + int counter; + + /* Sanity check input */ + if (length <= 0) { + SDLTest_LogError("The length of the harness seed must be >0."); + return NULL; + } + + /* Allocate output buffer */ + seed = (char *)SDL_malloc((length + 1) * sizeof(char)); + if (seed == NULL) { + SDLTest_LogError("SDL_malloc for run seed output buffer failed."); + return NULL; + } + + /* Generate a random string of alphanumeric characters */ + SDLTest_RandomInitTime(&randomContext); + for (counter = 0; counter < length - 1; ++counter) { + unsigned int number = SDLTest_Random(&randomContext); + char ch = (char) (number % (91 - 48)) + 48; + if (ch >= 58 && ch <= 64) { + ch = 65; + } + seed[counter] = ch; + } + seed[counter] = '\0'; + + return seed; } /** * Generates an execution key for the fuzzer. * -* \param runSeed The run seed to use -* \param suiteName The name of the test suite -* \param testName The name of the test -* \param iteration The iteration count +* \param runSeed The run seed to use +* \param suiteName The name of the test suite +* \param testName The name of the test +* \param iteration The iteration count * * \returns The generated execution key to initialize the fuzzer with. * @@ -99,61 +99,61 @@ SDLTest_GenerateRunSeed(const int length) Uint64 SDLTest_GenerateExecKey(char *runSeed, char *suiteName, char *testName, int iteration) { - SDLTest_Md5Context md5Context; - Uint64 *keys; - char iterationString[16]; - Uint32 runSeedLength; - Uint32 suiteNameLength; - Uint32 testNameLength; - Uint32 iterationStringLength; - Uint32 entireStringLength; - char *buffer; - - if (runSeed == NULL || SDL_strlen(runSeed)==0) { - SDLTest_LogError("Invalid runSeed string."); - return -1; - } - - if (suiteName == NULL || SDL_strlen(suiteName)==0) { - SDLTest_LogError("Invalid suiteName string."); - return -1; - } - - if (testName == NULL || SDL_strlen(testName)==0) { - SDLTest_LogError("Invalid testName string."); - return -1; - } - - if (iteration <= 0) { - SDLTest_LogError("Invalid iteration count."); - return -1; - } - - /* Convert iteration number into a string */ - SDL_memset(iterationString, 0, sizeof(iterationString)); - SDL_snprintf(iterationString, sizeof(iterationString) - 1, "%d", iteration); - - /* Combine the parameters into single string */ - runSeedLength = SDL_strlen(runSeed); - suiteNameLength = SDL_strlen(suiteName); - testNameLength = SDL_strlen(testName); - iterationStringLength = SDL_strlen(iterationString); - entireStringLength = runSeedLength + suiteNameLength + testNameLength + iterationStringLength + 1; - buffer = (char *)SDL_malloc(entireStringLength); - if (buffer == NULL) { - SDLTest_LogError("SDL_malloc failed to allocate buffer for execKey generation."); - return 0; - } - SDL_snprintf(buffer, entireStringLength, "%s%s%s%d", runSeed, suiteName, testName, iteration); - - /* Hash string and use half of the digest as 64bit exec key */ - SDLTest_Md5Init(&md5Context); - SDLTest_Md5Update(&md5Context, (unsigned char *)buffer, entireStringLength); - SDLTest_Md5Final(&md5Context); - SDL_free(buffer); - keys = (Uint64 *)md5Context.digest; - - return keys[0]; + SDLTest_Md5Context md5Context; + Uint64 *keys; + char iterationString[16]; + Uint32 runSeedLength; + Uint32 suiteNameLength; + Uint32 testNameLength; + Uint32 iterationStringLength; + Uint32 entireStringLength; + char *buffer; + + if (runSeed == NULL || SDL_strlen(runSeed)==0) { + SDLTest_LogError("Invalid runSeed string."); + return -1; + } + + if (suiteName == NULL || SDL_strlen(suiteName)==0) { + SDLTest_LogError("Invalid suiteName string."); + return -1; + } + + if (testName == NULL || SDL_strlen(testName)==0) { + SDLTest_LogError("Invalid testName string."); + return -1; + } + + if (iteration <= 0) { + SDLTest_LogError("Invalid iteration count."); + return -1; + } + + /* Convert iteration number into a string */ + SDL_memset(iterationString, 0, sizeof(iterationString)); + SDL_snprintf(iterationString, sizeof(iterationString) - 1, "%d", iteration); + + /* Combine the parameters into single string */ + runSeedLength = SDL_strlen(runSeed); + suiteNameLength = SDL_strlen(suiteName); + testNameLength = SDL_strlen(testName); + iterationStringLength = SDL_strlen(iterationString); + entireStringLength = runSeedLength + suiteNameLength + testNameLength + iterationStringLength + 1; + buffer = (char *)SDL_malloc(entireStringLength); + if (buffer == NULL) { + SDLTest_LogError("SDL_malloc failed to allocate buffer for execKey generation."); + return 0; + } + SDL_snprintf(buffer, entireStringLength, "%s%s%s%d", runSeed, suiteName, testName, iteration); + + /* Hash string and use half of the digest as 64bit exec key */ + SDLTest_Md5Init(&md5Context); + SDLTest_Md5Update(&md5Context, (unsigned char *)buffer, entireStringLength); + SDLTest_Md5Final(&md5Context); + SDL_free(buffer); + keys = (Uint64 *)md5Context.digest; + + return keys[0]; } /** @@ -163,52 +163,52 @@ SDLTest_GenerateExecKey(char *runSeed, char *suiteName, char *testName, int iter * * \param timeout Timeout interval in seconds. * \param callback Function that will be called after timeout has elapsed. -* +* * \return Timer id or -1 on failure. */ SDL_TimerID SDLTest_SetTestTimeout(int timeout, void (*callback)()) { - Uint32 timeoutInMilliseconds; - SDL_TimerID timerID; - - if (callback == NULL) { - SDLTest_LogError("Timeout callback can't be NULL"); - return -1; - } - - if (timeout < 0) { - SDLTest_LogError("Timeout value must be bigger than zero."); - return -1; - } - - /* Init SDL timer if not initialized before */ - if (SDL_WasInit(SDL_INIT_TIMER) == 0) { - if (SDL_InitSubSystem(SDL_INIT_TIMER)) { - SDLTest_LogError("Failed to init timer subsystem: %s", SDL_GetError()); - return -1; - } - } - - /* Set timer */ - timeoutInMilliseconds = timeout * 1000; - timerID = SDL_AddTimer(timeoutInMilliseconds, (SDL_TimerCallback)callback, 0x0); - if (timerID == 0) { - SDLTest_LogError("Creation of SDL timer failed: %s", SDL_GetError()); - return -1; - } - - return timerID; + Uint32 timeoutInMilliseconds; + SDL_TimerID timerID; + + if (callback == NULL) { + SDLTest_LogError("Timeout callback can't be NULL"); + return -1; + } + + if (timeout < 0) { + SDLTest_LogError("Timeout value must be bigger than zero."); + return -1; + } + + /* Init SDL timer if not initialized before */ + if (SDL_WasInit(SDL_INIT_TIMER) == 0) { + if (SDL_InitSubSystem(SDL_INIT_TIMER)) { + SDLTest_LogError("Failed to init timer subsystem: %s", SDL_GetError()); + return -1; + } + } + + /* Set timer */ + timeoutInMilliseconds = timeout * 1000; + timerID = SDL_AddTimer(timeoutInMilliseconds, (SDL_TimerCallback)callback, 0x0); + if (timerID == 0) { + SDLTest_LogError("Creation of SDL timer failed: %s", SDL_GetError()); + return -1; + } + + return timerID; } /** * \brief Timeout handler. Aborts test run and exits harness process. */ void - SDLTest_BailOut() + SDLTest_BailOut() { - SDLTest_LogError("TestCaseTimeout timer expired. Aborting test run."); - exit(TEST_ABORTED); /* bail out from the test */ + SDLTest_LogError("TestCaseTimeout timer expired. Aborting test run."); + exit(TEST_ABORTED); /* bail out from the test */ } /** @@ -223,127 +223,127 @@ void int SDLTest_RunTest(SDLTest_TestSuiteReference *testSuite, SDLTest_TestCaseReference *testCase, Uint64 execKey) { - SDL_TimerID timer = 0; - int testCaseResult = 0; - int testResult = 0; - int fuzzerCount; - - if (testSuite==NULL || testCase==NULL || testSuite->name==NULL || testCase->name==NULL) - { - SDLTest_LogError("Setup failure: testSuite or testCase references NULL"); - return TEST_RESULT_SETUP_FAILURE; - } - - if (!testCase->enabled) - { - SDLTest_Log((char *)SDLTest_FinalResultFormat, "Test", testCase->name, "Skipped (Disabled)"); - return TEST_RESULT_SKIPPED; - } - - - /* Initialize fuzzer */ - SDLTest_FuzzerInit(execKey); - - /* Reset assert tracker */ - SDLTest_ResetAssertSummary(); - - /* Set timeout timer */ - timer = SDLTest_SetTestTimeout(SDLTest_TestCaseTimeout, SDLTest_BailOut); - - /* Maybe run suite initalizer function */ - if (testSuite->testSetUp) { - testSuite->testSetUp(0x0); - if (SDLTest_AssertSummaryToTestResult() == TEST_RESULT_FAILED) { - SDLTest_LogError((char *)SDLTest_FinalResultFormat, "Suite Setup", testSuite->name, "Failed"); - return TEST_RESULT_SETUP_FAILURE; - } - } - - /* Run test case function */ - testCaseResult = testCase->testCase(0x0); - - /* Convert test execution result into harness result */ - if (testCaseResult == TEST_SKIPPED) { - /* Test was programatically skipped */ - testResult = TEST_RESULT_SKIPPED; - } else if (testCaseResult == TEST_STARTED) { - /* Test did not return a TEST_COMPLETED value; assume it failed */ - testResult = TEST_RESULT_FAILED; - } else if (testCaseResult == TEST_ABORTED) { - /* Test was aborted early; assume it failed */ - testResult = TEST_RESULT_FAILED; - } else { - /* Perform failure analysis based on asserts */ - testResult = SDLTest_AssertSummaryToTestResult(); - } - - /* Maybe run suite cleanup function (ignore failed asserts) */ - if (testSuite->testTearDown) { - testSuite->testTearDown(0x0); - } - - /* Cancel timeout timer */ - if (timer) { - SDL_RemoveTimer(timer); - } - - /* Report on asserts and fuzzer usage */ - fuzzerCount = SDLTest_GetFuzzerInvocationCount(); - if (fuzzerCount > 0) { - SDLTest_Log("Fuzzer invocations: %d", fuzzerCount); - } - - /* Final log based on test execution result */ - if (testCaseResult == TEST_SKIPPED) { - /* Test was programatically skipped */ - SDLTest_Log((char *)SDLTest_FinalResultFormat, "Test", testCase->name, "Skipped (Programmatically)"); - } else if (testCaseResult == TEST_STARTED) { - /* Test did not return a TEST_COMPLETED value; assume it failed */ - SDLTest_LogError((char *)SDLTest_FinalResultFormat, "Test", testCase->name, "Failed (test started, but did not return TEST_COMPLETED)"); - } else if (testCaseResult == TEST_ABORTED) { - /* Test was aborted early; assume it failed */ - SDLTest_LogError((char *)SDLTest_FinalResultFormat, "Test", testCase->name, "Failed (Aborted)"); - } else { - SDLTest_LogAssertSummary(); - } - - return testResult; + SDL_TimerID timer = 0; + int testCaseResult = 0; + int testResult = 0; + int fuzzerCount; + + if (testSuite==NULL || testCase==NULL || testSuite->name==NULL || testCase->name==NULL) + { + SDLTest_LogError("Setup failure: testSuite or testCase references NULL"); + return TEST_RESULT_SETUP_FAILURE; + } + + if (!testCase->enabled) + { + SDLTest_Log((char *)SDLTest_FinalResultFormat, "Test", testCase->name, "Skipped (Disabled)"); + return TEST_RESULT_SKIPPED; + } + + + /* Initialize fuzzer */ + SDLTest_FuzzerInit(execKey); + + /* Reset assert tracker */ + SDLTest_ResetAssertSummary(); + + /* Set timeout timer */ + timer = SDLTest_SetTestTimeout(SDLTest_TestCaseTimeout, SDLTest_BailOut); + + /* Maybe run suite initalizer function */ + if (testSuite->testSetUp) { + testSuite->testSetUp(0x0); + if (SDLTest_AssertSummaryToTestResult() == TEST_RESULT_FAILED) { + SDLTest_LogError((char *)SDLTest_FinalResultFormat, "Suite Setup", testSuite->name, "Failed"); + return TEST_RESULT_SETUP_FAILURE; + } + } + + /* Run test case function */ + testCaseResult = testCase->testCase(0x0); + + /* Convert test execution result into harness result */ + if (testCaseResult == TEST_SKIPPED) { + /* Test was programatically skipped */ + testResult = TEST_RESULT_SKIPPED; + } else if (testCaseResult == TEST_STARTED) { + /* Test did not return a TEST_COMPLETED value; assume it failed */ + testResult = TEST_RESULT_FAILED; + } else if (testCaseResult == TEST_ABORTED) { + /* Test was aborted early; assume it failed */ + testResult = TEST_RESULT_FAILED; + } else { + /* Perform failure analysis based on asserts */ + testResult = SDLTest_AssertSummaryToTestResult(); + } + + /* Maybe run suite cleanup function (ignore failed asserts) */ + if (testSuite->testTearDown) { + testSuite->testTearDown(0x0); + } + + /* Cancel timeout timer */ + if (timer) { + SDL_RemoveTimer(timer); + } + + /* Report on asserts and fuzzer usage */ + fuzzerCount = SDLTest_GetFuzzerInvocationCount(); + if (fuzzerCount > 0) { + SDLTest_Log("Fuzzer invocations: %d", fuzzerCount); + } + + /* Final log based on test execution result */ + if (testCaseResult == TEST_SKIPPED) { + /* Test was programatically skipped */ + SDLTest_Log((char *)SDLTest_FinalResultFormat, "Test", testCase->name, "Skipped (Programmatically)"); + } else if (testCaseResult == TEST_STARTED) { + /* Test did not return a TEST_COMPLETED value; assume it failed */ + SDLTest_LogError((char *)SDLTest_FinalResultFormat, "Test", testCase->name, "Failed (test started, but did not return TEST_COMPLETED)"); + } else if (testCaseResult == TEST_ABORTED) { + /* Test was aborted early; assume it failed */ + SDLTest_LogError((char *)SDLTest_FinalResultFormat, "Test", testCase->name, "Failed (Aborted)"); + } else { + SDLTest_LogAssertSummary(); + } + + return testResult; } /* Prints summary of all suites/tests contained in the given reference */ void SDLTest_LogTestSuiteSummary(SDLTest_TestSuiteReference *testSuites) { - int suiteCounter; - int testCounter; - SDLTest_TestSuiteReference *testSuite; - SDLTest_TestCaseReference *testCase; - - /* Loop over all suites */ - suiteCounter = 0; - while(&testSuites[suiteCounter]) { - testSuite=&testSuites[suiteCounter]; - suiteCounter++; - SDLTest_Log("Test Suite %i - %s\n", suiteCounter, - (testSuite->name) ? testSuite->name : SDLTest_InvalidNameFormat); - - /* Loop over all test cases */ - testCounter = 0; - while(testSuite->testCases[testCounter]) - { - testCase=(SDLTest_TestCaseReference *)testSuite->testCases[testCounter]; - testCounter++; - SDLTest_Log(" Test Case %i - %s: %s", testCounter, - (testCase->name) ? testCase->name : SDLTest_InvalidNameFormat, - (testCase->description) ? testCase->description : SDLTest_InvalidNameFormat); - } - } + int suiteCounter; + int testCounter; + SDLTest_TestSuiteReference *testSuite; + SDLTest_TestCaseReference *testCase; + + /* Loop over all suites */ + suiteCounter = 0; + while(&testSuites[suiteCounter]) { + testSuite=&testSuites[suiteCounter]; + suiteCounter++; + SDLTest_Log("Test Suite %i - %s\n", suiteCounter, + (testSuite->name) ? testSuite->name : SDLTest_InvalidNameFormat); + + /* Loop over all test cases */ + testCounter = 0; + while(testSuite->testCases[testCounter]) + { + testCase=(SDLTest_TestCaseReference *)testSuite->testCases[testCounter]; + testCounter++; + SDLTest_Log(" Test Case %i - %s: %s", testCounter, + (testCase->name) ? testCase->name : SDLTest_InvalidNameFormat, + (testCase->description) ? testCase->description : SDLTest_InvalidNameFormat); + } + } } /* Gets a timer value in seconds */ float GetClock() { - float currentClock = (float)clock(); - return currentClock / (float)CLOCKS_PER_SEC; + float currentClock = (float)clock(); + return currentClock / (float)CLOCKS_PER_SEC; } /** @@ -362,274 +362,274 @@ float GetClock() */ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *userRunSeed, Uint64 userExecKey, const char *filter, int testIterations) { - int suiteCounter; - int testCounter; - int iterationCounter; - SDLTest_TestSuiteReference *testSuite; - SDLTest_TestCaseReference *testCase; - const char *runSeed = NULL; - char *currentSuiteName; - char *currentTestName; - Uint64 execKey; - float runStartSeconds; - float suiteStartSeconds; - float testStartSeconds; - float runEndSeconds; - float suiteEndSeconds; - float testEndSeconds; - float runtime; - int suiteFilter = 0; - char *suiteFilterName = NULL; - int testFilter = 0; - char *testFilterName = NULL; - int testResult = 0; - int runResult = 0; - Uint32 totalTestFailedCount = 0; - Uint32 totalTestPassedCount = 0; - Uint32 totalTestSkippedCount = 0; - Uint32 testFailedCount = 0; - Uint32 testPassedCount = 0; - Uint32 testSkippedCount = 0; - Uint32 countSum = 0; - char *logFormat = (char *)SDLTest_LogSummaryFormat; - - /* Sanitize test iterations */ - if (testIterations < 1) { - testIterations = 1; - } - - /* Generate run see if we don't have one already */ - if (userRunSeed == NULL || SDL_strlen(userRunSeed) == 0) { - runSeed = SDLTest_GenerateRunSeed(16); - if (runSeed == NULL) { - SDLTest_LogError("Generating a random seed failed"); - return 2; - } - } else { - runSeed = userRunSeed; - } - - - /* Reset per-run counters */ - totalTestFailedCount = 0; - totalTestPassedCount = 0; - totalTestSkippedCount = 0; - - /* Take time - run start */ - runStartSeconds = GetClock(); - - /* Log run with fuzzer parameters */ - SDLTest_Log("::::: Test Run /w seed '%s' started\n", runSeed); - - /* Initialize filtering */ - if (filter != NULL && SDL_strlen(filter) > 0) { - /* Loop over all suites to check if we have a filter match */ - suiteCounter = 0; - while (testSuites[suiteCounter] && suiteFilter == 0) { - testSuite=(SDLTest_TestSuiteReference *)testSuites[suiteCounter]; - suiteCounter++; - if (testSuite->name != NULL && SDL_strcmp(filter, testSuite->name) == 0) { - /* Matched a suite name */ - suiteFilter = 1; - suiteFilterName = testSuite->name; - SDLTest_Log("Filtering: running only suite '%s'", suiteFilterName); - break; - } - - /* Within each suite, loop over all test cases to check if we have a filter match */ - testCounter = 0; - while (testSuite->testCases[testCounter] && testFilter == 0) - { - testCase=(SDLTest_TestCaseReference *)testSuite->testCases[testCounter]; - testCounter++; - if (testCase->name != NULL && SDL_strcmp(filter, testCase->name) == 0) { - /* Matched a test name */ - suiteFilter = 1; - suiteFilterName = testSuite->name; - testFilter = 1; - testFilterName = testCase->name; - SDLTest_Log("Filtering: running only test '%s' in suite '%s'", testFilterName, suiteFilterName); - break; - } - } - } - - if (suiteFilter == 0 && testFilter == 0) { - SDLTest_LogError("Filter '%s' did not match any test suite/case.", filter); - SDLTest_Log("Exit code: 2"); - return 2; - } - } - - /* Loop over all suites */ - suiteCounter = 0; - while(testSuites[suiteCounter]) { - testSuite=(SDLTest_TestSuiteReference *)testSuites[suiteCounter]; - currentSuiteName = (char *)((testSuite->name) ? testSuite->name : SDLTest_InvalidNameFormat); - suiteCounter++; - - /* Filter suite if flag set and we have a name */ - if (suiteFilter == 1 && suiteFilterName != NULL && testSuite->name != NULL && - SDL_strcmp(suiteFilterName, testSuite->name) != 0) { - /* Skip suite */ - SDLTest_Log("===== Test Suite %i: '%s' skipped\n", - suiteCounter, - currentSuiteName); - } else { - - /* Reset per-suite counters */ - testFailedCount = 0; - testPassedCount = 0; - testSkippedCount = 0; - - /* Take time - suite start */ - suiteStartSeconds = GetClock(); - - /* Log suite started */ - SDLTest_Log("===== Test Suite %i: '%s' started\n", - suiteCounter, - currentSuiteName); - - /* Loop over all test cases */ - testCounter = 0; - while(testSuite->testCases[testCounter]) - { - testCase=(SDLTest_TestCaseReference *)testSuite->testCases[testCounter]; - currentTestName = (char *)((testCase->name) ? testCase->name : SDLTest_InvalidNameFormat); - testCounter++; - - /* Filter tests if flag set and we have a name */ - if (testFilter == 1 && testFilterName != NULL && testCase->name != NULL && - SDL_strcmp(testFilterName, testCase->name) != 0) { - /* Skip test */ - SDLTest_Log("===== Test Case %i.%i: '%s' skipped\n", - suiteCounter, - testCounter, - currentTestName); - } else { - /* Override 'disabled' flag if we specified a test filter (i.e. force run for debugging) */ - if (testFilter == 1 && !testCase->enabled) { - SDLTest_Log("Force run of disabled test since test filter was set"); - testCase->enabled = 1; - } - - /* Take time - test start */ - testStartSeconds = GetClock(); - - /* Log test started */ - SDLTest_Log("----- Test Case %i.%i: '%s' started", - suiteCounter, - testCounter, - currentTestName); - if (testCase->description != NULL && SDL_strlen(testCase->description)>0) { - SDLTest_Log("Test Description: '%s'", - (testCase->description) ? testCase->description : SDLTest_InvalidNameFormat); - } - - /* Loop over all iterations */ - iterationCounter = 0; - while(iterationCounter < testIterations) - { - iterationCounter++; - - if (userExecKey != 0) { - execKey = userExecKey; - } else { - execKey = SDLTest_GenerateExecKey((char *)runSeed, testSuite->name, testCase->name, iterationCounter); - } - - SDLTest_Log("Test Iteration %i: execKey %llu", iterationCounter, execKey); - testResult = SDLTest_RunTest(testSuite, testCase, execKey); - - if (testResult == TEST_RESULT_PASSED) { - testPassedCount++; - totalTestPassedCount++; - } else if (testResult == TEST_RESULT_SKIPPED) { - testSkippedCount++; - totalTestSkippedCount++; - } else { - testFailedCount++; - totalTestFailedCount++; - } - } - - /* Take time - test end */ - testEndSeconds = GetClock(); - runtime = testEndSeconds - testStartSeconds; - if (runtime < 0.0f) runtime = 0.0f; - - if (testIterations > 1) { - /* Log test runtime */ - SDLTest_Log("Runtime of %i iterations: %.1f sec", testIterations, runtime); - SDLTest_Log("Average Test runtime: %.5f sec", runtime / (float)testIterations); - } else { - /* Log test runtime */ - SDLTest_Log("Total Test runtime: %.1f sec", runtime); - } - - /* Log final test result */ - switch (testResult) { - case TEST_RESULT_PASSED: - SDLTest_Log((char *)SDLTest_FinalResultFormat, "Test", currentTestName, "Passed"); - break; - case TEST_RESULT_FAILED: - SDLTest_LogError((char *)SDLTest_FinalResultFormat, "Test", currentTestName, "Failed"); - break; - case TEST_RESULT_NO_ASSERT: - SDLTest_LogError((char *)SDLTest_FinalResultFormat,"Test", currentTestName, "No Asserts"); - break; - } - - } - } - - /* Take time - suite end */ - suiteEndSeconds = GetClock(); - runtime = suiteEndSeconds - suiteStartSeconds; - if (runtime < 0.0f) runtime = 0.0f; - - /* Log suite runtime */ - SDLTest_Log("Total Suite runtime: %.1f sec", runtime); - - /* Log summary and final Suite result */ - countSum = testPassedCount + testFailedCount + testSkippedCount; - if (testFailedCount == 0) - { - SDLTest_Log(logFormat, "Suite", countSum, testPassedCount, testFailedCount, testSkippedCount); - SDLTest_Log((char *)SDLTest_FinalResultFormat, "Suite", currentSuiteName, "Passed"); - } - else - { - SDLTest_LogError(logFormat, "Suite", countSum, testPassedCount, testFailedCount, testSkippedCount); - SDLTest_LogError((char *)SDLTest_FinalResultFormat, "Suite", currentSuiteName, "Failed"); - } - - } - } - - /* Take time - run end */ - runEndSeconds = GetClock(); - runtime = runEndSeconds - runStartSeconds; - if (runtime < 0.0f) runtime = 0.0f; - - /* Log total runtime */ - SDLTest_Log("Total Run runtime: %.1f sec", runtime); - - /* Log summary and final run result */ - countSum = totalTestPassedCount + totalTestFailedCount + totalTestSkippedCount; - if (totalTestFailedCount == 0) - { - runResult = 0; - SDLTest_Log(logFormat, "Run", countSum, totalTestPassedCount, totalTestFailedCount, totalTestSkippedCount); - SDLTest_Log((char *)SDLTest_FinalResultFormat, "Run /w seed", runSeed, "Passed"); - } - else - { - runResult = 1; - SDLTest_LogError(logFormat, "Run", countSum, totalTestPassedCount, totalTestFailedCount, totalTestSkippedCount); - SDLTest_LogError((char *)SDLTest_FinalResultFormat, "Run /w seed", runSeed, "Failed"); - } - - SDLTest_Log("Exit code: %d", runResult); - return runResult; + int suiteCounter; + int testCounter; + int iterationCounter; + SDLTest_TestSuiteReference *testSuite; + SDLTest_TestCaseReference *testCase; + const char *runSeed = NULL; + char *currentSuiteName; + char *currentTestName; + Uint64 execKey; + float runStartSeconds; + float suiteStartSeconds; + float testStartSeconds; + float runEndSeconds; + float suiteEndSeconds; + float testEndSeconds; + float runtime; + int suiteFilter = 0; + char *suiteFilterName = NULL; + int testFilter = 0; + char *testFilterName = NULL; + int testResult = 0; + int runResult = 0; + Uint32 totalTestFailedCount = 0; + Uint32 totalTestPassedCount = 0; + Uint32 totalTestSkippedCount = 0; + Uint32 testFailedCount = 0; + Uint32 testPassedCount = 0; + Uint32 testSkippedCount = 0; + Uint32 countSum = 0; + char *logFormat = (char *)SDLTest_LogSummaryFormat; + + /* Sanitize test iterations */ + if (testIterations < 1) { + testIterations = 1; + } + + /* Generate run see if we don't have one already */ + if (userRunSeed == NULL || SDL_strlen(userRunSeed) == 0) { + runSeed = SDLTest_GenerateRunSeed(16); + if (runSeed == NULL) { + SDLTest_LogError("Generating a random seed failed"); + return 2; + } + } else { + runSeed = userRunSeed; + } + + + /* Reset per-run counters */ + totalTestFailedCount = 0; + totalTestPassedCount = 0; + totalTestSkippedCount = 0; + + /* Take time - run start */ + runStartSeconds = GetClock(); + + /* Log run with fuzzer parameters */ + SDLTest_Log("::::: Test Run /w seed '%s' started\n", runSeed); + + /* Initialize filtering */ + if (filter != NULL && SDL_strlen(filter) > 0) { + /* Loop over all suites to check if we have a filter match */ + suiteCounter = 0; + while (testSuites[suiteCounter] && suiteFilter == 0) { + testSuite=(SDLTest_TestSuiteReference *)testSuites[suiteCounter]; + suiteCounter++; + if (testSuite->name != NULL && SDL_strcmp(filter, testSuite->name) == 0) { + /* Matched a suite name */ + suiteFilter = 1; + suiteFilterName = testSuite->name; + SDLTest_Log("Filtering: running only suite '%s'", suiteFilterName); + break; + } + + /* Within each suite, loop over all test cases to check if we have a filter match */ + testCounter = 0; + while (testSuite->testCases[testCounter] && testFilter == 0) + { + testCase=(SDLTest_TestCaseReference *)testSuite->testCases[testCounter]; + testCounter++; + if (testCase->name != NULL && SDL_strcmp(filter, testCase->name) == 0) { + /* Matched a test name */ + suiteFilter = 1; + suiteFilterName = testSuite->name; + testFilter = 1; + testFilterName = testCase->name; + SDLTest_Log("Filtering: running only test '%s' in suite '%s'", testFilterName, suiteFilterName); + break; + } + } + } + + if (suiteFilter == 0 && testFilter == 0) { + SDLTest_LogError("Filter '%s' did not match any test suite/case.", filter); + SDLTest_Log("Exit code: 2"); + return 2; + } + } + + /* Loop over all suites */ + suiteCounter = 0; + while(testSuites[suiteCounter]) { + testSuite=(SDLTest_TestSuiteReference *)testSuites[suiteCounter]; + currentSuiteName = (char *)((testSuite->name) ? testSuite->name : SDLTest_InvalidNameFormat); + suiteCounter++; + + /* Filter suite if flag set and we have a name */ + if (suiteFilter == 1 && suiteFilterName != NULL && testSuite->name != NULL && + SDL_strcmp(suiteFilterName, testSuite->name) != 0) { + /* Skip suite */ + SDLTest_Log("===== Test Suite %i: '%s' skipped\n", + suiteCounter, + currentSuiteName); + } else { + + /* Reset per-suite counters */ + testFailedCount = 0; + testPassedCount = 0; + testSkippedCount = 0; + + /* Take time - suite start */ + suiteStartSeconds = GetClock(); + + /* Log suite started */ + SDLTest_Log("===== Test Suite %i: '%s' started\n", + suiteCounter, + currentSuiteName); + + /* Loop over all test cases */ + testCounter = 0; + while(testSuite->testCases[testCounter]) + { + testCase=(SDLTest_TestCaseReference *)testSuite->testCases[testCounter]; + currentTestName = (char *)((testCase->name) ? testCase->name : SDLTest_InvalidNameFormat); + testCounter++; + + /* Filter tests if flag set and we have a name */ + if (testFilter == 1 && testFilterName != NULL && testCase->name != NULL && + SDL_strcmp(testFilterName, testCase->name) != 0) { + /* Skip test */ + SDLTest_Log("===== Test Case %i.%i: '%s' skipped\n", + suiteCounter, + testCounter, + currentTestName); + } else { + /* Override 'disabled' flag if we specified a test filter (i.e. force run for debugging) */ + if (testFilter == 1 && !testCase->enabled) { + SDLTest_Log("Force run of disabled test since test filter was set"); + testCase->enabled = 1; + } + + /* Take time - test start */ + testStartSeconds = GetClock(); + + /* Log test started */ + SDLTest_Log("----- Test Case %i.%i: '%s' started", + suiteCounter, + testCounter, + currentTestName); + if (testCase->description != NULL && SDL_strlen(testCase->description)>0) { + SDLTest_Log("Test Description: '%s'", + (testCase->description) ? testCase->description : SDLTest_InvalidNameFormat); + } + + /* Loop over all iterations */ + iterationCounter = 0; + while(iterationCounter < testIterations) + { + iterationCounter++; + + if (userExecKey != 0) { + execKey = userExecKey; + } else { + execKey = SDLTest_GenerateExecKey((char *)runSeed, testSuite->name, testCase->name, iterationCounter); + } + + SDLTest_Log("Test Iteration %i: execKey %llu", iterationCounter, execKey); + testResult = SDLTest_RunTest(testSuite, testCase, execKey); + + if (testResult == TEST_RESULT_PASSED) { + testPassedCount++; + totalTestPassedCount++; + } else if (testResult == TEST_RESULT_SKIPPED) { + testSkippedCount++; + totalTestSkippedCount++; + } else { + testFailedCount++; + totalTestFailedCount++; + } + } + + /* Take time - test end */ + testEndSeconds = GetClock(); + runtime = testEndSeconds - testStartSeconds; + if (runtime < 0.0f) runtime = 0.0f; + + if (testIterations > 1) { + /* Log test runtime */ + SDLTest_Log("Runtime of %i iterations: %.1f sec", testIterations, runtime); + SDLTest_Log("Average Test runtime: %.5f sec", runtime / (float)testIterations); + } else { + /* Log test runtime */ + SDLTest_Log("Total Test runtime: %.1f sec", runtime); + } + + /* Log final test result */ + switch (testResult) { + case TEST_RESULT_PASSED: + SDLTest_Log((char *)SDLTest_FinalResultFormat, "Test", currentTestName, "Passed"); + break; + case TEST_RESULT_FAILED: + SDLTest_LogError((char *)SDLTest_FinalResultFormat, "Test", currentTestName, "Failed"); + break; + case TEST_RESULT_NO_ASSERT: + SDLTest_LogError((char *)SDLTest_FinalResultFormat,"Test", currentTestName, "No Asserts"); + break; + } + + } + } + + /* Take time - suite end */ + suiteEndSeconds = GetClock(); + runtime = suiteEndSeconds - suiteStartSeconds; + if (runtime < 0.0f) runtime = 0.0f; + + /* Log suite runtime */ + SDLTest_Log("Total Suite runtime: %.1f sec", runtime); + + /* Log summary and final Suite result */ + countSum = testPassedCount + testFailedCount + testSkippedCount; + if (testFailedCount == 0) + { + SDLTest_Log(logFormat, "Suite", countSum, testPassedCount, testFailedCount, testSkippedCount); + SDLTest_Log((char *)SDLTest_FinalResultFormat, "Suite", currentSuiteName, "Passed"); + } + else + { + SDLTest_LogError(logFormat, "Suite", countSum, testPassedCount, testFailedCount, testSkippedCount); + SDLTest_LogError((char *)SDLTest_FinalResultFormat, "Suite", currentSuiteName, "Failed"); + } + + } + } + + /* Take time - run end */ + runEndSeconds = GetClock(); + runtime = runEndSeconds - runStartSeconds; + if (runtime < 0.0f) runtime = 0.0f; + + /* Log total runtime */ + SDLTest_Log("Total Run runtime: %.1f sec", runtime); + + /* Log summary and final run result */ + countSum = totalTestPassedCount + totalTestFailedCount + totalTestSkippedCount; + if (totalTestFailedCount == 0) + { + runResult = 0; + SDLTest_Log(logFormat, "Run", countSum, totalTestPassedCount, totalTestFailedCount, totalTestSkippedCount); + SDLTest_Log((char *)SDLTest_FinalResultFormat, "Run /w seed", runSeed, "Passed"); + } + else + { + runResult = 1; + SDLTest_LogError(logFormat, "Run", countSum, totalTestPassedCount, totalTestFailedCount, totalTestSkippedCount); + SDLTest_LogError((char *)SDLTest_FinalResultFormat, "Run /w seed", runSeed, "Failed"); + } + + SDLTest_Log("Exit code: %d", runResult); + return runResult; } diff --git a/src/test/SDL_test_imageBlit.c b/src/test/SDL_test_imageBlit.c index 2608e4fa8..d1d12952c 100644 --- a/src/test/SDL_test_imageBlit.c +++ b/src/test/SDL_test_imageBlit.c @@ -540,11 +540,11 @@ const SDLTest_SurfaceImage_t SDLTest_imageBlit = { */ SDL_Surface *SDLTest_ImageBlit() { - SDL_Surface *surface = SDL_CreateRGBSurfaceFrom( + SDL_Surface *surface = SDL_CreateRGBSurfaceFrom( (void*)SDLTest_imageBlit.pixel_data, - SDLTest_imageBlit.width, - SDLTest_imageBlit.height, - SDLTest_imageBlit.bytes_per_pixel * 8, + SDLTest_imageBlit.width, + SDLTest_imageBlit.height, + SDLTest_imageBlit.bytes_per_pixel * 8, SDLTest_imageBlit.width * SDLTest_imageBlit.bytes_per_pixel, #if (SDL_BYTEORDER == SDL_BIG_ENDIAN) 0xff000000, /* Red bit mask. */ @@ -1023,11 +1023,11 @@ const SDLTest_SurfaceImage_t SDLTest_imageBlitColor = { */ SDL_Surface *SDLTest_ImageBlitColor() { - SDL_Surface *surface = SDL_CreateRGBSurfaceFrom( + SDL_Surface *surface = SDL_CreateRGBSurfaceFrom( (void*)SDLTest_imageBlitColor.pixel_data, - SDLTest_imageBlitColor.width, - SDLTest_imageBlitColor.height, - SDLTest_imageBlitColor.bytes_per_pixel * 8, + SDLTest_imageBlitColor.width, + SDLTest_imageBlitColor.height, + SDLTest_imageBlitColor.bytes_per_pixel * 8, SDLTest_imageBlitColor.width * SDLTest_imageBlitColor.bytes_per_pixel, #if (SDL_BYTEORDER == SDL_BIG_ENDIAN) 0xff000000, /* Red bit mask. */ @@ -1535,10 +1535,10 @@ const SDLTest_SurfaceImage_t SDLTest_imageBlitAlpha = { */ SDL_Surface *SDLTest_ImageBlitAlpha() { - SDL_Surface *surface = SDL_CreateRGBSurfaceFrom( + SDL_Surface *surface = SDL_CreateRGBSurfaceFrom( (void*)SDLTest_imageBlitAlpha.pixel_data, - SDLTest_imageBlitAlpha.width, - SDLTest_imageBlitAlpha.height, + SDLTest_imageBlitAlpha.width, + SDLTest_imageBlitAlpha.height, SDLTest_imageBlitAlpha.bytes_per_pixel * 8, SDLTest_imageBlitAlpha.width * SDLTest_imageBlitAlpha.bytes_per_pixel, #if (SDL_BYTEORDER == SDL_BIG_ENDIAN) diff --git a/src/test/SDL_test_imageBlitBlend.c b/src/test/SDL_test_imageBlitBlend.c index 8a4859533..06dbfabd4 100644 --- a/src/test/SDL_test_imageBlitBlend.c +++ b/src/test/SDL_test_imageBlitBlend.c @@ -580,11 +580,11 @@ const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendAdd = { */ SDL_Surface *SDLTest_ImageBlitBlendAdd() { - SDL_Surface *surface = SDL_CreateRGBSurfaceFrom( + SDL_Surface *surface = SDL_CreateRGBSurfaceFrom( (void*)SDLTest_imageBlitBlendAdd.pixel_data, - SDLTest_imageBlitBlendAdd.width, - SDLTest_imageBlitBlendAdd.height, - SDLTest_imageBlitBlendAdd.bytes_per_pixel * 8, + SDLTest_imageBlitBlendAdd.width, + SDLTest_imageBlitBlendAdd.height, + SDLTest_imageBlitBlendAdd.bytes_per_pixel * 8, SDLTest_imageBlitBlendAdd.width * SDLTest_imageBlitBlendAdd.bytes_per_pixel, #if (SDL_BYTEORDER == SDL_BIG_ENDIAN) 0xff000000, /* Red bit mask. */ @@ -1110,11 +1110,11 @@ const SDLTest_SurfaceImage_t SDLTest_imageBlitBlend = { */ SDL_Surface *SDLTest_ImageBlitBlend() { - SDL_Surface *surface = SDL_CreateRGBSurfaceFrom( + SDL_Surface *surface = SDL_CreateRGBSurfaceFrom( (void*)SDLTest_imageBlitBlend.pixel_data, - SDLTest_imageBlitBlend.width, - SDLTest_imageBlitBlend.height, - SDLTest_imageBlitBlend.bytes_per_pixel * 8, + SDLTest_imageBlitBlend.width, + SDLTest_imageBlitBlend.height, + SDLTest_imageBlitBlend.bytes_per_pixel * 8, SDLTest_imageBlitBlend.width * SDLTest_imageBlitBlend.bytes_per_pixel, #if (SDL_BYTEORDER == SDL_BIG_ENDIAN) 0xff000000, /* Red bit mask. */ @@ -1540,11 +1540,11 @@ const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendMod = { */ SDL_Surface *SDLTest_ImageBlitBlendMod() { - SDL_Surface *surface = SDL_CreateRGBSurfaceFrom( + SDL_Surface *surface = SDL_CreateRGBSurfaceFrom( (void*)SDLTest_imageBlitBlendMod.pixel_data, - SDLTest_imageBlitBlendMod.width, - SDLTest_imageBlitBlendMod.height, - SDLTest_imageBlitBlendMod.bytes_per_pixel * 8, + SDLTest_imageBlitBlendMod.width, + SDLTest_imageBlitBlendMod.height, + SDLTest_imageBlitBlendMod.bytes_per_pixel * 8, SDLTest_imageBlitBlendMod.width * SDLTest_imageBlitBlendMod.bytes_per_pixel, #if (SDL_BYTEORDER == SDL_BIG_ENDIAN) 0xff000000, /* Red bit mask. */ @@ -2353,11 +2353,11 @@ const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendNone = { */ SDL_Surface *SDLTest_ImageBlitBlendNone() { - SDL_Surface *surface = SDL_CreateRGBSurfaceFrom( + SDL_Surface *surface = SDL_CreateRGBSurfaceFrom( (void*)SDLTest_imageBlitBlendNone.pixel_data, - SDLTest_imageBlitBlendNone.width, - SDLTest_imageBlitBlendNone.height, - SDLTest_imageBlitBlendNone.bytes_per_pixel * 8, + SDLTest_imageBlitBlendNone.width, + SDLTest_imageBlitBlendNone.height, + SDLTest_imageBlitBlendNone.bytes_per_pixel * 8, SDLTest_imageBlitBlendNone.width * SDLTest_imageBlitBlendNone.bytes_per_pixel, #if (SDL_BYTEORDER == SDL_BIG_ENDIAN) 0xff000000, /* Red bit mask. */ @@ -2821,11 +2821,11 @@ const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendAll = { */ SDL_Surface *SDLTest_ImageBlitBlendAll() { - SDL_Surface *surface = SDL_CreateRGBSurfaceFrom( + SDL_Surface *surface = SDL_CreateRGBSurfaceFrom( (void*)SDLTest_imageBlitBlendAll.pixel_data, - SDLTest_imageBlitBlendAll.width, - SDLTest_imageBlitBlendAll.height, - SDLTest_imageBlitBlendAll.bytes_per_pixel * 8, + SDLTest_imageBlitBlendAll.width, + SDLTest_imageBlitBlendAll.height, + SDLTest_imageBlitBlendAll.bytes_per_pixel * 8, SDLTest_imageBlitBlendAll.width * SDLTest_imageBlitBlendAll.bytes_per_pixel, #if (SDL_BYTEORDER == SDL_BIG_ENDIAN) 0xff000000, /* Red bit mask. */ diff --git a/src/test/SDL_test_imageFace.c b/src/test/SDL_test_imageFace.c index 2dd7ea762..46c117a4f 100644 --- a/src/test/SDL_test_imageFace.c +++ b/src/test/SDL_test_imageFace.c @@ -223,11 +223,11 @@ const SDLTest_SurfaceImage_t SDLTest_imageFace = { */ SDL_Surface *SDLTest_ImageFace() { - SDL_Surface *surface = SDL_CreateRGBSurfaceFrom( + SDL_Surface *surface = SDL_CreateRGBSurfaceFrom( (void*)SDLTest_imageFace.pixel_data, - SDLTest_imageFace.width, - SDLTest_imageFace.height, - SDLTest_imageFace.bytes_per_pixel * 8, + SDLTest_imageFace.width, + SDLTest_imageFace.height, + SDLTest_imageFace.bytes_per_pixel * 8, SDLTest_imageFace.width * SDLTest_imageFace.bytes_per_pixel, #if (SDL_BYTEORDER == SDL_BIG_ENDIAN) 0xff000000, /* Red bit mask. */ diff --git a/src/test/SDL_test_imagePrimitives.c b/src/test/SDL_test_imagePrimitives.c index 191353854..93b99d692 100644 --- a/src/test/SDL_test_imagePrimitives.c +++ b/src/test/SDL_test_imagePrimitives.c @@ -490,11 +490,11 @@ const SDLTest_SurfaceImage_t SDLTest_imagePrimitives = { */ SDL_Surface *SDLTest_ImagePrimitives() { - SDL_Surface *surface = SDL_CreateRGBSurfaceFrom( + SDL_Surface *surface = SDL_CreateRGBSurfaceFrom( (void*)SDLTest_imagePrimitives.pixel_data, - SDLTest_imagePrimitives.width, + SDLTest_imagePrimitives.width, SDLTest_imagePrimitives.height, - SDLTest_imagePrimitives.bytes_per_pixel * 8, + SDLTest_imagePrimitives.bytes_per_pixel * 8, SDLTest_imagePrimitives.width * SDLTest_imagePrimitives.bytes_per_pixel, #if (SDL_BYTEORDER == SDL_BIG_ENDIAN) 0xff000000, /* Red bit mask. */ diff --git a/src/test/SDL_test_imagePrimitivesBlend.c b/src/test/SDL_test_imagePrimitivesBlend.c index 705e5c9bc..ce9adc51a 100644 --- a/src/test/SDL_test_imagePrimitivesBlend.c +++ b/src/test/SDL_test_imagePrimitivesBlend.c @@ -672,11 +672,11 @@ const SDLTest_SurfaceImage_t SDLTest_imagePrimitivesBlend = { */ SDL_Surface *SDLTest_ImagePrimitivesBlend() { - SDL_Surface *surface = SDL_CreateRGBSurfaceFrom( + SDL_Surface *surface = SDL_CreateRGBSurfaceFrom( (void*)SDLTest_imagePrimitivesBlend.pixel_data, - SDLTest_imagePrimitivesBlend.width, - SDLTest_imagePrimitivesBlend.height, - SDLTest_imagePrimitivesBlend.bytes_per_pixel * 8, + SDLTest_imagePrimitivesBlend.width, + SDLTest_imagePrimitivesBlend.height, + SDLTest_imagePrimitivesBlend.bytes_per_pixel * 8, SDLTest_imagePrimitivesBlend.width * SDLTest_imagePrimitivesBlend.bytes_per_pixel, #if (SDL_BYTEORDER == SDL_BIG_ENDIAN) 0xff000000, /* Red bit mask. */ diff --git a/src/test/SDL_test_log.c b/src/test/SDL_test_log.c index 4d19012dc..d184396a3 100644 --- a/src/test/SDL_test_log.c +++ b/src/test/SDL_test_log.c @@ -21,11 +21,11 @@ /* - Used by the test framework and test cases. + Used by the test framework and test cases. */ -// quiet windows compiler warnings +/* quiet windows compiler warnings */ #define _CRT_SECURE_NO_WARNINGS #include "SDL_config.h" @@ -50,18 +50,18 @@ * * \return Ascii representation of the timestamp in localtime in the format '08/23/01 14:55:02' */ -char *SDLTest_TimestampToString(const time_t timestamp) +char *SDLTest_TimestampToString(const time_t timestamp) { - time_t copy; - static char buffer[64]; - struct tm *local; + time_t copy; + static char buffer[64]; + struct tm *local; - SDL_memset(buffer, 0, sizeof(buffer));\ - copy = timestamp; - local = localtime(©); - strftime(buffer, sizeof(buffer), "%x %X", local); + SDL_memset(buffer, 0, sizeof(buffer));\ + copy = timestamp; + local = localtime(©); + strftime(buffer, sizeof(buffer), "%x %X", local); - return buffer; + return buffer; } /* @@ -69,17 +69,17 @@ char *SDLTest_TimestampToString(const time_t timestamp) */ void SDLTest_Log(const char *fmt, ...) { - va_list list; - char logMessage[SDLTEST_MAX_LOGMESSAGE_LENGTH]; + va_list list; + char logMessage[SDLTEST_MAX_LOGMESSAGE_LENGTH]; - // Print log message into a buffer - SDL_memset(logMessage, 0, SDLTEST_MAX_LOGMESSAGE_LENGTH); - va_start(list, fmt); - SDL_vsnprintf(logMessage, SDLTEST_MAX_LOGMESSAGE_LENGTH - 1, fmt, list); - va_end(list); + /* Print log message into a buffer */ + SDL_memset(logMessage, 0, SDLTEST_MAX_LOGMESSAGE_LENGTH); + va_start(list, fmt); + SDL_vsnprintf(logMessage, SDLTEST_MAX_LOGMESSAGE_LENGTH - 1, fmt, list); + va_end(list); - // Log with timestamp and newline - SDL_LogMessage(SDL_LOG_CATEGORY_TEST, SDL_LOG_PRIORITY_INFO, " %s: %s", SDLTest_TimestampToString(time(0)), logMessage); + /* Log with timestamp and newline */ + SDL_LogMessage(SDL_LOG_CATEGORY_TEST, SDL_LOG_PRIORITY_INFO, " %s: %s", SDLTest_TimestampToString(time(0)), logMessage); } /* @@ -87,15 +87,15 @@ void SDLTest_Log(const char *fmt, ...) */ void SDLTest_LogError(const char *fmt, ...) { - va_list list; - char logMessage[SDLTEST_MAX_LOGMESSAGE_LENGTH]; + va_list list; + char logMessage[SDLTEST_MAX_LOGMESSAGE_LENGTH]; - // Print log message into a buffer - SDL_memset(logMessage, 0, SDLTEST_MAX_LOGMESSAGE_LENGTH); - va_start(list, fmt); - SDL_vsnprintf(logMessage, SDLTEST_MAX_LOGMESSAGE_LENGTH - 1, fmt, list); - va_end(list); + /* Print log message into a buffer */ + SDL_memset(logMessage, 0, SDLTEST_MAX_LOGMESSAGE_LENGTH); + va_start(list, fmt); + SDL_vsnprintf(logMessage, SDLTEST_MAX_LOGMESSAGE_LENGTH - 1, fmt, list); + va_end(list); - // Log with timestamp and newline - SDL_LogMessage(SDL_LOG_CATEGORY_TEST, SDL_LOG_PRIORITY_ERROR, "%s: %s", SDLTest_TimestampToString(time(0)), logMessage); + /* Log with timestamp and newline */ + SDL_LogMessage(SDL_LOG_CATEGORY_TEST, SDL_LOG_PRIORITY_ERROR, "%s: %s", SDLTest_TimestampToString(time(0)), logMessage); } diff --git a/src/test/SDL_test_md5.c b/src/test/SDL_test_md5.c index 6d4d7d04b..3f42ed356 100644 --- a/src/test/SDL_test_md5.c +++ b/src/test/SDL_test_md5.c @@ -102,7 +102,7 @@ static unsigned char MD5PADDING[64] = { (a) += (b); \ } -/* +/* The routine MD5Init initializes the message-digest context mdContext. All fields are set to zero. */ @@ -122,14 +122,14 @@ void SDLTest_Md5Init(SDLTest_Md5Context * mdContext) mdContext->buf[3] = (MD5UINT4) 0x10325476; } -/* +/* The routine MD5Update updates the message-digest context to account for the presence of each of the characters inBuf[0..inLen-1] in the message whose digest is being computed. */ void SDLTest_Md5Update(SDLTest_Md5Context * mdContext, unsigned char *inBuf, - unsigned int inLen) + unsigned int inLen) { MD5UINT4 in[16]; int mdi; @@ -139,12 +139,12 @@ void SDLTest_Md5Update(SDLTest_Md5Context * mdContext, unsigned char *inBuf, if (inBuf == NULL || inLen < 1) return; /* - * compute number of bytes mod 64 + * compute number of bytes mod 64 */ mdi = (int) ((mdContext->i[0] >> 3) & 0x3F); /* - * update number of bits + * update number of bits */ if ((mdContext->i[0] + ((MD5UINT4) inLen << 3)) < mdContext->i[0]) mdContext->i[1]++; @@ -153,26 +153,26 @@ void SDLTest_Md5Update(SDLTest_Md5Context * mdContext, unsigned char *inBuf, while (inLen--) { /* - * add new character to buffer, increment mdi + * add new character to buffer, increment mdi */ mdContext->in[mdi++] = *inBuf++; /* - * transform if necessary + * transform if necessary */ if (mdi == 0x40) { for (i = 0, ii = 0; i < 16; i++, ii += 4) - in[i] = (((MD5UINT4) mdContext->in[ii + 3]) << 24) | - (((MD5UINT4) mdContext->in[ii + 2]) << 16) | - (((MD5UINT4) mdContext->in[ii + 1]) << 8) | - ((MD5UINT4) mdContext->in[ii]); + in[i] = (((MD5UINT4) mdContext->in[ii + 3]) << 24) | + (((MD5UINT4) mdContext->in[ii + 2]) << 16) | + (((MD5UINT4) mdContext->in[ii + 1]) << 8) | + ((MD5UINT4) mdContext->in[ii]); SDLTest_Md5Transform(mdContext->buf, in); mdi = 0; } } } -/* +/* The routine MD5Final terminates the message-digest computation and ends with the desired message digest in mdContext->digest[0...15]. */ @@ -187,24 +187,24 @@ void SDLTest_Md5Final(SDLTest_Md5Context * mdContext) if (mdContext == NULL) return; /* - * save number of bits + * save number of bits */ in[14] = mdContext->i[0]; in[15] = mdContext->i[1]; /* - * compute number of bytes mod 64 + * compute number of bytes mod 64 */ mdi = (int) ((mdContext->i[0] >> 3) & 0x3F); /* - * pad out to 56 mod 64 + * pad out to 56 mod 64 */ padLen = (mdi < 56) ? (56 - mdi) : (120 - mdi); SDLTest_Md5Update(mdContext, MD5PADDING, padLen); /* - * append length in bits and transform + * append length in bits and transform */ for (i = 0, ii = 0; i < 14; i++, ii += 4) in[i] = (((MD5UINT4) mdContext->in[ii + 3]) << 24) | @@ -214,7 +214,7 @@ void SDLTest_Md5Final(SDLTest_Md5Context * mdContext) SDLTest_Md5Transform(mdContext->buf, in); /* - * store buffer in digest + * store buffer in digest */ for (i = 0, ii = 0; i < 4; i++, ii += 4) { mdContext->digest[ii] = (unsigned char) (mdContext->buf[i] & 0xFF); @@ -234,100 +234,100 @@ static void SDLTest_Md5Transform(MD5UINT4 * buf, MD5UINT4 * in) MD5UINT4 a = buf[0], b = buf[1], c = buf[2], d = buf[3]; /* - * Round 1 + * Round 1 */ #define S11 7 #define S12 12 #define S13 17 #define S14 22 - FF(a, b, c, d, in[0], S11, 3614090360u); /* 1 */ - FF(d, a, b, c, in[1], S12, 3905402710u); /* 2 */ - FF(c, d, a, b, in[2], S13, 606105819u); /* 3 */ - FF(b, c, d, a, in[3], S14, 3250441966u); /* 4 */ - FF(a, b, c, d, in[4], S11, 4118548399u); /* 5 */ - FF(d, a, b, c, in[5], S12, 1200080426u); /* 6 */ - FF(c, d, a, b, in[6], S13, 2821735955u); /* 7 */ - FF(b, c, d, a, in[7], S14, 4249261313u); /* 8 */ - FF(a, b, c, d, in[8], S11, 1770035416u); /* 9 */ - FF(d, a, b, c, in[9], S12, 2336552879u); /* 10 */ - FF(c, d, a, b, in[10], S13, 4294925233u); /* 11 */ - FF(b, c, d, a, in[11], S14, 2304563134u); /* 12 */ - FF(a, b, c, d, in[12], S11, 1804603682u); /* 13 */ - FF(d, a, b, c, in[13], S12, 4254626195u); /* 14 */ - FF(c, d, a, b, in[14], S13, 2792965006u); /* 15 */ - FF(b, c, d, a, in[15], S14, 1236535329u); /* 16 */ + FF(a, b, c, d, in[0], S11, 3614090360u); /* 1 */ + FF(d, a, b, c, in[1], S12, 3905402710u); /* 2 */ + FF(c, d, a, b, in[2], S13, 606105819u); /* 3 */ + FF(b, c, d, a, in[3], S14, 3250441966u); /* 4 */ + FF(a, b, c, d, in[4], S11, 4118548399u); /* 5 */ + FF(d, a, b, c, in[5], S12, 1200080426u); /* 6 */ + FF(c, d, a, b, in[6], S13, 2821735955u); /* 7 */ + FF(b, c, d, a, in[7], S14, 4249261313u); /* 8 */ + FF(a, b, c, d, in[8], S11, 1770035416u); /* 9 */ + FF(d, a, b, c, in[9], S12, 2336552879u); /* 10 */ + FF(c, d, a, b, in[10], S13, 4294925233u); /* 11 */ + FF(b, c, d, a, in[11], S14, 2304563134u); /* 12 */ + FF(a, b, c, d, in[12], S11, 1804603682u); /* 13 */ + FF(d, a, b, c, in[13], S12, 4254626195u); /* 14 */ + FF(c, d, a, b, in[14], S13, 2792965006u); /* 15 */ + FF(b, c, d, a, in[15], S14, 1236535329u); /* 16 */ /* - * Round 2 + * Round 2 */ #define S21 5 #define S22 9 #define S23 14 #define S24 20 - GG(a, b, c, d, in[1], S21, 4129170786u); /* 17 */ - GG(d, a, b, c, in[6], S22, 3225465664u); /* 18 */ - GG(c, d, a, b, in[11], S23, 643717713u); /* 19 */ - GG(b, c, d, a, in[0], S24, 3921069994u); /* 20 */ - GG(a, b, c, d, in[5], S21, 3593408605u); /* 21 */ - GG(d, a, b, c, in[10], S22, 38016083u); /* 22 */ - GG(c, d, a, b, in[15], S23, 3634488961u); /* 23 */ - GG(b, c, d, a, in[4], S24, 3889429448u); /* 24 */ - GG(a, b, c, d, in[9], S21, 568446438u); /* 25 */ - GG(d, a, b, c, in[14], S22, 3275163606u); /* 26 */ - GG(c, d, a, b, in[3], S23, 4107603335u); /* 27 */ - GG(b, c, d, a, in[8], S24, 1163531501u); /* 28 */ - GG(a, b, c, d, in[13], S21, 2850285829u); /* 29 */ - GG(d, a, b, c, in[2], S22, 4243563512u); /* 30 */ - GG(c, d, a, b, in[7], S23, 1735328473u); /* 31 */ - GG(b, c, d, a, in[12], S24, 2368359562u); /* 32 */ + GG(a, b, c, d, in[1], S21, 4129170786u); /* 17 */ + GG(d, a, b, c, in[6], S22, 3225465664u); /* 18 */ + GG(c, d, a, b, in[11], S23, 643717713u); /* 19 */ + GG(b, c, d, a, in[0], S24, 3921069994u); /* 20 */ + GG(a, b, c, d, in[5], S21, 3593408605u); /* 21 */ + GG(d, a, b, c, in[10], S22, 38016083u); /* 22 */ + GG(c, d, a, b, in[15], S23, 3634488961u); /* 23 */ + GG(b, c, d, a, in[4], S24, 3889429448u); /* 24 */ + GG(a, b, c, d, in[9], S21, 568446438u); /* 25 */ + GG(d, a, b, c, in[14], S22, 3275163606u); /* 26 */ + GG(c, d, a, b, in[3], S23, 4107603335u); /* 27 */ + GG(b, c, d, a, in[8], S24, 1163531501u); /* 28 */ + GG(a, b, c, d, in[13], S21, 2850285829u); /* 29 */ + GG(d, a, b, c, in[2], S22, 4243563512u); /* 30 */ + GG(c, d, a, b, in[7], S23, 1735328473u); /* 31 */ + GG(b, c, d, a, in[12], S24, 2368359562u); /* 32 */ /* - * Round 3 + * Round 3 */ #define S31 4 #define S32 11 #define S33 16 #define S34 23 - HH(a, b, c, d, in[5], S31, 4294588738u); /* 33 */ - HH(d, a, b, c, in[8], S32, 2272392833u); /* 34 */ - HH(c, d, a, b, in[11], S33, 1839030562u); /* 35 */ - HH(b, c, d, a, in[14], S34, 4259657740u); /* 36 */ - HH(a, b, c, d, in[1], S31, 2763975236u); /* 37 */ - HH(d, a, b, c, in[4], S32, 1272893353u); /* 38 */ - HH(c, d, a, b, in[7], S33, 4139469664u); /* 39 */ - HH(b, c, d, a, in[10], S34, 3200236656u); /* 40 */ - HH(a, b, c, d, in[13], S31, 681279174u); /* 41 */ - HH(d, a, b, c, in[0], S32, 3936430074u); /* 42 */ - HH(c, d, a, b, in[3], S33, 3572445317u); /* 43 */ - HH(b, c, d, a, in[6], S34, 76029189u); /* 44 */ - HH(a, b, c, d, in[9], S31, 3654602809u); /* 45 */ - HH(d, a, b, c, in[12], S32, 3873151461u); /* 46 */ - HH(c, d, a, b, in[15], S33, 530742520u); /* 47 */ - HH(b, c, d, a, in[2], S34, 3299628645u); /* 48 */ + HH(a, b, c, d, in[5], S31, 4294588738u); /* 33 */ + HH(d, a, b, c, in[8], S32, 2272392833u); /* 34 */ + HH(c, d, a, b, in[11], S33, 1839030562u); /* 35 */ + HH(b, c, d, a, in[14], S34, 4259657740u); /* 36 */ + HH(a, b, c, d, in[1], S31, 2763975236u); /* 37 */ + HH(d, a, b, c, in[4], S32, 1272893353u); /* 38 */ + HH(c, d, a, b, in[7], S33, 4139469664u); /* 39 */ + HH(b, c, d, a, in[10], S34, 3200236656u); /* 40 */ + HH(a, b, c, d, in[13], S31, 681279174u); /* 41 */ + HH(d, a, b, c, in[0], S32, 3936430074u); /* 42 */ + HH(c, d, a, b, in[3], S33, 3572445317u); /* 43 */ + HH(b, c, d, a, in[6], S34, 76029189u); /* 44 */ + HH(a, b, c, d, in[9], S31, 3654602809u); /* 45 */ + HH(d, a, b, c, in[12], S32, 3873151461u); /* 46 */ + HH(c, d, a, b, in[15], S33, 530742520u); /* 47 */ + HH(b, c, d, a, in[2], S34, 3299628645u); /* 48 */ /* - * Round 4 + * Round 4 */ #define S41 6 #define S42 10 #define S43 15 #define S44 21 - II(a, b, c, d, in[0], S41, 4096336452u); /* 49 */ - II(d, a, b, c, in[7], S42, 1126891415u); /* 50 */ - II(c, d, a, b, in[14], S43, 2878612391u); /* 51 */ - II(b, c, d, a, in[5], S44, 4237533241u); /* 52 */ - II(a, b, c, d, in[12], S41, 1700485571u); /* 53 */ - II(d, a, b, c, in[3], S42, 2399980690u); /* 54 */ - II(c, d, a, b, in[10], S43, 4293915773u); /* 55 */ - II(b, c, d, a, in[1], S44, 2240044497u); /* 56 */ - II(a, b, c, d, in[8], S41, 1873313359u); /* 57 */ - II(d, a, b, c, in[15], S42, 4264355552u); /* 58 */ - II(c, d, a, b, in[6], S43, 2734768916u); /* 59 */ - II(b, c, d, a, in[13], S44, 1309151649u); /* 60 */ - II(a, b, c, d, in[4], S41, 4149444226u); /* 61 */ - II(d, a, b, c, in[11], S42, 3174756917u); /* 62 */ - II(c, d, a, b, in[2], S43, 718787259u); /* 63 */ - II(b, c, d, a, in[9], S44, 3951481745u); /* 64 */ + II(a, b, c, d, in[0], S41, 4096336452u); /* 49 */ + II(d, a, b, c, in[7], S42, 1126891415u); /* 50 */ + II(c, d, a, b, in[14], S43, 2878612391u); /* 51 */ + II(b, c, d, a, in[5], S44, 4237533241u); /* 52 */ + II(a, b, c, d, in[12], S41, 1700485571u); /* 53 */ + II(d, a, b, c, in[3], S42, 2399980690u); /* 54 */ + II(c, d, a, b, in[10], S43, 4293915773u); /* 55 */ + II(b, c, d, a, in[1], S44, 2240044497u); /* 56 */ + II(a, b, c, d, in[8], S41, 1873313359u); /* 57 */ + II(d, a, b, c, in[15], S42, 4264355552u); /* 58 */ + II(c, d, a, b, in[6], S43, 2734768916u); /* 59 */ + II(b, c, d, a, in[13], S44, 1309151649u); /* 60 */ + II(a, b, c, d, in[4], S41, 4149444226u); /* 61 */ + II(d, a, b, c, in[11], S42, 3174756917u); /* 62 */ + II(c, d, a, b, in[2], S43, 718787259u); /* 63 */ + II(b, c, d, a, in[9], S44, 3951481745u); /* 64 */ buf[0] += a; buf[1] += b; diff --git a/src/test/SDL_test_random.c b/src/test/SDL_test_random.c index 8b305c50e..2c70dbd47 100644 --- a/src/test/SDL_test_random.c +++ b/src/test/SDL_test_random.c @@ -23,14 +23,14 @@ A portable "32-bit Multiply with carry" random number generator. - Used by the fuzzer component. + Used by the fuzzer component. Original source code contributed by A. Schiffler for GSOC project. */ #include "SDL_config.h" -#include +#include #include #include @@ -41,13 +41,13 @@ void SDLTest_RandomInit(SDLTest_RandomContext * rndContext, unsigned int xi, unsigned int ci) { if (rndContext==NULL) return; - + /* * Choose a value for 'a' from this list * 1791398085 1929682203 1683268614 1965537969 1675393560 * 1967773755 1517746329 1447497129 1655692410 1606218150 * 2051013963 1075433238 1557985959 1781943330 1893513180 - * 1631296680 2131995753 2083801278 1873196400 1554115554 + * 1631296680 2131995753 2083801278 1873196400 1554115554 */ rndContext->a = 1655692410; rndContext->x = 30903; @@ -65,9 +65,9 @@ void SDLTest_RandomInit(SDLTest_RandomContext * rndContext, unsigned int xi, uns void SDLTest_RandomInitTime(SDLTest_RandomContext * rndContext) { int a, b; - + if (rndContext==NULL) return; - + srand((unsigned int)time(NULL)); a=rand(); srand(clock()); @@ -82,7 +82,7 @@ unsigned int SDLTest_Random(SDLTest_RandomContext * rndContext) unsigned int xh, xl; if (rndContext==NULL) return -1; - + xh = rndContext->x >> 16, xl = rndContext->x & 65535; rndContext->x = rndContext->x * rndContext->a + rndContext->c; rndContext->c = diff --git a/src/thread/SDL_thread.c b/src/thread/SDL_thread.c index e20f672ff..61e252c17 100644 --- a/src/thread/SDL_thread.c +++ b/src/thread/SDL_thread.c @@ -28,7 +28,7 @@ #include "SDL_systhread.h" #include "../SDL_error_c.h" -#define ARRAY_CHUNKSIZE 32 +#define ARRAY_CHUNKSIZE 32 /* The array of threads currently active in the application (except the main thread) The manipulation of an array here is safer than using a linked list. diff --git a/src/thread/psp/SDL_syssem.c b/src/thread/psp/SDL_syssem.c index 22ecc5f6b..8eff409e0 100644 --- a/src/thread/psp/SDL_syssem.c +++ b/src/thread/psp/SDL_syssem.c @@ -31,42 +31,42 @@ #include struct SDL_semaphore { - SceUID semid; + SceUID semid; }; /* Create a semaphore */ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) { - SDL_sem *sem; - - sem = (SDL_sem *) malloc(sizeof(*sem)); - if (sem != NULL) { - /* TODO: Figure out the limit on the maximum value. */ - sem->semid = sceKernelCreateSema("SDL sema", 0, initial_value, 255, NULL); - if (sem->semid < 0) { - SDL_SetError("Couldn't create semaphore"); - free(sem); - sem = NULL; - } - } else { - SDL_OutOfMemory(); - } - - return sem; + SDL_sem *sem; + + sem = (SDL_sem *) malloc(sizeof(*sem)); + if (sem != NULL) { + /* TODO: Figure out the limit on the maximum value. */ + sem->semid = sceKernelCreateSema("SDL sema", 0, initial_value, 255, NULL); + if (sem->semid < 0) { + SDL_SetError("Couldn't create semaphore"); + free(sem); + sem = NULL; + } + } else { + SDL_OutOfMemory(); + } + + return sem; } /* Free the semaphore */ void SDL_DestroySemaphore(SDL_sem *sem) { - if (sem != NULL) { - if (sem->semid > 0) { - sceKernelDeleteSema(sem->semid); - sem->semid = 0; - } - - free(sem); - } + if (sem != NULL) { + if (sem->semid > 0) { + sceKernelDeleteSema(sem->semid); + sem->semid = 0; + } + + free(sem); + } } /* TODO: This routine is a bit overloaded. @@ -75,30 +75,30 @@ void SDL_DestroySemaphore(SDL_sem *sem) * is specified, convert it to microseconds. */ int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout) { - Uint32 *pTimeout; + Uint32 *pTimeout; unsigned int res; - if (sem == NULL) { - SDL_SetError("Passed a NULL sem"); - return 0; - } - - if (timeout == 0) { - res = sceKernelPollSema(sem->semid, 1); - if (res < 0) { - return SDL_MUTEX_TIMEDOUT; - } - return 0; - } - - if (timeout == SDL_MUTEX_MAXWAIT) { - pTimeout = NULL; - } else { - timeout *= 1000; /* Convert to microseconds. */ - pTimeout = &timeout; - } - - res = sceKernelWaitSema(sem->semid, 1, pTimeout); + if (sem == NULL) { + SDL_SetError("Passed a NULL sem"); + return 0; + } + + if (timeout == 0) { + res = sceKernelPollSema(sem->semid, 1); + if (res < 0) { + return SDL_MUTEX_TIMEDOUT; + } + return 0; + } + + if (timeout == SDL_MUTEX_MAXWAIT) { + pTimeout = NULL; + } else { + timeout *= 1000; /* Convert to microseconds. */ + pTimeout = &timeout; + } + + res = sceKernelWaitSema(sem->semid, 1, pTimeout); switch (res) { case SCE_KERNEL_ERROR_OK: return 0; @@ -106,50 +106,50 @@ int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout) return SDL_MUTEX_TIMEDOUT; default: return SDL_SetError("WaitForSingleObject() failed"); - } + } } int SDL_SemTryWait(SDL_sem *sem) { - return SDL_SemWaitTimeout(sem, 0); + return SDL_SemWaitTimeout(sem, 0); } int SDL_SemWait(SDL_sem *sem) { - return SDL_SemWaitTimeout(sem, SDL_MUTEX_MAXWAIT); + return SDL_SemWaitTimeout(sem, SDL_MUTEX_MAXWAIT); } /* Returns the current count of the semaphore */ Uint32 SDL_SemValue(SDL_sem *sem) { - SceKernelSemaInfo info; + SceKernelSemaInfo info; - if (sem == NULL) { - SDL_SetError("Passed a NULL sem"); - return 0; - } + if (sem == NULL) { + SDL_SetError("Passed a NULL sem"); + return 0; + } - if (sceKernelReferSemaStatus(sem->semid, &info) >= 0) { - return info.currentCount; - } + if (sceKernelReferSemaStatus(sem->semid, &info) >= 0) { + return info.currentCount; + } - return 0; + return 0; } int SDL_SemPost(SDL_sem *sem) { - int res; + int res; - if (sem == NULL) { - return SDL_SetError("Passed a NULL sem"); - } + if (sem == NULL) { + return SDL_SetError("Passed a NULL sem"); + } - res = sceKernelSignalSema(sem->semid, 1); - if (res < 0) { - return SDL_SetError("sceKernelSignalSema() failed"); - } + res = sceKernelSignalSema(sem->semid, 1); + if (res < 0) { + return SDL_SetError("sceKernelSignalSema() failed"); + } - return 0; + return 0; } /* vim: ts=4 sw=4 diff --git a/src/thread/psp/SDL_systhread.c b/src/thread/psp/SDL_systhread.c index 57b932084..05a2341fe 100644 --- a/src/thread/psp/SDL_systhread.c +++ b/src/thread/psp/SDL_systhread.c @@ -35,57 +35,57 @@ static int ThreadEntry(SceSize args, void *argp) { - SDL_RunThread(*(void **) argp); - return 0; + SDL_RunThread(*(void **) argp); + return 0; } int SDL_SYS_CreateThread(SDL_Thread *thread, void *args) { - SceKernelThreadInfo status; - int priority = 32; - - /* Set priority of new thread to the same as the current thread */ - status.size = sizeof(SceKernelThreadInfo); - if (sceKernelReferThreadStatus(sceKernelGetThreadId(), &status) == 0) { - priority = status.currentPriority; - } - - thread->handle = sceKernelCreateThread("SDL thread", ThreadEntry, - priority, 0x8000, - PSP_THREAD_ATTR_VFPU, NULL); - if (thread->handle < 0) { - return SDL_SetError("sceKernelCreateThread() failed"); - } - - sceKernelStartThread(thread->handle, 4, &args); - return 0; + SceKernelThreadInfo status; + int priority = 32; + + /* Set priority of new thread to the same as the current thread */ + status.size = sizeof(SceKernelThreadInfo); + if (sceKernelReferThreadStatus(sceKernelGetThreadId(), &status) == 0) { + priority = status.currentPriority; + } + + thread->handle = sceKernelCreateThread("SDL thread", ThreadEntry, + priority, 0x8000, + PSP_THREAD_ATTR_VFPU, NULL); + if (thread->handle < 0) { + return SDL_SetError("sceKernelCreateThread() failed"); + } + + sceKernelStartThread(thread->handle, 4, &args); + return 0; } void SDL_SYS_SetupThread(const char *name) { - /* Do nothing. */ + /* Do nothing. */ } SDL_threadID SDL_ThreadID(void) { - return (SDL_threadID) sceKernelGetThreadId(); + return (SDL_threadID) sceKernelGetThreadId(); } void SDL_SYS_WaitThread(SDL_Thread *thread) { - sceKernelWaitThreadEnd(thread->handle, NULL); - sceKernelDeleteThread(thread->handle); + sceKernelWaitThreadEnd(thread->handle, NULL); + sceKernelDeleteThread(thread->handle); } void SDL_SYS_KillThread(SDL_Thread *thread) -{ - sceKernelTerminateDeleteThread(thread->handle); +{ + sceKernelTerminateDeleteThread(thread->handle); } int SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority) -{ +{ int value; - + if (priority == SDL_THREAD_PRIORITY_LOW) { value = 19; } else if (priority == SDL_THREAD_PRIORITY_HIGH) { @@ -93,7 +93,7 @@ int SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority) } else { value = 0; } - + return sceKernelChangeThreadPriority(sceKernelGetThreadId(),value); } diff --git a/src/thread/pthread/SDL_systhread.c b/src/thread/pthread/SDL_systhread.c index 62436936e..c967ca7f3 100644 --- a/src/thread/pthread/SDL_systhread.c +++ b/src/thread/pthread/SDL_systhread.c @@ -34,7 +34,7 @@ #include #include #include -#endif // __LINUX__ +#endif /* __LINUX__ */ #if defined(__LINUX__) || defined(__MACOSX__) || defined(__IPHONEOS__) #include diff --git a/src/thread/windows/SDL_systhread.c b/src/thread/windows/SDL_systhread.c index 6ae9cdb8f..ada365413 100644 --- a/src/thread/windows/SDL_systhread.c +++ b/src/thread/windows/SDL_systhread.c @@ -36,7 +36,7 @@ /* Cygwin gcc-3 ... MingW64 (even with a i386 host) does this like MSVC. */ #if (defined(__MINGW32__) && (__GNUC__ < 4)) typedef unsigned long (__cdecl *pfnSDL_CurrentBeginThread) (void *, unsigned, - unsigned (__stdcall *func)(void *), void *arg, + unsigned (__stdcall *func)(void *), void *arg, unsigned, unsigned *threadID); typedef void (__cdecl *pfnSDL_CurrentEndThread)(unsigned code); @@ -118,9 +118,9 @@ SDL_SYS_CreateThread(SDL_Thread * thread, void *args) if (!pThreadParms) { return SDL_OutOfMemory(); } - // Save the function which we will have to call to clear the RTL of calling app! + /* Save the function which we will have to call to clear the RTL of calling app! */ pThreadParms->pfnCurrentEndThread = pfnEndThread; - // Also save the real parameters we have to pass to thread function + /* Also save the real parameters we have to pass to thread function */ pThreadParms->args = args; if (pfnBeginThread) { diff --git a/src/timer/SDL_timer.c b/src/timer/SDL_timer.c index 5e542f083..5b6550c1c 100644 --- a/src/timer/SDL_timer.c +++ b/src/timer/SDL_timer.c @@ -336,7 +336,7 @@ SDL_AddTimer(Uint32 interval, SDL_TimerCallback callback, void *param) timer->interval = interval; timer->scheduled = SDL_GetTicks() + interval; timer->canceled = SDL_FALSE; - + entry = (SDL_TimerMap *)SDL_malloc(sizeof(*entry)); if (!entry) { SDL_free(timer); diff --git a/src/timer/SDL_timer_c.h b/src/timer/SDL_timer_c.h index c759bcd84..157485310 100644 --- a/src/timer/SDL_timer_c.h +++ b/src/timer/SDL_timer_c.h @@ -23,8 +23,8 @@ /* Useful functions and variables from SDL_timer.c */ #include "SDL_timer.h" -#define ROUND_RESOLUTION(X) \ - (((X+TIMER_RESOLUTION-1)/TIMER_RESOLUTION)*TIMER_RESOLUTION) +#define ROUND_RESOLUTION(X) \ + (((X+TIMER_RESOLUTION-1)/TIMER_RESOLUTION)*TIMER_RESOLUTION) extern void SDL_InitTicks(void); extern int SDL_TimerInit(void); diff --git a/src/timer/psp/SDL_systimer.c b/src/timer/psp/SDL_systimer.c index cfb0aeb25..59bb4df1c 100644 --- a/src/timer/psp/SDL_systimer.c +++ b/src/timer/psp/SDL_systimer.c @@ -32,17 +32,17 @@ static struct timeval start; void SDL_StartTicks(void) { - gettimeofday(&start, NULL); + gettimeofday(&start, NULL); } Uint32 SDL_GetTicks(void) { - struct timeval now; - Uint32 ticks; + struct timeval now; + Uint32 ticks; - gettimeofday(&now, NULL); - ticks=(now.tv_sec-start.tv_sec)*1000+(now.tv_usec-start.tv_usec)/1000; - return(ticks); + gettimeofday(&now, NULL); + ticks=(now.tv_sec-start.tv_sec)*1000+(now.tv_usec-start.tv_usec)/1000; + return(ticks); } Uint64 @@ -59,10 +59,10 @@ SDL_GetPerformanceFrequency(void) void SDL_Delay(Uint32 ms) { - const Uint32 max_delay = 0xffffffffUL / 1000; - if(ms > max_delay) - ms = max_delay; - sceKernelDelayThreadCB(ms * 1000); + const Uint32 max_delay = 0xffffffffUL / 1000; + if(ms > max_delay) + ms = max_delay; + sceKernelDelayThreadCB(ms * 1000); } /* vim: ts=4 sw=4 diff --git a/src/timer/unix/SDL_systimer.c b/src/timer/unix/SDL_systimer.c index c61b8b966..514ac2267 100644 --- a/src/timer/unix/SDL_systimer.c +++ b/src/timer/unix/SDL_systimer.c @@ -85,7 +85,7 @@ SDL_GetTicks(void) #if HAVE_CLOCK_GETTIME struct timespec now; clock_gettime(CLOCK_MONOTONIC, &now); - ticks = + ticks = (now.tv_sec - start_ts.tv_sec) * 1000 + (now.tv_nsec - start_ts.tv_nsec) / 1000000; #elif defined(__APPLE__) diff --git a/src/timer/windows/SDL_systimer.c b/src/timer/windows/SDL_systimer.c index 9d1711b96..33097634e 100644 --- a/src/timer/windows/SDL_systimer.c +++ b/src/timer/windows/SDL_systimer.c @@ -27,7 +27,7 @@ #include "SDL_timer.h" -#define TIME_WRAP_VALUE (~(DWORD)0) +#define TIME_WRAP_VALUE (~(DWORD)0) /* The first (low-resolution) ticks value of the application */ static DWORD start; @@ -48,7 +48,7 @@ SDL_StartTicks(void) #ifdef USE_GETTICKCOUNT start = GetTickCount(); #else - /* QueryPerformanceCounter has had problems in the past, but lots of games + /* QueryPerformanceCounter has had problems in the past, but lots of games use it, so we'll rely on it here. */ if (QueryPerformanceFrequency(&hires_ticks_per_second) == TRUE) { diff --git a/src/video/SDL_RLEaccel.c b/src/video/SDL_RLEaccel.c index 965a706f5..e1f12d13b 100644 --- a/src/video/SDL_RLEaccel.c +++ b/src/video/SDL_RLEaccel.c @@ -71,7 +71,7 @@ * For 32-bit targets, each pixel has the target RGB format but with * the alpha value occupying the highest 8 bits. The and * counts are 16 bit. - * + * * For 16-bit targets, each pixel has the target RGB format, but with * the middle component (usually green) shifted 16 steps to the left, * and the hole filled with the 5 most significant bits of the alpha value. @@ -97,20 +97,20 @@ #define MIN(a, b) ((a) < (b) ? (a) : (b)) #endif -#define PIXEL_COPY(to, from, len, bpp) \ -do { \ - if(bpp == 4) { \ - SDL_memcpy4(to, from, (size_t)(len)); \ - } else { \ - SDL_memcpy(to, from, (size_t)(len) * (bpp)); \ - } \ +#define PIXEL_COPY(to, from, len, bpp) \ +do { \ + if(bpp == 4) { \ + SDL_memcpy4(to, from, (size_t)(len)); \ + } else { \ + SDL_memcpy(to, from, (size_t)(len) * (bpp)); \ + } \ } while(0) /* * Various colorkey blit methods, for opaque and per-surface alpha */ -#define OPAQUE_BLIT(to, from, length, bpp, alpha) \ +#define OPAQUE_BLIT(to, from, length, bpp, alpha) \ PIXEL_COPY(to, from, length, bpp) /* @@ -120,22 +120,22 @@ do { \ * of each component, so the bits from the multiplication don't collide. * This can be used for any RGB permutation of course. */ -#define ALPHA_BLIT32_888(to, from, length, bpp, alpha) \ - do { \ - int i; \ - Uint32 *src = (Uint32 *)(from); \ - Uint32 *dst = (Uint32 *)(to); \ - for(i = 0; i < (int)(length); i++) { \ - Uint32 s = *src++; \ - Uint32 d = *dst; \ - Uint32 s1 = s & 0xff00ff; \ - Uint32 d1 = d & 0xff00ff; \ - d1 = (d1 + ((s1 - d1) * alpha >> 8)) & 0xff00ff; \ - s &= 0xff00; \ - d &= 0xff00; \ - d = (d + ((s - d) * alpha >> 8)) & 0xff00; \ - *dst++ = d1 | d; \ - } \ +#define ALPHA_BLIT32_888(to, from, length, bpp, alpha) \ + do { \ + int i; \ + Uint32 *src = (Uint32 *)(from); \ + Uint32 *dst = (Uint32 *)(to); \ + for(i = 0; i < (int)(length); i++) { \ + Uint32 s = *src++; \ + Uint32 d = *dst; \ + Uint32 s1 = s & 0xff00ff; \ + Uint32 d1 = d & 0xff00ff; \ + d1 = (d1 + ((s1 - d1) * alpha >> 8)) & 0xff00ff; \ + s &= 0xff00; \ + d &= 0xff00; \ + d = (d + ((s - d) * alpha >> 8)) & 0xff00; \ + *dst++ = d1 | d; \ + } \ } while(0) /* @@ -144,98 +144,98 @@ do { \ * components at the same time. Since the smallest gap is here just * 5 bits, we have to scale alpha down to 5 bits as well. */ -#define ALPHA_BLIT16_565(to, from, length, bpp, alpha) \ - do { \ - int i; \ - Uint16 *src = (Uint16 *)(from); \ - Uint16 *dst = (Uint16 *)(to); \ - Uint32 ALPHA = alpha >> 3; \ - for(i = 0; i < (int)(length); i++) { \ - Uint32 s = *src++; \ - Uint32 d = *dst; \ - s = (s | s << 16) & 0x07e0f81f; \ - d = (d | d << 16) & 0x07e0f81f; \ - d += (s - d) * ALPHA >> 5; \ - d &= 0x07e0f81f; \ - *dst++ = (Uint16)(d | d >> 16); \ - } \ +#define ALPHA_BLIT16_565(to, from, length, bpp, alpha) \ + do { \ + int i; \ + Uint16 *src = (Uint16 *)(from); \ + Uint16 *dst = (Uint16 *)(to); \ + Uint32 ALPHA = alpha >> 3; \ + for(i = 0; i < (int)(length); i++) { \ + Uint32 s = *src++; \ + Uint32 d = *dst; \ + s = (s | s << 16) & 0x07e0f81f; \ + d = (d | d << 16) & 0x07e0f81f; \ + d += (s - d) * ALPHA >> 5; \ + d &= 0x07e0f81f; \ + *dst++ = (Uint16)(d | d >> 16); \ + } \ } while(0) -#define ALPHA_BLIT16_555(to, from, length, bpp, alpha) \ - do { \ - int i; \ - Uint16 *src = (Uint16 *)(from); \ - Uint16 *dst = (Uint16 *)(to); \ - Uint32 ALPHA = alpha >> 3; \ - for(i = 0; i < (int)(length); i++) { \ - Uint32 s = *src++; \ - Uint32 d = *dst; \ - s = (s | s << 16) & 0x03e07c1f; \ - d = (d | d << 16) & 0x03e07c1f; \ - d += (s - d) * ALPHA >> 5; \ - d &= 0x03e07c1f; \ - *dst++ = (Uint16)(d | d >> 16); \ - } \ +#define ALPHA_BLIT16_555(to, from, length, bpp, alpha) \ + do { \ + int i; \ + Uint16 *src = (Uint16 *)(from); \ + Uint16 *dst = (Uint16 *)(to); \ + Uint32 ALPHA = alpha >> 3; \ + for(i = 0; i < (int)(length); i++) { \ + Uint32 s = *src++; \ + Uint32 d = *dst; \ + s = (s | s << 16) & 0x03e07c1f; \ + d = (d | d << 16) & 0x03e07c1f; \ + d += (s - d) * ALPHA >> 5; \ + d &= 0x03e07c1f; \ + *dst++ = (Uint16)(d | d >> 16); \ + } \ } while(0) /* * The general slow catch-all function, for remaining depths and formats */ -#define ALPHA_BLIT_ANY(to, from, length, bpp, alpha) \ - do { \ - int i; \ - Uint8 *src = from; \ - Uint8 *dst = to; \ - for(i = 0; i < (int)(length); i++) { \ - Uint32 s, d; \ - unsigned rs, gs, bs, rd, gd, bd; \ - switch(bpp) { \ - case 2: \ - s = *(Uint16 *)src; \ - d = *(Uint16 *)dst; \ - break; \ - case 3: \ - if(SDL_BYTEORDER == SDL_BIG_ENDIAN) { \ - s = (src[0] << 16) | (src[1] << 8) | src[2]; \ - d = (dst[0] << 16) | (dst[1] << 8) | dst[2]; \ - } else { \ - s = (src[2] << 16) | (src[1] << 8) | src[0]; \ - d = (dst[2] << 16) | (dst[1] << 8) | dst[0]; \ - } \ - break; \ - case 4: \ - s = *(Uint32 *)src; \ - d = *(Uint32 *)dst; \ - break; \ - } \ - RGB_FROM_PIXEL(s, fmt, rs, gs, bs); \ - RGB_FROM_PIXEL(d, fmt, rd, gd, bd); \ - rd += (rs - rd) * alpha >> 8; \ - gd += (gs - gd) * alpha >> 8; \ - bd += (bs - bd) * alpha >> 8; \ - PIXEL_FROM_RGB(d, fmt, rd, gd, bd); \ - switch(bpp) { \ - case 2: \ - *(Uint16 *)dst = (Uint16)d; \ - break; \ - case 3: \ - if(SDL_BYTEORDER == SDL_BIG_ENDIAN) { \ - dst[0] = (Uint8)(d >> 16); \ - dst[1] = (Uint8)(d >> 8); \ - dst[2] = (Uint8)(d); \ - } else { \ - dst[0] = (Uint8)d; \ - dst[1] = (Uint8)(d >> 8); \ - dst[2] = (Uint8)(d >> 16); \ - } \ - break; \ - case 4: \ - *(Uint32 *)dst = d; \ - break; \ - } \ - src += bpp; \ - dst += bpp; \ - } \ +#define ALPHA_BLIT_ANY(to, from, length, bpp, alpha) \ + do { \ + int i; \ + Uint8 *src = from; \ + Uint8 *dst = to; \ + for(i = 0; i < (int)(length); i++) { \ + Uint32 s, d; \ + unsigned rs, gs, bs, rd, gd, bd; \ + switch(bpp) { \ + case 2: \ + s = *(Uint16 *)src; \ + d = *(Uint16 *)dst; \ + break; \ + case 3: \ + if(SDL_BYTEORDER == SDL_BIG_ENDIAN) { \ + s = (src[0] << 16) | (src[1] << 8) | src[2]; \ + d = (dst[0] << 16) | (dst[1] << 8) | dst[2]; \ + } else { \ + s = (src[2] << 16) | (src[1] << 8) | src[0]; \ + d = (dst[2] << 16) | (dst[1] << 8) | dst[0]; \ + } \ + break; \ + case 4: \ + s = *(Uint32 *)src; \ + d = *(Uint32 *)dst; \ + break; \ + } \ + RGB_FROM_PIXEL(s, fmt, rs, gs, bs); \ + RGB_FROM_PIXEL(d, fmt, rd, gd, bd); \ + rd += (rs - rd) * alpha >> 8; \ + gd += (gs - gd) * alpha >> 8; \ + bd += (bs - bd) * alpha >> 8; \ + PIXEL_FROM_RGB(d, fmt, rd, gd, bd); \ + switch(bpp) { \ + case 2: \ + *(Uint16 *)dst = (Uint16)d; \ + break; \ + case 3: \ + if(SDL_BYTEORDER == SDL_BIG_ENDIAN) { \ + dst[0] = (Uint8)(d >> 16); \ + dst[1] = (Uint8)(d >> 8); \ + dst[2] = (Uint8)(d); \ + } else { \ + dst[0] = (Uint8)d; \ + dst[1] = (Uint8)(d >> 8); \ + dst[2] = (Uint8)(d >> 16); \ + } \ + break; \ + case 4: \ + *(Uint32 *)dst = d; \ + break; \ + } \ + src += bpp; \ + dst += bpp; \ + } \ } while(0) /* @@ -246,17 +246,17 @@ do { \ * First zero the lowest bit of each component, which gives us room to * add them. Then shift right and add the sum of the lowest bits. */ -#define ALPHA_BLIT32_888_50(to, from, length, bpp, alpha) \ - do { \ - int i; \ - Uint32 *src = (Uint32 *)(from); \ - Uint32 *dst = (Uint32 *)(to); \ - for(i = 0; i < (int)(length); i++) { \ - Uint32 s = *src++; \ - Uint32 d = *dst; \ - *dst++ = (((s & 0x00fefefe) + (d & 0x00fefefe)) >> 1) \ - + (s & d & 0x00010101); \ - } \ +#define ALPHA_BLIT32_888_50(to, from, length, bpp, alpha) \ + do { \ + int i; \ + Uint32 *src = (Uint32 *)(from); \ + Uint32 *dst = (Uint32 *)(to); \ + for(i = 0; i < (int)(length); i++) { \ + Uint32 s = *src++; \ + Uint32 d = *dst; \ + *dst++ = (((s & 0x00fefefe) + (d & 0x00fefefe)) >> 1) \ + + (s & d & 0x00010101); \ + } \ } while(0) /* @@ -265,116 +265,116 @@ do { \ */ /* helper: blend a single 16 bit pixel at 50% */ -#define BLEND16_50(dst, src, mask) \ - do { \ - Uint32 s = *src++; \ - Uint32 d = *dst; \ - *dst++ = (Uint16)((((s & mask) + (d & mask)) >> 1) + \ - (s & d & (~mask & 0xffff))); \ +#define BLEND16_50(dst, src, mask) \ + do { \ + Uint32 s = *src++; \ + Uint32 d = *dst; \ + *dst++ = (Uint16)((((s & mask) + (d & mask)) >> 1) + \ + (s & d & (~mask & 0xffff))); \ } while(0) /* basic 16bpp blender. mask is the pixels to keep when adding. */ -#define ALPHA_BLIT16_50(to, from, length, bpp, alpha, mask) \ - do { \ - unsigned n = (length); \ - Uint16 *src = (Uint16 *)(from); \ - Uint16 *dst = (Uint16 *)(to); \ - if(((uintptr_t)src ^ (uintptr_t)dst) & 3) { \ - /* source and destination not in phase, blit one by one */ \ - while(n--) \ - BLEND16_50(dst, src, mask); \ - } else { \ - if((uintptr_t)src & 3) { \ - /* first odd pixel */ \ - BLEND16_50(dst, src, mask); \ - n--; \ - } \ - for(; n > 1; n -= 2) { \ - Uint32 s = *(Uint32 *)src; \ - Uint32 d = *(Uint32 *)dst; \ - *(Uint32 *)dst = ((s & (mask | mask << 16)) >> 1) \ - + ((d & (mask | mask << 16)) >> 1) \ - + (s & d & (~(mask | mask << 16))); \ - src += 2; \ - dst += 2; \ - } \ - if(n) \ - BLEND16_50(dst, src, mask); /* last odd pixel */ \ - } \ +#define ALPHA_BLIT16_50(to, from, length, bpp, alpha, mask) \ + do { \ + unsigned n = (length); \ + Uint16 *src = (Uint16 *)(from); \ + Uint16 *dst = (Uint16 *)(to); \ + if(((uintptr_t)src ^ (uintptr_t)dst) & 3) { \ + /* source and destination not in phase, blit one by one */ \ + while(n--) \ + BLEND16_50(dst, src, mask); \ + } else { \ + if((uintptr_t)src & 3) { \ + /* first odd pixel */ \ + BLEND16_50(dst, src, mask); \ + n--; \ + } \ + for(; n > 1; n -= 2) { \ + Uint32 s = *(Uint32 *)src; \ + Uint32 d = *(Uint32 *)dst; \ + *(Uint32 *)dst = ((s & (mask | mask << 16)) >> 1) \ + + ((d & (mask | mask << 16)) >> 1) \ + + (s & d & (~(mask | mask << 16))); \ + src += 2; \ + dst += 2; \ + } \ + if(n) \ + BLEND16_50(dst, src, mask); /* last odd pixel */ \ + } \ } while(0) -#define ALPHA_BLIT16_565_50(to, from, length, bpp, alpha) \ +#define ALPHA_BLIT16_565_50(to, from, length, bpp, alpha) \ ALPHA_BLIT16_50(to, from, length, bpp, alpha, 0xf7de) -#define ALPHA_BLIT16_555_50(to, from, length, bpp, alpha) \ +#define ALPHA_BLIT16_555_50(to, from, length, bpp, alpha) \ ALPHA_BLIT16_50(to, from, length, bpp, alpha, 0xfbde) -#define CHOOSE_BLIT(blitter, alpha, fmt) \ - do { \ - if(alpha == 255) { \ - switch(fmt->BytesPerPixel) { \ - case 1: blitter(1, Uint8, OPAQUE_BLIT); break; \ - case 2: blitter(2, Uint8, OPAQUE_BLIT); break; \ - case 3: blitter(3, Uint8, OPAQUE_BLIT); break; \ - case 4: blitter(4, Uint16, OPAQUE_BLIT); break; \ - } \ - } else { \ - switch(fmt->BytesPerPixel) { \ - case 1: \ - /* No 8bpp alpha blitting */ \ - break; \ - \ - case 2: \ - switch(fmt->Rmask | fmt->Gmask | fmt->Bmask) { \ - case 0xffff: \ - if(fmt->Gmask == 0x07e0 \ - || fmt->Rmask == 0x07e0 \ - || fmt->Bmask == 0x07e0) { \ - if(alpha == 128) \ - blitter(2, Uint8, ALPHA_BLIT16_565_50); \ - else { \ - blitter(2, Uint8, ALPHA_BLIT16_565); \ - } \ - } else \ - goto general16; \ - break; \ - \ - case 0x7fff: \ - if(fmt->Gmask == 0x03e0 \ - || fmt->Rmask == 0x03e0 \ - || fmt->Bmask == 0x03e0) { \ - if(alpha == 128) \ - blitter(2, Uint8, ALPHA_BLIT16_555_50); \ - else { \ - blitter(2, Uint8, ALPHA_BLIT16_555); \ - } \ - break; \ - } \ - /* fallthrough */ \ - \ - default: \ - general16: \ - blitter(2, Uint8, ALPHA_BLIT_ANY); \ - } \ - break; \ - \ - case 3: \ - blitter(3, Uint8, ALPHA_BLIT_ANY); \ - break; \ - \ - case 4: \ - if((fmt->Rmask | fmt->Gmask | fmt->Bmask) == 0x00ffffff \ - && (fmt->Gmask == 0xff00 || fmt->Rmask == 0xff00 \ - || fmt->Bmask == 0xff00)) { \ - if(alpha == 128) \ - blitter(4, Uint16, ALPHA_BLIT32_888_50); \ - else \ - blitter(4, Uint16, ALPHA_BLIT32_888); \ - } else \ - blitter(4, Uint16, ALPHA_BLIT_ANY); \ - break; \ - } \ - } \ +#define CHOOSE_BLIT(blitter, alpha, fmt) \ + do { \ + if(alpha == 255) { \ + switch(fmt->BytesPerPixel) { \ + case 1: blitter(1, Uint8, OPAQUE_BLIT); break; \ + case 2: blitter(2, Uint8, OPAQUE_BLIT); break; \ + case 3: blitter(3, Uint8, OPAQUE_BLIT); break; \ + case 4: blitter(4, Uint16, OPAQUE_BLIT); break; \ + } \ + } else { \ + switch(fmt->BytesPerPixel) { \ + case 1: \ + /* No 8bpp alpha blitting */ \ + break; \ + \ + case 2: \ + switch(fmt->Rmask | fmt->Gmask | fmt->Bmask) { \ + case 0xffff: \ + if(fmt->Gmask == 0x07e0 \ + || fmt->Rmask == 0x07e0 \ + || fmt->Bmask == 0x07e0) { \ + if(alpha == 128) \ + blitter(2, Uint8, ALPHA_BLIT16_565_50); \ + else { \ + blitter(2, Uint8, ALPHA_BLIT16_565); \ + } \ + } else \ + goto general16; \ + break; \ + \ + case 0x7fff: \ + if(fmt->Gmask == 0x03e0 \ + || fmt->Rmask == 0x03e0 \ + || fmt->Bmask == 0x03e0) { \ + if(alpha == 128) \ + blitter(2, Uint8, ALPHA_BLIT16_555_50); \ + else { \ + blitter(2, Uint8, ALPHA_BLIT16_555); \ + } \ + break; \ + } \ + /* fallthrough */ \ + \ + default: \ + general16: \ + blitter(2, Uint8, ALPHA_BLIT_ANY); \ + } \ + break; \ + \ + case 3: \ + blitter(3, Uint8, ALPHA_BLIT_ANY); \ + break; \ + \ + case 4: \ + if((fmt->Rmask | fmt->Gmask | fmt->Bmask) == 0x00ffffff \ + && (fmt->Gmask == 0xff00 || fmt->Rmask == 0xff00 \ + || fmt->Bmask == 0xff00)) { \ + if(alpha == 128) \ + blitter(4, Uint16, ALPHA_BLIT32_888_50); \ + else \ + blitter(4, Uint16, ALPHA_BLIT32_888); \ + } else \ + blitter(4, Uint16, ALPHA_BLIT_ANY); \ + break; \ + } \ + } \ } while(0) /* @@ -387,48 +387,48 @@ RLEClipBlit(int w, Uint8 * srcbuf, SDL_Surface * dst, { SDL_PixelFormat *fmt = dst->format; -#define RLECLIPBLIT(bpp, Type, do_blit) \ - do { \ - int linecount = srcrect->h; \ - int ofs = 0; \ - int left = srcrect->x; \ - int right = left + srcrect->w; \ - dstbuf -= left * bpp; \ - for(;;) { \ - int run; \ - ofs += *(Type *)srcbuf; \ - run = ((Type *)srcbuf)[1]; \ - srcbuf += 2 * sizeof(Type); \ - if(run) { \ - /* clip to left and right borders */ \ - if(ofs < right) { \ - int start = 0; \ - int len = run; \ - int startcol; \ - if(left - ofs > 0) { \ - start = left - ofs; \ - len -= start; \ - if(len <= 0) \ - goto nocopy ## bpp ## do_blit; \ - } \ - startcol = ofs + start; \ - if(len > right - startcol) \ - len = right - startcol; \ - do_blit(dstbuf + startcol * bpp, srcbuf + start * bpp, \ - len, bpp, alpha); \ - } \ - nocopy ## bpp ## do_blit: \ - srcbuf += run * bpp; \ - ofs += run; \ - } else if(!ofs) \ - break; \ - if(ofs == w) { \ - ofs = 0; \ - dstbuf += dst->pitch; \ - if(!--linecount) \ - break; \ - } \ - } \ +#define RLECLIPBLIT(bpp, Type, do_blit) \ + do { \ + int linecount = srcrect->h; \ + int ofs = 0; \ + int left = srcrect->x; \ + int right = left + srcrect->w; \ + dstbuf -= left * bpp; \ + for(;;) { \ + int run; \ + ofs += *(Type *)srcbuf; \ + run = ((Type *)srcbuf)[1]; \ + srcbuf += 2 * sizeof(Type); \ + if(run) { \ + /* clip to left and right borders */ \ + if(ofs < right) { \ + int start = 0; \ + int len = run; \ + int startcol; \ + if(left - ofs > 0) { \ + start = left - ofs; \ + len -= start; \ + if(len <= 0) \ + goto nocopy ## bpp ## do_blit; \ + } \ + startcol = ofs + start; \ + if(len > right - startcol) \ + len = right - startcol; \ + do_blit(dstbuf + startcol * bpp, srcbuf + start * bpp, \ + len, bpp, alpha); \ + } \ + nocopy ## bpp ## do_blit: \ + srcbuf += run * bpp; \ + ofs += run; \ + } else if(!ofs) \ + break; \ + if(ofs == w) { \ + ofs = 0; \ + dstbuf += dst->pitch; \ + if(!--linecount) \ + break; \ + } \ + } \ } while(0) CHOOSE_BLIT(RLECLIPBLIT, alpha, fmt); @@ -469,23 +469,23 @@ SDL_RLEBlit(SDL_Surface * src, SDL_Rect * srcrect, int ofs = 0; if (vskip) { -#define RLESKIP(bpp, Type) \ - for(;;) { \ - int run; \ - ofs += *(Type *)srcbuf; \ - run = ((Type *)srcbuf)[1]; \ - srcbuf += sizeof(Type) * 2; \ - if(run) { \ - srcbuf += run * bpp; \ - ofs += run; \ - } else if(!ofs) \ - goto done; \ - if(ofs == w) { \ - ofs = 0; \ - if(!--vskip) \ - break; \ - } \ - } +#define RLESKIP(bpp, Type) \ + for(;;) { \ + int run; \ + ofs += *(Type *)srcbuf; \ + run = ((Type *)srcbuf)[1]; \ + srcbuf += sizeof(Type) * 2; \ + if(run) { \ + srcbuf += run * bpp; \ + ofs += run; \ + } else if(!ofs) \ + goto done; \ + if(ofs == w) { \ + ofs = 0; \ + if(!--vskip) \ + break; \ + } \ + } switch (src->format->BytesPerPixel) { case 1: @@ -514,29 +514,29 @@ SDL_RLEBlit(SDL_Surface * src, SDL_Rect * srcrect, } else { SDL_PixelFormat *fmt = src->format; -#define RLEBLIT(bpp, Type, do_blit) \ - do { \ - int linecount = srcrect->h; \ - int ofs = 0; \ - for(;;) { \ - unsigned run; \ - ofs += *(Type *)srcbuf; \ - run = ((Type *)srcbuf)[1]; \ - srcbuf += 2 * sizeof(Type); \ - if(run) { \ - do_blit(dstbuf + ofs * bpp, srcbuf, run, bpp, alpha); \ - srcbuf += run * bpp; \ - ofs += run; \ - } else if(!ofs) \ - break; \ - if(ofs == w) { \ - ofs = 0; \ - dstbuf += dst->pitch; \ - if(!--linecount) \ - break; \ - } \ - } \ - } while(0) +#define RLEBLIT(bpp, Type, do_blit) \ + do { \ + int linecount = srcrect->h; \ + int ofs = 0; \ + for(;;) { \ + unsigned run; \ + ofs += *(Type *)srcbuf; \ + run = ((Type *)srcbuf)[1]; \ + srcbuf += 2 * sizeof(Type); \ + if(run) { \ + do_blit(dstbuf + ofs * bpp, srcbuf, run, bpp, alpha); \ + srcbuf += run * bpp; \ + ofs += run; \ + } else if(!ofs) \ + break; \ + if(ofs == w) { \ + ofs = 0; \ + dstbuf += dst->pitch; \ + if(!--linecount) \ + break; \ + } \ + } \ + } while(0) CHOOSE_BLIT(RLEBLIT, alpha, fmt); @@ -562,46 +562,46 @@ SDL_RLEBlit(SDL_Surface * src, SDL_Rect * srcrect, * For 32bpp pixels, we have made sure the alpha is stored in the top * 8 bits, so proceed as usual */ -#define BLIT_TRANSL_888(src, dst) \ - do { \ - Uint32 s = src; \ - Uint32 d = dst; \ - unsigned alpha = s >> 24; \ - Uint32 s1 = s & 0xff00ff; \ - Uint32 d1 = d & 0xff00ff; \ - d1 = (d1 + ((s1 - d1) * alpha >> 8)) & 0xff00ff; \ - s &= 0xff00; \ - d &= 0xff00; \ - d = (d + ((s - d) * alpha >> 8)) & 0xff00; \ - dst = d1 | d | 0xff000000; \ +#define BLIT_TRANSL_888(src, dst) \ + do { \ + Uint32 s = src; \ + Uint32 d = dst; \ + unsigned alpha = s >> 24; \ + Uint32 s1 = s & 0xff00ff; \ + Uint32 d1 = d & 0xff00ff; \ + d1 = (d1 + ((s1 - d1) * alpha >> 8)) & 0xff00ff; \ + s &= 0xff00; \ + d &= 0xff00; \ + d = (d + ((s - d) * alpha >> 8)) & 0xff00; \ + dst = d1 | d | 0xff000000; \ } while(0) /* * For 16bpp pixels, we have stored the 5 most significant alpha bits in * bits 5-10. As before, we can process all 3 RGB components at the same time. */ -#define BLIT_TRANSL_565(src, dst) \ - do { \ - Uint32 s = src; \ - Uint32 d = dst; \ - unsigned alpha = (s & 0x3e0) >> 5; \ - s &= 0x07e0f81f; \ - d = (d | d << 16) & 0x07e0f81f; \ - d += (s - d) * alpha >> 5; \ - d &= 0x07e0f81f; \ - dst = (Uint16)(d | d >> 16); \ +#define BLIT_TRANSL_565(src, dst) \ + do { \ + Uint32 s = src; \ + Uint32 d = dst; \ + unsigned alpha = (s & 0x3e0) >> 5; \ + s &= 0x07e0f81f; \ + d = (d | d << 16) & 0x07e0f81f; \ + d += (s - d) * alpha >> 5; \ + d &= 0x07e0f81f; \ + dst = (Uint16)(d | d >> 16); \ } while(0) -#define BLIT_TRANSL_555(src, dst) \ - do { \ - Uint32 s = src; \ - Uint32 d = dst; \ - unsigned alpha = (s & 0x3e0) >> 5; \ - s &= 0x03e07c1f; \ - d = (d | d << 16) & 0x03e07c1f; \ - d += (s - d) * alpha >> 5; \ - d &= 0x03e07c1f; \ - dst = (Uint16)(d | d >> 16); \ +#define BLIT_TRANSL_555(src, dst) \ + do { \ + Uint32 s = src; \ + Uint32 d = dst; \ + unsigned alpha = (s & 0x3e0) >> 5; \ + s &= 0x03e07c1f; \ + d = (d | d << 16) & 0x03e07c1f; \ + d += (s - d) * alpha >> 5; \ + d &= 0x03e07c1f; \ + dst = (Uint16)(d | d >> 16); \ } while(0) /* used to save the destination format in the encoding. Designed to be @@ -635,72 +635,72 @@ RLEAlphaClipBlit(int w, Uint8 * srcbuf, SDL_Surface * dst, * Ctype the translucent count type, and do_blend the macro * to blend one pixel. */ -#define RLEALPHACLIPBLIT(Ptype, Ctype, do_blend) \ - do { \ - int linecount = srcrect->h; \ - int left = srcrect->x; \ - int right = left + srcrect->w; \ - dstbuf -= left * sizeof(Ptype); \ - do { \ - int ofs = 0; \ - /* blit opaque pixels on one line */ \ - do { \ - unsigned run; \ - ofs += ((Ctype *)srcbuf)[0]; \ - run = ((Ctype *)srcbuf)[1]; \ - srcbuf += 2 * sizeof(Ctype); \ - if(run) { \ - /* clip to left and right borders */ \ - int cofs = ofs; \ - int crun = run; \ - if(left - cofs > 0) { \ - crun -= left - cofs; \ - cofs = left; \ - } \ - if(crun > right - cofs) \ - crun = right - cofs; \ - if(crun > 0) \ - PIXEL_COPY(dstbuf + cofs * sizeof(Ptype), \ - srcbuf + (cofs - ofs) * sizeof(Ptype), \ - (unsigned)crun, sizeof(Ptype)); \ - srcbuf += run * sizeof(Ptype); \ - ofs += run; \ - } else if(!ofs) \ - return; \ - } while(ofs < w); \ - /* skip padding if necessary */ \ - if(sizeof(Ptype) == 2) \ - srcbuf += (uintptr_t)srcbuf & 2; \ - /* blit translucent pixels on the same line */ \ - ofs = 0; \ - do { \ - unsigned run; \ - ofs += ((Uint16 *)srcbuf)[0]; \ - run = ((Uint16 *)srcbuf)[1]; \ - srcbuf += 4; \ - if(run) { \ - /* clip to left and right borders */ \ - int cofs = ofs; \ - int crun = run; \ - if(left - cofs > 0) { \ - crun -= left - cofs; \ - cofs = left; \ - } \ - if(crun > right - cofs) \ - crun = right - cofs; \ - if(crun > 0) { \ - Ptype *dst = (Ptype *)dstbuf + cofs; \ - Uint32 *src = (Uint32 *)srcbuf + (cofs - ofs); \ - int i; \ - for(i = 0; i < crun; i++) \ - do_blend(src[i], dst[i]); \ - } \ - srcbuf += run * 4; \ - ofs += run; \ - } \ - } while(ofs < w); \ - dstbuf += dst->pitch; \ - } while(--linecount); \ +#define RLEALPHACLIPBLIT(Ptype, Ctype, do_blend) \ + do { \ + int linecount = srcrect->h; \ + int left = srcrect->x; \ + int right = left + srcrect->w; \ + dstbuf -= left * sizeof(Ptype); \ + do { \ + int ofs = 0; \ + /* blit opaque pixels on one line */ \ + do { \ + unsigned run; \ + ofs += ((Ctype *)srcbuf)[0]; \ + run = ((Ctype *)srcbuf)[1]; \ + srcbuf += 2 * sizeof(Ctype); \ + if(run) { \ + /* clip to left and right borders */ \ + int cofs = ofs; \ + int crun = run; \ + if(left - cofs > 0) { \ + crun -= left - cofs; \ + cofs = left; \ + } \ + if(crun > right - cofs) \ + crun = right - cofs; \ + if(crun > 0) \ + PIXEL_COPY(dstbuf + cofs * sizeof(Ptype), \ + srcbuf + (cofs - ofs) * sizeof(Ptype), \ + (unsigned)crun, sizeof(Ptype)); \ + srcbuf += run * sizeof(Ptype); \ + ofs += run; \ + } else if(!ofs) \ + return; \ + } while(ofs < w); \ + /* skip padding if necessary */ \ + if(sizeof(Ptype) == 2) \ + srcbuf += (uintptr_t)srcbuf & 2; \ + /* blit translucent pixels on the same line */ \ + ofs = 0; \ + do { \ + unsigned run; \ + ofs += ((Uint16 *)srcbuf)[0]; \ + run = ((Uint16 *)srcbuf)[1]; \ + srcbuf += 4; \ + if(run) { \ + /* clip to left and right borders */ \ + int cofs = ofs; \ + int crun = run; \ + if(left - cofs > 0) { \ + crun -= left - cofs; \ + cofs = left; \ + } \ + if(crun > right - cofs) \ + crun = right - cofs; \ + if(crun > 0) { \ + Ptype *dst = (Ptype *)dstbuf + cofs; \ + Uint32 *src = (Uint32 *)srcbuf + (cofs - ofs); \ + int i; \ + for(i = 0; i < crun; i++) \ + do_blend(src[i], dst[i]); \ + } \ + srcbuf += run * 4; \ + ofs += run; \ + } \ + } while(ofs < w); \ + dstbuf += dst->pitch; \ + } while(--linecount); \ } while(0) switch (df->BytesPerPixel) { @@ -804,50 +804,50 @@ SDL_RLEAlphaBlit(SDL_Surface * src, SDL_Rect * srcrect, * Ctype the translucent count type, and do_blend the * macro to blend one pixel. */ -#define RLEALPHABLIT(Ptype, Ctype, do_blend) \ - do { \ - int linecount = srcrect->h; \ - do { \ - int ofs = 0; \ - /* blit opaque pixels on one line */ \ - do { \ - unsigned run; \ - ofs += ((Ctype *)srcbuf)[0]; \ - run = ((Ctype *)srcbuf)[1]; \ - srcbuf += 2 * sizeof(Ctype); \ - if(run) { \ - PIXEL_COPY(dstbuf + ofs * sizeof(Ptype), srcbuf, \ - run, sizeof(Ptype)); \ - srcbuf += run * sizeof(Ptype); \ - ofs += run; \ - } else if(!ofs) \ - goto done; \ - } while(ofs < w); \ - /* skip padding if necessary */ \ - if(sizeof(Ptype) == 2) \ - srcbuf += (uintptr_t)srcbuf & 2; \ - /* blit translucent pixels on the same line */ \ - ofs = 0; \ - do { \ - unsigned run; \ - ofs += ((Uint16 *)srcbuf)[0]; \ - run = ((Uint16 *)srcbuf)[1]; \ - srcbuf += 4; \ - if(run) { \ - Ptype *dst = (Ptype *)dstbuf + ofs; \ - unsigned i; \ - for(i = 0; i < run; i++) { \ - Uint32 src = *(Uint32 *)srcbuf; \ - do_blend(src, *dst); \ - srcbuf += 4; \ - dst++; \ - } \ - ofs += run; \ - } \ - } while(ofs < w); \ - dstbuf += dst->pitch; \ - } while(--linecount); \ - } while(0) +#define RLEALPHABLIT(Ptype, Ctype, do_blend) \ + do { \ + int linecount = srcrect->h; \ + do { \ + int ofs = 0; \ + /* blit opaque pixels on one line */ \ + do { \ + unsigned run; \ + ofs += ((Ctype *)srcbuf)[0]; \ + run = ((Ctype *)srcbuf)[1]; \ + srcbuf += 2 * sizeof(Ctype); \ + if(run) { \ + PIXEL_COPY(dstbuf + ofs * sizeof(Ptype), srcbuf, \ + run, sizeof(Ptype)); \ + srcbuf += run * sizeof(Ptype); \ + ofs += run; \ + } else if(!ofs) \ + goto done; \ + } while(ofs < w); \ + /* skip padding if necessary */ \ + if(sizeof(Ptype) == 2) \ + srcbuf += (uintptr_t)srcbuf & 2; \ + /* blit translucent pixels on the same line */ \ + ofs = 0; \ + do { \ + unsigned run; \ + ofs += ((Uint16 *)srcbuf)[0]; \ + run = ((Uint16 *)srcbuf)[1]; \ + srcbuf += 4; \ + if(run) { \ + Ptype *dst = (Ptype *)dstbuf + ofs; \ + unsigned i; \ + for(i = 0; i < run; i++) { \ + Uint32 src = *(Uint32 *)srcbuf; \ + do_blend(src, *dst); \ + srcbuf += 4; \ + dst++; \ + } \ + ofs += run; \ + } \ + } while(ofs < w); \ + dstbuf += dst->pitch; \ + } while(--linecount); \ + } while(0) switch (df->BytesPerPixel) { case 2: @@ -1012,7 +1012,7 @@ uncopy_32(Uint32 * dst, void *src, int n, #define ISOPAQUE(pixel, fmt) ((((pixel) & fmt->Amask) >> fmt->Ashift) == 255) -#define ISTRANSL(pixel, fmt) \ +#define ISTRANSL(pixel, fmt) \ ((unsigned)((((pixel) & fmt->Amask) >> fmt->Ashift) - 1U) < 254U) /* convert surface to be quickly alpha-blittable onto dest, if possible */ @@ -1117,20 +1117,20 @@ RLEAlphaSurface(SDL_Surface * surface) Uint8 *lastline = dst; /* end of last non-blank line */ /* opaque counts are 8 or 16 bits, depending on target depth */ -#define ADD_OPAQUE_COUNTS(n, m) \ - if(df->BytesPerPixel == 4) { \ - ((Uint16 *)dst)[0] = n; \ - ((Uint16 *)dst)[1] = m; \ - dst += 4; \ - } else { \ - dst[0] = n; \ - dst[1] = m; \ - dst += 2; \ - } +#define ADD_OPAQUE_COUNTS(n, m) \ + if(df->BytesPerPixel == 4) { \ + ((Uint16 *)dst)[0] = n; \ + ((Uint16 *)dst)[1] = m; \ + dst += 4; \ + } else { \ + dst[0] = n; \ + dst[1] = m; \ + dst += 2; \ + } /* translucent counts are always 16 bit */ -#define ADD_TRANSL_COUNTS(n, m) \ - (((Uint16 *)dst)[0] = n, ((Uint16 *)dst)[1] = m, dst += 4) +#define ADD_TRANSL_COUNTS(n, m) \ + (((Uint16 *)dst)[0] = n, ((Uint16 *)dst)[1] = m, dst += 4) for (y = 0; y < h; y++) { int runstart, skipstart; @@ -1312,16 +1312,16 @@ RLEColorkeySurface(SDL_Surface * surface) w = surface->w; h = surface->h; -#define ADD_COUNTS(n, m) \ - if(bpp == 4) { \ - ((Uint16 *)dst)[0] = n; \ - ((Uint16 *)dst)[1] = m; \ - dst += 4; \ - } else { \ - dst[0] = n; \ - dst[1] = m; \ - dst += 2; \ - } +#define ADD_COUNTS(n, m) \ + if(bpp == 4) { \ + ((Uint16 *)dst)[0] = n; \ + ((Uint16 *)dst)[1] = m; \ + dst += 4; \ + } else { \ + dst[0] = n; \ + dst[1] = m; \ + dst += 2; \ + } for (y = 0; y < h; y++) { int x = 0; diff --git a/src/video/SDL_blit.h b/src/video/SDL_blit.h index e9965561a..7243e6193 100644 --- a/src/video/SDL_blit.h +++ b/src/video/SDL_blit.h @@ -118,289 +118,289 @@ extern SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface * surface); #endif /* Load pixel of the specified format from a buffer and get its R-G-B values */ -#define RGB_FROM_PIXEL(Pixel, fmt, r, g, b) \ -{ \ - r = SDL_expand_byte[fmt->Rloss][((Pixel&fmt->Rmask)>>fmt->Rshift)]; \ - g = SDL_expand_byte[fmt->Gloss][((Pixel&fmt->Gmask)>>fmt->Gshift)]; \ - b = SDL_expand_byte[fmt->Bloss][((Pixel&fmt->Bmask)>>fmt->Bshift)]; \ +#define RGB_FROM_PIXEL(Pixel, fmt, r, g, b) \ +{ \ + r = SDL_expand_byte[fmt->Rloss][((Pixel&fmt->Rmask)>>fmt->Rshift)]; \ + g = SDL_expand_byte[fmt->Gloss][((Pixel&fmt->Gmask)>>fmt->Gshift)]; \ + b = SDL_expand_byte[fmt->Bloss][((Pixel&fmt->Bmask)>>fmt->Bshift)]; \ } -#define RGB_FROM_RGB565(Pixel, r, g, b) \ -{ \ - r = SDL_expand_byte[3][((Pixel&0xF800)>>11)]; \ - g = SDL_expand_byte[2][((Pixel&0x07E0)>>5)]; \ - b = SDL_expand_byte[3][(Pixel&0x001F)]; \ +#define RGB_FROM_RGB565(Pixel, r, g, b) \ +{ \ + r = SDL_expand_byte[3][((Pixel&0xF800)>>11)]; \ + g = SDL_expand_byte[2][((Pixel&0x07E0)>>5)]; \ + b = SDL_expand_byte[3][(Pixel&0x001F)]; \ } -#define RGB_FROM_RGB555(Pixel, r, g, b) \ -{ \ - r = SDL_expand_byte[3][((Pixel&0x7C00)>>10)]; \ - g = SDL_expand_byte[3][((Pixel&0x03E0)>>5)]; \ - b = SDL_expand_byte[3][(Pixel&0x001F)]; \ +#define RGB_FROM_RGB555(Pixel, r, g, b) \ +{ \ + r = SDL_expand_byte[3][((Pixel&0x7C00)>>10)]; \ + g = SDL_expand_byte[3][((Pixel&0x03E0)>>5)]; \ + b = SDL_expand_byte[3][(Pixel&0x001F)]; \ } -#define RGB_FROM_RGB888(Pixel, r, g, b) \ -{ \ - r = ((Pixel&0xFF0000)>>16); \ - g = ((Pixel&0xFF00)>>8); \ - b = (Pixel&0xFF); \ +#define RGB_FROM_RGB888(Pixel, r, g, b) \ +{ \ + r = ((Pixel&0xFF0000)>>16); \ + g = ((Pixel&0xFF00)>>8); \ + b = (Pixel&0xFF); \ } -#define RETRIEVE_RGB_PIXEL(buf, bpp, Pixel) \ -do { \ - switch (bpp) { \ - case 2: \ - Pixel = *((Uint16 *)(buf)); \ - break; \ - \ - case 3: { \ - Uint8 *B = (Uint8 *)(buf); \ - if (SDL_BYTEORDER == SDL_LIL_ENDIAN) { \ - Pixel = B[0] + (B[1] << 8) + (B[2] << 16); \ - } else { \ - Pixel = (B[0] << 16) + (B[1] << 8) + B[2]; \ - } \ - } \ - break; \ - \ - case 4: \ - Pixel = *((Uint32 *)(buf)); \ - break; \ - \ - default: \ - Pixel = 0; /* stop gcc complaints */ \ - break; \ - } \ +#define RETRIEVE_RGB_PIXEL(buf, bpp, Pixel) \ +do { \ + switch (bpp) { \ + case 2: \ + Pixel = *((Uint16 *)(buf)); \ + break; \ + \ + case 3: { \ + Uint8 *B = (Uint8 *)(buf); \ + if (SDL_BYTEORDER == SDL_LIL_ENDIAN) { \ + Pixel = B[0] + (B[1] << 8) + (B[2] << 16); \ + } else { \ + Pixel = (B[0] << 16) + (B[1] << 8) + B[2]; \ + } \ + } \ + break; \ + \ + case 4: \ + Pixel = *((Uint32 *)(buf)); \ + break; \ + \ + default: \ + Pixel = 0; /* stop gcc complaints */ \ + break; \ + } \ } while (0) -#define DISEMBLE_RGB(buf, bpp, fmt, Pixel, r, g, b) \ -do { \ - switch (bpp) { \ - case 2: \ - Pixel = *((Uint16 *)(buf)); \ - RGB_FROM_PIXEL(Pixel, fmt, r, g, b); \ - break; \ - \ - case 3: { \ +#define DISEMBLE_RGB(buf, bpp, fmt, Pixel, r, g, b) \ +do { \ + switch (bpp) { \ + case 2: \ + Pixel = *((Uint16 *)(buf)); \ + RGB_FROM_PIXEL(Pixel, fmt, r, g, b); \ + break; \ + \ + case 3: { \ Pixel = 0; \ - if (SDL_BYTEORDER == SDL_LIL_ENDIAN) { \ - r = *((buf)+fmt->Rshift/8); \ - g = *((buf)+fmt->Gshift/8); \ - b = *((buf)+fmt->Bshift/8); \ - } else { \ - r = *((buf)+2-fmt->Rshift/8); \ - g = *((buf)+2-fmt->Gshift/8); \ - b = *((buf)+2-fmt->Bshift/8); \ - } \ - } \ - break; \ - \ - case 4: \ - Pixel = *((Uint32 *)(buf)); \ - RGB_FROM_PIXEL(Pixel, fmt, r, g, b); \ - break; \ - \ - default: \ - /* stop gcc complaints */ \ - Pixel = 0; \ + if (SDL_BYTEORDER == SDL_LIL_ENDIAN) { \ + r = *((buf)+fmt->Rshift/8); \ + g = *((buf)+fmt->Gshift/8); \ + b = *((buf)+fmt->Bshift/8); \ + } else { \ + r = *((buf)+2-fmt->Rshift/8); \ + g = *((buf)+2-fmt->Gshift/8); \ + b = *((buf)+2-fmt->Bshift/8); \ + } \ + } \ + break; \ + \ + case 4: \ + Pixel = *((Uint32 *)(buf)); \ + RGB_FROM_PIXEL(Pixel, fmt, r, g, b); \ + break; \ + \ + default: \ + /* stop gcc complaints */ \ + Pixel = 0; \ r = g = b = 0; \ - break; \ - } \ + break; \ + } \ } while (0) /* Assemble R-G-B values into a specified pixel format and store them */ -#define PIXEL_FROM_RGB(Pixel, fmt, r, g, b) \ -{ \ - Pixel = ((r>>fmt->Rloss)<Rshift)| \ - ((g>>fmt->Gloss)<Gshift)| \ - ((b>>fmt->Bloss)<Bshift)| \ - fmt->Amask; \ +#define PIXEL_FROM_RGB(Pixel, fmt, r, g, b) \ +{ \ + Pixel = ((r>>fmt->Rloss)<Rshift)| \ + ((g>>fmt->Gloss)<Gshift)| \ + ((b>>fmt->Bloss)<Bshift)| \ + fmt->Amask; \ } -#define RGB565_FROM_RGB(Pixel, r, g, b) \ -{ \ - Pixel = ((r>>3)<<11)|((g>>2)<<5)|(b>>3); \ +#define RGB565_FROM_RGB(Pixel, r, g, b) \ +{ \ + Pixel = ((r>>3)<<11)|((g>>2)<<5)|(b>>3); \ } -#define RGB555_FROM_RGB(Pixel, r, g, b) \ -{ \ - Pixel = ((r>>3)<<10)|((g>>3)<<5)|(b>>3); \ +#define RGB555_FROM_RGB(Pixel, r, g, b) \ +{ \ + Pixel = ((r>>3)<<10)|((g>>3)<<5)|(b>>3); \ } -#define RGB888_FROM_RGB(Pixel, r, g, b) \ -{ \ - Pixel = (r<<16)|(g<<8)|b; \ +#define RGB888_FROM_RGB(Pixel, r, g, b) \ +{ \ + Pixel = (r<<16)|(g<<8)|b; \ } -#define ARGB8888_FROM_RGBA(Pixel, r, g, b, a) \ -{ \ - Pixel = (a<<24)|(r<<16)|(g<<8)|b; \ +#define ARGB8888_FROM_RGBA(Pixel, r, g, b, a) \ +{ \ + Pixel = (a<<24)|(r<<16)|(g<<8)|b; \ } -#define RGBA8888_FROM_RGBA(Pixel, r, g, b, a) \ -{ \ - Pixel = (r<<24)|(g<<16)|(b<<8)|a; \ +#define RGBA8888_FROM_RGBA(Pixel, r, g, b, a) \ +{ \ + Pixel = (r<<24)|(g<<16)|(b<<8)|a; \ } -#define ABGR8888_FROM_RGBA(Pixel, r, g, b, a) \ -{ \ - Pixel = (a<<24)|(b<<16)|(g<<8)|r; \ +#define ABGR8888_FROM_RGBA(Pixel, r, g, b, a) \ +{ \ + Pixel = (a<<24)|(b<<16)|(g<<8)|r; \ } -#define BGRA8888_FROM_RGBA(Pixel, r, g, b, a) \ -{ \ - Pixel = (b<<24)|(g<<16)|(r<<8)|a; \ +#define BGRA8888_FROM_RGBA(Pixel, r, g, b, a) \ +{ \ + Pixel = (b<<24)|(g<<16)|(r<<8)|a; \ } -#define ASSEMBLE_RGB(buf, bpp, fmt, r, g, b) \ -{ \ - switch (bpp) { \ - case 2: { \ - Uint16 Pixel; \ - \ - PIXEL_FROM_RGB(Pixel, fmt, r, g, b); \ - *((Uint16 *)(buf)) = Pixel; \ - } \ - break; \ - \ - case 3: { \ - if (SDL_BYTEORDER == SDL_LIL_ENDIAN) { \ - *((buf)+fmt->Rshift/8) = r; \ - *((buf)+fmt->Gshift/8) = g; \ - *((buf)+fmt->Bshift/8) = b; \ - } else { \ - *((buf)+2-fmt->Rshift/8) = r; \ - *((buf)+2-fmt->Gshift/8) = g; \ - *((buf)+2-fmt->Bshift/8) = b; \ - } \ - } \ - break; \ - \ - case 4: { \ - Uint32 Pixel; \ - \ - PIXEL_FROM_RGB(Pixel, fmt, r, g, b); \ - *((Uint32 *)(buf)) = Pixel; \ - } \ - break; \ - } \ +#define ASSEMBLE_RGB(buf, bpp, fmt, r, g, b) \ +{ \ + switch (bpp) { \ + case 2: { \ + Uint16 Pixel; \ + \ + PIXEL_FROM_RGB(Pixel, fmt, r, g, b); \ + *((Uint16 *)(buf)) = Pixel; \ + } \ + break; \ + \ + case 3: { \ + if (SDL_BYTEORDER == SDL_LIL_ENDIAN) { \ + *((buf)+fmt->Rshift/8) = r; \ + *((buf)+fmt->Gshift/8) = g; \ + *((buf)+fmt->Bshift/8) = b; \ + } else { \ + *((buf)+2-fmt->Rshift/8) = r; \ + *((buf)+2-fmt->Gshift/8) = g; \ + *((buf)+2-fmt->Bshift/8) = b; \ + } \ + } \ + break; \ + \ + case 4: { \ + Uint32 Pixel; \ + \ + PIXEL_FROM_RGB(Pixel, fmt, r, g, b); \ + *((Uint32 *)(buf)) = Pixel; \ + } \ + break; \ + } \ } /* FIXME: Should we rescale alpha into 0..255 here? */ -#define RGBA_FROM_PIXEL(Pixel, fmt, r, g, b, a) \ -{ \ - r = SDL_expand_byte[fmt->Rloss][((Pixel&fmt->Rmask)>>fmt->Rshift)]; \ - g = SDL_expand_byte[fmt->Gloss][((Pixel&fmt->Gmask)>>fmt->Gshift)]; \ - b = SDL_expand_byte[fmt->Bloss][((Pixel&fmt->Bmask)>>fmt->Bshift)]; \ - a = SDL_expand_byte[fmt->Aloss][((Pixel&fmt->Amask)>>fmt->Ashift)]; \ +#define RGBA_FROM_PIXEL(Pixel, fmt, r, g, b, a) \ +{ \ + r = SDL_expand_byte[fmt->Rloss][((Pixel&fmt->Rmask)>>fmt->Rshift)]; \ + g = SDL_expand_byte[fmt->Gloss][((Pixel&fmt->Gmask)>>fmt->Gshift)]; \ + b = SDL_expand_byte[fmt->Bloss][((Pixel&fmt->Bmask)>>fmt->Bshift)]; \ + a = SDL_expand_byte[fmt->Aloss][((Pixel&fmt->Amask)>>fmt->Ashift)]; \ } -#define RGBA_FROM_8888(Pixel, fmt, r, g, b, a) \ -{ \ - r = (Pixel&fmt->Rmask)>>fmt->Rshift; \ - g = (Pixel&fmt->Gmask)>>fmt->Gshift; \ - b = (Pixel&fmt->Bmask)>>fmt->Bshift; \ - a = (Pixel&fmt->Amask)>>fmt->Ashift; \ +#define RGBA_FROM_8888(Pixel, fmt, r, g, b, a) \ +{ \ + r = (Pixel&fmt->Rmask)>>fmt->Rshift; \ + g = (Pixel&fmt->Gmask)>>fmt->Gshift; \ + b = (Pixel&fmt->Bmask)>>fmt->Bshift; \ + a = (Pixel&fmt->Amask)>>fmt->Ashift; \ } -#define RGBA_FROM_RGBA8888(Pixel, r, g, b, a) \ -{ \ - r = (Pixel>>24); \ - g = ((Pixel>>16)&0xFF); \ - b = ((Pixel>>8)&0xFF); \ - a = (Pixel&0xFF); \ +#define RGBA_FROM_RGBA8888(Pixel, r, g, b, a) \ +{ \ + r = (Pixel>>24); \ + g = ((Pixel>>16)&0xFF); \ + b = ((Pixel>>8)&0xFF); \ + a = (Pixel&0xFF); \ } -#define RGBA_FROM_ARGB8888(Pixel, r, g, b, a) \ -{ \ - r = ((Pixel>>16)&0xFF); \ - g = ((Pixel>>8)&0xFF); \ - b = (Pixel&0xFF); \ - a = (Pixel>>24); \ +#define RGBA_FROM_ARGB8888(Pixel, r, g, b, a) \ +{ \ + r = ((Pixel>>16)&0xFF); \ + g = ((Pixel>>8)&0xFF); \ + b = (Pixel&0xFF); \ + a = (Pixel>>24); \ } -#define RGBA_FROM_ABGR8888(Pixel, r, g, b, a) \ -{ \ - r = (Pixel&0xFF); \ - g = ((Pixel>>8)&0xFF); \ - b = ((Pixel>>16)&0xFF); \ - a = (Pixel>>24); \ +#define RGBA_FROM_ABGR8888(Pixel, r, g, b, a) \ +{ \ + r = (Pixel&0xFF); \ + g = ((Pixel>>8)&0xFF); \ + b = ((Pixel>>16)&0xFF); \ + a = (Pixel>>24); \ } -#define RGBA_FROM_BGRA8888(Pixel, r, g, b, a) \ -{ \ - r = ((Pixel>>8)&0xFF); \ - g = ((Pixel>>16)&0xFF); \ - b = (Pixel>>24); \ - a = (Pixel&0xFF); \ +#define RGBA_FROM_BGRA8888(Pixel, r, g, b, a) \ +{ \ + r = ((Pixel>>8)&0xFF); \ + g = ((Pixel>>16)&0xFF); \ + b = (Pixel>>24); \ + a = (Pixel&0xFF); \ } -#define DISEMBLE_RGBA(buf, bpp, fmt, Pixel, r, g, b, a) \ -do { \ - switch (bpp) { \ - case 2: \ - Pixel = *((Uint16 *)(buf)); \ - RGBA_FROM_PIXEL(Pixel, fmt, r, g, b, a); \ - break; \ - \ - case 3: { \ +#define DISEMBLE_RGBA(buf, bpp, fmt, Pixel, r, g, b, a) \ +do { \ + switch (bpp) { \ + case 2: \ + Pixel = *((Uint16 *)(buf)); \ + RGBA_FROM_PIXEL(Pixel, fmt, r, g, b, a); \ + break; \ + \ + case 3: { \ Pixel = 0; \ - if (SDL_BYTEORDER == SDL_LIL_ENDIAN) { \ - r = *((buf)+fmt->Rshift/8); \ - g = *((buf)+fmt->Gshift/8); \ - b = *((buf)+fmt->Bshift/8); \ - } else { \ - r = *((buf)+2-fmt->Rshift/8); \ - g = *((buf)+2-fmt->Gshift/8); \ - b = *((buf)+2-fmt->Bshift/8); \ - } \ - a = 0xFF; \ - } \ - break; \ - \ - case 4: \ - Pixel = *((Uint32 *)(buf)); \ - RGBA_FROM_PIXEL(Pixel, fmt, r, g, b, a); \ - break; \ - \ - default: \ - /* stop gcc complaints */ \ - Pixel = 0; \ + if (SDL_BYTEORDER == SDL_LIL_ENDIAN) { \ + r = *((buf)+fmt->Rshift/8); \ + g = *((buf)+fmt->Gshift/8); \ + b = *((buf)+fmt->Bshift/8); \ + } else { \ + r = *((buf)+2-fmt->Rshift/8); \ + g = *((buf)+2-fmt->Gshift/8); \ + b = *((buf)+2-fmt->Bshift/8); \ + } \ + a = 0xFF; \ + } \ + break; \ + \ + case 4: \ + Pixel = *((Uint32 *)(buf)); \ + RGBA_FROM_PIXEL(Pixel, fmt, r, g, b, a); \ + break; \ + \ + default: \ + /* stop gcc complaints */ \ + Pixel = 0; \ r = g = b = a = 0; \ - break; \ - } \ + break; \ + } \ } while (0) /* FIXME: this isn't correct, especially for Alpha (maximum != 255) */ -#define PIXEL_FROM_RGBA(Pixel, fmt, r, g, b, a) \ -{ \ - Pixel = ((r>>fmt->Rloss)<Rshift)| \ - ((g>>fmt->Gloss)<Gshift)| \ - ((b>>fmt->Bloss)<Bshift)| \ - ((a>>fmt->Aloss)<Ashift); \ +#define PIXEL_FROM_RGBA(Pixel, fmt, r, g, b, a) \ +{ \ + Pixel = ((r>>fmt->Rloss)<Rshift)| \ + ((g>>fmt->Gloss)<Gshift)| \ + ((b>>fmt->Bloss)<Bshift)| \ + ((a>>fmt->Aloss)<Ashift); \ } -#define ASSEMBLE_RGBA(buf, bpp, fmt, r, g, b, a) \ -{ \ - switch (bpp) { \ - case 2: { \ - Uint16 Pixel; \ - \ - PIXEL_FROM_RGBA(Pixel, fmt, r, g, b, a); \ - *((Uint16 *)(buf)) = Pixel; \ - } \ - break; \ - \ - case 3: { \ - if (SDL_BYTEORDER == SDL_LIL_ENDIAN) { \ - *((buf)+fmt->Rshift/8) = r; \ - *((buf)+fmt->Gshift/8) = g; \ - *((buf)+fmt->Bshift/8) = b; \ - } else { \ - *((buf)+2-fmt->Rshift/8) = r; \ - *((buf)+2-fmt->Gshift/8) = g; \ - *((buf)+2-fmt->Bshift/8) = b; \ - } \ - } \ - break; \ - \ - case 4: { \ - Uint32 Pixel; \ - \ - PIXEL_FROM_RGBA(Pixel, fmt, r, g, b, a); \ - *((Uint32 *)(buf)) = Pixel; \ - } \ - break; \ - } \ +#define ASSEMBLE_RGBA(buf, bpp, fmt, r, g, b, a) \ +{ \ + switch (bpp) { \ + case 2: { \ + Uint16 Pixel; \ + \ + PIXEL_FROM_RGBA(Pixel, fmt, r, g, b, a); \ + *((Uint16 *)(buf)) = Pixel; \ + } \ + break; \ + \ + case 3: { \ + if (SDL_BYTEORDER == SDL_LIL_ENDIAN) { \ + *((buf)+fmt->Rshift/8) = r; \ + *((buf)+fmt->Gshift/8) = g; \ + *((buf)+fmt->Bshift/8) = b; \ + } else { \ + *((buf)+2-fmt->Rshift/8) = r; \ + *((buf)+2-fmt->Gshift/8) = g; \ + *((buf)+2-fmt->Bshift/8) = b; \ + } \ + } \ + break; \ + \ + case 4: { \ + Uint32 Pixel; \ + \ + PIXEL_FROM_RGBA(Pixel, fmt, r, g, b, a); \ + *((Uint32 *)(buf)) = Pixel; \ + } \ + break; \ + } \ } /* Blend the RGB values of two Pixels based on a source alpha value */ -#define ALPHA_BLEND(sR, sG, sB, A, dR, dG, dB) \ -do { \ - dR = ((((int)(sR-dR)*(int)A)/255)+dR); \ - dG = ((((int)(sG-dG)*(int)A)/255)+dG); \ - dB = ((((int)(sB-dB)*(int)A)/255)+dB); \ +#define ALPHA_BLEND(sR, sG, sB, A, dR, dG, dB) \ +do { \ + dR = ((((int)(sR-dR)*(int)A)/255)+dR); \ + dG = ((((int)(sG-dG)*(int)A)/255)+dG); \ + dB = ((((int)(sB-dB)*(int)A)/255)+dB); \ } while(0) @@ -413,75 +413,75 @@ do { \ #ifdef USE_DUFFS_LOOP /* 8-times unrolled loop */ -#define DUFFS_LOOP8(pixel_copy_increment, width) \ -{ int n = (width+7)/8; \ - switch (width & 7) { \ - case 0: do { pixel_copy_increment; \ - case 7: pixel_copy_increment; \ - case 6: pixel_copy_increment; \ - case 5: pixel_copy_increment; \ - case 4: pixel_copy_increment; \ - case 3: pixel_copy_increment; \ - case 2: pixel_copy_increment; \ - case 1: pixel_copy_increment; \ - } while ( --n > 0 ); \ - } \ +#define DUFFS_LOOP8(pixel_copy_increment, width) \ +{ int n = (width+7)/8; \ + switch (width & 7) { \ + case 0: do { pixel_copy_increment; \ + case 7: pixel_copy_increment; \ + case 6: pixel_copy_increment; \ + case 5: pixel_copy_increment; \ + case 4: pixel_copy_increment; \ + case 3: pixel_copy_increment; \ + case 2: pixel_copy_increment; \ + case 1: pixel_copy_increment; \ + } while ( --n > 0 ); \ + } \ } /* 4-times unrolled loop */ -#define DUFFS_LOOP4(pixel_copy_increment, width) \ -{ int n = (width+3)/4; \ - switch (width & 3) { \ - case 0: do { pixel_copy_increment; \ - case 3: pixel_copy_increment; \ - case 2: pixel_copy_increment; \ - case 1: pixel_copy_increment; \ - } while (--n > 0); \ - } \ +#define DUFFS_LOOP4(pixel_copy_increment, width) \ +{ int n = (width+3)/4; \ + switch (width & 3) { \ + case 0: do { pixel_copy_increment; \ + case 3: pixel_copy_increment; \ + case 2: pixel_copy_increment; \ + case 1: pixel_copy_increment; \ + } while (--n > 0); \ + } \ } /* Use the 8-times version of the loop by default */ -#define DUFFS_LOOP(pixel_copy_increment, width) \ - DUFFS_LOOP8(pixel_copy_increment, width) +#define DUFFS_LOOP(pixel_copy_increment, width) \ + DUFFS_LOOP8(pixel_copy_increment, width) /* Special version of Duff's device for even more optimization */ -#define DUFFS_LOOP_124(pixel_copy_increment1, \ - pixel_copy_increment2, \ - pixel_copy_increment4, width) \ -{ int n = width; \ - if (n & 1) { \ - pixel_copy_increment1; n -= 1; \ - } \ - if (n & 2) { \ - pixel_copy_increment2; n -= 2; \ - } \ - if (n) { \ - n = (n+7)/ 8; \ - switch (n & 4) { \ - case 0: do { pixel_copy_increment4; \ - case 4: pixel_copy_increment4; \ - } while (--n > 0); \ - } \ - } \ +#define DUFFS_LOOP_124(pixel_copy_increment1, \ + pixel_copy_increment2, \ + pixel_copy_increment4, width) \ +{ int n = width; \ + if (n & 1) { \ + pixel_copy_increment1; n -= 1; \ + } \ + if (n & 2) { \ + pixel_copy_increment2; n -= 2; \ + } \ + if (n) { \ + n = (n+7)/ 8; \ + switch (n & 4) { \ + case 0: do { pixel_copy_increment4; \ + case 4: pixel_copy_increment4; \ + } while (--n > 0); \ + } \ + } \ } #else /* Don't use Duff's device to unroll loops */ -#define DUFFS_LOOP(pixel_copy_increment, width) \ -{ int n; \ - for ( n=width; n > 0; --n ) { \ - pixel_copy_increment; \ - } \ +#define DUFFS_LOOP(pixel_copy_increment, width) \ +{ int n; \ + for ( n=width; n > 0; --n ) { \ + pixel_copy_increment; \ + } \ } -#define DUFFS_LOOP8(pixel_copy_increment, width) \ - DUFFS_LOOP(pixel_copy_increment, width) -#define DUFFS_LOOP4(pixel_copy_increment, width) \ - DUFFS_LOOP(pixel_copy_increment, width) -#define DUFFS_LOOP_124(pixel_copy_increment1, \ - pixel_copy_increment2, \ - pixel_copy_increment4, width) \ - DUFFS_LOOP(pixel_copy_increment1, width) +#define DUFFS_LOOP8(pixel_copy_increment, width) \ + DUFFS_LOOP(pixel_copy_increment, width) +#define DUFFS_LOOP4(pixel_copy_increment, width) \ + DUFFS_LOOP(pixel_copy_increment, width) +#define DUFFS_LOOP_124(pixel_copy_increment1, \ + pixel_copy_increment2, \ + pixel_copy_increment4, width) \ + DUFFS_LOOP(pixel_copy_increment1, width) #endif /* USE_DUFFS_LOOP */ diff --git a/src/video/SDL_bmp.c b/src/video/SDL_bmp.c index 5b861dd93..7ee65d85d 100644 --- a/src/video/SDL_bmp.c +++ b/src/video/SDL_bmp.c @@ -20,14 +20,14 @@ */ #include "SDL_config.h" -/* +/* Code to load and save surfaces in Windows BMP format. Why support BMP format? Well, it's a native format for Windows, and most image processing programs can read and write it. It would be nice to be able to have at least one image format that we can natively load and save, and since PNG is so complex that it would bloat the library, - BMP is a good alternative. + BMP is a good alternative. This code currently supports Win32 DIBs in uncompressed 8 and 24 bpp. */ @@ -40,10 +40,10 @@ /* Compression encodings for BMP files */ #ifndef BI_RGB -#define BI_RGB 0 -#define BI_RLE8 1 -#define BI_RLE4 2 -#define BI_BITFIELDS 3 +#define BI_RGB 0 +#define BI_RLE8 1 +#define BI_RLE4 2 +#define BI_BITFIELDS 3 #endif @@ -439,7 +439,7 @@ SDL_SaveBMP_RW(SDL_Surface * saveme, SDL_RWops * dst, int freedst) /* If the surface has a colorkey or alpha channel we'll save a 32-bit BMP with alpha channel, otherwise save a 24-bit BMP. */ if (save32bit) { - SDL_InitFormat(&format, + SDL_InitFormat(&format, #if SDL_BYTEORDER == SDL_LIL_ENDIAN SDL_PIXELFORMAT_ARGB8888 #else diff --git a/src/video/SDL_pixels.c b/src/video/SDL_pixels.c index 271a17d3c..c472c38b5 100644 --- a/src/video/SDL_pixels.c +++ b/src/video/SDL_pixels.c @@ -139,7 +139,7 @@ SDL_PixelFormatEnumToMasks(Uint32 format, int *bpp, Uint32 * Rmask, SDL_SetError("FOURCC pixel formats are not supported"); return SDL_FALSE; } - + /* Initialize the values here */ if (SDL_BYTESPERPIXEL(format) <= 2) { *bpp = SDL_BITSPERPIXEL(format); @@ -615,7 +615,7 @@ SDL_Palette * SDL_AllocPalette(int ncolors) { SDL_Palette *palette; - + /* Input validation */ if (ncolors < 1) { SDL_InvalidParamError("ncolors"); @@ -741,7 +741,7 @@ SDL_DitherColors(SDL_Color * colors, int bpp) } } -/* +/* * Calculate the pad-aligned scanline width of a surface */ int @@ -1055,7 +1055,7 @@ SDL_MapSurface(SDL_Surface * src, SDL_Surface * dst) while we're still pointing at it. A better method would be for the destination surface to keep - track of surfaces that are mapped to it and automatically + track of surfaces that are mapped to it and automatically invalidate them when it is freed, but this will do for now. */ ++map->dst->refcount; @@ -1090,7 +1090,7 @@ void SDL_CalculateGammaRamp(float gamma, Uint16 * ramp) { int i; - + /* Input validation */ if (gamma < 0.0f ) { SDL_InvalidParamError("gamma"); diff --git a/src/video/SDL_rect.c b/src/video/SDL_rect.c index 045d3f1cf..8dcb5b651 100644 --- a/src/video/SDL_rect.c +++ b/src/video/SDL_rect.c @@ -85,7 +85,7 @@ SDL_IntersectRect(const SDL_Rect * A, const SDL_Rect * B, SDL_Rect * result) SDL_InvalidParamError("B"); return SDL_FALSE; } - + if (!result) { SDL_InvalidParamError("result"); return SDL_FALSE; @@ -97,7 +97,7 @@ SDL_IntersectRect(const SDL_Rect * A, const SDL_Rect * B, SDL_Rect * result) result->h = 0; return SDL_FALSE; } - + /* Horizontal intersection */ Amin = A->x; Amax = Amin + A->w; @@ -139,7 +139,7 @@ SDL_UnionRect(const SDL_Rect * A, const SDL_Rect * B, SDL_Rect * result) SDL_InvalidParamError("B"); return; } - + if (!result) { SDL_InvalidParamError("result"); return; @@ -155,14 +155,14 @@ SDL_UnionRect(const SDL_Rect * A, const SDL_Rect * B, SDL_Rect * result) *result = *B; return; } - } else { + } else { if (SDL_RectEmpty(B)) { /* A not empty, B empty */ *result = *A; return; - } + } } - + /* Horizontal union */ Amin = A->x; Amax = Amin + A->w; @@ -219,7 +219,7 @@ SDL_EnclosePoints(const SDL_Point * points, int count, const SDL_Rect * clip, if (SDL_RectEmpty(clip)) { return SDL_FALSE; } - + for (i = 0; i < count; ++i) { x = points[i].x; y = points[i].y; @@ -259,7 +259,7 @@ SDL_EnclosePoints(const SDL_Point * points, int count, const SDL_Rect * clip, if (result == NULL) { return SDL_TRUE; } - + /* No clipping, always add the first point */ minx = maxx = points[0].x; miny = maxy = points[0].y; @@ -330,22 +330,22 @@ SDL_IntersectRectAndLine(const SDL_Rect * rect, int *X1, int *Y1, int *X2, SDL_InvalidParamError("rect"); return SDL_FALSE; } - + if (!X1) { SDL_InvalidParamError("X1"); return SDL_FALSE; } - + if (!Y1) { SDL_InvalidParamError("Y1"); return SDL_FALSE; } - + if (!X2) { SDL_InvalidParamError("X2"); return SDL_FALSE; } - + if (!Y2) { SDL_InvalidParamError("Y2"); return SDL_FALSE; @@ -355,7 +355,7 @@ SDL_IntersectRectAndLine(const SDL_Rect * rect, int *X1, int *Y1, int *X2, if (SDL_RectEmpty(rect)) { return SDL_FALSE; } - + x1 = *X1; y1 = *Y1; x2 = *X2; diff --git a/src/video/SDL_shape.c b/src/video/SDL_shape.c index c3094802d..e9876e410 100644 --- a/src/video/SDL_shape.c +++ b/src/video/SDL_shape.c @@ -30,7 +30,8 @@ #include "SDL_shape_internals.h" SDL_Window* -SDL_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags) { +SDL_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags) +{ SDL_Window *result = NULL; result = SDL_CreateWindow(title,-1000,-1000,w,h,(flags | SDL_WINDOW_BORDERLESS) & (~SDL_WINDOW_FULLSCREEN) & (~SDL_WINDOW_RESIZABLE) /*& (~SDL_WINDOW_SHOWN)*/); if(result != NULL) { @@ -53,7 +54,8 @@ SDL_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned } SDL_bool -SDL_IsShapedWindow(const SDL_Window *window) { +SDL_IsShapedWindow(const SDL_Window *window) +{ if(window == NULL) return SDL_FALSE; else @@ -62,7 +64,8 @@ SDL_IsShapedWindow(const SDL_Window *window) { /* REQUIRES that bitmap point to a w-by-h bitmap with ppb pixels-per-byte. */ void -SDL_CalculateShapeBitmap(SDL_WindowShapeMode mode,SDL_Surface *shape,Uint8* bitmap,Uint8 ppb) { +SDL_CalculateShapeBitmap(SDL_WindowShapeMode mode,SDL_Surface *shape,Uint8* bitmap,Uint8 ppb) +{ int x = 0; int y = 0; Uint8 r = 0,g = 0,b = 0,alpha = 0; @@ -163,34 +166,35 @@ RecursivelyCalculateShapeTree(SDL_WindowShapeMode mode,SDL_Surface* mask,SDL_Rec last_opaque = pixel_opaque; if(last_opaque != pixel_opaque) { result->kind = QuadShape; - //These will stay the same. + /* These will stay the same. */ next.w = dimensions.w / 2; next.h = dimensions.h / 2; - //These will change from recursion to recursion. + /* These will change from recursion to recursion. */ next.x = dimensions.x; next.y = dimensions.y; result->data.children.upleft = (struct SDL_ShapeTree *)RecursivelyCalculateShapeTree(mode,mask,next); next.x += next.w; - //Unneeded: next.y = dimensions.y; + /* Unneeded: next.y = dimensions.y; */ result->data.children.upright = (struct SDL_ShapeTree *)RecursivelyCalculateShapeTree(mode,mask,next); next.x = dimensions.x; next.y += next.h; result->data.children.downleft = (struct SDL_ShapeTree *)RecursivelyCalculateShapeTree(mode,mask,next); next.x += next.w; - //Unneeded: next.y = dimensions.y + dimensions.h /2; + /* Unneeded: next.y = dimensions.y + dimensions.h /2; */ result->data.children.downright = (struct SDL_ShapeTree *)RecursivelyCalculateShapeTree(mode,mask,next); return result; } } } - //If we never recursed, all the pixels in this quadrant have the same "value". + /* If we never recursed, all the pixels in this quadrant have the same "value". */ result->kind = (last_opaque == SDL_TRUE ? OpaqueShape : TransparentShape); result->data.shape = dimensions; return result; } SDL_ShapeTree* -SDL_CalculateShapeTree(SDL_WindowShapeMode mode,SDL_Surface* shape) { +SDL_CalculateShapeTree(SDL_WindowShapeMode mode,SDL_Surface* shape) +{ SDL_Rect dimensions = {0,0,shape->w,shape->h}; SDL_ShapeTree* result = NULL; if(SDL_MUSTLOCK(shape)) @@ -202,7 +206,8 @@ SDL_CalculateShapeTree(SDL_WindowShapeMode mode,SDL_Surface* shape) { } void -SDL_TraverseShapeTree(SDL_ShapeTree *tree,SDL_TraversalFunction function,void* closure) { +SDL_TraverseShapeTree(SDL_ShapeTree *tree,SDL_TraversalFunction function,void* closure) +{ SDL_assert(tree != NULL); if(tree->kind == QuadShape) { SDL_TraverseShapeTree((SDL_ShapeTree *)tree->data.children.upleft,function,closure); @@ -215,7 +220,8 @@ SDL_TraverseShapeTree(SDL_ShapeTree *tree,SDL_TraversalFunction function,void* c } void -SDL_FreeShapeTree(SDL_ShapeTree** shape_tree) { +SDL_FreeShapeTree(SDL_ShapeTree** shape_tree) +{ if((*shape_tree)->kind == QuadShape) { SDL_FreeShapeTree((SDL_ShapeTree **)&(*shape_tree)->data.children.upleft); SDL_FreeShapeTree((SDL_ShapeTree **)&(*shape_tree)->data.children.upright); @@ -227,15 +233,16 @@ SDL_FreeShapeTree(SDL_ShapeTree** shape_tree) { } int -SDL_SetWindowShape(SDL_Window *window,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode) { +SDL_SetWindowShape(SDL_Window *window,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode) +{ int result; if(window == NULL || !SDL_IsShapedWindow(window)) - //The window given was not a shapeable window. + /* The window given was not a shapeable window. */ return SDL_NONSHAPEABLE_WINDOW; if(shape == NULL) - //Invalid shape argument. + /* Invalid shape argument. */ return SDL_INVALID_SHAPE_ARGUMENT; - + if(shape_mode != NULL) window->shaper->mode = *shape_mode; result = SDL_GetVideoDevice()->shape_driver.SetWindowShape(window->shaper,shape,shape_mode); @@ -249,21 +256,23 @@ SDL_SetWindowShape(SDL_Window *window,SDL_Surface *shape,SDL_WindowShapeMode *sh } static SDL_bool -SDL_WindowHasAShape(SDL_Window *window) { +SDL_WindowHasAShape(SDL_Window *window) +{ if (window == NULL || !SDL_IsShapedWindow(window)) return SDL_FALSE; return window->shaper->hasshape; } int -SDL_GetShapedWindowMode(SDL_Window *window,SDL_WindowShapeMode *shape_mode) { +SDL_GetShapedWindowMode(SDL_Window *window,SDL_WindowShapeMode *shape_mode) +{ if(window != NULL && SDL_IsShapedWindow(window)) { if(shape_mode == NULL) { if(SDL_WindowHasAShape(window)) - //The window given has a shape. + /* The window given has a shape. */ return 0; else - //The window given is shapeable but lacks a shape. + /* The window given is shapeable but lacks a shape. */ return SDL_WINDOW_LACKS_SHAPE; } else { @@ -272,6 +281,6 @@ SDL_GetShapedWindowMode(SDL_Window *window,SDL_WindowShapeMode *shape_mode) { } } else - //The window given is not a valid shapeable window. + /* The window given is not a valid shapeable window. */ return SDL_NONSHAPEABLE_WINDOW; } diff --git a/src/video/SDL_surface.c b/src/video/SDL_surface.c index 94ce6eacc..d1c57119c 100644 --- a/src/video/SDL_surface.c +++ b/src/video/SDL_surface.c @@ -473,13 +473,13 @@ SDL_GetClipRect(SDL_Surface * surface, SDL_Rect * rect) } } -/* +/* * Set up a blit between two surfaces -- split into three parts: - * The upper part, SDL_UpperBlit(), performs clipping and rectangle + * The upper part, SDL_UpperBlit(), performs clipping and rectangle * verification. The lower part is a pointer to a low level * accelerated blitting function. * - * These parts are separated out and each used internally by this + * These parts are separated out and each used internally by this * library in the optimimum places. They are exported so that if * you know exactly what you are doing, you can optimize your code * by calling the one(s) you need. @@ -738,7 +738,7 @@ SDL_LowerBlitScaled(SDL_Surface * src, SDL_Rect * srcrect, src->map->info.flags |= SDL_COPY_NEAREST; if ( !(src->map->info.flags & complex_copy_flags) && - src->format->format == dst->format->format && + src->format->format == dst->format->format && !SDL_ISPIXELFORMAT_INDEXED(src->format->format) ) { return SDL_SoftStretch( src, &final_src, dst, &final_dst ); } else { @@ -785,7 +785,7 @@ SDL_UnlockSurface(SDL_Surface * surface) } } -/* +/* * Convert a surface into the specified pixel format. */ SDL_Surface * @@ -854,7 +854,7 @@ SDL_ConvertSurface(SDL_Surface * surface, SDL_PixelFormat * format, SDL_bool set_colorkey_by_color = SDL_FALSE; if (surface->format->palette) { - if (format->palette && + if (format->palette && surface->format->palette->ncolors <= format->palette->ncolors && (SDL_memcmp(surface->format->palette->colors, format->palette->colors, surface->format->palette->ncolors * sizeof(SDL_Color)) == 0)) { @@ -917,7 +917,7 @@ SDL_ConvertSurfaceFormat(SDL_Surface * surface, Uint32 pixel_format, */ static __inline__ SDL_bool SDL_CreateSurfaceOnStack(int width, int height, Uint32 pixel_format, - void * pixels, int pitch, SDL_Surface * surface, + void * pixels, int pitch, SDL_Surface * surface, SDL_PixelFormat * format, SDL_BlitMap * blitmap) { if (SDL_ISPIXELFORMAT_INDEXED(pixel_format)) { diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h index 63f088fff..45ca74507 100644 --- a/src/video/SDL_sysvideo.h +++ b/src/video/SDL_sysvideo.h @@ -35,19 +35,19 @@ typedef struct SDL_VideoDevice SDL_VideoDevice; /* Define the SDL window-shaper structure */ struct SDL_WindowShaper -{ +{ /* The window associated with the shaper */ SDL_Window *window; - + /* The user's specified coordinates for the window, for once we give it a shape. */ Uint32 userx,usery; - + /* The parameters for shape calculation. */ SDL_WindowShapeMode mode; - + /* Has this window been assigned a shape? */ SDL_bool hasshape; - + void *driverdata; }; @@ -82,7 +82,7 @@ struct SDL_Window SDL_Rect windowed; SDL_DisplayMode fullscreen_mode; - + float brightness; Uint16 *gamma; Uint16 *saved_gamma; /* (just offset into gamma) */ @@ -128,7 +128,7 @@ struct SDL_VideoDisplay struct SDL_SysWMinfo; /* Define the SDL video driver structure */ -#define _THIS SDL_VideoDevice *_this +#define _THIS SDL_VideoDevice *_this struct SDL_VideoDevice { diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 034486e63..57cc934df 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -416,7 +416,7 @@ SDL_VideoInit(const char *driver_name) if (_this != NULL) { SDL_VideoQuit(); } - + #if !SDL_TIMERS_DISABLED SDL_InitTicks(); #endif @@ -1013,12 +1013,12 @@ int SDL_GetWindowDisplayMode(SDL_Window * window, SDL_DisplayMode * mode) { SDL_DisplayMode fullscreen_mode; - SDL_VideoDisplay *display; + SDL_VideoDisplay *display; if (!mode) { return SDL_InvalidParamError("mode"); } - + CHECK_WINDOW_MAGIC(window, -1); fullscreen_mode = window->fullscreen_mode; @@ -1028,15 +1028,15 @@ SDL_GetWindowDisplayMode(SDL_Window * window, SDL_DisplayMode * mode) if (!fullscreen_mode.h) { fullscreen_mode.h = window->h; } - - display = SDL_GetDisplayForWindow(window); - /* if in desktop size mode, just return the size of the desktop */ - if ( ( window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP ) == SDL_WINDOW_FULLSCREEN_DESKTOP ) - { - fullscreen_mode = display->desktop_mode; - } - else if (!SDL_GetClosestDisplayModeForDisplay(SDL_GetDisplayForWindow(window), + display = SDL_GetDisplayForWindow(window); + + /* if in desktop size mode, just return the size of the desktop */ + if ( ( window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP ) == SDL_WINDOW_FULLSCREEN_DESKTOP ) + { + fullscreen_mode = display->desktop_mode; + } + else if (!SDL_GetClosestDisplayModeForDisplay(SDL_GetDisplayForWindow(window), &fullscreen_mode, &fullscreen_mode)) { return SDL_SetError("Couldn't find display mode match"); @@ -1110,13 +1110,13 @@ SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool fullscreen) resized = SDL_FALSE; } - /* only do the mode change if we want exclusive fullscreen */ - if ( ( window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP ) != SDL_WINDOW_FULLSCREEN_DESKTOP ) - SDL_SetDisplayModeForDisplay(display, &fullscreen_mode); - else - SDL_SetDisplayModeForDisplay(display, NULL); + /* only do the mode change if we want exclusive fullscreen */ + if ( ( window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP ) != SDL_WINDOW_FULLSCREEN_DESKTOP ) + SDL_SetDisplayModeForDisplay(display, &fullscreen_mode); + else + SDL_SetDisplayModeForDisplay(display, NULL); + - if (_this->SetWindowFullscreen) { _this->SetWindowFullscreen(_this, other, display, SDL_TRUE); } @@ -1251,7 +1251,7 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags) SDL_SetWindowTitle(window, title); } SDL_FinishWindowCreation(window, flags); - + /* If the window was created fullscreen, make sure the mode code matches */ SDL_UpdateFullscreenMode(window, FULLSCREEN_VISIBLE(window)); @@ -1430,7 +1430,7 @@ SDL_SetWindowData(SDL_Window * window, const char *name, void *userdata) SDL_WindowUserData *prev, *data; CHECK_WINDOW_MAGIC(window, NULL); - + /* Input validation */ if (name == NULL || SDL_strlen(name) == 0) { SDL_InvalidParamError("name"); @@ -1602,7 +1602,7 @@ SDL_GetWindowSize(SDL_Window * window, int *w, int *h) } if (h) { *h = window->h; - } + } } void @@ -1617,7 +1617,7 @@ SDL_SetWindowMinimumSize(SDL_Window * window, int min_w, int min_h) SDL_InvalidParamError("min_h"); return; } - + if (!(window->flags & SDL_WINDOW_FULLSCREEN)) { window->min_w = min_w; window->min_h = min_h; @@ -1653,7 +1653,7 @@ SDL_SetWindowMaximumSize(SDL_Window * window, int max_w, int max_h) SDL_InvalidParamError("max_h"); return; } - + if (!(window->flags & SDL_WINDOW_FULLSCREEN)) { window->max_w = max_w; window->max_h = max_h; @@ -1772,14 +1772,14 @@ SDL_SetWindowFullscreen(SDL_Window * window, Uint32 flags) { CHECK_WINDOW_MAGIC(window, -1); - flags &= FULLSCREEN_MASK; - + flags &= FULLSCREEN_MASK; + if ( flags == (window->flags & FULLSCREEN_MASK) ) { return 0; } - - /* clear the previous flags and OR in the new ones */ - window->flags &= ~FULLSCREEN_MASK; + + /* clear the previous flags and OR in the new ones */ + window->flags &= ~FULLSCREEN_MASK; window->flags |= flags; SDL_UpdateFullscreenMode(window, FULLSCREEN_VISIBLE(window)); @@ -2065,15 +2065,15 @@ SDL_OnWindowFocusGained(SDL_Window * window) static SDL_bool ShouldMinimizeOnFocusLoss() { - const char *hint = SDL_GetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS); - if (hint) { - if (*hint == '0') { - return SDL_FALSE; - } else { - return SDL_TRUE; - } - } - return SDL_TRUE; + const char *hint = SDL_GetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS); + if (hint) { + if (*hint == '0') { + return SDL_FALSE; + } else { + return SDL_TRUE; + } + } + return SDL_TRUE; } void @@ -2086,8 +2086,8 @@ SDL_OnWindowFocusLost(SDL_Window * window) SDL_UpdateWindowGrab(window); /* If we're fullscreen on a single-head system and lose focus, minimize */ - if ((window->flags & SDL_WINDOW_FULLSCREEN) && ShouldMinimizeOnFocusLoss() ) { - SDL_MinimizeWindow(window); + if ((window->flags & SDL_WINDOW_FULLSCREEN) && ShouldMinimizeOnFocusLoss() ) { + SDL_MinimizeWindow(window); } } @@ -2472,27 +2472,27 @@ SDL_GL_SetAttribute(SDL_GLattr attr, int value) break; case SDL_GL_CONTEXT_FLAGS: if( value & ~(SDL_GL_CONTEXT_DEBUG_FLAG | - SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG | - SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG | - SDL_GL_CONTEXT_RESET_ISOLATION_FLAG) ) { - retval = SDL_SetError("Unknown OpenGL context flag %d", value); - break; - } + SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG | + SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG | + SDL_GL_CONTEXT_RESET_ISOLATION_FLAG) ) { + retval = SDL_SetError("Unknown OpenGL context flag %d", value); + break; + } _this->gl_config.flags = value; break; case SDL_GL_CONTEXT_PROFILE_MASK: if( value != 0 && - value != SDL_GL_CONTEXT_PROFILE_CORE && - value != SDL_GL_CONTEXT_PROFILE_COMPATIBILITY && - value != SDL_GL_CONTEXT_PROFILE_ES ) { - retval = SDL_SetError("Unknown OpenGL context profile %d", value); - break; - } + value != SDL_GL_CONTEXT_PROFILE_CORE && + value != SDL_GL_CONTEXT_PROFILE_COMPATIBILITY && + value != SDL_GL_CONTEXT_PROFILE_ES ) { + retval = SDL_SetError("Unknown OpenGL context profile %d", value); + break; + } _this->gl_config.profile_mask = value; break; case SDL_GL_SHARE_WITH_CURRENT_CONTEXT: _this->gl_config.share_with_current_context = value; - break; + break; default: retval = SDL_SetError("Unknown OpenGL attribute"); break; @@ -2779,7 +2779,7 @@ SDL_GL_DeleteContext(SDL_GLContext context) _this->GL_DeleteContext(_this, context); } -#if 0 // FIXME +#if 0 /* FIXME */ /* * Utility function used by SDL_WM_SetIcon(); flags & 1 for color key, flags * & 2 for alpha channel. @@ -2790,7 +2790,7 @@ CreateMaskFromColorKeyOrAlpha(SDL_Surface * icon, Uint8 * mask, int flags) int x, y; Uint32 colorkey; #define SET_MASKBIT(icon, x, y, mask) \ - mask[(y*((icon->w+7)/8))+(x/8)] &= ~(0x01<<(7-(x%8))) + mask[(y*((icon->w+7)/8))+(x/8)] &= ~(0x01<<(7-(x%8))) colorkey = icon->format->colorkey; switch (icon->format->BytesPerPixel) { @@ -2985,18 +2985,18 @@ int SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) { int dummybutton; - int retval = -1; - SDL_bool relative_mode = SDL_GetRelativeMouseMode(); - int show_cursor_prev = SDL_ShowCursor( 1 ); + int retval = -1; + SDL_bool relative_mode = SDL_GetRelativeMouseMode(); + int show_cursor_prev = SDL_ShowCursor( 1 ); - SDL_SetRelativeMouseMode( SDL_FALSE ); + SDL_SetRelativeMouseMode( SDL_FALSE ); if (!buttonid) { buttonid = &dummybutton; } if (_this && _this->ShowMessageBox) { if (_this->ShowMessageBox(_this, messageboxdata, buttonid) == 0) { - retval = 0; + retval = 0; } } @@ -3022,12 +3022,12 @@ SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) } #endif - SDL_ShowCursor( show_cursor_prev ); - SDL_SetRelativeMouseMode( relative_mode ); + SDL_ShowCursor( show_cursor_prev ); + SDL_SetRelativeMouseMode( relative_mode ); - if(retval == -1) { - SDL_SetError("No message system available"); - } + if(retval == -1) { + SDL_SetError("No message system available"); + } return retval; } @@ -3056,15 +3056,15 @@ SDL_ShowSimpleMessageBox(Uint32 flags, const char *title, const char *message, S SDL_bool SDL_ShouldAllowTopmost(void) { - const char *hint = SDL_GetHint(SDL_HINT_ALLOW_TOPMOST); - if (hint) { - if (*hint == '0') { - return SDL_FALSE; - } else { - return SDL_TRUE; - } - } - return SDL_TRUE; + const char *hint = SDL_GetHint(SDL_HINT_ALLOW_TOPMOST); + if (hint) { + if (*hint == '0') { + return SDL_FALSE; + } else { + return SDL_TRUE; + } + } + return SDL_TRUE; } /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/android/SDL_androidkeyboard.c b/src/video/android/SDL_androidkeyboard.c index 88b904acf..512007a2f 100644 --- a/src/video/android/SDL_androidkeyboard.c +++ b/src/video/android/SDL_androidkeyboard.c @@ -322,7 +322,7 @@ Android_SetTextInputRect(_THIS, SDL_Rect *rect) SDL_InvalidParamError("rect"); return; } - + videodata->textRect = *rect; } diff --git a/src/video/android/SDL_androidtouch.c b/src/video/android/SDL_androidtouch.c index c8d5ae6d5..1b42b5f77 100644 --- a/src/video/android/SDL_androidtouch.c +++ b/src/video/android/SDL_androidtouch.c @@ -36,7 +36,7 @@ #define ACTION_MOVE 2 #define ACTION_CANCEL 3 #define ACTION_OUTSIDE 4 -// The following two are deprecated but it seems they are still emitted (instead the corresponding ACTION_UP/DOWN) as of Android 3.2 +/* The following two are deprecated but it seems they are still emitted (instead the corresponding ACTION_UP/DOWN) as of Android 3.2 */ #define ACTION_POINTER_1_DOWN 5 #define ACTION_POINTER_1_UP 6 @@ -52,7 +52,7 @@ static void Android_GetWindowCoordinates(float x, float y, *window_y = (int)(y * window_h); } -void Android_OnTouch(int touch_device_id_in, int pointer_finger_id_in, int action, float x, float y, float p) +void Android_OnTouch(int touch_device_id_in, int pointer_finger_id_in, int action, float x, float y, float p) { SDL_TouchID touchDeviceId = 0; SDL_FingerID fingerId = 0; @@ -104,7 +104,7 @@ void Android_OnTouch(int touch_device_id_in, int pointer_finger_id_in, int actio break; default: break; - } + } } #endif /* SDL_VIDEO_DRIVER_ANDROID */ diff --git a/src/video/android/SDL_androidvideo.c b/src/video/android/SDL_androidvideo.c index ebf9535f5..4b4a85196 100644 --- a/src/video/android/SDL_androidvideo.c +++ b/src/video/android/SDL_androidvideo.c @@ -48,7 +48,6 @@ static void Android_VideoQuit(_THIS); extern int Android_GL_LoadLibrary(_THIS, const char *path); extern void *Android_GL_GetProcAddress(_THIS, const char *proc); extern void Android_GL_UnloadLibrary(_THIS); -//extern int *Android_GL_GetVisual(_THIS, Display * display, int screen); extern SDL_GLContext Android_GL_CreateContext(_THIS, SDL_Window * window); extern int Android_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context); @@ -60,8 +59,7 @@ extern void Android_GL_DeleteContext(_THIS, SDL_GLContext context); /* Android driver bootstrap functions */ -// These are filled in with real values in Android_SetScreenResolution on -// init (before SDL_main()) +/* These are filled in with real values in Android_SetScreenResolution on init (before SDL_main()) */ int Android_ScreenWidth = 0; int Android_ScreenHeight = 0; Uint32 Android_ScreenFormat = SDL_PIXELFORMAT_UNKNOWN; @@ -182,7 +180,7 @@ void Android_SetScreenResolution(int width, int height, Uint32 format) { Android_ScreenWidth = width; - Android_ScreenHeight = height; + Android_ScreenHeight = height; Android_ScreenFormat = format; if (Android_Window) { diff --git a/src/video/android/SDL_androidwindow.c b/src/video/android/SDL_androidwindow.c index 25a0e9f6f..b3c6cd9a4 100644 --- a/src/video/android/SDL_androidwindow.c +++ b/src/video/android/SDL_androidwindow.c @@ -49,7 +49,7 @@ Android_CreateWindow(_THIS, SDL_Window * window) window->flags |= SDL_WINDOW_FULLSCREEN; /* window is always fullscreen */ window->flags &= ~SDL_WINDOW_HIDDEN; window->flags |= SDL_WINDOW_SHOWN; /* only one window on Android */ - window->flags |= SDL_WINDOW_INPUT_FOCUS; /* always has input focus */ + window->flags |= SDL_WINDOW_INPUT_FOCUS; /* always has input focus */ /* One window, it always has focus */ SDL_SetMouseFocus(window); diff --git a/src/video/bwindow/SDL_BWin.h b/src/video/bwindow/SDL_BWin.h index 9d7a273b0..fb576da68 100644 --- a/src/video/bwindow/SDL_BWin.h +++ b/src/video/bwindow/SDL_BWin.h @@ -47,23 +47,23 @@ extern "C" { enum WinCommands { - BWIN_MOVE_WINDOW, - BWIN_RESIZE_WINDOW, - BWIN_SHOW_WINDOW, - BWIN_HIDE_WINDOW, - BWIN_MAXIMIZE_WINDOW, - BWIN_MINIMIZE_WINDOW, - BWIN_RESTORE_WINDOW, - BWIN_SET_TITLE, - BWIN_SET_BORDERED, - BWIN_FULLSCREEN + BWIN_MOVE_WINDOW, + BWIN_RESIZE_WINDOW, + BWIN_SHOW_WINDOW, + BWIN_HIDE_WINDOW, + BWIN_MAXIMIZE_WINDOW, + BWIN_MINIMIZE_WINDOW, + BWIN_RESTORE_WINDOW, + BWIN_SET_TITLE, + BWIN_SET_BORDERED, + BWIN_FULLSCREEN }; class SDL_BWin:public BDirectWindow { public: - /* Constructor/Destructor */ + /* Constructor/Destructor */ SDL_BWin(BRect bounds, window_look look, uint32 flags) : BDirectWindow(bounds, "Untitled", look, B_NORMAL_WINDOW_FEEL, flags) { @@ -85,7 +85,7 @@ class SDL_BWin:public BDirectWindow _bitmap = NULL; #ifdef DRAWTHREAD _draw_thread_id = spawn_thread(BE_DrawThread, "drawing_thread", - B_NORMAL_PRIORITY, (void*) this); + B_NORMAL_PRIORITY, (void*) this); resume_thread(_draw_thread_id); #endif } @@ -95,22 +95,22 @@ class SDL_BWin:public BDirectWindow Lock(); _connection_disabled = true; int32 result; - + #if SDL_VIDEO_OPENGL if (_SDL_GLView) { _SDL_GLView->UnlockGL(); - RemoveChild(_SDL_GLView); /* Why was this outside the if - statement before? */ + RemoveChild(_SDL_GLView); /* Why was this outside the if + statement before? */ } - -#endif + +#endif Unlock(); #if SDL_VIDEO_OPENGL if (_SDL_GLView) { delete _SDL_GLView; } #endif - + /* Clean up framebuffer stuff */ _buffer_locker->Lock(); #ifdef DRAWTHREAD @@ -119,7 +119,7 @@ class SDL_BWin:public BDirectWindow free(_clips); delete _buffer_locker; } - + /* * * * * OpenGL functionality * * * * */ #if SDL_VIDEO_OPENGL @@ -133,186 +133,186 @@ class SDL_BWin:public BDirectWindow } AddChild(_SDL_GLView); _SDL_GLView->EnableDirectMode(true); - _SDL_GLView->LockGL(); /* "New" GLViews are created */ + _SDL_GLView->LockGL(); /* "New" GLViews are created */ Unlock(); return (_SDL_GLView); } - + virtual void RemoveGLView() { - Lock(); - if(_SDL_GLView) { - _SDL_GLView->UnlockGL(); - RemoveChild(_SDL_GLView); - } - Unlock(); + Lock(); + if(_SDL_GLView) { + _SDL_GLView->UnlockGL(); + RemoveChild(_SDL_GLView); + } + Unlock(); } - + virtual void SwapBuffers(void) { - _SDL_GLView->UnlockGL(); - _SDL_GLView->LockGL(); - _SDL_GLView->SwapBuffers(); - } + _SDL_GLView->UnlockGL(); + _SDL_GLView->LockGL(); + _SDL_GLView->SwapBuffers(); + } #endif - + /* * * * * Framebuffering* * * * */ virtual void DirectConnected(direct_buffer_info *info) { - if(!_connected && _connection_disabled) { - return; - } - - /* Determine if the pixel buffer is usable after this update */ - _trash_window_buffer = _trash_window_buffer - || ((info->buffer_state & B_BUFFER_RESIZED) - || (info->buffer_state & B_BUFFER_RESET) - || (info->driver_state == B_MODE_CHANGED)); - LockBuffer(); - - switch(info->buffer_state & B_DIRECT_MODE_MASK) { - case B_DIRECT_START: - _connected = true; - - case B_DIRECT_MODIFY: - if(_clips) { - free(_clips); - _clips = NULL; - } - - _num_clips = info->clip_list_count; - _clips = (clipping_rect *)malloc(_num_clips*sizeof(clipping_rect)); - if(_clips) { - memcpy(_clips, info->clip_list, - _num_clips*sizeof(clipping_rect)); - - _bits = (uint8*) info->bits; - _row_bytes = info->bytes_per_row; - _bounds = info->window_bounds; - _bytes_per_px = info->bits_per_pixel / 8; - _buffer_dirty = true; - } - break; - - case B_DIRECT_STOP: - _connected = false; - break; - } + if(!_connected && _connection_disabled) { + return; + } + + /* Determine if the pixel buffer is usable after this update */ + _trash_window_buffer = _trash_window_buffer + || ((info->buffer_state & B_BUFFER_RESIZED) + || (info->buffer_state & B_BUFFER_RESET) + || (info->driver_state == B_MODE_CHANGED)); + LockBuffer(); + + switch(info->buffer_state & B_DIRECT_MODE_MASK) { + case B_DIRECT_START: + _connected = true; + + case B_DIRECT_MODIFY: + if(_clips) { + free(_clips); + _clips = NULL; + } + + _num_clips = info->clip_list_count; + _clips = (clipping_rect *)malloc(_num_clips*sizeof(clipping_rect)); + if(_clips) { + memcpy(_clips, info->clip_list, + _num_clips*sizeof(clipping_rect)); + + _bits = (uint8*) info->bits; + _row_bytes = info->bytes_per_row; + _bounds = info->window_bounds; + _bytes_per_px = info->bits_per_pixel / 8; + _buffer_dirty = true; + } + break; + + case B_DIRECT_STOP: + _connected = false; + break; + } #if SDL_VIDEO_OPENGL - if(_SDL_GLView) { - _SDL_GLView->DirectConnected(info); - } + if(_SDL_GLView) { + _SDL_GLView->DirectConnected(info); + } #endif - - - /* Call the base object directconnected */ - BDirectWindow::DirectConnected(info); - - UnlockBuffer(); - + + + /* Call the base object directconnected */ + BDirectWindow::DirectConnected(info); + + UnlockBuffer(); + } - - - - + + + + /* * * * * Event sending * * * * */ /* Hook functions */ virtual void FrameMoved(BPoint origin) { - /* Post a message to the BApp so that it can handle the window event */ - BMessage msg(BAPP_WINDOW_MOVED); - msg.AddInt32("window-x", (int)origin.x); - msg.AddInt32("window-y", (int)origin.y); - _PostWindowEvent(msg); - - /* Perform normal hook operations */ - BDirectWindow::FrameMoved(origin); + /* Post a message to the BApp so that it can handle the window event */ + BMessage msg(BAPP_WINDOW_MOVED); + msg.AddInt32("window-x", (int)origin.x); + msg.AddInt32("window-y", (int)origin.y); + _PostWindowEvent(msg); + + /* Perform normal hook operations */ + BDirectWindow::FrameMoved(origin); } - + virtual void FrameResized(float width, float height) { - /* Post a message to the BApp so that it can handle the window event */ - BMessage msg(BAPP_WINDOW_RESIZED); - - msg.AddInt32("window-w", (int)width + 1); - msg.AddInt32("window-h", (int)height + 1); - _PostWindowEvent(msg); - - /* Perform normal hook operations */ - BDirectWindow::FrameResized(width, height); + /* Post a message to the BApp so that it can handle the window event */ + BMessage msg(BAPP_WINDOW_RESIZED); + + msg.AddInt32("window-w", (int)width + 1); + msg.AddInt32("window-h", (int)height + 1); + _PostWindowEvent(msg); + + /* Perform normal hook operations */ + BDirectWindow::FrameResized(width, height); } - virtual bool QuitRequested() { - BMessage msg(BAPP_WINDOW_CLOSE_REQUESTED); - _PostWindowEvent(msg); + virtual bool QuitRequested() { + BMessage msg(BAPP_WINDOW_CLOSE_REQUESTED); + _PostWindowEvent(msg); - /* We won't allow a quit unless asked by DestroyWindow() */ - return false; + /* We won't allow a quit unless asked by DestroyWindow() */ + return false; } - + virtual void WindowActivated(bool active) { - BMessage msg(BAPP_KEYBOARD_FOCUS); /* Mouse focus sold separately */ - _PostWindowEvent(msg); + BMessage msg(BAPP_KEYBOARD_FOCUS); /* Mouse focus sold separately */ + _PostWindowEvent(msg); } - + virtual void Zoom(BPoint origin, - float width, - float height) { - BMessage msg(BAPP_MAXIMIZE); /* Closest thing to maximization Haiku has */ - _PostWindowEvent(msg); - - /* Before the window zooms, record its size */ - if( !_prev_frame ) - _prev_frame = new BRect(Frame()); - - /* Perform normal hook operations */ - BDirectWindow::Zoom(origin, width, height); + float width, + float height) { + BMessage msg(BAPP_MAXIMIZE); /* Closest thing to maximization Haiku has */ + _PostWindowEvent(msg); + + /* Before the window zooms, record its size */ + if( !_prev_frame ) + _prev_frame = new BRect(Frame()); + + /* Perform normal hook operations */ + BDirectWindow::Zoom(origin, width, height); } - + /* Member functions */ virtual void Show() { - while(IsHidden()) { - BDirectWindow::Show(); - } - _shown = true; + while(IsHidden()) { + BDirectWindow::Show(); + } + _shown = true; - BMessage msg(BAPP_SHOW); - _PostWindowEvent(msg); + BMessage msg(BAPP_SHOW); + _PostWindowEvent(msg); } - + virtual void Hide() { - BDirectWindow::Hide(); - _shown = false; + BDirectWindow::Hide(); + _shown = false; - BMessage msg(BAPP_HIDE); - _PostWindowEvent(msg); + BMessage msg(BAPP_HIDE); + _PostWindowEvent(msg); } virtual void Minimize(bool minimize) { - BDirectWindow::Minimize(minimize); - int32 minState = (minimize ? BAPP_MINIMIZE : BAPP_RESTORE); - - BMessage msg(minState); - _PostWindowEvent(msg); + BDirectWindow::Minimize(minimize); + int32 minState = (minimize ? BAPP_MINIMIZE : BAPP_RESTORE); + + BMessage msg(minState); + _PostWindowEvent(msg); } - - + + /* BView message interruption */ virtual void DispatchMessage(BMessage * msg, BHandler * target) { - BPoint where; /* Used by mouse moved */ - int32 buttons; /* Used for mouse button events */ - int32 key; /* Used for key events */ - + BPoint where; /* Used by mouse moved */ + int32 buttons; /* Used for mouse button events */ + int32 key; /* Used for key events */ + switch (msg->what) { case B_MOUSE_MOVED: int32 transit; if (msg->FindPoint("where", &where) == B_OK && msg->FindInt32("be:transit", &transit) == B_OK) { - _MouseMotionEvent(where, transit); + _MouseMotionEvent(where, transit); } - + /* FIXME: Apparently a button press/release event might be dropped if made before before a different button is released. Does B_MOUSE_MOVED have the data needed to check if a mouse button state has changed? */ if (msg->FindInt32("buttons", &buttons) == B_OK) { - _MouseButtonEvent(buttons); + _MouseButtonEvent(buttons); } break; @@ -321,32 +321,32 @@ class SDL_BWin:public BDirectWindow /* _MouseButtonEvent() detects any and all buttons that may have changed state, as well as that button's new state */ if (msg->FindInt32("buttons", &buttons) == B_OK) { - _MouseButtonEvent(buttons); + _MouseButtonEvent(buttons); } break; case B_MOUSE_WHEEL_CHANGED: - float x, y; - if (msg->FindFloat("be:wheel_delta_x", &x) == B_OK - && msg->FindFloat("be:wheel_delta_y", &y) == B_OK) { - _MouseWheelEvent((int)x, (int)y); - } - break; + float x, y; + if (msg->FindFloat("be:wheel_delta_x", &x) == B_OK + && msg->FindFloat("be:wheel_delta_y", &y) == B_OK) { + _MouseWheelEvent((int)x, (int)y); + } + break; case B_KEY_DOWN: case B_UNMAPPED_KEY_DOWN: /* modifier keys are unmapped */ - if (msg->FindInt32("key", &key) == B_OK) { - _KeyEvent((SDL_Scancode)key, SDL_PRESSED); - } - break; + if (msg->FindInt32("key", &key) == B_OK) { + _KeyEvent((SDL_Scancode)key, SDL_PRESSED); + } + break; case B_KEY_UP: case B_UNMAPPED_KEY_UP: /* modifier keys are unmapped */ - if (msg->FindInt32("key", &key) == B_OK) { - _KeyEvent(key, SDL_RELEASED); + if (msg->FindInt32("key", &key) == B_OK) { + _KeyEvent(key, SDL_RELEASED); } break; - + default: /* move it after switch{} so it's always handled that way we keep BeOS feautures like: @@ -359,263 +359,263 @@ class SDL_BWin:public BDirectWindow BDirectWindow::DispatchMessage(msg, target); } - + /* Handle command messages */ virtual void MessageReceived(BMessage* message) { - switch (message->what) { - /* Handle commands from SDL */ - case BWIN_SET_TITLE: - _SetTitle(message); - break; - case BWIN_MOVE_WINDOW: - _MoveTo(message); - break; - case BWIN_RESIZE_WINDOW: - _ResizeTo(message); - break; - case BWIN_SET_BORDERED: - _SetBordered(message); - break; - case BWIN_SHOW_WINDOW: - Show(); - break; - case BWIN_HIDE_WINDOW: - Hide(); - break; - case BWIN_MAXIMIZE_WINDOW: - BWindow::Zoom(); - break; - case BWIN_MINIMIZE_WINDOW: - Minimize(true); - break; - case BWIN_RESTORE_WINDOW: - _Restore(); - break; - case BWIN_FULLSCREEN: - _SetFullScreen(message); - break; - default: - /* Perform normal message handling */ - BDirectWindow::MessageReceived(message); - break; - } + switch (message->what) { + /* Handle commands from SDL */ + case BWIN_SET_TITLE: + _SetTitle(message); + break; + case BWIN_MOVE_WINDOW: + _MoveTo(message); + break; + case BWIN_RESIZE_WINDOW: + _ResizeTo(message); + break; + case BWIN_SET_BORDERED: + _SetBordered(message); + break; + case BWIN_SHOW_WINDOW: + Show(); + break; + case BWIN_HIDE_WINDOW: + Hide(); + break; + case BWIN_MAXIMIZE_WINDOW: + BWindow::Zoom(); + break; + case BWIN_MINIMIZE_WINDOW: + Minimize(true); + break; + case BWIN_RESTORE_WINDOW: + _Restore(); + break; + case BWIN_FULLSCREEN: + _SetFullScreen(message); + break; + default: + /* Perform normal message handling */ + BDirectWindow::MessageReceived(message); + break; + } } - - - - /* Accessor methods */ - bool IsShown() { return _shown; } - int32 GetID() { return _id; } - uint32 GetRowBytes() { return _row_bytes; } - int32 GetFbX() { return _bounds.left; } - int32 GetFbY() { return _bounds.top; } - bool ConnectionEnabled() { return !_connection_disabled; } - bool Connected() { return _connected; } - clipping_rect *GetClips() { return _clips; } - int32 GetNumClips() { return _num_clips; } - uint8* GetBufferPx() { return _bits; } - int32 GetBytesPerPx() { return _bytes_per_px; } - bool CanTrashWindowBuffer() { return _trash_window_buffer; } - bool BufferExists() { return _buffer_created; } - bool BufferIsDirty() { return _buffer_dirty; } - BBitmap *GetBitmap() { return _bitmap; } + + + + /* Accessor methods */ + bool IsShown() { return _shown; } + int32 GetID() { return _id; } + uint32 GetRowBytes() { return _row_bytes; } + int32 GetFbX() { return _bounds.left; } + int32 GetFbY() { return _bounds.top; } + bool ConnectionEnabled() { return !_connection_disabled; } + bool Connected() { return _connected; } + clipping_rect *GetClips() { return _clips; } + int32 GetNumClips() { return _num_clips; } + uint8* GetBufferPx() { return _bits; } + int32 GetBytesPerPx() { return _bytes_per_px; } + bool CanTrashWindowBuffer() { return _trash_window_buffer; } + bool BufferExists() { return _buffer_created; } + bool BufferIsDirty() { return _buffer_dirty; } + BBitmap *GetBitmap() { return _bitmap; } #if SDL_VIDEO_OPENGL - BGLView *GetGLView() { return _SDL_GLView; } + BGLView *GetGLView() { return _SDL_GLView; } #endif - - /* Setter methods */ - void SetID(int32 id) { _id = id; } - void SetBufferExists(bool bufferExists) { _buffer_created = bufferExists; } - void LockBuffer() { _buffer_locker->Lock(); } - void UnlockBuffer() { _buffer_locker->Unlock(); } - void SetBufferDirty(bool bufferDirty) { _buffer_dirty = bufferDirty; } - void SetTrashBuffer(bool trash) { _trash_window_buffer = trash; } - void SetBitmap(BBitmap *bitmap) { _bitmap = bitmap; } - - + + /* Setter methods */ + void SetID(int32 id) { _id = id; } + void SetBufferExists(bool bufferExists) { _buffer_created = bufferExists; } + void LockBuffer() { _buffer_locker->Lock(); } + void UnlockBuffer() { _buffer_locker->Unlock(); } + void SetBufferDirty(bool bufferDirty) { _buffer_dirty = bufferDirty; } + void SetTrashBuffer(bool trash) { _trash_window_buffer = trash; } + void SetBitmap(BBitmap *bitmap) { _bitmap = bitmap; } + + private: - /* Event redirection */ + /* Event redirection */ void _MouseMotionEvent(BPoint &where, int32 transit) { - if(transit == B_EXITED_VIEW) { - /* Change mouse focus */ - if(_mouse_focused) { - _MouseFocusEvent(false); - } - } else { - /* Change mouse focus */ - if (!_mouse_focused) { - _MouseFocusEvent(true); - } - BMessage msg(BAPP_MOUSE_MOVED); - msg.AddInt32("x", (int)where.x); - msg.AddInt32("y", (int)where.y); - - _PostWindowEvent(msg); - } + if(transit == B_EXITED_VIEW) { + /* Change mouse focus */ + if(_mouse_focused) { + _MouseFocusEvent(false); + } + } else { + /* Change mouse focus */ + if (!_mouse_focused) { + _MouseFocusEvent(true); + } + BMessage msg(BAPP_MOUSE_MOVED); + msg.AddInt32("x", (int)where.x); + msg.AddInt32("y", (int)where.y); + + _PostWindowEvent(msg); + } } - + void _MouseFocusEvent(bool focusGained) { - _mouse_focused = focusGained; - BMessage msg(BAPP_MOUSE_FOCUS); - msg.AddBool("focusGained", focusGained); - _PostWindowEvent(msg); - + _mouse_focused = focusGained; + BMessage msg(BAPP_MOUSE_FOCUS); + msg.AddBool("focusGained", focusGained); + _PostWindowEvent(msg); + //FIXME: Why were these here? // if false: be_app->SetCursor(B_HAND_CURSOR); // if true: SDL_SetCursor(NULL); } - + void _MouseButtonEvent(int32 buttons) { - int32 buttonStateChange = buttons ^ _last_buttons; - - /* Make sure at least one button has changed state */ - if( !(buttonStateChange) ) { - return; - } - - /* Add any mouse button events */ - if(buttonStateChange & B_PRIMARY_MOUSE_BUTTON) { - _SendMouseButton(SDL_BUTTON_LEFT, buttons & - B_PRIMARY_MOUSE_BUTTON); - } - if(buttonStateChange & B_SECONDARY_MOUSE_BUTTON) { - _SendMouseButton(SDL_BUTTON_RIGHT, buttons & - B_PRIMARY_MOUSE_BUTTON); - } - if(buttonStateChange & B_TERTIARY_MOUSE_BUTTON) { - _SendMouseButton(SDL_BUTTON_MIDDLE, buttons & - B_PRIMARY_MOUSE_BUTTON); - } - - _last_buttons = buttons; + int32 buttonStateChange = buttons ^ _last_buttons; + + /* Make sure at least one button has changed state */ + if( !(buttonStateChange) ) { + return; + } + + /* Add any mouse button events */ + if(buttonStateChange & B_PRIMARY_MOUSE_BUTTON) { + _SendMouseButton(SDL_BUTTON_LEFT, buttons & + B_PRIMARY_MOUSE_BUTTON); + } + if(buttonStateChange & B_SECONDARY_MOUSE_BUTTON) { + _SendMouseButton(SDL_BUTTON_RIGHT, buttons & + B_PRIMARY_MOUSE_BUTTON); + } + if(buttonStateChange & B_TERTIARY_MOUSE_BUTTON) { + _SendMouseButton(SDL_BUTTON_MIDDLE, buttons & + B_PRIMARY_MOUSE_BUTTON); + } + + _last_buttons = buttons; } - + void _SendMouseButton(int32 button, int32 state) { - BMessage msg(BAPP_MOUSE_BUTTON); - msg.AddInt32("button-id", button); - msg.AddInt32("button-state", state); - _PostWindowEvent(msg); + BMessage msg(BAPP_MOUSE_BUTTON); + msg.AddInt32("button-id", button); + msg.AddInt32("button-state", state); + _PostWindowEvent(msg); } - + void _MouseWheelEvent(int32 x, int32 y) { - /* Create a message to pass along to the BeApp thread */ - BMessage msg(BAPP_MOUSE_WHEEL); - msg.AddInt32("xticks", x); - msg.AddInt32("yticks", y); - _PostWindowEvent(msg); + /* Create a message to pass along to the BeApp thread */ + BMessage msg(BAPP_MOUSE_WHEEL); + msg.AddInt32("xticks", x); + msg.AddInt32("yticks", y); + _PostWindowEvent(msg); } - + void _KeyEvent(int32 keyCode, int32 keyState) { - /* Create a message to pass along to the BeApp thread */ - BMessage msg(BAPP_KEY); - msg.AddInt32("key-state", keyState); - msg.AddInt32("key-scancode", keyCode); - be_app->PostMessage(&msg); - /* Apparently SDL only uses the scancode */ + /* Create a message to pass along to the BeApp thread */ + BMessage msg(BAPP_KEY); + msg.AddInt32("key-state", keyState); + msg.AddInt32("key-scancode", keyCode); + be_app->PostMessage(&msg); + /* Apparently SDL only uses the scancode */ } - + void _RepaintEvent() { - /* Force a repaint: Call the SDL exposed event */ - BMessage msg(BAPP_REPAINT); - _PostWindowEvent(msg); + /* Force a repaint: Call the SDL exposed event */ + BMessage msg(BAPP_REPAINT); + _PostWindowEvent(msg); } void _PostWindowEvent(BMessage &msg) { - msg.AddInt32("window-id", _id); - be_app->PostMessage(&msg); + msg.AddInt32("window-id", _id); + be_app->PostMessage(&msg); } - - /* Command methods (functions called upon by SDL) */ + + /* Command methods (functions called upon by SDL) */ void _SetTitle(BMessage *msg) { - const char *title; - if( - msg->FindString("window-title", &title) != B_OK - ) { - return; - } - SetTitle(title); + const char *title; + if( + msg->FindString("window-title", &title) != B_OK + ) { + return; + } + SetTitle(title); } - + void _MoveTo(BMessage *msg) { - int32 x, y; - if( - msg->FindInt32("window-x", &x) != B_OK || - msg->FindInt32("window-y", &y) != B_OK - ) { - return; - } - MoveTo(x, y); + int32 x, y; + if( + msg->FindInt32("window-x", &x) != B_OK || + msg->FindInt32("window-y", &y) != B_OK + ) { + return; + } + MoveTo(x, y); } - + void _ResizeTo(BMessage *msg) { - int32 w, h; - if( - msg->FindInt32("window-w", &w) != B_OK || - msg->FindInt32("window-h", &h) != B_OK - ) { - return; - } - ResizeTo(w, h); + int32 w, h; + if( + msg->FindInt32("window-w", &w) != B_OK || + msg->FindInt32("window-h", &h) != B_OK + ) { + return; + } + ResizeTo(w, h); } void _SetBordered(BMessage *msg) { - bool bEnabled; - if(msg->FindBool("window-border", &bEnabled) != B_OK) { - return; - } - SetLook(bEnabled ? B_BORDERED_WINDOW_LOOK : B_NO_BORDER_WINDOW_LOOK); + bool bEnabled; + if(msg->FindBool("window-border", &bEnabled) != B_OK) { + return; + } + SetLook(bEnabled ? B_BORDERED_WINDOW_LOOK : B_NO_BORDER_WINDOW_LOOK); } void _Restore() { - if(IsMinimized()) { - Minimize(false); - } else if(IsHidden()) { - Show(); - } else if(_prev_frame != NULL) { /* Zoomed */ - MoveTo(_prev_frame->left, _prev_frame->top); - ResizeTo(_prev_frame->Width(), _prev_frame->Height()); - } + if(IsMinimized()) { + Minimize(false); + } else if(IsHidden()) { + Show(); + } else if(_prev_frame != NULL) { /* Zoomed */ + MoveTo(_prev_frame->left, _prev_frame->top); + ResizeTo(_prev_frame->Width(), _prev_frame->Height()); + } } void _SetFullScreen(BMessage *msg) { - bool fullscreen; - if( - msg->FindBool("fullscreen", &fullscreen) != B_OK - ) { - return; - } - SetFullScreen(fullscreen); + bool fullscreen; + if( + msg->FindBool("fullscreen", &fullscreen) != B_OK + ) { + return; + } + SetFullScreen(fullscreen); } - + /* Members */ #if SDL_VIDEO_OPENGL BGLView * _SDL_GLView; #endif - + int32 _last_buttons; - int32 _id; /* Window id used by SDL_BApp */ - bool _mouse_focused; /* Does this window have mouse focus? */ + int32 _id; /* Window id used by SDL_BApp */ + bool _mouse_focused; /* Does this window have mouse focus? */ bool _shown; bool _inhibit_resize; - - BRect *_prev_frame; /* Previous position and size of the window */ - + + BRect *_prev_frame; /* Previous position and size of the window */ + /* Framebuffer members */ - bool _connected, - _connection_disabled, - _buffer_created, - _buffer_dirty, - _trash_window_buffer; - uint8 *_bits; - uint32 _row_bytes; - clipping_rect _bounds; - BLocker *_buffer_locker; + bool _connected, + _connection_disabled, + _buffer_created, + _buffer_dirty, + _trash_window_buffer; + uint8 *_bits; + uint32 _row_bytes; + clipping_rect _bounds; + BLocker *_buffer_locker; clipping_rect *_clips; - int32 _num_clips; - int32 _bytes_per_px; - thread_id _draw_thread_id; - - BBitmap *_bitmap; + int32 _num_clips; + int32 _bytes_per_px; + thread_id _draw_thread_id; + + BBitmap *_bitmap; }; diff --git a/src/video/bwindow/SDL_bevents.h b/src/video/bwindow/SDL_bevents.h index 66284283a..a83d03b52 100644 --- a/src/video/bwindow/SDL_bevents.h +++ b/src/video/bwindow/SDL_bevents.h @@ -17,7 +17,7 @@ 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. -*/ +*/ #ifndef SDL_BEVENTS_H #define SDL_BEVENTS_H diff --git a/src/video/bwindow/SDL_bmodes.cc b/src/video/bwindow/SDL_bmodes.cc index 2e8f4b577..41894fb78 100644 --- a/src/video/bwindow/SDL_bmodes.cc +++ b/src/video/bwindow/SDL_bmodes.cc @@ -275,7 +275,7 @@ void BE_GetDisplayModes(_THIS, SDL_VideoDisplay *display) { bscreen.GetMode(&this_bmode); for(i = 0; i < count; ++i) { - //FIXME: Apparently there are errors with colorspace changes + // FIXME: Apparently there are errors with colorspace changes if (bmodes[i].space == this_bmode.space) { _BDisplayModeToSdlDisplayMode(&bmodes[i], &mode); SDL_AddDisplayMode(display, &mode); diff --git a/src/video/bwindow/SDL_bmodes.h b/src/video/bwindow/SDL_bmodes.h index 5e723a801..9ca04d087 100644 --- a/src/video/bwindow/SDL_bmodes.h +++ b/src/video/bwindow/SDL_bmodes.h @@ -34,10 +34,10 @@ extern int32 BE_BPPToSDLPxFormat(int32 bpp); extern int BE_InitModes(_THIS); extern int BE_QuitModes(_THIS); extern int BE_GetDisplayBounds(_THIS, SDL_VideoDisplay *display, - SDL_Rect *rect); + SDL_Rect *rect); extern void BE_GetDisplayModes(_THIS, SDL_VideoDisplay *display); extern int BE_SetDisplayMode(_THIS, SDL_VideoDisplay *display, - SDL_DisplayMode *mode); + SDL_DisplayMode *mode); #ifdef __cplusplus } diff --git a/src/video/bwindow/SDL_bopengl.h b/src/video/bwindow/SDL_bopengl.h index 35a3b204c..f0279ba66 100644 --- a/src/video/bwindow/SDL_bopengl.h +++ b/src/video/bwindow/SDL_bopengl.h @@ -29,13 +29,13 @@ extern "C" { #include "../SDL_sysvideo.h" -extern int BE_GL_LoadLibrary(_THIS, const char *path); //FIXME -extern void *BE_GL_GetProcAddress(_THIS, const char *proc); //FIXME -extern void BE_GL_UnloadLibrary(_THIS); //TODO +extern int BE_GL_LoadLibrary(_THIS, const char *path); //FIXME +extern void *BE_GL_GetProcAddress(_THIS, const char *proc); //FIXME +extern void BE_GL_UnloadLibrary(_THIS); //TODO extern int BE_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context); -extern int BE_GL_SetSwapInterval(_THIS, int interval); //TODO -extern int BE_GL_GetSwapInterval(_THIS); //TODO +extern int BE_GL_SetSwapInterval(_THIS, int interval); //TODO +extern int BE_GL_GetSwapInterval(_THIS); //TODO extern void BE_GL_SwapWindow(_THIS, SDL_Window * window); extern SDL_GLContext BE_GL_CreateContext(_THIS, SDL_Window * window); extern void BE_GL_DeleteContext(_THIS, SDL_GLContext context); diff --git a/src/video/cocoa/SDL_cocoaclipboard.m b/src/video/cocoa/SDL_cocoaclipboard.m index fd499260a..27d222769 100644 --- a/src/video/cocoa/SDL_cocoaclipboard.m +++ b/src/video/cocoa/SDL_cocoaclipboard.m @@ -99,8 +99,8 @@ SDL_bool result = SDL_FALSE; char *text = Cocoa_GetClipboardText(_this); if (text) { - result = (SDL_strlen(text)>0) ? SDL_TRUE : SDL_FALSE; - SDL_free(text); + result = (SDL_strlen(text)>0) ? SDL_TRUE : SDL_FALSE; + SDL_free(text); } return result; } diff --git a/src/video/cocoa/SDL_cocoaevents.m b/src/video/cocoa/SDL_cocoaevents.m index 7df95bbd0..e952a9e9f 100644 --- a/src/video/cocoa/SDL_cocoaevents.m +++ b/src/video/cocoa/SDL_cocoaevents.m @@ -68,7 +68,7 @@ - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filenam dict = (NSDictionary *)CFBundleGetInfoDictionary(CFBundleGetMainBundle()); if (dict) appName = [dict objectForKey: @"CFBundleName"]; - + if (![appName length]) appName = [[NSProcessInfo processInfo] processName]; @@ -84,14 +84,14 @@ - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filenam NSMenu *serviceMenu; NSMenu *windowMenu; NSMenuItem *menuItem; - + /* Create the main menu bar */ [NSApp setMainMenu:[[NSMenu alloc] init]]; /* Create the application menu */ appName = GetApplicationName(); appleMenu = [[NSMenu alloc] initWithTitle:@""]; - + /* Add menu items */ title = [@"About " stringByAppendingString:appName]; [appleMenu addItemWithTitle:title action:@selector(orderFrontStandardAboutPanel:) keyEquivalent:@""]; @@ -123,7 +123,7 @@ - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filenam title = [@"Quit " stringByAppendingString:appName]; [appleMenu addItemWithTitle:title action:@selector(terminate:) keyEquivalent:@"q"]; - + /* Put menu into the menubar */ menuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""]; [menuItem setSubmenu:appleMenu]; @@ -137,10 +137,10 @@ - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filenam /* Create the window menu */ windowMenu = [[NSMenu alloc] initWithTitle:@"Window"]; - + /* Add menu items */ [windowMenu addItemWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@"m"]; - + [windowMenu addItemWithTitle:@"Zoom" action:@selector(performZoom:) keyEquivalent:@""]; /* Put menu into the menubar */ @@ -148,7 +148,7 @@ - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filenam [menuItem setSubmenu:windowMenu]; [[NSApp mainMenu] addItem:menuItem]; [menuItem release]; - + /* Tell the application object that this is now the window menu */ [NSApp setWindowsMenu:windowMenu]; [windowMenu release]; @@ -203,7 +203,7 @@ - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filenam if ( event == nil ) { break; } - + switch ([event type]) { case NSLeftMouseDown: case NSOtherMouseDown: diff --git a/src/video/cocoa/SDL_cocoakeyboard.m b/src/video/cocoa/SDL_cocoakeyboard.m index 63f4bf942..705b0358d 100644 --- a/src/video/cocoa/SDL_cocoakeyboard.m +++ b/src/video/cocoa/SDL_cocoakeyboard.m @@ -29,7 +29,7 @@ #include -//#define DEBUG_IME NSLog +/*#define DEBUG_IME NSLog */ #define DEBUG_IME(...) #ifndef NX_DEVICERCTLKEYMASK @@ -93,9 +93,10 @@ - (void) insertText:(id) aString - (void) doCommandBySelector:(SEL) myselector { - // No need to do anything since we are not using Cocoa - // selectors to handle special keys, instead we use SDL - // key events to do the same job. + /* No need to do anything since we are not using Cocoa + selectors to handle special keys, instead we use SDL + key events to do the same job. + */ } - (BOOL) hasMarkedText @@ -181,18 +182,20 @@ - (NSInteger) conversationIdentifier return (long) self; } -// This method returns the index for character that is -// nearest to thePoint. thPoint is in screen coordinate system. +/* This method returns the index for character that is + * nearest to thePoint. thPoint is in screen coordinate system. + */ - (NSUInteger) characterIndexForPoint:(NSPoint) thePoint { DEBUG_IME(@"characterIndexForPoint: (%g, %g)", thePoint.x, thePoint.y); return 0; } -// This method is the key to attribute extension. -// We could add new attributes through this method. -// NSInputServer examines the return value of this -// method & constructs appropriate attributed string. +/* This method is the key to attribute extension. + * We could add new attributes through this method. + * NSInputServer examines the return value of this + * method & constructs appropriate attributed string. + */ - (NSArray *) validAttributesForMarkedText { return [NSArray array]; @@ -200,7 +203,7 @@ - (NSArray *) validAttributesForMarkedText @end -/* This is the original behavior, before support was added for +/* This is the original behavior, before support was added for * differentiating between left and right versions of the keys. */ static void @@ -239,7 +242,7 @@ - (NSArray *) validAttributesForMarkedText } } -/* This is a helper function for HandleModifierSide. This +/* This is a helper function for HandleModifierSide. This * function reverts back to behavior before the distinction between * sides was made. */ @@ -250,13 +253,13 @@ - (NSArray *) validAttributesForMarkedText SDL_Scancode scancode) { unsigned int oldMask, newMask; - - /* Isolate just the bits we care about in the depedent bits so we can + + /* Isolate just the bits we care about in the depedent bits so we can * figure out what changed - */ + */ oldMask = oldMods & device_independent_mask; newMask = newMods & device_independent_mask; - + if (oldMask && oldMask != newMask) { SDL_SendKeyboardKey(SDL_RELEASED, scancode); } else if (newMask && oldMask != newMask) { @@ -264,24 +267,24 @@ - (NSArray *) validAttributesForMarkedText } } -/* This is a helper function for HandleModifierSide. +/* This is a helper function for HandleModifierSide. * This function sets the actual SDL_PrivateKeyboard event. */ static void HandleModifierOneSide(unsigned int oldMods, unsigned int newMods, - SDL_Scancode scancode, + SDL_Scancode scancode, unsigned int sided_device_dependent_mask) { unsigned int old_dep_mask, new_dep_mask; - /* Isolate just the bits we care about in the depedent bits so we can + /* Isolate just the bits we care about in the depedent bits so we can * figure out what changed - */ + */ old_dep_mask = oldMods & sided_device_dependent_mask; new_dep_mask = newMods & sided_device_dependent_mask; /* We now know that this side bit flipped. But we don't know if - * it went pressed to released or released to pressed, so we must + * it went pressed to released or released to pressed, so we must * find out which it is. */ if (new_dep_mask && old_dep_mask != new_dep_mask) { @@ -292,23 +295,23 @@ - (NSArray *) validAttributesForMarkedText } /* This is a helper function for DoSidedModifiers. - * This function will figure out if the modifier key is the left or right side, - * e.g. left-shift vs right-shift. + * This function will figure out if the modifier key is the left or right side, + * e.g. left-shift vs right-shift. */ static void -HandleModifierSide(int device_independent_mask, - unsigned int oldMods, unsigned int newMods, - SDL_Scancode left_scancode, +HandleModifierSide(int device_independent_mask, + unsigned int oldMods, unsigned int newMods, + SDL_Scancode left_scancode, SDL_Scancode right_scancode, - unsigned int left_device_dependent_mask, + unsigned int left_device_dependent_mask, unsigned int right_device_dependent_mask) { unsigned int device_dependent_mask = (left_device_dependent_mask | right_device_dependent_mask); unsigned int diff_mod; - - /* On the basis that the device independent mask is set, but there are - * no device dependent flags set, we'll assume that we can't detect this + + /* On the basis that the device independent mask is set, but there are + * no device dependent flags set, we'll assume that we can't detect this * keyboard and revert to the unsided behavior. */ if ((device_dependent_mask & newMods) == 0) { @@ -321,7 +324,7 @@ - (NSArray *) validAttributesForMarkedText diff_mod = (device_dependent_mask & oldMods) ^ (device_dependent_mask & newMods); if (diff_mod) { - /* A change in state was found. Isolate the left and right bits + /* A change in state was found. Isolate the left and right bits * to handle them separately just in case the values can simulataneously * change or if the bits don't both exist. */ @@ -333,38 +336,38 @@ - (NSArray *) validAttributesForMarkedText } } } - + /* This is a helper function for DoSidedModifiers. - * This function will release a key press in the case that - * it is clear that the modifier has been released (i.e. one side + * This function will release a key press in the case that + * it is clear that the modifier has been released (i.e. one side * can't still be down). */ static void -ReleaseModifierSide(unsigned int device_independent_mask, +ReleaseModifierSide(unsigned int device_independent_mask, unsigned int oldMods, unsigned int newMods, - SDL_Scancode left_scancode, + SDL_Scancode left_scancode, SDL_Scancode right_scancode, - unsigned int left_device_dependent_mask, + unsigned int left_device_dependent_mask, unsigned int right_device_dependent_mask) { unsigned int device_dependent_mask = (left_device_dependent_mask | right_device_dependent_mask); - /* On the basis that the device independent mask is set, but there are - * no device dependent flags set, we'll assume that we can't detect this + /* On the basis that the device independent mask is set, but there are + * no device dependent flags set, we'll assume that we can't detect this * keyboard and revert to the unsided behavior. */ if ((device_dependent_mask & oldMods) == 0) { - /* In this case, we can't detect the keyboard, so use the left side - * to represent both, and release it. + /* In this case, we can't detect the keyboard, so use the left side + * to represent both, and release it. */ SDL_SendKeyboardKey(SDL_RELEASED, left_scancode); return; } - /* + /* * This could have been done in an if-else case because at this point, - * we know that all keys have been released when calling this function. + * we know that all keys have been released when calling this function. * But I'm being paranoid so I want to handle each separately, * so I hope this doesn't cause other problems. */ @@ -384,7 +387,7 @@ - (NSArray *) validAttributesForMarkedText unsigned int oldMods, unsigned int newMods) { unsigned int oldMask, newMask; - + oldMask = oldMods & NSAlphaShiftKeyMask; newMask = newMods & NSAlphaShiftKeyMask; @@ -402,14 +405,14 @@ - (NSArray *) validAttributesForMarkedText } } -/* This function will handle the modifier keys and also determine the +/* This function will handle the modifier keys and also determine the * correct side of the key. */ static void DoSidedModifiers(unsigned short scancode, unsigned int oldMods, unsigned int newMods) { - /* Set up arrays for the key syms for the left and right side. */ + /* Set up arrays for the key syms for the left and right side. */ const SDL_Scancode left_mapping[] = { SDL_SCANCODE_LSHIFT, SDL_SCANCODE_LCTRL, @@ -422,8 +425,8 @@ - (NSArray *) validAttributesForMarkedText SDL_SCANCODE_RALT, SDL_SCANCODE_RGUI }; - /* Set up arrays for the device dependent masks with indices that - * correspond to the _mapping arrays + /* Set up arrays for the device dependent masks with indices that + * correspond to the _mapping arrays */ const unsigned int left_device_mapping[] = { NX_DEVICELSHIFTKEYMASK, NX_DEVICELCTLKEYMASK, NX_DEVICELALTKEYMASK, NX_DEVICELCMDKEYMASK }; const unsigned int right_device_mapping[] = { NX_DEVICERSHIFTKEYMASK, NX_DEVICERCTLKEYMASK, NX_DEVICERALTKEYMASK, NX_DEVICERCMDKEYMASK }; @@ -436,10 +439,10 @@ - (NSArray *) validAttributesForMarkedText /* Iterate through the bits, testing each against the old modifiers */ for (i = 0, bit = NSShiftKeyMask; bit <= NSCommandKeyMask; bit <<= 1, ++i) { unsigned int oldMask, newMask; - + oldMask = oldMods & bit; newMask = newMods & bit; - + /* If the bit is set, we must always examine it because the left * and right side keys may alternate or both may be pressed. */ @@ -465,11 +468,11 @@ - (NSArray *) validAttributesForMarkedText SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; if (modifierFlags == data->modifierFlags) { - return; + return; } - /* - * Starting with Panther (10.3.0), the ability to distinguish between + /* + * Starting with Panther (10.3.0), the ability to distinguish between * left side and right side modifiers is available. */ if (data->osversion >= 0x1030) { @@ -611,7 +614,7 @@ - (NSArray *) validAttributesForMarkedText SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; UpdateKeymap(data); - + /* Set our own names for the platform-dependent but layout-independent keys */ /* This key is NumLock on the MacBook keyboard. :) */ /*SDL_SetScancodeName(SDL_SCANCODE_NUMLOCKCLEAR, "Clear");*/ @@ -640,7 +643,7 @@ - (NSArray *) validAttributesForMarkedText if (![[data->fieldEdit superview] isEqual: parentView]) { - // DEBUG_IME(@"add fieldEdit to window contentView"); + /* DEBUG_IME(@"add fieldEdit to window contentView"); */ [data->fieldEdit removeFromSuperview]; [parentView addSubview: data->fieldEdit]; [[NSApp keyWindow] makeFirstResponder: data->fieldEdit]; @@ -669,8 +672,8 @@ - (NSArray *) validAttributesForMarkedText SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; if (!rect) { - SDL_InvalidParamError("rect"); - return; + SDL_InvalidParamError("rect"); + return; } [data->fieldEdit setInputRect: rect]; diff --git a/src/video/cocoa/SDL_cocoamodes.m b/src/video/cocoa/SDL_cocoamodes.m index 563226c2a..ad6ece279 100644 --- a/src/video/cocoa/SDL_cocoamodes.m +++ b/src/video/cocoa/SDL_cocoamodes.m @@ -55,8 +55,8 @@ static inline void Cocoa_ToggleMenuBar(const BOOL show) #endif #if MAC_OS_X_VERSION_MAX_ALLOWED < 1050 -/* - Add methods to get at private members of NSScreen. +/* + Add methods to get at private members of NSScreen. Since there is a bug in Apple's screen switching code that does not update this variable when switching to fullscreen, we'll set it manually (but only for the @@ -226,7 +226,7 @@ - (void) setFrame:(NSRect)frame; NSDictionary *deviceInfo = (NSDictionary *)IODisplayCreateInfoDictionary(CGDisplayIOServicePort(displayID), kIODisplayOnlyPreferredName); NSDictionary *localizedNames = [deviceInfo objectForKey:[NSString stringWithUTF8String:kDisplayProductName]]; const char* displayName = NULL; - + if ([localizedNames count] > 0) { displayName = SDL_strdup([[localizedNames objectForKey:[[localizedNames allKeys] objectAtIndex:0]] UTF8String]); } @@ -304,7 +304,7 @@ - (void) setFrame:(NSRect)frame; displaydata->display = displays[i]; SDL_zero(display); - // this returns a stddup'ed string + /* this returns a stddup'ed string */ display.name = (char *)Cocoa_GetDisplayName(displays[i]); if (!GetDisplayMode (_this, moderef, &mode)) { Cocoa_ReleaseDisplayMode(_this, moderef); diff --git a/src/video/cocoa/SDL_cocoamouse.m b/src/video/cocoa/SDL_cocoamouse.m index 4a6c581d5..fd76bb584 100644 --- a/src/video/cocoa/SDL_cocoamouse.m +++ b/src/video/cocoa/SDL_cocoamouse.m @@ -153,7 +153,7 @@ + (NSCursor *)invisibleCursor if (nscursor) { cursor = SDL_calloc(1, sizeof(*cursor)); if (cursor) { - // We'll free it later, so retain it here + /* We'll free it later, so retain it here */ [nscursor retain]; cursor->driverdata = nscursor; } diff --git a/src/video/cocoa/SDL_cocoashape.h b/src/video/cocoa/SDL_cocoashape.h index fc867a081..3b656c1a9 100644 --- a/src/video/cocoa/SDL_cocoashape.h +++ b/src/video/cocoa/SDL_cocoashape.h @@ -30,10 +30,10 @@ #include "../SDL_shape_internals.h" typedef struct { - NSGraphicsContext* context; - SDL_bool saved; - - SDL_ShapeTree* shape; + NSGraphicsContext* context; + SDL_bool saved; + + SDL_ShapeTree* shape; } SDL_ShapeData; extern SDL_WindowShaper* Cocoa_CreateShaper(SDL_Window* window); diff --git a/src/video/cocoa/SDL_cocoashape.m b/src/video/cocoa/SDL_cocoashape.m index 8f2fa47dc..3cde7d048 100644 --- a/src/video/cocoa/SDL_cocoashape.m +++ b/src/video/cocoa/SDL_cocoashape.m @@ -42,13 +42,13 @@ result->mode.parameters.binarizationCutoff = 1; result->userx = result->usery = 0; window->shaper = result; - + SDL_ShapeData* data = malloc(sizeof(SDL_ShapeData)); result->driverdata = data; data->context = [windata->nswindow graphicsContext]; data->saved = SDL_FALSE; data->shape = NULL; - + int resized_properly = Cocoa_ResizeWindowShape(window); SDL_assert(resized_properly == 0); return result; @@ -72,26 +72,26 @@ int Cocoa_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode) { SDL_ShapeData* data = (SDL_ShapeData*)shaper->driverdata; - SDL_WindowData* windata = (SDL_WindowData*)shaper->window->driverdata; - SDL_CocoaClosure closure; - NSAutoreleasePool *pool = NULL; + SDL_WindowData* windata = (SDL_WindowData*)shaper->window->driverdata; + SDL_CocoaClosure closure; + NSAutoreleasePool *pool = NULL; if(data->saved == SDL_TRUE) { [data->context restoreGraphicsState]; data->saved = SDL_FALSE; } - + //[data->context saveGraphicsState]; //data->saved = SDL_TRUE; - [NSGraphicsContext setCurrentContext:data->context]; - + [NSGraphicsContext setCurrentContext:data->context]; + [[NSColor clearColor] set]; NSRectFill([[windata->nswindow contentView] frame]); data->shape = SDL_CalculateShapeTree(*shape_mode,shape); - - pool = [[NSAutoreleasePool alloc] init]; + + pool = [[NSAutoreleasePool alloc] init]; closure.view = [windata->nswindow contentView]; closure.path = [[NSBezierPath bezierPath] autorelease]; - closure.window = shaper->window; + closure.window = shaper->window; SDL_TraverseShapeTree(data->shape,&ConvertRects,&closure); [closure.path addClip]; diff --git a/src/video/cocoa/SDL_cocoavideo.m b/src/video/cocoa/SDL_cocoavideo.m index 6502a3fd7..5600222ae 100644 --- a/src/video/cocoa/SDL_cocoavideo.m +++ b/src/video/cocoa/SDL_cocoavideo.m @@ -110,11 +110,11 @@ device->SetWindowGrab = Cocoa_SetWindowGrab; device->DestroyWindow = Cocoa_DestroyWindow; device->GetWindowWMInfo = Cocoa_GetWindowWMInfo; - + device->shape_driver.CreateShaper = Cocoa_CreateShaper; device->shape_driver.SetWindowShape = Cocoa_SetWindowShape; device->shape_driver.ResizeWindowShape = Cocoa_ResizeWindowShape; - + #if SDL_VIDEO_OPENGL_CGL device->GL_LoadLibrary = Cocoa_GL_LoadLibrary; device->GL_GetProcAddress = Cocoa_GL_GetProcAddress; @@ -173,7 +173,7 @@ int i; NSImage *img; - converted = SDL_ConvertSurfaceFormat(surface, + converted = SDL_ConvertSurfaceFormat(surface, #if SDL_BYTEORDER == SDL_BIG_ENDIAN SDL_PIXELFORMAT_RGBA8888, #else diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m index f6d54a78d..d0f825cba 100644 --- a/src/video/cocoa/SDL_cocoawindow.m +++ b/src/video/cocoa/SDL_cocoawindow.m @@ -67,9 +67,10 @@ - (void)listen:(SDL_WindowData *)data [window setDelegate:self]; } - // Haven't found a delegate / notification that triggers when the window is - // ordered out (is not visible any more). You can be ordered out without - // minimizing, so DidMiniaturize doesn't work. (e.g. -[NSWindow orderOut:]) + /* Haven't found a delegate / notification that triggers when the window is + * ordered out (is not visible any more). You can be ordered out without + * minimizing, so DidMiniaturize doesn't work. (e.g. -[NSWindow orderOut:]) + */ [window addObserver:self forKeyPath:@"visible" options:NSKeyValueObservingOptionNew @@ -274,27 +275,29 @@ - (void)windowDidResignKey:(NSNotification *)aNotification } } -// We'll respond to key events by doing nothing so we don't beep. -// We could handle key messages here, but we lose some in the NSApp dispatch, -// where they get converted to action messages, etc. +/* We'll respond to key events by doing nothing so we don't beep. + * We could handle key messages here, but we lose some in the NSApp dispatch, + * where they get converted to action messages, etc. + */ - (void)flagsChanged:(NSEvent *)theEvent { - //Cocoa_HandleKeyEvent(SDL_GetVideoDevice(), theEvent); + /*Cocoa_HandleKeyEvent(SDL_GetVideoDevice(), theEvent);*/ } - (void)keyDown:(NSEvent *)theEvent { - //Cocoa_HandleKeyEvent(SDL_GetVideoDevice(), theEvent); + /*Cocoa_HandleKeyEvent(SDL_GetVideoDevice(), theEvent);*/ } - (void)keyUp:(NSEvent *)theEvent { - //Cocoa_HandleKeyEvent(SDL_GetVideoDevice(), theEvent); + /*Cocoa_HandleKeyEvent(SDL_GetVideoDevice(), theEvent);*/ } -// We'll respond to selectors by doing nothing so we don't beep. -// The escape key gets converted to a "cancel" selector, etc. +/* We'll respond to selectors by doing nothing so we don't beep. + * The escape key gets converted to a "cancel" selector, etc. + */ - (void)doCommandBySelector:(SEL)aSelector { - //NSLog(@"doCommandBySelector: %@\n", NSStringFromSelector(aSelector)); + /*NSLog(@"doCommandBySelector: %@\n", NSStringFromSelector(aSelector));*/ } - (void)mouseDown:(NSEvent *)theEvent @@ -472,7 +475,7 @@ - (void)handleTouches:(cocoaTouchType)type withEvent:(NSEvent *)event if (SDL_AddTouch(touchId, "") < 0) { return; } - } + } const SDL_FingerID fingerId = (SDL_FingerID)(intptr_t)[touch identity]; float x = [touch normalizedPosition].x; @@ -550,18 +553,18 @@ - (void)resetCursorRects { unsigned int style; - if (window->flags & SDL_WINDOW_FULLSCREEN) { + if (window->flags & SDL_WINDOW_FULLSCREEN) { style = NSBorderlessWindowMask; - } else { - if (window->flags & SDL_WINDOW_BORDERLESS) { - style = NSBorderlessWindowMask; - } else { - style = (NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask); - } - if (window->flags & SDL_WINDOW_RESIZABLE) { - style |= NSResizableWindowMask; - } - } + } else { + if (window->flags & SDL_WINDOW_BORDERLESS) { + style = NSBorderlessWindowMask; + } else { + style = (NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask); + } + if (window->flags & SDL_WINDOW_RESIZABLE) { + style |= NSResizableWindowMask; + } + } return style; } @@ -688,7 +691,7 @@ - (void)resetCursorRects } nswindow = [[SDLWindow alloc] initWithContentRect:rect styleMask:style backing:NSBackingStoreBuffered defer:NO screen:screen]; - // Create a default view for this window + /* Create a default view for this window */ rect = [nswindow contentRectForFrameRect:[nswindow frame]]; NSView *contentView = [[SDLView alloc] initWithFrame:rect]; [nswindow setContentView: contentView]; @@ -804,13 +807,13 @@ - (void)resetCursorRects { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; SDL_WindowData *windata = (SDL_WindowData *) window->driverdata; - + NSSize minSize; minSize.width = window->min_w; minSize.height = window->min_h; - + [windata->nswindow setContentMinSize:minSize]; - + [pool release]; } @@ -819,13 +822,13 @@ - (void)resetCursorRects { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; SDL_WindowData *windata = (SDL_WindowData *) window->driverdata; - + NSSize maxSize; maxSize.width = window->max_w; maxSize.height = window->max_h; - + [windata->nswindow setContentMaxSize:maxSize]; - + [pool release]; } @@ -937,7 +940,7 @@ - (void)resetCursorRects if ([nswindow respondsToSelector:@selector(setStyleMask:)]) { [nswindow setStyleMask:GetWindowStyle(window)]; if (bordered) { - Cocoa_SetWindowTitle(_this, window); // this got blanked out. + Cocoa_SetWindowTitle(_this, window); /* this got blanked out. */ } } [pool release]; @@ -1090,17 +1093,17 @@ - (void)resetCursorRects cgpoint.y = window->y + y; CGDisplayMoveCursorToPoint(kCGDirectMainDisplay, cgpoint); } - + if ( window->flags & SDL_WINDOW_FULLSCREEN ) { - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; - - if (SDL_ShouldAllowTopmost() && (window->flags & SDL_WINDOW_INPUT_FOCUS)) { - /* OpenGL is rendering to the window, so make it visible! */ - [data->nswindow setLevel:CGShieldingWindowLevel()]; - } else { - [data->nswindow setLevel:kCGNormalWindowLevel]; - } - } + SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + + if (SDL_ShouldAllowTopmost() && (window->flags & SDL_WINDOW_INPUT_FOCUS)) { + /* OpenGL is rendering to the window, so make it visible! */ + [data->nswindow setLevel:CGShieldingWindowLevel()]; + } else { + [data->nswindow setLevel:kCGNormalWindowLevel]; + } + } } void diff --git a/src/video/directfb/SDL_DirectFB_WM.c b/src/video/directfb/SDL_DirectFB_WM.c index 84e76ca1c..8241d9b3d 100644 --- a/src/video/directfb/SDL_DirectFB_WM.c +++ b/src/video/directfb/SDL_DirectFB_WM.c @@ -81,24 +81,24 @@ LoadFont(_THIS, SDL_Window * window) SDL_DFB_DEVICEDATA(_this); SDL_DFB_WINDOWDATA(window); - if (windata->font != NULL) { - SDL_DFB_RELEASE(windata->font); - windata->font = NULL; - SDL_DFB_CHECK(windata->window_surface->SetFont(windata->window_surface, windata->font)); - } - - if (windata->theme.font != NULL) - { + if (windata->font != NULL) { + SDL_DFB_RELEASE(windata->font); + windata->font = NULL; + SDL_DFB_CHECK(windata->window_surface->SetFont(windata->window_surface, windata->font)); + } + + if (windata->theme.font != NULL) + { DFBFontDescription fdesc; - SDL_zero(fdesc); - fdesc.flags = DFDESC_HEIGHT; - fdesc.height = windata->theme.font_size; - SDL_DFB_CHECK(devdata-> - dfb->CreateFont(devdata->dfb, windata->theme.font, - &fdesc, &windata->font)); - SDL_DFB_CHECK(windata->window_surface->SetFont(windata->window_surface, windata->font)); - } + SDL_zero(fdesc); + fdesc.flags = DFDESC_HEIGHT; + fdesc.height = windata->theme.font_size; + SDL_DFB_CHECK(devdata-> + dfb->CreateFont(devdata->dfb, windata->theme.font, + &fdesc, &windata->font)); + SDL_DFB_CHECK(windata->window_surface->SetFont(windata->window_surface, windata->font)); + } } static void @@ -130,8 +130,8 @@ DirectFB_WM_RedrawLayout(_THIS, SDL_Window * window) SDL_DFB_CHECK(s->SetDrawingFlags(s, DSDRAW_NOFX)); SDL_DFB_CHECK(s->SetBlittingFlags(s, DSBLIT_NOFX)); - LoadFont(_this, window); - //s->SetDrawingFlags(s, DSDRAW_BLEND); + LoadFont(_this, window); + /*s->SetDrawingFlags(s, DSDRAW_BLEND); */ s->SetColor(s, COLOR_EXPAND(t->frame_color)); /* top */ for (i = 0; i < t->top_size; i++) @@ -162,7 +162,7 @@ DirectFB_WM_RedrawLayout(_THIS, SDL_Window * window) /* Caption */ if (window->title) { - s->SetColor(s, COLOR_EXPAND(t->font_color)); + s->SetColor(s, COLOR_EXPAND(t->font_color)); DrawCraption(_this, s, (x - w) / 2, t->top_size + d, window->title); } /* Icon */ @@ -184,7 +184,7 @@ DFBResult DirectFB_WM_GetClientSize(_THIS, SDL_Window * window, int *cw, int *ch) { SDL_DFB_WINDOWDATA(window); - IDirectFBWindow *dfbwin = windata->dfbwin; + IDirectFBWindow *dfbwin = windata->dfbwin; SDL_DFB_CHECK(dfbwin->GetSize(dfbwin, cw, ch)); dfbwin->GetSize(dfbwin, cw, ch); @@ -203,8 +203,8 @@ DirectFB_WM_AdjustWindowLayout(SDL_Window * window, int flags, int w, int h) if (!windata->is_managed) windata->theme = theme_none; else if (flags & SDL_WINDOW_BORDERLESS) - //desc.caps |= DWCAPS_NODECORATION;) - windata->theme = theme_none; + /*desc.caps |= DWCAPS_NODECORATION;) */ + windata->theme = theme_none; else if (flags & SDL_WINDOW_FULLSCREEN) { windata->theme = theme_none; } else if (flags & SDL_WINDOW_MAXIMIZED) { @@ -289,8 +289,8 @@ DirectFB_WM_ProcessEvent(_THIS, SDL_Window * window, DFBWindowEvent * evt) { SDL_DFB_DEVICEDATA(_this); SDL_DFB_WINDOWDATA(window); - DFB_WindowData *gwindata = ((devdata->grabbed_window) ? (DFB_WindowData *) ((devdata->grabbed_window)->driverdata) : NULL); - IDirectFBWindow *dfbwin = windata->dfbwin; + DFB_WindowData *gwindata = ((devdata->grabbed_window) ? (DFB_WindowData *) ((devdata->grabbed_window)->driverdata) : NULL); + IDirectFBWindow *dfbwin = windata->dfbwin; DFBWindowOptions wopts; if (!windata->is_managed) @@ -306,29 +306,29 @@ DirectFB_WM_ProcessEvent(_THIS, SDL_Window * window, DFBWindowEvent * evt) case WM_POS_NONE: return 0; case WM_POS_CLOSE: - windata->wm_grab = WM_POS_NONE; + windata->wm_grab = WM_POS_NONE; SDL_SendWindowEvent(window, SDL_WINDOWEVENT_CLOSE, 0, 0); return 1; case WM_POS_MAX: - windata->wm_grab = WM_POS_NONE; - if (window->flags & SDL_WINDOW_MAXIMIZED) { - SDL_RestoreWindow(window); - } else { - SDL_MaximizeWindow(window); - } + windata->wm_grab = WM_POS_NONE; + if (window->flags & SDL_WINDOW_MAXIMIZED) { + SDL_RestoreWindow(window); + } else { + SDL_MaximizeWindow(window); + } return 1; case WM_POS_CAPTION: - if (!(wopts & DWOP_KEEP_STACKING)) { - DirectFB_RaiseWindow(_this, window); - } - if (window->flags & SDL_WINDOW_MAXIMIZED) - return 1; + if (!(wopts & DWOP_KEEP_STACKING)) { + DirectFB_RaiseWindow(_this, window); + } + if (window->flags & SDL_WINDOW_MAXIMIZED) + return 1; /* fall through */ default: windata->wm_grab = pos; if (gwindata != NULL) - SDL_DFB_CHECK(gwindata->dfbwin->UngrabPointer(gwindata->dfbwin)); + SDL_DFB_CHECK(gwindata->dfbwin->UngrabPointer(gwindata->dfbwin)); SDL_DFB_CHECK(dfbwin->GrabPointer(dfbwin)); windata->wm_lastx = evt->cx; windata->wm_lasty = evt->cy; @@ -343,21 +343,21 @@ DirectFB_WM_ProcessEvent(_THIS, SDL_Window * window, DFBWindowEvent * evt) int dx = evt->cx - windata->wm_lastx; int dy = evt->cy - windata->wm_lasty; - if (!(wopts & DWOP_KEEP_SIZE)) { + if (!(wopts & DWOP_KEEP_SIZE)) { int cw, ch; - if ((windata->wm_grab & (WM_POS_BOTTOM | WM_POS_RIGHT)) == WM_POS_BOTTOM) - dx = 0; - else if ((windata->wm_grab & (WM_POS_BOTTOM | WM_POS_RIGHT)) == WM_POS_RIGHT) - dy = 0; - SDL_DFB_CHECK(dfbwin->GetSize(dfbwin, &cw, &ch)); - - /* necessary to trigger an event - ugly*/ - SDL_DFB_CHECK(dfbwin->DisableEvents(dfbwin, DWET_ALL)); - SDL_DFB_CHECK(dfbwin->Resize(dfbwin, cw + dx + 1, ch + dy)); - SDL_DFB_CHECK(dfbwin->EnableEvents(dfbwin, DWET_ALL)); - - SDL_DFB_CHECK(dfbwin->Resize(dfbwin, cw + dx, ch + dy)); - } + if ((windata->wm_grab & (WM_POS_BOTTOM | WM_POS_RIGHT)) == WM_POS_BOTTOM) + dx = 0; + else if ((windata->wm_grab & (WM_POS_BOTTOM | WM_POS_RIGHT)) == WM_POS_RIGHT) + dy = 0; + SDL_DFB_CHECK(dfbwin->GetSize(dfbwin, &cw, &ch)); + + /* necessary to trigger an event - ugly*/ + SDL_DFB_CHECK(dfbwin->DisableEvents(dfbwin, DWET_ALL)); + SDL_DFB_CHECK(dfbwin->Resize(dfbwin, cw + dx + 1, ch + dy)); + SDL_DFB_CHECK(dfbwin->EnableEvents(dfbwin, DWET_ALL)); + + SDL_DFB_CHECK(dfbwin->Resize(dfbwin, cw + dx, ch + dy)); + } } SDL_DFB_CHECK(dfbwin->UngrabPointer(dfbwin)); if (gwindata != NULL) @@ -370,34 +370,34 @@ DirectFB_WM_ProcessEvent(_THIS, SDL_Window * window, DFBWindowEvent * evt) if (!windata->wm_grab) return 0; if (evt->buttons & DIBM_LEFT) { - int dx = evt->cx - windata->wm_lastx; + int dx = evt->cx - windata->wm_lastx; int dy = evt->cy - windata->wm_lasty; if (windata->wm_grab & WM_POS_CAPTION) { - if (!(wopts & DWOP_KEEP_POSITION)) - SDL_DFB_CHECK(dfbwin->Move(dfbwin, dx, dy)); + if (!(wopts & DWOP_KEEP_POSITION)) + SDL_DFB_CHECK(dfbwin->Move(dfbwin, dx, dy)); } if (windata->wm_grab & (WM_POS_RIGHT | WM_POS_BOTTOM)) { - if (!(wopts & DWOP_KEEP_SIZE)) { - int cw, ch; + if (!(wopts & DWOP_KEEP_SIZE)) { + int cw, ch; - /* Make sure all events are disabled for this operation ! */ - SDL_DFB_CHECK(dfbwin->DisableEvents(dfbwin, DWET_ALL)); + /* Make sure all events are disabled for this operation ! */ + SDL_DFB_CHECK(dfbwin->DisableEvents(dfbwin, DWET_ALL)); - if ((windata->wm_grab & (WM_POS_BOTTOM | WM_POS_RIGHT)) == WM_POS_BOTTOM) - dx = 0; - else if ((windata->wm_grab & (WM_POS_BOTTOM | WM_POS_RIGHT)) == WM_POS_RIGHT) - dy = 0; + if ((windata->wm_grab & (WM_POS_BOTTOM | WM_POS_RIGHT)) == WM_POS_BOTTOM) + dx = 0; + else if ((windata->wm_grab & (WM_POS_BOTTOM | WM_POS_RIGHT)) == WM_POS_RIGHT) + dy = 0; - SDL_DFB_CHECK(dfbwin->GetSize(dfbwin, &cw, &ch)); - SDL_DFB_CHECK(dfbwin->Resize(dfbwin, cw + dx, ch + dy)); + SDL_DFB_CHECK(dfbwin->GetSize(dfbwin, &cw, &ch)); + SDL_DFB_CHECK(dfbwin->Resize(dfbwin, cw + dx, ch + dy)); - SDL_DFB_CHECK(dfbwin->EnableEvents(dfbwin, DWET_ALL)); - } + SDL_DFB_CHECK(dfbwin->EnableEvents(dfbwin, DWET_ALL)); + } } - windata->wm_lastx = evt->cx; - windata->wm_lasty = evt->cy; - return 1; + windata->wm_lastx = evt->cx; + windata->wm_lasty = evt->cy; + return 1; } break; case DWET_KEYDOWN: diff --git a/src/video/directfb/SDL_DirectFB_dyn.c b/src/video/directfb/SDL_DirectFB_dyn.c index 496909252..cbbfa175b 100644 --- a/src/video/directfb/SDL_DirectFB_dyn.c +++ b/src/video/directfb/SDL_DirectFB_dyn.c @@ -32,7 +32,7 @@ #define DFB_SYM(ret, name, args, al, func) ret (*name) args; static struct _SDL_DirectFB_Symbols { - DFB_SYMS + DFB_SYMS const unsigned int *directfb_major_version; const unsigned int *directfb_minor_version; const unsigned int *directfb_micro_version; diff --git a/src/video/directfb/SDL_DirectFB_dyn.h b/src/video/directfb/SDL_DirectFB_dyn.h index de90961a6..52658b01f 100644 --- a/src/video/directfb/SDL_DirectFB_dyn.h +++ b/src/video/directfb/SDL_DirectFB_dyn.h @@ -23,15 +23,15 @@ #define _SDL_DirectFB_dyn_h #define DFB_SYMS \ - DFB_SYM(DFBResult, DirectFBError, (const char *msg, DFBResult result), (msg, result), return) \ - DFB_SYM(DFBResult, DirectFBErrorFatal, (const char *msg, DFBResult result), (msg, result), return) \ - DFB_SYM(const char *, DirectFBErrorString, (DFBResult result), (result), return) \ - DFB_SYM(const char *, DirectFBUsageString, ( void ), (), return) \ - DFB_SYM(DFBResult, DirectFBInit, (int *argc, char *(*argv[]) ), (argc, argv), return) \ - DFB_SYM(DFBResult, DirectFBSetOption, (const char *name, const char *value), (name, value), return) \ - DFB_SYM(DFBResult, DirectFBCreate, (IDirectFB **interface), (interface), return) \ - DFB_SYM(const char *, DirectFBCheckVersion, (unsigned int required_major, unsigned int required_minor, unsigned int required_micro), \ - (required_major, required_minor, required_micro), return) + DFB_SYM(DFBResult, DirectFBError, (const char *msg, DFBResult result), (msg, result), return) \ + DFB_SYM(DFBResult, DirectFBErrorFatal, (const char *msg, DFBResult result), (msg, result), return) \ + DFB_SYM(const char *, DirectFBErrorString, (DFBResult result), (result), return) \ + DFB_SYM(const char *, DirectFBUsageString, ( void ), (), return) \ + DFB_SYM(DFBResult, DirectFBInit, (int *argc, char *(*argv[]) ), (argc, argv), return) \ + DFB_SYM(DFBResult, DirectFBSetOption, (const char *name, const char *value), (name, value), return) \ + DFB_SYM(DFBResult, DirectFBCreate, (IDirectFB **interface), (interface), return) \ + DFB_SYM(const char *, DirectFBCheckVersion, (unsigned int required_major, unsigned int required_minor, unsigned int required_micro), \ + (required_major, required_minor, required_micro), return) int SDL_DirectFB_LoadLibrary(void); void SDL_DirectFB_UnLoadLibrary(void); diff --git a/src/video/directfb/SDL_DirectFB_events.c b/src/video/directfb/SDL_DirectFB_events.c index 8ee0b9085..ffb15c362 100644 --- a/src/video/directfb/SDL_DirectFB_events.c +++ b/src/video/directfb/SDL_DirectFB_events.c @@ -52,11 +52,11 @@ #endif typedef struct _cb_data cb_data; -struct _cb_data +struct _cb_data { - DFB_DeviceData *devdata; - int sys_ids; - int sys_kbd; + DFB_DeviceData *devdata; + int sys_ids; + int sys_kbd; }; /* The translation tables from a DirectFB keycode to a SDL keysym */ @@ -74,7 +74,7 @@ static int DirectFB_TranslateButton(DFBInputDeviceButtonIdentifier button); static void UnicodeToUtf8( Uint16 w , char *utf8buf) { unsigned char *utf8s = (unsigned char *) utf8buf; - + if ( w < 0x0080 ) { utf8s[0] = ( unsigned char ) w; utf8s[1] = 0; @@ -82,14 +82,14 @@ static void UnicodeToUtf8( Uint16 w , char *utf8buf) else if ( w < 0x0800 ) { utf8s[0] = 0xc0 | (( w ) >> 6 ); utf8s[1] = 0x80 | (( w ) & 0x3f ); - utf8s[2] = 0; + utf8s[2] = 0; } else { utf8s[0] = 0xe0 | (( w ) >> 12 ); utf8s[1] = 0x80 | (( ( w ) >> 6 ) & 0x3f ); utf8s[2] = 0x80 | (( w ) & 0x3f ); utf8s[3] = 0; - } + } } static void @@ -132,7 +132,7 @@ MotionAllMice(_THIS, int x, int y) SDL_Mouse *mouse = SDL_GetMouse(index); mouse->x = mouse->last_x = x; mouse->y = mouse->last_y = y; - //SDL_SendMouseMotion(devdata->mouse_id[index], 0, x, y, 0); + /*SDL_SendMouseMotion(devdata->mouse_id[index], 0, x, y, 0);*/ } #endif } @@ -215,7 +215,7 @@ ProcessWindowEvent(_THIS, SDL_Window *sdlwin, DFBWindowEvent * evt) SDL_SendMouseMotion_ex(sdlwin, devdata->mouse_id[0], 0, evt->x, evt->y, 0); } else { - /* relative movements are not exact! + /* relative movements are not exact! * This code should limit the number of events sent. * However it kills MAME axis recognition ... */ static int cnt = 0; @@ -232,10 +232,10 @@ ProcessWindowEvent(_THIS, SDL_Window *sdlwin, DFBWindowEvent * evt) case DWET_KEYDOWN: if (!devdata->use_linux_input) { DirectFB_TranslateKey(_this, evt, &keysym); - //printf("Scancode %d %d %d\n", keysym.scancode, evt->key_code, evt->key_id); + /*printf("Scancode %d %d %d\n", keysym.scancode, evt->key_code, evt->key_id);*/ SDL_SendKeyboardKey_ex(0, SDL_PRESSED, keysym.scancode); if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) { - SDL_zero(text); + SDL_zero(text); UnicodeToUtf8(keysym.unicode, text); if (*text) { SDL_SendKeyboardText_ex(0, text); @@ -262,7 +262,7 @@ ProcessWindowEvent(_THIS, SDL_Window *sdlwin, DFBWindowEvent * evt) } /* fall throught */ case DWET_SIZE: - // FIXME: what about < 0 + /* FIXME: what about < 0 */ evt->w -= (windata->theme.right_size + windata->theme.left_size); evt->h -= (windata->theme.top_size + windata->theme.bottom_size + @@ -286,7 +286,7 @@ ProcessWindowEvent(_THIS, SDL_Window *sdlwin, DFBWindowEvent * evt) case DWET_ENTER: /* SDL_DirectFB_ReshowCursor(_this, 0); */ FocusAllMice(_this, sdlwin); - // FIXME: when do we really enter ? + /* FIXME: when do we really enter ? */ if (ClientXY(windata, &evt->x, &evt->y)) MotionAllMice(_this, evt->x, evt->y); SDL_SendWindowEvent(sdlwin, SDL_WINDOWEVENT_ENTER, 0, 0); @@ -367,7 +367,7 @@ ProcessInputEvent(_THIS, DFBInputEvent * ievt) case DIET_KEYPRESS: kbd_idx = KbdIndex(_this, ievt->device_id); DirectFB_TranslateKeyInputEvent(_this, ievt, &keysym); - //printf("Scancode %d %d %d\n", keysym.scancode, evt->key_code, evt->key_id); + /*printf("Scancode %d %d %d\n", keysym.scancode, evt->key_code, evt->key_id); */ SDL_SendKeyboardKey_ex(kbd_idx, SDL_PRESSED, keysym.scancode); if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) { SDL_zero(text); @@ -435,7 +435,7 @@ DirectFB_PumpEventsWindow(_THIS) while (devdata->events->GetEvent(devdata->events, DFB_EVENT(&ievt)) == DFB_OK) { - if (SDL_GetEventState(SDL_SYSWMEVENT) == SDL_ENABLE) { + if (SDL_GetEventState(SDL_SYSWMEVENT) == SDL_ENABLE) { SDL_SysWMmsg wmmsg; SDL_VERSION(&wmmsg.version); wmmsg.subsystem = SDL_SYSWM_DIRECTFB; @@ -584,8 +584,8 @@ DirectFB_TranslateKey(_THIS, DFBWindowEvent * evt, SDL_Keysym * keysym) keysym->scancode = SDL_SCANCODE_UNKNOWN; if (kbd->map && evt->key_code >= kbd->map_adjust && - evt->key_code < kbd->map_size + kbd->map_adjust) - keysym->scancode = kbd->map[evt->key_code - kbd->map_adjust]; + evt->key_code < kbd->map_size + kbd->map_adjust) + keysym->scancode = kbd->map[evt->key_code - kbd->map_adjust]; if (keysym->scancode == SDL_SCANCODE_UNKNOWN || devdata->keyboard[kbd_idx].is_generic) { @@ -615,8 +615,8 @@ DirectFB_TranslateKeyInputEvent(_THIS, DFBInputEvent * evt, keysym->scancode = SDL_SCANCODE_UNKNOWN; if (kbd->map && evt->key_code >= kbd->map_adjust && - evt->key_code < kbd->map_size + kbd->map_adjust) - keysym->scancode = kbd->map[evt->key_code - kbd->map_adjust]; + evt->key_code < kbd->map_size + kbd->map_adjust) + keysym->scancode = kbd->map[evt->key_code - kbd->map_adjust]; if (keysym->scancode == SDL_SCANCODE_UNKNOWN || devdata->keyboard[kbd_idx].is_generic) { if (evt->key_id - DIKI_UNKNOWN < SDL_arraysize(oskeymap)) @@ -653,26 +653,26 @@ static DFBEnumerationResult EnumKeyboards(DFBInputDeviceID device_id, DFBInputDeviceDescription desc, void *callbackdata) { - cb_data *cb = callbackdata; + cb_data *cb = callbackdata; DFB_DeviceData *devdata = cb->devdata; #if USE_MULTI_API SDL_Keyboard keyboard; #endif SDL_Keycode keymap[SDL_NUM_SCANCODES]; - if (!cb->sys_kbd) { - if (cb->sys_ids) { - if (device_id >= 0x10) - return DFENUM_OK; - } else { - if (device_id < 0x10) - return DFENUM_OK; - } - } else { - if (device_id != DIDID_KEYBOARD) - return DFENUM_OK; - } - + if (!cb->sys_kbd) { + if (cb->sys_ids) { + if (device_id >= 0x10) + return DFENUM_OK; + } else { + if (device_id < 0x10) + return DFENUM_OK; + } + } else { + if (device_id != DIDID_KEYBOARD) + return DFENUM_OK; + } + if ((desc.caps & DIDTF_KEYBOARD)) { #if USE_MULTI_API SDL_zero(keyboard); @@ -682,17 +682,17 @@ EnumKeyboards(DFBInputDeviceID device_id, devdata->keyboard[devdata->num_keyboard].is_generic = 0; if (!strncmp("X11", desc.name, 3)) { - devdata->keyboard[devdata->num_keyboard].map = xfree86_scancode_table2; - devdata->keyboard[devdata->num_keyboard].map_size = SDL_arraysize(xfree86_scancode_table2); - devdata->keyboard[devdata->num_keyboard].map_adjust = 8; + devdata->keyboard[devdata->num_keyboard].map = xfree86_scancode_table2; + devdata->keyboard[devdata->num_keyboard].map_size = SDL_arraysize(xfree86_scancode_table2); + devdata->keyboard[devdata->num_keyboard].map_adjust = 8; } else { - devdata->keyboard[devdata->num_keyboard].map = linux_scancode_table; - devdata->keyboard[devdata->num_keyboard].map_size = SDL_arraysize(linux_scancode_table); - devdata->keyboard[devdata->num_keyboard].map_adjust = 0; + devdata->keyboard[devdata->num_keyboard].map = linux_scancode_table; + devdata->keyboard[devdata->num_keyboard].map_size = SDL_arraysize(linux_scancode_table); + devdata->keyboard[devdata->num_keyboard].map_adjust = 0; } - SDL_DFB_LOG("Keyboard %d - %s\n", device_id, desc.name); - + SDL_DFB_LOG("Keyboard %d - %s\n", device_id, desc.name); + SDL_GetDefaultKeymap(keymap); #if USE_MULTI_API SDL_SetKeymap(devdata->num_keyboard, 0, keymap, SDL_NUM_SCANCODES); @@ -701,8 +701,8 @@ EnumKeyboards(DFBInputDeviceID device_id, #endif devdata->num_keyboard++; - if (cb->sys_kbd) - return DFENUM_CANCEL; + if (cb->sys_kbd) + return DFENUM_CANCEL; } return DFENUM_OK; } @@ -711,15 +711,15 @@ void DirectFB_InitKeyboard(_THIS) { SDL_DFB_DEVICEDATA(_this); - cb_data cb; - + cb_data cb; + DirectFB_InitOSKeymap(_this, &oskeymap[0], SDL_arraysize(oskeymap)); devdata->num_keyboard = 0; cb.devdata = devdata; - + if (devdata->use_linux_input) { - cb.sys_kbd = 0; + cb.sys_kbd = 0; cb.sys_ids = 0; SDL_DFB_CHECK(devdata->dfb-> EnumInputDevices(devdata->dfb, EnumKeyboards, &cb)); @@ -730,7 +730,7 @@ DirectFB_InitKeyboard(_THIS) &cb)); } } else { - cb.sys_kbd = 1; + cb.sys_kbd = 1; SDL_DFB_CHECK(devdata->dfb->EnumInputDevices(devdata->dfb, EnumKeyboards, &cb)); @@ -740,7 +740,7 @@ DirectFB_InitKeyboard(_THIS) void DirectFB_QuitKeyboard(_THIS) { - //SDL_DFB_DEVICEDATA(_this); + /*SDL_DFB_DEVICEDATA(_this); */ SDL_KeyboardQuit(); diff --git a/src/video/directfb/SDL_DirectFB_modes.c b/src/video/directfb/SDL_DirectFB_modes.c index d3a7a54fa..c6d1bb49c 100644 --- a/src/video/directfb/SDL_DirectFB_modes.c +++ b/src/video/directfb/SDL_DirectFB_modes.c @@ -137,7 +137,7 @@ DirectFB_SetContext(_THIS, SDL_Window *window) SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); DFB_DisplayData *dispdata = (DFB_DisplayData *) display->driverdata; - /* FIXME: should we handle the error */ + /* FIXME: should we handle the error */ if (dispdata->vidIDinuse) SDL_DFB_CHECK(dispdata->vidlayer->SwitchContext(dispdata->vidlayer, DFB_TRUE)); @@ -220,7 +220,7 @@ DirectFB_InitModes(_THIS) SDL_DFB_CHECKERR(layer->GetConfiguration(layer, &dlc)); mode.format = DirectFB_DFBToSDLPixelFormat(dlc.pixelformat); - + if (mode.format == SDL_PIXELFORMAT_UNKNOWN) { SDL_DFB_ERR("Unknown dfb pixelformat %x !\n", dlc.pixelformat); goto error; @@ -309,7 +309,7 @@ DirectFB_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mod { /* * FIXME: video mode switch is currently broken for 1.2.0 - * + * */ SDL_DFB_DEVICEDATA(_this); diff --git a/src/video/directfb/SDL_DirectFB_modes.h b/src/video/directfb/SDL_DirectFB_modes.h index d9defec32..6e439cdc9 100644 --- a/src/video/directfb/SDL_DirectFB_modes.h +++ b/src/video/directfb/SDL_DirectFB_modes.h @@ -31,19 +31,19 @@ typedef struct _DFB_DisplayData DFB_DisplayData; struct _DFB_DisplayData { - IDirectFBDisplayLayer *layer; - DFBSurfacePixelFormat pixelformat; - /* FIXME: support for multiple video layer. - * However, I do not know any card supporting + IDirectFBDisplayLayer *layer; + DFBSurfacePixelFormat pixelformat; + /* FIXME: support for multiple video layer. + * However, I do not know any card supporting * more than one */ - DFBDisplayLayerID vidID; - IDirectFBDisplayLayer *vidlayer; + DFBDisplayLayerID vidID; + IDirectFBDisplayLayer *vidlayer; - int vidIDinuse; + int vidIDinuse; - int cw; - int ch; + int cw; + int ch; }; diff --git a/src/video/directfb/SDL_DirectFB_mouse.c b/src/video/directfb/SDL_DirectFB_mouse.c index 2377c877a..fb5ed4e7b 100644 --- a/src/video/directfb/SDL_DirectFB_mouse.c +++ b/src/video/directfb/SDL_DirectFB_mouse.c @@ -115,12 +115,12 @@ DirectFB_CreateDefaultCursor(void) { for (j = 0; j < 32; j++) { - switch (arrow[i][j]) - { - case ' ': dest[j] = 0x00000000; break; - case '.': dest[j] = 0xffffffff; break; - case 'X': dest[j] = 0xff000000; break; - } + switch (arrow[i][j]) + { + case ' ': dest[j] = 0x00000000; break; + case '.': dest[j] = 0xffffffff; break; + case 'X': dest[j] = 0xff000000; break; + } } dest += (pitch >> 2); } diff --git a/src/video/directfb/SDL_DirectFB_mouse.h b/src/video/directfb/SDL_DirectFB_mouse.h index b65f9fddb..906f1fb5e 100644 --- a/src/video/directfb/SDL_DirectFB_mouse.h +++ b/src/video/directfb/SDL_DirectFB_mouse.h @@ -30,8 +30,8 @@ typedef struct _DFB_CursorData DFB_CursorData; struct _DFB_CursorData { IDirectFBSurface *surf; - int hotx; - int hoty; + int hotx; + int hoty; }; #define SDL_DFB_CURSORDATA(curs) DFB_CursorData *curdata = (DFB_CursorData *) ((curs) ? (curs)->driverdata : NULL) diff --git a/src/video/directfb/SDL_DirectFB_opengl.c b/src/video/directfb/SDL_DirectFB_opengl.c index c325f4231..fac05e6f2 100644 --- a/src/video/directfb/SDL_DirectFB_opengl.c +++ b/src/video/directfb/SDL_DirectFB_opengl.c @@ -40,7 +40,7 @@ struct SDL_GLDriverData int gl_active; /* to stop switching drivers while we have a valid context */ int initialized; DirectFB_GLContext *firstgl; /* linked list */ - + /* OpenGL */ void (*glFinish) (void); void (*glFlush) (void); @@ -49,13 +49,13 @@ struct SDL_GLDriverData #define OPENGL_REQUIRS_DLOPEN #if defined(OPENGL_REQUIRS_DLOPEN) && defined(SDL_LOADSO_DLOPEN) #include -#define GL_LoadObject(X) dlopen(X, (RTLD_NOW|RTLD_GLOBAL)) -#define GL_LoadFunction dlsym -#define GL_UnloadObject dlclose +#define GL_LoadObject(X) dlopen(X, (RTLD_NOW|RTLD_GLOBAL)) +#define GL_LoadFunction dlsym +#define GL_UnloadObject dlclose #else -#define GL_LoadObject SDL_LoadObject -#define GL_LoadFunction SDL_LoadFunction -#define GL_UnloadObject SDL_UnloadObject +#define GL_LoadObject SDL_LoadObject +#define GL_LoadFunction SDL_LoadFunction +#define GL_UnloadObject SDL_UnloadObject #endif static void DirectFB_GL_UnloadLibrary(_THIS); @@ -107,8 +107,6 @@ DirectFB_GL_Shutdown(_THIS) int DirectFB_GL_LoadLibrary(_THIS, const char *path) { - //SDL_DFB_DEVICEDATA(_this); - void *handle = NULL; SDL_DFB_DEBUG("Loadlibrary : %s\n", path); @@ -181,7 +179,6 @@ DirectFB_GL_GetProcAddress(_THIS, const char *proc) SDL_GLContext DirectFB_GL_CreateContext(_THIS, SDL_Window * window) { - //SDL_DFB_DEVICEDATA(_this); SDL_DFB_WINDOWDATA(window); DirectFB_GLContext *context; @@ -195,7 +192,7 @@ DirectFB_GL_CreateContext(_THIS, SDL_Window * window) context->is_locked = 0; context->sdl_window = window; - + context->next = _this->gl_data->firstgl; _this->gl_data->firstgl = context; @@ -215,7 +212,6 @@ DirectFB_GL_CreateContext(_THIS, SDL_Window * window) int DirectFB_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) { - //SDL_DFB_WINDOWDATA(window); DirectFB_GLContext *ctx = (DirectFB_GLContext *) context; DirectFB_GLContext *p; @@ -225,7 +221,7 @@ DirectFB_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) SDL_DFB_CHECKERR(p->context->Unlock(p->context)); p->is_locked = 0; } - + } if (ctx != NULL) { @@ -253,7 +249,6 @@ DirectFB_GL_GetSwapInterval(_THIS) void DirectFB_GL_SwapWindow(_THIS, SDL_Window * window) { - //SDL_DFB_DEVICEDATA(_this); SDL_DFB_WINDOWDATA(window); DFBRegion region; DirectFB_GLContext *p; @@ -270,20 +265,14 @@ DirectFB_GL_SwapWindow(_THIS, SDL_Window * window) devdata->glFlush(); #endif - for (p = _this->gl_data->firstgl; p != NULL; p = p->next) + for (p = _this->gl_data->firstgl; p != NULL; p = p->next) if (p->sdl_window == window && p->is_locked) { SDL_DFB_CHECKERR(p->context->Unlock(p->context)); p->is_locked = 0; - } + } SDL_DFB_CHECKERR(windata->window_surface->Flip(windata->window_surface,NULL, DSFLIP_PIPELINE |DSFLIP_BLIT | DSFLIP_ONSYNC )); - - //if (windata->gl_context) { - //SDL_DFB_CHECKERR(windata->surface->Flip(windata->surface,NULL, DSFLIP_ONSYNC)); - //SDL_DFB_CHECKERR(windata->gl_context->context->Lock(windata->gl_context->context)); - //} - return; error: return; @@ -313,14 +302,14 @@ void DirectFB_GL_FreeWindowContexts(_THIS, SDL_Window * window) { DirectFB_GLContext *p; - - for (p = _this->gl_data->firstgl; p != NULL; p = p->next) - if (p->sdl_window == window) - { - if (p->is_locked) - SDL_DFB_CHECK(p->context->Unlock(p->context)); - SDL_DFB_RELEASE(p->context); - } + + for (p = _this->gl_data->firstgl; p != NULL; p = p->next) + if (p->sdl_window == window) + { + if (p->is_locked) + SDL_DFB_CHECK(p->context->Unlock(p->context)); + SDL_DFB_RELEASE(p->context); + } } void @@ -328,15 +317,15 @@ DirectFB_GL_ReAllocWindowContexts(_THIS, SDL_Window * window) { DirectFB_GLContext *p; - for (p = _this->gl_data->firstgl; p != NULL; p = p->next) - if (p->sdl_window == window) - { + for (p = _this->gl_data->firstgl; p != NULL; p = p->next) + if (p->sdl_window == window) + { SDL_DFB_WINDOWDATA(window); - SDL_DFB_CHECK(windata->surface->GetGL(windata->surface, - &p->context)); - if (p->is_locked) - SDL_DFB_CHECK(p->context->Lock(p->context)); - } + SDL_DFB_CHECK(windata->surface->GetGL(windata->surface, + &p->context)); + if (p->is_locked) + SDL_DFB_CHECK(p->context->Lock(p->context)); + } } void @@ -344,9 +333,9 @@ DirectFB_GL_DestroyWindowContexts(_THIS, SDL_Window * window) { DirectFB_GLContext *p; - for (p = _this->gl_data->firstgl; p != NULL; p = p->next) - if (p->sdl_window == window) - DirectFB_GL_DeleteContext(_this, p); + for (p = _this->gl_data->firstgl; p != NULL; p = p->next) + if (p->sdl_window == window) + DirectFB_GL_DeleteContext(_this, p); } #endif diff --git a/src/video/directfb/SDL_DirectFB_opengl.h b/src/video/directfb/SDL_DirectFB_opengl.h index 53d1572aa..efb11f766 100644 --- a/src/video/directfb/SDL_DirectFB_opengl.h +++ b/src/video/directfb/SDL_DirectFB_opengl.h @@ -32,11 +32,11 @@ typedef struct _DirectFB_GLContext DirectFB_GLContext; struct _DirectFB_GLContext { - IDirectFBGL *context; - DirectFB_GLContext *next; - - SDL_Window *sdl_window; - int is_locked; + IDirectFBGL *context; + DirectFB_GLContext *next; + + SDL_Window *sdl_window; + int is_locked; }; /* OpenGL functions */ diff --git a/src/video/directfb/SDL_DirectFB_render.c b/src/video/directfb/SDL_DirectFB_render.c index 07aa77d11..958793db7 100644 --- a/src/video/directfb/SDL_DirectFB_render.c +++ b/src/video/directfb/SDL_DirectFB_render.c @@ -21,7 +21,6 @@ #include "SDL_config.h" #if SDL_VIDEO_DRIVER_DIRECTFB -//#include "SDL_DirectFB_video.h" #include "SDL_DirectFB_window.h" #include "SDL_DirectFB_modes.h" @@ -30,8 +29,6 @@ #include "../SDL_sysvideo.h" #include "../../render/SDL_sysrender.h" -//#include "../SDL_rect_c.h" -//#include "../SDL_yuv_sw_c.h" #ifndef DFB_VERSION_ATLEAST @@ -242,7 +239,7 @@ SetBlendMode(DirectFB_RenderData * data, int blendMode, { IDirectFBSurface *destsurf = data->target; - //FIXME: check for format change + /* FIXME: check for format change */ if (1 || data->lastBlendMode != blendMode) { switch (blendMode) { case SDL_BLENDMODE_NONE: @@ -269,9 +266,9 @@ SetBlendMode(DirectFB_RenderData * data, int blendMode, case SDL_BLENDMODE_ADD: data->blitFlags = DSBLIT_BLEND_ALPHACHANNEL; data->drawFlags = DSDRAW_BLEND; - // FIXME: SRCALPHA kills performance on radeon ... - // It will be cheaper to copy the surface to - // a temporay surface and premultiply + /* FIXME: SRCALPHA kills performance on radeon ... */ + * It will be cheaper to copy the surface to a temporary surface and premultiply + */ if (source && TextureHasAlpha(source)) SDL_DFB_CHECK(destsurf->SetSrcBlendFunction(destsurf, DSBF_SRCALPHA)); else @@ -281,9 +278,6 @@ SetBlendMode(DirectFB_RenderData * data, int blendMode, case SDL_BLENDMODE_MOD: data->blitFlags = DSBLIT_BLEND_ALPHACHANNEL; data->drawFlags = DSDRAW_BLEND; - //SDL_DFB_CHECK(destsurf->SetSrcBlendFunction(destsurf, DSBF_DESTCOLOR)); - //SDL_DFB_CHECK(destsurf->SetDstBlendFunction(destsurf, DSBF_ZERO)); - //data->glBlendFunc(GL_ZERO, GL_SRC_COLOR); SDL_DFB_CHECK(destsurf->SetSrcBlendFunction(destsurf, DSBF_ZERO)); SDL_DFB_CHECK(destsurf->SetDstBlendFunction(destsurf, DSBF_SRCCOLOR)); @@ -332,8 +326,8 @@ DirectFB_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event) if (event->event == SDL_WINDOWEVENT_SIZE_CHANGED) { /* Rebind the context to the window area and update matrices */ - //SDL_CurrentContext = NULL; - //data->updateSize = SDL_TRUE; + /*SDL_CurrentContext = NULL; */ + /*data->updateSize = SDL_TRUE; */ renddata->size_changed = SDL_TRUE; } } @@ -362,7 +356,6 @@ DirectFB_CreateRenderer(SDL_Window * window, Uint32 flags) SDL_Renderer *renderer = NULL; DirectFB_RenderData *data = NULL; DFBSurfaceCapabilities scaps; - //char *p; SDL_DFB_ALLOC_CLEAR(renderer, sizeof(*renderer)); SDL_DFB_ALLOC_CLEAR(data, sizeof(*data)); @@ -386,7 +379,7 @@ DirectFB_CreateRenderer(SDL_Window * window, Uint32 flags) /* FIXME: Yet to be tested */ renderer->RenderReadPixels = DirectFB_RenderReadPixels; - //renderer->RenderWritePixels = DirectFB_RenderWritePixels; + /*renderer->RenderWritePixels = DirectFB_RenderWritePixels; */ renderer->DestroyTexture = DirectFB_DestroyTexture; renderer->DestroyRenderer = DirectFB_DestroyRenderer; @@ -458,7 +451,6 @@ DirectFB_ActivateRenderer(SDL_Renderer * renderer) SDL_DFB_WINDOWDATA(window); if (renddata->size_changed /*|| windata->wm_needs_redraw*/) { - //DirectFB_AdjustWindowSurface(window); renddata->size_changed = SDL_FALSE; } } @@ -467,7 +459,6 @@ DirectFB_ActivateRenderer(SDL_Renderer * renderer) static int DirectFB_AcquireVidLayer(SDL_Renderer * renderer, SDL_Texture * texture) { - //SDL_DFB_RENDERERDATA(renderer); SDL_Window *window = renderer->window; SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); SDL_DFB_DEVICEDATA(display->device); @@ -586,7 +577,7 @@ DirectFB_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) * Creating a new palette does not help. */ DFBPaletteDescription pal_desc; - pal_desc.flags = DPDESC_SIZE; // | DPDESC_ENTRIES + pal_desc.flags = DPDESC_SIZE; /* | DPDESC_ENTRIES */ pal_desc.size = 256; SDL_DFB_CHECKERR(devdata->dfb->CreatePalette(devdata->dfb, &pal_desc,&data->palette)); SDL_DFB_CHECKERR(data->surface->SetPalette(data->surface, data->palette)); @@ -710,7 +701,7 @@ DirectFB_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture) { switch (texture->blendMode) { case SDL_BLENDMODE_NONE: - //case SDL_BLENDMODE_MASK: + /*case SDL_BLENDMODE_MASK: */ case SDL_BLENDMODE_BLEND: case SDL_BLENDMODE_ADD: case SDL_BLENDMODE_MOD: @@ -726,7 +717,7 @@ DirectFB_SetDrawBlendMode(SDL_Renderer * renderer) { switch (renderer->blendMode) { case SDL_BLENDMODE_NONE: - //case SDL_BLENDMODE_MASK: + /*case SDL_BLENDMODE_MASK: */ case SDL_BLENDMODE_BLEND: case SDL_BLENDMODE_ADD: case SDL_BLENDMODE_MOD: @@ -778,7 +769,7 @@ DirectFB_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, int row; size_t length; int bpp = DFB_BYTES_PER_PIXEL(DirectFB_SDLToDFBPixelFormat(texture->format)); - // FIXME: SDL_BYTESPERPIXEL(texture->format) broken for yuv yv12 3 planes + /* FIXME: SDL_BYTESPERPIXEL(texture->format) broken for yuv yv12 3 planes */ DirectFB_ActivateRenderer(renderer); @@ -925,7 +916,7 @@ PrepareDraw(SDL_Renderer * renderer) switch (renderer->blendMode) { case SDL_BLENDMODE_NONE: - //case SDL_BLENDMODE_MASK: + /*case SDL_BLENDMODE_MASK: */ case SDL_BLENDMODE_BLEND: break; case SDL_BLENDMODE_ADD: @@ -1035,7 +1026,7 @@ DirectFB_RenderFillRects(SDL_Renderer * renderer, const SDL_FRect * rects, int c destsurf->GetClip(destsurf, &clip_region); for (i=0; iFillRectangle(destsurf, dst.x, dst.y, @@ -1137,7 +1128,7 @@ DirectFB_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, SDL_DFB_CHECKERR(destsurf-> SetColor(destsurf, r, g, b, alpha)); - // ???? flags |= DSBLIT_SRC_PREMULTCOLOR; + /* ???? flags |= DSBLIT_SRC_PREMULTCOLOR; */ SetBlendMode(data, texture->blendMode, texturedata); @@ -1208,7 +1199,6 @@ DirectFB_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) if (!data) { return; } - //SDL_FreeDirtyRects(&data->dirty); SDL_DFB_RELEASE(data->palette); SDL_DFB_RELEASE(data->surface); if (data->display) { diff --git a/src/video/directfb/SDL_DirectFB_shape.c b/src/video/directfb/SDL_DirectFB_shape.c index 01ac74449..13c3d703e 100644 --- a/src/video/directfb/SDL_DirectFB_shape.c +++ b/src/video/directfb/SDL_DirectFB_shape.c @@ -57,20 +57,20 @@ int DirectFB_ResizeWindowShape(SDL_Window* window) { SDL_ShapeData* data = window->shaper->driverdata; SDL_assert(data != NULL); - - if (window->x != -1000) + + if (window->x != -1000) { - window->shaper->userx = window->x; - window->shaper->usery = window->y; + window->shaper->userx = window->x; + window->shaper->usery = window->y; } SDL_SetWindowPosition(window,-1000,-1000); - + return 0; } - + int DirectFB_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode) { - + if(shaper == NULL || shape == NULL || shaper->driverdata == NULL) return -1; if(shape->format->Amask == 0 && SDL_SHAPEMODEALPHA(shape_mode->mode)) @@ -81,10 +81,10 @@ DirectFB_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowSh { SDL_VideoDisplay *display = SDL_GetDisplayForWindow(shaper->window); SDL_DFB_DEVICEDATA(display->device); - Uint32 *pixels; - Sint32 pitch; - Uint32 h,w; - Uint8 *src, *bitmap; + Uint32 *pixels; + Sint32 pitch; + Uint32 h,w; + Uint8 *src, *bitmap; DFBSurfaceDescription dsc; SDL_ShapeData *data = shaper->driverdata; @@ -103,32 +103,32 @@ DirectFB_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowSh SDL_DFB_ALLOC_CLEAR(bitmap, shape->w * shape->h); SDL_CalculateShapeBitmap(shaper->mode,shape,bitmap,1); - src = bitmap; + src = bitmap; SDL_DFB_CHECK(data->surface->Lock(data->surface, DSLF_WRITE | DSLF_READ, (void **) &pixels, &pitch)); - h = shaper->window->h; - while (h--) { - for (w = 0; w < shaper->window->w; w++) { - if (*src) - pixels[w] = 0xFFFFFFFF; - else - pixels[w] = 0; - src++; - - } - pixels += (pitch >> 2); - } + h = shaper->window->h; + while (h--) { + for (w = 0; w < shaper->window->w; w++) { + if (*src) + pixels[w] = 0xFFFFFFFF; + else + pixels[w] = 0; + src++; + + } + pixels += (pitch >> 2); + } SDL_DFB_CHECK(data->surface->Unlock(data->surface)); - SDL_DFB_FREE(bitmap); + SDL_DFB_FREE(bitmap); - /* FIXME: Need to call this here - Big ?? */ - DirectFB_WM_RedrawLayout(SDL_GetDisplayForWindow(shaper->window)->device, shaper->window); + /* FIXME: Need to call this here - Big ?? */ + DirectFB_WM_RedrawLayout(SDL_GetDisplayForWindow(shaper->window)->device, shaper->window); } - + return 0; error: - return -1; + return -1; } #endif /* SDL_VIDEO_DRIVER_DIRECTFB */ diff --git a/src/video/directfb/SDL_DirectFB_shape.h b/src/video/directfb/SDL_DirectFB_shape.h index b405bdea2..a99778533 100644 --- a/src/video/directfb/SDL_DirectFB_shape.h +++ b/src/video/directfb/SDL_DirectFB_shape.h @@ -28,12 +28,12 @@ #include "SDL_shape.h" typedef struct { - IDirectFBSurface *surface; + IDirectFBSurface *surface; } SDL_ShapeData; extern SDL_Window* DirectFB_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags); extern SDL_WindowShaper* DirectFB_CreateShaper(SDL_Window* window); extern int DirectFB_ResizeWindowShape(SDL_Window* window); -extern int DirectFB_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shapeMode); +extern int DirectFB_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shapeMode); #endif /* _SDL_DirectFB_shape_h */ diff --git a/src/video/directfb/SDL_DirectFB_video.c b/src/video/directfb/SDL_DirectFB_video.c index 3f9bba2ba..d20b5f122 100644 --- a/src/video/directfb/SDL_DirectFB_video.c +++ b/src/video/directfb/SDL_DirectFB_video.c @@ -148,13 +148,13 @@ DirectFB_CreateDevice(int devindex) #endif - /* Shaped window support */ - device->shape_driver.CreateShaper = DirectFB_CreateShaper; - device->shape_driver.SetWindowShape = DirectFB_SetWindowShape; - device->shape_driver.ResizeWindowShape = DirectFB_ResizeWindowShape; - + /* Shaped window support */ + device->shape_driver.CreateShaper = DirectFB_CreateShaper; + device->shape_driver.SetWindowShape = DirectFB_SetWindowShape; + device->shape_driver.ResizeWindowShape = DirectFB_ResizeWindowShape; + device->free = DirectFB_DeleteDevice; - + return device; error: if (device) @@ -235,19 +235,19 @@ DirectFB_VideoInit(_THIS) DirectFBSetOption("disable-module", "x11input"); } - /* FIXME: Reenable as default once multi kbd/mouse interface is sorted out */ - devdata->use_linux_input = readBoolEnv(DFBENV_USE_LINUX_INPUT, 0); /* default: on */ + /* FIXME: Reenable as default once multi kbd/mouse interface is sorted out */ + devdata->use_linux_input = readBoolEnv(DFBENV_USE_LINUX_INPUT, 0); /* default: on */ if (!devdata->use_linux_input) { - SDL_DFB_LOG("Disabling linxu input\n"); + SDL_DFB_LOG("Disabling linxu input\n"); DirectFBSetOption("disable-module", "linux_input"); } - + SDL_DFB_CHECKERR(DirectFBCreate(&dfb)); DirectFB_DeviceInformation(dfb); - + devdata->use_yuv_underlays = readBoolEnv(DFBENV_USE_YUV_UNDERLAY, 0); /* default: off */ devdata->use_yuv_direct = readBoolEnv(DFBENV_USE_YUV_DIRECT, 0); /* default is off! */ @@ -317,7 +317,7 @@ DirectFB_VideoQuit(_THIS) static const struct { DFBSurfacePixelFormat dfb; Uint32 sdl; -} pixelformat_tab[] = +} pixelformat_tab[] = { { DSPF_RGB32, SDL_PIXELFORMAT_RGB888 }, /* 24 bit RGB (4 byte, nothing@24, red 8@16, green 8@8, blue 8@0) */ { DSPF_ARGB, SDL_PIXELFORMAT_ARGB8888 }, /* 32 bit ARGB (4 byte, alpha 8@24, red 8@16, green 8@8, blue 8@0) */ @@ -342,38 +342,38 @@ static const struct { { DSPF_UNKNOWN, SDL_PIXELFORMAT_BGR555 }, #endif - /* Pfff ... nonmatching formats follow */ - + /* Pfff ... nonmatching formats follow */ + { DSPF_ALUT44, SDL_PIXELFORMAT_UNKNOWN }, /* 8 bit ALUT (1 byte, alpha 4@4, color lookup 4@0) */ - { DSPF_A8, SDL_PIXELFORMAT_UNKNOWN }, /* 8 bit alpha (1 byte, alpha 8@0), e.g. anti-aliased glyphs */ - { DSPF_AiRGB, SDL_PIXELFORMAT_UNKNOWN }, /* 32 bit ARGB (4 byte, inv. alpha 8@24, red 8@16, green 8@8, blue 8@0) */ - { DSPF_A1, SDL_PIXELFORMAT_UNKNOWN }, /* 1 bit alpha (1 byte/ 8 pixel, most significant bit used first) */ - { DSPF_NV12, SDL_PIXELFORMAT_UNKNOWN }, /* 12 bit YUV (8 bit Y plane followed by one 16 bit quarter size CbCr [15:0] plane) */ - { DSPF_NV16, SDL_PIXELFORMAT_UNKNOWN }, /* 16 bit YUV (8 bit Y plane followed by one 16 bit half width CbCr [15:0] plane) */ - { DSPF_ARGB2554, SDL_PIXELFORMAT_UNKNOWN }, /* 16 bit ARGB (2 byte, alpha 2@14, red 5@9, green 5@4, blue 4@0) */ - { DSPF_NV21, SDL_PIXELFORMAT_UNKNOWN }, /* 12 bit YUV (8 bit Y plane followed by one 16 bit quarter size CrCb [15:0] plane) */ - { DSPF_AYUV, SDL_PIXELFORMAT_UNKNOWN }, /* 32 bit AYUV (4 byte, alpha 8@24, Y 8@16, Cb 8@8, Cr 8@0) */ - { DSPF_A4, SDL_PIXELFORMAT_UNKNOWN }, /* 4 bit alpha (1 byte/ 2 pixel, more significant nibble used first) */ - { DSPF_ARGB1666, SDL_PIXELFORMAT_UNKNOWN }, /* 1 bit alpha (3 byte/ alpha 1@18, red 6@16, green 6@6, blue 6@0) */ - { DSPF_ARGB6666, SDL_PIXELFORMAT_UNKNOWN }, /* 6 bit alpha (3 byte/ alpha 6@18, red 6@16, green 6@6, blue 6@0) */ - { DSPF_RGB18, SDL_PIXELFORMAT_UNKNOWN }, /* 6 bit RGB (3 byte/ red 6@16, green 6@6, blue 6@0) */ - { DSPF_LUT2, SDL_PIXELFORMAT_UNKNOWN }, /* 2 bit LUT (1 byte/ 4 pixel, 2 bit color and alpha lookup from palette) */ + { DSPF_A8, SDL_PIXELFORMAT_UNKNOWN }, /* 8 bit alpha (1 byte, alpha 8@0), e.g. anti-aliased glyphs */ + { DSPF_AiRGB, SDL_PIXELFORMAT_UNKNOWN }, /* 32 bit ARGB (4 byte, inv. alpha 8@24, red 8@16, green 8@8, blue 8@0) */ + { DSPF_A1, SDL_PIXELFORMAT_UNKNOWN }, /* 1 bit alpha (1 byte/ 8 pixel, most significant bit used first) */ + { DSPF_NV12, SDL_PIXELFORMAT_UNKNOWN }, /* 12 bit YUV (8 bit Y plane followed by one 16 bit quarter size CbCr [15:0] plane) */ + { DSPF_NV16, SDL_PIXELFORMAT_UNKNOWN }, /* 16 bit YUV (8 bit Y plane followed by one 16 bit half width CbCr [15:0] plane) */ + { DSPF_ARGB2554, SDL_PIXELFORMAT_UNKNOWN }, /* 16 bit ARGB (2 byte, alpha 2@14, red 5@9, green 5@4, blue 4@0) */ + { DSPF_NV21, SDL_PIXELFORMAT_UNKNOWN }, /* 12 bit YUV (8 bit Y plane followed by one 16 bit quarter size CrCb [15:0] plane) */ + { DSPF_AYUV, SDL_PIXELFORMAT_UNKNOWN }, /* 32 bit AYUV (4 byte, alpha 8@24, Y 8@16, Cb 8@8, Cr 8@0) */ + { DSPF_A4, SDL_PIXELFORMAT_UNKNOWN }, /* 4 bit alpha (1 byte/ 2 pixel, more significant nibble used first) */ + { DSPF_ARGB1666, SDL_PIXELFORMAT_UNKNOWN }, /* 1 bit alpha (3 byte/ alpha 1@18, red 6@16, green 6@6, blue 6@0) */ + { DSPF_ARGB6666, SDL_PIXELFORMAT_UNKNOWN }, /* 6 bit alpha (3 byte/ alpha 6@18, red 6@16, green 6@6, blue 6@0) */ + { DSPF_RGB18, SDL_PIXELFORMAT_UNKNOWN }, /* 6 bit RGB (3 byte/ red 6@16, green 6@6, blue 6@0) */ + { DSPF_LUT2, SDL_PIXELFORMAT_UNKNOWN }, /* 2 bit LUT (1 byte/ 4 pixel, 2 bit color and alpha lookup from palette) */ #if (DFB_VERSION_ATLEAST(1,3,0)) - { DSPF_RGBA4444, SDL_PIXELFORMAT_UNKNOWN }, /* 16 bit RGBA (2 byte, red 4@12, green 4@8, blue 4@4, alpha 4@0) */ + { DSPF_RGBA4444, SDL_PIXELFORMAT_UNKNOWN }, /* 16 bit RGBA (2 byte, red 4@12, green 4@8, blue 4@4, alpha 4@0) */ #endif #if (DFB_VERSION_ATLEAST(1,4,3)) - { DSPF_RGBA5551, SDL_PIXELFORMAT_UNKNOWN }, /* 16 bit RGBA (2 byte, red 5@11, green 5@6, blue 5@1, alpha 1@0) */ - { DSPF_YUV444P, SDL_PIXELFORMAT_UNKNOWN }, /* 24 bit full YUV planar (8 bit Y plane followed by an 8 bit Cb and an 8 bit Cr plane) */ - { DSPF_ARGB8565, SDL_PIXELFORMAT_UNKNOWN }, /* 24 bit ARGB (3 byte, alpha 8@16, red 5@11, green 6@5, blue 5@0) */ - { DSPF_AVYU, SDL_PIXELFORMAT_UNKNOWN }, /* 32 bit AVYU 4:4:4 (4 byte, alpha 8@24, Cr 8@16, Y 8@8, Cb 8@0) */ - { DSPF_VYU, SDL_PIXELFORMAT_UNKNOWN }, /* 24 bit VYU 4:4:4 (3 byte, Cr 8@16, Y 8@8, Cb 8@0) */ + { DSPF_RGBA5551, SDL_PIXELFORMAT_UNKNOWN }, /* 16 bit RGBA (2 byte, red 5@11, green 5@6, blue 5@1, alpha 1@0) */ + { DSPF_YUV444P, SDL_PIXELFORMAT_UNKNOWN }, /* 24 bit full YUV planar (8 bit Y plane followed by an 8 bit Cb and an 8 bit Cr plane) */ + { DSPF_ARGB8565, SDL_PIXELFORMAT_UNKNOWN }, /* 24 bit ARGB (3 byte, alpha 8@16, red 5@11, green 6@5, blue 5@0) */ + { DSPF_AVYU, SDL_PIXELFORMAT_UNKNOWN }, /* 32 bit AVYU 4:4:4 (4 byte, alpha 8@24, Cr 8@16, Y 8@8, Cb 8@0) */ + { DSPF_VYU, SDL_PIXELFORMAT_UNKNOWN }, /* 24 bit VYU 4:4:4 (3 byte, Cr 8@16, Y 8@8, Cb 8@0) */ #endif - + { DSPF_UNKNOWN, SDL_PIXELFORMAT_INDEX1LSB }, { DSPF_UNKNOWN, SDL_PIXELFORMAT_INDEX1MSB }, - { DSPF_UNKNOWN, SDL_PIXELFORMAT_INDEX4LSB }, + { DSPF_UNKNOWN, SDL_PIXELFORMAT_INDEX4LSB }, { DSPF_UNKNOWN, SDL_PIXELFORMAT_INDEX4MSB }, { DSPF_UNKNOWN, SDL_PIXELFORMAT_BGR24 }, { DSPF_UNKNOWN, SDL_PIXELFORMAT_BGR888 }, @@ -384,14 +384,14 @@ static const struct { { DSPF_UNKNOWN, SDL_PIXELFORMAT_ABGR4444 }, { DSPF_UNKNOWN, SDL_PIXELFORMAT_ABGR1555 }, { DSPF_UNKNOWN, SDL_PIXELFORMAT_BGR565 }, - { DSPF_UNKNOWN, SDL_PIXELFORMAT_YVYU }, /**< Packed mode: Y0+V0+Y1+U0 (1 pla */ + { DSPF_UNKNOWN, SDL_PIXELFORMAT_YVYU }, /**< Packed mode: Y0+V0+Y1+U0 (1 pla */ }; Uint32 DirectFB_DFBToSDLPixelFormat(DFBSurfacePixelFormat pixelformat) { int i; - + for (i=0; pixelformat_tab[i].dfb != DSPF_UNKNOWN; i++) if (pixelformat_tab[i].dfb == pixelformat) { @@ -404,7 +404,7 @@ DFBSurfacePixelFormat DirectFB_SDLToDFBPixelFormat(Uint32 format) { int i; - + for (i=0; pixelformat_tab[i].dfb != DSPF_UNKNOWN; i++) if (pixelformat_tab[i].sdl == format) { @@ -415,11 +415,11 @@ DirectFB_SDLToDFBPixelFormat(Uint32 format) void DirectFB_SetSupportedPixelFormats(SDL_RendererInfo* ri) { - int i, j; + int i, j; for (i=0, j=0; pixelformat_tab[i].dfb != DSPF_UNKNOWN; i++) - if (pixelformat_tab[i].sdl != SDL_PIXELFORMAT_UNKNOWN) - ri->texture_formats[j++] = pixelformat_tab[i].sdl; + if (pixelformat_tab[i].sdl != SDL_PIXELFORMAT_UNKNOWN) + ri->texture_formats[j++] = pixelformat_tab[i].sdl; ri->num_texture_formats = j; } diff --git a/src/video/directfb/SDL_DirectFB_video.h b/src/video/directfb/SDL_DirectFB_video.h index 4980f7a5c..53fcdcfb9 100644 --- a/src/video/directfb/SDL_DirectFB_video.h +++ b/src/video/directfb/SDL_DirectFB_video.h @@ -33,14 +33,14 @@ #include "SDL_log.h" -#define DFB_VERSIONNUM(X, Y, Z) \ - ((X)*1000 + (Y)*100 + (Z)) +#define DFB_VERSIONNUM(X, Y, Z) \ + ((X)*1000 + (Y)*100 + (Z)) #define DFB_COMPILEDVERSION \ - DFB_VERSIONNUM(DIRECTFB_MAJOR_VERSION, DIRECTFB_MINOR_VERSION, DIRECTFB_MICRO_VERSION) + DFB_VERSIONNUM(DIRECTFB_MAJOR_VERSION, DIRECTFB_MINOR_VERSION, DIRECTFB_MICRO_VERSION) #define DFB_VERSION_ATLEAST(X, Y, Z) \ - (DFB_COMPILEDVERSION >= DFB_VERSIONNUM(X, Y, Z)) + (DFB_COMPILEDVERSION >= DFB_VERSIONNUM(X, Y, Z)) #if (DFB_VERSION_ATLEAST(1,0,0)) #ifdef SDL_VIDEO_OPENGL @@ -51,10 +51,10 @@ #endif /* Set below to 1 to compile with (old) multi mice/keyboard api. Code left in - * in case we see this again ... + * in case we see this again ... */ -#define USE_MULTI_API (0) +#define USE_MULTI_API (0) /* Support for LUT8/INDEX8 pixel format. * This is broken in DirectFB 1.4.3. It works in 1.4.0 and 1.4.5 @@ -62,18 +62,18 @@ */ #if (DFB_COMPILEDVERSION == DFB_VERSIONNUM(1, 4, 3)) -#define ENABLE_LUT8 (0) +#define ENABLE_LUT8 (0) #else -#define ENABLE_LUT8 (1) +#define ENABLE_LUT8 (1) #endif #define DIRECTFB_DEBUG 1 -#define DFBENV_USE_YUV_UNDERLAY "SDL_DIRECTFB_YUV_UNDERLAY" /* Default: off */ -#define DFBENV_USE_YUV_DIRECT "SDL_DIRECTFB_YUV_DIRECT" /* Default: off */ -#define DFBENV_USE_X11_CHECK "SDL_DIRECTFB_X11_CHECK" /* Default: on */ -#define DFBENV_USE_LINUX_INPUT "SDL_DIRECTFB_LINUX_INPUT" /* Default: on */ -#define DFBENV_USE_WM "SDL_DIRECTFB_WM" /* Default: off */ +#define DFBENV_USE_YUV_UNDERLAY "SDL_DIRECTFB_YUV_UNDERLAY" /* Default: off */ +#define DFBENV_USE_YUV_DIRECT "SDL_DIRECTFB_YUV_DIRECT" /* Default: off */ +#define DFBENV_USE_X11_CHECK "SDL_DIRECTFB_X11_CHECK" /* Default: on */ +#define DFBENV_USE_LINUX_INPUT "SDL_DIRECTFB_LINUX_INPUT" /* Default: on */ +#define DFBENV_USE_WM "SDL_DIRECTFB_WM" /* Default: off */ #define SDL_DFB_RELEASE(x) do { if ( (x) != NULL ) { SDL_DFB_CHECK(x->Release(x)); x = NULL; } } while (0) #define SDL_DFB_FREE(x) do { if ( (x) != NULL ) { SDL_free(x); x = NULL; } } while (0) @@ -89,11 +89,11 @@ #define SDL_DFB_DEBUG(x...) SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, x) static inline DFBResult sdl_dfb_check(DFBResult ret, const char *src_file, int src_line) { - if (ret != DFB_OK) { - SDL_DFB_LOG("%s (%d):%s", src_file, src_line, DirectFBErrorString (ret) ); - SDL_SetError("%s:%s", SDL_DFB_CONTEXT, DirectFBErrorString (ret) ); - } - return ret; + if (ret != DFB_OK) { + SDL_DFB_LOG("%s (%d):%s", src_file, src_line, DirectFBErrorString (ret) ); + SDL_SetError("%s:%s", SDL_DFB_CONTEXT, DirectFBErrorString (ret) ); + } + return ret; } #define SDL_DFB_CHECK(x...) do { sdl_dfb_check( x, __FILE__, __LINE__); } while (0) @@ -113,9 +113,9 @@ static inline DFBResult sdl_dfb_check(DFBResult ret, const char *src_file, int s do { \ r = SDL_calloc (n, s); \ if (!(r)) { \ - SDL_DFB_ERR("Out of memory"); \ + SDL_DFB_ERR("Out of memory"); \ SDL_OutOfMemory(); \ - goto error; \ + goto error; \ } \ } while (0) @@ -130,10 +130,10 @@ static inline DFBResult sdl_dfb_check(DFBResult ret, const char *src_file, int s typedef struct _DFB_KeyboardData DFB_KeyboardData; struct _DFB_KeyboardData { - const SDL_Scancode *map; /* keyboard scancode map */ - int map_size; /* size of map */ - int map_adjust; /* index adjust */ - int is_generic; /* generic keyboard */ + const SDL_Scancode *map; /* keyboard scancode map */ + int map_size; /* size of map */ + int map_adjust; /* index adjust */ + int is_generic; /* generic keyboard */ int id; }; @@ -142,21 +142,21 @@ struct _DFB_DeviceData { int initialized; - IDirectFB *dfb; - int num_mice; - int mouse_id[0x100]; - int num_keyboard; - DFB_KeyboardData keyboard[10]; - SDL_Window *firstwin; + IDirectFB *dfb; + int num_mice; + int mouse_id[0x100]; + int num_keyboard; + DFB_KeyboardData keyboard[10]; + SDL_Window *firstwin; - int use_yuv_underlays; - int use_yuv_direct; - int use_linux_input; - int has_own_wm; + int use_yuv_underlays; + int use_yuv_direct; + int use_linux_input; + int has_own_wm; - /* window grab */ - SDL_Window *grabbed_window; + /* window grab */ + SDL_Window *grabbed_window; /* global events */ IDirectFBEventBuffer *events; diff --git a/src/video/directfb/SDL_DirectFB_window.c b/src/video/directfb/SDL_DirectFB_window.c index 1ba4cfe60..cdcb4cce6 100644 --- a/src/video/directfb/SDL_DirectFB_window.c +++ b/src/video/directfb/SDL_DirectFB_window.c @@ -57,10 +57,10 @@ DirectFB_CreateWindow(_THIS, SDL_Window * window) SDL_DFB_CHECKERR(dispdata->layer->SetCooperativeLevel(dispdata->layer, DLSCL_ADMINISTRATIVE)); #endif - /* FIXME ... ughh, ugly */ - if (window->x == -1000 && window->y == -1000) - bshaped = 1; - + /* FIXME ... ughh, ugly */ + if (window->x == -1000 && window->y == -1000) + bshaped = 1; + /* Fill the window description. */ x = window->x; y = window->y; @@ -68,21 +68,21 @@ DirectFB_CreateWindow(_THIS, SDL_Window * window) DirectFB_WM_AdjustWindowLayout(window, window->flags, window->w, window->h); /* Create Window */ - desc.caps = 0; + desc.caps = 0; desc.flags = DWDESC_WIDTH | DWDESC_HEIGHT | DWDESC_POSX | DWDESC_POSY | DWDESC_SURFACE_CAPS; if (bshaped) { - desc.flags |= DWDESC_CAPS; - desc.caps |= DWCAPS_ALPHACHANNEL; + desc.flags |= DWDESC_CAPS; + desc.caps |= DWCAPS_ALPHACHANNEL; } else { - desc.flags |= DWDESC_PIXELFORMAT; + desc.flags |= DWDESC_PIXELFORMAT; } if (!(window->flags & SDL_WINDOW_BORDERLESS)) - desc.caps |= DWCAPS_NODECORATION; + desc.caps |= DWCAPS_NODECORATION; desc.posx = x; desc.posy = y; @@ -116,7 +116,7 @@ DirectFB_CreateWindow(_THIS, SDL_Window * window) wopts |= DWOP_KEEP_POSITION | DWOP_KEEP_STACKING | DWOP_KEEP_SIZE; SDL_DFB_CHECK(windata->dfbwin->SetStackingClass(windata->dfbwin, DWSC_UPPER)); } - + if (bshaped) { wopts |= DWOP_SHAPED | DWOP_ALPHACHANNEL; wopts &= ~DWOP_OPAQUE_REGION; @@ -155,7 +155,7 @@ DirectFB_CreateWindow(_THIS, SDL_Window * window) SDL_DFB_CHECK(windata->dfbwin->RaiseToTop(windata->dfbwin)); /* remember parent */ - //windata->sdlwin = window; + /*windata->sdlwin = window; */ /* Add to list ... */ @@ -168,7 +168,7 @@ DirectFB_CreateWindow(_THIS, SDL_Window * window) return 0; error: - SDL_DFB_RELEASE(windata->surface); + SDL_DFB_RELEASE(windata->surface); SDL_DFB_RELEASE(windata->dfbwin); return -1; } @@ -275,7 +275,7 @@ DirectFB_SetWindowSize(_THIS, SDL_Window * window) if (cw != window->w || ch != window->h) { - DirectFB_WM_AdjustWindowLayout(window, window->flags, window->w, window->h); + DirectFB_WM_AdjustWindowLayout(window, window->flags, window->w, window->h); SDL_DFB_CHECKERR(windata->dfbwin->Resize(windata->dfbwin, windata->size.w, windata->size.h)); @@ -367,7 +367,7 @@ DirectFB_RestoreWindow(_THIS, SDL_Window * window) /* Window layout */ DirectFB_WM_AdjustWindowLayout(window, window->flags & ~(SDL_WINDOW_MAXIMIZED | SDL_WINDOW_MINIMIZED), - windata->restore.w, windata->restore.h); + windata->restore.w, windata->restore.h); SDL_DFB_CHECK(windata->dfbwin->Resize(windata->dfbwin, windata->restore.w, windata->restore.h)); SDL_DFB_CHECK(windata->dfbwin->MoveTo(windata->dfbwin, windata->restore.x, @@ -393,8 +393,8 @@ DirectFB_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed) if ((window->flags & SDL_WINDOW_INPUT_GRABBED)) { if (gwindata != NULL) { - SDL_DFB_CHECK(gwindata->dfbwin->UngrabPointer(gwindata->dfbwin)); - SDL_DFB_CHECK(gwindata->dfbwin->UngrabKeyboard(gwindata->dfbwin)); + SDL_DFB_CHECK(gwindata->dfbwin->UngrabPointer(gwindata->dfbwin)); + SDL_DFB_CHECK(gwindata->dfbwin->UngrabKeyboard(gwindata->dfbwin)); } SDL_DFB_CHECK(windata->dfbwin->GrabPointer(windata->dfbwin)); SDL_DFB_CHECK(windata->dfbwin->GrabKeyboard(windata->dfbwin)); @@ -418,22 +418,22 @@ DirectFB_DestroyWindow(_THIS, SDL_Window * window) SDL_DFB_CHECK(windata->dfbwin->UngrabKeyboard(windata->dfbwin)); #if SDL_DIRECTFB_OPENGL - DirectFB_GL_DestroyWindowContexts(_this, window); + DirectFB_GL_DestroyWindowContexts(_this, window); #endif - if (window->shaper) - { - SDL_ShapeData *data = window->shaper->driverdata; - SDL_DFB_CHECK(data->surface->ReleaseSource(data->surface)); - SDL_DFB_RELEASE(data->surface); - SDL_DFB_FREE(data); - SDL_DFB_FREE(window->shaper); - } + if (window->shaper) + { + SDL_ShapeData *data = window->shaper->driverdata; + SDL_DFB_CHECK(data->surface->ReleaseSource(data->surface)); + SDL_DFB_RELEASE(data->surface); + SDL_DFB_FREE(data); + SDL_DFB_FREE(window->shaper); + } SDL_DFB_CHECK(windata->window_surface->SetFont(windata->window_surface, NULL)); SDL_DFB_CHECK(windata->surface->ReleaseSource(windata->surface)); SDL_DFB_CHECK(windata->window_surface->ReleaseSource(windata->window_surface)); - SDL_DFB_RELEASE(windata->icon); + SDL_DFB_RELEASE(windata->icon); SDL_DFB_RELEASE(windata->font); SDL_DFB_RELEASE(windata->eventbuffer); SDL_DFB_RELEASE(windata->surface); @@ -494,7 +494,7 @@ DirectFB_AdjustWindowSurface(SDL_Window * window) if (adjust) { #if SDL_DIRECTFB_OPENGL - DirectFB_GL_FreeWindowContexts(SDL_GetVideoDevice(), window); + DirectFB_GL_FreeWindowContexts(SDL_GetVideoDevice(), window); #endif #if (DFB_VERSION_ATLEAST(1,2,1)) @@ -521,9 +521,9 @@ DirectFB_AdjustWindowSurface(SDL_Window * window) &windata->client, &windata->surface)); #endif DirectFB_WM_RedrawLayout(SDL_GetVideoDevice(), window); - + #if SDL_DIRECTFB_OPENGL - DirectFB_GL_ReAllocWindowContexts(SDL_GetVideoDevice(), window); + DirectFB_GL_ReAllocWindowContexts(SDL_GetVideoDevice(), window); #endif } error: diff --git a/src/video/directfb/SDL_DirectFB_window.h b/src/video/directfb/SDL_DirectFB_window.h index 43a08d308..a4a1cc840 100644 --- a/src/video/directfb/SDL_DirectFB_window.h +++ b/src/video/directfb/SDL_DirectFB_window.h @@ -30,28 +30,28 @@ typedef struct _DFB_WindowData DFB_WindowData; struct _DFB_WindowData { - IDirectFBSurface *window_surface; /* window surface */ - IDirectFBSurface *surface; /* client drawing surface */ - IDirectFBWindow *dfbwin; - IDirectFBEventBuffer *eventbuffer; - //SDL_Window *sdlwin; - SDL_Window *next; - Uint8 opacity; - DFBRectangle client; - DFBDimension size; - DFBRectangle restore; + IDirectFBSurface *window_surface; /* window surface */ + IDirectFBSurface *surface; /* client drawing surface */ + IDirectFBWindow *dfbwin; + IDirectFBEventBuffer *eventbuffer; + /*SDL_Window *sdlwin; */ + SDL_Window *next; + Uint8 opacity; + DFBRectangle client; + DFBDimension size; + DFBRectangle restore; /* WM extras */ - int is_managed; - int wm_needs_redraw; - IDirectFBSurface *icon; - IDirectFBFont *font; - DFB_Theme theme; + int is_managed; + int wm_needs_redraw; + IDirectFBSurface *icon; + IDirectFBFont *font; + DFB_Theme theme; /* WM moving and sizing */ - int wm_grab; - int wm_lastx; - int wm_lasty; + int wm_grab; + int wm_lastx; + int wm_lasty; }; extern int DirectFB_CreateWindow(_THIS, SDL_Window * window); diff --git a/src/video/pandora/SDL_pandora.c b/src/video/pandora/SDL_pandora.c index 77d12b79c..17c761bd6 100644 --- a/src/video/pandora/SDL_pandora.c +++ b/src/video/pandora/SDL_pandora.c @@ -38,7 +38,7 @@ /* WIZ declarations */ #include "GLES/gl.h" #ifdef WIZ_GLES_LITE -static NativeWindowType hNativeWnd = 0; // A handle to the window we will create. +static NativeWindowType hNativeWnd = 0; /* A handle to the window we will create. */ #endif static SDL_bool PND_initialized = SDL_FALSE; @@ -343,7 +343,7 @@ PND_gl_loadlibrary(_THIS, const char *path) /* Already linked with GF library which provides egl* subset of */ /* functions, use Common profile of OpenGL ES library by default */ #ifdef WIZ_GLES_LITE - path = "/lib/libopengles_lite.so"; + path = "/lib/libopengles_lite.so"; #else path = "/usr/lib/libGLES_CM.so"; #endif @@ -628,21 +628,21 @@ PND_gl_createcontext(_THIS, SDL_Window * window) #ifdef WIZ_GLES_LITE if( !hNativeWnd ) { - hNativeWnd = (NativeWindowType)malloc(16*1024); + hNativeWnd = (NativeWindowType)malloc(16*1024); - if(!hNativeWnd) - printf( "Error : Wiz framebuffer allocatation failed\n" ); - else - printf( "SDL13: Wiz framebuffer allocated: %X\n", hNativeWnd ); + if(!hNativeWnd) + printf( "Error : Wiz framebuffer allocatation failed\n" ); + else + printf( "SDL13: Wiz framebuffer allocated: %X\n", hNativeWnd ); } else { - printf( "SDL13: Wiz framebuffer already allocated: %X\n", hNativeWnd ); + printf( "SDL13: Wiz framebuffer already allocated: %X\n", hNativeWnd ); } wdata->gles_surface = - eglCreateWindowSurface(phdata->egl_display, - wdata->gles_configs[wdata->gles_config], - hNativeWnd, NULL ); + eglCreateWindowSurface(phdata->egl_display, + wdata->gles_configs[wdata->gles_config], + hNativeWnd, NULL ); #else wdata->gles_surface = eglCreateWindowSurface(phdata->egl_display, @@ -838,9 +838,9 @@ PND_gl_deletecontext(_THIS, SDL_GLContext context) #ifdef WIZ_GLES_LITE if( hNativeWnd != 0 ) { - free(hNativeWnd); - hNativeWnd = 0; - printf( "SDL13: Wiz framebuffer released\n" ); + free(hNativeWnd); + hNativeWnd = 0; + printf( "SDL13: Wiz framebuffer released\n" ); } #endif diff --git a/src/video/psp/SDL_pspevents.c b/src/video/psp/SDL_pspevents.c index e418daae2..54cd4e7d8 100644 --- a/src/video/psp/SDL_pspevents.c +++ b/src/video/psp/SDL_pspevents.c @@ -47,236 +47,236 @@ static SDL_sem *event_sem = NULL; static SDL_Thread *thread = NULL; static int running = 0; static struct { - enum PspHprmKeys id; - SDL_Keycode sym; + enum PspHprmKeys id; + SDL_Keycode sym; } keymap_psp[] = { - { PSP_HPRM_PLAYPAUSE, SDLK_F10 }, - { PSP_HPRM_FORWARD, SDLK_F11 }, - { PSP_HPRM_BACK, SDLK_F12 }, - { PSP_HPRM_VOL_UP, SDLK_F13 }, - { PSP_HPRM_VOL_DOWN, SDLK_F14 }, - { PSP_HPRM_HOLD, SDLK_F15 } + { PSP_HPRM_PLAYPAUSE, SDLK_F10 }, + { PSP_HPRM_FORWARD, SDLK_F11 }, + { PSP_HPRM_BACK, SDLK_F12 }, + { PSP_HPRM_VOL_UP, SDLK_F13 }, + { PSP_HPRM_VOL_DOWN, SDLK_F14 }, + { PSP_HPRM_HOLD, SDLK_F15 } }; int EventUpdate(void *data) { - while (running) { + while (running) { SDL_SemWait(event_sem); - sceHprmPeekCurrentKey(&hprm); + sceHprmPeekCurrentKey(&hprm); SDL_SemPost(event_sem); /* Delay 1/60th of a second */ - sceKernelDelayThread(1000000 / 60); + sceKernelDelayThread(1000000 / 60); } return 0; } void PSP_PumpEvents(_THIS) { - int i; - enum PspHprmKeys keys; - enum PspHprmKeys changed; - static enum PspHprmKeys old_keys = 0; - SDL_Keysym sym; - - SDL_SemWait(event_sem); - keys = hprm; - SDL_SemPost(event_sem); - - /* HPRM Keyboard */ - changed = old_keys ^ keys; - old_keys = keys; - if(changed) { - for(i=0; i= 0) { - if((length % sizeof(SIrKeybScanCodeData)) == 0){ - count = length / sizeof(SIrKeybScanCodeData); - for( i=0; i < count; i++ ) { - unsigned char raw, pressed; - scanData=(SIrKeybScanCodeData*) buffer+i; - raw = scanData->raw; - pressed = scanData->pressed; - sym.scancode = raw; - sym.sym = keymap[raw]; - /* not tested*/ - //SDL_PrivateKeyboard(pressed?SDL_PRESSED:SDL_RELEASED, &sym); - SDL_SendKeyboardKey((keys & keymap_psp[i].id) ? - SDL_PRESSED : SDL_RELEASED, SDL_GetScancodeFromKey(keymap[raw]); - - } - } - } - } + if (irkbd_ready) { + unsigned char buffer[255]; + int i, length, count; + SIrKeybScanCodeData *scanData; + + if(pspIrKeybReadinput(buffer, &length) >= 0) { + if((length % sizeof(SIrKeybScanCodeData)) == 0){ + count = length / sizeof(SIrKeybScanCodeData); + for( i=0; i < count; i++ ) { + unsigned char raw, pressed; + scanData=(SIrKeybScanCodeData*) buffer+i; + raw = scanData->raw; + pressed = scanData->pressed; + sym.scancode = raw; + sym.sym = keymap[raw]; + /* not tested*/ + /*SDL_PrivateKeyboard(pressed?SDL_PRESSED:SDL_RELEASED, &sym); */ + SDL_SendKeyboardKey((keys & keymap_psp[i].id) ? + SDL_PRESSED : SDL_RELEASED, SDL_GetScancodeFromKey(keymap[raw]); + + } + } + } + } #endif - sceKernelDelayThread(0); + sceKernelDelayThread(0); - return; + return; } void PSP_InitOSKeymap(_THIS) { #ifdef PSPIRKEYB - int i; - for (i=0; igl_config.driver_loaded) { - _this->gl_config.driver_loaded = 1; + _this->gl_config.driver_loaded = 1; } return 0; } -/* pspgl doesn't provide this call, so stub it out since SDL requires it. +/* pspgl doesn't provide this call, so stub it out since SDL requires it. #define GLSTUB(func,params) void func params {} - + GLSTUB(glOrtho,(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, - GLdouble zNear, GLdouble zFar)) + GLdouble zNear, GLdouble zFar)) */ void * PSP_GL_GetProcAddress(_THIS, const char *proc) { - return eglGetProcAddress(proc); + return eglGetProcAddress(proc); } void PSP_GL_UnloadLibrary(_THIS) { - eglTerminate(_this->gl_data->display); + eglTerminate(_this->gl_data->display); } static EGLint width = 480; @@ -78,64 +78,64 @@ PSP_GL_CreateContext(_THIS, SDL_Window * window) SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; - EGLint attribs[32]; - EGLDisplay display; - EGLContext context; - EGLSurface surface; - EGLConfig config; - EGLint num_configs; - int i; - - - /* EGL init taken from glutCreateWindow() in PSPGL's glut.c. */ - EGLCHK(display = eglGetDisplay(0)); - EGLCHK(eglInitialize(display, NULL, NULL)); - wdata->uses_gles = SDL_TRUE; - window->flags |= SDL_WINDOW_FULLSCREEN; - - /* Setup the config based on SDL's current values. */ - i = 0; - attribs[i++] = EGL_RED_SIZE; - attribs[i++] = _this->gl_config.red_size; - attribs[i++] = EGL_GREEN_SIZE; - attribs[i++] = _this->gl_config.green_size; - attribs[i++] = EGL_BLUE_SIZE; - attribs[i++] = _this->gl_config.blue_size; - attribs[i++] = EGL_DEPTH_SIZE; - attribs[i++] = _this->gl_config.depth_size; - - if (_this->gl_config.alpha_size) - { - attribs[i++] = EGL_ALPHA_SIZE; - attribs[i++] = _this->gl_config.alpha_size; - } - if (_this->gl_config.stencil_size) - { - attribs[i++] = EGL_STENCIL_SIZE; - attribs[i++] = _this->gl_config.stencil_size; - } - - attribs[i++] = EGL_NONE; - - EGLCHK(eglChooseConfig(display, attribs, &config, 1, &num_configs)); - - if (num_configs == 0) - { - SDL_SetError("No valid EGL configs for requested mode"); - return 0; - } - - EGLCHK(eglGetConfigAttrib(display, config, EGL_WIDTH, &width)); - EGLCHK(eglGetConfigAttrib(display, config, EGL_HEIGHT, &height)); - - EGLCHK(context = eglCreateContext(display, config, NULL, NULL)); - EGLCHK(surface = eglCreateWindowSurface(display, config, 0, NULL)); - EGLCHK(eglMakeCurrent(display, surface, surface, context)); - - _this->gl_data->display = display; - _this->gl_data->context = context; - _this->gl_data->surface = surface; - + EGLint attribs[32]; + EGLDisplay display; + EGLContext context; + EGLSurface surface; + EGLConfig config; + EGLint num_configs; + int i; + + + /* EGL init taken from glutCreateWindow() in PSPGL's glut.c. */ + EGLCHK(display = eglGetDisplay(0)); + EGLCHK(eglInitialize(display, NULL, NULL)); + wdata->uses_gles = SDL_TRUE; + window->flags |= SDL_WINDOW_FULLSCREEN; + + /* Setup the config based on SDL's current values. */ + i = 0; + attribs[i++] = EGL_RED_SIZE; + attribs[i++] = _this->gl_config.red_size; + attribs[i++] = EGL_GREEN_SIZE; + attribs[i++] = _this->gl_config.green_size; + attribs[i++] = EGL_BLUE_SIZE; + attribs[i++] = _this->gl_config.blue_size; + attribs[i++] = EGL_DEPTH_SIZE; + attribs[i++] = _this->gl_config.depth_size; + + if (_this->gl_config.alpha_size) + { + attribs[i++] = EGL_ALPHA_SIZE; + attribs[i++] = _this->gl_config.alpha_size; + } + if (_this->gl_config.stencil_size) + { + attribs[i++] = EGL_STENCIL_SIZE; + attribs[i++] = _this->gl_config.stencil_size; + } + + attribs[i++] = EGL_NONE; + + EGLCHK(eglChooseConfig(display, attribs, &config, 1, &num_configs)); + + if (num_configs == 0) + { + SDL_SetError("No valid EGL configs for requested mode"); + return 0; + } + + EGLCHK(eglGetConfigAttrib(display, config, EGL_WIDTH, &width)); + EGLCHK(eglGetConfigAttrib(display, config, EGL_HEIGHT, &height)); + + EGLCHK(context = eglCreateContext(display, config, NULL, NULL)); + EGLCHK(surface = eglCreateWindowSurface(display, config, 0, NULL)); + EGLCHK(eglMakeCurrent(display, surface, surface, context)); + + _this->gl_data->display = display; + _this->gl_data->context = context; + _this->gl_data->surface = surface; + return context; } @@ -143,18 +143,18 @@ PSP_GL_CreateContext(_THIS, SDL_Window * window) int PSP_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) { - if (!eglMakeCurrent(_this->gl_data->display, _this->gl_data->surface, - _this->gl_data->surface, _this->gl_data->context)) - { - return SDL_SetError("Unable to make EGL context current"); - } + if (!eglMakeCurrent(_this->gl_data->display, _this->gl_data->surface, + _this->gl_data->surface, _this->gl_data->context)) + { + return SDL_SetError("Unable to make EGL context current"); + } return 0; } int PSP_GL_SetSwapInterval(_THIS, int interval) { - EGLBoolean status; + EGLBoolean status; status = eglSwapInterval(_this->gl_data->display, interval); if (status == EGL_TRUE) { /* Return success to upper level */ diff --git a/src/video/psp/SDL_pspgl_c.h b/src/video/psp/SDL_pspgl_c.h index 73235ef68..8b20d1544 100644 --- a/src/video/psp/SDL_pspgl_c.h +++ b/src/video/psp/SDL_pspgl_c.h @@ -30,9 +30,9 @@ typedef struct SDL_GLDriverData { - EGLDisplay display; - EGLContext context; - EGLSurface surface; + EGLDisplay display; + EGLContext context; + EGLSurface surface; uint32_t swapinterval; }SDL_GLDriverData; diff --git a/src/video/psp/SDL_pspmouse.c b/src/video/psp/SDL_pspmouse.c index 8f0ffdc7d..002a518b4 100644 --- a/src/video/psp/SDL_pspmouse.c +++ b/src/video/psp/SDL_pspmouse.c @@ -31,5 +31,5 @@ /* The implementation dependent data for the window manager cursor */ struct WMcursor { - int unused; + int unused; }; diff --git a/src/video/psp/SDL_pspvideo.c b/src/video/psp/SDL_pspvideo.c index d84e69b92..ed5ab1c96 100644 --- a/src/video/psp/SDL_pspvideo.c +++ b/src/video/psp/SDL_pspvideo.c @@ -51,7 +51,7 @@ PSP_Available(void) static void PSP_Destroy(SDL_VideoDevice * device) { -// SDL_VideoData *phdata = (SDL_VideoData *) device->driverdata; +/* SDL_VideoData *phdata = (SDL_VideoData *) device->driverdata; */ if (device->driverdata != NULL) { device->driverdata = NULL; @@ -87,15 +87,15 @@ PSP_Create() SDL_free(device); return NULL; } - - gldata = (SDL_GLDriverData *) SDL_calloc(1, sizeof(SDL_GLDriverData)); + + gldata = (SDL_GLDriverData *) SDL_calloc(1, sizeof(SDL_GLDriverData)); if (gldata == NULL) { SDL_OutOfMemory(); SDL_free(device); return NULL; - } + } device->gl_data = gldata; - + device->driverdata = phdata; phdata->egl_initialized = SDL_TRUE; @@ -136,11 +136,11 @@ PSP_Create() device->GL_GetSwapInterval = PSP_GL_GetSwapInterval; device->GL_SwapWindow = PSP_GL_SwapWindow; device->GL_DeleteContext = PSP_GL_DeleteContext; - device->HasScreenKeyboardSupport = PSP_HasScreenKeyboardSupport; - device->ShowScreenKeyboard = PSP_ShowScreenKeyboard; - device->HideScreenKeyboard = PSP_HideScreenKeyboard; - device->IsScreenKeyboardShown = PSP_IsScreenKeyboardShown; - + device->HasScreenKeyboardSupport = PSP_HasScreenKeyboardSupport; + device->ShowScreenKeyboard = PSP_ShowScreenKeyboard; + device->HideScreenKeyboard = PSP_HideScreenKeyboard; + device->IsScreenKeyboardShown = PSP_IsScreenKeyboardShown; + device->PumpEvents = PSP_PumpEvents; return device; @@ -163,15 +163,14 @@ PSP_VideoInit(_THIS) SDL_DisplayMode current_mode; SDL_zero(current_mode); - + current_mode.w = 480; current_mode.h = 272; - + current_mode.refresh_rate = 60; - // 32 bpp for default - // current_mode.format = SDL_PIXELFORMAT_RGBA8888; + /* 32 bpp for default */ current_mode.format = SDL_PIXELFORMAT_ABGR8888; - + current_mode.driverdata = NULL; SDL_zero(display); @@ -201,23 +200,21 @@ PSP_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode) { return 0; } -#define EGLCHK(stmt) \ - do { \ - EGLint err; \ - \ - stmt; \ - err = eglGetError(); \ - if (err != EGL_SUCCESS) { \ - SDL_SetError("EGL error %d", err); \ - return 0; \ - } \ - } while (0) - +#define EGLCHK(stmt) \ + do { \ + EGLint err; \ + \ + stmt; \ + err = eglGetError(); \ + if (err != EGL_SUCCESS) { \ + SDL_SetError("EGL error %d", err); \ + return 0; \ + } \ + } while (0) + int PSP_CreateWindow(_THIS, SDL_Window * window) { -// SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; - SDL_WindowData *wdata; /* Allocate window internal data */ @@ -288,8 +285,6 @@ PSP_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed) void PSP_DestroyWindow(_THIS, SDL_Window * window) { - -// eglTerminate(_this->gl_data->display); } /*****************************************************************************/ @@ -324,7 +319,7 @@ void PSP_HideScreenKeyboard(_THIS, SDL_Window *window) } SDL_bool PSP_IsScreenKeyboardShown(_THIS, SDL_Window *window) { - return SDL_FALSE; + return SDL_FALSE; } diff --git a/src/video/psp/SDL_pspvideo.h b/src/video/psp/SDL_pspvideo.h index 4c8a8cda4..d4ab32bfe 100644 --- a/src/video/psp/SDL_pspvideo.h +++ b/src/video/psp/SDL_pspvideo.h @@ -31,7 +31,7 @@ typedef struct SDL_VideoData { SDL_bool egl_initialized; /* OpenGL ES device initialization status */ uint32_t egl_refcount; /* OpenGL ES reference count */ - + } SDL_VideoData; @@ -46,7 +46,7 @@ typedef struct SDL_DisplayData typedef struct SDL_WindowData { SDL_bool uses_gles; /* if true window must support OpenGL ES */ - + } SDL_WindowData; @@ -96,7 +96,7 @@ SDL_bool PSP_HasScreenKeyboardSupport(_THIS); void PSP_ShowScreenKeyboard(_THIS, SDL_Window *window); void PSP_HideScreenKeyboard(_THIS, SDL_Window *window); SDL_bool PSP_IsScreenKeyboardShown(_THIS, SDL_Window *window); - + #endif /* __SDL_PANDORA_H__ */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/uikit/SDL_uikitappdelegate.m b/src/video/uikit/SDL_uikitappdelegate.m index 11e74025e..d13c2bbce 100644 --- a/src/video/uikit/SDL_uikitappdelegate.m +++ b/src/video/uikit/SDL_uikitappdelegate.m @@ -117,7 +117,7 @@ - (id)init if (self->splashLandscape) { [self->splashLandscape retain]; } - + [self updateSplashImage:[[UIApplication sharedApplication] statusBarOrientation]]; return self; @@ -126,8 +126,8 @@ - (id)init - (NSUInteger)supportedInterfaceOrientations { NSUInteger orientationMask = UIInterfaceOrientationMaskAll; - - // Don't allow upside-down orientation on the phone, so answering calls is in the natural orientation + + /* Don't allow upside-down orientation on the phone, so answering calls is in the natural orientation */ if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { orientationMask &= ~UIInterfaceOrientationMaskPortraitUpsideDown; } @@ -148,7 +148,7 @@ - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interf - (void)updateSplashImage:(UIInterfaceOrientation)interfaceOrientation { UIImage *image; - + if (UIInterfaceOrientationIsLandscape(interfaceOrientation)) { image = self->splashLandscape; } else { @@ -199,9 +199,10 @@ - (void)postFinishLaunch } /* exit, passing the return status from the user's application */ - // We don't actually exit to support applications that do setup in - // their main function and then allow the Cocoa event loop to run. - // exit(exit_status); + /* We don't actually exit to support applications that do setup in + * their main function and then allow the Cocoa event loop to run. + */ + /* exit(exit_status); */ } - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions diff --git a/src/video/uikit/SDL_uikitmessagebox.m b/src/video/uikit/SDL_uikitmessagebox.m index 26c218b01..5ec7e8b47 100644 --- a/src/video/uikit/SDL_uikitmessagebox.m +++ b/src/video/uikit/SDL_uikitmessagebox.m @@ -49,7 +49,7 @@ - (id)initWithButtonIndex:(int *)buttonIndex return nil; } self->clickedButtonIndex = buttonIndex; - + return self; } @@ -58,7 +58,7 @@ - (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger) *clickedButtonIndex = buttonIndex; } -@end // UIKit_UIAlertViewDelegate +@end /* UIKit_UIAlertViewDelegate */ SDL_bool @@ -71,7 +71,7 @@ - (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger) UIKit_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) { int clicked; - + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; UIAlertView* alert = [[UIAlertView alloc] init]; @@ -86,13 +86,13 @@ - (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger) [alert addButtonWithTitle:[[NSString alloc] initWithUTF8String:buttons[i].text]]; } - // Set up for showing the alert + /* Set up for showing the alert */ clicked = messageboxdata->numbuttons; [alert show]; - - // Run the main event loop until the alert has finished - // Note that this needs to be done on the main thread + + /* Run the main event loop until the alert has finished */ + /* Note that this needs to be done on the main thread */ s_showingMessageBox = SDL_TRUE; while (clicked == messageboxdata->numbuttons) { [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]; @@ -100,7 +100,7 @@ - (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger) s_showingMessageBox = SDL_FALSE; *buttonid = messageboxdata->buttons[clicked].buttonid; - + [alert.delegate release]; [alert release]; diff --git a/src/video/uikit/SDL_uikitmodes.m b/src/video/uikit/SDL_uikitmodes.m index 87c3cc1e5..f093a81c6 100644 --- a/src/video/uikit/SDL_uikitmodes.m +++ b/src/video/uikit/SDL_uikitmodes.m @@ -34,22 +34,22 @@ UIScreenMode * uiscreenmode, CGFloat scale) { SDL_DisplayModeData *data = NULL; - + if (uiscreenmode != nil) { /* Allocate the display mode data */ data = (SDL_DisplayModeData *) SDL_malloc(sizeof(*data)); if (!data) { return SDL_OutOfMemory(); } - + data->uiscreenmode = uiscreenmode; [data->uiscreenmode retain]; - + data->scale = scale; } - + mode->driverdata = data; - + return 0; } @@ -57,7 +57,7 @@ UIKit_FreeDisplayModeData(SDL_DisplayMode * mode) { if (!SDL_UIKit_supports_multiple_displays) { - // Not on at least iPhoneOS 3.2 (versions prior to iPad). + /* Not on at least iPhoneOS 3.2 (versions prior to iPad). */ SDL_assert(mode->driverdata == NULL); } else if (mode->driverdata != NULL) { SDL_DisplayModeData *data = (SDL_DisplayModeData *)mode->driverdata; @@ -73,13 +73,13 @@ { SDL_DisplayMode mode; SDL_zero(mode); - + mode.format = SDL_PIXELFORMAT_ABGR8888; mode.refresh_rate = 0; if (UIKit_AllocateDisplayModeData(&mode, uiscreenmode, scale) < 0) { return -1; } - + mode.w = w; mode.h = h; if (SDL_AddDisplayMode(display, &mode)) { @@ -97,14 +97,14 @@ if (UIKit_AddSingleDisplayMode(display, w, h, uiscreenmode, scale) < 0) { return -1; } - + if (addRotation) { - // Add the rotated version + /* Add the rotated version */ if (UIKit_AddSingleDisplayMode(display, h, w, uiscreenmode, scale) < 0) { return -1; } } - + return 0; } @@ -113,25 +113,26 @@ { CGSize size = [uiscreen bounds].size; - // Make sure the width/height are oriented correctly + /* Make sure the width/height are oriented correctly */ if (UIKit_IsDisplayLandscape(uiscreen) != (size.width > size.height)) { CGFloat height = size.width; size.width = size.height; size.height = height; } - // When dealing with UIKit all coordinates are specified in terms of - // what Apple refers to as points. On earlier devices without the - // so called "Retina" display, there is a one to one mapping between - // points and pixels. In other cases [UIScreen scale] indicates the - // relationship between points and pixels. Since SDL has no notion - // of points, we must compensate in all cases where dealing with such - // units. + /* When dealing with UIKit all coordinates are specified in terms of + * what Apple refers to as points. On earlier devices without the + * so called "Retina" display, there is a one to one mapping between + * points and pixels. In other cases [UIScreen scale] indicates the + * relationship between points and pixels. Since SDL has no notion + * of points, we must compensate in all cases where dealing with such + * units. + */ CGFloat scale; if ([UIScreen instancesRespondToSelector:@selector(scale)]) { - scale = [uiscreen scale]; // iOS >= 4.0 + scale = [uiscreen scale]; /* iOS >= 4.0 */ } else { - scale = 1.0f; // iOS < 4.0 + scale = 1.0f; /* iOS < 4.0 */ } SDL_VideoDisplay display; @@ -140,14 +141,15 @@ mode.format = SDL_PIXELFORMAT_ABGR8888; mode.w = (int)(size.width * scale); mode.h = (int)(size.height * scale); - + UIScreenMode * uiscreenmode = nil; - // UIScreenMode showed up in 3.2 (the iPad and later). We're - // misusing this supports_multiple_displays flag here for that. + /* UIScreenMode showed up in 3.2 (the iPad and later). We're + * misusing this supports_multiple_displays flag here for that. + */ if (SDL_UIKit_supports_multiple_displays) { uiscreenmode = [uiscreen currentMode]; } - + if (UIKit_AllocateDisplayModeData(&mode, uiscreenmode, scale) < 0) { return -1; } @@ -162,14 +164,14 @@ UIKit_FreeDisplayModeData(&display.desktop_mode); return SDL_OutOfMemory(); } - + [uiscreen retain]; data->uiscreen = uiscreen; data->scale = scale; - + display.driverdata = data; SDL_AddVideoDisplay(&display); - + return 0; } @@ -187,20 +189,21 @@ int UIKit_InitModes(_THIS) { - // this tells us whether we are running on ios >= 3.2 + /* this tells us whether we are running on ios >= 3.2 */ SDL_UIKit_supports_multiple_displays = [UIScreen instancesRespondToSelector:@selector(currentMode)]; - // Add the main screen. + /* Add the main screen. */ if (UIKit_AddDisplay([UIScreen mainScreen]) < 0) { return -1; } - // If this is iPhoneOS < 3.2, all devices are one screen, 320x480 pixels. - // The iPad added both a larger main screen and the ability to use - // external displays. So, add the other displays (screens in UI speak). + /* If this is iPhoneOS < 3.2, all devices are one screen, 320x480 pixels. */ + /* The iPad added both a larger main screen and the ability to use + * external displays. So, add the other displays (screens in UI speak). + */ if (SDL_UIKit_supports_multiple_displays) { for (UIScreen *uiscreen in [UIScreen screens]) { - // Only add the other screens + /* Only add the other screens */ if (uiscreen != [UIScreen mainScreen]) { if (UIKit_AddDisplay(uiscreen) < 0) { return -1; @@ -222,27 +225,28 @@ SDL_bool addRotation = (data->uiscreen == [UIScreen mainScreen]); if (SDL_UIKit_supports_multiple_displays) { - // availableModes showed up in 3.2 (the iPad and later). We should only - // land here for at least that version of the OS. + /* availableModes showed up in 3.2 (the iPad and later). We should only + * land here for at least that version of the OS. + */ for (UIScreenMode *uimode in [data->uiscreen availableModes]) { CGSize size = [uimode size]; int w = (int)size.width; int h = (int)size.height; - - // Make sure the width/height are oriented correctly + + /* Make sure the width/height are oriented correctly */ if (isLandscape != (w > h)) { int tmp = w; w = h; h = tmp; } - // Add the native screen resolution. + /* Add the native screen resolution. */ UIKit_AddDisplayMode(display, w, h, data->scale, uimode, addRotation); if (data->scale != 1.0f) { - // Add the native screen resolution divided by its scale. - // This is so devices capable of e.g. 640x960 also advertise - // 320x480. + /* Add the native screen resolution divided by its scale. + * This is so devices capable of e.g. 640x960 also advertise 320x480. + */ UIKit_AddDisplayMode(display, (int)(size.width / data->scale), (int)(size.height / data->scale), @@ -254,7 +258,7 @@ int w = (int)size.width; int h = (int)size.height; - // Make sure the width/height are oriented correctly + /* Make sure the width/height are oriented correctly */ if (isLandscape != (w > h)) { int tmp = w; w = h; @@ -262,7 +266,7 @@ } UIKit_AddDisplayMode(display, w, h, 1.0f, nil, addRotation); - } + } } int @@ -271,7 +275,7 @@ SDL_DisplayData *data = (SDL_DisplayData *) display->driverdata; if (!SDL_UIKit_supports_multiple_displays) { - // Not on at least iPhoneOS 3.2 (versions prior to iPad). + /* Not on at least iPhoneOS 3.2 (versions prior to iPad). */ SDL_assert(mode->driverdata == NULL); } else { SDL_DisplayModeData *modedata = (SDL_DisplayModeData *)mode->driverdata; @@ -295,7 +299,7 @@ void UIKit_QuitModes(_THIS) { - // Release Objective-C objects, so higher level doesn't free() them. + /* Release Objective-C objects, so higher level doesn't free() them. */ int i, j; for (i = 0; i < _this->num_displays; i++) { SDL_VideoDisplay *display = &_this->displays[i]; diff --git a/src/video/uikit/SDL_uikitopengles.m b/src/video/uikit/SDL_uikitopengles.m index 4fc1a2773..a7d370f2b 100644 --- a/src/video/uikit/SDL_uikitopengles.m +++ b/src/video/uikit/SDL_uikitopengles.m @@ -80,7 +80,7 @@ int UIKit_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) void UIKit_GL_SwapWindow(_THIS, SDL_Window * window) { #if SDL_POWER_UIKIT - // Check once a frame to see if we should turn off the battery monitor. + /* Check once a frame to see if we should turn off the battery monitor. */ SDL_UIKit_UpdateBatteryMonitoring(); #endif @@ -134,8 +134,8 @@ SDL_GLContext UIKit_GL_CreateContext(_THIS, SDL_Window * window) [view->viewcontroller retain]; } [uiwindow addSubview: view]; - - // The view controller needs to be the root in order to control rotation on iOS 6.0 + + /* The view controller needs to be the root in order to control rotation on iOS 6.0 */ if (uiwindow.rootViewController == nil) { uiwindow.rootViewController = view->viewcontroller; } diff --git a/src/video/uikit/SDL_uikitopenglview.m b/src/video/uikit/SDL_uikitopenglview.m index 16ac872d9..6ca5162d9 100644 --- a/src/video/uikit/SDL_uikitopenglview.m +++ b/src/video/uikit/SDL_uikitopenglview.m @@ -165,9 +165,10 @@ - (void)setAnimationCallback:(int)interval - (void)startAnimation { - // CADisplayLink is API new to iPhone SDK 3.1. Compiling against earlier versions will result in a warning, but can be dismissed - // if the system version runtime check for CADisplayLink exists in -initWithCoder:. - + /* CADisplayLink is API new to iPhone SDK 3.1. + * Compiling against earlier versions will result in a warning, but can be dismissed + * if the system version runtime check for CADisplayLink exists in -initWithCoder:. + */ displayLink = [NSClassFromString(@"CADisplayLink") displayLinkWithTarget:self selector:@selector(doLoop:)]; [displayLink setFrameInterval:animationInterval]; [displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; @@ -181,7 +182,7 @@ - (void)stopAnimation - (void)doLoop:(id)sender { - // Don't run the game loop while a messagebox is up + /* Don't run the game loop while a messagebox is up */ if (!UIKit_ShowingMessageBox()) { animationCallback(animationCallbackParam); } diff --git a/src/video/uikit/SDL_uikitvideo.h b/src/video/uikit/SDL_uikitvideo.h index c8418faa4..8969e91e9 100644 --- a/src/video/uikit/SDL_uikitvideo.h +++ b/src/video/uikit/SDL_uikitvideo.h @@ -26,7 +26,7 @@ #include "../SDL_sysvideo.h" #ifndef __IPHONE_6_0 -// This enum isn't available in older SDKs, but we use it for our own purposes on iOS 5.1 and for the system on iOS 6.0 +/* This enum isn't available in older SDKs, but we use it for our own purposes on iOS 5.1 and for the system on iOS 6.0 */ enum UIInterfaceOrientationMask { UIInterfaceOrientationMaskPortrait = (1 << UIInterfaceOrientationPortrait), @@ -37,7 +37,7 @@ enum UIInterfaceOrientationMask UIInterfaceOrientationMaskAll = (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskPortraitUpsideDown), UIInterfaceOrientationMaskAllButUpsideDown = (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight), }; -#endif // !__IPHONE_6_0 +#endif /* !__IPHONE_6_0 */ #endif /* _SDL_uikitvideo_h */ diff --git a/src/video/uikit/SDL_uikitview.m b/src/video/uikit/SDL_uikitview.m index ec37f1880..e808962ef 100644 --- a/src/video/uikit/SDL_uikitview.m +++ b/src/video/uikit/SDL_uikitview.m @@ -63,11 +63,11 @@ - (CGPoint)touchLocation:(UITouch *)touch shouldNormalize:(BOOL)normalize { CGPoint point = [touch locationInView: self]; - // Get the display scale and apply that to the input coordinates + /* Get the display scale and apply that to the input coordinates */ SDL_Window *window = self->viewcontroller.window; SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); SDL_DisplayModeData *displaymodedata = (SDL_DisplayModeData *) display->current_mode.driverdata; - + if (normalize) { CGRect bounds = [self bounds]; point.x /= bounds.size.width; @@ -99,9 +99,10 @@ - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES]; #ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS - // FIXME: TODO: Using touch as the fingerId is potentially dangerous - // It is also much more efficient than storing the UITouch pointer - // and comparing it to the incoming event. + /* FIXME: TODO: Using touch as the fingerId is potentially dangerous + * It is also much more efficient than storing the UITouch pointer + * and comparing it to the incoming event. + */ SDL_SendTouch(touchId, (SDL_FingerID)((size_t)touch), SDL_TRUE, locationInView.x, locationInView.y, 1.0f); #else diff --git a/src/video/uikit/SDL_uikitviewcontroller.m b/src/video/uikit/SDL_uikitviewcontroller.m index 896a76f0e..157b70aa0 100644 --- a/src/video/uikit/SDL_uikitviewcontroller.m +++ b/src/video/uikit/SDL_uikitviewcontroller.m @@ -51,7 +51,7 @@ - (id)initWithSDLWindow:(SDL_Window *)_window - (void)loadView { - // do nothing. + /* do nothing. */ } - (void)viewDidLayoutSubviews @@ -62,10 +62,10 @@ - (void)viewDidLayoutSubviews SDL_DisplayModeData *displaymodedata = (SDL_DisplayModeData *) display->current_mode.driverdata; const CGSize size = data->view.bounds.size; int w, h; - + w = (int)(size.width * displaymodedata->scale); h = (int)(size.height * displaymodedata->scale); - + SDL_SendWindowEvent(self->window, SDL_WINDOWEVENT_RESIZED, w, h); } } @@ -73,7 +73,7 @@ - (void)viewDidLayoutSubviews - (NSUInteger)supportedInterfaceOrientations { NSUInteger orientationMask = 0; - + const char *orientationsCString; if ((orientationsCString = SDL_GetHint(SDL_HINT_ORIENTATIONS)) != NULL) { BOOL rotate = NO; @@ -81,7 +81,7 @@ - (NSUInteger)supportedInterfaceOrientations encoding:NSUTF8StringEncoding]; NSArray *orientations = [orientationsNSString componentsSeparatedByCharactersInSet: [NSCharacterSet characterSetWithCharactersInString:@" "]]; - + if ([orientations containsObject:@"LandscapeLeft"]) { orientationMask |= UIInterfaceOrientationMaskLandscapeLeft; } @@ -94,9 +94,9 @@ - (NSUInteger)supportedInterfaceOrientations if ([orientations containsObject:@"PortraitUpsideDown"]) { orientationMask |= UIInterfaceOrientationMaskPortraitUpsideDown; } - + } else if (self->window->flags & SDL_WINDOW_RESIZABLE) { - orientationMask = UIInterfaceOrientationMaskAll; // any orientation is okay. + orientationMask = UIInterfaceOrientationMaskAll; /* any orientation is okay. */ } else { if (self->window->w >= self->window->h) { orientationMask |= UIInterfaceOrientationMaskLandscape; @@ -105,8 +105,8 @@ - (NSUInteger)supportedInterfaceOrientations orientationMask |= (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown); } } - - // Don't allow upside-down orientation on the phone, so answering calls is in the natural orientation + + /* Don't allow upside-down orientation on the phone, so answering calls is in the natural orientation */ if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { orientationMask &= ~UIInterfaceOrientationMaskPortraitUpsideDown; } diff --git a/src/video/uikit/SDL_uikitwindow.m b/src/video/uikit/SDL_uikitwindow.m index a009f5976..6be691518 100644 --- a/src/video/uikit/SDL_uikitwindow.m +++ b/src/video/uikit/SDL_uikitwindow.m @@ -76,7 +76,7 @@ static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bo int width = (int)(bounds.size.width * displaymodedata->scale); int height = (int)(bounds.size.height * displaymodedata->scale); - // Make sure the width/height are oriented correctly + /* Make sure the width/height are oriented correctly */ if (UIKit_IsDisplayLandscape(displaydata->uiscreen) != (width > height)) { int temp = width; width = height; @@ -93,30 +93,32 @@ static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bo window->flags &= ~SDL_WINDOW_HIDDEN; window->flags |= SDL_WINDOW_SHOWN; - // SDL_WINDOW_BORDERLESS controls whether status bar is hidden. - // This is only set if the window is on the main screen. Other screens - // just force the window to have the borderless flag. + /* SDL_WINDOW_BORDERLESS controls whether status bar is hidden. + * This is only set if the window is on the main screen. Other screens + * just force the window to have the borderless flag. + */ if (displaydata->uiscreen == [UIScreen mainScreen]) { - window->flags |= SDL_WINDOW_INPUT_FOCUS; // always has input focus - + window->flags |= SDL_WINDOW_INPUT_FOCUS; /* always has input focus */ + if ([UIApplication sharedApplication].statusBarHidden) { window->flags |= SDL_WINDOW_BORDERLESS; } else { window->flags &= ~SDL_WINDOW_BORDERLESS; } } else { - window->flags &= ~SDL_WINDOW_RESIZABLE; // window is NEVER resizeable - window->flags &= ~SDL_WINDOW_INPUT_FOCUS; // never has input focus - window->flags |= SDL_WINDOW_BORDERLESS; // never has a status bar. + window->flags &= ~SDL_WINDOW_RESIZABLE; /* window is NEVER resizeable */ + window->flags &= ~SDL_WINDOW_INPUT_FOCUS; /* never has input focus */ + window->flags |= SDL_WINDOW_BORDERLESS; /* never has a status bar. */ } - // The View Controller will handle rotating the view when the - // device orientation changes. This will trigger resize events, if - // appropriate. + /* The View Controller will handle rotating the view when the + * device orientation changes. This will trigger resize events, if + * appropriate. + */ SDL_uikitviewcontroller *controller; controller = [SDL_uikitviewcontroller alloc]; data->viewcontroller = [controller initWithSDLWindow:window]; - [data->viewcontroller setTitle:@"SDL App"]; // !!! FIXME: hook up SDL_SetWindowTitle() + [data->viewcontroller setTitle:@"SDL App"]; /* !!! FIXME: hook up SDL_SetWindowTitle() */ return 0; } @@ -128,7 +130,7 @@ static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bo SDL_DisplayData *data = (SDL_DisplayData *) display->driverdata; const BOOL external = ([UIScreen mainScreen] != data->uiscreen); - // SDL currently puts this window at the start of display's linked list. We rely on this. + /* SDL currently puts this window at the start of display's linked list. We rely on this. */ SDL_assert(_this->windows == window); /* We currently only handle a single window per display on iOS */ @@ -136,9 +138,10 @@ static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bo return SDL_SetError("Only one window allowed per display."); } - // If monitor has a resolution of 0x0 (hasn't been explicitly set by the - // user, so it's in standby), try to force the display to a resolution - // that most closely matches the desired window size. + /* If monitor has a resolution of 0x0 (hasn't been explicitly set by the + * user, so it's in standby), try to force the display to a resolution + * that most closely matches the desired window size. + */ if (SDL_UIKit_supports_multiple_displays) { const CGSize origsize = [[data->uiscreen currentMode] size]; if ((origsize.width == 0.0f) && (origsize.height == 0.0f)) { @@ -158,14 +161,15 @@ static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bo SDL_DisplayModeData *modedata = (SDL_DisplayModeData *)bestmode->driverdata; [data->uiscreen setCurrentMode:modedata->uiscreenmode]; - // desktop_mode doesn't change here (the higher level will - // use it to set all the screens back to their defaults - // upon window destruction, SDL_Quit(), etc. + /* desktop_mode doesn't change here (the higher level will + * use it to set all the screens back to their defaults + * upon window destruction, SDL_Quit(), etc. + */ display->current_mode = *bestmode; } } } - + if (data->uiscreen == [UIScreen mainScreen]) { if (window->flags & (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_BORDERLESS)) { [UIApplication sharedApplication].statusBarHidden = YES; @@ -173,7 +177,7 @@ static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bo [UIApplication sharedApplication].statusBarHidden = NO; } } - + if (!(window->flags & SDL_WINDOW_RESIZABLE)) { if (window->w > window->h) { if (!UIKit_IsDisplayLandscape(data->uiscreen)) { @@ -187,14 +191,15 @@ static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bo } /* ignore the size user requested, and make a fullscreen window */ - // !!! FIXME: can we have a smaller view? + /* !!! FIXME: can we have a smaller view? */ UIWindow *uiwindow = [UIWindow alloc]; uiwindow = [uiwindow initWithFrame:[data->uiscreen bounds]]; - // put the window on an external display if appropriate. This implicitly - // does [uiwindow setframe:[uiscreen bounds]], so don't do it on the - // main display, where we land by default, as that would eat the - // status bar real estate. + /* put the window on an external display if appropriate. This implicitly + * does [uiwindow setframe:[uiscreen bounds]], so don't do it on the + * main display, where we land by default, as that would eat the + * status bar real estate. + */ if (external) { [uiwindow setScreen:data->uiscreen]; } @@ -227,10 +232,11 @@ static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bo void UIKit_RaiseWindow(_THIS, SDL_Window * window) { - // We don't currently offer a concept of "raising" the SDL window, since - // we only allow one per display, in the iOS fashion. - // However, we use this entry point to rebind the context to the view - // during OnWindowRestored processing. + /* We don't currently offer a concept of "raising" the SDL window, since + * we only allow one per display, in the iOS fashion. + * However, we use this entry point to rebind the context to the view + * during OnWindowRestored processing. + */ _this->GL_MakeCurrent(_this, _this->current_glwin, _this->current_glctx); } diff --git a/src/video/windows/SDL_vkeys.h b/src/video/windows/SDL_vkeys.h index 2e835f543..ca24e8ff9 100644 --- a/src/video/windows/SDL_vkeys.h +++ b/src/video/windows/SDL_vkeys.h @@ -20,57 +20,57 @@ */ #ifndef VK_0 -#define VK_0 '0' -#define VK_1 '1' -#define VK_2 '2' -#define VK_3 '3' -#define VK_4 '4' -#define VK_5 '5' -#define VK_6 '6' -#define VK_7 '7' -#define VK_8 '8' -#define VK_9 '9' -#define VK_A 'A' -#define VK_B 'B' -#define VK_C 'C' -#define VK_D 'D' -#define VK_E 'E' -#define VK_F 'F' -#define VK_G 'G' -#define VK_H 'H' -#define VK_I 'I' -#define VK_J 'J' -#define VK_K 'K' -#define VK_L 'L' -#define VK_M 'M' -#define VK_N 'N' -#define VK_O 'O' -#define VK_P 'P' -#define VK_Q 'Q' -#define VK_R 'R' -#define VK_S 'S' -#define VK_T 'T' -#define VK_U 'U' -#define VK_V 'V' -#define VK_W 'W' -#define VK_X 'X' -#define VK_Y 'Y' -#define VK_Z 'Z' +#define VK_0 '0' +#define VK_1 '1' +#define VK_2 '2' +#define VK_3 '3' +#define VK_4 '4' +#define VK_5 '5' +#define VK_6 '6' +#define VK_7 '7' +#define VK_8 '8' +#define VK_9 '9' +#define VK_A 'A' +#define VK_B 'B' +#define VK_C 'C' +#define VK_D 'D' +#define VK_E 'E' +#define VK_F 'F' +#define VK_G 'G' +#define VK_H 'H' +#define VK_I 'I' +#define VK_J 'J' +#define VK_K 'K' +#define VK_L 'L' +#define VK_M 'M' +#define VK_N 'N' +#define VK_O 'O' +#define VK_P 'P' +#define VK_Q 'Q' +#define VK_R 'R' +#define VK_S 'S' +#define VK_T 'T' +#define VK_U 'U' +#define VK_V 'V' +#define VK_W 'W' +#define VK_X 'X' +#define VK_Y 'Y' +#define VK_Z 'Z' #endif /* VK_0 */ /* These keys haven't been defined, but were experimentally determined */ -#define VK_SEMICOLON 0xBA -#define VK_EQUALS 0xBB -#define VK_COMMA 0xBC -#define VK_MINUS 0xBD -#define VK_PERIOD 0xBE -#define VK_SLASH 0xBF -#define VK_GRAVE 0xC0 -#define VK_LBRACKET 0xDB -#define VK_BACKSLASH 0xDC -#define VK_RBRACKET 0xDD -#define VK_APOSTROPHE 0xDE -#define VK_BACKTICK 0xDF -#define VK_OEM_102 0xE2 +#define VK_SEMICOLON 0xBA +#define VK_EQUALS 0xBB +#define VK_COMMA 0xBC +#define VK_MINUS 0xBD +#define VK_PERIOD 0xBE +#define VK_SLASH 0xBF +#define VK_GRAVE 0xC0 +#define VK_LBRACKET 0xDB +#define VK_BACKSLASH 0xDC +#define VK_RBRACKET 0xDD +#define VK_APOSTROPHE 0xDE +#define VK_BACKTICK 0xDF +#define VK_OEM_102 0xE2 /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/windows/SDL_windowsclipboard.c b/src/video/windows/SDL_windowsclipboard.c index 4f0c87a81..83bf0caa3 100644 --- a/src/video/windows/SDL_windowsclipboard.c +++ b/src/video/windows/SDL_windowsclipboard.c @@ -137,7 +137,7 @@ WIN_HasClipboardText(_THIS) if (text) { result = (SDL_strlen(text)>0) ? SDL_TRUE : SDL_FALSE; SDL_free(text); - } + } return result; } diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c index f38429532..b30b8364b 100644 --- a/src/video/windows/SDL_windowsevents.c +++ b/src/video/windows/SDL_windowsevents.c @@ -36,7 +36,7 @@ /*#define WMMSG_DEBUG*/ #ifdef WMMSG_DEBUG -#include +#include #include "wmmsg.h" #endif @@ -46,7 +46,7 @@ #define VK_ENTER 10 /* Keypad Enter ... no VKEY defined? */ #ifndef VK_OEM_NEC_EQUAL -#define VK_OEM_NEC_EQUAL 0x92 +#define VK_OEM_NEC_EQUAL 0x92 #endif /* Make sure XBUTTON stuff is defined that isn't in older Platform SDKs... */ @@ -66,192 +66,192 @@ #define WM_TOUCH 0x0240 #endif -static SDL_Scancode +static SDL_Scancode WindowsScanCodeToSDLScanCode( LPARAM lParam, WPARAM wParam ) { - SDL_Scancode code; - char bIsExtended; - int nScanCode = ( lParam >> 16 ) & 0xFF; - - /* 0x45 here to work around both pause and numlock sharing the same scancode, so use the VK key to tell them apart */ - if ( nScanCode == 0 || nScanCode == 0x45 ) - { - switch( wParam ) - { - case VK_CLEAR: return SDL_SCANCODE_CLEAR; - case VK_MODECHANGE: return SDL_SCANCODE_MODE; - case VK_SELECT: return SDL_SCANCODE_SELECT; - case VK_EXECUTE: return SDL_SCANCODE_EXECUTE; - case VK_HELP: return SDL_SCANCODE_HELP; - case VK_PAUSE: return SDL_SCANCODE_PAUSE; - case VK_NUMLOCK: return SDL_SCANCODE_NUMLOCKCLEAR; - - case VK_F13: return SDL_SCANCODE_F13; - case VK_F14: return SDL_SCANCODE_F14; - case VK_F15: return SDL_SCANCODE_F15; - case VK_F16: return SDL_SCANCODE_F16; - case VK_F17: return SDL_SCANCODE_F17; - case VK_F18: return SDL_SCANCODE_F18; - case VK_F19: return SDL_SCANCODE_F19; - case VK_F20: return SDL_SCANCODE_F20; - case VK_F21: return SDL_SCANCODE_F21; - case VK_F22: return SDL_SCANCODE_F22; - case VK_F23: return SDL_SCANCODE_F23; - case VK_F24: return SDL_SCANCODE_F24; - - case VK_OEM_NEC_EQUAL: return SDL_SCANCODE_KP_EQUALS; - case VK_BROWSER_BACK: return SDL_SCANCODE_AC_BACK; - case VK_BROWSER_FORWARD: return SDL_SCANCODE_AC_FORWARD; - case VK_BROWSER_REFRESH: return SDL_SCANCODE_AC_REFRESH; - case VK_BROWSER_STOP: return SDL_SCANCODE_AC_STOP; - case VK_BROWSER_SEARCH: return SDL_SCANCODE_AC_SEARCH; - case VK_BROWSER_FAVORITES: return SDL_SCANCODE_AC_BOOKMARKS; - case VK_BROWSER_HOME: return SDL_SCANCODE_AC_HOME; - case VK_VOLUME_MUTE: return SDL_SCANCODE_AUDIOMUTE; - case VK_VOLUME_DOWN: return SDL_SCANCODE_VOLUMEDOWN; - case VK_VOLUME_UP: return SDL_SCANCODE_VOLUMEUP; - - case VK_MEDIA_NEXT_TRACK: return SDL_SCANCODE_AUDIONEXT; - case VK_MEDIA_PREV_TRACK: return SDL_SCANCODE_AUDIOPREV; - case VK_MEDIA_STOP: return SDL_SCANCODE_AUDIOSTOP; - case VK_MEDIA_PLAY_PAUSE: return SDL_SCANCODE_AUDIOPLAY; - case VK_LAUNCH_MAIL: return SDL_SCANCODE_MAIL; - case VK_LAUNCH_MEDIA_SELECT: return SDL_SCANCODE_MEDIASELECT; - - case VK_OEM_102: return SDL_SCANCODE_NONUSBACKSLASH; - - case VK_ATTN: return SDL_SCANCODE_SYSREQ; - case VK_CRSEL: return SDL_SCANCODE_CRSEL; - case VK_EXSEL: return SDL_SCANCODE_EXSEL; - case VK_OEM_CLEAR: return SDL_SCANCODE_CLEAR; - - case VK_LAUNCH_APP1: return SDL_SCANCODE_APP1; - case VK_LAUNCH_APP2: return SDL_SCANCODE_APP2; - - default: return SDL_SCANCODE_UNKNOWN; - } - } - - if ( nScanCode > 127 ) - return SDL_SCANCODE_UNKNOWN; - - code = windows_scancode_table[nScanCode]; - - bIsExtended = ( lParam & ( 1 << 24 ) ) != 0; - if ( !bIsExtended ) - { - switch ( code ) - { - case SDL_SCANCODE_HOME: - return SDL_SCANCODE_KP_7; - case SDL_SCANCODE_UP: - return SDL_SCANCODE_KP_8; - case SDL_SCANCODE_PAGEUP: - return SDL_SCANCODE_KP_9; - case SDL_SCANCODE_LEFT: - return SDL_SCANCODE_KP_4; - case SDL_SCANCODE_RIGHT: - return SDL_SCANCODE_KP_6; - case SDL_SCANCODE_END: - return SDL_SCANCODE_KP_1; - case SDL_SCANCODE_DOWN: - return SDL_SCANCODE_KP_2; - case SDL_SCANCODE_PAGEDOWN: - return SDL_SCANCODE_KP_3; - case SDL_SCANCODE_INSERT: - return SDL_SCANCODE_KP_0; - case SDL_SCANCODE_DELETE: - return SDL_SCANCODE_KP_PERIOD; - case SDL_SCANCODE_PRINTSCREEN: - return SDL_SCANCODE_KP_MULTIPLY; - default: - break; - } - } - else - { - switch ( code ) - { - case SDL_SCANCODE_RETURN: - return SDL_SCANCODE_KP_ENTER; - case SDL_SCANCODE_LALT: - return SDL_SCANCODE_RALT; - case SDL_SCANCODE_LCTRL: - return SDL_SCANCODE_RCTRL; - case SDL_SCANCODE_SLASH: - return SDL_SCANCODE_KP_DIVIDE; - case SDL_SCANCODE_CAPSLOCK: - return SDL_SCANCODE_KP_PLUS; + SDL_Scancode code; + char bIsExtended; + int nScanCode = ( lParam >> 16 ) & 0xFF; + + /* 0x45 here to work around both pause and numlock sharing the same scancode, so use the VK key to tell them apart */ + if ( nScanCode == 0 || nScanCode == 0x45 ) + { + switch( wParam ) + { + case VK_CLEAR: return SDL_SCANCODE_CLEAR; + case VK_MODECHANGE: return SDL_SCANCODE_MODE; + case VK_SELECT: return SDL_SCANCODE_SELECT; + case VK_EXECUTE: return SDL_SCANCODE_EXECUTE; + case VK_HELP: return SDL_SCANCODE_HELP; + case VK_PAUSE: return SDL_SCANCODE_PAUSE; + case VK_NUMLOCK: return SDL_SCANCODE_NUMLOCKCLEAR; + + case VK_F13: return SDL_SCANCODE_F13; + case VK_F14: return SDL_SCANCODE_F14; + case VK_F15: return SDL_SCANCODE_F15; + case VK_F16: return SDL_SCANCODE_F16; + case VK_F17: return SDL_SCANCODE_F17; + case VK_F18: return SDL_SCANCODE_F18; + case VK_F19: return SDL_SCANCODE_F19; + case VK_F20: return SDL_SCANCODE_F20; + case VK_F21: return SDL_SCANCODE_F21; + case VK_F22: return SDL_SCANCODE_F22; + case VK_F23: return SDL_SCANCODE_F23; + case VK_F24: return SDL_SCANCODE_F24; + + case VK_OEM_NEC_EQUAL: return SDL_SCANCODE_KP_EQUALS; + case VK_BROWSER_BACK: return SDL_SCANCODE_AC_BACK; + case VK_BROWSER_FORWARD: return SDL_SCANCODE_AC_FORWARD; + case VK_BROWSER_REFRESH: return SDL_SCANCODE_AC_REFRESH; + case VK_BROWSER_STOP: return SDL_SCANCODE_AC_STOP; + case VK_BROWSER_SEARCH: return SDL_SCANCODE_AC_SEARCH; + case VK_BROWSER_FAVORITES: return SDL_SCANCODE_AC_BOOKMARKS; + case VK_BROWSER_HOME: return SDL_SCANCODE_AC_HOME; + case VK_VOLUME_MUTE: return SDL_SCANCODE_AUDIOMUTE; + case VK_VOLUME_DOWN: return SDL_SCANCODE_VOLUMEDOWN; + case VK_VOLUME_UP: return SDL_SCANCODE_VOLUMEUP; + + case VK_MEDIA_NEXT_TRACK: return SDL_SCANCODE_AUDIONEXT; + case VK_MEDIA_PREV_TRACK: return SDL_SCANCODE_AUDIOPREV; + case VK_MEDIA_STOP: return SDL_SCANCODE_AUDIOSTOP; + case VK_MEDIA_PLAY_PAUSE: return SDL_SCANCODE_AUDIOPLAY; + case VK_LAUNCH_MAIL: return SDL_SCANCODE_MAIL; + case VK_LAUNCH_MEDIA_SELECT: return SDL_SCANCODE_MEDIASELECT; + + case VK_OEM_102: return SDL_SCANCODE_NONUSBACKSLASH; + + case VK_ATTN: return SDL_SCANCODE_SYSREQ; + case VK_CRSEL: return SDL_SCANCODE_CRSEL; + case VK_EXSEL: return SDL_SCANCODE_EXSEL; + case VK_OEM_CLEAR: return SDL_SCANCODE_CLEAR; + + case VK_LAUNCH_APP1: return SDL_SCANCODE_APP1; + case VK_LAUNCH_APP2: return SDL_SCANCODE_APP2; + + default: return SDL_SCANCODE_UNKNOWN; + } + } + + if ( nScanCode > 127 ) + return SDL_SCANCODE_UNKNOWN; + + code = windows_scancode_table[nScanCode]; + + bIsExtended = ( lParam & ( 1 << 24 ) ) != 0; + if ( !bIsExtended ) + { + switch ( code ) + { + case SDL_SCANCODE_HOME: + return SDL_SCANCODE_KP_7; + case SDL_SCANCODE_UP: + return SDL_SCANCODE_KP_8; + case SDL_SCANCODE_PAGEUP: + return SDL_SCANCODE_KP_9; + case SDL_SCANCODE_LEFT: + return SDL_SCANCODE_KP_4; + case SDL_SCANCODE_RIGHT: + return SDL_SCANCODE_KP_6; + case SDL_SCANCODE_END: + return SDL_SCANCODE_KP_1; + case SDL_SCANCODE_DOWN: + return SDL_SCANCODE_KP_2; + case SDL_SCANCODE_PAGEDOWN: + return SDL_SCANCODE_KP_3; + case SDL_SCANCODE_INSERT: + return SDL_SCANCODE_KP_0; + case SDL_SCANCODE_DELETE: + return SDL_SCANCODE_KP_PERIOD; + case SDL_SCANCODE_PRINTSCREEN: + return SDL_SCANCODE_KP_MULTIPLY; default: break; - } - } + } + } + else + { + switch ( code ) + { + case SDL_SCANCODE_RETURN: + return SDL_SCANCODE_KP_ENTER; + case SDL_SCANCODE_LALT: + return SDL_SCANCODE_RALT; + case SDL_SCANCODE_LCTRL: + return SDL_SCANCODE_RCTRL; + case SDL_SCANCODE_SLASH: + return SDL_SCANCODE_KP_DIVIDE; + case SDL_SCANCODE_CAPSLOCK: + return SDL_SCANCODE_KP_PLUS; + default: + break; + } + } - return code; + return code; } -void +void WIN_CheckWParamMouseButton( SDL_bool bwParamMousePressed, SDL_bool bSDLMousePressed, SDL_WindowData *data, Uint8 button ) { - if ( bwParamMousePressed && !bSDLMousePressed ) - { - SDL_SendMouseButton(data->window, 0, SDL_PRESSED, button); - } - else if ( !bwParamMousePressed && bSDLMousePressed ) - { - SDL_SendMouseButton(data->window, 0, SDL_RELEASED, button); - } + if ( bwParamMousePressed && !bSDLMousePressed ) + { + SDL_SendMouseButton(data->window, 0, SDL_PRESSED, button); + } + else if ( !bwParamMousePressed && bSDLMousePressed ) + { + SDL_SendMouseButton(data->window, 0, SDL_RELEASED, button); + } } /* * Some windows systems fail to send a WM_LBUTTONDOWN sometimes, but each mouse move contains the current button state also * so this funciton reconciles our view of the world with the current buttons reported by windows */ -void +void WIN_CheckWParamMouseButtons( WPARAM wParam, SDL_WindowData *data ) { - if ( wParam != data->mouse_button_flags ) - { - Uint32 mouseFlags = SDL_GetMouseState( NULL, NULL ); - WIN_CheckWParamMouseButton( (wParam & MK_LBUTTON), (mouseFlags & SDL_BUTTON_LMASK), data, SDL_BUTTON_LEFT ); - WIN_CheckWParamMouseButton( (wParam & MK_MBUTTON), (mouseFlags & SDL_BUTTON_MMASK), data, SDL_BUTTON_MIDDLE ); - WIN_CheckWParamMouseButton( (wParam & MK_RBUTTON), (mouseFlags & SDL_BUTTON_RMASK), data, SDL_BUTTON_RIGHT ); - WIN_CheckWParamMouseButton( (wParam & MK_XBUTTON1), (mouseFlags & SDL_BUTTON_X1MASK), data, SDL_BUTTON_X1 ); - WIN_CheckWParamMouseButton( (wParam & MK_XBUTTON2), (mouseFlags & SDL_BUTTON_X2MASK), data, SDL_BUTTON_X2 ); - data->mouse_button_flags = wParam; - } + if ( wParam != data->mouse_button_flags ) + { + Uint32 mouseFlags = SDL_GetMouseState( NULL, NULL ); + WIN_CheckWParamMouseButton( (wParam & MK_LBUTTON), (mouseFlags & SDL_BUTTON_LMASK), data, SDL_BUTTON_LEFT ); + WIN_CheckWParamMouseButton( (wParam & MK_MBUTTON), (mouseFlags & SDL_BUTTON_MMASK), data, SDL_BUTTON_MIDDLE ); + WIN_CheckWParamMouseButton( (wParam & MK_RBUTTON), (mouseFlags & SDL_BUTTON_RMASK), data, SDL_BUTTON_RIGHT ); + WIN_CheckWParamMouseButton( (wParam & MK_XBUTTON1), (mouseFlags & SDL_BUTTON_X1MASK), data, SDL_BUTTON_X1 ); + WIN_CheckWParamMouseButton( (wParam & MK_XBUTTON2), (mouseFlags & SDL_BUTTON_X2MASK), data, SDL_BUTTON_X2 ); + data->mouse_button_flags = wParam; + } } -void +void WIN_CheckRawMouseButtons( ULONG rawButtons, SDL_WindowData *data ) { - if ( rawButtons != data->mouse_button_flags ) - { - Uint32 mouseFlags = SDL_GetMouseState( NULL, NULL ); - if ( (rawButtons & RI_MOUSE_BUTTON_1_DOWN) ) - WIN_CheckWParamMouseButton( (rawButtons & RI_MOUSE_BUTTON_1_DOWN), (mouseFlags & SDL_BUTTON_LMASK), data, SDL_BUTTON_LEFT ); - if ( (rawButtons & RI_MOUSE_BUTTON_1_UP) ) - WIN_CheckWParamMouseButton( !(rawButtons & RI_MOUSE_BUTTON_1_UP), (mouseFlags & SDL_BUTTON_LMASK), data, SDL_BUTTON_LEFT ); - if ( (rawButtons & RI_MOUSE_BUTTON_2_DOWN) ) - WIN_CheckWParamMouseButton( (rawButtons & RI_MOUSE_BUTTON_2_DOWN), (mouseFlags & SDL_BUTTON_RMASK), data, SDL_BUTTON_RIGHT ); - if ( (rawButtons & RI_MOUSE_BUTTON_2_UP) ) - WIN_CheckWParamMouseButton( !(rawButtons & RI_MOUSE_BUTTON_2_UP), (mouseFlags & SDL_BUTTON_RMASK), data, SDL_BUTTON_RIGHT ); - if ( (rawButtons & RI_MOUSE_BUTTON_3_DOWN) ) - WIN_CheckWParamMouseButton( (rawButtons & RI_MOUSE_BUTTON_3_DOWN), (mouseFlags & SDL_BUTTON_MMASK), data, SDL_BUTTON_MIDDLE ); - if ( (rawButtons & RI_MOUSE_BUTTON_3_UP) ) - WIN_CheckWParamMouseButton( !(rawButtons & RI_MOUSE_BUTTON_3_UP), (mouseFlags & SDL_BUTTON_MMASK), data, SDL_BUTTON_MIDDLE ); - if ( (rawButtons & RI_MOUSE_BUTTON_4_DOWN) ) - WIN_CheckWParamMouseButton( (rawButtons & RI_MOUSE_BUTTON_4_DOWN), (mouseFlags & SDL_BUTTON_X1MASK), data, SDL_BUTTON_X1 ); - if ( (rawButtons & RI_MOUSE_BUTTON_4_UP) ) - WIN_CheckWParamMouseButton( !(rawButtons & RI_MOUSE_BUTTON_4_UP), (mouseFlags & SDL_BUTTON_X1MASK), data, SDL_BUTTON_X1 ); - if ( (rawButtons & RI_MOUSE_BUTTON_5_DOWN) ) - WIN_CheckWParamMouseButton( (rawButtons & RI_MOUSE_BUTTON_5_DOWN), (mouseFlags & SDL_BUTTON_X2MASK), data, SDL_BUTTON_X2 ); - if ( (rawButtons & RI_MOUSE_BUTTON_5_UP) ) - WIN_CheckWParamMouseButton( !(rawButtons & RI_MOUSE_BUTTON_5_UP), (mouseFlags & SDL_BUTTON_X2MASK), data, SDL_BUTTON_X2 ); - data->mouse_button_flags = rawButtons; - } + if ( rawButtons != data->mouse_button_flags ) + { + Uint32 mouseFlags = SDL_GetMouseState( NULL, NULL ); + if ( (rawButtons & RI_MOUSE_BUTTON_1_DOWN) ) + WIN_CheckWParamMouseButton( (rawButtons & RI_MOUSE_BUTTON_1_DOWN), (mouseFlags & SDL_BUTTON_LMASK), data, SDL_BUTTON_LEFT ); + if ( (rawButtons & RI_MOUSE_BUTTON_1_UP) ) + WIN_CheckWParamMouseButton( !(rawButtons & RI_MOUSE_BUTTON_1_UP), (mouseFlags & SDL_BUTTON_LMASK), data, SDL_BUTTON_LEFT ); + if ( (rawButtons & RI_MOUSE_BUTTON_2_DOWN) ) + WIN_CheckWParamMouseButton( (rawButtons & RI_MOUSE_BUTTON_2_DOWN), (mouseFlags & SDL_BUTTON_RMASK), data, SDL_BUTTON_RIGHT ); + if ( (rawButtons & RI_MOUSE_BUTTON_2_UP) ) + WIN_CheckWParamMouseButton( !(rawButtons & RI_MOUSE_BUTTON_2_UP), (mouseFlags & SDL_BUTTON_RMASK), data, SDL_BUTTON_RIGHT ); + if ( (rawButtons & RI_MOUSE_BUTTON_3_DOWN) ) + WIN_CheckWParamMouseButton( (rawButtons & RI_MOUSE_BUTTON_3_DOWN), (mouseFlags & SDL_BUTTON_MMASK), data, SDL_BUTTON_MIDDLE ); + if ( (rawButtons & RI_MOUSE_BUTTON_3_UP) ) + WIN_CheckWParamMouseButton( !(rawButtons & RI_MOUSE_BUTTON_3_UP), (mouseFlags & SDL_BUTTON_MMASK), data, SDL_BUTTON_MIDDLE ); + if ( (rawButtons & RI_MOUSE_BUTTON_4_DOWN) ) + WIN_CheckWParamMouseButton( (rawButtons & RI_MOUSE_BUTTON_4_DOWN), (mouseFlags & SDL_BUTTON_X1MASK), data, SDL_BUTTON_X1 ); + if ( (rawButtons & RI_MOUSE_BUTTON_4_UP) ) + WIN_CheckWParamMouseButton( !(rawButtons & RI_MOUSE_BUTTON_4_UP), (mouseFlags & SDL_BUTTON_X1MASK), data, SDL_BUTTON_X1 ); + if ( (rawButtons & RI_MOUSE_BUTTON_5_DOWN) ) + WIN_CheckWParamMouseButton( (rawButtons & RI_MOUSE_BUTTON_5_DOWN), (mouseFlags & SDL_BUTTON_X2MASK), data, SDL_BUTTON_X2 ); + if ( (rawButtons & RI_MOUSE_BUTTON_5_UP) ) + WIN_CheckWParamMouseButton( !(rawButtons & RI_MOUSE_BUTTON_5_UP), (mouseFlags & SDL_BUTTON_X2MASK), data, SDL_BUTTON_X2 ); + data->mouse_button_flags = rawButtons; + } } LRESULT CALLBACK @@ -280,8 +280,8 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) } #ifdef WMMSG_DEBUG - { - FILE *log = fopen("wmmsg.txt", "a"); + { + FILE *log = fopen("wmmsg.txt", "a"); fprintf(log, "Received windows message: %p ", hwnd); if (msg > MAX_WMMSG) { fprintf(log, "%d", msg); @@ -314,8 +314,8 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) minimized = HIWORD(wParam); if (!minimized && (LOWORD(wParam) != WA_INACTIVE)) { - Uint32 mouseFlags; - SHORT keyState; + Uint32 mouseFlags; + SHORT keyState; SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_SHOWN, 0, 0); SDL_SendWindowEvent(data->window, @@ -327,40 +327,40 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) if (SDL_GetKeyboardFocus() != data->window) { SDL_SetKeyboardFocus(data->window); } - /* mouse buttons may have changed state here, we need - to resync them, but we will get a WM_MOUSEMOVE right away which will fix - things up if in non raw mode also - */ - mouseFlags = SDL_GetMouseState( NULL, NULL ); - - keyState = GetAsyncKeyState( VK_LBUTTON ); - WIN_CheckWParamMouseButton( ( keyState & 0x8000 ), (mouseFlags & SDL_BUTTON_LMASK), data, SDL_BUTTON_LEFT ); - keyState = GetAsyncKeyState( VK_RBUTTON ); - WIN_CheckWParamMouseButton( ( keyState & 0x8000 ), (mouseFlags & SDL_BUTTON_RMASK), data, SDL_BUTTON_RIGHT ); - keyState = GetAsyncKeyState( VK_MBUTTON ); - WIN_CheckWParamMouseButton( ( keyState & 0x8000 ), (mouseFlags & SDL_BUTTON_MMASK), data, SDL_BUTTON_MIDDLE ); - keyState = GetAsyncKeyState( VK_XBUTTON1 ); - WIN_CheckWParamMouseButton( ( keyState & 0x8000 ), (mouseFlags & SDL_BUTTON_X1MASK), data, SDL_BUTTON_X1 ); - keyState = GetAsyncKeyState( VK_XBUTTON2 ); - WIN_CheckWParamMouseButton( ( keyState & 0x8000 ), (mouseFlags & SDL_BUTTON_X2MASK), data, SDL_BUTTON_X2 ); - data->mouse_button_flags = 0; - - if(SDL_GetMouse()->relative_mode) { - LONG cx, cy; - RECT rect; - GetWindowRect(hwnd, &rect); - - cx = (rect.left + rect.right) / 2; - cy = (rect.top + rect.bottom) / 2; - - /* Make an absurdly small clip rect */ - rect.left = cx-1; - rect.right = cx+1; - rect.top = cy-1; - rect.bottom = cy+1; - - ClipCursor(&rect); - } + /* mouse buttons may have changed state here, we need + to resync them, but we will get a WM_MOUSEMOVE right away which will fix + things up if in non raw mode also + */ + mouseFlags = SDL_GetMouseState( NULL, NULL ); + + keyState = GetAsyncKeyState( VK_LBUTTON ); + WIN_CheckWParamMouseButton( ( keyState & 0x8000 ), (mouseFlags & SDL_BUTTON_LMASK), data, SDL_BUTTON_LEFT ); + keyState = GetAsyncKeyState( VK_RBUTTON ); + WIN_CheckWParamMouseButton( ( keyState & 0x8000 ), (mouseFlags & SDL_BUTTON_RMASK), data, SDL_BUTTON_RIGHT ); + keyState = GetAsyncKeyState( VK_MBUTTON ); + WIN_CheckWParamMouseButton( ( keyState & 0x8000 ), (mouseFlags & SDL_BUTTON_MMASK), data, SDL_BUTTON_MIDDLE ); + keyState = GetAsyncKeyState( VK_XBUTTON1 ); + WIN_CheckWParamMouseButton( ( keyState & 0x8000 ), (mouseFlags & SDL_BUTTON_X1MASK), data, SDL_BUTTON_X1 ); + keyState = GetAsyncKeyState( VK_XBUTTON2 ); + WIN_CheckWParamMouseButton( ( keyState & 0x8000 ), (mouseFlags & SDL_BUTTON_X2MASK), data, SDL_BUTTON_X2 ); + data->mouse_button_flags = 0; + + if(SDL_GetMouse()->relative_mode) { + LONG cx, cy; + RECT rect; + GetWindowRect(hwnd, &rect); + + cx = (rect.left + rect.right) / 2; + cy = (rect.top + rect.bottom) / 2; + + /* Make an absurdly small clip rect */ + rect.left = cx-1; + rect.right = cx+1; + rect.top = cy-1; + rect.bottom = cy+1; + + ClipCursor(&rect); + } /* * FIXME: Update keyboard state @@ -379,65 +379,65 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) returnCode = 0; break; - case WM_MOUSEMOVE: - if( !SDL_GetMouse()->relative_mode ) - SDL_SendMouseMotion(data->window, 0, 0, LOWORD(lParam), HIWORD(lParam)); - /* don't break here, fall through to check the wParam like the button presses */ - case WM_LBUTTONUP: - case WM_RBUTTONUP: - case WM_MBUTTONUP: - case WM_XBUTTONUP: - case WM_LBUTTONDOWN: - case WM_RBUTTONDOWN: - case WM_MBUTTONDOWN: - case WM_XBUTTONDOWN: - if( !SDL_GetMouse()->relative_mode ) - WIN_CheckWParamMouseButtons( wParam, data ); - break; - - case WM_INPUT: - { - HRAWINPUT hRawInput = (HRAWINPUT)lParam; - RAWINPUT inp; - UINT size = sizeof(inp); - - if(!SDL_GetMouse()->relative_mode) - break; - - GetRawInputData(hRawInput, RID_INPUT, &inp, &size, sizeof(RAWINPUTHEADER)); - - /* Mouse data */ - if(inp.header.dwType == RIM_TYPEMOUSE) - { - RAWMOUSE* mouse = &inp.data.mouse; - - if((mouse->usFlags & 0x01) == MOUSE_MOVE_RELATIVE) - { - SDL_SendMouseMotion(data->window, 0, 1, (int)mouse->lLastX, (int)mouse->lLastY); - } - else - { - // synthesize relative moves from the abs position - static SDL_Point initialMousePoint; - if ( initialMousePoint.x == 0 && initialMousePoint.y == 0 ) - { - initialMousePoint.x = mouse->lLastX; - initialMousePoint.y = mouse->lLastY; - } - - SDL_SendMouseMotion(data->window, 0, 1, (int)(mouse->lLastX-initialMousePoint.x), (int)(mouse->lLastY-initialMousePoint.y) ); - - initialMousePoint.x = mouse->lLastX; - initialMousePoint.y = mouse->lLastY; - } - WIN_CheckRawMouseButtons( mouse->usButtonFlags, data ); - } - break; - } + case WM_MOUSEMOVE: + if( !SDL_GetMouse()->relative_mode ) + SDL_SendMouseMotion(data->window, 0, 0, LOWORD(lParam), HIWORD(lParam)); + /* don't break here, fall through to check the wParam like the button presses */ + case WM_LBUTTONUP: + case WM_RBUTTONUP: + case WM_MBUTTONUP: + case WM_XBUTTONUP: + case WM_LBUTTONDOWN: + case WM_RBUTTONDOWN: + case WM_MBUTTONDOWN: + case WM_XBUTTONDOWN: + if( !SDL_GetMouse()->relative_mode ) + WIN_CheckWParamMouseButtons( wParam, data ); + break; + + case WM_INPUT: + { + HRAWINPUT hRawInput = (HRAWINPUT)lParam; + RAWINPUT inp; + UINT size = sizeof(inp); + + if(!SDL_GetMouse()->relative_mode) + break; + + GetRawInputData(hRawInput, RID_INPUT, &inp, &size, sizeof(RAWINPUTHEADER)); + + /* Mouse data */ + if(inp.header.dwType == RIM_TYPEMOUSE) + { + RAWMOUSE* mouse = &inp.data.mouse; + + if((mouse->usFlags & 0x01) == MOUSE_MOVE_RELATIVE) + { + SDL_SendMouseMotion(data->window, 0, 1, (int)mouse->lLastX, (int)mouse->lLastY); + } + else + { + /* synthesize relative moves from the abs position */ + static SDL_Point initialMousePoint; + if ( initialMousePoint.x == 0 && initialMousePoint.y == 0 ) + { + initialMousePoint.x = mouse->lLastX; + initialMousePoint.y = mouse->lLastY; + } + + SDL_SendMouseMotion(data->window, 0, 1, (int)(mouse->lLastX-initialMousePoint.x), (int)(mouse->lLastY-initialMousePoint.y) ); + + initialMousePoint.x = mouse->lLastX; + initialMousePoint.y = mouse->lLastY; + } + WIN_CheckRawMouseButtons( mouse->usButtonFlags, data ); + } + break; + } case WM_MOUSEWHEEL: { - // FIXME: This may need to accumulate deltas up to WHEEL_DELTA + /* FIXME: This may need to accumulate deltas up to WHEEL_DELTA */ short motion = GET_WHEEL_DELTA_WPARAM(wParam) / WHEEL_DELTA; SDL_SendMouseWheel(data->window, 0, 0, motion); @@ -447,14 +447,14 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) #ifdef WM_MOUSELEAVE case WM_MOUSELEAVE: if (SDL_GetMouseFocus() == data->window) { - if (!SDL_GetMouse()->relative_mode) { - POINT cursorPos; - GetCursorPos(&cursorPos); - ScreenToClient(hwnd, &cursorPos); - SDL_SendMouseMotion(data->window, 0, 0, cursorPos.x, cursorPos.y); - } - - SDL_SetMouseFocus(NULL); + if (!SDL_GetMouse()->relative_mode) { + POINT cursorPos; + GetCursorPos(&cursorPos); + ScreenToClient(hwnd, &cursorPos); + SDL_SendMouseMotion(data->window, 0, 0, cursorPos.x, cursorPos.y); + } + + SDL_SetMouseFocus(NULL); } returnCode = 0; break; @@ -463,8 +463,8 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) case WM_SYSKEYDOWN: case WM_KEYDOWN: { - SDL_Scancode code = WindowsScanCodeToSDLScanCode( lParam, wParam ); - if ( code != SDL_SCANCODE_UNKNOWN ) { + SDL_Scancode code = WindowsScanCodeToSDLScanCode( lParam, wParam ); + if ( code != SDL_SCANCODE_UNKNOWN ) { SDL_SendKeyboardKey(SDL_PRESSED, code ); } } @@ -529,7 +529,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) int max_w, max_h; int style; BOOL menu; - BOOL constrain_max_size; + BOOL constrain_max_size; /* If we allow resizing, let the resize happen naturally */ if (SDL_IsShapedWindow(data->window)) @@ -545,7 +545,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) SDL_GetWindowMinimumSize(data->window, &min_w, &min_h); SDL_GetWindowMaximumSize(data->window, &max_w, &max_h); - /* Store in min_w and min_h difference between current size and minimal + /* Store in min_w and min_h difference between current size and minimal size so we don't need to call AdjustWindowRectEx twice */ min_w -= w; min_h -= h; @@ -680,56 +680,56 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) returnCode = 0; break; - case WM_TOUCH: - { - UINT i, num_inputs = LOWORD(wParam); - PTOUCHINPUT inputs = SDL_stack_alloc(TOUCHINPUT, num_inputs); - if (data->videodata->GetTouchInputInfo((HTOUCHINPUT)lParam, num_inputs, inputs, sizeof(TOUCHINPUT))) { - RECT rect; - float x, y; - - if (!GetClientRect(hwnd, &rect) || - (rect.right == rect.left && rect.bottom == rect.top)) { - break; - } - ClientToScreen(hwnd, (LPPOINT) & rect); - ClientToScreen(hwnd, (LPPOINT) & rect + 1); - rect.top *= 100; - rect.left *= 100; - rect.bottom *= 100; - rect.right *= 100; - - for (i = 0; i < num_inputs; ++i) { - PTOUCHINPUT input = &inputs[i]; - - const SDL_TouchID touchId = (SDL_TouchID)input->hSource; - if (!SDL_GetTouch(touchId)) { - if (SDL_AddTouch(touchId, "") < 0) { - continue; - } - } - - // Get the normalized coordinates for the window - x = (float)(input->x - rect.left)/(rect.right - rect.left); - y = (float)(input->y - rect.top)/(rect.bottom - rect.top); - - if (input->dwFlags & TOUCHEVENTF_DOWN) { - SDL_SendTouch(touchId, input->dwID, SDL_TRUE, x, y, 1.0f); - } - if (input->dwFlags & TOUCHEVENTF_MOVE) { - SDL_SendTouchMotion(touchId, input->dwID, x, y, 1.0f); - } - if (input->dwFlags & TOUCHEVENTF_UP) { - SDL_SendTouch(touchId, input->dwID, SDL_FALSE, x, y, 1.0f); - } - } - } - SDL_stack_free(inputs); - - data->videodata->CloseTouchInputHandle((HTOUCHINPUT)lParam); - return 0; - } - break; + case WM_TOUCH: + { + UINT i, num_inputs = LOWORD(wParam); + PTOUCHINPUT inputs = SDL_stack_alloc(TOUCHINPUT, num_inputs); + if (data->videodata->GetTouchInputInfo((HTOUCHINPUT)lParam, num_inputs, inputs, sizeof(TOUCHINPUT))) { + RECT rect; + float x, y; + + if (!GetClientRect(hwnd, &rect) || + (rect.right == rect.left && rect.bottom == rect.top)) { + break; + } + ClientToScreen(hwnd, (LPPOINT) & rect); + ClientToScreen(hwnd, (LPPOINT) & rect + 1); + rect.top *= 100; + rect.left *= 100; + rect.bottom *= 100; + rect.right *= 100; + + for (i = 0; i < num_inputs; ++i) { + PTOUCHINPUT input = &inputs[i]; + + const SDL_TouchID touchId = (SDL_TouchID)input->hSource; + if (!SDL_GetTouch(touchId)) { + if (SDL_AddTouch(touchId, "") < 0) { + continue; + } + } + + /* Get the normalized coordinates for the window */ + x = (float)(input->x - rect.left)/(rect.right - rect.left); + y = (float)(input->y - rect.top)/(rect.bottom - rect.top); + + if (input->dwFlags & TOUCHEVENTF_DOWN) { + SDL_SendTouch(touchId, input->dwID, SDL_TRUE, x, y, 1.0f); + } + if (input->dwFlags & TOUCHEVENTF_MOVE) { + SDL_SendTouchMotion(touchId, input->dwID, x, y, 1.0f); + } + if (input->dwFlags & TOUCHEVENTF_UP) { + SDL_SendTouch(touchId, input->dwID, SDL_FALSE, x, y, 1.0f); + } + } + } + SDL_stack_free(inputs); + + data->videodata->CloseTouchInputHandle((HTOUCHINPUT)lParam); + return 0; + } + break; case WM_DROPFILES: { diff --git a/src/video/windows/SDL_windowsframebuffer.c b/src/video/windows/SDL_windowsframebuffer.c index 5a2a9ef00..93af4c5e8 100644 --- a/src/video/windows/SDL_windowsframebuffer.c +++ b/src/video/windows/SDL_windowsframebuffer.c @@ -77,7 +77,7 @@ int WIN_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, voi /* Fill in the size information */ *pitch = (((window->w * SDL_BYTESPERPIXEL(*format)) + 3) & ~3); info->bmiHeader.biWidth = window->w; - info->bmiHeader.biHeight = -window->h; /* negative for topdown bitmap */ + info->bmiHeader.biHeight = -window->h; /* negative for topdown bitmap */ info->bmiHeader.biSizeImage = window->h * (*pitch); data->mdc = CreateCompatibleDC(data->hdc); diff --git a/src/video/windows/SDL_windowskeyboard.c b/src/video/windows/SDL_windowskeyboard.c index 74f078f86..5bb9d4217 100644 --- a/src/video/windows/SDL_windowskeyboard.c +++ b/src/video/windows/SDL_windowskeyboard.c @@ -187,12 +187,12 @@ void WIN_SetTextInputRect(_THIS, SDL_Rect *rect) { SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; - + if (!rect) { SDL_InvalidParamError("rect"); return; } - + videodata->ime_rect = *rect; } @@ -1031,7 +1031,7 @@ STDMETHODIMP UIElementSink_BeginUIElement(TSFSink *sink, DWORD dwUIElementId, BO } preading->lpVtbl->Release(preading); } - else if (SUCCEEDED(element->lpVtbl->QueryInterface(element, &IID_ITfCandidateListUIElement, (LPVOID *)&pcandlist))) { + else if (SUCCEEDED(element->lpVtbl->QueryInterface(element, &IID_ITfCandidateListUIElement, (LPVOID *)&pcandlist))) { videodata->ime_candref++; UILess_GetCandidateList(videodata, pcandlist); pcandlist->lpVtbl->Release(pcandlist); @@ -1058,7 +1058,7 @@ STDMETHODIMP UIElementSink_UpdateUIElement(TSFSink *sink, DWORD dwUIElementId) } preading->lpVtbl->Release(preading); } - else if (SUCCEEDED(element->lpVtbl->QueryInterface(element, &IID_ITfCandidateListUIElement, (LPVOID *)&pcandlist))) { + else if (SUCCEEDED(element->lpVtbl->QueryInterface(element, &IID_ITfCandidateListUIElement, (LPVOID *)&pcandlist))) { UILess_GetCandidateList(videodata, pcandlist); pcandlist->lpVtbl->Release(pcandlist); } @@ -1512,7 +1512,7 @@ void IME_Present(SDL_VideoData *videodata) if (videodata->ime_dirty) IME_Render(videodata); - // FIXME: Need to show the IME bitmap + /* FIXME: Need to show the IME bitmap */ } #endif /* SDL_DISABLE_WINDOWS_IME */ diff --git a/src/video/windows/SDL_windowsmessagebox.c b/src/video/windows/SDL_windowsmessagebox.c index 18504cb3c..bbe79237f 100644 --- a/src/video/windows/SDL_windowsmessagebox.c +++ b/src/video/windows/SDL_windowsmessagebox.c @@ -36,28 +36,28 @@ typedef struct { - WORD dlgVer; - WORD signature; - DWORD helpID; - DWORD exStyle; - DWORD style; - WORD cDlgItems; - short x; - short y; - short cx; - short cy; + WORD dlgVer; + WORD signature; + DWORD helpID; + DWORD exStyle; + DWORD style; + WORD cDlgItems; + short x; + short y; + short cx; + short cy; } DLGTEMPLATEEX; typedef struct { - DWORD helpID; - DWORD exStyle; - DWORD style; - short x; - short y; - short cx; - short cy; - DWORD id; + DWORD helpID; + DWORD exStyle; + DWORD style; + short x; + short y; + short cx; + short cy; + DWORD id; } DLGITEMTEMPLATEEX; #pragma pack(pop) @@ -76,7 +76,7 @@ static INT_PTR MessageBoxDialogProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPA switch ( iMessage ) { case WM_COMMAND: /* Return the ID of the button that was pushed */ - EndDialog(hDlg, LOWORD(wParam)); + EndDialog(hDlg, LOWORD(wParam)); return TRUE; default: @@ -108,7 +108,7 @@ static SDL_bool ExpandDialogSpace(WIN_DialogData *dialog, size_t space) } return SDL_TRUE; } - + static SDL_bool AlignDialogData(WIN_DialogData *dialog, size_t size) { size_t padding = (dialog->used % size); @@ -166,7 +166,7 @@ static int s_BaseUnitsX; static int s_BaseUnitsY; static void Vec2ToDLU(short *x, short *y) { - SDL_assert(s_BaseUnitsX != 0); // we init in WIN_ShowMessageBox(), which is the only public function... + SDL_assert(s_BaseUnitsX != 0); /* we init in WIN_ShowMessageBox(), which is the only public function... */ *x = MulDiv(*x, 4, s_BaseUnitsX); *y = MulDiv(*y, 8, s_BaseUnitsY); @@ -265,37 +265,37 @@ static WIN_DialogData *CreateDialogData(int w, int h, const char *caption) return NULL; } - // No menu + /* No menu */ WordToPass = 0; if (!AddDialogData(dialog, &WordToPass, 2)) { FreeDialogData(dialog); return NULL; } - // No custom class + /* No custom class */ if (!AddDialogData(dialog, &WordToPass, 2)) { FreeDialogData(dialog); return NULL; } - // title + /* title */ if (!AddDialogString(dialog, caption)) { FreeDialogData(dialog); return NULL; } - // Font stuff + /* Font stuff */ { - // - // We want to use the system messagebox font. - // + /* + * We want to use the system messagebox font. + */ BYTE ToPass; - + NONCLIENTMETRICSA NCM; NCM.cbSize = sizeof(NCM); SystemParametersInfoA(SPI_GETNONCLIENTMETRICS, 0, &NCM, 0); - - // Font size - convert to logical font size for dialog parameter. + + /* Font size - convert to logical font size for dialog parameter. */ { HDC ScreenDC = GetDC(0); WordToPass = (WORD)(-72 * NCM.lfMessageFont.lfHeight / GetDeviceCaps(ScreenDC, LOGPIXELSY)); @@ -307,28 +307,28 @@ static WIN_DialogData *CreateDialogData(int w, int h, const char *caption) return NULL; } - // Font weight + /* Font weight */ WordToPass = (WORD)NCM.lfMessageFont.lfWeight; if (!AddDialogData(dialog, &WordToPass, 2)) { FreeDialogData(dialog); return NULL; } - // italic? + /* italic? */ ToPass = NCM.lfMessageFont.lfItalic; if (!AddDialogData(dialog, &ToPass, 1)) { FreeDialogData(dialog); return NULL; } - // charset? + /* charset? */ ToPass = NCM.lfMessageFont.lfCharSet; if (!AddDialogData(dialog, &ToPass, 1)) { FreeDialogData(dialog); return NULL; } - // font typeface. + /* font typeface. */ if (!AddDialogString(dialog, NCM.lfMessageFont.lfFaceName)) { FreeDialogData(dialog); return NULL; @@ -355,44 +355,44 @@ WIN_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) const int ButtonHeight = 26; const int TextMargin = 16; const int ButtonMargin = 12; - - - // Jan 25th, 2013 - dant@fleetsa.com - // - // - // I've tried to make this more reasonable, but I've run in to a lot - // of nonsense. - // - // The original issue is the code was written in pixels and not - // dialog units (DLUs). All DialogBox functions use DLUs, which - // vary based on the selected font (yay). - // - // According to MSDN, the most reliable way to convert is via - // MapDialogUnits, which requires an HWND, which we don't have - // at time of template creation. - // - // We do however have: - // The system font (DLU width 8 for me) - // The font we select for the dialog (DLU width 6 for me) - // - // Based on experimentation, *neither* of these return the value - // actually used. Stepping in to MapDialogUnits(), the conversion - // is fairly clear, and uses 7 for me. - // - // As a result, some of this is hacky to ensure the sizing is - // somewhat correct. - // - // Honestly, a long term solution is to use CreateWindow, not CreateDialog. - // - - // - // In order to get text dimensions we need to have a DC with the desired font. - // I'm assuming a dialog box in SDL is rare enough we can to the create. - // + + + /* Jan 25th, 2013 - dant@fleetsa.com + * + * + * I've tried to make this more reasonable, but I've run in to a lot + * of nonsense. + * + * The original issue is the code was written in pixels and not + * dialog units (DLUs). All DialogBox functions use DLUs, which + * vary based on the selected font (yay). + * + * According to MSDN, the most reliable way to convert is via + * MapDialogUnits, which requires an HWND, which we don't have + * at time of template creation. + * + * We do however have: + * The system font (DLU width 8 for me) + * The font we select for the dialog (DLU width 6 for me) + * + * Based on experimentation, *neither* of these return the value + * actually used. Stepping in to MapDialogUnits(), the conversion + * is fairly clear, and uses 7 for me. + * + * As a result, some of this is hacky to ensure the sizing is + * somewhat correct. + * + * Honestly, a long term solution is to use CreateWindow, not CreateDialog. + * + + * + * In order to get text dimensions we need to have a DC with the desired font. + * I'm assuming a dialog box in SDL is rare enough we can to the create. + */ HDC FontDC = CreateCompatibleDC(0); - + { - // Create a duplicate of the font used in system message boxes. + /* Create a duplicate of the font used in system message boxes. */ LOGFONT lf; NONCLIENTMETRICS NCM; NCM.cbSize = sizeof(NCM); @@ -401,40 +401,40 @@ WIN_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) DialogFont = CreateFontIndirect(&lf); } - // Select the font in to our DC + /* Select the font in to our DC */ SelectObject(FontDC, DialogFont); { - // Get the metrics to try and figure our DLU conversion. + /* Get the metrics to try and figure our DLU conversion. */ GetTextMetrics(FontDC, &TM); s_BaseUnitsX = TM.tmAveCharWidth + 1; s_BaseUnitsY = TM.tmHeight; } - - // Measure the *pixel* size of the string. + + /* Measure the *pixel* size of the string. */ wmessage = WIN_UTF8ToString(messageboxdata->message); SDL_zero(TextSize); Size.cx = DrawText(FontDC, wmessage, -1, &TextSize, DT_CALCRECT); - // Add some padding for hangs, etc. + /* Add some padding for hangs, etc. */ TextSize.right += 2; TextSize.bottom += 2; - // Done with the DC, and the string + /* Done with the DC, and the string */ DeleteDC(FontDC); SDL_free(wmessage); - // Increase the size of the dialog by some border spacing around the text. + /* Increase the size of the dialog by some border spacing around the text. */ Size.cx = TextSize.right - TextSize.left; Size.cy = TextSize.bottom - TextSize.top; Size.cx += TextMargin * 2; Size.cy += TextMargin * 2; - // Ensure the size is wide enough for all of the buttons. + /* Ensure the size is wide enough for all of the buttons. */ if (Size.cx < messageboxdata->numbuttons * (ButtonWidth + ButtonMargin) + ButtonMargin) Size.cx = messageboxdata->numbuttons * (ButtonWidth + ButtonMargin) + ButtonMargin; - // Add vertical space for the buttons and border. + /* Add vertical space for the buttons and border. */ Size.cy += ButtonHeight + TextMargin; dialog = CreateDialogData(Size.cx, Size.cy, messageboxdata->title); @@ -447,7 +447,7 @@ WIN_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) return -1; } - // Align the buttons to the right/bottom. + /* Align the buttons to the right/bottom. */ x = Size.cx - ButtonWidth - ButtonMargin; y = Size.cy - ButtonHeight - ButtonMargin; for (i = 0; i < messageboxdata->numbuttons; ++i) { diff --git a/src/video/windows/SDL_windowsmouse.c b/src/video/windows/SDL_windowsmouse.c index d762bdf38..d61c8b6bb 100644 --- a/src/video/windows/SDL_windowsmouse.c +++ b/src/video/windows/SDL_windowsmouse.c @@ -180,44 +180,44 @@ static int WIN_SetRelativeMouseMode(SDL_bool enabled) { RAWINPUTDEVICE rawMouse = { 0x01, 0x02, 0, NULL }; /* Mouse: UsagePage = 1, Usage = 2 */ - HWND hWnd; - hWnd = GetActiveWindow(); + HWND hWnd; + hWnd = GetActiveWindow(); - rawMouse.hwndTarget = hWnd; - if(!enabled) { - rawMouse.dwFlags |= RIDEV_REMOVE; - rawMouse.hwndTarget = NULL; - } + rawMouse.hwndTarget = hWnd; + if(!enabled) { + rawMouse.dwFlags |= RIDEV_REMOVE; + rawMouse.hwndTarget = NULL; + } - /* (Un)register raw input for mice */ - if(RegisterRawInputDevices(&rawMouse, 1, sizeof(RAWINPUTDEVICE)) == FALSE) { + /* (Un)register raw input for mice */ + if(RegisterRawInputDevices(&rawMouse, 1, sizeof(RAWINPUTDEVICE)) == FALSE) { - /* Only return an error when registering. If we unregister and fail, then - it's probably that we unregistered twice. That's OK. */ - if(enabled) { - return SDL_Unsupported(); - } - } + /* Only return an error when registering. If we unregister and fail, then + it's probably that we unregistered twice. That's OK. */ + if(enabled) { + return SDL_Unsupported(); + } + } - if(enabled) { - LONG cx, cy; - RECT rect; - GetWindowRect(hWnd, &rect); + if(enabled) { + LONG cx, cy; + RECT rect; + GetWindowRect(hWnd, &rect); - cx = (rect.left + rect.right) / 2; - cy = (rect.top + rect.bottom) / 2; + cx = (rect.left + rect.right) / 2; + cy = (rect.top + rect.bottom) / 2; - /* Make an absurdly small clip rect */ - rect.left = cx-1; - rect.right = cx+1; - rect.top = cy-1; - rect.bottom = cy+1; + /* Make an absurdly small clip rect */ + rect.left = cx-1; + rect.right = cx+1; + rect.top = cy-1; + rect.bottom = cy+1; - ClipCursor(&rect); - } - else - ClipCursor(NULL); + ClipCursor(&rect); + } + else + ClipCursor(NULL); return 0; } @@ -228,7 +228,7 @@ WIN_InitMouse(_THIS) SDL_Mouse *mouse = SDL_GetMouse(); mouse->CreateCursor = WIN_CreateCursor; - mouse->CreateSystemCursor = WIN_CreateSystemCursor; + mouse->CreateSystemCursor = WIN_CreateSystemCursor; mouse->ShowCursor = WIN_ShowCursor; mouse->FreeCursor = WIN_FreeCursor; mouse->WarpMouse = WIN_WarpMouse; diff --git a/src/video/windows/SDL_windowsopengl.c b/src/video/windows/SDL_windowsopengl.c index 97cbaffc4..573b08796 100644 --- a/src/video/windows/SDL_windowsopengl.c +++ b/src/video/windows/SDL_windowsopengl.c @@ -503,7 +503,7 @@ WIN_GL_SetupWindow(_THIS, SDL_Window * window) } if (!pixel_format && _this->gl_config.accelerated != 1) { iAttr[-1] = WGL_NO_ACCELERATION_ARB; - pixel_format = WIN_GL_ChoosePixelFormatARB(_this, iAttribs, fAttribs); + pixel_format = WIN_GL_ChoosePixelFormatARB(_this, iAttribs, fAttribs); } if (!pixel_format) { pixel_format = WIN_GL_ChoosePixelFormat(hdc, &pfd); @@ -530,13 +530,13 @@ WIN_GL_CreateContext(_THIS, SDL_Window * window) } if (_this->gl_config.major_version < 3 && - _this->gl_config.profile_mask == 0 && - _this->gl_config.flags == 0) { + _this->gl_config.profile_mask == 0 && + _this->gl_config.flags == 0) { /* Create legacy context */ context = _this->gl_data->wglCreateContext(hdc); - if( share_context != 0 ) { + if( share_context != 0 ) { _this->gl_data->wglShareLists(share_context, context); - } + } } else { PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB; HGLRC temp_context = _this->gl_data->wglCreateContext(hdc); @@ -558,27 +558,27 @@ WIN_GL_CreateContext(_THIS, SDL_Window * window) SDL_SetError("GL 3.x is not supported"); context = temp_context; } else { - /* max 8 attributes plus terminator */ + /* max 8 attributes plus terminator */ int attribs[9] = { WGL_CONTEXT_MAJOR_VERSION_ARB, _this->gl_config.major_version, WGL_CONTEXT_MINOR_VERSION_ARB, _this->gl_config.minor_version, 0 }; - int iattr = 4; + int iattr = 4; - /* SDL profile bits match WGL profile bits */ - if( _this->gl_config.profile_mask != 0 ) { - attribs[iattr++] = WGL_CONTEXT_PROFILE_MASK_ARB; - attribs[iattr++] = _this->gl_config.profile_mask; - } + /* SDL profile bits match WGL profile bits */ + if( _this->gl_config.profile_mask != 0 ) { + attribs[iattr++] = WGL_CONTEXT_PROFILE_MASK_ARB; + attribs[iattr++] = _this->gl_config.profile_mask; + } - /* SDL flags match WGL flags */ - if( _this->gl_config.flags != 0 ) { - attribs[iattr++] = WGL_CONTEXT_FLAGS_ARB; - attribs[iattr++] = _this->gl_config.flags; - } + /* SDL flags match WGL flags */ + if( _this->gl_config.flags != 0 ) { + attribs[iattr++] = WGL_CONTEXT_FLAGS_ARB; + attribs[iattr++] = _this->gl_config.flags; + } - attribs[iattr++] = 0; + attribs[iattr++] = 0; /* Create the GL 3.x context */ context = wglCreateContextAttribsARB(hdc, share_context, attribs); diff --git a/src/video/windows/SDL_windowsshape.c b/src/video/windows/SDL_windowsshape.c index 5e3286175..fdbcdfc76 100644 --- a/src/video/windows/SDL_windowsshape.c +++ b/src/video/windows/SDL_windowsshape.c @@ -36,12 +36,12 @@ Win32_CreateShaper(SDL_Window * window) { result->userx = result->usery = 0; result->driverdata = (SDL_ShapeData*)SDL_malloc(sizeof(SDL_ShapeData)); ((SDL_ShapeData*)result->driverdata)->mask_tree = NULL; - //Put some driver-data here. + /* Put some driver-data here. */ window->shaper = result; resized_properly = Win32_ResizeWindowShape(window); if (resized_properly != 0) return NULL; - + return result; } @@ -49,15 +49,15 @@ void CombineRectRegions(SDL_ShapeTree* node,void* closure) { HRGN mask_region = *((HRGN*)closure),temp_region = NULL; if(node->kind == OpaqueShape) { - //Win32 API regions exclude their outline, so we widen the region by one pixel in each direction to include the real outline. + /* Win32 API regions exclude their outline, so we widen the region by one pixel in each direction to include the real outline. */ temp_region = CreateRectRgn(node->data.shape.x,node->data.shape.y,node->data.shape.x + node->data.shape.w + 1,node->data.shape.y + node->data.shape.h + 1); if(mask_region != NULL) { CombineRgn(mask_region,mask_region,temp_region,RGN_OR); DeleteObject(temp_region); - } - else + } + else *((HRGN*)closure) = temp_region; - } + } } int @@ -77,12 +77,12 @@ Win32_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShape if(data->mask_tree != NULL) SDL_FreeShapeTree(&data->mask_tree); data->mask_tree = SDL_CalculateShapeTree(*shape_mode,shape); - + SDL_TraverseShapeTree(data->mask_tree,&CombineRectRegions,&mask_region); - SDL_assert(mask_region != NULL); + SDL_assert(mask_region != NULL); SetWindowRgn(((SDL_WindowData *)(shaper->window->driverdata))->hwnd, mask_region, TRUE); - + return 0; } @@ -95,15 +95,15 @@ Win32_ResizeWindowShape(SDL_Window *window) { data = (SDL_ShapeData *)window->shaper->driverdata; if (data == NULL) return -1; - + if(data->mask_tree != NULL) SDL_FreeShapeTree(&data->mask_tree); if(window->shaper->hasshape == SDL_TRUE) { window->shaper->userx = window->x; window->shaper->usery = window->y; SDL_SetWindowPosition(window,-1000,-1000); - } - + } + return 0; } diff --git a/src/video/windows/SDL_windowsshape.h b/src/video/windows/SDL_windowsshape.h index 3b73425e5..06aaea11e 100644 --- a/src/video/windows/SDL_windowsshape.h +++ b/src/video/windows/SDL_windowsshape.h @@ -30,7 +30,7 @@ #include "../SDL_shape_internals.h" typedef struct { - SDL_ShapeTree *mask_tree; + SDL_ShapeTree *mask_tree; } SDL_ShapeData; extern SDL_WindowShaper* Win32_CreateShaper(SDL_Window * window); diff --git a/src/video/windows/SDL_windowsvideo.c b/src/video/windows/SDL_windowsvideo.c index 7b46d2751..883cafae4 100644 --- a/src/video/windows/SDL_windowsvideo.c +++ b/src/video/windows/SDL_windowsvideo.c @@ -51,9 +51,9 @@ WIN_DeleteDevice(SDL_VideoDevice * device) SDL_VideoData *data = (SDL_VideoData *) device->driverdata; SDL_UnregisterApp(); - if (data->userDLL) { - SDL_UnloadObject(data->userDLL); - } + if (data->userDLL) { + SDL_UnloadObject(data->userDLL); + } SDL_free(device->driverdata); SDL_free(device); @@ -83,12 +83,12 @@ WIN_CreateDevice(int devindex) } device->driverdata = data; - data->userDLL = SDL_LoadObject("USER32.DLL"); - if (data->userDLL) { - data->CloseTouchInputHandle = (BOOL (WINAPI *)( HTOUCHINPUT )) SDL_LoadFunction(data->userDLL, "CloseTouchInputHandle"); - data->GetTouchInputInfo = (BOOL (WINAPI *)( HTOUCHINPUT, UINT, PTOUCHINPUT, int )) SDL_LoadFunction(data->userDLL, "GetTouchInputInfo"); - data->RegisterTouchWindow = (BOOL (WINAPI *)( HWND, ULONG )) SDL_LoadFunction(data->userDLL, "RegisterTouchWindow"); - } + data->userDLL = SDL_LoadObject("USER32.DLL"); + if (data->userDLL) { + data->CloseTouchInputHandle = (BOOL (WINAPI *)( HTOUCHINPUT )) SDL_LoadFunction(data->userDLL, "CloseTouchInputHandle"); + data->GetTouchInputInfo = (BOOL (WINAPI *)( HTOUCHINPUT, UINT, PTOUCHINPUT, int )) SDL_LoadFunction(data->userDLL, "GetTouchInputInfo"); + data->RegisterTouchWindow = (BOOL (WINAPI *)( HWND, ULONG )) SDL_LoadFunction(data->userDLL, "RegisterTouchWindow"); + } /* Set the function pointers */ device->VideoInit = WIN_VideoInit; @@ -122,11 +122,11 @@ WIN_CreateDevice(int devindex) device->UpdateWindowFramebuffer = WIN_UpdateWindowFramebuffer; device->DestroyWindowFramebuffer = WIN_DestroyWindowFramebuffer; device->OnWindowEnter = WIN_OnWindowEnter; - + device->shape_driver.CreateShaper = Win32_CreateShaper; device->shape_driver.SetWindowShape = Win32_SetWindowShape; device->shape_driver.ResizeWindowShape = Win32_ResizeWindowShape; - + #if SDL_VIDEO_OPENGL_WGL device->GL_LoadLibrary = WIN_GL_LoadLibrary; device->GL_GetProcAddress = WIN_GL_GetProcAddress; diff --git a/src/video/windows/SDL_windowsvideo.h b/src/video/windows/SDL_windowsvideo.h index 199a8ba8f..0943708b5 100644 --- a/src/video/windows/SDL_windowsvideo.h +++ b/src/video/windows/SDL_windowsvideo.h @@ -51,8 +51,8 @@ #if WINVER < 0x0601 /* Touch input definitions */ -#define TWF_FINETOUCH 1 -#define TWF_WANTPALM 2 +#define TWF_FINETOUCH 1 +#define TWF_WANTPALM 2 #define TOUCHEVENTF_MOVE 0x0001 #define TOUCHEVENTF_DOWN 0x0002 @@ -61,16 +61,16 @@ DECLARE_HANDLE(HTOUCHINPUT); typedef struct _TOUCHINPUT { - LONG x; - LONG y; - HANDLE hSource; - DWORD dwID; - DWORD dwFlags; - DWORD dwMask; - DWORD dwTime; - ULONG_PTR dwExtraInfo; - DWORD cxContact; - DWORD cyContact; + LONG x; + LONG y; + HANDLE hSource; + DWORD dwID; + DWORD dwFlags; + DWORD dwMask; + DWORD dwTime; + ULONG_PTR dwExtraInfo; + DWORD cxContact; + DWORD cyContact; } TOUCHINPUT, *PTOUCHINPUT; #endif /* WINVER < 0x0601 */ @@ -78,7 +78,7 @@ typedef struct _TOUCHINPUT { typedef BOOL (*PFNSHFullScreen)(HWND, DWORD); typedef void (*PFCoordTransform)(SDL_Window*, POINT*); -typedef struct +typedef struct { void **lpVtbl; int refcount; @@ -115,13 +115,13 @@ typedef struct SDL_VideoData { int render; - DWORD clipboard_count; + DWORD clipboard_count; - /* Touch input functions */ - void* userDLL; - BOOL (WINAPI *CloseTouchInputHandle)( HTOUCHINPUT ); - BOOL (WINAPI *GetTouchInputInfo)( HTOUCHINPUT, UINT, PTOUCHINPUT, int ); - BOOL (WINAPI *RegisterTouchWindow)( HWND, ULONG ); + /* Touch input functions */ + void* userDLL; + BOOL (WINAPI *CloseTouchInputHandle)( HTOUCHINPUT ); + BOOL (WINAPI *GetTouchInputInfo)( HTOUCHINPUT, UINT, PTOUCHINPUT, int ); + BOOL (WINAPI *RegisterTouchWindow)( HWND, ULONG ); SDL_bool ime_com_initialized; struct ITfThreadMgr *ime_threadmgr; diff --git a/src/video/windows/SDL_windowswindow.c b/src/video/windows/SDL_windowswindow.c index 97db15fb2..1e41182e4 100644 --- a/src/video/windows/SDL_windowswindow.c +++ b/src/video/windows/SDL_windowswindow.c @@ -201,7 +201,7 @@ WIN_CreateWindow(_THIS, SDL_Window * window) DWORD style = STYLE_BASIC; int x, y; int w, h; - + style |= GetWindowStyle(window); /* Figure out what the window area will be */ @@ -352,7 +352,7 @@ WIN_SetWindowPositionInternal(_THIS, SDL_Window * window, UINT flags) /* Figure out what the window area will be */ if ( SDL_ShouldAllowTopmost() && (window->flags & (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_INPUT_FOCUS)) == (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_INPUT_FOCUS )) { - top = HWND_TOPMOST; + top = HWND_TOPMOST; } else { top = HWND_NOTOPMOST; } @@ -403,11 +403,11 @@ WIN_RaiseWindow(_THIS, SDL_Window * window) HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd; HWND top; - if ( SDL_ShouldAllowTopmost() && (window->flags & (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_INPUT_FOCUS)) == (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_INPUT_FOCUS )) { - top = HWND_TOPMOST; - } else { - top = HWND_NOTOPMOST; - } + if ( SDL_ShouldAllowTopmost() && (window->flags & (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_INPUT_FOCUS)) == (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_INPUT_FOCUS )) { + top = HWND_TOPMOST; + } else { + top = HWND_NOTOPMOST; + } SetWindowPos(hwnd, top, 0, 0, 0, 0, (SWP_NOMOVE | SWP_NOSIZE)); } @@ -464,11 +464,11 @@ WIN_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, int x, y; int w, h; - if ( SDL_ShouldAllowTopmost() && (window->flags & (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_INPUT_FOCUS)) == (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_INPUT_FOCUS )) { - top = HWND_TOPMOST; - } else { - top = HWND_NOTOPMOST; - } + if ( SDL_ShouldAllowTopmost() && (window->flags & (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_INPUT_FOCUS)) == (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_INPUT_FOCUS )) { + top = HWND_TOPMOST; + } else { + top = HWND_NOTOPMOST; + } style = GetWindowLong(hwnd, GWL_STYLE); style &= ~STYLE_MASK; @@ -550,22 +550,22 @@ WIN_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed) ClipCursor(NULL); } - if ( window->flags & SDL_WINDOW_FULLSCREEN ) - { - HWND top; - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; - HWND hwnd = data->hwnd; - UINT flags = SWP_NOMOVE | SWP_NOSIZE; - - if ( SDL_ShouldAllowTopmost() && (window->flags & SDL_WINDOW_INPUT_FOCUS ) ) { - top = HWND_TOPMOST; - } else { - top = HWND_NOTOPMOST; - flags |= SWP_NOZORDER; - } - - SetWindowPos(hwnd, top, 0, 0, 0, 0, flags); - } + if ( window->flags & SDL_WINDOW_FULLSCREEN ) + { + HWND top; + SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + HWND hwnd = data->hwnd; + UINT flags = SWP_NOMOVE | SWP_NOSIZE; + + if ( SDL_ShouldAllowTopmost() && (window->flags & SDL_WINDOW_INPUT_FOCUS ) ) { + top = HWND_TOPMOST; + } else { + top = HWND_NOTOPMOST; + flags |= SWP_NOZORDER; + } + + SetWindowPos(hwnd, top, 0, 0, 0, 0, flags); + } } void diff --git a/src/video/windows/wmmsg.h b/src/video/windows/wmmsg.h index 0c36cf82c..2cc7a843f 100644 --- a/src/video/windows/wmmsg.h +++ b/src/video/windows/wmmsg.h @@ -1,5 +1,5 @@ -#define MAX_WMMSG (sizeof(wmtab)/sizeof(wmtab[0])) +#define MAX_WMMSG (sizeof(wmtab)/sizeof(wmtab[0])) char *wmtab[] = { "WM_NULL", diff --git a/src/video/x11/SDL_x11clipboard.c b/src/video/x11/SDL_x11clipboard.c index 0c3b000e0..bdeb4da8a 100644 --- a/src/video/x11/SDL_x11clipboard.c +++ b/src/video/x11/SDL_x11clipboard.c @@ -139,7 +139,7 @@ X11_GetClipboardText(_THIS) if (!text) { text = SDL_strdup(""); } - + return text; } @@ -151,7 +151,7 @@ X11_HasClipboardText(_THIS) if (text) { result = (SDL_strlen(text)>0) ? SDL_TRUE : SDL_FALSE; SDL_free(text); - } + } return result; } diff --git a/src/video/x11/SDL_x11dyn.c b/src/video/x11/SDL_x11dyn.c index dbd7d7c13..ab0eafb4d 100644 --- a/src/video/x11/SDL_x11dyn.c +++ b/src/video/x11/SDL_x11dyn.c @@ -107,9 +107,9 @@ X11_GetSym(const char *fnname, int *pHasModule) /* Define all the function pointers and wrappers... */ #define SDL_X11_MODULE(modname) #define SDL_X11_SYM(rc,fn,params,args,ret) \ - typedef rc (*SDL_DYNX11FN_##fn) params; \ - static SDL_DYNX11FN_##fn p##fn = NULL; \ - rc fn params { ret p##fn args ; } + typedef rc (*SDL_DYNX11FN_##fn) params; \ + static SDL_DYNX11FN_##fn p##fn = NULL; \ + rc fn params { ret p##fn args ; } #include "SDL_x11sym.h" #undef SDL_X11_MODULE #undef SDL_X11_SYM diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c index e26f64ca3..757abd93c 100644 --- a/src/video/x11/SDL_x11events.c +++ b/src/video/x11/SDL_x11events.c @@ -42,29 +42,29 @@ #include typedef struct { - unsigned char *data; - int format, count; - Atom type; + unsigned char *data; + int format, count; + Atom type; } SDL_x11Prop; /* Reads property Must call XFree on results */ -static void X11_ReadProperty(SDL_x11Prop *p, Display *disp, Window w, Atom prop) +static void X11_ReadProperty(SDL_x11Prop *p, Display *disp, Window w, Atom prop) { unsigned char *ret=NULL; Atom type; int fmt; unsigned long count; unsigned long bytes_left; - int bytes_fetch = 0; - + int bytes_fetch = 0; + do { if (ret != 0) XFree(ret); XGetWindowProperty(disp, w, prop, 0, bytes_fetch, False, AnyPropertyType, &type, &fmt, &count, &bytes_left, &ret); bytes_fetch += bytes_left; } while (bytes_left != 0); - + p->data=ret; p->format=fmt; p->count=count; @@ -124,7 +124,7 @@ static SDL_bool X11_IsWheelEvent(Display * display,XEvent * event,int * ticks) /* according to the xlib docs, no specific mouse wheel events exist. however, mouse wheel events trigger a button press and a button release immediately. thus, checking if the same button was released at the same - time as it was pressed, should be an adequate hack to derive a mouse + time as it was pressed, should be an adequate hack to derive a mouse wheel event. */ XPeekEvent(display,&peekevent); if ((peekevent.type == ButtonRelease) && @@ -501,7 +501,7 @@ X11_DispatchEvent(_THIS) case ClientMessage:{ int xdnd_version=0; - + if (xevent.xclient.message_type == videodata->XdndEnter) { SDL_bool use_list = xevent.xclient.data.l[1] & 1; data->xdnd_source = xevent.xclient.data.l[0]; @@ -519,7 +519,7 @@ X11_DispatchEvent(_THIS) } } else if (xevent.xclient.message_type == videodata->XdndPosition) { - + /* reply with status */ XClientMessageEvent m; memset(&m, 0, sizeof(XClientMessageEvent)); @@ -533,7 +533,7 @@ X11_DispatchEvent(_THIS) m.data.l[2] = 0; /* specify an empty rectangle */ m.data.l[3] = 0; m.data.l[4] = videodata->XdndActionCopy; /* we only accept copying anyway */ - + XSendEvent(display, xevent.xclient.data.l[0], False, NoEventMask, (XEvent*)&m); XFlush(display); } @@ -554,9 +554,9 @@ X11_DispatchEvent(_THIS) } else { /* convert */ if(xdnd_version >= 1) { - XConvertSelection(display, videodata->XdndSelection, data->xdnd_req, videodata->PRIMARY, data->xwindow, xevent.xclient.data.l[2]); + XConvertSelection(display, videodata->XdndSelection, data->xdnd_req, videodata->PRIMARY, data->xwindow, xevent.xclient.data.l[2]); } else { - XConvertSelection(display, videodata->XdndSelection, data->xdnd_req, videodata->PRIMARY, data->xwindow, CurrentTime); + XConvertSelection(display, videodata->XdndSelection, data->xdnd_req, videodata->PRIMARY, data->xwindow, CurrentTime); } } } @@ -596,7 +596,7 @@ X11_DispatchEvent(_THIS) break; case MotionNotify:{ - SDL_Mouse *mouse = SDL_GetMouse(); + SDL_Mouse *mouse = SDL_GetMouse(); if(!mouse->relative_mode) { #ifdef DEBUG_MOTION printf("window %p: X11 motion: %d,%d\n", xevent.xmotion.x, xevent.xmotion.y); @@ -775,7 +775,7 @@ X11_DispatchEvent(_THIS) /* read data */ SDL_x11Prop p; X11_ReadProperty(&p, display, data->xwindow, videodata->PRIMARY); - + if(p.format==8) { SDL_bool expect_lf = SDL_FALSE; char *start = NULL; @@ -807,9 +807,9 @@ X11_DispatchEvent(_THIS) scan++; } } - + XFree(p.data); - + /* send reply */ XClientMessageEvent m; memset(&m, 0, sizeof(XClientMessageEvent)); @@ -822,13 +822,13 @@ X11_DispatchEvent(_THIS) m.data.l[1] = 1; m.data.l[2] = videodata->XdndActionCopy; XSendEvent(display, data->xdnd_source, False, NoEventMask, (XEvent*)&m); - + XSync(display, False); - + } else { videodata->selection_waiting = SDL_FALSE; } - + } break; @@ -915,7 +915,7 @@ X11_PumpEvents(_THIS) data->screensaver_activity = now; } - } + } /* Keep processing pending events */ while (X11_Pending(data->display)) { diff --git a/src/video/x11/SDL_x11framebuffer.c b/src/video/x11/SDL_x11framebuffer.c index 0c8febe4a..4dfe0d174 100644 --- a/src/video/x11/SDL_x11framebuffer.c +++ b/src/video/x11/SDL_x11framebuffer.c @@ -111,7 +111,7 @@ X11_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, if (!shm_error) { data->ximage = XShmCreateImage(display, data->visual, vinfo.depth, ZPixmap, - shminfo->shmaddr, shminfo, + shminfo->shmaddr, shminfo, window->w, window->h); if (!data->ximage) { XShmDetach(display, shminfo); @@ -133,7 +133,7 @@ X11_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, } data->ximage = XCreateImage(display, data->visual, - vinfo.depth, ZPixmap, 0, (char *)(*pixels), + vinfo.depth, ZPixmap, 0, (char *)(*pixels), window->w, window->h, 32, 0); if (!data->ximage) { SDL_free(*pixels); diff --git a/src/video/x11/SDL_x11messagebox.c b/src/video/x11/SDL_x11messagebox.c index 47cac1c66..38867f06a 100644 --- a/src/video/x11/SDL_x11messagebox.c +++ b/src/video/x11/SDL_x11messagebox.c @@ -700,8 +700,8 @@ X11_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) int fds[2]; int status = 0; - /* Need to flush here in case someone has turned grab off and it hasn't gone through yet, etc. */ - XFlush(data->display); + /* Need to flush here in case someone has turned grab off and it hasn't gone through yet, etc. */ + XFlush(data->display); if (pipe(fds) == -1) { return X11_ShowMessageBoxImpl(messageboxdata, buttonid); /* oh well. */ diff --git a/src/video/x11/SDL_x11modes.c b/src/video/x11/SDL_x11modes.c index 60363b491..b1da7370f 100644 --- a/src/video/x11/SDL_x11modes.c +++ b/src/video/x11/SDL_x11modes.c @@ -577,7 +577,7 @@ X11_InitModes(_THIS) unsigned long nitems, bytes_after; Atom actual_type; - if (props[i] == EDID) { + if (props[i] == EDID) { if (XRRGetOutputProperty(data->display, res->outputs[output], props[i], 0, 100, False, False, diff --git a/src/video/x11/SDL_x11mouse.c b/src/video/x11/SDL_x11mouse.c index 1d021b7b6..441ecdfe3 100644 --- a/src/video/x11/SDL_x11mouse.c +++ b/src/video/x11/SDL_x11mouse.c @@ -194,8 +194,8 @@ X11_CreatePixmapCursor(SDL_Surface * surface, int hot_x, int hot_y) surface->w, surface->h); cursor = XCreatePixmapCursor(display, data_pixmap, mask_pixmap, &fg, &bg, hot_x, hot_y); - XFreePixmap(display, data_pixmap); - XFreePixmap(display, mask_pixmap); + XFreePixmap(display, data_pixmap); + XFreePixmap(display, mask_pixmap); return cursor; } @@ -236,8 +236,8 @@ X11_CreateSystemCursor(SDL_SystemCursor id) default: SDL_assert(0); return NULL; - // X Font Cursors reference: - // http://tronche.com/gui/x/xlib/appendix/b/ + /* X Font Cursors reference: */ + /* http://tronche.com/gui/x/xlib/appendix/b/ */ case SDL_SYSTEM_CURSOR_ARROW: shape = XC_left_ptr; break; case SDL_SYSTEM_CURSOR_IBEAM: shape = XC_xterm; break; case SDL_SYSTEM_CURSOR_WAIT: shape = XC_watch; break; @@ -336,7 +336,7 @@ X11_InitMouse(_THIS) SDL_Mouse *mouse = SDL_GetMouse(); mouse->CreateCursor = X11_CreateCursor; - mouse->CreateSystemCursor = X11_CreateSystemCursor; + mouse->CreateSystemCursor = X11_CreateSystemCursor; mouse->ShowCursor = X11_ShowCursor; mouse->FreeCursor = X11_FreeCursor; mouse->WarpMouse = X11_WarpMouse; diff --git a/src/video/x11/SDL_x11opengl.c b/src/video/x11/SDL_x11opengl.c index 8e6614bef..1e1078eff 100644 --- a/src/video/x11/SDL_x11opengl.c +++ b/src/video/x11/SDL_x11opengl.c @@ -33,13 +33,13 @@ #if defined(__IRIX__) /* IRIX doesn't have a GL library versioning system */ -#define DEFAULT_OPENGL "libGL.so" +#define DEFAULT_OPENGL "libGL.so" #elif defined(__MACOSX__) -#define DEFAULT_OPENGL "/usr/X11R6/lib/libGL.1.dylib" +#define DEFAULT_OPENGL "/usr/X11R6/lib/libGL.1.dylib" #elif defined(__QNXNTO__) -#define DEFAULT_OPENGL "libGL.so.3" +#define DEFAULT_OPENGL "libGL.so.3" #else -#define DEFAULT_OPENGL "libGL.so.1" +#define DEFAULT_OPENGL "libGL.so.1" #endif #ifndef GLX_NONE_EXT @@ -118,13 +118,13 @@ typedef GLXContext(*PFNGLXCREATECONTEXTATTRIBSARBPROC) (Display * dpy, #define OPENGL_REQUIRES_DLOPEN #if defined(OPENGL_REQUIRES_DLOPEN) && defined(SDL_LOADSO_DLOPEN) #include -#define GL_LoadObject(X) dlopen(X, (RTLD_NOW|RTLD_GLOBAL)) -#define GL_LoadFunction dlsym -#define GL_UnloadObject dlclose +#define GL_LoadObject(X) dlopen(X, (RTLD_NOW|RTLD_GLOBAL)) +#define GL_LoadFunction dlsym +#define GL_UnloadObject dlclose #else -#define GL_LoadObject SDL_LoadObject -#define GL_LoadFunction SDL_LoadFunction -#define GL_UnloadObject SDL_UnloadObject +#define GL_LoadObject SDL_LoadObject +#define GL_LoadFunction SDL_LoadFunction +#define GL_UnloadObject SDL_UnloadObject #endif static void X11_GL_InitExtensions(_THIS); @@ -369,21 +369,21 @@ X11_GL_InitExtensions(_THIS) } /* glXChooseVisual and glXChooseFBConfig have some small differences in - * the attribute encoding, it can be chosen with the for_FBConfig parameter. + * the attribute encoding, it can be chosen with the for_FBConfig parameter. */ -int +int X11_GL_GetAttributes(_THIS, Display * display, int screen, int * attribs, int size, Bool for_FBConfig) { int i = 0; - const int MAX_ATTRIBUTES = 64; + const int MAX_ATTRIBUTES = 64; - /* assert buffer is large enough to hold all SDL attributes. */ + /* assert buffer is large enough to hold all SDL attributes. */ SDL_assert(size >= MAX_ATTRIBUTES); /* Setup our GLX attributes according to the gl_config. */ if( for_FBConfig ) { attribs[i++] = GLX_RENDER_TYPE; - attribs[i++] = GLX_RGBA_BIT; + attribs[i++] = GLX_RGBA_BIT; } else { attribs[i++] = GLX_RGBA; } @@ -401,8 +401,8 @@ X11_GL_GetAttributes(_THIS, Display * display, int screen, int * attribs, int si if (_this->gl_config.double_buffer) { attribs[i++] = GLX_DOUBLEBUFFER; - if( for_FBConfig ) - attribs[i++] = True; + if( for_FBConfig ) + attribs[i++] = True; } attribs[i++] = GLX_DEPTH_SIZE; @@ -435,8 +435,8 @@ X11_GL_GetAttributes(_THIS, Display * display, int screen, int * attribs, int si if (_this->gl_config.stereo) { attribs[i++] = GLX_STEREO; - if( for_FBConfig ) - attribs[i++] = True; + if( for_FBConfig ) + attribs[i++] = True; } if (_this->gl_config.multisamplebuffers) { @@ -467,7 +467,7 @@ X11_GL_GetAttributes(_THIS, Display * display, int screen, int * attribs, int si attribs[i++] = None; SDL_assert(i <= MAX_ATTRIBUTES); - + return i; } @@ -631,7 +631,7 @@ X11_GL_CreateContext(_THIS, SDL_Window * window) } XSync(display, False); XSetErrorHandler(handler); - + if (!context) { SDL_SetError("Could not create GL context"); return NULL; @@ -664,7 +664,7 @@ X11_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) return 0; } -/* +/* 0 is a valid argument to glxSwapInterval(MESA|EXT) and setting it to 0 will undo the effect of a previous call with a value that is greater than zero (or at least that is what the docs say). OTOH, 0 is an invalid diff --git a/src/video/x11/SDL_x11opengles.c b/src/video/x11/SDL_x11opengles.c index 279c58c34..218421b32 100644 --- a/src/video/x11/SDL_x11opengles.c +++ b/src/video/x11/SDL_x11opengles.c @@ -32,11 +32,11 @@ #define DEFAULT_OGL_ES "libGLESv1_CM.so" #define LOAD_FUNC(NAME) \ - *((void**)&_this->gles_data->NAME) = dlsym(handle, #NAME); \ - if (!_this->gles_data->NAME) \ - { \ - return SDL_SetError("Could not retrieve EGL function " #NAME); \ - } + *((void**)&_this->gles_data->NAME) = dlsym(handle, #NAME); \ + if (!_this->gles_data->NAME) \ + { \ + return SDL_SetError("Could not retrieve EGL function " #NAME); \ + } /* GLES implementation of SDL OpenGL support */ @@ -54,7 +54,7 @@ X11_GLES_GetProcAddress(_THIS, const char *proc) return retval; } } - + handle = _this->gl_config.dll_handle; #if defined(__OpenBSD__) && !defined(__ELF__) #undef dlsym(x,y); @@ -379,7 +379,7 @@ X11_GLES_SetSwapInterval(_THIS, int interval) status = _this->gles_data->eglSwapInterval(_this->gles_data->egl_display, interval); if (status == EGL_TRUE) { _this->gles_data->egl_swapinterval = interval; - return 0; + return 0; } return SDL_SetError("Unable to set the EGL swap interval"); @@ -406,7 +406,7 @@ void X11_GLES_DeleteContext(_THIS, SDL_GLContext context) { /* Clean up GLES and EGL */ - if (!_this->gles_data) { + if (!_this->gles_data) { return; } diff --git a/src/video/x11/SDL_x11shape.c b/src/video/x11/SDL_x11shape.c index e1e68934e..cea280722 100644 --- a/src/video/x11/SDL_x11shape.c +++ b/src/video/x11/SDL_x11shape.c @@ -61,7 +61,7 @@ int X11_ResizeWindowShape(SDL_Window* window) { SDL_ShapeData* data = window->shaper->driverdata; SDL_assert(data != NULL); - + unsigned int bitmapsize = window->w / 8; if(window->w % 8 > 0) bitmapsize += 1; @@ -76,14 +76,14 @@ X11_ResizeWindowShape(SDL_Window* window) { } } memset(data->bitmap,0,data->bitmapsize); - + window->shaper->userx = window->x; window->shaper->usery = window->y; SDL_SetWindowPosition(window,-1000,-1000); - + return 0; } - + int X11_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode) { if(shaper == NULL || shape == NULL || shaper->driverdata == NULL) @@ -95,13 +95,13 @@ X11_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMo if(shape->w != shaper->window->w || shape->h != shaper->window->h) return -3; SDL_ShapeData *data = shaper->driverdata; - + /* Assume that shaper->alphacutoff already has a value, because SDL_SetWindowShape() should have given it one. */ SDL_CalculateShapeBitmap(shaper->mode,shape,data->bitmap,8); - + SDL_WindowData *windowdata = (SDL_WindowData*)(shaper->window->driverdata); Pixmap shapemask = XCreateBitmapFromData(windowdata->videodata->display,windowdata->xwindow,data->bitmap,shaper->window->w,shaper->window->h); - + XShapeCombineMask(windowdata->videodata->display,windowdata->xwindow, ShapeBounding, 0, 0,shapemask, ShapeSet); XSync(windowdata->videodata->display,False); diff --git a/src/video/x11/SDL_x11shape.h b/src/video/x11/SDL_x11shape.h index d7c389283..96b4a8b0a 100644 --- a/src/video/x11/SDL_x11shape.h +++ b/src/video/x11/SDL_x11shape.h @@ -28,13 +28,13 @@ #include "../SDL_sysvideo.h" typedef struct { - void* bitmap; - Uint32 bitmapsize; + void* bitmap; + Uint32 bitmapsize; } SDL_ShapeData; extern SDL_Window* X11_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags); extern SDL_WindowShaper* X11_CreateShaper(SDL_Window* window); extern int X11_ResizeWindowShape(SDL_Window* window); -extern int X11_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shapeMode); +extern int X11_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shapeMode); #endif /* _SDL_x11shape_h */ diff --git a/src/video/x11/SDL_x11video.c b/src/video/x11/SDL_x11video.c index 4794241e9..d12f87a7b 100644 --- a/src/video/x11/SDL_x11video.c +++ b/src/video/x11/SDL_x11video.c @@ -32,7 +32,7 @@ #include "SDL_x11video.h" #include "SDL_x11framebuffer.h" #include "SDL_x11shape.h" -#include "SDL_x11touch.h" +#include "SDL_x11touch.h" #include "SDL_x11xinput2.h" #if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 diff --git a/src/video/x11/SDL_x11video.h b/src/video/x11/SDL_x11video.h index 9411b7b7e..68a041326 100644 --- a/src/video/x11/SDL_x11video.h +++ b/src/video/x11/SDL_x11video.h @@ -110,9 +110,9 @@ typedef struct SDL_VideoData Atom XdndDrop; Atom XdndFinished; Atom XdndSelection; - + SDL_Scancode key_layout[256]; - SDL_bool selection_waiting; + SDL_bool selection_waiting; #if SDL_USE_LIBDBUS DBusConnection *dbus; diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c index 6403ac4b4..eda47f7ef 100644 --- a/src/video/x11/SDL_x11window.c +++ b/src/video/x11/SDL_x11window.c @@ -349,7 +349,7 @@ X11_CreateWindow(_THIS, SDL_Window * window) if (window->flags & SDL_WINDOW_OPENGL) { XVisualInfo *vinfo; -#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 +#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 if (_this->gl_config.use_egl == 1) { vinfo = X11_GLES_GetVisual(_this, display, screen); } else @@ -532,7 +532,7 @@ X11_CreateWindow(_THIS, SDL_Window * window) PropModeReplace, (unsigned char *)&_NET_WM_WINDOW_TYPE_NORMAL, 1); - + { Atom protocols[] = { data->WM_DELETE_WINDOW, /* Allow window to be deleted by the WM */ @@ -565,7 +565,7 @@ X11_CreateWindow(_THIS, SDL_Window * window) XdndAware = XInternAtom(display, "XdndAware", False); XChangeProperty(display, w, XdndAware, XA_ATOM, 32, PropModeReplace, - (unsigned char*)&xdnd_version, 1); + (unsigned char*)&xdnd_version, 1); XFlush(display); @@ -836,7 +836,7 @@ X11_ShowWindow(_THIS, SDL_Window * window) if (!X11_IsWindowMapped(_this, window)) { XMapRaised(display, data->xwindow); /* Blocking wait for "MapNotify" event. - * We use XIfEvent because XWindowEvent takes a mask rather than a type, + * We use XIfEvent because XWindowEvent takes a mask rather than a type, * and XCheckTypedWindowEvent doesn't block */ XIfEvent(display, &event, &isMapNotify, (XPointer)&data->xwindow); XFlush(display); @@ -853,7 +853,7 @@ X11_HideWindow(_THIS, SDL_Window * window) if (X11_IsWindowMapped(_this, window)) { XUnmapWindow(display, data->xwindow); /* Blocking wait for "UnmapNotify" event */ - XIfEvent(display, &event, &isUnmapNotify, (XPointer)&data->xwindow); + XIfEvent(display, &event, &isUnmapNotify, (XPointer)&data->xwindow); XFlush(display); } } @@ -922,7 +922,7 @@ X11_MinimizeWindow(_THIS, SDL_Window * window) SDL_DisplayData *displaydata = (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata; Display *display = data->videodata->display; - + XIconifyWindow(display, data->xwindow, displaydata->screen); XFlush(display); } @@ -934,7 +934,7 @@ SetWindowActive(_THIS, SDL_Window * window) SDL_DisplayData *displaydata = (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata; Display *display = data->videodata->display; - Atom _NET_ACTIVE_WINDOW = data->videodata->_NET_ACTIVE_WINDOW; + Atom _NET_ACTIVE_WINDOW = data->videodata->_NET_ACTIVE_WINDOW; if (X11_IsWindowMapped(_this, window)) { XEvent e; @@ -945,13 +945,13 @@ SetWindowActive(_THIS, SDL_Window * window) e.xclient.format = 32; e.xclient.window = data->xwindow; e.xclient.data.l[0] = 1; /* source indication. 1 = application */ - e.xclient.data.l[1] = CurrentTime; - e.xclient.data.l[2] = 0; + e.xclient.data.l[1] = CurrentTime; + e.xclient.data.l[2] = 0; XSendEvent(display, RootWindow(display, displaydata->screen), 0, SubstructureNotifyMask | SubstructureRedirectMask, &e); - XFlush(display); + XFlush(display); } } @@ -959,7 +959,7 @@ void X11_RestoreWindow(_THIS, SDL_Window * window) { SetWindowMaximized(_this, window, SDL_FALSE); - SetWindowActive(_this, window); + SetWindowActive(_this, window); X11_ShowWindow(_this, window); } diff --git a/src/video/x11/SDL_x11xinput2.c b/src/video/x11/SDL_x11xinput2.c index 2bd466a54..1b86c6774 100644 --- a/src/video/x11/SDL_x11xinput2.c +++ b/src/video/x11/SDL_x11xinput2.c @@ -39,7 +39,7 @@ static int xinput2_multitouch_supported = 0; /* Opcode returned XQueryExtension * It will be used in event processing * to know that the event came from - * this extension */ + * this extension */ static int xinput2_opcode; static void parse_valuators(const double *input_values,unsigned char *mask,int mask_len, @@ -61,7 +61,7 @@ static void parse_valuators(const double *input_values,unsigned char *mask,int m } #endif /* SDL_VIDEO_DRIVER_X11_XINPUT2 */ -void +void X11_InitXinput2(_THIS) { #if SDL_VIDEO_DRIVER_X11_XINPUT2 @@ -78,8 +78,8 @@ X11_InitXinput2(_THIS) /* * Initialize XInput 2 * According to http://who-t.blogspot.com/2009/05/xi2-recipes-part-1.html its better - * to inform Xserver what version of Xinput we support.The server will store the version we support. - * "As XI2 progresses it becomes important that you use this call as the server may treat the client + * to inform Xserver what version of Xinput we support.The server will store the version we support. + * "As XI2 progresses it becomes important that you use this call as the server may treat the client * differently depending on the supported version". * * FIXME:event and err are not needed but if not passed XQueryExtension returns SegmentationFault @@ -114,14 +114,14 @@ X11_InitXinput2(_THIS) eventmask.mask = mask; XISetMask(mask, XI_RawMotion); - + if (XISelectEvents(data->display,DefaultRootWindow(data->display),&eventmask,1) != Success) { - return; + return; } #endif } -int +int X11_HandleXinput2Event(SDL_VideoData *videodata,XGenericEventCookie *cookie) { #if SDL_VIDEO_DRIVER_X11_XINPUT2 @@ -172,7 +172,7 @@ X11_HandleXinput2Event(SDL_VideoData *videodata,XGenericEventCookie *cookie) return 0; } -void +void X11_InitXinput2Multitouch(_THIS) { #if SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH @@ -202,7 +202,7 @@ X11_InitXinput2Multitouch(_THIS) #endif } -void +void X11_Xinput2SelectTouch(_THIS, SDL_Window *window) { #if SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH @@ -222,13 +222,13 @@ X11_Xinput2SelectTouch(_THIS, SDL_Window *window) XISetMask(mask, XI_TouchBegin); XISetMask(mask, XI_TouchUpdate); XISetMask(mask, XI_TouchEnd); - + XISelectEvents(data->display,window_data->xwindow,&eventmask,1); #endif } -int +int X11_Xinput2IsInitialized() { #if SDL_VIDEO_DRIVER_X11_XINPUT2 diff --git a/src/video/x11/SDL_x11xinput2.h b/src/video/x11/SDL_x11xinput2.h index e74018f9c..56a4b906c 100644 --- a/src/video/x11/SDL_x11xinput2.h +++ b/src/video/x11/SDL_x11xinput2.h @@ -24,11 +24,11 @@ #define _SDL_x11xinput2_h #ifndef SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS -/*Define XGenericEventCookie as forward declaration when +/*Define XGenericEventCookie as forward declaration when *xinput2 is not available in order to compile*/ struct XGenericEventCookie; typedef struct XGenericEventCookie XGenericEventCookie; -#endif +#endif extern void X11_InitXinput2(_THIS); extern void X11_InitXinput2Multitouch(_THIS); diff --git a/test/automated/common/common.h b/test/automated/common/common.h index 25e7ecf74..299f8197e 100644 --- a/test/automated/common/common.h +++ b/test/automated/common/common.h @@ -21,12 +21,12 @@ typedef struct SurfaceImage_s { int width; int height; - unsigned int bytes_per_pixel; /* 3:RGB, 4:RGBA */ + unsigned int bytes_per_pixel; /* 3:RGB, 4:RGBA */ const char *pixel_data; } SurfaceImage_t; -#define ALLOWABLE_ERROR_OPAQUE 0 -#define ALLOWABLE_ERROR_BLENDED 64 +#define ALLOWABLE_ERROR_OPAQUE 0 +#define ALLOWABLE_ERROR_BLENDED 64 /** * @brief Compares a surface and a surface image for equality. diff --git a/test/automated/rwops/TestSupportRWops_Cocoa.m b/test/automated/rwops/TestSupportRWops_Cocoa.m index 5f0dc07d3..153fd8d4d 100644 --- a/test/automated/rwops/TestSupportRWops_Cocoa.m +++ b/test/automated/rwops/TestSupportRWops_Cocoa.m @@ -20,70 +20,70 @@ { FILE* fp = NULL; - // If the file mode is writable, skip all the bundle stuff because generally the bundle is read-only. - if(strcmp("r", mode) && strcmp("rb", mode)) - { - return fopen(file, mode); - } - - NSAutoreleasePool* autorelease_pool = [[NSAutoreleasePool alloc] init]; + /* If the file mode is writable, skip all the bundle stuff because generally the bundle is read-only. */ + if(strcmp("r", mode) && strcmp("rb", mode)) + { + return fopen(file, mode); + } + NSAutoreleasePool* autorelease_pool = [[NSAutoreleasePool alloc] init]; - NSFileManager* file_manager = [NSFileManager defaultManager]; - NSString* resource_path = [[NSBundle mainBundle] resourcePath]; - NSString* ns_string_file_component = [file_manager stringWithFileSystemRepresentation:file length:strlen(file)]; + NSFileManager* file_manager = [NSFileManager defaultManager]; + NSString* resource_path = [[NSBundle mainBundle] resourcePath]; - NSString* full_path_with_file_to_try = [resource_path stringByAppendingPathComponent:ns_string_file_component]; - if([file_manager fileExistsAtPath:full_path_with_file_to_try]) - { - fp = fopen([full_path_with_file_to_try fileSystemRepresentation], mode); - } - else - { - fp = fopen(file, mode); - } + NSString* ns_string_file_component = [file_manager stringWithFileSystemRepresentation:file length:strlen(file)]; - [autorelease_pool drain]; + NSString* full_path_with_file_to_try = [resource_path stringByAppendingPathComponent:ns_string_file_component]; + if([file_manager fileExistsAtPath:full_path_with_file_to_try]) + { + fp = fopen([full_path_with_file_to_try fileSystemRepresentation], mode); + } + else + { + fp = fopen(file, mode); + } - return fp; + [autorelease_pool drain]; + + return fp; } FILE* TestSupportRWops_OpenFPFromWriteDir(const char *file, const char *mode) { FILE* fp = NULL; - - NSAutoreleasePool* autorelease_pool = [[NSAutoreleasePool alloc] init]; - - NSFileManager* file_manager = [NSFileManager defaultManager]; - NSString* ns_string_file_component = [file_manager stringWithFileSystemRepresentation:file length:strlen(file)]; - NSString* full_path_with_file_to_try = [NSTemporaryDirectory() stringByAppendingPathComponent:ns_string_file_component]; - - fp = fopen([full_path_with_file_to_try fileSystemRepresentation], mode); - - [autorelease_pool drain]; - - return fp; + + NSAutoreleasePool* autorelease_pool = [[NSAutoreleasePool alloc] init]; + + NSFileManager* file_manager = [NSFileManager defaultManager]; + NSString* ns_string_file_component = [file_manager stringWithFileSystemRepresentation:file length:strlen(file)]; + NSString* full_path_with_file_to_try = [NSTemporaryDirectory() stringByAppendingPathComponent:ns_string_file_component]; + + fp = fopen([full_path_with_file_to_try fileSystemRepresentation], mode); + + [autorelease_pool drain]; + + return fp; } SDL_RWops* TestSupportRWops_OpenRWopsFromReadDir(const char *file, const char *mode) { - return SDL_RWFromFile(file, mode); + return SDL_RWFromFile(file, mode); } SDL_RWops* TestSupportRWops_OpenRWopsFromWriteDir(const char *file, const char *mode) { - SDL_RWops* rw = NULL; - - NSAutoreleasePool* autorelease_pool = [[NSAutoreleasePool alloc] init]; - - NSFileManager* file_manager = [NSFileManager defaultManager]; - NSString* ns_string_file_component = [file_manager stringWithFileSystemRepresentation:file length:strlen(file)]; - NSString* full_path_with_file_to_try = [NSTemporaryDirectory() stringByAppendingPathComponent:ns_string_file_component]; - - rw = SDL_RWFromFile( [full_path_with_file_to_try fileSystemRepresentation], mode ); - - [autorelease_pool drain]; - return rw; + SDL_RWops* rw = NULL; + + NSAutoreleasePool* autorelease_pool = [[NSAutoreleasePool alloc] init]; + + NSFileManager* file_manager = [NSFileManager defaultManager]; + NSString* ns_string_file_component = [file_manager stringWithFileSystemRepresentation:file length:strlen(file)]; + NSString* full_path_with_file_to_try = [NSTemporaryDirectory() stringByAppendingPathComponent:ns_string_file_component]; + + rw = SDL_RWFromFile( [full_path_with_file_to_try fileSystemRepresentation], mode ); + + [autorelease_pool drain]; + return rw; } diff --git a/test/automated/rwops/TestSupportRWops_Generic.c b/test/automated/rwops/TestSupportRWops_Generic.c index a4b366a34..36128bf3a 100644 --- a/test/automated/rwops/TestSupportRWops_Generic.c +++ b/test/automated/rwops/TestSupportRWops_Generic.c @@ -2,7 +2,7 @@ * Customizations for specific platforms should go in alternative files. */ -// quiet windows compiler warnings +/* quiet windows compiler warnings */ #define _CRT_SECURE_NO_WARNINGS #include @@ -13,20 +13,20 @@ const char* RWOPS_WRITE = "rwops/write"; FILE* TestSupportRWops_OpenFPFromReadDir(const char *file, const char *mode) { - return fopen(file, mode); + return fopen(file, mode); } FILE* TestSupportRWops_OpenFPFromWriteDir(const char *file, const char *mode) { - return fopen(file, mode); + return fopen(file, mode); } SDL_RWops* TestSupportRWops_OpenRWopsFromReadDir(const char *file, const char *mode) { - return SDL_RWFromFile(file, mode); + return SDL_RWFromFile(file, mode); } SDL_RWops* TestSupportRWops_OpenRWopsFromWriteDir(const char *file, const char *mode) { - return SDL_RWFromFile(file, mode); + return SDL_RWFromFile(file, mode); } diff --git a/test/automated/surface/surface.c b/test/automated/surface/surface.c index 037cde924..c3974836c 100644 --- a/test/automated/surface/surface.c +++ b/test/automated/surface/surface.c @@ -49,9 +49,9 @@ static void surface_testLoad( SDL_Surface *testsur ) /* Create the blit surface. */ #ifdef __APPLE__ - face = SDL_LoadBMP("icon.bmp"); + face = SDL_LoadBMP("icon.bmp"); #else - face = SDL_LoadBMP("../icon.bmp"); + face = SDL_LoadBMP("../icon.bmp"); #endif if (SDL_ATassert( "SDL_CreateLoadBmp", face != NULL)) @@ -428,7 +428,7 @@ int test_surface (void) * Surface on surface tests. */ /* Create the test surface. */ - testsur = SDL_CreateRGBSurface( 0, 80, 60, 32, + testsur = SDL_CreateRGBSurface( 0, 80, 60, 32, RMASK, GMASK, BMASK, AMASK ); if (SDL_ATassert( "SDL_CreateRGBSurface", testsur != NULL)) goto err; diff --git a/test/checkkeys.c b/test/checkkeys.c index 49dc277b2..aa94f9f50 100644 --- a/test/checkkeys.c +++ b/test/checkkeys.c @@ -11,7 +11,7 @@ */ /* Simple program: Loop, watching keystrokes - Note that you need to call SDL_PollEvent() or SDL_WaitEvent() to + Note that you need to call SDL_PollEvent() or SDL_WaitEvent() to pump the event loop and catch keystrokes. */ diff --git a/test/loopwave.c b/test/loopwave.c index 8e7604111..11c0f1b41 100644 --- a/test/loopwave.c +++ b/test/loopwave.c @@ -12,8 +12,8 @@ /* Program to load a wave file and loop playing it using SDL sound */ -/* loopwaves.c is much more robust in handling WAVE files -- - This is only for simple WAVEs +/* loopwaves.c is much more robust in handling WAVE files -- + This is only for simple WAVEs */ #include "SDL_config.h" diff --git a/test/test-automation/include/SDL_test.h b/test/test-automation/include/SDL_test.h index 4f3b6f02e..0b37bc89f 100644 --- a/test/test-automation/include/SDL_test.h +++ b/test/test-automation/include/SDL_test.h @@ -35,12 +35,12 @@ #define ASSERT_FAILURE 0 //! Definition of all the possible test results -#define TEST_RESULT_PASS 0 -#define TEST_RESULT_FAILURE 1 -#define TEST_RESULT_NO_ASSERT 2 -#define TEST_RESULT_SKIPPED 3 -#define TEST_RESULT_KILLED 4 -#define TEST_RESULT_SETUP_FAILURE 5 +#define TEST_RESULT_PASS 0 +#define TEST_RESULT_FAILURE 1 +#define TEST_RESULT_NO_ASSERT 2 +#define TEST_RESULT_SKIPPED 3 +#define TEST_RESULT_KILLED 4 +#define TEST_RESULT_SETUP_FAILURE 5 //! Definitions for test requirements #define TEST_REQUIRES_AUDIO 1 @@ -51,16 +51,16 @@ * Holds information about a test case */ typedef struct TestCaseReference { - /*!< "Func2Stress" */ - char *name; - /*!< "This test beats the crap out of func2()" */ - char *description; - /*!< Set to TEST_ENABLED or TEST_DISABLED */ - int enabled; - /*!< Set to TEST_REQUIRES_OPENGL, TEST_REQUIRES_AUDIO, ... */ - long requirements; - /* 0) { - Log(time(0), "Fuzzer invocation count: %d", GetInvocationCount()); - } + if(GetInvocationCount() > 0) { + Log(time(0), "Fuzzer invocation count: %d", GetInvocationCount()); + } - DeinitFuzzer(); + DeinitFuzzer(); - return _testReturnValue; + return _testReturnValue; } int _CountFailedAsserts() { - return _testAssertsFailed; + return _testAssertsFailed; } /*! @@ -87,18 +87,18 @@ void _BailOut() { if(!canBailOut) - return ; + return ; - AssertSummary(_testAssertsFailed + _testAssertsPassed, + AssertSummary(_testAssertsFailed + _testAssertsPassed, _testAssertsFailed, _testAssertsPassed, time(0)); - if(GetInvocationCount() > 0) { - Log(time(0), "Fuzzer invocation count: %d", GetInvocationCount()); - } + if(GetInvocationCount() > 0) { + Log(time(0), "Fuzzer invocation count: %d", GetInvocationCount()); + } - DeinitFuzzer(); + DeinitFuzzer(); - exit(TEST_RESULT_FAILURE); // bail out from the test + exit(TEST_RESULT_FAILURE); // bail out from the test } void @@ -120,8 +120,8 @@ AssertEquals(int expected, int actual, char *message, ...) _BailOut(); } else { - AssertWithValues("AssertEquals", 1, buf, - actual, expected, time(0)); + AssertWithValues("AssertEquals", 1, buf, + actual, expected, time(0)); _testAssertsPassed++; } @@ -145,9 +145,9 @@ AssertTrue(int condition, char *message, ...) _BailOut(); } else { - Assert("AssertTrue", 1, buf, time(0)); + Assert("AssertTrue", 1, buf, time(0)); - _testAssertsPassed++; + _testAssertsPassed++; } } @@ -156,7 +156,7 @@ AssertPass(char *message, ...) { va_list args; char buf[256]; - + va_start( args, message ); SDL_vsnprintf( buf, sizeof(buf), message, args ); va_end( args ); @@ -172,7 +172,7 @@ AssertFail(char *message, ...) { va_list args; char buf[256]; - + va_start( args, message ); SDL_vsnprintf( buf, sizeof(buf), message, args ); va_end( args ); diff --git a/test/test-automation/src/libSDLtest/common/common.h b/test/test-automation/src/libSDLtest/common/common.h index cf40f1feb..f2abc9564 100644 --- a/test/test-automation/src/libSDLtest/common/common.h +++ b/test/test-automation/src/libSDLtest/common/common.h @@ -22,12 +22,12 @@ typedef struct SurfaceImage_s { int width; int height; - unsigned int bytes_per_pixel; /* 3:RGB, 4:RGBA */ + unsigned int bytes_per_pixel; /* 3:RGB, 4:RGBA */ const unsigned char pixel_data[]; } SurfaceImage_t; -#define ALLOWABLE_ERROR_OPAQUE 0 -#define ALLOWABLE_ERROR_BLENDED 64 +#define ALLOWABLE_ERROR_OPAQUE 0 +#define ALLOWABLE_ERROR_BLENDED 64 /** * @brief Compares a surface and a surface image for equality. diff --git a/test/test-automation/src/libSDLtest/fuzzer/fuzzer.c b/test/test-automation/src/libSDLtest/fuzzer/fuzzer.c index 1d245371a..0c0fc5541 100644 --- a/test/test-automation/src/libSDLtest/fuzzer/fuzzer.c +++ b/test/test-automation/src/libSDLtest/fuzzer/fuzzer.c @@ -38,156 +38,156 @@ int invocationCounter = 0; Uint64 GenerateExecKey(char *runSeed, char *suiteName, - char *testName, int iterationNumber) + char *testName, int iterationNumber) { - if(runSeed == NULL) { - fprintf(stderr, "Error: Incorrect runSeed given to GenerateExecKey function\n"); - return -1; - } - - if(suiteName == NULL) { - fprintf(stderr, "Error: Incorrect suiteName given to GenerateExecKey function\n"); - return -1; - } - - if(testName == NULL) { - fprintf(stderr, "Error: Incorrect testName given to GenerateExecKey function\n"); - return -1; - } - - if(iterationNumber < 0) { - fprintf(stderr, "Error: Incorrect iteration number given to GenerateExecKey function\n"); - return -1; - } - - char iterationString[16]; - memset(iterationString, 0, sizeof(iterationString)); - SDL_snprintf(iterationString, sizeof(iterationString) - 1, "%d", iterationNumber); - - // combine the parameters - const Uint32 runSeedLength = strlen(runSeed); - const Uint32 suiteNameLength = strlen(suiteName); - const Uint32 testNameLength = strlen(testName); - const Uint32 iterationStringLength = strlen(iterationString); - - // size of the entire + 3 for slashes and + 1 for '\0' - const Uint32 entireString = runSeedLength + suiteNameLength + - testNameLength + iterationStringLength + 3 + 1; - - char *buffer = SDL_malloc(entireString); - if(!buffer) { - return 0; - } - - SDL_snprintf(buffer, entireString, "%s/%s/%s/%d", runSeed, suiteName, - testName, iterationNumber); - - MD5_CTX md5Context; - utl_md5Init(&md5Context); - utl_md5Update(&md5Context, buffer, entireString); - utl_md5Final(&md5Context); - - SDL_free(buffer); - - Uint64 *keys = (Uint64 *)md5Context.digest; - - return keys[0]; + if(runSeed == NULL) { + fprintf(stderr, "Error: Incorrect runSeed given to GenerateExecKey function\n"); + return -1; + } + + if(suiteName == NULL) { + fprintf(stderr, "Error: Incorrect suiteName given to GenerateExecKey function\n"); + return -1; + } + + if(testName == NULL) { + fprintf(stderr, "Error: Incorrect testName given to GenerateExecKey function\n"); + return -1; + } + + if(iterationNumber < 0) { + fprintf(stderr, "Error: Incorrect iteration number given to GenerateExecKey function\n"); + return -1; + } + + char iterationString[16]; + memset(iterationString, 0, sizeof(iterationString)); + SDL_snprintf(iterationString, sizeof(iterationString) - 1, "%d", iterationNumber); + + // combine the parameters + const Uint32 runSeedLength = strlen(runSeed); + const Uint32 suiteNameLength = strlen(suiteName); + const Uint32 testNameLength = strlen(testName); + const Uint32 iterationStringLength = strlen(iterationString); + + // size of the entire + 3 for slashes and + 1 for '\0' + const Uint32 entireString = runSeedLength + suiteNameLength + + testNameLength + iterationStringLength + 3 + 1; + + char *buffer = SDL_malloc(entireString); + if(!buffer) { + return 0; + } + + SDL_snprintf(buffer, entireString, "%s/%s/%s/%d", runSeed, suiteName, + testName, iterationNumber); + + MD5_CTX md5Context; + utl_md5Init(&md5Context); + utl_md5Update(&md5Context, buffer, entireString); + utl_md5Final(&md5Context); + + SDL_free(buffer); + + Uint64 *keys = (Uint64 *)md5Context.digest; + + return keys[0]; } void InitFuzzer(Uint64 execKey) { - Uint32 a = (execKey >> 32) & 0x00000000FFFFFFFF; - Uint32 b = execKey & 0x00000000FFFFFFFF; - utl_randomInit(&rndContext, a, b); + Uint32 a = (execKey >> 32) & 0x00000000FFFFFFFF; + Uint32 b = execKey & 0x00000000FFFFFFFF; + utl_randomInit(&rndContext, a, b); } int GetInvocationCount() { - return invocationCounter; + return invocationCounter; } void DeinitFuzzer() { - invocationCounter = 0; + invocationCounter = 0; } Uint8 RandomUint8() { - invocationCounter++; + invocationCounter++; - return (Uint8) utl_randomInt(&rndContext) & 0x000000FF; + return (Uint8) utl_randomInt(&rndContext) & 0x000000FF; } Sint8 RandomSint8() { - invocationCounter++; + invocationCounter++; - return (Sint8) utl_randomInt(&rndContext) & 0x000000FF; + return (Sint8) utl_randomInt(&rndContext) & 0x000000FF; } Uint16 RandomUint16() { - invocationCounter++; + invocationCounter++; - return (Uint16) utl_randomInt(&rndContext) & 0x0000FFFF; + return (Uint16) utl_randomInt(&rndContext) & 0x0000FFFF; } Sint16 RandomSint16() { - invocationCounter++; + invocationCounter++; - return (Sint16) utl_randomInt(&rndContext) & 0x0000FFFF; + return (Sint16) utl_randomInt(&rndContext) & 0x0000FFFF; } Sint32 RandomSint32() { - invocationCounter++; + invocationCounter++; - return (Sint32) utl_randomInt(&rndContext); + return (Sint32) utl_randomInt(&rndContext); } Uint32 RandomUint32() { - invocationCounter++; + invocationCounter++; - return (Uint32) utl_randomInt(&rndContext); + return (Uint32) utl_randomInt(&rndContext); } Uint64 RandomUint64() { - Uint64 value; + Uint64 value; - invocationCounter++; + invocationCounter++; - Uint32 *vp = (Uint32*)&value; - vp[0] = RandomSint32(); - vp[1] = RandomSint32(); + Uint32 *vp = (Uint32*)&value; + vp[0] = RandomSint32(); + vp[1] = RandomSint32(); - return value; + return value; } Sint64 RandomSint64() { - Uint64 value; + Uint64 value; - invocationCounter++; + invocationCounter++; - Uint32 *vp = (Uint32*)&value; - vp[0] = RandomSint32(); - vp[1] = RandomSint32(); + Uint32 *vp = (Uint32*)&value; + vp[0] = RandomSint32(); + vp[1] = RandomSint32(); - return value; + return value; } @@ -195,20 +195,20 @@ RandomSint64() Sint32 RandomIntegerInRange(Sint32 pMin, Sint32 pMax) { - Sint64 min = pMin; - Sint64 max = pMax; + Sint64 min = pMin; + Sint64 max = pMax; - if(pMin > pMax) { - Sint64 temp = min; - min = max; - max = temp; - } else if(pMin == pMax) { - return min; - } + if(pMin > pMax) { + Sint64 temp = min; + min = max; + max = temp; + } else if(pMin == pMax) { + return min; + } - Sint64 number = RandomUint32(); // invocation count increment in there + Sint64 number = RandomUint32(); // invocation count increment in there - return (Sint32)((number % ((max + 1) - min)) + min); + return (Sint32)((number % ((max + 1) - min)) + min); } /*! @@ -230,7 +230,7 @@ RandomIntegerInRange(Sint32 pMin, Sint32 pMax) * If outbuffer != NULL, it'll be freed. * * \param maxValue The biggest value that is acceptable for this data type. - * For instance, for Uint8 -> 255, Uint16 -> 65536 etc. + * For instance, for Uint8 -> 255, Uint16 -> 65536 etc. * \param pBoundary1 defines lower boundary * \param pBoundary2 defines upper boundary * \param validDomain Generate only for valid domain (for the data type) @@ -241,164 +241,164 @@ RandomIntegerInRange(Sint32 pMin, Sint32 pMax) */ Uint32 GenerateUnsignedBoundaryValues(const Uint64 maxValue, - Uint64 pBoundary1, Uint64 pBoundary2, SDL_bool validDomain, - Uint64 *outBuffer) + Uint64 pBoundary1, Uint64 pBoundary2, SDL_bool validDomain, + Uint64 *outBuffer) { - Uint64 boundary1 = pBoundary1, boundary2 = pBoundary2; - - if(outBuffer != NULL) { - SDL_free(outBuffer); - } - - if(boundary1 > boundary2) { - Uint64 temp = boundary1; - boundary1 = boundary2; - boundary2 = temp; - } - - Uint64 tempBuf[4]; - Uint64 index = 0; - - if(boundary1 == boundary2) { - tempBuf[index++] = boundary1; - } - else if(validDomain) { - tempBuf[index++] = boundary1; - - if(boundary1 < UINT64_MAX) - tempBuf[index++] = boundary1 + 1; - - tempBuf[index++] = boundary2 - 1; - tempBuf[index++] = boundary2; - } - else { - if(boundary1 > 0) { - tempBuf[index++] = boundary1 - 1; - } - - if(boundary2 < maxValue && boundary2 < UINT64_MAX) { - tempBuf[index++] = boundary2 + 1; - } - } - - if(index == 0) { - // There are no valid boundaries - return 0; - } - - // Create the return buffer - outBuffer = SDL_malloc(index * sizeof(Uint64)); - if(outBuffer == NULL) { - return 0; - } - - SDL_memcpy(outBuffer, tempBuf, index * sizeof(Uint64)); - - return index; + Uint64 boundary1 = pBoundary1, boundary2 = pBoundary2; + + if(outBuffer != NULL) { + SDL_free(outBuffer); + } + + if(boundary1 > boundary2) { + Uint64 temp = boundary1; + boundary1 = boundary2; + boundary2 = temp; + } + + Uint64 tempBuf[4]; + Uint64 index = 0; + + if(boundary1 == boundary2) { + tempBuf[index++] = boundary1; + } + else if(validDomain) { + tempBuf[index++] = boundary1; + + if(boundary1 < UINT64_MAX) + tempBuf[index++] = boundary1 + 1; + + tempBuf[index++] = boundary2 - 1; + tempBuf[index++] = boundary2; + } + else { + if(boundary1 > 0) { + tempBuf[index++] = boundary1 - 1; + } + + if(boundary2 < maxValue && boundary2 < UINT64_MAX) { + tempBuf[index++] = boundary2 + 1; + } + } + + if(index == 0) { + // There are no valid boundaries + return 0; + } + + // Create the return buffer + outBuffer = SDL_malloc(index * sizeof(Uint64)); + if(outBuffer == NULL) { + return 0; + } + + SDL_memcpy(outBuffer, tempBuf, index * sizeof(Uint64)); + + return index; } Uint8 RandomUint8BoundaryValue(Uint8 boundary1, Uint8 boundary2, SDL_bool validDomain) { - Uint64 *buffer = NULL; - Uint32 size; + Uint64 *buffer = NULL; + Uint32 size; - // max value for Uint8 - const Uint64 maxValue = UINT8_MAX; + // max value for Uint8 + const Uint64 maxValue = UINT8_MAX; - size = GenerateUnsignedBoundaryValues(maxValue, - (Uint64) boundary1, (Uint64) boundary2, - validDomain, buffer); - if(size == 0) { - return 0; - } + size = GenerateUnsignedBoundaryValues(maxValue, + (Uint64) boundary1, (Uint64) boundary2, + validDomain, buffer); + if(size == 0) { + return 0; + } - Uint32 index = RandomSint32() % size; - Uint8 retVal = (Uint8) buffer[index]; + Uint32 index = RandomSint32() % size; + Uint8 retVal = (Uint8) buffer[index]; - SDL_free(buffer); + SDL_free(buffer); - invocationCounter++; + invocationCounter++; - return retVal; + return retVal; } Uint16 RandomUint16BoundaryValue(Uint16 boundary1, Uint16 boundary2, SDL_bool validDomain) { - Uint64 *buffer = NULL; - Uint32 size; + Uint64 *buffer = NULL; + Uint32 size; - // max value for Uint16 - const Uint64 maxValue = UINT16_MAX; + // max value for Uint16 + const Uint64 maxValue = UINT16_MAX; - size = GenerateUnsignedBoundaryValues(maxValue, - (Uint64) boundary1, (Uint64) boundary2, - validDomain, buffer); - if(size == 0) { - return 0; - } + size = GenerateUnsignedBoundaryValues(maxValue, + (Uint64) boundary1, (Uint64) boundary2, + validDomain, buffer); + if(size == 0) { + return 0; + } - Uint32 index = RandomSint32() % size; - Uint16 retVal = (Uint16) buffer[index]; + Uint32 index = RandomSint32() % size; + Uint16 retVal = (Uint16) buffer[index]; - SDL_free(buffer); + SDL_free(buffer); - invocationCounter++; + invocationCounter++; - return retVal; + return retVal; } Uint32 RandomUint32BoundaryValue(Uint32 boundary1, Uint32 boundary2, SDL_bool validDomain) { - Uint64 *buffer = NULL; - Uint32 size; + Uint64 *buffer = NULL; + Uint32 size; - // max value for Uint32 - const Uint64 maxValue = UINT32_MAX; + // max value for Uint32 + const Uint64 maxValue = UINT32_MAX; - size = GenerateUnsignedBoundaryValues(maxValue, - (Uint64) boundary1, (Uint64) boundary2, - validDomain, buffer); - if(size == 0) { - return 0; - } + size = GenerateUnsignedBoundaryValues(maxValue, + (Uint64) boundary1, (Uint64) boundary2, + validDomain, buffer); + if(size == 0) { + return 0; + } - Uint32 index = RandomSint32() % size; - Uint32 retVal = (Uint32) buffer[index]; + Uint32 index = RandomSint32() % size; + Uint32 retVal = (Uint32) buffer[index]; - SDL_free(buffer); + SDL_free(buffer); - invocationCounter++; + invocationCounter++; - return retVal; + return retVal; } Uint64 RandomUint64BoundaryValue(Uint64 boundary1, Uint64 boundary2, SDL_bool validDomain) { - Uint64 *buffer = NULL; - Uint32 size; + Uint64 *buffer = NULL; + Uint32 size; - // max value for Uint64 - const Uint64 maxValue = UINT64_MAX; + // max value for Uint64 + const Uint64 maxValue = UINT64_MAX; - size = GenerateUnsignedBoundaryValues(maxValue, - (Uint64) boundary1, (Uint64) boundary2, - validDomain, buffer); - if(size == 0) { - return 0; - } + size = GenerateUnsignedBoundaryValues(maxValue, + (Uint64) boundary1, (Uint64) boundary2, + validDomain, buffer); + if(size == 0) { + return 0; + } - Uint32 index = RandomSint32() % size; - Uint64 retVal = (Uint64) buffer[index]; + Uint32 index = RandomSint32() % size; + Uint64 retVal = (Uint64) buffer[index]; - SDL_free(buffer); + SDL_free(buffer); - invocationCounter++; + invocationCounter++; - return retVal; + return retVal; } /*! @@ -421,9 +421,9 @@ RandomUint64BoundaryValue(Uint64 boundary1, Uint64 boundary2, SDL_bool validDoma * * * \param minValue The smallest value that is acceptable for this data type. - * For instance, for Uint8 -> -128, Uint16 -> -32,768 etc. + * For instance, for Uint8 -> -128, Uint16 -> -32,768 etc. * \param maxValue The biggest value that is acceptable for this data type. - * For instance, for Uint8 -> 127, Uint16 -> 32767 etc. + * For instance, for Uint8 -> 127, Uint16 -> 32767 etc. * \param pBoundary1 defines lower boundary * \param pBoundary2 defines upper boundary * \param validDomain Generate only for valid domain (for the data type) @@ -434,229 +434,229 @@ RandomUint64BoundaryValue(Uint64 boundary1, Uint64 boundary2, SDL_bool validDoma */ Uint32 GenerateSignedBoundaryValues(const Sint64 minValue, const Sint64 maxValue, - Sint64 pBoundary1, Sint64 pBoundary2, SDL_bool validDomain, - Sint64 *outBuffer) + Sint64 pBoundary1, Sint64 pBoundary2, SDL_bool validDomain, + Sint64 *outBuffer) { - Sint64 boundary1 = pBoundary1, boundary2 = pBoundary2; + Sint64 boundary1 = pBoundary1, boundary2 = pBoundary2; - if(outBuffer != NULL) { - SDL_free(outBuffer); - } + if(outBuffer != NULL) { + SDL_free(outBuffer); + } - if(boundary1 > boundary2) { - Sint64 temp = boundary1; - boundary1 = boundary2; - boundary2 = temp; - } + if(boundary1 > boundary2) { + Sint64 temp = boundary1; + boundary1 = boundary2; + boundary2 = temp; + } - Sint64 tempBuf[4]; + Sint64 tempBuf[4]; - Sint64 index = 0; + Sint64 index = 0; - if(boundary1 == boundary2) { - tempBuf[index++] = boundary1; - } - else if(validDomain) { - tempBuf[index++] = boundary1; + if(boundary1 == boundary2) { + tempBuf[index++] = boundary1; + } + else if(validDomain) { + tempBuf[index++] = boundary1; - if(boundary1 < LLONG_MAX) - tempBuf[index++] = boundary1 + 1; + if(boundary1 < LLONG_MAX) + tempBuf[index++] = boundary1 + 1; - if(boundary2 > LLONG_MIN) - tempBuf[index++] = boundary2 - 1; + if(boundary2 > LLONG_MIN) + tempBuf[index++] = boundary2 - 1; - tempBuf[index++] = boundary2; - } - else { - if(boundary1 > minValue && boundary1 > LLONG_MIN) { - tempBuf[index++] = boundary1 - 1; - } + tempBuf[index++] = boundary2; + } + else { + if(boundary1 > minValue && boundary1 > LLONG_MIN) { + tempBuf[index++] = boundary1 - 1; + } - if(boundary2 < maxValue && boundary2 < UINT64_MAX) { - tempBuf[index++] = boundary2 + 1; - } - } + if(boundary2 < maxValue && boundary2 < UINT64_MAX) { + tempBuf[index++] = boundary2 + 1; + } + } - if(index == 0) { - // There are no valid boundaries - return 0; - } + if(index == 0) { + // There are no valid boundaries + return 0; + } - // Create the return buffer - outBuffer = SDL_malloc(index * sizeof(Sint64)); - if(outBuffer == NULL) { - return 0; - } + // Create the return buffer + outBuffer = SDL_malloc(index * sizeof(Sint64)); + if(outBuffer == NULL) { + return 0; + } - SDL_memcpy(outBuffer, tempBuf, index * sizeof(Sint64)); + SDL_memcpy(outBuffer, tempBuf, index * sizeof(Sint64)); - return index; + return index; } Sint8 RandomSint8BoundaryValue(Sint8 boundary1, Sint8 boundary2, SDL_bool validDomain) { - Sint64 *buffer = NULL; - Uint32 size; + Sint64 *buffer = NULL; + Uint32 size; - // min & max values for Sint8 - const Sint64 maxValue = CHAR_MAX; - const Sint64 minValue = CHAR_MIN; + // min & max values for Sint8 + const Sint64 maxValue = CHAR_MAX; + const Sint64 minValue = CHAR_MIN; - size = GenerateSignedBoundaryValues(minValue, maxValue, - (Sint64) boundary1, (Sint64) boundary2, - validDomain, buffer); - if(size == 0) { - return CHAR_MIN; - } + size = GenerateSignedBoundaryValues(minValue, maxValue, + (Sint64) boundary1, (Sint64) boundary2, + validDomain, buffer); + if(size == 0) { + return CHAR_MIN; + } - Uint32 index = RandomSint32() % size; - Sint8 retVal = (Sint8) buffer[index]; + Uint32 index = RandomSint32() % size; + Sint8 retVal = (Sint8) buffer[index]; - SDL_free(buffer); + SDL_free(buffer); - invocationCounter++; + invocationCounter++; - return retVal; + return retVal; } Sint16 RandomSint16BoundaryValue(Sint16 boundary1, Sint16 boundary2, SDL_bool validDomain) { - Sint64 *buffer = NULL; - Uint32 size; + Sint64 *buffer = NULL; + Uint32 size; - // min & max values for Sint16 - const Sint64 maxValue = SHRT_MAX; - const Sint64 minValue = SHRT_MIN; + // min & max values for Sint16 + const Sint64 maxValue = SHRT_MAX; + const Sint64 minValue = SHRT_MIN; - size = GenerateSignedBoundaryValues(minValue, maxValue, - (Sint64) boundary1, (Sint64) boundary2, - validDomain, buffer); - if(size == 0) { - return SHRT_MIN; - } + size = GenerateSignedBoundaryValues(minValue, maxValue, + (Sint64) boundary1, (Sint64) boundary2, + validDomain, buffer); + if(size == 0) { + return SHRT_MIN; + } - Uint32 index = RandomSint32() % size; - Sint16 retVal = (Sint16) buffer[index]; + Uint32 index = RandomSint32() % size; + Sint16 retVal = (Sint16) buffer[index]; - SDL_free(buffer); + SDL_free(buffer); - invocationCounter++; + invocationCounter++; - return retVal; + return retVal; } Sint32 RandomSint32BoundaryValue(Sint32 boundary1, Sint32 boundary2, SDL_bool validDomain) { - Sint64 *buffer = NULL; - Uint32 size; + Sint64 *buffer = NULL; + Uint32 size; - // min & max values for Sint32 - const Sint64 maxValue = INT_MAX; - const Sint64 minValue = INT_MIN; + // min & max values for Sint32 + const Sint64 maxValue = INT_MAX; + const Sint64 minValue = INT_MIN; - size = GenerateSignedBoundaryValues(minValue, maxValue, - (Sint64) boundary1, (Sint64) boundary2, - validDomain, buffer); - if(size == 0) { - return INT_MIN; - } + size = GenerateSignedBoundaryValues(minValue, maxValue, + (Sint64) boundary1, (Sint64) boundary2, + validDomain, buffer); + if(size == 0) { + return INT_MIN; + } - Uint32 index = RandomSint32() % size; - Sint32 retVal = (Sint32) buffer[index]; + Uint32 index = RandomSint32() % size; + Sint32 retVal = (Sint32) buffer[index]; - SDL_free(buffer); + SDL_free(buffer); - invocationCounter++; + invocationCounter++; - return retVal; + return retVal; } Sint64 RandomSint64BoundaryValue(Sint64 boundary1, Sint64 boundary2, SDL_bool validDomain) { - Sint64 *buffer = NULL; - Uint32 size; + Sint64 *buffer = NULL; + Uint32 size; - // min & max values for Sint64 - const Sint64 maxValue = LLONG_MAX; - const Sint64 minValue = LLONG_MIN; + // min & max values for Sint64 + const Sint64 maxValue = LLONG_MAX; + const Sint64 minValue = LLONG_MIN; - size = GenerateSignedBoundaryValues(minValue, maxValue, - (Sint64) boundary1, (Sint64) boundary2, - validDomain, buffer); - if(size == 0) { - return LLONG_MIN; - } + size = GenerateSignedBoundaryValues(minValue, maxValue, + (Sint64) boundary1, (Sint64) boundary2, + validDomain, buffer); + if(size == 0) { + return LLONG_MIN; + } - Uint32 index = RandomSint32() % size; - Sint64 retVal = (Sint64) buffer[index]; + Uint32 index = RandomSint32() % size; + Sint64 retVal = (Sint64) buffer[index]; - SDL_free(buffer); + SDL_free(buffer); - invocationCounter++; + invocationCounter++; - return retVal; + return retVal; } float RandomUnitFloat() { - return (float) RandomUint32() / UINT_MAX; + return (float) RandomUint32() / UINT_MAX; } double RandomUnitDouble() { - return (RandomUint64() >> 11) * (1.0/9007199254740992.0); + return (RandomUint64() >> 11) * (1.0/9007199254740992.0); } float RandomFloat() { - invocationCounter++; + invocationCounter++; - // \todo to be implemented - return 0.0f; + // \todo to be implemented + return 0.0f; } double RandomDouble() { - invocationCounter++; + invocationCounter++; - // \todo to be implemented - return 0.0f; + // \todo to be implemented + return 0.0f; } char * RandomAsciiString() { - // note: invocationCounter is increment in the RandomAsciiStringWithMaximumLenght - return RandomAsciiStringWithMaximumLength(255); + // note: invocationCounter is increment in the RandomAsciiStringWithMaximumLenght + return RandomAsciiStringWithMaximumLength(255); } char * RandomAsciiStringWithMaximumLength(int maxSize) { - invocationCounter++; + invocationCounter++; - if(maxSize < 1) { - return NULL; - } + if(maxSize < 1) { + return NULL; + } - int size = (RandomUint32() % (maxSize + 1)) + 1; - char *string = SDL_malloc(size * sizeof(char)); + int size = (RandomUint32() % (maxSize + 1)) + 1; + char *string = SDL_malloc(size * sizeof(char)); - int counter = 0; - for( ; counter < size; ++counter) { - string[counter] = (char) RandomIntegerInRange(1, 127); - } + int counter = 0; + for( ; counter < size; ++counter) { + string[counter] = (char) RandomIntegerInRange(1, 127); + } - string[counter] = '\0'; + string[counter] = '\0'; - return string; + return string; } diff --git a/test/test-automation/src/libSDLtest/fuzzer/fuzzer.h b/test/test-automation/src/libSDLtest/fuzzer/fuzzer.h index f090deb7c..88096d35e 100644 --- a/test/test-automation/src/libSDLtest/fuzzer/fuzzer.h +++ b/test/test-automation/src/libSDLtest/fuzzer/fuzzer.h @@ -349,7 +349,7 @@ char *RandomAsciiStringWithMaximumLength(int maxLength); * \param iterationNumber of test iteration * * \return Generated execution key as blob of 16 bytes. It needs be deallocated. - * On error, returns NULL. + * On error, returns NULL. */ Uint64 GenerateExecKey(char *runSeed, char *suiteName, char *testName, int iterationNumber); diff --git a/test/test-automation/src/libSDLtest/fuzzer/utl_crc32.c b/test/test-automation/src/libSDLtest/fuzzer/utl_crc32.c index eb7903041..8c2e9a102 100644 --- a/test/test-automation/src/libSDLtest/fuzzer/utl_crc32.c +++ b/test/test-automation/src/libSDLtest/fuzzer/utl_crc32.c @@ -9,10 +9,10 @@ int utl_crc32Init(CRC32_CTX *crcContext) /* Sanity check context pointer */ if (crcContext==NULL) { return(-1); - } - + } + /* - * Build auxiliary table for parallel byte-at-a-time CRC-32 + * Build auxiliary table for parallel byte-at-a-time CRC-32 */ #ifdef ORIGINAL_METHOD for (i = 0; i < 256; ++i) { @@ -34,7 +34,7 @@ int utl_crc32Init(CRC32_CTX *crcContext) crcContext->crc32_table[i] = c; } #endif - + return(0); } @@ -50,7 +50,7 @@ int utl_crc32Calc(CRC32_CTX * crcContext, CrcUint8 *inBuf, CrcUint32 inLen, CrcU } if (utl_crc32CalcEnd(crcContext, crc32)) { return(-1); - } + } return(0); } @@ -62,10 +62,10 @@ int utl_crc32CalcStart(CRC32_CTX * crcContext, CrcUint32 *crc32) if (crcContext==NULL) { *crc32=0; return(-1); - } + } /* - * Preload shift register, per CRC-32 spec + * Preload shift register, per CRC-32 spec */ *crc32 = 0xffffffff; @@ -77,7 +77,7 @@ int utl_crc32CalcStart(CRC32_CTX * crcContext, CrcUint32 *crc32) int utl_crc32CalcEnd(CRC32_CTX * crcContext, CrcUint32 *crc32) { /* - * Return complement, per CRC-32 spec + * Return complement, per CRC-32 spec */ *crc32 = (~(*crc32)); @@ -95,22 +95,22 @@ int utl_crc32CalcBuffer(CRC32_CTX * crcContext, CrcUint8 *inBuf, CrcUint32 inLen if (crcContext==NULL) { *crc32=0; return(-1); - } + } /* - * Calculate CRC from data + * Calculate CRC from data */ crc = *crc32; for (p = inBuf; inLen > 0; ++p, --inLen) { -#ifdef ORIGINAL_METHOD +#ifdef ORIGINAL_METHOD crc = (crc << 8) ^ crcContext->crc32_table[(crc >> 24) ^ *p]; #else crc = ((crc >> 8) & 0x00FFFFFF) ^ crcContext->crc32_table[ (crc ^ *p) & 0xFF ]; -#endif - } +#endif + } *crc32 = crc; - + return(0); } @@ -119,7 +119,7 @@ int utl_crc32Done(CRC32_CTX * crcContext) /* Sanity check context pointer */ if (crcContext==NULL) { return(-1); - } + } return(0); } diff --git a/test/test-automation/src/libSDLtest/fuzzer/utl_crc32.h b/test/test-automation/src/libSDLtest/fuzzer/utl_crc32.h index dbbcb47ce..418d7e488 100644 --- a/test/test-automation/src/libSDLtest/fuzzer/utl_crc32.h +++ b/test/test-automation/src/libSDLtest/fuzzer/utl_crc32.h @@ -15,14 +15,14 @@ extern "C" { /* Definition shared by all CRC routines */ #ifndef CrcUint32 - #define CrcUint32 unsigned int + #define CrcUint32 unsigned int #endif #ifndef CrcUint8 - #define CrcUint8 unsigned char + #define CrcUint8 unsigned char #endif #ifdef ORIGINAL_METHOD - #define CRC32_POLY 0x04c11db7 /* AUTODIN II, Ethernet, & FDDI */ + #define CRC32_POLY 0x04c11db7 /* AUTODIN II, Ethernet, & FDDI */ #else #define CRC32_POLY 0xEDB88320 /* Perl String::CRC32 compatible */ #endif @@ -45,12 +45,12 @@ extern "C" { #define DLLINTERFACE #endif -/* +/* * utl_crc32Init: initialize the CRC context * * Parameters: * - * crcContext pointer to context variable + * crcContext pointer to context variable * * Return value: * @@ -64,10 +64,10 @@ extern "C" { /* * utl_crc32Calc: calculate a crc32 from a data block - * + * * Parameters: * - * crcContext pointer to context variable + * crcContext pointer to context variable * inBuf input buffer to checksum * inLen length of input buffer * crc32 pointer to Uint32 to store the final CRC into @@ -93,7 +93,7 @@ extern "C" { * * Parameters: * - * crcContext pointer to context variable + * crcContext pointer to context variable * * Return value: * diff --git a/test/test-automation/src/libSDLtest/fuzzer/utl_md5.c b/test/test-automation/src/libSDLtest/fuzzer/utl_md5.c index 626297bcf..c4f224735 100644 --- a/test/test-automation/src/libSDLtest/fuzzer/utl_md5.c +++ b/test/test-automation/src/libSDLtest/fuzzer/utl_md5.c @@ -81,7 +81,7 @@ static unsigned char MD5PADDING[64] = { (a) += (b); \ } -/* +/* The routine MD5Init initializes the message-digest context mdContext. All fields are set to zero. */ @@ -99,26 +99,26 @@ void utl_md5Init(MD5_CTX * mdContext) mdContext->buf[3] = (MD5UINT4) 0x10325476; } -/* +/* The routine MD5Update updates the message-digest context to account for the presence of each of the characters inBuf[0..inLen-1] in the message whose digest is being computed. */ void utl_md5Update(MD5_CTX * mdContext, unsigned char *inBuf, - unsigned int inLen) + unsigned int inLen) { MD5UINT4 in[16]; int mdi; unsigned int i, ii; /* - * compute number of bytes mod 64 + * compute number of bytes mod 64 */ mdi = (int) ((mdContext->i[0] >> 3) & 0x3F); /* - * update number of bits + * update number of bits */ if ((mdContext->i[0] + ((MD5UINT4) inLen << 3)) < mdContext->i[0]) mdContext->i[1]++; @@ -127,26 +127,26 @@ void utl_md5Update(MD5_CTX * mdContext, unsigned char *inBuf, while (inLen--) { /* - * add new character to buffer, increment mdi + * add new character to buffer, increment mdi */ mdContext->in[mdi++] = *inBuf++; /* - * transform if necessary + * transform if necessary */ if (mdi == 0x40) { for (i = 0, ii = 0; i < 16; i++, ii += 4) - in[i] = (((MD5UINT4) mdContext->in[ii + 3]) << 24) | - (((MD5UINT4) mdContext->in[ii + 2]) << 16) | - (((MD5UINT4) mdContext->in[ii + 1]) << 8) | - ((MD5UINT4) mdContext->in[ii]); + in[i] = (((MD5UINT4) mdContext->in[ii + 3]) << 24) | + (((MD5UINT4) mdContext->in[ii + 2]) << 16) | + (((MD5UINT4) mdContext->in[ii + 1]) << 8) | + ((MD5UINT4) mdContext->in[ii]); Transform(mdContext->buf, in); mdi = 0; } } } -/* +/* The routine MD5Final terminates the message-digest computation and ends with the desired message digest in mdContext->digest[0...15]. */ @@ -159,24 +159,24 @@ void utl_md5Final(MD5_CTX * mdContext) unsigned int padLen; /* - * save number of bits + * save number of bits */ in[14] = mdContext->i[0]; in[15] = mdContext->i[1]; /* - * compute number of bytes mod 64 + * compute number of bytes mod 64 */ mdi = (int) ((mdContext->i[0] >> 3) & 0x3F); /* - * pad out to 56 mod 64 + * pad out to 56 mod 64 */ padLen = (mdi < 56) ? (56 - mdi) : (120 - mdi); utl_md5Update(mdContext, MD5PADDING, padLen); /* - * append length in bits and transform + * append length in bits and transform */ for (i = 0, ii = 0; i < 14; i++, ii += 4) in[i] = (((MD5UINT4) mdContext->in[ii + 3]) << 24) | @@ -186,7 +186,7 @@ void utl_md5Final(MD5_CTX * mdContext) Transform(mdContext->buf, in); /* - * store buffer in digest + * store buffer in digest */ for (i = 0, ii = 0; i < 4; i++, ii += 4) { mdContext->digest[ii] = (unsigned char) (mdContext->buf[i] & 0xFF); @@ -206,100 +206,100 @@ static void Transform(MD5UINT4 * buf, MD5UINT4 * in) MD5UINT4 a = buf[0], b = buf[1], c = buf[2], d = buf[3]; /* - * Round 1 + * Round 1 */ #define S11 7 #define S12 12 #define S13 17 #define S14 22 - FF(a, b, c, d, in[0], S11, 3614090360u); /* 1 */ - FF(d, a, b, c, in[1], S12, 3905402710u); /* 2 */ - FF(c, d, a, b, in[2], S13, 606105819u); /* 3 */ - FF(b, c, d, a, in[3], S14, 3250441966u); /* 4 */ - FF(a, b, c, d, in[4], S11, 4118548399u); /* 5 */ - FF(d, a, b, c, in[5], S12, 1200080426u); /* 6 */ - FF(c, d, a, b, in[6], S13, 2821735955u); /* 7 */ - FF(b, c, d, a, in[7], S14, 4249261313u); /* 8 */ - FF(a, b, c, d, in[8], S11, 1770035416u); /* 9 */ - FF(d, a, b, c, in[9], S12, 2336552879u); /* 10 */ - FF(c, d, a, b, in[10], S13, 4294925233u); /* 11 */ - FF(b, c, d, a, in[11], S14, 2304563134u); /* 12 */ - FF(a, b, c, d, in[12], S11, 1804603682u); /* 13 */ - FF(d, a, b, c, in[13], S12, 4254626195u); /* 14 */ - FF(c, d, a, b, in[14], S13, 2792965006u); /* 15 */ - FF(b, c, d, a, in[15], S14, 1236535329u); /* 16 */ + FF(a, b, c, d, in[0], S11, 3614090360u); /* 1 */ + FF(d, a, b, c, in[1], S12, 3905402710u); /* 2 */ + FF(c, d, a, b, in[2], S13, 606105819u); /* 3 */ + FF(b, c, d, a, in[3], S14, 3250441966u); /* 4 */ + FF(a, b, c, d, in[4], S11, 4118548399u); /* 5 */ + FF(d, a, b, c, in[5], S12, 1200080426u); /* 6 */ + FF(c, d, a, b, in[6], S13, 2821735955u); /* 7 */ + FF(b, c, d, a, in[7], S14, 4249261313u); /* 8 */ + FF(a, b, c, d, in[8], S11, 1770035416u); /* 9 */ + FF(d, a, b, c, in[9], S12, 2336552879u); /* 10 */ + FF(c, d, a, b, in[10], S13, 4294925233u); /* 11 */ + FF(b, c, d, a, in[11], S14, 2304563134u); /* 12 */ + FF(a, b, c, d, in[12], S11, 1804603682u); /* 13 */ + FF(d, a, b, c, in[13], S12, 4254626195u); /* 14 */ + FF(c, d, a, b, in[14], S13, 2792965006u); /* 15 */ + FF(b, c, d, a, in[15], S14, 1236535329u); /* 16 */ /* - * Round 2 + * Round 2 */ #define S21 5 #define S22 9 #define S23 14 #define S24 20 - GG(a, b, c, d, in[1], S21, 4129170786u); /* 17 */ - GG(d, a, b, c, in[6], S22, 3225465664u); /* 18 */ - GG(c, d, a, b, in[11], S23, 643717713u); /* 19 */ - GG(b, c, d, a, in[0], S24, 3921069994u); /* 20 */ - GG(a, b, c, d, in[5], S21, 3593408605u); /* 21 */ - GG(d, a, b, c, in[10], S22, 38016083u); /* 22 */ - GG(c, d, a, b, in[15], S23, 3634488961u); /* 23 */ - GG(b, c, d, a, in[4], S24, 3889429448u); /* 24 */ - GG(a, b, c, d, in[9], S21, 568446438u); /* 25 */ - GG(d, a, b, c, in[14], S22, 3275163606u); /* 26 */ - GG(c, d, a, b, in[3], S23, 4107603335u); /* 27 */ - GG(b, c, d, a, in[8], S24, 1163531501u); /* 28 */ - GG(a, b, c, d, in[13], S21, 2850285829u); /* 29 */ - GG(d, a, b, c, in[2], S22, 4243563512u); /* 30 */ - GG(c, d, a, b, in[7], S23, 1735328473u); /* 31 */ - GG(b, c, d, a, in[12], S24, 2368359562u); /* 32 */ + GG(a, b, c, d, in[1], S21, 4129170786u); /* 17 */ + GG(d, a, b, c, in[6], S22, 3225465664u); /* 18 */ + GG(c, d, a, b, in[11], S23, 643717713u); /* 19 */ + GG(b, c, d, a, in[0], S24, 3921069994u); /* 20 */ + GG(a, b, c, d, in[5], S21, 3593408605u); /* 21 */ + GG(d, a, b, c, in[10], S22, 38016083u); /* 22 */ + GG(c, d, a, b, in[15], S23, 3634488961u); /* 23 */ + GG(b, c, d, a, in[4], S24, 3889429448u); /* 24 */ + GG(a, b, c, d, in[9], S21, 568446438u); /* 25 */ + GG(d, a, b, c, in[14], S22, 3275163606u); /* 26 */ + GG(c, d, a, b, in[3], S23, 4107603335u); /* 27 */ + GG(b, c, d, a, in[8], S24, 1163531501u); /* 28 */ + GG(a, b, c, d, in[13], S21, 2850285829u); /* 29 */ + GG(d, a, b, c, in[2], S22, 4243563512u); /* 30 */ + GG(c, d, a, b, in[7], S23, 1735328473u); /* 31 */ + GG(b, c, d, a, in[12], S24, 2368359562u); /* 32 */ /* - * Round 3 + * Round 3 */ #define S31 4 #define S32 11 #define S33 16 #define S34 23 - HH(a, b, c, d, in[5], S31, 4294588738u); /* 33 */ - HH(d, a, b, c, in[8], S32, 2272392833u); /* 34 */ - HH(c, d, a, b, in[11], S33, 1839030562u); /* 35 */ - HH(b, c, d, a, in[14], S34, 4259657740u); /* 36 */ - HH(a, b, c, d, in[1], S31, 2763975236u); /* 37 */ - HH(d, a, b, c, in[4], S32, 1272893353u); /* 38 */ - HH(c, d, a, b, in[7], S33, 4139469664u); /* 39 */ - HH(b, c, d, a, in[10], S34, 3200236656u); /* 40 */ - HH(a, b, c, d, in[13], S31, 681279174u); /* 41 */ - HH(d, a, b, c, in[0], S32, 3936430074u); /* 42 */ - HH(c, d, a, b, in[3], S33, 3572445317u); /* 43 */ - HH(b, c, d, a, in[6], S34, 76029189u); /* 44 */ - HH(a, b, c, d, in[9], S31, 3654602809u); /* 45 */ - HH(d, a, b, c, in[12], S32, 3873151461u); /* 46 */ - HH(c, d, a, b, in[15], S33, 530742520u); /* 47 */ - HH(b, c, d, a, in[2], S34, 3299628645u); /* 48 */ + HH(a, b, c, d, in[5], S31, 4294588738u); /* 33 */ + HH(d, a, b, c, in[8], S32, 2272392833u); /* 34 */ + HH(c, d, a, b, in[11], S33, 1839030562u); /* 35 */ + HH(b, c, d, a, in[14], S34, 4259657740u); /* 36 */ + HH(a, b, c, d, in[1], S31, 2763975236u); /* 37 */ + HH(d, a, b, c, in[4], S32, 1272893353u); /* 38 */ + HH(c, d, a, b, in[7], S33, 4139469664u); /* 39 */ + HH(b, c, d, a, in[10], S34, 3200236656u); /* 40 */ + HH(a, b, c, d, in[13], S31, 681279174u); /* 41 */ + HH(d, a, b, c, in[0], S32, 3936430074u); /* 42 */ + HH(c, d, a, b, in[3], S33, 3572445317u); /* 43 */ + HH(b, c, d, a, in[6], S34, 76029189u); /* 44 */ + HH(a, b, c, d, in[9], S31, 3654602809u); /* 45 */ + HH(d, a, b, c, in[12], S32, 3873151461u); /* 46 */ + HH(c, d, a, b, in[15], S33, 530742520u); /* 47 */ + HH(b, c, d, a, in[2], S34, 3299628645u); /* 48 */ /* - * Round 4 + * Round 4 */ #define S41 6 #define S42 10 #define S43 15 #define S44 21 - II(a, b, c, d, in[0], S41, 4096336452u); /* 49 */ - II(d, a, b, c, in[7], S42, 1126891415u); /* 50 */ - II(c, d, a, b, in[14], S43, 2878612391u); /* 51 */ - II(b, c, d, a, in[5], S44, 4237533241u); /* 52 */ - II(a, b, c, d, in[12], S41, 1700485571u); /* 53 */ - II(d, a, b, c, in[3], S42, 2399980690u); /* 54 */ - II(c, d, a, b, in[10], S43, 4293915773u); /* 55 */ - II(b, c, d, a, in[1], S44, 2240044497u); /* 56 */ - II(a, b, c, d, in[8], S41, 1873313359u); /* 57 */ - II(d, a, b, c, in[15], S42, 4264355552u); /* 58 */ - II(c, d, a, b, in[6], S43, 2734768916u); /* 59 */ - II(b, c, d, a, in[13], S44, 1309151649u); /* 60 */ - II(a, b, c, d, in[4], S41, 4149444226u); /* 61 */ - II(d, a, b, c, in[11], S42, 3174756917u); /* 62 */ - II(c, d, a, b, in[2], S43, 718787259u); /* 63 */ - II(b, c, d, a, in[9], S44, 3951481745u); /* 64 */ + II(a, b, c, d, in[0], S41, 4096336452u); /* 49 */ + II(d, a, b, c, in[7], S42, 1126891415u); /* 50 */ + II(c, d, a, b, in[14], S43, 2878612391u); /* 51 */ + II(b, c, d, a, in[5], S44, 4237533241u); /* 52 */ + II(a, b, c, d, in[12], S41, 1700485571u); /* 53 */ + II(d, a, b, c, in[3], S42, 2399980690u); /* 54 */ + II(c, d, a, b, in[10], S43, 4293915773u); /* 55 */ + II(b, c, d, a, in[1], S44, 2240044497u); /* 56 */ + II(a, b, c, d, in[8], S41, 1873313359u); /* 57 */ + II(d, a, b, c, in[15], S42, 4264355552u); /* 58 */ + II(c, d, a, b, in[6], S43, 2734768916u); /* 59 */ + II(b, c, d, a, in[13], S44, 1309151649u); /* 60 */ + II(a, b, c, d, in[4], S41, 4149444226u); /* 61 */ + II(d, a, b, c, in[11], S42, 3174756917u); /* 62 */ + II(c, d, a, b, in[2], S43, 718787259u); /* 63 */ + II(b, c, d, a, in[9], S44, 3951481745u); /* 64 */ buf[0] += a; buf[1] += b; diff --git a/test/test-automation/src/libSDLtest/fuzzer/utl_md5.h b/test/test-automation/src/libSDLtest/fuzzer/utl_md5.h index e812b4992..ab6dbe59e 100644 --- a/test/test-automation/src/libSDLtest/fuzzer/utl_md5.h +++ b/test/test-automation/src/libSDLtest/fuzzer/utl_md5.h @@ -40,10 +40,10 @@ extern "C" { /* Data structure for MD5 (Message-Digest) computation */ typedef struct { - MD5UINT4 i[2]; /* number of _bits_ handled mod 2^64 */ - MD5UINT4 buf[4]; /* scratch buffer */ - unsigned char in[64]; /* input buffer */ - unsigned char digest[16]; /* actual digest after MD5Final call */ + MD5UINT4 i[2]; /* number of _bits_ handled mod 2^64 */ + MD5UINT4 buf[4]; /* scratch buffer */ + unsigned char in[64]; /* input buffer */ + unsigned char digest[16]; /* actual digest after MD5Final call */ } MD5_CTX; /* ---------- Function Prototypes ------------- */ @@ -58,19 +58,19 @@ extern "C" { #define DLLINTERFACE #endif -/* +/* * utl_md5Init: initialize the context * * Parameters: * - * mdContext pointer to context variable + * mdContext pointer to context variable * * Return value: * * none * * Note: The function initializes the message-digest context - * mdContext. Call before each new use of the context - + * mdContext. Call before each new use of the context - * all fields are set to zero. */ DLLINTERFACE void utl_md5Init(MD5_CTX * mdContext); @@ -78,7 +78,7 @@ extern "C" { /* * utl_md5update: update digest from variable length data - * + * * Parameters: * * mdContext pointer to context variable @@ -89,13 +89,13 @@ extern "C" { * * none * - * Note: The function updates the message-digest context to account + * Note: The function updates the message-digest context to account * for the presence of each of the characters inBuf[0..inLen-1] * in the message whose digest is being computed. */ DLLINTERFACE void utl_md5Update(MD5_CTX * mdContext, unsigned char *inBuf, - unsigned int inLen); + unsigned int inLen); /* @@ -103,7 +103,7 @@ extern "C" { * * Parameters: * - * mdContext pointer to context variable + * mdContext pointer to context variable * * Return value: * diff --git a/test/test-automation/src/libSDLtest/fuzzer/utl_random.c b/test/test-automation/src/libSDLtest/fuzzer/utl_random.c index 9290afe47..7f540d622 100644 --- a/test/test-automation/src/libSDLtest/fuzzer/utl_random.c +++ b/test/test-automation/src/libSDLtest/fuzzer/utl_random.c @@ -1,10 +1,10 @@ -/* +/* utl_random - A "32-bit Multiply with carry" random number generator. - + A "32-bit Multiply with carry" random number generator. + */ @@ -20,7 +20,7 @@ void utl_randomInit(RND_CTX * rndContext, unsigned int xi, unsigned int ci) * 1791398085 1929682203 1683268614 1965537969 1675393560 * 1967773755 1517746329 1447497129 1655692410 1606218150 * 2051013963 1075433238 1557985959 1781943330 1893513180 - * 1631296680 2131995753 2083801278 1873196400 1554115554 + * 1631296680 2131995753 2083801278 1873196400 1554115554 */ rndContext->a = 1655692410; rndContext->x = 30903; @@ -37,7 +37,7 @@ void utl_randomInit(RND_CTX * rndContext, unsigned int xi, unsigned int ci) void utl_randomInitTime(RND_CTX * rndContext) { int a,b; - + srand(time(NULL)); a=rand(); srand(clock()); diff --git a/test/test-automation/src/libSDLtest/fuzzer/utl_random.h b/test/test-automation/src/libSDLtest/fuzzer/utl_random.h index 7fcaa71bf..cd4379c99 100644 --- a/test/test-automation/src/libSDLtest/fuzzer/utl_random.h +++ b/test/test-automation/src/libSDLtest/fuzzer/utl_random.h @@ -1,11 +1,11 @@ -/* +/* - A "32-bit Multiply with carry: random number generator. + A "32-bit Multiply with carry: random number generator. Has a list of recommended multipliers. Very fast and good. - + multiply-with-carry generator" x(n) = a*x(n-1) + carry mod 2^32. period" (a*2^31)-1 - + */ #ifndef _utl_random_h @@ -28,8 +28,8 @@ extern "C" { * Macros that return random number in a specific format. See utl_random() * below for details. Float values are in the range [0.0-1.0]. */ -#define utl_randomInt(c) ((int)utl_random(c)) -#define utl_randomFloat(c) ((double)utl_random(c)/(unsigned long)0xffffffff) +#define utl_randomInt(c) ((int)utl_random(c)) +#define utl_randomFloat(c) ((double)utl_random(c)/(unsigned long)0xffffffff) typedef struct { unsigned int a; @@ -51,8 +51,8 @@ extern "C" { #define DLLINTERFACE #endif -/* - * utl_randomInit: Initialize random number generator with two integers. +/* + * utl_randomInit: Initialize random number generator with two integers. * * Paramaters: * @@ -68,10 +68,10 @@ extern "C" { * */ DLLINTERFACE void utl_randomInit(RND_CTX * rndContext, unsigned int xi, - unsigned int ci); + unsigned int ci); -/* - * utl_randomInitTime: Initialize random number generator with the time +/* + * utl_randomInitTime: Initialize random number generator with the time * * Parameters: * @@ -85,8 +85,8 @@ extern "C" { DLLINTERFACE void utl_randomInitTime(RND_CTX * rndContext); -/* - * utl_random: Returns random numbers +/* + * utl_random: Returns random numbers * * Parameters: * diff --git a/test/test-automation/src/libSDLtest/logger_helpers.c b/test/test-automation/src/libSDLtest/logger_helpers.c index f8b55513b..9e8eab025 100644 --- a/test/test-automation/src/libSDLtest/logger_helpers.c +++ b/test/test-automation/src/libSDLtest/logger_helpers.c @@ -33,12 +33,12 @@ * \returns Given integer as string */ char *IntToString(const int integer) { - static char buffer[256]; // malloc might work better - memset(buffer, 0, sizeof(buffer)); + static char buffer[256]; // malloc might work better + memset(buffer, 0, sizeof(buffer)); - SDL_snprintf(buffer, sizeof(buffer), "%d", integer); + SDL_snprintf(buffer, sizeof(buffer), "%d", integer); - return buffer; + return buffer; } /*! @@ -53,12 +53,12 @@ char *IntToString(const int integer) { * \returns Given integer as string in hex fomat */ char *IntToHexString(const Uint64 integer) { - static char buffer[256]; // malloc might work better - memset(buffer, 0, sizeof(buffer)); + static char buffer[256]; // malloc might work better + memset(buffer, 0, sizeof(buffer)); - SDL_snprintf(buffer, sizeof(buffer), "%llX", integer); + SDL_snprintf(buffer, sizeof(buffer), "%llX", integer); - return buffer; + return buffer; } /*! @@ -72,12 +72,12 @@ char *IntToHexString(const Uint64 integer) { * \returns Given double value as string */ char *DoubleToString(const double decimal) { - static char buffer[256]; // malloc might work better - memset(buffer, 0, sizeof(buffer)); + static char buffer[256]; // malloc might work better + memset(buffer, 0, sizeof(buffer)); - SDL_snprintf(buffer, sizeof(buffer), "%.5f", decimal); + SDL_snprintf(buffer, sizeof(buffer), "%.5f", decimal); - return buffer; + return buffer; } /*! @@ -91,15 +91,15 @@ char *DoubleToString(const double decimal) { * \return Ascii presentation */ char *TimestampToString(const time_t timestamp) { - static char buffer[256]; - memset(buffer, 0, sizeof(buffer)); + static char buffer[256]; + memset(buffer, 0, sizeof(buffer)); - time_t copy = timestamp; + time_t copy = timestamp; - struct tm *local = localtime(©); - strftime(buffer, sizeof(buffer), "%a %Y-%m-%d %H:%M:%S %Z", local); + struct tm *local = localtime(©); + strftime(buffer, sizeof(buffer), "%a %Y-%m-%d %H:%M:%S %Z", local); - return buffer; + return buffer; } /*! @@ -115,15 +115,15 @@ char *TimestampToString(const time_t timestamp) { * \return Ascii presentation */ char *TimestampToStringWithFormat(const time_t timestamp, char *format) { - static char buffer[256]; - memset(buffer, 0, sizeof(buffer)); + static char buffer[256]; + memset(buffer, 0, sizeof(buffer)); - time_t copy = timestamp; + time_t copy = timestamp; - struct tm *local = localtime(©); - strftime(buffer, sizeof(buffer), format, local); + struct tm *local = localtime(©); + strftime(buffer, sizeof(buffer), format, local); - return buffer; + return buffer; } /*! Turns all the characters of the given @@ -135,23 +135,23 @@ char *TimestampToStringWithFormat(const time_t timestamp, char *format) { char * ToLowerCase(const char *string) { - if(ValidateString(string) == 0) { - return NULL; - } + if(ValidateString(string) == 0) { + return NULL; + } - const int size = SDL_strlen(string); - char *ret = SDL_malloc(size + 1); - strncpy(ret, string, size); - ret[size] = '\0'; + const int size = SDL_strlen(string); + char *ret = SDL_malloc(size + 1); + strncpy(ret, string, size); + ret[size] = '\0'; - int counter = 0; - for(; counter < size; ++counter) { - ret[counter] = tolower(ret[counter]); - } + int counter = 0; + for(; counter < size; ++counter) { + ret[counter] = tolower(ret[counter]); + } - // printf("Debug: %s == %s\n", string, ret); + // printf("Debug: %s == %s\n", string, ret); - return ret; + return ret; } /*! @@ -164,19 +164,19 @@ ToLowerCase(const char *string) int ValidateString(const char *string) { - int retVal = 1; + int retVal = 1; - if(string != NULL) { - if(SDL_strlen(string) > 0) { - retVal = 1; - } + if(string != NULL) { + if(SDL_strlen(string) > 0) { + retVal = 1; + } - retVal = 1; - } else { - retVal = 0; - } + retVal = 1; + } else { + retVal = 0; + } - return retVal; + return retVal; } diff --git a/test/test-automation/src/libSDLtest/plain_logger.c b/test/test-automation/src/libSDLtest/plain_logger.c index f570cf84d..5fc4babb5 100644 --- a/test/test-automation/src/libSDLtest/plain_logger.c +++ b/test/test-automation/src/libSDLtest/plain_logger.c @@ -48,178 +48,178 @@ static FILE *logFile; int Output(const int currentIndentLevel, const char *message, ...) { - if(logFile == NULL) { - fprintf(stderr, "logfile is NULL\n"); - exit(3); - } + if(logFile == NULL) { + fprintf(stderr, "logfile is NULL\n"); + exit(3); + } - int indent = 0; - for( ; indent < currentIndentLevel; ++indent) { - fprintf(logFile, " "); // \todo make configurable? - } + int indent = 0; + for( ; indent < currentIndentLevel; ++indent) { + fprintf(logFile, " "); // \todo make configurable? + } - char buffer[1024]; - memset(buffer, 0, 1024); + char buffer[1024]; + memset(buffer, 0, 1024); - va_list list; - va_start(list, message); + va_list list; + va_start(list, message); - SDL_vsnprintf(buffer, 1024, message, list); + SDL_vsnprintf(buffer, 1024, message, list); - va_end(list); - fprintf(logFile, "%s\n", buffer); - fflush(logFile); + va_end(list); + fprintf(logFile, "%s\n", buffer); + fflush(logFile); } void PlainRunStarted(int parameterCount, char *runnerParameters[], char *runSeed, - time_t eventTime, LoggerData *data) + time_t eventTime, LoggerData *data) { - if(data == NULL) { - fprintf(stderr, "Logger data is NULL\n"); - exit(3); - } - - // Set up the logging destination - if(data->stdoutEnabled == 1) { - logFile = stdout; - } else { - logFile = fopen(data->filename, "w"); - if(logFile == NULL) { - fprintf(stderr, "Log file %s couldn't opened\n", data->filename); - exit(3); - } - } - - - level = data->level; - - Output(indentLevel, "Test run started at %s", TimestampToString(eventTime)); - Output(indentLevel, "Fuzzer seed is: %s", runSeed); - Output(indentLevel, "Runner parameters: "); - - int counter = 0; - for(counter = 0; counter < parameterCount; counter++) { - char *parameter = runnerParameters[counter]; - Output(indentLevel, "\t%s", parameter); - } - - Output(indentLevel, ""); + if(data == NULL) { + fprintf(stderr, "Logger data is NULL\n"); + exit(3); + } + + // Set up the logging destination + if(data->stdoutEnabled == 1) { + logFile = stdout; + } else { + logFile = fopen(data->filename, "w"); + if(logFile == NULL) { + fprintf(stderr, "Log file %s couldn't opened\n", data->filename); + exit(3); + } + } + + + level = data->level; + + Output(indentLevel, "Test run started at %s", TimestampToString(eventTime)); + Output(indentLevel, "Fuzzer seed is: %s", runSeed); + Output(indentLevel, "Runner parameters: "); + + int counter = 0; + for(counter = 0; counter < parameterCount; counter++) { + char *parameter = runnerParameters[counter]; + Output(indentLevel, "\t%s", parameter); + } + + Output(indentLevel, ""); } void PlainRunEnded(int testCount, int suiteCount, int testPassCount, int testFailCount, - int testSkippedCount, time_t endTime, double totalRuntime) + int testSkippedCount, time_t endTime, double totalRuntime) { - Output(indentLevel, "Test run ended at %s", TimestampToString(endTime)); + Output(indentLevel, "Test run ended at %s", TimestampToString(endTime)); - Output(indentLevel, "Ran %d tests in %0.5f seconds from %d suites.", - testCount, totalRuntime, suiteCount); + Output(indentLevel, "Ran %d tests in %0.5f seconds from %d suites.", + testCount, totalRuntime, suiteCount); - Output(indentLevel, "%d tests passed", testPassCount); - Output(indentLevel, "%d tests failed", testFailCount); - Output(indentLevel, "%d tests skipped", testSkippedCount); + Output(indentLevel, "%d tests passed", testPassCount); + Output(indentLevel, "%d tests failed", testFailCount); + Output(indentLevel, "%d tests skipped", testSkippedCount); - fclose(logFile); + fclose(logFile); } void PlainSuiteStarted(const char *suiteName, time_t eventTime) { - Output(indentLevel++, "Executing tests from %s", suiteName); + Output(indentLevel++, "Executing tests from %s", suiteName); } void PlainSuiteEnded(int testsPassed, int testsFailed, int testsSkipped, time_t endTime, double totalRuntime) { - Output(--indentLevel, "Suite executed. %d passed, %d failed and %d skipped. Total runtime %0.5f seconds", - testsPassed, testsFailed, testsSkipped, totalRuntime); - Output(indentLevel, ""); + Output(--indentLevel, "Suite executed. %d passed, %d failed and %d skipped. Total runtime %0.5f seconds", + testsPassed, testsFailed, testsSkipped, totalRuntime); + Output(indentLevel, ""); } void PlainTestStarted(const char *testName, const char *suiteName, - const char *testDescription, Uint64 execKey, time_t startTime) + const char *testDescription, Uint64 execKey, time_t startTime) { - Output(indentLevel, "Executing test: %s (in %s, exec key: %llX)", testName, suiteName, execKey); - Output(indentLevel++, "Test description: %s", testDescription); + Output(indentLevel, "Executing test: %s (in %s, exec key: %llX)", testName, suiteName, execKey); + Output(indentLevel++, "Test description: %s", testDescription); } void PlainTestEnded(const char *testName, const char *suiteName, int testResult, time_t endTime, double totalRuntime) { - switch(testResult) { - case TEST_RESULT_PASS: - Output(--indentLevel, "%s: ok", testName); - break; - case TEST_RESULT_FAILURE: - Output(--indentLevel, "%s: failed", testName); - break; - case TEST_RESULT_NO_ASSERT: - Output(--indentLevel, "%s: failed -> no assert", testName); - break; - case TEST_RESULT_SKIPPED: - Output(--indentLevel, "%s: skipped", testName); - break; - case TEST_RESULT_KILLED: - Output(--indentLevel, "%s: killed, exceeded timeout", testName); - break; - case TEST_RESULT_SETUP_FAILURE: - Output(--indentLevel, "%s: killed, setup failure", testName); - break; - } + switch(testResult) { + case TEST_RESULT_PASS: + Output(--indentLevel, "%s: ok", testName); + break; + case TEST_RESULT_FAILURE: + Output(--indentLevel, "%s: failed", testName); + break; + case TEST_RESULT_NO_ASSERT: + Output(--indentLevel, "%s: failed -> no assert", testName); + break; + case TEST_RESULT_SKIPPED: + Output(--indentLevel, "%s: skipped", testName); + break; + case TEST_RESULT_KILLED: + Output(--indentLevel, "%s: killed, exceeded timeout", testName); + break; + case TEST_RESULT_SETUP_FAILURE: + Output(--indentLevel, "%s: killed, setup failure", testName); + break; + } } void PlainAssert(const char *assertName, int assertResult, const char *assertMessage, - time_t eventTime) + time_t eventTime) { - // Log passed asserts only on VERBOSE level - if(level <= LOGGER_TERSE && assertResult == ASSERT_PASS) { - return ; - } + // Log passed asserts only on VERBOSE level + if(level <= LOGGER_TERSE && assertResult == ASSERT_PASS) { + return ; + } - const char *result = (assertResult) ? "passed" : "failed"; - Output(indentLevel, "%s: %s - %s", assertName, result, assertMessage); + const char *result = (assertResult) ? "passed" : "failed"; + Output(indentLevel, "%s: %s - %s", assertName, result, assertMessage); } void PlainAssertWithValues(const char *assertName, int assertResult, const char *assertMessage, - int actualValue, int expectedValue, time_t eventTime) + int actualValue, int expectedValue, time_t eventTime) { - // Log passed asserts only on VERBOSE level - if(level <= LOGGER_TERSE && assertResult == ASSERT_PASS) { - return ; - } - - const char *result = (assertResult) ? "passed" : "failed"; - Output(indentLevel, "%s: %s (expected %d, actualValue %d) - %s", - assertName, result, expectedValue, actualValue, assertMessage); + // Log passed asserts only on VERBOSE level + if(level <= LOGGER_TERSE && assertResult == ASSERT_PASS) { + return ; + } + + const char *result = (assertResult) ? "passed" : "failed"; + Output(indentLevel, "%s: %s (expected %d, actualValue %d) - %s", + assertName, result, expectedValue, actualValue, assertMessage); } void PlainAssertSummary(int numAsserts, int numAssertsFailed, int numAssertsPass, time_t eventTime) { - Output(indentLevel, "Assert summary: %d failed, %d passed (total: %d)", - numAssertsFailed, numAssertsPass, numAsserts); + Output(indentLevel, "Assert summary: %d failed, %d passed (total: %d)", + numAssertsFailed, numAssertsPass, numAsserts); } void PlainLog(time_t eventTime, char *fmt, ...) { - // create the log message - va_list args; - char logMessage[1024]; - memset(logMessage, 0, sizeof(logMessage)); + // create the log message + va_list args; + char logMessage[1024]; + memset(logMessage, 0, sizeof(logMessage)); - va_start( args, fmt ); - SDL_vsnprintf( logMessage, sizeof(logMessage), fmt, args ); - va_end( args ); + va_start( args, fmt ); + SDL_vsnprintf( logMessage, sizeof(logMessage), fmt, args ); + va_end( args ); - Output(indentLevel, "%s", logMessage); + Output(indentLevel, "%s", logMessage); } #endif diff --git a/test/test-automation/src/libSDLtest/plain_logger.h b/test/test-automation/src/libSDLtest/plain_logger.h index a0e1d6198..00e525c9a 100644 --- a/test/test-automation/src/libSDLtest/plain_logger.h +++ b/test/test-automation/src/libSDLtest/plain_logger.h @@ -36,7 +36,7 @@ * */ void PlainRunStarted(int parameterCount, char *runnerParameters[], char *runSeed, - time_t eventTime, LoggerData *data); + time_t eventTime, LoggerData *data); /*! * Prints out information about ending the test run. @@ -50,7 +50,7 @@ void PlainRunStarted(int parameterCount, char *runnerParameters[], char *runSeed * \param totalRuntime How long the execution took */ void PlainRunEnded(int testCount, int suiteCount, int testPassCount, int testFailCount, - int testSkippedCount, time_t endTime, double totalRuntime); + int testSkippedCount, time_t endTime, double totalRuntime); /*! * Prints the data about the test suite that'll be executed next @@ -106,7 +106,7 @@ void PlainTestEnded(const char *testName, const char *suiteName, * \param eventTime When the assert happened */ void PlainAssert(const char *assertName, int assertResult, const char *assertMessage, - time_t eventTime); + time_t eventTime); /*! * Prints information about assert that has actual and expected values @@ -119,7 +119,7 @@ void PlainAssert(const char *assertName, int assertResult, const char *assertMes * \param eventTime When the assert happened */ void PlainAssertWithValues(const char *assertName, int assertResult, const char *assertMessage, - int actualValue, int expected, time_t eventTime); + int actualValue, int expected, time_t eventTime); /*! * Prints summary of all assertions of certain tests diff --git a/test/test-automation/src/libSDLtest/xml.c b/test/test-automation/src/libSDLtest/xml.c index db7528d2d..c9cb58ef8 100644 --- a/test/test-automation/src/libSDLtest/xml.c +++ b/test/test-automation/src/libSDLtest/xml.c @@ -39,8 +39,8 @@ static const char *root; * Defines structure used for "counting" open XML-tags */ typedef struct TagList { - const char *tag; - struct TagList *next; + const char *tag; + struct TagList *next; } TagList; static TagList *openTags = NULL; @@ -53,26 +53,26 @@ static TagList *openTags = NULL; static int AddOpenTag(const char *tag) { - TagList *openTag = SDL_malloc(sizeof(TagList)); - if(openTag == NULL) { - return 1; - } - memset(openTag, 0, sizeof(TagList)); + TagList *openTag = SDL_malloc(sizeof(TagList)); + if(openTag == NULL) { + return 1; + } + memset(openTag, 0, sizeof(TagList)); - const int tagSize = SDL_strlen(tag) + 1; - openTag->tag = SDL_malloc(tagSize); - if(openTag->tag == NULL) { - SDL_free(openTag); - return 1; - } + const int tagSize = SDL_strlen(tag) + 1; + openTag->tag = SDL_malloc(tagSize); + if(openTag->tag == NULL) { + SDL_free(openTag); + return 1; + } - strncpy((char *)openTag->tag, (char *)tag, tagSize); + strncpy((char *)openTag->tag, (char *)tag, tagSize); - openTag->next = openTags; + openTag->next = openTags; - openTags = openTag; + openTags = openTag; - return 0; + return 0; } /*! @@ -83,30 +83,30 @@ AddOpenTag(const char *tag) static int RemoveOpenTag(const char *tag) { - if(openTags == NULL || ValidateString(tag) == 0) { - return 1; - } - - int retVal = 0; - - const int size = SDL_strlen(tag); - char *tempTag = SDL_malloc(size); - strncpy(tempTag, tag, size); - - // Tag should always be the same as previously opened tag - // It prevents opening and ending tag mismatch - if(SDL_strncmp(tempTag, tag, size) == 0) { - TagList *openTag = openTags; - SDL_free((char *)openTag->tag); - - openTags = openTags->next; - SDL_free(openTag); - } else { - //printf("Debug | xml.c:RemoveOpenTag(): open/end tag mismatch"); - retVal = 1; - } - - return retVal; + if(openTags == NULL || ValidateString(tag) == 0) { + return 1; + } + + int retVal = 0; + + const int size = SDL_strlen(tag); + char *tempTag = SDL_malloc(size); + strncpy(tempTag, tag, size); + + // Tag should always be the same as previously opened tag + // It prevents opening and ending tag mismatch + if(SDL_strncmp(tempTag, tag, size) == 0) { + TagList *openTag = openTags; + SDL_free((char *)openTag->tag); + + openTags = openTags->next; + SDL_free(openTag); + } else { + //printf("Debug | xml.c:RemoveOpenTag(): open/end tag mismatch"); + retVal = 1; + } + + return retVal; } /*! @@ -115,12 +115,12 @@ RemoveOpenTag(const char *tag) static void PrintOpenTags() { - printf("\nOpen tags:\n"); + printf("\nOpen tags:\n"); - TagList *openTag = NULL; - for(openTag = openTags; openTag; openTag = openTag->next) { - printf("\ttag: %s\n", openTag->tag); - } + TagList *openTag = NULL; + for(openTag = openTags; openTag; openTag = openTag->next) { + printf("\ttag: %s\n", openTag->tag); + } } @@ -134,83 +134,83 @@ PrintOpenTags() const char * EscapeString(const char *string) { - // Calculate the size of the escaped string - int totalSize = 0; - - const int maxCount = SDL_strlen(string); - - int counter = 0; - for(; counter < maxCount; ++counter) { - char character = string[counter]; - - switch(character) { - case '&': totalSize += 5; //SDL_strlen("&"); - break; - case '\'': totalSize += 6; //SDL_strlen("'"); - break; - case '"': totalSize += 6; //SDL_strlen("""); - break; - case '<': totalSize += 4; //SDL_strlen("<"); - break; - case '>': totalSize += 4; //SDL_strlen(">"); - break; - default: - totalSize += 1; - break; - } - } - totalSize += 1; // for '\0' - - char *retBuffer = SDL_malloc(totalSize * sizeof(char)); - if(retBuffer == NULL) { - return NULL; - } - - // escape the string - char *curRetBuffer = retBuffer; - const char *curString = string; - - char character = *curString; - while( (character = *curString++) ) { - - switch(character) { - case '&': - memcpy((void *)curRetBuffer, (void *)"&", 5); - curRetBuffer += 5; - break; - case '\'': - memcpy((void *)curRetBuffer, (void *)"'", 6); - curRetBuffer += 6; - break; - case '"': - memcpy((void *)curRetBuffer, (void *)""", 6); - curRetBuffer += 6; - break; - case '<': - memcpy((void *)curRetBuffer, (void *)"<", 4); - curRetBuffer += 4; - break; - case '>': - memcpy((void *)curRetBuffer, (void *)">", 4); - curRetBuffer += 4; - break; - default: - *curRetBuffer = character; - curRetBuffer += 1; - break; - } - } - - *curRetBuffer = '\0'; - - return retBuffer; + // Calculate the size of the escaped string + int totalSize = 0; + + const int maxCount = SDL_strlen(string); + + int counter = 0; + for(; counter < maxCount; ++counter) { + char character = string[counter]; + + switch(character) { + case '&': totalSize += 5; //SDL_strlen("&"); + break; + case '\'': totalSize += 6; //SDL_strlen("'"); + break; + case '"': totalSize += 6; //SDL_strlen("""); + break; + case '<': totalSize += 4; //SDL_strlen("<"); + break; + case '>': totalSize += 4; //SDL_strlen(">"); + break; + default: + totalSize += 1; + break; + } + } + totalSize += 1; // for '\0' + + char *retBuffer = SDL_malloc(totalSize * sizeof(char)); + if(retBuffer == NULL) { + return NULL; + } + + // escape the string + char *curRetBuffer = retBuffer; + const char *curString = string; + + char character = *curString; + while( (character = *curString++) ) { + + switch(character) { + case '&': + memcpy((void *)curRetBuffer, (void *)"&", 5); + curRetBuffer += 5; + break; + case '\'': + memcpy((void *)curRetBuffer, (void *)"'", 6); + curRetBuffer += 6; + break; + case '"': + memcpy((void *)curRetBuffer, (void *)""", 6); + curRetBuffer += 6; + break; + case '<': + memcpy((void *)curRetBuffer, (void *)"<", 4); + curRetBuffer += 4; + break; + case '>': + memcpy((void *)curRetBuffer, (void *)">", 4); + curRetBuffer += 4; + break; + default: + *curRetBuffer = character; + curRetBuffer += 1; + break; + } + } + + *curRetBuffer = '\0'; + + return retBuffer; } /* =================== - Functions to handle creation of XML elements + Functions to handle creation of XML elements =================== */ @@ -218,159 +218,159 @@ EscapeString(const char *string) char * XMLOpenDocument(const char *rootTag, const char *xslStyle) { - const char *doctype = "\n"; + const char *doctype = "\n"; - //! \todo refactor this mess - char *style = NULL; - if(xslStyle) { - const char *styleStart = "\n"; + //! \todo refactor this mess + char *style = NULL; + if(xslStyle) { + const char *styleStart = "\n"; - const int sizeStyleStart = SDL_strlen(styleStart); - const int sizeStyleEnd = SDL_strlen(styleEnd); - const int sizeStyleSheetName = SDL_strlen(xslStyle); + const int sizeStyleStart = SDL_strlen(styleStart); + const int sizeStyleEnd = SDL_strlen(styleEnd); + const int sizeStyleSheetName = SDL_strlen(xslStyle); - const int tempSize = sizeStyleStart + sizeStyleEnd + sizeStyleSheetName + 1; - style = SDL_malloc(tempSize); - memset(style, 0, tempSize); - SDL_snprintf(style, tempSize, "%s%s%s", styleStart, xslStyle, styleEnd); - } + const int tempSize = sizeStyleStart + sizeStyleEnd + sizeStyleSheetName + 1; + style = SDL_malloc(tempSize); + memset(style, 0, tempSize); + SDL_snprintf(style, tempSize, "%s%s%s", styleStart, xslStyle, styleEnd); + } - memset(buffer, 0, bufferSize); - SDL_snprintf(buffer, bufferSize, "<%s>", rootTag); + memset(buffer, 0, bufferSize); + SDL_snprintf(buffer, bufferSize, "<%s>", rootTag); - AddOpenTag(rootTag); + AddOpenTag(rootTag); - root = rootTag; // it's fine, as long as rootTag points to static memory? + root = rootTag; // it's fine, as long as rootTag points to static memory? - char *retBuf = NULL; - if(xslStyle) { - const int doctypeSize = SDL_strlen(doctype); - const int styleSize = SDL_strlen(style); - const int tagSize = SDL_strlen(buffer); + char *retBuf = NULL; + if(xslStyle) { + const int doctypeSize = SDL_strlen(doctype); + const int styleSize = SDL_strlen(style); + const int tagSize = SDL_strlen(buffer); - const int size = doctypeSize + styleSize + tagSize + 1; // extra byte for '\0' - retBuf = SDL_malloc(size); + const int size = doctypeSize + styleSize + tagSize + 1; // extra byte for '\0' + retBuf = SDL_malloc(size); - SDL_snprintf(retBuf, size, "%s%s%s", doctype, style, buffer); + SDL_snprintf(retBuf, size, "%s%s%s", doctype, style, buffer); - SDL_free(style); - } else { - const int doctypeSize = SDL_strlen(doctype); - const int tagSize = SDL_strlen(buffer); + SDL_free(style); + } else { + const int doctypeSize = SDL_strlen(doctype); + const int tagSize = SDL_strlen(buffer); - const int size = doctypeSize + tagSize + 1; // extra byte for '\0' - retBuf = SDL_malloc(size); + const int size = doctypeSize + tagSize + 1; // extra byte for '\0' + retBuf = SDL_malloc(size); - SDL_snprintf(retBuf, size, "%s%s", doctype, buffer); - } + SDL_snprintf(retBuf, size, "%s%s", doctype, buffer); + } - return retBuf; + return retBuf; } char * XMLCloseDocument() { - return XMLCloseElement(root); + return XMLCloseElement(root); } char * XMLOpenElement(const char *tag) { - memset(buffer, 0, bufferSize); - SDL_snprintf(buffer, bufferSize, "<%s>", tag); + memset(buffer, 0, bufferSize); + SDL_snprintf(buffer, bufferSize, "<%s>", tag); - AddOpenTag(tag); + AddOpenTag(tag); - const int size = SDL_strlen(buffer); - char *ret = SDL_malloc(size + 1); - strncpy(ret, buffer, size); - ret[size] = '\0'; + const int size = SDL_strlen(buffer); + char *ret = SDL_malloc(size + 1); + strncpy(ret, buffer, size); + ret[size] = '\0'; - return ret; + return ret; } char * XMLAddContent(const char *content) { - if(ValidateString(content) == 0) { - return NULL; - } + if(ValidateString(content) == 0) { + return NULL; + } - const char *escapedContent = EscapeString(content); + const char *escapedContent = EscapeString(content); - if(SDL_strlen(escapedContent) >= bufferSize) { - return NULL; - } + if(SDL_strlen(escapedContent) >= bufferSize) { + return NULL; + } - memset(buffer, 0, bufferSize); - SDL_snprintf(buffer, bufferSize, "%s", escapedContent); - SDL_free((char *)escapedContent); + memset(buffer, 0, bufferSize); + SDL_snprintf(buffer, bufferSize, "%s", escapedContent); + SDL_free((char *)escapedContent); - const int size = SDL_strlen(buffer); - char *ret = SDL_malloc(size + 1); - strncpy(ret, buffer, size); - ret[size] = '\0'; + const int size = SDL_strlen(buffer); + char *ret = SDL_malloc(size + 1); + strncpy(ret, buffer, size); + ret[size] = '\0'; - return ret; + return ret; } char * XMLCloseElement(const char *tag) { - if(ValidateString(tag) == 0) { - return NULL; - } + if(ValidateString(tag) == 0) { + return NULL; + } - int retBufferSize = 150; - char *ret = SDL_malloc(retBufferSize); - memset(ret, 0, retBufferSize); + int retBufferSize = 150; + char *ret = SDL_malloc(retBufferSize); + memset(ret, 0, retBufferSize); - // \todo check that element we're trying to close is actually open, - // otherwise it'll cause nesting problems + // \todo check that element we're trying to close is actually open, + // otherwise it'll cause nesting problems - // Close the open tags with proper nesting. Closes tags until it finds - // the given tag which is the last tag that will be closed - TagList *openTag = openTags; - while(openTag) { - TagList *temp = openTag->next; + // Close the open tags with proper nesting. Closes tags until it finds + // the given tag which is the last tag that will be closed + TagList *openTag = openTags; + while(openTag) { + TagList *temp = openTag->next; - char *lowOpenTag = ToLowerCase(openTag->tag); - char *lowTag = ToLowerCase(tag); + char *lowOpenTag = ToLowerCase(openTag->tag); + char *lowTag = ToLowerCase(tag); - const int openTagSize = SDL_strlen(lowOpenTag); - const int tagSize = SDL_strlen(lowTag); - const int compSize = (openTagSize > tagSize) ? openTagSize : tagSize; + const int openTagSize = SDL_strlen(lowOpenTag); + const int tagSize = SDL_strlen(lowTag); + const int compSize = (openTagSize > tagSize) ? openTagSize : tagSize; - memset(buffer, 0, bufferSize); + memset(buffer, 0, bufferSize); - int breakOut = 0; - if(SDL_strncmp(lowOpenTag, lowTag, compSize) == 0) { - breakOut = 1; - SDL_snprintf(buffer, bufferSize, "", tag); - } else { - SDL_snprintf(buffer, bufferSize, "", openTag->tag); - } + int breakOut = 0; + if(SDL_strncmp(lowOpenTag, lowTag, compSize) == 0) { + breakOut = 1; + SDL_snprintf(buffer, bufferSize, "", tag); + } else { + SDL_snprintf(buffer, bufferSize, "", openTag->tag); + } - SDL_free(lowOpenTag); - SDL_free(lowTag); + SDL_free(lowOpenTag); + SDL_free(lowTag); - int bytesLeft = bufferSize - SDL_strlen(ret); - if(bytesLeft) { - strncat(ret, buffer, bytesLeft); - } else { - // \! todo there's probably better way to report an error? - fprintf(stderr, "xml.c | XMLCloseElement: Buffer is full"); - } + int bytesLeft = bufferSize - SDL_strlen(ret); + if(bytesLeft) { + strncat(ret, buffer, bytesLeft); + } else { + // \! todo there's probably better way to report an error? + fprintf(stderr, "xml.c | XMLCloseElement: Buffer is full"); + } - RemoveOpenTag(openTag->tag); + RemoveOpenTag(openTag->tag); - openTag = temp; + openTag = temp; - if(breakOut) { - break; - } - } + if(breakOut) { + break; + } + } - return ret; + return ret; } diff --git a/test/test-automation/src/libSDLtest/xml.h b/test/test-automation/src/libSDLtest/xml.h index 98d02f866..e31019f3b 100644 --- a/test/test-automation/src/libSDLtest/xml.h +++ b/test/test-automation/src/libSDLtest/xml.h @@ -23,8 +23,8 @@ /*! Defines attribute for XML elements */ typedef struct Attribute { - const char *attribute; - const char *value; + const char *attribute; + const char *value; } Attribute; diff --git a/test/test-automation/src/libSDLtest/xml_logger.c b/test/test-automation/src/libSDLtest/xml_logger.c index 93e51678c..e164345f2 100644 --- a/test/test-automation/src/libSDLtest/xml_logger.c +++ b/test/test-automation/src/libSDLtest/xml_logger.c @@ -93,582 +93,582 @@ static FILE *logFile = NULL; */ void XMLOutputter(const int currentIndentLevel, - int EOL, const char *message) + int EOL, const char *message) { - if(ValidateString(message)) { - int indent = 0; - for( ; indent < currentIndentLevel && prevEOL; ++indent) { - fprintf(logFile, " "); // \todo make configurable? - } - - prevEOL = EOL; - - if(EOL) { - fprintf(logFile, "%s\n", message); - } else { - fprintf(logFile, "%s", message); - } - - fflush(logFile); - } else { - fprintf(logFile, "Error: Tried to output invalid string!"); - } - - SDL_free((char *)message); + if(ValidateString(message)) { + int indent = 0; + for( ; indent < currentIndentLevel && prevEOL; ++indent) { + fprintf(logFile, " "); // \todo make configurable? + } + + prevEOL = EOL; + + if(EOL) { + fprintf(logFile, "%s\n", message); + } else { + fprintf(logFile, "%s", message); + } + + fflush(logFile); + } else { + fprintf(logFile, "Error: Tried to output invalid string!"); + } + + SDL_free((char *)message); } void XMLRunStarted(int parameterCount, char *runnerParameters[], char *runSeed, - time_t eventTime, LoggerData *data) + time_t eventTime, LoggerData *data) { - // Set up the logging destination - if(data->stdoutEnabled) { - logFile = stdout; - } else { - logFile = fopen(data->filename, "w"); - if(logFile == NULL) { - fprintf(stderr, "Log file %s couldn't opened\n", data->filename); - exit(3); - } - } + // Set up the logging destination + if(data->stdoutEnabled) { + logFile = stdout; + } else { + logFile = fopen(data->filename, "w"); + if(logFile == NULL) { + fprintf(stderr, "Log file %s couldn't opened\n", data->filename); + exit(3); + } + } - // Set up the style sheet - char *xslStylesheet = (char *)data->custom; - level = data->level; - //printf("Debug: %d == %d\n", level, data->level); + // Set up the style sheet + char *xslStylesheet = (char *)data->custom; + level = data->level; + //printf("Debug: %d == %d\n", level, data->level); - char *output = XMLOpenDocument(documentRoot, xslStylesheet); - XMLOutputter(indentLevel++, YES, output); + char *output = XMLOpenDocument(documentRoot, xslStylesheet); + XMLOutputter(indentLevel++, YES, output); - // log harness parameters - output = XMLOpenElement(parametersElementName); - XMLOutputter(indentLevel++, YES, output); + // log harness parameters + output = XMLOpenElement(parametersElementName); + XMLOutputter(indentLevel++, YES, output); - int counter = 0; - for(counter = 0; counter < parameterCount; counter++) { - char *parameter = runnerParameters[counter]; + int counter = 0; + for(counter = 0; counter < parameterCount; counter++) { + char *parameter = runnerParameters[counter]; - output = XMLOpenElement(parameterElementName); - XMLOutputter(indentLevel++, NO, output); + output = XMLOpenElement(parameterElementName); + XMLOutputter(indentLevel++, NO, output); - output = XMLAddContent(parameter); - XMLOutputter(indentLevel, NO, output); + output = XMLAddContent(parameter); + XMLOutputter(indentLevel, NO, output); - output = XMLCloseElement(parameterElementName); - XMLOutputter(--indentLevel, YES, output); - } + output = XMLCloseElement(parameterElementName); + XMLOutputter(--indentLevel, YES, output); + } - output = XMLCloseElement(parametersElementName); - XMLOutputter(--indentLevel, YES, output); + output = XMLCloseElement(parametersElementName); + XMLOutputter(--indentLevel, YES, output); - // log seed - output = XMLOpenElement(seedElementName); - XMLOutputter(indentLevel++, NO, output); + // log seed + output = XMLOpenElement(seedElementName); + XMLOutputter(indentLevel++, NO, output); - output = XMLAddContent(runSeed); - XMLOutputter(indentLevel, NO, output); + output = XMLAddContent(runSeed); + XMLOutputter(indentLevel, NO, output); - output = XMLCloseElement(seedElementName); - XMLOutputter(--indentLevel, YES, output); + output = XMLCloseElement(seedElementName); + XMLOutputter(--indentLevel, YES, output); - // log start time - output = XMLOpenElement(startTimeElementName); - XMLOutputter(indentLevel++, NO, output); + // log start time + output = XMLOpenElement(startTimeElementName); + XMLOutputter(indentLevel++, NO, output); - output = XMLAddContent(TimestampToString(eventTime)); - XMLOutputter(indentLevel, NO, output); + output = XMLAddContent(TimestampToString(eventTime)); + XMLOutputter(indentLevel, NO, output); - output = XMLCloseElement(startTimeElementName); - XMLOutputter(--indentLevel, YES, output); + output = XMLCloseElement(startTimeElementName); + XMLOutputter(--indentLevel, YES, output); } void XMLRunEnded(int testCount, int suiteCount, int testPassCount, int testFailCount, - int testSkippedCount, time_t endTime, double totalRuntime) + int testSkippedCount, time_t endTime, double totalRuntime) { - // log suite count - char *output = XMLOpenElement(numSuitesElementName); - XMLOutputter(indentLevel++, NO, output); + // log suite count + char *output = XMLOpenElement(numSuitesElementName); + XMLOutputter(indentLevel++, NO, output); - output = XMLAddContent(IntToString(suiteCount)); - XMLOutputter(indentLevel, NO, output); + output = XMLAddContent(IntToString(suiteCount)); + XMLOutputter(indentLevel, NO, output); - output = XMLCloseElement(numSuitesElementName); - XMLOutputter(--indentLevel, YES, output); + output = XMLCloseElement(numSuitesElementName); + XMLOutputter(--indentLevel, YES, output); - // log test count - output = XMLOpenElement(numTestElementName); - XMLOutputter(indentLevel++, NO, output); + // log test count + output = XMLOpenElement(numTestElementName); + XMLOutputter(indentLevel++, NO, output); - output = XMLAddContent(IntToString(testCount)); - XMLOutputter(indentLevel, NO, output); + output = XMLAddContent(IntToString(testCount)); + XMLOutputter(indentLevel, NO, output); - output = XMLCloseElement(numTestElementName); - XMLOutputter(--indentLevel, YES, output); + output = XMLCloseElement(numTestElementName); + XMLOutputter(--indentLevel, YES, output); - // log passed test count - output = XMLOpenElement(numPassedTestsElementName); - XMLOutputter(indentLevel++, NO, output); + // log passed test count + output = XMLOpenElement(numPassedTestsElementName); + XMLOutputter(indentLevel++, NO, output); - output = XMLAddContent(IntToString(testPassCount)); - XMLOutputter(indentLevel, NO, output); + output = XMLAddContent(IntToString(testPassCount)); + XMLOutputter(indentLevel, NO, output); - output = XMLCloseElement(numPassedTestsElementName); - XMLOutputter(--indentLevel, YES, output); + output = XMLCloseElement(numPassedTestsElementName); + XMLOutputter(--indentLevel, YES, output); - // log failed test count - output = XMLOpenElement(numFailedTestsElementName); - XMLOutputter(indentLevel++, NO, output); + // log failed test count + output = XMLOpenElement(numFailedTestsElementName); + XMLOutputter(indentLevel++, NO, output); - output = XMLAddContent(IntToString(testFailCount)); - XMLOutputter(indentLevel, NO, output); + output = XMLAddContent(IntToString(testFailCount)); + XMLOutputter(indentLevel, NO, output); - output = XMLCloseElement(numFailedTestsElementName); - XMLOutputter(--indentLevel, YES, output); + output = XMLCloseElement(numFailedTestsElementName); + XMLOutputter(--indentLevel, YES, output); - // log skipped test count - output = XMLOpenElement(numSkippedTestsElementName); - XMLOutputter(indentLevel++, NO, output); + // log skipped test count + output = XMLOpenElement(numSkippedTestsElementName); + XMLOutputter(indentLevel++, NO, output); - output = XMLAddContent(IntToString(testSkippedCount)); - XMLOutputter(indentLevel, NO, output); + output = XMLAddContent(IntToString(testSkippedCount)); + XMLOutputter(indentLevel, NO, output); - output = XMLCloseElement(numSkippedTestsElementName); - XMLOutputter(--indentLevel, YES, output); + output = XMLCloseElement(numSkippedTestsElementName); + XMLOutputter(--indentLevel, YES, output); - // log end tite - output = XMLOpenElement(endTimeElementName); - XMLOutputter(indentLevel++, NO, output); + // log end tite + output = XMLOpenElement(endTimeElementName); + XMLOutputter(indentLevel++, NO, output); - output = XMLAddContent(TimestampToString(endTime)); - XMLOutputter(indentLevel, NO, output); + output = XMLAddContent(TimestampToString(endTime)); + XMLOutputter(indentLevel, NO, output); - output = XMLCloseElement(endTimeElementName); - XMLOutputter(--indentLevel, YES, output); + output = XMLCloseElement(endTimeElementName); + XMLOutputter(--indentLevel, YES, output); - // log total runtime - output = XMLOpenElement(totalRuntimeElementName); - XMLOutputter(indentLevel++, NO, output); + // log total runtime + output = XMLOpenElement(totalRuntimeElementName); + XMLOutputter(indentLevel++, NO, output); - output = XMLAddContent(DoubleToString(totalRuntime)); - XMLOutputter(indentLevel, NO, output); + output = XMLAddContent(DoubleToString(totalRuntime)); + XMLOutputter(indentLevel, NO, output); - output = XMLCloseElement(totalRuntimeElementName); - XMLOutputter(--indentLevel, YES, output); + output = XMLCloseElement(totalRuntimeElementName); + XMLOutputter(--indentLevel, YES, output); - output = XMLCloseDocument(documentRoot); - XMLOutputter(--indentLevel, YES, output); + output = XMLCloseDocument(documentRoot); + XMLOutputter(--indentLevel, YES, output); - // close the log file - fclose(logFile); + // close the log file + fclose(logFile); } void XMLSuiteStarted(const char *suiteName, time_t eventTime) { - // log suite name - char *output = XMLOpenElement(suiteElementName); - XMLOutputter(indentLevel++, YES, output); + // log suite name + char *output = XMLOpenElement(suiteElementName); + XMLOutputter(indentLevel++, YES, output); - output = XMLOpenElement(nameElementName); - XMLOutputter(indentLevel++, NO, output); + output = XMLOpenElement(nameElementName); + XMLOutputter(indentLevel++, NO, output); - output = XMLAddContent(suiteName); - XMLOutputter(indentLevel, NO, output); + output = XMLAddContent(suiteName); + XMLOutputter(indentLevel, NO, output); - // log test name - output = XMLCloseElement(nameElementName); - XMLOutputter(--indentLevel, YES, output); + // log test name + output = XMLCloseElement(nameElementName); + XMLOutputter(--indentLevel, YES, output); - output = XMLOpenElement(startTimeElementName); - XMLOutputter(indentLevel++, NO, output); + output = XMLOpenElement(startTimeElementName); + XMLOutputter(indentLevel++, NO, output); - // log beginning time - output = XMLAddContent(TimestampToString(eventTime)); - XMLOutputter(indentLevel, NO, output); + // log beginning time + output = XMLAddContent(TimestampToString(eventTime)); + XMLOutputter(indentLevel, NO, output); - output = XMLCloseElement(startTimeElementName); - XMLOutputter(--indentLevel, YES, output); + output = XMLCloseElement(startTimeElementName); + XMLOutputter(--indentLevel, YES, output); } void XMLSuiteEnded(int testsPassed, int testsFailed, int testsSkipped, time_t endTime, double totalRuntime) { - // log tests passed - char *output = XMLOpenElement(testsPassedElementName); - XMLOutputter(indentLevel++, NO, output); + // log tests passed + char *output = XMLOpenElement(testsPassedElementName); + XMLOutputter(indentLevel++, NO, output); - output = XMLAddContent(IntToString(testsPassed)); - XMLOutputter(indentLevel, NO, output); + output = XMLAddContent(IntToString(testsPassed)); + XMLOutputter(indentLevel, NO, output); - output = XMLCloseElement(testsPassedElementName); - XMLOutputter(--indentLevel, YES, output); + output = XMLCloseElement(testsPassedElementName); + XMLOutputter(--indentLevel, YES, output); - // log tests failed - output = XMLOpenElement(testsFailedElementName); - XMLOutputter(indentLevel++, NO, output); + // log tests failed + output = XMLOpenElement(testsFailedElementName); + XMLOutputter(indentLevel++, NO, output); - output = XMLAddContent(IntToString(testsFailed)); - XMLOutputter(indentLevel, NO, output); + output = XMLAddContent(IntToString(testsFailed)); + XMLOutputter(indentLevel, NO, output); - output = XMLCloseElement(testsFailedElementName); - XMLOutputter(--indentLevel, YES, output); + output = XMLCloseElement(testsFailedElementName); + XMLOutputter(--indentLevel, YES, output); - // log tests skipped - output = XMLOpenElement(testsSkippedElementName); - XMLOutputter(indentLevel++, NO, output); + // log tests skipped + output = XMLOpenElement(testsSkippedElementName); + XMLOutputter(indentLevel++, NO, output); - output = XMLAddContent(IntToString(testsSkipped)); - XMLOutputter(indentLevel, NO, output); + output = XMLAddContent(IntToString(testsSkipped)); + XMLOutputter(indentLevel, NO, output); - output = XMLCloseElement(testsSkippedElementName); - XMLOutputter(--indentLevel, YES, output); + output = XMLCloseElement(testsSkippedElementName); + XMLOutputter(--indentLevel, YES, output); - // log tests skipped - output = XMLOpenElement(endTimeElementName); - XMLOutputter(indentLevel++, NO, output); + // log tests skipped + output = XMLOpenElement(endTimeElementName); + XMLOutputter(indentLevel++, NO, output); - output = XMLAddContent(TimestampToString(endTime)); - XMLOutputter(indentLevel, NO, output); + output = XMLAddContent(TimestampToString(endTime)); + XMLOutputter(indentLevel, NO, output); - output = XMLCloseElement(endTimeElementName); - XMLOutputter(--indentLevel, YES, output); + output = XMLCloseElement(endTimeElementName); + XMLOutputter(--indentLevel, YES, output); - // log total runtime - output = XMLOpenElement(totalRuntimeElementName); - XMLOutputter(indentLevel++, NO, output); + // log total runtime + output = XMLOpenElement(totalRuntimeElementName); + XMLOutputter(indentLevel++, NO, output); - output = XMLAddContent(DoubleToString(totalRuntime)); - XMLOutputter(indentLevel, NO, output); + output = XMLAddContent(DoubleToString(totalRuntime)); + XMLOutputter(indentLevel, NO, output); - output = XMLCloseElement(totalRuntimeElementName); - XMLOutputter(--indentLevel, YES, output); + output = XMLCloseElement(totalRuntimeElementName); + XMLOutputter(--indentLevel, YES, output); - output = XMLCloseElement(suiteElementName); - XMLOutputter(--indentLevel, YES, output); + output = XMLCloseElement(suiteElementName); + XMLOutputter(--indentLevel, YES, output); } void XMLTestStarted(const char *testName, const char *suiteName, - const char *testDescription, Uint64 execKey, time_t startTime) + const char *testDescription, Uint64 execKey, time_t startTime) { - char * output = XMLOpenElement(testElementName); - XMLOutputter(indentLevel++, YES, output); + char * output = XMLOpenElement(testElementName); + XMLOutputter(indentLevel++, YES, output); - // log test name - output = XMLOpenElement(nameElementName); - XMLOutputter(indentLevel++, NO, output); + // log test name + output = XMLOpenElement(nameElementName); + XMLOutputter(indentLevel++, NO, output); - output = XMLAddContent(testName); - XMLOutputter(indentLevel, NO, output); + output = XMLAddContent(testName); + XMLOutputter(indentLevel, NO, output); - output = XMLCloseElement(nameElementName); - XMLOutputter(--indentLevel, YES, output); + output = XMLCloseElement(nameElementName); + XMLOutputter(--indentLevel, YES, output); - // log test description - output = XMLOpenElement(descriptionElementName); - XMLOutputter(indentLevel++, NO, output); + // log test description + output = XMLOpenElement(descriptionElementName); + XMLOutputter(indentLevel++, NO, output); - output = XMLAddContent(testDescription); - XMLOutputter(indentLevel, NO, output); + output = XMLAddContent(testDescription); + XMLOutputter(indentLevel, NO, output); - output = XMLCloseElement(descriptionElementName); - XMLOutputter(--indentLevel, YES, output); + output = XMLCloseElement(descriptionElementName); + XMLOutputter(--indentLevel, YES, output); - // log execution key - output = XMLOpenElement(execKeyElementName); - XMLOutputter(indentLevel++, NO, output); + // log execution key + output = XMLOpenElement(execKeyElementName); + XMLOutputter(indentLevel++, NO, output); - output = XMLAddContent(IntToHexString(execKey)); - XMLOutputter(indentLevel, NO, output); + output = XMLAddContent(IntToHexString(execKey)); + XMLOutputter(indentLevel, NO, output); - output = XMLCloseElement(execKeyElementName); - XMLOutputter(--indentLevel, YES, output); + output = XMLCloseElement(execKeyElementName); + XMLOutputter(--indentLevel, YES, output); - // log start time - output = XMLOpenElement(startTimeElementName); - XMLOutputter(indentLevel++, NO, output); + // log start time + output = XMLOpenElement(startTimeElementName); + XMLOutputter(indentLevel++, NO, output); - output = XMLAddContent(TimestampToString(startTime)); - XMLOutputter(indentLevel, NO, output); + output = XMLAddContent(TimestampToString(startTime)); + XMLOutputter(indentLevel, NO, output); - output = XMLCloseElement(startTimeElementName); - XMLOutputter(--indentLevel, YES, output); + output = XMLCloseElement(startTimeElementName); + XMLOutputter(--indentLevel, YES, output); } void XMLTestEnded(const char *testName, const char *suiteName, int testResult, time_t endTime, double totalRuntime) { - // Log test result - char *output = XMLOpenElement(resultElementName); - XMLOutputter(indentLevel++, NO, output); - - switch(testResult) { - case TEST_RESULT_PASS: - output = XMLAddContent("passed"); - break; - case TEST_RESULT_FAILURE: - output = XMLAddContent("failed"); - break; - case TEST_RESULT_NO_ASSERT: - output = XMLAddContent("failed"); - break; - case TEST_RESULT_SKIPPED: - output = XMLAddContent("skipped"); - break; - case TEST_RESULT_KILLED: - output = XMLAddContent("failed"); - break; - case TEST_RESULT_SETUP_FAILURE: - output = XMLAddContent("failed"); - break; - } - XMLOutputter(indentLevel, NO, output); - - output = XMLCloseElement(resultElementName); - XMLOutputter(--indentLevel, YES, output); - - // Log description of test result. Why the test failed, - // if there's some specific reason - output = XMLOpenElement(resultDescriptionElementName); - XMLOutputter(indentLevel++, NO, output); - - switch(testResult) { - case TEST_RESULT_PASS: - case TEST_RESULT_FAILURE: - case TEST_RESULT_SKIPPED: - output = XMLAddContent(""); - break; - case TEST_RESULT_NO_ASSERT: - output = XMLAddContent("No assert"); - break; - case TEST_RESULT_KILLED: - output = XMLAddContent("Timeout exceeded"); - break; - case TEST_RESULT_SETUP_FAILURE: - output = XMLAddContent("Setup failure, couldn't be executed"); - break; - } - XMLOutputter(indentLevel, NO, output); - - output = XMLCloseElement(resultDescriptionElementName); - XMLOutputter(--indentLevel, YES, output); - - // log total runtime - output = XMLOpenElement(endTimeElementName); - XMLOutputter(indentLevel++, NO, output); - - output = XMLAddContent(TimestampToString(endTime)); - XMLOutputter(indentLevel, NO, output); - - output = XMLCloseElement(endTimeElementName); - XMLOutputter(--indentLevel, YES, output); - - // log total runtime - output = XMLOpenElement(totalRuntimeElementName); - XMLOutputter(indentLevel++, NO, output); - - output = XMLAddContent(DoubleToString(totalRuntime)); - XMLOutputter(indentLevel, NO, output); - - output = XMLCloseElement(totalRuntimeElementName); - XMLOutputter(--indentLevel, YES, output); - - output = XMLCloseElement(testElementName); - XMLOutputter(--indentLevel, YES, output); + // Log test result + char *output = XMLOpenElement(resultElementName); + XMLOutputter(indentLevel++, NO, output); + + switch(testResult) { + case TEST_RESULT_PASS: + output = XMLAddContent("passed"); + break; + case TEST_RESULT_FAILURE: + output = XMLAddContent("failed"); + break; + case TEST_RESULT_NO_ASSERT: + output = XMLAddContent("failed"); + break; + case TEST_RESULT_SKIPPED: + output = XMLAddContent("skipped"); + break; + case TEST_RESULT_KILLED: + output = XMLAddContent("failed"); + break; + case TEST_RESULT_SETUP_FAILURE: + output = XMLAddContent("failed"); + break; + } + XMLOutputter(indentLevel, NO, output); + + output = XMLCloseElement(resultElementName); + XMLOutputter(--indentLevel, YES, output); + + // Log description of test result. Why the test failed, + // if there's some specific reason + output = XMLOpenElement(resultDescriptionElementName); + XMLOutputter(indentLevel++, NO, output); + + switch(testResult) { + case TEST_RESULT_PASS: + case TEST_RESULT_FAILURE: + case TEST_RESULT_SKIPPED: + output = XMLAddContent(""); + break; + case TEST_RESULT_NO_ASSERT: + output = XMLAddContent("No assert"); + break; + case TEST_RESULT_KILLED: + output = XMLAddContent("Timeout exceeded"); + break; + case TEST_RESULT_SETUP_FAILURE: + output = XMLAddContent("Setup failure, couldn't be executed"); + break; + } + XMLOutputter(indentLevel, NO, output); + + output = XMLCloseElement(resultDescriptionElementName); + XMLOutputter(--indentLevel, YES, output); + + // log total runtime + output = XMLOpenElement(endTimeElementName); + XMLOutputter(indentLevel++, NO, output); + + output = XMLAddContent(TimestampToString(endTime)); + XMLOutputter(indentLevel, NO, output); + + output = XMLCloseElement(endTimeElementName); + XMLOutputter(--indentLevel, YES, output); + + // log total runtime + output = XMLOpenElement(totalRuntimeElementName); + XMLOutputter(indentLevel++, NO, output); + + output = XMLAddContent(DoubleToString(totalRuntime)); + XMLOutputter(indentLevel, NO, output); + + output = XMLCloseElement(totalRuntimeElementName); + XMLOutputter(--indentLevel, YES, output); + + output = XMLCloseElement(testElementName); + XMLOutputter(--indentLevel, YES, output); } void XMLAssert(const char *assertName, int assertResult, const char *assertMessage, - time_t eventTime) + time_t eventTime) { - // Log passed asserts only on VERBOSE level - if(level <= LOGGER_TERSE && assertResult == ASSERT_PASS) { - return ; - } + // Log passed asserts only on VERBOSE level + if(level <= LOGGER_TERSE && assertResult == ASSERT_PASS) { + return ; + } - char *output = XMLOpenElement(assertElementName); - XMLOutputter(indentLevel++, YES, output); + char *output = XMLOpenElement(assertElementName); + XMLOutputter(indentLevel++, YES, output); - // log assert name - output = XMLOpenElement(nameElementName); - XMLOutputter(indentLevel++, NO, output); + // log assert name + output = XMLOpenElement(nameElementName); + XMLOutputter(indentLevel++, NO, output); - output = XMLAddContent(assertName); - XMLOutputter(indentLevel, NO, output); + output = XMLAddContent(assertName); + XMLOutputter(indentLevel, NO, output); - output = XMLCloseElement(nameElementName); - XMLOutputter(--indentLevel, YES, output); + output = XMLCloseElement(nameElementName); + XMLOutputter(--indentLevel, YES, output); - // log assert result - output = XMLOpenElement(resultElementName); - XMLOutputter(indentLevel++, NO, output); + // log assert result + output = XMLOpenElement(resultElementName); + XMLOutputter(indentLevel++, NO, output); - output = XMLAddContent((assertResult) ? "pass" : "failure"); - XMLOutputter(indentLevel, NO, output); + output = XMLAddContent((assertResult) ? "pass" : "failure"); + XMLOutputter(indentLevel, NO, output); - output = XMLCloseElement(resultElementName); - XMLOutputter(--indentLevel, YES, output); + output = XMLCloseElement(resultElementName); + XMLOutputter(--indentLevel, YES, output); - // log assert message - output = XMLOpenElement(messageElementName); - XMLOutputter(indentLevel++, NO, output); + // log assert message + output = XMLOpenElement(messageElementName); + XMLOutputter(indentLevel++, NO, output); - output = XMLAddContent(assertMessage); - XMLOutputter(indentLevel, NO, output); + output = XMLAddContent(assertMessage); + XMLOutputter(indentLevel, NO, output); - output = XMLCloseElement(messageElementName); - XMLOutputter(--indentLevel, YES, output); + output = XMLCloseElement(messageElementName); + XMLOutputter(--indentLevel, YES, output); - // log event time - output = XMLOpenElement(timeElementName); - XMLOutputter(indentLevel++, NO, output); + // log event time + output = XMLOpenElement(timeElementName); + XMLOutputter(indentLevel++, NO, output); - output = XMLAddContent(TimestampToString(eventTime)); - XMLOutputter(indentLevel, NO, output); + output = XMLAddContent(TimestampToString(eventTime)); + XMLOutputter(indentLevel, NO, output); - output = XMLCloseElement(timeElementName); - XMLOutputter(--indentLevel, YES, output); + output = XMLCloseElement(timeElementName); + XMLOutputter(--indentLevel, YES, output); - output = XMLCloseElement(assertElementName); - XMLOutputter(--indentLevel, YES, output); + output = XMLCloseElement(assertElementName); + XMLOutputter(--indentLevel, YES, output); } void XMLAssertWithValues(const char *assertName, int assertResult, const char *assertMessage, - int actualValue, int excpected, time_t eventTime) + int actualValue, int excpected, time_t eventTime) { - // Log passed asserts only on VERBOSE level - if(level <= LOGGER_TERSE && assertResult == ASSERT_PASS) { - return ; - } + // Log passed asserts only on VERBOSE level + if(level <= LOGGER_TERSE && assertResult == ASSERT_PASS) { + return ; + } - char *output = XMLOpenElement(assertElementName); - XMLOutputter(indentLevel++, YES, output); + char *output = XMLOpenElement(assertElementName); + XMLOutputter(indentLevel++, YES, output); - // log assert name - output = XMLOpenElement(nameElementName); - XMLOutputter(indentLevel++, NO, output); + // log assert name + output = XMLOpenElement(nameElementName); + XMLOutputter(indentLevel++, NO, output); - output = XMLAddContent(assertName); - XMLOutputter(indentLevel, NO, output); + output = XMLAddContent(assertName); + XMLOutputter(indentLevel, NO, output); - output = XMLCloseElement(nameElementName); - XMLOutputter(--indentLevel, YES, output); + output = XMLCloseElement(nameElementName); + XMLOutputter(--indentLevel, YES, output); - // log assert result - output = XMLOpenElement(resultElementName); - XMLOutputter(indentLevel++, NO, output); + // log assert result + output = XMLOpenElement(resultElementName); + XMLOutputter(indentLevel++, NO, output); - output = XMLAddContent((assertResult) ? "pass" : "failure"); - XMLOutputter(indentLevel, NO, output); + output = XMLAddContent((assertResult) ? "pass" : "failure"); + XMLOutputter(indentLevel, NO, output); - output = XMLCloseElement(resultElementName); - XMLOutputter(--indentLevel, YES, output); + output = XMLCloseElement(resultElementName); + XMLOutputter(--indentLevel, YES, output); - // log assert message - output = XMLOpenElement(messageElementName); - XMLOutputter(indentLevel++, NO, output); + // log assert message + output = XMLOpenElement(messageElementName); + XMLOutputter(indentLevel++, NO, output); - output = XMLAddContent(assertMessage); - XMLOutputter(indentLevel, NO, output); + output = XMLAddContent(assertMessage); + XMLOutputter(indentLevel, NO, output); - output = XMLCloseElement(messageElementName); - XMLOutputter(--indentLevel, YES, output); + output = XMLCloseElement(messageElementName); + XMLOutputter(--indentLevel, YES, output); - // log event time - output = XMLOpenElement(timeElementName); - XMLOutputter(indentLevel++, NO, output); + // log event time + output = XMLOpenElement(timeElementName); + XMLOutputter(indentLevel++, NO, output); - output = XMLAddContent(TimestampToString(eventTime)); - XMLOutputter(indentLevel, NO, output); + output = XMLAddContent(TimestampToString(eventTime)); + XMLOutputter(indentLevel, NO, output); - output = XMLCloseElement(timeElementName); - XMLOutputter(--indentLevel, YES, output); + output = XMLCloseElement(timeElementName); + XMLOutputter(--indentLevel, YES, output); - output = XMLCloseElement(assertElementName); - XMLOutputter(--indentLevel, YES, output); + output = XMLCloseElement(assertElementName); + XMLOutputter(--indentLevel, YES, output); } void XMLAssertSummary(int numAsserts, int numAssertsFailed, - int numAssertsPass, time_t eventTime) + int numAssertsPass, time_t eventTime) { - char *output = XMLOpenElement(assertSummaryElementName); - XMLOutputter(indentLevel++, YES, output); + char *output = XMLOpenElement(assertSummaryElementName); + XMLOutputter(indentLevel++, YES, output); - output = XMLOpenElement(assertCountElementName); - XMLOutputter(indentLevel++, NO, output); + output = XMLOpenElement(assertCountElementName); + XMLOutputter(indentLevel++, NO, output); - output = XMLAddContent(IntToString(numAsserts)); - XMLOutputter(indentLevel, NO, output); + output = XMLAddContent(IntToString(numAsserts)); + XMLOutputter(indentLevel, NO, output); - output = XMLCloseElement(assertCountElementName); - XMLOutputter(--indentLevel, YES, output); + output = XMLCloseElement(assertCountElementName); + XMLOutputter(--indentLevel, YES, output); - output = XMLOpenElement(assertsPassedElementName); - XMLOutputter(indentLevel++, NO, output); + output = XMLOpenElement(assertsPassedElementName); + XMLOutputter(indentLevel++, NO, output); - output = XMLAddContent(IntToString(numAssertsPass)); - XMLOutputter(indentLevel, NO, output); + output = XMLAddContent(IntToString(numAssertsPass)); + XMLOutputter(indentLevel, NO, output); - output = XMLCloseElement(assertsPassedElementName); - XMLOutputter(--indentLevel, YES, output); + output = XMLCloseElement(assertsPassedElementName); + XMLOutputter(--indentLevel, YES, output); - output = XMLOpenElement(assertsFailedElementName); - XMLOutputter(indentLevel++, NO, output); + output = XMLOpenElement(assertsFailedElementName); + XMLOutputter(indentLevel++, NO, output); - output = XMLAddContent(IntToString(numAsserts)); - XMLOutputter(indentLevel, NO, output); + output = XMLAddContent(IntToString(numAsserts)); + XMLOutputter(indentLevel, NO, output); - output = XMLCloseElement(assertsFailedElementName); - XMLOutputter(--indentLevel, YES, output); + output = XMLCloseElement(assertsFailedElementName); + XMLOutputter(--indentLevel, YES, output); - output = XMLCloseElement(assertSummaryElementName); - XMLOutputter(--indentLevel, YES, output); + output = XMLCloseElement(assertSummaryElementName); + XMLOutputter(--indentLevel, YES, output); } void XMLLog(time_t eventTime, char *fmt, ...) { - // create the log message - va_list args; - char logMessage[1024]; - memset(logMessage, 0, sizeof(logMessage)); + // create the log message + va_list args; + char logMessage[1024]; + memset(logMessage, 0, sizeof(logMessage)); - va_start( args, fmt ); - SDL_vsnprintf( logMessage, sizeof(logMessage), fmt, args ); - va_end( args ); + va_start( args, fmt ); + SDL_vsnprintf( logMessage, sizeof(logMessage), fmt, args ); + va_end( args ); - char *output = XMLOpenElement(logElementName); - XMLOutputter(indentLevel++, YES, output); + char *output = XMLOpenElement(logElementName); + XMLOutputter(indentLevel++, YES, output); - // log message - output = XMLOpenElement(messageElementName); - XMLOutputter(indentLevel++, NO, output); + // log message + output = XMLOpenElement(messageElementName); + XMLOutputter(indentLevel++, NO, output); - // fix this here! - output = XMLAddContent(logMessage); - XMLOutputter(indentLevel, NO, output); + // fix this here! + output = XMLAddContent(logMessage); + XMLOutputter(indentLevel, NO, output); - output = XMLCloseElement(messageElementName); - XMLOutputter(--indentLevel, YES, output); + output = XMLCloseElement(messageElementName); + XMLOutputter(--indentLevel, YES, output); - // log eventTime - output = XMLOpenElement(timeElementName); - XMLOutputter(indentLevel++, NO, output); + // log eventTime + output = XMLOpenElement(timeElementName); + XMLOutputter(indentLevel++, NO, output); - output = XMLAddContent(TimestampToString(eventTime)); - XMLOutputter(indentLevel, NO, output); + output = XMLAddContent(TimestampToString(eventTime)); + XMLOutputter(indentLevel, NO, output); - output = XMLCloseElement(timeElementName); - XMLOutputter(--indentLevel, YES, output); + output = XMLCloseElement(timeElementName); + XMLOutputter(--indentLevel, YES, output); - output = XMLCloseElement(logElementName); - XMLOutputter(--indentLevel, YES, output); + output = XMLCloseElement(logElementName); + XMLOutputter(--indentLevel, YES, output); } diff --git a/test/test-automation/src/libSDLtest/xml_logger.h b/test/test-automation/src/libSDLtest/xml_logger.h index 7ca6f58c9..fc04c52f1 100644 --- a/test/test-automation/src/libSDLtest/xml_logger.h +++ b/test/test-automation/src/libSDLtest/xml_logger.h @@ -35,7 +35,7 @@ * \param data LoggerData structure which contains data for the logger */ void XMLRunStarted(int parameterCount, char *runnerParameters[], char *runSeed, - time_t eventTime, LoggerData *data); + time_t eventTime, LoggerData *data); /*! * Prints out information about ending the test run in XML @@ -49,7 +49,7 @@ void XMLRunStarted(int parameterCount, char *runnerParameters[], char *runSeed, * \param totalRuntime How long the execution took */ void XMLRunEnded(int testCount, int suiteCount, int testPassCount, int testFailCount, - int testSkippedCount, time_t endTime, double totalRuntime); + int testSkippedCount, time_t endTime, double totalRuntime); /*! * Prints the data about the test suite that'll be executed next in XML @@ -81,7 +81,7 @@ void XMLSuiteEnded(int testsPassed, int testsFailed, int testsSkipped, * \param startTime When the test started to execute */ void XMLTestStarted(const char *testName, const char *suiteName, - const char *testDescription, Uint64 execKey, time_t startTime); + const char *testDescription, Uint64 execKey, time_t startTime); /*! * Prints information about the test test that was just executed in XML @@ -104,7 +104,7 @@ void XMLTestEnded(const char *testName, const char *suiteName, * \param eventTime When the assert happened */ void XMLAssert(const char *assertName, int assertResult, const char *assertMessage, - time_t eventTime); + time_t eventTime); /*! * Prints information about assert that has actual and expected values in XML @@ -117,7 +117,7 @@ void XMLAssert(const char *assertName, int assertResult, const char *assertMessa * \param eventTime When the assert happened */ void XMLAssertWithValues(const char *assertName, int assertResult, const char *assertMessage, - int actualValue, int expected, time_t eventTime); + int actualValue, int expected, time_t eventTime); /*! * Prints summary of all assertions of certain tests in XML diff --git a/test/test-automation/src/runner/logger.h b/test/test-automation/src/runner/logger.h index d4225e020..3c8538261 100644 --- a/test/test-automation/src/runner/logger.h +++ b/test/test-automation/src/runner/logger.h @@ -26,8 +26,8 @@ /* Logging levels */ typedef enum LogLevel { - LOGGER_TERSE = 1, - LOGGER_VERBOSE + LOGGER_TERSE = 1, + LOGGER_VERBOSE } Level; //! Default logging level @@ -35,14 +35,14 @@ typedef enum LogLevel { //! Contains information for the logger typedef struct LoggerData { - //! If enabled logger will write to stdout instead of file - int stdoutEnabled; - //!< Name and directory of the log file (ie. logs/runner-seed.log) - char *filename; - //!< Logging level of the logger (such as VERBOSE) - Level level; - //!< Some custom data that a logger needs - char *custom; + //! If enabled logger will write to stdout instead of file + int stdoutEnabled; + //!< Name and directory of the log file (ie. logs/runner-seed.log) + char *filename; + //!< Logging level of the logger (such as VERBOSE) + Level level; + //!< Some custom data that a logger needs + char *custom; } LoggerData; /*! @@ -50,30 +50,30 @@ typedef struct LoggerData { * logging interface. See the headers of implementations (plain_logger.h or * xml_logger.h) for more information. */ -typedef void (*RunStartedFp)(int parameterCount, char *runnerParameters[], char *runSeed, time_t eventTime, LoggerData *data); -typedef void (*RunEndedFp)(int testCount, int suiteCount, int testPassCount, int testFailCount, +typedef void (*RunStartedFp)(int parameterCount, char *runnerParameters[], char *runSeed, time_t eventTime, LoggerData *data); +typedef void (*RunEndedFp)(int testCount, int suiteCount, int testPassCount, int testFailCount, int testSkippedCount, time_t endTime, double totalRuntime); -typedef void (*SuiteStartedFp)(const char *suiteName, time_t eventTime); -typedef void (*SuiteEndedFp)(int testsPassed, int testsFailed, int testsSkipped, - time_t endTime, double totalRuntime); +typedef void (*SuiteStartedFp)(const char *suiteName, time_t eventTime); +typedef void (*SuiteEndedFp)(int testsPassed, int testsFailed, int testsSkipped, + time_t endTime, double totalRuntime); -typedef void (*TestStartedFp)(const char *testName, const char *suiteName, +typedef void (*TestStartedFp)(const char *testName, const char *suiteName, const char *testDescription, Uint64 execKey, time_t startTime); -typedef void (*TestEndedFp)(const char *testName, const char *suiteName, int testResult, +typedef void (*TestEndedFp)(const char *testName, const char *suiteName, int testResult, time_t endTime, double totalRuntime); -typedef void (*AssertFp)(const char *assertName, int assertResult, - const char *assertMessage, time_t eventTime); +typedef void (*AssertFp)(const char *assertName, int assertResult, + const char *assertMessage, time_t eventTime); -typedef void (*AssertWithValuesFp)(const char *assertName, int assertResult, - const char *assertMessage, int actualValue, int expected, - time_t eventTime); +typedef void (*AssertWithValuesFp)(const char *assertName, int assertResult, + const char *assertMessage, int actualValue, int expected, + time_t eventTime); -typedef void (*AssertSummaryFp)(int numAsserts, int numAssertsFailed, - int numAssertsPass, time_t eventTime); +typedef void (*AssertSummaryFp)(int numAsserts, int numAssertsFailed, + int numAssertsPass, time_t eventTime); -typedef void (*LogFp)(time_t eventTime, char *fmt, ...); +typedef void (*LogFp)(time_t eventTime, char *fmt, ...); /*! Function pointers to actual logging function implementations */ diff --git a/test/test-automation/src/runner/runner.c b/test/test-automation/src/runner/runner.c index 3303aa919..b45b33107 100644 --- a/test/test-automation/src/runner/runner.c +++ b/test/test-automation/src/runner/runner.c @@ -154,11 +154,11 @@ int testFailureCount = 0, testPassCount = 0, testSkipCount = 0; * and pointer to dynamic library. Implemented as linked list. */ typedef struct TestSuiteReference { - char *name; //!< test suite name - char *directoryPath; //!< test suites path (eg. tests/libtestsuite) - void *library; //!< pointer to shared/dynamic library implementing the suite + char *name; //!< test suite name + char *directoryPath; //!< test suites path (eg. tests/libtestsuite) + void *library; //!< pointer to shared/dynamic library implementing the suite - struct TestSuiteReference *next; //!< Pointer to next item in the list + struct TestSuiteReference *next; //!< Pointer to next item in the list } TestSuiteReference; @@ -168,22 +168,22 @@ typedef struct TestSuiteReference { * Implemented as linked list. */ typedef struct TestCaseItem { - char *testName; - char *suiteName; + char *testName; + char *suiteName; - char *description; - long requirements; - long timeout; + char *description; + long requirements; + long timeout; - InitTestInvironmentFp initTestEnvironment; - TestCaseSetUpFp testSetUp; - TestCaseFp testCase; - TestCaseTearDownFp testTearDown; - QuitTestInvironmentFp quitTestEnvironment; + InitTestInvironmentFp initTestEnvironment; + TestCaseSetUpFp testSetUp; + TestCaseFp testCase; + TestCaseTearDownFp testTearDown; + QuitTestInvironmentFp quitTestEnvironment; - CountFailedAssertsFp countFailedAsserts; + CountFailedAssertsFp countFailedAsserts; - struct TestCaseItem *next; + struct TestCaseItem *next; } TestCase; @@ -228,112 +228,112 @@ LogFp Log = NULL; * \param extension What file extension is used with dynamic objects * * \return Pointer to TestSuiteReference which holds all the info about suites - * or NULL on failure + * or NULL on failure */ TestSuiteReference * ScanForTestSuites(char *directoryName, char *extension) { - typedef struct dirent Entry; - TestSuiteReference *suites = NULL; - TestSuiteReference *reference = NULL; - Entry *entry = NULL; - DIR *directory = NULL; - - if(directoryName == NULL || extension == NULL || - SDL_strlen(directoryName) == 0 || SDL_strlen(extension) == 0) { - return NULL; - } - - directory = opendir(directoryName); - if(!directory) { - fprintf(stderr, "Failed to open test suite directory: %s\n", directoryName); - perror("Error message"); - exit(2); - } - - while( (entry = readdir(directory)) ) { - // discards . and .. and hidden files starting with dot and directories etc. - if(strlen(entry->d_name) > 2 && entry->d_name[0] != '.' && entry->d_type == DT_REG) { - const char *delimiters = "."; - char *name = strtok(entry->d_name, delimiters); - char *ext = strtok(NULL, delimiters); - - if(name == NULL || ext == NULL) { - goto error; - } - - - int ok = 1; // on default, we want to include all tests - - // filter out all other suites but the selected test suite - if(only_selected_suite) { - ok = SDL_strncmp(selected_suite_name, name, NAME_BUFFER_SIZE) == 0; - } - - if(SDL_strncmp(name, DUMMY_TEST_NAME, NAME_BUFFER_SIZE) == 0) { - if(include_dummy_suite) { - ok = 1; - } else { - ok = 0; - } - } - - if(ok && SDL_strncmp(ext, extension, SDL_strlen(extension)) == 0) { - // create test suite reference - reference = (TestSuiteReference *) SDL_malloc(sizeof(TestSuiteReference)); - if(reference == NULL) { - goto error; - } - - memset(reference, 0, sizeof(TestSuiteReference)); - - const Uint32 dirSize = SDL_strlen(directoryName); - const Uint32 extSize = SDL_strlen(ext); - const Uint32 nameSize = SDL_strlen(name) + 1; - - // copy the name - reference->name = SDL_malloc(nameSize * sizeof(char)); - if(reference->name == NULL) { - goto error; - } - - SDL_snprintf(reference->name, nameSize, "%s", name); - - // copy the directory path - const Uint32 dpSize = dirSize + nameSize + 1 + extSize + 1; - reference->directoryPath = SDL_malloc(dpSize * sizeof(char)); - if(reference->directoryPath == NULL) { - goto error; - } - - SDL_snprintf(reference->directoryPath, dpSize, "%s%s.%s", - directoryName, name, ext); - - reference->next = suites; - suites = reference; - } - } - } - - goto finished; - - error: - if(reference) { - SDL_free(reference->name); - SDL_free(reference->directoryPath); - SDL_free(reference); - } - - // Unload all the suites that are loaded thus far - UnloadTestSuites(suites); - suites = NULL; - - finished: - if(directory) { - closedir(directory); - } - - return suites; + typedef struct dirent Entry; + TestSuiteReference *suites = NULL; + TestSuiteReference *reference = NULL; + Entry *entry = NULL; + DIR *directory = NULL; + + if(directoryName == NULL || extension == NULL || + SDL_strlen(directoryName) == 0 || SDL_strlen(extension) == 0) { + return NULL; + } + + directory = opendir(directoryName); + if(!directory) { + fprintf(stderr, "Failed to open test suite directory: %s\n", directoryName); + perror("Error message"); + exit(2); + } + + while( (entry = readdir(directory)) ) { + // discards . and .. and hidden files starting with dot and directories etc. + if(strlen(entry->d_name) > 2 && entry->d_name[0] != '.' && entry->d_type == DT_REG) { + const char *delimiters = "."; + char *name = strtok(entry->d_name, delimiters); + char *ext = strtok(NULL, delimiters); + + if(name == NULL || ext == NULL) { + goto error; + } + + + int ok = 1; // on default, we want to include all tests + + // filter out all other suites but the selected test suite + if(only_selected_suite) { + ok = SDL_strncmp(selected_suite_name, name, NAME_BUFFER_SIZE) == 0; + } + + if(SDL_strncmp(name, DUMMY_TEST_NAME, NAME_BUFFER_SIZE) == 0) { + if(include_dummy_suite) { + ok = 1; + } else { + ok = 0; + } + } + + if(ok && SDL_strncmp(ext, extension, SDL_strlen(extension)) == 0) { + // create test suite reference + reference = (TestSuiteReference *) SDL_malloc(sizeof(TestSuiteReference)); + if(reference == NULL) { + goto error; + } + + memset(reference, 0, sizeof(TestSuiteReference)); + + const Uint32 dirSize = SDL_strlen(directoryName); + const Uint32 extSize = SDL_strlen(ext); + const Uint32 nameSize = SDL_strlen(name) + 1; + + // copy the name + reference->name = SDL_malloc(nameSize * sizeof(char)); + if(reference->name == NULL) { + goto error; + } + + SDL_snprintf(reference->name, nameSize, "%s", name); + + // copy the directory path + const Uint32 dpSize = dirSize + nameSize + 1 + extSize + 1; + reference->directoryPath = SDL_malloc(dpSize * sizeof(char)); + if(reference->directoryPath == NULL) { + goto error; + } + + SDL_snprintf(reference->directoryPath, dpSize, "%s%s.%s", + directoryName, name, ext); + + reference->next = suites; + suites = reference; + } + } + } + + goto finished; + + error: + if(reference) { + SDL_free(reference->name); + SDL_free(reference->directoryPath); + SDL_free(reference); + } + + // Unload all the suites that are loaded thus far + UnloadTestSuites(suites); + suites = NULL; + + finished: + if(directory) { + closedir(directory); + } + + return suites; } @@ -347,13 +347,13 @@ ScanForTestSuites(char *directoryName, char *extension) void * LoadTestSuite(const TestSuiteReference *suite) { - void *library = SDL_LoadObject(suite->directoryPath); - if(library == NULL) { - fprintf(stderr, "Loading %s failed\n", suite->name); - fprintf(stderr, "%s\n", SDL_GetError()); - } + void *library = SDL_LoadObject(suite->directoryPath); + if(library == NULL) { + fprintf(stderr, "Loading %s failed\n", suite->name); + fprintf(stderr, "%s\n", SDL_GetError()); + } - return library; + return library; } @@ -369,12 +369,12 @@ LoadTestSuite(const TestSuiteReference *suite) TestSuiteReference * LoadTestSuites(TestSuiteReference *suites) { - TestSuiteReference *reference = NULL; - for(reference = suites; reference; reference = reference->next) { - reference->library = LoadTestSuite(reference); - } + TestSuiteReference *reference = NULL; + for(reference = suites; reference; reference = reference->next) { + reference->library = LoadTestSuite(reference); + } - return suites; + return suites; } @@ -387,23 +387,23 @@ LoadTestSuites(TestSuiteReference *suites) void UnloadTestSuites(TestSuiteReference *suites) { - TestSuiteReference *ref = suites; - while(ref) { - if(ref->name) - SDL_free(ref->name); + TestSuiteReference *ref = suites; + while(ref) { + if(ref->name) + SDL_free(ref->name); - if(ref->directoryPath) - SDL_free(ref->directoryPath); + if(ref->directoryPath) + SDL_free(ref->directoryPath); - if(ref->library) - SDL_UnloadObject(ref->library); + if(ref->library) + SDL_UnloadObject(ref->library); - TestSuiteReference *temp = ref->next; - SDL_free(ref); - ref = temp; - } + TestSuiteReference *temp = ref->next; + SDL_free(ref); + ref = temp; + } - suites = NULL; + suites = NULL; } @@ -420,86 +420,86 @@ UnloadTestSuites(TestSuiteReference *suites) TestCase * LoadTestCases(TestSuiteReference *suites) { - TestCase *testCases = NULL; - - TestSuiteReference *suiteReference = NULL; - for(suiteReference = suites; suiteReference; suiteReference = suiteReference->next) { - TestCaseReference **tests = QueryTestCaseReferences(suiteReference->library); - - TestCaseReference *testReference = NULL; - int counter = 0; - for(testReference = tests[counter]; testReference; testReference = tests[++counter]) { - //void *suite = suiteReference->library; - - // Load test case functions - InitTestInvironmentFp initTestEnvironment = LoadInitTestInvironmentFunction(suiteReference->library); - QuitTestInvironmentFp quitTestEnvironment = LoadQuitTestInvironmentFunction(suiteReference->library); - - TestCaseSetUpFp testSetUp = LoadTestSetUpFunction(suiteReference->library); - TestCaseTearDownFp testTearDown = LoadTestTearDownFunction(suiteReference->library); - - TestCaseFp testCase = LoadTestCaseFunction(suiteReference->library, testReference->name); - - CountFailedAssertsFp countFailedAsserts = LoadCountFailedAssertsFunction(suiteReference->library); - - // Do the filtering - if(FilterTestCase(testReference)) { - TestCase *item = SDL_malloc(sizeof(TestCase)); - memset(item, 0, sizeof(TestCase)); - - item->initTestEnvironment = initTestEnvironment; - item->quitTestEnvironment = quitTestEnvironment; - - item->testSetUp = testSetUp; - item->testTearDown = testTearDown; - - item->testCase = testCase; - - item->countFailedAsserts = countFailedAsserts; - - // copy suite name - int length = SDL_strlen(suiteReference->name) + 1; - item->suiteName = SDL_malloc(length); - if(item->suiteName == NULL) { - SDL_free(item); - return NULL; - } - strncpy(item->suiteName, suiteReference->name, length); - - // copy test name - length = SDL_strlen(testReference->name) + 1; - item->testName = SDL_malloc(length); - if(item->testName == NULL) { - SDL_free(item->suiteName); - SDL_free(item); - return NULL; - } - strncpy(item->testName, testReference->name, length); - - // copy test description - length = SDL_strlen(testReference->description) + 1; - item->description = SDL_malloc(length); - if(item->description == NULL) { - SDL_free(item->description); - SDL_free(item->suiteName); - SDL_free(item); - return NULL; - } - strncpy(item->description, testReference->description, length); - - item->requirements = testReference->requirements; - item->timeout = testReference->timeout; - - // prepend the list - item->next = testCases; - testCases = item; - - //printf("Added test: %s\n", testReference->name); - } - } - } - - return testCases; + TestCase *testCases = NULL; + + TestSuiteReference *suiteReference = NULL; + for(suiteReference = suites; suiteReference; suiteReference = suiteReference->next) { + TestCaseReference **tests = QueryTestCaseReferences(suiteReference->library); + + TestCaseReference *testReference = NULL; + int counter = 0; + for(testReference = tests[counter]; testReference; testReference = tests[++counter]) { + //void *suite = suiteReference->library; + + // Load test case functions + InitTestInvironmentFp initTestEnvironment = LoadInitTestInvironmentFunction(suiteReference->library); + QuitTestInvironmentFp quitTestEnvironment = LoadQuitTestInvironmentFunction(suiteReference->library); + + TestCaseSetUpFp testSetUp = LoadTestSetUpFunction(suiteReference->library); + TestCaseTearDownFp testTearDown = LoadTestTearDownFunction(suiteReference->library); + + TestCaseFp testCase = LoadTestCaseFunction(suiteReference->library, testReference->name); + + CountFailedAssertsFp countFailedAsserts = LoadCountFailedAssertsFunction(suiteReference->library); + + // Do the filtering + if(FilterTestCase(testReference)) { + TestCase *item = SDL_malloc(sizeof(TestCase)); + memset(item, 0, sizeof(TestCase)); + + item->initTestEnvironment = initTestEnvironment; + item->quitTestEnvironment = quitTestEnvironment; + + item->testSetUp = testSetUp; + item->testTearDown = testTearDown; + + item->testCase = testCase; + + item->countFailedAsserts = countFailedAsserts; + + // copy suite name + int length = SDL_strlen(suiteReference->name) + 1; + item->suiteName = SDL_malloc(length); + if(item->suiteName == NULL) { + SDL_free(item); + return NULL; + } + strncpy(item->suiteName, suiteReference->name, length); + + // copy test name + length = SDL_strlen(testReference->name) + 1; + item->testName = SDL_malloc(length); + if(item->testName == NULL) { + SDL_free(item->suiteName); + SDL_free(item); + return NULL; + } + strncpy(item->testName, testReference->name, length); + + // copy test description + length = SDL_strlen(testReference->description) + 1; + item->description = SDL_malloc(length); + if(item->description == NULL) { + SDL_free(item->description); + SDL_free(item->suiteName); + SDL_free(item); + return NULL; + } + strncpy(item->description, testReference->description, length); + + item->requirements = testReference->requirements; + item->timeout = testReference->timeout; + + // prepend the list + item->next = testCases; + testCases = item; + + //printf("Added test: %s\n", testReference->name); + } + } + } + + return testCases; } @@ -512,23 +512,23 @@ LoadTestCases(TestSuiteReference *suites) void UnloadTestCases(TestCase *testCases) { - TestCase *ref = testCases; - while(ref) { - if(ref->testName) - SDL_free(ref->testName); + TestCase *ref = testCases; + while(ref) { + if(ref->testName) + SDL_free(ref->testName); - if(ref->suiteName) - SDL_free(ref->suiteName); + if(ref->suiteName) + SDL_free(ref->suiteName); - if(ref->description) - SDL_free(ref->description); + if(ref->description) + SDL_free(ref->description); - TestCase *temp = ref->next; - SDL_free(ref); - ref = temp; - } + TestCase *temp = ref->next; + SDL_free(ref); + ref = temp; + } - testCases = NULL; + testCases = NULL; } @@ -541,29 +541,29 @@ UnloadTestCases(TestCase *testCases) int FilterTestCase(TestCaseReference *testReference) { - int retVal = 1; - - if(testReference->enabled == TEST_DISABLED) { - retVal = 0; - } - - if(only_selected_test) { - if(SDL_strncmp(testReference->name, selected_test_name, NAME_BUFFER_SIZE) == 0) { - retVal = 1; - } else { - retVal = 0; - } - } - - if(only_tests_with_string) { - if(strstr(testReference->name, testcase_name_substring) != NULL) { - retVal = 1; - } else { - retVal = 0; - } - } - - return retVal; + int retVal = 1; + + if(testReference->enabled == TEST_DISABLED) { + retVal = 0; + } + + if(only_selected_test) { + if(SDL_strncmp(testReference->name, selected_test_name, NAME_BUFFER_SIZE) == 0) { + retVal = 1; + } else { + retVal = 0; + } + } + + if(only_tests_with_string) { + if(strstr(testReference->name, testcase_name_substring) != NULL) { + retVal = 1; + } else { + retVal = 0; + } + } + + return retVal; } @@ -576,21 +576,21 @@ FilterTestCase(TestCaseReference *testReference) TestCaseReference ** QueryTestCaseReferences(void *library) { - TestCaseReference **(*suite)(void); + TestCaseReference **(*suite)(void); - suite = (TestCaseReference **(*)(void)) SDL_LoadFunction(library, "QueryTestSuite"); - if(suite == NULL) { - fprintf(stderr, "Loading QueryTestCaseReferences() failed.\n"); - fprintf(stderr, "%s\n", SDL_GetError()); - } + suite = (TestCaseReference **(*)(void)) SDL_LoadFunction(library, "QueryTestSuite"); + if(suite == NULL) { + fprintf(stderr, "Loading QueryTestCaseReferences() failed.\n"); + fprintf(stderr, "%s\n", SDL_GetError()); + } - TestCaseReference **tests = suite(); - if(tests == NULL) { - fprintf(stderr, "Failed to load test references.\n"); - fprintf(stderr, "%s\n", SDL_GetError()); - } + TestCaseReference **tests = suite(); + if(tests == NULL) { + fprintf(stderr, "Failed to load test references.\n"); + fprintf(stderr, "%s\n", SDL_GetError()); + } - return tests; + return tests; } @@ -605,13 +605,13 @@ QueryTestCaseReferences(void *library) TestCaseFp LoadTestCaseFunction(void *suite, char *testName) { - TestCaseFp test = (TestCaseFp) SDL_LoadFunction(suite, testName); - if(test == NULL) { - fprintf(stderr, "Loading test %s failed, test == NULL\n", testName); - fprintf(stderr, "%s\n", SDL_GetError()); - } + TestCaseFp test = (TestCaseFp) SDL_LoadFunction(suite, testName); + if(test == NULL) { + fprintf(stderr, "Loading test %s failed, test == NULL\n", testName); + fprintf(stderr, "%s\n", SDL_GetError()); + } - return test; + return test; } @@ -625,7 +625,7 @@ LoadTestCaseFunction(void *suite, char *testName) */ TestCaseSetUpFp LoadTestSetUpFunction(void *suite) { - return (TestCaseSetUpFp) SDL_LoadFunction(suite, "SetUp"); + return (TestCaseSetUpFp) SDL_LoadFunction(suite, "SetUp"); } @@ -639,7 +639,7 @@ LoadTestSetUpFunction(void *suite) { */ TestCaseTearDownFp LoadTestTearDownFunction(void *suite) { - return (TestCaseTearDownFp) SDL_LoadFunction(suite, "TearDown"); + return (TestCaseTearDownFp) SDL_LoadFunction(suite, "TearDown"); } @@ -653,13 +653,13 @@ LoadTestTearDownFunction(void *suite) { */ InitTestInvironmentFp LoadInitTestInvironmentFunction(void *suite) { - InitTestInvironmentFp testEnvInit = (InitTestInvironmentFp) SDL_LoadFunction(suite, "_InitTestEnvironment"); - if(testEnvInit == NULL) { - fprintf(stderr, "Loading _InitTestInvironment function failed, testEnvInit == NULL\n"); - fprintf(stderr, "%s\n", SDL_GetError()); - } + InitTestInvironmentFp testEnvInit = (InitTestInvironmentFp) SDL_LoadFunction(suite, "_InitTestEnvironment"); + if(testEnvInit == NULL) { + fprintf(stderr, "Loading _InitTestInvironment function failed, testEnvInit == NULL\n"); + fprintf(stderr, "%s\n", SDL_GetError()); + } - return testEnvInit; + return testEnvInit; } @@ -673,13 +673,13 @@ LoadInitTestInvironmentFunction(void *suite) { */ QuitTestInvironmentFp LoadQuitTestInvironmentFunction(void *suite) { - QuitTestInvironmentFp testEnvQuit = (QuitTestInvironmentFp) SDL_LoadFunction(suite, "_QuitTestEnvironment"); - if(testEnvQuit == NULL) { - fprintf(stderr, "Loading _QuitTestEnvironment function failed, testEnvQuit == NULL\n"); - fprintf(stderr, "%s\n", SDL_GetError()); - } + QuitTestInvironmentFp testEnvQuit = (QuitTestInvironmentFp) SDL_LoadFunction(suite, "_QuitTestEnvironment"); + if(testEnvQuit == NULL) { + fprintf(stderr, "Loading _QuitTestEnvironment function failed, testEnvQuit == NULL\n"); + fprintf(stderr, "%s\n", SDL_GetError()); + } - return testEnvQuit; + return testEnvQuit; } @@ -693,13 +693,13 @@ LoadQuitTestInvironmentFunction(void *suite) { */ CountFailedAssertsFp LoadCountFailedAssertsFunction(void *suite) { - CountFailedAssertsFp countFailedAssert = (CountFailedAssertsFp) SDL_LoadFunction(suite, "_CountFailedAsserts"); - if(countFailedAssert == NULL) { - fprintf(stderr, "Loading _CountFailedAsserts function failed, countFailedAssert == NULL\n"); - fprintf(stderr, "%s\n", SDL_GetError()); - } + CountFailedAssertsFp countFailedAssert = (CountFailedAssertsFp) SDL_LoadFunction(suite, "_CountFailedAsserts"); + if(countFailedAssert == NULL) { + fprintf(stderr, "Loading _CountFailedAsserts function failed, countFailedAssert == NULL\n"); + fprintf(stderr, "%s\n", SDL_GetError()); + } - return countFailedAssert; + return countFailedAssert; } #define USE_SDL_TIMER_FOR_TIMEOUT @@ -713,38 +713,38 @@ LoadCountFailedAssertsFunction(void *suite) { void SetTestTimeout(int timeout, void (*callback)(int)) { - if(callback == NULL) { - fprintf(stderr, "Error: timeout callback can't be NULL"); - } + if(callback == NULL) { + fprintf(stderr, "Error: timeout callback can't be NULL"); + } - if(timeout < 0) { - fprintf(stderr, "Error: timeout value must be bigger than zero."); - } + if(timeout < 0) { + fprintf(stderr, "Error: timeout value must be bigger than zero."); + } - int tm = (timeout > universal_timeout ? timeout : universal_timeout); + int tm = (timeout > universal_timeout ? timeout : universal_timeout); #ifdef USE_SDL_TIMER_FOR_TIMEOUT - /* Init SDL timer if not initialized before */ - if(SDL_WasInit(SDL_INIT_TIMER) == 0) { - if(SDL_InitSubSystem(SDL_INIT_TIMER)) { - fprintf(stderr, "Error: Failed to init timer subsystem"); - fprintf(stderr, "%s\n", SDL_GetError()); - } - } - - /* Note: - * SDL_Init(SDL_INIT_TIMER) should be successfully called before using this - */ - int timeoutInMilliseconds = tm * 1000; - - SDL_TimerID timerID = SDL_AddTimer(timeoutInMilliseconds, (SDL_TimerCallback) callback, 0x0); - if(timerID == 0) { - fprintf(stderr, "Error: Creation of SDL timer failed.\n"); - fprintf(stderr, "Error: %s\n", SDL_GetError()); - } + /* Init SDL timer if not initialized before */ + if(SDL_WasInit(SDL_INIT_TIMER) == 0) { + if(SDL_InitSubSystem(SDL_INIT_TIMER)) { + fprintf(stderr, "Error: Failed to init timer subsystem"); + fprintf(stderr, "%s\n", SDL_GetError()); + } + } + + /* Note: + * SDL_Init(SDL_INIT_TIMER) should be successfully called before using this + */ + int timeoutInMilliseconds = tm * 1000; + + SDL_TimerID timerID = SDL_AddTimer(timeoutInMilliseconds, (SDL_TimerCallback) callback, 0x0); + if(timerID == 0) { + fprintf(stderr, "Error: Creation of SDL timer failed.\n"); + fprintf(stderr, "Error: %s\n", SDL_GetError()); + } #else - signal(SIGALRM, callback); - alarm((unsigned int) tm); + signal(SIGALRM, callback); + alarm((unsigned int) tm); #endif } @@ -764,9 +764,9 @@ SetTestTimeout(int timeout, void (*callback)(int)) void KillHungTestInChildProcess(int signum) { - (void)signum; // keeps the compiler silent about unused variable + (void)signum; // keeps the compiler silent about unused variable - exit(TEST_RESULT_KILLED); + exit(TEST_RESULT_KILLED); } /*! @@ -778,23 +778,23 @@ KillHungTestInChildProcess(int signum) int CheckTestRequirements(TestCase *testCase) { - int retVal = 1; + int retVal = 1; - if(testCase == NULL) { - fprintf(stderr, "TestCase parameter can't be NULL"); - return -1; - } + if(testCase == NULL) { + fprintf(stderr, "TestCase parameter can't be NULL"); + return -1; + } - if(testCase->requirements & TEST_REQUIRES_AUDIO) { - retVal = PlatformSupportsAudio(); - } + if(testCase->requirements & TEST_REQUIRES_AUDIO) { + retVal = PlatformSupportsAudio(); + } - if(testCase->requirements & TEST_REQUIRES_STDIO) { - retVal = PlatformSupportsStdio(); - } + if(testCase->requirements & TEST_REQUIRES_STDIO) { + retVal = PlatformSupportsStdio(); + } - return retVal; + return retVal; } @@ -808,42 +808,42 @@ CheckTestRequirements(TestCase *testCase) int RunTest(TestCase *testCase, Uint64 execKey) { - if(!testCase) { - return -1; - } - - int runnable = CheckTestRequirements(testCase); - if(runnable != 1) { - return TEST_RESULT_SKIPPED; - } - - if(testCase->timeout > 0 || universal_timeout > 0) { - if(execute_inproc) { - Log(time(0), "Test asked for timeout which is not supported."); - } - else { - SetTestTimeout(testCase->timeout, KillHungTestInChildProcess); - } - } - - testCase->initTestEnvironment(execKey, execute_inproc); - - if(testCase->testSetUp) { - testCase->testSetUp(0x0); - } - - int cntFailedAsserts = testCase->countFailedAsserts(); - if(cntFailedAsserts != 0) { - return TEST_RESULT_SETUP_FAILURE; - } - - testCase->testCase(0x0); - - if(testCase->testTearDown) { - testCase->testTearDown(0x0); - } - - return testCase->quitTestEnvironment(); + if(!testCase) { + return -1; + } + + int runnable = CheckTestRequirements(testCase); + if(runnable != 1) { + return TEST_RESULT_SKIPPED; + } + + if(testCase->timeout > 0 || universal_timeout > 0) { + if(execute_inproc) { + Log(time(0), "Test asked for timeout which is not supported."); + } + else { + SetTestTimeout(testCase->timeout, KillHungTestInChildProcess); + } + } + + testCase->initTestEnvironment(execKey, execute_inproc); + + if(testCase->testSetUp) { + testCase->testSetUp(0x0); + } + + int cntFailedAsserts = testCase->countFailedAsserts(); + if(cntFailedAsserts != 0) { + return TEST_RESULT_SETUP_FAILURE; + } + + testCase->testCase(0x0); + + if(testCase->testTearDown) { + testCase->testTearDown(0x0); + } + + return testCase->quitTestEnvironment(); } @@ -858,37 +858,37 @@ RunTest(TestCase *testCase, Uint64 execKey) */ int ExecuteTest(TestCase *testItem, Uint64 execKey) { - int retVal = -1; - - if(execute_inproc) { - retVal = RunTest(testItem, execKey); - } else { - int childpid = fork(); - if(childpid == 0) { - exit(RunTest(testItem, execKey)); - } else { - int stat_lock = -1; - wait(&stat_lock); - - retVal = HandleChildProcessReturnValue(stat_lock); - } - } - - if(retVal == TEST_RESULT_SKIPPED) { - testSkipCount++; - totalTestSkipCount++; - } - else if(retVal) { - totalTestFailureCount++; - testFailureCount++; - } - else { - totalTestPassCount++; - testPassCount++; - } - - // return the value for logger - return retVal; + int retVal = -1; + + if(execute_inproc) { + retVal = RunTest(testItem, execKey); + } else { + int childpid = fork(); + if(childpid == 0) { + exit(RunTest(testItem, execKey)); + } else { + int stat_lock = -1; + wait(&stat_lock); + + retVal = HandleChildProcessReturnValue(stat_lock); + } + } + + if(retVal == TEST_RESULT_SKIPPED) { + testSkipCount++; + totalTestSkipCount++; + } + else if(retVal) { + totalTestFailureCount++; + testFailureCount++; + } + else { + totalTestPassCount++; + testPassCount++; + } + + // return the value for logger + return retVal; } @@ -905,18 +905,18 @@ ExecuteTest(TestCase *testItem, Uint64 execKey) { int HandleChildProcessReturnValue(int stat_lock) { - int returnValue = -1; - - if(WIFEXITED(stat_lock)) { - returnValue = WEXITSTATUS(stat_lock); - } else if(WIFSIGNALED(stat_lock)) { - int signal = WTERMSIG(stat_lock); - // \todo add this to logger (add signal number) - Log(time(0), "FAILURE: test was aborted due to %d\n", signal); - returnValue = 1; - } - - return returnValue; + int returnValue = -1; + + if(WIFEXITED(stat_lock)) { + returnValue = WEXITSTATUS(stat_lock); + } else if(WIFSIGNALED(stat_lock)) { + int signal = WTERMSIG(stat_lock); + // \todo add this to logger (add signal number) + Log(time(0), "FAILURE: test was aborted due to %d\n", signal); + returnValue = 1; + } + + return returnValue; } @@ -931,36 +931,36 @@ HandleChildProcessReturnValue(int stat_lock) char * GenerateRunSeed(const int length) { - if(length <= 0) { - fprintf(stderr, "Error: length of the harness seed can't be less than zero\n"); - return NULL; - } + if(length <= 0) { + fprintf(stderr, "Error: length of the harness seed can't be less than zero\n"); + return NULL; + } - char *seed = SDL_malloc((length + 1) * sizeof(char)); - if(seed == NULL) { - fprintf(stderr, "Error: malloc for run seed failed\n"); - return NULL; - } + char *seed = SDL_malloc((length + 1) * sizeof(char)); + if(seed == NULL) { + fprintf(stderr, "Error: malloc for run seed failed\n"); + return NULL; + } - RND_CTX randomContext; + RND_CTX randomContext; - utl_randomInitTime(&randomContext); + utl_randomInitTime(&randomContext); - int counter = 0; - for( ; counter < length - 1; ++counter) { - int number = abs(utl_random(&randomContext)); - char ch = (char) (number % (91 - 48)) + 48; + int counter = 0; + for( ; counter < length - 1; ++counter) { + int number = abs(utl_random(&randomContext)); + char ch = (char) (number % (91 - 48)) + 48; - if(ch >= 58 && ch <= 64) { - ch = 65; - } + if(ch >= 58 && ch <= 64) { + ch = 65; + } - seed[counter] = ch; - } + seed[counter] = ch; + } - seed[counter] = '\0'; + seed[counter] = '\0'; - return seed; + return seed; } /*! @@ -970,109 +970,109 @@ GenerateRunSeed(const int length) */ LoggerData * SetUpLogger(const int log_stdout_enabled, const int xml_enabled, const int xsl_enabled, - const int custom_xsl_enabled, const char *defaultXslSheet, const time_t timestamp) + const int custom_xsl_enabled, const char *defaultXslSheet, const time_t timestamp) { - LoggerData *loggerData = SDL_malloc(sizeof(LoggerData)); - if(loggerData == NULL) { - fprintf(stderr, "Error: Logger data structure not allocated."); - return NULL; - } - memset(loggerData, 0, sizeof(LoggerData)); + LoggerData *loggerData = SDL_malloc(sizeof(LoggerData)); + if(loggerData == NULL) { + fprintf(stderr, "Error: Logger data structure not allocated."); + return NULL; + } + memset(loggerData, 0, sizeof(LoggerData)); - loggerData->level = (enable_verbose_logger ? LOGGER_VERBOSE : LOGGER_TERSE); + loggerData->level = (enable_verbose_logger ? LOGGER_VERBOSE : LOGGER_TERSE); - if(log_stdout_enabled == 1) { - loggerData->stdoutEnabled = 1; - loggerData->filename = NULL; - } else { - loggerData->stdoutEnabled = 0; + if(log_stdout_enabled == 1) { + loggerData->stdoutEnabled = 1; + loggerData->filename = NULL; + } else { + loggerData->stdoutEnabled = 0; - const char *extension = (xml_enabled ? "xml" : "log"); + const char *extension = (xml_enabled ? "xml" : "log"); - // create directory (if it doesn't exist yet) - unsigned int mode = S_IRWXU | S_IRGRP | S_ISUID; - mkdir(log_directory, mode); + // create directory (if it doesn't exist yet) + unsigned int mode = S_IRWXU | S_IRGRP | S_ISUID; + mkdir(log_directory, mode); - char *timeString = TimestampToStringWithFormat(timestamp, "%Y%m%d_%H:%M:%S"); + char *timeString = TimestampToStringWithFormat(timestamp, "%Y%m%d_%H:%M:%S"); - /* Combine and create directory for log file */ - const Uint32 directoryLength = SDL_strlen(log_directory); - const Uint32 basenameLength = SDL_strlen(log_basename); - const Uint32 seedLength = SDL_strlen(runSeed); - const Uint32 extensionLength = SDL_strlen(extension); + /* Combine and create directory for log file */ + const Uint32 directoryLength = SDL_strlen(log_directory); + const Uint32 basenameLength = SDL_strlen(log_basename); + const Uint32 seedLength = SDL_strlen(runSeed); + const Uint32 extensionLength = SDL_strlen(extension); - const Uint32 timeLength = SDL_strlen(timeString); + const Uint32 timeLength = SDL_strlen(timeString); - // couple of extras bytes for '/', '-', '.' and '\0' at the end - const Uint32 length = directoryLength + basenameLength + seedLength - + extensionLength + timeLength + 5; + // couple of extras bytes for '/', '-', '.' and '\0' at the end + const Uint32 length = directoryLength + basenameLength + seedLength + + extensionLength + timeLength + 5; - if(length <= 0) { - return NULL; - } + if(length <= 0) { + return NULL; + } - char *filename = SDL_malloc(length); - if(filename == NULL) { - SDL_free(loggerData); + char *filename = SDL_malloc(length); + if(filename == NULL) { + SDL_free(loggerData); - fprintf(stderr, "Error: Failed to allocate memory for filename of log"); - return NULL; - } - memset(filename, 0, length); + fprintf(stderr, "Error: Failed to allocate memory for filename of log"); + return NULL; + } + memset(filename, 0, length); - SDL_snprintf(filename, length, "%s%c%s-%s-%s.%s", log_directory, - DIRECTORY_SEPARATOR, log_basename, timeString, runSeed, extension); + SDL_snprintf(filename, length, "%s%c%s-%s-%s.%s", log_directory, + DIRECTORY_SEPARATOR, log_basename, timeString, runSeed, extension); - loggerData->filename = filename; - } + loggerData->filename = filename; + } - if(xml_enabled) { - char *sheet = NULL; - if(xsl_enabled) { - sheet = (char *) defaultXslSheet; - } + if(xml_enabled) { + char *sheet = NULL; + if(xsl_enabled) { + sheet = (char *) defaultXslSheet; + } - if(custom_xsl_enabled) { - sheet = xsl_stylesheet_name; - } + if(custom_xsl_enabled) { + sheet = xsl_stylesheet_name; + } - loggerData->custom = sheet; - } + loggerData->custom = sheet; + } - if(xml_enabled) { - RunStarted = XMLRunStarted; - RunEnded = XMLRunEnded; + if(xml_enabled) { + RunStarted = XMLRunStarted; + RunEnded = XMLRunEnded; - SuiteStarted = XMLSuiteStarted; - SuiteEnded = XMLSuiteEnded; + SuiteStarted = XMLSuiteStarted; + SuiteEnded = XMLSuiteEnded; - TestStarted = XMLTestStarted; - TestEnded = XMLTestEnded; + TestStarted = XMLTestStarted; + TestEnded = XMLTestEnded; - Assert = XMLAssert; - AssertWithValues = XMLAssertWithValues; - AssertSummary = XMLAssertSummary; + Assert = XMLAssert; + AssertWithValues = XMLAssertWithValues; + AssertSummary = XMLAssertSummary; - Log = XMLLog; - } else { - RunStarted = PlainRunStarted; - RunEnded = PlainRunEnded; + Log = XMLLog; + } else { + RunStarted = PlainRunStarted; + RunEnded = PlainRunEnded; - SuiteStarted = PlainSuiteStarted; - SuiteEnded = PlainSuiteEnded; + SuiteStarted = PlainSuiteStarted; + SuiteEnded = PlainSuiteEnded; - TestStarted = PlainTestStarted; - TestEnded = PlainTestEnded; + TestStarted = PlainTestStarted; + TestEnded = PlainTestEnded; - Assert = PlainAssert; - AssertWithValues = PlainAssertWithValues; - AssertSummary = PlainAssertSummary; + Assert = PlainAssert; + AssertWithValues = PlainAssertWithValues; + AssertSummary = PlainAssertSummary; - Log = PlainLog; - } + Log = PlainLog; + } - return loggerData; + return loggerData; } @@ -1081,40 +1081,40 @@ SetUpLogger(const int log_stdout_enabled, const int xml_enabled, const int xsl_e */ void PrintUsage() { - printf("Usage: ./runner [--in-proc] [--show-tests] [--verbose]\n"); - printf(" [--logfile [BASENAME]] [--logdir DIR] [--xml]\n"); - printf(" [--xsl [STYLESHEET]] [--seed VALUE] [--iterations VALUE]\n"); - printf(" [--exec-key KEY] [--timeout VALUE] [--test TEST]\n"); - printf(" [--name-contains SUBSTR] [--suite SUITE] [--include-dummy]\n"); - printf(" [--version] [--help]\n"); - printf("Options:\n"); - printf(" --in-proc Executes tests in-process\n"); - printf(" --show-tests Prints out all the executable tests\n"); - printf(" -v --verbose Enables verbose logging\n"); - printf(" --logfile [BASENAME] Enables logging to a file. If BASENAME is\n"); - printf(" specified it'll be used as basename for\n"); - printf(" the log file\n"); - printf(" --logdir DIR Define directory for logs. Defaults to 'logs'\n"); - printf(" --xml Enables XML logger\n"); - printf(" --xsl [STYLESHEET] Adds XSL stylesheet to the XML test reports for\n"); - printf(" browser viewing. Optionally uses the specified XSL\n"); - printf(" file or URL instead of the default one\n"); - printf(" --seed VALUE Specify fuzzing seed for the harness\n"); - printf(" --iterations VALUE Specify how many times a test will be executed\n"); - printf(" --exec-key KEY Run test(s) with specific execution key\n"); - printf(" -tm --timeout VALUE Specify common timeout value for all tests\n"); - printf(" Timeout is given in seconds and it'll override\n"); - printf(" test specific timeout value only if the given\n"); - printf(" value is greater than the test specific value\n"); - printf(" note: doesn't work with --in-proc option.\n"); - printf(" -t --test TEST Executes only tests with given name\n"); - printf(" -ts --name-contains SUBSTR Executes only tests that have given\n"); - printf(" substring in test name\n"); - printf(" -s --suite SUITE Executes only the given test suite\n"); - printf(" --include-dummy Includes dummy test suite in the test run\n"); - - printf(" --version Print version information\n"); - printf(" -h --help Print this help\n"); + printf("Usage: ./runner [--in-proc] [--show-tests] [--verbose]\n"); + printf(" [--logfile [BASENAME]] [--logdir DIR] [--xml]\n"); + printf(" [--xsl [STYLESHEET]] [--seed VALUE] [--iterations VALUE]\n"); + printf(" [--exec-key KEY] [--timeout VALUE] [--test TEST]\n"); + printf(" [--name-contains SUBSTR] [--suite SUITE] [--include-dummy]\n"); + printf(" [--version] [--help]\n"); + printf("Options:\n"); + printf(" --in-proc Executes tests in-process\n"); + printf(" --show-tests Prints out all the executable tests\n"); + printf(" -v --verbose Enables verbose logging\n"); + printf(" --logfile [BASENAME] Enables logging to a file. If BASENAME is\n"); + printf(" specified it'll be used as basename for\n"); + printf(" the log file\n"); + printf(" --logdir DIR Define directory for logs. Defaults to 'logs'\n"); + printf(" --xml Enables XML logger\n"); + printf(" --xsl [STYLESHEET] Adds XSL stylesheet to the XML test reports for\n"); + printf(" browser viewing. Optionally uses the specified XSL\n"); + printf(" file or URL instead of the default one\n"); + printf(" --seed VALUE Specify fuzzing seed for the harness\n"); + printf(" --iterations VALUE Specify how many times a test will be executed\n"); + printf(" --exec-key KEY Run test(s) with specific execution key\n"); + printf(" -tm --timeout VALUE Specify common timeout value for all tests\n"); + printf(" Timeout is given in seconds and it'll override\n"); + printf(" test specific timeout value only if the given\n"); + printf(" value is greater than the test specific value\n"); + printf(" note: doesn't work with --in-proc option.\n"); + printf(" -t --test TEST Executes only tests with given name\n"); + printf(" -ts --name-contains SUBSTR Executes only tests that have given\n"); + printf(" substring in test name\n"); + printf(" -s --suite SUITE Executes only the given test suite\n"); + printf(" --include-dummy Includes dummy test suite in the test run\n"); + + printf(" --version Print version information\n"); + printf(" -h --help Print this help\n"); } @@ -1135,178 +1135,178 @@ ParseOptions(int argc, char *argv[]) execute_inproc = 1; } else if(SDL_strcmp(arg, "--show-tests") == 0) { - only_print_tests = 1; + only_print_tests = 1; } else if(SDL_strcmp(arg, "--xml") == 0) { - xml_enabled = 1; + xml_enabled = 1; } else if(SDL_strcmp(arg, "--verbose") == 0 || SDL_strcmp(arg, "-v") == 0) { - enable_verbose_logger = 1; + enable_verbose_logger = 1; } else if(SDL_strcmp(arg, "--logdir") == 0) { - char *dirString = NULL; + char *dirString = NULL; - if( (i + 1) < argc && argv[i+1][0] != '-') { - dirString = argv[++i]; - } else { - printf("runner: dir is missing\n"); - PrintUsage(); - exit(1); - } + if( (i + 1) < argc && argv[i+1][0] != '-') { + dirString = argv[++i]; + } else { + printf("runner: dir is missing\n"); + PrintUsage(); + exit(1); + } - memset(log_directory, 0, NAME_BUFFER_SIZE); - memcpy(log_directory, dirString, SDL_strlen(dirString)); + memset(log_directory, 0, NAME_BUFFER_SIZE); + memcpy(log_directory, dirString, SDL_strlen(dirString)); - log_stdout_enabled = 0; + log_stdout_enabled = 0; } else if(SDL_strcmp(arg, "--logfile") == 0) { - char *fileString = NULL; + char *fileString = NULL; - if( (i + 1) < argc && argv[i+1][0] != '-') { - fileString = argv[++i]; - } else { - fileString = DEFAULT_LOG_FILENAME; - } + if( (i + 1) < argc && argv[i+1][0] != '-') { + fileString = argv[++i]; + } else { + fileString = DEFAULT_LOG_FILENAME; + } - memset(log_basename, 0, NAME_BUFFER_SIZE); - memcpy(log_basename, fileString, SDL_strlen(fileString)); + memset(log_basename, 0, NAME_BUFFER_SIZE); + memcpy(log_basename, fileString, SDL_strlen(fileString)); - log_stdout_enabled = 0; + log_stdout_enabled = 0; } else if(SDL_strcmp(arg, "--timeout") == 0 || SDL_strcmp(arg, "-tm") == 0) { - universal_timeout_enabled = 1; - char *timeoutString = NULL; - - if( (i + 1) < argc && argv[i+1][0] != '-') { - timeoutString = argv[++i]; - } else { - printf("runner: timeout is missing\n"); - PrintUsage(); - exit(1); - } - - universal_timeout = atoi(timeoutString); + universal_timeout_enabled = 1; + char *timeoutString = NULL; + + if( (i + 1) < argc && argv[i+1][0] != '-') { + timeoutString = argv[++i]; + } else { + printf("runner: timeout is missing\n"); + PrintUsage(); + exit(1); + } + + universal_timeout = atoi(timeoutString); } else if(SDL_strcmp(arg, "--seed") == 0) { - userRunSeed = 1; - - if( (i + 1) < argc && argv[i+1][0] != '-') { - runSeed = argv[++i]; - } else { - printf("runner: seed value is missing\n"); - PrintUsage(); - exit(1); - } - //!Ê\todo should the seed be copied to a buffer? + userRunSeed = 1; + + if( (i + 1) < argc && argv[i+1][0] != '-') { + runSeed = argv[++i]; + } else { + printf("runner: seed value is missing\n"); + PrintUsage(); + exit(1); + } + //!Ê\todo should the seed be copied to a buffer? } else if(SDL_strcmp(arg, "--iterations") == 0) { - char *iterationsString = NULL; - if( (i + 1) < argc && argv[i+1][0] != '-') { - iterationsString = argv[++i]; - } else { - printf("runner: iterations value is missing\n"); - PrintUsage(); - exit(1); - } - - testInvocationCount = atoi(iterationsString); - if(testInvocationCount < 1) { - printf("Iteration value has to bigger than 0.\n"); - exit(1); - } + char *iterationsString = NULL; + if( (i + 1) < argc && argv[i+1][0] != '-') { + iterationsString = argv[++i]; + } else { + printf("runner: iterations value is missing\n"); + PrintUsage(); + exit(1); + } + + testInvocationCount = atoi(iterationsString); + if(testInvocationCount < 1) { + printf("Iteration value has to bigger than 0.\n"); + exit(1); + } } else if(SDL_strcmp(arg, "--exec-key") == 0) { - char *execKeyString = NULL; - if( (i + 1) < argc && argv[i+1][0] != '-') { - execKeyString = argv[++i]; - } else { - printf("runner: execkey value is missing\n"); - PrintUsage(); - exit(1); - } - - int ret = sscanf(execKeyString, "%llx", &userExecKey); - if(ret != 1) { - fprintf(stderr, "Error: Failed to parse exec-key option"); - exit(1); - } + char *execKeyString = NULL; + if( (i + 1) < argc && argv[i+1][0] != '-') { + execKeyString = argv[++i]; + } else { + printf("runner: execkey value is missing\n"); + PrintUsage(); + exit(1); + } + + int ret = sscanf(execKeyString, "%llx", &userExecKey); + if(ret != 1) { + fprintf(stderr, "Error: Failed to parse exec-key option"); + exit(1); + } } else if(SDL_strcmp(arg, "--test") == 0 || SDL_strcmp(arg, "-t") == 0) { - only_selected_test = 1; - char *testName = NULL; - - if( (i + 1) < argc && argv[i+1][0] != '-') { - testName = argv[++i]; - } else { - printf("runner: test name is missing\n"); - PrintUsage(); - exit(1); - } - - memset(selected_test_name, 0, NAME_BUFFER_SIZE); - strncpy(selected_test_name, testName, NAME_BUFFER_SIZE); + only_selected_test = 1; + char *testName = NULL; + + if( (i + 1) < argc && argv[i+1][0] != '-') { + testName = argv[++i]; + } else { + printf("runner: test name is missing\n"); + PrintUsage(); + exit(1); + } + + memset(selected_test_name, 0, NAME_BUFFER_SIZE); + strncpy(selected_test_name, testName, NAME_BUFFER_SIZE); } else if(SDL_strcmp(arg, "--xsl") == 0) { - xsl_enabled = 1; + xsl_enabled = 1; - if( (i + 1) < argc && argv[i+1][0] != '-') { - char *stylesheet = argv[++i]; - if(stylesheet[0] != '-') { - custom_xsl_enabled = 1; + if( (i + 1) < argc && argv[i+1][0] != '-') { + char *stylesheet = argv[++i]; + if(stylesheet[0] != '-') { + custom_xsl_enabled = 1; - memset(xsl_stylesheet_name, 0, NAME_BUFFER_SIZE); - strncpy(xsl_stylesheet_name, stylesheet, NAME_BUFFER_SIZE); - } - } + memset(xsl_stylesheet_name, 0, NAME_BUFFER_SIZE); + strncpy(xsl_stylesheet_name, stylesheet, NAME_BUFFER_SIZE); + } + } } else if(SDL_strcmp(arg, "--name-contains") == 0 || SDL_strcmp(arg, "-ts") == 0) { - only_tests_with_string = 1; - char *substring = NULL; - - if( (i + 1) < argc && argv[i+1][0] != '-') { - substring = argv[++i]; - } else { - printf("runner: substring of test name is missing\n"); - PrintUsage(); - exit(1); - } - - memset(testcase_name_substring, 0, NAME_BUFFER_SIZE); - strncpy(testcase_name_substring, strdup(substring), NAME_BUFFER_SIZE); + only_tests_with_string = 1; + char *substring = NULL; + + if( (i + 1) < argc && argv[i+1][0] != '-') { + substring = argv[++i]; + } else { + printf("runner: substring of test name is missing\n"); + PrintUsage(); + exit(1); + } + + memset(testcase_name_substring, 0, NAME_BUFFER_SIZE); + strncpy(testcase_name_substring, strdup(substring), NAME_BUFFER_SIZE); } else if(SDL_strcmp(arg, "--suite") == 0 || SDL_strcmp(arg, "-s") == 0) { - only_selected_suite = 1; - - char *suiteName = NULL; - if( (i + 1) < argc && argv[i+1][0] != '-') { - suiteName = argv[++i]; - } else { - printf("runner: suite name is missing\n"); - PrintUsage(); - exit(1); - } - - memset(selected_suite_name, 0, NAME_BUFFER_SIZE); - strcpy(selected_suite_name, suiteName); + only_selected_suite = 1; + + char *suiteName = NULL; + if( (i + 1) < argc && argv[i+1][0] != '-') { + suiteName = argv[++i]; + } else { + printf("runner: suite name is missing\n"); + PrintUsage(); + exit(1); + } + + memset(selected_suite_name, 0, NAME_BUFFER_SIZE); + strcpy(selected_suite_name, suiteName); } else if(SDL_strcmp(arg, "--include-dummy") == 0) { - include_dummy_suite = 1; + include_dummy_suite = 1; } else if(SDL_strcmp(arg, "--version") == 0) { - fprintf(stdout, "SDL test harness (version %s)\n", PACKAGE_VERSION); + fprintf(stdout, "SDL test harness (version %s)\n", PACKAGE_VERSION); - // print: Testing against SDL version fuu (rev: bar) + // print: Testing against SDL version fuu (rev: bar) - exit(0); + exit(0); } else if(SDL_strcmp(arg, "--help") == 0 || SDL_strcmp(arg, "-h") == 0) { - PrintUsage(); - exit(0); + PrintUsage(); + exit(0); } else { - printf("runner: unknown command '%s'\n", arg); - PrintUsage(); - exit(0); + printf("runner: unknown command '%s'\n", arg); + PrintUsage(); + exit(0); } } } @@ -1314,14 +1314,14 @@ ParseOptions(int argc, char *argv[]) void InitRunner() { - // Inits some global buffers to their default values - memcpy(log_basename, (void *)DEFAULT_LOG_FILENAME, SDL_strlen(DEFAULT_LOG_FILENAME)); - memcpy(log_directory, (void *)DEFAULT_LOG_DIRECTORY, SDL_strlen(DEFAULT_LOG_DIRECTORY)); - - memset(selected_test_name, 0, NAME_BUFFER_SIZE); - memset(selected_suite_name, 0, NAME_BUFFER_SIZE); - memset(testcase_name_substring, 0, NAME_BUFFER_SIZE); - memset(xsl_stylesheet_name, 0, NAME_BUFFER_SIZE); + // Inits some global buffers to their default values + memcpy(log_basename, (void *)DEFAULT_LOG_FILENAME, SDL_strlen(DEFAULT_LOG_FILENAME)); + memcpy(log_directory, (void *)DEFAULT_LOG_DIRECTORY, SDL_strlen(DEFAULT_LOG_DIRECTORY)); + + memset(selected_test_name, 0, NAME_BUFFER_SIZE); + memset(selected_suite_name, 0, NAME_BUFFER_SIZE); + memset(testcase_name_substring, 0, NAME_BUFFER_SIZE); + memset(xsl_stylesheet_name, 0, NAME_BUFFER_SIZE); } @@ -1334,173 +1334,173 @@ InitRunner() int main(int argc, char *argv[]) { - InitRunner(); + InitRunner(); - ParseOptions(argc, argv); + ParseOptions(argc, argv); - int suiteCounter = 0; + int suiteCounter = 0; #if defined(linux) || defined( __linux) - char *extension = "so"; + char *extension = "so"; #else - char *extension = "dylib"; + char *extension = "dylib"; #endif - const Uint32 startTicks = SDL_GetTicks(); - - TestSuiteReference *suites = ScanForTestSuites(DEFAULT_TEST_DIRECTORY, extension); - if(suites == NULL) { - fprintf(stderr, "No test suites loaded.\n"); - fprintf(stderr, "Compile you suites and install them to tests/\n"); - return 2; - } - suites = LoadTestSuites(suites); - - TestCase *testCases = LoadTestCases(suites); - if(testCases == NULL) { - fprintf(stderr, "Found zero test cases\n"); - fprintf(stderr, "Check out your command line options\n"); - return 2; - } - - // if --show-tests option is given, only print tests and exit - if(only_print_tests) { - TestCase *testItem = NULL; - char *lastSuiteName = NULL; - for(testItem = testCases; testItem; testItem = testItem->next) { - if ((lastSuiteName == NULL) || (strcmp(lastSuiteName, testItem->suiteName)!=0)) { - lastSuiteName = testItem->suiteName; - printf ("%s:\n", lastSuiteName); - } - printf(" %s: %s", testItem->testName, testItem->description); - if (testItem->timeout>0) { - printf (" (timeout: %i sec)", testItem->timeout); - } - printf ("\n"); - } - - return 0; - } - - if(userRunSeed == 0) { - runSeed = GenerateRunSeed(16); - if(runSeed == NULL) { - fprintf(stderr, "Error: Generating harness seed failed\n"); - return 2; - } - } - - const time_t startTimestamp = time(0); - - LoggerData *loggerData = SetUpLogger(log_stdout_enabled, xml_enabled, - xsl_enabled, custom_xsl_enabled, defaultXSLStylesheet, startTimestamp); - if(loggerData == NULL) { - printf("Failed to create a logger.\n"); - return 2; - } - - if(log_stdout_enabled == 0) { - printf("Runner is executing the tests.\n"); - if(enable_verbose_logger) { - printf("Logging level is set to verbose.\n"); - } - printf("Test report is created to: %s\n", loggerData->filename); - fflush(stdout); - } - - RunStarted(argc, argv, runSeed, startTimestamp, loggerData); - - // logger data is no longer used so free it - SDL_free(loggerData->filename); - SDL_free(loggerData); - - - // validate the parsed command options - // \todo add a lot more and refactor. There are many more combinations - // of commands that doesn't make sense together - if(execute_inproc && universal_timeout_enabled) { - Log(time(0), "Test timeout is not supported with in-proc execution."); - Log(time(0), "Timeout will be disabled..."); - - universal_timeout_enabled = 0; - universal_timeout = -1; - } /* - if(userExecKey && testInvocationCount > 1 || userRunSeed) { - printf("The given combination of command line options doesn't make sense\n"); - printf("--exec-key should only be used to rerun failed fuzz tests\n"); - }*/ - - char *currentSuiteName = NULL; - int suiteStartTime = SDL_GetTicks(); - - int notFirstSuite = 0; - int startNewSuite = 1; - TestCase *testItem = NULL; - for(testItem = testCases; testItem; testItem = testItem->next) { - if(currentSuiteName && strncmp(currentSuiteName, testItem->suiteName, NAME_BUFFER_SIZE) != 0) { - startNewSuite = 1; - } - - if(startNewSuite) { - if(notFirstSuite) { - const double suiteRuntime = (SDL_GetTicks() - suiteStartTime) / 1000.0f; - - SuiteEnded(testPassCount, testFailureCount, testSkipCount, time(0), - suiteRuntime); - } - - suiteStartTime = SDL_GetTicks(); - - currentSuiteName = testItem->suiteName; - SuiteStarted(currentSuiteName, time(0)); - testFailureCount = testPassCount = testSkipCount = 0; - suiteCounter++; - - startNewSuite = 0; - notFirstSuite = 1; - } - - int currentIteration = testInvocationCount; - while(currentIteration > 0) { - Uint64 execKey = 5; - if(userExecKey != 0) { - execKey = userExecKey; - } else { - execKey = GenerateExecKey(runSeed, testItem->suiteName, - testItem->testName, currentIteration); - } - - TestStarted(testItem->testName, testItem->suiteName, - testItem->description, execKey, time(0)); - - const Uint32 testTimeStart = SDL_GetTicks(); - - int retVal = ExecuteTest(testItem, execKey); - - const double testTotalRuntime = (SDL_GetTicks() - testTimeStart) / 1000.0f; - - TestEnded(testItem->testName, testItem->suiteName, retVal, time(0), testTotalRuntime); - - currentIteration--; - } - } - - if(currentSuiteName) { - SuiteEnded(testPassCount, testFailureCount, testSkipCount, time(0), - (SDL_GetTicks() - suiteStartTime) / 1000.0f); - } + const Uint32 startTicks = SDL_GetTicks(); + + TestSuiteReference *suites = ScanForTestSuites(DEFAULT_TEST_DIRECTORY, extension); + if(suites == NULL) { + fprintf(stderr, "No test suites loaded.\n"); + fprintf(stderr, "Compile you suites and install them to tests/\n"); + return 2; + } + suites = LoadTestSuites(suites); + + TestCase *testCases = LoadTestCases(suites); + if(testCases == NULL) { + fprintf(stderr, "Found zero test cases\n"); + fprintf(stderr, "Check out your command line options\n"); + return 2; + } + + // if --show-tests option is given, only print tests and exit + if(only_print_tests) { + TestCase *testItem = NULL; + char *lastSuiteName = NULL; + for(testItem = testCases; testItem; testItem = testItem->next) { + if ((lastSuiteName == NULL) || (strcmp(lastSuiteName, testItem->suiteName)!=0)) { + lastSuiteName = testItem->suiteName; + printf ("%s:\n", lastSuiteName); + } + printf(" %s: %s", testItem->testName, testItem->description); + if (testItem->timeout>0) { + printf (" (timeout: %i sec)", testItem->timeout); + } + printf ("\n"); + } + + return 0; + } + + if(userRunSeed == 0) { + runSeed = GenerateRunSeed(16); + if(runSeed == NULL) { + fprintf(stderr, "Error: Generating harness seed failed\n"); + return 2; + } + } + + const time_t startTimestamp = time(0); + + LoggerData *loggerData = SetUpLogger(log_stdout_enabled, xml_enabled, + xsl_enabled, custom_xsl_enabled, defaultXSLStylesheet, startTimestamp); + if(loggerData == NULL) { + printf("Failed to create a logger.\n"); + return 2; + } + + if(log_stdout_enabled == 0) { + printf("Runner is executing the tests.\n"); + if(enable_verbose_logger) { + printf("Logging level is set to verbose.\n"); + } + printf("Test report is created to: %s\n", loggerData->filename); + fflush(stdout); + } + + RunStarted(argc, argv, runSeed, startTimestamp, loggerData); + + // logger data is no longer used so free it + SDL_free(loggerData->filename); + SDL_free(loggerData); + + + // validate the parsed command options + // \todo add a lot more and refactor. There are many more combinations + // of commands that doesn't make sense together + if(execute_inproc && universal_timeout_enabled) { + Log(time(0), "Test timeout is not supported with in-proc execution."); + Log(time(0), "Timeout will be disabled..."); + + universal_timeout_enabled = 0; + universal_timeout = -1; + } /* + if(userExecKey && testInvocationCount > 1 || userRunSeed) { + printf("The given combination of command line options doesn't make sense\n"); + printf("--exec-key should only be used to rerun failed fuzz tests\n"); + }*/ + + char *currentSuiteName = NULL; + int suiteStartTime = SDL_GetTicks(); + + int notFirstSuite = 0; + int startNewSuite = 1; + TestCase *testItem = NULL; + for(testItem = testCases; testItem; testItem = testItem->next) { + if(currentSuiteName && strncmp(currentSuiteName, testItem->suiteName, NAME_BUFFER_SIZE) != 0) { + startNewSuite = 1; + } + + if(startNewSuite) { + if(notFirstSuite) { + const double suiteRuntime = (SDL_GetTicks() - suiteStartTime) / 1000.0f; + + SuiteEnded(testPassCount, testFailureCount, testSkipCount, time(0), + suiteRuntime); + } + + suiteStartTime = SDL_GetTicks(); + + currentSuiteName = testItem->suiteName; + SuiteStarted(currentSuiteName, time(0)); + testFailureCount = testPassCount = testSkipCount = 0; + suiteCounter++; + + startNewSuite = 0; + notFirstSuite = 1; + } + + int currentIteration = testInvocationCount; + while(currentIteration > 0) { + Uint64 execKey = 5; + if(userExecKey != 0) { + execKey = userExecKey; + } else { + execKey = GenerateExecKey(runSeed, testItem->suiteName, + testItem->testName, currentIteration); + } + + TestStarted(testItem->testName, testItem->suiteName, + testItem->description, execKey, time(0)); + + const Uint32 testTimeStart = SDL_GetTicks(); + + int retVal = ExecuteTest(testItem, execKey); + + const double testTotalRuntime = (SDL_GetTicks() - testTimeStart) / 1000.0f; + + TestEnded(testItem->testName, testItem->suiteName, retVal, time(0), testTotalRuntime); + + currentIteration--; + } + } + + if(currentSuiteName) { + SuiteEnded(testPassCount, testFailureCount, testSkipCount, time(0), + (SDL_GetTicks() - suiteStartTime) / 1000.0f); + } - UnloadTestCases(testCases); - UnloadTestSuites(suites); - - const Uint32 endTicks = SDL_GetTicks(); - const double totalRunTime = (endTicks - startTicks) / 1000.0f; - - RunEnded(totalTestPassCount + totalTestFailureCount + totalTestSkipCount, suiteCounter, - totalTestPassCount, totalTestFailureCount, totalTestSkipCount, time(0), totalRunTime); + UnloadTestCases(testCases); + UnloadTestSuites(suites); + + const Uint32 endTicks = SDL_GetTicks(); + const double totalRunTime = (endTicks - startTicks) / 1000.0f; + + RunEnded(totalTestPassCount + totalTestFailureCount + totalTestSkipCount, suiteCounter, + totalTestPassCount, totalTestFailureCount, totalTestSkipCount, time(0), totalRunTime); - // Some SDL subsystem might be init'ed so shut them down - SDL_Quit(); + // Some SDL subsystem might be init'ed so shut them down + SDL_Quit(); - return (totalTestFailureCount ? 1 : 0); + return (totalTestFailureCount ? 1 : 0); } diff --git a/test/test-automation/src/runner/support.c b/test/test-automation/src/runner/support.c index 0f8e89d3f..e5cbfa599 100644 --- a/test/test-automation/src/runner/support.c +++ b/test/test-automation/src/runner/support.c @@ -25,28 +25,28 @@ int PlatformSupportsAudio() { - int retValue = 0; + int retValue = 0; #ifdef SDL_AUDIO_DRIVER_COREAUDIO - retValue = 1; + retValue = 1; #endif #ifdef SDL_AUDIO_DRIVER_OSS - retValue = 1; + retValue = 1; #endif - return retValue; + return retValue; } int PlatformSupportsStdio() { - int retValue = 0; + int retValue = 0; #ifdef HAVE_STDIO_H - retValue = 1; + retValue = 1; #endif - return retValue; + return retValue; } @@ -64,12 +64,12 @@ SDL_test.h int PlatformSupportsOpenGL() { - int retValue = 0; + int retValue = 0; #define SDL_VIDEO_OPENGL - retValue = 1; + retValue = 1; #endif - return retValue; + return retValue; } */ diff --git a/test/test-automation/tests/testaudio/testaudio.c b/test/test-automation/tests/testaudio/testaudio.c index 511a78fe4..8d1f05ccb 100644 --- a/test/test-automation/tests/testaudio/testaudio.c +++ b/test/test-automation/tests/testaudio/testaudio.c @@ -11,25 +11,25 @@ /* Test cases */ static const TestCaseReference test1 = - (TestCaseReference){ "audio_enumerateAndNameAudioDevices", "Enumerate and name available audio devices (output and capture)", TEST_ENABLED, TEST_REQUIRES_AUDIO, 0}; + (TestCaseReference){ "audio_enumerateAndNameAudioDevices", "Enumerate and name available audio devices (output and capture)", TEST_ENABLED, TEST_REQUIRES_AUDIO, 0}; static const TestCaseReference test2 = - (TestCaseReference){ "audio_enumerateAndNameAudioDevicesNegativeTests", "Netative tests around enumeration and naming of audio devices.", TEST_ENABLED, TEST_REQUIRES_AUDIO, 0}; + (TestCaseReference){ "audio_enumerateAndNameAudioDevicesNegativeTests", "Netative tests around enumeration and naming of audio devices.", TEST_ENABLED, TEST_REQUIRES_AUDIO, 0}; static const TestCaseReference test3 = - (TestCaseReference){ "audio_printAudioDrivers", "Checks available audio driver names.", TEST_ENABLED, TEST_REQUIRES_AUDIO, 0}; + (TestCaseReference){ "audio_printAudioDrivers", "Checks available audio driver names.", TEST_ENABLED, TEST_REQUIRES_AUDIO, 0}; static const TestCaseReference test4 = - (TestCaseReference){ "audio_printCurrentAudioDriver", "Checks current audio driver name with initialized audio.", TEST_ENABLED, TEST_REQUIRES_AUDIO, 0}; + (TestCaseReference){ "audio_printCurrentAudioDriver", "Checks current audio driver name with initialized audio.", TEST_ENABLED, TEST_REQUIRES_AUDIO, 0}; /* Test suite */ extern const TestCaseReference *testSuite[] = { - &test1, &test2, &test3, &test4, NULL + &test1, &test2, &test3, &test4, NULL }; TestCaseReference **QueryTestSuite() { - return (TestCaseReference **)testSuite; + return (TestCaseReference **)testSuite; } /* Fixture */ @@ -37,23 +37,23 @@ TestCaseReference **QueryTestSuite() { void SetUp(void *arg) { - /* Start SDL. */ - int ret = SDL_Init( SDL_INIT_AUDIO ); - AssertTrue(ret==0, "SDL_Init(SDL_INIT_AUDIO): %s", SDL_GetError()); + /* Start SDL. */ + int ret = SDL_Init( SDL_INIT_AUDIO ); + AssertTrue(ret==0, "SDL_Init(SDL_INIT_AUDIO): %s", SDL_GetError()); } void TearDown(void *arg) { - /* Quit SDL. */ - SDL_Quit(); + /* Quit SDL. */ + SDL_Quit(); } /* Test case functions */ /** * \brief Enumerate and name available audio devices (output and capture). - * + * * \sa http://wiki.libsdl.org/moin.cgi/SDL_GetNumAudioDevices * \sa http://wiki.libsdl.org/moin.cgi/SDL_GetAudioDeviceName */ @@ -66,13 +66,13 @@ int audio_enumerateAndNameAudioDevices() /* Iterate over types: t=0 output device, t=1 input/capture device */ for (t=0; t<2; t++) { - + /* Get number of devices. */ n = SDL_GetNumAudioDevices(t); - AssertTrue(n>=0, - "Number of %s devices < 0, reported as %i: %s", + AssertTrue(n>=0, + "Number of %s devices < 0, reported as %i: %s", (t) ? "output" : "capture", - n, + n, SDL_GetError()); /* Variation of non-zero type */ @@ -82,8 +82,8 @@ int audio_enumerateAndNameAudioDevices() AssertTrue(n==nn, "SDL_GetNumAudioDevices(%i) : expected same number of audio devices %i, got %i", tt, n, nn); nn = SDL_GetNumAudioDevices(-tt); AssertTrue(n==nn, "SDL_GetNumAudioDevices(%i) : expected same number of audio devices %i, got %i", -tt, n, nn); - } - + } + /* List devices. */ if (n>0) { for (i=0; i0, "SDL_GetAudioDeviceName(%i, %i): returned empty name string", i, tt); - AssertTrue(strcmp(name, nameAgain)==0, - "SDL_GetAudioDeviceName(%i, %i): returned unexpected name string %s, expected %s", + AssertTrue(strcmp(name, nameAgain)==0, + "SDL_GetAudioDeviceName(%i, %i): returned unexpected name string %s, expected %s", i, tt, nameAgain, name); } } @@ -106,7 +106,7 @@ int audio_enumerateAndNameAudioDevices() /** * \brief Negative tests around enumeration and naming of audio devices. - * + * * \sa http://wiki.libsdl.org/moin.cgi/SDL_GetNumAudioDevices * \sa http://wiki.libsdl.org/moin.cgi/SDL_GetAudioDeviceName */ @@ -116,25 +116,25 @@ int audio_enumerateAndNameAudioDevicesNegativeTests() int t; int i, j, no, nc; const char *name; - + /* Get number of devices. */ no = SDL_GetNumAudioDevices(0); nc = SDL_GetNumAudioDevices(1); - + /* Invalid device index when getting name */ for (t=0; t<2; t++) { /* Negative device index */ i = -1; name = SDL_GetAudioDeviceName(i, t); AssertTrue(name == NULL, "SDL_GetAudioDeviceName(%i, %i): returned a name, should return NULL", i, t); - + /* Device index past range */ for (j=0; j<3; j++) { i = (t) ? nc+j : no+j; name = SDL_GetAudioDeviceName(i, t); AssertTrue(name == NULL, "SDL_GetAudioDeviceName(%i, %i): returned a name, should return NULL", i, t); } - + /* Capture index past capture range but within output range */ if ((no>0) && (no>nc) && (t==1)) { i = no-1; @@ -155,7 +155,7 @@ int audio_printAudioDrivers() /* Get number of drivers */ n = SDL_GetNumAudioDrivers(); AssertTrue(n>=0, "Number of audio drivers >= 0"); - + /* List drivers. */ if (n>0) { diff --git a/test/test-automation/tests/testclipboard/testclipboard.c b/test/test-automation/tests/testclipboard/testclipboard.c index 6fd272b33..c4ff59d1f 100644 --- a/test/test-automation/tests/testclipboard/testclipboard.c +++ b/test/test-automation/tests/testclipboard/testclipboard.c @@ -12,24 +12,24 @@ /* Test cases */ static const TestCaseReference test1 = - (TestCaseReference){ "clipboard_testHasClipboardText", "Check call to SDL_HasClipboardText", TEST_ENABLED, 0, 0 }; + (TestCaseReference){ "clipboard_testHasClipboardText", "Check call to SDL_HasClipboardText", TEST_ENABLED, 0, 0 }; static const TestCaseReference test2 = - (TestCaseReference){ "clipboard_testGetClipboardText", "Check call to SDL_GetClipboardText", TEST_ENABLED, 0, 0 }; + (TestCaseReference){ "clipboard_testGetClipboardText", "Check call to SDL_GetClipboardText", TEST_ENABLED, 0, 0 }; static const TestCaseReference test3 = - (TestCaseReference){ "clipboard_testSetClipboardText", "Check call to SDL_SetClipboardText", TEST_ENABLED, 0, 0 }; + (TestCaseReference){ "clipboard_testSetClipboardText", "Check call to SDL_SetClipboardText", TEST_ENABLED, 0, 0 }; static const TestCaseReference test4 = - (TestCaseReference){ "clipboard_testClipboardTextFunctions", "End-to-end test of SDL_xyzClipboardText functions", TEST_ENABLED, 0, 0 }; + (TestCaseReference){ "clipboard_testClipboardTextFunctions", "End-to-end test of SDL_xyzClipboardText functions", TEST_ENABLED, 0, 0 }; /* Test suite */ extern const TestCaseReference *testSuite[] = { - &test1, &test2, &test3, &test4, NULL + &test1, &test2, &test3, &test4, NULL }; TestCaseReference **QueryTestSuite() { - return (TestCaseReference **)testSuite; + return (TestCaseReference **)testSuite; } void @@ -39,7 +39,7 @@ SetUp(void *arg) int ret = SDL_InitSubSystem( SDL_INIT_VIDEO ); AssertTrue(ret==0, "SDL_Init(SDL_INIT_VIDEO) failed: %s", SDL_GetError()); } - + void TearDown(void *arg) { @@ -50,52 +50,52 @@ TearDown(void *arg) /** * \brief Check call to SDL_HasClipboardText * - * \sa + * \sa * http://wiki.libsdl.org/moin.cgi/SDL_HasClipboardText */ int clipboard_testHasClipboardText(void *arg) { - SDL_bool result; - result = SDL_HasClipboardText(); - AssertPass("Call to SDL_HasClipboardText succeeded"); + SDL_bool result; + result = SDL_HasClipboardText(); + AssertPass("Call to SDL_HasClipboardText succeeded"); } /** * \brief Check call to SDL_GetClipboardText * - * \sa + * \sa * http://wiki.libsdl.org/moin.cgi/SDL_GetClipboardText */ int clipboard_testGetClipboardText(void *arg) { - char *result; - result = SDL_GetClipboardText(); - AssertPass("Call to SDL_GetClipboardText succeeded"); + char *result; + result = SDL_GetClipboardText(); + AssertPass("Call to SDL_GetClipboardText succeeded"); } /** * \brief Check call to SDL_SetClipboardText - * \sa + * \sa * http://wiki.libsdl.org/moin.cgi/SDL_SetClipboardText */ int clipboard_testSetClipboardText(void *arg) { - char *textRef = RandomAsciiString(); - char *text = strdup(textRef); - int result; - result = SDL_SetClipboardText((const char *)text); - AssertTrue( - result == 0, - "Call to SDL_SetClipboardText failed with error %i: %s", - result, SDL_GetError()); - AssertTrue( - strcmp(textRef, text) == 0, - "SDL_SetClipboardText modified input string: expected %s, got %s", - textRef, text); - + char *textRef = RandomAsciiString(); + char *text = strdup(textRef); + int result; + result = SDL_SetClipboardText((const char *)text); + AssertTrue( + result == 0, + "Call to SDL_SetClipboardText failed with error %i: %s", + result, SDL_GetError()); + AssertTrue( + strcmp(textRef, text) == 0, + "SDL_SetClipboardText modified input string: expected %s, got %s", + textRef, text); + /* Cleanup */ if (textRef) free(textRef); if (text) free(text); @@ -104,7 +104,7 @@ clipboard_testSetClipboardText(void *arg) /** * \brief End-to-end test of SDL_xyzClipboardText functions - * \sa + * \sa * http://wiki.libsdl.org/moin.cgi/SDL_HasClipboardText * http://wiki.libsdl.org/moin.cgi/SDL_GetClipboardText * http://wiki.libsdl.org/moin.cgi/SDL_SetClipboardText @@ -112,54 +112,54 @@ clipboard_testSetClipboardText(void *arg) int clipboard_testClipboardTextFunctions(void *arg) { - char *textRef = RandomAsciiString(); - char *text = strdup(textRef); - SDL_bool boolResult; - int intResult; - char *charResult; - - /* Clear clipboard text state */ - boolResult = SDL_HasClipboardText(); - if (boolResult == SDL_TRUE) { + char *textRef = RandomAsciiString(); + char *text = strdup(textRef); + SDL_bool boolResult; + int intResult; + char *charResult; + + /* Clear clipboard text state */ + boolResult = SDL_HasClipboardText(); + if (boolResult == SDL_TRUE) { intResult = SDL_SetClipboardText((const char *)NULL); - AssertTrue( - intResult == 0, - "Call to SDL_SetClipboardText("") failed with error %i: %s", - intResult, SDL_GetError()); - charResult = SDL_GetClipboardText(); - boolResult = SDL_HasClipboardText(); - AssertTrue( + AssertTrue( + intResult == 0, + "Call to SDL_SetClipboardText("") failed with error %i: %s", + intResult, SDL_GetError()); + charResult = SDL_GetClipboardText(); + boolResult = SDL_HasClipboardText(); + AssertTrue( boolResult == SDL_FALSE, - "SDL_HasClipboardText returned TRUE, expected FALSE"); + "SDL_HasClipboardText returned TRUE, expected FALSE"); } - - /* Empty clipboard */ - charResult = SDL_GetClipboardText(); - AssertTrue( - charResult != NULL, - "SDL_GetClipboardText returned NULL"); - AssertTrue( - strlen(charResult) == 0, - "SDL_GetClipboardText returned string with length >0: got length %i", - strlen(charResult)); - intResult = SDL_SetClipboardText((const char *)text); - AssertTrue( - intResult == 0, - "Call to SDL_SetClipboardText failed with error %i: %s", - intResult, SDL_GetError()); - AssertTrue( - strcmp(textRef, text) == 0, - "SDL_SetClipboardText modified input string: expected %s, got %s", - textRef, text); - boolResult = SDL_HasClipboardText(); - AssertTrue( + + /* Empty clipboard */ + charResult = SDL_GetClipboardText(); + AssertTrue( + charResult != NULL, + "SDL_GetClipboardText returned NULL"); + AssertTrue( + strlen(charResult) == 0, + "SDL_GetClipboardText returned string with length >0: got length %i", + strlen(charResult)); + intResult = SDL_SetClipboardText((const char *)text); + AssertTrue( + intResult == 0, + "Call to SDL_SetClipboardText failed with error %i: %s", + intResult, SDL_GetError()); + AssertTrue( + strcmp(textRef, text) == 0, + "SDL_SetClipboardText modified input string: expected %s, got %s", + textRef, text); + boolResult = SDL_HasClipboardText(); + AssertTrue( boolResult == SDL_TRUE, - "SDL_HasClipboardText returned FALSE, expected TRUE"); - charResult = SDL_GetClipboardText(); - AssertTrue( - strcmp(textRef, charResult) == 0, - "SDL_GetClipboardText did not return correst string: expected %s, got %s", - textRef, charResult); + "SDL_HasClipboardText returned FALSE, expected TRUE"); + charResult = SDL_GetClipboardText(); + AssertTrue( + strcmp(textRef, charResult) == 0, + "SDL_GetClipboardText did not return correst string: expected %s, got %s", + textRef, charResult); /* Cleanup */ if (textRef) free(textRef); diff --git a/test/test-automation/tests/testdummy/testdummy.c b/test/test-automation/tests/testdummy/testdummy.c index 6a20626db..945a6620f 100644 --- a/test/test-automation/tests/testdummy/testdummy.c +++ b/test/test-automation/tests/testdummy/testdummy.c @@ -35,25 +35,25 @@ /* Test case references */ static const TestCaseReference test1 = - (TestCaseReference){ "test_dummy1", "description", TEST_ENABLED, 0, 4}; + (TestCaseReference){ "test_dummy1", "description", TEST_ENABLED, 0, 4}; static const TestCaseReference test2 = - (TestCaseReference){ "test_dummy2", "description", TEST_ENABLED, 0, 0}; + (TestCaseReference){ "test_dummy2", "description", TEST_ENABLED, 0, 0}; static const TestCaseReference test3 = - (TestCaseReference){ "test_fuzzy", "description", TEST_ENABLED, 0, 2}; + (TestCaseReference){ "test_fuzzy", "description", TEST_ENABLED, 0, 2}; static const TestCaseReference test4 = - (TestCaseReference){ "test_leak", "description", TEST_ENABLED, 0, 2}; + (TestCaseReference){ "test_leak", "description", TEST_ENABLED, 0, 2}; /* Test suite */ extern const TestCaseReference *testSuite[] = { - &test1, &test2, &test3, &test4, NULL + &test1, &test2, &test3, &test4, NULL }; TestCaseReference **QueryTestSuite() { - return (TestCaseReference **)testSuite; + return (TestCaseReference **)testSuite; } /* Create test fixture */ @@ -72,8 +72,8 @@ TestCaseReference **QueryTestSuite() { void SetUp(void *arg) { - // create test fixture, - // for example, set up static variables used by test cases here + // create test fixture, + // for example, set up static variables used by test cases here } /*! @@ -87,71 +87,71 @@ SetUp(void *arg) void TearDown(void *arg) { - // destroy test fixture + // destroy test fixture } /* Test case functions */ void test_dummy1(void *arg) { - AssertEquals(5, 5, "Assert message"); - - /* - for( ; 1 ; ) - Log(0, "uint8 (same value): %u", RandomUint32()); - // */ - - //Log(0, "uint8 (same value): %d", RandomUint8BoundaryValue(200, 200, SDL_TRUE)); - - int c = 0; - //for(; c < 100 ; c++) - printf("%f\n", RandomUnitFloat()); - - for(; 0 ; ) - printf("%d\n", RandomSint16()); - - for( ; 0 ; ) { - //Log(0, "sint8: %d", RandomSint8BoundaryValue(-11, 10, SDL_TRUE)); - //Log(0, "sint16: %d", RandomSint16BoundaryValue(SHRT_MIN, SHRT_MAX, SDL_FALSE)); - Log(0, "sint32: %d", RandomSint32BoundaryValue(INT_MIN, 3000, SDL_FALSE)); - //Log(0, "sint64: %lld", RandomSint64BoundaryValue(-34, -34, SDL_FALSE)); - } - - for(; 0 ;) { - //Log(0, "int8: %u", RandomUint8BoundaryValue(0, 255, SDL_FALSE)); - //Log(0, "uint16: %u", RandomUint16BoundaryValue(0, UINT16_MAX, SDL_FALSE)); - //Log(0, "int32: %u", RandomUint32BoundaryValue(0, 0xFFFFFFFE, SDL_FALSE)); - Log(0, "int64: %llu", RandomUint64BoundaryValue(2, 0xFFFFFFFFFFFFFFFE, SDL_FALSE)); - } - - for(; 0 ;) { - int min = -5; - int max = 5; - int random = RandomIntegerInRange(min, max); - if(random < min || random > max ) { - AssertFail("Generated incorrect integer"); - } - Log(0, "%d", random); - } - - //Log(0, "Random: %s", RandomAsciiString()); + AssertEquals(5, 5, "Assert message"); + + /* + for( ; 1 ; ) + Log(0, "uint8 (same value): %u", RandomUint32()); + // */ + + //Log(0, "uint8 (same value): %d", RandomUint8BoundaryValue(200, 200, SDL_TRUE)); + + int c = 0; + //for(; c < 100 ; c++) + printf("%f\n", RandomUnitFloat()); + + for(; 0 ; ) + printf("%d\n", RandomSint16()); + + for( ; 0 ; ) { + //Log(0, "sint8: %d", RandomSint8BoundaryValue(-11, 10, SDL_TRUE)); + //Log(0, "sint16: %d", RandomSint16BoundaryValue(SHRT_MIN, SHRT_MAX, SDL_FALSE)); + Log(0, "sint32: %d", RandomSint32BoundaryValue(INT_MIN, 3000, SDL_FALSE)); + //Log(0, "sint64: %lld", RandomSint64BoundaryValue(-34, -34, SDL_FALSE)); + } + + for(; 0 ;) { + //Log(0, "int8: %u", RandomUint8BoundaryValue(0, 255, SDL_FALSE)); + //Log(0, "uint16: %u", RandomUint16BoundaryValue(0, UINT16_MAX, SDL_FALSE)); + //Log(0, "int32: %u", RandomUint32BoundaryValue(0, 0xFFFFFFFE, SDL_FALSE)); + Log(0, "int64: %llu", RandomUint64BoundaryValue(2, 0xFFFFFFFFFFFFFFFE, SDL_FALSE)); + } + + for(; 0 ;) { + int min = -5; + int max = 5; + int random = RandomIntegerInRange(min, max); + if(random < min || random > max ) { + AssertFail("Generated incorrect integer"); + } + Log(0, "%d", random); + } + + //Log(0, "Random: %s", RandomAsciiString()); } void test_dummy2(void *arg) { - char *msg = "eello"; - //msg[0] = 'H'; - AssertTrue(1, "Assert message"); - AssertTrue(0, "Assert message"); - AssertTrue(1, "Assert message"); + char *msg = "eello"; + //msg[0] = 'H'; + AssertTrue(1, "Assert message"); + AssertTrue(0, "Assert message"); + AssertTrue(1, "Assert message"); } void test_fuzzy(void *arg) { - // Simulates a fuzzing failure - AssertTrue(RandomUint8() != 100, "Value is 100"); + // Simulates a fuzzing failure + AssertTrue(RandomUint8() != 100, "Value is 100"); } static void @@ -164,9 +164,9 @@ f(void) { void test_leak(void *arg) { - // Creates a memory leak - f(); + // Creates a memory leak + f(); - AssertPass(""); + AssertPass(""); } diff --git a/test/test-automation/tests/testevents/testevents.c b/test/test-automation/tests/testevents/testevents.c index bdb7f089d..3b5b7dc02 100644 --- a/test/test-automation/tests/testevents/testevents.c +++ b/test/test-automation/tests/testevents/testevents.c @@ -13,15 +13,15 @@ /* Test cases */ static const TestCaseReference test1 = - (TestCaseReference){ "events_test", "description", TEST_DISABLED, 0, 0 }; + (TestCaseReference){ "events_test", "description", TEST_DISABLED, 0, 0 }; /* Test suite */ extern const TestCaseReference *testSuite[] = { - &test1, NULL + &test1, NULL }; TestCaseReference **QueryTestSuite() { - return (TestCaseReference **)testSuite; + return (TestCaseReference **)testSuite; } /** @@ -30,5 +30,5 @@ TestCaseReference **QueryTestSuite() { int events_test(void *arg) { - AssertPass(""); + AssertPass(""); } diff --git a/test/test-automation/tests/testkeyboard/testkeyboard.c b/test/test-automation/tests/testkeyboard/testkeyboard.c index 341e39449..47240399b 100644 --- a/test/test-automation/tests/testkeyboard/testkeyboard.c +++ b/test/test-automation/tests/testkeyboard/testkeyboard.c @@ -13,15 +13,15 @@ /* Test cases */ static const TestCaseReference test1 = - (TestCaseReference){ "keyboard_test", "description", TEST_DISABLED, 0, 0 }; + (TestCaseReference){ "keyboard_test", "description", TEST_DISABLED, 0, 0 }; /* Test suite */ extern const TestCaseReference *testSuite[] = { - &test1, NULL + &test1, NULL }; TestCaseReference **QueryTestSuite() { - return (TestCaseReference **)testSuite; + return (TestCaseReference **)testSuite; } /** @@ -30,5 +30,5 @@ TestCaseReference **QueryTestSuite() { int keyboard_test(void *arg) { - AssertPass(""); + AssertPass(""); } diff --git a/test/test-automation/tests/testplatform/testplatform.c b/test/test-automation/tests/testplatform/testplatform.c index 974d6afb7..d4fb286bd 100644 --- a/test/test-automation/tests/testplatform/testplatform.c +++ b/test/test-automation/tests/testplatform/testplatform.c @@ -11,45 +11,45 @@ /* Test cases */ static const TestCaseReference test1 = - (TestCaseReference){ "platform_testTypes", "Tests predefined types", TEST_ENABLED, 0, 0 }; + (TestCaseReference){ "platform_testTypes", "Tests predefined types", TEST_ENABLED, 0, 0 }; static const TestCaseReference test2 = - (TestCaseReference){ "platform_testEndianessAndSwap", "Tests endianess and swap functions", TEST_ENABLED, 0, 0 }; + (TestCaseReference){ "platform_testEndianessAndSwap", "Tests endianess and swap functions", TEST_ENABLED, 0, 0 }; static const TestCaseReference test3 = - (TestCaseReference){ "platform_testGetFunctions", "Tests various SDL_GetXYZ functions", TEST_ENABLED, 0, 0 }; + (TestCaseReference){ "platform_testGetFunctions", "Tests various SDL_GetXYZ functions", TEST_ENABLED, 0, 0 }; static const TestCaseReference test4 = - (TestCaseReference){ "platform_testHasFunctions", "Tests various SDL_HasXYZ functions", TEST_ENABLED, 0, 0 }; + (TestCaseReference){ "platform_testHasFunctions", "Tests various SDL_HasXYZ functions", TEST_ENABLED, 0, 0 }; static const TestCaseReference test5 = - (TestCaseReference){ "platform_testGetVersion", "Tests SDL_GetVersion function", TEST_ENABLED, 0, 0 }; + (TestCaseReference){ "platform_testGetVersion", "Tests SDL_GetVersion function", TEST_ENABLED, 0, 0 }; static const TestCaseReference test6 = - (TestCaseReference){ "platform_testSDLVersion", "Tests SDL_VERSION macro", TEST_ENABLED, 0, 0 }; + (TestCaseReference){ "platform_testSDLVersion", "Tests SDL_VERSION macro", TEST_ENABLED, 0, 0 }; static const TestCaseReference test7 = - (TestCaseReference){ "platform_testDefaultInit", "Tests default SDL_Init", TEST_ENABLED, 0, 0 }; + (TestCaseReference){ "platform_testDefaultInit", "Tests default SDL_Init", TEST_ENABLED, 0, 0 }; static const TestCaseReference test8 = - (TestCaseReference){ "platform_testGetSetClearError", "Tests SDL_Get/Set/ClearError", TEST_ENABLED, 0, 0 }; + (TestCaseReference){ "platform_testGetSetClearError", "Tests SDL_Get/Set/ClearError", TEST_ENABLED, 0, 0 }; static const TestCaseReference test9 = - (TestCaseReference){ "platform_testSetErrorEmptyInput", "Tests SDL_SetError with empty input", TEST_ENABLED, 0, 0 }; + (TestCaseReference){ "platform_testSetErrorEmptyInput", "Tests SDL_SetError with empty input", TEST_ENABLED, 0, 0 }; static const TestCaseReference test10 = - (TestCaseReference){ "platform_testSetErrorInvalidInput", "Tests SDL_SetError with invalid input", TEST_ENABLED, 0, 0 }; + (TestCaseReference){ "platform_testSetErrorInvalidInput", "Tests SDL_SetError with invalid input", TEST_ENABLED, 0, 0 }; static const TestCaseReference test11 = - (TestCaseReference){ "platform_testGetPowerInfo", "Tests SDL_GetPowerInfo function", TEST_ENABLED, 0, 0 }; + (TestCaseReference){ "platform_testGetPowerInfo", "Tests SDL_GetPowerInfo function", TEST_ENABLED, 0, 0 }; /* Test suite */ extern const TestCaseReference *testSuite[] = { - &test1, &test2, &test3, &test4, &test5, &test6, &test7, &test8, &test9, &test10, &test11, NULL + &test1, &test2, &test3, &test4, &test5, &test6, &test7, &test8, &test9, &test10, &test11, NULL }; TestCaseReference **QueryTestSuite() { - return (TestCaseReference **)testSuite; + return (TestCaseReference **)testSuite; } /** @@ -103,14 +103,14 @@ int platform_testEndianessAndSwap(void *arg) swapped64 = 0x1234ABCD; swapped64 <<= 32; swapped64 |= 0xDEADBEEF; - + if ((*((char *) &value) >> 4) == 0x1) { real_byteorder = SDL_BIG_ENDIAN; } else { real_byteorder = SDL_LIL_ENDIAN; } - /* Test endianness. */ + /* Test endianness. */ AssertTrue( real_byteorder == SDL_BYTEORDER, "Machine detected as %s endian, appears to be %s endian.", (SDL_BYTEORDER == SDL_LIL_ENDIAN) ? "little" : "big", @@ -151,29 +151,29 @@ int platform_testGetFunctions (void *arg) char *revision; int ret; int len; - + platform = (char *)SDL_GetPlatform(); AssertPass("SDL_GetPlatform()"); AssertTrue(platform != NULL, "SDL_GetPlatform() != NULL"); if (platform != NULL) { len = strlen(platform); - AssertTrue(len > 0, - "SDL_GetPlatform(): expected non-empty platform, was platform: '%s', len: %i", - platform, + AssertTrue(len > 0, + "SDL_GetPlatform(): expected non-empty platform, was platform: '%s', len: %i", + platform, len); } - + ret = SDL_GetCPUCount(); AssertPass("SDL_GetCPUCount()"); AssertTrue(ret > 0, - "SDL_GetCPUCount(): expected count > 0, was: %i", - ret); + "SDL_GetCPUCount(): expected count > 0, was: %i", + ret); ret = SDL_GetCPUCacheLineSize(); AssertPass("SDL_GetCPUCacheLineSize()"); AssertTrue(ret >= 0, - "SDL_GetCPUCacheLineSize(): expected size >= 0, was: %i", - ret); + "SDL_GetCPUCacheLineSize(): expected size >= 0, was: %i", + ret); revision = (char *)SDL_GetRevision(); AssertPass("SDL_GetRevision()"); @@ -199,12 +199,12 @@ int platform_testGetFunctions (void *arg) int platform_testHasFunctions (void *arg) { int ret; - + // TODO: independently determine and compare values as well - + ret = SDL_HasRDTSC(); AssertPass("SDL_HasRDTSC()"); - + ret = SDL_HasAltiVec(); AssertPass("SDL_HasAltiVec()"); @@ -238,16 +238,16 @@ int platform_testHasFunctions (void *arg) int platform_testGetVersion(void *arg) { SDL_version linked; - + SDL_GetVersion(&linked); AssertTrue( linked.major >= SDL_MAJOR_VERSION, "SDL_GetVersion(): returned major %i (>= %i)", linked.major, - SDL_MAJOR_VERSION); + SDL_MAJOR_VERSION); AssertTrue( linked.minor >= SDL_MINOR_VERSION, "SDL_GetVersion(): returned minor %i (>= %i)", linked.minor, - SDL_MINOR_VERSION); + SDL_MINOR_VERSION); } /*! @@ -256,16 +256,16 @@ int platform_testGetVersion(void *arg) int platform_testSDLVersion(void *arg) { SDL_version compiled; - + SDL_VERSION(&compiled); AssertTrue( compiled.major >= SDL_MAJOR_VERSION, "SDL_VERSION() returned major %i (>= %i)", compiled.major, - SDL_MAJOR_VERSION); + SDL_MAJOR_VERSION); AssertTrue( compiled.minor >= SDL_MINOR_VERSION, "SDL_VERSION() returned minor %i (>= %i)", compiled.minor, - SDL_MINOR_VERSION); + SDL_MINOR_VERSION); } /*! @@ -275,24 +275,24 @@ int platform_testDefaultInit(void *arg) { int ret; int subsystem; - - ret = SDL_Init(0); - AssertTrue( ret == 0, + + ret = SDL_Init(0); + AssertTrue( ret == 0, "SDL_Init(0): returned %i, expected 0, error: %s", ret, SDL_GetError()); - + subsystem = SDL_WasInit(0); - AssertTrue( subsystem == 0, + AssertTrue( subsystem == 0, "SDL_WasInit(0): returned %i, expected 0", - ret); - + ret); + SDL_Quit(); } /*! * \brief Tests SDL_Get/Set/ClearError - * \sa + * \sa * http://wiki.libsdl.org/moin.cgi/SDL_GetError * http://wiki.libsdl.org/moin.cgi/SDL_SetError * http://wiki.libsdl.org/moin.cgi/SDL_ClearError @@ -302,40 +302,40 @@ int platform_testGetSetClearError(void *arg) const char *testError = "Testing"; char *lastError; int len; - + SDL_ClearError(); AssertPass("SDL_ClearError()"); - - lastError = (char *)SDL_GetError(); + + lastError = (char *)SDL_GetError(); AssertPass("SDL_GetError()"); - AssertTrue(lastError != NULL, + AssertTrue(lastError != NULL, "SDL_GetError() != NULL"); if (lastError != NULL) { len = strlen(lastError); - AssertTrue(len == 0, + AssertTrue(len == 0, "SDL_GetError(): no message expected, len: %i", len); } - + SDL_SetError("%s", testError); AssertPass("SDL_SetError()"); - lastError = (char *)SDL_GetError(); - AssertTrue(lastError != NULL, + lastError = (char *)SDL_GetError(); + AssertTrue(lastError != NULL, "SDL_GetError() != NULL"); if (lastError != NULL) { len = strlen(lastError); - AssertTrue(len == strlen(testError), - "SDL_GetError(): expected message len %i, was len: %i", - strlen(testError), + AssertTrue(len == strlen(testError), + "SDL_GetError(): expected message len %i, was len: %i", + strlen(testError), len); - AssertTrue(strcmp(lastError, testError) == 0, - "SDL_GetError(): expected message %s, was message: %s", - testError, + AssertTrue(strcmp(lastError, testError) == 0, + "SDL_GetError(): expected message %s, was message: %s", + testError, lastError); } - // Clean up + // Clean up SDL_ClearError(); } @@ -349,32 +349,32 @@ int platform_testSetErrorEmptyInput(void *arg) const char *testError = ""; char *lastError; int len; - + SDL_SetError("%s", testError); AssertPass("SDL_SetError()"); - lastError = (char *)SDL_GetError(); - AssertTrue(lastError != NULL, + lastError = (char *)SDL_GetError(); + AssertTrue(lastError != NULL, "SDL_GetError() != NULL"); if (lastError != NULL) { len = strlen(lastError); - AssertTrue(len == strlen(testError), - "SDL_GetError(): expected message len %i, was len: %i", - strlen(testError), + AssertTrue(len == strlen(testError), + "SDL_GetError(): expected message len %i, was len: %i", + strlen(testError), len); - AssertTrue(strcmp(lastError, testError) == 0, - "SDL_GetError(): expected message '%s', was message: '%s'", - testError, + AssertTrue(strcmp(lastError, testError) == 0, + "SDL_GetError(): expected message '%s', was message: '%s'", + testError, lastError); } - // Clean up + // Clean up SDL_ClearError(); } /*! * \brief Tests SDL_SetError with invalid input - * \sa + * \sa * http://wiki.libsdl.org/moin.cgi/SDL_SetError */ int platform_testSetErrorInvalidInput(void *arg) @@ -386,48 +386,48 @@ int platform_testSetErrorInvalidInput(void *arg) // Reset SDL_ClearError(); - + // Check for no-op SDL_SetError(testError); AssertPass("SDL_SetError()"); - lastError = (char *)SDL_GetError(); - AssertTrue(lastError != NULL, + lastError = (char *)SDL_GetError(); + AssertTrue(lastError != NULL, "SDL_GetError() != NULL"); if (lastError != NULL) { len = strlen(lastError); - AssertTrue(len == 0, - "SDL_GetError(): expected message len 0, was len: %i", - 0, + AssertTrue(len == 0, + "SDL_GetError(): expected message len 0, was len: %i", + 0, len); - AssertTrue(strcmp(lastError, "") == 0, - "SDL_GetError(): expected message '', was message: '%s'", + AssertTrue(strcmp(lastError, "") == 0, + "SDL_GetError(): expected message '', was message: '%s'", lastError); } - + // Set SDL_SetError(probeError); - + // Check for no-op SDL_SetError(testError); AssertPass("SDL_SetError()"); - lastError = (char *)SDL_GetError(); - AssertTrue(lastError != NULL, + lastError = (char *)SDL_GetError(); + AssertTrue(lastError != NULL, "SDL_GetError() != NULL"); if (lastError != NULL) { len = strlen(lastError); - AssertTrue(len == strlen(probeError), - "SDL_GetError(): expected message len %i, was len: %i", - strlen(probeError), + AssertTrue(len == strlen(probeError), + "SDL_GetError(): expected message len %i, was len: %i", + strlen(probeError), len); - AssertTrue(strcmp(lastError, probeError) == 0, + AssertTrue(strcmp(lastError, probeError) == 0, "SDL_GetError(): expected message '%s', was message: '%s'", probeError, lastError); } - // Clean up + // Clean up SDL_ClearError(); } @@ -444,7 +444,7 @@ int platform_testGetPowerInfo(void *arg) int secsAgain; int pct; int pctAgain; - + state = SDL_GetPowerInfo(&secs, &pct); AssertPass("SDL_GetPowerInfo()"); AssertTrue( @@ -455,7 +455,7 @@ int platform_testGetPowerInfo(void *arg) state==SDL_POWERSTATE_CHARGED, "SDL_GetPowerInfo(): state %i is one of the expected values", (int)state); - + if (state==SDL_POWERSTATE_ON_BATTERY) { AssertTrue( @@ -465,7 +465,7 @@ int platform_testGetPowerInfo(void *arg) AssertTrue( (pct >= 0) && (pct <= 100), "SDL_GetPowerInfo(): on battery, pct=[0,100], was: %i", - pct); + pct); } if (state==SDL_POWERSTATE_UNKNOWN || @@ -478,31 +478,31 @@ int platform_testGetPowerInfo(void *arg) AssertTrue( pct == -1, "SDL_GetPowerInfo(): no battery, pct == -1, was: %i", - pct); + pct); } - // Partial return value variations + // Partial return value variations stateAgain = SDL_GetPowerInfo(&secsAgain, NULL); AssertTrue( state==stateAgain, "State %i returned when only 'secs' requested", - stateAgain); + stateAgain); AssertTrue( secs==secsAgain, "Value %i matches when only 'secs' requested", - secsAgain); + secsAgain); stateAgain = SDL_GetPowerInfo(NULL, &pctAgain); AssertTrue( state==stateAgain, "State %i returned when only 'pct' requested", - stateAgain); + stateAgain); AssertTrue( pct==pctAgain, "Value %i matches when only 'pct' requested", - pctAgain); + pctAgain); stateAgain = SDL_GetPowerInfo(NULL, NULL); AssertTrue( state==stateAgain, "State %i returned when no value requested", - stateAgain); + stateAgain); } diff --git a/test/test-automation/tests/testrect/testrect.c b/test/test-automation/tests/testrect/testrect.c index 77df61aae..ea2ce6b40 100644 --- a/test/test-automation/tests/testrect/testrect.c +++ b/test/test-automation/tests/testrect/testrect.c @@ -11,98 +11,98 @@ /* SDL_IntersectRectAndLine */ static const TestCaseReference test1 = - (TestCaseReference){ "rect_testIntersectRectAndLine", "Tests SDL_IntersectRectAndLine clipping cases", TEST_ENABLED, 0, 0 }; + (TestCaseReference){ "rect_testIntersectRectAndLine", "Tests SDL_IntersectRectAndLine clipping cases", TEST_ENABLED, 0, 0 }; static const TestCaseReference test2 = - (TestCaseReference){ "rect_testIntersectRectAndLineInside", "Tests SDL_IntersectRectAndLine with line fully contained in rect", TEST_ENABLED, 0, 0 }; + (TestCaseReference){ "rect_testIntersectRectAndLineInside", "Tests SDL_IntersectRectAndLine with line fully contained in rect", TEST_ENABLED, 0, 0 }; static const TestCaseReference test3 = - (TestCaseReference){ "rect_testIntersectRectAndLineOutside", "Tests SDL_IntersectRectAndLine with line fully outside of rect", TEST_ENABLED, 0, 0 }; + (TestCaseReference){ "rect_testIntersectRectAndLineOutside", "Tests SDL_IntersectRectAndLine with line fully outside of rect", TEST_ENABLED, 0, 0 }; static const TestCaseReference test4 = - (TestCaseReference){ "rect_testIntersectRectAndLineEmpty", "Tests SDL_IntersectRectAndLine with empty rectangle ", TEST_ENABLED, 0, 0 }; + (TestCaseReference){ "rect_testIntersectRectAndLineEmpty", "Tests SDL_IntersectRectAndLine with empty rectangle ", TEST_ENABLED, 0, 0 }; static const TestCaseReference test5 = - (TestCaseReference){ "rect_testIntersectRectAndLineParam", "Negative tests against SDL_IntersectRectAndLine with invalid parameters", TEST_ENABLED, 0, 0 }; + (TestCaseReference){ "rect_testIntersectRectAndLineParam", "Negative tests against SDL_IntersectRectAndLine with invalid parameters", TEST_ENABLED, 0, 0 }; /* SDL_IntersectRect */ static const TestCaseReference test6 = - (TestCaseReference){ "rect_testIntersectRectInside", "Tests SDL_IntersectRect with B fully contained in A", TEST_ENABLED, 0, 0 }; + (TestCaseReference){ "rect_testIntersectRectInside", "Tests SDL_IntersectRect with B fully contained in A", TEST_ENABLED, 0, 0 }; static const TestCaseReference test7 = - (TestCaseReference){ "rect_testIntersectRectOutside", "Tests SDL_IntersectRect with B fully outside of A", TEST_ENABLED, 0, 0 }; + (TestCaseReference){ "rect_testIntersectRectOutside", "Tests SDL_IntersectRect with B fully outside of A", TEST_ENABLED, 0, 0 }; static const TestCaseReference test8 = - (TestCaseReference){ "rect_testIntersectRectPartial", "Tests SDL_IntersectRect with B partially intersecting A", TEST_ENABLED, 0, 0 }; + (TestCaseReference){ "rect_testIntersectRectPartial", "Tests SDL_IntersectRect with B partially intersecting A", TEST_ENABLED, 0, 0 }; static const TestCaseReference test9 = - (TestCaseReference){ "rect_testIntersectRectPoint", "Tests SDL_IntersectRect with 1x1 sized rectangles", TEST_ENABLED, 0, 0 }; + (TestCaseReference){ "rect_testIntersectRectPoint", "Tests SDL_IntersectRect with 1x1 sized rectangles", TEST_ENABLED, 0, 0 }; static const TestCaseReference test10 = - (TestCaseReference){ "rect_testIntersectRectEmpty", "Tests SDL_IntersectRect with empty rectangles", TEST_ENABLED, 0, 0 }; + (TestCaseReference){ "rect_testIntersectRectEmpty", "Tests SDL_IntersectRect with empty rectangles", TEST_ENABLED, 0, 0 }; static const TestCaseReference test11 = - (TestCaseReference){ "rect_testIntersectRectParam", "Negative tests against SDL_IntersectRect with invalid parameters", TEST_ENABLED, 0, 0 }; + (TestCaseReference){ "rect_testIntersectRectParam", "Negative tests against SDL_IntersectRect with invalid parameters", TEST_ENABLED, 0, 0 }; /* SDL_HasIntersection */ static const TestCaseReference test12 = - (TestCaseReference){ "rect_testHasIntersectionInside", "Tests SDL_HasIntersection with B fully contained in A", TEST_ENABLED, 0, 0 }; + (TestCaseReference){ "rect_testHasIntersectionInside", "Tests SDL_HasIntersection with B fully contained in A", TEST_ENABLED, 0, 0 }; static const TestCaseReference test13 = - (TestCaseReference){ "rect_testHasIntersectionOutside", "Tests SDL_HasIntersection with B fully outside of A", TEST_ENABLED, 0, 0 }; + (TestCaseReference){ "rect_testHasIntersectionOutside", "Tests SDL_HasIntersection with B fully outside of A", TEST_ENABLED, 0, 0 }; static const TestCaseReference test14 = - (TestCaseReference){ "rect_testHasIntersectionPartial", "Tests SDL_HasIntersection with B partially intersecting A", TEST_ENABLED, 0, 0 }; + (TestCaseReference){ "rect_testHasIntersectionPartial", "Tests SDL_HasIntersection with B partially intersecting A", TEST_ENABLED, 0, 0 }; static const TestCaseReference test15 = - (TestCaseReference){ "rect_testHasIntersectionPoint", "Tests SDL_HasIntersection with 1x1 sized rectangles", TEST_ENABLED, 0, 0 }; + (TestCaseReference){ "rect_testHasIntersectionPoint", "Tests SDL_HasIntersection with 1x1 sized rectangles", TEST_ENABLED, 0, 0 }; static const TestCaseReference test16 = - (TestCaseReference){ "rect_testHasIntersectionEmpty", "Tests SDL_HasIntersection with empty rectangles", TEST_ENABLED, 0, 0 }; + (TestCaseReference){ "rect_testHasIntersectionEmpty", "Tests SDL_HasIntersection with empty rectangles", TEST_ENABLED, 0, 0 }; static const TestCaseReference test17 = - (TestCaseReference){ "rect_testHasIntersectionParam", "Negative tests against SDL_HasIntersection with invalid parameters", TEST_ENABLED, 0, 0 }; + (TestCaseReference){ "rect_testHasIntersectionParam", "Negative tests against SDL_HasIntersection with invalid parameters", TEST_ENABLED, 0, 0 }; /* SDL_EnclosePoints */ static const TestCaseReference test18 = - (TestCaseReference){ "rect_testEnclosePoints", "Tests SDL_EnclosePoints without clipping", TEST_ENABLED, 0, 0 }; + (TestCaseReference){ "rect_testEnclosePoints", "Tests SDL_EnclosePoints without clipping", TEST_ENABLED, 0, 0 }; static const TestCaseReference test19 = - (TestCaseReference){ "rect_testEnclosePointsWithClipping", "Tests SDL_EnclosePoints with clipping", TEST_ENABLED, 0, 0 }; + (TestCaseReference){ "rect_testEnclosePointsWithClipping", "Tests SDL_EnclosePoints with clipping", TEST_ENABLED, 0, 0 }; static const TestCaseReference test20 = - (TestCaseReference){ "rect_testEnclosePointsRepeatedInput", "Tests SDL_EnclosePoints with repeated input", TEST_ENABLED, 0, 0 }; + (TestCaseReference){ "rect_testEnclosePointsRepeatedInput", "Tests SDL_EnclosePoints with repeated input", TEST_ENABLED, 0, 0 }; static const TestCaseReference test21 = - (TestCaseReference){ "rect_testEnclosePointsParam", "Negative tests against SDL_EnclosePoints with invalid parameters", TEST_ENABLED, 0, 0 }; + (TestCaseReference){ "rect_testEnclosePointsParam", "Negative tests against SDL_EnclosePoints with invalid parameters", TEST_ENABLED, 0, 0 }; /* SDL_UnionRect */ static const TestCaseReference test22 = - (TestCaseReference){ "rect_testUnionRectInside", "Tests SDL_UnionRect where rect B is inside rect A", TEST_ENABLED, 0, 0 }; + (TestCaseReference){ "rect_testUnionRectInside", "Tests SDL_UnionRect where rect B is inside rect A", TEST_ENABLED, 0, 0 }; static const TestCaseReference test23 = - (TestCaseReference){ "rect_testUnionRectOutside", "Tests SDL_UnionRect where rect B is outside rect A", TEST_ENABLED, 0, 0 }; + (TestCaseReference){ "rect_testUnionRectOutside", "Tests SDL_UnionRect where rect B is outside rect A", TEST_ENABLED, 0, 0 }; static const TestCaseReference test24 = - (TestCaseReference){ "rect_testUnionRectEmpty", "Tests SDL_UnionRect where rect A or rect B are empty", TEST_ENABLED, 0, 0 }; + (TestCaseReference){ "rect_testUnionRectEmpty", "Tests SDL_UnionRect where rect A or rect B are empty", TEST_ENABLED, 0, 0 }; static const TestCaseReference test25 = - (TestCaseReference){ "rect_testUnionRectParam", "Negative tests against SDL_UnionRect with invalid parameters", TEST_ENABLED, 0, 0 }; + (TestCaseReference){ "rect_testUnionRectParam", "Negative tests against SDL_UnionRect with invalid parameters", TEST_ENABLED, 0, 0 }; /* SDL_RectEmpty */ static const TestCaseReference test26 = - (TestCaseReference){ "rect_testRectEmpty", "Tests SDL_RectEmpty with various inputs", TEST_ENABLED, 0, 0 }; + (TestCaseReference){ "rect_testRectEmpty", "Tests SDL_RectEmpty with various inputs", TEST_ENABLED, 0, 0 }; static const TestCaseReference test27 = - (TestCaseReference){ "rect_testRectEmptyParam", "Negative tests against SDL_RectEmpty with invalid parameters", TEST_ENABLED, 0, 0 }; + (TestCaseReference){ "rect_testRectEmptyParam", "Negative tests against SDL_RectEmpty with invalid parameters", TEST_ENABLED, 0, 0 }; /* SDL_RectEquals */ static const TestCaseReference test28 = - (TestCaseReference){ "rect_testRectEquals", "Tests SDL_RectEquals with various inputs", TEST_ENABLED, 0, 0 }; + (TestCaseReference){ "rect_testRectEquals", "Tests SDL_RectEquals with various inputs", TEST_ENABLED, 0, 0 }; static const TestCaseReference test29 = - (TestCaseReference){ "rect_testRectEqualsParam", "Negative tests against SDL_RectEquals with invalid parameters", TEST_ENABLED, 0, 0 }; + (TestCaseReference){ "rect_testRectEqualsParam", "Negative tests against SDL_RectEquals with invalid parameters", TEST_ENABLED, 0, 0 }; /*! @@ -112,13 +112,13 @@ static const TestCaseReference test29 = * http://wiki.libsdl.org/moin.cgi/CategoryRect */ extern const TestCaseReference *testSuite[] = { - &test1, &test2, &test3, &test4, &test5, &test6, &test7, &test8, &test9, &test10, &test11, &test12, &test13, &test14, - &test15, &test16, &test17, &test18, &test19, &test20, &test21, &test22, &test23, &test24, &test25, &test26, &test27, - &test28, &test29, NULL + &test1, &test2, &test3, &test4, &test5, &test6, &test7, &test8, &test9, &test10, &test11, &test12, &test13, &test14, + &test15, &test16, &test17, &test18, &test19, &test20, &test21, &test22, &test23, &test24, &test25, &test26, &test27, + &test28, &test29, NULL }; TestCaseReference **QueryTestSuite() { - return (TestCaseReference **)testSuite; + return (TestCaseReference **)testSuite; } /*! @@ -130,7 +130,7 @@ void _validateIntersectRectAndLineResults( int x1, int y1, int x2, int y2, int x1Ref, int y1Ref, int x2Ref, int y2Ref) { - AssertTrue(intersection == expectedIntersection, + AssertTrue(intersection == expectedIntersection, "Incorrect intersection result: expected %s, got %s intersecting rect (%d,%d,%d,%d) with line (%d,%d - %d,%d)\n", (expectedIntersection == SDL_TRUE) ? "true" : "false", (intersection == SDL_TRUE) ? "true" : "false", @@ -344,7 +344,7 @@ int rect_testIntersectRectAndLineEmpty (void *arg) int x1, y1, x1Ref, y1Ref; int x2, y2, x2Ref, y2Ref; SDL_bool intersected; - + refRect.x = RandomIntegerInRange(1, 1024); refRect.y = RandomIntegerInRange(1, 1024); refRect.w = 0; @@ -377,10 +377,10 @@ int rect_testIntersectRectAndLineParam (void *arg) int x2 = x1; int y2 = 2 * rect.h; SDL_bool intersected; - + intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2); AssertTrue(intersected == SDL_TRUE, "Test variables not intersected as expected"); - + intersected = SDL_IntersectRectAndLine((SDL_Rect *)NULL, &x1, &y1, &x2, &y2); AssertTrue(intersected == SDL_FALSE, "Incorrect intersected result when 1st parameter is NULL"); intersected = SDL_IntersectRectAndLine(&rect, (int *)NULL, &y1, &x2, &y2); @@ -399,14 +399,14 @@ int rect_testIntersectRectAndLineParam (void *arg) * \brief Private helper to check SDL_HasIntersection results */ void _validateHasIntersectionResults( - SDL_bool intersection, SDL_bool expectedIntersection, + SDL_bool intersection, SDL_bool expectedIntersection, SDL_Rect *rectA, SDL_Rect *rectB, SDL_Rect *refRectA, SDL_Rect *refRectB) { - AssertTrue(intersection == expectedIntersection, + AssertTrue(intersection == expectedIntersection, "Incorrect intersection result: expected %s, got %s intersecting A (%d,%d,%d,%d) with B (%d,%d,%d,%d)\n", (expectedIntersection == SDL_TRUE) ? "true" : "false", (intersection == SDL_TRUE) ? "true" : "false", - rectA->x, rectA->y, rectA->w, rectA->h, + rectA->x, rectA->y, rectA->w, rectA->h, rectB->x, rectB->y, rectB->w, rectB->h); AssertTrue(rectA->x == refRectA->x && rectA->y == refRectA->y && rectA->w == refRectA->w && rectA->h == refRectA->h, "Source rectangle A was modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)", @@ -422,15 +422,15 @@ void _validateHasIntersectionResults( * \brief Private helper to check SDL_IntersectRect results */ void _validateIntersectRectResults( - SDL_bool intersection, SDL_bool expectedIntersection, - SDL_Rect *rectA, SDL_Rect *rectB, SDL_Rect *refRectA, SDL_Rect *refRectB, + SDL_bool intersection, SDL_bool expectedIntersection, + SDL_Rect *rectA, SDL_Rect *rectB, SDL_Rect *refRectA, SDL_Rect *refRectB, SDL_Rect *result, SDL_Rect *expectedResult) { _validateHasIntersectionResults(intersection, expectedIntersection, rectA, rectB, refRectA, refRectB); if (result && expectedResult) { AssertTrue(result->x == expectedResult->x && result->y == expectedResult->y && result->w == expectedResult->w && result->h == expectedResult->h, "Intersection of rectangles A (%d,%d,%d,%d) and B (%d,%d,%d,%d) was incorrectly calculated, got (%d,%d,%d,%d) expected (%d,%d,%d,%d)", - rectA->x, rectA->y, rectA->w, rectA->h, + rectA->x, rectA->y, rectA->w, rectA->h, rectB->x, rectB->y, rectB->w, rectB->h, result->x, result->y, result->w, result->h, expectedResult->x, expectedResult->y, expectedResult->w, expectedResult->h); @@ -441,7 +441,7 @@ void _validateIntersectRectResults( * \brief Private helper to check SDL_UnionRect results */ void _validateUnionRectResults( - SDL_Rect *rectA, SDL_Rect *rectB, SDL_Rect *refRectA, SDL_Rect *refRectB, + SDL_Rect *rectA, SDL_Rect *rectB, SDL_Rect *refRectA, SDL_Rect *refRectB, SDL_Rect *result, SDL_Rect *expectedResult) { AssertTrue(rectA->x == refRectA->x && rectA->y == refRectA->y && rectA->w == refRectA->w && rectA->h == refRectA->h, @@ -454,7 +454,7 @@ void _validateUnionRectResults( refRectB->x, refRectB->y, refRectB->w, refRectB->h); AssertTrue(result->x == expectedResult->x && result->y == expectedResult->y && result->w == expectedResult->w && result->h == expectedResult->h, "Union of rectangles A (%d,%d,%d,%d) and B (%d,%d,%d,%d) was incorrectly calculated, got (%d,%d,%d,%d) expected (%d,%d,%d,%d)", - rectA->x, rectA->y, rectA->w, rectA->h, + rectA->x, rectA->y, rectA->w, rectA->h, rectB->x, rectB->y, rectB->w, rectB->h, result->x, result->y, result->w, result->h, expectedResult->x, expectedResult->y, expectedResult->w, expectedResult->h); @@ -464,10 +464,10 @@ void _validateUnionRectResults( * \brief Private helper to check SDL_RectEmpty results */ void _validateRectEmptyResults( - SDL_bool empty, SDL_bool expectedEmpty, + SDL_bool empty, SDL_bool expectedEmpty, SDL_Rect *rect, SDL_Rect *refRect) { - AssertTrue(empty == expectedEmpty, + AssertTrue(empty == expectedEmpty, "Incorrect empty result: expected %s, got %s testing (%d,%d,%d,%d)\n", (expectedEmpty == SDL_TRUE) ? "true" : "false", (empty == SDL_TRUE) ? "true" : "false", @@ -482,10 +482,10 @@ void _validateRectEmptyResults( * \brief Private helper to check SDL_RectEquals results */ void _validateRectEqualsResults( - SDL_bool equals, SDL_bool expectedEquals, + SDL_bool equals, SDL_bool expectedEquals, SDL_Rect *rectA, SDL_Rect *rectB, SDL_Rect *refRectA, SDL_Rect *refRectB) { - AssertTrue(equals == expectedEquals, + AssertTrue(equals == expectedEquals, "Incorrect equals result: expected %s, got %s testing (%d,%d,%d,%d) and (%d,%d,%d,%d) \n", (expectedEquals == SDL_TRUE) ? "true" : "false", (equals == SDL_TRUE) ? "true" : "false", @@ -550,7 +550,7 @@ int rect_testIntersectRectOutside (void *arg) rectA = refRectA; rectB = refRectB; intersection = SDL_IntersectRect(&rectA, &rectB, &result); - _validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL); + _validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL); } /*! @@ -579,7 +579,7 @@ int rect_testIntersectRectPartial (void *arg) expectedResult.x = refRectB.x; expectedResult.y = refRectB.y; expectedResult.w = refRectA.w - refRectB.x; - expectedResult.h = refRectA.h - refRectB.y; + expectedResult.h = refRectA.h - refRectB.y; intersection = SDL_IntersectRect(&rectA, &rectB, &result); _validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult); @@ -593,7 +593,7 @@ int rect_testIntersectRectPartial (void *arg) expectedResult.x = refRectB.x; expectedResult.y = refRectB.y; expectedResult.w = 1; - expectedResult.h = refRectB.h; + expectedResult.h = refRectB.h; intersection = SDL_IntersectRect(&rectA, &rectB, &result); _validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult); @@ -607,7 +607,7 @@ int rect_testIntersectRectPartial (void *arg) expectedResult.x = 0; expectedResult.y = refRectB.y; expectedResult.w = 1; - expectedResult.h = refRectB.h; + expectedResult.h = refRectB.h; intersection = SDL_IntersectRect(&rectA, &rectB, &result); _validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult); @@ -621,7 +621,7 @@ int rect_testIntersectRectPartial (void *arg) expectedResult.x = refRectB.x; expectedResult.y = refRectB.y; expectedResult.w = refRectB.w; - expectedResult.h = 1; + expectedResult.h = 1; intersection = SDL_IntersectRect(&rectA, &rectB, &result); _validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult); @@ -635,7 +635,7 @@ int rect_testIntersectRectPartial (void *arg) expectedResult.x = refRectB.x; expectedResult.y = 0; expectedResult.w = refRectB.w; - expectedResult.h = 1; + expectedResult.h = 1; intersection = SDL_IntersectRect(&rectA, &rectB, &result); _validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult); } @@ -673,7 +673,7 @@ int rect_testIntersectRectPoint (void *arg) refRectA.x = RandomIntegerInRange(1, 100); refRectA.y = RandomIntegerInRange(1, 100); refRectB.x = refRectA.x; - refRectB.y = refRectA.y; + refRectB.y = refRectA.y; refRectB.x += offsetX; refRectB.y += offsetY; rectA = refRectA; @@ -757,17 +757,17 @@ int rect_testIntersectRectParam(void *arg) // invalid parameter combinations intersection = SDL_IntersectRect((SDL_Rect *)NULL, &rectB, &result); - AssertTrue(intersection == SDL_FALSE, "Function did not return false when 1st parameter was NULL"); + AssertTrue(intersection == SDL_FALSE, "Function did not return false when 1st parameter was NULL"); intersection = SDL_IntersectRect(&rectA, (SDL_Rect *)NULL, &result); - AssertTrue(intersection == SDL_FALSE, "Function did not return false when 2st parameter was NULL"); + AssertTrue(intersection == SDL_FALSE, "Function did not return false when 2st parameter was NULL"); intersection = SDL_IntersectRect(&rectA, &rectB, (SDL_Rect *)NULL); - AssertTrue(intersection == SDL_FALSE, "Function did not return false when 3st parameter was NULL"); + AssertTrue(intersection == SDL_FALSE, "Function did not return false when 3st parameter was NULL"); intersection = SDL_IntersectRect((SDL_Rect *)NULL, (SDL_Rect *)NULL, &result); - AssertTrue(intersection == SDL_FALSE, "Function did not return false when 1st and 2nd parameters were NULL"); + AssertTrue(intersection == SDL_FALSE, "Function did not return false when 1st and 2nd parameters were NULL"); intersection = SDL_IntersectRect((SDL_Rect *)NULL, &rectB, (SDL_Rect *)NULL); - AssertTrue(intersection == SDL_FALSE, "Function did not return false when 1st and 3rd parameters were NULL "); + AssertTrue(intersection == SDL_FALSE, "Function did not return false when 1st and 3rd parameters were NULL "); intersection = SDL_IntersectRect((SDL_Rect *)NULL, (SDL_Rect *)NULL, (SDL_Rect *)NULL); - AssertTrue(intersection == SDL_FALSE, "Function did not return false when all parameters were NULL"); + AssertTrue(intersection == SDL_FALSE, "Function did not return false when all parameters were NULL"); } /*! @@ -918,7 +918,7 @@ int rect_testHasIntersectionPoint (void *arg) refRectA.x = RandomIntegerInRange(1, 100); refRectA.y = RandomIntegerInRange(1, 100); refRectB.x = refRectA.x; - refRectB.y = refRectA.y; + refRectB.y = refRectA.y; refRectB.x += offsetX; refRectB.y += offsetY; rectA = refRectA; @@ -1000,11 +1000,11 @@ int rect_testHasIntersectionParam(void *arg) // invalid parameter combinations intersection = SDL_HasIntersection((SDL_Rect *)NULL, &rectB); - AssertTrue(intersection == SDL_FALSE, "Function did not return false when 1st parameter was NULL"); + AssertTrue(intersection == SDL_FALSE, "Function did not return false when 1st parameter was NULL"); intersection = SDL_HasIntersection(&rectA, (SDL_Rect *)NULL); - AssertTrue(intersection == SDL_FALSE, "Function did not return false when 2st parameter was NULL"); + AssertTrue(intersection == SDL_FALSE, "Function did not return false when 2st parameter was NULL"); intersection = SDL_HasIntersection((SDL_Rect *)NULL, (SDL_Rect *)NULL); - AssertTrue(intersection == SDL_FALSE, "Function did not return false when all parameters were NULL"); + AssertTrue(intersection == SDL_FALSE, "Function did not return false when all parameters were NULL"); } /*! @@ -1045,26 +1045,26 @@ int rect_testEnclosePoints(void *arg) if (newy>maxy) maxy=newy; } } - + // Call function and validate - special case: no result requested anyEnclosedNoResult = SDL_EnclosePoints((const SDL_Point *)points, numPoints, (const SDL_Rect *)NULL, (SDL_Rect *)NULL); - AssertTrue(expectedEnclosed==anyEnclosedNoResult, - "Expected return value %s, got %s", + AssertTrue(expectedEnclosed==anyEnclosedNoResult, + "Expected return value %s, got %s", (expectedEnclosed==SDL_TRUE) ? "true" : "false", (anyEnclosedNoResult==SDL_TRUE) ? "true" : "false"); for (i=0; irefRectB.x) ? refRectA.x : refRectB.x; miny = (refRectA.yrefRectB.y) ? refRectA.y : refRectB.y; + maxy = (refRectA.y>refRectB.y) ? refRectA.y : refRectB.y; expectedResult.x = minx; expectedResult.y = miny; expectedResult.w = maxx - minx + 1; @@ -1307,7 +1307,7 @@ int rect_testUnionRectOutside(void *arg) } /* Union outside overlap */ - for (dx = -1; dx < 2; dx++) { + for (dx = -1; dx < 2; dx++) { for (dy = -1; dy < 2; dy++) { if ((dx != 0) || (dy != 0)) { refRectA.x=RandomIntegerInRange(-1024, 1024); @@ -1345,7 +1345,7 @@ int rect_testUnionRectEmpty(void *arg) SDL_Rect expectedResult; SDL_Rect result; - /* A empty */ + /* A empty */ refRectA.x=RandomIntegerInRange(-1024, 1024); refRectA.y=RandomIntegerInRange(-1024, 1024); refRectA.w=0; @@ -1359,8 +1359,8 @@ int rect_testUnionRectEmpty(void *arg) rectB = refRectB; SDL_UnionRect(&rectA, &rectB, &result); _validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult); - - /* B empty */ + + /* B empty */ refRectA.x=RandomIntegerInRange(-1024, 1024); refRectA.y=RandomIntegerInRange(-1024, 1024); refRectA.w=RandomIntegerInRange(1, 1024); @@ -1375,7 +1375,7 @@ int rect_testUnionRectEmpty(void *arg) SDL_UnionRect(&rectA, &rectB, &result); _validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult); - /* A and B empty */ + /* A and B empty */ refRectA.x=RandomIntegerInRange(-1024, 1024); refRectA.y=RandomIntegerInRange(-1024, 1024); refRectA.w=0; @@ -1409,7 +1409,7 @@ int rect_testUnionRectInside(void *arg) SDL_Rect result; int minx, maxx, miny, maxy; int dx, dy; - + /* Union 1x1 with itself */ refRectA.x=RandomIntegerInRange(-1024, 1024); refRectA.y=RandomIntegerInRange(-1024, 1024); @@ -1436,7 +1436,7 @@ int rect_testUnionRectInside(void *arg) _validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult); /* Union inside with edges modified */ - for (dx = -1; dx < 2; dx++) { + for (dx = -1; dx < 2; dx++) { for (dy = -1; dy < 2; dy++) { if ((dx != 0) || (dy != 0)) { refRectA.x=RandomIntegerInRange(-1024, 1024); @@ -1447,7 +1447,7 @@ int rect_testUnionRectInside(void *arg) if (dx == -1) refRectB.x++; if ((dx == 1) || (dx == -1)) refRectB.w--; if (dy == -1) refRectB.y++; - if ((dy == 1) || (dy == -1)) refRectB.h--; + if ((dy == 1) || (dy == -1)) refRectB.h--; expectedResult = refRectA; rectA = refRectA; rectB = refRectB; @@ -1471,17 +1471,17 @@ int rect_testUnionRectParam(void *arg) // invalid parameter combinations SDL_UnionRect((SDL_Rect *)NULL, &rectB, &result); - AssertPass("Function did return when 1st parameter was NULL"); + AssertPass("Function did return when 1st parameter was NULL"); SDL_UnionRect(&rectA, (SDL_Rect *)NULL, &result); - AssertPass("Function did return when 2nd parameter was NULL"); + AssertPass("Function did return when 2nd parameter was NULL"); SDL_UnionRect(&rectA, &rectB, (SDL_Rect *)NULL); - AssertPass("Function did return when 3rd parameter was NULL"); + AssertPass("Function did return when 3rd parameter was NULL"); SDL_UnionRect((SDL_Rect *)NULL, &rectB, (SDL_Rect *)NULL); - AssertPass("Function did return when 1st and 3rd parameter were NULL"); + AssertPass("Function did return when 1st and 3rd parameter were NULL"); SDL_UnionRect(&rectA, (SDL_Rect *)NULL, (SDL_Rect *)NULL); - AssertPass("Function did return when 2nd and 3rd parameter were NULL"); + AssertPass("Function did return when 2nd and 3rd parameter were NULL"); SDL_UnionRect((SDL_Rect *)NULL, (SDL_Rect *)NULL, (SDL_Rect *)NULL); - AssertPass("Function did return when all parameters were NULL"); + AssertPass("Function did return when all parameters were NULL"); } /*! @@ -1507,7 +1507,7 @@ int rect_testRectEmpty(void *arg) rect = refRect; result = SDL_RectEmpty((const SDL_Rect *)&rect); _validateRectEmptyResults(result, expectedResult, &rect, &refRect); - + // Empty case for (w=-1; w<2; w++) { for (h=-1; h<2; h++) { @@ -1537,7 +1537,7 @@ int rect_testRectEmptyParam(void *arg) // invalid parameter combinations result = SDL_RectEmpty((const SDL_Rect *)NULL); - AssertTrue(result == SDL_TRUE, "Function did not return TRUE when 1st parameter was NULL"); + AssertTrue(result == SDL_TRUE, "Function did not return TRUE when 1st parameter was NULL"); } /*! @@ -1560,7 +1560,7 @@ int rect_testRectEquals(void *arg) refRectA.y=RandomIntegerInRange(-1024, 1024); refRectA.w=RandomIntegerInRange(1, 1024); refRectA.h=RandomIntegerInRange(1, 1024); - refRectB = refRectA; + refRectB = refRectA; expectedResult = SDL_TRUE; rectA = refRectA; rectB = refRectB; @@ -1592,9 +1592,9 @@ int rect_testRectEqualsParam(void *arg) // invalid parameter combinations result = SDL_RectEquals((const SDL_Rect *)NULL, (const SDL_Rect *)&rectB); - AssertTrue(result == SDL_FALSE, "Function did not return FALSE when 1st parameter was NULL"); + AssertTrue(result == SDL_FALSE, "Function did not return FALSE when 1st parameter was NULL"); result = SDL_RectEquals((const SDL_Rect *)&rectA, (const SDL_Rect *)NULL); - AssertTrue(result == SDL_FALSE, "Function did not return FALSE when 2nd parameter was NULL"); + AssertTrue(result == SDL_FALSE, "Function did not return FALSE when 2nd parameter was NULL"); result = SDL_RectEquals((const SDL_Rect *)NULL, (const SDL_Rect *)NULL); - AssertTrue(result == SDL_FALSE, "Function did not return FALSE when 1st and 2nd parameter were NULL"); + AssertTrue(result == SDL_FALSE, "Function did not return FALSE when 1st and 2nd parameter were NULL"); } diff --git a/test/test-automation/tests/testrender/testrender.c b/test/test-automation/tests/testrender/testrender.c index bea2040d5..f95469f8c 100644 --- a/test/test-automation/tests/testrender/testrender.c +++ b/test/test-automation/tests/testrender/testrender.c @@ -30,38 +30,38 @@ static int _isSupported(int code); /* Test cases */ static const TestCaseReference test1 = - (TestCaseReference){ "render_testGetNumRenderDrivers", "Tests call to SDL_GetNumRenderDrivers", TEST_ENABLED, 0, 0 }; + (TestCaseReference){ "render_testGetNumRenderDrivers", "Tests call to SDL_GetNumRenderDrivers", TEST_ENABLED, 0, 0 }; static const TestCaseReference test2 = - (TestCaseReference){ "render_testCreateRenderer", "Tests SDL_CreateRenderer", TEST_ENABLED, 0, 0 }; + (TestCaseReference){ "render_testCreateRenderer", "Tests SDL_CreateRenderer", TEST_ENABLED, 0, 0 }; static const TestCaseReference test3 = - (TestCaseReference){ "render_testPrimitives", "Tests rendering primitives", TEST_ENABLED, 0, 0 }; + (TestCaseReference){ "render_testPrimitives", "Tests rendering primitives", TEST_ENABLED, 0, 0 }; static const TestCaseReference test4 = - (TestCaseReference){ "render_testPrimitivesBlend", "Tests rendering primitives with blending", TEST_ENABLED, 0, 0 }; + (TestCaseReference){ "render_testPrimitivesBlend", "Tests rendering primitives with blending", TEST_ENABLED, 0, 0 }; static const TestCaseReference test5 = - (TestCaseReference){ "render_testBlit", "Tests blitting", TEST_ENABLED, 0, 0 }; + (TestCaseReference){ "render_testBlit", "Tests blitting", TEST_ENABLED, 0, 0 }; static const TestCaseReference test6 = - (TestCaseReference){ "render_testBlitColour", "Tests blitting with color", TEST_ENABLED, 0, 0 }; + (TestCaseReference){ "render_testBlitColour", "Tests blitting with color", TEST_ENABLED, 0, 0 }; static const TestCaseReference test7 = - (TestCaseReference){ "render_testBlitAlpha", "Tests blitting with alpha", TEST_ENABLED, 0, 0 }; + (TestCaseReference){ "render_testBlitAlpha", "Tests blitting with alpha", TEST_ENABLED, 0, 0 }; static const TestCaseReference test8 = - (TestCaseReference){ "render_testBlitBlend", "Tests blitting with blending", TEST_ENABLED, 0, 0 }; + (TestCaseReference){ "render_testBlitBlend", "Tests blitting with blending", TEST_ENABLED, 0, 0 }; /* Test suite */ extern const TestCaseReference *testSuite[] = { - &test1, &test2, &test3, &test4, &test5, &test6, &test7, &test8, NULL + &test1, &test2, &test3, &test4, &test5, &test6, &test7, &test8, NULL }; TestCaseReference **QueryTestSuite() { - return (TestCaseReference **)testSuite; + return (TestCaseReference **)testSuite; } // Fixture @@ -74,10 +74,10 @@ SetUp(void *arg) AssertTrue(ret==0, "SDL_Init(SDL_INIT_VIDEO): %s", SDL_GetError()); SDL_Window *w = SDL_CreateWindow( "title", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, - 80, 60, SDL_WINDOW_SHOWN ); + 80, 60, SDL_WINDOW_SHOWN ); renderer = SDL_CreateRenderer(w, 0, 0); } - + void TearDown(void *arg) { @@ -88,7 +88,7 @@ TearDown(void *arg) /** * @brief Tests call to SDL_GetNumRenderDrivers * - * \sa + * \sa * http://wiki.libsdl.org/moin.cgi/SDL_GetNumRenderDrivers */ int @@ -118,7 +118,7 @@ render_testCreateRenderer(void *arg) if (window != NULL) { AssertPass("Window created"); renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_SOFTWARE); - if (renderer) { + if (renderer) { AssertPass("Renderer created"); SDL_DestroyRenderer(renderer); } else { @@ -127,7 +127,7 @@ render_testCreateRenderer(void *arg) SDL_DestroyWindow(window); } else { AssertFail("Could not create window: %s", SDL_GetError()); - } + } } diff --git a/test/test-automation/tests/testrwops/testrwops.c b/test/test-automation/tests/testrwops/testrwops.c index 8e0c4bcd8..6bc336d31 100644 --- a/test/test-automation/tests/testrwops/testrwops.c +++ b/test/test-automation/tests/testrwops/testrwops.c @@ -22,35 +22,35 @@ static const char const_mem[] = "Hello World!"; /* Test cases */ static const TestCaseReference test1 = - (TestCaseReference){ "rwops_testParam", " Negative test for SDL_RWFromFile parameters", TEST_ENABLED, 0, 60 }; + (TestCaseReference){ "rwops_testParam", " Negative test for SDL_RWFromFile parameters", TEST_ENABLED, 0, 60 }; static const TestCaseReference test2 = - (TestCaseReference){ "rwops_testMem", "Tests opening from memory", TEST_ENABLED, 0, 60 }; + (TestCaseReference){ "rwops_testMem", "Tests opening from memory", TEST_ENABLED, 0, 60 }; static const TestCaseReference test3 = - (TestCaseReference){ "rwops_testConstMem", "Tests opening from (const) memory", TEST_ENABLED, 0, 60 }; + (TestCaseReference){ "rwops_testConstMem", "Tests opening from (const) memory", TEST_ENABLED, 0, 60 }; static const TestCaseReference test4 = - (TestCaseReference){ "rwops_testFileRead", "Tests reading from a file", TEST_ENABLED, 0, 60 }; + (TestCaseReference){ "rwops_testFileRead", "Tests reading from a file", TEST_ENABLED, 0, 60 }; static const TestCaseReference test5 = - (TestCaseReference){ "rwops_testFileWrite", "Test writing to a file", TEST_ENABLED, 0, 60 }; + (TestCaseReference){ "rwops_testFileWrite", "Test writing to a file", TEST_ENABLED, 0, 60 }; static const TestCaseReference test6 = - (TestCaseReference){ "rwops_testFPRead", "Test reading from stdio", TEST_ENABLED, TEST_REQUIRES_STDIO, 60 }; + (TestCaseReference){ "rwops_testFPRead", "Test reading from stdio", TEST_ENABLED, TEST_REQUIRES_STDIO, 60 }; static const TestCaseReference test7 = - (TestCaseReference){ "rwops_testFPWrite", "Test writing to stdio", TEST_ENABLED, TEST_REQUIRES_STDIO, 60 }; + (TestCaseReference){ "rwops_testFPWrite", "Test writing to stdio", TEST_ENABLED, TEST_REQUIRES_STDIO, 60 }; /* Test suite */ extern const TestCaseReference *testSuite[] = { - &test1, &test2, &test3, &test4, &test5, &test6, &test7, NULL + &test1, &test2, &test3, &test4, &test5, &test6, &test7, NULL }; TestCaseReference **QueryTestSuite() { - return (TestCaseReference **)testSuite; + return (TestCaseReference **)testSuite; } @@ -58,19 +58,19 @@ TestCaseReference **QueryTestSuite() { void SetUp(void *arg) { - FILE *handle = fopen(RWOPS_READ, "w"); - AssertTrue(handle != NULL, "Creating file '%s' failed", RWOPS_READ); + FILE *handle = fopen(RWOPS_READ, "w"); + AssertTrue(handle != NULL, "Creating file '%s' failed", RWOPS_READ); - fwrite(hello_world, 1, SDL_strlen(hello_world), handle); - fclose(handle); + fwrite(hello_world, 1, SDL_strlen(hello_world), handle); + fclose(handle); } void TearDown(void *arg) { - // Remove the created files - remove(RWOPS_READ); - remove(RWOPS_WRITE); + // Remove the created files + remove(RWOPS_READ); + remove(RWOPS_WRITE); } /** @@ -93,10 +93,10 @@ int _testGeneric( SDL_RWops *rw, int write ) i = SDL_RWwrite( rw, hello_world, sizeof(hello_world)-1, 1); if (write) { - AssertEquals(i, 1, "Writing with SDL_RWwrite (failed to write)"); + AssertEquals(i, 1, "Writing with SDL_RWwrite (failed to write)"); } else { - AssertTrue(i <= 0, "Writing with SDL_RWwrite (wrote when shouldn't have): %d <= 0", i); + AssertTrue(i <= 0, "Writing with SDL_RWwrite (wrote when shouldn't have): %d <= 0", i); } /* Test seek. */ diff --git a/test/test-automation/tests/testsurface/testsurface.c b/test/test-automation/tests/testsurface/testsurface.c index 43b775cfb..dda9b1c10 100644 --- a/test/test-automation/tests/testsurface/testsurface.c +++ b/test/test-automation/tests/testsurface/testsurface.c @@ -11,47 +11,47 @@ /* Test case references */ static const TestCaseReference test1 = - (TestCaseReference){ "surface_testLoad", "Tests sprite loading.", TEST_ENABLED, 0, 0}; + (TestCaseReference){ "surface_testLoad", "Tests sprite loading.", TEST_ENABLED, 0, 0}; static const TestCaseReference test2 = - (TestCaseReference){ "surface_testBlit", "Tests some blitting routines.", TEST_ENABLED, 0, 0}; + (TestCaseReference){ "surface_testBlit", "Tests some blitting routines.", TEST_ENABLED, 0, 0}; static const TestCaseReference test3 = - (TestCaseReference){ "surface_testBlitBlendNone", "Tests blitting routines with none blending.", TEST_ENABLED, 0, 0}; + (TestCaseReference){ "surface_testBlitBlendNone", "Tests blitting routines with none blending.", TEST_ENABLED, 0, 0}; static const TestCaseReference test4 = - (TestCaseReference){ "surface_testLoadFailure", "Tests sprite loading. A failure case.", TEST_ENABLED, 0, 0}; + (TestCaseReference){ "surface_testLoadFailure", "Tests sprite loading. A failure case.", TEST_ENABLED, 0, 0}; static const TestCaseReference test5 = - (TestCaseReference){ "surface_testConversion", "Tests sprite conversion.", TEST_ENABLED, 0, 0}; + (TestCaseReference){ "surface_testConversion", "Tests sprite conversion.", TEST_ENABLED, 0, 0}; static const TestCaseReference test6 = - (TestCaseReference){ "surface_testBlitColorMod", "Tests some blitting routines with color mod.", TEST_ENABLED, 0, 0}; + (TestCaseReference){ "surface_testBlitColorMod", "Tests some blitting routines with color mod.", TEST_ENABLED, 0, 0}; static const TestCaseReference test7 = - (TestCaseReference){ "surface_testBlitAlphaMod", "Tests some blitting routines with alpha mod.", TEST_ENABLED, 0, 0}; + (TestCaseReference){ "surface_testBlitAlphaMod", "Tests some blitting routines with alpha mod.", TEST_ENABLED, 0, 0}; static const TestCaseReference test8 = - (TestCaseReference){ "surface_testBlitBlendLoop", "Test blittin routines with blending", TEST_ENABLED, 0, 0}; + (TestCaseReference){ "surface_testBlitBlendLoop", "Test blittin routines with blending", TEST_ENABLED, 0, 0}; static const TestCaseReference test9 = - (TestCaseReference){ "surface_testBlitBlendBlend", "Tests blitting routines with blend blending.", TEST_ENABLED, 0, 0}; + (TestCaseReference){ "surface_testBlitBlendBlend", "Tests blitting routines with blend blending.", TEST_ENABLED, 0, 0}; static const TestCaseReference test10 = - (TestCaseReference){ "surface_testBlitBlendAdd", "Tests blitting routines with add blending.", TEST_ENABLED, 0, 0}; + (TestCaseReference){ "surface_testBlitBlendAdd", "Tests blitting routines with add blending.", TEST_ENABLED, 0, 0}; static const TestCaseReference test11 = - (TestCaseReference){ "surface_testBlitBlendMod", "Tests blitting routines with modblending.", TEST_ENABLED, 0, 0}; + (TestCaseReference){ "surface_testBlitBlendMod", "Tests blitting routines with modblending.", TEST_ENABLED, 0, 0}; /* Test suite */ extern const TestCaseReference *testSuite[] = { - &test1, &test2, &test3, &test4, &test5, - &test6, &test7, &test8, &test9, &test10, &test11, NULL + &test1, &test2, &test3, &test4, &test5, + &test6, &test7, &test8, &test9, &test10, &test11, NULL }; TestCaseReference **QueryTestSuite() { - return (TestCaseReference **)testSuite; + return (TestCaseReference **)testSuite; } /* Function prototypes */ @@ -66,19 +66,19 @@ static SDL_Surface *testsur = NULL; void SetUp(void *arg) { - int ret = SDL_Init(SDL_INIT_VIDEO); - AssertTrue(ret == 0, "SDL_Init(SDL_INIT_VIDEO)"); + int ret = SDL_Init(SDL_INIT_VIDEO); + AssertTrue(ret == 0, "SDL_Init(SDL_INIT_VIDEO)"); - testsur = _CreateTestSurface(); - AssertTrue(testsur != NULL, "SDL_Init(SDL_INIT_VIDEO)"); + testsur = _CreateTestSurface(); + AssertTrue(testsur != NULL, "SDL_Init(SDL_INIT_VIDEO)"); } void TearDown(void *arg) { - SDL_FreeSurface( testsur ); + SDL_FreeSurface( testsur ); - SDL_Quit(); + SDL_Quit(); } /* Helper functions for the test cases */ @@ -93,24 +93,24 @@ TearDown(void *arg) SDL_Surface * _CreateTestSurface() { - SDL_Surface *testsur = NULL; + SDL_Surface *testsur = NULL; - /* Create the test surface. */ - testsur = SDL_CreateRGBSurface( 0, - TEST_SURFACE_WIDTH, TEST_SURFACE_HEIGHT, 32, - RMASK, GMASK, BMASK, AMASK ); + /* Create the test surface. */ + testsur = SDL_CreateRGBSurface( 0, + TEST_SURFACE_WIDTH, TEST_SURFACE_HEIGHT, 32, + RMASK, GMASK, BMASK, AMASK ); - if(testsur->w != TEST_SURFACE_WIDTH) { - AssertFail("Test surface width doesn't match"); - } + if(testsur->w != TEST_SURFACE_WIDTH) { + AssertFail("Test surface width doesn't match"); + } - if(testsur->h != TEST_SURFACE_HEIGHT) { - AssertFail("Test surface height doesn't match"); - } + if(testsur->h != TEST_SURFACE_HEIGHT) { + AssertFail("Test surface height doesn't match"); + } - AssertTrue(testsur != NULL, "SDL_CreateRGBSurface"); + AssertTrue(testsur != NULL, "SDL_CreateRGBSurface"); - return testsur; + return testsur; } /*! @@ -119,26 +119,26 @@ _CreateTestSurface() SDL_Surface * _createTestSurfaceFromMemory() { - SDL_Surface *face = NULL; - - /* Create face surface. */ - face = SDL_CreateRGBSurfaceFrom( (void*)img_face.pixel_data, - img_face.width, img_face.height, 32, img_face.width*4, - #if (SDL_BYTEORDER == SDL_BIG_ENDIAN) - 0xff000000, /* Red bit mask. */ - 0x00ff0000, /* Green bit mask. */ - 0x0000ff00, /* Blue bit mask. */ - 0x000000ff /* Alpha bit mask. */ - #else - 0x000000ff, /* Red bit mask. */ - 0x0000ff00, /* Green bit mask. */ - 0x00ff0000, /* Blue bit mask. */ - 0xff000000 /* Alpha bit mask. */ - #endif - ); - AssertTrue(face != NULL, "SDL_CreateRGBSurfaceFrom"); - - return face; + SDL_Surface *face = NULL; + + /* Create face surface. */ + face = SDL_CreateRGBSurfaceFrom( (void*)img_face.pixel_data, + img_face.width, img_face.height, 32, img_face.width*4, + #if (SDL_BYTEORDER == SDL_BIG_ENDIAN) + 0xff000000, /* Red bit mask. */ + 0x00ff0000, /* Green bit mask. */ + 0x0000ff00, /* Blue bit mask. */ + 0x000000ff /* Alpha bit mask. */ + #else + 0x000000ff, /* Red bit mask. */ + 0x0000ff00, /* Green bit mask. */ + 0x00ff0000, /* Blue bit mask. */ + 0xff000000 /* Alpha bit mask. */ + #endif + ); + AssertTrue(face != NULL, "SDL_CreateRGBSurfaceFrom"); + + return face; } /** @@ -146,50 +146,50 @@ _createTestSurfaceFromMemory() */ void _testBlitBlendMode(SDL_Surface *testsur, SDL_Surface *face, int mode) { - int ret; - int i, j, ni, nj; - SDL_Rect rect; - - AssertTrue(testsur != NULL, "testsur != NULL"); - AssertTrue(face != NULL, "face != NULL"); - - /* Clear surface. */ - ret = SDL_FillRect( testsur, NULL, - SDL_MapRGB( testsur->format, 0, 0, 0 ) ); - AssertTrue(ret == 0, "SDL_FillRect"); - - /* Steps to take. */ - ni = testsur->w - face->w; - nj = testsur->h - face->h; - - /* Constant values. */ - rect.w = face->w; - rect.h = face->h; - - /* Test blend mode. */ - for (j=0; j <= nj; j+=4) { - for (i=0; i <= ni; i+=4) { - /* Set blend mode. */ - ret = SDL_SetSurfaceBlendMode( face, mode ); - AssertTrue(ret == 0, "SDL_SetSurfaceBlendMode"); - - /* Blitting. */ - rect.x = i; - rect.y = j; - // TODO Add pixel level validation, SDL_BlitSurface might be no-op - ret = SDL_BlitSurface( face, NULL, testsur, &rect ); - AssertTrue(ret == 0, "SDL_BlitSurface"); - } - } + int ret; + int i, j, ni, nj; + SDL_Rect rect; + + AssertTrue(testsur != NULL, "testsur != NULL"); + AssertTrue(face != NULL, "face != NULL"); + + /* Clear surface. */ + ret = SDL_FillRect( testsur, NULL, + SDL_MapRGB( testsur->format, 0, 0, 0 ) ); + AssertTrue(ret == 0, "SDL_FillRect"); + + /* Steps to take. */ + ni = testsur->w - face->w; + nj = testsur->h - face->h; + + /* Constant values. */ + rect.w = face->w; + rect.h = face->h; + + /* Test blend mode. */ + for (j=0; j <= nj; j+=4) { + for (i=0; i <= ni; i+=4) { + /* Set blend mode. */ + ret = SDL_SetSurfaceBlendMode( face, mode ); + AssertTrue(ret == 0, "SDL_SetSurfaceBlendMode"); + + /* Blitting. */ + rect.x = i; + rect.y = j; + // TODO Add pixel level validation, SDL_BlitSurface might be no-op + ret = SDL_BlitSurface( face, NULL, testsur, &rect ); + AssertTrue(ret == 0, "SDL_BlitSurface"); + } + } } int _AssertFileExist(const char *filename) { - struct stat st; - int ret = stat(filename, &st); + struct stat st; + int ret = stat(filename, &st); - AssertTrue(ret == 0, "Does file %s exist", filename); + AssertTrue(ret == 0, "Does file %s exist", filename); } /* Test case functions */ @@ -198,25 +198,25 @@ _AssertFileExist(const char *filename) */ void surface_testLoad(void *arg) { - int ret; + int ret; SDL_Surface *face, *rface; /* Clear surface. */ /* ret = SDL_FillRect( testsur, NULL, SDL_MapRGB( testsur->format, 0, 0, 0 ) ); - AssertTrue(ret == 0, "SDL_FillRect"); - */ + AssertTrue(ret == 0, "SDL_FillRect"); + */ /* Create the blit surface. */ - const char *filename = "data/images/icon.bmp"; - _AssertFileExist(filename); + const char *filename = "data/images/icon.bmp"; + _AssertFileExist(filename); - face = SDL_LoadBMP(filename); - AssertTrue(face != NULL, "SDL_CreateLoadBmp"); + face = SDL_LoadBMP(filename); + AssertTrue(face != NULL, "SDL_CreateLoadBmp"); - AssertTrue(face->w == 32, "testing icon width"); - AssertTrue(face->h == 32, "testing icon height"); + AssertTrue(face->w == 32, "testing icon width"); + AssertTrue(face->h == 32, "testing icon height"); } /*! @@ -224,32 +224,32 @@ void surface_testLoad(void *arg) */ void surface_testConversion(void *arg) { - SDL_Surface *rface = NULL, *face = NULL; - int ret = 0; + SDL_Surface *rface = NULL, *face = NULL; + int ret = 0; - const char *filename = "data/images/icon.bmp"; - _AssertFileExist(filename); + const char *filename = "data/images/icon.bmp"; + _AssertFileExist(filename); - face = SDL_LoadBMP(filename); - AssertTrue(face != NULL, "SDL_CreateLoadBmp"); + face = SDL_LoadBMP(filename); + AssertTrue(face != NULL, "SDL_CreateLoadBmp"); - /* Set transparent pixel as the pixel at (0,0) */ - if (face->format->palette) { - ret = SDL_SetColorKey(face, SDL_RLEACCEL, *(Uint8 *) face->pixels); - AssertTrue(ret == 0, "SDL_SetColorKey"); - } + /* Set transparent pixel as the pixel at (0,0) */ + if (face->format->palette) { + ret = SDL_SetColorKey(face, SDL_RLEACCEL, *(Uint8 *) face->pixels); + AssertTrue(ret == 0, "SDL_SetColorKey"); + } - /* Convert to 32 bit to compare. */ - rface = SDL_ConvertSurface( face, testsur->format, 0 ); - AssertTrue(rface != NULL, "SDL_ConvertSurface"); + /* Convert to 32 bit to compare. */ + rface = SDL_ConvertSurface( face, testsur->format, 0 ); + AssertTrue(rface != NULL, "SDL_ConvertSurface"); - /* See if it's the same. */ - AssertTrue(surface_compare( rface, &img_face, 0 ) == 0, - "Comparing primitives output."); + /* See if it's the same. */ + AssertTrue(surface_compare( rface, &img_face, 0 ) == 0, + "Comparing primitives output."); - /* Clean up. */ - SDL_FreeSurface( rface ); - SDL_FreeSurface( face ); + /* Clean up. */ + SDL_FreeSurface( rface ); + SDL_FreeSurface( face ); } @@ -258,8 +258,8 @@ void surface_testConversion(void *arg) */ void surface_testLoadFailure(void *arg) { - SDL_Surface *face = SDL_LoadBMP("nonexistant.bmp"); - AssertTrue(face == NULL, "SDL_CreateLoadBmp"); + SDL_Surface *face = SDL_LoadBMP("nonexistant.bmp"); + AssertTrue(face == NULL, "SDL_CreateLoadBmp"); } /** @@ -302,7 +302,7 @@ void surface_testBlit(void *arg) /* See if it's the same. */ AssertTrue(surface_compare( testsur, &img_blit, 0 ) == 0, - "Comparing blitting output (normal blit)."); + "Comparing blitting output (normal blit)."); /* Clean up. */ SDL_FreeSurface( face ); @@ -357,7 +357,7 @@ void surface_testBlitColorMod(void *arg) /* See if it's the same. */ AssertTrue(surface_compare( testsur, &img_blitColour, 0 ) == 0, - "Comparing blitting output (using SDL_SetSurfaceColorMod)."); + "Comparing blitting output (using SDL_SetSurfaceColorMod)."); /* Clean up. */ SDL_FreeSurface( face ); @@ -415,7 +415,7 @@ void surface_testBlitAlphaMod(void *arg) /* See if it's the same. */ AssertTrue(surface_compare( testsur, &img_blitAlpha, 0 ) == 0, - "Comparing blitting output (using SDL_SetSurfaceAlphaMod)."); + "Comparing blitting output (using SDL_SetSurfaceAlphaMod)."); /* Clean up. */ SDL_FreeSurface( face ); @@ -458,22 +458,22 @@ void surface_testBlitBlendNone(void *arg) /* Test None. */ _testBlitBlendMode( testsur, face, SDL_BLENDMODE_NONE ); AssertTrue(surface_compare( testsur, &img_blendNone, 0 ) == 0, - "Comparing blitting blending output (using SDL_BLENDMODE_NONE)."); + "Comparing blitting blending output (using SDL_BLENDMODE_NONE)."); /* Test Blend. */ _testBlitBlendMode( testsur, face, SDL_BLENDMODE_BLEND ); AssertTrue(surface_compare( testsur, &img_blendBlend, 0 ) == 0, - "Comparing blitting blending output (using SDL_BLENDMODE_BLEND)."); + "Comparing blitting blending output (using SDL_BLENDMODE_BLEND)."); /* Test Add. */ _testBlitBlendMode( testsur, face, SDL_BLENDMODE_ADD ); AssertTrue(surface_compare( testsur, &img_blendAdd, 0 ) == 0, - "Comparing blitting blending output (using SDL_BLENDMODE_ADD)."); + "Comparing blitting blending output (using SDL_BLENDMODE_ADD)."); /* Test Mod. */ _testBlitBlendMode( testsur, face, SDL_BLENDMODE_MOD ); AssertTrue(surface_compare( testsur, &img_blendMod, 0 ) == 0, - "Comparing blitting blending output not the same (using SDL_BLENDMODE_MOD)."); + "Comparing blitting blending output not the same (using SDL_BLENDMODE_MOD)."); } /** @@ -513,7 +513,7 @@ void surface_testBlitBlendBlend(void *arg) /* Test Blend. */ _testBlitBlendMode( testsur, face, SDL_BLENDMODE_BLEND ); AssertTrue(surface_compare( testsur, &img_blendBlend, 0 ) == 0, - "Comparing blitting blending output (using SDL_BLENDMODE_BLEND)."); + "Comparing blitting blending output (using SDL_BLENDMODE_BLEND)."); } /** @@ -553,7 +553,7 @@ void surface_testBlitBlendAdd(void *arg) /* Test Add. */ _testBlitBlendMode( testsur, face, SDL_BLENDMODE_ADD ); AssertTrue(surface_compare( testsur, &img_blendAdd, 0 ) == 0, - "Comparing blitting blending output (using SDL_BLENDMODE_ADD)."); + "Comparing blitting blending output (using SDL_BLENDMODE_ADD)."); } /** @@ -594,41 +594,41 @@ void surface_testBlitBlendMod(void *arg) /* Test Mod. */ _testBlitBlendMode( testsur, face, SDL_BLENDMODE_MOD ); AssertTrue(surface_compare( testsur, &img_blendMod, 0 ) == 0, - "Comparing blitting blending output (using SDL_BLENDMODE_MOD)."); + "Comparing blitting blending output (using SDL_BLENDMODE_MOD)."); } /** * @brief Tests some more blitting routines with loop */ void surface_testBlitBlendLoop(void *arg) { - int ret; - SDL_Rect rect; - SDL_Surface *face; - int i, j, ni, nj; - int mode; + int ret; + SDL_Rect rect; + SDL_Surface *face; + int i, j, ni, nj; + int mode; - /* Clear surface. */ - ret = SDL_FillRect( testsur, NULL, - SDL_MapRGB( testsur->format, 0, 0, 0 ) ); - AssertTrue(ret == 0, "SDL_FillRect"); + /* Clear surface. */ + ret = SDL_FillRect( testsur, NULL, + SDL_MapRGB( testsur->format, 0, 0, 0 ) ); + AssertTrue(ret == 0, "SDL_FillRect"); - face = _createTestSurfaceFromMemory(); + face = _createTestSurfaceFromMemory(); - /* Set alpha mod. */ - // TODO alpha value could be generated by fuzzer - ret = SDL_SetSurfaceAlphaMod( face, 100 ); - AssertTrue(ret == 0, "SDL_SetSurfaceAlphaMod"); + /* Set alpha mod. */ + // TODO alpha value could be generated by fuzzer + ret = SDL_SetSurfaceAlphaMod( face, 100 ); + AssertTrue(ret == 0, "SDL_SetSurfaceAlphaMod"); - /* Steps to take. */ - ni = testsur->w - face->w; - nj = testsur->h - face->h; + /* Steps to take. */ + ni = testsur->w - face->w; + nj = testsur->h - face->h; - AssertTrue(ni != 0, "ni != 0"); - AssertTrue(nj != 0, "nj != 0"); + AssertTrue(ni != 0, "ni != 0"); + AssertTrue(nj != 0, "nj != 0"); - /* Constant values. */ - rect.w = face->w; - rect.h = face->h; + /* Constant values. */ + rect.w = face->w; + rect.h = face->h; /* Clear surface. */ ret = SDL_FillRect( testsur, NULL, @@ -668,7 +668,7 @@ void surface_testBlitBlendLoop(void *arg) { /* Check to see if matches. */ AssertTrue(surface_compare( testsur, &img_blendAll, 0 ) == 0, - "Surface comparison (surface_compare)."); + "Surface comparison (surface_compare)."); /* Clean up. */ SDL_FreeSurface( face ); diff --git a/test/test-automation/tests/testsyswm/testsyswm.c b/test/test-automation/tests/testsyswm/testsyswm.c index c1ed07c76..6360eb4e0 100644 --- a/test/test-automation/tests/testsyswm/testsyswm.c +++ b/test/test-automation/tests/testsyswm/testsyswm.c @@ -13,15 +13,15 @@ /* Test cases */ static const TestCaseReference test1 = - (TestCaseReference){ "syswm_test", "description", TEST_DISABLED, 0, 0 }; + (TestCaseReference){ "syswm_test", "description", TEST_DISABLED, 0, 0 }; /* Test suite */ extern const TestCaseReference *testSuite[] = { - &test1, NULL + &test1, NULL }; TestCaseReference **QueryTestSuite() { - return (TestCaseReference **)testSuite; + return (TestCaseReference **)testSuite; } /** @@ -30,5 +30,5 @@ TestCaseReference **QueryTestSuite() { int syswm_test(void *arg) { - AssertPass(""); + AssertPass(""); } diff --git a/test/test-automation/tests/testvideo/testvideo.c b/test/test-automation/tests/testvideo/testvideo.c index bedfcac66..686c42881 100644 --- a/test/test-automation/tests/testvideo/testvideo.c +++ b/test/test-automation/tests/testvideo/testvideo.c @@ -13,15 +13,15 @@ /* Test cases */ static const TestCaseReference test1 = - (TestCaseReference){ "video_test", "video stuff", TEST_DISABLED, 0, 0 }; + (TestCaseReference){ "video_test", "video stuff", TEST_DISABLED, 0, 0 }; /* Test suite */ extern const TestCaseReference *testSuite[] = { - &test1, NULL + &test1, NULL }; TestCaseReference **QueryTestSuite() { - return (TestCaseReference **)testSuite; + return (TestCaseReference **)testSuite; } /** @@ -30,5 +30,5 @@ TestCaseReference **QueryTestSuite() { int video_test(void *arg) { - AssertPass(""); + AssertPass(""); } diff --git a/test/testatomic.c b/test/testatomic.c index 7bcceb559..143d707c0 100644 --- a/test/testatomic.c +++ b/test/testatomic.c @@ -53,7 +53,7 @@ void RunBasicTest() printf("AtomicUnlock lock=%d\n", lock); printf("\natomic -----------------------------------------\n\n"); - + SDL_AtomicSet(&v, 0); tfret = SDL_AtomicSet(&v, 10) == 0; printf("AtomicSet(10) tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v)); @@ -95,27 +95,27 @@ void RunBasicTest() * at the end the value is compared with the expected * and with a non-atomic counter. */ - + /* Number of concurrent incrementers */ #define NThreads 2 #define CountInc 100 #define VALBITS (sizeof(atomicValue)*8) - + #define atomicValue int #define CountTo ((atomicValue)((unsigned int)(1<<(VALBITS-1))-1)) #define NInter (CountTo/CountInc/NThreads) #define Expect (CountTo-NInter*CountInc*NThreads) - + SDL_COMPILE_TIME_ASSERT(size, CountTo>0); /* check for rollover */ - + static SDL_atomic_t good = { 42 }; - + static atomicValue bad = 42; - + static SDL_atomic_t threadsRunning; static SDL_sem *threadDone; - + static int adder(void* junk) { @@ -129,111 +129,111 @@ int adder(void* junk) SDL_SemPost(threadDone); return 0; } - + static void runAdder(void) { Uint32 start, end; int T=NThreads; - + start = SDL_GetTicks(); - + threadDone = SDL_CreateSemaphore(0); SDL_AtomicSet(&threadsRunning, NThreads); while (T--) SDL_CreateThread(adder, "Adder", NULL); - + while (SDL_AtomicGet(&threadsRunning) > 0) SDL_SemWait(threadDone); - + SDL_DestroySemaphore(threadDone); end = SDL_GetTicks(); - + printf("Finished in %f sec\n", (end - start) / 1000.f); } - + static void RunEpicTest() { int b; atomicValue v; - + printf("\nepic test---------------------------------------\n\n"); printf("Size asserted to be >= 32-bit\n"); SDL_assert(sizeof(atomicValue)>=4); - + printf("Check static initializer\n"); v=SDL_AtomicGet(&good); SDL_assert(v==42); - + SDL_assert(bad==42); - + printf("Test negative values\n"); SDL_AtomicSet(&good, -5); v=SDL_AtomicGet(&good); SDL_assert(v==-5); - + printf("Verify maximum value\n"); SDL_AtomicSet(&good, CountTo); v=SDL_AtomicGet(&good); SDL_assert(v==CountTo); - + printf("Test compare and exchange\n"); - + b=SDL_AtomicCAS(&good, 500, 43); SDL_assert(!b); /* no swap since CountTo!=500 */ v=SDL_AtomicGet(&good); SDL_assert(v==CountTo); /* ensure no swap */ - + b=SDL_AtomicCAS(&good, CountTo, 44); SDL_assert(!!b); /* will swap */ v=SDL_AtomicGet(&good); SDL_assert(v==44); - + printf("Test Add\n"); - + v=SDL_AtomicAdd(&good, 1); SDL_assert(v==44); v=SDL_AtomicGet(&good); SDL_assert(v==45); - + v=SDL_AtomicAdd(&good, 10); SDL_assert(v==45); v=SDL_AtomicGet(&good); SDL_assert(v==55); - + printf("Test Add (Negative values)\n"); - + v=SDL_AtomicAdd(&good, -20); SDL_assert(v==55); v=SDL_AtomicGet(&good); SDL_assert(v==35); - + v=SDL_AtomicAdd(&good, -50); /* crossing zero down */ SDL_assert(v==35); v=SDL_AtomicGet(&good); SDL_assert(v==-15); - + v=SDL_AtomicAdd(&good, 30); /* crossing zero up */ SDL_assert(v==-15); v=SDL_AtomicGet(&good); SDL_assert(v==15); - + printf("Reset before count down test\n"); SDL_AtomicSet(&good, CountTo); v=SDL_AtomicGet(&good); SDL_assert(v==CountTo); - + bad=CountTo; SDL_assert(bad==CountTo); - + printf("Counting down from %d, Expect %d remaining\n",CountTo,Expect); runAdder(); - + v=SDL_AtomicGet(&good); printf("Atomic %d Non-Atomic %d\n",v,bad); SDL_assert(v==Expect); @@ -599,7 +599,7 @@ static void RunFIFOTest(SDL_bool lock_free) Uint32 start, end; int i, j; int grand_total; - + printf("\nFIFO test---------------------------------------\n\n"); printf("Mode: %s\n", lock_free ? "LockFree" : "Mutex"); @@ -614,7 +614,7 @@ static void RunFIFOTest(SDL_bool lock_free) } start = SDL_GetTicks(); - + #ifdef TEST_SPINLOCK_FIFO /* Start a monitoring thread */ if (lock_free) { @@ -646,12 +646,12 @@ static void RunFIFOTest(SDL_bool lock_free) writerData[i].lock_free = lock_free; SDL_CreateThread(FIFO_Writer, name, &writerData[i]); } - + /* Wait for the writers */ while (SDL_AtomicGet(&writersRunning) > 0) { SDL_SemWait(writersDone); } - + /* Shut down the queue so readers exit */ queue.active = SDL_FALSE; @@ -661,14 +661,14 @@ static void RunFIFOTest(SDL_bool lock_free) } end = SDL_GetTicks(); - + SDL_DestroySemaphore(readersDone); SDL_DestroySemaphore(writersDone); if (!lock_free) { SDL_DestroyMutex(queue.mutex); } - + printf("Finished in %f sec\n", (end - start) / 1000.f); printf("\n"); diff --git a/test/testautomation.c b/test/testautomation.c index a32853c53..be3bd7ff8 100644 --- a/test/testautomation.c +++ b/test/testautomation.c @@ -57,27 +57,27 @@ main(int argc, char *argv[]) if (argv[i + 1]) { testIterations = SDL_atoi(argv[i + 1]); if (testIterations < 1) testIterations = 1; - consumed = 2; + consumed = 2; } - } + } else if (SDL_strcasecmp(argv[i], "--execKey") == 0) { if (argv[i + 1]) { SDL_sscanf(argv[i + 1], "%llu", (long long unsigned int *)&userExecKey); - consumed = 2; + consumed = 2; } - } + } else if (SDL_strcasecmp(argv[i], "--seed") == 0) { if (argv[i + 1]) { userRunSeed = SDL_strdup(argv[i + 1]); consumed = 2; } - } + } else if (SDL_strcasecmp(argv[i], "--filter") == 0) { if (argv[i + 1]) { filter = SDL_strdup(argv[i + 1]); consumed = 2; } - } + } } if (consumed < 0) { fprintf(stderr, @@ -85,11 +85,11 @@ main(int argc, char *argv[]) argv[0], SDLTest_CommonUsage(state)); quit(1); } - + i += consumed; } - /* Initialize common state */ + /* Initialize common state */ if (!SDLTest_CommonInit(state)) { quit(2); } @@ -104,7 +104,7 @@ main(int argc, char *argv[]) /* Call Harness */ result = SDLTest_RunSuites(testSuites, (const char *)userRunSeed, userExecKey, (const char *)filter, testIterations); - /* Empty event queue */ + /* Empty event queue */ done = 0; for (i=0; i<100; i++) { while (SDL_PollEvent(&event)) { @@ -120,9 +120,9 @@ main(int argc, char *argv[]) if (filter != NULL) { SDL_free(filter); } - + /* Shutdown everything */ - quit(result); + quit(result); return(result); } diff --git a/test/testautomation_audio.c b/test/testautomation_audio.c index b6f316393..90b08acbd 100644 --- a/test/testautomation_audio.c +++ b/test/testautomation_audio.c @@ -16,11 +16,11 @@ void _audioSetUp(void *arg) { - /* Start SDL audio subsystem */ - int ret = SDL_InitSubSystem( SDL_INIT_AUDIO ); + /* Start SDL audio subsystem */ + int ret = SDL_InitSubSystem( SDL_INIT_AUDIO ); SDLTest_AssertPass("Call to SDL_InitSubSystem(SDL_INIT_AUDIO)"); - SDLTest_AssertCheck(ret==0, "Check result from SDL_InitSubSystem(SDL_INIT_AUDIO)"); - if (ret != 0) { + SDLTest_AssertCheck(ret==0, "Check result from SDL_InitSubSystem(SDL_INIT_AUDIO)"); + if (ret != 0) { SDLTest_LogError("%s", SDL_GetError()); } } @@ -37,14 +37,14 @@ void _audio_testCallback(void *userdata, Uint8 *stream, int len) /** * \brief Stop and restart audio subsystem - * + * * \sa http://wiki.libsdl.org/moin.cgi/SDL_QuitSubSystem * \sa http://wiki.libsdl.org/moin.cgi/SDL_InitSubSystem */ int audio_quitInitAudioSubSystem() { - /* Stop SDL audio subsystem */ - SDL_QuitSubSystem( SDL_INIT_AUDIO ); + /* Stop SDL audio subsystem */ + SDL_QuitSubSystem( SDL_INIT_AUDIO ); SDLTest_AssertPass("Call to SDL_QuitSubSystem(SDL_INIT_AUDIO)"); /* Restart audio again */ @@ -55,18 +55,18 @@ int audio_quitInitAudioSubSystem() /** * \brief Start and stop audio directly - * + * * \sa http://wiki.libsdl.org/moin.cgi/SDL_InitAudio * \sa http://wiki.libsdl.org/moin.cgi/SDL_QuitAudio */ int audio_initQuitAudio() { int result; - int i, iMax; - const char* audioDriver; - - /* Stop SDL audio subsystem */ - SDL_QuitSubSystem( SDL_INIT_AUDIO ); + int i, iMax; + const char* audioDriver; + + /* Stop SDL audio subsystem */ + SDL_QuitSubSystem( SDL_INIT_AUDIO ); SDLTest_AssertPass("Call to SDL_QuitSubSystem(SDL_INIT_AUDIO)"); /* Loop over all available audio drivers */ @@ -74,33 +74,33 @@ int audio_initQuitAudio() SDLTest_AssertPass("Call to SDL_GetNumAudioDrivers"); SDLTest_AssertCheck(iMax > 0, "Validate number of audio drivers; expected: >0 got: %d", iMax); for (i = 0; i < iMax; i++) { - audioDriver = SDL_GetAudioDriver(i); - SDLTest_AssertPass("Call to SDL_GetAudioDriver(%d)", i); - SDLTest_AssertCheck(audioDriver != NULL, "Audio driver name is not NULL"); - SDLTest_AssertCheck(SDL_strlen(audioDriver) > 0, "Audio driver name is not empty; got: %s", audioDriver); - - /* Call Init */ - result = SDL_AudioInit(audioDriver); - SDLTest_AssertPass("Call to SDL_AudioInit('%s')", audioDriver); - SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0 got: %d", result); - - /* Call Quit */ - SDL_AudioQuit(); - SDLTest_AssertPass("Call to SDL_AudioQuit()"); - } - - /* NULL driver specification */ - audioDriver = NULL; - - /* Call Init */ - result = SDL_AudioInit(audioDriver); - SDLTest_AssertPass("Call to SDL_AudioInit(NULL)"); - SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0 got: %d", result); - - /* Call Quit */ - SDL_AudioQuit(); - SDLTest_AssertPass("Call to SDL_AudioQuit()"); - + audioDriver = SDL_GetAudioDriver(i); + SDLTest_AssertPass("Call to SDL_GetAudioDriver(%d)", i); + SDLTest_AssertCheck(audioDriver != NULL, "Audio driver name is not NULL"); + SDLTest_AssertCheck(SDL_strlen(audioDriver) > 0, "Audio driver name is not empty; got: %s", audioDriver); + + /* Call Init */ + result = SDL_AudioInit(audioDriver); + SDLTest_AssertPass("Call to SDL_AudioInit('%s')", audioDriver); + SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0 got: %d", result); + + /* Call Quit */ + SDL_AudioQuit(); + SDLTest_AssertPass("Call to SDL_AudioQuit()"); + } + + /* NULL driver specification */ + audioDriver = NULL; + + /* Call Init */ + result = SDL_AudioInit(audioDriver); + SDLTest_AssertPass("Call to SDL_AudioInit(NULL)"); + SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0 got: %d", result); + + /* Call Quit */ + SDL_AudioQuit(); + SDLTest_AssertPass("Call to SDL_AudioQuit()"); + /* Restart audio again */ _audioSetUp(NULL); @@ -109,7 +109,7 @@ int audio_initQuitAudio() /** * \brief Start, open, close and stop audio - * + * * \sa http://wiki.libsdl.org/moin.cgi/SDL_InitAudio * \sa http://wiki.libsdl.org/moin.cgi/SDL_OpenAudio * \sa http://wiki.libsdl.org/moin.cgi/SDL_CloseAudio @@ -118,12 +118,12 @@ int audio_initQuitAudio() int audio_initOpenCloseQuitAudio() { int result; - int i, iMax, j; - const char* audioDriver; - SDL_AudioSpec desired; - - /* Stop SDL audio subsystem */ - SDL_QuitSubSystem( SDL_INIT_AUDIO ); + int i, iMax, j; + const char* audioDriver; + SDL_AudioSpec desired; + + /* Stop SDL audio subsystem */ + SDL_QuitSubSystem( SDL_INIT_AUDIO ); SDLTest_AssertPass("Call to SDL_QuitSubSystem(SDL_INIT_AUDIO)"); /* Loop over all available audio drivers */ @@ -131,58 +131,58 @@ int audio_initOpenCloseQuitAudio() SDLTest_AssertPass("Call to SDL_GetNumAudioDrivers"); SDLTest_AssertCheck(iMax > 0, "Validate number of audio drivers; expected: >0 got: %d", iMax); for (i = 0; i < iMax; i++) { - audioDriver = SDL_GetAudioDriver(i); - SDLTest_AssertPass("Call to SDL_GetAudioDriver(%d)", i); - SDLTest_AssertCheck(audioDriver != NULL, "Audio driver name is not NULL"); - SDLTest_AssertCheck(SDL_strlen(audioDriver) > 0, "Audio driver name is not empty; got: %s", audioDriver); - - /* Change specs */ - for (j = 0; j < 2; j++) { - - /* Call Init */ - result = SDL_AudioInit(audioDriver); - SDLTest_AssertPass("Call to SDL_AudioInit('%s')", audioDriver); - SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0 got: %d", result); - - /* Set spec */ - SDL_memset(&desired, 0, sizeof(desired)); - switch (j) { - case 0: - /* Set standard desired spec */ - desired.freq = 22050; - desired.format = AUDIO_S16SYS; - desired.channels = 2; - desired.samples = 4096; - desired.callback = _audio_testCallback; - desired.userdata = NULL; - - case 1: - /* Set custom desired spec */ - desired.freq = 48000; - desired.format = AUDIO_F32SYS; - desired.channels = 2; - desired.samples = 2048; - desired.callback = _audio_testCallback; - desired.userdata = NULL; - break; - } - - /* Call Open */ - result = SDL_OpenAudio(&desired, NULL); - SDLTest_AssertPass("Call to SDL_OpenAudio(desired_spec_%d, NULL)", j); - SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0 got: %d", result); - - /* Call Close */ - SDL_CloseAudio(); - SDLTest_AssertPass("Call to SDL_CloseAudio()"); - - /* Call Quit */ - SDL_AudioQuit(); - SDLTest_AssertPass("Call to SDL_AudioQuit()"); - - } /* spec loop */ - } /* driver loop */ - + audioDriver = SDL_GetAudioDriver(i); + SDLTest_AssertPass("Call to SDL_GetAudioDriver(%d)", i); + SDLTest_AssertCheck(audioDriver != NULL, "Audio driver name is not NULL"); + SDLTest_AssertCheck(SDL_strlen(audioDriver) > 0, "Audio driver name is not empty; got: %s", audioDriver); + + /* Change specs */ + for (j = 0; j < 2; j++) { + + /* Call Init */ + result = SDL_AudioInit(audioDriver); + SDLTest_AssertPass("Call to SDL_AudioInit('%s')", audioDriver); + SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0 got: %d", result); + + /* Set spec */ + SDL_memset(&desired, 0, sizeof(desired)); + switch (j) { + case 0: + /* Set standard desired spec */ + desired.freq = 22050; + desired.format = AUDIO_S16SYS; + desired.channels = 2; + desired.samples = 4096; + desired.callback = _audio_testCallback; + desired.userdata = NULL; + + case 1: + /* Set custom desired spec */ + desired.freq = 48000; + desired.format = AUDIO_F32SYS; + desired.channels = 2; + desired.samples = 2048; + desired.callback = _audio_testCallback; + desired.userdata = NULL; + break; + } + + /* Call Open */ + result = SDL_OpenAudio(&desired, NULL); + SDLTest_AssertPass("Call to SDL_OpenAudio(desired_spec_%d, NULL)", j); + SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0 got: %d", result); + + /* Call Close */ + SDL_CloseAudio(); + SDLTest_AssertPass("Call to SDL_CloseAudio()"); + + /* Call Quit */ + SDL_AudioQuit(); + SDLTest_AssertPass("Call to SDL_AudioQuit()"); + + } /* spec loop */ + } /* driver loop */ + /* Restart audio again */ _audioSetUp(NULL); @@ -191,7 +191,7 @@ int audio_initOpenCloseQuitAudio() /** * \brief Enumerate and name available audio devices (output and capture). - * + * * \sa http://wiki.libsdl.org/moin.cgi/SDL_GetNumAudioDevices * \sa http://wiki.libsdl.org/moin.cgi/SDL_GetAudioDeviceName */ @@ -203,7 +203,7 @@ int audio_enumerateAndNameAudioDevices() /* Iterate over types: t=0 output device, t=1 input/capture device */ for (t=0; t<2; t++) { - + /* Get number of devices. */ n = SDL_GetNumAudioDevices(t); SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(%i)", t); @@ -217,8 +217,8 @@ int audio_enumerateAndNameAudioDevices() SDLTest_AssertCheck(n==nn, "Verify result from SDL_GetNumAudioDevices(%i), expected same number of audio devices %i, got %i", tt, n, nn); nn = SDL_GetNumAudioDevices(-tt); SDLTest_AssertCheck(n==nn, "Verify result from SDL_GetNumAudioDevices(%i), expected same number of audio devices %i, got %i", -tt, n, nn); - } - + } + /* List devices. */ if (n>0) { for (i=0; i0, "Verify result from SDL_GetAudioDeviceName(%i, %i) is not empty, got: '%s'", i, tt, nameAgain); - SDLTest_AssertCheck(SDL_strcmp(name, nameAgain)==0, - "Verify SDL_GetAudioDeviceName(%i, %i) and SDL_GetAudioDeviceName(%i %i) return the same string", + SDLTest_AssertCheck(SDL_strcmp(name, nameAgain)==0, + "Verify SDL_GetAudioDeviceName(%i, %i) and SDL_GetAudioDeviceName(%i %i) return the same string", i, t, i, tt); } } @@ -243,13 +243,13 @@ int audio_enumerateAndNameAudioDevices() } } } - + return TEST_COMPLETED; } /** * \brief Negative tests around enumeration and naming of audio devices. - * + * * \sa http://wiki.libsdl.org/moin.cgi/SDL_GetNumAudioDevices * \sa http://wiki.libsdl.org/moin.cgi/SDL_GetAudioDeviceName */ @@ -258,13 +258,13 @@ int audio_enumerateAndNameAudioDevicesNegativeTests() int t; int i, j, no, nc; const char *name; - + /* Get number of devices. */ no = SDL_GetNumAudioDevices(0); SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(0)"); nc = SDL_GetNumAudioDevices(1); SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(1)"); - + /* Invalid device index when getting name */ for (t=0; t<2; t++) { /* Negative device index */ @@ -272,7 +272,7 @@ int audio_enumerateAndNameAudioDevicesNegativeTests() name = SDL_GetAudioDeviceName(i, t); SDLTest_AssertPass("Call to SDL_GetAudioDeviceName(%i, %i)", i, t); SDLTest_AssertCheck(name == NULL, "Check SDL_GetAudioDeviceName(%i, %i) result NULL, expected NULL, got: %s", i, t, (name == NULL) ? "NULL" : name); - + /* Device index past range */ for (j=0; j<3; j++) { i = (t) ? nc+j : no+j; @@ -280,7 +280,7 @@ int audio_enumerateAndNameAudioDevicesNegativeTests() SDLTest_AssertPass("Call to SDL_GetAudioDeviceName(%i, %i)", i, t); SDLTest_AssertCheck(name == NULL, "Check SDL_GetAudioDeviceName(%i, %i) result, expected: NULL, got: %s", i, t, (name == NULL) ? "NULL" : name); } - + /* Capture index past capture range but within output range */ if ((no>0) && (no>nc) && (t==1)) { i = no-1; @@ -309,7 +309,7 @@ int audio_printAudioDrivers() n = SDL_GetNumAudioDrivers(); SDLTest_AssertPass("Call to SDL_GetNumAudioDrivers()"); SDLTest_AssertCheck(n>=0, "Verify number of audio drivers >= 0, got: %i", n); - + /* List drivers. */ if (n>0) { @@ -347,11 +347,11 @@ int audio_printCurrentAudioDriver() /* Definition of all formats, channels, and frequencies used to test audio conversions */ const int _numAudioFormats = 18; -SDL_AudioFormat _audioFormats[] = { AUDIO_S8, AUDIO_U8, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_S16SYS, AUDIO_S16, AUDIO_U16LSB, - AUDIO_U16MSB, AUDIO_U16SYS, AUDIO_U16, AUDIO_S32LSB, AUDIO_S32MSB, AUDIO_S32SYS, AUDIO_S32, +SDL_AudioFormat _audioFormats[] = { AUDIO_S8, AUDIO_U8, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_S16SYS, AUDIO_S16, AUDIO_U16LSB, + AUDIO_U16MSB, AUDIO_U16SYS, AUDIO_U16, AUDIO_S32LSB, AUDIO_S32MSB, AUDIO_S32SYS, AUDIO_S32, AUDIO_F32LSB, AUDIO_F32MSB, AUDIO_F32SYS, AUDIO_F32 }; -char *_audioFormatsVerbose[] = { "AUDIO_S8", "AUDIO_U8", "AUDIO_S16LSB", "AUDIO_S16MSB", "AUDIO_S16SYS", "AUDIO_S16", "AUDIO_U16LSB", - "AUDIO_U16MSB", "AUDIO_U16SYS", "AUDIO_U16", "AUDIO_S32LSB", "AUDIO_S32MSB", "AUDIO_S32SYS", "AUDIO_S32", +char *_audioFormatsVerbose[] = { "AUDIO_S8", "AUDIO_U8", "AUDIO_S16LSB", "AUDIO_S16MSB", "AUDIO_S16SYS", "AUDIO_S16", "AUDIO_U16LSB", + "AUDIO_U16MSB", "AUDIO_U16SYS", "AUDIO_U16", "AUDIO_S32LSB", "AUDIO_S32MSB", "AUDIO_S32SYS", "AUDIO_S32", "AUDIO_F32LSB", "AUDIO_F32MSB", "AUDIO_F32SYS", "AUDIO_F32" }; const int _numAudioChannels = 4; Uint8 _audioChannels[] = { 1, 2, 4, 6 }; @@ -371,7 +371,7 @@ int audio_buildAudioCVT() SDL_AudioSpec spec1; SDL_AudioSpec spec2; int i, ii, j, jj, k, kk; - + /* No conversion needed */ spec1.format = AUDIO_S16LSB; spec1.channels = 2; @@ -387,7 +387,7 @@ int audio_buildAudioCVT() spec1.freq = 22050; spec2.format = AUDIO_S16LSB; spec2.channels = 2; - spec2.freq = 44100; + spec2.freq = 44100; result = SDL_BuildAudioCVT(&cvt, spec1.format, spec1.channels, spec1.freq, spec2.format, spec2.channels, spec2.freq); SDLTest_AssertPass("Call to SDL_BuildAudioCVT(spec1 ==> spec2)"); @@ -408,7 +408,7 @@ int audio_buildAudioCVT() spec2.freq = _audioFrequencies[kk]; result = SDL_BuildAudioCVT(&cvt, spec1.format, spec1.channels, spec1.freq, spec2.format, spec2.channels, spec2.freq); - SDLTest_AssertPass("Call to SDL_BuildAudioCVT(format[%i]=%s(%i),channels[%i]=%i,freq[%i]=%i ==> format[%i]=%s(%i),channels[%i]=%i,freq[%i]=%i)", + SDLTest_AssertPass("Call to SDL_BuildAudioCVT(format[%i]=%s(%i),channels[%i]=%i,freq[%i]=%i ==> format[%i]=%s(%i),channels[%i]=%i,freq[%i]=%i)", i, _audioFormatsVerbose[i], spec1.format, j, spec1.channels, k, spec1.freq, ii, _audioFormatsVerbose[ii], spec2.format, jj, spec2.channels, kk, spec2.freq); SDLTest_AssertCheck(result == 0 || result == 1, "Verify result value; expected: 0 or 1, got: %i", result); if (result<0) { @@ -431,7 +431,7 @@ int audio_buildAudioCVT() int audio_buildAudioCVTNegative() { const char *expectedError = "Parameter 'cvt' is invalid"; - const char *error; + const char *error; int result; SDL_AudioCVT cvt; SDL_AudioSpec spec1; @@ -439,13 +439,13 @@ int audio_buildAudioCVTNegative() int i; char message[256]; - /* Valid format */ + /* Valid format */ spec1.format = AUDIO_S8; spec1.channels = 1; spec1.freq = 22050; spec2.format = AUDIO_S16LSB; spec2.channels = 2; - spec2.freq = 44100; + spec2.freq = 44100; SDL_ClearError(); SDLTest_AssertPass("Call to SDL_ClearError()"); @@ -454,51 +454,51 @@ int audio_buildAudioCVTNegative() result = SDL_BuildAudioCVT((SDL_AudioCVT *)NULL, spec1.format, spec1.channels, spec1.freq, spec2.format, spec2.channels, spec2.freq); SDLTest_AssertPass("Call to SDL_BuildAudioCVT(NULL,...)"); - SDLTest_AssertCheck(result == -1, "Verify result value; expected: -1, got: %i", result); + SDLTest_AssertCheck(result == -1, "Verify result value; expected: -1, got: %i", result); error = SDL_GetError(); SDLTest_AssertPass("Call to SDL_GetError()"); SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL"); if (error != NULL) { - SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0, + SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0, "Validate error message, expected: '%s', got: '%s'", expectedError, error); } /* Invalid conversions */ for (i = 1; i < 64; i++) { - /* Valid format to start with */ + /* Valid format to start with */ spec1.format = AUDIO_S8; spec1.channels = 1; spec1.freq = 22050; spec2.format = AUDIO_S16LSB; spec2.channels = 2; - spec2.freq = 44100; + spec2.freq = 44100; SDL_ClearError(); SDLTest_AssertPass("Call to SDL_ClearError()"); - + /* Set various invalid format inputs */ SDL_strlcpy(message, "Invalid: ", 256); if (i & 1) { SDL_strlcat(message, " spec1.format", 256); spec1.format = 0; } - if (i & 2) { + if (i & 2) { SDL_strlcat(message, " spec1.channels", 256); spec1.channels = 0; } - if (i & 4) { + if (i & 4) { SDL_strlcat(message, " spec1.freq", 256); spec1.freq = 0; } - if (i & 8) { + if (i & 8) { SDL_strlcat(message, " spec2.format", 256); spec2.format = 0; } - if (i & 16) { + if (i & 16) { SDL_strlcat(message, " spec2.channels", 256); spec2.channels = 0; } - if (i & 32) { + if (i & 32) { SDL_strlcat(message, " spec2.freq", 256); spec2.freq = 0; } @@ -514,7 +514,7 @@ int audio_buildAudioCVTNegative() SDL_ClearError(); SDLTest_AssertPass("Call to SDL_ClearError()"); - + return TEST_COMPLETED; } @@ -531,7 +531,7 @@ int audio_getAudioStatus() result = SDL_GetAudioStatus(); SDLTest_AssertPass("Call to SDL_GetAudioStatus()"); SDLTest_AssertCheck(result == SDL_AUDIO_STOPPED || result == SDL_AUDIO_PLAYING || result == SDL_AUDIO_PAUSED, - "Verify returned value; expected: STOPPED (%i) | PLAYING (%i) | PAUSED (%i), got: %i", + "Verify returned value; expected: STOPPED (%i) | PLAYING (%i) | PAUSED (%i), got: %i", SDL_AUDIO_STOPPED, SDL_AUDIO_PLAYING, SDL_AUDIO_PAUSED, result); return TEST_COMPLETED; @@ -549,10 +549,10 @@ int audio_openCloseAndGetAudioStatus() SDL_AudioStatus result; int i; int count; - char *device; + char *device; SDL_AudioDeviceID id; SDL_AudioSpec desired, obtained; - + /* Get number of devices. */ count = SDL_GetNumAudioDevices(0); SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(0)"); @@ -571,20 +571,20 @@ int audio_openCloseAndGetAudioStatus() desired.samples=4096; desired.callback=_audio_testCallback; desired.userdata=NULL; - + /* Open device */ id = SDL_OpenAudioDevice((const char *)device, 0, &desired, &obtained, SDL_AUDIO_ALLOW_ANY_CHANGE); SDLTest_AssertPass("SDL_OpenAudioDevice('%s',...)", device); SDLTest_AssertCheck(id > 1, "Validate device ID; expected: >=2, got: %i", id); if (id > 1) { - + /* Check device audio status */ result = SDL_GetAudioDeviceStatus(id); SDLTest_AssertPass("Call to SDL_GetAudioDeviceStatus()"); SDLTest_AssertCheck(result == SDL_AUDIO_STOPPED || result == SDL_AUDIO_PLAYING || result == SDL_AUDIO_PAUSED, - "Verify returned value; expected: STOPPED (%i) | PLAYING (%i) | PAUSED (%i), got: %i", - SDL_AUDIO_STOPPED, SDL_AUDIO_PLAYING, SDL_AUDIO_PAUSED, result); - + "Verify returned value; expected: STOPPED (%i) | PLAYING (%i) | PAUSED (%i), got: %i", + SDL_AUDIO_STOPPED, SDL_AUDIO_PLAYING, SDL_AUDIO_PAUSED, result); + /* Close device again */ SDL_CloseAudioDevice(id); SDLTest_AssertPass("Call to SDL_CloseAudioDevice()"); @@ -593,7 +593,7 @@ int audio_openCloseAndGetAudioStatus() } else { SDLTest_Log("No devices to test with"); } - + return TEST_COMPLETED; } @@ -607,10 +607,10 @@ int audio_lockUnlockOpenAudioDevice() { int i; int count; - char *device; + char *device; SDL_AudioDeviceID id; SDL_AudioSpec desired, obtained; - + /* Get number of devices. */ count = SDL_GetNumAudioDevices(0); SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(0)"); @@ -629,24 +629,24 @@ int audio_lockUnlockOpenAudioDevice() desired.samples=4096; desired.callback=_audio_testCallback; desired.userdata=NULL; - + /* Open device */ id = SDL_OpenAudioDevice((const char *)device, 0, &desired, &obtained, SDL_AUDIO_ALLOW_ANY_CHANGE); SDLTest_AssertPass("SDL_OpenAudioDevice('%s',...)", device); SDLTest_AssertCheck(id > 1, "Validate device ID; expected: >=2, got: %i", id); - if (id > 1) { + if (id > 1) { /* Lock to protect callback */ SDL_LockAudioDevice(id); SDLTest_AssertPass("SDL_LockAudioDevice(%i)", id); - + /* Simulate callback processing */ SDL_Delay(10); SDLTest_Log("Simulate callback processing - delay"); - - /* Unlock again*/ + + /* Unlock again*/ SDL_UnlockAudioDevice(id); - SDLTest_AssertPass("SDL_UnlockAudioDevice(%i)", id); - + SDLTest_AssertPass("SDL_UnlockAudioDevice(%i)", id); + /* Close device again */ SDL_CloseAudioDevice(id); SDLTest_AssertPass("Call to SDL_CloseAudioDevice()"); @@ -655,7 +655,7 @@ int audio_lockUnlockOpenAudioDevice() } else { SDLTest_Log("No devices to test with"); } - + return TEST_COMPLETED; } @@ -692,11 +692,11 @@ int audio_convertAudio() /* All source conversions with random conversion targets */ for (i = 0; i < _numAudioFormats; i++) { for (j = 0; j < _numAudioChannels; j++) { - for (k = 0; k < _numAudioFrequencies; k++) { + for (k = 0; k < _numAudioFrequencies; k++) { spec1.format = _audioFormats[i]; spec1.channels = _audioChannels[j]; spec1.freq = _audioFrequencies[k]; - + /* Ensure we have a different target format */ do { if (c & 1) { @@ -718,10 +718,10 @@ int audio_convertAudio() spec2.format = _audioFormats[ii]; spec2.channels = _audioChannels[jj]; spec2.freq = _audioFrequencies[kk]; - + result = SDL_BuildAudioCVT(&cvt, spec1.format, spec1.channels, spec1.freq, spec2.format, spec2.channels, spec2.freq); - SDLTest_AssertPass("Call to SDL_BuildAudioCVT(format[%i]=%s(%i),channels[%i]=%i,freq[%i]=%i ==> format[%i]=%s(%i),channels[%i]=%i,freq[%i]=%i)", + SDLTest_AssertPass("Call to SDL_BuildAudioCVT(format[%i]=%s(%i),channels[%i]=%i,freq[%i]=%i ==> format[%i]=%s(%i),channels[%i]=%i,freq[%i]=%i)", i, _audioFormatsVerbose[i], spec1.format, j, spec1.channels, k, spec1.freq, ii, _audioFormatsVerbose[ii], spec2.format, jj, spec2.channels, kk, spec2.freq); SDLTest_AssertCheck(result == 1, "Verify result value; expected: 1, got: %i", result); if (result != 1) { @@ -729,7 +729,7 @@ int audio_convertAudio() } else { SDLTest_AssertCheck(cvt.len_mult > 0, "Verify that cvt.len_mult value; expected: >0, got: %i", cvt.len_mult); if (cvt.len_mult < 1) return TEST_ABORTED; - + /* Create some random data to convert */ l = 64; ll = l * cvt.len_mult; @@ -738,20 +738,20 @@ int audio_convertAudio() cvt.buf = (Uint8 *)SDL_malloc(ll); SDLTest_AssertCheck(cvt.buf != NULL, "Check data buffer to convert is not NULL"); if (cvt.buf == NULL) return TEST_ABORTED; - + /* Convert the data */ result = SDL_ConvertAudio(&cvt); SDLTest_AssertPass("Call to SDL_ConvertAudio()"); SDLTest_AssertCheck(result == 0, "Verify result value; expected: 0; got: %i", result); SDLTest_AssertCheck(cvt.buf != NULL, "Verify conversion buffer is not NULL"); SDLTest_AssertCheck(cvt.len_ratio > 0.0, "Verify conversion length ratio; expected: >0; got: %f", cvt.len_ratio); - + /* Free converted buffer */ if (cvt.buf != NULL) { - SDL_free(cvt.buf); - cvt.buf = NULL; - } - } + SDL_free(cvt.buf); + cvt.buf = NULL; + } + } } } } @@ -771,10 +771,10 @@ int audio_openCloseAudioDeviceConnected() int result = -1; int i; int count; - char *device; + char *device; SDL_AudioDeviceID id; SDL_AudioSpec desired, obtained; - + /* Get number of devices. */ count = SDL_GetNumAudioDevices(0); SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(0)"); @@ -793,7 +793,7 @@ int audio_openCloseAudioDeviceConnected() desired.samples=4096; desired.callback=_audio_testCallback; desired.userdata=NULL; - + /* Open device */ id = SDL_OpenAudioDevice((const char *)device, 0, &desired, &obtained, SDL_AUDIO_ALLOW_ANY_CHANGE); SDLTest_AssertPass("SDL_OpenAudioDevice('%s',...)", device); @@ -802,13 +802,13 @@ int audio_openCloseAudioDeviceConnected() /* TODO: enable test code when function is available in SDL2 */ -#ifdef AUDIODEVICECONNECTED_DEFINED +#ifdef AUDIODEVICECONNECTED_DEFINED /* Get connected status */ result = SDL_AudioDeviceConnected(id); SDLTest_AssertPass("Call to SDL_AudioDeviceConnected()"); #endif SDLTest_AssertCheck(result == 1, "Verify returned value; expected: 1; got: %i", result); - + /* Close device again */ SDL_CloseAudioDevice(id); SDLTest_AssertPass("Call to SDL_CloseAudioDevice()"); @@ -817,7 +817,7 @@ int audio_openCloseAudioDeviceConnected() } else { SDLTest_Log("No devices to test with"); } - + return TEST_COMPLETED; } @@ -827,69 +827,69 @@ int audio_openCloseAudioDeviceConnected() /* Audio test cases */ static const SDLTest_TestCaseReference audioTest1 = - { (SDLTest_TestCaseFp)audio_enumerateAndNameAudioDevices, "audio_enumerateAndNameAudioDevices", "Enumerate and name available audio devices (output and capture)", TEST_ENABLED }; + { (SDLTest_TestCaseFp)audio_enumerateAndNameAudioDevices, "audio_enumerateAndNameAudioDevices", "Enumerate and name available audio devices (output and capture)", TEST_ENABLED }; static const SDLTest_TestCaseReference audioTest2 = - { (SDLTest_TestCaseFp)audio_enumerateAndNameAudioDevicesNegativeTests, "audio_enumerateAndNameAudioDevicesNegativeTests", "Negative tests around enumeration and naming of audio devices.", TEST_ENABLED }; + { (SDLTest_TestCaseFp)audio_enumerateAndNameAudioDevicesNegativeTests, "audio_enumerateAndNameAudioDevicesNegativeTests", "Negative tests around enumeration and naming of audio devices.", TEST_ENABLED }; static const SDLTest_TestCaseReference audioTest3 = - { (SDLTest_TestCaseFp)audio_printAudioDrivers, "audio_printAudioDrivers", "Checks available audio driver names.", TEST_ENABLED }; + { (SDLTest_TestCaseFp)audio_printAudioDrivers, "audio_printAudioDrivers", "Checks available audio driver names.", TEST_ENABLED }; static const SDLTest_TestCaseReference audioTest4 = - { (SDLTest_TestCaseFp)audio_printCurrentAudioDriver, "audio_printCurrentAudioDriver", "Checks current audio driver name with initialized audio.", TEST_ENABLED }; + { (SDLTest_TestCaseFp)audio_printCurrentAudioDriver, "audio_printCurrentAudioDriver", "Checks current audio driver name with initialized audio.", TEST_ENABLED }; static const SDLTest_TestCaseReference audioTest5 = - { (SDLTest_TestCaseFp)audio_buildAudioCVT, "audio_buildAudioCVT", "Builds various audio conversion structures.", TEST_ENABLED }; + { (SDLTest_TestCaseFp)audio_buildAudioCVT, "audio_buildAudioCVT", "Builds various audio conversion structures.", TEST_ENABLED }; static const SDLTest_TestCaseReference audioTest6 = - { (SDLTest_TestCaseFp)audio_buildAudioCVTNegative, "audio_buildAudioCVTNegative", "Checks calls with invalid input to SDL_BuildAudioCVT", TEST_ENABLED }; + { (SDLTest_TestCaseFp)audio_buildAudioCVTNegative, "audio_buildAudioCVTNegative", "Checks calls with invalid input to SDL_BuildAudioCVT", TEST_ENABLED }; static const SDLTest_TestCaseReference audioTest7 = - { (SDLTest_TestCaseFp)audio_getAudioStatus, "audio_getAudioStatus", "Checks current audio status.", TEST_ENABLED }; + { (SDLTest_TestCaseFp)audio_getAudioStatus, "audio_getAudioStatus", "Checks current audio status.", TEST_ENABLED }; static const SDLTest_TestCaseReference audioTest8 = - { (SDLTest_TestCaseFp)audio_openCloseAndGetAudioStatus, "audio_openCloseAndGetAudioStatus", "Opens and closes audio device and get audio status.", TEST_ENABLED }; + { (SDLTest_TestCaseFp)audio_openCloseAndGetAudioStatus, "audio_openCloseAndGetAudioStatus", "Opens and closes audio device and get audio status.", TEST_ENABLED }; static const SDLTest_TestCaseReference audioTest9 = - { (SDLTest_TestCaseFp)audio_lockUnlockOpenAudioDevice, "audio_lockUnlockOpenAudioDevice", "Locks and unlocks an open audio device.", TEST_ENABLED }; + { (SDLTest_TestCaseFp)audio_lockUnlockOpenAudioDevice, "audio_lockUnlockOpenAudioDevice", "Locks and unlocks an open audio device.", TEST_ENABLED }; /* TODO: enable test when SDL_ConvertAudio segfaults on cygwin have been fixed. */ /* For debugging, test case can be run manually using --filter audio_convertAudio */ static const SDLTest_TestCaseReference audioTest10 = - { (SDLTest_TestCaseFp)audio_convertAudio, "audio_convertAudio", "Convert audio using available formats.", TEST_DISABLED }; + { (SDLTest_TestCaseFp)audio_convertAudio, "audio_convertAudio", "Convert audio using available formats.", TEST_DISABLED }; /* TODO: enable test when SDL_AudioDeviceConnected has been implemented. */ static const SDLTest_TestCaseReference audioTest11 = - { (SDLTest_TestCaseFp)audio_openCloseAudioDeviceConnected, "audio_openCloseAudioDeviceConnected", "Opens and closes audio device and get connected status.", TEST_DISABLED }; + { (SDLTest_TestCaseFp)audio_openCloseAudioDeviceConnected, "audio_openCloseAudioDeviceConnected", "Opens and closes audio device and get connected status.", TEST_DISABLED }; static const SDLTest_TestCaseReference audioTest12 = - { (SDLTest_TestCaseFp)audio_quitInitAudioSubSystem, "audio_quitInitAudioSubSystem", "Quit and re-init audio subsystem.", TEST_ENABLED }; + { (SDLTest_TestCaseFp)audio_quitInitAudioSubSystem, "audio_quitInitAudioSubSystem", "Quit and re-init audio subsystem.", TEST_ENABLED }; /* TODO: enable when bugs 1343 and 1396 are fixed. */ /* For debugging, test case can be run manually using --filter audio_initQuitAudio */ static const SDLTest_TestCaseReference audioTest13 = - { (SDLTest_TestCaseFp)audio_initQuitAudio, "audio_initQuitAudio", "Init and quit audio drivers directly.", TEST_DISABLED }; + { (SDLTest_TestCaseFp)audio_initQuitAudio, "audio_initQuitAudio", "Init and quit audio drivers directly.", TEST_DISABLED }; /* TODO: enable when bugs 1343 and 1396 are fixed. */ /* For debugging, test case can be run manually using --filter audio_initOpenCloseQuitAudio */ static const SDLTest_TestCaseReference audioTest14 = - { (SDLTest_TestCaseFp)audio_initOpenCloseQuitAudio, "audio_initOpenCloseQuitAudio", "Cycle through init, open, close and quit with various audio specs.", TEST_DISABLED }; + { (SDLTest_TestCaseFp)audio_initOpenCloseQuitAudio, "audio_initOpenCloseQuitAudio", "Cycle through init, open, close and quit with various audio specs.", TEST_DISABLED }; /* Sequence of Audio test cases */ static const SDLTest_TestCaseReference *audioTests[] = { - &audioTest1, &audioTest2, &audioTest3, &audioTest4, &audioTest5, &audioTest6, - &audioTest7, &audioTest8, &audioTest9, &audioTest10, &audioTest11, - &audioTest12, &audioTest13, &audioTest14, NULL + &audioTest1, &audioTest2, &audioTest3, &audioTest4, &audioTest5, &audioTest6, + &audioTest7, &audioTest8, &audioTest9, &audioTest10, &audioTest11, + &audioTest12, &audioTest13, &audioTest14, NULL }; /* Audio test suite (global) */ SDLTest_TestSuiteReference audioTestSuite = { - "Audio", - _audioSetUp, - audioTests, - NULL + "Audio", + _audioSetUp, + audioTests, + NULL }; diff --git a/test/testautomation_clipboard.c b/test/testautomation_clipboard.c index 76c2936f8..cc112f9a6 100644 --- a/test/testautomation_clipboard.c +++ b/test/testautomation_clipboard.c @@ -21,9 +21,9 @@ int clipboard_testHasClipboardText(void *arg) { - SDL_bool result; - result = SDL_HasClipboardText(); - SDLTest_AssertPass("Call to SDL_HasClipboardText succeeded"); + SDL_bool result; + result = SDL_HasClipboardText(); + SDLTest_AssertPass("Call to SDL_HasClipboardText succeeded"); return TEST_COMPLETED; } @@ -37,11 +37,11 @@ clipboard_testHasClipboardText(void *arg) int clipboard_testGetClipboardText(void *arg) { - char *charResult; - charResult = SDL_GetClipboardText(); - SDLTest_AssertPass("Call to SDL_GetClipboardText succeeded"); + char *charResult; + charResult = SDL_GetClipboardText(); + SDLTest_AssertPass("Call to SDL_GetClipboardText succeeded"); - if (charResult) SDL_free(charResult); + if (charResult) SDL_free(charResult); return TEST_COMPLETED; } @@ -54,19 +54,19 @@ clipboard_testGetClipboardText(void *arg) int clipboard_testSetClipboardText(void *arg) { - char *textRef = SDLTest_RandomAsciiString(); - char *text = SDL_strdup(textRef); - int result; - result = SDL_SetClipboardText((const char *)text); - SDLTest_AssertPass("Call to SDL_SetClipboardText succeeded"); - SDLTest_AssertCheck( - result == 0, - "Validate SDL_SetClipboardText result, expected 0, got %i", - result); - SDLTest_AssertCheck( - SDL_strcmp(textRef, text) == 0, - "Verify SDL_SetClipboardText did not modify input string, expected '%s', got '%s'", - textRef, text); + char *textRef = SDLTest_RandomAsciiString(); + char *text = SDL_strdup(textRef); + int result; + result = SDL_SetClipboardText((const char *)text); + SDLTest_AssertPass("Call to SDL_SetClipboardText succeeded"); + SDLTest_AssertCheck( + result == 0, + "Validate SDL_SetClipboardText result, expected 0, got %i", + result); + SDLTest_AssertCheck( + SDL_strcmp(textRef, text) == 0, + "Verify SDL_SetClipboardText did not modify input string, expected '%s', got '%s'", + textRef, text); /* Cleanup */ if (textRef) SDL_free(textRef); @@ -85,64 +85,64 @@ clipboard_testSetClipboardText(void *arg) int clipboard_testClipboardTextFunctions(void *arg) { - char *textRef = SDLTest_RandomAsciiString(); - char *text = SDL_strdup(textRef); - SDL_bool boolResult; - int intResult; - char *charResult; - - /* Clear clipboard text state */ - boolResult = SDL_HasClipboardText(); - SDLTest_AssertPass("Call to SDL_HasClipboardText succeeded"); - if (boolResult == SDL_TRUE) { + char *textRef = SDLTest_RandomAsciiString(); + char *text = SDL_strdup(textRef); + SDL_bool boolResult; + int intResult; + char *charResult; + + /* Clear clipboard text state */ + boolResult = SDL_HasClipboardText(); + SDLTest_AssertPass("Call to SDL_HasClipboardText succeeded"); + if (boolResult == SDL_TRUE) { intResult = SDL_SetClipboardText((const char *)NULL); SDLTest_AssertPass("Call to SDL_SetClipboardText(NULL) succeeded"); - SDLTest_AssertCheck( - intResult == 0, - "Verify result from SDL_SetClipboardText(NULL), expected 0, got %i", - intResult); - charResult = SDL_GetClipboardText(); - SDLTest_AssertPass("Call to SDL_GetClipboardText succeeded"); - boolResult = SDL_HasClipboardText(); - SDLTest_AssertPass("Call to SDL_HasClipboardText succeeded"); - SDLTest_AssertCheck( + SDLTest_AssertCheck( + intResult == 0, + "Verify result from SDL_SetClipboardText(NULL), expected 0, got %i", + intResult); + charResult = SDL_GetClipboardText(); + SDLTest_AssertPass("Call to SDL_GetClipboardText succeeded"); + boolResult = SDL_HasClipboardText(); + SDLTest_AssertPass("Call to SDL_HasClipboardText succeeded"); + SDLTest_AssertCheck( boolResult == SDL_FALSE, - "Verify SDL_HasClipboardText returned SDL_FALSE, got %s", - (boolResult) ? "SDL_TRUE" : "SDL_FALSE"); + "Verify SDL_HasClipboardText returned SDL_FALSE, got %s", + (boolResult) ? "SDL_TRUE" : "SDL_FALSE"); } /* Empty clipboard */ - charResult = SDL_GetClipboardText(); - SDLTest_AssertPass("Call to SDL_GetClipboardText succeeded"); - SDLTest_AssertCheck( - charResult != NULL, - "Verify SDL_GetClipboardText did not return NULL"); - SDLTest_AssertCheck( - SDL_strlen(charResult) == 0, - "Verify SDL_GetClipboardText returned string with length 0, got length %i", - SDL_strlen(charResult)); + charResult = SDL_GetClipboardText(); + SDLTest_AssertPass("Call to SDL_GetClipboardText succeeded"); + SDLTest_AssertCheck( + charResult != NULL, + "Verify SDL_GetClipboardText did not return NULL"); + SDLTest_AssertCheck( + SDL_strlen(charResult) == 0, + "Verify SDL_GetClipboardText returned string with length 0, got length %i", + SDL_strlen(charResult)); intResult = SDL_SetClipboardText((const char *)text); - SDLTest_AssertPass("Call to SDL_SetClipboardText succeeded"); - SDLTest_AssertCheck( - intResult == 0, - "Verify result from SDL_SetClipboardText(NULL), expected 0, got %i", - intResult); - SDLTest_AssertCheck( - SDL_strcmp(textRef, text) == 0, - "Verify SDL_SetClipboardText did not modify input string, expected '%s', got '%s'", - textRef, text); - boolResult = SDL_HasClipboardText(); - SDLTest_AssertPass("Call to SDL_HasClipboardText succeeded"); - SDLTest_AssertCheck( + SDLTest_AssertPass("Call to SDL_SetClipboardText succeeded"); + SDLTest_AssertCheck( + intResult == 0, + "Verify result from SDL_SetClipboardText(NULL), expected 0, got %i", + intResult); + SDLTest_AssertCheck( + SDL_strcmp(textRef, text) == 0, + "Verify SDL_SetClipboardText did not modify input string, expected '%s', got '%s'", + textRef, text); + boolResult = SDL_HasClipboardText(); + SDLTest_AssertPass("Call to SDL_HasClipboardText succeeded"); + SDLTest_AssertCheck( boolResult == SDL_TRUE, - "Verify SDL_HasClipboardText returned SDL_TRUE, got %s", - (boolResult) ? "SDL_TRUE" : "SDL_FALSE"); - charResult = SDL_GetClipboardText(); - SDLTest_AssertPass("Call to SDL_GetClipboardText succeeded"); - SDLTest_AssertCheck( - strcmp(textRef, charResult) == 0, - "Verify SDL_GetClipboardText returned correct string, expected '%s', got '%s'", - textRef, charResult); + "Verify SDL_HasClipboardText returned SDL_TRUE, got %s", + (boolResult) ? "SDL_TRUE" : "SDL_FALSE"); + charResult = SDL_GetClipboardText(); + SDLTest_AssertPass("Call to SDL_GetClipboardText succeeded"); + SDLTest_AssertCheck( + strcmp(textRef, charResult) == 0, + "Verify SDL_GetClipboardText returned correct string, expected '%s', got '%s'", + textRef, charResult); /* Cleanup */ if (textRef) SDL_free(textRef); @@ -157,26 +157,26 @@ clipboard_testClipboardTextFunctions(void *arg) /* Clipboard test cases */ static const SDLTest_TestCaseReference clipboardTest1 = - { (SDLTest_TestCaseFp)clipboard_testHasClipboardText, "clipboard_testHasClipboardText", "Check call to SDL_HasClipboardText", TEST_ENABLED }; + { (SDLTest_TestCaseFp)clipboard_testHasClipboardText, "clipboard_testHasClipboardText", "Check call to SDL_HasClipboardText", TEST_ENABLED }; static const SDLTest_TestCaseReference clipboardTest2 = - { (SDLTest_TestCaseFp)clipboard_testGetClipboardText, "clipboard_testGetClipboardText", "Check call to SDL_GetClipboardText", TEST_ENABLED }; + { (SDLTest_TestCaseFp)clipboard_testGetClipboardText, "clipboard_testGetClipboardText", "Check call to SDL_GetClipboardText", TEST_ENABLED }; static const SDLTest_TestCaseReference clipboardTest3 = - { (SDLTest_TestCaseFp)clipboard_testSetClipboardText, "clipboard_testSetClipboardText", "Check call to SDL_SetClipboardText", TEST_ENABLED }; + { (SDLTest_TestCaseFp)clipboard_testSetClipboardText, "clipboard_testSetClipboardText", "Check call to SDL_SetClipboardText", TEST_ENABLED }; static const SDLTest_TestCaseReference clipboardTest4 = - { (SDLTest_TestCaseFp)clipboard_testClipboardTextFunctions, "clipboard_testClipboardTextFunctions", "End-to-end test of SDL_xyzClipboardText functions", TEST_ENABLED }; + { (SDLTest_TestCaseFp)clipboard_testClipboardTextFunctions, "clipboard_testClipboardTextFunctions", "End-to-end test of SDL_xyzClipboardText functions", TEST_ENABLED }; /* Sequence of Clipboard test cases */ static const SDLTest_TestCaseReference *clipboardTests[] = { - &clipboardTest1, &clipboardTest2, &clipboardTest3, &clipboardTest4, NULL + &clipboardTest1, &clipboardTest2, &clipboardTest3, &clipboardTest4, NULL }; /* Clipboard test suite (global) */ SDLTest_TestSuiteReference clipboardTestSuite = { - "Clipboard", - NULL, - clipboardTests, - NULL + "Clipboard", + NULL, + clipboardTests, + NULL }; diff --git a/test/testautomation_events.c b/test/testautomation_events.c index 930d44cb3..638607e76 100644 --- a/test/testautomation_events.c +++ b/test/testautomation_events.c @@ -28,14 +28,14 @@ int _userdataValue2 = 2; int _events_sampleNullEventFilter(void *userdata, SDL_Event *event) { _eventFilterCalled = 1; - + if (_userdataCheck != 0) { SDLTest_AssertCheck(userdata != NULL, "Check userdata pointer, expected: non-NULL, got: %s", (userdata != NULL) ? "non-NULL" : "NULL"); if (userdata != NULL) { SDLTest_AssertCheck(*(int *)userdata == _userdataValue, "Check userdata value, expected: %i, got: %i", _userdataValue, *(int *)userdata); } } - + return 0; } @@ -51,24 +51,24 @@ events_pushPumpAndPollUserevent(void *arg) SDL_Event event1; SDL_Event event2; int result; - + /* Create user event */ event1.type = SDL_USEREVENT; event1.user.code = SDLTest_RandomSint32(); event1.user.data1 = (void *)&_userdataValue1; event1.user.data2 = (void *)&_userdataValue2; - + /* Push a user event onto the queue and force queue update*/ SDL_PushEvent(&event1); SDLTest_AssertPass("Call to SDL_PushEvent()"); SDL_PumpEvents(); SDLTest_AssertPass("Call to SDL_PumpEvents()"); - + /* Poll for user event */ result = SDL_PollEvent(&event2); SDLTest_AssertPass("Call to SDL_PollEvent()"); SDLTest_AssertCheck(result == 1, "Check result from SDL_PollEvent, expected: 1, got: %d", result); - + return TEST_COMPLETED; } @@ -84,7 +84,7 @@ int events_addDelEventWatch(void *arg) { SDL_Event event; - + /* Create user event */ event.type = SDL_USEREVENT; event.user.code = SDLTest_RandomSint32();; @@ -97,10 +97,10 @@ events_addDelEventWatch(void *arg) /* Reset event filter call tracker */ _eventFilterCalled = 0; - /* Add watch */ + /* Add watch */ SDL_AddEventWatch(_events_sampleNullEventFilter, NULL); SDLTest_AssertPass("Call to SDL_AddEventWatch()"); - + /* Push a user event onto the queue and force queue update*/ SDL_PushEvent(&event); SDLTest_AssertPass("Call to SDL_PushEvent()"); @@ -134,13 +134,13 @@ int events_addDelEventWatchWithUserdata(void *arg) { SDL_Event event; - + /* Create user event */ event.type = SDL_USEREVENT; event.user.code = SDLTest_RandomSint32();; event.user.data1 = (void *)&_userdataValue1; event.user.data2 = (void *)&_userdataValue2; - + /* Enable userdata check and set a value to check */ _userdataCheck = 1; _userdataValue = SDLTest_RandomIntegerInRange(-1024, 1024); @@ -148,7 +148,7 @@ events_addDelEventWatchWithUserdata(void *arg) /* Reset event filter call tracker */ _eventFilterCalled = 0; - /* Add watch */ + /* Add watch */ SDL_AddEventWatch(_events_sampleNullEventFilter, (void *)&_userdataValue); SDLTest_AssertPass("Call to SDL_AddEventWatch()"); @@ -162,7 +162,7 @@ events_addDelEventWatchWithUserdata(void *arg) /* Delete watch */ SDL_DelEventWatch(_events_sampleNullEventFilter, (void *)&_userdataValue); SDLTest_AssertPass("Call to SDL_DelEventWatch()"); - + /* Push a user event onto the queue and force queue update*/ _eventFilterCalled = 0; SDL_PushEvent(&event); @@ -170,7 +170,7 @@ events_addDelEventWatchWithUserdata(void *arg) SDL_PumpEvents(); SDLTest_AssertPass("Call to SDL_PumpEvents()"); SDLTest_AssertCheck(_eventFilterCalled == 0, "Check that event filter was NOT called"); - + return TEST_COMPLETED; } @@ -179,23 +179,23 @@ events_addDelEventWatchWithUserdata(void *arg) /* Events test cases */ static const SDLTest_TestCaseReference eventsTest1 = - { (SDLTest_TestCaseFp)events_pushPumpAndPollUserevent, "events_pushPumpAndPollUserevent", "Pushes, pumps and polls a user event", TEST_ENABLED }; + { (SDLTest_TestCaseFp)events_pushPumpAndPollUserevent, "events_pushPumpAndPollUserevent", "Pushes, pumps and polls a user event", TEST_ENABLED }; static const SDLTest_TestCaseReference eventsTest2 = - { (SDLTest_TestCaseFp)events_addDelEventWatch, "events_addDelEventWatch", "Adds and deletes an event watch function with NULL userdata", TEST_ENABLED }; + { (SDLTest_TestCaseFp)events_addDelEventWatch, "events_addDelEventWatch", "Adds and deletes an event watch function with NULL userdata", TEST_ENABLED }; static const SDLTest_TestCaseReference eventsTest3 = - { (SDLTest_TestCaseFp)events_addDelEventWatchWithUserdata, "events_addDelEventWatchWithUserdata", "Adds and deletes an event watch function with userdata", TEST_ENABLED }; + { (SDLTest_TestCaseFp)events_addDelEventWatchWithUserdata, "events_addDelEventWatchWithUserdata", "Adds and deletes an event watch function with userdata", TEST_ENABLED }; /* Sequence of Events test cases */ static const SDLTest_TestCaseReference *eventsTests[] = { - &eventsTest1, &eventsTest2, &eventsTest3, NULL + &eventsTest1, &eventsTest2, &eventsTest3, NULL }; /* Events test suite (global) */ SDLTest_TestSuiteReference eventsTestSuite = { - "Events", - NULL, - eventsTests, - NULL + "Events", + NULL, + eventsTests, + NULL }; diff --git a/test/testautomation_keyboard.c b/test/testautomation_keyboard.c index ab80631b6..1e5df4ff0 100644 --- a/test/testautomation_keyboard.c +++ b/test/testautomation_keyboard.c @@ -15,7 +15,7 @@ /** * @brief Check call to SDL_GetKeyboardState with and without numkeys reference. - * + * * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetKeyboardState */ int @@ -24,7 +24,7 @@ keyboard_getKeyboardState(void *arg) int numkeys; Uint8 *state; - /* Case where numkeys pointer is NULL */ + /* Case where numkeys pointer is NULL */ state = SDL_GetKeyboardState(NULL); SDLTest_AssertPass("Call to SDL_GetKeyboardState(NULL)"); SDLTest_AssertCheck(state != NULL, "Validate that return value from SDL_GetKeyboardState is not NULL"); @@ -35,13 +35,13 @@ keyboard_getKeyboardState(void *arg) SDLTest_AssertPass("Call to SDL_GetKeyboardState(&numkeys)"); SDLTest_AssertCheck(state != NULL, "Validate that return value from SDL_GetKeyboardState is not NULL"); SDLTest_AssertCheck(numkeys >= 0, "Validate that value of numkeys is >= 0, got: %i", numkeys); - + return TEST_COMPLETED; } /** * @brief Check call to SDL_GetKeyboardFocus - * + * * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetKeyboardFocus */ int @@ -58,7 +58,7 @@ keyboard_getKeyboardFocus(void *arg) /** * @brief Check call to SDL_GetKeyFromName for known, unknown and invalid name. - * + * * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetKeyFromName */ int @@ -104,19 +104,19 @@ keyboard_getKeyFromName(void *arg) return TEST_COMPLETED; } -/* +/* * Local helper to check for the invalid scancode error message */ void _checkInvalidScancodeError() { const char *expectedError = "Parameter 'scancode' is invalid"; - const char *error; + const char *error; error = SDL_GetError(); SDLTest_AssertPass("Call to SDL_GetError()"); SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL"); if (error != NULL) { - SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0, + SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0, "Validate error message, expected: '%s', got: '%s'", expectedError, error); SDL_ClearError(); SDLTest_AssertPass("Call to SDL_ClearError()"); @@ -125,7 +125,7 @@ _checkInvalidScancodeError() /** * @brief Check call to SDL_GetKeyFromScancode - * + * * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetKeyFromScancode */ int @@ -164,12 +164,12 @@ keyboard_getKeyFromScancode(void *arg) /** * @brief Check call to SDL_GetKeyName - * + * * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetKeyName */ int keyboard_getKeyName(void *arg) -{ +{ char *result; char *expected; @@ -220,12 +220,12 @@ keyboard_getKeyName(void *arg) /** * @brief SDL_GetScancodeName negative cases - * + * * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetScancodeName */ int keyboard_getScancodeNameNegative(void *arg) -{ +{ SDL_Scancode scancode; char *result; char *expected = ""; @@ -247,12 +247,12 @@ keyboard_getScancodeNameNegative(void *arg) /** * @brief SDL_GetKeyName negative cases - * + * * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetKeyName */ int keyboard_getKeyNameNegative(void *arg) -{ +{ SDL_Keycode keycode; char *result; char *expected = ""; @@ -284,17 +284,17 @@ keyboard_getKeyNameNegative(void *arg) /** * @brief Check call to SDL_GetModState and SDL_SetModState - * + * * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetModState * @sa http://wiki.libsdl.org/moin.cgi/SDL_SetModState */ int keyboard_getSetModState(void *arg) -{ +{ SDL_Keymod result; SDL_Keymod currentState; SDL_Keymod newState; - SDL_Keymod allStates = + SDL_Keymod allStates = KMOD_NONE | KMOD_LSHIFT | KMOD_RSHIFT | @@ -309,13 +309,13 @@ keyboard_getSetModState(void *arg) KMOD_MODE | KMOD_RESERVED; - /* Get state, cache for later reset */ + /* Get state, cache for later reset */ result = SDL_GetModState(); SDLTest_AssertPass("Call to SDL_GetModState()"); - SDLTest_AssertCheck(result >=0 && result <= allStates, "Verify result from call is valid, expected: 0 <= result <= %i, got: %i", allStates, result); + SDLTest_AssertCheck(result >=0 && result <= allStates, "Verify result from call is valid, expected: 0 <= result <= %i, got: %i", allStates, result); currentState = result; - /* Set random state */ + /* Set random state */ newState = SDLTest_RandomIntegerInRange(0, allStates); SDL_SetModState(newState); SDLTest_AssertPass("Call to SDL_SetModState(%i)", newState); @@ -345,13 +345,13 @@ keyboard_getSetModState(void *arg) /** * @brief Check call to SDL_StartTextInput and SDL_StopTextInput - * + * * @sa http://wiki.libsdl.org/moin.cgi/SDL_StartTextInput * @sa http://wiki.libsdl.org/moin.cgi/SDL_StopTextInput */ int keyboard_startStopTextInput(void *arg) -{ +{ /* Start-Stop */ SDL_StartTextInput(); SDLTest_AssertPass("Call to SDL_StartTextInput()"); @@ -361,12 +361,12 @@ keyboard_startStopTextInput(void *arg) /* Stop-Start */ SDL_StartTextInput(); SDLTest_AssertPass("Call to SDL_StartTextInput()"); - + /* Start-Start */ SDL_StartTextInput(); SDLTest_AssertPass("Call to SDL_StartTextInput()"); - /* Stop-Stop */ + /* Stop-Stop */ SDL_StopTextInput(); SDLTest_AssertPass("Call to SDL_StopTextInput()"); SDL_StopTextInput(); @@ -379,34 +379,34 @@ keyboard_startStopTextInput(void *arg) void _testSetTextInputRect(SDL_Rect refRect) { SDL_Rect testRect; - + testRect = refRect; SDL_SetTextInputRect(&testRect); SDLTest_AssertPass("Call to SDL_SetTextInputRect with refRect(x:%i,y:%i,w:%i,h:%i)", refRect.x, refRect.y, refRect.w, refRect.h); SDLTest_AssertCheck( - (refRect.x == testRect.x) && (refRect.y == testRect.y) && (refRect.w == testRect.w) && (refRect.h == testRect.h), - "Check that input data was not modified, expected: x:%i,y:%i,w:%i,h:%i, got: x:%i,y:%i,w:%i,h:%i", - refRect.x, refRect.y, refRect.w, refRect.h, + (refRect.x == testRect.x) && (refRect.y == testRect.y) && (refRect.w == testRect.w) && (refRect.h == testRect.h), + "Check that input data was not modified, expected: x:%i,y:%i,w:%i,h:%i, got: x:%i,y:%i,w:%i,h:%i", + refRect.x, refRect.y, refRect.w, refRect.h, testRect.x, testRect.y, testRect.w, testRect.h); } /** * @brief Check call to SDL_SetTextInputRect - * + * * @sa http://wiki.libsdl.org/moin.cgi/SDL_SetTextInputRect */ int keyboard_setTextInputRect(void *arg) -{ +{ SDL_Rect refRect; - + /* Normal visible refRect, origin inside */ refRect.x = SDLTest_RandomIntegerInRange(1, 50);; refRect.y = SDLTest_RandomIntegerInRange(1, 50);; refRect.w = SDLTest_RandomIntegerInRange(10, 50); refRect.h = SDLTest_RandomIntegerInRange(10, 50); _testSetTextInputRect(refRect); - + /* Normal visible refRect, origin 0,0 */ refRect.x = 0; refRect.y = 0; @@ -472,133 +472,133 @@ keyboard_setTextInputRect(void *arg) /** * @brief Check call to SDL_SetTextInputRect with invalid data - * + * * @sa http://wiki.libsdl.org/moin.cgi/SDL_SetTextInputRect */ int keyboard_setTextInputRectNegative(void *arg) -{ +{ /* Some platforms set also an error message; prepare for checking it */ -#if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_ANDROID || SDL_VIDEO_DRIVER_COCOA +#if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_ANDROID || SDL_VIDEO_DRIVER_COCOA const char *expectedError = "Parameter 'rect' is invalid"; const char *error; - + SDL_ClearError(); SDLTest_AssertPass("Call to SDL_ClearError()"); #endif - + /* NULL refRect */ SDL_SetTextInputRect(NULL); SDLTest_AssertPass("Call to SDL_SetTextInputRect(NULL)"); /* Some platforms set also an error message; so check it */ -#if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_ANDROID || SDL_VIDEO_DRIVER_COCOA +#if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_ANDROID || SDL_VIDEO_DRIVER_COCOA error = SDL_GetError(); SDLTest_AssertPass("Call to SDL_GetError()"); SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL"); if (error != NULL) { - SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0, + SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0, "Validate error message, expected: '%s', got: '%s'", expectedError, error); } SDL_ClearError(); SDLTest_AssertPass("Call to SDL_ClearError()"); #endif - + return TEST_COMPLETED; } /** * @brief Check call to SDL_GetScancodeFromKey - * + * * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetScancodeFromKey * @sa http://wiki.libsdl.org/moin.cgi/SDL_Keycode */ int keyboard_getScancodeFromKey(void *arg) -{ +{ SDL_Scancode scancode; - + /* Regular key */ scancode = SDL_GetScancodeFromKey(SDLK_4); SDLTest_AssertPass("Call to SDL_GetScancodeFromKey(SDLK_4)"); - SDLTest_AssertCheck(scancode == SDL_SCANCODE_4, "Validate return value from SDL_GetScancodeFromKey, expected: %i, got: %i", SDL_SCANCODE_4, scancode); + SDLTest_AssertCheck(scancode == SDL_SCANCODE_4, "Validate return value from SDL_GetScancodeFromKey, expected: %i, got: %i", SDL_SCANCODE_4, scancode); /* Virtual key */ scancode = SDL_GetScancodeFromKey(SDLK_PLUS); SDLTest_AssertPass("Call to SDL_GetScancodeFromKey(SDLK_PLUS)"); - SDLTest_AssertCheck(scancode == 0, "Validate return value from SDL_GetScancodeFromKey, expected: 0, got: %i", scancode); - + SDLTest_AssertCheck(scancode == 0, "Validate return value from SDL_GetScancodeFromKey, expected: 0, got: %i", scancode); + return TEST_COMPLETED; } /** * @brief Check call to SDL_GetScancodeFromName - * + * * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetScancodeFromName * @sa http://wiki.libsdl.org/moin.cgi/SDL_Keycode */ int keyboard_getScancodeFromName(void *arg) -{ +{ SDL_Scancode scancode; /* Regular key, 1 character, first name in list */ scancode = SDL_GetScancodeFromName("A"); SDLTest_AssertPass("Call to SDL_GetScancodeFromName('A')"); - SDLTest_AssertCheck(scancode == SDL_SCANCODE_A, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_A, scancode); + SDLTest_AssertCheck(scancode == SDL_SCANCODE_A, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_A, scancode); /* Regular key, 1 character */ scancode = SDL_GetScancodeFromName("4"); SDLTest_AssertPass("Call to SDL_GetScancodeFromName('4')"); - SDLTest_AssertCheck(scancode == SDL_SCANCODE_4, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_4, scancode); + SDLTest_AssertCheck(scancode == SDL_SCANCODE_4, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_4, scancode); /* Regular key, 2 characters */ scancode = SDL_GetScancodeFromName("F1"); SDLTest_AssertPass("Call to SDL_GetScancodeFromName('F1')"); - SDLTest_AssertCheck(scancode == SDL_SCANCODE_F1, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_F1, scancode); + SDLTest_AssertCheck(scancode == SDL_SCANCODE_F1, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_F1, scancode); /* Regular key, 3 characters */ scancode = SDL_GetScancodeFromName("End"); SDLTest_AssertPass("Call to SDL_GetScancodeFromName('End')"); - SDLTest_AssertCheck(scancode == SDL_SCANCODE_END, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_END, scancode); + SDLTest_AssertCheck(scancode == SDL_SCANCODE_END, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_END, scancode); /* Regular key, 4 characters */ scancode = SDL_GetScancodeFromName("Find"); SDLTest_AssertPass("Call to SDL_GetScancodeFromName('Find')"); - SDLTest_AssertCheck(scancode == SDL_SCANCODE_FIND, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_FIND, scancode); + SDLTest_AssertCheck(scancode == SDL_SCANCODE_FIND, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_FIND, scancode); /* Regular key, several characters */ scancode = SDL_GetScancodeFromName("Backspace"); SDLTest_AssertPass("Call to SDL_GetScancodeFromName('Backspace')"); - SDLTest_AssertCheck(scancode == SDL_SCANCODE_BACKSPACE, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_BACKSPACE, scancode); + SDLTest_AssertCheck(scancode == SDL_SCANCODE_BACKSPACE, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_BACKSPACE, scancode); /* Regular key, several characters with space */ scancode = SDL_GetScancodeFromName("Keypad Enter"); SDLTest_AssertPass("Call to SDL_GetScancodeFromName('Keypad Enter')"); - SDLTest_AssertCheck(scancode == SDL_SCANCODE_KP_ENTER, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_KP_ENTER, scancode); + SDLTest_AssertCheck(scancode == SDL_SCANCODE_KP_ENTER, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_KP_ENTER, scancode); /* Regular key, last name in list */ scancode = SDL_GetScancodeFromName("Sleep"); SDLTest_AssertPass("Call to SDL_GetScancodeFromName('Sleep')"); - SDLTest_AssertCheck(scancode == SDL_SCANCODE_SLEEP, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_SLEEP, scancode); - + SDLTest_AssertCheck(scancode == SDL_SCANCODE_SLEEP, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_SLEEP, scancode); + return TEST_COMPLETED; } -/* +/* * Local helper to check for the invalid scancode error message */ void _checkInvalidNameError() { const char *expectedError = "Parameter 'name' is invalid"; - const char *error; + const char *error; error = SDL_GetError(); SDLTest_AssertPass("Call to SDL_GetError()"); SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL"); if (error != NULL) { - SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0, + SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0, "Validate error message, expected: '%s', got: '%s'", expectedError, error); SDL_ClearError(); SDLTest_AssertPass("Call to SDL_ClearError()"); @@ -607,13 +607,13 @@ _checkInvalidNameError() /** * @brief Check call to SDL_GetScancodeFromName with invalid data - * + * * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetScancodeFromName * @sa http://wiki.libsdl.org/moin.cgi/SDL_Keycode */ int keyboard_getScancodeFromNameNegative(void *arg) -{ +{ char *name; SDL_Scancode scancode; @@ -626,13 +626,13 @@ keyboard_getScancodeFromNameNegative(void *arg) SDLTest_Assert(name != NULL, "Check that random name is not NULL"); if (name == NULL) { return TEST_ABORTED; - } + } scancode = SDL_GetScancodeFromName((const char *)name); SDLTest_AssertPass("Call to SDL_GetScancodeFromName('%s')", name); SDL_free(name); SDLTest_AssertCheck(scancode == SDL_SCANCODE_UNKNOWN, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_UNKNOWN, scancode); _checkInvalidNameError(); - + /* Zero length string input */ name = ""; scancode = SDL_GetScancodeFromName((const char *)name); @@ -646,7 +646,7 @@ keyboard_getScancodeFromNameNegative(void *arg) SDLTest_AssertPass("Call to SDL_GetScancodeFromName(NULL)"); SDLTest_AssertCheck(scancode == SDL_SCANCODE_UNKNOWN, "Validate return value from SDL_GetScancodeFromName, expected: %i, got: %i", SDL_SCANCODE_UNKNOWN, scancode); _checkInvalidNameError(); - + return TEST_COMPLETED; } @@ -656,58 +656,58 @@ keyboard_getScancodeFromNameNegative(void *arg) /* Keyboard test cases */ static const SDLTest_TestCaseReference keyboardTest1 = - { (SDLTest_TestCaseFp)keyboard_getKeyboardState, "keyboard_getKeyboardState", "Check call to SDL_GetKeyboardState with and without numkeys reference", TEST_ENABLED }; + { (SDLTest_TestCaseFp)keyboard_getKeyboardState, "keyboard_getKeyboardState", "Check call to SDL_GetKeyboardState with and without numkeys reference", TEST_ENABLED }; static const SDLTest_TestCaseReference keyboardTest2 = - { (SDLTest_TestCaseFp)keyboard_getKeyboardFocus, "keyboard_getKeyboardFocus", "Check call to SDL_GetKeyboardFocus", TEST_ENABLED }; + { (SDLTest_TestCaseFp)keyboard_getKeyboardFocus, "keyboard_getKeyboardFocus", "Check call to SDL_GetKeyboardFocus", TEST_ENABLED }; static const SDLTest_TestCaseReference keyboardTest3 = - { (SDLTest_TestCaseFp)keyboard_getKeyFromName, "keyboard_getKeyFromName", "Check call to SDL_GetKeyFromName for known, unknown and invalid name", TEST_ENABLED }; + { (SDLTest_TestCaseFp)keyboard_getKeyFromName, "keyboard_getKeyFromName", "Check call to SDL_GetKeyFromName for known, unknown and invalid name", TEST_ENABLED }; static const SDLTest_TestCaseReference keyboardTest4 = - { (SDLTest_TestCaseFp)keyboard_getKeyFromScancode, "keyboard_getKeyFromScancode", "Check call to SDL_GetKeyFromScancode", TEST_ENABLED }; + { (SDLTest_TestCaseFp)keyboard_getKeyFromScancode, "keyboard_getKeyFromScancode", "Check call to SDL_GetKeyFromScancode", TEST_ENABLED }; static const SDLTest_TestCaseReference keyboardTest5 = - { (SDLTest_TestCaseFp)keyboard_getKeyName, "keyboard_getKeyName", "Check call to SDL_GetKeyName", TEST_ENABLED }; + { (SDLTest_TestCaseFp)keyboard_getKeyName, "keyboard_getKeyName", "Check call to SDL_GetKeyName", TEST_ENABLED }; static const SDLTest_TestCaseReference keyboardTest6 = - { (SDLTest_TestCaseFp)keyboard_getSetModState, "keyboard_getSetModState", "Check call to SDL_GetModState and SDL_SetModState", TEST_ENABLED }; + { (SDLTest_TestCaseFp)keyboard_getSetModState, "keyboard_getSetModState", "Check call to SDL_GetModState and SDL_SetModState", TEST_ENABLED }; static const SDLTest_TestCaseReference keyboardTest7 = - { (SDLTest_TestCaseFp)keyboard_startStopTextInput, "keyboard_startStopTextInput", "Check call to SDL_StartTextInput and SDL_StopTextInput", TEST_ENABLED }; + { (SDLTest_TestCaseFp)keyboard_startStopTextInput, "keyboard_startStopTextInput", "Check call to SDL_StartTextInput and SDL_StopTextInput", TEST_ENABLED }; static const SDLTest_TestCaseReference keyboardTest8 = - { (SDLTest_TestCaseFp)keyboard_setTextInputRect, "keyboard_setTextInputRect", "Check call to SDL_SetTextInputRect", TEST_ENABLED }; + { (SDLTest_TestCaseFp)keyboard_setTextInputRect, "keyboard_setTextInputRect", "Check call to SDL_SetTextInputRect", TEST_ENABLED }; static const SDLTest_TestCaseReference keyboardTest9 = - { (SDLTest_TestCaseFp)keyboard_setTextInputRectNegative, "keyboard_setTextInputRectNegative", "Check call to SDL_SetTextInputRect with invalid data", TEST_ENABLED }; + { (SDLTest_TestCaseFp)keyboard_setTextInputRectNegative, "keyboard_setTextInputRectNegative", "Check call to SDL_SetTextInputRect with invalid data", TEST_ENABLED }; static const SDLTest_TestCaseReference keyboardTest10 = - { (SDLTest_TestCaseFp)keyboard_getScancodeFromKey, "keyboard_getScancodeFromKey", "Check call to SDL_GetScancodeFromKey", TEST_ENABLED }; + { (SDLTest_TestCaseFp)keyboard_getScancodeFromKey, "keyboard_getScancodeFromKey", "Check call to SDL_GetScancodeFromKey", TEST_ENABLED }; static const SDLTest_TestCaseReference keyboardTest11 = - { (SDLTest_TestCaseFp)keyboard_getScancodeFromName, "keyboard_getScancodeFromName", "Check call to SDL_GetScancodeFromName", TEST_ENABLED }; + { (SDLTest_TestCaseFp)keyboard_getScancodeFromName, "keyboard_getScancodeFromName", "Check call to SDL_GetScancodeFromName", TEST_ENABLED }; static const SDLTest_TestCaseReference keyboardTest12 = - { (SDLTest_TestCaseFp)keyboard_getScancodeFromNameNegative, "keyboard_getScancodeFromNameNegative", "Check call to SDL_GetScancodeFromName with invalid data", TEST_ENABLED }; + { (SDLTest_TestCaseFp)keyboard_getScancodeFromNameNegative, "keyboard_getScancodeFromNameNegative", "Check call to SDL_GetScancodeFromName with invalid data", TEST_ENABLED }; static const SDLTest_TestCaseReference keyboardTest13 = - { (SDLTest_TestCaseFp)keyboard_getKeyNameNegative, "keyboard_getKeyNameNegative", "Check call to SDL_GetKeyName with invalid data", TEST_ENABLED }; + { (SDLTest_TestCaseFp)keyboard_getKeyNameNegative, "keyboard_getKeyNameNegative", "Check call to SDL_GetKeyName with invalid data", TEST_ENABLED }; static const SDLTest_TestCaseReference keyboardTest14 = - { (SDLTest_TestCaseFp)keyboard_getScancodeNameNegative, "keyboard_getScancodeNameNegative", "Check call to SDL_GetScancodeName with invalid data", TEST_ENABLED }; + { (SDLTest_TestCaseFp)keyboard_getScancodeNameNegative, "keyboard_getScancodeNameNegative", "Check call to SDL_GetScancodeName with invalid data", TEST_ENABLED }; /* Sequence of Keyboard test cases */ static const SDLTest_TestCaseReference *keyboardTests[] = { - &keyboardTest1, &keyboardTest2, &keyboardTest3, &keyboardTest4, &keyboardTest5, &keyboardTest6, - &keyboardTest7, &keyboardTest8, &keyboardTest9, &keyboardTest10, &keyboardTest11, &keyboardTest12, - &keyboardTest13, &keyboardTest14, NULL + &keyboardTest1, &keyboardTest2, &keyboardTest3, &keyboardTest4, &keyboardTest5, &keyboardTest6, + &keyboardTest7, &keyboardTest8, &keyboardTest9, &keyboardTest10, &keyboardTest11, &keyboardTest12, + &keyboardTest13, &keyboardTest14, NULL }; /* Keyboard test suite (global) */ SDLTest_TestSuiteReference keyboardTestSuite = { - "Keyboard", - NULL, - keyboardTests, - NULL + "Keyboard", + NULL, + keyboardTests, + NULL }; diff --git a/test/testautomation_main.c b/test/testautomation_main.c index a39bf3ca1..f695903c2 100644 --- a/test/testautomation_main.c +++ b/test/testautomation_main.c @@ -126,32 +126,32 @@ static int main_testImpliedJoystickQuit (void *arg) } static const SDLTest_TestCaseReference mainTest1 = - { (SDLTest_TestCaseFp)main_testInitQuitJoystickHaptic, "main_testInitQuitJoystickHaptic", "Tests SDL_Init/Quit of Joystick and Haptic subsystem", TEST_ENABLED}; + { (SDLTest_TestCaseFp)main_testInitQuitJoystickHaptic, "main_testInitQuitJoystickHaptic", "Tests SDL_Init/Quit of Joystick and Haptic subsystem", TEST_ENABLED}; static const SDLTest_TestCaseReference mainTest2 = - { (SDLTest_TestCaseFp)main_testInitQuitSubSystem, "main_testInitQuitSubSystem", "Tests SDL_InitSubSystem/QuitSubSystem", TEST_ENABLED}; + { (SDLTest_TestCaseFp)main_testInitQuitSubSystem, "main_testInitQuitSubSystem", "Tests SDL_InitSubSystem/QuitSubSystem", TEST_ENABLED}; static const SDLTest_TestCaseReference mainTest3 = - { (SDLTest_TestCaseFp)main_testImpliedJoystickInit, "main_testImpliedJoystickInit", "Tests that init for gamecontroller properly implies joystick", TEST_ENABLED}; + { (SDLTest_TestCaseFp)main_testImpliedJoystickInit, "main_testImpliedJoystickInit", "Tests that init for gamecontroller properly implies joystick", TEST_ENABLED}; static const SDLTest_TestCaseReference mainTest4 = - { (SDLTest_TestCaseFp)main_testImpliedJoystickQuit, "main_testImpliedJoystickQuit", "Tests that quit for gamecontroller doesn't quit joystick if you inited it explicitly", TEST_ENABLED}; + { (SDLTest_TestCaseFp)main_testImpliedJoystickQuit, "main_testImpliedJoystickQuit", "Tests that quit for gamecontroller doesn't quit joystick if you inited it explicitly", TEST_ENABLED}; /* Sequence of Platform test cases */ static const SDLTest_TestCaseReference *mainTests[] = { - &mainTest1, - &mainTest2, - &mainTest3, - &mainTest4, - NULL + &mainTest1, + &mainTest2, + &mainTest3, + &mainTest4, + NULL }; /* Platform test suite (global) */ SDLTest_TestSuiteReference mainTestSuite = { - "Main", - NULL, - mainTests, - NULL + "Main", + NULL, + mainTests, + NULL }; /* vi: set ts=4 sw=4 expandtab: */ diff --git a/test/testautomation_mouse.c b/test/testautomation_mouse.c index 2f7eb1b8e..57cadee2e 100644 --- a/test/testautomation_mouse.c +++ b/test/testautomation_mouse.c @@ -15,17 +15,17 @@ /* Helper to evaluate state returned from SDL_GetMouseState */ int _mouseStateCheck(Uint32 state) { - return (state == 0) || - (state == SDL_BUTTON(SDL_BUTTON_LEFT)) || - (state == SDL_BUTTON(SDL_BUTTON_MIDDLE)) || - (state == SDL_BUTTON(SDL_BUTTON_RIGHT)) || - (state == SDL_BUTTON(SDL_BUTTON_X1)) || + return (state == 0) || + (state == SDL_BUTTON(SDL_BUTTON_LEFT)) || + (state == SDL_BUTTON(SDL_BUTTON_MIDDLE)) || + (state == SDL_BUTTON(SDL_BUTTON_RIGHT)) || + (state == SDL_BUTTON(SDL_BUTTON_X1)) || (state == SDL_BUTTON(SDL_BUTTON_X2)); } /** * @brief Check call to SDL_GetMouseState - * + * */ int mouse_getMouseState(void *arg) @@ -38,7 +38,7 @@ mouse_getMouseState(void *arg) SDL_PumpEvents(); SDLTest_AssertPass("Call to SDL_PumpEvents()"); - /* Case where x, y pointer is NULL */ + /* Case where x, y pointer is NULL */ state = SDL_GetMouseState(NULL, NULL); SDLTest_AssertPass("Call to SDL_GetMouseState(NULL, NULL)"); SDLTest_AssertCheck(_mouseStateCheck(state), "Validate state returned from function, got: %i", state); @@ -65,13 +65,13 @@ mouse_getMouseState(void *arg) SDLTest_AssertCheck(x > INT_MIN, "Validate that value of x is > INT_MIN, got: %i", x); SDLTest_AssertCheck(y > INT_MIN, "Validate that value of y is > INT_MIN, got: %i", y); SDLTest_AssertCheck(_mouseStateCheck(state), "Validate state returned from function, got: %i", state); - + return TEST_COMPLETED; } /** * @brief Check call to SDL_GetRelativeMouseState - * + * */ int mouse_getRelativeMouseState(void *arg) @@ -84,7 +84,7 @@ mouse_getRelativeMouseState(void *arg) SDL_PumpEvents(); SDLTest_AssertPass("Call to SDL_PumpEvents()"); - /* Case where x, y pointer is NULL */ + /* Case where x, y pointer is NULL */ state = SDL_GetRelativeMouseState(NULL, NULL); SDLTest_AssertPass("Call to SDL_GetRelativeMouseState(NULL, NULL)"); SDLTest_AssertCheck(_mouseStateCheck(state), "Validate state returned from function, got: %i", state); @@ -111,7 +111,7 @@ mouse_getRelativeMouseState(void *arg) SDLTest_AssertCheck(x > INT_MIN, "Validate that value of x is > INT_MIN, got: %i", x); SDLTest_AssertCheck(y > INT_MIN, "Validate that value of y is > INT_MIN, got: %i", y); SDLTest_AssertCheck(_mouseStateCheck(state), "Validate state returned from function, got: %i", state); - + return TEST_COMPLETED; } @@ -191,225 +191,225 @@ static SDL_Cursor *_initArrowCursor(const char *image[]) /** * @brief Check call to SDL_CreateCursor and SDL_FreeCursor - * + * * @sa http://wiki.libsdl.org/moin.cgi/SDL_CreateCursor * @sa http://wiki.libsdl.org/moin.cgi/SDL_FreeCursor */ int mouse_createFreeCursor(void *arg) { - SDL_Cursor *cursor; + SDL_Cursor *cursor; - /* Create a cursor */ - cursor = _initArrowCursor(_mouseArrowData); + /* Create a cursor */ + cursor = _initArrowCursor(_mouseArrowData); SDLTest_AssertPass("Call to SDL_CreateCursor()"); - SDLTest_AssertCheck(cursor != NULL, "Validate result from SDL_CreateCursor() is not NULL"); - if (cursor == NULL) { - return TEST_ABORTED; - } + SDLTest_AssertCheck(cursor != NULL, "Validate result from SDL_CreateCursor() is not NULL"); + if (cursor == NULL) { + return TEST_ABORTED; + } - /* Free cursor again */ - SDL_FreeCursor(cursor); - SDLTest_AssertPass("Call to SDL_FreeCursor()"); + /* Free cursor again */ + SDL_FreeCursor(cursor); + SDLTest_AssertPass("Call to SDL_FreeCursor()"); - return TEST_COMPLETED; + return TEST_COMPLETED; } /** * @brief Check call to SDL_CreateColorCursor and SDL_FreeCursor - * + * * @sa http://wiki.libsdl.org/moin.cgi/SDL_CreateColorCursor * @sa http://wiki.libsdl.org/moin.cgi/SDL_FreeCursor */ int mouse_createFreeColorCursor(void *arg) { - SDL_Surface *face; - SDL_Cursor *cursor; - - /* Get sample surface */ - face = SDLTest_ImageFace(); - SDLTest_AssertCheck(face != NULL, "Validate sample input image is not NULL"); - if (face == NULL) return TEST_ABORTED; - - /* Create a color cursor from surface */ - cursor = SDL_CreateColorCursor(face, 0, 0); + SDL_Surface *face; + SDL_Cursor *cursor; + + /* Get sample surface */ + face = SDLTest_ImageFace(); + SDLTest_AssertCheck(face != NULL, "Validate sample input image is not NULL"); + if (face == NULL) return TEST_ABORTED; + + /* Create a color cursor from surface */ + cursor = SDL_CreateColorCursor(face, 0, 0); SDLTest_AssertPass("Call to SDL_CreateColorCursor()"); - SDLTest_AssertCheck(cursor != NULL, "Validate result from SDL_CreateColorCursor() is not NULL"); - if (cursor == NULL) { - SDL_FreeSurface(face); - return TEST_ABORTED; - } - - /* Free cursor again */ - SDL_FreeCursor(cursor); - SDLTest_AssertPass("Call to SDL_FreeCursor()"); - - /* Clean up */ - SDL_FreeSurface(face); - - return TEST_COMPLETED; + SDLTest_AssertCheck(cursor != NULL, "Validate result from SDL_CreateColorCursor() is not NULL"); + if (cursor == NULL) { + SDL_FreeSurface(face); + return TEST_ABORTED; + } + + /* Free cursor again */ + SDL_FreeCursor(cursor); + SDLTest_AssertPass("Call to SDL_FreeCursor()"); + + /* Clean up */ + SDL_FreeSurface(face); + + return TEST_COMPLETED; } /* Helper that changes cursor visibility */ void _changeCursorVisibility(int state) { - int oldState; - int newState; - int result; + int oldState; + int newState; + int result; oldState = SDL_ShowCursor(SDL_QUERY); - SDLTest_AssertPass("Call to SDL_ShowCursor(SDL_QUERY)"); + SDLTest_AssertPass("Call to SDL_ShowCursor(SDL_QUERY)"); result = SDL_ShowCursor(state); - SDLTest_AssertPass("Call to SDL_ShowCursor(%s)", (state == SDL_ENABLE) ? "SDL_ENABLE" : "SDL_DISABLE"); - SDLTest_AssertCheck(result == oldState, "Validate result from SDL_ShowCursor(%s), expected: %i, got: %i", - (state == SDL_ENABLE) ? "SDL_ENABLE" : "SDL_DISABLE", oldState, result); - - newState = SDL_ShowCursor(SDL_QUERY); - SDLTest_AssertPass("Call to SDL_ShowCursor(SDL_QUERY)"); - SDLTest_AssertCheck(state == newState, "Validate new state, expected: %i, got: %i", - state, newState); + SDLTest_AssertPass("Call to SDL_ShowCursor(%s)", (state == SDL_ENABLE) ? "SDL_ENABLE" : "SDL_DISABLE"); + SDLTest_AssertCheck(result == oldState, "Validate result from SDL_ShowCursor(%s), expected: %i, got: %i", + (state == SDL_ENABLE) ? "SDL_ENABLE" : "SDL_DISABLE", oldState, result); + + newState = SDL_ShowCursor(SDL_QUERY); + SDLTest_AssertPass("Call to SDL_ShowCursor(SDL_QUERY)"); + SDLTest_AssertCheck(state == newState, "Validate new state, expected: %i, got: %i", + state, newState); } /** * @brief Check call to SDL_ShowCursor - * + * * @sa http://wiki.libsdl.org/moin.cgi/SDL_ShowCursor */ int mouse_showCursor(void *arg) { - int currentState; - - /* Get current state */ - currentState = SDL_ShowCursor(SDL_QUERY); - SDLTest_AssertPass("Call to SDL_ShowCursor(SDL_QUERY)"); - SDLTest_AssertCheck(currentState == SDL_DISABLE || currentState == SDL_ENABLE, - "Validate result is %i or %i, got: %i", SDL_DISABLE, SDL_ENABLE, currentState); - if (currentState == SDL_DISABLE) { - /* Show the cursor, then hide it again */ - _changeCursorVisibility(SDL_ENABLE); - _changeCursorVisibility(SDL_DISABLE); - } else if (currentState == SDL_ENABLE) { - /* Hide the cursor, then show it again */ - _changeCursorVisibility(SDL_DISABLE); - _changeCursorVisibility(SDL_ENABLE); - } else { - return TEST_ABORTED; - } - - return TEST_COMPLETED; + int currentState; + + /* Get current state */ + currentState = SDL_ShowCursor(SDL_QUERY); + SDLTest_AssertPass("Call to SDL_ShowCursor(SDL_QUERY)"); + SDLTest_AssertCheck(currentState == SDL_DISABLE || currentState == SDL_ENABLE, + "Validate result is %i or %i, got: %i", SDL_DISABLE, SDL_ENABLE, currentState); + if (currentState == SDL_DISABLE) { + /* Show the cursor, then hide it again */ + _changeCursorVisibility(SDL_ENABLE); + _changeCursorVisibility(SDL_DISABLE); + } else if (currentState == SDL_ENABLE) { + /* Hide the cursor, then show it again */ + _changeCursorVisibility(SDL_DISABLE); + _changeCursorVisibility(SDL_ENABLE); + } else { + return TEST_ABORTED; + } + + return TEST_COMPLETED; } /** * @brief Check call to SDL_SetCursor - * + * * @sa http://wiki.libsdl.org/moin.cgi/SDL_SetCursor */ int mouse_setCursor(void *arg) { - SDL_Cursor *cursor; + SDL_Cursor *cursor; - /* Create a cursor */ - cursor = _initArrowCursor(_mouseArrowData); + /* Create a cursor */ + cursor = _initArrowCursor(_mouseArrowData); SDLTest_AssertPass("Call to SDL_CreateCursor()"); - SDLTest_AssertCheck(cursor != NULL, "Validate result from SDL_CreateCursor() is not NULL"); - if (cursor == NULL) { - return TEST_ABORTED; - } + SDLTest_AssertCheck(cursor != NULL, "Validate result from SDL_CreateCursor() is not NULL"); + if (cursor == NULL) { + return TEST_ABORTED; + } - /* Set the arrow cursor */ - SDL_SetCursor(cursor); - SDLTest_AssertPass("Call to SDL_SetCursor(cursor)"); + /* Set the arrow cursor */ + SDL_SetCursor(cursor); + SDLTest_AssertPass("Call to SDL_SetCursor(cursor)"); - /* Force redraw */ - SDL_SetCursor(NULL); - SDLTest_AssertPass("Call to SDL_SetCursor(NULL)"); + /* Force redraw */ + SDL_SetCursor(NULL); + SDLTest_AssertPass("Call to SDL_SetCursor(NULL)"); - /* Free cursor again */ - SDL_FreeCursor(cursor); - SDLTest_AssertPass("Call to SDL_FreeCursor()"); + /* Free cursor again */ + SDL_FreeCursor(cursor); + SDLTest_AssertPass("Call to SDL_FreeCursor()"); - return TEST_COMPLETED; + return TEST_COMPLETED; } /** * @brief Check call to SDL_GetCursor - * + * * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetCursor */ int mouse_getCursor(void *arg) { - SDL_Cursor *cursor; + SDL_Cursor *cursor; - /* Get current cursor */ - cursor = SDL_GetCursor(); + /* Get current cursor */ + cursor = SDL_GetCursor(); SDLTest_AssertPass("Call to SDL_GetCursor()"); - SDLTest_AssertCheck(cursor != NULL, "Validate result from SDL_GetCursor() is not NULL"); + SDLTest_AssertCheck(cursor != NULL, "Validate result from SDL_GetCursor() is not NULL"); - return TEST_COMPLETED; + return TEST_COMPLETED; } /** * @brief Check call to SDL_GetRelativeMouseMode and SDL_SetRelativeMouseMode - * + * * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetRelativeMouseMode * @sa http://wiki.libsdl.org/moin.cgi/SDL_SetRelativeMouseMode */ int mouse_getSetRelativeMouseMode(void *arg) { - int result; + int result; int i; - SDL_bool initialState; - SDL_bool currentState; + SDL_bool initialState; + SDL_bool currentState; - /* Capture original state so we can revert back to it later */ - initialState = SDL_GetRelativeMouseMode(); + /* Capture original state so we can revert back to it later */ + initialState = SDL_GetRelativeMouseMode(); SDLTest_AssertPass("Call to SDL_GetRelativeMouseMode()"); /* Repeat twice to check D->D transition */ for (i=0; i<2; i++) { - /* Disable - should always be supported */ + /* Disable - should always be supported */ result = SDL_SetRelativeMouseMode(SDL_FALSE); SDLTest_AssertPass("Call to SDL_SetRelativeMouseMode(FALSE)"); SDLTest_AssertCheck(result == 0, "Validate result value from SDL_SetRelativeMouseMode, expected: 0, got: %i", result); - currentState = SDL_GetRelativeMouseMode(); + currentState = SDL_GetRelativeMouseMode(); SDLTest_AssertPass("Call to SDL_GetRelativeMouseMode()"); SDLTest_AssertCheck(currentState == SDL_FALSE, "Validate current state is FALSE, got: %i", currentState); } - + /* Repeat twice to check D->E->E transition */ for (i=0; i<2; i++) { - /* Enable - may not be supported */ + /* Enable - may not be supported */ result = SDL_SetRelativeMouseMode(SDL_TRUE); SDLTest_AssertPass("Call to SDL_SetRelativeMouseMode(TRUE)"); if (result != -1) { SDLTest_AssertCheck(result == 0, "Validate result value from SDL_SetRelativeMouseMode, expected: 0, got: %i", result); - currentState = SDL_GetRelativeMouseMode(); + currentState = SDL_GetRelativeMouseMode(); SDLTest_AssertPass("Call to SDL_GetRelativeMouseMode()"); SDLTest_AssertCheck(currentState == SDL_TRUE, "Validate current state is TRUE, got: %i", currentState); } } - /* Disable to check E->D transition */ + /* Disable to check E->D transition */ result = SDL_SetRelativeMouseMode(SDL_FALSE); SDLTest_AssertPass("Call to SDL_SetRelativeMouseMode(FALSE)"); SDLTest_AssertCheck(result == 0, "Validate result value from SDL_SetRelativeMouseMode, expected: 0, got: %i", result); - currentState = SDL_GetRelativeMouseMode(); + currentState = SDL_GetRelativeMouseMode(); SDLTest_AssertPass("Call to SDL_GetRelativeMouseMode()"); SDLTest_AssertCheck(currentState == SDL_FALSE, "Validate current state is FALSE, got: %i", currentState); - + /* Revert to original state - ignore result */ result = SDL_SetRelativeMouseMode(initialState); - return TEST_COMPLETED; + return TEST_COMPLETED; } -#define MOUSE_TESTWINDOW_WIDTH 320 +#define MOUSE_TESTWINDOW_WIDTH 320 #define MOUSE_TESTWINDOW_HEIGHT 200 /** @@ -426,11 +426,11 @@ SDL_Window *_createMouseSuiteTestWindow() } /* - * Destroy test window + * Destroy test window */ void _destroyMouseSuiteTestWindow(SDL_Window *window) { - if (window != NULL) { + if (window != NULL) { SDL_DestroyWindow(window); window = NULL; SDLTest_AssertPass("SDL_DestroyWindow()"); @@ -439,156 +439,156 @@ void _destroyMouseSuiteTestWindow(SDL_Window *window) /** * @brief Check call to SDL_WarpMouseInWindow - * + * * @sa http://wiki.libsdl.org/moin.cgi/SDL_WarpMouseInWindow */ int mouse_warpMouseInWindow(void *arg) { - const int w = MOUSE_TESTWINDOW_WIDTH, h = MOUSE_TESTWINDOW_HEIGHT; - int numPositions = 6; - int xPositions[] = {-1, 0, 1, w-1, w, w+1 }; - int yPositions[] = {-1, 0, 1, h-1, h, h+1 }; - int x, y, i, j; - SDL_Window *window; - - /* Create test window */ - window = _createMouseSuiteTestWindow(); - if (window == NULL) return TEST_ABORTED; - - /* Mouse to random position inside window */ - x = SDLTest_RandomIntegerInRange(1, w-1); - y = SDLTest_RandomIntegerInRange(1, h-1); - SDL_WarpMouseInWindow(window, x, y); - SDLTest_AssertPass("SDL_WarpMouseInWindow(...,%i,%i)", x, y); + const int w = MOUSE_TESTWINDOW_WIDTH, h = MOUSE_TESTWINDOW_HEIGHT; + int numPositions = 6; + int xPositions[] = {-1, 0, 1, w-1, w, w+1 }; + int yPositions[] = {-1, 0, 1, h-1, h, h+1 }; + int x, y, i, j; + SDL_Window *window; + + /* Create test window */ + window = _createMouseSuiteTestWindow(); + if (window == NULL) return TEST_ABORTED; + + /* Mouse to random position inside window */ + x = SDLTest_RandomIntegerInRange(1, w-1); + y = SDLTest_RandomIntegerInRange(1, h-1); + SDL_WarpMouseInWindow(window, x, y); + SDLTest_AssertPass("SDL_WarpMouseInWindow(...,%i,%i)", x, y); /* Same position again */ - SDL_WarpMouseInWindow(window, x, y); - SDLTest_AssertPass("SDL_WarpMouseInWindow(...,%i,%i)", x, y); - - /* Mouse to various boundary positions */ - for (i=0; iformat == format, "Verify value of result.format; expected: %u, got %u", format, result->format); - SDLTest_AssertCheck(result->BitsPerPixel == 0, "Verify value of result.BitsPerPixel; expected: 0, got %u", result->BitsPerPixel); - SDLTest_AssertCheck(result->BytesPerPixel == 0, "Verify value of result.BytesPerPixel; expected: 0, got %u", result->BytesPerPixel); + SDLTest_AssertCheck(result->format == format, "Verify value of result.format; expected: %u, got %u", format, result->format); + SDLTest_AssertCheck(result->BitsPerPixel == 0, "Verify value of result.BitsPerPixel; expected: 0, got %u", result->BitsPerPixel); + SDLTest_AssertCheck(result->BytesPerPixel == 0, "Verify value of result.BytesPerPixel; expected: 0, got %u", result->BytesPerPixel); masks = result->Rmask | result->Gmask | result->Bmask | result->Amask; SDLTest_AssertCheck(masks == 0, "Verify value of result.[RGBA]mask combined; expected: 0, got %u", masks); - + /* Deallocate again */ SDL_FreeFormat(result); - SDLTest_AssertPass("Call to SDL_FreeFormat()"); + SDLTest_AssertPass("Call to SDL_FreeFormat()"); } /* RGB formats */ for (i = 0; i < _numRGBPixelFormats; i++) { format = _RGBPixelFormats[i]; SDLTest_Log("RGB Format: %s (%u)", _RGBPixelFormatsVerbose[i], format); - + /* Allocate format */ result = SDL_AllocFormat(format); SDLTest_AssertPass("Call to SDL_AllocFormat()"); - SDLTest_AssertCheck(result != NULL, "Verify result is not NULL"); + SDLTest_AssertCheck(result != NULL, "Verify result is not NULL"); if (result != NULL) { - SDLTest_AssertCheck(result->format == format, "Verify value of result.format; expected: %u, got %u", format, result->format); - SDLTest_AssertCheck(result->BitsPerPixel > 0, "Verify value of result.BitsPerPixel; expected: >0, got %u", result->BitsPerPixel); - SDLTest_AssertCheck(result->BytesPerPixel > 0, "Verify value of result.BytesPerPixel; expected: >0, got %u", result->BytesPerPixel); - if (result->palette != NULL) { + SDLTest_AssertCheck(result->format == format, "Verify value of result.format; expected: %u, got %u", format, result->format); + SDLTest_AssertCheck(result->BitsPerPixel > 0, "Verify value of result.BitsPerPixel; expected: >0, got %u", result->BitsPerPixel); + SDLTest_AssertCheck(result->BytesPerPixel > 0, "Verify value of result.BytesPerPixel; expected: >0, got %u", result->BytesPerPixel); + if (result->palette != NULL) { masks = result->Rmask | result->Gmask | result->Bmask | result->Amask; SDLTest_AssertCheck(masks > 0, "Verify value of result.[RGBA]mask combined; expected: >0, got %u", masks); } - + /* Deallocate again */ SDL_FreeFormat(result); - SDLTest_AssertPass("Call to SDL_FreeFormat()"); + SDLTest_AssertPass("Call to SDL_FreeFormat()"); } } @@ -177,28 +177,28 @@ pixels_allocFreeFormat(void *arg) for (i = 0; i < _numNonRGBPixelFormats; i++) { format = _nonRGBPixelFormats[i]; SDLTest_Log("non-RGB Format: %s (%u)", _nonRGBPixelFormatsVerbose[i], format); - + /* Try to allocate format */ result = SDL_AllocFormat(format); SDLTest_AssertPass("Call to SDL_AllocFormat()"); - SDLTest_AssertCheck(result == NULL, "Verify result is NULL"); + SDLTest_AssertCheck(result == NULL, "Verify result is NULL"); } - + /* Negative cases */ - - /* Invalid Formats */ + + /* Invalid Formats */ for (i = 0; i < _numInvalidPixelFormats; i++) { SDL_ClearError(); SDLTest_AssertPass("Call to SDL_ClearError()"); format = _invalidPixelFormats[i]; result = SDL_AllocFormat(format); SDLTest_AssertPass("Call to SDL_AllocFormat(%u)", format); - SDLTest_AssertCheck(result == NULL, "Verify result is NULL"); + SDLTest_AssertCheck(result == NULL, "Verify result is NULL"); error = SDL_GetError(); SDLTest_AssertPass("Call to SDL_GetError()"); SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL"); if (error != NULL) { - SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0, + SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0, "Validate error message, expected: '%s', got: '%s'", expectedError, error); } } @@ -212,10 +212,10 @@ pixels_allocFreeFormat(void *arg) SDLTest_AssertPass("Call to SDL_GetError()"); SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL"); if (error != NULL) { - SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0, + SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0, "Validate error message, expected: '%s', got: '%s'", expectedError, error); } - + return TEST_COMPLETED; } @@ -228,7 +228,7 @@ int pixels_getPixelFormatName(void *arg) { const char *unknownFormat = "SDL_PIXELFORMAT_UNKNOWN"; - const char *error; + const char *error; int i; Uint32 format; char* result; @@ -236,14 +236,14 @@ pixels_getPixelFormatName(void *arg) /* Blank/undefined format */ format = 0; SDLTest_Log("RGB Format: %s (%u)", unknownFormat, format); - + /* Get name of format */ result = (char *)SDL_GetPixelFormatName(format); SDLTest_AssertPass("Call to SDL_GetPixelFormatName()"); - SDLTest_AssertCheck(result != NULL, "Verify result is not NULL"); + SDLTest_AssertCheck(result != NULL, "Verify result is not NULL"); if (result != NULL) { SDLTest_AssertCheck(SDL_strlen(result) > 0, "Verify result is non-empty"); - SDLTest_AssertCheck(SDL_strcmp(result, unknownFormat) == 0, + SDLTest_AssertCheck(SDL_strcmp(result, unknownFormat) == 0, "Verify result text; expected: %s, got %s", unknownFormat, result); } @@ -251,14 +251,14 @@ pixels_getPixelFormatName(void *arg) for (i = 0; i < _numRGBPixelFormats; i++) { format = _RGBPixelFormats[i]; SDLTest_Log("RGB Format: %s (%u)", _RGBPixelFormatsVerbose[i], format); - + /* Get name of format */ result = (char *)SDL_GetPixelFormatName(format); SDLTest_AssertPass("Call to SDL_GetPixelFormatName()"); - SDLTest_AssertCheck(result != NULL, "Verify result is not NULL"); + SDLTest_AssertCheck(result != NULL, "Verify result is not NULL"); if (result != NULL) { SDLTest_AssertCheck(SDL_strlen(result) > 0, "Verify result is non-empty"); - SDLTest_AssertCheck(SDL_strcmp(result, _RGBPixelFormatsVerbose[i]) == 0, + SDLTest_AssertCheck(SDL_strcmp(result, _RGBPixelFormatsVerbose[i]) == 0, "Verify result text; expected: %s, got %s", _RGBPixelFormatsVerbose[i], result); } } @@ -267,30 +267,30 @@ pixels_getPixelFormatName(void *arg) for (i = 0; i < _numNonRGBPixelFormats; i++) { format = _nonRGBPixelFormats[i]; SDLTest_Log("non-RGB Format: %s (%u)", _nonRGBPixelFormatsVerbose[i], format); - + /* Get name of format */ result = (char *)SDL_GetPixelFormatName(format); SDLTest_AssertPass("Call to SDL_GetPixelFormatName()"); - SDLTest_AssertCheck(result != NULL, "Verify result is not NULL"); + SDLTest_AssertCheck(result != NULL, "Verify result is not NULL"); if (result != NULL) { SDLTest_AssertCheck(SDL_strlen(result) > 0, "Verify result is non-empty"); - SDLTest_AssertCheck(SDL_strcmp(result, _nonRGBPixelFormatsVerbose[i]) == 0, + SDLTest_AssertCheck(SDL_strcmp(result, _nonRGBPixelFormatsVerbose[i]) == 0, "Verify result text; expected: %s, got %s", _nonRGBPixelFormatsVerbose[i], result); } } - + /* Negative cases */ - - /* Invalid Formats */ + + /* Invalid Formats */ SDL_ClearError(); SDLTest_AssertPass("Call to SDL_ClearError()"); for (i = 0; i < _numInvalidPixelFormats; i++) { format = _invalidPixelFormats[i]; result = (char *)SDL_GetPixelFormatName(format); SDLTest_AssertPass("Call to SDL_GetPixelFormatName(%u)", format); - SDLTest_AssertCheck(result != NULL, "Verify result is not NULL"); + SDLTest_AssertCheck(result != NULL, "Verify result is not NULL"); if (result != NULL) { - SDLTest_AssertCheck(SDL_strlen(result) > 0, + SDLTest_AssertCheck(SDL_strlen(result) > 0, "Verify result is non-empty; got: %s", result); SDLTest_AssertCheck(SDL_strcmp(result, _invalidPixelFormatsVerbose[i]) == 0, "Validate name is UNKNOWN, expected: '%s', got: '%s'", _invalidPixelFormatsVerbose[i], result); @@ -314,14 +314,14 @@ pixels_allocFreePalette(void *arg) { const char *expectedError1 = "Parameter 'ncolors' is invalid"; const char *expectedError2 = "Parameter 'palette' is invalid"; - const char *error; + const char *error; int variation; int i; int ncolors; SDL_Palette* result; /* Allocate palette */ - for (variation = 1; variation <= 3; variation++) { + for (variation = 1; variation <= 3; variation++) { switch (variation) { /* Just one color */ case 1: @@ -339,28 +339,28 @@ pixels_allocFreePalette(void *arg) result = SDL_AllocPalette(ncolors); SDLTest_AssertPass("Call to SDL_AllocPalette(%d)", ncolors); - SDLTest_AssertCheck(result != NULL, "Verify result is not NULL"); + SDLTest_AssertCheck(result != NULL, "Verify result is not NULL"); if (result != NULL) { - SDLTest_AssertCheck(result->ncolors == ncolors, "Verify value of result.ncolors; expected: %u, got %u", ncolors, result->ncolors); + SDLTest_AssertCheck(result->ncolors == ncolors, "Verify value of result.ncolors; expected: %u, got %u", ncolors, result->ncolors); if (result->ncolors > 0) { SDLTest_AssertCheck(result->colors != NULL, "Verify value of result.colors is not NULL"); if (result->colors != NULL) { for(i = 0; i < result->ncolors; i++) { - SDLTest_AssertCheck(result->colors[i].r == 255, "Verify value of result.colors[%d].r; expected: 255, got %u", i, result->colors[i].r); - SDLTest_AssertCheck(result->colors[i].g == 255, "Verify value of result.colors[%d].g; expected: 255, got %u", i, result->colors[i].g); - SDLTest_AssertCheck(result->colors[i].b == 255, "Verify value of result.colors[%d].b; expected: 255, got %u", i, result->colors[i].b); + SDLTest_AssertCheck(result->colors[i].r == 255, "Verify value of result.colors[%d].r; expected: 255, got %u", i, result->colors[i].r); + SDLTest_AssertCheck(result->colors[i].g == 255, "Verify value of result.colors[%d].g; expected: 255, got %u", i, result->colors[i].g); + SDLTest_AssertCheck(result->colors[i].b == 255, "Verify value of result.colors[%d].b; expected: 255, got %u", i, result->colors[i].b); } - } + } } - + /* Deallocate again */ SDL_FreePalette(result); - SDLTest_AssertPass("Call to SDL_FreePalette()"); + SDLTest_AssertPass("Call to SDL_FreePalette()"); } } /* Negative cases */ - + /* Invalid number of colors */ for (ncolors = 0; ncolors > -3; ncolors--) { SDL_ClearError(); @@ -372,7 +372,7 @@ pixels_allocFreePalette(void *arg) SDLTest_AssertPass("Call to SDL_GetError()"); SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL"); if (error != NULL) { - SDLTest_AssertCheck(SDL_strcmp(error, expectedError1) == 0, + SDLTest_AssertCheck(SDL_strcmp(error, expectedError1) == 0, "Validate error message, expected: '%s', got: '%s'", expectedError1, error); } } @@ -386,10 +386,10 @@ pixels_allocFreePalette(void *arg) SDLTest_AssertPass("Call to SDL_GetError()"); SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL"); if (error != NULL) { - SDLTest_AssertCheck(SDL_strcmp(error, expectedError2) == 0, + SDLTest_AssertCheck(SDL_strcmp(error, expectedError2) == 0, "Validate error message, expected: '%s', got: '%s'", expectedError2, error); } - + return TEST_COMPLETED; } @@ -403,7 +403,7 @@ pixels_calcGammaRamp(void *arg) { const char *expectedError1 = "Parameter 'gamma' is invalid"; const char *expectedError2 = "Parameter 'ramp' is invalid"; - const char *error; + const char *error; float gamma; Uint16 *ramp; int variation; @@ -415,29 +415,29 @@ pixels_calcGammaRamp(void *arg) ramp = (Uint16 *)SDL_malloc(256 * sizeof(Uint16)); SDLTest_AssertCheck(ramp != NULL, "Validate temp ramp array could be allocated"); if (ramp == NULL) return TEST_ABORTED; - + /* Make call with different gamma values */ for (variation = 0; variation < 4; variation++) { switch (variation) { /* gamma = 0 all black */ - case 0: + case 0: gamma = 0.0f; break; /* gamma = 1 identity */ case 1: gamma = 1.0f; break; - /* gamma = [0.2,0.8] normal range */ + /* gamma = [0.2,0.8] normal range */ case 2: gamma = 0.2f + 0.8f * SDLTest_RandomUnitFloat(); break; - /* gamma = >1.1 non-standard range */ + /* gamma = >1.1 non-standard range */ case 3: gamma = 1.1f + SDLTest_RandomUnitFloat(); break; } - /* Make call and check that values were updated */ + /* Make call and check that values were updated */ for (i = 0; i < 256; i++) ramp[i] = magic; SDL_CalculateGammaRamp(gamma, ramp); SDLTest_AssertPass("Call to SDL_CalculateGammaRamp(%f)", gamma); @@ -460,7 +460,7 @@ pixels_calcGammaRamp(void *arg) break; } } - + /* Negative cases */ SDL_ClearError(); SDLTest_AssertPass("Call to SDL_ClearError()"); @@ -472,7 +472,7 @@ pixels_calcGammaRamp(void *arg) SDLTest_AssertPass("Call to SDL_GetError()"); SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL"); if (error != NULL) { - SDLTest_AssertCheck(SDL_strcmp(error, expectedError1) == 0, + SDLTest_AssertCheck(SDL_strcmp(error, expectedError1) == 0, "Validate error message, expected: '%s', got: '%s'", expectedError1, error); } changed = 0; @@ -485,14 +485,14 @@ pixels_calcGammaRamp(void *arg) SDLTest_AssertPass("Call to SDL_GetError()"); SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL"); if (error != NULL) { - SDLTest_AssertCheck(SDL_strcmp(error, expectedError2) == 0, + SDLTest_AssertCheck(SDL_strcmp(error, expectedError2) == 0, "Validate error message, expected: '%s', got: '%s'", expectedError2, error); } - + /* Cleanup */ SDL_free(ramp); - - + + return TEST_COMPLETED; } @@ -500,26 +500,26 @@ pixels_calcGammaRamp(void *arg) /* Pixels test cases */ static const SDLTest_TestCaseReference pixelsTest1 = - { (SDLTest_TestCaseFp)pixels_allocFreeFormat, "pixels_allocFreeFormat", "Call to SDL_AllocFormat and SDL_FreeFormat", TEST_ENABLED }; + { (SDLTest_TestCaseFp)pixels_allocFreeFormat, "pixels_allocFreeFormat", "Call to SDL_AllocFormat and SDL_FreeFormat", TEST_ENABLED }; static const SDLTest_TestCaseReference pixelsTest2 = - { (SDLTest_TestCaseFp)pixels_allocFreePalette, "pixels_allocFreePalette", "Call to SDL_AllocPalette and SDL_FreePalette", TEST_ENABLED }; + { (SDLTest_TestCaseFp)pixels_allocFreePalette, "pixels_allocFreePalette", "Call to SDL_AllocPalette and SDL_FreePalette", TEST_ENABLED }; static const SDLTest_TestCaseReference pixelsTest3 = - { (SDLTest_TestCaseFp)pixels_calcGammaRamp, "pixels_calcGammaRamp", "Call to SDL_CalculateGammaRamp", TEST_ENABLED }; + { (SDLTest_TestCaseFp)pixels_calcGammaRamp, "pixels_calcGammaRamp", "Call to SDL_CalculateGammaRamp", TEST_ENABLED }; static const SDLTest_TestCaseReference pixelsTest4 = - { (SDLTest_TestCaseFp)pixels_getPixelFormatName, "pixels_getPixelFormatName", "Call to SDL_GetPixelFormatName", TEST_ENABLED }; + { (SDLTest_TestCaseFp)pixels_getPixelFormatName, "pixels_getPixelFormatName", "Call to SDL_GetPixelFormatName", TEST_ENABLED }; /* Sequence of Pixels test cases */ static const SDLTest_TestCaseReference *pixelsTests[] = { - &pixelsTest1, &pixelsTest2, &pixelsTest3, &pixelsTest4, NULL + &pixelsTest1, &pixelsTest2, &pixelsTest3, &pixelsTest4, NULL }; /* Pixels test suite (global) */ SDLTest_TestSuiteReference pixelsTestSuite = { - "Pixels", - NULL, - pixelsTests, - NULL + "Pixels", + NULL, + pixelsTests, + NULL }; diff --git a/test/testautomation_platform.c b/test/testautomation_platform.c index a77aad280..5ed2abad1 100644 --- a/test/testautomation_platform.c +++ b/test/testautomation_platform.c @@ -504,58 +504,58 @@ int platform_testGetPowerInfo(void *arg) /* Platform test cases */ static const SDLTest_TestCaseReference platformTest1 = - { (SDLTest_TestCaseFp)platform_testTypes, "platform_testTypes", "Tests predefined types", TEST_ENABLED}; + { (SDLTest_TestCaseFp)platform_testTypes, "platform_testTypes", "Tests predefined types", TEST_ENABLED}; static const SDLTest_TestCaseReference platformTest2 = - { (SDLTest_TestCaseFp)platform_testEndianessAndSwap, "platform_testEndianessAndSwap", "Tests endianess and swap functions", TEST_ENABLED}; + { (SDLTest_TestCaseFp)platform_testEndianessAndSwap, "platform_testEndianessAndSwap", "Tests endianess and swap functions", TEST_ENABLED}; static const SDLTest_TestCaseReference platformTest3 = - { (SDLTest_TestCaseFp)platform_testGetFunctions, "platform_testGetFunctions", "Tests various SDL_GetXYZ functions", TEST_ENABLED}; + { (SDLTest_TestCaseFp)platform_testGetFunctions, "platform_testGetFunctions", "Tests various SDL_GetXYZ functions", TEST_ENABLED}; static const SDLTest_TestCaseReference platformTest4 = - { (SDLTest_TestCaseFp)platform_testHasFunctions, "platform_testHasFunctions", "Tests various SDL_HasXYZ functions", TEST_ENABLED}; + { (SDLTest_TestCaseFp)platform_testHasFunctions, "platform_testHasFunctions", "Tests various SDL_HasXYZ functions", TEST_ENABLED}; static const SDLTest_TestCaseReference platformTest5 = - { (SDLTest_TestCaseFp)platform_testGetVersion, "platform_testGetVersion", "Tests SDL_GetVersion function", TEST_ENABLED}; + { (SDLTest_TestCaseFp)platform_testGetVersion, "platform_testGetVersion", "Tests SDL_GetVersion function", TEST_ENABLED}; static const SDLTest_TestCaseReference platformTest6 = - { (SDLTest_TestCaseFp)platform_testSDLVersion, "platform_testSDLVersion", "Tests SDL_VERSION macro", TEST_ENABLED}; + { (SDLTest_TestCaseFp)platform_testSDLVersion, "platform_testSDLVersion", "Tests SDL_VERSION macro", TEST_ENABLED}; static const SDLTest_TestCaseReference platformTest7 = - { (SDLTest_TestCaseFp)platform_testDefaultInit, "platform_testDefaultInit", "Tests default SDL_Init", TEST_ENABLED}; + { (SDLTest_TestCaseFp)platform_testDefaultInit, "platform_testDefaultInit", "Tests default SDL_Init", TEST_ENABLED}; static const SDLTest_TestCaseReference platformTest8 = - { (SDLTest_TestCaseFp)platform_testGetSetClearError, "platform_testGetSetClearError", "Tests SDL_Get/Set/ClearError", TEST_ENABLED}; + { (SDLTest_TestCaseFp)platform_testGetSetClearError, "platform_testGetSetClearError", "Tests SDL_Get/Set/ClearError", TEST_ENABLED}; static const SDLTest_TestCaseReference platformTest9 = - { (SDLTest_TestCaseFp)platform_testSetErrorEmptyInput, "platform_testSetErrorEmptyInput", "Tests SDL_SetError with empty input", TEST_ENABLED}; + { (SDLTest_TestCaseFp)platform_testSetErrorEmptyInput, "platform_testSetErrorEmptyInput", "Tests SDL_SetError with empty input", TEST_ENABLED}; static const SDLTest_TestCaseReference platformTest10 = - { (SDLTest_TestCaseFp)platform_testSetErrorInvalidInput, "platform_testSetErrorInvalidInput", "Tests SDL_SetError with invalid input", TEST_ENABLED}; + { (SDLTest_TestCaseFp)platform_testSetErrorInvalidInput, "platform_testSetErrorInvalidInput", "Tests SDL_SetError with invalid input", TEST_ENABLED}; static const SDLTest_TestCaseReference platformTest11 = - { (SDLTest_TestCaseFp)platform_testGetPowerInfo, "platform_testGetPowerInfo", "Tests SDL_GetPowerInfo function", TEST_ENABLED }; + { (SDLTest_TestCaseFp)platform_testGetPowerInfo, "platform_testGetPowerInfo", "Tests SDL_GetPowerInfo function", TEST_ENABLED }; /* Sequence of Platform test cases */ static const SDLTest_TestCaseReference *platformTests[] = { - &platformTest1, - &platformTest2, - &platformTest3, - &platformTest4, - &platformTest5, - &platformTest6, - &platformTest7, - &platformTest8, - &platformTest9, - &platformTest10, - &platformTest11, - NULL + &platformTest1, + &platformTest2, + &platformTest3, + &platformTest4, + &platformTest5, + &platformTest6, + &platformTest7, + &platformTest8, + &platformTest9, + &platformTest10, + &platformTest11, + NULL }; /* Platform test suite (global) */ SDLTest_TestSuiteReference platformTestSuite = { - "Platform", - NULL, - platformTests, - NULL + "Platform", + NULL, + platformTests, + NULL }; diff --git a/test/testautomation_rect.c b/test/testautomation_rect.c index 333c973ed..77a7347e6 100644 --- a/test/testautomation_rect.c +++ b/test/testautomation_rect.c @@ -21,7 +21,7 @@ void _validateIntersectRectAndLineResults( int x1, int y1, int x2, int y2, int x1Ref, int y1Ref, int x2Ref, int y2Ref) { - SDLTest_AssertCheck(intersection == expectedIntersection, + SDLTest_AssertCheck(intersection == expectedIntersection, "Check for correct intersection result: expected %s, got %s intersecting rect (%d,%d,%d,%d) with line (%d,%d - %d,%d)", (expectedIntersection == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", (intersection == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", @@ -45,7 +45,7 @@ void _validateIntersectRectAndLineResults( * \sa * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRectAndLine */ -int +int rect_testIntersectRectAndLine (void *arg) { SDL_Rect refRect = { 0, 0, 32, 32 }; @@ -107,7 +107,7 @@ rect_testIntersectRectAndLine (void *arg) intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2); _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, 31, 0, 0, 31); - return TEST_COMPLETED; + return TEST_COMPLETED; } /*! @@ -116,7 +116,7 @@ rect_testIntersectRectAndLine (void *arg) * \sa * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRectAndLine */ -int +int rect_testIntersectRectAndLineInside (void *arg) { SDL_Rect refRect = { 0, 0, 32, 32 }; @@ -174,7 +174,7 @@ rect_testIntersectRectAndLineInside (void *arg) intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2); _validateIntersectRectAndLineResults(intersected, SDL_TRUE, &rect, &refRect, x1, y1, x2, y2, xmin, ymax, xmax, ymin); - return TEST_COMPLETED; + return TEST_COMPLETED; } /*! @@ -183,7 +183,7 @@ rect_testIntersectRectAndLineInside (void *arg) * \sa * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRectAndLine */ -int +int rect_testIntersectRectAndLineOutside (void *arg) { SDL_Rect refRect = { 0, 0, 32, 32 }; @@ -229,7 +229,7 @@ rect_testIntersectRectAndLineOutside (void *arg) intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2); _validateIntersectRectAndLineResults(intersected, SDL_FALSE, &rect, &refRect, x1, y1, x2, y2, 0, yBottom, 31, yBottom); - return TEST_COMPLETED; + return TEST_COMPLETED; } /*! @@ -238,7 +238,7 @@ rect_testIntersectRectAndLineOutside (void *arg) * \sa * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRectAndLine */ -int +int rect_testIntersectRectAndLineEmpty (void *arg) { SDL_Rect refRect; @@ -246,7 +246,7 @@ rect_testIntersectRectAndLineEmpty (void *arg) int x1, y1, x1Ref, y1Ref; int x2, y2, x2Ref, y2Ref; SDL_bool intersected; - + refRect.x = SDLTest_RandomIntegerInRange(1, 1024); refRect.y = SDLTest_RandomIntegerInRange(1, 1024); refRect.w = 0; @@ -264,7 +264,7 @@ rect_testIntersectRectAndLineEmpty (void *arg) intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2); _validateIntersectRectAndLineResults(intersected, SDL_FALSE, &rect, &refRect, x1, y1, x2, y2, x1Ref, y1Ref, x2Ref, y2Ref); - return TEST_COMPLETED; + return TEST_COMPLETED; } /*! @@ -273,7 +273,7 @@ rect_testIntersectRectAndLineEmpty (void *arg) * \sa * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRectAndLine */ -int +int rect_testIntersectRectAndLineParam (void *arg) { SDL_Rect rect = { 0, 0, 32, 32 }; @@ -282,10 +282,10 @@ rect_testIntersectRectAndLineParam (void *arg) int x2 = x1; int y2 = 2 * rect.h; SDL_bool intersected; - + intersected = SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2); SDLTest_AssertCheck(intersected == SDL_TRUE, "Check that intersection result was SDL_TRUE"); - + intersected = SDL_IntersectRectAndLine((SDL_Rect *)NULL, &x1, &y1, &x2, &y2); SDLTest_AssertCheck(intersected == SDL_FALSE, "Check that function returns SDL_FALSE when 1st parameter is NULL"); intersected = SDL_IntersectRectAndLine(&rect, (int *)NULL, &y1, &x2, &y2); @@ -299,21 +299,21 @@ rect_testIntersectRectAndLineParam (void *arg) intersected = SDL_IntersectRectAndLine((SDL_Rect *)NULL, (int *)NULL, (int *)NULL, (int *)NULL, (int *)NULL); SDLTest_AssertCheck(intersected == SDL_FALSE, "Check that function returns SDL_FALSE when all parameters are NULL"); - return TEST_COMPLETED; + return TEST_COMPLETED; } /*! * \brief Private helper to check SDL_HasIntersection results */ void _validateHasIntersectionResults( - SDL_bool intersection, SDL_bool expectedIntersection, + SDL_bool intersection, SDL_bool expectedIntersection, SDL_Rect *rectA, SDL_Rect *rectB, SDL_Rect *refRectA, SDL_Rect *refRectB) { - SDLTest_AssertCheck(intersection == expectedIntersection, + SDLTest_AssertCheck(intersection == expectedIntersection, "Check intersection result: expected %s, got %s intersecting A (%d,%d,%d,%d) with B (%d,%d,%d,%d)", (expectedIntersection == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", (intersection == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", - rectA->x, rectA->y, rectA->w, rectA->h, + rectA->x, rectA->y, rectA->w, rectA->h, rectB->x, rectB->y, rectB->w, rectB->h); SDLTest_AssertCheck(rectA->x == refRectA->x && rectA->y == refRectA->y && rectA->w == refRectA->w && rectA->h == refRectA->h, "Check that source rectangle A was not modified: got (%d,%d,%d,%d) expected (%d,%d,%d,%d)", @@ -329,15 +329,15 @@ void _validateHasIntersectionResults( * \brief Private helper to check SDL_IntersectRect results */ void _validateIntersectRectResults( - SDL_bool intersection, SDL_bool expectedIntersection, - SDL_Rect *rectA, SDL_Rect *rectB, SDL_Rect *refRectA, SDL_Rect *refRectB, + SDL_bool intersection, SDL_bool expectedIntersection, + SDL_Rect *rectA, SDL_Rect *rectB, SDL_Rect *refRectA, SDL_Rect *refRectB, SDL_Rect *result, SDL_Rect *expectedResult) { _validateHasIntersectionResults(intersection, expectedIntersection, rectA, rectB, refRectA, refRectB); if (result && expectedResult) { SDLTest_AssertCheck(result->x == expectedResult->x && result->y == expectedResult->y && result->w == expectedResult->w && result->h == expectedResult->h, "Check that intersection of rectangles A (%d,%d,%d,%d) and B (%d,%d,%d,%d) was correctly calculated, got (%d,%d,%d,%d) expected (%d,%d,%d,%d)", - rectA->x, rectA->y, rectA->w, rectA->h, + rectA->x, rectA->y, rectA->w, rectA->h, rectB->x, rectB->y, rectB->w, rectB->h, result->x, result->y, result->w, result->h, expectedResult->x, expectedResult->y, expectedResult->w, expectedResult->h); @@ -348,7 +348,7 @@ void _validateIntersectRectResults( * \brief Private helper to check SDL_UnionRect results */ void _validateUnionRectResults( - SDL_Rect *rectA, SDL_Rect *rectB, SDL_Rect *refRectA, SDL_Rect *refRectB, + SDL_Rect *rectA, SDL_Rect *rectB, SDL_Rect *refRectA, SDL_Rect *refRectB, SDL_Rect *result, SDL_Rect *expectedResult) { SDLTest_AssertCheck(rectA->x == refRectA->x && rectA->y == refRectA->y && rectA->w == refRectA->w && rectA->h == refRectA->h, @@ -361,7 +361,7 @@ void _validateUnionRectResults( refRectB->x, refRectB->y, refRectB->w, refRectB->h); SDLTest_AssertCheck(result->x == expectedResult->x && result->y == expectedResult->y && result->w == expectedResult->w && result->h == expectedResult->h, "Check that union of rectangles A (%d,%d,%d,%d) and B (%d,%d,%d,%d) was correctly calculated, got (%d,%d,%d,%d) expected (%d,%d,%d,%d)", - rectA->x, rectA->y, rectA->w, rectA->h, + rectA->x, rectA->y, rectA->w, rectA->h, rectB->x, rectB->y, rectB->w, rectB->h, result->x, result->y, result->w, result->h, expectedResult->x, expectedResult->y, expectedResult->w, expectedResult->h); @@ -371,10 +371,10 @@ void _validateUnionRectResults( * \brief Private helper to check SDL_RectEmpty results */ void _validateRectEmptyResults( - SDL_bool empty, SDL_bool expectedEmpty, + SDL_bool empty, SDL_bool expectedEmpty, SDL_Rect *rect, SDL_Rect *refRect) { - SDLTest_AssertCheck(empty == expectedEmpty, + SDLTest_AssertCheck(empty == expectedEmpty, "Check for correct empty result: expected %s, got %s testing (%d,%d,%d,%d)", (expectedEmpty == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", (empty == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", @@ -389,10 +389,10 @@ void _validateRectEmptyResults( * \brief Private helper to check SDL_RectEquals results */ void _validateRectEqualsResults( - SDL_bool equals, SDL_bool expectedEquals, + SDL_bool equals, SDL_bool expectedEquals, SDL_Rect *rectA, SDL_Rect *rectB, SDL_Rect *refRectA, SDL_Rect *refRectB) { - SDLTest_AssertCheck(equals == expectedEquals, + SDLTest_AssertCheck(equals == expectedEquals, "Check for correct equals result: expected %s, got %s testing (%d,%d,%d,%d) and (%d,%d,%d,%d)", (expectedEquals == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", (equals == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", @@ -433,7 +433,7 @@ int rect_testIntersectRectInside (void *arg) intersection = SDL_IntersectRect(&rectA, &rectB, &result); _validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &refRectB); - return TEST_COMPLETED; + return TEST_COMPLETED; } /*! @@ -459,9 +459,9 @@ int rect_testIntersectRectOutside (void *arg) rectA = refRectA; rectB = refRectB; intersection = SDL_IntersectRect(&rectA, &rectB, &result); - _validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL); + _validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL); - return TEST_COMPLETED; + return TEST_COMPLETED; } /*! @@ -490,7 +490,7 @@ int rect_testIntersectRectPartial (void *arg) expectedResult.x = refRectB.x; expectedResult.y = refRectB.y; expectedResult.w = refRectA.w - refRectB.x; - expectedResult.h = refRectA.h - refRectB.y; + expectedResult.h = refRectA.h - refRectB.y; intersection = SDL_IntersectRect(&rectA, &rectB, &result); _validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult); @@ -504,7 +504,7 @@ int rect_testIntersectRectPartial (void *arg) expectedResult.x = refRectB.x; expectedResult.y = refRectB.y; expectedResult.w = 1; - expectedResult.h = refRectB.h; + expectedResult.h = refRectB.h; intersection = SDL_IntersectRect(&rectA, &rectB, &result); _validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult); @@ -518,7 +518,7 @@ int rect_testIntersectRectPartial (void *arg) expectedResult.x = 0; expectedResult.y = refRectB.y; expectedResult.w = 1; - expectedResult.h = refRectB.h; + expectedResult.h = refRectB.h; intersection = SDL_IntersectRect(&rectA, &rectB, &result); _validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult); @@ -532,7 +532,7 @@ int rect_testIntersectRectPartial (void *arg) expectedResult.x = refRectB.x; expectedResult.y = refRectB.y; expectedResult.w = refRectB.w; - expectedResult.h = 1; + expectedResult.h = 1; intersection = SDL_IntersectRect(&rectA, &rectB, &result); _validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult); @@ -546,11 +546,11 @@ int rect_testIntersectRectPartial (void *arg) expectedResult.x = refRectB.x; expectedResult.y = 0; expectedResult.w = refRectB.w; - expectedResult.h = 1; + expectedResult.h = 1; intersection = SDL_IntersectRect(&rectA, &rectB, &result); _validateIntersectRectResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult); - return TEST_COMPLETED; + return TEST_COMPLETED; } /*! @@ -586,7 +586,7 @@ int rect_testIntersectRectPoint (void *arg) refRectA.x = SDLTest_RandomIntegerInRange(1, 100); refRectA.y = SDLTest_RandomIntegerInRange(1, 100); refRectB.x = refRectA.x; - refRectB.y = refRectA.y; + refRectB.y = refRectA.y; refRectB.x += offsetX; refRectB.y += offsetY; rectA = refRectA; @@ -597,7 +597,7 @@ int rect_testIntersectRectPoint (void *arg) } } - return TEST_COMPLETED; + return TEST_COMPLETED; } /*! @@ -632,7 +632,7 @@ int rect_testIntersectRectEmpty (void *arg) _validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL); empty = (SDL_bool)SDL_RectEmpty(&result); SDLTest_AssertCheck(empty == SDL_TRUE, "Validate result is empty Rect; got: %s", (empty == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE"); - + // Rect B empty result.w = SDLTest_RandomIntegerInRange(1, 100); result.h = SDLTest_RandomIntegerInRange(1, 100); @@ -687,19 +687,19 @@ int rect_testIntersectRectParam(void *arg) // invalid parameter combinations intersection = SDL_IntersectRect((SDL_Rect *)NULL, &rectB, &result); - SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 1st parameter is NULL"); + SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 1st parameter is NULL"); intersection = SDL_IntersectRect(&rectA, (SDL_Rect *)NULL, &result); - SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 2st parameter is NULL"); + SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 2st parameter is NULL"); intersection = SDL_IntersectRect(&rectA, &rectB, (SDL_Rect *)NULL); - SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 3st parameter is NULL"); + SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 3st parameter is NULL"); intersection = SDL_IntersectRect((SDL_Rect *)NULL, (SDL_Rect *)NULL, &result); - SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 1st and 2nd parameters are NULL"); + SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 1st and 2nd parameters are NULL"); intersection = SDL_IntersectRect((SDL_Rect *)NULL, &rectB, (SDL_Rect *)NULL); - SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 1st and 3rd parameters are NULL "); + SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 1st and 3rd parameters are NULL "); intersection = SDL_IntersectRect((SDL_Rect *)NULL, (SDL_Rect *)NULL, (SDL_Rect *)NULL); - SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when all parameters are NULL"); + SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when all parameters are NULL"); - return TEST_COMPLETED; + return TEST_COMPLETED; } /*! @@ -726,7 +726,7 @@ int rect_testHasIntersectionInside (void *arg) intersection = SDL_HasIntersection(&rectA, &rectB); _validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB); - return TEST_COMPLETED; + return TEST_COMPLETED; } /*! @@ -753,7 +753,7 @@ int rect_testHasIntersectionOutside (void *arg) intersection = SDL_HasIntersection(&rectA, &rectB); _validateHasIntersectionResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB); - return TEST_COMPLETED; + return TEST_COMPLETED; } /*! @@ -820,7 +820,7 @@ int rect_testHasIntersectionPartial (void *arg) intersection = SDL_HasIntersection(&rectA, &rectB); _validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB); - return TEST_COMPLETED; + return TEST_COMPLETED; } /*! @@ -855,7 +855,7 @@ int rect_testHasIntersectionPoint (void *arg) refRectA.x = SDLTest_RandomIntegerInRange(1, 100); refRectA.y = SDLTest_RandomIntegerInRange(1, 100); refRectB.x = refRectA.x; - refRectB.y = refRectA.y; + refRectB.y = refRectA.y; refRectB.x += offsetX; refRectB.y += offsetY; rectA = refRectA; @@ -866,7 +866,7 @@ int rect_testHasIntersectionPoint (void *arg) } } - return TEST_COMPLETED; + return TEST_COMPLETED; } /*! @@ -924,7 +924,7 @@ int rect_testHasIntersectionEmpty (void *arg) intersection = SDL_HasIntersection(&rectA, &rectB); _validateHasIntersectionResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB); - return TEST_COMPLETED; + return TEST_COMPLETED; } /*! @@ -941,13 +941,13 @@ int rect_testHasIntersectionParam(void *arg) // invalid parameter combinations intersection = SDL_HasIntersection((SDL_Rect *)NULL, &rectB); - SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 1st parameter is NULL"); + SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 1st parameter is NULL"); intersection = SDL_HasIntersection(&rectA, (SDL_Rect *)NULL); - SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 2st parameter is NULL"); + SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when 2st parameter is NULL"); intersection = SDL_HasIntersection((SDL_Rect *)NULL, (SDL_Rect *)NULL); - SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when all parameters are NULL"); + SDLTest_AssertCheck(intersection == SDL_FALSE, "Check that function returns SDL_FALSE when all parameters are NULL"); - return TEST_COMPLETED; + return TEST_COMPLETED; } /*! @@ -989,35 +989,35 @@ int rect_testEnclosePoints(void *arg) if (newy > maxy) maxy = newy; } } - + // Call function and validate - special case: no result requested anyEnclosedNoResult = SDL_EnclosePoints((const SDL_Point *)points, numPoints, (const SDL_Rect *)NULL, (SDL_Rect *)NULL); - SDLTest_AssertCheck(expectedEnclosed==anyEnclosedNoResult, - "Check expected return value %s, got %s", - (expectedEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", - (anyEnclosedNoResult==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE"); + SDLTest_AssertCheck(expectedEnclosed==anyEnclosedNoResult, + "Check expected return value %s, got %s", + (expectedEnclosed==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE", + (anyEnclosedNoResult==SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE"); for (i=0; irefRectB.x) ? refRectA.x : refRectB.x; miny = (refRectA.yrefRectB.y) ? refRectA.y : refRectB.y; + maxy = (refRectA.y>refRectB.y) ? refRectA.y : refRectB.y; expectedResult.x = minx; expectedResult.y = miny; expectedResult.w = maxx - minx + 1; @@ -1267,7 +1267,7 @@ int rect_testUnionRectOutside(void *arg) } /* Union outside overlap */ - for (dx = -1; dx < 2; dx++) { + for (dx = -1; dx < 2; dx++) { for (dy = -1; dy < 2; dy++) { if ((dx != 0) || (dy != 0)) { refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024); @@ -1291,7 +1291,7 @@ int rect_testUnionRectOutside(void *arg) } } - return TEST_COMPLETED; + return TEST_COMPLETED; } /*! @@ -1307,7 +1307,7 @@ int rect_testUnionRectEmpty(void *arg) SDL_Rect expectedResult; SDL_Rect result; - /* A empty */ + /* A empty */ refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024); refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024); refRectA.w=0; @@ -1321,8 +1321,8 @@ int rect_testUnionRectEmpty(void *arg) rectB = refRectB; SDL_UnionRect(&rectA, &rectB, &result); _validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult); - - /* B empty */ + + /* B empty */ refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024); refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024); refRectA.w=SDLTest_RandomIntegerInRange(1, 1024); @@ -1337,7 +1337,7 @@ int rect_testUnionRectEmpty(void *arg) SDL_UnionRect(&rectA, &rectB, &result); _validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult); - /* A and B empty */ + /* A and B empty */ refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024); refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024); refRectA.w=0; @@ -1356,7 +1356,7 @@ int rect_testUnionRectEmpty(void *arg) SDL_UnionRect(&rectA, &rectB, &result); _validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult); - return TEST_COMPLETED; + return TEST_COMPLETED; } /*! @@ -1372,7 +1372,7 @@ int rect_testUnionRectInside(void *arg) SDL_Rect expectedResult; SDL_Rect result; int dx, dy; - + /* Union 1x1 with itself */ refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024); refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024); @@ -1399,7 +1399,7 @@ int rect_testUnionRectInside(void *arg) _validateUnionRectResults(&rectA, &rectB, &refRectA, &refRectB, &result, &expectedResult); /* Union inside with edges modified */ - for (dx = -1; dx < 2; dx++) { + for (dx = -1; dx < 2; dx++) { for (dy = -1; dy < 2; dy++) { if ((dx != 0) || (dy != 0)) { refRectA.x=SDLTest_RandomIntegerInRange(-1024, 1024); @@ -1410,7 +1410,7 @@ int rect_testUnionRectInside(void *arg) if (dx == -1) refRectB.x++; if ((dx == 1) || (dx == -1)) refRectB.w--; if (dy == -1) refRectB.y++; - if ((dy == 1) || (dy == -1)) refRectB.h--; + if ((dy == 1) || (dy == -1)) refRectB.h--; expectedResult = refRectA; rectA = refRectA; rectB = refRectB; @@ -1420,7 +1420,7 @@ int rect_testUnionRectInside(void *arg) } } - return TEST_COMPLETED; + return TEST_COMPLETED; } /*! @@ -1436,19 +1436,19 @@ int rect_testUnionRectParam(void *arg) // invalid parameter combinations SDL_UnionRect((SDL_Rect *)NULL, &rectB, &result); - SDLTest_AssertPass("Check that function returns when 1st parameter is NULL"); + SDLTest_AssertPass("Check that function returns when 1st parameter is NULL"); SDL_UnionRect(&rectA, (SDL_Rect *)NULL, &result); - SDLTest_AssertPass("Check that function returns when 2nd parameter is NULL"); + SDLTest_AssertPass("Check that function returns when 2nd parameter is NULL"); SDL_UnionRect(&rectA, &rectB, (SDL_Rect *)NULL); - SDLTest_AssertPass("Check that function returns when 3rd parameter is NULL"); + SDLTest_AssertPass("Check that function returns when 3rd parameter is NULL"); SDL_UnionRect((SDL_Rect *)NULL, &rectB, (SDL_Rect *)NULL); - SDLTest_AssertPass("Check that function returns when 1st and 3rd parameter are NULL"); + SDLTest_AssertPass("Check that function returns when 1st and 3rd parameter are NULL"); SDL_UnionRect(&rectA, (SDL_Rect *)NULL, (SDL_Rect *)NULL); - SDLTest_AssertPass("Check that function returns when 2nd and 3rd parameter are NULL"); + SDLTest_AssertPass("Check that function returns when 2nd and 3rd parameter are NULL"); SDL_UnionRect((SDL_Rect *)NULL, (SDL_Rect *)NULL, (SDL_Rect *)NULL); - SDLTest_AssertPass("Check that function returns when all parameters are NULL"); + SDLTest_AssertPass("Check that function returns when all parameters are NULL"); - return TEST_COMPLETED; + return TEST_COMPLETED; } /*! @@ -1474,7 +1474,7 @@ int rect_testRectEmpty(void *arg) rect = refRect; result = (SDL_bool)SDL_RectEmpty((const SDL_Rect *)&rect); _validateRectEmptyResults(result, expectedResult, &rect, &refRect); - + // Empty case for (w=-1; w<2; w++) { for (h=-1; h<2; h++) { @@ -1491,7 +1491,7 @@ int rect_testRectEmpty(void *arg) } } - return TEST_COMPLETED; + return TEST_COMPLETED; } /*! @@ -1506,9 +1506,9 @@ int rect_testRectEmptyParam(void *arg) // invalid parameter combinations result = (SDL_bool)SDL_RectEmpty((const SDL_Rect *)NULL); - SDLTest_AssertCheck(result == SDL_TRUE, "Check that function returns TRUE when 1st parameter is NULL"); + SDLTest_AssertCheck(result == SDL_TRUE, "Check that function returns TRUE when 1st parameter is NULL"); - return TEST_COMPLETED; + return TEST_COMPLETED; } /*! @@ -1531,14 +1531,14 @@ int rect_testRectEquals(void *arg) refRectA.y=SDLTest_RandomIntegerInRange(-1024, 1024); refRectA.w=SDLTest_RandomIntegerInRange(1, 1024); refRectA.h=SDLTest_RandomIntegerInRange(1, 1024); - refRectB = refRectA; + refRectB = refRectA; expectedResult = SDL_TRUE; rectA = refRectA; rectB = refRectB; result = (SDL_bool)SDL_RectEquals((const SDL_Rect *)&rectA, (const SDL_Rect *)&rectB); _validateRectEqualsResults(result, expectedResult, &rectA, &rectB, &refRectA, &refRectB); - return TEST_COMPLETED; + return TEST_COMPLETED; } /*! @@ -1565,13 +1565,13 @@ int rect_testRectEqualsParam(void *arg) // invalid parameter combinations result = (SDL_bool)SDL_RectEquals((const SDL_Rect *)NULL, (const SDL_Rect *)&rectB); - SDLTest_AssertCheck(result == SDL_FALSE, "Check that function returns SDL_FALSE when 1st parameter is NULL"); + SDLTest_AssertCheck(result == SDL_FALSE, "Check that function returns SDL_FALSE when 1st parameter is NULL"); result = (SDL_bool)SDL_RectEquals((const SDL_Rect *)&rectA, (const SDL_Rect *)NULL); - SDLTest_AssertCheck(result == SDL_FALSE, "Check that function returns SDL_FALSE when 2nd parameter is NULL"); + SDLTest_AssertCheck(result == SDL_FALSE, "Check that function returns SDL_FALSE when 2nd parameter is NULL"); result = (SDL_bool)SDL_RectEquals((const SDL_Rect *)NULL, (const SDL_Rect *)NULL); - SDLTest_AssertCheck(result == SDL_FALSE, "Check that function returns SDL_FALSE when 1st and 2nd parameter are NULL"); + SDLTest_AssertCheck(result == SDL_FALSE, "Check that function returns SDL_FALSE when 1st and 2nd parameter are NULL"); - return TEST_COMPLETED; + return TEST_COMPLETED; } /* ================= Test References ================== */ @@ -1580,98 +1580,98 @@ int rect_testRectEqualsParam(void *arg) /* SDL_IntersectRectAndLine */ static const SDLTest_TestCaseReference rectTest1 = - { (SDLTest_TestCaseFp)rect_testIntersectRectAndLine,"rect_testIntersectRectAndLine", "Tests SDL_IntersectRectAndLine clipping cases", TEST_ENABLED }; + { (SDLTest_TestCaseFp)rect_testIntersectRectAndLine,"rect_testIntersectRectAndLine", "Tests SDL_IntersectRectAndLine clipping cases", TEST_ENABLED }; static const SDLTest_TestCaseReference rectTest2 = - { (SDLTest_TestCaseFp)rect_testIntersectRectAndLineInside, "rect_testIntersectRectAndLineInside", "Tests SDL_IntersectRectAndLine with line fully contained in rect", TEST_ENABLED }; + { (SDLTest_TestCaseFp)rect_testIntersectRectAndLineInside, "rect_testIntersectRectAndLineInside", "Tests SDL_IntersectRectAndLine with line fully contained in rect", TEST_ENABLED }; static const SDLTest_TestCaseReference rectTest3 = - { (SDLTest_TestCaseFp)rect_testIntersectRectAndLineOutside, "rect_testIntersectRectAndLineOutside", "Tests SDL_IntersectRectAndLine with line fully outside of rect", TEST_ENABLED }; + { (SDLTest_TestCaseFp)rect_testIntersectRectAndLineOutside, "rect_testIntersectRectAndLineOutside", "Tests SDL_IntersectRectAndLine with line fully outside of rect", TEST_ENABLED }; static const SDLTest_TestCaseReference rectTest4 = - { (SDLTest_TestCaseFp)rect_testIntersectRectAndLineEmpty, "rect_testIntersectRectAndLineEmpty", "Tests SDL_IntersectRectAndLine with empty rectangle ", TEST_ENABLED }; + { (SDLTest_TestCaseFp)rect_testIntersectRectAndLineEmpty, "rect_testIntersectRectAndLineEmpty", "Tests SDL_IntersectRectAndLine with empty rectangle ", TEST_ENABLED }; static const SDLTest_TestCaseReference rectTest5 = - { (SDLTest_TestCaseFp)rect_testIntersectRectAndLineParam, "rect_testIntersectRectAndLineParam", "Negative tests against SDL_IntersectRectAndLine with invalid parameters", TEST_ENABLED }; + { (SDLTest_TestCaseFp)rect_testIntersectRectAndLineParam, "rect_testIntersectRectAndLineParam", "Negative tests against SDL_IntersectRectAndLine with invalid parameters", TEST_ENABLED }; /* SDL_IntersectRect */ static const SDLTest_TestCaseReference rectTest6 = - { (SDLTest_TestCaseFp)rect_testIntersectRectInside, "rect_testIntersectRectInside", "Tests SDL_IntersectRect with B fully contained in A", TEST_ENABLED }; + { (SDLTest_TestCaseFp)rect_testIntersectRectInside, "rect_testIntersectRectInside", "Tests SDL_IntersectRect with B fully contained in A", TEST_ENABLED }; static const SDLTest_TestCaseReference rectTest7 = - { (SDLTest_TestCaseFp)rect_testIntersectRectOutside, "rect_testIntersectRectOutside", "Tests SDL_IntersectRect with B fully outside of A", TEST_ENABLED }; + { (SDLTest_TestCaseFp)rect_testIntersectRectOutside, "rect_testIntersectRectOutside", "Tests SDL_IntersectRect with B fully outside of A", TEST_ENABLED }; static const SDLTest_TestCaseReference rectTest8 = - { (SDLTest_TestCaseFp)rect_testIntersectRectPartial, "rect_testIntersectRectPartial", "Tests SDL_IntersectRect with B partially intersecting A", TEST_ENABLED }; + { (SDLTest_TestCaseFp)rect_testIntersectRectPartial, "rect_testIntersectRectPartial", "Tests SDL_IntersectRect with B partially intersecting A", TEST_ENABLED }; static const SDLTest_TestCaseReference rectTest9 = - { (SDLTest_TestCaseFp)rect_testIntersectRectPoint, "rect_testIntersectRectPoint", "Tests SDL_IntersectRect with 1x1 sized rectangles", TEST_ENABLED }; + { (SDLTest_TestCaseFp)rect_testIntersectRectPoint, "rect_testIntersectRectPoint", "Tests SDL_IntersectRect with 1x1 sized rectangles", TEST_ENABLED }; static const SDLTest_TestCaseReference rectTest10 = - { (SDLTest_TestCaseFp)rect_testIntersectRectEmpty, "rect_testIntersectRectEmpty", "Tests SDL_IntersectRect with empty rectangles", TEST_ENABLED }; + { (SDLTest_TestCaseFp)rect_testIntersectRectEmpty, "rect_testIntersectRectEmpty", "Tests SDL_IntersectRect with empty rectangles", TEST_ENABLED }; static const SDLTest_TestCaseReference rectTest11 = - { (SDLTest_TestCaseFp)rect_testIntersectRectParam, "rect_testIntersectRectParam", "Negative tests against SDL_IntersectRect with invalid parameters", TEST_ENABLED }; + { (SDLTest_TestCaseFp)rect_testIntersectRectParam, "rect_testIntersectRectParam", "Negative tests against SDL_IntersectRect with invalid parameters", TEST_ENABLED }; /* SDL_HasIntersection */ static const SDLTest_TestCaseReference rectTest12 = - { (SDLTest_TestCaseFp)rect_testHasIntersectionInside, "rect_testHasIntersectionInside", "Tests SDL_HasIntersection with B fully contained in A", TEST_ENABLED }; + { (SDLTest_TestCaseFp)rect_testHasIntersectionInside, "rect_testHasIntersectionInside", "Tests SDL_HasIntersection with B fully contained in A", TEST_ENABLED }; static const SDLTest_TestCaseReference rectTest13 = - { (SDLTest_TestCaseFp)rect_testHasIntersectionOutside, "rect_testHasIntersectionOutside", "Tests SDL_HasIntersection with B fully outside of A", TEST_ENABLED }; + { (SDLTest_TestCaseFp)rect_testHasIntersectionOutside, "rect_testHasIntersectionOutside", "Tests SDL_HasIntersection with B fully outside of A", TEST_ENABLED }; static const SDLTest_TestCaseReference rectTest14 = - { (SDLTest_TestCaseFp)rect_testHasIntersectionPartial,"rect_testHasIntersectionPartial", "Tests SDL_HasIntersection with B partially intersecting A", TEST_ENABLED }; + { (SDLTest_TestCaseFp)rect_testHasIntersectionPartial,"rect_testHasIntersectionPartial", "Tests SDL_HasIntersection with B partially intersecting A", TEST_ENABLED }; static const SDLTest_TestCaseReference rectTest15 = - { (SDLTest_TestCaseFp)rect_testHasIntersectionPoint, "rect_testHasIntersectionPoint", "Tests SDL_HasIntersection with 1x1 sized rectangles", TEST_ENABLED }; + { (SDLTest_TestCaseFp)rect_testHasIntersectionPoint, "rect_testHasIntersectionPoint", "Tests SDL_HasIntersection with 1x1 sized rectangles", TEST_ENABLED }; static const SDLTest_TestCaseReference rectTest16 = - { (SDLTest_TestCaseFp)rect_testHasIntersectionEmpty, "rect_testHasIntersectionEmpty", "Tests SDL_HasIntersection with empty rectangles", TEST_ENABLED }; + { (SDLTest_TestCaseFp)rect_testHasIntersectionEmpty, "rect_testHasIntersectionEmpty", "Tests SDL_HasIntersection with empty rectangles", TEST_ENABLED }; static const SDLTest_TestCaseReference rectTest17 = - { (SDLTest_TestCaseFp)rect_testHasIntersectionParam, "rect_testHasIntersectionParam", "Negative tests against SDL_HasIntersection with invalid parameters", TEST_ENABLED }; + { (SDLTest_TestCaseFp)rect_testHasIntersectionParam, "rect_testHasIntersectionParam", "Negative tests against SDL_HasIntersection with invalid parameters", TEST_ENABLED }; /* SDL_EnclosePoints */ static const SDLTest_TestCaseReference rectTest18 = - { (SDLTest_TestCaseFp)rect_testEnclosePoints, "rect_testEnclosePoints", "Tests SDL_EnclosePoints without clipping", TEST_ENABLED }; + { (SDLTest_TestCaseFp)rect_testEnclosePoints, "rect_testEnclosePoints", "Tests SDL_EnclosePoints without clipping", TEST_ENABLED }; static const SDLTest_TestCaseReference rectTest19 = - { (SDLTest_TestCaseFp)rect_testEnclosePointsWithClipping, "rect_testEnclosePointsWithClipping", "Tests SDL_EnclosePoints with clipping", TEST_ENABLED }; + { (SDLTest_TestCaseFp)rect_testEnclosePointsWithClipping, "rect_testEnclosePointsWithClipping", "Tests SDL_EnclosePoints with clipping", TEST_ENABLED }; static const SDLTest_TestCaseReference rectTest20 = - { (SDLTest_TestCaseFp)rect_testEnclosePointsRepeatedInput, "rect_testEnclosePointsRepeatedInput", "Tests SDL_EnclosePoints with repeated input", TEST_ENABLED }; + { (SDLTest_TestCaseFp)rect_testEnclosePointsRepeatedInput, "rect_testEnclosePointsRepeatedInput", "Tests SDL_EnclosePoints with repeated input", TEST_ENABLED }; static const SDLTest_TestCaseReference rectTest21 = - { (SDLTest_TestCaseFp)rect_testEnclosePointsParam, "rect_testEnclosePointsParam", "Negative tests against SDL_EnclosePoints with invalid parameters", TEST_ENABLED }; + { (SDLTest_TestCaseFp)rect_testEnclosePointsParam, "rect_testEnclosePointsParam", "Negative tests against SDL_EnclosePoints with invalid parameters", TEST_ENABLED }; /* SDL_UnionRect */ static const SDLTest_TestCaseReference rectTest22 = - { (SDLTest_TestCaseFp)rect_testUnionRectInside, "rect_testUnionRectInside", "Tests SDL_UnionRect where rect B is inside rect A", TEST_ENABLED }; + { (SDLTest_TestCaseFp)rect_testUnionRectInside, "rect_testUnionRectInside", "Tests SDL_UnionRect where rect B is inside rect A", TEST_ENABLED }; static const SDLTest_TestCaseReference rectTest23 = - { (SDLTest_TestCaseFp)rect_testUnionRectOutside, "rect_testUnionRectOutside", "Tests SDL_UnionRect where rect B is outside rect A", TEST_ENABLED }; + { (SDLTest_TestCaseFp)rect_testUnionRectOutside, "rect_testUnionRectOutside", "Tests SDL_UnionRect where rect B is outside rect A", TEST_ENABLED }; static const SDLTest_TestCaseReference rectTest24 = - { (SDLTest_TestCaseFp)rect_testUnionRectEmpty, "rect_testUnionRectEmpty", "Tests SDL_UnionRect where rect A or rect B are empty", TEST_ENABLED }; + { (SDLTest_TestCaseFp)rect_testUnionRectEmpty, "rect_testUnionRectEmpty", "Tests SDL_UnionRect where rect A or rect B are empty", TEST_ENABLED }; static const SDLTest_TestCaseReference rectTest25 = - { (SDLTest_TestCaseFp)rect_testUnionRectParam, "rect_testUnionRectParam", "Negative tests against SDL_UnionRect with invalid parameters", TEST_ENABLED }; + { (SDLTest_TestCaseFp)rect_testUnionRectParam, "rect_testUnionRectParam", "Negative tests against SDL_UnionRect with invalid parameters", TEST_ENABLED }; /* SDL_RectEmpty */ static const SDLTest_TestCaseReference rectTest26 = - { (SDLTest_TestCaseFp)rect_testRectEmpty, "rect_testRectEmpty", "Tests SDL_RectEmpty with various inputs", TEST_ENABLED }; + { (SDLTest_TestCaseFp)rect_testRectEmpty, "rect_testRectEmpty", "Tests SDL_RectEmpty with various inputs", TEST_ENABLED }; static const SDLTest_TestCaseReference rectTest27 = - { (SDLTest_TestCaseFp)rect_testRectEmptyParam, "rect_testRectEmptyParam", "Negative tests against SDL_RectEmpty with invalid parameters", TEST_ENABLED }; + { (SDLTest_TestCaseFp)rect_testRectEmptyParam, "rect_testRectEmptyParam", "Negative tests against SDL_RectEmpty with invalid parameters", TEST_ENABLED }; /* SDL_RectEquals */ static const SDLTest_TestCaseReference rectTest28 = - { (SDLTest_TestCaseFp)rect_testRectEquals, "rect_testRectEquals", "Tests SDL_RectEquals with various inputs", TEST_ENABLED }; + { (SDLTest_TestCaseFp)rect_testRectEquals, "rect_testRectEquals", "Tests SDL_RectEquals with various inputs", TEST_ENABLED }; static const SDLTest_TestCaseReference rectTest29 = - { (SDLTest_TestCaseFp)rect_testRectEqualsParam, "rect_testRectEqualsParam", "Negative tests against SDL_RectEquals with invalid parameters", TEST_ENABLED }; + { (SDLTest_TestCaseFp)rect_testRectEqualsParam, "rect_testRectEqualsParam", "Negative tests against SDL_RectEquals with invalid parameters", TEST_ENABLED }; /*! @@ -1681,16 +1681,16 @@ static const SDLTest_TestCaseReference rectTest29 = * http://wiki.libsdl.org/moin.cgi/CategoryRect */ static const SDLTest_TestCaseReference *rectTests[] = { - &rectTest1, &rectTest2, &rectTest3, &rectTest4, &rectTest5, &rectTest6, &rectTest7, &rectTest8, &rectTest9, &rectTest10, &rectTest11, &rectTest12, &rectTest13, &rectTest14, - &rectTest15, &rectTest16, &rectTest17, &rectTest18, &rectTest19, &rectTest20, &rectTest21, &rectTest22, &rectTest23, &rectTest24, &rectTest25, &rectTest26, &rectTest27, - &rectTest28, &rectTest29, NULL + &rectTest1, &rectTest2, &rectTest3, &rectTest4, &rectTest5, &rectTest6, &rectTest7, &rectTest8, &rectTest9, &rectTest10, &rectTest11, &rectTest12, &rectTest13, &rectTest14, + &rectTest15, &rectTest16, &rectTest17, &rectTest18, &rectTest19, &rectTest20, &rectTest21, &rectTest22, &rectTest23, &rectTest24, &rectTest25, &rectTest26, &rectTest27, + &rectTest28, &rectTest29, NULL }; /* Rect test suite (global) */ SDLTest_TestSuiteReference rectTestSuite = { - "Rect", - NULL, - rectTests, - NULL + "Rect", + NULL, + rectTests, + NULL }; diff --git a/test/testautomation_render.c b/test/testautomation_render.c index 48350e74b..d582cb07c 100644 --- a/test/testautomation_render.c +++ b/test/testautomation_render.c @@ -19,8 +19,8 @@ #define RENDER_COMPARE_GMASK 0x0000ff00 /**< Green bit mask. */ #define RENDER_COMPARE_BMASK 0x000000ff /**< Blue bit mask. */ -#define ALLOWABLE_ERROR_OPAQUE 0 -#define ALLOWABLE_ERROR_BLENDED 64 +#define ALLOWABLE_ERROR_OPAQUE 0 +#define ALLOWABLE_ERROR_BLENDED 64 /* Test window and renderer */ SDL_Window *window = NULL; @@ -50,7 +50,7 @@ void InitCreateRenderer(void *arg) if (window == NULL) { return; } - + renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED); SDLTest_AssertPass("SDL_CreateRenderer()"); SDLTest_AssertCheck(renderer != 0, "Check SDL_CreateRenderer result"); @@ -61,17 +61,17 @@ void InitCreateRenderer(void *arg) } /* - * Destroy renderer for tests + * Destroy renderer for tests */ void CleanupDestroyRenderer(void *arg) { - if (renderer != NULL) { + if (renderer != NULL) { SDL_DestroyRenderer(renderer); renderer = NULL; SDLTest_AssertPass("SDL_DestroyRenderer()"); } - - if (window != NULL) { + + if (window != NULL) { SDL_DestroyWindow(window); window = NULL; SDLTest_AssertPass("SDL_DestroyWindow"); @@ -288,7 +288,7 @@ int render_testPrimitivesBlend (void *arg) SDLTest_AssertCheck(checkFailCount1 == 0, "Validate results from calls to SDL_SetRenderDrawColor, expected: 0, got: %i", checkFailCount1); SDLTest_AssertCheck(checkFailCount2 == 0, "Validate results from calls to SDL_SetRenderDrawBlendMode, expected: 0, got: %i", checkFailCount2); SDLTest_AssertCheck(checkFailCount3 == 0, "Validate results from calls to SDL_RenderDrawLine, expected: 0, got: %i", checkFailCount3); - + checkFailCount1 = 0; checkFailCount2 = 0; checkFailCount3 = 0; @@ -323,7 +323,7 @@ int render_testPrimitivesBlend (void *arg) ret = SDL_RenderDrawPoint(renderer, i, j ); if (ret != 0) checkFailCount3++; } - } + } SDLTest_AssertCheck(checkFailCount1 == 0, "Validate results from calls to SDL_SetRenderDrawColor, expected: 0, got: %i", checkFailCount1); SDLTest_AssertCheck(checkFailCount2 == 0, "Validate results from calls to SDL_SetRenderDrawBlendMode, expected: 0, got: %i", checkFailCount2); SDLTest_AssertCheck(checkFailCount3 == 0, "Validate results from calls to SDL_RenderDrawPoint, expected: 0, got: %i", checkFailCount3); @@ -533,7 +533,7 @@ render_testBlitAlpha (void *arg) ret = SDL_RenderCopy(renderer, tface, NULL, &rect ); if (ret != 0) checkFailCount2++; } - } + } SDLTest_AssertCheck(checkFailCount1 == 0, "Validate results from calls to SDL_SetTextureAlphaMod, expected: 0, got: %i", checkFailCount1); SDLTest_AssertCheck(checkFailCount2 == 0, "Validate results from calls to SDL_RenderCopy, expected: 0, got: %i", checkFailCount2); @@ -654,12 +654,12 @@ render_testBlitBlend (void *arg) /* Test None. */ _testBlitBlendMode( tface, SDL_BLENDMODE_NONE ); referenceSurface = SDLTest_ImageBlitBlendNone(); - _compare(referenceSurface, ALLOWABLE_ERROR_OPAQUE ); + _compare(referenceSurface, ALLOWABLE_ERROR_OPAQUE ); if (referenceSurface != NULL) { SDL_FreeSurface(referenceSurface); referenceSurface = NULL; } - + /* Test Blend. */ _testBlitBlendMode( tface, SDL_BLENDMODE_BLEND ); referenceSurface = SDLTest_ImageBlitBlend(); @@ -773,7 +773,7 @@ _hasDrawColor (void) ret = SDL_GetRenderDrawColor(renderer, &r, &g, &b, &a ); if (!_isSupported(ret)) fail = 1; - + /* Restore natural. */ ret = SDL_SetRenderDrawColor(renderer, 0, 0, 0, SDL_ALPHA_OPAQUE ); if (!_isSupported(ret)) @@ -782,7 +782,7 @@ _hasDrawColor (void) /* Something failed, consider not available. */ if (fail) return 0; - + /* Not set properly, consider failed. */ else if ((r != 100) || (g != 100) || (b != 100) || (a != 100)) return 0; @@ -862,7 +862,7 @@ _loadTestFace(void) if (face == NULL) { return NULL; } - + tface = SDL_CreateTextureFromSurface(renderer, face); if (tface == NULL) { SDLTest_LogError("SDL_CreateTextureFromSurface() failed with error: %s", SDL_GetError()); @@ -996,7 +996,7 @@ _compare(SDL_Surface *referenceSurface, int allowable_error) /* Clean up. */ if (pixels != NULL) { - SDL_free(pixels); + SDL_free(pixels); } if (testSurface != NULL) { SDL_FreeSurface(testSurface); @@ -1038,38 +1038,38 @@ _clearScreen(void) /* Render test cases */ static const SDLTest_TestCaseReference renderTest1 = - { (SDLTest_TestCaseFp)render_testGetNumRenderDrivers, "render_testGetNumRenderDrivers", "Tests call to SDL_GetNumRenderDrivers", TEST_ENABLED }; + { (SDLTest_TestCaseFp)render_testGetNumRenderDrivers, "render_testGetNumRenderDrivers", "Tests call to SDL_GetNumRenderDrivers", TEST_ENABLED }; static const SDLTest_TestCaseReference renderTest2 = - { (SDLTest_TestCaseFp)render_testPrimitives, "render_testPrimitives", "Tests rendering primitives", TEST_ENABLED }; + { (SDLTest_TestCaseFp)render_testPrimitives, "render_testPrimitives", "Tests rendering primitives", TEST_ENABLED }; /* TODO: rewrite test case, define new test data and re-enable; current implementation fails */ static const SDLTest_TestCaseReference renderTest3 = - { (SDLTest_TestCaseFp)render_testPrimitivesBlend, "render_testPrimitivesBlend", "Tests rendering primitives with blending", TEST_DISABLED }; + { (SDLTest_TestCaseFp)render_testPrimitivesBlend, "render_testPrimitivesBlend", "Tests rendering primitives with blending", TEST_DISABLED }; static const SDLTest_TestCaseReference renderTest4 = - { (SDLTest_TestCaseFp)render_testBlit, "render_testBlit", "Tests blitting", TEST_ENABLED }; + { (SDLTest_TestCaseFp)render_testBlit, "render_testBlit", "Tests blitting", TEST_ENABLED }; static const SDLTest_TestCaseReference renderTest5 = - { (SDLTest_TestCaseFp)render_testBlitColor, "render_testBlitColor", "Tests blitting with color", TEST_ENABLED }; + { (SDLTest_TestCaseFp)render_testBlitColor, "render_testBlitColor", "Tests blitting with color", TEST_ENABLED }; /* TODO: rewrite test case, define new test data and re-enable; current implementation fails */ static const SDLTest_TestCaseReference renderTest6 = - { (SDLTest_TestCaseFp)render_testBlitAlpha, "render_testBlitAlpha", "Tests blitting with alpha", TEST_DISABLED }; + { (SDLTest_TestCaseFp)render_testBlitAlpha, "render_testBlitAlpha", "Tests blitting with alpha", TEST_DISABLED }; /* TODO: rewrite test case, define new test data and re-enable; current implementation fails */ static const SDLTest_TestCaseReference renderTest7 = - { (SDLTest_TestCaseFp)render_testBlitBlend, "render_testBlitBlend", "Tests blitting with blending", TEST_DISABLED }; + { (SDLTest_TestCaseFp)render_testBlitBlend, "render_testBlitBlend", "Tests blitting with blending", TEST_DISABLED }; /* Sequence of Render test cases */ static const SDLTest_TestCaseReference *renderTests[] = { - &renderTest1, &renderTest2, &renderTest3, &renderTest4, &renderTest5, &renderTest6, &renderTest7, NULL + &renderTest1, &renderTest2, &renderTest3, &renderTest4, &renderTest5, &renderTest6, &renderTest7, NULL }; /* Render test suite (global) */ SDLTest_TestSuiteReference renderTestSuite = { - "Render", - InitCreateRenderer, - renderTests, - CleanupDestroyRenderer + "Render", + InitCreateRenderer, + renderTests, + CleanupDestroyRenderer }; diff --git a/test/testautomation_rwops.c b/test/testautomation_rwops.c index be93809db..f536d8b8b 100644 --- a/test/testautomation_rwops.c +++ b/test/testautomation_rwops.c @@ -32,56 +32,56 @@ static const char RWopsAlphabetString[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; void RWopsSetUp(void *arg) { - int fileLen; - FILE *handle; - int writtenLen; - int result; - - /* Clean up from previous runs (if any); ignore errors */ - remove(RWopsReadTestFilename); - remove(RWopsWriteTestFilename); - remove(RWopsAlphabetFilename); - - /* Create a test file */ - handle = fopen(RWopsReadTestFilename, "w"); - SDLTest_AssertCheck(handle != NULL, "Verify creation of file '%s' returned non NULL handle", RWopsReadTestFilename); + int fileLen; + FILE *handle; + int writtenLen; + int result; + + /* Clean up from previous runs (if any); ignore errors */ + remove(RWopsReadTestFilename); + remove(RWopsWriteTestFilename); + remove(RWopsAlphabetFilename); + + /* Create a test file */ + handle = fopen(RWopsReadTestFilename, "w"); + SDLTest_AssertCheck(handle != NULL, "Verify creation of file '%s' returned non NULL handle", RWopsReadTestFilename); if (handle == NULL) return; - /* Write some known text into it */ - fileLen = SDL_strlen(RWopsHelloWorldTestString); - writtenLen = (int)fwrite(RWopsHelloWorldTestString, 1, fileLen, handle); - SDLTest_AssertCheck(fileLen == writtenLen, "Verify number of written bytes, expected %i, got %i", fileLen, writtenLen); - result = fclose(handle); - SDLTest_AssertCheck(result == 0, "Verify result from fclose, expected 0, got %i", result); + /* Write some known text into it */ + fileLen = SDL_strlen(RWopsHelloWorldTestString); + writtenLen = (int)fwrite(RWopsHelloWorldTestString, 1, fileLen, handle); + SDLTest_AssertCheck(fileLen == writtenLen, "Verify number of written bytes, expected %i, got %i", fileLen, writtenLen); + result = fclose(handle); + SDLTest_AssertCheck(result == 0, "Verify result from fclose, expected 0, got %i", result); - /* Create a second test file */ - handle = fopen(RWopsAlphabetFilename, "w"); - SDLTest_AssertCheck(handle != NULL, "Verify creation of file '%s' returned non NULL handle", RWopsAlphabetFilename); + /* Create a second test file */ + handle = fopen(RWopsAlphabetFilename, "w"); + SDLTest_AssertCheck(handle != NULL, "Verify creation of file '%s' returned non NULL handle", RWopsAlphabetFilename); if (handle == NULL) return; - /* Write alphabet text into it */ - fileLen = SDL_strlen(RWopsAlphabetString); - writtenLen = (int)fwrite(RWopsAlphabetString, 1, fileLen, handle); - SDLTest_AssertCheck(fileLen == writtenLen, "Verify number of written bytes, expected %i, got %i", fileLen, writtenLen); - result = fclose(handle); - SDLTest_AssertCheck(result == 0, "Verify result from fclose, expected 0, got %i", result); + /* Write alphabet text into it */ + fileLen = SDL_strlen(RWopsAlphabetString); + writtenLen = (int)fwrite(RWopsAlphabetString, 1, fileLen, handle); + SDLTest_AssertCheck(fileLen == writtenLen, "Verify number of written bytes, expected %i, got %i", fileLen, writtenLen); + result = fclose(handle); + SDLTest_AssertCheck(result == 0, "Verify result from fclose, expected 0, got %i", result); - SDLTest_AssertPass("Creation of test file completed"); + SDLTest_AssertPass("Creation of test file completed"); } void RWopsTearDown(void *arg) { - int result; - - /* Remove the created files to clean up; ignore errors for write filename */ - result = remove(RWopsReadTestFilename); - SDLTest_AssertCheck(result == 0, "Verify result from remove(%s), expected 0, got %i", RWopsReadTestFilename, result); - remove(RWopsWriteTestFilename); - result = remove(RWopsAlphabetFilename); - SDLTest_AssertCheck(result == 0, "Verify result from remove(%s), expected 0, got %i", RWopsAlphabetFilename, result); - - SDLTest_AssertPass("Cleanup of test files completed"); + int result; + + /* Remove the created files to clean up; ignore errors for write filename */ + result = remove(RWopsReadTestFilename); + SDLTest_AssertCheck(result == 0, "Verify result from remove(%s), expected 0, got %i", RWopsReadTestFilename, result); + remove(RWopsWriteTestFilename); + result = remove(RWopsAlphabetFilename); + SDLTest_AssertCheck(result == 0, "Verify result from remove(%s), expected 0, got %i", RWopsAlphabetFilename, result); + + SDLTest_AssertPass("Cleanup of test files completed"); } /** @@ -91,7 +91,7 @@ RWopsTearDown(void *arg) * http://wiki.libsdl.org/moin.cgi/SDL_RWseek * http://wiki.libsdl.org/moin.cgi/SDL_RWread */ -void +void _testGenericRWopsValidations(SDL_RWops *rw, int write) { char buf[sizeof(RWopsHelloWorldTestString)]; @@ -111,10 +111,10 @@ _testGenericRWopsValidations(SDL_RWops *rw, int write) s = SDL_RWwrite(rw, RWopsHelloWorldTestString, sizeof(RWopsHelloWorldTestString)-1, 1); SDLTest_AssertPass("Call to SDL_RWwrite succeeded"); if (write) { - SDLTest_AssertCheck(s == (size_t)1, "Verify result of writing one byte with SDL_RWwrite, expected 1, got %i", s); + SDLTest_AssertCheck(s == (size_t)1, "Verify result of writing one byte with SDL_RWwrite, expected 1, got %i", s); } else { - SDLTest_AssertCheck(s == (size_t)0, "Verify result of writing with SDL_RWwrite, expected: 0, got %i", s); + SDLTest_AssertCheck(s == (size_t)0, "Verify result of writing with SDL_RWwrite, expected: 0, got %i", s); } /* Test seek to random position */ @@ -131,38 +131,38 @@ _testGenericRWopsValidations(SDL_RWops *rw, int write) s = SDL_RWread( rw, buf, 1, sizeof(RWopsHelloWorldTestString)-1 ); SDLTest_AssertPass("Call to SDL_RWread succeeded"); SDLTest_AssertCheck( - s == (size_t)(sizeof(RWopsHelloWorldTestString)-1), - "Verify result from SDL_RWread, expected %i, got %i", - sizeof(RWopsHelloWorldTestString)-1, - s); + s == (size_t)(sizeof(RWopsHelloWorldTestString)-1), + "Verify result from SDL_RWread, expected %i, got %i", + sizeof(RWopsHelloWorldTestString)-1, + s); SDLTest_AssertCheck( - SDL_memcmp(buf, RWopsHelloWorldTestString, sizeof(RWopsHelloWorldTestString)-1 ) == 0, - "Verify read bytes match expected string, expected '%s', got '%s'", RWopsHelloWorldTestString, buf); + SDL_memcmp(buf, RWopsHelloWorldTestString, sizeof(RWopsHelloWorldTestString)-1 ) == 0, + "Verify read bytes match expected string, expected '%s', got '%s'", RWopsHelloWorldTestString, buf); /* More seek tests. */ i = SDL_RWseek( rw, -4, RW_SEEK_CUR ); SDLTest_AssertPass("Call to SDL_RWseek(...,-4,RW_SEEK_CUR) succeeded"); SDLTest_AssertCheck( - i == (Sint64)(sizeof(RWopsHelloWorldTestString)-5), - "Verify seek to -4 with SDL_RWseek (RW_SEEK_CUR), expected %i, got %i", - sizeof(RWopsHelloWorldTestString)-5, - i); + i == (Sint64)(sizeof(RWopsHelloWorldTestString)-5), + "Verify seek to -4 with SDL_RWseek (RW_SEEK_CUR), expected %i, got %i", + sizeof(RWopsHelloWorldTestString)-5, + i); i = SDL_RWseek( rw, -1, RW_SEEK_END ); SDLTest_AssertPass("Call to SDL_RWseek(...,-1,RW_SEEK_END) succeeded"); SDLTest_AssertCheck( - i == (Sint64)(sizeof(RWopsHelloWorldTestString)-2), - "Verify seek to -1 with SDL_RWseek (RW_SEEK_END), expected %i, got %i", - sizeof(RWopsHelloWorldTestString)-2, - i); - + i == (Sint64)(sizeof(RWopsHelloWorldTestString)-2), + "Verify seek to -1 with SDL_RWseek (RW_SEEK_END), expected %i, got %i", + sizeof(RWopsHelloWorldTestString)-2, + i); + /* Invalid whence seek */ i = SDL_RWseek( rw, 0, 999 ); SDLTest_AssertPass("Call to SDL_RWseek(...,0,invalid_whence) succeeded"); SDLTest_AssertCheck( - i == (Sint64)(-1), - "Verify seek with SDL_RWseek (invalid_whence); expected: -1, got %i", - i); + i == (Sint64)(-1), + "Verify seek with SDL_RWseek (invalid_whence); expected: -1, got %i", + i); } /*! @@ -258,7 +258,7 @@ rwops_testMem (void) * http://wiki.libsdl.org/moin.cgi/SDL_RWFromConstMem * http://wiki.libsdl.org/moin.cgi/SDL_RWClose */ -int +int rwops_testConstMem (void) { SDL_RWops *rw; @@ -311,15 +311,15 @@ rwops_testFileRead(void) /* Check type */ #if defined(ANDROID) SDLTest_AssertCheck( - rw->type == SDL_RWOPS_STDFILE || rw->type == SDL_RWOPS_JNIFILE, + rw->type == SDL_RWOPS_STDFILE || rw->type == SDL_RWOPS_JNIFILE, "Verify RWops type is SDL_RWOPS_STDFILE or SDL_RWOPS_JNIFILE; expected: %d|%d, got: %d", SDL_RWOPS_STDFILE, SDL_RWOPS_JNIFILE, rw->type); #elif defined(__WIN32__) SDLTest_AssertCheck( - rw->type == SDL_RWOPS_WINFILE, + rw->type == SDL_RWOPS_WINFILE, "Verify RWops type is SDL_RWOPS_WINFILE; expected: %d, got: %d", SDL_RWOPS_WINFILE, rw->type); #else SDLTest_AssertCheck( - rw->type == SDL_RWOPS_STDFILE, + rw->type == SDL_RWOPS_STDFILE, "Verify RWops type is SDL_RWOPS_STDFILE; expected: %d, got: %d", SDL_RWOPS_STDFILE, rw->type); #endif @@ -358,15 +358,15 @@ rwops_testFileWrite(void) /* Check type */ #if defined(ANDROID) SDLTest_AssertCheck( - rw->type == SDL_RWOPS_STDFILE || rw->type == SDL_RWOPS_JNIFILE, + rw->type == SDL_RWOPS_STDFILE || rw->type == SDL_RWOPS_JNIFILE, "Verify RWops type is SDL_RWOPS_STDFILE or SDL_RWOPS_JNIFILE; expected: %d|%d, got: %d", SDL_RWOPS_STDFILE, SDL_RWOPS_JNIFILE, rw->type); #elif defined(__WIN32__) SDLTest_AssertCheck( - rw->type == SDL_RWOPS_WINFILE, + rw->type == SDL_RWOPS_WINFILE, "Verify RWops type is SDL_RWOPS_WINFILE; expected: %d, got: %d", SDL_RWOPS_WINFILE, rw->type); #else SDLTest_AssertCheck( - rw->type == SDL_RWOPS_STDFILE, + rw->type == SDL_RWOPS_STDFILE, "Verify RWops type is SDL_RWOPS_STDFILE; expected: %d, got: %d", SDL_RWOPS_STDFILE, rw->type); #endif @@ -417,7 +417,7 @@ rwops_testFPRead(void) /* Check type */ SDLTest_AssertCheck( - rw->type == SDL_RWOPS_STDFILE, + rw->type == SDL_RWOPS_STDFILE, "Verify RWops type is SDL_RWOPS_STDFILE; expected: %d, got: %d", SDL_RWOPS_STDFILE, rw->type); /* Run generic tests */ @@ -467,7 +467,7 @@ rwops_testFPWrite(void) /* Check type */ SDLTest_AssertCheck( - rw->type == SDL_RWOPS_STDFILE, + rw->type == SDL_RWOPS_STDFILE, "Verify RWops type is SDL_RWOPS_STDFILE; expected: %d, got: %d", SDL_RWOPS_STDFILE, rw->type); /* Run generic tests */ @@ -498,9 +498,9 @@ rwops_testAllocFree (void) /* Check type */ SDLTest_AssertCheck( - rw->type == SDL_RWOPS_UNKNOWN, + rw->type == SDL_RWOPS_UNKNOWN, "Verify RWops type is SDL_RWOPS_UNKNOWN; expected: %d, got: %d", SDL_RWOPS_UNKNOWN, rw->type); - + /* Free context again */ SDL_FreeRW(rw); SDLTest_AssertPass("Call to SDL_FreeRW() succeeded"); @@ -529,13 +529,13 @@ rwops_testCompareRWFromMemWithRWFromFile(void) int size; int result; - + for (size=5; size<10; size++) { /* Terminate buffer */ buffer_file[slen] = 0; buffer_mem[slen] = 0; - + /* Read/seek from memory */ rwops_mem = SDL_RWFromMem((void *)RWopsAlphabetString, slen); SDLTest_AssertPass("Call to SDL_RWFromMem()"); @@ -557,7 +557,7 @@ rwops_testCompareRWFromMemWithRWFromFile(void) result = SDL_RWclose(rwops_file); SDLTest_AssertPass("Call to SDL_RWclose(file)"); SDLTest_AssertCheck(result == 0, "Verify result value is 0; got: %d", result); - + /* Compare */ SDLTest_AssertCheck(rv_mem == rv_file, "Verify returned read blocks matches for mem and file reads; got: rv_mem=%d rv_file=%d", rv_mem, rv_file); SDLTest_AssertCheck(sv_mem == sv_file, "Verify SEEK_END position matches for mem and file seeks; got: sv_mem=%llu sv_file=%llu", sv_mem, sv_file); @@ -570,7 +570,7 @@ rwops_testCompareRWFromMemWithRWFromFile(void) SDL_strncmp(buffer_file, RWopsAlphabetString, slen) == 0, "Verify file buffer contain alphabet string; expected: %s, got: %s", RWopsAlphabetString, buffer_file); } - + return TEST_COMPLETED; } @@ -605,7 +605,7 @@ rwops_testFileWriteReadEndian(void) int cresult; for (mode = 0; mode < 3; mode++) { - + /* Create test data */ switch (mode) { case 0: @@ -636,7 +636,7 @@ rwops_testFileWriteReadEndian(void) LE64value = SDLTest_RandomUint64(); break; } - + /* Write test. */ rw = SDL_RWFromFile(RWopsWriteTestFilename, "w+"); SDLTest_AssertPass("Call to SDL_RWFromFile(..,\"w+\")"); @@ -648,22 +648,22 @@ rwops_testFileWriteReadEndian(void) /* Write test data */ objectsWritten = SDL_WriteBE16(rw, BE16value); SDLTest_AssertPass("Call to SDL_WriteBE16"); - SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", objectsWritten); + SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", objectsWritten); objectsWritten = SDL_WriteBE32(rw, BE32value); SDLTest_AssertPass("Call to SDL_WriteBE32"); - SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", objectsWritten); + SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", objectsWritten); objectsWritten = SDL_WriteBE64(rw, BE64value); SDLTest_AssertPass("Call to SDL_WriteBE64"); - SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", objectsWritten); + SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", objectsWritten); objectsWritten = SDL_WriteLE16(rw, LE16value); SDLTest_AssertPass("Call to SDL_WriteLE16"); - SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", objectsWritten); + SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", objectsWritten); objectsWritten = SDL_WriteLE32(rw, LE32value); SDLTest_AssertPass("Call to SDL_WriteLE32"); - SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", objectsWritten); + SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", objectsWritten); objectsWritten = SDL_WriteLE64(rw, LE64value); SDLTest_AssertPass("Call to SDL_WriteLE64"); - SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", objectsWritten); + SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", objectsWritten); /* Test seek to start */ result = SDL_RWseek( rw, 0, RW_SEEK_SET ); @@ -676,16 +676,16 @@ rwops_testFileWriteReadEndian(void) SDLTest_AssertCheck(BE16test == BE16value, "Validate return value from SDL_ReadBE16, expected: %hu, got: %hu", BE16value, BE16test); BE32test = SDL_ReadBE32(rw); SDLTest_AssertPass("Call to SDL_ReadBE32"); - SDLTest_AssertCheck(BE32test == BE32value, "Validate return value from SDL_ReadBE32, expected: %u, got: %u", BE32value, BE32test); + SDLTest_AssertCheck(BE32test == BE32value, "Validate return value from SDL_ReadBE32, expected: %u, got: %u", BE32value, BE32test); BE64test = SDL_ReadBE64(rw); SDLTest_AssertPass("Call to SDL_ReadBE64"); - SDLTest_AssertCheck(BE64test == BE64value, "Validate return value from SDL_ReadBE64, expected: %llu, got: %llu", BE64value, BE64test); + SDLTest_AssertCheck(BE64test == BE64value, "Validate return value from SDL_ReadBE64, expected: %llu, got: %llu", BE64value, BE64test); LE16test = SDL_ReadLE16(rw); SDLTest_AssertPass("Call to SDL_ReadLE16"); SDLTest_AssertCheck(LE16test == LE16value, "Validate return value from SDL_ReadLE16, expected: %hu, got: %hu", LE16value, LE16test); LE32test = SDL_ReadLE32(rw); SDLTest_AssertPass("Call to SDL_ReadLE32"); - SDLTest_AssertCheck(LE32test == LE32value, "Validate return value from SDL_ReadLE32, expected: %u, got: %u", LE32value, LE32test); + SDLTest_AssertCheck(LE32test == LE32value, "Validate return value from SDL_ReadLE32, expected: %u, got: %u", LE32value, LE32test); LE64test = SDL_ReadLE64(rw); SDLTest_AssertPass("Call to SDL_ReadLE64"); SDLTest_AssertCheck(LE64test == LE64value, "Validate return value from SDL_ReadLE64, expected: %llu, got: %llu", LE64value, LE64test); @@ -693,7 +693,7 @@ rwops_testFileWriteReadEndian(void) /* Close handle */ cresult = SDL_RWclose(rw); SDLTest_AssertPass("Call to SDL_RWclose() succeeded"); - SDLTest_AssertCheck(cresult == 0, "Verify result value is 0; got: %d", cresult); + SDLTest_AssertCheck(cresult == 0, "Verify result value is 0; got: %d", cresult); } return TEST_COMPLETED; @@ -704,45 +704,45 @@ rwops_testFileWriteReadEndian(void) /* RWops test cases */ static const SDLTest_TestCaseReference rwopsTest1 = - { (SDLTest_TestCaseFp)rwops_testParamNegative, "rwops_testParamNegative", "Negative test for SDL_RWFromFile parameters", TEST_ENABLED }; + { (SDLTest_TestCaseFp)rwops_testParamNegative, "rwops_testParamNegative", "Negative test for SDL_RWFromFile parameters", TEST_ENABLED }; static const SDLTest_TestCaseReference rwopsTest2 = - { (SDLTest_TestCaseFp)rwops_testMem, "rwops_testMem", "Tests opening from memory", TEST_ENABLED }; + { (SDLTest_TestCaseFp)rwops_testMem, "rwops_testMem", "Tests opening from memory", TEST_ENABLED }; static const SDLTest_TestCaseReference rwopsTest3 = - { (SDLTest_TestCaseFp)rwops_testConstMem, "rwops_testConstMem", "Tests opening from (const) memory", TEST_ENABLED }; + { (SDLTest_TestCaseFp)rwops_testConstMem, "rwops_testConstMem", "Tests opening from (const) memory", TEST_ENABLED }; static const SDLTest_TestCaseReference rwopsTest4 = - { (SDLTest_TestCaseFp)rwops_testFileRead, "rwops_testFileRead", "Tests reading from a file", TEST_ENABLED }; + { (SDLTest_TestCaseFp)rwops_testFileRead, "rwops_testFileRead", "Tests reading from a file", TEST_ENABLED }; static const SDLTest_TestCaseReference rwopsTest5 = - { (SDLTest_TestCaseFp)rwops_testFileWrite, "rwops_testFileWrite", "Test writing to a file", TEST_ENABLED }; + { (SDLTest_TestCaseFp)rwops_testFileWrite, "rwops_testFileWrite", "Test writing to a file", TEST_ENABLED }; static const SDLTest_TestCaseReference rwopsTest6 = - { (SDLTest_TestCaseFp)rwops_testFPRead, "rwops_testFPRead", "Test reading from file pointer", TEST_ENABLED }; + { (SDLTest_TestCaseFp)rwops_testFPRead, "rwops_testFPRead", "Test reading from file pointer", TEST_ENABLED }; static const SDLTest_TestCaseReference rwopsTest7 = - { (SDLTest_TestCaseFp)rwops_testFPWrite, "rwops_testFPWrite", "Test writing to file pointer", TEST_ENABLED }; + { (SDLTest_TestCaseFp)rwops_testFPWrite, "rwops_testFPWrite", "Test writing to file pointer", TEST_ENABLED }; static const SDLTest_TestCaseReference rwopsTest8 = - { (SDLTest_TestCaseFp)rwops_testAllocFree, "rwops_testAllocFree", "Test alloc and free of RW context", TEST_ENABLED }; + { (SDLTest_TestCaseFp)rwops_testAllocFree, "rwops_testAllocFree", "Test alloc and free of RW context", TEST_ENABLED }; static const SDLTest_TestCaseReference rwopsTest9 = - { (SDLTest_TestCaseFp)rwops_testFileWriteReadEndian, "rwops_testFileWriteReadEndian", "Test writing and reading via the Endian aware functions", TEST_ENABLED }; + { (SDLTest_TestCaseFp)rwops_testFileWriteReadEndian, "rwops_testFileWriteReadEndian", "Test writing and reading via the Endian aware functions", TEST_ENABLED }; static const SDLTest_TestCaseReference rwopsTest10 = - { (SDLTest_TestCaseFp)rwops_testCompareRWFromMemWithRWFromFile, "rwops_testCompareRWFromMemWithRWFromFile", "Compare RWFromMem and RWFromFile RWops for read and seek", TEST_ENABLED }; + { (SDLTest_TestCaseFp)rwops_testCompareRWFromMemWithRWFromFile, "rwops_testCompareRWFromMemWithRWFromFile", "Compare RWFromMem and RWFromFile RWops for read and seek", TEST_ENABLED }; /* Sequence of RWops test cases */ static const SDLTest_TestCaseReference *rwopsTests[] = { - &rwopsTest1, &rwopsTest2, &rwopsTest3, &rwopsTest4, &rwopsTest5, &rwopsTest6, - &rwopsTest7, &rwopsTest8, &rwopsTest9, &rwopsTest10, NULL + &rwopsTest1, &rwopsTest2, &rwopsTest3, &rwopsTest4, &rwopsTest5, &rwopsTest6, + &rwopsTest7, &rwopsTest8, &rwopsTest9, &rwopsTest10, NULL }; /* RWops test suite (global) */ SDLTest_TestSuiteReference rwopsTestSuite = { - "RWops", - RWopsSetUp, - rwopsTests, - RWopsTearDown + "RWops", + RWopsSetUp, + rwopsTests, + RWopsTearDown }; diff --git a/test/testautomation_sdltest.c b/test/testautomation_sdltest.c index 26d0f72c8..b8bc326a7 100644 --- a/test/testautomation_sdltest.c +++ b/test/testautomation_sdltest.c @@ -29,18 +29,18 @@ sdltest_getFuzzerInvocationCount(void *arg) { Uint8 result; int fuzzerCount1, fuzzerCount2; - + fuzzerCount1 = SDLTest_GetFuzzerInvocationCount(); SDLTest_AssertPass("Call to SDLTest_GetFuzzerInvocationCount()"); SDLTest_AssertCheck(fuzzerCount1 >= 0, "Verify returned value, expected: >=0, got: %d", fuzzerCount1); - + result = SDLTest_RandomUint8(); SDLTest_AssertPass("Call to SDLTest_RandomUint8(), returned %d", result); fuzzerCount2 = SDLTest_GetFuzzerInvocationCount(); SDLTest_AssertPass("Call to SDLTest_GetFuzzerInvocationCount()"); SDLTest_AssertCheck(fuzzerCount2 > fuzzerCount1, "Verify returned value, expected: >%d, got: %d", fuzzerCount1, fuzzerCount2); - + return TEST_COMPLETED; } @@ -56,7 +56,7 @@ sdltest_randomNumber(void *arg) double dresult; Uint64 umax; Sint64 min, max; - + result = (Sint64)SDLTest_RandomUint8(); umax = (1 << 8) - 1; SDLTest_AssertPass("Call to SDLTest_RandomUint8"); @@ -67,7 +67,7 @@ sdltest_randomNumber(void *arg) max = (1 << 7) - 1; SDLTest_AssertPass("Call to SDLTest_RandomSint8"); SDLTest_AssertCheck(result >= min && result <= max, "Verify result value, expected: [%lld,%lld], got: %lld", min, max, result); - + result = (Sint64)SDLTest_RandomUint16(); umax = (1 << 16) - 1; SDLTest_AssertPass("Call to SDLTest_RandomUint16"); @@ -99,7 +99,7 @@ sdltest_randomNumber(void *arg) dresult = (double)SDLTest_RandomUnitFloat(); SDLTest_AssertPass("Call to SDLTest_RandomUnitFloat"); SDLTest_AssertCheck(dresult >= 0.0 && dresult < 1.0, "Verify result value, expected: [0.0,1.0[, got: %e", dresult); - + dresult = (double)SDLTest_RandomFloat(); SDLTest_AssertPass("Call to SDLTest_RandomFloat"); SDLTest_AssertCheck(dresult >= (double)(-FLT_MAX) && dresult <= (double)FLT_MAX, "Verify result value, expected: [%e,%e], got: %e", (double)(-FLT_MAX), (double)FLT_MAX, dresult); @@ -110,7 +110,7 @@ sdltest_randomNumber(void *arg) dresult = SDLTest_RandomDouble(); SDLTest_AssertPass("Call to SDLTest_RandomDouble"); - + return TEST_COMPLETED; } @@ -133,56 +133,56 @@ sdltest_randomBoundaryNumberUint8(void *arg) SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue"); SDLTest_AssertCheck( uresult == 10, - "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", uresult); + "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", uresult); /* RandomUintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */ uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(10, 11, SDL_TRUE); SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue"); SDLTest_AssertCheck( uresult == 10 || uresult == 11, - "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", uresult); + "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", uresult); /* RandomUintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */ uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(10, 12, SDL_TRUE); SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue"); SDLTest_AssertCheck( uresult == 10 || uresult == 11 || uresult == 12, - "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", uresult); + "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", uresult); /* RandomUintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */ uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(10, 13, SDL_TRUE); SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue"); SDLTest_AssertCheck( uresult == 10 || uresult == 11 || uresult == 12 || uresult == 13, - "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", uresult); + "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", uresult); /* RandomUintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */ uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(10, 20, SDL_TRUE); SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue"); SDLTest_AssertCheck( uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20, - "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult); + "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult); /* RandomUintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */ uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(20, 10, SDL_TRUE); SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue"); SDLTest_AssertCheck( uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20, - "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult); + "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult); /* RandomUintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */ uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(1, 20, SDL_FALSE); SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue"); SDLTest_AssertCheck( uresult == 0 || uresult == 21, - "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", uresult); - + "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", uresult); + /* RandomUintXBoundaryValue(0, 99, SDL_FALSE) returns 100 */ uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(0, 99, SDL_FALSE); SDLTest_AssertPass("Call to SDLTest_RandomUint8BoundaryValue"); SDLTest_AssertCheck( uresult == 100, - "Validate result value for parameters (0,99,SDL_FALSE); expected: 100, got: %lld", uresult); + "Validate result value for parameters (0,99,SDL_FALSE); expected: 100, got: %lld", uresult); /* RandomUintXBoundaryValue(1, 0xff, SDL_FALSE) returns 0 (no error) */ uresult = (Uint64)SDLTest_RandomUint8BoundaryValue(1, 255, SDL_FALSE); @@ -243,56 +243,56 @@ sdltest_randomBoundaryNumberUint16(void *arg) SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue"); SDLTest_AssertCheck( uresult == 10, - "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", uresult); + "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", uresult); /* RandomUintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */ uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(10, 11, SDL_TRUE); SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue"); SDLTest_AssertCheck( uresult == 10 || uresult == 11, - "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", uresult); + "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", uresult); /* RandomUintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */ uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(10, 12, SDL_TRUE); SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue"); SDLTest_AssertCheck( uresult == 10 || uresult == 11 || uresult == 12, - "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", uresult); + "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", uresult); /* RandomUintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */ uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(10, 13, SDL_TRUE); SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue"); SDLTest_AssertCheck( uresult == 10 || uresult == 11 || uresult == 12 || uresult == 13, - "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", uresult); + "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", uresult); /* RandomUintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */ uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(10, 20, SDL_TRUE); SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue"); SDLTest_AssertCheck( uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20, - "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult); + "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult); /* RandomUintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */ uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(20, 10, SDL_TRUE); SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue"); SDLTest_AssertCheck( uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20, - "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult); + "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult); /* RandomUintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */ uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(1, 20, SDL_FALSE); SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue"); SDLTest_AssertCheck( uresult == 0 || uresult == 21, - "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", uresult); - + "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", uresult); + /* RandomUintXBoundaryValue(0, 99, SDL_FALSE) returns 100 */ uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(0, 99, SDL_FALSE); SDLTest_AssertPass("Call to SDLTest_RandomUint16BoundaryValue"); SDLTest_AssertCheck( uresult == 100, - "Validate result value for parameters (0,99,SDL_FALSE); expected: 100, got: %lld", uresult); + "Validate result value for parameters (0,99,SDL_FALSE); expected: 100, got: %lld", uresult); /* RandomUintXBoundaryValue(1, 0xffff, SDL_FALSE) returns 0 (no error) */ uresult = (Uint64)SDLTest_RandomUint16BoundaryValue(1, 0xffff, SDL_FALSE); @@ -333,7 +333,7 @@ sdltest_randomBoundaryNumberUint16(void *arg) return TEST_COMPLETED; } - + /* * @brief Calls to random boundary number generators for Uint32 */ @@ -353,56 +353,56 @@ sdltest_randomBoundaryNumberUint32(void *arg) SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue"); SDLTest_AssertCheck( uresult == 10, - "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", uresult); + "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", uresult); /* RandomUintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */ uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(10, 11, SDL_TRUE); SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue"); SDLTest_AssertCheck( uresult == 10 || uresult == 11, - "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", uresult); + "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", uresult); /* RandomUintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */ uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(10, 12, SDL_TRUE); SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue"); SDLTest_AssertCheck( uresult == 10 || uresult == 11 || uresult == 12, - "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", uresult); + "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", uresult); /* RandomUintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */ uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(10, 13, SDL_TRUE); SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue"); SDLTest_AssertCheck( uresult == 10 || uresult == 11 || uresult == 12 || uresult == 13, - "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", uresult); + "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", uresult); /* RandomUintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */ uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(10, 20, SDL_TRUE); SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue"); SDLTest_AssertCheck( uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20, - "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult); + "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult); /* RandomUintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */ uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(20, 10, SDL_TRUE); SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue"); SDLTest_AssertCheck( uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20, - "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult); + "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult); /* RandomUintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */ uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(1, 20, SDL_FALSE); SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue"); SDLTest_AssertCheck( uresult == 0 || uresult == 21, - "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", uresult); - + "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", uresult); + /* RandomUintXBoundaryValue(0, 99, SDL_FALSE) returns 100 */ uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(0, 99, SDL_FALSE); SDLTest_AssertPass("Call to SDLTest_RandomUint32BoundaryValue"); SDLTest_AssertCheck( uresult == 100, - "Validate result value for parameters (0,99,SDL_FALSE); expected: 100, got: %lld", uresult); + "Validate result value for parameters (0,99,SDL_FALSE); expected: 100, got: %lld", uresult); /* RandomUintXBoundaryValue(1, 0xffffffff, SDL_FALSE) returns 0 (no error) */ uresult = (Uint64)SDLTest_RandomUint32BoundaryValue(1, 0xffffffff, SDL_FALSE); @@ -463,56 +463,56 @@ sdltest_randomBoundaryNumberUint64(void *arg) SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue"); SDLTest_AssertCheck( uresult == 10, - "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", uresult); + "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", uresult); /* RandomUintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */ uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(10, 11, SDL_TRUE); SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue"); SDLTest_AssertCheck( uresult == 10 || uresult == 11, - "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", uresult); + "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", uresult); /* RandomUintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */ uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(10, 12, SDL_TRUE); SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue"); SDLTest_AssertCheck( uresult == 10 || uresult == 11 || uresult == 12, - "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", uresult); + "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", uresult); /* RandomUintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */ uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(10, 13, SDL_TRUE); SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue"); SDLTest_AssertCheck( uresult == 10 || uresult == 11 || uresult == 12 || uresult == 13, - "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", uresult); + "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", uresult); /* RandomUintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */ uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(10, 20, SDL_TRUE); SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue"); SDLTest_AssertCheck( uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20, - "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult); + "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult); /* RandomUintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */ uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(20, 10, SDL_TRUE); SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue"); SDLTest_AssertCheck( uresult == 10 || uresult == 11 || uresult == 19 || uresult == 20, - "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult); + "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", uresult); /* RandomUintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */ uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(1, 20, SDL_FALSE); SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue"); SDLTest_AssertCheck( uresult == 0 || uresult == 21, - "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", uresult); - + "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", uresult); + /* RandomUintXBoundaryValue(0, 99, SDL_FALSE) returns 100 */ uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(0, 99, SDL_FALSE); SDLTest_AssertPass("Call to SDLTest_RandomUint64BoundaryValue"); SDLTest_AssertCheck( uresult == 100, - "Validate result value for parameters (0,99,SDL_FALSE); expected: 100, got: %lld", uresult); + "Validate result value for parameters (0,99,SDL_FALSE); expected: 100, got: %lld", uresult); /* RandomUintXBoundaryValue(1, 0xffffffffffffffff, SDL_FALSE) returns 0 (no error) */ uresult = (Uint64)SDLTest_RandomUint64BoundaryValue(1, (Uint64)0xffffffffffffffffULL, SDL_FALSE); @@ -573,56 +573,56 @@ sdltest_randomBoundaryNumberSint8(void *arg) SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue"); SDLTest_AssertCheck( sresult == 10, - "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", sresult); + "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", sresult); /* RandomSintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */ sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(10, 11, SDL_TRUE); SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue"); SDLTest_AssertCheck( sresult == 10 || sresult == 11, - "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", sresult); + "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", sresult); /* RandomSintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */ sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(10, 12, SDL_TRUE); SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue"); SDLTest_AssertCheck( sresult == 10 || sresult == 11 || sresult == 12, - "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", sresult); + "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", sresult); /* RandomSintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */ sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(10, 13, SDL_TRUE); SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue"); SDLTest_AssertCheck( sresult == 10 || sresult == 11 || sresult == 12 || sresult == 13, - "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", sresult); + "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", sresult); /* RandomSintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */ sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(10, 20, SDL_TRUE); SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue"); SDLTest_AssertCheck( sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20, - "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult); + "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult); /* RandomSintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */ sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(20, 10, SDL_TRUE); SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue"); SDLTest_AssertCheck( sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20, - "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult); + "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult); /* RandomSintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */ sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(1, 20, SDL_FALSE); SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue"); SDLTest_AssertCheck( sresult == 0 || sresult == 21, - "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", sresult); - + "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", sresult); + /* RandomSintXBoundaryValue(SCHAR_MIN, 99, SDL_FALSE) returns 100 */ sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(SCHAR_MIN, 99, SDL_FALSE); SDLTest_AssertPass("Call to SDLTest_RandomSint8BoundaryValue"); SDLTest_AssertCheck( sresult == 100, - "Validate result value for parameters (SCHAR_MIN,99,SDL_FALSE); expected: 100, got: %lld", sresult); + "Validate result value for parameters (SCHAR_MIN,99,SDL_FALSE); expected: 100, got: %lld", sresult); /* RandomSintXBoundaryValue(SCHAR_MIN + 1, SCHAR_MAX, SDL_FALSE) returns SCHAR_MIN (no error) */ sresult = (Sint64)SDLTest_RandomSint8BoundaryValue(SCHAR_MIN + 1, SCHAR_MAX, SDL_FALSE); @@ -660,7 +660,7 @@ sdltest_randomBoundaryNumberSint8(void *arg) /* Clear error messages */ SDL_ClearError(); SDLTest_AssertPass("SDL_ClearError()"); - + return TEST_COMPLETED; } @@ -683,56 +683,56 @@ sdltest_randomBoundaryNumberSint16(void *arg) SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue"); SDLTest_AssertCheck( sresult == 10, - "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", sresult); + "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", sresult); /* RandomSintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */ sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(10, 11, SDL_TRUE); SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue"); SDLTest_AssertCheck( sresult == 10 || sresult == 11, - "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", sresult); + "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", sresult); /* RandomSintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */ sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(10, 12, SDL_TRUE); SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue"); SDLTest_AssertCheck( sresult == 10 || sresult == 11 || sresult == 12, - "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", sresult); + "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", sresult); /* RandomSintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */ sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(10, 13, SDL_TRUE); SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue"); SDLTest_AssertCheck( sresult == 10 || sresult == 11 || sresult == 12 || sresult == 13, - "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", sresult); + "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", sresult); /* RandomSintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */ sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(10, 20, SDL_TRUE); SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue"); SDLTest_AssertCheck( sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20, - "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult); + "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult); /* RandomSintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */ sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(20, 10, SDL_TRUE); SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue"); SDLTest_AssertCheck( sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20, - "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult); + "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult); /* RandomSintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */ sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(1, 20, SDL_FALSE); SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue"); SDLTest_AssertCheck( sresult == 0 || sresult == 21, - "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", sresult); - + "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", sresult); + /* RandomSintXBoundaryValue(SHRT_MIN, 99, SDL_FALSE) returns 100 */ sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(SHRT_MIN, 99, SDL_FALSE); SDLTest_AssertPass("Call to SDLTest_RandomSint16BoundaryValue"); SDLTest_AssertCheck( sresult == 100, - "Validate result value for parameters (SHRT_MIN,99,SDL_FALSE); expected: 100, got: %lld", sresult); + "Validate result value for parameters (SHRT_MIN,99,SDL_FALSE); expected: 100, got: %lld", sresult); /* RandomSintXBoundaryValue(SHRT_MIN + 1, SHRT_MAX, SDL_FALSE) returns SHRT_MIN (no error) */ sresult = (Sint64)SDLTest_RandomSint16BoundaryValue(SHRT_MIN + 1, SHRT_MAX, SDL_FALSE); @@ -773,7 +773,7 @@ sdltest_randomBoundaryNumberSint16(void *arg) return TEST_COMPLETED; } - + /* * @brief Calls to random boundary number generators for Sint32 */ @@ -784,7 +784,7 @@ sdltest_randomBoundaryNumberSint32(void *arg) char *lastError; Sint64 sresult; #if ((ULONG_MAX) == (UINT_MAX)) - Sint32 long_min = LONG_MIN; + Sint32 long_min = LONG_MIN; Sint32 long_max = LONG_MAX; #else Sint32 long_min = INT_MIN; @@ -800,56 +800,56 @@ sdltest_randomBoundaryNumberSint32(void *arg) SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue"); SDLTest_AssertCheck( sresult == 10, - "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", sresult); + "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", sresult); /* RandomSintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */ sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(10, 11, SDL_TRUE); SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue"); SDLTest_AssertCheck( sresult == 10 || sresult == 11, - "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", sresult); + "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", sresult); /* RandomSintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */ sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(10, 12, SDL_TRUE); SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue"); SDLTest_AssertCheck( sresult == 10 || sresult == 11 || sresult == 12, - "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", sresult); + "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", sresult); /* RandomSintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */ sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(10, 13, SDL_TRUE); SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue"); SDLTest_AssertCheck( sresult == 10 || sresult == 11 || sresult == 12 || sresult == 13, - "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", sresult); + "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", sresult); /* RandomSintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */ sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(10, 20, SDL_TRUE); SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue"); SDLTest_AssertCheck( sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20, - "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult); + "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult); /* RandomSintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */ sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(20, 10, SDL_TRUE); SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue"); SDLTest_AssertCheck( sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20, - "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult); + "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult); /* RandomSintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */ sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(1, 20, SDL_FALSE); SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue"); SDLTest_AssertCheck( sresult == 0 || sresult == 21, - "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", sresult); - + "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", sresult); + /* RandomSintXBoundaryValue(LONG_MIN, 99, SDL_FALSE) returns 100 */ sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(long_min, 99, SDL_FALSE); SDLTest_AssertPass("Call to SDLTest_RandomSint32BoundaryValue"); SDLTest_AssertCheck( sresult == 100, - "Validate result value for parameters (LONG_MIN,99,SDL_FALSE); expected: 100, got: %lld", sresult); + "Validate result value for parameters (LONG_MIN,99,SDL_FALSE); expected: 100, got: %lld", sresult); /* RandomSintXBoundaryValue(LONG_MIN + 1, LONG_MAX, SDL_FALSE) returns LONG_MIN (no error) */ sresult = (Sint64)SDLTest_RandomSint32BoundaryValue(long_min + 1, long_max, SDL_FALSE); @@ -910,56 +910,56 @@ sdltest_randomBoundaryNumberSint64(void *arg) SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue"); SDLTest_AssertCheck( sresult == 10, - "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", sresult); + "Validate result value for parameters (10,10,SDL_TRUE); expected: 10, got: %lld", sresult); /* RandomSintXBoundaryValue(10, 11, SDL_TRUE) returns 10, 11 */ sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(10, 11, SDL_TRUE); SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue"); SDLTest_AssertCheck( sresult == 10 || sresult == 11, - "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", sresult); + "Validate result value for parameters (10,11,SDL_TRUE); expected: 10|11, got: %lld", sresult); /* RandomSintXBoundaryValue(10, 12, SDL_TRUE) returns 10, 11, 12 */ sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(10, 12, SDL_TRUE); SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue"); SDLTest_AssertCheck( sresult == 10 || sresult == 11 || sresult == 12, - "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", sresult); + "Validate result value for parameters (10,12,SDL_TRUE); expected: 10|11|12, got: %lld", sresult); /* RandomSintXBoundaryValue(10, 13, SDL_TRUE) returns 10, 11, 12, 13 */ sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(10, 13, SDL_TRUE); SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue"); SDLTest_AssertCheck( sresult == 10 || sresult == 11 || sresult == 12 || sresult == 13, - "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", sresult); + "Validate result value for parameters (10,13,SDL_TRUE); expected: 10|11|12|13, got: %lld", sresult); /* RandomSintXBoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 */ sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(10, 20, SDL_TRUE); SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue"); SDLTest_AssertCheck( sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20, - "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult); + "Validate result value for parameters (10,20,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult); /* RandomSintXBoundaryValue(20, 10, SDL_TRUE) returns 10, 11, 19 or 20 */ sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(20, 10, SDL_TRUE); SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue"); SDLTest_AssertCheck( sresult == 10 || sresult == 11 || sresult == 19 || sresult == 20, - "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult); + "Validate result value for parameters (20,10,SDL_TRUE); expected: 10|11|19|20, got: %lld", sresult); /* RandomSintXBoundaryValue(1, 20, SDL_FALSE) returns 0, 21 */ sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(1, 20, SDL_FALSE); SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue"); SDLTest_AssertCheck( sresult == 0 || sresult == 21, - "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", sresult); - + "Validate result value for parameters (1,20,SDL_FALSE); expected: 0|21, got: %lld", sresult); + /* RandomSintXBoundaryValue(LLONG_MIN, 99, SDL_FALSE) returns 100 */ sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(LLONG_MIN, 99, SDL_FALSE); SDLTest_AssertPass("Call to SDLTest_RandomSint64BoundaryValue"); SDLTest_AssertCheck( sresult == 100, - "Validate result value for parameters (LLONG_MIN,99,SDL_FALSE); expected: 100, got: %lld", sresult); + "Validate result value for parameters (LLONG_MIN,99,SDL_FALSE); expected: 100, got: %lld", sresult); /* RandomSintXBoundaryValue(LLONG_MIN + 1, LLONG_MAX, SDL_FALSE) returns LLONG_MIN (no error) */ sresult = (Sint64)SDLTest_RandomSint64BoundaryValue(LLONG_MIN + 1, LLONG_MAX, SDL_FALSE); @@ -1010,7 +1010,7 @@ sdltest_randomIntegerInRange(void *arg) Sint32 min, max; Sint32 result; #if ((ULONG_MAX) == (UINT_MAX)) - Sint32 long_min = LONG_MIN; + Sint32 long_min = LONG_MIN; Sint32 long_max = LONG_MAX; #else Sint32 long_min = INT_MIN; @@ -1101,11 +1101,11 @@ sdltest_randomAsciiString(void *arg) } SDLTest_AssertCheck(nonAsciiCharacters == 0, "Validate that result does not contain non-Ascii characters, got: %d", nonAsciiCharacters); if (nonAsciiCharacters) { - SDLTest_LogError("Invalid result from generator: '%s'", result); + SDLTest_LogError("Invalid result from generator: '%s'", result); } - SDL_free(result); + SDL_free(result); } - + return TEST_COMPLETED; } @@ -1139,9 +1139,9 @@ sdltest_randomAsciiStringWithMaximumLength(void *arg) } SDLTest_AssertCheck(nonAsciiCharacters == 0, "Validate that result does not contain non-Ascii characters, got: %d", nonAsciiCharacters); if (nonAsciiCharacters) { - SDLTest_LogError("Invalid result from generator: '%s'", result); + SDLTest_LogError("Invalid result from generator: '%s'", result); } - SDL_free(result); + SDL_free(result); } /* Negative test */ @@ -1159,7 +1159,7 @@ sdltest_randomAsciiStringWithMaximumLength(void *arg) /* Clear error messages */ SDL_ClearError(); SDLTest_AssertPass("SDL_ClearError()"); - + return TEST_COMPLETED; } @@ -1193,11 +1193,11 @@ sdltest_randomAsciiStringOfSize(void *arg) } SDLTest_AssertCheck(nonAsciiCharacters == 0, "Validate that result does not contain non-ASCII characters, got: %d", nonAsciiCharacters); if (nonAsciiCharacters) { - SDLTest_LogError("Invalid result from generator: '%s'", result); + SDLTest_LogError("Invalid result from generator: '%s'", result); } - SDL_free(result); + SDL_free(result); } - + /* Negative test */ targetLen = 0; result = SDLTest_RandomAsciiStringOfSize(targetLen); @@ -1213,7 +1213,7 @@ sdltest_randomAsciiStringOfSize(void *arg) /* Clear error messages */ SDL_ClearError(); SDLTest_AssertPass("SDL_ClearError()"); - + return TEST_COMPLETED; } @@ -1222,58 +1222,58 @@ sdltest_randomAsciiStringOfSize(void *arg) /* SDL_test test cases */ static const SDLTest_TestCaseReference sdltestTest1 = - { (SDLTest_TestCaseFp)sdltest_getFuzzerInvocationCount, "sdltest_getFuzzerInvocationCount", "Call to sdltest_GetFuzzerInvocationCount", TEST_ENABLED }; + { (SDLTest_TestCaseFp)sdltest_getFuzzerInvocationCount, "sdltest_getFuzzerInvocationCount", "Call to sdltest_GetFuzzerInvocationCount", TEST_ENABLED }; static const SDLTest_TestCaseReference sdltestTest2 = - { (SDLTest_TestCaseFp)sdltest_randomNumber, "sdltest_randomNumber", "Calls to random number generators", TEST_ENABLED }; + { (SDLTest_TestCaseFp)sdltest_randomNumber, "sdltest_randomNumber", "Calls to random number generators", TEST_ENABLED }; static const SDLTest_TestCaseReference sdltestTest3 = - { (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberUint8, "sdltest_randomBoundaryNumberUint8", "Calls to random boundary number generators for Uint8", TEST_ENABLED }; + { (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberUint8, "sdltest_randomBoundaryNumberUint8", "Calls to random boundary number generators for Uint8", TEST_ENABLED }; static const SDLTest_TestCaseReference sdltestTest4 = - { (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberUint16, "sdltest_randomBoundaryNumberUint16", "Calls to random boundary number generators for Uint16", TEST_ENABLED }; + { (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberUint16, "sdltest_randomBoundaryNumberUint16", "Calls to random boundary number generators for Uint16", TEST_ENABLED }; static const SDLTest_TestCaseReference sdltestTest5 = - { (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberUint32, "sdltest_randomBoundaryNumberUint32", "Calls to random boundary number generators for Uint32", TEST_ENABLED }; + { (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberUint32, "sdltest_randomBoundaryNumberUint32", "Calls to random boundary number generators for Uint32", TEST_ENABLED }; static const SDLTest_TestCaseReference sdltestTest6 = - { (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberUint64, "sdltest_randomBoundaryNumberUint64", "Calls to random boundary number generators for Uint64", TEST_ENABLED }; + { (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberUint64, "sdltest_randomBoundaryNumberUint64", "Calls to random boundary number generators for Uint64", TEST_ENABLED }; static const SDLTest_TestCaseReference sdltestTest7 = - { (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberSint8, "sdltest_randomBoundaryNumberSint8", "Calls to random boundary number generators for Sint8", TEST_ENABLED }; + { (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberSint8, "sdltest_randomBoundaryNumberSint8", "Calls to random boundary number generators for Sint8", TEST_ENABLED }; static const SDLTest_TestCaseReference sdltestTest8 = - { (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberSint16, "sdltest_randomBoundaryNumberSint16", "Calls to random boundary number generators for Sint16", TEST_ENABLED }; + { (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberSint16, "sdltest_randomBoundaryNumberSint16", "Calls to random boundary number generators for Sint16", TEST_ENABLED }; static const SDLTest_TestCaseReference sdltestTest9 = - { (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberSint32, "sdltest_randomBoundaryNumberSint32", "Calls to random boundary number generators for Sint32", TEST_ENABLED }; + { (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberSint32, "sdltest_randomBoundaryNumberSint32", "Calls to random boundary number generators for Sint32", TEST_ENABLED }; static const SDLTest_TestCaseReference sdltestTest10 = - { (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberSint64, "sdltest_randomBoundaryNumberSint64", "Calls to random boundary number generators for Sint64", TEST_ENABLED }; + { (SDLTest_TestCaseFp)sdltest_randomBoundaryNumberSint64, "sdltest_randomBoundaryNumberSint64", "Calls to random boundary number generators for Sint64", TEST_ENABLED }; static const SDLTest_TestCaseReference sdltestTest11 = - { (SDLTest_TestCaseFp)sdltest_randomIntegerInRange, "sdltest_randomIntegerInRange", "Calls to ranged random number generator", TEST_ENABLED }; + { (SDLTest_TestCaseFp)sdltest_randomIntegerInRange, "sdltest_randomIntegerInRange", "Calls to ranged random number generator", TEST_ENABLED }; static const SDLTest_TestCaseReference sdltestTest12 = - { (SDLTest_TestCaseFp)sdltest_randomAsciiString, "sdltest_randomAsciiString", "Calls to default ASCII string generator", TEST_ENABLED }; + { (SDLTest_TestCaseFp)sdltest_randomAsciiString, "sdltest_randomAsciiString", "Calls to default ASCII string generator", TEST_ENABLED }; static const SDLTest_TestCaseReference sdltestTest13 = - { (SDLTest_TestCaseFp)sdltest_randomAsciiStringWithMaximumLength, "sdltest_randomAsciiStringWithMaximumLength", "Calls to random maximum length ASCII string generator", TEST_ENABLED }; + { (SDLTest_TestCaseFp)sdltest_randomAsciiStringWithMaximumLength, "sdltest_randomAsciiStringWithMaximumLength", "Calls to random maximum length ASCII string generator", TEST_ENABLED }; static const SDLTest_TestCaseReference sdltestTest14 = - { (SDLTest_TestCaseFp)sdltest_randomAsciiStringOfSize, "sdltest_randomAsciiStringOfSize", "Calls to fixed size ASCII string generator", TEST_ENABLED }; + { (SDLTest_TestCaseFp)sdltest_randomAsciiStringOfSize, "sdltest_randomAsciiStringOfSize", "Calls to fixed size ASCII string generator", TEST_ENABLED }; /* Sequence of SDL_test test cases */ static const SDLTest_TestCaseReference *sdltestTests[] = { - &sdltestTest1, &sdltestTest2, &sdltestTest3, &sdltestTest4, &sdltestTest5, &sdltestTest6, - &sdltestTest7, &sdltestTest8, &sdltestTest9, &sdltestTest10, &sdltestTest11, &sdltestTest12, - &sdltestTest13, &sdltestTest14, NULL + &sdltestTest1, &sdltestTest2, &sdltestTest3, &sdltestTest4, &sdltestTest5, &sdltestTest6, + &sdltestTest7, &sdltestTest8, &sdltestTest9, &sdltestTest10, &sdltestTest11, &sdltestTest12, + &sdltestTest13, &sdltestTest14, NULL }; /* SDL_test test suite (global) */ SDLTest_TestSuiteReference sdltestTestSuite = { - "SDLtest", - NULL, - sdltestTests, - NULL + "SDLtest", + NULL, + sdltestTests, + NULL }; diff --git a/test/testautomation_suites.h b/test/testautomation_suites.h index 53e51578c..e42cd4266 100644 --- a/test/testautomation_suites.h +++ b/test/testautomation_suites.h @@ -28,23 +28,23 @@ extern SDLTest_TestSuiteReference pixelsTestSuite; // All test suites SDLTest_TestSuiteReference *testSuites[] = { - &audioTestSuite, - &clipboardTestSuite, - &eventsTestSuite, - &keyboardTestSuite, - &mainTestSuite, - &platformTestSuite, - &rectTestSuite, - &renderTestSuite, - &rwopsTestSuite, - &surfaceTestSuite, - &syswmTestSuite, - &sdltestTestSuite, - &videoTestSuite, - &mouseTestSuite, - &timerTestSuite, - &pixelsTestSuite, - NULL + &audioTestSuite, + &clipboardTestSuite, + &eventsTestSuite, + &keyboardTestSuite, + &mainTestSuite, + &platformTestSuite, + &rectTestSuite, + &renderTestSuite, + &rwopsTestSuite, + &surfaceTestSuite, + &syswmTestSuite, + &sdltestTestSuite, + &videoTestSuite, + &mouseTestSuite, + &timerTestSuite, + &pixelsTestSuite, + NULL }; #endif diff --git a/test/testautomation_surface.c b/test/testautomation_surface.c index c75ac0125..159dd1a89 100644 --- a/test/testautomation_surface.c +++ b/test/testautomation_surface.c @@ -56,21 +56,21 @@ _surfaceSetUp(void *arg) SDLTest_AssertCheck(result == 0, "Validate result from SDL_SetSurfaceBlendMode, expected: 0, got: %i", result); result = SDL_GetSurfaceBlendMode(testSurface, ¤tBlendMode); SDLTest_AssertCheck(result == 0, "Validate result from SDL_GetSurfaceBlendMode, expected: 0, got: %i", result); - SDLTest_AssertCheck(currentBlendMode == blendMode, "Validate blendMode, expected: %i, got: %i", blendMode, currentBlendMode); + SDLTest_AssertCheck(currentBlendMode == blendMode, "Validate blendMode, expected: %i, got: %i", blendMode, currentBlendMode); } } void _surfaceTearDown(void *arg) { - if (referenceSurface != NULL) { - SDL_FreeSurface(referenceSurface); - referenceSurface = NULL; - } - if (testSurface != NULL) { - SDL_FreeSurface(testSurface); - testSurface = NULL; - } + if (referenceSurface != NULL) { + SDL_FreeSurface(referenceSurface); + referenceSurface = NULL; + } + if (testSurface != NULL) { + SDL_FreeSurface(testSurface); + testSurface = NULL; + } } /** @@ -78,15 +78,15 @@ _surfaceTearDown(void *arg) */ void _clearTestSurface() { - int ret; - Uint32 color; - - /* Clear surface. */ - color = SDL_MapRGBA( testSurface->format, 0, 0, 0, 0); - SDLTest_AssertPass("Call to SDL_MapRGBA()"); - ret = SDL_FillRect( testSurface, NULL, color); - SDLTest_AssertPass("Call to SDL_FillRect()"); - SDLTest_AssertCheck(ret == 0, "Verify result from SDL_FillRect, expected: 0, got: %i", ret); + int ret; + Uint32 color; + + /* Clear surface. */ + color = SDL_MapRGBA( testSurface->format, 0, 0, 0, 0); + SDLTest_AssertPass("Call to SDL_MapRGBA()"); + ret = SDL_FillRect( testSurface, NULL, color); + SDLTest_AssertPass("Call to SDL_FillRect()"); + SDLTest_AssertCheck(ret == 0, "Verify result from SDL_FillRect, expected: 0, got: %i", ret); } /** @@ -94,119 +94,119 @@ void _clearTestSurface() */ void _testBlitBlendMode(int mode) { - int ret; - int i, j, ni, nj; - SDL_Surface *face; - SDL_Rect rect; - int nmode; - SDL_BlendMode bmode; - int checkFailCount1; - int checkFailCount2; - int checkFailCount3; - int checkFailCount4; - - /* Check test surface */ - SDLTest_AssertCheck(testSurface != NULL, "Verify testSurface is not NULL"); - if (testSurface == NULL) return; - - /* Create sample surface */ - face = SDLTest_ImageFace(); - SDLTest_AssertCheck(face != NULL, "Verify face surface is not NULL"); - if (face == NULL) return; - - /* Reset alpha modulation */ - ret = SDL_SetSurfaceAlphaMod(face, 255); - SDLTest_AssertPass("Call to SDL_SetSurfaceAlphaMod()"); - SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetSurfaceAlphaMod(), expected: 0, got: %i", ret); - - /* Reset color modulation */ - ret = SDL_SetSurfaceColorMod(face, 255, 255, 255); - SDLTest_AssertPass("Call to SDL_SetSurfaceColorMod()"); - SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetSurfaceColorMod(), expected: 0, got: %i", ret); - - /* Reset color key */ - ret = SDL_SetColorKey(face, SDL_FALSE, 0); - SDLTest_AssertPass("Call to SDL_SetColorKey()"); - SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetColorKey(), expected: 0, got: %i", ret); - - /* Clear the test surface */ + int ret; + int i, j, ni, nj; + SDL_Surface *face; + SDL_Rect rect; + int nmode; + SDL_BlendMode bmode; + int checkFailCount1; + int checkFailCount2; + int checkFailCount3; + int checkFailCount4; + + /* Check test surface */ + SDLTest_AssertCheck(testSurface != NULL, "Verify testSurface is not NULL"); + if (testSurface == NULL) return; + + /* Create sample surface */ + face = SDLTest_ImageFace(); + SDLTest_AssertCheck(face != NULL, "Verify face surface is not NULL"); + if (face == NULL) return; + + /* Reset alpha modulation */ + ret = SDL_SetSurfaceAlphaMod(face, 255); + SDLTest_AssertPass("Call to SDL_SetSurfaceAlphaMod()"); + SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetSurfaceAlphaMod(), expected: 0, got: %i", ret); + + /* Reset color modulation */ + ret = SDL_SetSurfaceColorMod(face, 255, 255, 255); + SDLTest_AssertPass("Call to SDL_SetSurfaceColorMod()"); + SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetSurfaceColorMod(), expected: 0, got: %i", ret); + + /* Reset color key */ + ret = SDL_SetColorKey(face, SDL_FALSE, 0); + SDLTest_AssertPass("Call to SDL_SetColorKey()"); + SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetColorKey(), expected: 0, got: %i", ret); + + /* Clear the test surface */ _clearTestSurface(); - - /* Target rect size */ - rect.w = face->w; - rect.h = face->h; - - /* Steps to take */ - ni = testSurface->w - face->w; - nj = testSurface->h - face->h; - - /* Optionally set blend mode. */ - if (mode >= 0) { - ret = SDL_SetSurfaceBlendMode( face, (SDL_BlendMode)mode ); - SDLTest_AssertPass("Call to SDL_SetSurfaceBlendMode()"); - SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetSurfaceBlendMode(..., %i), expected: 0, got: %i", mode, ret); - } - - /* Test blend mode. */ - checkFailCount1 = 0; - checkFailCount2 = 0; - checkFailCount3 = 0; - checkFailCount4 = 0; - for (j=0; j <= nj; j+=4) { - for (i=0; i <= ni; i+=4) { - if (mode == -2) { - /* Set color mod. */ - ret = SDL_SetSurfaceColorMod( face, (255/nj)*j, (255/ni)*i, (255/nj)*j ); - if (ret != 0) checkFailCount2++; - } - else if (mode == -3) { - /* Set alpha mod. */ - ret = SDL_SetSurfaceAlphaMod( face, (255/ni)*i ); - if (ret != 0) checkFailCount3++; - } - else if (mode == -4) { - /* Crazy blending mode magic. */ - nmode = (i/4*j/4) % 4; - if (nmode==0) { - bmode = SDL_BLENDMODE_NONE; - } else if (nmode==1) { - bmode = SDL_BLENDMODE_BLEND; - } else if (nmode==2) { - bmode = SDL_BLENDMODE_ADD; - } else if (nmode==3) { - bmode = SDL_BLENDMODE_MOD; - } - ret = SDL_SetSurfaceBlendMode( face, bmode ); - if (ret != 0) checkFailCount4++; - } - - /* Blitting. */ - rect.x = i; - rect.y = j; - ret = SDL_BlitSurface( face, NULL, testSurface, &rect ); - if (ret != 0) checkFailCount1++; - } - } - SDLTest_AssertCheck(checkFailCount1 == 0, "Validate results from calls to SDL_BlitSurface, expected: 0, got: %i", checkFailCount1); - SDLTest_AssertCheck(checkFailCount2 == 0, "Validate results from calls to SDL_SetSurfaceColorMod, expected: 0, got: %i", checkFailCount2); - SDLTest_AssertCheck(checkFailCount3 == 0, "Validate results from calls to SDL_SetSurfaceAlphaMod, expected: 0, got: %i", checkFailCount3); - SDLTest_AssertCheck(checkFailCount4 == 0, "Validate results from calls to SDL_SetSurfaceBlendMode, expected: 0, got: %i", checkFailCount4); - - /* Clean up */ - if (face != NULL) { - SDL_FreeSurface(face); - face = NULL; - } + + /* Target rect size */ + rect.w = face->w; + rect.h = face->h; + + /* Steps to take */ + ni = testSurface->w - face->w; + nj = testSurface->h - face->h; + + /* Optionally set blend mode. */ + if (mode >= 0) { + ret = SDL_SetSurfaceBlendMode( face, (SDL_BlendMode)mode ); + SDLTest_AssertPass("Call to SDL_SetSurfaceBlendMode()"); + SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetSurfaceBlendMode(..., %i), expected: 0, got: %i", mode, ret); + } + + /* Test blend mode. */ + checkFailCount1 = 0; + checkFailCount2 = 0; + checkFailCount3 = 0; + checkFailCount4 = 0; + for (j=0; j <= nj; j+=4) { + for (i=0; i <= ni; i+=4) { + if (mode == -2) { + /* Set color mod. */ + ret = SDL_SetSurfaceColorMod( face, (255/nj)*j, (255/ni)*i, (255/nj)*j ); + if (ret != 0) checkFailCount2++; + } + else if (mode == -3) { + /* Set alpha mod. */ + ret = SDL_SetSurfaceAlphaMod( face, (255/ni)*i ); + if (ret != 0) checkFailCount3++; + } + else if (mode == -4) { + /* Crazy blending mode magic. */ + nmode = (i/4*j/4) % 4; + if (nmode==0) { + bmode = SDL_BLENDMODE_NONE; + } else if (nmode==1) { + bmode = SDL_BLENDMODE_BLEND; + } else if (nmode==2) { + bmode = SDL_BLENDMODE_ADD; + } else if (nmode==3) { + bmode = SDL_BLENDMODE_MOD; + } + ret = SDL_SetSurfaceBlendMode( face, bmode ); + if (ret != 0) checkFailCount4++; + } + + /* Blitting. */ + rect.x = i; + rect.y = j; + ret = SDL_BlitSurface( face, NULL, testSurface, &rect ); + if (ret != 0) checkFailCount1++; + } + } + SDLTest_AssertCheck(checkFailCount1 == 0, "Validate results from calls to SDL_BlitSurface, expected: 0, got: %i", checkFailCount1); + SDLTest_AssertCheck(checkFailCount2 == 0, "Validate results from calls to SDL_SetSurfaceColorMod, expected: 0, got: %i", checkFailCount2); + SDLTest_AssertCheck(checkFailCount3 == 0, "Validate results from calls to SDL_SetSurfaceAlphaMod, expected: 0, got: %i", checkFailCount3); + SDLTest_AssertCheck(checkFailCount4 == 0, "Validate results from calls to SDL_SetSurfaceBlendMode, expected: 0, got: %i", checkFailCount4); + + /* Clean up */ + if (face != NULL) { + SDL_FreeSurface(face); + face = NULL; + } } /* Helper to check that a file exists */ void _AssertFileExist(const char *filename) { - struct stat st; - int ret = stat(filename, &st); + struct stat st; + int ret = stat(filename, &st); - SDLTest_AssertCheck(ret == 0, "Verify file '%s' exists", filename); + SDLTest_AssertCheck(ret == 0, "Verify file '%s' exists", filename); } @@ -234,16 +234,16 @@ surface_testSaveLoadBitmap(void *arg) /* Save a surface */ ret = SDL_SaveBMP(face, sampleFilename); SDLTest_AssertPass("Call to SDL_SaveBMP()"); - SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SaveBMP, expected: 0, got: %i", ret); + SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SaveBMP, expected: 0, got: %i", ret); _AssertFileExist(sampleFilename); - + /* Load a surface */ rface = SDL_LoadBMP(sampleFilename); SDLTest_AssertPass("Call to SDL_LoadBMP()"); SDLTest_AssertCheck(rface != NULL, "Verify result from SDL_LoadBMP is not NULL"); if (rface != NULL) { - SDLTest_AssertCheck(face->w == rface->w, "Verify width of loaded surface, expected: %i, got: %i", face->w, rface->w); - SDLTest_AssertCheck(face->h == rface->h, "Verify height of loaded surface, expected: %i, got: %i", face->h, rface->h); + SDLTest_AssertCheck(face->w == rface->w, "Verify width of loaded surface, expected: %i, got: %i", face->w, rface->w); + SDLTest_AssertCheck(face->h == rface->h, "Verify height of loaded surface, expected: %i, got: %i", face->h, rface->h); } /* Delete test file; ignore errors */ @@ -251,14 +251,14 @@ surface_testSaveLoadBitmap(void *arg) /* Clean up */ if (face != NULL) { - SDL_FreeSurface(face); - face = NULL; + SDL_FreeSurface(face); + face = NULL; } if (rface != NULL) { - SDL_FreeSurface(rface); - rface = NULL; + SDL_FreeSurface(rface); + rface = NULL; } - + return TEST_COMPLETED; } @@ -268,42 +268,42 @@ surface_testSaveLoadBitmap(void *arg) int surface_testSurfaceConversion(void *arg) { - SDL_Surface *rface = NULL, *face = NULL; - int ret = 0; - - /* Create sample surface */ - face = SDLTest_ImageFace(); - SDLTest_AssertCheck(face != NULL, "Verify face surface is not NULL"); - if (face == NULL) - return TEST_ABORTED; - - /* Set transparent pixel as the pixel at (0,0) */ - if (face->format->palette) { - ret = SDL_SetColorKey(face, SDL_RLEACCEL, *(Uint8 *) face->pixels); - SDLTest_AssertPass("Call to SDL_SetColorKey()"); - SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetColorKey, expected: 0, got: %i", ret); - } - - /* Convert to 32 bit to compare. */ - rface = SDL_ConvertSurface( face, testSurface->format, 0 ); - SDLTest_AssertPass("Call to SDL_ConvertSurface()"); - SDLTest_AssertCheck(rface != NULL, "Verify result from SDL_ConvertSurface is not NULL"); - - /* Compare surface. */ - ret = SDLTest_CompareSurfaces( rface, face, 0 ); - SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); - - /* Clean up. */ - if (face != NULL) { - SDL_FreeSurface( face ); - face = NULL; - } - if (rface != NULL) { - SDL_FreeSurface( rface ); - rface = NULL; - } - - return TEST_COMPLETED; + SDL_Surface *rface = NULL, *face = NULL; + int ret = 0; + + /* Create sample surface */ + face = SDLTest_ImageFace(); + SDLTest_AssertCheck(face != NULL, "Verify face surface is not NULL"); + if (face == NULL) + return TEST_ABORTED; + + /* Set transparent pixel as the pixel at (0,0) */ + if (face->format->palette) { + ret = SDL_SetColorKey(face, SDL_RLEACCEL, *(Uint8 *) face->pixels); + SDLTest_AssertPass("Call to SDL_SetColorKey()"); + SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetColorKey, expected: 0, got: %i", ret); + } + + /* Convert to 32 bit to compare. */ + rface = SDL_ConvertSurface( face, testSurface->format, 0 ); + SDLTest_AssertPass("Call to SDL_ConvertSurface()"); + SDLTest_AssertCheck(rface != NULL, "Verify result from SDL_ConvertSurface is not NULL"); + + /* Compare surface. */ + ret = SDLTest_CompareSurfaces( rface, face, 0 ); + SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); + + /* Clean up. */ + if (face != NULL) { + SDL_FreeSurface( face ); + face = NULL; + } + if (rface != NULL) { + SDL_FreeSurface( rface ); + rface = NULL; + } + + return TEST_COMPLETED; } @@ -313,10 +313,10 @@ surface_testSurfaceConversion(void *arg) int surface_testLoadFailure(void *arg) { - SDL_Surface *face = SDL_LoadBMP("nonexistant.bmp"); - SDLTest_AssertCheck(face == NULL, "SDL_CreateLoadBmp"); + SDL_Surface *face = SDL_LoadBMP("nonexistant.bmp"); + SDLTest_AssertCheck(face == NULL, "SDL_CreateLoadBmp"); - return TEST_COMPLETED; + return TEST_COMPLETED; } /** @@ -328,17 +328,17 @@ surface_testBlit(void *arg) int ret; SDL_Surface *compareSurface; - /* Basic blitting */ + /* Basic blitting */ _testBlitBlendMode(-1); - + /* Verify result by comparing surfaces */ compareSurface = SDLTest_ImageBlit(); ret = SDLTest_CompareSurfaces( testSurface, compareSurface, 0 ); SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); - + /* Clean up. */ - if (compareSurface != NULL) { - SDL_FreeSurface( compareSurface ); + if (compareSurface != NULL) { + SDL_FreeSurface( compareSurface ); } return TEST_COMPLETED; @@ -353,17 +353,17 @@ surface_testBlitColorMod(void *arg) int ret; SDL_Surface *compareSurface; - /* Basic blitting with color mod */ + /* Basic blitting with color mod */ _testBlitBlendMode(-2); - + /* Verify result by comparing surfaces */ compareSurface = SDLTest_ImageBlitColor(); ret = SDLTest_CompareSurfaces( testSurface, compareSurface, 0 ); SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); - + /* Clean up. */ - if (compareSurface != NULL) { - SDL_FreeSurface( compareSurface ); + if (compareSurface != NULL) { + SDL_FreeSurface( compareSurface ); } return TEST_COMPLETED; @@ -378,17 +378,17 @@ surface_testBlitAlphaMod(void *arg) int ret; SDL_Surface *compareSurface; - /* Basic blitting with alpha mod */ + /* Basic blitting with alpha mod */ _testBlitBlendMode(-3); - + /* Verify result by comparing surfaces */ compareSurface = SDLTest_ImageBlitAlpha(); ret = SDLTest_CompareSurfaces( testSurface, compareSurface, 0 ); SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); - + /* Clean up. */ - if (compareSurface != NULL) { - SDL_FreeSurface( compareSurface ); + if (compareSurface != NULL) { + SDL_FreeSurface( compareSurface ); } return TEST_COMPLETED; @@ -404,17 +404,17 @@ surface_testBlitBlendNone(void *arg) int ret; SDL_Surface *compareSurface; - /* Basic blitting */ + /* Basic blitting */ _testBlitBlendMode(SDL_BLENDMODE_NONE); - + /* Verify result by comparing surfaces */ compareSurface = SDLTest_ImageBlitBlendNone(); ret = SDLTest_CompareSurfaces( testSurface, compareSurface, 0 ); SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); - + /* Clean up. */ - if (compareSurface != NULL) { - SDL_FreeSurface( compareSurface ); + if (compareSurface != NULL) { + SDL_FreeSurface( compareSurface ); } return TEST_COMPLETED; @@ -429,17 +429,17 @@ surface_testBlitBlendBlend(void *arg) int ret; SDL_Surface *compareSurface; - /* Blend blitting */ + /* Blend blitting */ _testBlitBlendMode(SDL_BLENDMODE_BLEND); - + /* Verify result by comparing surfaces */ compareSurface = SDLTest_ImageBlitBlend(); ret = SDLTest_CompareSurfaces( testSurface, compareSurface, 0 ); SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); - + /* Clean up. */ - if (compareSurface != NULL) { - SDL_FreeSurface( compareSurface ); + if (compareSurface != NULL) { + SDL_FreeSurface( compareSurface ); } return TEST_COMPLETED; @@ -454,17 +454,17 @@ surface_testBlitBlendAdd(void *arg) int ret; SDL_Surface *compareSurface; - /* Add blitting */ + /* Add blitting */ _testBlitBlendMode(SDL_BLENDMODE_ADD); - + /* Verify result by comparing surfaces */ compareSurface = SDLTest_ImageBlitBlendAdd(); ret = SDLTest_CompareSurfaces( testSurface, compareSurface, 0 ); SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); - + /* Clean up. */ - if (compareSurface != NULL) { - SDL_FreeSurface( compareSurface ); + if (compareSurface != NULL) { + SDL_FreeSurface( compareSurface ); } return TEST_COMPLETED; @@ -479,17 +479,17 @@ surface_testBlitBlendMod(void *arg) int ret; SDL_Surface *compareSurface; - /* Mod blitting */ + /* Mod blitting */ _testBlitBlendMode(SDL_BLENDMODE_MOD); - + /* Verify result by comparing surfaces */ compareSurface = SDLTest_ImageBlitBlendMod(); ret = SDLTest_CompareSurfaces( testSurface, compareSurface, 0 ); SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); - + /* Clean up. */ - if (compareSurface != NULL) { - SDL_FreeSurface( compareSurface ); + if (compareSurface != NULL) { + SDL_FreeSurface( compareSurface ); } return TEST_COMPLETED; @@ -504,17 +504,17 @@ surface_testBlitBlendLoop(void *arg) { int ret; SDL_Surface *compareSurface; - /* All blitting modes */ + /* All blitting modes */ _testBlitBlendMode(-4); - + /* Verify result by comparing surfaces */ compareSurface = SDLTest_ImageBlitBlendAll(); ret = SDLTest_CompareSurfaces( testSurface, compareSurface, 0 ); SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); - + /* Clean up. */ - if (compareSurface != NULL) { - SDL_FreeSurface(compareSurface); + if (compareSurface != NULL) { + SDL_FreeSurface(compareSurface); } return TEST_COMPLETED; @@ -525,52 +525,52 @@ surface_testBlitBlendLoop(void *arg) { /* Surface test cases */ static const SDLTest_TestCaseReference surfaceTest1 = - { (SDLTest_TestCaseFp)surface_testSaveLoadBitmap, "surface_testSaveLoadBitmap", "Tests sprite saving and loading.", TEST_ENABLED}; + { (SDLTest_TestCaseFp)surface_testSaveLoadBitmap, "surface_testSaveLoadBitmap", "Tests sprite saving and loading.", TEST_ENABLED}; static const SDLTest_TestCaseReference surfaceTest2 = - { (SDLTest_TestCaseFp)surface_testBlit, "surface_testBlit", "Tests basic blitting.", TEST_ENABLED}; + { (SDLTest_TestCaseFp)surface_testBlit, "surface_testBlit", "Tests basic blitting.", TEST_ENABLED}; static const SDLTest_TestCaseReference surfaceTest3 = - { (SDLTest_TestCaseFp)surface_testBlitBlendNone, "surface_testBlitBlendNone", "Tests blitting routines with none blending mode.", TEST_ENABLED}; + { (SDLTest_TestCaseFp)surface_testBlitBlendNone, "surface_testBlitBlendNone", "Tests blitting routines with none blending mode.", TEST_ENABLED}; static const SDLTest_TestCaseReference surfaceTest4 = - { (SDLTest_TestCaseFp)surface_testLoadFailure, "surface_testLoadFailure", "Tests sprite loading. A failure case.", TEST_ENABLED}; + { (SDLTest_TestCaseFp)surface_testLoadFailure, "surface_testLoadFailure", "Tests sprite loading. A failure case.", TEST_ENABLED}; static const SDLTest_TestCaseReference surfaceTest5 = - { (SDLTest_TestCaseFp)surface_testSurfaceConversion, "surface_testSurfaceConversion", "Tests surface conversion.", TEST_ENABLED}; + { (SDLTest_TestCaseFp)surface_testSurfaceConversion, "surface_testSurfaceConversion", "Tests surface conversion.", TEST_ENABLED}; static const SDLTest_TestCaseReference surfaceTest6 = - { (SDLTest_TestCaseFp)surface_testBlitColorMod, "surface_testBlitColorMod", "Tests some blitting routines with color mod.", TEST_ENABLED}; + { (SDLTest_TestCaseFp)surface_testBlitColorMod, "surface_testBlitColorMod", "Tests some blitting routines with color mod.", TEST_ENABLED}; static const SDLTest_TestCaseReference surfaceTest7 = - { (SDLTest_TestCaseFp)surface_testBlitAlphaMod, "surface_testBlitAlphaMod", "Tests some blitting routines with alpha mod.", TEST_ENABLED}; + { (SDLTest_TestCaseFp)surface_testBlitAlphaMod, "surface_testBlitAlphaMod", "Tests some blitting routines with alpha mod.", TEST_ENABLED}; /* TODO: rewrite test case, define new test data and re-enable; current implementation fails */ static const SDLTest_TestCaseReference surfaceTest8 = - { (SDLTest_TestCaseFp)surface_testBlitBlendLoop, "surface_testBlitBlendLoop", "Test blittin routines with verious blending modes", TEST_DISABLED}; + { (SDLTest_TestCaseFp)surface_testBlitBlendLoop, "surface_testBlitBlendLoop", "Test blittin routines with verious blending modes", TEST_DISABLED}; /* TODO: rewrite test case, define new test data and re-enable; current implementation fails */ static const SDLTest_TestCaseReference surfaceTest9 = - { (SDLTest_TestCaseFp)surface_testBlitBlendBlend, "surface_testBlitBlendBlend", "Tests blitting routines with blend blending mode.", TEST_DISABLED}; + { (SDLTest_TestCaseFp)surface_testBlitBlendBlend, "surface_testBlitBlendBlend", "Tests blitting routines with blend blending mode.", TEST_DISABLED}; /* TODO: rewrite test case, define new test data and re-enable; current implementation fails */ static const SDLTest_TestCaseReference surfaceTest10 = - { (SDLTest_TestCaseFp)surface_testBlitBlendAdd, "surface_testBlitBlendAdd", "Tests blitting routines with add blending mode.", TEST_DISABLED}; + { (SDLTest_TestCaseFp)surface_testBlitBlendAdd, "surface_testBlitBlendAdd", "Tests blitting routines with add blending mode.", TEST_DISABLED}; static const SDLTest_TestCaseReference surfaceTest11 = - { (SDLTest_TestCaseFp)surface_testBlitBlendMod, "surface_testBlitBlendMod", "Tests blitting routines with mod blending mode.", TEST_ENABLED}; + { (SDLTest_TestCaseFp)surface_testBlitBlendMod, "surface_testBlitBlendMod", "Tests blitting routines with mod blending mode.", TEST_ENABLED}; /* Sequence of Surface test cases */ static const SDLTest_TestCaseReference *surfaceTests[] = { - &surfaceTest1, &surfaceTest2, &surfaceTest3, &surfaceTest4, &surfaceTest5, - &surfaceTest6, &surfaceTest7, &surfaceTest8, &surfaceTest9, &surfaceTest10, &surfaceTest11, NULL + &surfaceTest1, &surfaceTest2, &surfaceTest3, &surfaceTest4, &surfaceTest5, + &surfaceTest6, &surfaceTest7, &surfaceTest8, &surfaceTest9, &surfaceTest10, &surfaceTest11, NULL }; /* Surface test suite (global) */ SDLTest_TestSuiteReference surfaceTestSuite = { - "Surface", - _surfaceSetUp, - surfaceTests, - _surfaceTearDown + "Surface", + _surfaceSetUp, + surfaceTests, + _surfaceTearDown }; diff --git a/test/testautomation_syswm.c b/test/testautomation_syswm.c index b3ee6f4dd..3e368f63e 100644 --- a/test/testautomation_syswm.c +++ b/test/testautomation_syswm.c @@ -17,27 +17,27 @@ int syswm_getWindowWMInfo(void *arg) { SDL_bool result; - SDL_Window *window; + SDL_Window *window; SDL_SysWMinfo info; - + window = SDL_CreateWindow("", 0, 0, 0, 0, SDL_WINDOW_HIDDEN); SDLTest_AssertPass("Call to SDL_CreateWindow()"); SDLTest_AssertCheck(window != NULL, "Check that value returned from SDL_CreateWindow is not NULL"); if (window == NULL) { return TEST_ABORTED; } - + /* Initialize info structure with SDL version info */ - SDL_VERSION(&info.version); - + SDL_VERSION(&info.version); + /* Make call */ result = SDL_GetWindowWMInfo(window, &info); SDLTest_AssertPass("Call to SDL_GetWindowWMInfo"); SDLTest_Log((result == SDL_TRUE) ? "Got window information" : "Couldn't get window information"); - + SDL_DestroyWindow(window); SDLTest_AssertPass("Call to SDL_DestroyWindow()"); - + return TEST_COMPLETED; } @@ -45,17 +45,17 @@ syswm_getWindowWMInfo(void *arg) /* SysWM test cases */ static const SDLTest_TestCaseReference syswmTest1 = - { (SDLTest_TestCaseFp)syswm_getWindowWMInfo, "syswm_getWindowWMInfo", "Call to SDL_GetWindowWMInfo", TEST_ENABLED }; + { (SDLTest_TestCaseFp)syswm_getWindowWMInfo, "syswm_getWindowWMInfo", "Call to SDL_GetWindowWMInfo", TEST_ENABLED }; /* Sequence of SysWM test cases */ static const SDLTest_TestCaseReference *syswmTests[] = { - &syswmTest1, NULL + &syswmTest1, NULL }; /* SysWM test suite (global) */ SDLTest_TestSuiteReference syswmTestSuite = { - "SysWM", - NULL, - syswmTests, - NULL + "SysWM", + NULL, + syswmTests, + NULL }; diff --git a/test/testautomation_timer.c b/test/testautomation_timer.c index 71cc8d8aa..ddf6a5f29 100644 --- a/test/testautomation_timer.c +++ b/test/testautomation_timer.c @@ -21,11 +21,11 @@ int _timerCallbackCalled = 0; void _timerSetUp(void *arg) { - /* Start SDL timer subsystem */ - int ret = SDL_InitSubSystem( SDL_INIT_TIMER ); + /* Start SDL timer subsystem */ + int ret = SDL_InitSubSystem( SDL_INIT_TIMER ); SDLTest_AssertPass("Call to SDL_InitSubSystem(SDL_INIT_TIMER)"); - SDLTest_AssertCheck(ret==0, "Check result from SDL_InitSubSystem(SDL_INIT_TIMER)"); - if (ret != 0) { + SDLTest_AssertCheck(ret==0, "Check result from SDL_InitSubSystem(SDL_INIT_TIMER)"); + if (ret != 0) { SDLTest_LogError("%s", SDL_GetError()); } } @@ -39,11 +39,11 @@ int timer_getPerformanceCounter(void *arg) { Uint64 result; - + result = SDL_GetPerformanceCounter(); SDLTest_AssertPass("Call to SDL_GetPerformanceCounter()"); SDLTest_AssertCheck(result > 0, "Check result value, expected: >0, got: %lu", result); - + return TEST_COMPLETED; } @@ -54,11 +54,11 @@ int timer_getPerformanceFrequency(void *arg) { Uint64 result; - + result = SDL_GetPerformanceFrequency(); SDLTest_AssertPass("Call to SDL_GetPerformanceFrequency()"); SDLTest_AssertCheck(result > 0, "Check result value, expected: >0, got: %lu", result); - + return TEST_COMPLETED; } @@ -74,18 +74,18 @@ timer_delayAndGetTicks(void *arg) Uint32 result2; Uint32 difference; - /* Zero delay */ + /* Zero delay */ SDL_Delay(0); SDLTest_AssertPass("Call to SDL_Delay(0)"); - + /* Non-zero delay */ SDL_Delay(1); SDLTest_AssertPass("Call to SDL_Delay(1)"); SDL_Delay(SDLTest_RandomIntegerInRange(5, 15)); SDLTest_AssertPass("Call to SDL_Delay()"); - - /* Get ticks count - should be non-zero by now */ + + /* Get ticks count - should be non-zero by now */ result = SDL_GetTicks(); SDLTest_AssertPass("Call to SDL_GetTicks()"); SDLTest_AssertCheck(result > 0, "Check result value, expected: >0, got: %d", result); @@ -99,7 +99,7 @@ timer_delayAndGetTicks(void *arg) difference = result2 - result; SDLTest_AssertCheck(difference > (testDelay - marginOfError), "Check difference, expected: >%d, got: %d", testDelay - marginOfError, difference); SDLTest_AssertCheck(difference < (testDelay + marginOfError), "Check difference, expected: <%d, got: %d", testDelay + marginOfError, difference); - + return TEST_COMPLETED; } @@ -107,14 +107,14 @@ timer_delayAndGetTicks(void *arg) Uint32 _timerTestCallback(Uint32 interval, void *param) { _timerCallbackCalled = 1; - + if (_paramCheck != 0) { SDLTest_AssertCheck(param != NULL, "Check param pointer, expected: non-NULL, got: %s", (param != NULL) ? "non-NULL" : "NULL"); if (param != NULL) { SDLTest_AssertCheck(*(int *)param == _paramValue, "Check param value, expected: %i, got: %i", _paramValue, *(int *)param); } } - + return 0; } @@ -131,12 +131,12 @@ timer_addRemoveTimer(void *arg) /* Reset state */ _paramCheck = 0; _timerCallbackCalled = 0; - - /* Set timer with a long delay */ + + /* Set timer with a long delay */ id = SDL_AddTimer(10000, _timerTestCallback, NULL); SDLTest_AssertPass("Call to SDL_AddTimer(10000,...)"); SDLTest_AssertCheck(id > 0, "Check result value, expected: >0, got: %d", id); - + /* Remove timer again and check that callback was not called */ result = SDL_RemoveTimer(id); SDLTest_AssertPass("Call to SDL_RemoveTimer()"); @@ -154,21 +154,21 @@ timer_addRemoveTimer(void *arg) _paramValue = param; _timerCallbackCalled = 0; - /* Set timer with a short delay */ + /* Set timer with a short delay */ id = SDL_AddTimer(10, _timerTestCallback, (void *)¶m); SDLTest_AssertPass("Call to SDL_AddTimer(10, param)"); SDLTest_AssertCheck(id > 0, "Check result value, expected: >0, got: %d", id); - + /* Wait to let timer trigger callback */ SDL_Delay(100); SDLTest_AssertPass("Call to SDL_Delay(100)"); - + /* Remove timer again and check that callback was called */ result = SDL_RemoveTimer(id); SDLTest_AssertPass("Call to SDL_RemoveTimer()"); SDLTest_AssertCheck(result == SDL_FALSE, "Check result value, expected: %i, got: %i", SDL_FALSE, result); SDLTest_AssertCheck(_timerCallbackCalled == 1, "Check callback WAS called, expected: 1, got: %i", _timerCallbackCalled); - + return TEST_COMPLETED; } @@ -176,26 +176,26 @@ timer_addRemoveTimer(void *arg) /* Timer test cases */ static const SDLTest_TestCaseReference timerTest1 = - { (SDLTest_TestCaseFp)timer_getPerformanceCounter, "timer_getPerformanceCounter", "Call to SDL_GetPerformanceCounter", TEST_ENABLED }; + { (SDLTest_TestCaseFp)timer_getPerformanceCounter, "timer_getPerformanceCounter", "Call to SDL_GetPerformanceCounter", TEST_ENABLED }; static const SDLTest_TestCaseReference timerTest2 = - { (SDLTest_TestCaseFp)timer_getPerformanceFrequency, "timer_getPerformanceFrequency", "Call to SDL_GetPerformanceFrequency", TEST_ENABLED }; + { (SDLTest_TestCaseFp)timer_getPerformanceFrequency, "timer_getPerformanceFrequency", "Call to SDL_GetPerformanceFrequency", TEST_ENABLED }; static const SDLTest_TestCaseReference timerTest3 = - { (SDLTest_TestCaseFp)timer_delayAndGetTicks, "timer_delayAndGetTicks", "Call to SDL_Delay and SDL_GetTicks", TEST_ENABLED }; + { (SDLTest_TestCaseFp)timer_delayAndGetTicks, "timer_delayAndGetTicks", "Call to SDL_Delay and SDL_GetTicks", TEST_ENABLED }; static const SDLTest_TestCaseReference timerTest4 = - { (SDLTest_TestCaseFp)timer_addRemoveTimer, "timer_addRemoveTimer", "Call to SDL_AddTimer and SDL_RemoveTimer", TEST_ENABLED }; + { (SDLTest_TestCaseFp)timer_addRemoveTimer, "timer_addRemoveTimer", "Call to SDL_AddTimer and SDL_RemoveTimer", TEST_ENABLED }; /* Sequence of Timer test cases */ static const SDLTest_TestCaseReference *timerTests[] = { - &timerTest1, &timerTest2, &timerTest3, &timerTest4, NULL + &timerTest1, &timerTest2, &timerTest3, &timerTest4, NULL }; /* Timer test suite (global) */ SDLTest_TestSuiteReference timerTestSuite = { - "Timer", - _timerSetUp, - timerTests, - NULL + "Timer", + _timerSetUp, + timerTests, + NULL }; diff --git a/test/testautomation_video.c b/test/testautomation_video.c index 9abf32aa1..f35e06392 100644 --- a/test/testautomation_video.c +++ b/test/testautomation_video.c @@ -20,7 +20,7 @@ /* Private helpers */ -/* +/* * Create a test window */ SDL_Window *_createVideoSuiteTestWindow(const char *title) @@ -35,7 +35,7 @@ SDL_Window *_createVideoSuiteTestWindow(const char *title) w = SDLTest_RandomIntegerInRange(320, 1024); h = SDLTest_RandomIntegerInRange(320, 768); flags = SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_BORDERLESS; - + window = SDL_CreateWindow(title, x, y, w, h, flags); SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,%d)", x, y, w, h, flags); SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL"); @@ -44,11 +44,11 @@ SDL_Window *_createVideoSuiteTestWindow(const char *title) } /* - * Destroy test window + * Destroy test window */ void _destroyVideoSuiteTestWindow(SDL_Window *window) { - if (window != NULL) { + if (window != NULL) { SDL_DestroyWindow(window); window = NULL; SDLTest_AssertPass("Call to SDL_DestroyWindow"); @@ -63,50 +63,50 @@ void _destroyVideoSuiteTestWindow(SDL_Window *window) int video_enableDisableScreensaver(void *arg) { - SDL_bool initialResult; - SDL_bool result; - - /* Get current state and proceed according to current state */ - initialResult = SDL_IsScreenSaverEnabled(); - SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()"); - if (initialResult == SDL_TRUE) { - - /* Currently enabled: disable first, then enable again */ - - /* Disable screensaver and check */ - SDL_DisableScreenSaver(); - SDLTest_AssertPass("Call to SDL_DisableScreenSaver()"); - result = SDL_IsScreenSaverEnabled(); - SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()"); - SDLTest_AssertCheck(result == SDL_FALSE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_FALSE, result); - - /* Enable screensaver and check */ - SDL_EnableScreenSaver(); - SDLTest_AssertPass("Call to SDL_EnableScreenSaver()"); - result = SDL_IsScreenSaverEnabled(); - SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()"); - SDLTest_AssertCheck(result == SDL_TRUE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_TRUE, result); - - } else { - - /* Currently disabled: enable first, then disable again */ - - /* Enable screensaver and check */ - SDL_EnableScreenSaver(); - SDLTest_AssertPass("Call to SDL_EnableScreenSaver()"); - result = SDL_IsScreenSaverEnabled(); - SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()"); - SDLTest_AssertCheck(result == SDL_TRUE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_TRUE, result); - - /* Disable screensaver and check */ - SDL_DisableScreenSaver(); - SDLTest_AssertPass("Call to SDL_DisableScreenSaver()"); - result = SDL_IsScreenSaverEnabled(); - SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()"); - SDLTest_AssertCheck(result == SDL_FALSE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_FALSE, result); - } - - return TEST_COMPLETED; + SDL_bool initialResult; + SDL_bool result; + + /* Get current state and proceed according to current state */ + initialResult = SDL_IsScreenSaverEnabled(); + SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()"); + if (initialResult == SDL_TRUE) { + + /* Currently enabled: disable first, then enable again */ + + /* Disable screensaver and check */ + SDL_DisableScreenSaver(); + SDLTest_AssertPass("Call to SDL_DisableScreenSaver()"); + result = SDL_IsScreenSaverEnabled(); + SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()"); + SDLTest_AssertCheck(result == SDL_FALSE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_FALSE, result); + + /* Enable screensaver and check */ + SDL_EnableScreenSaver(); + SDLTest_AssertPass("Call to SDL_EnableScreenSaver()"); + result = SDL_IsScreenSaverEnabled(); + SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()"); + SDLTest_AssertCheck(result == SDL_TRUE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_TRUE, result); + + } else { + + /* Currently disabled: enable first, then disable again */ + + /* Enable screensaver and check */ + SDL_EnableScreenSaver(); + SDLTest_AssertPass("Call to SDL_EnableScreenSaver()"); + result = SDL_IsScreenSaverEnabled(); + SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()"); + SDLTest_AssertCheck(result == SDL_TRUE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_TRUE, result); + + /* Disable screensaver and check */ + SDL_DisableScreenSaver(); + SDLTest_AssertPass("Call to SDL_DisableScreenSaver()"); + result = SDL_IsScreenSaverEnabled(); + SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()"); + SDLTest_AssertCheck(result == SDL_FALSE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_FALSE, result); + } + + return TEST_COMPLETED; } /** @@ -119,73 +119,73 @@ video_createWindowVariousPositions(void *arg) const char* title = "video_createWindowVariousPositions Test Window"; int x, y, w, h; int xVariation, yVariation; - + for (xVariation = 0; xVariation < 6; xVariation++) { for (yVariation = 0; yVariation < 6; yVariation++) { switch(xVariation) { case 0: - /* Zero X Position */ + /* Zero X Position */ x = 0; break; case 1: - /* Random X position inside screen */ + /* Random X position inside screen */ x = SDLTest_RandomIntegerInRange(1, 100); break; case 2: - /* Random X position outside screen (positive) */ + /* Random X position outside screen (positive) */ x = SDLTest_RandomIntegerInRange(10000, 11000); break; case 3: - /* Random X position outside screen (negative) */ + /* Random X position outside screen (negative) */ x = SDLTest_RandomIntegerInRange(-1000, -100); break; case 4: - /* Centered X position */ + /* Centered X position */ x = SDL_WINDOWPOS_CENTERED; break; case 5: - /* Undefined X position */ + /* Undefined X position */ x = SDL_WINDOWPOS_UNDEFINED; break; } switch(yVariation) { case 0: - /* Zero X Position */ + /* Zero X Position */ y = 0; break; case 1: - /* Random X position inside screen */ + /* Random X position inside screen */ y = SDLTest_RandomIntegerInRange(1, 100); break; case 2: - /* Random X position outside screen (positive) */ + /* Random X position outside screen (positive) */ y = SDLTest_RandomIntegerInRange(10000, 11000); break; case 3: - /* Random Y position outside screen (negative) */ + /* Random Y position outside screen (negative) */ y = SDLTest_RandomIntegerInRange(-1000, -100); break; case 4: - /* Centered Y position */ + /* Centered Y position */ y = SDL_WINDOWPOS_CENTERED; break; case 5: - /* Undefined Y position */ + /* Undefined Y position */ y = SDL_WINDOWPOS_UNDEFINED; break; } - + w = SDLTest_RandomIntegerInRange(32, 96); h = SDLTest_RandomIntegerInRange(32, 96); window = SDL_CreateWindow(title, x, y, w, h, SDL_WINDOW_SHOWN); SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,SHOWN)", x, y, w, h); SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL"); - /* Clean up */ + /* Clean up */ _destroyVideoSuiteTestWindow(window); } - } + } return TEST_COMPLETED; } @@ -200,49 +200,49 @@ video_createWindowVariousSizes(void *arg) const char* title = "video_createWindowVariousSizes Test Window"; int x, y, w, h; int wVariation, hVariation; - + x = SDLTest_RandomIntegerInRange(1, 100); y = SDLTest_RandomIntegerInRange(1, 100); for (wVariation = 0; wVariation < 3; wVariation++) { for (hVariation = 0; hVariation < 3; hVariation++) { switch(wVariation) { case 0: - /* Width of 1 */ + /* Width of 1 */ w = 1; break; case 1: - /* Random "normal" width */ + /* Random "normal" width */ w = SDLTest_RandomIntegerInRange(320, 1920); break; case 2: - /* Random "large" width */ + /* Random "large" width */ w = SDLTest_RandomIntegerInRange(2048, 4095); break; } switch(hVariation) { case 0: - /* Height of 1 */ + /* Height of 1 */ h = 1; break; case 1: - /* Random "normal" height */ + /* Random "normal" height */ h = SDLTest_RandomIntegerInRange(320, 1080); break; case 2: - /* Random "large" height */ + /* Random "large" height */ h = SDLTest_RandomIntegerInRange(2048, 4095); break; } - + window = SDL_CreateWindow(title, x, y, w, h, SDL_WINDOW_SHOWN); SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,SHOWN)", x, y, w, h); SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL"); - /* Clean up */ + /* Clean up */ _destroyVideoSuiteTestWindow(window); } - } + } return TEST_COMPLETED; } @@ -258,7 +258,7 @@ video_createWindowVariousFlags(void *arg) int x, y, w, h; int fVariation; SDL_WindowFlags flags; - + /* Standard window */ x = SDLTest_RandomIntegerInRange(1, 100); y = SDLTest_RandomIntegerInRange(1, 100); @@ -270,54 +270,54 @@ video_createWindowVariousFlags(void *arg) case 0: flags = SDL_WINDOW_FULLSCREEN; /* Skip - blanks screen; comment out next line to run test */ - continue; + continue; break; case 1: flags = SDL_WINDOW_FULLSCREEN_DESKTOP; /* Skip - blanks screen; comment out next line to run test */ - continue; + continue; break; case 2: flags = SDL_WINDOW_OPENGL; - break; + break; case 3: flags = SDL_WINDOW_SHOWN; - break; - case 4: + break; + case 4: flags = SDL_WINDOW_HIDDEN; - break; + break; case 5: flags = SDL_WINDOW_BORDERLESS; - break; + break; case 6: flags = SDL_WINDOW_RESIZABLE; - break; + break; case 7: flags = SDL_WINDOW_MINIMIZED; - break; + break; case 8: flags = SDL_WINDOW_MAXIMIZED; break; - case 9: + case 9: flags = SDL_WINDOW_INPUT_GRABBED; break; - case 10: + case 10: flags = SDL_WINDOW_INPUT_FOCUS; - break; - case 11: + break; + case 11: flags = SDL_WINDOW_MOUSE_FOCUS; break; - case 12: + case 12: flags = SDL_WINDOW_FOREIGN; break; } - + window = SDL_CreateWindow(title, x, y, w, h, flags); SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,%d)", x, y, w, h, flags); SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL"); - /* Clean up */ - _destroyVideoSuiteTestWindow(window); + /* Clean up */ + _destroyVideoSuiteTestWindow(window); } return TEST_COMPLETED; @@ -334,11 +334,11 @@ video_getWindowFlags(void *arg) const char* title = "video_getWindowFlags Test Window"; SDL_WindowFlags flags; Uint32 actualFlags; - + /* Reliable flag set always set in test window */ flags = SDL_WINDOW_SHOWN; - - /* Call against new test window */ + + /* Call against new test window */ window = _createVideoSuiteTestWindow(title); if (window != NULL) { actualFlags = SDL_GetWindowFlags(window); @@ -346,9 +346,9 @@ video_getWindowFlags(void *arg) SDLTest_AssertCheck((flags & actualFlags) == flags, "Verify returned value has flags %d set, got: %d", flags, actualFlags); } - /* Clean up */ + /* Clean up */ _destroyVideoSuiteTestWindow(window); - + return TEST_COMPLETED; } @@ -366,7 +366,7 @@ video_getNumDisplayModes(void *arg) displayNum = SDL_GetNumVideoDisplays(); SDLTest_AssertPass("Call to SDL_GetNumVideoDisplays"); - /* Make call for each display */ + /* Make call for each display */ for (i=0; i= 0.0 && result <= 1.0, "Validate range of result value; expected: [0.0, 1.0], got: %f", result); } - /* Clean up */ + /* Clean up */ _destroyVideoSuiteTestWindow(window); - + return TEST_COMPLETED; } @@ -544,7 +544,7 @@ video_getWindowBrightnessNegative(void *arg) const char* title = "video_getWindowBrightnessNegative Test Window"; float result; - /* Call against invalid window */ + /* Call against invalid window */ result = SDL_GetWindowBrightness(NULL); SDLTest_AssertPass("Call to SDL_GetWindowBrightness(window=NULL)"); SDLTest_AssertCheck(result == 1.0, "Validate result value; expected: 1.0, got: %f", result); @@ -579,7 +579,7 @@ video_getWindowDisplayMode(void *arg) mode.h = -1; mode.refresh_rate = -1; - /* Call against new test window */ + /* Call against new test window */ window = _createVideoSuiteTestWindow(title); if (window != NULL) { result = SDL_GetWindowDisplayMode(window, &mode); @@ -590,9 +590,9 @@ video_getWindowDisplayMode(void *arg) SDLTest_AssertCheck(mode.refresh_rate > 0, "Validate mode.refresh_rate content; expected: >0, got: %d", mode.refresh_rate); } - /* Clean up */ + /* Clean up */ _destroyVideoSuiteTestWindow(window); - + return TEST_COMPLETED; } @@ -611,7 +611,7 @@ void _checkInvalidWindowError() invalidWindowError, lastError); SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); + SDLTest_AssertPass("Call to SDL_ClearError()"); } } @@ -630,7 +630,7 @@ video_getWindowDisplayModeNegative(void *arg) SDL_DisplayMode mode; int result; - /* Call against new test window */ + /* Call against new test window */ window = _createVideoSuiteTestWindow(title); if (window != NULL) { result = SDL_GetWindowDisplayMode(window, NULL); @@ -640,16 +640,16 @@ video_getWindowDisplayModeNegative(void *arg) SDLTest_AssertPass("SDL_GetError()"); SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL"); if (lastError != NULL) { - SDLTest_AssertCheck(SDL_strcmp(lastError, expectedError) == 0, + SDLTest_AssertCheck(SDL_strcmp(lastError, expectedError) == 0, "SDL_GetError(): expected message '%s', was message: '%s'", expectedError, lastError); } } - /* Clean up */ + /* Clean up */ _destroyVideoSuiteTestWindow(window); - + /* Call against invalid window */ result = SDL_GetWindowDisplayMode(NULL, &mode); SDLTest_AssertPass("Call to SDL_GetWindowDisplayMode(window=NULL,...)"); @@ -674,10 +674,10 @@ video_getWindowGammaRamp(void *arg) Uint16 blue[256]; int result; - /* Call against new test window */ + /* Call against new test window */ window = _createVideoSuiteTestWindow(title); if (window == NULL) return TEST_ABORTED; - + /* Retrieve no channel */ result = SDL_GetWindowGammaRamp(window, NULL, NULL, NULL); SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(all NULL)"); @@ -714,9 +714,9 @@ video_getWindowGammaRamp(void *arg) SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(r,g,b)"); SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result); - /* Clean up */ + /* Clean up */ _destroyVideoSuiteTestWindow(window); - + return TEST_COMPLETED; } @@ -737,21 +737,21 @@ video_getWindowGammaRampNegative(void *arg) SDL_ClearError(); SDLTest_AssertPass("Call to SDL_ClearError()"); - /* Call against invalid window */ + /* Call against invalid window */ result = SDL_GetWindowGammaRamp(NULL, red, green, blue); SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(window=NULL,r,g,b)"); SDLTest_AssertCheck(result == -1, "Validate result value; expected: -1, got: %f", result); _checkInvalidWindowError(); - + return TEST_COMPLETED; } /* Helper for setting and checking the window grab state */ -void +void _setAndCheckWindowGrabState(SDL_Window* window, SDL_bool desiredState) { SDL_bool currentState; - + /* Set state */ SDL_SetWindowGrab(window, desiredState); SDLTest_AssertPass("Call to SDL_SetWindowGrab(%s)", (desiredState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE"); @@ -760,8 +760,8 @@ _setAndCheckWindowGrabState(SDL_Window* window, SDL_bool desiredState) currentState = SDL_GetWindowGrab(window); SDLTest_AssertPass("Call to SDL_GetWindowGrab()"); SDLTest_AssertCheck( - currentState == desiredState, - "Validate returned state; expected: %s, got: %s", + currentState == desiredState, + "Validate returned state; expected: %s, got: %s", (desiredState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE", (currentState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE"); } @@ -779,11 +779,11 @@ video_getSetWindowGrab(void *arg) SDL_Window* window; SDL_bool originalState, dummyState, currentState, desiredState; - /* Call against new test window */ + /* Call against new test window */ window = _createVideoSuiteTestWindow(title); if (window == NULL) return TEST_ABORTED; - /* Get state */ + /* Get state */ originalState = SDL_GetWindowGrab(window); SDLTest_AssertPass("Call to SDL_GetWindowGrab()"); @@ -792,7 +792,7 @@ video_getSetWindowGrab(void *arg) /* F --> F */ _setAndCheckWindowGrabState(window, SDL_FALSE); - + /* F --> T */ _setAndCheckWindowGrabState(window, SDL_TRUE); @@ -801,7 +801,7 @@ video_getSetWindowGrab(void *arg) /* T --> F */ _setAndCheckWindowGrabState(window, SDL_FALSE); - + /* Negative tests */ dummyState = SDL_GetWindowGrab(NULL); SDLTest_AssertPass("Call to SDL_GetWindowGrab(window=NULL)"); @@ -814,21 +814,21 @@ video_getSetWindowGrab(void *arg) SDL_SetWindowGrab(NULL, SDL_TRUE); SDLTest_AssertPass("Call to SDL_SetWindowGrab(window=NULL,SDL_FALSE)"); _checkInvalidWindowError(); - + /* State should still be F */ desiredState = SDL_FALSE; currentState = SDL_GetWindowGrab(window); SDLTest_AssertPass("Call to SDL_GetWindowGrab()"); SDLTest_AssertCheck( - currentState == desiredState, - "Validate returned state; expected: %s, got: %s", + currentState == desiredState, + "Validate returned state; expected: %s, got: %s", (desiredState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE", (currentState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE"); - - /* Restore state */ + + /* Restore state */ _setAndCheckWindowGrabState(window, originalState); - /* Clean up */ + /* Clean up */ _destroyVideoSuiteTestWindow(window); return TEST_COMPLETED; @@ -849,7 +849,7 @@ video_getWindowId(void *arg) SDL_Window* result; Uint32 id, randomId; - /* Call against new test window */ + /* Call against new test window */ window = _createVideoSuiteTestWindow(title); if (window == NULL) return TEST_ABORTED; @@ -873,9 +873,9 @@ video_getWindowId(void *arg) result = SDL_GetWindowFromID(UINT32_MAX); SDLTest_AssertPass("Call to SDL_GetWindowID(UINT32_MAX)"); - /* Clean up */ + /* Clean up */ _destroyVideoSuiteTestWindow(window); - + /* Get window from ID for closed window*/ result = SDL_GetWindowFromID(id); SDLTest_AssertPass("Call to SDL_GetWindowID(%d/closed_window)", id); @@ -887,7 +887,7 @@ video_getWindowId(void *arg) id = SDL_GetWindowID(NULL); SDLTest_AssertPass("Call to SDL_GetWindowID(window=NULL)"); _checkInvalidWindowError(); - + return TEST_COMPLETED; } @@ -903,7 +903,7 @@ video_getWindowPixelFormat(void *arg) SDL_Window* window; Uint32 format; - /* Call against new test window */ + /* Call against new test window */ window = _createVideoSuiteTestWindow(title); if (window == NULL) return TEST_ABORTED; @@ -911,10 +911,10 @@ video_getWindowPixelFormat(void *arg) format = SDL_GetWindowPixelFormat(window); SDLTest_AssertPass("Call to SDL_GetWindowPixelFormat()"); SDLTest_AssertCheck(format != SDL_PIXELFORMAT_UNKNOWN, "Verify that returned format is valid; expected: != %d, got: %d", SDL_PIXELFORMAT_UNKNOWN, format); - - /* Clean up */ + + /* Clean up */ _destroyVideoSuiteTestWindow(window); - + /* Negative test */ SDL_ClearError(); SDLTest_AssertPass("Call to SDL_ClearError()"); @@ -941,46 +941,46 @@ video_getSetWindowPosition(void *arg) int currentX, currentY; int desiredX, desiredY; - /* Call against new test window */ + /* Call against new test window */ window = _createVideoSuiteTestWindow(title); if (window == NULL) return TEST_ABORTED; - + for (xVariation = 0; xVariation < 4; xVariation++) { for (yVariation = 0; yVariation < 4; yVariation++) { switch(xVariation) { case 0: - /* Zero X Position */ + /* Zero X Position */ desiredX = 0; break; case 1: - /* Random X position inside screen */ + /* Random X position inside screen */ desiredX = SDLTest_RandomIntegerInRange(1, 100); break; case 2: - /* Random X position outside screen (positive) */ + /* Random X position outside screen (positive) */ desiredX = SDLTest_RandomIntegerInRange(10000, 11000); break; case 3: - /* Random X position outside screen (negative) */ + /* Random X position outside screen (negative) */ desiredX = SDLTest_RandomIntegerInRange(-1000, -100); break; } switch(yVariation) { case 0: - /* Zero X Position */ + /* Zero X Position */ desiredY = 0; break; case 1: - /* Random X position inside screen */ + /* Random X position inside screen */ desiredY = SDLTest_RandomIntegerInRange(1, 100); break; case 2: - /* Random X position outside screen (positive) */ + /* Random X position outside screen (positive) */ desiredY = SDLTest_RandomIntegerInRange(10000, 11000); break; case 3: - /* Random Y position outside screen (negative) */ + /* Random Y position outside screen (negative) */ desiredY = SDLTest_RandomIntegerInRange(-1000, -100); break; } @@ -988,7 +988,7 @@ video_getSetWindowPosition(void *arg) /* Set position */ SDL_SetWindowPosition(window, desiredX, desiredY); SDLTest_AssertPass("Call to SDL_SetWindowPosition(...,%d,%d)", desiredX, desiredY); - + /* Get position */ currentX = desiredX + 1; currentY = desiredY + 1; @@ -998,7 +998,7 @@ video_getSetWindowPosition(void *arg) SDLTest_AssertCheck(desiredY == currentY, "Verify returned Y position; expected: %d, got: %d", desiredY, currentY); /* Get position X */ - currentX = desiredX + 1; + currentX = desiredX + 1; SDL_GetWindowPosition(window, ¤tX, NULL); SDLTest_AssertPass("Call to SDL_GetWindowPosition(&y=NULL)"); SDLTest_AssertCheck(desiredX == currentX, "Verify returned X position; expected: %d, got: %d", desiredX, currentX); @@ -1014,10 +1014,10 @@ video_getSetWindowPosition(void *arg) /* Dummy call with both pointers NULL */ SDL_GetWindowPosition(window, NULL, NULL); SDLTest_AssertPass("Call to SDL_GetWindowPosition(&x=NULL,&y=NULL)"); - - /* Clean up */ + + /* Clean up */ _destroyVideoSuiteTestWindow(window); - + /* Set some 'magic' value for later check that nothing was changed */ referenceX = SDLTest_RandomSint32(); referenceY = SDLTest_RandomSint32(); @@ -1028,14 +1028,14 @@ video_getSetWindowPosition(void *arg) /* Negative tests */ SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); + SDLTest_AssertPass("Call to SDL_ClearError()"); SDL_GetWindowPosition(NULL, ¤tX, ¤tY); SDLTest_AssertPass("Call to SDL_GetWindowPosition(window=NULL)"); SDLTest_AssertCheck( - currentX == referenceX && currentY == referenceY, - "Verify that content of X and Y pointers has not been modified; expected: %d,%d; got: %d,%d", - referenceX, referenceY, - currentX, currentY); + currentX == referenceX && currentY == referenceY, + "Verify that content of X and Y pointers has not been modified; expected: %d,%d; got: %d,%d", + referenceX, referenceY, + currentX, currentY); _checkInvalidWindowError(); SDL_GetWindowPosition(NULL, NULL, NULL); @@ -1045,7 +1045,7 @@ video_getSetWindowPosition(void *arg) SDL_SetWindowPosition(NULL, desiredX, desiredY); SDLTest_AssertPass("Call to SDL_SetWindowPosition(window=NULL)"); _checkInvalidWindowError(); - + return TEST_COMPLETED; } @@ -1064,7 +1064,7 @@ void _checkInvalidParameterError() invalidParameterError, lastError); SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); + SDLTest_AssertPass("Call to SDL_ClearError()"); } } @@ -1091,47 +1091,47 @@ video_getSetWindowSize(void *arg) SDLTest_AssertPass("SDL_GetDisplayBounds()"); SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result); if (result != 0) return TEST_ABORTED; - - /* Call against new test window */ + + /* Call against new test window */ window = _createVideoSuiteTestWindow(title); if (window == NULL) return TEST_ABORTED; - + for (wVariation = 0; wVariation < 4; wVariation++) { for (hVariation = 0; hVariation < 4; hVariation++) { switch(wVariation) { case 0: - /* 1 Pixel Wide */ + /* 1 Pixel Wide */ desiredW = 1; break; case 1: - /* Random width inside screen */ + /* Random width inside screen */ desiredW = SDLTest_RandomIntegerInRange(1, 100); break; case 2: - /* Width at screen size */ + /* Width at screen size */ desiredW = display.w; break; case 3: - /* Width 1 pixel larger than screen */ + /* Width 1 pixel larger than screen */ desiredW = display.w + 1; break; } switch(hVariation) { case 0: - /* 1 Pixel High */ + /* 1 Pixel High */ desiredH = 1; break; case 1: - /* Random height inside screen */ + /* Random height inside screen */ desiredH = SDLTest_RandomIntegerInRange(1, 100); break; case 2: - /* Height at screen size */ + /* Height at screen size */ desiredH = display.h; break; case 3: - /* Height 1 pixel larger than screen */ + /* Height 1 pixel larger than screen */ desiredH = display.h + 1; break; } @@ -1139,7 +1139,7 @@ video_getSetWindowSize(void *arg) /* Set size */ SDL_SetWindowSize(window, desiredW, desiredH); SDLTest_AssertPass("Call to SDL_SetWindowSize(...,%d,%d)", desiredW, desiredH); - + /* Get size */ currentW = desiredW + 1; currentH = desiredH + 1; @@ -1149,7 +1149,7 @@ video_getSetWindowSize(void *arg) SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH); /* Get just width */ - currentW = desiredW + 1; + currentW = desiredW + 1; SDL_GetWindowSize(window, ¤tW, NULL); SDLTest_AssertPass("Call to SDL_GetWindowSize(&h=NULL)"); SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentH); @@ -1168,20 +1168,20 @@ video_getSetWindowSize(void *arg) /* Negative tests for parameter input */ SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); + SDLTest_AssertPass("Call to SDL_ClearError()"); for (desiredH = -2; desiredH < 2; desiredH++) { for (desiredW = -2; desiredW < 2; desiredW++) { - if (desiredW <= 0 || desiredH <= 0) { + if (desiredW <= 0 || desiredH <= 0) { SDL_SetWindowSize(window, desiredW, desiredH); SDLTest_AssertPass("Call to SDL_SetWindowSize(...,%d,%d)", desiredW, desiredH); _checkInvalidParameterError(); } } } - - /* Clean up */ + + /* Clean up */ _destroyVideoSuiteTestWindow(window); - + /* Set some 'magic' value for later check that nothing was changed */ referenceW = SDLTest_RandomSint32(); referenceH = SDLTest_RandomSint32(); @@ -1189,17 +1189,17 @@ video_getSetWindowSize(void *arg) currentH = referenceH; desiredW = SDLTest_RandomSint32(); desiredH = SDLTest_RandomSint32(); - + /* Negative tests for window input */ SDL_ClearError(); SDLTest_AssertPass("Call to SDL_ClearError()"); SDL_GetWindowSize(NULL, ¤tW, ¤tH); SDLTest_AssertPass("Call to SDL_GetWindowSize(window=NULL)"); SDLTest_AssertCheck( - currentW == referenceW && currentH == referenceH, - "Verify that content of W and H pointers has not been modified; expected: %d,%d; got: %d,%d", - referenceW, referenceH, - currentW, currentH); + currentW == referenceW && currentH == referenceH, + "Verify that content of W and H pointers has not been modified; expected: %d,%d; got: %d,%d", + referenceW, referenceH, + currentW, currentH); _checkInvalidWindowError(); SDL_GetWindowSize(NULL, NULL, NULL); @@ -1209,7 +1209,7 @@ video_getSetWindowSize(void *arg) SDL_SetWindowSize(NULL, desiredW, desiredH); SDLTest_AssertPass("Call to SDL_SetWindowSize(window=NULL)"); _checkInvalidWindowError(); - + return TEST_COMPLETED; } @@ -1235,42 +1235,42 @@ video_getSetWindowMinimumSize(void *arg) SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result); if (result != 0) return TEST_ABORTED; - /* Call against new test window */ + /* Call against new test window */ window = _createVideoSuiteTestWindow(title); if (window == NULL) return TEST_ABORTED; - + for (wVariation = 0; wVariation < 5; wVariation++) { for (hVariation = 0; hVariation < 5; hVariation++) { switch(wVariation) { case 0: - /* 1 Pixel Wide */ + /* 1 Pixel Wide */ desiredW = 1; break; case 1: - /* Random width inside screen */ + /* Random width inside screen */ desiredW = SDLTest_RandomIntegerInRange(2, display.w - 1); break; case 2: - /* Width at screen size */ + /* Width at screen size */ desiredW = display.w; break; } switch(hVariation) { case 0: - /* 1 Pixel High */ + /* 1 Pixel High */ desiredH = 1; break; case 1: - /* Random height inside screen */ + /* Random height inside screen */ desiredH = SDLTest_RandomIntegerInRange(2, display.h - 1); break; case 2: - /* Height at screen size */ + /* Height at screen size */ desiredH = display.h; break; case 4: - /* Height 1 pixel larger than screen */ + /* Height 1 pixel larger than screen */ desiredH = display.h + 1; break; } @@ -1278,7 +1278,7 @@ video_getSetWindowMinimumSize(void *arg) /* Set size */ SDL_SetWindowMinimumSize(window, desiredW, desiredH); SDLTest_AssertPass("Call to SDL_SetWindowMinimumSize(...,%d,%d)", desiredW, desiredH); - + /* Get size */ currentW = desiredW + 1; currentH = desiredH + 1; @@ -1288,7 +1288,7 @@ video_getSetWindowMinimumSize(void *arg) SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH); /* Get just width */ - currentW = desiredW + 1; + currentW = desiredW + 1; SDL_GetWindowMinimumSize(window, ¤tW, NULL); SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(&h=NULL)"); SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentH); @@ -1307,20 +1307,20 @@ video_getSetWindowMinimumSize(void *arg) /* Negative tests for parameter input */ SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); + SDLTest_AssertPass("Call to SDL_ClearError()"); for (desiredH = -2; desiredH < 2; desiredH++) { for (desiredW = -2; desiredW < 2; desiredW++) { - if (desiredW <= 0 || desiredH <= 0) { + if (desiredW <= 0 || desiredH <= 0) { SDL_SetWindowMinimumSize(window, desiredW, desiredH); SDLTest_AssertPass("Call to SDL_SetWindowMinimumSize(...,%d,%d)", desiredW, desiredH); _checkInvalidParameterError(); } } } - - /* Clean up */ + + /* Clean up */ _destroyVideoSuiteTestWindow(window); - + /* Set some 'magic' value for later check that nothing was changed */ referenceW = SDLTest_RandomSint32(); referenceH = SDLTest_RandomSint32(); @@ -1328,17 +1328,17 @@ video_getSetWindowMinimumSize(void *arg) currentH = referenceH; desiredW = SDLTest_RandomSint32(); desiredH = SDLTest_RandomSint32(); - + /* Negative tests for window input */ SDL_ClearError(); SDLTest_AssertPass("Call to SDL_ClearError()"); SDL_GetWindowMinimumSize(NULL, ¤tW, ¤tH); SDLTest_AssertPass("Call to SDL_GetWindowMinimumSize(window=NULL)"); SDLTest_AssertCheck( - currentW == referenceW && currentH == referenceH, - "Verify that content of W and H pointers has not been modified; expected: %d,%d; got: %d,%d", - referenceW, referenceH, - currentW, currentH); + currentW == referenceW && currentH == referenceH, + "Verify that content of W and H pointers has not been modified; expected: %d,%d; got: %d,%d", + referenceW, referenceH, + currentW, currentH); _checkInvalidWindowError(); SDL_GetWindowMinimumSize(NULL, NULL, NULL); @@ -1348,7 +1348,7 @@ video_getSetWindowMinimumSize(void *arg) SDL_SetWindowMinimumSize(NULL, desiredW, desiredH); SDLTest_AssertPass("Call to SDL_SetWindowMinimumSize(window=NULL)"); _checkInvalidWindowError(); - + return TEST_COMPLETED; } @@ -1374,38 +1374,38 @@ video_getSetWindowMaximumSize(void *arg) SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result); if (result != 0) return TEST_ABORTED; - /* Call against new test window */ + /* Call against new test window */ window = _createVideoSuiteTestWindow(title); if (window == NULL) return TEST_ABORTED; - + for (wVariation = 0; wVariation < 3; wVariation++) { for (hVariation = 0; hVariation < 3; hVariation++) { switch(wVariation) { case 0: - /* 1 Pixel Wide */ + /* 1 Pixel Wide */ desiredW = 1; break; case 1: - /* Random width inside screen */ + /* Random width inside screen */ desiredW = SDLTest_RandomIntegerInRange(2, display.w - 1); break; case 2: - /* Width at screen size */ + /* Width at screen size */ desiredW = display.w; break; } switch(hVariation) { case 0: - /* 1 Pixel High */ + /* 1 Pixel High */ desiredH = 1; break; case 1: - /* Random height inside screen */ + /* Random height inside screen */ desiredH = SDLTest_RandomIntegerInRange(2, display.h - 1); break; case 2: - /* Height at screen size */ + /* Height at screen size */ desiredH = display.h; break; } @@ -1413,7 +1413,7 @@ video_getSetWindowMaximumSize(void *arg) /* Set size */ SDL_SetWindowMaximumSize(window, desiredW, desiredH); SDLTest_AssertPass("Call to SDL_SetWindowMaximumSize(...,%d,%d)", desiredW, desiredH); - + /* Get size */ currentW = desiredW + 1; currentH = desiredH + 1; @@ -1423,7 +1423,7 @@ video_getSetWindowMaximumSize(void *arg) SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH); /* Get just width */ - currentW = desiredW + 1; + currentW = desiredW + 1; SDL_GetWindowMaximumSize(window, ¤tW, NULL); SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(&h=NULL)"); SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentH); @@ -1442,20 +1442,20 @@ video_getSetWindowMaximumSize(void *arg) /* Negative tests for parameter input */ SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); + SDLTest_AssertPass("Call to SDL_ClearError()"); for (desiredH = -2; desiredH < 2; desiredH++) { for (desiredW = -2; desiredW < 2; desiredW++) { - if (desiredW <= 0 || desiredH <= 0) { + if (desiredW <= 0 || desiredH <= 0) { SDL_SetWindowMaximumSize(window, desiredW, desiredH); SDLTest_AssertPass("Call to SDL_SetWindowMaximumSize(...,%d,%d)", desiredW, desiredH); _checkInvalidParameterError(); } } } - - /* Clean up */ + + /* Clean up */ _destroyVideoSuiteTestWindow(window); - + /* Set some 'magic' value for later check that nothing was changed */ referenceW = SDLTest_RandomSint32(); referenceH = SDLTest_RandomSint32(); @@ -1463,17 +1463,17 @@ video_getSetWindowMaximumSize(void *arg) currentH = referenceH; desiredW = SDLTest_RandomSint32(); desiredH = SDLTest_RandomSint32(); - + /* Negative tests */ SDL_ClearError(); SDLTest_AssertPass("Call to SDL_ClearError()"); SDL_GetWindowMaximumSize(NULL, ¤tW, ¤tH); SDLTest_AssertPass("Call to SDL_GetWindowMaximumSize(window=NULL)"); SDLTest_AssertCheck( - currentW == referenceW && currentH == referenceH, - "Verify that content of W and H pointers has not been modified; expected: %d,%d; got: %d,%d", - referenceW, referenceH, - currentW, currentH); + currentW == referenceW && currentH == referenceH, + "Verify that content of W and H pointers has not been modified; expected: %d,%d; got: %d,%d", + referenceW, referenceH, + currentW, currentH); _checkInvalidWindowError(); SDL_GetWindowMaximumSize(NULL, NULL, NULL); @@ -1483,7 +1483,7 @@ video_getSetWindowMaximumSize(void *arg) SDL_SetWindowMaximumSize(NULL, desiredW, desiredH); SDLTest_AssertPass("Call to SDL_SetWindowMaximumSize(window=NULL)"); _checkInvalidWindowError(); - + return TEST_COMPLETED; } @@ -1512,47 +1512,47 @@ video_getSetWindowData(void *arg) char *result; int iteration; - /* Call against new test window */ + /* Call against new test window */ window = _createVideoSuiteTestWindow(title); if (window == NULL) return TEST_ABORTED; /* Create testdata */ - datasize = SDLTest_RandomIntegerInRange(1, 32); + datasize = SDLTest_RandomIntegerInRange(1, 32); referenceUserdata = SDLTest_RandomAsciiStringOfSize(datasize); - if (referenceUserdata == NULL) { - returnValue = TEST_ABORTED; - goto cleanup; + if (referenceUserdata == NULL) { + returnValue = TEST_ABORTED; + goto cleanup; } userdata = SDL_strdup(referenceUserdata); if (userdata == NULL) { - returnValue = TEST_ABORTED; - goto cleanup; + returnValue = TEST_ABORTED; + goto cleanup; } - datasize = SDLTest_RandomIntegerInRange(1, 32); + datasize = SDLTest_RandomIntegerInRange(1, 32); referenceUserdata2 = SDLTest_RandomAsciiStringOfSize(datasize); - if (referenceUserdata2 == NULL) { - returnValue = TEST_ABORTED; - goto cleanup; + if (referenceUserdata2 == NULL) { + returnValue = TEST_ABORTED; + goto cleanup; } userdata2 = (char *)SDL_strdup(referenceUserdata2); if (userdata2 == NULL) { - returnValue = TEST_ABORTED; - goto cleanup; + returnValue = TEST_ABORTED; + goto cleanup; } - + /* Get non-existent data */ result = (char *)SDL_GetWindowData(window, name); SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s)", name); SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); - + /* Set data */ result = (char *)SDL_SetWindowData(window, name, userdata); SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,%s)", name, userdata); SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata); - + /* Get data (twice) */ for (iteration = 1; iteration <= 2; iteration++) { result = (char *)SDL_GetWindowData(window, name); @@ -1560,7 +1560,7 @@ video_getSetWindowData(void *arg) SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, result) == 0, "Validate that correct result was returned; expected: %s, got: %s", referenceUserdata, result); SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); } - + /* Set data again twice */ for (iteration = 1; iteration <= 2; iteration++) { result = (char *)SDL_SetWindowData(window, name, userdata); @@ -1569,7 +1569,7 @@ video_getSetWindowData(void *arg) SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata); } - + /* Get data again */ result = (char *)SDL_GetWindowData(window, name); SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s) [again]", name); @@ -1591,7 +1591,7 @@ video_getSetWindowData(void *arg) SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata); SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, userdata2) == 0, "Validate that userdata2 was not changed, expected: %s, got: %s", referenceUserdata2, userdata2); - + /* Get new data */ result = (char *)SDL_GetWindowData(window, name); SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s)", name); @@ -1613,7 +1613,7 @@ video_getSetWindowData(void *arg) SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata); SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, userdata2) == 0, "Validate that userdata2 was not changed, expected: %s, got: %s", referenceUserdata2, userdata2); - + /* Get non-existent data */ result = (char *)SDL_GetWindowData(window, name); SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s)", name); @@ -1632,7 +1632,7 @@ video_getSetWindowData(void *arg) SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata); - + /* Get data (again) */ result = (char *)SDL_GetWindowData(window, name); SDLTest_AssertPass("Call to SDL_GetWindowData(..,%s) [again, after clear]", name); @@ -1643,12 +1643,12 @@ video_getSetWindowData(void *arg) SDL_ClearError(); SDLTest_AssertPass("Call to SDL_ClearError()"); - /* Set with invalid window */ + /* Set with invalid window */ result = (char *)SDL_SetWindowData(NULL, name, userdata); SDLTest_AssertPass("Call to SDL_SetWindowData(window=NULL)"); SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); _checkInvalidWindowError(); - + /* Set data with NULL name, valid userdata */ result = (char *)SDL_SetWindowData(window, NULL, userdata); SDLTest_AssertPass("Call to SDL_SetWindowData(name=NULL)"); @@ -1678,7 +1678,7 @@ video_getSetWindowData(void *arg) SDLTest_AssertPass("Call to SDL_GetWindowData(window=NULL)"); SDLTest_AssertCheck(result == NULL, "Validate that result is NULL"); _checkInvalidWindowError(); - + /* Get data with NULL name */ result = (char *)SDL_GetWindowData(window, NULL); SDLTest_AssertPass("Call to SDL_GetWindowData(name=NULL)"); @@ -1693,13 +1693,13 @@ video_getSetWindowData(void *arg) /* Clean up */ _destroyVideoSuiteTestWindow(window); - + cleanup: if (referenceUserdata != NULL) SDL_free(referenceUserdata); if (referenceUserdata2 != NULL) SDL_free(referenceUserdata2); if (userdata != NULL) SDL_free(userdata); if (userdata2 != NULL) SDL_free(userdata2); - + return returnValue; } @@ -1708,87 +1708,87 @@ video_getSetWindowData(void *arg) /* Video test cases */ static const SDLTest_TestCaseReference videoTest1 = - { (SDLTest_TestCaseFp)video_enableDisableScreensaver, "video_enableDisableScreensaver", "Enable and disable screenaver while checking state", TEST_ENABLED }; + { (SDLTest_TestCaseFp)video_enableDisableScreensaver, "video_enableDisableScreensaver", "Enable and disable screenaver while checking state", TEST_ENABLED }; static const SDLTest_TestCaseReference videoTest2 = - { (SDLTest_TestCaseFp)video_createWindowVariousPositions, "video_createWindowVariousPositions", "Create windows at various locations", TEST_ENABLED }; + { (SDLTest_TestCaseFp)video_createWindowVariousPositions, "video_createWindowVariousPositions", "Create windows at various locations", TEST_ENABLED }; static const SDLTest_TestCaseReference videoTest3 = - { (SDLTest_TestCaseFp)video_createWindowVariousSizes, "video_createWindowVariousSizes", "Create windows with various sizes", TEST_ENABLED }; + { (SDLTest_TestCaseFp)video_createWindowVariousSizes, "video_createWindowVariousSizes", "Create windows with various sizes", TEST_ENABLED }; static const SDLTest_TestCaseReference videoTest4 = - { (SDLTest_TestCaseFp)video_createWindowVariousFlags, "video_createWindowVariousFlags", "Create windows using various flags", TEST_ENABLED }; + { (SDLTest_TestCaseFp)video_createWindowVariousFlags, "video_createWindowVariousFlags", "Create windows using various flags", TEST_ENABLED }; static const SDLTest_TestCaseReference videoTest5 = - { (SDLTest_TestCaseFp)video_getWindowFlags, "video_getWindowFlags", "Get window flags set during SDL_CreateWindow", TEST_ENABLED }; + { (SDLTest_TestCaseFp)video_getWindowFlags, "video_getWindowFlags", "Get window flags set during SDL_CreateWindow", TEST_ENABLED }; static const SDLTest_TestCaseReference videoTest6 = - { (SDLTest_TestCaseFp)video_getNumDisplayModes, "video_getNumDisplayModes", "Use SDL_GetNumDisplayModes function to get number of display modes", TEST_ENABLED }; + { (SDLTest_TestCaseFp)video_getNumDisplayModes, "video_getNumDisplayModes", "Use SDL_GetNumDisplayModes function to get number of display modes", TEST_ENABLED }; static const SDLTest_TestCaseReference videoTest7 = - { (SDLTest_TestCaseFp)video_getNumDisplayModesNegative, "video_getNumDisplayModesNegative", "Negative tests for SDL_GetNumDisplayModes", TEST_ENABLED }; + { (SDLTest_TestCaseFp)video_getNumDisplayModesNegative, "video_getNumDisplayModesNegative", "Negative tests for SDL_GetNumDisplayModes", TEST_ENABLED }; static const SDLTest_TestCaseReference videoTest8 = - { (SDLTest_TestCaseFp)video_getClosestDisplayModeCurrentResolution, "video_getClosestDisplayModeCurrentResolution", "Use function to get closes match to requested display mode for current resolution", TEST_ENABLED }; + { (SDLTest_TestCaseFp)video_getClosestDisplayModeCurrentResolution, "video_getClosestDisplayModeCurrentResolution", "Use function to get closes match to requested display mode for current resolution", TEST_ENABLED }; static const SDLTest_TestCaseReference videoTest9 = - { (SDLTest_TestCaseFp)video_getClosestDisplayModeRandomResolution, "video_getClosestDisplayModeRandomResolution", "Use function to get closes match to requested display mode for random resolution", TEST_ENABLED }; + { (SDLTest_TestCaseFp)video_getClosestDisplayModeRandomResolution, "video_getClosestDisplayModeRandomResolution", "Use function to get closes match to requested display mode for random resolution", TEST_ENABLED }; static const SDLTest_TestCaseReference videoTest10 = - { (SDLTest_TestCaseFp)video_getWindowBrightness, "video_getWindowBrightness", "Get window brightness", TEST_ENABLED }; + { (SDLTest_TestCaseFp)video_getWindowBrightness, "video_getWindowBrightness", "Get window brightness", TEST_ENABLED }; static const SDLTest_TestCaseReference videoTest11 = - { (SDLTest_TestCaseFp)video_getWindowBrightnessNegative, "video_getWindowBrightnessNegative", "Get window brightness with invalid input", TEST_ENABLED }; + { (SDLTest_TestCaseFp)video_getWindowBrightnessNegative, "video_getWindowBrightnessNegative", "Get window brightness with invalid input", TEST_ENABLED }; static const SDLTest_TestCaseReference videoTest12 = - { (SDLTest_TestCaseFp)video_getWindowDisplayMode, "video_getWindowDisplayMode", "Get window display mode", TEST_ENABLED }; + { (SDLTest_TestCaseFp)video_getWindowDisplayMode, "video_getWindowDisplayMode", "Get window display mode", TEST_ENABLED }; static const SDLTest_TestCaseReference videoTest13 = - { (SDLTest_TestCaseFp)video_getWindowDisplayModeNegative, "video_getWindowDisplayModeNegative", "Get window display mode with invalid input", TEST_ENABLED }; + { (SDLTest_TestCaseFp)video_getWindowDisplayModeNegative, "video_getWindowDisplayModeNegative", "Get window display mode with invalid input", TEST_ENABLED }; static const SDLTest_TestCaseReference videoTest14 = - { (SDLTest_TestCaseFp)video_getWindowGammaRamp, "video_getWindowGammaRamp", "Get window gamma ramp", TEST_ENABLED }; + { (SDLTest_TestCaseFp)video_getWindowGammaRamp, "video_getWindowGammaRamp", "Get window gamma ramp", TEST_ENABLED }; static const SDLTest_TestCaseReference videoTest15 = - { (SDLTest_TestCaseFp)video_getWindowGammaRampNegative, "video_getWindowGammaRampNegative", "Get window gamma ramp against invalid input", TEST_ENABLED }; + { (SDLTest_TestCaseFp)video_getWindowGammaRampNegative, "video_getWindowGammaRampNegative", "Get window gamma ramp against invalid input", TEST_ENABLED }; static const SDLTest_TestCaseReference videoTest16 = - { (SDLTest_TestCaseFp)video_getSetWindowGrab, "video_getSetWindowGrab", "Checks SDL_GetWindowGrab and SDL_SetWindowGrab positive and negative cases", TEST_ENABLED }; + { (SDLTest_TestCaseFp)video_getSetWindowGrab, "video_getSetWindowGrab", "Checks SDL_GetWindowGrab and SDL_SetWindowGrab positive and negative cases", TEST_ENABLED }; static const SDLTest_TestCaseReference videoTest17 = - { (SDLTest_TestCaseFp)video_getWindowId, "video_getWindowId", "Checks SDL_GetWindowID and SDL_GetWindowFromID", TEST_ENABLED }; + { (SDLTest_TestCaseFp)video_getWindowId, "video_getWindowId", "Checks SDL_GetWindowID and SDL_GetWindowFromID", TEST_ENABLED }; static const SDLTest_TestCaseReference videoTest18 = - { (SDLTest_TestCaseFp)video_getWindowPixelFormat, "video_getWindowPixelFormat", "Checks SDL_GetWindowPixelFormat", TEST_ENABLED }; + { (SDLTest_TestCaseFp)video_getWindowPixelFormat, "video_getWindowPixelFormat", "Checks SDL_GetWindowPixelFormat", TEST_ENABLED }; static const SDLTest_TestCaseReference videoTest19 = - { (SDLTest_TestCaseFp)video_getSetWindowPosition, "video_getSetWindowPosition", "Checks SDL_GetWindowPosition and SDL_SetWindowPosition positive and negative cases", TEST_ENABLED }; + { (SDLTest_TestCaseFp)video_getSetWindowPosition, "video_getSetWindowPosition", "Checks SDL_GetWindowPosition and SDL_SetWindowPosition positive and negative cases", TEST_ENABLED }; static const SDLTest_TestCaseReference videoTest20 = - { (SDLTest_TestCaseFp)video_getSetWindowSize, "video_getSetWindowSize", "Checks SDL_GetWindowSize and SDL_SetWindowSize positive and negative cases", TEST_ENABLED }; + { (SDLTest_TestCaseFp)video_getSetWindowSize, "video_getSetWindowSize", "Checks SDL_GetWindowSize and SDL_SetWindowSize positive and negative cases", TEST_ENABLED }; static const SDLTest_TestCaseReference videoTest21 = - { (SDLTest_TestCaseFp)video_getSetWindowMinimumSize, "video_getSetWindowMinimumSize", "Checks SDL_GetWindowMinimumSize and SDL_SetWindowMinimumSize positive and negative cases", TEST_ENABLED }; + { (SDLTest_TestCaseFp)video_getSetWindowMinimumSize, "video_getSetWindowMinimumSize", "Checks SDL_GetWindowMinimumSize and SDL_SetWindowMinimumSize positive and negative cases", TEST_ENABLED }; static const SDLTest_TestCaseReference videoTest22 = - { (SDLTest_TestCaseFp)video_getSetWindowMaximumSize, "video_getSetWindowMaximumSize", "Checks SDL_GetWindowMaximumSize and SDL_SetWindowMaximumSize positive and negative cases", TEST_ENABLED }; + { (SDLTest_TestCaseFp)video_getSetWindowMaximumSize, "video_getSetWindowMaximumSize", "Checks SDL_GetWindowMaximumSize and SDL_SetWindowMaximumSize positive and negative cases", TEST_ENABLED }; static const SDLTest_TestCaseReference videoTest23 = - { (SDLTest_TestCaseFp)video_getSetWindowData, "video_getSetWindowData", "Checks SDL_SetWindowData and SDL_GetWindowData positive and negative cases", TEST_ENABLED }; + { (SDLTest_TestCaseFp)video_getSetWindowData, "video_getSetWindowData", "Checks SDL_SetWindowData and SDL_GetWindowData positive and negative cases", TEST_ENABLED }; /* Sequence of Video test cases */ static const SDLTest_TestCaseReference *videoTests[] = { - &videoTest1, &videoTest2, &videoTest3, &videoTest4, &videoTest5, &videoTest6, - &videoTest7, &videoTest8, &videoTest9, &videoTest10, &videoTest11, &videoTest12, - &videoTest13, &videoTest14, &videoTest15, &videoTest16, &videoTest17, - &videoTest18, &videoTest19, &videoTest20, &videoTest21, &videoTest22, - &videoTest23, NULL + &videoTest1, &videoTest2, &videoTest3, &videoTest4, &videoTest5, &videoTest6, + &videoTest7, &videoTest8, &videoTest9, &videoTest10, &videoTest11, &videoTest12, + &videoTest13, &videoTest14, &videoTest15, &videoTest16, &videoTest17, + &videoTest18, &videoTest19, &videoTest20, &videoTest21, &videoTest22, + &videoTest23, NULL }; /* Video test suite (global) */ SDLTest_TestSuiteReference videoTestSuite = { - "Video", - NULL, - videoTests, - NULL + "Video", + NULL, + videoTests, + NULL }; diff --git a/test/testdraw2.c b/test/testdraw2.c index 3fced878d..272c5067b 100644 --- a/test/testdraw2.c +++ b/test/testdraw2.c @@ -18,7 +18,7 @@ #include "SDL_test_common.h" -#define NUM_OBJECTS 100 +#define NUM_OBJECTS 100 static SDLTest_CommonState *state; static int num_objects; diff --git a/test/testfile.c b/test/testfile.c index 3ee75ba91..6496eccd3 100644 --- a/test/testfile.c +++ b/test/testfile.c @@ -30,11 +30,11 @@ /* WARNING ! those 2 files will be destroyed by this test program */ #ifdef __IPHONEOS__ -#define FBASENAME1 "../Documents/sdldata1" /* this file will be created during tests */ +#define FBASENAME1 "../Documents/sdldata1" /* this file will be created during tests */ #define FBASENAME2 "../Documents/sdldata2" /* this file should not exist before starting test */ #else -#define FBASENAME1 "sdldata1" /* this file will be created during tests */ -#define FBASENAME2 "sdldata2" /* this file should not exist before starting test */ +#define FBASENAME1 "sdldata1" /* this file will be created during tests */ +#define FBASENAME2 "sdldata2" /* this file should not exist before starting test */ #endif #ifndef NULL @@ -61,7 +61,7 @@ rwops_error_quit(unsigned line, SDL_RWops * rwops) exit(1); /* quit with rwops error (test failed) */ } -#define RWOP_ERR_QUIT(x) rwops_error_quit( __LINE__, (x) ) +#define RWOP_ERR_QUIT(x) rwops_error_quit( __LINE__, (x) ) @@ -93,9 +93,9 @@ main(int argc, char *argv[]) printf("test1 OK\n"); /* test 2 : check that inexistant file is not successfully opened/created when required */ -/* modes : r, r+ implie that file MUST exist +/* modes : r, r+ implie that file MUST exist modes : a, a+, w, w+ checks that it succeeds (file may not exists) - + */ rwops = SDL_RWFromFile(FBASENAME2, "rb"); /* this file doesn't exist that call must fail */ if (rwops) @@ -125,8 +125,8 @@ main(int argc, char *argv[]) unlink(FBASENAME2); printf("test2 OK\n"); -/* test 3 : creation, writing , reading, seeking, - test : w mode, r mode, w+ mode +/* test 3 : creation, writing , reading, seeking, + test : w mode, r mode, w+ mode */ rwops = SDL_RWFromFile(FBASENAME1, "wb"); /* write only */ if (!rwops) diff --git a/test/testgamecontroller.c b/test/testgamecontroller.c index 2e9d98ad5..0ca424627 100644 --- a/test/testgamecontroller.c +++ b/test/testgamecontroller.c @@ -125,7 +125,7 @@ WatchGameController(SDL_GameController * gamecontroller) /* Print info about the controller we are watching */ printf("Watching controller %s\n", name ? name : "Unknown Controller"); - + /* Loop, getting controller events! */ while (!done) { /* blank screen, set up for drawing this frame. */ @@ -199,7 +199,7 @@ WatchGameController(SDL_GameController * gamecontroller) SDL_SetRenderDrawColor(screen, 0x00, 0x00, 0xFF, SDL_ALPHA_OPAQUE); SDL_RenderPresent(screen); - + if ( !done ) done = SDL_GameControllerGetAttached( gamecontroller ) == 0; } diff --git a/test/testgesture.c b/test/testgesture.c index 53e7e8a55..0f5356191 100644 --- a/test/testgesture.c +++ b/test/testgesture.c @@ -93,12 +93,12 @@ void setpix(SDL_Surface *screen, float _x, float _y, unsigned int col) int x = (int)_x; int y = (int)_y; float a; - + if(x < 0 || x >= screen->w) return; if(y < 0 || y >= screen->h) return; pixmem32 = (Uint32*) screen->pixels + y*screen->pitch/BPP + x; - + SDL_memcpy(&colour,pixmem32,screen->format->BytesPerPixel); SDL_GetRGB(colour,screen->format,&r,&g,&b); @@ -110,7 +110,7 @@ void setpix(SDL_Surface *screen, float _x, float _y, unsigned int col) g = (Uint8)(g*(1-a) + ((col>> 8)&0xFF)*(a)); b = (Uint8)(b*(1-a) + ((col>> 0)&0xFF)*(a)); colour = SDL_MapRGB( screen->format,r, g, b); - + *pixmem32 = colour; } @@ -129,7 +129,7 @@ void drawCircle(SDL_Surface* screen,float x,float y,float r,unsigned int c) xr = (float)sqrt(r*r - ty*ty); if(r > 0) { //r > 0 ==> filled circle for(tx=-xr+.5f;tx<=xr-.5;tx++) { - setpix(screen,x+tx,y+ty,c); + setpix(screen,x+tx,y+ty,c); } } else { @@ -140,9 +140,9 @@ void drawCircle(SDL_Surface* screen,float x,float y,float r,unsigned int c) } void drawKnob(SDL_Surface* screen,Knob k) { - drawCircle(screen,k.p.x*screen->w,k.p.y*screen->h,k.r*screen->w,0xFFFFFF); + drawCircle(screen,k.p.x*screen->w,k.p.y*screen->h,k.r*screen->w,0xFFFFFF); drawCircle(screen,(k.p.x+k.r/2*cosf(k.ang))*screen->w, - (k.p.y+k.r/2*sinf(k.ang))*screen->h,k.r/4*screen->w,0); + (k.p.y+k.r/2*sinf(k.ang))*screen->h,k.r/4*screen->w,0); } void DrawScreen(SDL_Surface* screen) @@ -154,36 +154,36 @@ void DrawScreen(SDL_Surface* screen) int x, y; for(y = 0;y < screen->h;y++) for(x = 0;x < screen->w;x++) - setpix(screen,(float)x,(float)y,((x%255)<<16) + ((y%255)<<8) + (x+y)%255); + setpix(screen,(float)x,(float)y,((x%255)<<16) + ((y%255)<<8) + (x+y)%255); #endif //draw Touch History for(i = eventWrite; i < eventWrite+EVENT_BUF_SIZE; ++i) { const SDL_Event *event = &events[i&(EVENT_BUF_SIZE-1)]; float age = (float)(i - eventWrite) / EVENT_BUF_SIZE; - float x, y; - unsigned int c, col; + float x, y; + unsigned int c, col; - if(event->type == SDL_FINGERMOTION || + if(event->type == SDL_FINGERMOTION || event->type == SDL_FINGERDOWN || event->type == SDL_FINGERUP) { x = event->tfinger.x; y = event->tfinger.y; - - //draw the touch: - c = colors[event->tfinger.fingerId%7]; + + //draw the touch: + c = colors[event->tfinger.fingerId%7]; col = ((unsigned int)(c*(.1+.85))) | (unsigned int)(0xFF*age)<<24; if(event->type == SDL_FINGERMOTION) - drawCircle(screen,x*screen->w,y*screen->h,5,col); + drawCircle(screen,x*screen->w,y*screen->h,5,col); else if(event->type == SDL_FINGERDOWN) - drawCircle(screen,x*screen->w,y*screen->h,-10,col); + drawCircle(screen,x*screen->w,y*screen->h,-10,col); } } - + if(knob.p.x > 0) drawKnob(screen,knob); - + SDL_UpdateWindowSurface(window); } @@ -201,7 +201,7 @@ SDL_Surface* initScreen(int width,int height) } int main(int argc, char* argv[]) -{ +{ SDL_Surface *screen; SDL_Event event; SDL_bool quitting = SDL_FALSE; @@ -212,7 +212,7 @@ int main(int argc, char* argv[]) knob.ang = 0; if (SDL_Init(SDL_INIT_VIDEO) < 0 ) return 1; - + if (!(screen = initScreen(WIDTH,HEIGHT))) { SDL_Quit(); @@ -220,92 +220,92 @@ int main(int argc, char* argv[]) } while(!quitting) { - while(SDL_PollEvent(&event)) + while(SDL_PollEvent(&event)) + { + //Record _all_ events + events[eventWrite & (EVENT_BUF_SIZE-1)] = event; + eventWrite++; + + switch (event.type) { - //Record _all_ events - events[eventWrite & (EVENT_BUF_SIZE-1)] = event; - eventWrite++; - - switch (event.type) - { - case SDL_QUIT: - quitting = SDL_TRUE; - break; - case SDL_KEYDOWN: - switch (event.key.keysym.sym) - { - case SDLK_SPACE: - SDL_RecordGesture(-1); - break; - case SDLK_s: - src = SDL_RWFromFile("gestureSave","w"); - SDL_Log("Wrote %i templates",SDL_SaveAllDollarTemplates(src)); - SDL_RWclose(src); - break; - case SDLK_l: - src = SDL_RWFromFile("gestureSave","r"); - SDL_Log("Loaded: %i",SDL_LoadDollarTemplates(-1,src)); - SDL_RWclose(src); - break; - case SDLK_ESCAPE: - quitting = SDL_TRUE; - break; - } - break; - case SDL_WINDOWEVENT: + case SDL_QUIT: + quitting = SDL_TRUE; + break; + case SDL_KEYDOWN: + switch (event.key.keysym.sym) + { + case SDLK_SPACE: + SDL_RecordGesture(-1); + break; + case SDLK_s: + src = SDL_RWFromFile("gestureSave","w"); + SDL_Log("Wrote %i templates",SDL_SaveAllDollarTemplates(src)); + SDL_RWclose(src); + break; + case SDLK_l: + src = SDL_RWFromFile("gestureSave","r"); + SDL_Log("Loaded: %i",SDL_LoadDollarTemplates(-1,src)); + SDL_RWclose(src); + break; + case SDLK_ESCAPE: + quitting = SDL_TRUE; + break; + } + break; + case SDL_WINDOWEVENT: if (event.window.event == SDL_WINDOWEVENT_RESIZED) { - if (!(screen = initScreen(event.window.data1, event.window.data2))) - { - SDL_Quit(); - return 1; - } + if (!(screen = initScreen(event.window.data1, event.window.data2))) + { + SDL_Quit(); + return 1; + } } - break; - case SDL_FINGERMOTION: + break; + case SDL_FINGERMOTION: #if VERBOSE - SDL_Log("Finger: %i,x: %i, y: %i",event.tfinger.fingerId, - event.tfinger.x,event.tfinger.y); + SDL_Log("Finger: %i,x: %i, y: %i",event.tfinger.fingerId, + event.tfinger.x,event.tfinger.y); #endif - break; - case SDL_FINGERDOWN: + break; + case SDL_FINGERDOWN: #if VERBOSE - SDL_Log("Finger: %"PRIs64" down - x: %i, y: %i", - event.tfinger.fingerId,event.tfinger.x,event.tfinger.y); + SDL_Log("Finger: %"PRIs64" down - x: %i, y: %i", + event.tfinger.fingerId,event.tfinger.x,event.tfinger.y); #endif - break; - case SDL_FINGERUP: + break; + case SDL_FINGERUP: #if VERBOSE - SDL_Log("Finger: %"PRIs64" up - x: %i, y: %i", - event.tfinger.fingerId,event.tfinger.x,event.tfinger.y); + SDL_Log("Finger: %"PRIs64" up - x: %i, y: %i", + event.tfinger.fingerId,event.tfinger.x,event.tfinger.y); #endif - break; - case SDL_MULTIGESTURE: -#if VERBOSE - SDL_Log("Multi Gesture: x = %f, y = %f, dAng = %f, dR = %f", - event.mgesture.x, - event.mgesture.y, - event.mgesture.dTheta, - event.mgesture.dDist); - SDL_Log("MG: numDownTouch = %i",event.mgesture.numFingers); + break; + case SDL_MULTIGESTURE: +#if VERBOSE + SDL_Log("Multi Gesture: x = %f, y = %f, dAng = %f, dR = %f", + event.mgesture.x, + event.mgesture.y, + event.mgesture.dTheta, + event.mgesture.dDist); + SDL_Log("MG: numDownTouch = %i",event.mgesture.numFingers); #endif - knob.p.x = event.mgesture.x; - knob.p.y = event.mgesture.y; - knob.ang += event.mgesture.dTheta; - knob.r += event.mgesture.dDist; - break; - case SDL_DOLLARGESTURE: - SDL_Log("Gesture %"PRIs64" performed, error: %f", - event.dgesture.gestureId, - event.dgesture.error); - break; - case SDL_DOLLARRECORD: - SDL_Log("Recorded gesture: %"PRIs64"",event.dgesture.gestureId); - break; - } + knob.p.x = event.mgesture.x; + knob.p.y = event.mgesture.y; + knob.ang += event.mgesture.dTheta; + knob.r += event.mgesture.dDist; + break; + case SDL_DOLLARGESTURE: + SDL_Log("Gesture %"PRIs64" performed, error: %f", + event.dgesture.gestureId, + event.dgesture.error); + break; + case SDL_DOLLARRECORD: + SDL_Log("Recorded gesture: %"PRIs64"",event.dgesture.gestureId); + break; + } } DrawScreen(screen); - } - SDL_Quit(); + } + SDL_Quit(); return 0; } diff --git a/test/testime.c b/test/testime.c index e9a469328..2fa65e6e1 100644 --- a/test/testime.c +++ b/test/testime.c @@ -238,7 +238,7 @@ int main(int argc, char *argv[]) { } } } - + if (!SDLTest_CommonInit(state)) { return 2; } @@ -267,7 +267,7 @@ int main(int argc, char *argv[]) { SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF); SDL_RenderClear(renderer); } - Redraw(); + Redraw(); /* Main render loop */ done = 0; while (!done) { @@ -356,7 +356,7 @@ int main(int argc, char *argv[]) { break; } break; - + } } } diff --git a/test/testintersections.c b/test/testintersections.c index e892f8d87..c93f04ed9 100644 --- a/test/testintersections.c +++ b/test/testintersections.c @@ -19,7 +19,7 @@ #include "SDL_test_common.h" #define SWAP(typ,a,b) do{typ t=a;a=b;b=t;}while(0) -#define NUM_OBJECTS 100 +#define NUM_OBJECTS 100 static SDLTest_CommonState *state; static int num_objects; diff --git a/test/testjoystick.c b/test/testjoystick.c index df94631f1..7132e667a 100644 --- a/test/testjoystick.c +++ b/test/testjoystick.c @@ -21,11 +21,11 @@ #ifndef SDL_JOYSTICK_DISABLED #ifdef __IPHONEOS__ -#define SCREEN_WIDTH 320 -#define SCREEN_HEIGHT 480 +#define SCREEN_WIDTH 320 +#define SCREEN_HEIGHT 480 #else -#define SCREEN_WIDTH 640 -#define SCREEN_HEIGHT 480 +#define SCREEN_WIDTH 640 +#define SCREEN_HEIGHT 480 #endif diff --git a/test/testlock.c b/test/testlock.c index 04abf3d7f..e77a2c42d 100644 --- a/test/testlock.c +++ b/test/testlock.c @@ -10,7 +10,7 @@ freely. */ -/* Test the thread and mutex locking functions +/* Test the thread and mutex locking functions Also exercises the system's signal/thread interaction */ diff --git a/test/testnative.c b/test/testnative.c index ec66c18aa..2579b18b9 100644 --- a/test/testnative.c +++ b/test/testnative.c @@ -18,7 +18,7 @@ #define WINDOW_W 640 #define WINDOW_H 480 #define NUM_SPRITES 100 -#define MAX_SPEED 1 +#define MAX_SPEED 1 static NativeWindowFactory *factories[] = { #ifdef TEST_NATIVE_WINDOWS diff --git a/test/testrelative.c b/test/testrelative.c index 44ffaf028..6cb9d364e 100644 --- a/test/testrelative.c +++ b/test/testrelative.c @@ -35,7 +35,7 @@ main(int argc, char *argv[]) int i, done; SDL_Event event; - + /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); if (!state) { diff --git a/test/testsem.c b/test/testsem.c index 9d5d027a3..6f463747a 100644 --- a/test/testsem.c +++ b/test/testsem.c @@ -74,7 +74,7 @@ TestWaitTimeout(void) fprintf(stderr, "Wait took %d milliseconds\n", duration); /* Check to make sure the return value indicates timed out */ - if (retval != SDL_MUTEX_TIMEDOUT) + if (retval != SDL_MUTEX_TIMEDOUT) fprintf(stderr, "SDL_SemWaitTimeout returned: %d; expected: %d\n", retval, SDL_MUTEX_TIMEDOUT); } diff --git a/test/testshader.c b/test/testshader.c index 5d3963652..c555335d2 100644 --- a/test/testshader.c +++ b/test/testshader.c @@ -119,7 +119,7 @@ static ShaderData shaders[NUM_SHADERS] = { "}" }, }; - + static PFNGLATTACHOBJECTARBPROC glAttachObjectARB; static PFNGLCOMPILESHADERARBPROC glCompileShaderARB; static PFNGLCREATEPROGRAMOBJECTARBPROC glCreateProgramObjectARB; @@ -195,7 +195,7 @@ static SDL_bool CompileShaderProgram(ShaderData *data) } } glUseProgramObjectARB(0); - + return (glGetError() == GL_NO_ERROR); } @@ -382,7 +382,7 @@ void DrawGLScene(GLuint texture, GLfloat * texcoord) glLoadIdentity(); // Reset The View glTranslatef(-1.5f,0.0f,0.0f); // Move Left 1.5 Units - + // draw a triangle (in smooth coloring mode) glBegin(GL_POLYGON); // start drawing a polygon glColor3f(1.0f,0.0f,0.0f); // Set The Color To Red @@ -390,8 +390,8 @@ void DrawGLScene(GLuint texture, GLfloat * texcoord) glColor3f(0.0f,1.0f,0.0f); // Set The Color To Green glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right glColor3f(0.0f,0.0f,1.0f); // Set The Color To Blue - glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left - glEnd(); // we're done with the polygon (smooth color interpolation) + glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left + glEnd(); // we're done with the polygon (smooth color interpolation) glTranslatef(3.0f,0.0f,0.0f); // Move Right 3 Units @@ -416,7 +416,7 @@ void DrawGLScene(GLuint texture, GLfloat * texcoord) glTexCoord2f(texcoord[MAXX], texcoord[MAXY]); glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right glTexCoord2f(texcoord[MINX], texcoord[MAXY]); - glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left + glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left glEnd(); // done with the polygon if (shaders_supported) { @@ -428,8 +428,8 @@ void DrawGLScene(GLuint texture, GLfloat * texcoord) SDL_GL_SwapBuffers(); } -int main(int argc, char **argv) -{ +int main(int argc, char **argv) +{ int done; SDL_Surface *surface; GLuint texture; diff --git a/test/testshape.c b/test/testshape.c index 3afb19406..7eb8d9c75 100644 --- a/test/testshape.c +++ b/test/testshape.c @@ -32,10 +32,10 @@ void render(SDL_Renderer *renderer,SDL_Texture *texture,SDL_Rect texture_dimensi //Clear render-target to blue. SDL_SetRenderDrawColor(renderer,0x00,0x00,0xff,0xff); SDL_RenderClear(renderer); - + //Render the texture. SDL_RenderCopy(renderer,texture,&texture_dimensions,&texture_dimensions); - + SDL_RenderPresent(renderer); } @@ -72,12 +72,12 @@ int main(int argc,char** argv) printf("SDL_Shape requires at least one bitmap file as argument.\n"); exit(-1); } - + if(SDL_VideoInit(NULL) == -1) { printf("Could not initialize SDL video.\n"); exit(-2); } - + num_pictures = argc - 1; pictures = (LoadedPicture *)malloc(sizeof(LoadedPicture)*num_pictures); for(i=0;i