mirror of
https://github.com/glfw/glfw.git
synced 2025-12-20 14:11:55 +00:00
Compare commits
21 Commits
78e034a7f7
...
f5ad6ff8e7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f5ad6ff8e7 | ||
|
|
ac10768495 | ||
|
|
feb2a6b728 | ||
|
|
d11cb3779b | ||
|
|
d1b87143bc | ||
|
|
da7aa4130f | ||
|
|
6cd8a73064 | ||
|
|
ed65906282 | ||
|
|
b9acd9d45f | ||
|
|
a4c3492a03 | ||
|
|
094db02c39 | ||
|
|
a06c00215a | ||
|
|
39dec1415b | ||
|
|
e65723069f | ||
|
|
712942e596 | ||
|
|
ccf7c931b0 | ||
|
|
ef269c0ae9 | ||
|
|
1ed4c69550 | ||
|
|
ee4132b5cf | ||
|
|
f5536ccae0 | ||
|
|
556cc61848 |
@ -29,7 +29,7 @@ for:
|
|||||||
only:
|
only:
|
||||||
- GENERATOR: MinGW Makefiles
|
- GENERATOR: MinGW Makefiles
|
||||||
build_script:
|
build_script:
|
||||||
- set PATH=%PATH:C:\Program Files\Git\usr\bin=C:\MinGW\bin%
|
- set PATH=C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin;%PATH:C:\Program Files\Git\usr\bin=%
|
||||||
- cmake -B build -G "%GENERATOR%" -DBUILD_SHARED_LIBS=%BUILD_SHARED_LIBS%
|
- cmake -B build -G "%GENERATOR%" -DBUILD_SHARED_LIBS=%BUILD_SHARED_LIBS%
|
||||||
- cmake --build build
|
- cmake --build build
|
||||||
-
|
-
|
||||||
|
|||||||
@ -41,12 +41,6 @@ indent_size = 2
|
|||||||
indent_style = tab
|
indent_style = tab
|
||||||
indent_size = unset
|
indent_size = unset
|
||||||
|
|
||||||
[deps/mingw/*.h]
|
|
||||||
indent_style = space
|
|
||||||
indent_size = 4
|
|
||||||
tab_width = 8
|
|
||||||
trim_trailing_whitespace = false
|
|
||||||
|
|
||||||
[deps/getopt.{c,h}]
|
[deps/getopt.{c,h}]
|
||||||
indent_style = space
|
indent_style = space
|
||||||
indent_size = 2
|
indent_size = 2
|
||||||
|
|||||||
@ -295,6 +295,9 @@ video tutorials.
|
|||||||
- Jonas Ådahl
|
- Jonas Ådahl
|
||||||
- Lasse Öörni
|
- Lasse Öörni
|
||||||
- Leonard König
|
- Leonard König
|
||||||
|
- Beoran
|
||||||
|
- Enthuin
|
||||||
|
- Narrik Synthfox
|
||||||
- All the unmentioned and anonymous contributors in the GLFW community, for bug
|
- All the unmentioned and anonymous contributors in the GLFW community, for bug
|
||||||
reports, patches, feedback, testing and encouragement
|
reports, patches, feedback, testing and encouragement
|
||||||
|
|
||||||
|
|||||||
10
README.md
10
README.md
@ -52,7 +52,7 @@ and window system. It does not need any additional headers for context creation
|
|||||||
APIs (WGL, GLX, EGL, NSGL, OSMesa) or rendering APIs (OpenGL, OpenGL ES, Vulkan)
|
APIs (WGL, GLX, EGL, NSGL, OSMesa) or rendering APIs (OpenGL, OpenGL ES, Vulkan)
|
||||||
to enable support for them.
|
to enable support for them.
|
||||||
|
|
||||||
GLFW supports compilation on Windows with Visual C++ 2013 and later, MinGW and
|
GLFW supports compilation on Windows with Visual C++ (2013 and later) and
|
||||||
MinGW-w64, on macOS with Clang and on Linux and other Unix-like systems with GCC
|
MinGW-w64, on macOS with Clang and on Linux and other Unix-like systems with GCC
|
||||||
and Clang. It will likely compile in other environments as well, but this is
|
and Clang. It will likely compile in other environments as well, but this is
|
||||||
not regularly tested.
|
not regularly tested.
|
||||||
@ -79,7 +79,7 @@ more information.
|
|||||||
|
|
||||||
## System requirements
|
## System requirements
|
||||||
|
|
||||||
GLFW supports Windows XP and later and macOS 10.11 and later. Linux and other
|
GLFW supports Windows 7 and later and macOS 10.11 and later. Linux and other
|
||||||
Unix-like systems running the X Window System are supported even without
|
Unix-like systems running the X Window System are supported even without
|
||||||
a desktop environment or modern extensions, although some features require
|
a desktop environment or modern extensions, although some features require
|
||||||
a running window or clipboard manager. The OSMesa backend requires Mesa 6.3.
|
a running window or clipboard manager. The OSMesa backend requires Mesa 6.3.
|
||||||
@ -124,18 +124,22 @@ information on what to include when reporting a bug.
|
|||||||
- Added `GLFW_UNLIMITED_MOUSE_BUTTONS` input mode that allows mouse buttons beyond
|
- Added `GLFW_UNLIMITED_MOUSE_BUTTONS` input mode that allows mouse buttons beyond
|
||||||
the limit of the mouse button tokens to be reported (#2423)
|
the limit of the mouse button tokens to be reported (#2423)
|
||||||
- Updated minimum CMake version to 3.16 (#2541)
|
- Updated minimum CMake version to 3.16 (#2541)
|
||||||
|
- Removed support for building with original MinGW (#2540)
|
||||||
|
- [Win32] Removed support for Windows XP and Vista (#2505)
|
||||||
- [Cocoa] Added `QuartzCore` framework as link-time dependency
|
- [Cocoa] Added `QuartzCore` framework as link-time dependency
|
||||||
- [Cocoa] Removed support for OS X 10.10 Yosemite and earlier (#2506)
|
- [Cocoa] Removed support for OS X 10.10 Yosemite and earlier (#2506)
|
||||||
- [Wayland] Bugfix: The fractional scaling related objects were not destroyed
|
- [Wayland] Bugfix: The fractional scaling related objects were not destroyed
|
||||||
- [Wayland] Bugfix: `glfwInit` would segfault on compositor with no seat (#2517)
|
- [Wayland] Bugfix: `glfwInit` would segfault on compositor with no seat (#2517)
|
||||||
- [Wayland] Bugfix: A drag entering a non-GLFW surface could cause a segfault
|
- [Wayland] Bugfix: A drag entering a non-GLFW surface could cause a segfault
|
||||||
- [Wayland] Bugfix: Ignore key repeat events when no window has keyboard focus (#2727)
|
- [Wayland] Bugfix: Ignore key repeat events when no window has keyboard focus (#2727)
|
||||||
|
- [Wayland] Bugfix: Reset key repeat timer when window destroyed (#2741,#2727)
|
||||||
|
- [Wayland] Bugfix: Memory would leak if reading a data offer failed midway
|
||||||
- [X11] Bugfix: Running without a WM could trigger an assert (#2593,#2601,#2631)
|
- [X11] Bugfix: Running without a WM could trigger an assert (#2593,#2601,#2631)
|
||||||
- [Null] Added Vulkan 'window' surface creation via `VK_EXT_headless_surface`
|
- [Null] Added Vulkan 'window' surface creation via `VK_EXT_headless_surface`
|
||||||
- [Null] Added EGL context creation on Mesa via `EGL_MESA_platform_surfaceless`
|
- [Null] Added EGL context creation on Mesa via `EGL_MESA_platform_surfaceless`
|
||||||
- [EGL] Allowed native access on Wayland with `GLFW_CONTEXT_CREATION_API` set to
|
- [EGL] Allowed native access on Wayland with `GLFW_CONTEXT_CREATION_API` set to
|
||||||
`GLFW_NATIVE_CONTEXT_API` (#2518)
|
`GLFW_NATIVE_CONTEXT_API` (#2518)
|
||||||
|
- Added `GLFWgamepadstatefun`, `glfwSetGamepadStateCallback`, `GLFWjoystickbuttonfun`,`glfwSetJoystickButtonCallback`, `GLFWjoystickaxisfun`, `glfwSetJoystickAxisCallback`, `GLFWjoystickhatfun`, and `glfwSetJoystickHatCallback` for event-based joystick/gamepad input.
|
||||||
|
|
||||||
## Contact
|
## Contact
|
||||||
|
|
||||||
|
|||||||
117
deps/mingw/_mingw_dxhelper.h
vendored
117
deps/mingw/_mingw_dxhelper.h
vendored
@ -1,117 +0,0 @@
|
|||||||
/**
|
|
||||||
* This file has no copyright assigned and is placed in the Public Domain.
|
|
||||||
* This file is part of the mingw-w64 runtime package.
|
|
||||||
* No warranty is given; refer to the file DISCLAIMER within this package.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if defined(_MSC_VER) && !defined(_MSC_EXTENSIONS)
|
|
||||||
#define NONAMELESSUNION 1
|
|
||||||
#endif
|
|
||||||
#if defined(NONAMELESSSTRUCT) && \
|
|
||||||
!defined(NONAMELESSUNION)
|
|
||||||
#define NONAMELESSUNION 1
|
|
||||||
#endif
|
|
||||||
#if defined(NONAMELESSUNION) && \
|
|
||||||
!defined(NONAMELESSSTRUCT)
|
|
||||||
#define NONAMELESSSTRUCT 1
|
|
||||||
#endif
|
|
||||||
#if !defined(__GNU_EXTENSION)
|
|
||||||
#if defined(__GNUC__) || defined(__GNUG__)
|
|
||||||
#define __GNU_EXTENSION __extension__
|
|
||||||
#else
|
|
||||||
#define __GNU_EXTENSION
|
|
||||||
#endif
|
|
||||||
#endif /* __extension__ */
|
|
||||||
|
|
||||||
#ifndef __ANONYMOUS_DEFINED
|
|
||||||
#define __ANONYMOUS_DEFINED
|
|
||||||
#if defined(__GNUC__) || defined(__GNUG__)
|
|
||||||
#define _ANONYMOUS_UNION __extension__
|
|
||||||
#define _ANONYMOUS_STRUCT __extension__
|
|
||||||
#else
|
|
||||||
#define _ANONYMOUS_UNION
|
|
||||||
#define _ANONYMOUS_STRUCT
|
|
||||||
#endif
|
|
||||||
#ifndef NONAMELESSUNION
|
|
||||||
#define _UNION_NAME(x)
|
|
||||||
#define _STRUCT_NAME(x)
|
|
||||||
#else /* NONAMELESSUNION */
|
|
||||||
#define _UNION_NAME(x) x
|
|
||||||
#define _STRUCT_NAME(x) x
|
|
||||||
#endif
|
|
||||||
#endif /* __ANONYMOUS_DEFINED */
|
|
||||||
|
|
||||||
#ifndef DUMMYUNIONNAME
|
|
||||||
# ifdef NONAMELESSUNION
|
|
||||||
# define DUMMYUNIONNAME u
|
|
||||||
# define DUMMYUNIONNAME1 u1 /* Wine uses this variant */
|
|
||||||
# define DUMMYUNIONNAME2 u2
|
|
||||||
# define DUMMYUNIONNAME3 u3
|
|
||||||
# define DUMMYUNIONNAME4 u4
|
|
||||||
# define DUMMYUNIONNAME5 u5
|
|
||||||
# define DUMMYUNIONNAME6 u6
|
|
||||||
# define DUMMYUNIONNAME7 u7
|
|
||||||
# define DUMMYUNIONNAME8 u8
|
|
||||||
# define DUMMYUNIONNAME9 u9
|
|
||||||
# else /* NONAMELESSUNION */
|
|
||||||
# define DUMMYUNIONNAME
|
|
||||||
# define DUMMYUNIONNAME1 /* Wine uses this variant */
|
|
||||||
# define DUMMYUNIONNAME2
|
|
||||||
# define DUMMYUNIONNAME3
|
|
||||||
# define DUMMYUNIONNAME4
|
|
||||||
# define DUMMYUNIONNAME5
|
|
||||||
# define DUMMYUNIONNAME6
|
|
||||||
# define DUMMYUNIONNAME7
|
|
||||||
# define DUMMYUNIONNAME8
|
|
||||||
# define DUMMYUNIONNAME9
|
|
||||||
# endif
|
|
||||||
#endif /* DUMMYUNIONNAME */
|
|
||||||
|
|
||||||
#if !defined(DUMMYUNIONNAME1) /* MinGW does not define this one */
|
|
||||||
# ifdef NONAMELESSUNION
|
|
||||||
# define DUMMYUNIONNAME1 u1 /* Wine uses this variant */
|
|
||||||
# else
|
|
||||||
# define DUMMYUNIONNAME1 /* Wine uses this variant */
|
|
||||||
# endif
|
|
||||||
#endif /* DUMMYUNIONNAME1 */
|
|
||||||
|
|
||||||
#ifndef DUMMYSTRUCTNAME
|
|
||||||
# ifdef NONAMELESSUNION
|
|
||||||
# define DUMMYSTRUCTNAME s
|
|
||||||
# define DUMMYSTRUCTNAME1 s1 /* Wine uses this variant */
|
|
||||||
# define DUMMYSTRUCTNAME2 s2
|
|
||||||
# define DUMMYSTRUCTNAME3 s3
|
|
||||||
# define DUMMYSTRUCTNAME4 s4
|
|
||||||
# define DUMMYSTRUCTNAME5 s5
|
|
||||||
# else
|
|
||||||
# define DUMMYSTRUCTNAME
|
|
||||||
# define DUMMYSTRUCTNAME1 /* Wine uses this variant */
|
|
||||||
# define DUMMYSTRUCTNAME2
|
|
||||||
# define DUMMYSTRUCTNAME3
|
|
||||||
# define DUMMYSTRUCTNAME4
|
|
||||||
# define DUMMYSTRUCTNAME5
|
|
||||||
# endif
|
|
||||||
#endif /* DUMMYSTRUCTNAME */
|
|
||||||
|
|
||||||
/* These are for compatibility with the Wine source tree */
|
|
||||||
|
|
||||||
#ifndef WINELIB_NAME_AW
|
|
||||||
# ifdef __MINGW_NAME_AW
|
|
||||||
# define WINELIB_NAME_AW __MINGW_NAME_AW
|
|
||||||
# else
|
|
||||||
# ifdef UNICODE
|
|
||||||
# define WINELIB_NAME_AW(func) func##W
|
|
||||||
# else
|
|
||||||
# define WINELIB_NAME_AW(func) func##A
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
#endif /* WINELIB_NAME_AW */
|
|
||||||
|
|
||||||
#ifndef DECL_WINELIB_TYPE_AW
|
|
||||||
# ifdef __MINGW_TYPEDEF_AW
|
|
||||||
# define DECL_WINELIB_TYPE_AW __MINGW_TYPEDEF_AW
|
|
||||||
# else
|
|
||||||
# define DECL_WINELIB_TYPE_AW(type) typedef WINELIB_NAME_AW(type) type;
|
|
||||||
# endif
|
|
||||||
#endif /* DECL_WINELIB_TYPE_AW */
|
|
||||||
|
|
||||||
2467
deps/mingw/dinput.h
vendored
2467
deps/mingw/dinput.h
vendored
File diff suppressed because it is too large
Load Diff
239
deps/mingw/xinput.h
vendored
239
deps/mingw/xinput.h
vendored
@ -1,239 +0,0 @@
|
|||||||
/*
|
|
||||||
* The Wine project - Xinput Joystick Library
|
|
||||||
* Copyright 2008 Andrew Fenn
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __WINE_XINPUT_H
|
|
||||||
#define __WINE_XINPUT_H
|
|
||||||
|
|
||||||
#include <windef.h>
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Bitmasks for the joysticks buttons, determines what has
|
|
||||||
* been pressed on the joystick, these need to be mapped
|
|
||||||
* to whatever device you're using instead of an xbox 360
|
|
||||||
* joystick
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define XINPUT_GAMEPAD_DPAD_UP 0x0001
|
|
||||||
#define XINPUT_GAMEPAD_DPAD_DOWN 0x0002
|
|
||||||
#define XINPUT_GAMEPAD_DPAD_LEFT 0x0004
|
|
||||||
#define XINPUT_GAMEPAD_DPAD_RIGHT 0x0008
|
|
||||||
#define XINPUT_GAMEPAD_START 0x0010
|
|
||||||
#define XINPUT_GAMEPAD_BACK 0x0020
|
|
||||||
#define XINPUT_GAMEPAD_LEFT_THUMB 0x0040
|
|
||||||
#define XINPUT_GAMEPAD_RIGHT_THUMB 0x0080
|
|
||||||
#define XINPUT_GAMEPAD_LEFT_SHOULDER 0x0100
|
|
||||||
#define XINPUT_GAMEPAD_RIGHT_SHOULDER 0x0200
|
|
||||||
#define XINPUT_GAMEPAD_A 0x1000
|
|
||||||
#define XINPUT_GAMEPAD_B 0x2000
|
|
||||||
#define XINPUT_GAMEPAD_X 0x4000
|
|
||||||
#define XINPUT_GAMEPAD_Y 0x8000
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Defines the flags used to determine if the user is pushing
|
|
||||||
* down on a button, not holding a button, etc
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define XINPUT_KEYSTROKE_KEYDOWN 0x0001
|
|
||||||
#define XINPUT_KEYSTROKE_KEYUP 0x0002
|
|
||||||
#define XINPUT_KEYSTROKE_REPEAT 0x0004
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Defines the codes which are returned by XInputGetKeystroke
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define VK_PAD_A 0x5800
|
|
||||||
#define VK_PAD_B 0x5801
|
|
||||||
#define VK_PAD_X 0x5802
|
|
||||||
#define VK_PAD_Y 0x5803
|
|
||||||
#define VK_PAD_RSHOULDER 0x5804
|
|
||||||
#define VK_PAD_LSHOULDER 0x5805
|
|
||||||
#define VK_PAD_LTRIGGER 0x5806
|
|
||||||
#define VK_PAD_RTRIGGER 0x5807
|
|
||||||
#define VK_PAD_DPAD_UP 0x5810
|
|
||||||
#define VK_PAD_DPAD_DOWN 0x5811
|
|
||||||
#define VK_PAD_DPAD_LEFT 0x5812
|
|
||||||
#define VK_PAD_DPAD_RIGHT 0x5813
|
|
||||||
#define VK_PAD_START 0x5814
|
|
||||||
#define VK_PAD_BACK 0x5815
|
|
||||||
#define VK_PAD_LTHUMB_PRESS 0x5816
|
|
||||||
#define VK_PAD_RTHUMB_PRESS 0x5817
|
|
||||||
#define VK_PAD_LTHUMB_UP 0x5820
|
|
||||||
#define VK_PAD_LTHUMB_DOWN 0x5821
|
|
||||||
#define VK_PAD_LTHUMB_RIGHT 0x5822
|
|
||||||
#define VK_PAD_LTHUMB_LEFT 0x5823
|
|
||||||
#define VK_PAD_LTHUMB_UPLEFT 0x5824
|
|
||||||
#define VK_PAD_LTHUMB_UPRIGHT 0x5825
|
|
||||||
#define VK_PAD_LTHUMB_DOWNRIGHT 0x5826
|
|
||||||
#define VK_PAD_LTHUMB_DOWNLEFT 0x5827
|
|
||||||
#define VK_PAD_RTHUMB_UP 0x5830
|
|
||||||
#define VK_PAD_RTHUMB_DOWN 0x5831
|
|
||||||
#define VK_PAD_RTHUMB_RIGHT 0x5832
|
|
||||||
#define VK_PAD_RTHUMB_LEFT 0x5833
|
|
||||||
#define VK_PAD_RTHUMB_UPLEFT 0x5834
|
|
||||||
#define VK_PAD_RTHUMB_UPRIGHT 0x5835
|
|
||||||
#define VK_PAD_RTHUMB_DOWNRIGHT 0x5836
|
|
||||||
#define VK_PAD_RTHUMB_DOWNLEFT 0x5837
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Deadzones are for analogue joystick controls on the joypad
|
|
||||||
* which determine when input should be assumed to be in the
|
|
||||||
* middle of the pad. This is a threshold to stop a joypad
|
|
||||||
* controlling the game when the player isn't touching the
|
|
||||||
* controls.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE 7849
|
|
||||||
#define XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE 8689
|
|
||||||
#define XINPUT_GAMEPAD_TRIGGER_THRESHOLD 30
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Defines what type of abilities the type of joystick has
|
|
||||||
* DEVTYPE_GAMEPAD is available for all joysticks, however
|
|
||||||
* there may be more specific identifiers for other joysticks
|
|
||||||
* which are being used.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define XINPUT_DEVTYPE_GAMEPAD 0x01
|
|
||||||
#define XINPUT_DEVSUBTYPE_GAMEPAD 0x01
|
|
||||||
#define XINPUT_DEVSUBTYPE_WHEEL 0x02
|
|
||||||
#define XINPUT_DEVSUBTYPE_ARCADE_STICK 0x03
|
|
||||||
#define XINPUT_DEVSUBTYPE_FLIGHT_SICK 0x04
|
|
||||||
#define XINPUT_DEVSUBTYPE_DANCE_PAD 0x05
|
|
||||||
#define XINPUT_DEVSUBTYPE_GUITAR 0x06
|
|
||||||
#define XINPUT_DEVSUBTYPE_DRUM_KIT 0x08
|
|
||||||
|
|
||||||
/*
|
|
||||||
* These are used with the XInputGetCapabilities function to
|
|
||||||
* determine the abilities to the joystick which has been
|
|
||||||
* plugged in.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define XINPUT_CAPS_VOICE_SUPPORTED 0x0004
|
|
||||||
#define XINPUT_FLAG_GAMEPAD 0x00000001
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Defines the status of the battery if one is used in the
|
|
||||||
* attached joystick. The first two define if the joystick
|
|
||||||
* supports a battery. Disconnected means that the joystick
|
|
||||||
* isn't connected. Wired shows that the joystick is a wired
|
|
||||||
* joystick.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define BATTERY_DEVTYPE_GAMEPAD 0x00
|
|
||||||
#define BATTERY_DEVTYPE_HEADSET 0x01
|
|
||||||
#define BATTERY_TYPE_DISCONNECTED 0x00
|
|
||||||
#define BATTERY_TYPE_WIRED 0x01
|
|
||||||
#define BATTERY_TYPE_ALKALINE 0x02
|
|
||||||
#define BATTERY_TYPE_NIMH 0x03
|
|
||||||
#define BATTERY_TYPE_UNKNOWN 0xFF
|
|
||||||
#define BATTERY_LEVEL_EMPTY 0x00
|
|
||||||
#define BATTERY_LEVEL_LOW 0x01
|
|
||||||
#define BATTERY_LEVEL_MEDIUM 0x02
|
|
||||||
#define BATTERY_LEVEL_FULL 0x03
|
|
||||||
|
|
||||||
/*
|
|
||||||
* How many joysticks can be used with this library. Games that
|
|
||||||
* use the xinput library will not go over this number.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define XUSER_MAX_COUNT 4
|
|
||||||
#define XUSER_INDEX_ANY 0x000000FF
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Defines the structure of an xbox 360 joystick.
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef struct _XINPUT_GAMEPAD {
|
|
||||||
WORD wButtons;
|
|
||||||
BYTE bLeftTrigger;
|
|
||||||
BYTE bRightTrigger;
|
|
||||||
SHORT sThumbLX;
|
|
||||||
SHORT sThumbLY;
|
|
||||||
SHORT sThumbRX;
|
|
||||||
SHORT sThumbRY;
|
|
||||||
} XINPUT_GAMEPAD, *PXINPUT_GAMEPAD;
|
|
||||||
|
|
||||||
typedef struct _XINPUT_STATE {
|
|
||||||
DWORD dwPacketNumber;
|
|
||||||
XINPUT_GAMEPAD Gamepad;
|
|
||||||
} XINPUT_STATE, *PXINPUT_STATE;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Defines the structure of how much vibration is set on both the
|
|
||||||
* right and left motors in a joystick. If you're not using a 360
|
|
||||||
* joystick you will have to map these to your device.
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef struct _XINPUT_VIBRATION {
|
|
||||||
WORD wLeftMotorSpeed;
|
|
||||||
WORD wRightMotorSpeed;
|
|
||||||
} XINPUT_VIBRATION, *PXINPUT_VIBRATION;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Defines the structure for what kind of abilities the joystick has
|
|
||||||
* such abilities are things such as if the joystick has the ability
|
|
||||||
* to send and receive audio, if the joystick is in fact a driving
|
|
||||||
* wheel or perhaps if the joystick is some kind of dance pad or
|
|
||||||
* guitar.
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef struct _XINPUT_CAPABILITIES {
|
|
||||||
BYTE Type;
|
|
||||||
BYTE SubType;
|
|
||||||
WORD Flags;
|
|
||||||
XINPUT_GAMEPAD Gamepad;
|
|
||||||
XINPUT_VIBRATION Vibration;
|
|
||||||
} XINPUT_CAPABILITIES, *PXINPUT_CAPABILITIES;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Defines the structure for a joystick input event which is
|
|
||||||
* retrieved using the function XInputGetKeystroke
|
|
||||||
*/
|
|
||||||
typedef struct _XINPUT_KEYSTROKE {
|
|
||||||
WORD VirtualKey;
|
|
||||||
WCHAR Unicode;
|
|
||||||
WORD Flags;
|
|
||||||
BYTE UserIndex;
|
|
||||||
BYTE HidCode;
|
|
||||||
} XINPUT_KEYSTROKE, *PXINPUT_KEYSTROKE;
|
|
||||||
|
|
||||||
typedef struct _XINPUT_BATTERY_INFORMATION
|
|
||||||
{
|
|
||||||
BYTE BatteryType;
|
|
||||||
BYTE BatteryLevel;
|
|
||||||
} XINPUT_BATTERY_INFORMATION, *PXINPUT_BATTERY_INFORMATION;
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void WINAPI XInputEnable(WINBOOL);
|
|
||||||
DWORD WINAPI XInputSetState(DWORD, XINPUT_VIBRATION*);
|
|
||||||
DWORD WINAPI XInputGetState(DWORD, XINPUT_STATE*);
|
|
||||||
DWORD WINAPI XInputGetKeystroke(DWORD, DWORD, PXINPUT_KEYSTROKE);
|
|
||||||
DWORD WINAPI XInputGetCapabilities(DWORD, DWORD, XINPUT_CAPABILITIES*);
|
|
||||||
DWORD WINAPI XInputGetDSoundAudioDeviceGuids(DWORD, GUID*, GUID*);
|
|
||||||
DWORD WINAPI XInputGetBatteryInformation(DWORD, BYTE, XINPUT_BATTERY_INFORMATION*);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* __WINE_XINPUT_H */
|
|
||||||
@ -36,9 +36,9 @@ specific to GLFW. It may be a useful companion to this one.
|
|||||||
|
|
||||||
### Installing dependencies {#compile_deps}
|
### Installing dependencies {#compile_deps}
|
||||||
|
|
||||||
The C/C++ development environments in Visual Studio, Xcode and MinGW come with
|
The C/C++ development environments in Visual Studio, Xcode and MinGW-w64 come
|
||||||
all necessary dependencies for compiling GLFW, but on Unix-like systems like
|
with all necessary dependencies for compiling GLFW, but on Unix-like systems
|
||||||
Linux and FreeBSD you will need a few extra packages.
|
like Linux and FreeBSD you will need a few extra packages.
|
||||||
|
|
||||||
|
|
||||||
#### Dependencies for Wayland and X11 {#compile_deps_wayland}
|
#### Dependencies for Wayland and X11 {#compile_deps_wayland}
|
||||||
@ -180,7 +180,7 @@ cd path/to/build
|
|||||||
make
|
make
|
||||||
```
|
```
|
||||||
|
|
||||||
With MinGW, it is `mingw32-make`.
|
With MinGW-w64, it is `mingw32-make`.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
cd path/to/build
|
cd path/to/build
|
||||||
@ -299,12 +299,12 @@ library. This option is only available when compiling for Linux and other Unix-
|
|||||||
systems other than macOS. This is enabled by default.
|
systems other than macOS. This is enabled by default.
|
||||||
|
|
||||||
|
|
||||||
## Cross-compilation with CMake and MinGW {#compile_mingw_cross}
|
## Cross-compilation with CMake and MinGW-w64 {#compile_mingw_cross}
|
||||||
|
|
||||||
Both Cygwin and many Linux distributions have MinGW or MinGW-w64 packages. For
|
Both Cygwin and many Linux distributions have MinGW-w64 packages. For example,
|
||||||
example, Cygwin has the `mingw64-i686-gcc` and `mingw64-x86_64-gcc` packages
|
Cygwin has the `mingw64-i686-gcc` and `mingw64-x86_64-gcc` packages for 32- and
|
||||||
for 32- and 64-bit version of MinGW-w64, while Debian GNU/Linux and derivatives
|
64-bit version of MinGW-w64, while Debian GNU/Linux and derivatives like Ubuntu
|
||||||
like Ubuntu have the `mingw-w64` package for both.
|
have the `mingw-w64` package for both.
|
||||||
|
|
||||||
GLFW has CMake toolchain files in the `CMake` subdirectory that set up
|
GLFW has CMake toolchain files in the `CMake` subdirectory that set up
|
||||||
cross-compilation of Windows binaries. To use these files you set the
|
cross-compilation of Windows binaries. To use these files you set the
|
||||||
@ -315,9 +315,9 @@ configuring and generating the build files.
|
|||||||
cmake -S path/to/glfw -B path/to/build -D CMAKE_TOOLCHAIN_FILE=path/to/file
|
cmake -S path/to/glfw -B path/to/build -D CMAKE_TOOLCHAIN_FILE=path/to/file
|
||||||
```
|
```
|
||||||
|
|
||||||
The exact toolchain file to use depends on the prefix used by the MinGW or
|
The exact toolchain file to use depends on the prefix used by the MinGW-w64
|
||||||
MinGW-w64 binaries on your system. You can usually see this in the /usr
|
binaries on your system. You can usually see this in the /usr directory. For
|
||||||
directory. For example, both the Ubuntu and Cygwin MinGW-w64 packages have
|
example, both the Ubuntu and Cygwin MinGW-w64 packages have
|
||||||
`/usr/x86_64-w64-mingw32` for the 64-bit compilers, so the correct invocation
|
`/usr/x86_64-w64-mingw32` for the 64-bit compilers, so the correct invocation
|
||||||
would be:
|
would be:
|
||||||
|
|
||||||
|
|||||||
@ -911,6 +911,85 @@ righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,
|
|||||||
were recently added to SDL. The input modifiers `+`, `-` and `~` are supported
|
were recently added to SDL. The input modifiers `+`, `-` and `~` are supported
|
||||||
and described above.
|
and described above.
|
||||||
|
|
||||||
|
### Event-based joystick and gamepad input {#joystick_input_event}
|
||||||
|
|
||||||
|
If you wish to be notified when a button on a joystick is pressed or released, set a joystick button callback.
|
||||||
|
|
||||||
|
```c
|
||||||
|
glfwSetJoystickButtonCallback(joystick_button_callback);
|
||||||
|
```
|
||||||
|
|
||||||
|
The callback function receives the joystick id, the [joystick button](@ref joystick_button) that was pressed or released, and action.
|
||||||
|
|
||||||
|
```c
|
||||||
|
void joystick_button_callback(int jid, int button, int action)
|
||||||
|
{
|
||||||
|
if (button == 0 && action == GLFW_PRESS)
|
||||||
|
jump();
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
The action is one of `GLFW_PRESS` or `GLFW_RELEASE`
|
||||||
|
|
||||||
|
If you wish to be notified when an axis on a joystick is moved, set a joystick axis callback.
|
||||||
|
|
||||||
|
```c
|
||||||
|
glfwSetJoystickAxisCallback(joystick_axis_callback);
|
||||||
|
```
|
||||||
|
|
||||||
|
The callback function receives the joystick id, [joystick axis](@ref joystick_axis) that was moved, and float value from -1.0 to 1.0 for the axis.
|
||||||
|
|
||||||
|
```c
|
||||||
|
void joystick_axis_callback(int jid, int axis, float value)
|
||||||
|
{
|
||||||
|
if (axis == 0){
|
||||||
|
if(value == -1.0f)
|
||||||
|
move_left();
|
||||||
|
else if(value == 1.0f)
|
||||||
|
move_right();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
If you wish to be notified when a hat on a joystick is moved, set a joystick hat callback.
|
||||||
|
|
||||||
|
```c
|
||||||
|
glfwSetJoystickHatCallback(joystick_hat_callback);
|
||||||
|
```
|
||||||
|
|
||||||
|
The callback function receives the joystick id, hat, and the [hat states](@ref hat_state).
|
||||||
|
|
||||||
|
```c
|
||||||
|
void joystick_hat_callback(int jid, int hat, int position)
|
||||||
|
{
|
||||||
|
if(hat == 0 && position == GLFW_HAT_UP)
|
||||||
|
move_up();
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
If you wish to be notified when the state of a gamepad is updated, set a gamepad state callback. This callback will occur every time any button, axis, or hat updates, so with this, you will have to handle checks for if a value is changed.
|
||||||
|
|
||||||
|
```c
|
||||||
|
glfwSetGamepadStateCallback(gamepad_state_callback);
|
||||||
|
```
|
||||||
|
|
||||||
|
The callback function recieves the joystick id and the gamepad state.
|
||||||
|
|
||||||
|
```c
|
||||||
|
bool jumpButtonHeld = false;
|
||||||
|
|
||||||
|
gamepad_state_callback(int jid, GLFWgamepadstate state){
|
||||||
|
if (state.buttons[GLFW_GAMEPAD_BUTTON_A] && !jumpButtonHeld)
|
||||||
|
{
|
||||||
|
input_jump();
|
||||||
|
jumpButtonHeld = true;
|
||||||
|
}
|
||||||
|
else if (!state.buttons[GLFW_GAMEPAD_BUTTON_A] && jumpButtonHeld)
|
||||||
|
{
|
||||||
|
jumpButtonHeld = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## Time input {#time}
|
## Time input {#time}
|
||||||
|
|
||||||
|
|||||||
@ -621,11 +621,11 @@ The format of the string is as follows:
|
|||||||
- The names of the always supported context creation APIs EGL and OSMesa
|
- The names of the always supported context creation APIs EGL and OSMesa
|
||||||
- Any additional compile-time options, APIs and (on Windows) what compiler was used
|
- Any additional compile-time options, APIs and (on Windows) what compiler was used
|
||||||
|
|
||||||
For example, compiling GLFW 3.5 with MinGW as a DLL for Windows, may result in a version string
|
For example, compiling GLFW 3.5 with MinGW-64 as a DLL for Windows, may result
|
||||||
like this:
|
in a version string like this:
|
||||||
|
|
||||||
```c
|
```c
|
||||||
3.5.0 Win32 WGL Null EGL OSMesa MinGW DLL
|
3.5.0 Win32 WGL Null EGL OSMesa MinGW-w64 DLL
|
||||||
```
|
```
|
||||||
|
|
||||||
Compiling GLFW as a static library for Linux, with both Wayland and X11 enabled, may
|
Compiling GLFW as a static library for Linux, with both Wayland and X11 enabled, may
|
||||||
|
|||||||
30
docs/news.md
30
docs/news.md
@ -14,18 +14,48 @@ values over 8. For compatibility with older versions, the
|
|||||||
@ref GLFW_UNLIMITED_MOUSE_BUTTONS input mode needs to be set to make use of
|
@ref GLFW_UNLIMITED_MOUSE_BUTTONS input mode needs to be set to make use of
|
||||||
this.
|
this.
|
||||||
|
|
||||||
|
### Callback functions for gamepad state, joystick buttons, joystick axes, and joystick hat inputs {#joystick_input_callbacks}
|
||||||
|
|
||||||
|
GLFW now has callback functions for [gamepad state](@ref glfwSetGamepadStateCallback), [joystick buttons](@ref glfwSetJoystickButtonCallback), [joystick axes](@ref glfwSetJoystickAxisCallback), and [joystick hats](@ref glfwSetJoystickHatCallback), allowing for
|
||||||
|
event-based inputs for joysticks and gamepads.
|
||||||
|
|
||||||
## Caveats {#caveats}
|
## Caveats {#caveats}
|
||||||
|
|
||||||
## Deprecations {#deprecations}
|
## Deprecations {#deprecations}
|
||||||
|
|
||||||
## Removals {#removals}
|
## Removals {#removals}
|
||||||
|
|
||||||
|
### Windows XP and Vista support has been removed {#winxp_vista}
|
||||||
|
|
||||||
|
Support for Windows XP and Vista has been removed. Windows XP has been out of extended
|
||||||
|
support since 2014.
|
||||||
|
|
||||||
|
|
||||||
|
### Original MinGW support has been removed {#original_mingw}
|
||||||
|
|
||||||
|
Support for the now unmaintained original MinGW distribution has been removed.
|
||||||
|
|
||||||
|
This does not apply to the much more capable [MinGW-w64](https://www.mingw-w64.org/),
|
||||||
|
which remains fully supported. MinGW-w64 can build both 32- and 64-bit binaries, is
|
||||||
|
actively maintained and available on many platforms.
|
||||||
|
|
||||||
|
|
||||||
## New symbols {#new_symbols}
|
## New symbols {#new_symbols}
|
||||||
|
|
||||||
### New functions {#new_functions}
|
### New functions {#new_functions}
|
||||||
|
|
||||||
|
- @ref glfwSetJoystickButtonCallback
|
||||||
|
- @ref glfwSetJoystickAxisCallback
|
||||||
|
- @ref glfwSetJoystickHatCallback
|
||||||
|
- @ref glfwSetGamepadStateCallback
|
||||||
|
|
||||||
### New types {#new_types}
|
### New types {#new_types}
|
||||||
|
|
||||||
|
- @ref GLFWjoystickbuttonfun
|
||||||
|
- @ref GLFWjoystickaxisfun
|
||||||
|
- @ref GLFWjoystickhatfun
|
||||||
|
- @ref GLFWgamepadstatefun
|
||||||
|
|
||||||
### New constants {#new_constants}
|
### New constants {#new_constants}
|
||||||
|
|
||||||
- @ref GLFW_UNLIMITED_MOUSE_BUTTONS
|
- @ref GLFW_UNLIMITED_MOUSE_BUTTONS
|
||||||
|
|||||||
@ -2106,6 +2106,7 @@ typedef struct GLFWimage
|
|||||||
*
|
*
|
||||||
* @sa @ref gamepad
|
* @sa @ref gamepad
|
||||||
* @sa @ref glfwGetGamepadState
|
* @sa @ref glfwGetGamepadState
|
||||||
|
* @sa @ref glfwSetGamepadStateCallback
|
||||||
*
|
*
|
||||||
* @since Added in version 3.3.
|
* @since Added in version 3.3.
|
||||||
*
|
*
|
||||||
@ -2155,6 +2156,103 @@ typedef struct GLFWallocator
|
|||||||
void* user;
|
void* user;
|
||||||
} GLFWallocator;
|
} GLFWallocator;
|
||||||
|
|
||||||
|
/*! @brief The function pointer type for joystick button callbacks.
|
||||||
|
*
|
||||||
|
* This is the function pointer type for joystick button callbacks. A joystick
|
||||||
|
* button callback function has the following signature:
|
||||||
|
* @code
|
||||||
|
* void function_name(int jid, int button, int action)
|
||||||
|
* @endcode
|
||||||
|
*
|
||||||
|
* @param[in] jid The joystick that had a button pressed or released.
|
||||||
|
* @param[in] button The [joystick button](@ref buttons) that was pressed or released.
|
||||||
|
* @param[in] action `GLFW_PRESS` or `GLFW_RELEASE`. Future
|
||||||
|
* releases may add more actions.
|
||||||
|
*
|
||||||
|
* @sa @ref input_joystick_button
|
||||||
|
* @sa @ref glfwSetJoystickButonCallback
|
||||||
|
*
|
||||||
|
* @since Added in version 3.4.
|
||||||
|
* @ingroup input
|
||||||
|
*/
|
||||||
|
typedef void (* GLFWjoystickbuttonfun)(int,int,int);
|
||||||
|
|
||||||
|
/*! @brief The function pointer type for joystick axis movement callbacks.
|
||||||
|
*
|
||||||
|
* This is the function pointer type for joystick axis movement callbacks. A joystick
|
||||||
|
* axis movement callback function has the following signature:
|
||||||
|
* @code
|
||||||
|
* void function_name(int jid, int axis, float position)
|
||||||
|
* @endcode
|
||||||
|
*
|
||||||
|
* @param[in] jid The joystick that had an axis moved.
|
||||||
|
* @param[in] axis The [joystick axis](@ref gamepad axes) that was moved.
|
||||||
|
* @param[in] position A value between -1.0 and 1.0 that indicates the position of the axis.
|
||||||
|
*
|
||||||
|
* @sa @ref input_gamepad_axis
|
||||||
|
* @sa @ref glfwSetJoystickAxisCallback
|
||||||
|
*
|
||||||
|
* @since Added in version 3.4.
|
||||||
|
* @ingroup input
|
||||||
|
*/
|
||||||
|
typedef void (* GLFWjoystickaxisfun)(int,int,float);
|
||||||
|
|
||||||
|
/*! @brief The function pointer type for joystick hat movement callbacks.
|
||||||
|
*
|
||||||
|
* This is the function pointer type for joystick hat movement callbacks. A joystick
|
||||||
|
* hat movement callback function has the following signature:
|
||||||
|
* @code
|
||||||
|
* void function_name(int jid, int hat, int position)
|
||||||
|
* @endcode
|
||||||
|
*
|
||||||
|
* @param[in] jid The joystick that had an axis moved.
|
||||||
|
* @param[in] hat The [joystick hat](@ref joystick hats) that was moved.
|
||||||
|
* @param[in] position A value that indicates the position of the hat.
|
||||||
|
* The position parameter is one of the following values:
|
||||||
|
*
|
||||||
|
* Name | Value
|
||||||
|
* ---- | -----
|
||||||
|
* `GLFW_HAT_CENTERED` | 0
|
||||||
|
* `GLFW_HAT_UP` | 1
|
||||||
|
* `GLFW_HAT_RIGHT` | 2
|
||||||
|
* `GLFW_HAT_DOWN` | 4
|
||||||
|
* `GLFW_HAT_LEFT` | 8
|
||||||
|
* `GLFW_HAT_RIGHT_UP` | `GLFW_HAT_RIGHT` \| `GLFW_HAT_UP`
|
||||||
|
* `GLFW_HAT_RIGHT_DOWN` | `GLFW_HAT_RIGHT` \| `GLFW_HAT_DOWN`
|
||||||
|
* `GLFW_HAT_LEFT_UP` | `GLFW_HAT_LEFT` \| `GLFW_HAT_UP`
|
||||||
|
* `GLFW_HAT_LEFT_DOWN` | `GLFW_HAT_LEFT` \| `GLFW_HAT_DOWN`
|
||||||
|
*
|
||||||
|
* The diagonal directions are bitwise combinations of the primary (up, right,
|
||||||
|
* down and left) directions and you can test for these individually by ANDing
|
||||||
|
* it with the corresponding direction.
|
||||||
|
*
|
||||||
|
* @sa @ref input_joystick_hat
|
||||||
|
* @sa @ref glfwSetJoystickHatCallback
|
||||||
|
*
|
||||||
|
* @since Added in version 3.4.
|
||||||
|
* @ingroup input
|
||||||
|
*/
|
||||||
|
typedef void (* GLFWjoystickhatfun)(int,int,int);
|
||||||
|
|
||||||
|
/*! @brief The function pointer type for game pad state changes.
|
||||||
|
*
|
||||||
|
* This is the function pointer type for game pad state change callbacks.
|
||||||
|
* A game pad state change callback function has the following signature:
|
||||||
|
* @code
|
||||||
|
* void function_name(int jid, GLFWgamepadstate* state)
|
||||||
|
* @endcode
|
||||||
|
*
|
||||||
|
* @param[in] jid The ID of the game pad that changed state.
|
||||||
|
* @param[in] state the state of the game pad
|
||||||
|
*
|
||||||
|
* @sa @ref input_gamepad
|
||||||
|
* @sa @ref glfwSetGamepadStateCallback
|
||||||
|
*
|
||||||
|
* @since Added in version 3.4.
|
||||||
|
* @ingroup input
|
||||||
|
*/
|
||||||
|
typedef void (* GLFWgamepadstatefun)(int jid, GLFWgamepadstate state);
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
* GLFW API functions
|
* GLFW API functions
|
||||||
@ -5806,6 +5904,140 @@ GLFWAPI int glfwJoystickIsGamepad(int jid);
|
|||||||
*/
|
*/
|
||||||
GLFWAPI GLFWjoystickfun glfwSetJoystickCallback(GLFWjoystickfun callback);
|
GLFWAPI GLFWjoystickfun glfwSetJoystickCallback(GLFWjoystickfun callback);
|
||||||
|
|
||||||
|
/*! @brief Sets the joystick button callback.
|
||||||
|
*
|
||||||
|
* This function sets the joystick configuration callback, or removes the
|
||||||
|
* currently set callback. This is called when a joystick button is pressed
|
||||||
|
* or released.
|
||||||
|
*
|
||||||
|
* For joystick button events to be delivered on all platforms,
|
||||||
|
* you need to call one of the [event processing](@ref events)
|
||||||
|
* functions.
|
||||||
|
*
|
||||||
|
* @param[in] callback The new callback, or `NULL` to remove the currently set
|
||||||
|
* callback.
|
||||||
|
* @return The previously set callback, or `NULL` if no callback was set or the
|
||||||
|
* library had not been [initialized](@ref intro_init).
|
||||||
|
*
|
||||||
|
* @callback_signature
|
||||||
|
* @code
|
||||||
|
* void function_name(int jid, int button, int state)
|
||||||
|
* @endcode
|
||||||
|
* For more information about the callback parameters, see the
|
||||||
|
* [function pointer type](@ref GLFWjoystickbuttonfun).
|
||||||
|
*
|
||||||
|
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
|
||||||
|
*
|
||||||
|
* @thread_safety This function must only be called from the main thread.
|
||||||
|
*
|
||||||
|
* @sa @ref joystick_event
|
||||||
|
*
|
||||||
|
* @since Added in version 3.2.
|
||||||
|
*
|
||||||
|
* @ingroup input
|
||||||
|
*/
|
||||||
|
GLFWAPI GLFWjoystickbuttonfun glfwSetJoystickButtonCallback(GLFWjoystickbuttonfun callback);
|
||||||
|
|
||||||
|
/*! @brief Sets the joystick axis callback.
|
||||||
|
*
|
||||||
|
* This function sets the joystick axis callback, or removes the
|
||||||
|
* currently set callback. This is called when a joystick axis moved.
|
||||||
|
*
|
||||||
|
* For joystick axis events to be delivered on all platforms,
|
||||||
|
* you need to call one of the [event processing](@ref events)
|
||||||
|
* functions.
|
||||||
|
*
|
||||||
|
* @param[in] callback The new callback, or `NULL` to remove the currently set
|
||||||
|
* callback.
|
||||||
|
* @return The previously set callback, or `NULL` if no callback was set or the
|
||||||
|
* library had not been [initialized](@ref intro_init).
|
||||||
|
*
|
||||||
|
* @callback_signature
|
||||||
|
* @code
|
||||||
|
* void function_name(int jid, int axis, float state)
|
||||||
|
* @endcode
|
||||||
|
* For more information about the callback parameters, see the
|
||||||
|
* [function pointer type](@ref GLFWjoystickaxisfun).
|
||||||
|
*
|
||||||
|
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
|
||||||
|
*
|
||||||
|
* @thread_safety This function must only be called from the main thread.
|
||||||
|
*
|
||||||
|
* @sa @ref joystick_event
|
||||||
|
*
|
||||||
|
* @since Added in version 3.2.
|
||||||
|
*
|
||||||
|
* @ingroup input
|
||||||
|
*/
|
||||||
|
GLFWAPI GLFWjoystickaxisfun glfwSetJoystickAxisCallback(GLFWjoystickaxisfun callback);
|
||||||
|
|
||||||
|
/*! @brief Sets the joystick hat callback.
|
||||||
|
*
|
||||||
|
* This function sets the joystick hat callback, or removes the
|
||||||
|
* currently set callback. This is called when a joystick hat moved.
|
||||||
|
*
|
||||||
|
* For joystick hat events to be delivered on all platforms,
|
||||||
|
* you need to call one of the [event processing](@ref events)
|
||||||
|
* functions.
|
||||||
|
*
|
||||||
|
* @param[in] callback The new callback, or `NULL` to remove the currently set
|
||||||
|
* callback.
|
||||||
|
* @return The previously set callback, or `NULL` if no callback was set or the
|
||||||
|
* library had not been [initialized](@ref intro_init).
|
||||||
|
*
|
||||||
|
* @callback_signature
|
||||||
|
* @code
|
||||||
|
* void function_name(int jid, int hat, int state)
|
||||||
|
* @endcode
|
||||||
|
* For more information about the callback parameters, see the
|
||||||
|
* [function pointer type](@ref GLFWjoystickhatfun).
|
||||||
|
*
|
||||||
|
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
|
||||||
|
*
|
||||||
|
* @thread_safety This function must only be called from the main thread.
|
||||||
|
*
|
||||||
|
* @sa @ref joystick_event
|
||||||
|
*
|
||||||
|
* @since Added in version 3.2.
|
||||||
|
*
|
||||||
|
* @ingroup input
|
||||||
|
*/
|
||||||
|
GLFWAPI GLFWjoystickhatfun glfwSetJoystickHatCallback(GLFWjoystickhatfun callback);
|
||||||
|
|
||||||
|
/*! @brief Sets the game pad state callback.
|
||||||
|
*
|
||||||
|
* This function sets the game pad state callback, or removes the
|
||||||
|
* currently set callback. This is called when a game pad state changes.
|
||||||
|
*
|
||||||
|
* For game pad events to be delivered on all platforms,
|
||||||
|
* you need to call one of the [event processing](@ref events)
|
||||||
|
* functions.
|
||||||
|
*
|
||||||
|
* @param[in] callback The new callback, or `NULL` to remove the currently set
|
||||||
|
* callback.
|
||||||
|
* @return The previously set callback, or `NULL` if no callback was set or the
|
||||||
|
* library had not been [initialized](@ref intro_init).
|
||||||
|
*
|
||||||
|
* @callback_signature
|
||||||
|
* @code
|
||||||
|
* void function_name(int jid, unsigned char buttons[15], float axes[6])
|
||||||
|
* @endcode
|
||||||
|
* For more information about the callback parameters, see the
|
||||||
|
* [function pointer type](@ref GLFWgamepadstatefun).
|
||||||
|
*
|
||||||
|
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
|
||||||
|
*
|
||||||
|
* @thread_safety This function must only be called from the main thread.
|
||||||
|
*
|
||||||
|
* @sa @ref joystick_event
|
||||||
|
*
|
||||||
|
* @since Added in version 3.2.
|
||||||
|
*
|
||||||
|
* @ingroup input
|
||||||
|
*/
|
||||||
|
GLFWAPI GLFWgamepadstatefun glfwSetGamepadStateCallback(GLFWgamepadstatefun callback);
|
||||||
|
|
||||||
|
|
||||||
/*! @brief Adds the specified SDL_GameControllerDB gamepad mappings.
|
/*! @brief Adds the specified SDL_GameControllerDB gamepad mappings.
|
||||||
*
|
*
|
||||||
* This function parses the specified ASCII encoded string and updates the
|
* This function parses the specified ASCII encoded string and updates the
|
||||||
|
|||||||
@ -255,24 +255,6 @@ if (GLFW_BUILD_WIN32)
|
|||||||
target_compile_definitions(glfw PRIVATE UNICODE _UNICODE)
|
target_compile_definitions(glfw PRIVATE UNICODE _UNICODE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# HACK: When building on MinGW, WINVER and UNICODE need to be defined before
|
|
||||||
# the inclusion of stddef.h (by glfw3.h), which is itself included before
|
|
||||||
# win32_platform.h. We define them here until a saner solution can be found
|
|
||||||
# NOTE: MinGW-w64 and Visual C++ do /not/ need this hack.
|
|
||||||
if (MINGW)
|
|
||||||
target_compile_definitions(glfw PRIVATE WINVER=0x0501)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Workaround for legacy MinGW not providing XInput and DirectInput
|
|
||||||
if (MINGW)
|
|
||||||
include(CheckIncludeFile)
|
|
||||||
check_include_file(dinput.h DINPUT_H_FOUND)
|
|
||||||
check_include_file(xinput.h XINPUT_H_FOUND)
|
|
||||||
if (NOT DINPUT_H_FOUND OR NOT XINPUT_H_FOUND)
|
|
||||||
target_include_directories(glfw PRIVATE "${GLFW_SOURCE_DIR}/deps/mingw")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Workaround for the MS CRT deprecating parts of the standard library
|
# Workaround for the MS CRT deprecating parts of the standard library
|
||||||
if (MSVC OR CMAKE_C_SIMULATE_ID STREQUAL "MSVC")
|
if (MSVC OR CMAKE_C_SIMULATE_ID STREQUAL "MSVC")
|
||||||
target_compile_definitions(glfw PRIVATE _CRT_SECURE_NO_WARNINGS)
|
target_compile_definitions(glfw PRIVATE _CRT_SECURE_NO_WARNINGS)
|
||||||
@ -286,10 +268,6 @@ endif()
|
|||||||
if (GLFW_BUILD_SHARED_LIBRARY)
|
if (GLFW_BUILD_SHARED_LIBRARY)
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
if (MINGW)
|
if (MINGW)
|
||||||
# Remove the dependency on the shared version of libgcc
|
|
||||||
# NOTE: MinGW-w64 has the correct default but MinGW needs this
|
|
||||||
target_link_libraries(glfw PRIVATE "-static-libgcc")
|
|
||||||
|
|
||||||
# Remove the lib prefix on the DLL (but not the import library)
|
# Remove the lib prefix on the DLL (but not the import library)
|
||||||
set_target_properties(glfw PROPERTIES PREFIX "")
|
set_target_properties(glfw PROPERTIES PREFIX "")
|
||||||
|
|
||||||
|
|||||||
90
src/input.c
90
src/input.c
@ -413,6 +413,27 @@ void _glfwInputDrop(_GLFWwindow* window, int count, const char** paths)
|
|||||||
window->callbacks.drop((GLFWwindow*) window, count, paths);
|
window->callbacks.drop((GLFWwindow*) window, count, paths);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Notifies shared code of a change in the gamepad state.
|
||||||
|
// Automatically recalculates the state if the gamepad callback is installed.
|
||||||
|
void _glfwInputGamepad(_GLFWjoystick *js)
|
||||||
|
{
|
||||||
|
const int jid = (int)(js - _glfw.joysticks);
|
||||||
|
|
||||||
|
if (!_glfw.initialized)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((js->mapping != NULL) && (_glfw.callbacks.gamepad_state))
|
||||||
|
{
|
||||||
|
GLFWgamepadstate state;
|
||||||
|
if (glfwGetGamepadState(jid, &state))
|
||||||
|
{
|
||||||
|
_glfw.callbacks.gamepad_state(jid, state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Notifies shared code of a joystick connection or disconnection
|
// Notifies shared code of a joystick connection or disconnection
|
||||||
//
|
//
|
||||||
void _glfwInputJoystick(_GLFWjoystick* js, int event)
|
void _glfwInputJoystick(_GLFWjoystick* js, int event)
|
||||||
@ -437,7 +458,17 @@ void _glfwInputJoystickAxis(_GLFWjoystick* js, int axis, float value)
|
|||||||
assert(axis >= 0);
|
assert(axis >= 0);
|
||||||
assert(axis < js->axisCount);
|
assert(axis < js->axisCount);
|
||||||
|
|
||||||
|
if (js->axes[axis] != value)
|
||||||
|
{
|
||||||
|
const int jid = (int)(js - _glfw.joysticks);
|
||||||
|
|
||||||
|
js->axes[axis] = value;
|
||||||
|
if (_glfw.callbacks.joystick_axis)
|
||||||
|
_glfw.callbacks.joystick_axis(jid, axis, value);
|
||||||
|
_glfwInputGamepad(js);
|
||||||
|
} else {
|
||||||
js->axes[axis] = value;
|
js->axes[axis] = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Notifies shared code of the new value of a joystick button
|
// Notifies shared code of the new value of a joystick button
|
||||||
@ -449,7 +480,16 @@ void _glfwInputJoystickButton(_GLFWjoystick* js, int button, char value)
|
|||||||
assert(button < js->buttonCount);
|
assert(button < js->buttonCount);
|
||||||
assert(value == GLFW_PRESS || value == GLFW_RELEASE);
|
assert(value == GLFW_PRESS || value == GLFW_RELEASE);
|
||||||
|
|
||||||
|
if (js->buttons[button] != value) {
|
||||||
|
const int jid = (int)(js - _glfw.joysticks);
|
||||||
|
|
||||||
js->buttons[button] = value;
|
js->buttons[button] = value;
|
||||||
|
if (_glfw.callbacks.joystick_button)
|
||||||
|
_glfw.callbacks.joystick_button(jid, button, value);
|
||||||
|
_glfwInputGamepad(js);
|
||||||
|
} else {
|
||||||
|
js->buttons[button] = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Notifies shared code of the new value of a joystick hat
|
// Notifies shared code of the new value of a joystick hat
|
||||||
@ -474,11 +514,17 @@ void _glfwInputJoystickHat(_GLFWjoystick* js, int hat, char value)
|
|||||||
js->buttons[base + 1] = (value & 0x02) ? GLFW_PRESS : GLFW_RELEASE;
|
js->buttons[base + 1] = (value & 0x02) ? GLFW_PRESS : GLFW_RELEASE;
|
||||||
js->buttons[base + 2] = (value & 0x04) ? GLFW_PRESS : GLFW_RELEASE;
|
js->buttons[base + 2] = (value & 0x04) ? GLFW_PRESS : GLFW_RELEASE;
|
||||||
js->buttons[base + 3] = (value & 0x08) ? GLFW_PRESS : GLFW_RELEASE;
|
js->buttons[base + 3] = (value & 0x08) ? GLFW_PRESS : GLFW_RELEASE;
|
||||||
|
if (js->hats[hat] != value)
|
||||||
|
{
|
||||||
|
const int jid = (int)(js - _glfw.joysticks);
|
||||||
|
|
||||||
js->hats[hat] = value;
|
js->hats[hat] = value;
|
||||||
|
if (_glfw.callbacks.joystick_hat)
|
||||||
|
_glfw.callbacks.joystick_hat(jid, hat, value);
|
||||||
|
_glfwInputGamepad(js);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
////// GLFW internal API //////
|
////// GLFW internal API //////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
@ -554,6 +600,19 @@ void _glfwCenterCursorInContentArea(_GLFWwindow* window)
|
|||||||
_glfw.platform.setCursorPos(window, width / 2.0, height / 2.0);
|
_glfw.platform.setCursorPos(window, width / 2.0, height / 2.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _glfwPollAllJoysticks()
|
||||||
|
{
|
||||||
|
int jid;
|
||||||
|
|
||||||
|
for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
|
||||||
|
{
|
||||||
|
if (_glfw.joysticks[jid].connected == GLFW_TRUE)
|
||||||
|
{
|
||||||
|
_glfw.platform.pollJoystick(_glfw.joysticks + jid, _GLFW_POLL_ALL);
|
||||||
|
glfwPostEmptyEvent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
////// GLFW public API //////
|
////// GLFW public API //////
|
||||||
@ -1269,6 +1328,34 @@ GLFWAPI GLFWjoystickfun glfwSetJoystickCallback(GLFWjoystickfun cbfun)
|
|||||||
return cbfun;
|
return cbfun;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GLFWAPI GLFWgamepadstatefun glfwSetGamepadStateCallback(GLFWgamepadstatefun cbfun)
|
||||||
|
{
|
||||||
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||||
|
_GLFW_SWAP(GLFWgamepadstatefun, _glfw.callbacks.gamepad_state, cbfun);
|
||||||
|
return cbfun;
|
||||||
|
}
|
||||||
|
|
||||||
|
GLFWAPI GLFWjoystickbuttonfun glfwSetJoystickButtonCallback(GLFWjoystickbuttonfun cbfun)
|
||||||
|
{
|
||||||
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||||
|
_GLFW_SWAP(GLFWjoystickbuttonfun, _glfw.callbacks.joystick_button, cbfun);
|
||||||
|
return cbfun;
|
||||||
|
}
|
||||||
|
|
||||||
|
GLFWAPI GLFWjoystickaxisfun glfwSetJoystickAxisCallback(GLFWjoystickaxisfun cbfun)
|
||||||
|
{
|
||||||
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||||
|
_GLFW_SWAP(GLFWjoystickaxisfun, _glfw.callbacks.joystick_axis, cbfun);
|
||||||
|
return cbfun;
|
||||||
|
}
|
||||||
|
|
||||||
|
GLFWAPI GLFWjoystickhatfun glfwSetJoystickHatCallback(GLFWjoystickhatfun cbfun)
|
||||||
|
{
|
||||||
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||||
|
_GLFW_SWAP(GLFWjoystickhatfun, _glfw.callbacks.joystick_hat, cbfun);
|
||||||
|
return cbfun;
|
||||||
|
}
|
||||||
|
|
||||||
GLFWAPI int glfwUpdateGamepadMappings(const char* string)
|
GLFWAPI int glfwUpdateGamepadMappings(const char* string)
|
||||||
{
|
{
|
||||||
int jid;
|
int jid;
|
||||||
@ -1520,4 +1607,3 @@ GLFWAPI uint64_t glfwGetTimerFrequency(void)
|
|||||||
_GLFW_REQUIRE_INIT_OR_RETURN(0);
|
_GLFW_REQUIRE_INIT_OR_RETURN(0);
|
||||||
return _glfwPlatformGetTimerFrequency();
|
return _glfwPlatformGetTimerFrequency();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -876,8 +876,12 @@ struct _GLFWlibrary
|
|||||||
} vk;
|
} vk;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
GLFWmonitorfun monitor;
|
GLFWmonitorfun monitor;
|
||||||
GLFWjoystickfun joystick;
|
GLFWjoystickfun joystick;
|
||||||
|
GLFWjoystickaxisfun joystick_axis;
|
||||||
|
GLFWjoystickbuttonfun joystick_button;
|
||||||
|
GLFWjoystickhatfun joystick_hat;
|
||||||
|
GLFWgamepadstatefun gamepad_state;
|
||||||
} callbacks;
|
} callbacks;
|
||||||
|
|
||||||
// These are defined in platform.h
|
// These are defined in platform.h
|
||||||
@ -986,6 +990,7 @@ _GLFWjoystick* _glfwAllocJoystick(const char* name,
|
|||||||
int hatCount);
|
int hatCount);
|
||||||
void _glfwFreeJoystick(_GLFWjoystick* js);
|
void _glfwFreeJoystick(_GLFWjoystick* js);
|
||||||
void _glfwCenterCursorInContentArea(_GLFWwindow* window);
|
void _glfwCenterCursorInContentArea(_GLFWwindow* window);
|
||||||
|
void _glfwPollAllJoysticks();
|
||||||
|
|
||||||
GLFWbool _glfwInitEGL(void);
|
GLFWbool _glfwInitEGL(void);
|
||||||
void _glfwTerminateEGL(void);
|
void _glfwTerminateEGL(void);
|
||||||
|
|||||||
@ -187,8 +187,6 @@ GLFWAPI const char* glfwGetVersionString(void)
|
|||||||
" OSMesa"
|
" OSMesa"
|
||||||
#if defined(__MINGW64_VERSION_MAJOR)
|
#if defined(__MINGW64_VERSION_MAJOR)
|
||||||
" MinGW-w64"
|
" MinGW-w64"
|
||||||
#elif defined(__MINGW32__)
|
|
||||||
" MinGW"
|
|
||||||
#elif defined(_MSC_VER)
|
#elif defined(_MSC_VER)
|
||||||
" VisualC"
|
" VisualC"
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -327,8 +327,8 @@ static void swapBuffersWGL(_GLFWwindow* window)
|
|||||||
{
|
{
|
||||||
if (!window->monitor)
|
if (!window->monitor)
|
||||||
{
|
{
|
||||||
// HACK: Use DwmFlush when desktop composition is enabled on Windows Vista and 7
|
// HACK: Use DwmFlush when desktop composition is enabled on Windows 7
|
||||||
if (!IsWindows8OrGreater() && IsWindowsVistaOrGreater())
|
if (!IsWindows8OrGreater())
|
||||||
{
|
{
|
||||||
BOOL enabled = FALSE;
|
BOOL enabled = FALSE;
|
||||||
|
|
||||||
@ -353,9 +353,9 @@ static void swapIntervalWGL(int interval)
|
|||||||
|
|
||||||
if (!window->monitor)
|
if (!window->monitor)
|
||||||
{
|
{
|
||||||
// HACK: Disable WGL swap interval when desktop composition is enabled on Windows
|
// HACK: Disable WGL swap interval when desktop composition is enabled on
|
||||||
// Vista and 7 to avoid interfering with DWM vsync
|
// Windows 7 to avoid interfering with DWM vsync
|
||||||
if (!IsWindows8OrGreater() && IsWindowsVistaOrGreater())
|
if (!IsWindows8OrGreater())
|
||||||
{
|
{
|
||||||
BOOL enabled = FALSE;
|
BOOL enabled = FALSE;
|
||||||
|
|
||||||
|
|||||||
@ -89,10 +89,6 @@ static GLFWbool loadLibraries(void)
|
|||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
_glfw.win32.user32.SetProcessDPIAware_ = (PFN_SetProcessDPIAware)
|
|
||||||
_glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "SetProcessDPIAware");
|
|
||||||
_glfw.win32.user32.ChangeWindowMessageFilterEx_ = (PFN_ChangeWindowMessageFilterEx)
|
|
||||||
_glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "ChangeWindowMessageFilterEx");
|
|
||||||
_glfw.win32.user32.EnableNonClientDpiScaling_ = (PFN_EnableNonClientDpiScaling)
|
_glfw.win32.user32.EnableNonClientDpiScaling_ = (PFN_EnableNonClientDpiScaling)
|
||||||
_glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "EnableNonClientDpiScaling");
|
_glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "EnableNonClientDpiScaling");
|
||||||
_glfw.win32.user32.SetProcessDpiAwarenessContext_ = (PFN_SetProcessDpiAwarenessContext)
|
_glfw.win32.user32.SetProcessDpiAwarenessContext_ = (PFN_SetProcessDpiAwarenessContext)
|
||||||
@ -692,7 +688,7 @@ int _glfwInitWin32(void)
|
|||||||
SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
|
SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
|
||||||
else if (IsWindows8Point1OrGreater())
|
else if (IsWindows8Point1OrGreater())
|
||||||
SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE);
|
SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE);
|
||||||
else if (IsWindowsVistaOrGreater())
|
else
|
||||||
SetProcessDPIAware();
|
SetProcessDPIAware();
|
||||||
|
|
||||||
if (!createHelperWindow())
|
if (!createHelperWindow())
|
||||||
|
|||||||
@ -48,14 +48,14 @@
|
|||||||
#define UNICODE
|
#define UNICODE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// GLFW requires Windows XP or later
|
// GLFW requires Windows 7 or later
|
||||||
#if WINVER < 0x0501
|
#if WINVER < 0x0601
|
||||||
#undef WINVER
|
#undef WINVER
|
||||||
#define WINVER 0x0501
|
#define WINVER 0x0601
|
||||||
#endif
|
#endif
|
||||||
#if _WIN32_WINNT < 0x0501
|
#if _WIN32_WINNT < 0x0601
|
||||||
#undef _WIN32_WINNT
|
#undef _WIN32_WINNT
|
||||||
#define _WIN32_WINNT 0x0501
|
#define _WIN32_WINNT 0x0601
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// GLFW uses DirectInput8 interfaces
|
// GLFW uses DirectInput8 interfaces
|
||||||
@ -66,41 +66,21 @@
|
|||||||
|
|
||||||
#include <wctype.h>
|
#include <wctype.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include <dwmapi.h>
|
||||||
#include <dinput.h>
|
#include <dinput.h>
|
||||||
#include <xinput.h>
|
#include <xinput.h>
|
||||||
#include <dbt.h>
|
#include <dbt.h>
|
||||||
|
|
||||||
// HACK: Define macros that some windows.h variants don't
|
// HACK: Define macros that some windows.h variants don't
|
||||||
#ifndef WM_MOUSEHWHEEL
|
|
||||||
#define WM_MOUSEHWHEEL 0x020E
|
|
||||||
#endif
|
|
||||||
#ifndef WM_DWMCOMPOSITIONCHANGED
|
|
||||||
#define WM_DWMCOMPOSITIONCHANGED 0x031E
|
|
||||||
#endif
|
|
||||||
#ifndef WM_DWMCOLORIZATIONCOLORCHANGED
|
|
||||||
#define WM_DWMCOLORIZATIONCOLORCHANGED 0x0320
|
|
||||||
#endif
|
|
||||||
#ifndef WM_COPYGLOBALDATA
|
#ifndef WM_COPYGLOBALDATA
|
||||||
#define WM_COPYGLOBALDATA 0x0049
|
#define WM_COPYGLOBALDATA 0x0049
|
||||||
#endif
|
#endif
|
||||||
#ifndef WM_UNICHAR
|
|
||||||
#define WM_UNICHAR 0x0109
|
|
||||||
#endif
|
|
||||||
#ifndef UNICODE_NOCHAR
|
|
||||||
#define UNICODE_NOCHAR 0xFFFF
|
|
||||||
#endif
|
|
||||||
#ifndef WM_DPICHANGED
|
#ifndef WM_DPICHANGED
|
||||||
#define WM_DPICHANGED 0x02E0
|
#define WM_DPICHANGED 0x02E0
|
||||||
#endif
|
#endif
|
||||||
#ifndef GET_XBUTTON_WPARAM
|
|
||||||
#define GET_XBUTTON_WPARAM(w) (HIWORD(w))
|
|
||||||
#endif
|
|
||||||
#ifndef EDS_ROTATEDMODE
|
#ifndef EDS_ROTATEDMODE
|
||||||
#define EDS_ROTATEDMODE 0x00000004
|
#define EDS_ROTATEDMODE 0x00000004
|
||||||
#endif
|
#endif
|
||||||
#ifndef DISPLAY_DEVICE_ACTIVE
|
|
||||||
#define DISPLAY_DEVICE_ACTIVE 0x00000001
|
|
||||||
#endif
|
|
||||||
#ifndef _WIN32_WINNT_WINBLUE
|
#ifndef _WIN32_WINNT_WINBLUE
|
||||||
#define _WIN32_WINNT_WINBLUE 0x0603
|
#define _WIN32_WINNT_WINBLUE 0x0603
|
||||||
#endif
|
#endif
|
||||||
@ -113,34 +93,6 @@
|
|||||||
#ifndef USER_DEFAULT_SCREEN_DPI
|
#ifndef USER_DEFAULT_SCREEN_DPI
|
||||||
#define USER_DEFAULT_SCREEN_DPI 96
|
#define USER_DEFAULT_SCREEN_DPI 96
|
||||||
#endif
|
#endif
|
||||||
#ifndef OCR_HAND
|
|
||||||
#define OCR_HAND 32649
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if WINVER < 0x0601
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
DWORD cbSize;
|
|
||||||
DWORD ExtStatus;
|
|
||||||
} CHANGEFILTERSTRUCT;
|
|
||||||
#ifndef MSGFLT_ALLOW
|
|
||||||
#define MSGFLT_ALLOW 1
|
|
||||||
#endif
|
|
||||||
#endif /*Windows 7*/
|
|
||||||
|
|
||||||
#if WINVER < 0x0600
|
|
||||||
#define DWM_BB_ENABLE 0x00000001
|
|
||||||
#define DWM_BB_BLURREGION 0x00000002
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
DWORD dwFlags;
|
|
||||||
BOOL fEnable;
|
|
||||||
HRGN hRgnBlur;
|
|
||||||
BOOL fTransitionOnMaximized;
|
|
||||||
} DWM_BLURBEHIND;
|
|
||||||
#else
|
|
||||||
#include <dwmapi.h>
|
|
||||||
#endif /*Windows Vista*/
|
|
||||||
|
|
||||||
#ifndef DPI_ENUMS_DECLARED
|
#ifndef DPI_ENUMS_DECLARED
|
||||||
typedef enum
|
typedef enum
|
||||||
@ -165,12 +117,6 @@ typedef enum
|
|||||||
// Replacement for versionhelpers.h macros, as we cannot rely on the
|
// Replacement for versionhelpers.h macros, as we cannot rely on the
|
||||||
// application having a correct embedded manifest
|
// application having a correct embedded manifest
|
||||||
//
|
//
|
||||||
#define IsWindowsVistaOrGreater() \
|
|
||||||
_glfwIsWindowsVersionOrGreaterWin32(HIBYTE(_WIN32_WINNT_VISTA), \
|
|
||||||
LOBYTE(_WIN32_WINNT_VISTA), 0)
|
|
||||||
#define IsWindows7OrGreater() \
|
|
||||||
_glfwIsWindowsVersionOrGreaterWin32(HIBYTE(_WIN32_WINNT_WIN7), \
|
|
||||||
LOBYTE(_WIN32_WINNT_WIN7), 0)
|
|
||||||
#define IsWindows8OrGreater() \
|
#define IsWindows8OrGreater() \
|
||||||
_glfwIsWindowsVersionOrGreaterWin32(HIBYTE(_WIN32_WINNT_WIN8), \
|
_glfwIsWindowsVersionOrGreaterWin32(HIBYTE(_WIN32_WINNT_WIN8), \
|
||||||
LOBYTE(_WIN32_WINNT_WIN8), 0)
|
LOBYTE(_WIN32_WINNT_WIN8), 0)
|
||||||
@ -281,15 +227,11 @@ typedef HRESULT (WINAPI * PFN_DirectInput8Create)(HINSTANCE,DWORD,REFIID,LPVOID*
|
|||||||
#define DirectInput8Create _glfw.win32.dinput8.Create
|
#define DirectInput8Create _glfw.win32.dinput8.Create
|
||||||
|
|
||||||
// user32.dll function pointer typedefs
|
// user32.dll function pointer typedefs
|
||||||
typedef BOOL (WINAPI * PFN_SetProcessDPIAware)(void);
|
|
||||||
typedef BOOL (WINAPI * PFN_ChangeWindowMessageFilterEx)(HWND,UINT,DWORD,CHANGEFILTERSTRUCT*);
|
|
||||||
typedef BOOL (WINAPI * PFN_EnableNonClientDpiScaling)(HWND);
|
typedef BOOL (WINAPI * PFN_EnableNonClientDpiScaling)(HWND);
|
||||||
typedef BOOL (WINAPI * PFN_SetProcessDpiAwarenessContext)(HANDLE);
|
typedef BOOL (WINAPI * PFN_SetProcessDpiAwarenessContext)(HANDLE);
|
||||||
typedef UINT (WINAPI * PFN_GetDpiForWindow)(HWND);
|
typedef UINT (WINAPI * PFN_GetDpiForWindow)(HWND);
|
||||||
typedef BOOL (WINAPI * PFN_AdjustWindowRectExForDpi)(LPRECT,DWORD,BOOL,DWORD,UINT);
|
typedef BOOL (WINAPI * PFN_AdjustWindowRectExForDpi)(LPRECT,DWORD,BOOL,DWORD,UINT);
|
||||||
typedef int (WINAPI * PFN_GetSystemMetricsForDpi)(int,UINT);
|
typedef int (WINAPI * PFN_GetSystemMetricsForDpi)(int,UINT);
|
||||||
#define SetProcessDPIAware _glfw.win32.user32.SetProcessDPIAware_
|
|
||||||
#define ChangeWindowMessageFilterEx _glfw.win32.user32.ChangeWindowMessageFilterEx_
|
|
||||||
#define EnableNonClientDpiScaling _glfw.win32.user32.EnableNonClientDpiScaling_
|
#define EnableNonClientDpiScaling _glfw.win32.user32.EnableNonClientDpiScaling_
|
||||||
#define SetProcessDpiAwarenessContext _glfw.win32.user32.SetProcessDpiAwarenessContext_
|
#define SetProcessDpiAwarenessContext _glfw.win32.user32.SetProcessDpiAwarenessContext_
|
||||||
#define GetDpiForWindow _glfw.win32.user32.GetDpiForWindow_
|
#define GetDpiForWindow _glfw.win32.user32.GetDpiForWindow_
|
||||||
@ -475,8 +417,6 @@ typedef struct _GLFWlibraryWin32
|
|||||||
|
|
||||||
struct {
|
struct {
|
||||||
HINSTANCE instance;
|
HINSTANCE instance;
|
||||||
PFN_SetProcessDPIAware SetProcessDPIAware_;
|
|
||||||
PFN_ChangeWindowMessageFilterEx ChangeWindowMessageFilterEx_;
|
|
||||||
PFN_EnableNonClientDpiScaling EnableNonClientDpiScaling_;
|
PFN_EnableNonClientDpiScaling EnableNonClientDpiScaling_;
|
||||||
PFN_SetProcessDpiAwarenessContext SetProcessDpiAwarenessContext_;
|
PFN_SetProcessDpiAwarenessContext SetProcessDpiAwarenessContext_;
|
||||||
PFN_GetDpiForWindow GetDpiForWindow_;
|
PFN_GetDpiForWindow GetDpiForWindow_;
|
||||||
|
|||||||
@ -374,9 +374,6 @@ static void updateFramebufferTransparency(const _GLFWwindow* window)
|
|||||||
BOOL composition, opaque;
|
BOOL composition, opaque;
|
||||||
DWORD color;
|
DWORD color;
|
||||||
|
|
||||||
if (!IsWindowsVistaOrGreater())
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (FAILED(DwmIsCompositionEnabled(&composition)) || !composition)
|
if (FAILED(DwmIsCompositionEnabled(&composition)) || !composition)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -983,7 +980,6 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l
|
|||||||
|
|
||||||
case WM_MOUSEHWHEEL:
|
case WM_MOUSEHWHEEL:
|
||||||
{
|
{
|
||||||
// This message is only sent on Windows Vista and later
|
|
||||||
// NOTE: The X-axis is inverted for consistency with macOS and X11
|
// NOTE: The X-axis is inverted for consistency with macOS and X11
|
||||||
_glfwInputScroll(window, -((SHORT) HIWORD(wParam) / (double) WHEEL_DELTA), 0.0);
|
_glfwInputScroll(window, -((SHORT) HIWORD(wParam) / (double) WHEEL_DELTA), 0.0);
|
||||||
return 0;
|
return 0;
|
||||||
@ -1407,15 +1403,9 @@ static int createNativeWindow(_GLFWwindow* window,
|
|||||||
|
|
||||||
SetPropW(window->win32.handle, L"GLFW", window);
|
SetPropW(window->win32.handle, L"GLFW", window);
|
||||||
|
|
||||||
if (IsWindows7OrGreater())
|
ChangeWindowMessageFilterEx(window->win32.handle, WM_DROPFILES, MSGFLT_ALLOW, NULL);
|
||||||
{
|
ChangeWindowMessageFilterEx(window->win32.handle, WM_COPYDATA, MSGFLT_ALLOW, NULL);
|
||||||
ChangeWindowMessageFilterEx(window->win32.handle,
|
ChangeWindowMessageFilterEx(window->win32.handle, WM_COPYGLOBALDATA, MSGFLT_ALLOW, NULL);
|
||||||
WM_DROPFILES, MSGFLT_ALLOW, NULL);
|
|
||||||
ChangeWindowMessageFilterEx(window->win32.handle,
|
|
||||||
WM_COPYDATA, MSGFLT_ALLOW, NULL);
|
|
||||||
ChangeWindowMessageFilterEx(window->win32.handle,
|
|
||||||
WM_COPYGLOBALDATA, MSGFLT_ALLOW, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
window->win32.scaleToMonitor = wndconfig->scaleToMonitor;
|
window->win32.scaleToMonitor = wndconfig->scaleToMonitor;
|
||||||
window->win32.keymenu = wndconfig->win32.keymenu;
|
window->win32.keymenu = wndconfig->win32.keymenu;
|
||||||
@ -1981,9 +1971,6 @@ GLFWbool _glfwFramebufferTransparentWin32(_GLFWwindow* window)
|
|||||||
if (!window->win32.transparent)
|
if (!window->win32.transparent)
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
|
|
||||||
if (!IsWindowsVistaOrGreater())
|
|
||||||
return GLFW_FALSE;
|
|
||||||
|
|
||||||
if (FAILED(DwmIsCompositionEnabled(&composition)) || !composition)
|
if (FAILED(DwmIsCompositionEnabled(&composition)) || !composition)
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
|
|
||||||
|
|||||||
@ -1167,12 +1167,14 @@ GLFWAPI GLFWwindowcontentscalefun glfwSetWindowContentScaleCallback(GLFWwindow*
|
|||||||
GLFWAPI void glfwPollEvents(void)
|
GLFWAPI void glfwPollEvents(void)
|
||||||
{
|
{
|
||||||
_GLFW_REQUIRE_INIT();
|
_GLFW_REQUIRE_INIT();
|
||||||
|
_glfwPollAllJoysticks();
|
||||||
_glfw.platform.pollEvents();
|
_glfw.platform.pollEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI void glfwWaitEvents(void)
|
GLFWAPI void glfwWaitEvents(void)
|
||||||
{
|
{
|
||||||
_GLFW_REQUIRE_INIT();
|
_GLFW_REQUIRE_INIT();
|
||||||
|
_glfwPollAllJoysticks();
|
||||||
_glfw.platform.waitEvents();
|
_glfw.platform.waitEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1333,6 +1333,7 @@ static char* readDataOfferAsString(struct wl_data_offer* offer, const char* mime
|
|||||||
if (!longer)
|
if (!longer)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_OUT_OF_MEMORY, NULL);
|
_glfwInputError(GLFW_OUT_OF_MEMORY, NULL);
|
||||||
|
_glfw_free(string);
|
||||||
close(fds[0]);
|
close(fds[0]);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -1352,6 +1353,7 @@ static char* readDataOfferAsString(struct wl_data_offer* offer, const char* mime
|
|||||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
"Wayland: Failed to read from data offer pipe: %s",
|
"Wayland: Failed to read from data offer pipe: %s",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
|
_glfw_free(string);
|
||||||
close(fds[0]);
|
close(fds[0]);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -2187,7 +2189,12 @@ void _glfwDestroyWindowWayland(_GLFWwindow* window)
|
|||||||
_glfw.wl.pointerFocus = NULL;
|
_glfw.wl.pointerFocus = NULL;
|
||||||
|
|
||||||
if (window == _glfw.wl.keyboardFocus)
|
if (window == _glfw.wl.keyboardFocus)
|
||||||
|
{
|
||||||
|
struct itimerspec timer = {0};
|
||||||
|
timerfd_settime(_glfw.wl.keyRepeatTimerfd, 0, &timer, NULL);
|
||||||
|
|
||||||
_glfw.wl.keyboardFocus = NULL;
|
_glfw.wl.keyboardFocus = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (window->wl.fractionalScale)
|
if (window->wl.fractionalScale)
|
||||||
wp_fractional_scale_v1_destroy(window->wl.fractionalScale);
|
wp_fractional_scale_v1_destroy(window->wl.fractionalScale);
|
||||||
|
|||||||
@ -542,6 +542,52 @@ static void joystick_callback(int jid, int event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void joystick_button_callback(int jid, int button, int state) {
|
||||||
|
printf("%08x at %0.3f: Joystick %i (%s) button %d state %d\n",
|
||||||
|
counter++, glfwGetTime(),
|
||||||
|
jid,
|
||||||
|
glfwGetJoystickName(jid),
|
||||||
|
button,
|
||||||
|
state);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void joystick_axis_callback(int jid, int axis, float value) {
|
||||||
|
printf("%08x at %0.3f: Joystick %i (%s) axis %d value %0.4f\n",
|
||||||
|
counter++, glfwGetTime(), jid,
|
||||||
|
glfwGetJoystickName(jid),
|
||||||
|
axis,
|
||||||
|
value);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void joystick_hat_callback(int jid, int hat, int value) {
|
||||||
|
printf("%08x at %0.3f: Joystick %i (%s) hat %d value %d\n",
|
||||||
|
counter++, glfwGetTime(),
|
||||||
|
jid,
|
||||||
|
glfwGetJoystickName(jid),
|
||||||
|
hat,
|
||||||
|
value);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gamepad_state_callback(int jid, GLFWgamepadstate state) {
|
||||||
|
int i = 0;
|
||||||
|
printf("%08x at %0.3f: Gamepad %i (%s) state:",
|
||||||
|
counter++, glfwGetTime(),
|
||||||
|
jid,
|
||||||
|
glfwGetJoystickName(jid));
|
||||||
|
|
||||||
|
printf("Buttons: ");
|
||||||
|
for (i= 0 ; i < 15; i++) {
|
||||||
|
printf(" %d:%d", i, state.buttons[i]);
|
||||||
|
}
|
||||||
|
printf("Axes: ");
|
||||||
|
for (i= 0 ; i < 6; i++) {
|
||||||
|
printf(" %d:%0.4f", i, state.axes[i]);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
Slot* slots;
|
Slot* slots;
|
||||||
@ -557,6 +603,10 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
glfwSetMonitorCallback(monitor_callback);
|
glfwSetMonitorCallback(monitor_callback);
|
||||||
glfwSetJoystickCallback(joystick_callback);
|
glfwSetJoystickCallback(joystick_callback);
|
||||||
|
glfwSetJoystickAxisCallback(joystick_axis_callback);
|
||||||
|
glfwSetJoystickButtonCallback(joystick_button_callback);
|
||||||
|
glfwSetJoystickHatCallback(joystick_hat_callback);
|
||||||
|
glfwSetGamepadStateCallback(gamepad_state_callback);
|
||||||
|
|
||||||
while ((ch = getopt(argc, argv, "hfn:")) != -1)
|
while ((ch = getopt(argc, argv, "hfn:")) != -1)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user