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
35 #include "wine/winuser16.h"
36 #include "wine/debug.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(keyboard
);
41 typedef struct _KBINFO
43 BYTE Begin_First_Range
;
45 BYTE Begin_Second_Range
;
46 BYTE End_Second_Range
;
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 /***********************************************************************
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
;
88 /***********************************************************************
89 * AnsiToOem (KEYBOARD.5)
91 INT16 WINAPI
AnsiToOem16( LPCSTR s
, LPSTR d
)
97 /***********************************************************************
98 * OemToAnsi (KEYBOARD.6)
100 INT16 WINAPI
OemToAnsi16( LPCSTR s
, LPSTR d
)
106 /**********************************************************************
107 * SetSpeed (KEYBOARD.7)
109 WORD WINAPI
SetSpeed16(WORD unused
)
111 FIXME("(%04x): stub\n", unused
);
115 /**********************************************************************
116 * ScreenSwitchEnable (KEYBOARD.100)
118 VOID WINAPI
ScreenSwitchEnable16(WORD unused
)
120 FIXME("(%04x): stub\n", unused
);
123 /**********************************************************************
124 * OemKeyScan (KEYBOARD.128)
126 DWORD WINAPI
OemKeyScan16(WORD wOemChar
)
128 return OemKeyScan( wOemChar
);
131 /**********************************************************************
132 * VkKeyScan (KEYBOARD.129)
134 WORD WINAPI
VkKeyScan16(CHAR cChar
)
136 return VkKeyScanA( cChar
);
139 /******************************************************************************
140 * GetKeyboardType (KEYBOARD.130)
142 INT16 WINAPI
GetKeyboardType16(INT16 nTypeFlag
)
144 return GetKeyboardType( nTypeFlag
);
147 /******************************************************************************
148 * MapVirtualKey (KEYBOARD.131)
150 * MapVirtualKey translates keycodes from one format to another
152 UINT16 WINAPI
MapVirtualKey16(UINT16 wCode
, UINT16 wMapType
)
154 return MapVirtualKeyA(wCode
,wMapType
);
157 /****************************************************************************
158 * GetKBCodePage (KEYBOARD.132)
160 INT16 WINAPI
GetKBCodePage16(void)
162 return GetKBCodePage();
165 /****************************************************************************
166 * GetKeyNameText (KEYBOARD.133)
168 INT16 WINAPI
GetKeyNameText16(LONG lParam
, LPSTR lpBuffer
, INT16 nSize
)
170 return GetKeyNameTextA( lParam
, lpBuffer
, nSize
);
173 /***********************************************************************
174 * AnsiToOemBuff (KEYBOARD.134)
176 void WINAPI
AnsiToOemBuff16( LPCSTR s
, LPSTR d
, UINT16 len
)
178 if (len
!= 0) CharToOemBuffA( s
, d
, len
);
181 /***********************************************************************
182 * OemToAnsiBuff (KEYBOARD.135)
184 void WINAPI
OemToAnsiBuff16( LPCSTR s
, LPSTR d
, UINT16 len
)
186 if (len
!= 0) OemToCharBuffA( s
, d
, len
);
189 /****************************************************************************
190 * ToAscii (KEYBOARD.4)
192 * The ToAscii function translates the specified virtual-key code and keyboard
193 * state to the corresponding Windows character or characters.
195 * If the specified key is a dead key, the return value is negative. Otherwise,
196 * it is one of the following values:
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.
204 * FIXME : should do the above (return 2 for non matching deadchar+char combinations)
207 INT16 WINAPI
ToAscii16(UINT16 virtKey
,UINT16 scanCode
, LPBYTE lpKeyState
,
208 LPVOID lpChar
, UINT16 flags
)
210 return ToAscii( virtKey
, scanCode
, lpKeyState
, lpChar
, flags
);
213 /***********************************************************************
214 * MessageBeep (USER.104)
216 void WINAPI
MessageBeep16( UINT16 i
)
221 /***********************************************************************
222 * keybd_event (USER.289)
224 void WINAPI
keybd_event16( CONTEXT86
*context
)
228 if (HIBYTE(context
->Eax
) & 0x80) dwFlags
|= KEYEVENTF_KEYUP
;
229 if (HIBYTE(context
->Ebx
) & 0x01) dwFlags
|= KEYEVENTF_EXTENDEDKEY
;
231 keybd_event( LOBYTE(context
->Eax
), LOBYTE(context
->Ebx
),
232 dwFlags
, MAKELONG(LOWORD(context
->Esi
), LOWORD(context
->Edi
)) );
236 /****************************************************************************
237 * GetKeyboardLayoutName (USER.477)
239 INT16 WINAPI
GetKeyboardLayoutName16( LPSTR name
)
241 return GetKeyboardLayoutNameA( name
);