mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
Made it easier to add new keyboard layouts.
Added Danish keyboard layout (DK). svn path=/trunk/; revision=2616
This commit is contained in:
parent
0ce194ac1a
commit
59c5e836e1
6 changed files with 228 additions and 115 deletions
21
reactos/apps/utils/pice/makefile
Normal file
21
reactos/apps/utils/pice/makefile
Normal file
|
@ -0,0 +1,21 @@
|
|||
# $Id: makefile,v 1.1 2002/02/10 02:01:31 chorns Exp $
|
||||
|
||||
all:
|
||||
make -C loader
|
||||
make -C module
|
||||
|
||||
implib:
|
||||
make -C loader implib
|
||||
make -C module implib
|
||||
|
||||
clean:
|
||||
make -C loader clean
|
||||
make -C module clean
|
||||
|
||||
dist:
|
||||
make -C loader dist
|
||||
make -C module dist
|
||||
|
||||
install:
|
||||
make -C loader install
|
||||
make -C module install
|
|
@ -214,7 +214,7 @@ CMDTABLE CmdTable[]={
|
|||
{"pci",ShowPCI,"show PCI devices" ,COMMAND_HAS_PARAMS|COMMAND_HAS_SWITCHES,{PARAM_CAN_BE_DECIMAL,PARAM_CAN_BE_DECIMAL,0,0,0},"a",COMMAND_GROUP_INFO},
|
||||
{"next",NextInstr,"advance EIP to next instruction" ,0,{0,0,0,0,0},""},
|
||||
{"i3here",I3here,"catch INT 3s" ,COMMAND_HAS_PARAMS,{PARAM_CAN_BE_ONOFF,0,0,0,0},"",COMMAND_GROUP_FLOW},
|
||||
{"layout",SetKeyboardLayout,"sets keyboard layout" ,COMMAND_HAS_PARAMS,{PARAM_CAN_BE_DECIMAL,0,0,0,0},"",COMMAND_GROUP_FLOW},
|
||||
{"layout",SetKeyboardLayout,"sets keyboard layout" ,COMMAND_HAS_PARAMS,{PARAM_CAN_BE_ANY_STRING,0,0,0,0},"",COMMAND_GROUP_FLOW},
|
||||
{"syscall",ShowSysCallTable,"displays syscall (table)" ,COMMAND_HAS_PARAMS,{PARAM_CAN_BE_DECIMAL,0,0,0,0},"",COMMAND_GROUP_FLOW},
|
||||
{"altkey",SetAltKey,"set alternate break key" ,COMMAND_HAS_PARAMS,{PARAM_CAN_BE_LETTER,0,0,0,0},"",COMMAND_GROUP_FLOW},
|
||||
{"addr",ShowContext,"show/set address contexts" ,COMMAND_HAS_PARAMS,{PARAM_CAN_BE_PRNAME,0,0,0,0},"",COMMAND_GROUP_FLOW},
|
||||
|
@ -3124,26 +3124,22 @@ CommonShowPCIExit:
|
|||
//*************************************************************************
|
||||
COMMAND_PROTOTYPE(SetKeyboardLayout)
|
||||
{
|
||||
PKEYBOARD_LAYOUT layout;
|
||||
|
||||
ENTER_FUNC();
|
||||
|
||||
layout = GetKeyboardLayout();
|
||||
|
||||
switch(pArgs->Count)
|
||||
{
|
||||
case 0:
|
||||
PICE_sprintf(tempCmd,"current layout = %s\n",(ucKeyboardLayout == GERMANY)?"german":"american");
|
||||
PICE_sprintf(tempCmd,"current layout = %s\n", layout->name);
|
||||
Print(OUTPUT_WINDOW,tempCmd);
|
||||
break;
|
||||
case 1:
|
||||
if(pArgs->Value[0] < 2)
|
||||
{
|
||||
ucKeyboardLayout = pArgs->Value[0];
|
||||
PICE_sprintf(tempCmd,"current layout = %s\n",(ucKeyboardLayout == GERMANY)?"german":"american");
|
||||
Print(OUTPUT_WINDOW,tempCmd);
|
||||
}
|
||||
else
|
||||
{
|
||||
PICE_sprintf(tempCmd,"current layout = %s\n",(ucKeyboardLayout == GERMANY)?"german":"american");
|
||||
Print(OUTPUT_WINDOW,tempCmd);
|
||||
}
|
||||
layout = SetKeyboardLayoutByName((LPSTR)pArgs->Value[0]);
|
||||
PICE_sprintf(tempCmd,"current layout = %s\n", layout->name);
|
||||
Print(OUTPUT_WINDOW,tempCmd);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -66,8 +66,6 @@ BOOLEAN bStepInto = FALSE;
|
|||
|
||||
// key handling
|
||||
UCHAR ucConverted; // key converted from scancode to ANSI
|
||||
// keyboard layout
|
||||
UCHAR ucKeyboardLayout = USA;
|
||||
|
||||
volatile BOOLEAN bControl=FALSE; // TRUE when CTRL key was pressed
|
||||
volatile BOOLEAN bShift=FALSE; // TRUE when SHIFT key was pressed
|
||||
|
|
|
@ -88,8 +88,4 @@ extern volatile BOOLEAN bEnterNow;
|
|||
|
||||
void ShowStatusLine(void);
|
||||
|
||||
#define USA (0)
|
||||
#define GERMANY (1)
|
||||
extern UCHAR ucKeyboardLayout;
|
||||
|
||||
#define KEYBOARD_IRQ 1
|
||||
|
|
|
@ -46,16 +46,10 @@ char tempFlowChanges[256];
|
|||
|
||||
ULONG TwoPagesForPhysMem[2*_PAGE_SIZE];
|
||||
|
||||
// scancode to ASCII conversion
|
||||
typedef struct tagSCANTOASCII
|
||||
{
|
||||
UCHAR s,a;
|
||||
}SCANTOASCII;
|
||||
|
||||
// scancode to ASCII table
|
||||
SCANTOASCII ucScanToAscii_GER[]=
|
||||
SCANTOASCII ucScanToAscii_DE[]=
|
||||
{
|
||||
// german keyboard
|
||||
// German keyboard
|
||||
{16,'q'},{17,'w'},{18,'e'},{19,'r'},{20,'t'},
|
||||
{21,'z'},{22,'u'},{23,'i'},{24,'o'},{25,'p'},
|
||||
{30,'a'},{31,'s'},{32,'d'},{33,'f'},{34,'g'},
|
||||
|
@ -65,7 +59,26 @@ SCANTOASCII ucScanToAscii_GER[]=
|
|||
{2,'1'},{3,'2'},{4,'3'},{ 5,'4'},{ 6,'5'},
|
||||
{7,'6'},{8,'7'},{9,'8'},{10,'9'},{11,'0'},
|
||||
{12,'ß'}, // 239 = ß
|
||||
{0x39,' '},{0x35,'-'},{0x34,'.'},{0x1b,'+'}
|
||||
{0x39,' '},{0x35,'-'},{0x34,'.'},{0x1b,'+'},
|
||||
{0,0}
|
||||
};
|
||||
|
||||
SCANTOASCII ucShiftScanToAscii_DE[]=
|
||||
{
|
||||
// German keyboard SHIFTED
|
||||
{16,'Q'},{17,'W'},{18,'E'},{19,'R'},{20,'T'},
|
||||
{21,'Z'},{22,'U'},{23,'I'},{24,'O'},{25,'P'},
|
||||
{30,'A'},{31,'S'},{32,'D'},{33,'F'},{34,'G'},
|
||||
{35,'H'},{36,'J'},{37,'K'},{38,'L'},
|
||||
{44,'Y'},{45,'X'},{46,'C'},{47,'V'},{48,'B'},
|
||||
{49,'N'},{50,'M'},
|
||||
{2,'!'},{3,'\"'}, // " // (fixes mc syntax highlighting)
|
||||
{4,'@'}, // is pragraph sign on keyboard
|
||||
{ 5,'$'},{ 6,'%'},
|
||||
{7,'&'},{8,'/'},{9,'('},{10,')'},{11,'='},
|
||||
{12,'?'},
|
||||
{0x39,' '},{0x35,'_'},{0x34,':'},{0x1b,'*'},
|
||||
{0,0}
|
||||
};
|
||||
|
||||
SCANTOASCII ucScanToAscii_US[]=
|
||||
|
@ -82,24 +95,8 @@ SCANTOASCII ucScanToAscii_US[]=
|
|||
{8,'7'},{9,'8'},{10,'9'},{11,'0'},{12,'-'},
|
||||
{0x39,' '},{0x35,'/'},{0x34,'.'},{0x1b,']'},
|
||||
{0x1a,'['},{0x33,','},{0x27,';'},{0x0d,'='},
|
||||
{0x2b,'\\'},{0x28,'\''},{0x29,'`'}
|
||||
};
|
||||
|
||||
SCANTOASCII ucShiftScanToAscii_GER[]=
|
||||
{
|
||||
// german keyboard SHIFTED
|
||||
{16,'Q'},{17,'W'},{18,'E'},{19,'R'},{20,'T'},
|
||||
{21,'Z'},{22,'U'},{23,'I'},{24,'O'},{25,'P'},
|
||||
{30,'A'},{31,'S'},{32,'D'},{33,'F'},{34,'G'},
|
||||
{35,'H'},{36,'J'},{37,'K'},{38,'L'},
|
||||
{44,'Y'},{45,'X'},{46,'C'},{47,'V'},{48,'B'},
|
||||
{49,'N'},{50,'M'},
|
||||
{2,'!'},{3,'\"'}, // " // (fixes mc syntax highlighting)
|
||||
{4,'@'}, // is pragraph sign on keyboard
|
||||
{ 5,'$'},{ 6,'%'},
|
||||
{7,'&'},{8,'/'},{9,'('},{10,')'},{11,'='},
|
||||
{12,'?'},
|
||||
{0x39,' '},{0x35,'_'},{0x34,':'},{0x1b,'*'}
|
||||
{0x2b,'\\'},{0x28,'\''},{0x29,'`'},
|
||||
{0,0}
|
||||
};
|
||||
|
||||
SCANTOASCII ucShiftScanToAscii_US[]=
|
||||
|
@ -116,13 +113,113 @@ SCANTOASCII ucShiftScanToAscii_US[]=
|
|||
{8,'&'},{9,'*'},{10,'('},{11,')'},{12,'_'},
|
||||
{0x39,' '},{0x35,'?'},{0x34,'>'},{0x1b,'}'},
|
||||
{0x1a,'{'},{0x33,'<'},{0x27,':'},{0x0d,'+'},
|
||||
{0x2b,'|'},{0x28,'\"'},{0x29,'~'}
|
||||
{0x2b,'|'},{0x28,'\"'},{0x29,'~'},
|
||||
{0,0}
|
||||
};
|
||||
|
||||
SCANTOASCII ucScanToAscii_DK[]=
|
||||
{
|
||||
// Danish keyboard
|
||||
{16,'q'},{17,'w'},{18,'e'},{19,'r'},
|
||||
{20,'t'},{21,'y'},{22,'u'},{23,'i'},
|
||||
{24,'o'},{25,'p'},{30,'a'},{31,'s'},
|
||||
{32,'d'},{33,'f'},{34,'g'},{35,'h'},
|
||||
{36,'j'},{37,'k'},{38,'l'},{44,'z'},
|
||||
{45,'x'},{46,'c'},{47,'v'},{48,'b'},
|
||||
{49,'n'},{50,'m'},{2,'1'},{3,'2'},
|
||||
{4,'3'},{5,'4'},{6,'5'},{7,'6'},
|
||||
{8,'7'},{9,'8'},{10,'9'},{11,'0'},{12,'+'},
|
||||
{0x39,' '},{0x35,'_'},{0x34,'.'},{0x1b,'¨'},
|
||||
{0x1a,'ĺ'},{0x33,','},{0x27,'ć'},{0x0d,'´'},
|
||||
{0x2b,'\''},{0x28,'ř'},{0x29,' '},
|
||||
{0,0}
|
||||
};
|
||||
|
||||
SCANTOASCII ucShiftScanToAscii_DK[]=
|
||||
{
|
||||
// Danish keyboard SHIFTED
|
||||
{16,'Q'},{17,'W'},{18,'E'},{19,'R'},
|
||||
{20,'T'},{21,'Y'},{22,'U'},{23,'I'},
|
||||
{24,'O'},{25,'P'},{30,'A'},{31,'S'},
|
||||
{32,'D'},{33,'F'},{34,'G'},{35,'H'},
|
||||
{36,'J'},{37,'K'},{38,'L'},{44,'Z'},
|
||||
{45,'X'},{46,'C'},{47,'V'},{48,'B'},
|
||||
{49,'N'},{50,'M'},{2,'!'},{3,'"'},
|
||||
{4,'#'},{5,'¤'},{6,'%'},{7,'&'},
|
||||
{8,'/'},{9,'('},{10,')'},{11,'='},{12,'?'},
|
||||
{0x39,' '},{0x35,'_'},{0x34,':'},{0x1b,'^'},
|
||||
{0x1a,'Ĺ'},{0x33,';'},{0x27,'Ć'},{0x0d,'`'},
|
||||
{0x2b,'*'},{0x28,'Ř'},{0x29,'§'},
|
||||
{0,0}
|
||||
};
|
||||
|
||||
SCANTOASCII ucAltScanToAscii_DK[]=
|
||||
{
|
||||
// Danish keyboard ALTED
|
||||
{16,' '},{17,' '},{18,' '},{19,' '},
|
||||
{20,' '},{21,' '},{22,' '},{23,' '},
|
||||
{24,' '},{25,' '},{30,' '},{31,' '},
|
||||
{32,' '},{33,' '},{34,' '},{35,' '},
|
||||
{36,' '},{37,' '},{38,' '},{44,' '},
|
||||
{45,' '},{46,' '},{47,' '},{48,' '},
|
||||
{49,' '},{50,' '},{2,' '},{3,'@'},
|
||||
{4,'Ł'},{5,'$'},{6,'€'},{7,' '},
|
||||
{8,'{'},{9,'['},{10,']'},{11,'}'},{12,' '},
|
||||
{0x39,' '},{0x35,' '},{0x34,' '},{0x1b,'~'},
|
||||
{0x1a,' '},{0x33,' '},{0x27,' '},{0x0d,'|'},
|
||||
{0x2b,' '},{0x28,' '},{0x29,' '},
|
||||
{0,0}
|
||||
};
|
||||
|
||||
KEYBOARD_LAYOUT ucKeyboard[]=
|
||||
{
|
||||
{"de", ucScanToAscii_DE, ucShiftScanToAscii_DE, NULL},
|
||||
{"us", ucScanToAscii_US, ucShiftScanToAscii_US, NULL},
|
||||
{"dk", ucScanToAscii_DK, ucShiftScanToAscii_DK, ucAltScanToAscii_DK},
|
||||
{NULL, NULL, NULL, NULL}
|
||||
};
|
||||
|
||||
PKEYBOARD_LAYOUT CurrentKeyboard = NULL;
|
||||
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
// FUNCTIONS
|
||||
////
|
||||
|
||||
//*************************************************************************
|
||||
// GetKeyboardLayout()
|
||||
//
|
||||
//*************************************************************************
|
||||
PKEYBOARD_LAYOUT GetKeyboardLayout()
|
||||
{
|
||||
if (CurrentKeyboard == NULL)
|
||||
{
|
||||
CurrentKeyboard = &ucKeyboard[kbUS];
|
||||
}
|
||||
|
||||
return CurrentKeyboard;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
// SetKeyboardLayoutByName()
|
||||
//
|
||||
//*************************************************************************
|
||||
PKEYBOARD_LAYOUT SetKeyboardLayoutByName(LPSTR Name)
|
||||
{
|
||||
CHAR tempCmd[256];
|
||||
ULONG i;
|
||||
|
||||
for(i=0;ucKeyboard[i].name != NULL;i++)
|
||||
{
|
||||
if(PICE_strcmpi(ucKeyboard[i].name, Name) == 0)
|
||||
{
|
||||
CurrentKeyboard = &ucKeyboard[i];
|
||||
return CurrentKeyboard;
|
||||
}
|
||||
}
|
||||
return GetKeyboardLayout();
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
// PICE_memset()
|
||||
//
|
||||
|
@ -1982,60 +2079,37 @@ int PICE_sprintf(char * buf, const char *fmt, ...)
|
|||
//*************************************************************************
|
||||
UCHAR AsciiFromScan(UCHAR s)
|
||||
{
|
||||
PSCANTOASCII table;
|
||||
ULONG i;
|
||||
|
||||
ENTER_FUNC();
|
||||
|
||||
if(!bShift)
|
||||
if (bShift)
|
||||
{
|
||||
if(ucKeyboardLayout == GERMANY)
|
||||
{
|
||||
for(i=0;i<DIM(ucScanToAscii_GER);i++)
|
||||
{
|
||||
if(ucScanToAscii_GER[i].s==s)
|
||||
{
|
||||
LEAVE_FUNC();
|
||||
return ucScanToAscii_GER[i].a;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(i=0;i<DIM(ucScanToAscii_US);i++)
|
||||
{
|
||||
if(ucScanToAscii_US[i].s==s)
|
||||
{
|
||||
LEAVE_FUNC();
|
||||
return ucScanToAscii_US[i].a;
|
||||
}
|
||||
}
|
||||
}
|
||||
table = GetKeyboardLayout()->shifted;
|
||||
}
|
||||
else if(bAlt)
|
||||
{
|
||||
table = GetKeyboardLayout()->alted;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(ucKeyboardLayout == GERMANY)
|
||||
{
|
||||
for(i=0;i<DIM(ucShiftScanToAscii_GER);i++)
|
||||
{
|
||||
if(ucShiftScanToAscii_GER[i].s==s)
|
||||
{
|
||||
LEAVE_FUNC();
|
||||
return ucShiftScanToAscii_GER[i].a;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(i=0;i<DIM(ucShiftScanToAscii_US);i++)
|
||||
{
|
||||
if(ucShiftScanToAscii_US[i].s==s)
|
||||
{
|
||||
LEAVE_FUNC();
|
||||
return ucShiftScanToAscii_US[i].a;
|
||||
}
|
||||
}
|
||||
}
|
||||
table = GetKeyboardLayout()->normal;
|
||||
}
|
||||
|
||||
|
||||
if (table)
|
||||
{
|
||||
for(i=0;table[i].s != 0;i++)
|
||||
{
|
||||
if(table[i].s==s)
|
||||
{
|
||||
LEAVE_FUNC();
|
||||
return table[i].a;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DPRINT((0,"AsciiFromScan(): no translation for key\n"));
|
||||
LEAVE_FUNC();
|
||||
return 0;
|
||||
|
@ -2049,35 +2123,38 @@ UCHAR AsciiFromScan(UCHAR s)
|
|||
//*************************************************************************
|
||||
UCHAR AsciiToScan(UCHAR s)
|
||||
{
|
||||
ULONG i;
|
||||
PSCANTOASCII table;
|
||||
ULONG i;
|
||||
|
||||
ENTER_FUNC();
|
||||
ENTER_FUNC();
|
||||
|
||||
if(ucKeyboardLayout == GERMANY)
|
||||
if (bShift)
|
||||
{
|
||||
for(i=0;i<DIM(ucShiftScanToAscii_GER);i++)
|
||||
{
|
||||
if(ucShiftScanToAscii_GER[i].a==s)
|
||||
{
|
||||
LEAVE_FUNC();
|
||||
return ucShiftScanToAscii_GER[i].s;
|
||||
}
|
||||
}
|
||||
table = GetKeyboardLayout()->shifted;
|
||||
}
|
||||
else
|
||||
else if(bAlt)
|
||||
{
|
||||
for(i=0;i<DIM(ucShiftScanToAscii_US);i++)
|
||||
{
|
||||
if(ucShiftScanToAscii_GER[i].a==s)
|
||||
{
|
||||
LEAVE_FUNC();
|
||||
return ucShiftScanToAscii_GER[i].s;
|
||||
}
|
||||
}
|
||||
table = GetKeyboardLayout()->alted;
|
||||
}
|
||||
else
|
||||
{
|
||||
table = GetKeyboardLayout()->normal;
|
||||
}
|
||||
|
||||
DPRINT((0,"AsciiToScan(): no translation for ASCII code\n"));
|
||||
LEAVE_FUNC();
|
||||
if (table)
|
||||
{
|
||||
for(i=0;table[i].s != 0;i++)
|
||||
{
|
||||
if(table[i].a==s)
|
||||
{
|
||||
LEAVE_FUNC();
|
||||
return table[i].s;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DPRINT((0,"AsciiToScan(): no translation for ASCII code\n"));
|
||||
LEAVE_FUNC();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,30 @@ Copyright notice:
|
|||
#define __STR(x) #x
|
||||
#define STR(x) __STR(x)
|
||||
|
||||
typedef enum {
|
||||
kbDE,
|
||||
kbUS,
|
||||
kbDK,
|
||||
kbMaximum
|
||||
} KeyboardLayout;
|
||||
|
||||
// scancode to ASCII conversion
|
||||
typedef struct tagSCANTOASCII
|
||||
{
|
||||
UCHAR s; // 0 terminates the table
|
||||
UCHAR a;
|
||||
}SCANTOASCII, *PSCANTOASCII;
|
||||
|
||||
typedef struct tagKEYBOARD_LAYOUT
|
||||
{
|
||||
LPSTR name;
|
||||
PSCANTOASCII normal;
|
||||
PSCANTOASCII shifted;
|
||||
PSCANTOASCII alted;
|
||||
} KEYBOARD_LAYOUT, *PKEYBOARD_LAYOUT;
|
||||
|
||||
extern PKEYBOARD_LAYOUT CurrentKeyboard;
|
||||
|
||||
typedef struct _FRAME
|
||||
{
|
||||
ULONG error_code;
|
||||
|
@ -168,7 +192,8 @@ typedef struct tagDESCRIPTOR
|
|||
USHORT Val :13; // index into table
|
||||
}DESCRIPTOR,*PDESCRIPTOR;
|
||||
|
||||
|
||||
PKEYBOARD_LAYOUT GetKeyboardLayout();
|
||||
PKEYBOARD_LAYOUT SetKeyboardLayoutByName(LPSTR Name);
|
||||
void PICE_memset(void* p,unsigned char c,int sz);
|
||||
void PICE_memcpy(void* t,void* s,int sz);
|
||||
char *PICE_strrev(char *);
|
||||
|
|
Loading…
Reference in a new issue