Commit 4447e6cf authored by Sam Lantinga's avatar Sam Lantinga

Untested Win32 keyboard scancode code.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402720
parent 16230927
......@@ -20,7 +20,7 @@
slouken@libsdl.org
*/
/* Mac virtual key code to SDLKey mapping table
/* Mac virtual key code to SDL scancode mapping table
Sources:
- Inside Macintosh: Text <http://developer.apple.com/documentation/mac/Text/Text-571.html>
- Apple USB keyboard driver source <http://darwinsource.opendarwin.org/10.4.6.ppc/IOHIDFamily-172.8/IOHIDFamily/Cosmo_USB2ADB.c>
......
This diff is collapsed.
This diff is collapsed.
......@@ -24,6 +24,7 @@
#include "SDL_win32video.h"
#include "../../events/SDL_keyboard_c.h"
#include "../../events/scancodes_win32.h"
void
WIN_InitKeyboard(_THIS)
......@@ -31,8 +32,41 @@ WIN_InitKeyboard(_THIS)
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
SDL_Keyboard keyboard;
data->key_layout = win32_scancode_table;
SDL_zero(keyboard);
data->keyboard = SDL_AddKeyboard(&keyboard, -1);
WIN_UpdateKeymap(_this);
SDL_SetScancodeName(SDL_SCANCODE_APPLICATION, "Menu");
SDL_SetScancodeName(SDL_SCANCODE_LGUI, "Left Windows");
SDL_SetScancodeName(SDL_SCANCODE_RGUI, "Right Windows");
}
void
WIN_UpdateKeymap(_THIS)
{
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
int i;
SDL_scancode scancode;
SDLKey keymap[SDL_NUM_SCANCODES];
SDL_GetDefaultKeymap(keymap);
for (i = 0; i < SDL_arraysize(win32_scancode_table); i++) {
/* Make sure this scancode is a valid character scancode */
scancode = win32_scancode_table[i];
if (scancode == SDL_SCANCODE_UNKNOWN ||
(keymap[scancode] & SDLK_SCANCODE_MASK)) {
continue;
}
#ifndef MAPVK_VK_TO_CHAR
#define MAPVK_VK_TO_CHAR 2
#endif
keymap[scancode] = (MapVirtualKey(i, MAPVK_VK_TO_CHAR) & 0x7FFF);
}
SDL_SetKeymap(data->keyboard, 0, keymap, SDL_NUM_SCANCODES);
}
void
......
......@@ -25,6 +25,7 @@
#define _SDL_win32keyboard_h
extern void WIN_InitKeyboard(_THIS);
extern void WIN_UpdateKeymap(_THIS);
extern void WIN_QuitKeyboard(_THIS);
#endif /* _SDL_win32keyboard_h */
......
......@@ -63,6 +63,7 @@ typedef struct SDL_VideoData
#endif
int mouse;
int keyboard;
SDL_scancode *key_layout;
} SDL_VideoData;
#endif /* _SDL_win32video_h */
......
......@@ -277,14 +277,16 @@ static KeySym XKeySymTable[SDL_NUM_SCANCODES] = {
0, /* SDL_SCANCODE_SLEEP ? */
};
/* *INDENT-OFF* */
static struct
{
SDL_scancode *table;
int table_size;
} scancode_set[] = {
{
darwin_scancode_table, SDL_arraysize(darwin_scancode_table)}, {
xfree86_scancode_table, SDL_arraysize(xfree86_scancode_table)},};
{ darwin_scancode_table, SDL_arraysize(darwin_scancode_table) },
{ xfree86_scancode_table, SDL_arraysize(xfree86_scancode_table) },
};
/* *INDENT-OFF* */
int
X11_InitKeyboard(_THIS)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment