Release 20031118.
[wine/multimedia.git] / windows / keyboard.c
blob976ced0e024f1257571d11fa3ab0d35786b2bb00
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 "win.h"
35 #include "user.h"
36 #include "message.h"
37 #include "wine/debug.h"
38 #include "winerror.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(keyboard);
42 #include "pshpack1.h"
43 typedef struct _KBINFO
45 BYTE Begin_First_Range;
46 BYTE End_First_Range;
47 BYTE Begin_Second_Range;
48 BYTE End_Second_Range;
49 WORD StateSize;
50 } KBINFO, *LPKBINFO;
51 #include "poppack.h"
53 static FARPROC16 DefKeybEventProc;
54 static LPBYTE pKeyStateTable;
56 /***********************************************************************
57 * Inquire (KEYBOARD.1)
59 WORD WINAPI KEYBOARD_Inquire(LPKBINFO kbInfo)
61 kbInfo->Begin_First_Range = 0;
62 kbInfo->End_First_Range = 0;
63 kbInfo->Begin_Second_Range = 0;
64 kbInfo->End_Second_Range = 0;
65 kbInfo->StateSize = 16;
67 return sizeof(KBINFO);
70 /***********************************************************************
71 * Enable (KEYBOARD.2)
73 VOID WINAPI KEYBOARD_Enable( FARPROC16 proc, LPBYTE lpKeyState )
75 DefKeybEventProc = proc;
76 pKeyStateTable = lpKeyState;
78 memset( lpKeyState, 0, 256 ); /* all states to false */
81 /***********************************************************************
82 * Disable (KEYBOARD.3)
84 VOID WINAPI KEYBOARD_Disable(VOID)
86 DefKeybEventProc = NULL;
87 pKeyStateTable = NULL;
91 /**********************************************************************
92 * SetSpeed (KEYBOARD.7)
94 WORD WINAPI SetSpeed16(WORD unused)
96 FIXME("(%04x): stub\n", unused);
97 return 0xffff;
100 /**********************************************************************
101 * ScreenSwitchEnable (KEYBOARD.100)
103 VOID WINAPI ScreenSwitchEnable16(WORD unused)
105 FIXME("(%04x): stub\n", unused);
108 /**********************************************************************
109 * OemKeyScan (KEYBOARD.128)
110 * OemKeyScan (USER32.@)
112 DWORD WINAPI OemKeyScan(WORD wOemChar)
114 TRACE("(%d)\n", wOemChar);
116 return wOemChar;
119 /**********************************************************************
120 * VkKeyScan (KEYBOARD.129)
122 WORD WINAPI VkKeyScan16(CHAR cChar)
124 return VkKeyScanA( cChar );
127 /******************************************************************************
128 * GetKeyboardType (KEYBOARD.130)
130 INT16 WINAPI GetKeyboardType16(INT16 nTypeFlag)
132 return GetKeyboardType( nTypeFlag );
135 /******************************************************************************
136 * MapVirtualKey (KEYBOARD.131)
138 * MapVirtualKey translates keycodes from one format to another
140 UINT16 WINAPI MapVirtualKey16(UINT16 wCode, UINT16 wMapType)
142 return MapVirtualKeyA(wCode,wMapType);
145 /****************************************************************************
146 * GetKBCodePage (KEYBOARD.132)
148 INT16 WINAPI GetKBCodePage16(void)
150 return GetKBCodePage();
153 /****************************************************************************
154 * GetKeyNameText (KEYBOARD.133)
156 INT16 WINAPI GetKeyNameText16(LONG lParam, LPSTR lpBuffer, INT16 nSize)
158 return GetKeyNameTextA( lParam, lpBuffer, nSize );
161 /****************************************************************************
162 * ToAscii (KEYBOARD.4)
164 * The ToAscii function translates the specified virtual-key code and keyboard
165 * state to the corresponding Windows character or characters.
167 * If the specified key is a dead key, the return value is negative. Otherwise,
168 * it is one of the following values:
169 * Value Meaning
170 * 0 The specified virtual key has no translation for the current state of the keyboard.
171 * 1 One Windows character was copied to the buffer.
172 * 2 Two characters were copied to the buffer. This usually happens when a
173 * dead-key character (accent or diacritic) stored in the keyboard layout cannot
174 * be composed with the specified virtual key to form a single character.
176 * FIXME : should do the above (return 2 for non matching deadchar+char combinations)
179 INT16 WINAPI ToAscii16(UINT16 virtKey,UINT16 scanCode, LPBYTE lpKeyState,
180 LPVOID lpChar, UINT16 flags)
182 return ToAscii( virtKey, scanCode, lpKeyState, lpChar, flags );
185 /***********************************************************************
186 * MessageBeep (USER.104)
188 void WINAPI MessageBeep16( UINT16 i )
190 MessageBeep( i );
193 /***********************************************************************
194 * MessageBeep (USER32.@)
196 BOOL WINAPI MessageBeep( UINT i )
198 BOOL active = TRUE;
199 SystemParametersInfoA( SPI_GETBEEP, 0, &active, FALSE );
200 if (active) USER_Driver.pBeep();
201 return TRUE;