1
0
Fork 0
mirror of https://github.com/gwm17/glfw.git synced 2024-11-23 02:38:52 -05:00
Commit Graph

84 Commits

Author SHA1 Message Date
Camilla Löwy 3d52f7e345 Limit scope of some loop counters in C99 files 2021-10-25 23:39:06 +02:00
Camilla Löwy 56a4cb0a3a Add runtime platform selection
This adds compile-time support for multiple platforms and runtime
detection of them.  Window system related platform functions are now
called from shared code via the function pointer struct _GLFWplatform.

The timer, thread and module loading platform functions are still called
directly by name and the implementation chosen at link-time.  These
functions are the same for any backend on a given OS, including the Null
backend.

The platforms are now enabled via CMake dependent options following the
GLFW_BUILD_<platform> pattern instead of a mix of automagic and ad-hoc
option names.  There is no longer any option for the Null backend as it
is now always enabled.

Much of the struct stitching work in platform.h was based on an earlier
experimental branch for runtime platform selection by @ronchaine.

Every platform function related to windows, contexts, monitors, input,
event processing and Vulkan have been renamed so that multiple sets of
them can exist without colliding.  Calls to these are now routed through
the _glfw.platform struct member.  These changes makes up most of this
commit.

For Wayland and X11 the client library loading and display creation is
used to detect a running compositor/server.  The XDG_SESSION_TYPE
environment variable is ignored for now, as X11 is still by far the more
complete implementation.

Closes #1655
Closes #1958
2021-10-13 21:47:11 +02:00
Camilla Löwy 6d51b39106 Select mapping platform name at runtime
This is done in preparation for runtime platform selection.
2021-10-12 12:54:35 +02:00
Camilla Löwy 22b586b3d8 Add pluggable heap allocator
This adds the glfwInitAllocator function for specifying a custom memory
allocator to use instead of the C runtime library.

The allocator is a struct of type GLFWallocator with fields
corresponding to malloc, realloc and free, while the internal API
corresponds to calloc, realloc and free.

Heap allocation calls are filtered before reaching the user-provided
functions, so deallocation of NULL and allocations of zero bytes are not
passed on, reallocating NULL is transformed into an allocation and
reallocating to size zero is transformed into deallocation.

The clearing of a new block to zero is performed by the internal
calloc-like function.

Closes #544.
Fixes #1628.
Closes #1947.
2021-08-25 21:00:10 +02:00
Camilla Löwy f771d41292 Cleanup
Moving functions to their respective sections.  Related to delayed
joystick Initialization.
2020-07-21 17:54:07 +02:00
Camilla Löwy 782e6b6cef Make joystick platform code init on demand
This makes joystick support initialize the first time a joystick
function is called, including those gamepad functions that are layered
on top of joystick functions.

Related to #1284.
Related to #1646.
2020-07-21 17:38:56 +02:00
Luflosi 74a46dfa0c Use the correct type in a for loop
The `sizeof()` operator has the type `size_t`, so the `for` loop
iterating over it should use the same type.

Closes #1614.
2019-12-26 16:31:37 +01:00
Camilla Löwy 56aad76b16 Add C dialect reminders to each source file
Files built for Win32 must use C89 style declarations for compatibility
with VS 2010 and 2012, which are still supported by GLFW.
2019-05-24 14:43:49 +02:00
Camilla Löwy a337c56848 Start 3.4 2019-04-16 23:08:39 +02:00
Camilla Löwy ab118b2529 Fix copyright years (somewhat) 2019-04-15 20:50:00 +02:00
Camilla Löwy 0d355379e0 Cocoa: Support some sim page joystick elements
This is an SDL2 compatibility fix.
2019-03-28 22:58:47 +01:00
Camilla Löwy c20754c4a6 Fix Coverity Scan false positive 2019-03-04 18:52:56 +01:00
Camilla Löwy 90e22947c6 Cleanup 2019-01-31 01:58:04 +01:00
Camilla Löwy 463ef7eb71 Cocoa: Fix handling of analog joystick buttons
The reported state was not clamped to [0,1], i.e. GLFW_RELEASE and
GLFW_PRESS.

Fixes #1385.
2019-01-31 01:54:49 +01:00
Camilla Löwy 51ca41dd9f Cocoa: Add missing IOHID page and usages
Related to #1385.
2019-01-31 01:53:55 +01:00
Stephen Gowen bb13275b72 Cocoa: Fix Xcode Warnings
Closes #1132.
2017-11-20 18:04:05 +01:00
Camilla Löwy e3be6b8ae0 Cleanup
Break up some overly long lines.
2017-09-17 15:14:22 +02:00
Camilla Löwy ea6c50d9e2 Cleanup 2017-07-10 12:53:20 +02:00
Camilla Löwy 617c42b20a Cleanup 2017-07-09 14:01:48 +02:00
Camilla Löwy 953106e74d Add support for SDL_GameControllerDB
This adds support for importing and applying mappings from the
SDL_GameControllerDB database.

Related to #900.
2017-07-07 15:52:33 +02:00
Camilla Löwy cf2eab5b4e Cocoa: Made axis auto-calibration less jumpy 2017-03-23 17:33:05 +01:00
Camilla Löwy 55d0560746 Cocoa: Fix range handling for hats and buttons
Fixes #888.
2017-03-23 15:58:14 +01:00
Camilla Löwy 798d7c6d68 Implement glfwGetJoystickHats
This moves the buttons-as-hats logic to shared code and adds the
GLFW_JOYSTICK_HAT_BUTTONS input mode as a way to disable this legacy
behavior.

Fixes #889.
2017-03-06 03:23:29 +01:00
Camilla Löwy 9950d8a319 Cleanup 2017-02-26 22:18:47 +01:00
Camilla Löwy bfd564f257 Move internals to shared joystick objects
Preparation for gamecontrollerdb support and the gamepad API.
2017-01-30 16:52:49 +01:00
Camilla Löwy e7722af9a2 Cleanup 2017-01-12 05:30:56 +01:00
Camilla Löwy f4d0c83181 Paperwork done 2016-11-30 14:00:41 +01:00
Camilla Berglund efc6b35615 Rename joystick ID variables 2016-10-16 14:07:18 +02:00
Camilla Berglund 53fafad915 Start 3.3 2016-08-18 23:55:49 +02:00
Camilla Berglund 76801973e1 Cocoa: Clean up joystick globals 2016-06-15 01:35:07 +02:00
Camilla Berglund 757eea2779 Update email address 2016-06-01 21:25:20 +02:00
Camilla Berglund 6a8e169001 Update copyright notice year 2016-06-01 21:25:19 +02:00
IntellectualKitty 3b0b5dacf5 Fix test for joystick presence in matchCallback
The matchCallback function has an initial loop to filter out redundant
joystick additions based on matching deviceRef values.  However, the if
statement incorrectly combines this test with the condition that the
joystick is not present, which is obviously incorrect.

Closes #753.
2016-04-27 15:42:19 +02:00
Camilla Berglund 3aebb0bfe3 Cleanup 2016-03-31 12:23:49 +02:00
Camilla Berglund 8a7fa306ce Add glfwSetJoystickCallback 2016-03-31 12:12:09 +02:00
Camilla Berglund c580949417 Cleanup 2016-03-29 14:01:06 +02:00
IntellectualKitty ae4ece840d Remove redundant OS X joystick polling
Closes #729.
2016-03-29 14:00:13 +02:00
Aaron Jacobs 49d228207f Fix crash when joystick name unavailable on OS X
Fixes #694.
Closes #701.
2016-02-09 07:52:00 +01:00
Camilla Berglund 12871db0f9 Only poll requested joystick on OS X 2015-12-13 15:15:50 +01:00
Camilla Berglund 7fec7a0569 Make source file names more consistent
Use platform prefix for files specific to that platform AND that have no
credible alternative API on that platform.

The exception is WinMM, which will be replaced before 3.2.
2015-12-13 14:51:44 +01:00
Camilla Berglund 660034332d Separated joystick state from window system state.
This is partially in preparation for pending support for additional
joystick APIs like XInput, DirectInput and IOHID.
2014-04-08 16:07:21 +02:00
Shane Liesegang b4c03b992c Fixing memory leak in cocoa_joystick
Making sure that propsRef and valueRef get released no matter when we
break out of the loop.

Resolves #231.
2014-02-06 23:18:43 +01:00
Camilla Berglund 611006af18 Updated API version in comment headers. 2014-01-22 01:32:00 +01:00
Camilla Berglund b13c84f854 Removed joystick axis value negation on OS X. 2013-11-07 20:45:29 +01:00
Camilla Berglund 4013f733fe Reverted change of IOKit functions.
The previously used set of functions caused a regression where no axes
or buttons were reported.  Fixes #78.
2013-11-07 20:19:30 +01:00
Camilla Berglund 3cfc400cf9 Simplified source file comment headers. 2013-07-30 14:46:52 +02:00
Camilla Berglund 7a03ca8dbc Removed superflous casts of allocated memory. 2013-07-04 14:54:07 +02:00
Camilla Berglund 209a470a5f Replaced all uses of malloc with calloc. 2013-07-04 14:20:14 +02:00
Camilla Berglund 180a4ee640 Fixed constness of joystick data. 2013-06-04 18:20:38 +02:00
Camilla Berglund 7f2eb7b15b New joystick API. 2013-05-22 21:56:14 +02:00