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