mirror of
https://github.com/reactos/reactos.git
synced 2025-07-31 09:11:42 +00:00
Fixed some compiler warnings.
svn path=/trunk/; revision=515
This commit is contained in:
parent
5f710be5ef
commit
b887962d1d
1 changed files with 31 additions and 29 deletions
|
@ -346,6 +346,7 @@ static BYTE VirtualToAscii(WORD keyCode,BOOL isDown)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((keyCode>=VK_A)&&(keyCode<=VK_Z))
|
if ((keyCode>=VK_A)&&(keyCode<=VK_Z))
|
||||||
|
{
|
||||||
if (ctrlKeyState & CAPSLOCK_ON)
|
if (ctrlKeyState & CAPSLOCK_ON)
|
||||||
if (ctrlKeyState & SHIFT_PRESSED)
|
if (ctrlKeyState & SHIFT_PRESSED)
|
||||||
return keyCode-VK_A+'a';
|
return keyCode-VK_A+'a';
|
||||||
|
@ -356,21 +357,26 @@ static BYTE VirtualToAscii(WORD keyCode,BOOL isDown)
|
||||||
return keyCode-VK_A+'A';
|
return keyCode-VK_A+'A';
|
||||||
else
|
else
|
||||||
return keyCode-VK_A+'a';
|
return keyCode-VK_A+'a';
|
||||||
|
}
|
||||||
|
|
||||||
if ((keyCode>=VK_0)&&(keyCode<=VK_9))
|
if ((keyCode>=VK_0)&&(keyCode<=VK_9))
|
||||||
|
{
|
||||||
if (ctrlKeyState & SHIFT_PRESSED)
|
if (ctrlKeyState & SHIFT_PRESSED)
|
||||||
return asciiTable1[keyCode-VK_0];
|
return asciiTable1[keyCode-VK_0];
|
||||||
else
|
else
|
||||||
return keyCode-VK_0+'0';
|
return keyCode-VK_0+'0';
|
||||||
|
}
|
||||||
|
|
||||||
if ((keyCode>=VK_NUMPAD0)&&(keyCode<=VK_DIVIDE))
|
if ((keyCode>=VK_NUMPAD0)&&(keyCode<=VK_DIVIDE))
|
||||||
return asciiTable2[keyCode-VK_NUMPAD0];
|
return asciiTable2[keyCode-VK_NUMPAD0];
|
||||||
|
|
||||||
if ((keyCode>=186)&&(keyCode<=222))
|
if ((keyCode>=186)&&(keyCode<=222))
|
||||||
|
{
|
||||||
if (ctrlKeyState & SHIFT_PRESSED)
|
if (ctrlKeyState & SHIFT_PRESSED)
|
||||||
return asciiTable4[keyCode-186];
|
return asciiTable4[keyCode-186];
|
||||||
else
|
else
|
||||||
return asciiTable3[keyCode-186];
|
return asciiTable3[keyCode-186];
|
||||||
|
}
|
||||||
|
|
||||||
switch(keyCode)
|
switch(keyCode)
|
||||||
{
|
{
|
||||||
|
@ -425,21 +431,21 @@ static VOID KbdDpcRoutine(PKDPC Dpc,
|
||||||
IoStartNextPacket(DeviceObject,FALSE);
|
IoStartNextPacket(DeviceObject,FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned int KeyboardHandler(unsigned int irq)
|
static BOOLEAN KeyboardHandler(PKINTERRUPT Interrupt, PVOID Context)
|
||||||
{
|
{
|
||||||
BYTE resp,thisKey;
|
BYTE thisKey;
|
||||||
BOOL isDown;
|
BOOL isDown;
|
||||||
static BYTE lastKey;
|
static BYTE lastKey;
|
||||||
|
|
||||||
CHECKPOINT;
|
CHECKPOINT;
|
||||||
|
|
||||||
// Read scan code
|
// Read scan code
|
||||||
thisKey=inb_p(KBD_DATA_PORT);
|
thisKey=inb_p(KBD_DATA_PORT);
|
||||||
if ((thisKey==0xE0)||(thisKey==0xE1)) // Extended key
|
if ((thisKey==0xE0)||(thisKey==0xE1)) // Extended key
|
||||||
{
|
{
|
||||||
extKey=1; // Wait for next byte
|
extKey=1; // Wait for next byte
|
||||||
lastKey=thisKey;
|
lastKey=thisKey;
|
||||||
return 0;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
isDown=!(thisKey & 0x80);
|
isDown=!(thisKey & 0x80);
|
||||||
|
@ -455,7 +461,7 @@ static unsigned int KeyboardHandler(unsigned int irq)
|
||||||
if (extKey & ((thisKey==0x2A)||(thisKey==0x36)))
|
if (extKey & ((thisKey==0x2A)||(thisKey==0x36)))
|
||||||
{
|
{
|
||||||
extKey=0;
|
extKey=0;
|
||||||
return 0;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for PAUSE sequence
|
// Check for PAUSE sequence
|
||||||
|
@ -465,27 +471,27 @@ static unsigned int KeyboardHandler(unsigned int irq)
|
||||||
lastKey=0xFF; // Sequence is OK
|
lastKey=0xFF; // Sequence is OK
|
||||||
else
|
else
|
||||||
extKey=0;
|
extKey=0;
|
||||||
return 0;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (extKey && (lastKey==0xFF))
|
if (extKey && (lastKey==0xFF))
|
||||||
{
|
{
|
||||||
if (thisKey!=0x45)
|
if (thisKey!=0x45)
|
||||||
{
|
{
|
||||||
extKey=0; // Bad sequence
|
extKey=0; // Bad sequence
|
||||||
return 0;
|
return FALSE;
|
||||||
}
|
}
|
||||||
thisKey=0x7F; // Pseudo-code for PAUSE
|
thisKey=0x7F; // Pseudo-code for PAUSE
|
||||||
}
|
}
|
||||||
|
|
||||||
ProcessScanCode(thisKey,isDown);
|
ProcessScanCode(thisKey,isDown);
|
||||||
|
|
||||||
// DbgPrint("Key: %c\n",VirtualToAscii(ScanToVirtual(thisKey),isDown));
|
// DbgPrint("Key: %c\n",VirtualToAscii(ScanToVirtual(thisKey),isDown));
|
||||||
// DbgPrint("Key: %x\n",ScanToVirtual(thisKey));
|
// DbgPrint("Key: %x\n",ScanToVirtual(thisKey));
|
||||||
if (ScanToVirtual(thisKey)==0x2a)
|
if (ScanToVirtual(thisKey)==0x2a)
|
||||||
{
|
{
|
||||||
KeBugCheck(0);
|
KeBugCheck(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CurrentIrp!=NULL)
|
if (CurrentIrp!=NULL)
|
||||||
{
|
{
|
||||||
KEY_EVENT_RECORD* rec = (KEY_EVENT_RECORD *)
|
KEY_EVENT_RECORD* rec = (KEY_EVENT_RECORD *)
|
||||||
|
@ -512,14 +518,14 @@ static unsigned int KeyboardHandler(unsigned int irq)
|
||||||
CurrentIrp=NULL;
|
CurrentIrp=NULL;
|
||||||
}
|
}
|
||||||
CHECKPOINT;
|
CHECKPOINT;
|
||||||
return(TRUE);
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Buffer is full ?
|
// Buffer is full ?
|
||||||
if (keysInBuffer==KBD_BUFFER_SIZE) // Buffer is full
|
if (keysInBuffer==KBD_BUFFER_SIZE) // Buffer is full
|
||||||
{
|
{
|
||||||
extKey=0;
|
extKey=0;
|
||||||
return 0;
|
return FALSE;
|
||||||
}
|
}
|
||||||
kbdBuffer[bufHead].bKeyDown=isDown;
|
kbdBuffer[bufHead].bKeyDown=isDown;
|
||||||
kbdBuffer[bufHead].wRepeatCount=1;
|
kbdBuffer[bufHead].wRepeatCount=1;
|
||||||
|
@ -535,6 +541,8 @@ static unsigned int KeyboardHandler(unsigned int irq)
|
||||||
bufHead&=KBD_WRAP_MASK; // Modulo KBD_BUFFER_SIZE
|
bufHead&=KBD_WRAP_MASK; // Modulo KBD_BUFFER_SIZE
|
||||||
keysInBuffer++;
|
keysInBuffer++;
|
||||||
extKey=0;
|
extKey=0;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -590,10 +598,6 @@ static int InitializeKeyboard(void)
|
||||||
* Read data from keyboard buffer
|
* Read data from keyboard buffer
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void dummy(void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOLEAN KbdSynchronizeRoutine(PVOID Context)
|
BOOLEAN KbdSynchronizeRoutine(PVOID Context)
|
||||||
{
|
{
|
||||||
PIRP Irp = (PIRP)Context;
|
PIRP Irp = (PIRP)Context;
|
||||||
|
@ -605,7 +609,7 @@ BOOLEAN KbdSynchronizeRoutine(PVOID Context)
|
||||||
|
|
||||||
DPRINT("NrToRead %d keysInBuffer %d\n",NrToRead,keysInBuffer);
|
DPRINT("NrToRead %d keysInBuffer %d\n",NrToRead,keysInBuffer);
|
||||||
NrToRead = min(NrToRead,keysInBuffer);
|
NrToRead = min(NrToRead,keysInBuffer);
|
||||||
|
|
||||||
DPRINT("NrToRead %d stk->Parameters.Read.Length %d\n",
|
DPRINT("NrToRead %d stk->Parameters.Read.Length %d\n",
|
||||||
NrToRead,stk->Parameters.Read.Length);
|
NrToRead,stk->Parameters.Read.Length);
|
||||||
DPRINT("sizeof(KEY_EVENT_RECORD) %d\n",sizeof(KEY_EVENT_RECORD));
|
DPRINT("sizeof(KEY_EVENT_RECORD) %d\n",sizeof(KEY_EVENT_RECORD));
|
||||||
|
@ -620,11 +624,11 @@ BOOLEAN KbdSynchronizeRoutine(PVOID Context)
|
||||||
{
|
{
|
||||||
return(TRUE);
|
return(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
KeysRequired=stk->Parameters.Read.Length/sizeof(KEY_EVENT_RECORD);
|
KeysRequired=stk->Parameters.Read.Length/sizeof(KEY_EVENT_RECORD);
|
||||||
KeysRead=NrToRead;
|
KeysRead=NrToRead;
|
||||||
CurrentIrp=Irp;
|
CurrentIrp=Irp;
|
||||||
|
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -652,7 +656,7 @@ NTSTATUS KbdDispatch(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||||
case IRP_MJ_CLOSE:
|
case IRP_MJ_CLOSE:
|
||||||
Status = STATUS_SUCCESS;
|
Status = STATUS_SUCCESS;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IRP_MJ_READ:
|
case IRP_MJ_READ:
|
||||||
DPRINT("Handling Read request\n");
|
DPRINT("Handling Read request\n");
|
||||||
if (KeSynchronizeExecution(KbdInterrupt,KbdSynchronizeRoutine,Irp))
|
if (KeSynchronizeExecution(KbdInterrupt,KbdSynchronizeRoutine,Irp))
|
||||||
|
@ -666,12 +670,12 @@ NTSTATUS KbdDispatch(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||||
Status = STATUS_PENDING;
|
Status = STATUS_PENDING;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Status = STATUS_NOT_IMPLEMENTED;
|
Status = STATUS_NOT_IMPLEMENTED;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Status==STATUS_PENDING)
|
if (Status==STATUS_PENDING)
|
||||||
{
|
{
|
||||||
DPRINT("Marking irp pending\n");
|
DPRINT("Marking irp pending\n");
|
||||||
|
@ -698,26 +702,24 @@ DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
|
||||||
UNICODE_STRING device_name;
|
UNICODE_STRING device_name;
|
||||||
ANSI_STRING asymlink_name;
|
ANSI_STRING asymlink_name;
|
||||||
UNICODE_STRING symlink_name;
|
UNICODE_STRING symlink_name;
|
||||||
|
|
||||||
DbgPrint("Keyboard Driver 0.0.4\n");
|
DbgPrint("Keyboard Driver 0.0.4\n");
|
||||||
InitializeKeyboard();
|
InitializeKeyboard();
|
||||||
|
|
||||||
DriverObject->MajorFunction[IRP_MJ_CREATE] = KbdDispatch;
|
DriverObject->MajorFunction[IRP_MJ_CREATE] = KbdDispatch;
|
||||||
DriverObject->MajorFunction[IRP_MJ_CLOSE] = KbdDispatch;
|
DriverObject->MajorFunction[IRP_MJ_CLOSE] = KbdDispatch;
|
||||||
DriverObject->MajorFunction[IRP_MJ_READ] = KbdDispatch;
|
DriverObject->MajorFunction[IRP_MJ_READ] = KbdDispatch;
|
||||||
DriverObject->DriverStartIo = KbdStartIo;
|
DriverObject->DriverStartIo = KbdStartIo;
|
||||||
|
|
||||||
RtlInitAnsiString(&adevice_name,"\\Device\\Keyboard");
|
RtlInitAnsiString(&adevice_name,"\\Device\\Keyboard");
|
||||||
RtlAnsiStringToUnicodeString(&device_name,&adevice_name,TRUE);
|
RtlAnsiStringToUnicodeString(&device_name,&adevice_name,TRUE);
|
||||||
IoCreateDevice(DriverObject,0,&device_name,FILE_DEVICE_KEYBOARD,0,
|
IoCreateDevice(DriverObject,0,&device_name,FILE_DEVICE_KEYBOARD,0,
|
||||||
TRUE,&DeviceObject);
|
TRUE,&DeviceObject);
|
||||||
DeviceObject->Flags = DO_BUFFERED_IO;
|
DeviceObject->Flags = DO_BUFFERED_IO;
|
||||||
|
|
||||||
RtlInitAnsiString(&asymlink_name,"\\??\\Keyboard");
|
RtlInitAnsiString(&asymlink_name,"\\??\\Keyboard");
|
||||||
RtlAnsiStringToUnicodeString(&symlink_name,&asymlink_name,TRUE);
|
RtlAnsiStringToUnicodeString(&symlink_name,&asymlink_name,TRUE);
|
||||||
IoCreateSymbolicLink(&symlink_name,&device_name);
|
IoCreateSymbolicLink(&symlink_name,&device_name);
|
||||||
|
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue