Use Interlocked* functions in AddRef and Release.
[wine/multimedia.git] / dlls / user / kbd16.c
blob57f2c35aa503dd8c081405bae398fa21aa448c70
1 /*
2 * KEYBOARD driver
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
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.
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.
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
25 #include <stdarg.h>
26 #include <stdlib.h>
27 #include <string.h>
28 #include <ctype.h>
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"
38 WINE_DEFAULT_DEBUG_CHANNEL(keyboard);
40 #include "pshpack1.h"
41 typedef struct _KBINFO
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"
51 static FARPROC16 DefKeybEventProc;
52 static LPBYTE pKeyStateTable;
54 /***********************************************************************
55 * Inquire (KEYBOARD.1)
57 WORD WINAPI KEYBOARD_Inquire(LPKBINFO kbInfo)
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;
65 return sizeof(KBINFO);
68 /***********************************************************************
69 * Enable (KEYBOARD.2)
71 VOID WINAPI KEYBOARD_Enable( FARPROC16 proc, LPBYTE lpKeyState )
73 DefKeybEventProc = proc;
74 pKeyStateTable = lpKeyState;
76 memset( lpKeyState, 0, 256 ); /* all states to false */
79 /***********************************************************************
80 * Disable (KEYBOARD.3)
82 VOID WINAPI KEYBOARD_Disable(VOID)
84 DefKeybEventProc = NULL;
85 pKeyStateTable = NULL;
89 /**********************************************************************
90 * SetSpeed (KEYBOARD.7)
92 WORD WINAPI SetSpeed16(WORD unused)
94 FIXME("(%04x): stub\n", unused);
95 return 0xffff;
98 /**********************************************************************
99 * ScreenSwitchEnable (KEYBOARD.100)
101 VOID WINAPI ScreenSwitchEnable16(WORD unused)
103 FIXME("(%04x): stub\n", unused);
106 /**********************************************************************
107 * OemKeyScan (KEYBOARD.128)
109 DWORD WINAPI OemKeyScan16(WORD wOemChar)
111 return OemKeyScan( wOemChar );
114 /**********************************************************************
115 * VkKeyScan (KEYBOARD.129)
117 WORD WINAPI VkKeyScan16(CHAR cChar)
119 return VkKeyScanA( cChar );
122 /******************************************************************************
123 * GetKeyboardType (KEYBOARD.130)
125 INT16 WINAPI GetKeyboardType16(INT16 nTypeFlag)
127 return GetKeyboardType( nTypeFlag );
130 /******************************************************************************
131 * MapVirtualKey (KEYBOARD.131)
133 * MapVirtualKey translates keycodes from one format to another
135 UINT16 WINAPI MapVirtualKey16(UINT16 wCode, UINT16 wMapType)
137 return MapVirtualKeyA(wCode,wMapType);
140 /****************************************************************************
141 * GetKBCodePage (KEYBOARD.132)
143 INT16 WINAPI GetKBCodePage16(void)
145 return GetKBCodePage();
148 /****************************************************************************
149 * GetKeyNameText (KEYBOARD.133)
151 INT16 WINAPI GetKeyNameText16(LONG lParam, LPSTR lpBuffer, INT16 nSize)
153 return GetKeyNameTextA( lParam, lpBuffer, nSize );
156 /****************************************************************************
157 * ToAscii (KEYBOARD.4)
159 * The ToAscii function translates the specified virtual-key code and keyboard
160 * state to the corresponding Windows character or characters.
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.
171 * FIXME : should do the above (return 2 for non matching deadchar+char combinations)
174 INT16 WINAPI ToAscii16(UINT16 virtKey,UINT16 scanCode, LPBYTE lpKeyState,
175 LPVOID lpChar, UINT16 flags)
177 return ToAscii( virtKey, scanCode, lpKeyState, lpChar, flags );
180 /***********************************************************************
181 * MessageBeep (USER.104)
183 void WINAPI MessageBeep16( UINT16 i )
185 MessageBeep( i );
188 /***********************************************************************
189 * keybd_event (USER.289)
191 void WINAPI keybd_event16( CONTEXT86 *context )
193 DWORD dwFlags = 0;
195 if (HIBYTE(context->Eax) & 0x80) dwFlags |= KEYEVENTF_KEYUP;
196 if (HIBYTE(context->Ebx) & 0x01) dwFlags |= KEYEVENTF_EXTENDEDKEY;
198 keybd_event( LOBYTE(context->Eax), LOBYTE(context->Ebx),
199 dwFlags, MAKELONG(LOWORD(context->Esi), LOWORD(context->Edi)) );
203 /****************************************************************************
204 * GetKeyboardLayoutName (USER.477)
206 INT16 WINAPI GetKeyboardLayoutName16( LPSTR name )
208 return GetKeyboardLayoutNameA( name );