libfreerdp-locale: separate Solaris code

This commit is contained in:
Marc-André Moreau 2012-02-18 22:54:44 -05:00
parent c7a524aa5a
commit bd79959687
5 changed files with 395 additions and 346 deletions

View File

@ -22,43 +22,53 @@ set(FREERDP_LOCALE_SRCS
layouts.c
keyboard.c
keyboard.h
keyboard_x11.c
keyboard_x11.h
liblocale.h)
set(FREERDP_LOCALE_X11_SRCS
keyboard_x11.c
keyboard_x11.h)
set(FREERDP_LOCALE_XKB_SRCS
keyboard_xkb.c
keyboard_xkb.h)
set(FREERDP_LOCALE_SUN_SRCS
keyboard_sun.c
keyboard_sun.h)
# TODO: Detect Solaris
#set(WITH_SUN true)
set(FREERDP_LOCALE_LINK_LIBRARIES freerdp-utils)
if(NOT WIN32)
find_suggested_package(X11)
if(NOT APPLE)
find_suggested_package(XKBFile)
if (WITH_X11)
add_definitions(-DWITH_X11)
if(WITH_X11)
add_definitions(-DWITH_X11)
include_directories(${X11_INCLUDE_DIRS})
set(FREERDP_LOCALE_SRCS ${FREERDP_LOCALE_SRCS} ${FREERDP_LOCALE_X11_SRCS})
set(FREERDP_LOCALE_LINK_LIBRARIES ${FREERDP_LOCALE_LINK_LIBRARIES} ${X11_LIBRARIES})
if(NOT APPLE)
find_suggested_package(XKBFile)
if(WITH_XKBFILE)
add_definitions(-DWITH_XKB)
include_directories(${XKBFILE_INCLUDE_DIRS})
set(FREERDP_LOCALE_SRCS ${FREERDP_LOCALE_SRCS} ${FREERDP_LOCALE_XKB_SRCS})
set(FREERDP_LOCALE_LINK_LIBRARIES ${FREERDP_LOCALE_LINK_LIBRARIES} ${XKBFILE_LIBRARIES})
endif()
endif()
if(WITH_SUN)
add_definitions(-DWITH_SUN)
set(FREERDP_LOCALE_SRCS ${FREERDP_LOCALE_SRCS} ${FREERDP_LOCALE_SUN_SRCS})
endif()
endif()
endif()
add_library(freerdp-locale ${FREERDP_LOCALE_SRCS})
if(NOT WIN32)
if(WITH_X11)
target_link_libraries(freerdp-locale ${X11_LIBRARIES})
if(WITH_XKBFILE)
target_link_libraries(freerdp-locale ${XKBFILE_LIBRARIES})
endif()
endif()
endif()
set_target_properties(freerdp-locale PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib")
target_link_libraries(freerdp-locale freerdp-utils)
target_link_libraries(freerdp-locale ${FREERDP_LOCALE_LINK_LIBRARIES})
install(TARGETS freerdp-locale DESTINATION ${CMAKE_INSTALL_LIBDIR})

View File

@ -28,10 +28,18 @@
#include "liblocale.h"
#ifdef WITH_X11
#include "keyboard_x11.h"
#endif
#ifdef WITH_XKB
#include "keyboard_xkb.h"
#endif
#ifdef WITH_SUN
#include "keyboard_sun.h"
#endif
#include <freerdp/locale/locales.h>
#include <freerdp/locale/vkcodes.h>
#include <freerdp/locale/layouts.h>
@ -50,21 +58,11 @@ RdpScancodes x_keycode_to_rdp_scancode;
uint8 rdp_scancode_to_x_keycode[256][2];
uint32 freerdp_detect_keyboard(void* display, uint32 keyboardLayoutID, char* xkbfile, size_t xkbfile_length)
uint32 freerdp_detect_keyboard(uint32 keyboardLayoutID)
{
xkbfile[0] = '\0';
if (keyboardLayoutID != 0)
DEBUG_KBD("keyboard layout configuration: %X", keyboardLayoutID);
#if defined(sun)
if (keyboardLayoutID == 0)
{
keyboardLayoutID = detect_keyboard_type_and_layout_sunos(xkbfile, xkbfile_length);
DEBUG_KBD("detect_keyboard_type_and_layout_sunos: %X %s", keyboardLayoutID, xkbfile);
}
#endif
if (keyboardLayoutID == 0)
{
keyboardLayoutID = detect_keyboard_layout_from_locale();
@ -77,27 +75,15 @@ uint32 freerdp_detect_keyboard(void* display, uint32 keyboardLayoutID, char* xkb
DEBUG_KBD("using default keyboard layout: %X", keyboardLayoutID);
}
if (xkbfile[0] == '\0')
{
strncpy(xkbfile, "base", xkbfile_length);
DEBUG_KBD("using default keyboard layout: %s", xkbfile);
}
return keyboardLayoutID;
}
/*
* Initialize global keyboard mapping and return the suggested server side layout.
* display must be a X Display* or NULL.
*/
uint32 freerdp_keyboard_init(uint32 keyboard_layout_id)
uint32 freerdp_keyboard_init_xkb(uint32 keyboardLayoutId)
{
void* display;
memset(x_keycode_to_rdp_scancode, 0, sizeof(x_keycode_to_rdp_scancode));
memset(rdp_scancode_to_x_keycode, '\0', sizeof(rdp_scancode_to_x_keycode));
#ifdef WITH_XKB
display = freerdp_keyboard_xkb_init();
if (!display)
@ -106,26 +92,42 @@ uint32 freerdp_keyboard_init(uint32 keyboard_layout_id)
return 0;
}
if (keyboard_layout_id == 0)
if (keyboardLayoutId == 0)
{
keyboard_layout_id = detect_keyboard_layout_from_xkb(display);
DEBUG_KBD("detect_keyboard_layout_from_xkb: %X", keyboard_layout_id);
keyboardLayoutId = detect_keyboard_layout_from_xkb(display);
DEBUG_KBD("detect_keyboard_layout_from_xkb: %X", keyboardLayoutId);
}
freerdp_keyboard_load_map_from_xkb(display, x_keycode_to_rdp_scancode, rdp_scancode_to_x_keycode);
#else
int vkcode;
int keycode;
char xkbfile[256];
return keyboardLayoutId;
}
uint32 freerdp_keyboard_init_x11(uint32 keyboardLayoutId)
{
uint32 vkcode;
uint32 keycode;
KeycodeToVkcode keycodeToVkcode;
if (keyboard_layout_id == 0)
keyboard_layout_id = freerdp_detect_keyboard(display, keyboard_layout_id, xkbfile, sizeof(xkbfile));
memset(x_keycode_to_rdp_scancode, 0, sizeof(x_keycode_to_rdp_scancode));
memset(rdp_scancode_to_x_keycode, '\0', sizeof(rdp_scancode_to_x_keycode));
DEBUG_KBD("Using keyboard layout 0x%X with xkb name %s and xkbfile %s",
keyboard_layout_id, get_layout_name(keyboard_layout_id), xkbfile);
if (keyboardLayoutId == 0)
{
keyboardLayoutId = detect_keyboard_layout_from_locale();
DEBUG_KBD("using keyboard layout: %X", keyboardLayoutID);
}
freerdp_keyboard_load_maps(keycodeToVkcode, xkbfile);
if (keyboardLayoutId == 0)
{
keyboardLayoutId = 0x0409;
DEBUG_KBD("using default keyboard layout: %X", keyboardLayoutID);
}
#ifdef __APPLE__
/* Apple X11 breaks XKB detection */
freerdp_keyboard_load_map(keycodeToVkcode, "macosx(macosx)");
#endif
for (keycode = 0; keycode < 256; keycode++)
{
@ -144,78 +146,70 @@ uint32 freerdp_keyboard_init(uint32 keyboard_layout_id)
else
rdp_scancode_to_x_keycode[virtualKeyboard[vkcode].scancode][0] = keycode;
}
#endif
return keyboard_layout_id;
return keyboardLayoutId;
}
/* Default built-in keymap */
static const KeycodeToVkcode defaultKeycodeToVkcode =
uint32 freerdp_keyboard_init(uint32 keyboardLayoutId)
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1B, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36,
0x37, 0x38, 0x39, 0x30, 0xBD, 0xBB, 0x08, 0x09, 0x51, 0x57, 0x45, 0x52, 0x54, 0x59, 0x55, 0x49,
0x4F, 0x50, 0xDB, 0xDD, 0x0D, 0xA2, 0x41, 0x53, 0x44, 0x46, 0x47, 0x48, 0x4A, 0x4B, 0x4C, 0xBA,
0xDE, 0xC0, 0xA0, 0x00, 0x5A, 0x58, 0x43, 0x56, 0x42, 0x4E, 0x4D, 0xBC, 0xBE, 0xBF, 0xA1, 0x6A,
0x12, 0x20, 0x14, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x90, 0x91, 0x67,
0x68, 0x69, 0x6D, 0x64, 0x65, 0x66, 0x6B, 0x61, 0x62, 0x63, 0x60, 0x6E, 0x00, 0x00, 0x00, 0x7A,
0x7B, 0x24, 0x26, 0x21, 0x25, 0x00, 0x27, 0x23, 0x28, 0x22, 0x2D, 0x2E, 0x0D, 0xA3, 0x13, 0x2C,
0x6F, 0x12, 0x00, 0x5B, 0x5C, 0x5D, 0x7C, 0x7D, 0x7E, 0x7F, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xA1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
#ifdef WITH_XKB
keyboardLayoutId = freerdp_keyboard_init_xkb(keyboardLayoutId);
static int freerdp_keyboard_load_map(KeycodeToVkcode map, char* kbd)
if (keyboardLayoutId == 0)
keyboardLayoutId = freerdp_keyboard_init_x11(keyboardLayoutId);
#else
#ifdef WITH_X11
keyboardLayoutId = freerdp_keyboard_init_x11(keyboardLayoutId);
#endif
#endif
return keyboardLayoutId;
}
static int freerdp_keyboard_load_map(KeycodeToVkcode map, char* name)
{
FILE* fp;
char* pch;
char* beg;
char* end;
char* xkbfile_path;
char xkbmap[256] = "";
char xkbinc[256] = "";
char buffer[1024] = "";
char xkbfile[256] = "";
FILE* fp;
int kbdFound = 0;
int i = 0;
int keycode = 0;
int kbdFound = 0;
char* keymap_path;
uint32 keycode = 0;
char buffer[1024] = "";
char keymap_name[256] = "";
char keymap_include[256] = "";
char keymap_filename[256] = "";
char keycodeString[32] = "";
char vkcodeName[128] = "";
beg = kbd;
beg = name;
/* Extract file name and keymap name */
if ((end = strrchr(kbd, '(')) != NULL)
if ((end = strrchr(name, '(')) != NULL)
{
strncpy(xkbfile, &kbd[beg - kbd], end - beg);
strncpy(keymap_filename, &name[beg - name], end - beg);
beg = end + 1;
if ((end = strrchr(kbd, ')')) != NULL)
if ((end = strrchr(name, ')')) != NULL)
{
strncpy(xkbmap, &kbd[beg - kbd], end - beg);
xkbmap[end - beg] = '\0';
strncpy(keymap_name, &name[beg - name], end - beg);
keymap_name[end - beg] = '\0';
}
}
else
{
/* The keyboard name is the same as the file name */
strcpy(xkbfile, kbd);
strcpy(xkbmap, kbd);
strcpy(keymap_filename, name);
strcpy(keymap_name, name);
}
/* Get path to file relative to freerdp's directory */
xkbfile_path = freerdp_construct_path(FREERDP_KEYMAP_PATH, xkbfile);
keymap_path = freerdp_construct_path(FREERDP_KEYMAP_PATH, keymap_filename);
DEBUG_KBD("Loading keymap %s, first trying %s", kbd, xkbfile_path);
DEBUG_KBD("Loading keymap %s, first trying %s", name, keymap_path);
if ((fp = fopen(xkbfile_path, "r")) == NULL)
if ((fp = fopen(keymap_path, "r")) == NULL)
{
return 0;
}
@ -287,10 +281,10 @@ static int freerdp_keyboard_load_map(KeycodeToVkcode map, char* kbd)
if ((end = strchr(beg, '"')) == NULL)
break;
strncpy(xkbinc, beg, end - beg);
xkbinc[end - beg] = '\0';
strncpy(keymap_include, beg, end - beg);
keymap_include[end - beg] = '\0';
freerdp_keyboard_load_map(map, xkbinc); /* Load included keymap */
freerdp_keyboard_load_map(map, keymap_include); /* Load included keymap */
}
}
else if ((pch = strstr(buffer, "keyboard")) != NULL)
@ -307,7 +301,7 @@ static int freerdp_keyboard_load_map(KeycodeToVkcode map, char* kbd)
buffer[end - beg] = '\0';
/* Does it match our keymap name? */
if (strncmp(xkbmap, pch, strlen(xkbmap)) == 0)
if (strncmp(keymap_name, pch, strlen(keymap_name)) == 0)
kbdFound = 1;
}
}
@ -328,10 +322,6 @@ void freerdp_keyboard_load_maps(KeycodeToVkcode keycodeToVkcode, char* xkbfile)
kbd = xkbfile;
xkbfileEnd = xkbfile + strlen(xkbfile);
#ifdef __APPLE__
/* Apple X11 breaks XKB detection */
keymapLoaded += freerdp_keyboard_load_map(keycodeToVkcode, "macosx(macosx)");
#else
do
{
/* Multiple maps are separated by '+' */
@ -344,15 +334,11 @@ void freerdp_keyboard_load_maps(KeycodeToVkcode keycodeToVkcode, char* xkbfile)
kbd += kbdlen + 1;
}
while (kbd < xkbfileEnd);
#endif
DEBUG_KBD("loaded %d keymaps", keymapLoaded);
if (keymapLoaded <= 0)
{
/* No keymap was loaded, load default hard-coded keymap */
DEBUG_KBD("using default keymap");
memcpy(keycodeToVkcode, defaultKeycodeToVkcode, sizeof(keycodeToVkcode));
}
printf("error: no keyboard mapping available!\n");
}
rdpKeyboardLayout* freerdp_keyboard_get_layouts(uint32 types)

