Added ability to turn on/off debug channels.
[wine.git] / windows / keyboard.c
blob50df439b89e9bf529f551df38cae9236901f29ed
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 <stdlib.h>
26 #include <string.h>
27 #include <ctype.h>
29 #include "windef.h"
30 #include "winbase.h"
31 #include "wingdi.h"
32 #include "winuser.h"
33 #include "win.h"
34 #include "user.h"
35 #include "message.h"
36 #include "wine/debug.h"
37 #include "winerror.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(keyboard);
41 #include "pshpack1.h"
42 typedef struct _KBINFO
44 BYTE Begin_First_Range;
45 BYTE End_First_Range;
46 BYTE Begin_Second_Range;
47 BYTE End_Second_Range;
48 WORD StateSize;
49 } KBINFO, *LPKBINFO;
50 #include "poppack.h"
52 static FARPROC16 DefKeybEventProc;
53 static LPBYTE pKeyStateTable;
55 /***********************************************************************
56 * Inquire (KEYBOARD.1)
58 WORD WINAPI KEYBOARD_Inquire(LPKBINFO kbInfo)
60 kbInfo->Begin_First_Range = 0;
61 kbInfo->End_First_Range = 0;
62 kbInfo->Begin_Second_Range = 0;
63 kbInfo->End_Second_Range = 0;
64 kbInfo->StateSize = 16;
66 return sizeof(KBINFO);
69 /***********************************************************************
70 * Enable (KEYBOARD.2)
72 VOID WINAPI KEYBOARD_Enable( FARPROC16 proc, LPBYTE lpKeyState )
74 DefKeybEventProc = proc;
75 pKeyStateTable = lpKeyState;
77 memset( lpKeyState, 0, 256 ); /* all states to false */
80 /***********************************************************************
81 * Disable (KEYBOARD.3)
83 VOID WINAPI KEYBOARD_Disable(VOID)
85 DefKeybEventProc = NULL;
86 pKeyStateTable = NULL;
90 /**********************************************************************
91 * SetSpeed (KEYBOARD.7)
93 WORD WINAPI SetSpeed16(WORD unused)
95 FIXME("(%04x): stub\n", unused);
96 return 0xffff;
99 /**********************************************************************
100 * ScreenSwitchEnable (KEYBOARD.100)
102 VOID WINAPI ScreenSwitchEnable16(WORD unused)
104 FIXME("(%04x): stub\n", unused);
107 /**********************************************************************
108 * OemKeyScan (KEYBOARD.128)
109 * OemKeyScan (USER32.@)
111 DWORD WINAPI OemKeyScan(WORD wOemChar)
113 TRACE("(%d)\n", wOemChar);
115 return wOemChar;
118 /**********************************************************************
119 * VkKeyScan (KEYBOARD.129)
121 WORD WINAPI VkKeyScan16(CHAR cChar)
123 return VkKeyScanA( cChar );
126 /******************************************************************************
127 * GetKeyboardType (KEYBOARD.130)
129 INT16 WINAPI GetKeyboardType16(INT16 nTypeFlag)
131 return GetKeyboardType( nTypeFlag );
134 /******************************************************************************
135 * MapVirtualKey (KEYBOARD.131)
137 * MapVirtualKey translates keycodes from one format to another
139 UINT16 WINAPI MapVirtualKey16(UINT16 wCode, UINT16 wMapType)
141 return MapVirtualKeyA(wCode,wMapType);
144 /****************************************************************************
145 * GetKBCodePage (KEYBOARD.132)
147 INT16 WINAPI GetKBCodePage16(void)
149 return GetKBCodePage();
152 /****************************************************************************
153 * GetKeyNameText (KEYBOARD.133)
155 INT16 WINAPI GetKeyNameText16(LONG lParam, LPSTR lpBuffer, INT16 nSize)
157 return GetKeyNameTextA( lParam, lpBuffer, nSize );
160 /****************************************************************************
161 * ToAscii (KEYBOARD.4)
163 * The ToAscii function translates the specified virtual-key code and keyboard
164 * state to the corresponding Windows character or characters.
166 * If the specified key is a dead key, the return value is negative. Otherwise,
167 * it is one of the following values:
168 * Value Meaning
169 * 0 The specified virtual key has no translation for the current state of the keyboard.
170 * 1 One Windows character was copied to the buffer.
171 * 2 Two characters were copied to the buffer. This usually happens when a
172 * dead-key character (accent or diacritic) stored in the keyboard layout cannot
173 * be composed with the specified virtual key to form a single character.
175 * FIXME : should do the above (return 2 for non matching deadchar+char combinations)
178 INT16 WINAPI ToAscii16(UINT16 virtKey,UINT16 scanCode, LPBYTE lpKeyState,
179 LPVOID lpChar, UINT16 flags)
181 return ToAscii( virtKey, scanCode, lpKeyState, lpChar, flags );
184 /***********************************************************************
185 * MessageBeep (USER.104)
187 void WINAPI MessageBeep16( UINT16 i )
189 MessageBeep( i );
192 /***********************************************************************
193 * MessageBeep (USER32.@)
195 BOOL WINAPI MessageBeep( UINT i )
197 BOOL active = TRUE;
198 SystemParametersInfoA( SPI_GETBEEP, 0, &active, FALSE );
199 if (active) USER_Driver.pBeep();
200 return TRUE;