wined3d: Filter out some shader compilation spam.
[wine] / dlls / user32 / kbd16.c
1 /*
2  * KEYBOARD driver
3  *
4  * Copyright 1993 Bob Amstadt
5  * Copyright 1996 Albrecht Kleine
6  * Copyright 1997 David Faure
7  * Copyright 1998 Morten Welinder
8  * Copyright 1998 Ulrich Weigand
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 2.1 of the License, or (at your option) any later version.
14  *
15  * This library is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * 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
23  */
24
25 #include <stdarg.h>
26 #include <stdlib.h>
27 #include <string.h>
28 #include <ctype.h>
29
30 #include "windef.h"
31 #include "winbase.h"
32 #include "wingdi.h"
33 #include "winuser.h"
34 #include "winerror.h"
35 #include "wine/winuser16.h"
36 #include "wine/debug.h"
37
38 WINE_DEFAULT_DEBUG_CHANNEL(keyboard);
39
40 #include "pshpack1.h"
41 typedef struct _KBINFO
42 {
43     BYTE Begin_First_Range;
44     BYTE End_First_Range;
45     BYTE Begin_Second_Range;
46     BYTE End_Second_Range;
47     WORD StateSize;
48 } KBINFO, *LPKBINFO;
49 #include "poppack.h"
50
51 static FARPROC16 DefKeybEventProc;
52 static LPBYTE pKeyStateTable;
53
54 /***********************************************************************
55  *              Inquire (KEYBOARD.1)
56  */
57 WORD WINAPI KEYBOARD_Inquire(LPKBINFO kbInfo)
58 {
59   kbInfo->Begin_First_Range = 0;
60   kbInfo->End_First_Range = 0;
61   kbInfo->Begin_Second_Range = 0;
62   kbInfo->End_Second_Range = 0;
63   kbInfo->StateSize = 16;
64
65   return sizeof(KBINFO);
66 }
67
68 /***********************************************************************
69  *              Enable (KEYBOARD.2)
70  */
71 VOID WINAPI KEYBOARD_Enable( 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 KEYBOARD_Disable(VOID)
83 {
84     DefKeybEventProc = NULL;
85     pKeyStateTable = NULL;
86 }
87
88 /***********************************************************************
89  *           AnsiToOem   (KEYBOARD.5)
90  */
91 INT16 WINAPI AnsiToOem16( LPCSTR s, LPSTR d )
92 {
93     CharToOemA( s, d );
94     return -1;
95 }
96
97 /***********************************************************************
98  *           OemToAnsi   (KEYBOARD.6)
99  */
100 INT16 WINAPI OemToAnsi16( LPCSTR s, LPSTR d )
101 {
102     OemToCharA( s, d );
103     return -1;
104 }
105
106 /**********************************************************************
107  *              SetSpeed (KEYBOARD.7)
108  */
109 WORD WINAPI SetSpeed16(WORD unused)
110 {
111     FIXME("(%04x): stub\n", unused);
112     return 0xffff;
113 }
114
115 /**********************************************************************
116  *              ScreenSwitchEnable (KEYBOARD.100)
117  */
118 VOID WINAPI ScreenSwitchEnable16(WORD unused)
119 {
120   FIXME("(%04x): stub\n", unused);
121 }
122
123 /**********************************************************************
124  *              OemKeyScan (KEYBOARD.128)
125  */
126 DWORD WINAPI OemKeyScan16(WORD wOemChar)
127 {
128     return OemKeyScan( wOemChar );
129 }
130
131 /**********************************************************************
132  *              VkKeyScan (KEYBOARD.129)
133  */
134 WORD WINAPI VkKeyScan16(CHAR cChar)
135 {
136     return VkKeyScanA( cChar );
137 }
138
139 /******************************************************************************
140  *              GetKeyboardType (KEYBOARD.130)
141  */
142 INT16 WINAPI GetKeyboardType16(INT16 nTypeFlag)
143 {
144     return GetKeyboardType( nTypeFlag );
145 }
146
147 /******************************************************************************
148  *              MapVirtualKey (KEYBOARD.131)
149  *
150  * MapVirtualKey translates keycodes from one format to another
151  */
152 UINT16 WINAPI MapVirtualKey16(UINT16 wCode, UINT16 wMapType)
153 {
154     return MapVirtualKeyA(wCode,wMapType);
155 }
156
157 /****************************************************************************
158  *              GetKBCodePage (KEYBOARD.132)
159  */
160 INT16 WINAPI GetKBCodePage16(void)
161 {
162     return GetKBCodePage();
163 }
164
165 /****************************************************************************
166  *              GetKeyNameText (KEYBOARD.133)
167  */
168 INT16 WINAPI GetKeyNameText16(LONG lParam, LPSTR lpBuffer, INT16 nSize)
169 {
170     return GetKeyNameTextA( lParam, lpBuffer, nSize );
171 }
172
173 /***********************************************************************
174  *           AnsiToOemBuff   (KEYBOARD.134)
175  */
176 void WINAPI AnsiToOemBuff16( LPCSTR s, LPSTR d, UINT16 len )
177 {
178     if (len != 0) CharToOemBuffA( s, d, len );
179 }
180
181 /***********************************************************************
182  *           OemToAnsiBuff   (KEYBOARD.135)
183  */
184 void WINAPI OemToAnsiBuff16( LPCSTR s, LPSTR d, UINT16 len )
185 {
186     if (len != 0) OemToCharBuffA( s, d, len );
187 }
188
189 /****************************************************************************
190  *              ToAscii (KEYBOARD.4)
191  *
192  * The ToAscii function translates the specified virtual-key code and keyboard
193  * state to the corresponding Windows character or characters.
194  *
195  * If the specified key is a dead key, the return value is negative. Otherwise,
196  * it is one of the following values:
197  * Value        Meaning
198  * 0    The specified virtual key has no translation for the current state of the keyboard.
199  * 1    One Windows character was copied to the buffer.
200  * 2    Two characters were copied to the buffer. This usually happens when a
201  *      dead-key character (accent or diacritic) stored in the keyboard layout cannot
202  *      be composed with the specified virtual key to form a single character.
203  *
204  * FIXME : should do the above (return 2 for non matching deadchar+char combinations)
205  *
206  */
207 INT16 WINAPI ToAscii16(UINT16 virtKey,UINT16 scanCode, LPBYTE lpKeyState,
208                        LPVOID lpChar, UINT16 flags)
209 {
210     return ToAscii( virtKey, scanCode, lpKeyState, lpChar, flags );
211 }
212
213 /***********************************************************************
214  *              MessageBeep (USER.104)
215  */
216 void WINAPI MessageBeep16( UINT16 i )
217 {
218     MessageBeep( i );
219 }
220
221 /***********************************************************************
222  *              keybd_event (USER.289)
223  */
224 void WINAPI keybd_event16( CONTEXT86 *context )
225 {
226     DWORD dwFlags = 0;
227
228     if (HIBYTE(context->Eax) & 0x80) dwFlags |= KEYEVENTF_KEYUP;
229     if (HIBYTE(context->Ebx) & 0x01) dwFlags |= KEYEVENTF_EXTENDEDKEY;
230
231     keybd_event( LOBYTE(context->Eax), LOBYTE(context->Ebx),
232                  dwFlags, MAKELONG(LOWORD(context->Esi), LOWORD(context->Edi)) );
233 }
234
235
236 /****************************************************************************
237  *              GetKeyboardLayoutName (USER.477)
238  */
239 INT16 WINAPI GetKeyboardLayoutName16( LPSTR name )
240 {
241     return GetKeyboardLayoutNameA( name );
242 }