Fixed some errors in function prototypes.
[wine] / dlls / user / 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  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 /**********************************************************************
90  *              SetSpeed (KEYBOARD.7)
91  */
92 WORD WINAPI SetSpeed16(WORD unused)
93 {
94     FIXME("(%04x): stub\n", unused);
95     return 0xffff;
96 }
97
98 /**********************************************************************
99  *              ScreenSwitchEnable (KEYBOARD.100)
100  */
101 VOID WINAPI ScreenSwitchEnable16(WORD unused)
102 {
103   FIXME("(%04x): stub\n", unused);
104 }
105
106 /**********************************************************************
107  *              OemKeyScan (KEYBOARD.128)
108  */
109 DWORD WINAPI OemKeyScan16(WORD wOemChar)
110 {
111     return OemKeyScan( wOemChar );
112 }
113
114 /**********************************************************************
115  *              VkKeyScan (KEYBOARD.129)
116  */
117 WORD WINAPI VkKeyScan16(CHAR cChar)
118 {
119     return VkKeyScanA( cChar );
120 }
121
122 /******************************************************************************
123  *              GetKeyboardType (KEYBOARD.130)
124  */
125 INT16 WINAPI GetKeyboardType16(INT16 nTypeFlag)
126 {
127     return GetKeyboardType( nTypeFlag );
128 }
129
130 /******************************************************************************
131  *              MapVirtualKey (KEYBOARD.131)
132  *
133  * MapVirtualKey translates keycodes from one format to another
134  */
135 UINT16 WINAPI MapVirtualKey16(UINT16 wCode, UINT16 wMapType)
136 {
137     return MapVirtualKeyA(wCode,wMapType);
138 }
139
140 /****************************************************************************
141  *              GetKBCodePage (KEYBOARD.132)
142  */
143 INT16 WINAPI GetKBCodePage16(void)
144 {
145     return GetKBCodePage();
146 }
147
148 /****************************************************************************
149  *              GetKeyNameText (KEYBOARD.133)
150  */
151 INT16 WINAPI GetKeyNameText16(LONG lParam, LPSTR lpBuffer, INT16 nSize)
152 {
153     return GetKeyNameTextA( lParam, lpBuffer, nSize );
154 }
155
156 /****************************************************************************
157  *              ToAscii (KEYBOARD.4)
158  *
159  * The ToAscii function translates the specified virtual-key code and keyboard
160  * state to the corresponding Windows character or characters.
161  *
162  * If the specified key is a dead key, the return value is negative. Otherwise,
163  * it is one of the following values:
164  * Value        Meaning
165  * 0    The specified virtual key has no translation for the current state of the keyboard.
166  * 1    One Windows character was copied to the buffer.
167  * 2    Two characters were copied to the buffer. This usually happens when a
168  *      dead-key character (accent or diacritic) stored in the keyboard layout cannot
169  *      be composed with the specified virtual key to form a single character.
170  *
171  * FIXME : should do the above (return 2 for non matching deadchar+char combinations)
172  *
173  */
174 INT16 WINAPI ToAscii16(UINT16 virtKey,UINT16 scanCode, LPBYTE lpKeyState,
175                        LPVOID lpChar, UINT16 flags)
176 {
177     return ToAscii( virtKey, scanCode, lpKeyState, lpChar, flags );
178 }
179
180 /***********************************************************************
181  *              MessageBeep (USER.104)
182  */
183 void WINAPI MessageBeep16( UINT16 i )
184 {
185     MessageBeep( i );
186 }
187
188 /***********************************************************************
189  *              keybd_event (USER.289)
190  */
191 void WINAPI keybd_event16( CONTEXT86 *context )
192 {
193     DWORD dwFlags = 0;
194
195     if (HIBYTE(context->Eax) & 0x80) dwFlags |= KEYEVENTF_KEYUP;
196     if (HIBYTE(context->Ebx) & 0x01) dwFlags |= KEYEVENTF_EXTENDEDKEY;
197
198     keybd_event( LOBYTE(context->Eax), LOBYTE(context->Ebx),
199                  dwFlags, MAKELONG(LOWORD(context->Esi), LOWORD(context->Edi)) );
200 }
201
202
203 /****************************************************************************
204  *              GetKeyboardLayoutName (USER.477)
205  */
206 INT16 WINAPI GetKeyboardLayoutName16( LPSTR name )
207 {
208     return GetKeyboardLayoutNameA( name );
209 }