Hello I modified the layout file (us_qwerty.c) and create a new layout to support Arabic keyboard in HelenOS. It seems to work fine with me. I attached the patch file and the layout file ar.c (which is based on us_qwerty.c).
Sorry for any errors or mistakes it's my first time to sumbit a patch for HelenOS. Sorry for my English also :-) Regards, Mohammed Q. Hussain.
/*
* Copyright (c) 2011 Jiri Svoboda
* Copyright (c) 2012 Mohammed Q. Hussain (For Arabic Keyboard)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/** @addtogroup input
* @brief Arabic keyboard layout (Based on US QWERTY layout's code).
* @{
*/
#include <errno.h>
#include <io/console.h>
#include <io/keycode.h>
#include "../layout.h"
#include "../kbd.h"
static int ar_create(layout_t *);
static void ar_destroy(layout_t *);
static wchar_t ar_parse_ev(layout_t *, kbd_event_t *ev);
layout_ops_t ar_ops = {
.create = ar_create,
.destroy = ar_destroy,
.parse_ev = ar_parse_ev
};
static wchar_t map_lcase[] = {
[KC_Q] = L'ض',
[KC_W] = L'ص',
[KC_E] = L'Ø«',
[KC_R] = L'Ù',
[KC_T] = L'Ù',
[KC_Y] = L'غ',
[KC_U] = L'ع',
[KC_I] = L'Ù',
[KC_O] = L'Ø®',
[KC_P] = L'Ø',
[KC_A] = L'Ø´',
[KC_S] = L'س',
[KC_D] = L'Ù',
[KC_F] = L'ب',
[KC_G] = L'Ù',
[KC_H] = L'ا',
[KC_J] = L'ت',
[KC_K] = L'Ù',
[KC_L] = L'Ù
',
[KC_Z] = L'ئ',
[KC_X] = L'Ø¡',
[KC_C] = L'ؤ',
[KC_V] = L'ر',
[KC_B] = L'ï»»',
[KC_N] = L'Ù',
[KC_M] = L'Ø©',
};
static wchar_t map_ucase[] = {
[KC_Q] = L'Ù',
[KC_W] = L'Ù',
[KC_E] = L'Ù',
[KC_R] = L'Ù',
[KC_T] = L'ﻹ',
[KC_Y] = L'Ø¥',
[KC_U] = L'`',
[KC_I] = L'÷',
[KC_O] = L'Ã',
[KC_P] = L'Ø',
[KC_A] = L'Ù',
[KC_S] = L'Ù',
[KC_D] = L']',
[KC_F] = L'[',
[KC_G] = L'ï»·',
[KC_H] = L'Ø£',
[KC_J] = L'Ù',
[KC_K] = L'Ø',
[KC_L] = L'/',
[KC_Z] = L'~',
[KC_X] = L'Ù',
[KC_C] = L'}',
[KC_V] = L'{',
[KC_B] = L'ﻵ',
[KC_N] = L'Ø¢',
[KC_M] = L'\'',
};
static wchar_t map_not_shifted[] = {
[KC_BACKTICK] = L'ذ',
[KC_1] = '1',
[KC_2] = '2',
[KC_3] = '3',
[KC_4] = '4',
[KC_5] = '5',
[KC_6] = '6',
[KC_7] = '7',
[KC_8] = '8',
[KC_9] = '9',
[KC_0] = '0',
[KC_MINUS] = '-',
[KC_EQUALS] = '=',
[KC_LBRACKET] = L'ج',
[KC_RBRACKET] = L'د',
[KC_SEMICOLON] = L'Ù',
[KC_QUOTE] = L'Ø·',
[KC_BACKSLASH] = '\\',
[KC_COMMA] = L'Ù',
[KC_PERIOD] = L'ز',
[KC_SLASH] = L'ظ',
};
static wchar_t map_shifted[] = {
[KC_BACKTICK] = L'Ù',
[KC_1] = '!',
[KC_2] = '@',
[KC_3] = '#',
[KC_4] = '$',
[KC_5] = '%',
[KC_6] = '^',
[KC_7] = '&',
[KC_8] = '*',
[KC_9] = ')',
[KC_0] = '(',
[KC_MINUS] = '_',
[KC_EQUALS] = '+',
[KC_LBRACKET] = '<',
[KC_RBRACKET] = '>',
[KC_SEMICOLON] = ':',
[KC_QUOTE] = '"',
[KC_BACKSLASH] = '|',
[KC_COMMA] = ',',
[KC_PERIOD] = '.',
[KC_SLASH] = L'Ø',
};
static wchar_t map_neutral[] = {
[KC_BACKSPACE] = '\b',
[KC_TAB] = '\t',
[KC_ENTER] = '\n',
[KC_SPACE] = ' ',
[KC_NSLASH] = '/',
[KC_NTIMES] = '*',
[KC_NMINUS] = '-',
[KC_NPLUS] = '+',
[KC_NENTER] = '\n'
};
static wchar_t map_numeric[] = {
[KC_N7] = '7',
[KC_N8] = '8',
[KC_N9] = '9',
[KC_N4] = '4',
[KC_N5] = '5',
[KC_N6] = '6',
[KC_N1] = '1',
[KC_N2] = '2',
[KC_N3] = '3',
[KC_N0] = '0',
[KC_NPERIOD] = '.'
};
static wchar_t translate(unsigned int key, wchar_t *map, size_t map_length)
{
if (key >= map_length)
return 0;
return map[key];
}
static int ar_create(layout_t *state)
{
return EOK;
}
static void ar_destroy(layout_t *state)
{
}
static wchar_t ar_parse_ev(layout_t *state, kbd_event_t *ev)
{
wchar_t c;
/* Produce no characters when Ctrl or Alt is pressed. */
if ((ev->mods & (KM_CTRL | KM_ALT)) != 0)
return 0;
c = translate(ev->key, map_neutral, sizeof(map_neutral) / sizeof(wchar_t));
if (c != 0)
return c;
if (((ev->mods & KM_SHIFT) != 0))
c = translate(ev->key, map_ucase, sizeof(map_ucase) / sizeof(wchar_t));
else
c = translate(ev->key, map_lcase, sizeof(map_lcase) / sizeof(wchar_t));
if (c != 0)
return c;
if ((ev->mods & KM_SHIFT) != 0)
c = translate(ev->key, map_shifted, sizeof(map_shifted) / sizeof(wchar_t));
else
c = translate(ev->key, map_not_shifted, sizeof(map_not_shifted) / sizeof(wchar_t));
if (c != 0)
return c;
if ((ev->mods & KM_NUM_LOCK) != 0)
c = translate(ev->key, map_numeric, sizeof(map_numeric) / sizeof(wchar_t));
else
c = 0;
return c;
}
/**
* @}
*/
ArabicKeyboard.patch
Description: Binary data
_______________________________________________ HelenOS-devel mailing list [email protected] http://lists.modry.cz/cgi-bin/listinfo/helenos-devel
