Merged
This commit is contained in:
commit
932ea49e88
7 changed files with 55 additions and 109 deletions
|
@ -38,7 +38,7 @@
|
||||||
* SDL_Event structure.
|
* SDL_Event structure.
|
||||||
*
|
*
|
||||||
* The values in this enumeration are based on the USB usage page standard:
|
* The values in this enumeration are based on the USB usage page standard:
|
||||||
* http://www.usb.org/developers/devclass_docs/Hut1_12.pdf
|
* http://www.usb.org/developers/devclass_docs/Hut1_12v2.pdf
|
||||||
*/
|
*/
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,13 +20,8 @@
|
||||||
*/
|
*/
|
||||||
#include "../../include/SDL_scancode.h"
|
#include "../../include/SDL_scancode.h"
|
||||||
|
|
||||||
/* Win32 virtual key code to SDL scancode mapping table
|
/* Windows scancode to SDL scancode mapping table */
|
||||||
Sources:
|
|
||||||
- msdn.microsoft.com
|
|
||||||
*/
|
|
||||||
/* *INDENT-OFF* */
|
/* *INDENT-OFF* */
|
||||||
// this maps non-translated keyboard scan codes to engine key codes
|
|
||||||
// Google for 'Keyboard Scan Code Specification'
|
|
||||||
static const SDL_Scancode windows_scancode_table[] =
|
static const SDL_Scancode windows_scancode_table[] =
|
||||||
{
|
{
|
||||||
// 0 1 2 3 4 5 6 7
|
// 0 1 2 3 4 5 6 7
|
||||||
|
@ -55,5 +50,4 @@ static const SDL_Scancode windows_scancode_table[] =
|
||||||
SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, // 7
|
SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, // 7
|
||||||
SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN // 7
|
SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN // 7
|
||||||
};
|
};
|
||||||
|
|
||||||
/* *INDENT-ON* */
|
/* *INDENT-ON* */
|
||||||
|
|
|
@ -28,13 +28,12 @@
|
||||||
#include "SDL_vkeys.h"
|
#include "SDL_vkeys.h"
|
||||||
#include "../../events/SDL_events_c.h"
|
#include "../../events/SDL_events_c.h"
|
||||||
#include "../../events/SDL_touch_c.h"
|
#include "../../events/SDL_touch_c.h"
|
||||||
|
#include "../../events/scancodes_windows.h"
|
||||||
|
|
||||||
/* Dropfile support */
|
/* Dropfile support */
|
||||||
#include <shellapi.h>
|
#include <shellapi.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*#define WMMSG_DEBUG*/
|
/*#define WMMSG_DEBUG*/
|
||||||
#ifdef WMMSG_DEBUG
|
#ifdef WMMSG_DEBUG
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -68,7 +67,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static SDL_Scancode
|
static SDL_Scancode
|
||||||
WindowsScanCodeToSDLScanCode( int lParam, int wParam, const SDL_Scancode *key_map )
|
WindowsScanCodeToSDLScanCode( int lParam, int wParam )
|
||||||
{
|
{
|
||||||
SDL_Scancode code;
|
SDL_Scancode code;
|
||||||
char bIsExtended;
|
char bIsExtended;
|
||||||
|
@ -133,7 +132,7 @@ WindowsScanCodeToSDLScanCode( int lParam, int wParam, const SDL_Scancode *key_ma
|
||||||
if ( nScanCode > 127 )
|
if ( nScanCode > 127 )
|
||||||
return SDL_SCANCODE_UNKNOWN;
|
return SDL_SCANCODE_UNKNOWN;
|
||||||
|
|
||||||
code = key_map[nScanCode];
|
code = windows_scancode_table[nScanCode];
|
||||||
|
|
||||||
bIsExtended = ( lParam & ( 1 << 24 ) ) != 0;
|
bIsExtended = ( lParam & ( 1 << 24 ) ) != 0;
|
||||||
if ( !bIsExtended )
|
if ( !bIsExtended )
|
||||||
|
@ -159,7 +158,7 @@ WindowsScanCodeToSDLScanCode( int lParam, int wParam, const SDL_Scancode *key_ma
|
||||||
case SDL_SCANCODE_INSERT:
|
case SDL_SCANCODE_INSERT:
|
||||||
return SDL_SCANCODE_KP_0;
|
return SDL_SCANCODE_KP_0;
|
||||||
case SDL_SCANCODE_DELETE:
|
case SDL_SCANCODE_DELETE:
|
||||||
return SDL_SCANCODE_KP_DECIMAL;
|
return SDL_SCANCODE_KP_PERIOD;
|
||||||
case SDL_SCANCODE_PRINTSCREEN:
|
case SDL_SCANCODE_PRINTSCREEN:
|
||||||
return SDL_SCANCODE_KP_MULTIPLY;
|
return SDL_SCANCODE_KP_MULTIPLY;
|
||||||
default:
|
default:
|
||||||
|
@ -453,7 +452,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
case WM_SYSKEYDOWN:
|
case WM_SYSKEYDOWN:
|
||||||
case WM_KEYDOWN:
|
case WM_KEYDOWN:
|
||||||
{
|
{
|
||||||
SDL_Scancode code = WindowsScanCodeToSDLScanCode( lParam, wParam, data->videodata->key_layout );
|
SDL_Scancode code = WindowsScanCodeToSDLScanCode( lParam, wParam );
|
||||||
if ( code != SDL_SCANCODE_UNKNOWN ) {
|
if ( code != SDL_SCANCODE_UNKNOWN ) {
|
||||||
SDL_SendKeyboardKey(SDL_PRESSED, code );
|
SDL_SendKeyboardKey(SDL_PRESSED, code );
|
||||||
}
|
}
|
||||||
|
@ -464,15 +463,13 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
case WM_SYSKEYUP:
|
case WM_SYSKEYUP:
|
||||||
case WM_KEYUP:
|
case WM_KEYUP:
|
||||||
{
|
{
|
||||||
SDL_Scancode code = WindowsScanCodeToSDLScanCode( lParam, wParam, data->videodata->key_layout );
|
SDL_Scancode code = WindowsScanCodeToSDLScanCode( lParam, wParam );
|
||||||
if ( code != SDL_SCANCODE_UNKNOWN ) {
|
if ( code != SDL_SCANCODE_UNKNOWN ) {
|
||||||
if (wParam == VK_SNAPSHOT
|
if (code == SDL_SCANCODE_PRINTSCREEN &&
|
||||||
&& SDL_GetKeyboardState(NULL)[SDL_SCANCODE_PRINTSCREEN] ==
|
SDL_GetKeyboardState(NULL)[code] == SDL_RELEASED) {
|
||||||
SDL_RELEASED) {
|
SDL_SendKeyboardKey(SDL_PRESSED, code);
|
||||||
SDL_SendKeyboardKey(SDL_PRESSED,
|
}
|
||||||
code);
|
SDL_SendKeyboardKey(SDL_RELEASED, code);
|
||||||
}
|
|
||||||
SDL_SendKeyboardKey(SDL_RELEASED, code );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
returnCode = 0;
|
returnCode = 0;
|
||||||
|
|
|
@ -48,50 +48,10 @@ static void IME_Quit(SDL_VideoData *videodata);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Alphabetic scancodes for PC keyboards */
|
/* Alphabetic scancodes for PC keyboards */
|
||||||
BYTE alpha_scancodes[26] = {
|
|
||||||
30, 48, 46, 32, 18, 33, 34, 35, 23, 36, 37, 38, 50, 49, 24,
|
|
||||||
25, 16, 19, 31, 20, 22, 47, 17, 45, 21, 44
|
|
||||||
};
|
|
||||||
|
|
||||||
BYTE keypad_scancodes[10] = {
|
|
||||||
82, 79, 80, 81, 75, 76, 77, 71, 72, 73
|
|
||||||
};
|
|
||||||
|
|
||||||
void
|
void
|
||||||
WIN_InitKeyboard(_THIS)
|
WIN_InitKeyboard(_THIS)
|
||||||
{
|
{
|
||||||
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
||||||
int i;
|
|
||||||
|
|
||||||
/* Make sure the alpha scancodes are correct. T isn't usually remapped */
|
|
||||||
if (MapVirtualKey('T', MAPVK_VK_TO_VSC) != alpha_scancodes['T' - 'A']) {
|
|
||||||
#if 0
|
|
||||||
printf
|
|
||||||
("Fixing alpha scancode map, assuming US QWERTY layout!\nPlease send the following 26 lines of output to the SDL mailing list <sdl@libsdl.org>, including a description of your keyboard hardware.\n");
|
|
||||||
#endif
|
|
||||||
for (i = 0; i < SDL_arraysize(alpha_scancodes); ++i) {
|
|
||||||
alpha_scancodes[i] = MapVirtualKey('A' + i, MAPVK_VK_TO_VSC);
|
|
||||||
#if 0
|
|
||||||
printf("%d = %d\n", i, alpha_scancodes[i]);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (MapVirtualKey(VK_NUMPAD0, MAPVK_VK_TO_VSC) != keypad_scancodes[0]) {
|
|
||||||
#if 0
|
|
||||||
printf
|
|
||||||
("Fixing keypad scancode map!\nPlease send the following 10 lines of output to the SDL mailing list <sdl@libsdl.org>, including a description of your keyboard hardware.\n");
|
|
||||||
#endif
|
|
||||||
for (i = 0; i < SDL_arraysize(keypad_scancodes); ++i) {
|
|
||||||
keypad_scancodes[i] =
|
|
||||||
MapVirtualKey(VK_NUMPAD0 + i, MAPVK_VK_TO_VSC);
|
|
||||||
#if 0
|
|
||||||
printf("%d = %d\n", i, keypad_scancodes[i]);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// windows scancode to SDL scancode table
|
|
||||||
data->key_layout = windows_scancode_table;
|
|
||||||
|
|
||||||
data->ime_com_initialized = SDL_FALSE;
|
data->ime_com_initialized = SDL_FALSE;
|
||||||
data->ime_threadmgr = 0;
|
data->ime_threadmgr = 0;
|
||||||
|
@ -151,42 +111,36 @@ WIN_UpdateKeymap()
|
||||||
SDL_Scancode scancode;
|
SDL_Scancode scancode;
|
||||||
SDL_Keycode keymap[SDL_NUM_SCANCODES];
|
SDL_Keycode keymap[SDL_NUM_SCANCODES];
|
||||||
|
|
||||||
for (i = 0; i < SDL_arraysize(keymap); ++i)
|
SDL_GetDefaultKeymap(keymap);
|
||||||
{
|
|
||||||
keymap[i] = SDL_SCANCODE_TO_KEYCODE( i );
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < SDL_arraysize(windows_scancode_table); i++) {
|
for (i = 0; i < SDL_arraysize(windows_scancode_table); i++) {
|
||||||
int vk;
|
int vk;
|
||||||
/* Make sure this scancode is a valid character scancode */
|
/* Make sure this scancode is a valid character scancode */
|
||||||
scancode = windows_scancode_table[i];
|
scancode = windows_scancode_table[i];
|
||||||
if (scancode == SDL_SCANCODE_UNKNOWN ) {
|
if (scancode == SDL_SCANCODE_UNKNOWN ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/* Don't allow the number keys right above the qwerty row to translate or the top left key (grave/backquote) */
|
|
||||||
/* not mapping numbers fixes the AZERTY layout (french) causing non-shifted number to appear by default */
|
|
||||||
if ( scancode == SDL_SCANCODE_GRAVE ) {
|
|
||||||
keymap[scancode] = SDLK_BACKQUOTE;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if ( scancode >= SDL_SCANCODE_1 && scancode <= SDL_SCANCODE_0 ) {
|
|
||||||
keymap[scancode] = SDLK_1 + ( scancode - SDL_SCANCODE_1 );
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
vk = MapVirtualKey(i, MAPVK_VSC_TO_VK);
|
/* If this key is one of the non-mappable keys, ignore it */
|
||||||
if ( vk ) {
|
/* Don't allow the number keys right above the qwerty row to translate or the top left key (grave/backquote) */
|
||||||
int ch;
|
/* Not mapping numbers fixes the French layout, giving numeric keycodes for the number keys, which is the expected behavior */
|
||||||
ch = (MapVirtualKey( vk, MAPVK_VK_TO_CHAR ) & 0x7FFF);
|
if ((keymap[scancode] & SDLK_SCANCODE_MASK) ||
|
||||||
if ( ch )
|
scancode == SDL_SCANCODE_GRAVE ||
|
||||||
{
|
(scancode >= SDL_SCANCODE_1 && scancode <= SDL_SCANCODE_0) ) {
|
||||||
if ( ch >= 'A' && ch <= 'Z' )
|
continue;
|
||||||
keymap[scancode] = SDLK_a + ( ch - 'A' );
|
}
|
||||||
else
|
|
||||||
keymap[scancode] = ch;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
vk = MapVirtualKey(i, MAPVK_VSC_TO_VK);
|
||||||
|
if ( vk ) {
|
||||||
|
int ch = (MapVirtualKey( vk, MAPVK_VK_TO_CHAR ) & 0x7FFF);
|
||||||
|
if ( ch ) {
|
||||||
|
if ( ch >= 'A' && ch <= 'Z' ) {
|
||||||
|
keymap[scancode] = SDLK_a + ( ch - 'A' );
|
||||||
|
} else {
|
||||||
|
keymap[scancode] = ch;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_SetKeymap(0, keymap, SDL_NUM_SCANCODES);
|
SDL_SetKeymap(0, keymap, SDL_NUM_SCANCODES);
|
||||||
|
|
|
@ -23,9 +23,6 @@
|
||||||
#ifndef _SDL_windowskeyboard_h
|
#ifndef _SDL_windowskeyboard_h
|
||||||
#define _SDL_windowskeyboard_h
|
#define _SDL_windowskeyboard_h
|
||||||
|
|
||||||
extern BYTE alpha_scancodes[26];
|
|
||||||
extern BYTE keypad_scancodes[10];
|
|
||||||
|
|
||||||
extern void WIN_InitKeyboard(_THIS);
|
extern void WIN_InitKeyboard(_THIS);
|
||||||
extern void WIN_UpdateKeymap(void);
|
extern void WIN_UpdateKeymap(void);
|
||||||
extern void WIN_QuitKeyboard(_THIS);
|
extern void WIN_QuitKeyboard(_THIS);
|
||||||
|
|
|
@ -115,7 +115,6 @@ typedef struct SDL_VideoData
|
||||||
{
|
{
|
||||||
int render;
|
int render;
|
||||||
|
|
||||||
const SDL_Scancode *key_layout;
|
|
||||||
DWORD clipboard_count;
|
DWORD clipboard_count;
|
||||||
|
|
||||||
/* Touch input functions */
|
/* Touch input functions */
|
||||||
|
|
|
@ -576,26 +576,31 @@ X11_InitModes(_THIS)
|
||||||
int actual_format;
|
int actual_format;
|
||||||
unsigned long nitems, bytes_after;
|
unsigned long nitems, bytes_after;
|
||||||
Atom actual_type;
|
Atom actual_type;
|
||||||
|
|
||||||
if (props[i] == EDID) {
|
|
||||||
XRRGetOutputProperty(data->display, res->outputs[output], props[i],
|
|
||||||
0, 100, False, False,
|
|
||||||
AnyPropertyType,
|
|
||||||
&actual_type, &actual_format,
|
|
||||||
&nitems, &bytes_after, &prop);
|
|
||||||
|
|
||||||
MonitorInfo *info = decode_edid(prop);
|
if (props[i] == EDID) {
|
||||||
if (info) {
|
if (XRRGetOutputProperty(data->display,
|
||||||
#ifdef X11MODES_DEBUG
|
res->outputs[output], props[i],
|
||||||
printf("Found EDID data for %s\n", output_info->name);
|
0, 100, False, False,
|
||||||
dump_monitor_info(info);
|
AnyPropertyType,
|
||||||
#endif
|
&actual_type, &actual_format,
|
||||||
SDL_strlcpy(display_name, info->dsc_product_name, sizeof(display_name));
|
&nitems, &bytes_after, &prop) == Success ) {
|
||||||
free(info);
|
MonitorInfo *info = decode_edid(prop);
|
||||||
|
if (info) {
|
||||||
|
#ifdef X11MODES_DEBUG
|
||||||
|
printf("Found EDID data for %s\n", output_info->name);
|
||||||
|
dump_monitor_info(info);
|
||||||
|
#endif
|
||||||
|
SDL_strlcpy(display_name, info->dsc_product_name, sizeof(display_name));
|
||||||
|
free(info);
|
||||||
|
}
|
||||||
|
XFree(prop);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (props) {
|
||||||
|
XFree(props);
|
||||||
|
}
|
||||||
|
|
||||||
if (*display_name && inches) {
|
if (*display_name && inches) {
|
||||||
size_t len = SDL_strlen(display_name);
|
size_t len = SDL_strlen(display_name);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue