Commit Graph

256 Commits

Author SHA1 Message Date
Sam Lantinga
1e2caac58b Added SDL_JoystickRumbleTriggers() and SDL_GameControllerRumbleTriggers() 2020-11-11 18:57:37 -08:00
Ryan C. Gordon
c3a32605f8 testvulkan: Patched to compile with SDL's internal Vulkan headers. 2020-11-09 04:55:15 -05:00
Sam Lantinga
009b62f1c2 Be explicit about mapping the new game controller paddle buttons 2020-11-07 02:22:15 -08:00
Sam Lantinga
5a92edee03 Don't try to map the accelerometer as a game controller 2020-11-06 15:54:18 -08:00
Sam Lantinga
59a644fb01 iOS should use the same size window for the controller tests as other platforms
Otherwise the position of the button and axis elements won't be correct
2020-11-06 14:44:26 -08:00
Sam Lantinga
3a3aaac221 Added 4 auxiliary buttons to the game controller API
Xbox Elite controllers use AUX1-AUX4 to represent the paddle buttons when using the HIDAPI driver
PS4 and PS5 controllers use AUX1 to represent the touchpad button
Nintendo Switch Pro controllers use AUX1 to represent the capture button
2020-11-06 11:30:52 -08:00
Sam Lantinga
e555d45331 Added SDL_JoystickHasLED
Currently, this is only supported by the PS4 HIDAPI driver.
2020-11-05 11:07:54 -08:00
Ozkan Sezer
d27238751f os2: integrate the port into main tree. 2020-10-14 23:01:06 +03:00
Ozkan Sezer
1d9cf23e4c os2: updated copyright dates for 2020. header guard fixes. 2020-10-14 23:01:05 +03:00
Ozkan Sezer
4551c63372 os2: make testnative working -- imported from bitwiseworks' fork:
e2abc76b24
2020-10-14 23:01:02 +03:00
Ozkan Sezer
74cfb81dbb os2: add port files for SDL2-2.0.4 from Andrey Vasilkin
only geniconv/iconv.h (was from LGPL libiconv) is replaced with a generic
minimal iconv.h based on public knowledge.
2020-10-14 23:01:00 +03:00
Ozkan Sezer
10eb5108b6 test/Makefile.os2: add testlocale.exe to build. 2020-10-11 20:00:20 +03:00
Ryan C. Gordon
b7b2995fbe url: Added to Visual Studio project files. 2020-10-05 15:27:32 -04:00
Ryan C. Gordon
77c9d73b63 Removed SDL_AndroidOpenURL, added SDL_OpenURL.
Still needs to be wired into Xcode and Visual Studio projects.
2020-10-05 11:30:33 -04:00
Ryan C. Gordon
0e98040d43 joystick: Linux joysticks now recover better from dropped events.
Fixes Bugzilla #4830.
2020-06-28 16:23:05 -04:00
Ryan C. Gordon
50fd0dd143 test: testspriteminimal wasn't calling SDL_Quit() on exit. 2020-06-26 21:35:54 -04:00
Ryan C. Gordon
fa23e3d00b locale: Implemented SDL_GetPreferredLocales().
This was something I proposed a long time ago, Sylvain Becker did
additional work on it, then back to me.

Fixes Bugzilla #2131.
2020-05-04 02:27:29 -04:00
Sam Lantinga
aba2792896 Added a Windows Gaming Input joystick driver
This driver supports the Razer Atrox Arcade Stick

Some of the quirks of this driver, inherent in Windows Gaming Input:
* There will never appear to be controllers connected at startup. You must support hot-plugging in order to see these controllers.
* You can't read the state of the guide button
* You can't get controller events in the background
2020-04-18 21:41:37 -07:00
Sam Lantinga
ef147d2e29 Enable virtual joystick API by default 2020-04-13 08:13:50 -07:00
Sam Lantinga
3d942ccc15 Removed debug code 2020-04-08 09:02:02 -07:00
Sam Lantinga
09f552639a Fixed memory leak and removed debug code from Windows sensor implementation 2020-04-08 09:00:10 -07:00
Jay Petacat
c760c02c6c Fix some format specifier warnings
The warnings were produced by GCC 9.2.x for x86_64-linux-gnu or
i386-pc-msdosdjgpp targets.

Most of the fixes involve changing the type of a variable rather than
the format specifier. For many of the affected test conuter variables,
a basic int seems sufficient.

Some format specifier warnings still remain for cases where changing
type or casting seemed inappropriate. Those warnings will probably
require some new format specifier macros (e.g. SDL_PRIu32).
2020-03-25 01:34:15 -04:00
Sam Lantinga
89fe32ddf9 Fixed bug 5072 - Test resources missing when building with SDL_TEST and CMake
DominikD

There are several tests that need resources in the output directory to work:
* `testiconv` depends on `utf8.txt`
* `testoverlay2` and `teststreaming` depend on `moose.dat`

This patch adds these two files to the `RESOURCE_FILES` variable.

One could also copy `shapes\*.bmp` over to the output directory for `testshape` to use but this patch doesn't do that for three reasons:
* executable takes path as an argument and doesn't need these files side by side
* these are ~45MB and copying them over would cause build directory to swell
* there are already files in the output directory that can be used with this test (`sample.bmp` and `button.bmp`)
2020-04-05 08:46:59 -07:00
Ryan C. Gordon
377f2d35d5 configure: Remove wayland-protocols check from configure and CMake scripts.
We ship these with SDL now, don't need the system versions installed.
2020-04-01 13:43:53 -04:00
Sam Lantinga
2be75c6a61 Fixed bug 5028 - Virtual Joysticks (new joystick backend)
David Ludwig

I have created a new driver for SDL's Joystick and Game-Controller subsystem: a Virtual driver.  This driver allows one to create a software-based joystick, which to SDL applications will look and react like a real joystick, but whose state can be set programmatically.  A primary use case for this is to help enable developers to add touch-screen joysticks to their apps.

The driver comes with a set of new, public APIs, with functions to attach and detach joysticks, set virtual-joystick state, and to determine if a joystick is a virtual-one.

Use of virtual joysticks goes as such:

1. Attach one or more virtual joysticks by calling SDL_JoystickAttachVirtual.  If successful, this returns the virtual-device's joystick-index.
2. Open the virtual joysticks (using indicies returned by SDL_JoystickAttachVirtual).
3. Call any of the SDL_JoystickSetVirtual* functions when joystick-state changes.  Please note that virtual-joystick state will only get applied on the next call to SDL_JoystickUpdate, or when pumping or polling for SDL events (via SDL_PumpEvents or SDL_PollEvent).


Here is a listing of the new, public APIs, at present and subject to change:

------------------------------------------------------------

/**
 * Attaches a new virtual joystick.
 * Returns the joystick's device index, or -1 if an error occurred.
 */
extern DECLSPEC int SDLCALL SDL_JoystickAttachVirtual(SDL_JoystickType type, int naxes, int nballs, int nbuttons, int nhats);

/**
 * Detaches a virtual joystick
 * Returns 0 on success, or -1 if an error occurred.
 */
extern DECLSPEC int SDLCALL SDL_JoystickDetachVirtual(int device_index);

/**
 * Indicates whether or not a virtual-joystick is at a given device index.
 */
extern DECLSPEC SDL_bool SDLCALL SDL_JoystickIsVirtual(int device_index);

/**
 * Set values on an opened, virtual-joystick's controls.
 * Returns 0 on success, -1 on error.
 */
extern DECLSPEC int SDLCALL SDL_JoystickSetVirtualAxis(SDL_Joystick * joystick, int axis, Sint16 value);
extern DECLSPEC int SDLCALL SDL_JoystickSetVirtualBall(SDL_Joystick * joystick, int ball, Sint16 xrel, Sint16 yrel);
extern DECLSPEC int SDLCALL SDL_JoystickSetVirtualButton(SDL_Joystick * joystick, int button, Uint8 value);
extern DECLSPEC int SDLCALL SDL_JoystickSetVirtualHat(SDL_Joystick * joystick, int hat, Uint8 value);

------------------------------------------------------------

Miscellaneous notes on the initial patch, which are also subject to change:

1. no test code is present in SDL, yet.  This should, perhaps, change.  Initial development was done with an ImGui-based app, which potentially is too thick for use in SDL-official.  If tests are to be added, what kind of tests?  Automated?  Graphical?

2. virtual game controllers can be created by calling SDL_JoystickAttachVirtual with a joystick-type of SDL_JOYSTICK_TYPE_GAME_CONTROLLER, with naxes (num axes) set to SDL_CONTROLLER_AXIS_MAX, and with nbuttons (num buttons) set to SDL_CONTROLLER_BUTTON_MAX.  When updating their state, values of type SDL_GameControllerAxis or SDL_GameControllerButton can be casted to an int and used for the control-index (in calls to SDL_JoystickSetVirtual* functions).

