| 1 | /* $Id: conin.cpp,v 1.3 1999-06-21 18:53:51 phaller Exp $ */
|
|---|
| 2 |
|
|---|
| 3 | /*
|
|---|
| 4 | * Win32 Console API Translation for OS/2
|
|---|
| 5 | * 1998/02/10 Patrick Haller (haller@zebra.fh-weingarten.de)
|
|---|
| 6 | * Project Odin Software License can be found in LICENSE.TXT
|
|---|
| 7 | */
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 | #ifdef DEBUG
|
|---|
| 11 | #define DEBUG_LOCAL
|
|---|
| 12 | #endif
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 | /*****************************************************************************
|
|---|
| 16 | * Remark *
|
|---|
| 17 | *****************************************************************************
|
|---|
| 18 | */
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 | /*****************************************************************************
|
|---|
| 22 | * Includes *
|
|---|
| 23 | *****************************************************************************/
|
|---|
| 24 |
|
|---|
| 25 | #define INCL_WIN
|
|---|
| 26 | #define INCL_DOSMEMMGR
|
|---|
| 27 | #define INCL_DOSSEMAPHORES
|
|---|
| 28 | #define INCL_DOSERRORS
|
|---|
| 29 | #define INCL_DOSPROCESS
|
|---|
| 30 | #define INCL_DOSMODULEMGR
|
|---|
| 31 | #define INCL_VIO
|
|---|
| 32 | #define INCL_AVIO
|
|---|
| 33 | #include <os2wrap.h> //Odin32 OS/2 api wrappers
|
|---|
| 34 |
|
|---|
| 35 | #include <misc.h>
|
|---|
| 36 | #include <string.h>
|
|---|
| 37 |
|
|---|
| 38 | #include "conwin.h" // Windows Header for console only
|
|---|
| 39 | #include "HandleManager.h"
|
|---|
| 40 | #include "HMDevice.h"
|
|---|
| 41 | #include "Conin.H"
|
|---|
| 42 | #include "Console2.h"
|
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 | /***********************************
|
|---|
| 46 | * Open32 support for SetLastError *
|
|---|
| 47 | ***********************************/
|
|---|
| 48 | #include <os2sel.h>
|
|---|
| 49 |
|
|---|
| 50 | extern "C"
|
|---|
| 51 | {
|
|---|
| 52 | void _System _O32_SetLastError(DWORD dwError);
|
|---|
| 53 | }
|
|---|
| 54 |
|
|---|
| 55 | inline void SetLastError(DWORD a)
|
|---|
| 56 | {
|
|---|
| 57 | USHORT sel = GetFS();
|
|---|
| 58 |
|
|---|
| 59 | _O32_SetLastError(a);
|
|---|
| 60 | SetFS(sel);
|
|---|
| 61 | }
|
|---|
| 62 |
|
|---|
| 63 |
|
|---|
| 64 | /*****************************************************************************
|
|---|
| 65 | * Name : DWORD HMDeviceConsoleInClass::CreateFile
|
|---|
| 66 | * Purpose : this is called from the handle manager if a CreateFile() is
|
|---|
| 67 | * performed on a handle
|
|---|
| 68 | * Parameters: LPCSTR lpFileName name of the file / device
|
|---|
| 69 | * PHMHANDLEDATA pHMHandleData data of the NEW handle
|
|---|
| 70 | * PVOID lpSecurityAttributes ignored
|
|---|
| 71 | * PHMHANDLEDATA pHMHandleDataTemplate data of the template handle
|
|---|
| 72 | * Variables :
|
|---|
| 73 | * Result :
|
|---|
| 74 | * Remark : @@@PH CONIN$ handles should be exclusive
|
|---|
| 75 | * reject other requests to this device
|
|---|
| 76 | * Status : NO_ERROR - API succeeded
|
|---|
| 77 | * other - what is to be set in SetLastError
|
|---|
| 78 | *
|
|---|
| 79 | * Author : Patrick Haller [Wed, 1998/02/11 20:44]
|
|---|
| 80 | *****************************************************************************/
|
|---|
| 81 |
|
|---|
| 82 | DWORD HMDeviceConsoleInClass::CreateFile (LPCSTR lpFileName,
|
|---|
| 83 | PHMHANDLEDATA pHMHandleData,
|
|---|
| 84 | PVOID lpSecurityAttributes,
|
|---|
| 85 | PHMHANDLEDATA pHMHandleDataTemplate)
|
|---|
| 86 | {
|
|---|
| 87 | #ifdef DEBUG_LOCAL
|
|---|
| 88 | WriteLog("KERNEL32/CONSOLE:HMDeviceConsoleInClass::CreateFile %s(%s,%08x,%08x,%08x)\n",
|
|---|
| 89 | lpHMDeviceName,
|
|---|
| 90 | lpFileName,
|
|---|
| 91 | pHMHandleData->hHMHandle,
|
|---|
| 92 | lpSecurityAttributes,
|
|---|
| 93 | pHMHandleDataTemplate);
|
|---|
| 94 | #endif
|
|---|
| 95 |
|
|---|
| 96 | pHMHandleData->dwType = FILE_TYPE_CHAR; /* we're a character device */
|
|---|
| 97 |
|
|---|
| 98 | return(NO_ERROR);
|
|---|
| 99 | }
|
|---|
| 100 |
|
|---|
| 101 |
|
|---|
| 102 | /*****************************************************************************
|
|---|
| 103 | * Name :
|
|---|
| 104 | * Purpose :
|
|---|
| 105 | * Parameters:
|
|---|
| 106 | * Variables :
|
|---|
| 107 | * Result :
|
|---|
| 108 | * Remark :
|
|---|
| 109 | * Status :
|
|---|
| 110 | *
|
|---|
| 111 | * Author : Patrick Haller [Wed, 1998/02/11 20:44]
|
|---|
| 112 | *****************************************************************************/
|
|---|
| 113 |
|
|---|
| 114 | DWORD HMDeviceConsoleInClass::ReadFile(PHMHANDLEDATA pHMHandleData,
|
|---|
| 115 | LPCVOID lpBuffer,
|
|---|
| 116 | DWORD nNumberOfBytesToRead,
|
|---|
| 117 | LPDWORD lpNumberOfBytesRead,
|
|---|
| 118 | LPOVERLAPPED lpOverlapped)
|
|---|
| 119 | {
|
|---|
| 120 | ULONG ulCounter; /* character counter for the queue loop */
|
|---|
| 121 | PSZ pszTarget; /* pointer to target buffer */
|
|---|
| 122 | APIRET rc; /* API returncode */
|
|---|
| 123 | INPUT_RECORD InputRecord; /* buffer for the event to be read */
|
|---|
| 124 | ULONG ulPostCounter; /* semaphore post counter */
|
|---|
| 125 |
|
|---|
| 126 | #ifdef DEBUG_LOCAL
|
|---|
| 127 | WriteLog("KERNEL32/CONSOLE:HMDeviceConsoleInClass::ReadFile %s(%08x,%08x,%08x,%08x,%08x)\n",
|
|---|
| 128 | lpHMDeviceName,
|
|---|
| 129 | pHMHandleData->hHMHandle,
|
|---|
| 130 | lpBuffer,
|
|---|
| 131 | nNumberOfBytesToRead,
|
|---|
| 132 | lpNumberOfBytesRead,
|
|---|
| 133 | lpOverlapped);
|
|---|
| 134 | #endif
|
|---|
| 135 |
|
|---|
| 136 | ulCounter = 0; /* read ascii chars from queue */
|
|---|
| 137 | pszTarget = (PSZ)lpBuffer;
|
|---|
| 138 |
|
|---|
| 139 | /* @@@PH: ConsoleMode: ENABLE_LINE_INPUT - blocks until CR is read */
|
|---|
| 140 |
|
|---|
| 141 | /* block if no key events are in the queue */
|
|---|
| 142 | for (;ulCounter==0;) /* until we got some characters */
|
|---|
| 143 | {
|
|---|
| 144 | if (iConsoleInputQueryEvents() == 0) /* if queue is currently empty */
|
|---|
| 145 | {
|
|---|
| 146 | rc = DosWaitEventSem(pConsoleInput->hevInputQueue, /* wait for input */
|
|---|
| 147 | SEM_INDEFINITE_WAIT);
|
|---|
| 148 | DosResetEventSem(pConsoleInput->hevInputQueue, /* reset semaphore */
|
|---|
| 149 | &ulPostCounter); /* post counter - ignored */
|
|---|
| 150 | }
|
|---|
| 151 |
|
|---|
| 152 | do
|
|---|
| 153 | {
|
|---|
| 154 | rc = iConsoleInputEventPop(&InputRecord); /* get event from queue */
|
|---|
| 155 | if (rc == NO_ERROR) /* if we've got a valid event in the queue */
|
|---|
| 156 | {
|
|---|
| 157 | if (InputRecord.EventType == KEY_EVENT) /* check event type */
|
|---|
| 158 | {
|
|---|
| 159 | *pszTarget = InputRecord.Event.KeyEvent.uChar.AsciiChar;
|
|---|
| 160 | pszTarget++;
|
|---|
| 161 | ulCounter++;
|
|---|
| 162 |
|
|---|
| 163 | /* local echo enabled ? */
|
|---|
| 164 | if (pConsoleInput->dwConsoleMode & ENABLE_ECHO_INPUT)
|
|---|
| 165 | HMWriteFile(pConsoleGlobals->hConsoleBuffer,
|
|---|
| 166 | &InputRecord.Event.KeyEvent.uChar.AsciiChar,
|
|---|
| 167 | 1,
|
|---|
| 168 | &ulPostCounter, /* dummy result */
|
|---|
| 169 | NULL);
|
|---|
| 170 |
|
|---|
| 171 | if (ulCounter >= nNumberOfBytesToRead) /* at buffer's end ? */
|
|---|
| 172 | goto __readfile_exit;
|
|---|
| 173 | }
|
|---|
| 174 | /* Note: other events are discarded */
|
|---|
| 175 | }
|
|---|
| 176 | }
|
|---|
| 177 | while (rc == NO_ERROR);
|
|---|
| 178 | }
|
|---|
| 179 |
|
|---|
| 180 | __readfile_exit:
|
|---|
| 181 |
|
|---|
| 182 | *lpNumberOfBytesRead = ulCounter; /* write result */
|
|---|
| 183 |
|
|---|
| 184 | return(TRUE); /* OK */
|
|---|
| 185 | }
|
|---|
| 186 |
|
|---|
| 187 |
|
|---|
| 188 | /*****************************************************************************
|
|---|
| 189 | * Name :
|
|---|
| 190 | * Purpose :
|
|---|
| 191 | * Parameters:
|
|---|
| 192 | * Variables :
|
|---|
| 193 | * Result :
|
|---|
| 194 | * Remark :
|
|---|
| 195 | * Status :
|
|---|
| 196 | *
|
|---|
| 197 | * Author : Patrick Haller [Wed, 1998/02/11 20:44]
|
|---|
| 198 | *****************************************************************************/
|
|---|
| 199 |
|
|---|
| 200 | DWORD HMDeviceConsoleInClass::WriteFile(PHMHANDLEDATA pHMHandleData,
|
|---|
| 201 | LPCVOID lpBuffer,
|
|---|
| 202 | DWORD nNumberOfBytesToWrite,
|
|---|
| 203 | LPDWORD lpNumberOfBytesWritten,
|
|---|
| 204 | LPOVERLAPPED lpOverlapped)
|
|---|
| 205 | {
|
|---|
| 206 |
|
|---|
| 207 | #ifdef DEBUG_LOCAL
|
|---|
| 208 | WriteLog("KERNEL32/CONSOLE:HMDeviceConsoleInClass:WriteFile %s(%08x,%08x,%08x,%08x,%08x)\n",
|
|---|
| 209 | lpHMDeviceName,
|
|---|
| 210 | pHMHandleData->hHMHandle,
|
|---|
| 211 | lpBuffer,
|
|---|
| 212 | nNumberOfBytesToWrite,
|
|---|
| 213 | lpNumberOfBytesWritten,
|
|---|
| 214 | lpOverlapped);
|
|---|
| 215 | #endif
|
|---|
| 216 |
|
|---|
| 217 | return(ERROR_ACCESS_DENIED);
|
|---|
| 218 | }
|
|---|
| 219 |
|
|---|
| 220 |
|
|---|
| 221 | /*****************************************************************************
|
|---|
| 222 | * Name :
|
|---|
| 223 | * Purpose :
|
|---|
| 224 | * Parameters:
|
|---|
| 225 | * Variables :
|
|---|
| 226 | * Result :
|
|---|
| 227 | * Remark :
|
|---|
| 228 | * Status :
|
|---|
| 229 | *
|
|---|
| 230 | * Author : Patrick Haller [Wed, 1998/02/11 20:44]
|
|---|
| 231 | *****************************************************************************/
|
|---|
| 232 |
|
|---|
| 233 | DWORD HMDeviceConsoleInClass::_DeviceRequest (PHMHANDLEDATA pHMHandleData,
|
|---|
| 234 | ULONG ulRequestCode,
|
|---|
| 235 | ULONG arg1,
|
|---|
| 236 | ULONG arg2,
|
|---|
| 237 | ULONG arg3,
|
|---|
| 238 | ULONG arg4)
|
|---|
| 239 | {
|
|---|
| 240 | switch (ulRequestCode)
|
|---|
| 241 | {
|
|---|
| 242 | case DRQ_FLUSHCONSOLEINPUTBUFFER:
|
|---|
| 243 | return (HMDeviceConsoleInClass::
|
|---|
| 244 | FlushConsoleInputBuffer(pHMHandleData));
|
|---|
| 245 |
|
|---|
| 246 | case DRQ_GETNUMBEROFCONSOLEINPUTEVENTS:
|
|---|
| 247 | return (HMDeviceConsoleInClass::
|
|---|
| 248 | GetNumberOfConsoleInputEvents(pHMHandleData,
|
|---|
| 249 | (LPDWORD)arg1));
|
|---|
| 250 |
|
|---|
| 251 | case DRQ_PEEKCONSOLEINPUTA:
|
|---|
| 252 | return (HMDeviceConsoleInClass::
|
|---|
| 253 | PeekConsoleInputA(pHMHandleData,
|
|---|
| 254 | (PINPUT_RECORD)arg1,
|
|---|
| 255 | (DWORD) arg2,
|
|---|
| 256 | (LPDWORD) arg3));
|
|---|
| 257 |
|
|---|
| 258 | case DRQ_PEEKCONSOLEINPUTW:
|
|---|
| 259 | return (HMDeviceConsoleInClass::
|
|---|
| 260 | PeekConsoleInputW(pHMHandleData,
|
|---|
| 261 | (PINPUT_RECORD)arg1,
|
|---|
| 262 | (DWORD) arg2,
|
|---|
| 263 | (LPDWORD) arg3));
|
|---|
| 264 |
|
|---|
| 265 |
|
|---|
| 266 | case DRQ_READCONSOLEA:
|
|---|
| 267 | return (HMDeviceConsoleInClass::
|
|---|
| 268 | ReadConsoleA(pHMHandleData,
|
|---|
| 269 | (CONST VOID*) arg1,
|
|---|
| 270 | (DWORD) arg2,
|
|---|
| 271 | (LPDWORD) arg3,
|
|---|
| 272 | (LPVOID) arg4));
|
|---|
| 273 |
|
|---|
| 274 | case DRQ_READCONSOLEW:
|
|---|
| 275 | return (HMDeviceConsoleInClass::
|
|---|
| 276 | ReadConsoleW(pHMHandleData,
|
|---|
| 277 | (CONST VOID*) arg1,
|
|---|
| 278 | (DWORD) arg2,
|
|---|
| 279 | (LPDWORD) arg3,
|
|---|
| 280 | (LPVOID) arg4));
|
|---|
| 281 |
|
|---|
| 282 | case DRQ_READCONSOLEINPUTA:
|
|---|
| 283 | return (HMDeviceConsoleInClass::
|
|---|
| 284 | ReadConsoleInputA(pHMHandleData,
|
|---|
| 285 | (PINPUT_RECORD)arg1,
|
|---|
| 286 | (DWORD)arg2,
|
|---|
| 287 | (LPDWORD)arg3));
|
|---|
| 288 |
|
|---|
| 289 | case DRQ_READCONSOLEINPUTW:
|
|---|
| 290 | return (HMDeviceConsoleInClass::
|
|---|
| 291 | ReadConsoleInputW(pHMHandleData,
|
|---|
| 292 | (PINPUT_RECORD)arg1,
|
|---|
| 293 | (DWORD)arg2,
|
|---|
| 294 | (LPDWORD)arg3));
|
|---|
| 295 |
|
|---|
| 296 | case DRQ_WRITECONSOLEINPUTA:
|
|---|
| 297 | return (HMDeviceConsoleInClass::
|
|---|
| 298 | WriteConsoleInputA(pHMHandleData,
|
|---|
| 299 | (PINPUT_RECORD)arg1,
|
|---|
| 300 | (DWORD)arg2,
|
|---|
| 301 | (LPDWORD)arg3));
|
|---|
| 302 |
|
|---|
| 303 | case DRQ_WRITECONSOLEINPUTW:
|
|---|
| 304 | return (HMDeviceConsoleInClass::
|
|---|
| 305 | WriteConsoleInputW(pHMHandleData,
|
|---|
| 306 | (PINPUT_RECORD)arg1,
|
|---|
| 307 | (DWORD)arg2,
|
|---|
| 308 | (LPDWORD)arg3));
|
|---|
| 309 |
|
|---|
| 310 | }
|
|---|
| 311 |
|
|---|
| 312 | #ifdef DEBUG_LOCAL
|
|---|
| 313 | WriteLog("KERNEL32/CONSOLE:HMDeviceConsoleInClass:_DeviceRequest %s(%08x,%08x,%08x,%08x,%08x,%08x) unknown request\n",
|
|---|
| 314 | lpHMDeviceName,
|
|---|
| 315 | pHMHandleData->hHMHandle,
|
|---|
| 316 | ulRequestCode,
|
|---|
| 317 | arg1,
|
|---|
| 318 | arg2,
|
|---|
| 319 | arg3,
|
|---|
| 320 | arg4);
|
|---|
| 321 | #endif
|
|---|
| 322 |
|
|---|
| 323 | SetLastError(ERROR_INVALID_FUNCTION); /* request not implemented */
|
|---|
| 324 | return(FALSE); /* we assume this indicates API call failed */
|
|---|
| 325 | }
|
|---|
| 326 |
|
|---|
| 327 |
|
|---|
| 328 | /*****************************************************************************
|
|---|
| 329 | * Name : BOOL HMDeviceConsoleInClass::FlushConsoleInputBuffer
|
|---|
| 330 | * Purpose : flushes all events from the input queue
|
|---|
| 331 | * Parameters: PHMHANDLEDATA pHMHandleData - handle specific data
|
|---|
| 332 | * Variables :
|
|---|
| 333 | * Result :
|
|---|
| 334 | * Remark :
|
|---|
| 335 | * Status : UNTESTED
|
|---|
| 336 | *
|
|---|
| 337 | * Author : Patrick Haller [Wed, 1998/02/16 11:46]
|
|---|
| 338 | *****************************************************************************/
|
|---|
| 339 |
|
|---|
| 340 | BOOL HMDeviceConsoleInClass::FlushConsoleInputBuffer(PHMHANDLEDATA pHMHandleData)
|
|---|
| 341 | {
|
|---|
| 342 | ULONG ulCounter; /* loop counter */
|
|---|
| 343 |
|
|---|
| 344 | #ifdef DEBUG_LOCAL2
|
|---|
| 345 | WriteLog("KERNEL32/CONSOLE: CONIN$::FlushConsoleInputBuffer(%08x).\n",
|
|---|
| 346 | pHMHandleData);
|
|---|
| 347 | #endif
|
|---|
| 348 |
|
|---|
| 349 | pConsoleInput->ulIndexFree = 0;
|
|---|
| 350 | pConsoleInput->ulIndexEvent = 0;
|
|---|
| 351 | pConsoleInput->ulEvents = 0;
|
|---|
| 352 |
|
|---|
| 353 | for (ulCounter = 0;
|
|---|
| 354 | ulCounter < CONSOLE_INPUTQUEUESIZE;
|
|---|
| 355 | ulCounter++)
|
|---|
| 356 | pConsoleInput->arrInputRecord[ulCounter].EventType = 0x0000; /* free event */
|
|---|
| 357 |
|
|---|
| 358 | return (TRUE);
|
|---|
| 359 | }
|
|---|
| 360 |
|
|---|
| 361 |
|
|---|
| 362 | /*****************************************************************************
|
|---|
| 363 | * Name : DWORD HMDeviceConsoleInClass::GetConsoleMode
|
|---|
| 364 | * Purpose : queries the current console mode
|
|---|
| 365 | * Parameters: PHMHANDLEDATA pHMHandleData - handle specific data
|
|---|
| 366 | * LPDWORD lpMode
|
|---|
| 367 | * Variables :
|
|---|
| 368 | * Result :
|
|---|
| 369 |
|
|---|
| 370 | * Remark :
|
|---|
| 371 | * Status : UNTESTED
|
|---|
| 372 | *
|
|---|
| 373 | * Author : Patrick Haller [Wed, 1998/02/16 11:46]
|
|---|
| 374 | *****************************************************************************/
|
|---|
| 375 |
|
|---|
| 376 | DWORD HMDeviceConsoleInClass::GetConsoleMode(PHMHANDLEDATA pHMHandleData,
|
|---|
| 377 | LPDWORD lpMode)
|
|---|
| 378 | {
|
|---|
| 379 | #ifdef DEBUG_LOCAL2
|
|---|
| 380 | WriteLog("KERNEL32/CONSOLE: CONIN$::GetConsoleMode(%08x,%08x).\n",
|
|---|
| 381 | pHMHandleData,
|
|---|
| 382 | lpMode);
|
|---|
| 383 | #endif
|
|---|
| 384 |
|
|---|
| 385 | *lpMode = pConsoleInput->dwConsoleMode; /* return current console mode */
|
|---|
| 386 |
|
|---|
| 387 | return (TRUE);
|
|---|
| 388 | }
|
|---|
| 389 |
|
|---|
| 390 |
|
|---|
| 391 | /*****************************************************************************
|
|---|
| 392 | * Name : DWORD HMDeviceConsoleInClass::GetNumberOfConsoleInputEvents
|
|---|
| 393 | * Purpose : queries the current number of events in the input queue
|
|---|
| 394 | * Parameters: PHMHANDLEDATA pHMHandleData - handle specific data
|
|---|
| 395 | * LPDWORD lpNumberOfEvents - return number of events
|
|---|
| 396 | * Variables :
|
|---|
| 397 | * Result :
|
|---|
| 398 | * Remark :
|
|---|
| 399 | * Status : UNTESTED
|
|---|
| 400 | *
|
|---|
| 401 | * Author : Patrick Haller [Wed, 1998/02/16 11:46]
|
|---|
| 402 | *****************************************************************************/
|
|---|
| 403 |
|
|---|
| 404 | BOOL HMDeviceConsoleInClass::GetNumberOfConsoleInputEvents(PHMHANDLEDATA pHMHandleData,
|
|---|
| 405 | LPDWORD lpNumberOfEvents)
|
|---|
| 406 | {
|
|---|
| 407 | #ifdef DEBUG_LOCAL2
|
|---|
| 408 | WriteLog("KERNEL32/CONSOLE: CONIN$::GetNumberOfConsoleInputEvents(%08x,%08x).\n",
|
|---|
| 409 | pHMHandleData,
|
|---|
| 410 | lpNumberOfEvents);
|
|---|
| 411 | #endif
|
|---|
| 412 |
|
|---|
| 413 | *lpNumberOfEvents = pConsoleInput->ulEvents; /* return number of events */
|
|---|
| 414 |
|
|---|
| 415 | return (TRUE);
|
|---|
| 416 | }
|
|---|
| 417 |
|
|---|
| 418 |
|
|---|
| 419 | /*****************************************************************************
|
|---|
| 420 | * Name : DWORD HMDeviceConsoleInClass::PeekConsoleInputA
|
|---|
| 421 | * Purpose : peeks events placed in the console input queue
|
|---|
| 422 | * Parameters: PHMHANDLEDATA pHMHandleData - current handle data
|
|---|
| 423 | * PINPUT_RECORD pirBuffer - target buffer for events
|
|---|
| 424 | * DWORD cInRecords - number of input records
|
|---|
| 425 | * LPDWORD lpcRead - returns number of events stored
|
|---|
| 426 | * Variables :
|
|---|
| 427 | * Result : TRUE if successful, FALSE otherwise
|
|---|
| 428 | * Remark : if queue is completely filled and no event is free,
|
|---|
| 429 | * loop will scan over queue multiple times, until target
|
|---|
| 430 | * buffer is filled. It does not check ulCounter to stop
|
|---|
| 431 | * when one scan of the queue is complete.
|
|---|
| 432 | * Status : UNTESTED
|
|---|
| 433 | *
|
|---|
| 434 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 435 | *****************************************************************************/
|
|---|
| 436 |
|
|---|
| 437 | DWORD HMDeviceConsoleInClass::PeekConsoleInputA(PHMHANDLEDATA pHMHandleData,
|
|---|
| 438 | PINPUT_RECORD pirBuffer,
|
|---|
| 439 | DWORD cInRecords,
|
|---|
| 440 | LPDWORD lpcRead)
|
|---|
| 441 | {
|
|---|
| 442 | ULONG ulCounter; /* loop counter */
|
|---|
| 443 | ULONG ulCurrentEvent; /* index of current event in the queue */
|
|---|
| 444 | PINPUT_RECORD pirEvent; /* pointer to current queue element */
|
|---|
| 445 |
|
|---|
| 446 | #ifdef DEBUG_LOCAL2
|
|---|
| 447 | WriteLog("KERNEL32/CONSOLE: HMDeviceConsoleInClass::PeekConsoleInputA(%08x,%08x,%08x,%08x).\n",
|
|---|
| 448 | pHMHandleData,
|
|---|
| 449 | pirBuffer,
|
|---|
| 450 | cInRecords,
|
|---|
| 451 | lpcRead);
|
|---|
| 452 | #endif
|
|---|
| 453 |
|
|---|
| 454 | if (iConsoleInputQueryEvents() == 0) /* if queue is currently empty */
|
|---|
| 455 | {
|
|---|
| 456 | *lpcRead = 0; /* no events read from queue */
|
|---|
| 457 | return (TRUE); /* OK, we're done */
|
|---|
| 458 | }
|
|---|
| 459 |
|
|---|
| 460 |
|
|---|
| 461 | for (ulCounter = 0,
|
|---|
| 462 | ulCurrentEvent = pConsoleInput->ulIndexEvent,
|
|---|
| 463 | pirEvent = &pConsoleInput->arrInputRecord[pConsoleInput->ulIndexEvent];
|
|---|
| 464 |
|
|---|
| 465 | ulCounter < cInRecords;
|
|---|
| 466 |
|
|---|
| 467 | ulCounter++,
|
|---|
| 468 | ulCurrentEvent++,
|
|---|
| 469 | pirEvent++,
|
|---|
| 470 | pirBuffer++)
|
|---|
| 471 | {
|
|---|
| 472 | if (ulCurrentEvent > CONSOLE_INPUTQUEUESIZE) /* reaching after end of que*/
|
|---|
| 473 | {
|
|---|
| 474 | ulCurrentEvent = 0; /* then start over from beginning of queue */
|
|---|
| 475 | pirEvent = pConsoleInput->arrInputRecord;
|
|---|
| 476 | }
|
|---|
| 477 |
|
|---|
| 478 | if (pirEvent->EventType == 0x0000) /* no more events ? */
|
|---|
| 479 | break; /* leave loop then */
|
|---|
| 480 |
|
|---|
| 481 | memcpy(pirEvent, /* copy event data */
|
|---|
| 482 | pirBuffer,
|
|---|
| 483 | sizeof(INPUT_RECORD));
|
|---|
| 484 | }
|
|---|
| 485 |
|
|---|
| 486 | *lpcRead = ulCounter; /* return number of events read */
|
|---|
| 487 | return (TRUE); /* OK, we're done */
|
|---|
| 488 | }
|
|---|
| 489 |
|
|---|
| 490 |
|
|---|
| 491 | /*****************************************************************************
|
|---|
| 492 | * Name : DWORD HMDeviceConsoleInClass::PeekConsoleInputW
|
|---|
| 493 | * Purpose : peeks events placed in the console input queue
|
|---|
| 494 | * Parameters: PHMHANDLEDATA pHMHandleData - current handle data
|
|---|
| 495 | * PINPUT_RECORD pirBuffer - target buffer for events
|
|---|
| 496 | * DWORD cInRecords - number of input records
|
|---|
| 497 | * LPDWORD lpcRead - returns number of events stored
|
|---|
| 498 | * Variables :
|
|---|
| 499 | * Result : TRUE if successful, FALSE otherwise
|
|---|
| 500 | * Remark : if queue is completely filled and no event is free,
|
|---|
| 501 | * loop will scan over queue multiple times, until target
|
|---|
| 502 | * buffer is filled. It does not check ulCounter to stop
|
|---|
| 503 | * when one scan of the queue is complete.
|
|---|
| 504 | * Status : UNTESTED
|
|---|
| 505 | *
|
|---|
| 506 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 507 | *****************************************************************************/
|
|---|
| 508 |
|
|---|
| 509 | DWORD HMDeviceConsoleInClass::PeekConsoleInputW(PHMHANDLEDATA pHMHandleData,
|
|---|
| 510 | PINPUT_RECORD pirBuffer,
|
|---|
| 511 | DWORD cInRecords,
|
|---|
| 512 | LPDWORD lpcRead)
|
|---|
| 513 | {
|
|---|
| 514 | ULONG ulCounter; /* loop counter */
|
|---|
| 515 | ULONG ulCurrentEvent; /* index of current event in the queue */
|
|---|
| 516 | PINPUT_RECORD pirEvent; /* pointer to current queue element */
|
|---|
| 517 |
|
|---|
| 518 | #ifdef DEBUG_LOCAL2
|
|---|
| 519 | WriteLog("KERNEL32/CONSOLE: HMDeviceConsoleInClass::PeekConsoleInputW(%08x,%08x,%08x,%08x).\n",
|
|---|
| 520 | pHMHandleData,
|
|---|
| 521 | pirBuffer,
|
|---|
| 522 | cInRecords,
|
|---|
| 523 | lpcRead);
|
|---|
| 524 | #endif
|
|---|
| 525 |
|
|---|
| 526 | if (iConsoleInputQueryEvents() == 0) /* if queue is currently empty */
|
|---|
| 527 | {
|
|---|
| 528 | *lpcRead = 0; /* no events read from queue */
|
|---|
| 529 | return (TRUE); /* OK, we're done */
|
|---|
| 530 | }
|
|---|
| 531 |
|
|---|
| 532 |
|
|---|
| 533 | for (ulCounter = 0,
|
|---|
| 534 | ulCurrentEvent = pConsoleInput->ulIndexEvent,
|
|---|
| 535 | pirEvent = &pConsoleInput->arrInputRecord[pConsoleInput->ulIndexEvent];
|
|---|
| 536 |
|
|---|
| 537 | ulCounter < cInRecords;
|
|---|
| 538 |
|
|---|
| 539 | ulCounter++,
|
|---|
| 540 | ulCurrentEvent++,
|
|---|
| 541 | pirEvent++,
|
|---|
| 542 | pirBuffer++)
|
|---|
| 543 | {
|
|---|
| 544 | if (ulCurrentEvent > CONSOLE_INPUTQUEUESIZE) /* reaching after end of que*/
|
|---|
| 545 | {
|
|---|
| 546 | ulCurrentEvent = 0; /* then start over from beginning of queue */
|
|---|
| 547 | pirEvent = pConsoleInput->arrInputRecord;
|
|---|
| 548 | }
|
|---|
| 549 |
|
|---|
| 550 | if (pirEvent->EventType == 0x0000) /* no more events ? */
|
|---|
| 551 | break; /* leave loop then */
|
|---|
| 552 |
|
|---|
| 553 | memcpy(pirEvent, /* copy event data */
|
|---|
| 554 | pirBuffer,
|
|---|
| 555 | sizeof(INPUT_RECORD));
|
|---|
| 556 | }
|
|---|
| 557 |
|
|---|
| 558 | *lpcRead = ulCounter; /* return number of events read */
|
|---|
| 559 | return (TRUE); /* OK, we're done */
|
|---|
| 560 | }
|
|---|
| 561 |
|
|---|
| 562 |
|
|---|
| 563 | /*****************************************************************************
|
|---|
| 564 | * Name : DWORD HMDeviceConsoleInClass::ReadConsoleA
|
|---|
| 565 | * Purpose : read a string from the console
|
|---|
| 566 | * Parameters: PHMHANDLEDATA pHMHandleData - handle specific data
|
|---|
| 567 | * LPWORD lpwAttribute
|
|---|
| 568 | * DWORD cWriteCells
|
|---|
| 569 | * COORD dwWriteCoord
|
|---|
| 570 | * LPDWORD lpcWritten
|
|---|
| 571 | * Variables :
|
|---|
| 572 | * Result :
|
|---|
| 573 | * Remark :
|
|---|
| 574 | * Status : UNTESTED
|
|---|
| 575 | *
|
|---|
| 576 | * Author : Patrick Haller [Wed, 1998/02/16 11:46]
|
|---|
| 577 | *****************************************************************************/
|
|---|
| 578 |
|
|---|
| 579 | DWORD HMDeviceConsoleInClass::ReadConsoleA(PHMHANDLEDATA pHMHandleData,
|
|---|
| 580 | CONST VOID* lpvBuffer,
|
|---|
| 581 | DWORD cchToRead,
|
|---|
| 582 | LPDWORD lpcchRead,
|
|---|
| 583 | LPVOID lpvReserved)
|
|---|
| 584 | {
|
|---|
| 585 | PCONSOLEBUFFER pConsoleBuffer = (PCONSOLEBUFFER)pHMHandleData->lpHandlerData;
|
|---|
| 586 |
|
|---|
| 587 | #ifdef DEBUG_LOCAL2
|
|---|
| 588 | WriteLog("KERNEL32/CONSOLE: CONIN$::ReadConsoleA(%08x,%08x,%u,%08x,%08x).\n",
|
|---|
| 589 | pHMHandleData,
|
|---|
| 590 | lpvBuffer,
|
|---|
| 591 | cchToRead,
|
|---|
| 592 | lpcchRead,
|
|---|
| 593 | lpvReserved);
|
|---|
| 594 | #endif
|
|---|
| 595 |
|
|---|
| 596 | /* simply forward the request to that routine */
|
|---|
| 597 | return (HMDeviceConsoleInClass::ReadFile(pHMHandleData,
|
|---|
| 598 | lpvBuffer,
|
|---|
| 599 | cchToRead,
|
|---|
| 600 | lpcchRead,
|
|---|
| 601 | NULL));
|
|---|
| 602 | }
|
|---|
| 603 |
|
|---|
| 604 |
|
|---|
| 605 | /*****************************************************************************
|
|---|
| 606 | * Name : DWORD HMDeviceConsoleInClass::ReadConsoleW
|
|---|
| 607 | * Purpose : write a string to the console
|
|---|
| 608 | * Parameters: PHMHANDLEDATA pHMHandleData - handle specific data
|
|---|
| 609 | * LPWORD lpwAttribute
|
|---|
| 610 | * DWORD cWriteCells
|
|---|
| 611 | * COORD dwWriteCoord
|
|---|
| 612 | * LPDWORD lpcWritten
|
|---|
| 613 | * Variables :
|
|---|
| 614 | * Result :
|
|---|
| 615 | * Remark :
|
|---|
| 616 | * Status : UNTESTED
|
|---|
| 617 | *
|
|---|
| 618 | * Author : Patrick Haller [Wed, 1998/02/16 11:46]
|
|---|
| 619 | *****************************************************************************/
|
|---|
| 620 |
|
|---|
| 621 | DWORD HMDeviceConsoleInClass::ReadConsoleW(PHMHANDLEDATA pHMHandleData,
|
|---|
| 622 | CONST VOID* lpvBuffer,
|
|---|
| 623 | DWORD cchToRead,
|
|---|
| 624 | LPDWORD lpcchRead,
|
|---|
| 625 | LPVOID lpvReserved)
|
|---|
| 626 | {
|
|---|
| 627 | PCONSOLEBUFFER pConsoleBuffer = (PCONSOLEBUFFER)pHMHandleData->lpHandlerData;
|
|---|
| 628 | DWORD dwResult;
|
|---|
| 629 |
|
|---|
| 630 | #ifdef DEBUG_LOCAL2
|
|---|
| 631 | WriteLog("KERNEL32/CONSOLE: CONIN$::ReadConsoleW(%08x,%08x,%u,%08x,%08x).\n",
|
|---|
| 632 | pHMHandleData,
|
|---|
| 633 | lpvBuffer,
|
|---|
| 634 | cchToRead,
|
|---|
| 635 | lpcchRead,
|
|---|
| 636 | lpvReserved);
|
|---|
| 637 | #endif
|
|---|
| 638 |
|
|---|
| 639 | /* simply forward the request to that routine */
|
|---|
| 640 | dwResult = HMDeviceConsoleInClass::ReadFile(pHMHandleData,
|
|---|
| 641 | lpvBuffer,
|
|---|
| 642 | cchToRead,
|
|---|
| 643 | lpcchRead,
|
|---|
| 644 | NULL);
|
|---|
| 645 | /* @@@PH AScii -> unicode translation */
|
|---|
| 646 |
|
|---|
| 647 | return (dwResult); /* deliver return code */
|
|---|
| 648 | }
|
|---|
| 649 |
|
|---|
| 650 |
|
|---|
| 651 | /*****************************************************************************
|
|---|
| 652 | * Name : DWORD HMDeviceConsoleInClass::ReadConsoleInputA
|
|---|
| 653 | * Purpose : read events placed in the console input queue
|
|---|
| 654 | * Parameters: PHMHANDLEDATA pHMHandleData - current handle data
|
|---|
| 655 | * PINPUT_RECORD pirBuffer - target buffer for events
|
|---|
| 656 | * DWORD cInRecords - number of input records
|
|---|
| 657 | * LPDWORD lpcRead - returns number of events stored
|
|---|
| 658 | * Variables :
|
|---|
| 659 | * Result : TRUE if successful, FALSE otherwise
|
|---|
| 660 | * Remark :
|
|---|
| 661 | * Status : UNTESTED
|
|---|
| 662 | *
|
|---|
| 663 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 664 | *****************************************************************************/
|
|---|
| 665 |
|
|---|
| 666 | DWORD HMDeviceConsoleInClass::ReadConsoleInputA(PHMHANDLEDATA pHMHandleData,
|
|---|
| 667 | PINPUT_RECORD pirBuffer,
|
|---|
| 668 | DWORD cInRecords,
|
|---|
| 669 | LPDWORD lpcRead)
|
|---|
| 670 | {
|
|---|
| 671 | ULONG ulPostCounter; /* semaphore post counter - ignored */
|
|---|
| 672 | APIRET rc; /* API returncode */
|
|---|
| 673 |
|
|---|
| 674 | #ifdef DEBUG_LOCAL2
|
|---|
| 675 | WriteLog("KERNEL32/CONSOLE: HMDeviceConsoleInClass::ReadConsoleInputA(%08x,%08x,%08x,%08x).\n",
|
|---|
| 676 | pHMHandleData,
|
|---|
| 677 | pirBuffer,
|
|---|
| 678 | cInRecords,
|
|---|
| 679 | lpcRead);
|
|---|
| 680 | #endif
|
|---|
| 681 |
|
|---|
| 682 | if (iConsoleInputQueryEvents() == 0) /* if queue is currently empty */
|
|---|
| 683 | {
|
|---|
| 684 | rc = DosWaitEventSem(pConsoleInput->hevInputQueue, /* wait for input */
|
|---|
| 685 | SEM_INDEFINITE_WAIT);
|
|---|
| 686 | DosResetEventSem(pConsoleInput->hevInputQueue, /* reset semaphore */
|
|---|
| 687 | &ulPostCounter); /* post counter - ignored */
|
|---|
| 688 | }
|
|---|
| 689 |
|
|---|
| 690 |
|
|---|
| 691 | /* now read events into target buffer */
|
|---|
| 692 | for (ulPostCounter = 0;
|
|---|
| 693 | ulPostCounter < cInRecords;
|
|---|
| 694 | ulPostCounter++,
|
|---|
| 695 | pirBuffer++)
|
|---|
| 696 | {
|
|---|
| 697 | rc = iConsoleInputEventPop(pirBuffer); /* get event from queue */
|
|---|
| 698 | if (rc != NO_ERROR) /* if read error occurs, break look */
|
|---|
| 699 | break;
|
|---|
| 700 | }
|
|---|
| 701 |
|
|---|
| 702 | *lpcRead = ulPostCounter; /* return number of records read */
|
|---|
| 703 | return (TRUE); /* OK */
|
|---|
| 704 | }
|
|---|
| 705 |
|
|---|
| 706 |
|
|---|
| 707 | /*****************************************************************************
|
|---|
| 708 | * Name : DWORD HMDeviceConsoleInClass::ReadConsoleInputW
|
|---|
| 709 | * Purpose : read events placed in the console input queue
|
|---|
| 710 | * Parameters: PHMHANDLEDATA pHMHandleData - current handle data
|
|---|
| 711 | * PINPUT_RECORD pirBuffer - target buffer for events
|
|---|
| 712 | * DWORD cInRecords - number of input records
|
|---|
| 713 | * LPDWORD lpcRead - returns number of events stored
|
|---|
| 714 | * Variables :
|
|---|
| 715 | * Result : TRUE if successful, FALSE otherwise
|
|---|
| 716 | * Remark :
|
|---|
| 717 | * Status : UNTESTED
|
|---|
| 718 | *
|
|---|
| 719 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 720 | *****************************************************************************/
|
|---|
| 721 |
|
|---|
| 722 | DWORD HMDeviceConsoleInClass::ReadConsoleInputW(PHMHANDLEDATA pHMHandleData,
|
|---|
| 723 | PINPUT_RECORD pirBuffer,
|
|---|
| 724 | DWORD cInRecords,
|
|---|
| 725 | LPDWORD lpcRead)
|
|---|
| 726 | {
|
|---|
| 727 | ULONG ulPostCounter; /* semaphore post counter - ignored */
|
|---|
| 728 | APIRET rc; /* API returncode */
|
|---|
| 729 |
|
|---|
| 730 | #ifdef DEBUG_LOCAL2
|
|---|
| 731 | WriteLog("KERNEL32/CONSOLE: HMDeviceConsoleInClass::ReadConsoleInputW(%08x,%08x,%08x,%08x).\n",
|
|---|
| 732 | pHMHandleData,
|
|---|
| 733 | pirBuffer,
|
|---|
| 734 | cInRecords,
|
|---|
| 735 | lpcRead);
|
|---|
| 736 | #endif
|
|---|
| 737 |
|
|---|
| 738 | if (iConsoleInputQueryEvents() == 0) /* if queue is currently empty */
|
|---|
| 739 | {
|
|---|
| 740 | rc = DosWaitEventSem(pConsoleInput->hevInputQueue, /* wait for input */
|
|---|
| 741 | SEM_INDEFINITE_WAIT);
|
|---|
| 742 | DosResetEventSem(pConsoleInput->hevInputQueue, /* reset semaphore */
|
|---|
| 743 | &ulPostCounter); /* post counter - ignored */
|
|---|
| 744 | }
|
|---|
| 745 |
|
|---|
| 746 |
|
|---|
| 747 | /* now read events into target buffer */
|
|---|
| 748 | for (ulPostCounter = 0;
|
|---|
| 749 | ulPostCounter < cInRecords;
|
|---|
| 750 | ulPostCounter++,
|
|---|
| 751 | pirBuffer++)
|
|---|
| 752 | {
|
|---|
| 753 | rc = iConsoleInputEventPop(pirBuffer); /* get event from queue */
|
|---|
| 754 | if (rc != NO_ERROR) /* if read error occurs, break look */
|
|---|
| 755 | break;
|
|---|
| 756 | }
|
|---|
| 757 |
|
|---|
| 758 | *lpcRead = ulPostCounter; /* return number of records read */
|
|---|
| 759 | return (TRUE); /* OK */
|
|---|
| 760 | }
|
|---|
| 761 |
|
|---|
| 762 |
|
|---|
| 763 | /*****************************************************************************
|
|---|
| 764 | * Name : DWORD HMDeviceConsoleInClass::SetConsoleMode
|
|---|
| 765 | * Purpose : sets the current console mode
|
|---|
| 766 | * Parameters: PHMHANDLEDATA pHMHandleData - handle specific data
|
|---|
| 767 | * DWORD dwMode - console mode
|
|---|
| 768 | * Variables :
|
|---|
| 769 | * Result :
|
|---|
| 770 | * Remark :
|
|---|
| 771 | * Status : UNTESTED
|
|---|
| 772 | *
|
|---|
| 773 | * Author : Patrick Haller [Wed, 1998/02/16 11:46]
|
|---|
| 774 | *****************************************************************************/
|
|---|
| 775 |
|
|---|
| 776 | DWORD HMDeviceConsoleInClass::SetConsoleMode(PHMHANDLEDATA pHMHandleData,
|
|---|
| 777 | DWORD dwMode)
|
|---|
| 778 | {
|
|---|
| 779 | PCONSOLEBUFFER pConsoleBuffer = (PCONSOLEBUFFER)pHMHandleData->lpHandlerData;
|
|---|
| 780 |
|
|---|
| 781 | #ifdef DEBUG_LOCAL2
|
|---|
| 782 | WriteLog("KERNEL32/CONSOLE: CONIN$::SetConsoleMode(%08x,%08x).\n",
|
|---|
| 783 | pHMHandleData,
|
|---|
| 784 | dwMode);
|
|---|
| 785 | #endif
|
|---|
| 786 |
|
|---|
| 787 | pConsoleInput->dwConsoleMode = dwMode; /* set current console mode */
|
|---|
| 788 |
|
|---|
| 789 | return (TRUE);
|
|---|
| 790 | }
|
|---|
| 791 |
|
|---|
| 792 |
|
|---|
| 793 | /*****************************************************************************
|
|---|
| 794 | * Name : DWORD HMDeviceConsoleInClass::WriteConsoleInputA
|
|---|
| 795 | * Purpose : this writes event records directly into the queue
|
|---|
| 796 | * Parameters: PHMHANDLEDATA pHMHandleData
|
|---|
| 797 | * PINPUT_RECORD pirBuffer
|
|---|
| 798 | * DWORD cInRecords
|
|---|
| 799 | * LPDWORD lpcWritten
|
|---|
| 800 | * Variables :
|
|---|
| 801 | * Result :
|
|---|
| 802 | * Remark :
|
|---|
| 803 | * Status : NO_ERROR - API succeeded
|
|---|
| 804 | * other - what is to be set in SetLastError
|
|---|
| 805 | *
|
|---|
| 806 | * Author : Patrick Haller [Wed, 1998/02/11 20:44]
|
|---|
| 807 | *****************************************************************************/
|
|---|
| 808 |
|
|---|
| 809 | DWORD HMDeviceConsoleInClass::WriteConsoleInputA (PHMHANDLEDATA pHMHandleData,
|
|---|
| 810 | PINPUT_RECORD pirBuffer,
|
|---|
| 811 | DWORD cInRecords,
|
|---|
| 812 | LPDWORD lpcWritten)
|
|---|
| 813 | {
|
|---|
| 814 | PCONSOLEBUFFER pConsoleBuffer = (PCONSOLEBUFFER)pHMHandleData->lpHandlerData;
|
|---|
| 815 | APIRET rc; /* API returncode */
|
|---|
| 816 | ULONG ulCounter; /* loop counter */
|
|---|
| 817 |
|
|---|
| 818 | #ifdef DEBUG_LOCAL2
|
|---|
| 819 | WriteLog("KERNEL32/CONSOLE: CONIN$::WriteConsoleInputA(%08x,%08x,%u,%08x).\n",
|
|---|
| 820 | pHMHandleData,
|
|---|
| 821 | pirBuffer,
|
|---|
| 822 | cInRecords,
|
|---|
| 823 | lpcWritten);
|
|---|
| 824 | #endif
|
|---|
| 825 |
|
|---|
| 826 | for (ulCounter = 0;
|
|---|
| 827 | ulCounter < cInRecords;
|
|---|
| 828 | ulCounter++,
|
|---|
| 829 | pirBuffer++)
|
|---|
| 830 | {
|
|---|
| 831 | rc = iConsoleInputEventPush(pirBuffer); /* push current event */
|
|---|
| 832 | if (rc != NO_ERROR) /* oops ? queue full ? problem ? */
|
|---|
| 833 | break;
|
|---|
| 834 | }
|
|---|
| 835 |
|
|---|
| 836 | *lpcWritten = ulCounter; /* return number of events written */
|
|---|
| 837 | return (TRUE); /* OK */
|
|---|
| 838 | }
|
|---|
| 839 |
|
|---|
| 840 |
|
|---|
| 841 | /*****************************************************************************
|
|---|
| 842 | * Name : DWORD HMDeviceConsoleInClass::WriteConsoleInputW
|
|---|
| 843 | * Purpose : this writes event records directly into the queue
|
|---|
| 844 | * Parameters: PHMHANDLEDATA pHMHandleData
|
|---|
| 845 | * PINPUT_RECORD pirBuffer
|
|---|
| 846 | * DWORD cInRecords
|
|---|
| 847 | * LPDWORD lpcWritten
|
|---|
| 848 | * Variables :
|
|---|
| 849 | * Result :
|
|---|
| 850 | * Remark :
|
|---|
| 851 | * Status : NO_ERROR - API succeeded
|
|---|
| 852 | * other - what is to be set in SetLastError
|
|---|
| 853 | *
|
|---|
| 854 | * Author : Patrick Haller [Wed, 1998/02/11 20:44]
|
|---|
| 855 | *****************************************************************************/
|
|---|
| 856 |
|
|---|
| 857 | DWORD HMDeviceConsoleInClass::WriteConsoleInputW (PHMHANDLEDATA pHMHandleData,
|
|---|
| 858 | PINPUT_RECORD pirBuffer,
|
|---|
| 859 | DWORD cInRecords,
|
|---|
| 860 | LPDWORD lpcWritten)
|
|---|
| 861 | {
|
|---|
| 862 | PCONSOLEBUFFER pConsoleBuffer = (PCONSOLEBUFFER)pHMHandleData->lpHandlerData;
|
|---|
| 863 | APIRET rc; /* API returncode */
|
|---|
| 864 | ULONG ulCounter; /* loop counter */
|
|---|
| 865 |
|
|---|
| 866 | #ifdef DEBUG_LOCAL2
|
|---|
| 867 | WriteLog("KERNEL32/CONSOLE: CONIN$::WriteConsoleInputW(%08x,%08x,%u,%08x).\n",
|
|---|
| 868 | pHMHandleData,
|
|---|
| 869 | pirBuffer,
|
|---|
| 870 | cInRecords,
|
|---|
| 871 | lpcWritten);
|
|---|
| 872 | #endif
|
|---|
| 873 |
|
|---|
| 874 | for (ulCounter = 0;
|
|---|
| 875 | ulCounter < cInRecords;
|
|---|
| 876 | ulCounter++,
|
|---|
| 877 | pirBuffer++)
|
|---|
| 878 | {
|
|---|
| 879 | rc = iConsoleInputEventPush(pirBuffer); /* push current event */
|
|---|
| 880 | if (rc != NO_ERROR) /* oops ? queue full ? problem ? */
|
|---|
| 881 | break;
|
|---|
| 882 | }
|
|---|
| 883 |
|
|---|
| 884 | *lpcWritten = ulCounter; /* return number of events written */
|
|---|
| 885 | return (TRUE); /* OK */
|
|---|
| 886 | }
|
|---|
| 887 |
|
|---|
| 888 |
|
|---|