mirror of
https://github.com/glfw/glfw.git
synced 2026-09-17 22:32:50 +00:00
Add glfwGetKeyScancode
Allows retrieval of platform scancode from GLFW_KEY_*. Implemented for Win32, Cocoa and X11. Stubs for Mir and Wayland. Closes #830.
This commit is contained in:
committed by
Camilla Berglund
parent
f17d60da64
commit
e745b0dd47
@@ -1511,6 +1511,16 @@ const char* _glfwPlatformGetKeyName(int key, int scancode)
|
||||
return _glfw.ns.keyName;
|
||||
}
|
||||
|
||||
const short int _glfwPlatformGetKeyScancode(int key)
|
||||
{
|
||||
if(key <= -1 || key >= (sizeof(_glfw.ns.nativeKeys) / sizeof(_glfw.ns.nativeKeys[0])))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return _glfw.ns.nativeKeys[key];
|
||||
}
|
||||
|
||||
int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
|
||||
const GLFWimage* image,
|
||||
int xhot, int yhot)
|
||||
|
||||
@@ -256,6 +256,12 @@ GLFWAPI const char* glfwGetKeyName(int key, int scancode)
|
||||
return _glfwPlatformGetKeyName(key, scancode);
|
||||
}
|
||||
|
||||
GLFWAPI const short int glfwGetKeyScancode(int key)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(-1);
|
||||
return _glfwPlatformGetKeyScancode(key);
|
||||
}
|
||||
|
||||
GLFWAPI int glfwGetKey(GLFWwindow* handle, int key)
|
||||
{
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
|
||||
@@ -542,6 +542,11 @@ void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode);
|
||||
*/
|
||||
const char* _glfwPlatformGetKeyName(int key, int scancode);
|
||||
|
||||
/*! @copydoc glfwGetKeyScancode
|
||||
* @ingroup platform
|
||||
*/
|
||||
const short int _glfwPlatformGetKeyScancode(int key);
|
||||
|
||||
/*! @copydoc glfwGetMonitors
|
||||
* @ingroup platform
|
||||
*/
|
||||
|
||||
@@ -744,6 +744,13 @@ const char* _glfwPlatformGetKeyName(int key, int scancode)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const int _glfwPlatformGetKeyScancode(int key)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Mir: Unsupported function %s", __PRETTY_FUNCTION__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void _glfwPlatformSetClipboardString(_GLFWwindow* window, const char* string)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
|
||||
@@ -1511,6 +1511,16 @@ const char* _glfwPlatformGetKeyName(int key, int scancode)
|
||||
return _glfw.win32.keyName;
|
||||
}
|
||||
|
||||
const short int _glfwPlatformGetKeyScancode(int key)
|
||||
{
|
||||
if(key <= -1 || key >= (sizeof(_glfw.win32.nativeKeys) / sizeof(_glfw.win32.nativeKeys[0])))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return _glfw.win32.nativeKeys[key];
|
||||
}
|
||||
|
||||
int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
|
||||
const GLFWimage* image,
|
||||
int xhot, int yhot)
|
||||
|
||||
@@ -686,6 +686,12 @@ const char* _glfwPlatformGetKeyName(int key, int scancode)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const int _glfwPlatformGetKeyScancode(int key)
|
||||
{
|
||||
// TODO
|
||||
return -1;
|
||||
}
|
||||
|
||||
int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
|
||||
const GLFWimage* image,
|
||||
int xhot, int yhot)
|
||||
|
||||
@@ -2186,6 +2186,16 @@ const char* _glfwPlatformGetKeyName(int key, int scancode)
|
||||
return _glfw.x11.keyName;
|
||||
}
|
||||
|
||||
const short int _glfwPlatformGetKeyScancode(int key)
|
||||
{
|
||||
if(key <= -1 || key >= (sizeof(_glfw.x11.nativeKeys) / sizeof(_glfw.x11.nativeKeys[0])))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return _glfw.x11.nativeKeys[key];
|
||||
}
|
||||
|
||||
int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
|
||||
const GLFWimage* image,
|
||||
int xhot, int yhot)
|
||||
|
||||
Reference in New Issue
Block a user