3. virtual joysticks' guids are mostly all-zeros with the exception of the last two bytes, the first of which is a 'v', to indicate that the guid is a virtual one, and the second of which is a SDL_JoystickType that has been converted into a Uint8.

4. virtual joysticks are ONLY turned into virtual game-controllers if and when their joystick-type is set to SDL_JOYSTICK_TYPE_GAMECONTROLLER.  This is controlled by having SDL's default list of game-controllers have a single entry for a virtual game controller (of guid, "00000000000000000000000000007601", which is subject to the guid-encoding described above).

5. regarding having to call SDL_JoystickUpdate, either directly or indirectly via SDL_PumpEvents or SDL_PollEvents, before new virtual-joystick state becomes active (as specified via SDL_JoystickSetVirtual* function-calls), this was done to match behavior found in SDL's other joystick drivers, almost all of which will only update SDL-state during SDL_JoystickUpdate.

6. the initial patch is based off of SDL 2.0.12

7. the virtual joystick subsystem is disabled by default.  It should be possible to enable it by building with SDL_JOYSTICK_VIRTUAL=1



Questions, comments, suggestions, or bug reports very welcome!
2020-03-13 19:08:45 -07:00
Sam Lantinga
de2001eeee Fixed binding the D-PAD on the 8BitDo M30 controller 2020-03-13 13:05:40 -07:00
Sam Lantinga
611403dd0e Clarified that the clip rectangle is defined relative to the viewport, and added a clip test to testviewport.c 2020-03-08 21:02:40 -07:00
Sam Lantinga
25061816bf Fixed compile warning 2020-03-02 10:58:08 -08:00
Cameron Cawley
80cf4f0724 test: Improved detection of OpenGL support 2020-02-08 19:34:51 +00:00
Cameron Cawley
8f1a916ac5 Add basic support for compiling on RISC OS 2020-02-13 20:50:47 +00:00
Cameron Cawley
033aa51d87 testfilesystem: Don't exit the application if SDL_GetBasePath isn't supported 2020-02-13 22:58:04 +00:00
Sam Lantinga
dd0ebfdf8b Use the triggers to test rumble for more fine grained vibration feedback 2020-02-07 11:45:32 -08:00
Sam Lantinga
0a7fe18fe6 On Mac OSX there are spurious hat events at program start, so skip these 2020-01-17 11:06:02 -08:00
Sam Lantinga
a8780c6a28 Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
David Ludwig
acbf25935e Emscripten: build fix for testoverlay2.c 2020-01-13 11:46:17 -05:00
Sam Lantinga
46e1377d49 Automatically assign player indexes to game controllers, and allow changing the player index for game controllers and joysticks.
Added the functions SDL_JoystickFromPlayerIndex(), SDL_JoystickSetPlayerIndex(), SDL_GameControllerFromPlayerIndex(), and SDL_GameControllerSetPlayerIndex()
2019-12-20 20:12:03 -08:00
Sam Lantinga
8ce894a316 Ignore axis jitter when mapping controllers 2019-12-05 13:18:56 -08:00
Sam Lantinga
8aaf945b2f Fixed mapping controllers that have axes that start at -32768 and then snap to 0 at the first input report 2019-11-28 11:44:15 -08:00
Sam Lantinga
b5aff9d7c3 Added SDL_GameControllerTypeForIndex() and SDL_GameControllerGetType() to return the type of controller attached. 2019-11-22 13:12:12 -08:00
Sam Lantinga
c8896e4681 Turned on controllermap debug output by default 2019-11-21 10:09:26 -08:00
Cameron Cawley
20ddf45ede Added SDL_PIXELFORMAT_BGR444 2019-11-02 22:58:52 +00:00
Brandon Schaefer
68985371a0 offscreen: Add new video driver backend Offscreen
The Offscreen video driver is intended to be used for headless rendering
  as well as allows for multiple GPUs to be used for headless rendering

