Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Merged

  • Loading branch information
slouken committed Mar 1, 2013
2 parents d2cd3cf + 7481ef3 commit 77e27b9bd3c09a561c2e5a93c9bc426617ed61be
@@ -38,7 +38,7 @@
* SDL_Event structure.
*
* 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
{
@@ -20,13 +20,8 @@
*/
#include "../../include/SDL_scancode.h"

/* Win32 virtual key code to SDL scancode mapping table
Sources:
- msdn.microsoft.com
*/
/* Windows scancode to SDL scancode mapping table */
/* *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[] =
{
// 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
};

/* *INDENT-ON* */
@@ -28,13 +28,12 @@
#include "SDL_vkeys.h"
#include "../../events/SDL_events_c.h"
#include "../../events/SDL_touch_c.h"
#include "../../events/scancodes_windows.h"

/* Dropfile support */
#include <shellapi.h>




/*#define WMMSG_DEBUG*/
#ifdef WMMSG_DEBUG
#include <stdio.h>
@@ -68,7 +67,7 @@
#endif

static SDL_Scancode
WindowsScanCodeToSDLScanCode( int lParam, int wParam, const SDL_Scancode *key_map )
WindowsScanCodeToSDLScanCode( int lParam, int wParam )
{
SDL_Scancode code;
char bIsExtended;
@@ -133,7 +132,7 @@ WindowsScanCodeToSDLScanCode( int lParam, int wParam, const SDL_Scancode *key_ma
if ( nScanCode > 127 )
return SDL_SCANCODE_UNKNOWN;

code = key_map[nScanCode];
code = windows_scancode_table[nScanCode];

bIsExtended = ( lParam & ( 1 << 24 ) ) != 0;
if ( !bIsExtended )
@@ -159,7 +158,7 @@ WindowsScanCodeToSDLScanCode( int lParam, int wParam, const SDL_Scancode *key_ma
case SDL_SCANCODE_INSERT:
return SDL_SCANCODE_KP_0;
case SDL_SCANCODE_DELETE:
return SDL_SCANCODE_KP_DECIMAL;
return SDL_SCANCODE_KP_PERIOD;
case SDL_SCANCODE_PRINTSCREEN:
return SDL_SCANCODE_KP_MULTIPLY;
default:
@@ -453,7 +452,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
case WM_SYSKEYDOWN:
case WM_KEYDOWN:
{
SDL_Scancode code = WindowsScanCodeToSDLScanCode( lParam, wParam, data->videodata->key_layout );
SDL_Scancode code = WindowsScanCodeToSDLScanCode( lParam, wParam );
if ( code != SDL_SCANCODE_UNKNOWN ) {
SDL_SendKeyboardKey(SDL_PRESSED, code );
}
@@ -464,15 +463,13 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
case WM_SYSKEYUP:
case WM_KEYUP:
{
SDL_Scancode code = WindowsScanCodeToSDLScanCode( lParam, wParam, data->videodata->key_layout );
if ( code != SDL_SCANCODE_UNKNOWN ) {
if (wParam == VK_SNAPSHOT
&& SDL_GetKeyboardState(NULL)[SDL_SCANCODE_PRINTSCREEN] ==
SDL_RELEASED) {
SDL_SendKeyboardKey(SDL_PRESSED,
code);
}
SDL_SendKeyboardKey(SDL_RELEASED, code );
SDL_Scancode code = WindowsScanCodeToSDLScanCode( lParam, wParam );
if ( code != SDL_SCANCODE_UNKNOWN ) {
if (code == SDL_SCANCODE_PRINTSCREEN &&
SDL_GetKeyboardState(NULL)[code] == SDL_RELEASED) {
SDL_SendKeyboardKey(SDL_PRESSED, code);
}
SDL_SendKeyboardKey(SDL_RELEASED, code);
}
}
returnCode = 0;
@@ -48,50 +48,10 @@ static void IME_Quit(SDL_VideoData *videodata);
#endif

/* 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
WIN_InitKeyboard(_THIS)
{
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_threadmgr = 0;
@@ -151,42 +111,36 @@ WIN_UpdateKeymap()
SDL_Scancode scancode;
SDL_Keycode keymap[SDL_NUM_SCANCODES];

for (i = 0; i < SDL_arraysize(keymap); ++i)
{
keymap[i] = SDL_SCANCODE_TO_KEYCODE( i );
}
SDL_GetDefaultKeymap(keymap);

for (i = 0; i < SDL_arraysize(windows_scancode_table); i++) {
int vk;
int vk;
/* Make sure this scancode is a valid character scancode */
scancode = windows_scancode_table[i];
if (scancode == SDL_SCANCODE_UNKNOWN ) {
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 ( vk ) {
int ch;
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;
}

}

/* If this key is one of the non-mappable keys, ignore it */
/* 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 French layout, giving numeric keycodes for the number keys, which is the expected behavior */
if ((keymap[scancode] & SDLK_SCANCODE_MASK) ||
scancode == SDL_SCANCODE_GRAVE ||
(scancode >= SDL_SCANCODE_1 && scancode <= SDL_SCANCODE_0) ) {
continue;
}

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);
@@ -23,9 +23,6 @@
#ifndef _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_UpdateKeymap(void);
extern void WIN_QuitKeyboard(_THIS);
@@ -115,7 +115,6 @@ typedef struct SDL_VideoData
{
int render;

const SDL_Scancode *key_layout;
DWORD clipboard_count;

/* Touch input functions */
@@ -576,26 +576,31 @@ X11_InitModes(_THIS)
int actual_format;
unsigned long nitems, bytes_after;
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 (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);
if (XRRGetOutputProperty(data->display,
res->outputs[output], props[i],
0, 100, False, False,
AnyPropertyType,
&actual_type, &actual_format,
&nitems, &bytes_after, &prop) == Success ) {
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;
}
}
if (props) {
XFree(props);
}

if (*display_name && inches) {
size_t len = SDL_strlen(display_name);

0 comments on commit 77e27b9

Please sign in to comment.