keyboard.c 5.06 KB
Newer Older
Alexandre Julliard's avatar
Alexandre Julliard committed
1
/*
2
 * KEYBOARD driver
Alexandre Julliard's avatar
Alexandre Julliard committed
3 4
 *
 * Copyright 1993 Bob Amstadt
5
 * Copyright 1996 Albrecht Kleine
Alexandre Julliard's avatar
Alexandre Julliard committed
6
 * Copyright 1997 David Faure
Alexandre Julliard's avatar
Alexandre Julliard committed
7
 * Copyright 1998 Morten Welinder
8
 * Copyright 1998 Ulrich Weigand
Alexandre Julliard's avatar
Alexandre Julliard committed
9
 *
10 11 12 13 14 15 16 17 18 19 20 21
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
22
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
Alexandre Julliard's avatar
Alexandre Julliard committed
23
 */
Alexandre Julliard's avatar
Alexandre Julliard committed
24

25
#include <stdarg.h>
Alexandre Julliard's avatar
Alexandre Julliard committed
26
#include <stdlib.h>
Alexandre Julliard's avatar
Alexandre Julliard committed
27
#include <string.h>
Alexandre Julliard's avatar
Alexandre Julliard committed
28
#include <ctype.h>
29

30
#include "windef.h"
31
#include "winbase.h"
32
#include "wingdi.h"
33
#include "winuser.h"
Alexandre Julliard's avatar
Alexandre Julliard committed
34
#include "winerror.h"
35 36
#include "wine/winuser16.h"
#include "wine/debug.h"
Alexandre Julliard's avatar
Alexandre Julliard committed
37

38
WINE_DEFAULT_DEBUG_CHANNEL(keyboard);
39 40 41 42 43 44 45 46 47 48 49

#include "pshpack1.h"
typedef struct _KBINFO
{
    BYTE Begin_First_Range;
    BYTE End_First_Range;
    BYTE Begin_Second_Range;
    BYTE End_Second_Range;
    WORD StateSize;
} KBINFO, *LPKBINFO;
#include "poppack.h"
50

51
static FARPROC16 DefKeybEventProc;
52
static LPBYTE pKeyStateTable;
53

54 55 56
/***********************************************************************
 *		Inquire (KEYBOARD.1)
 */
57
WORD WINAPI Inquire16(LPKBINFO kbInfo)
58 59 60 61 62
{
  kbInfo->Begin_First_Range = 0;
  kbInfo->End_First_Range = 0;
  kbInfo->Begin_Second_Range = 0;
  kbInfo->End_Second_Range = 0;
63 64
  kbInfo->StateSize = 16;

65 66
  return sizeof(KBINFO);
}
67

68 69 70
/***********************************************************************
 *		Enable (KEYBOARD.2)
 */
71
VOID WINAPI Enable16( FARPROC16 proc, LPBYTE lpKeyState )
72
{
73
    DefKeybEventProc = proc;
74
    pKeyStateTable = lpKeyState;
75

76
    memset( lpKeyState, 0, 256 ); /* all states to false */
77 78
}

79
/***********************************************************************
80
 *		Disable (KEYBOARD.3)
81
 */
82
VOID WINAPI Disable16(VOID)
83
{
84 85
    DefKeybEventProc = NULL;
    pKeyStateTable = NULL;
86 87
}

88 89 90 91 92 93 94 95 96
/****************************************************************************
 *		ToAscii (KEYBOARD.4)
 */
INT16 WINAPI ToAscii16(UINT16 virtKey,UINT16 scanCode, LPBYTE lpKeyState,
                       LPVOID lpChar, UINT16 flags)
{
    return ToAscii( virtKey, scanCode, lpKeyState, lpChar, flags );
}

97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
/***********************************************************************
 *           AnsiToOem   (KEYBOARD.5)
 */
INT16 WINAPI AnsiToOem16( LPCSTR s, LPSTR d )
{
    CharToOemA( s, d );
    return -1;
}

/***********************************************************************
 *           OemToAnsi   (KEYBOARD.6)
 */
INT16 WINAPI OemToAnsi16( LPCSTR s, LPSTR d )
{
    OemToCharA( s, d );
    return -1;
}
Alexandre Julliard's avatar
Alexandre Julliard committed
114

115
/**********************************************************************
116
 *		SetSpeed (KEYBOARD.7)
117 118 119
 */
WORD WINAPI SetSpeed16(WORD unused)
{
120
    FIXME("(%04x): stub\n", unused);
121 122 123
    return 0xffff;
}

Alexandre Julliard's avatar
Alexandre Julliard committed
124
/**********************************************************************
125
 *		ScreenSwitchEnable (KEYBOARD.100)
Alexandre Julliard's avatar
Alexandre Julliard committed
126
 */
