KEY.CPP (40699B)
1 // 2 // Copyright 2020 Electronic Arts Inc. 3 // 4 // TiberianDawn.DLL and RedAlert.dll and corresponding source code is free 5 // software: you can redistribute it and/or modify it under the terms of 6 // the GNU General Public License as published by the Free Software Foundation, 7 // either version 3 of the License, or (at your option) any later version. 8 9 // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed 10 // in the hope that it will be useful, but with permitted additional restrictions 11 // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT 12 // distributed with this program. You should have received a copy of the 13 // GNU General Public License along with permitted additional restrictions 14 // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection 15 16 /* $Header: /CounterStrike/KEY.CPP 1 3/03/97 10:25a Joe_bostic $ */ 17 /*********************************************************************************************** 18 * * 19 * Project Name : Westwood Keyboard Library * 20 * * 21 * File Name : KEYBOARD.CPP * 22 * * 23 * Programmer : Philip W. Gorrow * 24 * * 25 * Start Date : 10/16/95 * 26 * * 27 * Last Update : November 2, 1996 [JLB] * 28 * * 29 *---------------------------------------------------------------------------------------------* 30 * Functions: * 31 * WWKeyboardClass::Buff_Get -- Lowlevel function to get a key from key buffer * 32 * WWKeyboardClass::Check -- Checks to see if a key is in the buffer * 33 * WWKeyboardClass::Clear -- Clears the keyboard buffer. * 34 * WWKeyboardClass::Down -- Checks to see if the specified key is being held down. * 35 * WWKeyboardClass::Fetch_Element -- Extract the next element in the keyboard buffer. * 36 * WWKeyboardClass::Fill_Buffer_From_Syste -- Extract and process any queued windows messages* 37 * WWKeyboardClass::Get -- Logic to get a metakey from the buffer * 38 * WWKeyboardClass::Get_Mouse_X -- Returns the mouses current x position in pixels * 39 * WWKeyboardClass::Get_Mouse_XY -- Returns the mouses x,y position via reference vars * 40 * WWKeyboardClass::Get_Mouse_Y -- returns the mouses current y position in pixels * 41 * WWKeyboardClass::Is_Buffer_Empty -- Checks to see if the keyboard buffer is empty. * 42 * WWKeyboardClass::Is_Buffer_Full -- Determines if the keyboard buffer is full. * 43 * WWKeyboardClass::Is_Mouse_Key -- Checks to see if specified key refers to the mouse. * 44 * WWKeyboardClass::Message_Handler -- Process a windows message as it relates to the keyboar* 45 * WWKeyboardClass::Peek_Element -- Fetches the next element in the keyboard buffer. * 46 * WWKeyboardClass::Put -- Logic to insert a key into the keybuffer] * 47 * WWKeyboardClass::Put_Element -- Put a keyboard data element into the buffer. * 48 * WWKeyboardClass::Put_Key_Message -- Translates and inserts wParam into Keyboard Buffer * 49 * WWKeyboardClass::To_ASCII -- Convert the key value into an ASCII representation. * 50 * WWKeyboardClass::Available_Buffer_Room -- Fetch the quantity of free elements in the keybo* 51 * WWKeyboardClass::Put_Mouse_Message -- Stores a mouse type message into the keyboard buffer* 52 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ 53 54 #include "key.h" 55 56 #include "monoc.h" 57 58 //void Message_Loop(void); 59 60 //WWKeyboardClass * _Kbd = NULL; 61 62 63 #define ARRAY_SIZE(x) int(sizeof(x)/sizeof(x[0])) 64 65 66 /*********************************************************************************************** 67 * WWKeyboardClass::WWKeyBoardClass -- Construction for Westwood Keyboard Class * 68 * * 69 * INPUT: none * 70 * * 71 * OUTPUT: none * 72 * * 73 * HISTORY: * 74 * 10/16/1995 PWG : Created. * 75 *=============================================================================================*/ 76 WWKeyboardClass::WWKeyboardClass(void) : 77 MouseQX(0), 78 MouseQY(0), 79 Head(0), 80 Tail(0) 81 { 82 // _Kbd = this; 83 84 memset(KeyState, '\0', sizeof(KeyState)); 85 } 86 87 88 /*********************************************************************************************** 89 * WWKeyboardClass::Buff_Get -- Lowlevel function to get a key from key buffer * 90 * * 91 * INPUT: none * 92 * * 93 * OUTPUT: int - the key value that was pulled from buffer (includes bits) * * 94 * * 95 * WARNINGS: If the key was a mouse event MouseQX and MouseQY will be updated * 96 * * 97 * HISTORY: * 98 * 10/17/1995 PWG : Created. * 99 *=============================================================================================*/ 100 unsigned short WWKeyboardClass::Buff_Get(void) 101 { 102 while (!Check()) {} // wait for key in buffer 103 104 unsigned short temp = Fetch_Element(); 105 if (Is_Mouse_Key(temp)) { 106 MouseQX = Fetch_Element(); 107 MouseQY = Fetch_Element(); 108 } 109 return(temp); 110 } 111 112 113 /*********************************************************************************************** 114 * WWKeyboardClass::Is_Mouse_Key -- Checks to see if specified key refers to the mouse. * 115 * * 116 * This checks the specified key code to see if it refers to the mouse buttons. * 117 * * 118 * INPUT: key -- The key to check. * 119 * * 120 * OUTPUT: bool; Is the key a mouse button key? * 121 * * 122 * WARNINGS: none * 123 * * 124 * HISTORY: * 125 * 09/30/1996 JLB : Created. * 126 *=============================================================================================*/ 127 bool WWKeyboardClass::Is_Mouse_Key(unsigned short key) 128 { 129 key &= 0xFF; 130 return (key == VK_LBUTTON || key == VK_MBUTTON || key == VK_RBUTTON); 131 } 132 133 134 /*********************************************************************************************** 135 * WWKeyboardClass::Check -- Checks to see if a key is in the buffer * 136 * * 137 * INPUT: * 138 * * 139 * OUTPUT: * 140 * * 141 * WARNINGS: * 142 * * 143 * HISTORY: * 144 * 10/16/1995 PWG : Created. * 145 * 09/24/1996 JLB : Converted to new style keyboard system. * 146 *=============================================================================================*/ 147 unsigned short WWKeyboardClass::Check(void) const 148 { 149 ((WWKeyboardClass *)this)->Fill_Buffer_From_System(); 150 if (Is_Buffer_Empty()) return(false); 151 return(Peek_Element()); 152 } 153 154 155 /*********************************************************************************************** 156 * WWKeyboardClass::Get -- Logic to get a metakey from the buffer * 157 * * 158 * INPUT: none * 159 * * 160 * OUTPUT: int - the meta key taken from the buffer. * 161 * * 162 * WARNINGS: This routine will not return until a keypress is received * 163 * * 164 * HISTORY: * 165 * 10/16/1995 PWG : Created. * 166 *=============================================================================================*/ 167 unsigned short WWKeyboardClass::Get(void) 168 { 169 while (!Check()) {} // wait for key in buffer 170 return (Buff_Get()); 171 } 172 173 174 /*********************************************************************************************** 175 * WWKeyboardClass::Put -- Logic to insert a key into the keybuffer] * 176 * * 177 * INPUT: int - the key to insert into the buffer * 178 * * 179 * OUTPUT: bool - true if key is sucessfuly inserted. * 180 * * 181 * WARNINGS: none * 182 * * 183 * HISTORY: * 184 * 10/16/1995 PWG : Created. * 185 *=============================================================================================*/ 186 bool WWKeyboardClass::Put(unsigned short key) 187 { 188 if (!Is_Buffer_Full()) { 189 Put_Element(key); 190 return(true); 191 } 192 return(false); 193 } 194 195 196 /*********************************************************************************************** 197 * WWKeyboardClass::Put_Key_Message -- Translates and inserts wParam into Keyboard Buffer * 198 * * 199 * INPUT: * 200 * * 201 * OUTPUT: * 202 * * 203 * WARNINGS: * 204 * * 205 * HISTORY: * 206 * 10/16/1995 PWG : Created. * 207 *=============================================================================================*/ 208 bool WWKeyboardClass::Put_Key_Message(unsigned short vk_key, bool release) 209 { 210 /* 211 ** Get the status of all of the different keyboard modifiers. Note, only pay attention 212 ** to numlock and caps lock if we are dealing with a key that is affected by them. Note 213 ** that we do not want to set the shift, ctrl and alt bits for Mouse keypresses as this 214 ** would be incompatible with the dos version. 215 */ 216 if (!Is_Mouse_Key(vk_key)) { 217 if (((GetKeyState(VK_SHIFT) & 0x8000) != 0) || 218 ((GetKeyState(VK_CAPITAL) & 0x0008) != 0) || 219 ((GetKeyState(VK_NUMLOCK) & 0x0008) != 0)) { 220 221 vk_key |= WWKEY_SHIFT_BIT; 222 } 223 if ((GetKeyState(VK_CONTROL) & 0x8000) != 0) { 224 vk_key |= WWKEY_CTRL_BIT; 225 } 226 if ((GetKeyState(VK_MENU) & 0x8000) != 0) { 227 vk_key |= WWKEY_ALT_BIT; 228 } 229 } 230 231 if (release) { 232 vk_key |= WWKEY_RLS_BIT; 233 } 234 235 /* 236 ** Finally use the put command to enter the key into the keyboard 237 ** system. 238 */ 239 return(Put(vk_key)); 240 } 241 242 243 /*********************************************************************************************** 244 * WWKeyboardClass::Put_Mouse_Message -- Stores a mouse type message into the keyboard buffer. * 245 * * 246 * This routine will store the mouse type event into the keyboard buffer. It also checks * 247 * to ensure that there is enough room in the buffer so that partial mouse events won't * 248 * be recorded. * 249 * * 250 * INPUT: vk_key -- The mouse key message itself. * 251 * * 252 * x,y -- The mouse coordinates at the time of the event. * 253 * * 254 * release -- Is this a mouse button release? * 255 * * 256 * OUTPUT: bool; Was the event stored sucessfully into the keyboard buffer? * 257 * * 258 * WARNINGS: none * 259 * * 260 * HISTORY: * 261 * 11/02/1996 JLB : Created. * 262 *=============================================================================================*/ 263 bool WWKeyboardClass::Put_Mouse_Message(unsigned short vk_key, int x, int y, bool release) 264 { 265 if (Available_Buffer_Room() >= 3 && Is_Mouse_Key(vk_key)) { 266 Put_Key_Message(vk_key, release); 267 Put((unsigned short)x); 268 Put((unsigned short)y); 269 return(true); 270 } 271 return(false); 272 } 273 274 275 /*********************************************************************************************** 276 * WWKeyboardClass::To_ASCII -- Convert the key value into an ASCII representation. * 277 * * 278 * This routine will convert the key code specified into an ASCII value. This takes into * 279 * consideration the language and keyboard mapping of the host Windows system. * 280 * * 281 * INPUT: key -- The key code to convert into ASCII. * 282 * * 283 * OUTPUT: Returns with the key converted into ASCII. If the key has no ASCII equivalent, * 284 * then '\0' is returned. * 285 * * 286 * WARNINGS: none * 287 * * 288 * HISTORY: * 289 * 09/30/1996 JLB : Created. * 290 *=============================================================================================*/ 291 char WWKeyboardClass::To_ASCII(unsigned short key) 292 { 293 /* 294 ** Released keys never translate into an ASCII value. 295 */ 296 if (key & WWKEY_RLS_BIT) { 297 return('\0'); 298 } 299 300 /* 301 ** Set the KeyState buffer to reflect the shift bits stored in the key value. 302 */ 303 if (key & WWKEY_SHIFT_BIT) { 304 KeyState[VK_SHIFT] = 0x80; 305 } 306 if (key & WWKEY_CTRL_BIT) { 307 KeyState[VK_CONTROL] = 0x80; 308 } 309 if (key & WWKEY_ALT_BIT) { 310 KeyState[VK_MENU] = 0x80; 311 } 312 313 /* 314 ** Ask windows to translate the key into an ASCII equivalent. 315 */ 316 char buffer[10]; 317 int result = 1; 318 int scancode = 0; 319 320 scancode = MapVirtualKey(key & 0xFF, 0); 321 result = ToAscii((UINT)(key & 0xFF), (UINT)scancode, (PBYTE)KeyState, (LPWORD)buffer, (UINT)0); 322 323 /* 324 ** Restore the KeyState buffer back to pristine condition. 325 */ 326 if (key & WWKEY_SHIFT_BIT) { 327 KeyState[VK_SHIFT] = 0; 328 } 329 if (key & WWKEY_CTRL_BIT) { 330 KeyState[VK_CONTROL] = 0; 331 } 332 if (key & WWKEY_ALT_BIT) { 333 KeyState[VK_MENU] = 0; 334 } 335 336 /* 337 ** If Windows could not perform the translation as expected, then 338 ** return with a null ASCII value. 339 */ 340 if (result != 1) { 341 return('\0'); 342 } 343 344 return(buffer[0]); 345 } 346 347 348 /*********************************************************************************************** 349 * WWKeyboardClass::Down -- Checks to see if the specified key is being held down. * 350 * * 351 * This routine will examine the key specified to see if it is currently being held down. * 352 * * 353 * INPUT: key -- The key to check. * 354 * * 355 * OUTPUT: bool; Is the specified key currently being held down? * 356 * * 357 * WARNINGS: none * 358 * * 359 * HISTORY: * 360 * 09/30/1996 JLB : Created. * 361 *=============================================================================================*/ 362 bool WWKeyboardClass::Down(unsigned short key) 363 { 364 return(GetAsyncKeyState(key & 0xFF) == 0 ? false : true); 365 } 366 367 368 extern "C" { 369 void __cdecl Stop_Execution (void); 370 } 371 372 373 /*********************************************************************************************** 374 * WWKeyboardClass::Fetch_Element -- Extract the next element in the keyboard buffer. * 375 * * 376 * This routine will extract the next pending element in the keyboard queue. If there is * 377 * no element available, then NULL is returned. * 378 * * 379 * INPUT: none * 380 * * 381 * OUTPUT: Returns with the element extracted from the queue. An empty queue is signified * 382 * by a 0 return value. * 383 * * 384 * WARNINGS: * 385 * * 386 * HISTORY: * 387 * 09/30/1996 JLB : Created. * 388 *=============================================================================================*/ 389 unsigned short WWKeyboardClass::Fetch_Element(void) 390 { 391 unsigned short val = 0; 392 if (Head != Tail) { 393 val = Buffer[Head]; 394 395 Head = (Head + 1) % ARRAY_SIZE(Buffer); 396 } 397 return(val); 398 } 399 400 401 /*********************************************************************************************** 402 * WWKeyboardClass::Peek_Element -- Fetches the next element in the keyboard buffer. * 403 * * 404 * This routine will examine and return with the next element in the keyboard buffer but * 405 * it will not alter or remove that element. Use this routine to see what is pending in * 406 * the keyboard queue. * 407 * * 408 * INPUT: none * 409 * * 410 * OUTPUT: Returns with the next element in the keyboard queue. If the keyboard buffer is * 411 * empty, then 0 is returned. * 412 * * 413 * WARNINGS: none * 414 * * 415 * HISTORY: * 416 * 09/30/1996 JLB : Created. * 417 *=============================================================================================*/ 418 unsigned short WWKeyboardClass::Peek_Element(void) const 419 { 420 if (!Is_Buffer_Empty()) { 421 return(Buffer[Head]); 422 } 423 return(0); 424 } 425 426 427 /*********************************************************************************************** 428 * WWKeyboardClass::Put_Element -- Put a keyboard data element into the buffer. * 429 * * 430 * This will put one keyboard data element into the keyboard buffer. Typically, this data * 431 * is a key code, but it might be mouse coordinates. * 432 * * 433 * INPUT: val -- The data element to add to the keyboard buffer. * 434 * * 435 * OUTPUT: bool; Was the keyboard element added successfully? A failure would indicate that * 436 * the keyboard buffer is full. * 437 * * 438 * WARNINGS: none * 439 * * 440 * HISTORY: * 441 * 09/30/1996 JLB : Created. * 442 *=============================================================================================*/ 443 bool WWKeyboardClass::Put_Element(unsigned short val) 444 { 445 if (!Is_Buffer_Full()) { 446 int temp = (Tail+1) % ARRAY_SIZE(Buffer); 447 Buffer[Tail] = val; 448 Tail = temp; 449 return(true); 450 } 451 return(false); 452 } 453 454 455 /*********************************************************************************************** 456 * WWKeyboardClass::Is_Buffer_Full -- Determines if the keyboard buffer is full. * 457 * * 458 * This routine will examine the keyboard buffer to determine if it is completely * 459 * full of queued keyboard events. * 460 * * 461 * INPUT: none * 462 * * 463 * OUTPUT: bool; Is the keyboard buffer completely full? * 464 * * 465 * WARNINGS: none * 466 * * 467 * HISTORY: * 468 * 09/30/1996 JLB : Created. * 469 *=============================================================================================*/ 470 bool WWKeyboardClass::Is_Buffer_Full(void) const 471 { 472 if ((Tail + 1) % ARRAY_SIZE(Buffer) == Head) { 473 return(true); 474 } 475 return(false); 476 } 477 478 479 /*********************************************************************************************** 480 * WWKeyboardClass::Is_Buffer_Empty -- Checks to see if the keyboard buffer is empty. * 481 * * 482 * This routine will examine the keyboard buffer to see if it contains no events at all. * 483 * * 484 * INPUT: none * 485 * * 486 * OUTPUT: bool; Is the keyboard buffer currently without any pending events queued? * 487 * * 488 * WARNINGS: none * 489 * * 490 * HISTORY: * 491 * 09/30/1996 JLB : Created. * 492 *=============================================================================================*/ 493 bool WWKeyboardClass::Is_Buffer_Empty(void) const 494 { 495 if (Head == Tail) { 496 return(true); 497 } 498 return(false); 499 } 500 501 502 /*********************************************************************************************** 503 * WWKeyboardClass::Fill_Buffer_From_Syste -- Extract and process any queued windows messages. * 504 * * 505 * This routine will extract and process any windows messages in the windows message * 506 * queue. It is presumed that the normal message handler will call the keyboard * 507 * message processing function. * 508 * * 509 * INPUT: none * 510 * * 511 * OUTPUT: none * 512 * * 513 * WARNINGS: none * 514 * * 515 * HISTORY: * 516 * 09/30/1996 JLB : Created. * 517 *=============================================================================================*/ 518 void WWKeyboardClass::Fill_Buffer_From_System(void) 519 { 520 if (!Is_Buffer_Full()) { 521 MSG msg; 522 while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) { 523 if (!GetMessage( &msg, NULL, 0, 0 )) { 524 return; 525 } 526 TranslateMessage(&msg); 527 DispatchMessage(&msg); 528 } 529 } 530 } 531 532 533 /*********************************************************************************************** 534 * WWKeyboardClass::Clear -- Clears the keyboard buffer. * 535 * * 536 * This routine will clear the keyboard buffer of all pending keyboard events. * 537 * * 538 * INPUT: none * 539 * * 540 * OUTPUT: none * 541 * * 542 * WARNINGS: none * 543 * * 544 * HISTORY: * 545 * 09/30/1996 JLB : Created. * 546 *=============================================================================================*/ 547 void WWKeyboardClass::Clear(void) 548 { 549 /* 550 ** Extract any windows pending keyboard message events and then clear out the keyboard 551 ** buffer. 552 */ 553 Fill_Buffer_From_System(); 554 Head = Tail; 555 556 /* 557 ** Perform a second clear to handle the rare case of the keyboard buffer being full and there 558 ** still remains keyboard related events in the windows message queue. 559 */ 560 Fill_Buffer_From_System(); 561 Head = Tail; 562 } 563 564 565 /*********************************************************************************************** 566 * WWKeyboardClass::Message_Handler -- Process a windows message as it relates to the keyboard * 567 * * 568 * This routine will examine the Windows message specified. If the message relates to an * 569 * event that the keyboard input system needs to process, then it will be processed * 570 * accordingly. * 571 * * 572 * INPUT: window -- Handle to the window receiving the message. * 573 * * 574 * message -- The message number of this event. * 575 * * 576 * wParam -- The windows specific word parameter (meaning depends on message). * 577 * * 578 * lParam -- The windows specific long word parameter (meaning is message dependant)* 579 * * 580 * OUTPUT: bool; Was this keyboard message recognized and processed? A 'false' return value * 581 * means that the message should be processed normally. * 582 * * 583 * WARNINGS: none * 584 * * 585 * HISTORY: * 586 * 09/30/1996 JLB : Created. * 587 *=============================================================================================*/ 588 bool WWKeyboardClass::Message_Handler(HWND window, UINT message, UINT wParam, LONG lParam) 589 { 590 // ST - 5/13/2019 591 #if (0) 592 bool processed = false; 593 594 /* 595 ** Examine the message to see if it is one that should be processed. Only keyboard and 596 ** pertinant mouse messages are processed. 597 */ 598 switch (message) { 599 600 /* 601 ** System key has been pressed. This is the normal keyboard event message. 602 */ 603 case WM_SYSKEYDOWN: 604 case WM_KEYDOWN: 605 if (wParam == VK_SCROLL) { 606 Stop_Execution(); 607 } else { 608 Put_Key_Message((unsigned short)wParam); 609 } 610 processed = true; 611 break; 612 613 /* 614 ** The key has been released. This is the normal key release message. 615 */ 616 case WM_SYSKEYUP: 617 case WM_KEYUP: 618 Put_Key_Message((unsigned short)wParam, true); 619 processed = true; 620 break; 621 622 /* 623 ** Press of the left mouse button. 624 */ 625 case WM_LBUTTONDOWN: 626 Put_Mouse_Message(VK_LBUTTON, LOWORD(lParam), HIWORD(lParam)); 627 processed = true; 628 break; 629 630 /* 631 ** Release of the left mouse button. 632 */ 633 case WM_LBUTTONUP: 634 Put_Mouse_Message(VK_LBUTTON, LOWORD(lParam), HIWORD(lParam), true); 635 processed = true; 636 break; 637 638 /* 639 ** Double click of the left mouse button. Fake this into being 640 ** just a rapid click of the left button twice. 641 */ 642 case WM_LBUTTONDBLCLK: 643 Put_Mouse_Message(VK_LBUTTON, LOWORD(lParam), HIWORD(lParam)); 644 Put_Mouse_Message(VK_LBUTTON, LOWORD(lParam), HIWORD(lParam), true); 645 Put_Mouse_Message(VK_LBUTTON, LOWORD(lParam), HIWORD(lParam)); 646 Put_Mouse_Message(VK_LBUTTON, LOWORD(lParam), HIWORD(lParam), true); 647 processed = true; 648 break; 649 650 /* 651 ** Press of the middle mouse button. 652 */ 653 case WM_MBUTTONDOWN: 654 Put_Mouse_Message(VK_MBUTTON, LOWORD(lParam), HIWORD(lParam)); 655 processed = true; 656 break; 657 658 /* 659 ** Release of the middle mouse button. 660 */ 661 case WM_MBUTTONUP: 662 Put_Mouse_Message(VK_MBUTTON, LOWORD(lParam), HIWORD(lParam), true); 663 processed = true; 664 break; 665 666 /* 667 ** Middle button double click gets translated into two 668 ** regular middle button clicks. 669 */ 670 case WM_MBUTTONDBLCLK: 671 Put_Mouse_Message(VK_MBUTTON, LOWORD(lParam), HIWORD(lParam)); 672 Put_Mouse_Message(VK_MBUTTON, LOWORD(lParam), HIWORD(lParam), true); 673 Put_Mouse_Message(VK_MBUTTON, LOWORD(lParam), HIWORD(lParam)); 674 Put_Mouse_Message(VK_MBUTTON, LOWORD(lParam), HIWORD(lParam), true); 675 processed = true; 676 break; 677 678 /* 679 ** Right mouse button press. 680 */ 681 case WM_RBUTTONDOWN: 682 Put_Mouse_Message(VK_RBUTTON, LOWORD(lParam), HIWORD(lParam)); 683 processed = true; 684 break; 685 686 /* 687 ** Right mouse button release. 688 */ 689 case WM_RBUTTONUP: 690 Put_Mouse_Message(VK_RBUTTON, LOWORD(lParam), HIWORD(lParam), true); 691 processed = true; 692 break; 693 694 /* 695 ** Translate a double click of the right button 696 ** into being just two regular right button clicks. 697 */ 698 case WM_RBUTTONDBLCLK: 699 Put_Mouse_Message(VK_RBUTTON, LOWORD(lParam), HIWORD(lParam)); 700 Put_Mouse_Message(VK_RBUTTON, LOWORD(lParam), HIWORD(lParam), true); 701 Put_Mouse_Message(VK_RBUTTON, LOWORD(lParam), HIWORD(lParam)); 702 Put_Mouse_Message(VK_RBUTTON, LOWORD(lParam), HIWORD(lParam), true); 703 processed = true; 704 break; 705 706 /* 707 ** If the message is not pertinant to the keyboard system, 708 ** then do nothing. 709 */ 710 default: 711 break; 712 } 713 714 /* 715 ** If this message has been processed, then pass it on to the system 716 ** directly. 717 */ 718 if (processed) { 719 DefWindowProc(window, message, wParam, lParam); 720 return(true); 721 } 722 #endif 723 return(false); 724 } 725 726 727 /*********************************************************************************************** 728 * WWKeyboardClass::Available_Buffer_Room -- Fetch the quantity of free elements in the keyboa * 729 * * 730 * This examines the keyboard buffer queue and determine how many elements are available * 731 * for use before the buffer becomes full. Typical use of this would be when inserting * 732 * mouse events that require more than one element. Such an event must detect when there * 733 * would be insufficient room in the buffer and bail accordingly. * 734 * * 735 * INPUT: none * 736 * * 737 * OUTPUT: Returns with the number of elements that may be stored in to the keyboard buffer * 738 * before it becomes full and cannot accept any more elements. * 739 * * 740 * WARNINGS: none * 741 * * 742 * HISTORY: * 743 * 11/02/1996 JLB : Created. * 744 *=============================================================================================*/ 745 int WWKeyboardClass::Available_Buffer_Room(void) const 746 { 747 int avail; 748 if (Head == Tail) { 749 avail = ARRAY_SIZE(Buffer); 750 } 751 if (Head < Tail) { 752 avail = Tail - Head; 753 } 754 if (Head > Tail) { 755 avail = (Tail + ARRAY_SIZE(Buffer)) - Head; 756 } 757 return(avail); 758 }