Commit Graph

1376 Commits (392f3882d03c7cb7c920b43bb7f94a206d77f737)

Author SHA1 Message Date
Pierre Wendling 392f3882d0 N3DS: Use SDL_Sensor instead of Joystick sensors. 2022-10-10 08:50:59 -07:00
Pierre Wendling f9785702a6 N3DS: Deduce screen from window's display.
This removes the need for a dedicated window creation flag.
2022-10-10 08:50:59 -07:00
Pierre Wendling 655275378d N3DS port (squashed)
A dedicated renderer using Citro3D would likely allow for better
much better graphical performances.
2022-10-10 08:50:59 -07:00
Sam Lantinga efdb390caa Disable the HIDAPI Wii driver by default as it doesn't work with the dolphinbar 2022-10-09 09:11:33 -07:00
SDL Wiki Bot 9df1af352f Sync SDL wiki -> header 2022-10-09 15:44:07 +00:00
Sam Lantinga b18c361b0f Updated variable name for mouse coordinates in mouse wheel events 2022-10-08 13:18:00 -07:00
Sam Lantinga 4f318c904a Add cursor position to mouse wheel event (thanks @meyraud705!)
Fixes https://github.com/libsdl-org/SDL/pull/6351
2022-10-08 12:01:42 -07:00
Kamil Ševeček 31991ab851 Fix \sa to a valid function in SDL_metal.h. 2022-10-07 07:15:53 -07:00
SDL Wiki Bot 4ca86dae2f Sync SDL wiki -> header 2022-10-05 23:26:14 +00:00
David Gow ad29875ee6 Wayland: Emulate mouse warp using relative mouse mode
Several games (including Source and GoldSrc games, and Bioshock
Infinite) attempt to "fake" relative mouse mode by repeatedly warping
the cursor to the centre of the screen. Since mouse warping is not
supported under Wayland, the viewport ends up "stuck" in a rectangular
area.

Detect this case (mouse warp while the cursor is not visible), and
enable relative mouse mode, which tracks the cursor position
independently, and so can Warp successfully.

This is behind the SDL_HINT_VIDEO_WAYLAND_EMULATE_MOUSE_WARP hint, which
is enabled by default, unless the application enables relative mouse
mode itself using SDL_SetRelativeMouseMode(SDL_TRUE).

Note that there is a behavoural difference, in that relative mouse mode
typically doesn't take mouse accelleration into account, but the
repeated-warping technique does, so mouse movement can seem very slow
with this (unless the game has its own mouse accelleration option, such
as in Portal 2).
2022-10-03 19:11:18 -07:00
SDL Wiki Bot 34b28002d9 Sync SDL wiki -> header 2022-10-03 00:20:15 +00:00
Sam Lantinga 64ea6cefaf SDL_ResetHint() no longer clears the callbacks associated with a hint
Also added SDL_ResetHints() to reset all callbacks, and clarified that SDL_ClearHints() is just used for cleanup at shutdown.