Currently only supports EGL (OpenGL / ES) or Framebuffers
Adds a hint to specifiy which EGL device to use: SDL_HINT_EGL_DEVICE
Adds testoffscreen.c which can be used to test the backend out
Disabled by default for now
2019-09-24 16:36:48 -04:00
David Ludwig
4e518f98a8 CMake: add version strings to Apple Info.plist files
This fills in the CFBundleVersion and CFBundleShortVersionString fields,
if and when SDL's test-apps are built via CMake.  This is needed to install
the .app bundles on iOS 13+ (using 'xcrun simctl install booted path/to/testsuchandsuch.app')
2019-09-23 17:48:14 -04:00
David Ludwig
b13c951cca CMake: iOS support added
When using a recent version of CMake (3.14+), this should make it possible to:
- build SDL for iOS, both static and dynamic
- build SDL test apps (as iOS .app bundles)
- generate a working SDL_config.h for iOS (using SDL_config.h.cmake as a basis)

To use, set the following CMake variables when running CMake's configuration stage:
- CMAKE_SYSTEM_NAME=iOS
- CMAKE_OSX_SYSROOT=<SDK>  (examples: iphoneos, iphonesimulator, iphoneos12.4, /full/path/to/iPhoneOS.sdk, etc.)
- CMAKE_OSX_ARCHITECTURES=<semicolon-separated list of CPU architectures> (example: "arm64;armv7s")

Examples:
- for Simulator, using the latest, installed SDK:
    cmake path/to/SDL -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphonesimulator -DCMAKE_OSX_ARCHITECTURES=x86_64

- for Device, using the latest, installed SDK, 64-bit only
    cmake path/to/SDL -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos -DCMAKE_OSX_ARCHITECTURES=arm64

- for Device, using the latest, installed SDK, mixed 32/64 bit
    cmake path/to/SDL -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos -DCMAKE_OSX_ARCHITECTURES="arm64;armv7s"

- for Device, using a specific SDK revision (iOS 12.4, in this example):
    cmake path/to/SDL -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos12.4 -DCMAKE_OSX_ARCHITECTURES=arm64

- for Simulator, using the latest, installed SDK, and building SDL test apps (as .app bundles):
    cmake path/to/SDL -DSDL_TEST=1 -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphonesimulator -DCMAKE_OSX_ARCHITECTURES=x86_64
2019-08-27 11:07:43 -04:00
Ozkan Sezer
32bb8b4b40 test: replace some exit()s with returns. 2019-09-10 10:03:20 +03:00
Ozkan Sezer
6f8910e398 minor warning fixes. 2019-08-04 14:56:02 +03:00
Ozkan Sezer
edc158894c remove test/aclocal.m4 2019-08-03 12:49:50 +03:00
Ozkan Sezer
4953e050f5 use SDL_zeroa at more places where the argument is an array. 2019-07-31 05:11:40 +03:00
Sam Lantinga
3fc447dfc9 Fixed bug 4708 - testdropfile: double-free
Juha Niemim?ki

SDLTest_CommonEvent seems to free the file name so testdropfile prints some garbage to console and crashes when freeing the name again.
2019-07-03 02:37:15 -07:00
Ryan C. Gordon
f71454c0ad testoverlay2: Changed some C runtime calls to be SDL equivalents. 2019-06-11 02:32:43 -04:00
Ryan C. Gordon
b5d3b6fc25 test: unify all the command line usage logging. 2019-05-28 17:39:13 -04:00
Ryan C. Gordon
00e5eeb40e test: added SDLTest_CommonDefaultArgs()
This is for test apps that don't need custom command line arguments; it lets
us reduce the boilerplate code a tiny bit.
2019-05-19 01:45:15 -04:00
Ryan C. Gordon
18d83093a8 test: configure/make shouldn't build GL/GLES1/GLES2 programs if unsupported. 2019-05-18 23:47:57 -04:00
Sam Lantinga
1febfedf85 configure.in: Rename configure.ac to fix an 'aclocal' warning 2019-04-02 05:31:08 -07:00
Ryan C. Gordon
edebdeb47f testgesture: Make the background gray.
This is so you can see it on systems that have a minimal window manager and
a black background.
2019-03-17 12:45:19 -04:00
Ryan C. Gordon
6727408d2c testgesture: cleaned up code formatting, etc. 2019-03-15 22:39:31 -04:00
Ryan C. Gordon
7cc0a606d8 testgesture: minor cleanups. 2019-03-15 22:17:21 -04:00
Ryan C. Gordon
5897ed85f5 test: Moved testgesture.c over to the common SDLtest framework. 2019-03-15 22:16:02 -04:00
Sam Lantinga
5e13087b0f Updated copyright for 2019 2019-01-04 22:01:14 -08:00
Ryan C. Gordon
c3e3503ee8 testgl2: Press 'o' or 'p' to decrease/increase OpenGL swap interval. 2018-12-16 01:04:07 -05:00
Ozkan Sezer
14e389eadc minor update to Makefile.os2, added a test/Makefile.os2. 2018-11-20 10:55:00 +03:00
Ryan C. Gordon
e0cc19f2d8 testsprite2: report average FPS in blocks of five seconds.
This makes the reporting more accurate, vs startup inefficiencies and other
scheduling burps.
2018-09-20 15:41:57 -04:00
Ryan C. Gordon
aae29c9ebd test: Makefile should copy .dat files for testoverlay2. 2018-09-02 00:35:11 -04:00
Jeremy Ong
a794126d56 vulkan: SDL_Vulkan_GetInstanceExtensions should accept a NULL window.
Fixes Bugzilla #4235.
2018-08-24 09:49:48 -04:00
Sam Lantinga
7c3040e08a First pass on the new SDL sensor API 2018-08-21 12:11:34 -07:00
Sam Lantinga
d2042e1ed4 Added HIDAPI joystick drivers for more consistent support for Xbox, PS4 and Nintendo Switch Pro controller support across platforms.
Added SDL_GameControllerRumble() and SDL_JoystickRumble() for simple force feedback outside of the SDL haptics API
2018-08-09 16:00:17 -07:00
Ryan C. Gordon
e061a92dc9 Some drag'and'drop improvements.
First: disable d'n'd events by default; most apps don't need these at all, and
if an app doesn't explicitly handle these, each drop on the window will cause
a memory leak if the events are enabled. This follows the guidelines we have
for SDL_TEXTINPUT events already.

Second: when events are enabled or disabled, signal the video layer, as it
might be able to inform the OS, causing UI changes or optimizations (for
example, dropping a file icon on a Cocoa app that isn't accepting drops will
cause macOS to show a rejection animation instead of the drop operation just
vanishing into the ether, X11 might show a different cursor when dragging
onto an accepting window, etc).

Third: fill in the drop event details in the test library and enable the
events in testwm.c for making sure this all works as expected.
2018-08-02 16:03:47 -04:00
Ryan C. Gordon
ed4fe4c9a0 testresample: correctly output .wav files that have floating point audio. 2018-05-15 00:04:02 -04:00
Ryan C. Gordon
4df859c586 cpuinfo: Added SDL_HasAVX512F().
This checks for the "foundation" AVX-512 instructions (that all AVX-512
compatible CPUs support).
2018-05-21 11:35:42 -04:00
Sam Lantinga
f521b22eb5 Added SDL_THREAD_PRIORITY_TIME_CRITICAL 2018-04-23 22:07:56 -07:00
Sam Lantinga
816a6e68e5 Added support for adjusting thread priorities using Linux RealtimeKit
Michael Sartain

This is a quick pass at adding Linux RealtimeKit thread priority support to SDL.

It allows me to bump the thread priority to high without root privileges or setting any caps, etc.

rtkit readme here:
    http://git.0pointer.net/rtkit.git/tree/README
2018-04-23 17:10:36 -07:00
Sam Lantinga
e20d4173bf Added Android custom cursor implementation
This is commented out in SDLActivity.java, with the note #CURSORIMPLEENTATION because it requires API 24, which is higher than the minimum required SDK
2018-03-15 18:22:48 -07:00
Sam Lantinga
6cf4d0e43b Fixed bug 4092 - CMake support for building everything in the "test" directory
Eric Wasylishen

Patch to support building the tests with cmake.
Disabled by default, use: "cmake .. -DSDL_TEST=YES" to enable the tests.

Tested on macOS 10.13 with the ninja, makefile, and Xcode generators, and Windows 10 with the Visual Studio 2017 generator.
2018-02-24 08:59:58 -08:00
Ryan C. Gordon
af498591df testoverlay2: use SDL_atoi, not atoi. 2018-01-22 09:46:48 -05:00
Sam Lantinga
e3cc5b2c6b Updated copyright for 2018 2018-01-03 10:03:25 -08:00
Sam Lantinga
4764f7a45c Fixed building YUV test programs (thanks Ozkan!) 2017-11-17 10:54:46 -08:00
Sam Lantinga
a6a4e27ae8 Updated SDL's YUV support, many thanks to Adrien Descamps
New functions get and set the YUV colorspace conversion mode:
	SDL_SetYUVConversionMode()
	SDL_GetYUVConversionMode()
	SDL_GetYUVConversionModeForResolution()

SDL_ConvertPixels() converts between all supported RGB and YUV formats, with SSE acceleration for converting from planar YUV formats (YV12, NV12, etc) to common RGB/RGBA formats.

Added a new test program, testyuv, to verify correctness and speed of YUV conversion functionality.
2017-11-12 22:51:12 -08:00
Sam Lantinga
a225ffc1d7 Added min/max macros for the sized SDL datatypes 2017-10-16 14:39:56 -07:00
Brandon Schaefer
e564da78b7 revert files I didnt mean to commit! 2017-09-29 10:15:44 -07:00
Brandon Schaefer
e27f12e0da wayland: Fix bug 3814 -Wmissing-field-initializers 2017-09-29 10:07:37 -07:00
Ryan C. Gordon
846a9ab95e test: forgot to change a variable.
Fixes Bugzilla #3787.
2017-08-29 18:25:55 -04:00
Ryan C. Gordon
4fc0163853 test: Fix for negative int that was now a size_t (thanks, Ozkan!).
Fixes Bugzilla #3787.
2017-08-29 18:16:38 -04:00
Ryan C. Gordon
eb3c66d3c8 A few more compiler warnings fixed. 2017-08-29 16:05:03 -04:00
Ryan C. Gordon
ae667da638 Fixed a bunch of compiler warnings. 2017-08-29 15:52:49 -04:00
Sam Lantinga
37ce9f2773 Fixed typedef redefinition errors when including both SDL_vulkan.h and vulkan.h
You should always include vulkan/vulkan.h first, then include SDL_vulkan.h
2017-08-27 23:13:15 -07:00
Sam Lantinga
1f2e151b44 Added Vulkan support to the Visual Studio 2010 solution 2017-08-27 22:20:17 -07:00
Sam Lantinga
071e101837 We use the SDL Vulkan headers 2017-08-27 20:41:48 -07:00
Ryan C. Gordon
c722e58d1f vulkan: Include a copy of vulkan.h and vk_platform.h.
Now we can provide Vulkan support in the build even if the build box doesn't
have a Vulkan SDK, since we dynamically link to the library anyhow.
2017-08-27 23:25:12 -04:00
Sam Lantinga
803fd6d526 Use SDL_Vulkan_GetDrawableSize() instead of SDL_GL_GetDrawableSize() 2017-08-27 19:32:08 -07:00
Ryan C. Gordon
25e3a1ec90 vulkan: Initial Vulkan support!
This work was done by Jacob Lifshay and Mark Callow; I'm just merging it
into revision control.
2017-08-27 22:15:57 -04:00
Sam Lantinga
aad997fc9f Fixed bug 3740 - atexit() in test/testime.c 2017-08-27 19:00:03 -07:00
Sam Lantinga
c59d9923b3 Implemented more flexible blending modes for accelerated renderers
This fixes bug 2594 - Propose new blend mode, SDL_BLENDMODE_BLEND_DSTA

	blendMode = SDL_ComposeCustomBlendMode(SDL_BLENDFACTOR_SRC_ALPHA,
	                                       SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA,
	                                       SDL_BLENDOPERATION_ADD,
	                                       SDL_BLENDFACTOR_ZERO,
	                                       SDL_BLENDFACTOR_ONE,
	                                       SDL_BLENDOPERATION_ADD);

This fixes bug 2828 - Subtractive Blending

	blendMode = SDL_ComposeCustomBlendMode(SDL_BLENDFACTOR_SRC_ALPHA,
	                                       SDL_BLENDFACTOR_ONE,
	                                       SDL_BLENDOPERATION_SUBTRACT,
	                                       SDL_BLENDFACTOR_ZERO,
	                                       SDL_BLENDFACTOR_ONE,
	                                       SDL_BLENDOPERATION_SUBTRACT);


This goes partway to fixing bug 3684 - Add support for a pre-multiplied alpha blending mode

	blendMode = SDL_ComposeCustomBlendMode(SDL_BLENDFACTOR_ONE,
	                                       SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA,
	                                       SDL_BLENDOPERATION_ADD,
	                                       SDL_BLENDFACTOR_ONE,
	                                       SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA,
	                                       SDL_BLENDOPERATION_ADD);
2017-08-14 05:51:44 -07:00
Sam Lantinga
0112f61889 Fixed bug 3743 - make testautomation_sdltest.c to compile
Ozkan Sezer

The attached patch makes testautomation_sdltest.c more compatible wrt
LLONG_{MIN|MAX} macros and makes it to compile on older systems  (e.g.
glibc-2.8) too, by replacing LLONG_{MIN|MAX} with INT64_{MIN|MAX}.

c.f.: bug #3494, where the same issue was described for SDL_test_fuzzer.c
2017-08-13 21:18:59 -07:00
Sam Lantinga
2da830a909 Fixed bug 3741 - more compatible initializers for arrays
Ozkan Sezer

An array defined like  int xPositions[] = {-1, 0, 1, w-1, w, w+1 };
errors with Open Watcom: it strictly wants constants.  Small patch
like below makes things more compatible.
2017-08-13 21:15:44 -07:00
Sam Lantinga
93a520b385 Fixed bug 3605 - Software renderer no longer renders after Android screen orientation change
Sylvain

This still happens with the current trunk version.  (software renderer of testdrawchessboard.c)

When there is a rotation, the window size changed and the internal surface is marked as "surface_valid == SDL_FALSE".
And all further call fails.

SDL_video.c :

2478 void
2479 SDL_OnWindowResized(SDL_Window * window)
2480 {
2481     window->surface_valid = SDL_FALSE;
2482     SDL_SendWindowEvent(window, SDL_WINDOWEVENT_SIZE_CHANGED, window->w, window->h);
2483 }

some error set to :
2233         return SDL_SetError("Window surface is invalid, please call SDL_GetWindowSurface() to get a new surface");


So, this seems to be the behavior of the API ...


In the loop() function of testdrawchessboard.c, we can recreate the surface/renderer :

 65        if (e.type == SDL_WINDOWEVENT)
 66        {
 67             if (e.window.event == SDL_WINDOWEVENT_SIZE_CHANGED)
 68             {
 69                surface = SDL_GetWindowSurface(window);
 70                renderer = SDL_CreateSoftwareRenderer(surface);
 71             }
 72             /* Clear the rendering surface with the specified color */
 73             SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0xFF, 0xFF);
 74             SDL_RenderClear(renderer);
 75        }

And it displays correctly.
2017-08-13 21:12:14 -07:00
Sam Lantinga
ca5c304814 Fixed bug 3744 - missing SDLCALL in several functions
Ozkan Sezer

The attached patch adds missing SDLCALL to several functions, so that
they properly match the headers as intended.
2017-08-13 21:06:52 -07:00
Sam Lantinga
658975f381 Fixed bug 3639 - SDL_GetPrefPath returns a path with two consecutive slashes on Unix if org is omitted
Fabian Greffrath

we use SDL_GetPrefPath() in Chocolate Doom to get a reasonable directory to save and restore config files and savegames:

https://github.com/chocolate-doom/chocolate-doom/blob/sdl2-branch/src/m_config.c#L2162

However, since there is no "organization" behind Chocolate Doom and there is really only one "product" called Chocolate Doom, we pass an empty string for the org parameter and the package string for app.

This leads to two consecutive slashes in the path returned by SDL_GetPrefPath() like this:

/home/user/.local/share//chocolate-doom/

While this is harmless, it sure looks bad.

I believe that it should be possible to either pass a NULL pointer for the org parameter or at least have the function detect an empty string as a means to express "there is no origanization, just a single product". The generation of the path string to be returned by the function will have to get adapted accordingly.
2017-08-11 11:32:00 -07:00
Sam Lantinga
222bacd86c Fixed bug 3682 - Toggle text input in checkkeys when the mouse is clicked
Eric Wasylishen

Small change to checkkeys so you can toggle text input mode with a mouse click.
This is needed for testing how dead keys react to toggling mouse input, i.e. these bugs:
2017-08-11 10:32:47 -07:00
Philipp Wiesemann
707ee5be26 Fixed typo in log message in testime program. 2017-07-09 23:00:35 +02:00
Philipp Wiesemann
705efc3532 Fixed handling only one event per frame in testshape program. 2017-06-24 23:45:19 +02:00