127
VOID WINAPI ScreenSwitchEnable16(WORD unused)
Alexandre Julliard's avatar
Alexandre Julliard committed
128
{
129
  FIXME("(%04x): stub\n", unused);
Alexandre Julliard's avatar
Alexandre Julliard committed
130 131
}

Alexandre Julliard's avatar
Alexandre Julliard committed
132
/**********************************************************************
Patrik Stridvall's avatar
Patrik Stridvall committed
133
 *		OemKeyScan (KEYBOARD.128)
Alexandre Julliard's avatar
Alexandre Julliard committed
134
 */
135
DWORD WINAPI OemKeyScan16(WORD wOemChar)
Alexandre Julliard's avatar
Alexandre Julliard committed
136
{
137
    return OemKeyScan( wOemChar );
Alexandre Julliard's avatar
Alexandre Julliard committed
138 139
}

Alexandre Julliard's avatar
Alexandre Julliard committed
140
/**********************************************************************
141
 *		VkKeyScan (KEYBOARD.129)
Alexandre Julliard's avatar
Alexandre Julliard committed
142
 */
143
WORD WINAPI VkKeyScan16(CHAR cChar)
Alexandre Julliard's avatar
Alexandre Julliard committed
144
{
145
    return VkKeyScanA( cChar );
Alexandre Julliard's avatar
Alexandre Julliard committed
146 147
}

Alexandre Julliard's avatar
Alexandre Julliard committed
148
/******************************************************************************
149
 *		GetKeyboardType (KEYBOARD.130)
Alexandre Julliard's avatar
Alexandre Julliard committed
150
 */
Alexandre Julliard's avatar
Alexandre Julliard committed
151
INT16 WINAPI GetKeyboardType16(INT16 nTypeFlag)
Alexandre Julliard's avatar
Alexandre Julliard committed
152
{
153
    return GetKeyboardType( nTypeFlag );
Alexandre Julliard's avatar
Alexandre Julliard committed
154 155
}

Alexandre Julliard's avatar
Alexandre Julliard committed
156
/******************************************************************************
157
 *		MapVirtualKey (KEYBOARD.131)
Alexandre Julliard's avatar
Alexandre Julliard committed
158
 *
Alexandre Julliard's avatar
Alexandre Julliard committed
159 160
 * MapVirtualKey translates keycodes from one format to another
 */
Alexandre Julliard's avatar
Alexandre Julliard committed
161
UINT16 WINAPI MapVirtualKey16(UINT16 wCode, UINT16 wMapType)
Alexandre Julliard's avatar
Alexandre Julliard committed
162
{
163
    return MapVirtualKeyA(wCode,wMapType);
Alexandre Julliard's avatar
Alexandre Julliard committed
164 165
}

Alexandre Julliard's avatar
Alexandre Julliard committed
166
/****************************************************************************
167
 *		GetKBCodePage (KEYBOARD.132)
Alexandre Julliard's avatar
Alexandre Julliard committed
168
 */
Alexandre Julliard's avatar
Alexandre Julliard committed
169
INT16 WINAPI GetKBCodePage16(void)
Alexandre Julliard's avatar
Alexandre Julliard committed
170
{
171
    return GetKBCodePage();
Alexandre Julliard's avatar
Alexandre Julliard committed
172 173
}

Alexandre Julliard's avatar
Alexandre Julliard committed
174
/****************************************************************************
175
 *		GetKeyNameText (KEYBOARD.133)
Alexandre Julliard's avatar
Alexandre Julliard committed
176
 */
Alexandre Julliard's avatar
Alexandre Julliard committed
177
INT16 WINAPI GetKeyNameText16(LONG lParam, LPSTR lpBuffer, INT16 nSize)
Alexandre Julliard's avatar
Alexandre Julliard committed
178
{
179
    return GetKeyNameTextA( lParam, lpBuffer, nSize );
Alexandre Julliard's avatar
Alexandre Julliard committed
180 181
}

182 183 184 185 186 187 188 189 190 191 192 193 194 195 196
/***********************************************************************
 *           AnsiToOemBuff   (KEYBOARD.134)
 */
void WINAPI AnsiToOemBuff16( LPCSTR s, LPSTR d, UINT16 len )
{
    if (len != 0) CharToOemBuffA( s, d, len );
}

/***********************************************************************
 *           OemToAnsiBuff   (KEYBOARD.135)
 */
void WINAPI OemToAnsiBuff16( LPCSTR s, LPSTR d, UINT16 len )
{
    if (len != 0) OemToCharBuffA( s, d, len );
}