Fixes https://github.com/libsdl-org/SDL/issues/6313
2022-10-02 17:17:31 -07:00
Happy Harry 6c8bf3af4c
Add vertical mode for Nintendo Joy-Con (#6303)
* Added support for vertical mode for Joy-Con controllers
* Added the hint SDL_HINT_JOYSTICK_HIDAPI_VERTICAL_JOY_CONS for switching to this mode
* Added support for SL/SR buttons in combined/vertical mode and L/ZL/R/ZR buttons in mini-gamepad mode
2022-10-02 09:19:34 -07:00
SDL Wiki Bot 36e7670143 Sync SDL wiki -> header 2022-09-27 16:57:17 +00:00
Sam Lantinga 2c518747b9 Added microsecond timestamp to sensor values for PS4 and PS5 controllers using the HIDAPI driver 2022-09-27 09:56:49 -07:00
Sam Lantinga 61201e06ef Removed obsolete extension definitions
Fixes https://github.com/libsdl-org/SDL/issues/6231
2022-09-15 06:19:18 -07:00
Ozkan Sezer 6dec78ed11 fix permissions of SDL_opengl_glext.h 2022-09-15 11:55:04 +03:00
SDL Wiki Bot c49faabb6d Sync SDL wiki -> header 2022-09-14 16:29:16 +00:00
DS ac5b9bc4ee
Add support for X11 primary selection (#6132)
X11 has a so-called primary selection, which you can use by marking text and middle-clicking elsewhere to copy the marked text.

There are 3 new API functions in `SDL_clipboard.h`, which work exactly like their clipboard equivalents.

## Test Instructions

* Run the tests (just a copy of the clipboard tests): `$ ./test/testautomation --filter Clipboard`
* Build and run this small application:
<details>
```C
#include <SDL.h>
#include <unistd.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

void print_error(const char *where)
{
	const char *errstr = SDL_GetError();
	if (errstr == NULL || errstr[0] == '\0')
		return;
	fprintf(stderr, "SDL Error after '%s': %s\n", where, errstr);
	SDL_ClearError();
}

int main()
{
	char text_buf[256];

	srand(time(NULL));

	SDL_Init(SDL_INIT_VIDEO);
	print_error("SDL_INIT()");
	SDL_Window *window = SDL_CreateWindow("Primary Selection Test", SDL_WINDOWPOS_UNDEFINED,
			SDL_WINDOWPOS_UNDEFINED, 400, 400, SDL_WINDOW_SHOWN);
	print_error("SDL_CreateWindow()");
	SDL_Renderer *renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
	print_error("SDL_CreateRenderer()");

	bool quit = false;
	unsigned int do_render = 0;
	while (!quit) {
		SDL_Event event;
		while (SDL_PollEvent(&event)) {
			print_error("SDL_PollEvent()");
			switch (event.type) {
			case SDL_QUIT: {
				quit = true;
				break;
			} case SDL_KEYDOWN: {
				switch (event.key.keysym.sym) {
				case SDLK_ESCAPE:
				case SDLK_q:
					quit = true;
					break;
				case SDLK_c:
					snprintf(text_buf, sizeof(text_buf), "foo%d", rand());
					SDL_SetClipboardText(text_buf);
					print_error("SDL_SetClipboardText()");
					printf("clipboard: set_to=\"%s\"\n", text_buf);
					break;
				case SDLK_v: {
					printf("clipboard: has=%d, ", SDL_HasClipboardText());
					print_error("SDL_HasClipboardText()");
					char *text = SDL_GetClipboardText();
					print_error("SDL_GetClipboardText()");
					printf("text=\"%s\"\n", text);
					SDL_free(text);
					break;
				} case SDLK_d:
					snprintf(text_buf, sizeof(text_buf), "bar%d", rand());
					SDL_SetPrimarySelectionText(text_buf);
					print_error("SDL_SetPrimarySelectionText()");
					printf("primselec: set_to=\"%s\"\n", text_buf);
					break;
				case SDLK_f: {
					printf("primselec: has=%d, ", SDL_HasPrimarySelectionText());
					print_error("SDL_HasPrimarySelectionText()");
					char *text = SDL_GetPrimarySelectionText();
					print_error("SDL_GetPrimarySelectionText()");
					printf("text=\"%s\"\n", text);
					SDL_free(text);
					break;
				} default:
					break;
				}
				break;
			} default: {
				break;
			}}
		}
		// create less noise with WAYLAND_DEBUG=1
		if (do_render == 0) {
			SDL_RenderPresent(renderer);
			print_error("SDL_RenderPresent()");
		}
		do_render += 1;
		usleep(12000);
	}

	SDL_DestroyRenderer(renderer);
	SDL_DestroyWindow(window);
	SDL_Quit();
	print_error("quit");
	return 0;
}
```
</details>

* Use c,v,d,f to get and set the clipboard and primary selection.
* Mark text and middle-click also in other applications.
* For wayland under x:
  * `$ mutter --wayland --no-x11 --nested`
  * `$ XDG_SESSION_TYPE=wayland SDL_VIDEODRIVER=wayland ./<path_to_test_appl_binary>`
2022-09-14 09:28:35 -07:00
Sam Lantinga 72fe6cc8f1 Updated to the latest version of OpenGL and Vulkan headers from the Khronos registry
Fixes https://github.com/libsdl-org/SDL/issues/6193
2022-09-14 09:14:47 -07:00
Sam Lantinga 4018f35ef2 Added left and right sensors for Nintendo Joy-Con and Wii controllers 2022-09-07 00:00:27 -07:00
Cameron Cawley fd93f817ba Assume that stdint.h is available on Windows with compilers other than MSVC <= 2008 2022-09-05 09:01:31 -07:00
Sam Lantinga c887cb02af Added the hint SDL_HINT_JOYSTICK_HIDAPI_WII_PLAYER_LED to control whether the player LED should be lit on the Nintendo Wii controllers
Also fixed the Y axes on the Wii U Pro controller, and various formatting cleanup
2022-09-01 16:30:55 -07:00
Sam Lantinga c72e14e8f4 Added initial support for Wii controllers (thanks @tellowkrinkle!) 2022-09-01 15:29:41 -07:00
Ozkan Sezer 4ebf34857a updated os2 config file after commit 3f89d1704d 2022-09-01 21:56:50 +03:00
Sam Lantinga 3f89d1704d Fixed building with libusb not dynamicaly loaded 2022-09-01 11:30:02 -07:00
Sam Lantinga 6c2c01e0d1 Fixed documentation to match function parameter 2022-08-31 15:04:12 -07:00
Sam Lantinga 0e4baf1c4e Don't crash if SDL functions are passed a closed joystick or gamecontroller 2022-08-30 12:39:23 -07:00
SDL Wiki Bot 3fe6768caf Sync SDL wiki -> header 2022-08-30 18:47:15 +00:00
Sam Lantinga 40bd4feedc Revamped joystick locking
This makes the joystick locking more robust by holding the lock while updating joysticks.

The lock should be held when calling any SDL joystick function on a different thread than the one calling SDL_PumpEvents() and SDL_JoystickUpdate().

It is now possible to hold the lock while reinitializing the joystick subsystem, however any open joysticks will become invalid and potentially cause crashes if used afterwards.

Fixes https://github.com/libsdl-org/SDL/issues/6063
2022-08-30 11:42:13 -07:00
Francisco Javier Trujillo Mata f1e4685806 Adding specific SDL_Hint for the dynamic VSYNC 2022-08-30 07:20:36 -04:00
SDL Wiki Bot 644a4e5b31 Sync SDL wiki -> header 2022-08-28 02:01:12 +00:00
Sam Lantinga 3cbfd75d0f Re-added the CRC to the joystick guid
This is now used as a crc field in the mapping rather than directly in mapping guids, for better mapping compatibility between versions of SDL.

Added SDL_GetJoystickGUIDInfo() to get device information encoded in a joystick GUID, so that mapping programs can clear the CRC from the GUID when generating mappings.

sort_controllers.py has been updated to extract the CRC from mappings created by older mapping programs and convert it into the new crc field. It will also take the CRC into account when checking for duplicate mappings.

Also regenerated the GUIDs for the PS2/PSP/Vita controller mappings, fixing https://github.com/libsdl-org/SDL/issues/6151
2022-08-27 19:00:31 -07:00
SDL Wiki Bot 111626f4cf Sync SDL wiki -> header 2022-08-25 17:17:12 +00:00
Sam Lantinga e4b85091fd Document the range of trigger axes for virtual joysticks
Fixes https://github.com/libsdl-org/SDL/issues/6130
2022-08-25 10:15:45 -07:00
Noel Berry 00452e47fa
Adding SDL_GetWindowSizeInPixels for window size in pixels (#6112) 2022-08-24 11:25:13 -07:00
Sam Lantinga 1fc7f68118 Document that it's not possible to use the HIDAPI driver for PS3 controllers on Windows 2022-08-24 06:38:36 -07:00
Sam Lantinga b6f96b69aa Initial HIDAPI driver support for the PS3 controller 2022-08-23 22:45:37 -07:00
Sam Lantinga 92b3c53c92 Added a hint SDL_HINT_MOUSE_RELATIVE_SYSTEM_SCALE to control whether to use system mouse acceleration on raw relative motion.
This is currently only implemented on Windows, and "Enhanced pointer
precision" mode is not quite correct.
2022-08-22 16:48:09 -07:00
SDL Wiki Bot a7066c527a Sync SDL wiki -> header 2022-08-21 14:05:04 +00:00
SDL Wiki Bot 8fb1b50a9e Sync SDL wiki -> header 2022-08-20 17:50:04 +00:00
Oleg Derevenetz a204ef50bb Use __ARM_ARCH instead of __ARM_ARCH__ 2022-08-19 13:15:28 -07:00
Sam Lantinga 5a3adbfdb2 Added the hint SDL_HINT_JOYSTICK_HIDAPI_XBOX_360_PLAYER_LED to control whether the player LED is set on Xbox 360 controllers 2022-08-19 11:11:25 -07:00
Sam Lantinga 52b6899a6b Added hints for more fine grained control over HIDAPI Xbox controller support 2022-08-19 11:11:23 -07:00
Sam Lantinga 6e9c14e550 Updated to version 2.25.0 for development 2022-08-19 09:38:42 -07:00
Sam Lantinga 8c9beb0c87 Updated to version Updated to version 2.24.0 for release 2022-08-19 08:44:09 -07:00
Sam Lantinga f6b81125b3 Always define SDL_COMPILE_TIME_ASSERT as static_assert() in C++
Apparently some versions of gcc will define __STDC_VERSION__ even when compiling in C++ mode.

Fixes https://github.com/libsdl-org/SDL/issues/6078
2022-08-18 16:06:42 -07:00
Sam Lantinga f1416ef2ba Updated to version 2.23.2 for release candidate 2022-08-12 20:27:22 -07:00
SDL Wiki Bot f35bbe0c3f Sync SDL wiki -> header 2022-08-11 21:11:11 +00:00
Sam Lantinga 3861c557da Added the hint SDL_HINT_MOUSE_RELATIVE_WARP_MOTION
This hint controls whether mouse warping generates motion events in relative mode, and defaults off.

Fixes https://github.com/libsdl-org/SDL/issues/6034
Fixes https://github.com/libsdl-org/SDL/issues/5741
2022-08-11 14:02:03 -07:00