Thu Aug 4 07:18:02 1994 Michael Patra <micky@marie.physik.tu-berlin.de> * [windows/message.c] Implemented WaitMessage() (USER.112). * [if1632/user.spec] Added WaitMessage. * [windows/defwnd.c] WM_ERASEBKGND: Added support for hbrBackground=COLOR_xxx. * [miscemu/int{13,21,2a}.c] * [miscemu/Imakefile] * [signal/loader.c] Added a few basic disk information and diagnostic functions to prevent programs using this function from crashing. All drives are claimed to be remote ones, so direct I/O isn't allowed. * [controls/edit.c] EDIT_WriteText(): Added code to correctly erase the remaining space of the edit-control if the size of the control has changed sinced it's creation. Tue Jul 26 22:05:54 MET DST 1994 Erik Bos <erik@hacktic.nl> * [if1632/mouse.spec] Added mouse.dll entry, no functions. * [loader/resource.c] Bug fix in AccessResource(). * [misc/keyboard.c], added [include/keyboard.h] Changed functions to return more useful values. * [windows/dialog.c] Hacked DIALOG_GetControl() to support resources which have 0xff00 - 0xffff as id. ** Needs to be done properly by someone who knows the NE fileformat ** Jul 29, 94 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte) * [windows/event.c] Add new stub for EnableHGardwareInput() function. * [windows/message.c] Add coding for HWND_BROADCAST in PostMessage(). * [misc/file.c] Add coding for OpenFile() also search in WindowPaths. * [misc/mmsystem.c] * [misc/audio.c] * [misc/mmaux.c] * [misc/mcicda.c] Change #include "linux/soundcard.h" by #include "sys/soundcard.h" Add coding in MMIO functions. Now, mmioDescend() can find WAV chunks. SndPlaySound & MCI_ELEMENT now use MMIO and adjust to proper formats.
128 lines
2.7 KiB
C
128 lines
2.7 KiB
C
static char RCSId[] = "$Id: keyboard.c,v 1.2 1993/09/13 18:52:02 scott Exp $";
|
|
static char Copyright[] = "Copyright Scott A. Laird, Erik Bos 1993, 1994";
|
|
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include "prototypes.h"
|
|
#include "windows.h"
|
|
#include "keyboard.h"
|
|
|
|
int ToAscii(WORD wVirtKey, WORD wScanCode, LPSTR lpKeyState,
|
|
LPVOID lpChar, WORD wFlags)
|
|
{
|
|
int i;
|
|
|
|
printf("ToAscii (%d,%d)\n",wVirtKey, wScanCode);
|
|
|
|
/* FIXME: this is not sufficient but better than returing -1 */
|
|
|
|
for (i = 0 ; i != KeyTableSize ; i++)
|
|
if (KeyTable[i].virtualkey == wVirtKey) {
|
|
*(BYTE*)lpChar++ = *KeyTable[i].name;
|
|
*(BYTE*)lpChar = 0;
|
|
return 1;
|
|
}
|
|
|
|
*(BYTE*)lpChar = 0;
|
|
return 0;
|
|
}
|
|
|
|
DWORD OemKeyScan(WORD wOemChar)
|
|
{
|
|
printf("*OemKeyScan (%d)\n",wOemChar);
|
|
|
|
return wOemChar;
|
|
}
|
|
|
|
/* VkKeyScan translates an ANSI character to a virtual-key and shift code
|
|
* for the current keyboard. */
|
|
|
|
WORD VkKeyScan(WORD cChar)
|
|
{
|
|
int i;
|
|
|
|
printf("VkKeyScan (%d)\n",cChar);
|
|
|
|
for (i = 0 ; i != KeyTableSize ; i++)
|
|
if (KeyTable[i].ASCII == cChar)
|
|
return KeyTable[i].virtualkey;
|
|
|
|
return -1;
|
|
}
|
|
|
|
int GetKeyboardType(int nTypeFlag)
|
|
{
|
|
printf("GetKeyboardType(%d)\n",nTypeFlag);
|
|
switch(nTypeFlag)
|
|
{
|
|
case 0: /* Keyboard type */
|
|
return 4; /* AT-101 */
|
|
break;
|
|
case 1: /* Keyboard Subtype */
|
|
return 0; /* There are no defined subtypes */
|
|
break;
|
|
case 2: /* Number of F-keys */
|
|
return 12; /* We're doing an 101 for now, so return 12 F-keys */
|
|
break;
|
|
default:
|
|
fprintf(stderr, "Unknown type on GetKeyboardType\n");
|
|
return 0; /* The book says 0 here, so 0 */
|
|
}
|
|
}
|
|
|
|
/* MapVirtualKey translates keycodes from one format to another. */
|
|
|
|
WORD MapVirtualKey(WORD wCode, WORD wMapType)
|
|
{
|
|
int i;
|
|
|
|
switch(wMapType) {
|
|
case 0:
|
|
for (i = 0 ; i != KeyTableSize ; i++)
|
|
if (KeyTable[i].virtualkey == wCode)
|
|
return KeyTable[i].scancode;
|
|
return 0;
|
|
|
|
case 1:
|
|
for (i = 0 ; i != KeyTableSize ; i++)
|
|
if (KeyTable[i].scancode == wCode)
|
|
return KeyTable[i].virtualkey;
|
|
return 0;
|
|
|
|
case 2:
|
|
for (i = 0 ; i != KeyTableSize ; i++)
|
|
if (KeyTable[i].virtualkey == wCode)
|
|
return KeyTable[i].ASCII;
|
|
return 0;
|
|
|
|
default:
|
|
fprintf(stderr, "MapVirtualKey: unknown wMapType!\n");
|
|
return 0;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
int GetKbCodePage(void)
|
|
{
|
|
printf("GetKbCodePage()\n");
|
|
return 850;
|
|
}
|
|
|
|
int GetKeyNameText(LONG lParam, LPSTR lpBuffer, int nSize)
|
|
{
|
|
int i;
|
|
|
|
printf("GetKeyNameText(%d,<ptr>, %d)\n",lParam,nSize);
|
|
|
|
lParam >>= 16;
|
|
lParam &= 0xff;
|
|
|
|
for (i = 0 ; i != KeyTableSize ; i++)
|
|
if (KeyTable[i].scancode == lParam) {
|
|
strncpy(lpBuffer, KeyTable[i].name, nSize);
|
|
return strlen(lpBuffer);
|
|
}
|
|
|
|
*lpBuffer = 0;
|
|
return 0;
|
|
}
|