View File

@ -0,0 +1,262 @@
/**
* FreeRDP: A Remote Desktop Protocol Client
* XKB-based Keyboard Mapping to Microsoft Keyboard System
*
* Copyright 2009 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "liblocale.h"
#include <freerdp/locale/layouts.h>
#include "keyboard_x11.h"
#include "keyboard_sun.h"
/* OpenSolaris 2008.11 and 2009.06 keyboard layouts
*
* While OpenSolaris comes with Xorg and XKB, it maintains a set of keyboard layout
* names that map directly to a particular keyboard layout in XKB. Fortunately for us,
* this way of doing things comes from Solaris, which is XKB unaware. The same keyboard
* layout naming system is used in Solaris, so we can use the same XKB configuration as
* we would on OpenSolaris and get an accurate keyboard layout detection :)
*
* We can check for the current keyboard layout using the "kbd -l" command:
*
* type=6
* layout=33 (0x21)
* delay(ms)=500
* rate(ms)=40
*
* We can check at runtime if the kbd utility is present, parse the output, and use the
* keyboard layout indicated by the index given (in this case, 33, or US-English).
*/
struct _SunOSKeyboard
{
int type; /* Sun keyboard type */
int layout; /* Layout */
char* xkbType; /* XKB keyboard */
uint32 keyboardLayoutID; /* XKB keyboard layout */
};
typedef struct _SunOSKeyboard SunOSKeyboard;
static const SunOSKeyboard SunOSKeyboards[] =
{
{ 4, 0, "sun(type4)", KBD_US }, /* US4 */
{ 4, 1, "sun(type4)", KBD_US }, /* US4 */
{ 4, 2, "sun(type4tuv)", KBD_FRENCH }, /* FranceBelg4 */
{ 4, 3, "sun(type4_ca)", KBD_US }, /* Canada4 */
{ 4, 4, "sun(type4tuv)", KBD_DANISH }, /* Denmark4 */
{ 4, 5, "sun(type4tuv)", KBD_GERMAN }, /* Germany4 */
{ 4, 6, "sun(type4tuv)", KBD_ITALIAN }, /* Italy4 */
{ 4, 7, "sun(type4tuv)", KBD_DUTCH }, /* Netherland4 */
{ 4, 8, "sun(type4tuv)", KBD_NORWEGIAN }, /* Norway4 */
{ 4, 9, "sun(type4tuv)", KBD_PORTUGUESE }, /* Portugal4 */
{ 4, 10, "sun(type4tuv)", KBD_SPANISH }, /* SpainLatAm4 */
{ 4, 11, "sun(type4tuv)", KBD_SWEDISH }, /* SwedenFin4 */
{ 4, 12, "sun(type4tuv)", KBD_SWISS_FRENCH }, /* Switzer_Fr4 */
{ 4, 13, "sun(type4tuv)", KBD_SWISS_GERMAN }, /* Switzer_Ge4 */
{ 4, 14, "sun(type4tuv)", KBD_UNITED_KINGDOM }, /* UK4 */
{ 4, 16, "sun(type4)", KBD_KOREAN_INPUT_SYSTEM_IME_2000 }, /* Korea4 */
{ 4, 17, "sun(type4)", KBD_CHINESE_TRADITIONAL_PHONETIC }, /* Taiwan4 */
{ 4, 32, "sun(type4jp)", KBD_JAPANESE_INPUT_SYSTEM_MS_IME2002 }, /* Japan4 */
{ 4, 19, "sun(type5)", KBD_US }, /* US101A_PC */
{ 4, 33, "sun(type5)", KBD_US }, /* US5 */
{ 4, 34, "sun(type5unix)", KBD_US }, /* US_UNIX5 */
{ 4, 35, "sun(type5tuv)", KBD_FRENCH }, /* France5 */
{ 4, 36, "sun(type5tuv)", KBD_DANISH }, /* Denmark5 */
{ 4, 37, "sun(type5tuv)", KBD_GERMAN }, /* Germany5 */
{ 4, 38, "sun(type5tuv)", KBD_ITALIAN }, /* Italy5 */
{ 4, 39, "sun(type5tuv)", KBD_DUTCH }, /* Netherland5 */
{ 4, 40, "sun(type5tuv)", KBD_NORWEGIAN }, /* Norway5 */
{ 4, 41, "sun(type5tuv)", KBD_PORTUGUESE }, /* Portugal5 */
{ 4, 42, "sun(type5tuv)", KBD_SPANISH }, /* Spain5 */
{ 4, 43, "sun(type5tuv)", KBD_SWEDISH }, /* Sweden5 */
{ 4, 44, "sun(type5tuv)", KBD_SWISS_FRENCH }, /* Switzer_Fr5 */
{ 4, 45, "sun(type5tuv)", KBD_SWISS_GERMAN }, /* Switzer_Ge5 */
{ 4, 46, "sun(type5tuv)", KBD_UNITED_KINGDOM }, /* UK5 */
{ 4, 47, "sun(type5)", KBD_KOREAN_INPUT_SYSTEM_IME_2000 }, /* Korea5 */
{ 4, 48, "sun(type5)", KBD_CHINESE_TRADITIONAL_PHONETIC }, /* Taiwan5 */
{ 4, 49, "sun(type5jp)", KBD_JAPANESE_INPUT_SYSTEM_MS_IME2002 }, /* Japan5 */
{ 4, 50, "sun(type5tuv)", KBD_CANADIAN_FRENCH }, /* Canada_Fr5 */
{ 4, 51, "sun(type5tuv)", KBD_HUNGARIAN }, /* Hungary5 */
{ 4, 52, "sun(type5tuv)", KBD_POLISH_214 }, /* Poland5 */
{ 4, 53, "sun(type5tuv)", KBD_CZECH }, /* Czech5 */
{ 4, 54, "sun(type5tuv)", KBD_RUSSIAN }, /* Russia5 */
{ 4, 55, "sun(type5tuv)", KBD_LATVIAN }, /* Latvia5 */
{ 4, 57, "sun(type5tuv)", KBD_GREEK }, /* Greece5 */
{ 4, 59, "sun(type5tuv)", KBD_LITHUANIAN }, /* Lithuania5 */
{ 4, 63, "sun(type5tuv)", KBD_CANADIAN_FRENCH }, /* Canada_Fr5_TBITS5 */
{ 4, 56, "sun(type5tuv)", KBD_TURKISH_Q }, /* TurkeyQ5 */
{ 4, 58, "sun(type5tuv)", KBD_ARABIC_101 }, /* Arabic5 */
{ 4, 60, "sun(type5tuv)", KBD_BELGIAN_FRENCH }, /* Belgian5 */
{ 4, 62, "sun(type5tuv)", KBD_TURKISH_F }, /* TurkeyF5 */
{ 4, 80, "sun(type5hobo)", KBD_US }, /* US5_Hobo */
{ 4, 81, "sun(type5hobo)", KBD_US }, /* US_UNIX5_Hobo */
{ 4, 82, "sun(type5tuvhobo)", KBD_FRENCH }, /* France5_Hobo */
{ 4, 83, "sun(type5tuvhobo)", KBD_DANISH }, /* Denmark5_Hobo */
{ 4, 84, "sun(type5tuvhobo)", KBD_GERMAN }, /* Germany5_Hobo */
{ 4, 85, "sun(type5tuvhobo)", KBD_ITALIAN }, /* Italy5_Hobo */
{ 4, 86, "sun(type5tuvhobo)", KBD_DUTCH }, /* Netherland5_Hobo */
{ 4, 87, "sun(type5tuvhobo)", KBD_NORWEGIAN }, /* Norway5_Hobo */
{ 4, 88, "sun(type5tuvhobo)", KBD_PORTUGUESE }, /* Portugal5_Hobo */
{ 4, 89, "sun(type5tuvhobo)", KBD_SPANISH }, /* Spain5_Hobo */
{ 4, 90, "sun(type5tuvhobo)", KBD_SWEDISH }, /* Sweden5_Hobo */
{ 4, 91, "sun(type5tuvhobo)", KBD_SWISS_FRENCH }, /* Switzer_Fr5_Hobo */
{ 4, 92, "sun(type5tuvhobo)", KBD_SWISS_GERMAN }, /* Switzer_Ge5_Hobo */
{ 4, 93, "sun(type5tuvhobo)", KBD_UNITED_KINGDOM }, /* UK5_Hobo */
{ 4, 94, "sun(type5hobo)", KBD_KOREAN_INPUT_SYSTEM_IME_2000 }, /* Korea5_Hobo */
{ 4, 95, "sun(type5hobo)", KBD_CHINESE_TRADITIONAL_PHONETIC }, /* Taiwan5_Hobo */
{ 4, 96, "sun(type5jphobo)", KBD_JAPANESE_INPUT_SYSTEM_MS_IME2002 }, /* Japan5_Hobo */
{ 4, 97, "sun(type5tuvhobo)", KBD_CANADIAN_FRENCH }, /* Canada_Fr5_Hobo */
{ 101, 1, "digital_vndr/pc(pc104)", KBD_US }, /* US101A_x86 */
{ 101, 34, "digital_vndr/pc(pc104)", KBD_US }, /* J3100_x86 */
{ 101, 35, "digital_vndr/pc(pc104)", KBD_FRENCH }, /* France_x86 */
{ 101, 36, "digital_vndr/pc(pc104)", KBD_DANISH }, /* Denmark_x86 */
{ 101, 37, "digital_vndr/pc(pc104)", KBD_GERMAN }, /* Germany_x86 */
{ 101, 38, "digital_vndr/pc(pc104)", KBD_ITALIAN }, /* Italy_x86 */
{ 101, 39, "digital_vndr/pc(pc104)", KBD_DUTCH }, /* Netherland_x86 */
{ 101, 40, "digital_vndr/pc(pc104)", KBD_NORWEGIAN }, /* Norway_x86 */
{ 101, 41, "digital_vndr/pc(pc104)", KBD_PORTUGUESE }, /* Portugal_x86 */
{ 101, 42, "digital_vndr/pc(pc104)", KBD_SPANISH }, /* Spain_x86 */
{ 101, 43, "digital_vndr/pc(pc104)", KBD_SWEDISH }, /* Sweden_x86 */
{ 101, 44, "digital_vndr/pc(pc104)", KBD_SWISS_FRENCH }, /* Switzer_Fr_x86 */
{ 101, 45, "digital_vndr/pc(pc104)", KBD_SWISS_GERMAN }, /* Switzer_Ge_x86 */
{ 101, 46, "digital_vndr/pc(pc104)", KBD_UNITED_KINGDOM }, /* UK_x86 */
{ 101, 47, "digital_vndr/pc(pc104)", KBD_KOREAN_INPUT_SYSTEM_IME_2000 }, /* Korea_x86 */
{ 101, 48, "digital_vndr/pc(pc104)", KBD_CHINESE_TRADITIONAL_PHONETIC }, /* Taiwan_x86 */
{ 101, 49, "digital_vndr/pc(lk411jj)", KBD_JAPANESE_INPUT_SYSTEM_MS_IME2002 }, /* Japan_x86 */
{ 101, 50, "digital_vndr/pc(pc104)", KBD_CANADIAN_FRENCH }, /* Canada_Fr2_x86 */
{ 101, 51, "digital_vndr/pc(pc104)", KBD_HUNGARIAN }, /* Hungary_x86 */
{ 101, 52, "digital_vndr/pc(pc104)", KBD_POLISH_214 }, /* Poland_x86 */
{ 101, 53, "digital_vndr/pc(pc104)", KBD_CZECH }, /* Czech_x86 */
{ 101, 54, "digital_vndr/pc(pc104)", KBD_RUSSIAN }, /* Russia_x86 */
{ 101, 55, "digital_vndr/pc(pc104)", KBD_LATVIAN }, /* Latvia_x86 */
{ 101, 56, "digital_vndr/pc(pc104)", KBD_TURKISH_Q }, /* Turkey_x86 */
{ 101, 57, "digital_vndr/pc(pc104)", KBD_GREEK }, /* Greece_x86 */
{ 101, 59, "digital_vndr/pc(pc104)", KBD_LITHUANIAN }, /* Lithuania_x86 */
{ 101, 1001, "digital_vndr/pc(pc104)", KBD_US }, /* MS_US101A_x86 */
{ 6, 6, "sun(type6tuv)", KBD_DANISH }, /* Denmark6_usb */
{ 6, 7, "sun(type6tuv)", KBD_FINNISH }, /* Finnish6_usb */
{ 6, 8, "sun(type6tuv)", KBD_FRENCH }, /* France6_usb */
{ 6, 9, "sun(type6tuv)", KBD_GERMAN }, /* Germany6_usb */
{ 6, 14, "sun(type6tuv)", KBD_ITALIAN }, /* Italy6_usb */
{ 6, 15, "sun(type6jp)", KBD_JAPANESE_INPUT_SYSTEM_MS_IME2002 }, /* Japan7_usb */
{ 6, 16, "sun(type6)", KBD_KOREAN_INPUT_SYSTEM_IME_2000 }, /* Korea6_usb */
{ 6, 18, "sun(type6tuv)", KBD_DUTCH }, /* Netherland6_usb */
{ 6, 19, "sun(type6tuv)", KBD_NORWEGIAN }, /* Norway6_usb */
{ 6, 22, "sun(type6tuv)", KBD_PORTUGUESE }, /* Portugal6_usb */
{ 6, 23, "sun(type6tuv)", KBD_RUSSIAN }, /* Russia6_usb */
{ 6, 25, "sun(type6tuv)", KBD_SPANISH }, /* Spain6_usb */
{ 6, 26, "sun(type6tuv)", KBD_SWEDISH }, /* Sweden6_usb */
{ 6, 27, "sun(type6tuv)", KBD_SWISS_FRENCH }, /* Switzer_Fr6_usb */
{ 6, 28, "sun(type6tuv)", KBD_SWISS_GERMAN }, /* Switzer_Ge6_usb */
{ 6, 30, "sun(type6)", KBD_CHINESE_TRADITIONAL_PHONETIC }, /* Taiwan6_usb */
{ 6, 32, "sun(type6tuv)", KBD_UNITED_KINGDOM }, /* UK6_usb */
{ 6, 33, "sun(type6)", KBD_US }, /* US6_usb */
{ 6, 1, "sun(type6tuv)", KBD_ARABIC_101 }, /* Arabic6_usb */
{ 6, 2, "sun(type6tuv)", KBD_BELGIAN_FRENCH }, /* Belgian6_usb */
{ 6, 31, "sun(type6tuv)", KBD_TURKISH_Q }, /* TurkeyQ6_usb */
{ 6, 35, "sun(type6tuv)", KBD_TURKISH_F }, /* TurkeyF6_usb */
{ 6, 271, "sun(type6jp)", KBD_JAPANESE_INPUT_SYSTEM_MS_IME2002 }, /* Japan6_usb */
{ 6, 264, "sun(type6tuv)", KBD_ALBANIAN }, /* Albanian6_usb */
{ 6, 261, "sun(type6tuv)", KBD_BELARUSIAN }, /* Belarusian6_usb */
{ 6, 260, "sun(type6tuv)", KBD_BULGARIAN }, /* Bulgarian6_usb */
{ 6, 259, "sun(type6tuv)", KBD_CROATIAN }, /* Croatian6_usb */
{ 6, 5, "sun(type6tuv)", KBD_CZECH }, /* Czech6_usb */
{ 6, 4, "sun(type6tuv)", KBD_CANADIAN_FRENCH }, /* French-Canadian6_usb */
{ 6, 12, "sun(type6tuv)", KBD_HUNGARIAN }, /* Hungarian6_usb */
{ 6, 10, "sun(type6tuv)", KBD_GREEK }, /* Greek6_usb */
{ 6, 17, "sun(type6)", KBD_LATIN_AMERICAN }, /* Latin-American6_usb */
{ 6, 265, "sun(type6tuv)", KBD_LITHUANIAN }, /* Lithuanian6_usb */
{ 6, 266, "sun(type6tuv)", KBD_LATVIAN }, /* Latvian6_usb */
{ 6, 267, "sun(type6tuv)", KBD_FYRO_MACEDONIAN }, /* Macedonian6_usb */
{ 6, 263, "sun(type6tuv)", KBD_MALTESE_47_KEY }, /* Malta_UK6_usb */
{ 6, 262, "sun(type6tuv)", KBD_MALTESE_48_KEY }, /* Malta_US6_usb */
{ 6, 21, "sun(type6tuv)", KBD_POLISH_214 }, /* Polish6_usb */
{ 6, 257, "sun(type6tuv)", KBD_SERBIAN_LATIN }, /* Serbia-And-Montenegro6_usb */
{ 6, 256, "sun(type6tuv)", KBD_SLOVENIAN }, /* Slovenian6_usb */
{ 6, 24, "sun(type6tuv)", KBD_SLOVAK }, /* Slovakian6_usb */
{ 6, 3, "sun(type6)", KBD_CANADIAN_MULTILINGUAL_STANDARD }, /* Canada_Bi6_usb */
{ 6, 272, "sun(type6)", KBD_PORTUGUESE_BRAZILIAN_ABNT } /* Brazil6_usb */
};
uint32 detect_keyboard_type_and_layout_sunos(char* xkbfile, int length)
{
FILE* kbd;
int i;
int type = 0;
int layout = 0;
char* pch;
char* beg;
char* end;
char buffer[1024];
/*
Sample output for "kbd -t -l" :
USB keyboard
type=6
layout=3 (0x03)
delay(ms)=500
rate(ms)=40
*/
kbd = popen("kbd -t -l", "r");
if (kbd < 0)
return 0;
while (fgets(buffer, sizeof(buffer), kbd) != NULL)
{
if ((pch = strstr(buffer, "type=")) != NULL)
{
beg = pch + sizeof("type=") - 1;
end = strchr(beg, '\n');
end[0] = '\0';
type = atoi(beg);
}
else if ((pch = strstr(buffer, "layout=")) != NULL)
{
beg = pch + sizeof("layout=") - 1;
end = strchr(beg, ' ');
end[0] = '\0';
layout = atoi(beg);
}
}
pclose(kbd);
for (i = 0; i < sizeof(SunOSKeyboards) / sizeof(SunOSKeyboard); i++)
{
if (SunOSKeyboards[i].type == type)
{
if (SunOSKeyboards[i].layout == layout)
{
strncpy(xkbfile, SunOSKeyboards[i].xkbType, length);
return SunOSKeyboards[i].keyboardLayoutID;
}
}
}
return 0;
}

View File

@ -0,0 +1,27 @@
/**
* FreeRDP: A Remote Desktop Protocol Client
* XKB-based Keyboard Mapping to Microsoft Keyboard System
*
* Copyright 2009 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __KEYBOARD_SUN_H
#define __KEYBOARD_SUN_H
#include "keyboard_x11.h"
uint32 detect_keyboard_type_and_layout_sunos(char* xkbfile, int length);
#endif

View File

@ -891,175 +891,6 @@ static const XKB_LAYOUT xkbLayouts[] =
{ "tm", KBD_TURKISH_Q, tm_variants }, /* Turkmenistan */
};
/* OpenSolaris 2008.11 and 2009.06 keyboard layouts
*
* While OpenSolaris comes with Xorg and XKB, it maintains a set of keyboard layout
* names that map directly to a particular keyboard layout in XKB. Fortunately for us,
* this way of doing things comes from Solaris, which is XKB unaware. The same keyboard
* layout naming system is used in Solaris, so we can use the same XKB configuration as
* we would on OpenSolaris and get an accurate keyboard layout detection :)
*
* We can check for the current keyboard layout using the "kbd -l" command:
*
* type=6
* layout=33 (0x21)
* delay(ms)=500
* rate(ms)=40
*
* We can check at runtime if the kbd utility is present, parse the output, and use the
* keyboard layout indicated by the index given (in this case, 33, or US-English).
*/
struct _SunOSKeyboard
{
int type; /* Sun keyboard type */
int layout; /* Layout */
char* xkbType; /* XKB keyboard */
uint32 keyboardLayoutID; /* XKB keyboard layout */
};
typedef struct _SunOSKeyboard SunOSKeyboard;
static const SunOSKeyboard SunOSKeyboards[] =
{
{ 4, 0, "sun(type4)", KBD_US }, /* US4 */
{ 4, 1, "sun(type4)", KBD_US }, /* US4 */
{ 4, 2, "sun(type4tuv)", KBD_FRENCH }, /* FranceBelg4 */
{ 4, 3, "sun(type4_ca)", KBD_US }, /* Canada4 */
{ 4, 4, "sun(type4tuv)", KBD_DANISH }, /* Denmark4 */
{ 4, 5, "sun(type4tuv)", KBD_GERMAN }, /* Germany4 */
{ 4, 6, "sun(type4tuv)", KBD_ITALIAN }, /* Italy4 */
{ 4, 7, "sun(type4tuv)", KBD_DUTCH }, /* Netherland4 */
{ 4, 8, "sun(type4tuv)", KBD_NORWEGIAN }, /* Norway4 */
{ 4, 9, "sun(type4tuv)", KBD_PORTUGUESE }, /* Portugal4 */
{ 4, 10, "sun(type4tuv)", KBD_SPANISH }, /* SpainLatAm4 */
{ 4, 11, "sun(type4tuv)", KBD_SWEDISH }, /* SwedenFin4 */
{ 4, 12, "sun(type4tuv)", KBD_SWISS_FRENCH }, /* Switzer_Fr4 */
{ 4, 13, "sun(type4tuv)", KBD_SWISS_GERMAN }, /* Switzer_Ge4 */
{ 4, 14, "sun(type4tuv)", KBD_UNITED_KINGDOM }, /* UK4 */
{ 4, 16, "sun(type4)", KBD_KOREAN_INPUT_SYSTEM_IME_2000 }, /* Korea4 */
{ 4, 17, "sun(type4)", KBD_CHINESE_TRADITIONAL_PHONETIC }, /* Taiwan4 */
{ 4, 32, "sun(type4jp)", KBD_JAPANESE_INPUT_SYSTEM_MS_IME2002 }, /* Japan4 */
{ 4, 19, "sun(type5)", KBD_US }, /* US101A_PC */
{ 4, 33, "sun(type5)", KBD_US }, /* US5 */
{ 4, 34, "sun(type5unix)", KBD_US }, /* US_UNIX5 */
{ 4, 35, "sun(type5tuv)", KBD_FRENCH }, /* France5 */
{ 4, 36, "sun(type5tuv)", KBD_DANISH }, /* Denmark5 */
{ 4, 37, "sun(type5tuv)", KBD_GERMAN }, /* Germany5 */
{ 4, 38, "sun(type5tuv)", KBD_ITALIAN }, /* Italy5 */
{ 4, 39, "sun(type5tuv)", KBD_DUTCH }, /* Netherland5 */
{ 4, 40, "sun(type5tuv)", KBD_NORWEGIAN }, /* Norway5 */
{ 4, 41, "sun(type5tuv)", KBD_PORTUGUESE }, /* Portugal5 */
{ 4, 42, "sun(type5tuv)", KBD_SPANISH }, /* Spain5 */
{ 4, 43, "sun(type5tuv)", KBD_SWEDISH }, /* Sweden5 */
{ 4, 44, "sun(type5tuv)", KBD_SWISS_FRENCH }, /* Switzer_Fr5 */
{ 4, 45, "sun(type5tuv)", KBD_SWISS_GERMAN }, /* Switzer_Ge5 */
{ 4, 46, "sun(type5tuv)", KBD_UNITED_KINGDOM }, /* UK5 */
{ 4, 47, "sun(type5)", KBD_KOREAN_INPUT_SYSTEM_IME_2000 }, /* Korea5 */
{ 4, 48, "sun(type5)", KBD_CHINESE_TRADITIONAL_PHONETIC }, /* Taiwan5 */
{ 4, 49, "sun(type5jp)", KBD_JAPANESE_INPUT_SYSTEM_MS_IME2002 }, /* Japan5 */
{ 4, 50, "sun(type5tuv)", KBD_CANADIAN_FRENCH }, /* Canada_Fr5 */
{ 4, 51, "sun(type5tuv)", KBD_HUNGARIAN }, /* Hungary5 */
{ 4, 52, "sun(type5tuv)", KBD_POLISH_214 }, /* Poland5 */
{ 4, 53, "sun(type5tuv)", KBD_CZECH }, /* Czech5 */
{ 4, 54, "sun(type5tuv)", KBD_RUSSIAN }, /* Russia5 */
{ 4, 55, "sun(type5tuv)", KBD_LATVIAN }, /* Latvia5 */
{ 4, 57, "sun(type5tuv)", KBD_GREEK }, /* Greece5 */
{ 4, 59, "sun(type5tuv)", KBD_LITHUANIAN }, /* Lithuania5 */
{ 4, 63, "sun(type5tuv)", KBD_CANADIAN_FRENCH }, /* Canada_Fr5_TBITS5 */
{ 4, 56, "sun(type5tuv)", KBD_TURKISH_Q }, /* TurkeyQ5 */
{ 4, 58, "sun(type5tuv)", KBD_ARABIC_101 }, /* Arabic5 */
{ 4, 60, "sun(type5tuv)", KBD_BELGIAN_FRENCH }, /* Belgian5 */
{ 4, 62, "sun(type5tuv)", KBD_TURKISH_F }, /* TurkeyF5 */
{ 4, 80, "sun(type5hobo)", KBD_US }, /* US5_Hobo */
{ 4, 81, "sun(type5hobo)", KBD_US }, /* US_UNIX5_Hobo */
{ 4, 82, "sun(type5tuvhobo)", KBD_FRENCH }, /* France5_Hobo */
{ 4, 83, "sun(type5tuvhobo)", KBD_DANISH }, /* Denmark5_Hobo */
{ 4, 84, "sun(type5tuvhobo)", KBD_GERMAN }, /* Germany5_Hobo */
{ 4, 85, "sun(type5tuvhobo)", KBD_ITALIAN }, /* Italy5_Hobo */
{ 4, 86, "sun(type5tuvhobo)", KBD_DUTCH }, /* Netherland5_Hobo */
{ 4, 87, "sun(type5tuvhobo)", KBD_NORWEGIAN }, /* Norway5_Hobo */
{ 4, 88, "sun(type5tuvhobo)", KBD_PORTUGUESE }, /* Portugal5_Hobo */
{ 4, 89, "sun(type5tuvhobo)", KBD_SPANISH }, /* Spain5_Hobo */
{ 4, 90, "sun(type5tuvhobo)", KBD_SWEDISH }, /* Sweden5_Hobo */
{ 4, 91, "sun(type5tuvhobo)", KBD_SWISS_FRENCH }, /* Switzer_Fr5_Hobo */
{ 4, 92, "sun(type5tuvhobo)", KBD_SWISS_GERMAN }, /* Switzer_Ge5_Hobo */
{ 4, 93, "sun(type5tuvhobo)", KBD_UNITED_KINGDOM }, /* UK5_Hobo */
{ 4, 94, "sun(type5hobo)", KBD_KOREAN_INPUT_SYSTEM_IME_2000 }, /* Korea5_Hobo */
{ 4, 95, "sun(type5hobo)", KBD_CHINESE_TRADITIONAL_PHONETIC }, /* Taiwan5_Hobo */
{ 4, 96, "sun(type5jphobo)", KBD_JAPANESE_INPUT_SYSTEM_MS_IME2002 }, /* Japan5_Hobo */
{ 4, 97, "sun(type5tuvhobo)", KBD_CANADIAN_FRENCH }, /* Canada_Fr5_Hobo */
{ 101, 1, "digital_vndr/pc(pc104)", KBD_US }, /* US101A_x86 */
{ 101, 34, "digital_vndr/pc(pc104)", KBD_US }, /* J3100_x86 */
{ 101, 35, "digital_vndr/pc(pc104)", KBD_FRENCH }, /* France_x86 */
{ 101, 36, "digital_vndr/pc(pc104)", KBD_DANISH }, /* Denmark_x86 */
{ 101, 37, "digital_vndr/pc(pc104)", KBD_GERMAN }, /* Germany_x86 */
{ 101, 38, "digital_vndr/pc(pc104)", KBD_ITALIAN }, /* Italy_x86 */
{ 101, 39, "digital_vndr/pc(pc104)", KBD_DUTCH }, /* Netherland_x86 */
{ 101, 40, "digital_vndr/pc(pc104)", KBD_NORWEGIAN }, /* Norway_x86 */
{ 101, 41, "digital_vndr/pc(pc104)", KBD_PORTUGUESE }, /* Portugal_x86 */
{ 101, 42, "digital_vndr/pc(pc104)", KBD_SPANISH }, /* Spain_x86 */
{ 101, 43, "digital_vndr/pc(pc104)", KBD_SWEDISH }, /* Sweden_x86 */
{ 101, 44, "digital_vndr/pc(pc104)", KBD_SWISS_FRENCH }, /* Switzer_Fr_x86 */
{ 101, 45, "digital_vndr/pc(pc104)", KBD_SWISS_GERMAN }, /* Switzer_Ge_x86 */
{ 101, 46, "digital_vndr/pc(pc104)", KBD_UNITED_KINGDOM }, /* UK_x86 */
{ 101, 47, "digital_vndr/pc(pc104)", KBD_KOREAN_INPUT_SYSTEM_IME_2000 }, /* Korea_x86 */
{ 101, 48, "digital_vndr/pc(pc104)", KBD_CHINESE_TRADITIONAL_PHONETIC }, /* Taiwan_x86 */
{ 101, 49, "digital_vndr/pc(lk411jj)", KBD_JAPANESE_INPUT_SYSTEM_MS_IME2002 }, /* Japan_x86 */
{ 101, 50, "digital_vndr/pc(pc104)", KBD_CANADIAN_FRENCH }, /* Canada_Fr2_x86 */
{ 101, 51, "digital_vndr/pc(pc104)", KBD_HUNGARIAN }, /* Hungary_x86 */
{ 101, 52, "digital_vndr/pc(pc104)", KBD_POLISH_214 }, /* Poland_x86 */
{ 101, 53, "digital_vndr/pc(pc104)", KBD_CZECH }, /* Czech_x86 */
{ 101, 54, "digital_vndr/pc(pc104)", KBD_RUSSIAN }, /* Russia_x86 */
{ 101, 55, "digital_vndr/pc(pc104)", KBD_LATVIAN }, /* Latvia_x86 */
{ 101, 56, "digital_vndr/pc(pc104)", KBD_TURKISH_Q }, /* Turkey_x86 */
{ 101, 57, "digital_vndr/pc(pc104)", KBD_GREEK }, /* Greece_x86 */
{ 101, 59, "digital_vndr/pc(pc104)", KBD_LITHUANIAN }, /* Lithuania_x86 */
{ 101, 1001, "digital_vndr/pc(pc104)", KBD_US }, /* MS_US101A_x86 */
{ 6, 6, "sun(type6tuv)", KBD_DANISH }, /* Denmark6_usb */
{ 6, 7, "sun(type6tuv)", KBD_FINNISH }, /* Finnish6_usb */
{ 6, 8, "sun(type6tuv)", KBD_FRENCH }, /* France6_usb */
{ 6, 9, "sun(type6tuv)", KBD_GERMAN }, /* Germany6_usb */
{ 6, 14, "sun(type6tuv)", KBD_ITALIAN }, /* Italy6_usb */
{ 6, 15, "sun(type6jp)", KBD_JAPANESE_INPUT_SYSTEM_MS_IME2002 }, /* Japan7_usb */
{ 6, 16, "sun(type6)", KBD_KOREAN_INPUT_SYSTEM_IME_2000 }, /* Korea6_usb */
{ 6, 18, "sun(type6tuv)", KBD_DUTCH }, /* Netherland6_usb */
{ 6, 19, "sun(type6tuv)", KBD_NORWEGIAN }, /* Norway6_usb */
{ 6, 22, "sun(type6tuv)", KBD_PORTUGUESE }, /* Portugal6_usb */
{ 6, 23, "sun(type6tuv)", KBD_RUSSIAN }, /* Russia6_usb */
{ 6, 25, "sun(type6tuv)", KBD_SPANISH }, /* Spain6_usb */
{ 6, 26, "sun(type6tuv)", KBD_SWEDISH }, /* Sweden6_usb */
{ 6, 27, "sun(type6tuv)", KBD_SWISS_FRENCH }, /* Switzer_Fr6_usb */
{ 6, 28, "sun(type6tuv)", KBD_SWISS_GERMAN }, /* Switzer_Ge6_usb */
{ 6, 30, "sun(type6)", KBD_CHINESE_TRADITIONAL_PHONETIC }, /* Taiwan6_usb */
{ 6, 32, "sun(type6tuv)", KBD_UNITED_KINGDOM }, /* UK6_usb */
{ 6, 33, "sun(type6)", KBD_US }, /* US6_usb */
{ 6, 1, "sun(type6tuv)", KBD_ARABIC_101 }, /* Arabic6_usb */
{ 6, 2, "sun(type6tuv)", KBD_BELGIAN_FRENCH }, /* Belgian6_usb */
{ 6, 31, "sun(type6tuv)", KBD_TURKISH_Q }, /* TurkeyQ6_usb */
{ 6, 35, "sun(type6tuv)", KBD_TURKISH_F }, /* TurkeyF6_usb */
{ 6, 271, "sun(type6jp)", KBD_JAPANESE_INPUT_SYSTEM_MS_IME2002 }, /* Japan6_usb */
{ 6, 264, "sun(type6tuv)", KBD_ALBANIAN }, /* Albanian6_usb */
{ 6, 261, "sun(type6tuv)", KBD_BELARUSIAN }, /* Belarusian6_usb */
{ 6, 260, "sun(type6tuv)", KBD_BULGARIAN }, /* Bulgarian6_usb */
{ 6, 259, "sun(type6tuv)", KBD_CROATIAN }, /* Croatian6_usb */
{ 6, 5, "sun(type6tuv)", KBD_CZECH }, /* Czech6_usb */
{ 6, 4, "sun(type6tuv)", KBD_CANADIAN_FRENCH }, /* French-Canadian6_usb */
{ 6, 12, "sun(type6tuv)", KBD_HUNGARIAN }, /* Hungarian6_usb */
{ 6, 10, "sun(type6tuv)", KBD_GREEK }, /* Greek6_usb */
{ 6, 17, "sun(type6)", KBD_LATIN_AMERICAN }, /* Latin-American6_usb */
{ 6, 265, "sun(type6tuv)", KBD_LITHUANIAN }, /* Lithuanian6_usb */
{ 6, 266, "sun(type6tuv)", KBD_LATVIAN }, /* Latvian6_usb */
{ 6, 267, "sun(type6tuv)", KBD_FYRO_MACEDONIAN }, /* Macedonian6_usb */
{ 6, 263, "sun(type6tuv)", KBD_MALTESE_47_KEY }, /* Malta_UK6_usb */
{ 6, 262, "sun(type6tuv)", KBD_MALTESE_48_KEY }, /* Malta_US6_usb */
{ 6, 21, "sun(type6tuv)", KBD_POLISH_214 }, /* Polish6_usb */
{ 6, 257, "sun(type6tuv)", KBD_SERBIAN_LATIN }, /* Serbia-And-Montenegro6_usb */
{ 6, 256, "sun(type6tuv)", KBD_SLOVENIAN }, /* Slovenian6_usb */
{ 6, 24, "sun(type6tuv)", KBD_SLOVAK }, /* Slovakian6_usb */
{ 6, 3, "sun(type6)", KBD_CANADIAN_MULTILINGUAL_STANDARD }, /* Canada_Bi6_usb */
{ 6, 272, "sun(type6)", KBD_PORTUGUESE_BRAZILIAN_ABNT } /* Brazil6_usb */
};
uint32 find_keyboard_layout_in_xorg_rules(char* layout, char* variant)
{
int i, j;
@ -1087,70 +918,3 @@ uint32 find_keyboard_layout_in_xorg_rules(char* layout, char* variant)
return 0;
}
#ifdef sun
uint32 detect_keyboard_type_and_layout_sunos(char* xkbfile, int length)
{
FILE* kbd;
int i;
int type = 0;
int layout = 0;
char* pch;
char* beg;
char* end;
char buffer[1024];
/*
Sample output for "kbd -t -l" :
USB keyboard
type=6
layout=3 (0x03)
delay(ms)=500
rate(ms)=40
*/
kbd = popen("kbd -t -l", "r");
if (kbd < 0)
return 0;
while (fgets(buffer, sizeof(buffer), kbd) != NULL)
{
if ((pch = strstr(buffer, "type=")) != NULL)
{
beg = pch + sizeof("type=") - 1;
end = strchr(beg, '\n');
end[0] = '\0';
type = atoi(beg);
}
else if ((pch = strstr(buffer, "layout=")) != NULL)
{
beg = pch + sizeof("layout=") - 1;
end = strchr(beg, ' ');
end[0] = '\0';
layout = atoi(beg);
}
}
pclose(kbd);
for (i = 0; i < sizeof(SunOSKeyboards) / sizeof(SunOSKeyboard); i++)
{
if (SunOSKeyboards[i].type == type)
{
if (SunOSKeyboards[i].layout == layout)
{
strncpy(xkbfile, SunOSKeyboards[i].xkbType, length);
return SunOSKeyboards[i].keyboardLayoutID;
}
}
}
return 0;
}
#endif