User Input changes

This commit is contained in:
Ben Lankamp
2020-07-01 21:39:30 +02:00
parent 196decf9bd
commit 8337ad6672
5 changed files with 2580 additions and 0 deletions
+778
View File
@@ -0,0 +1,778 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is free
// software: you can redistribute it and/or modify it under the terms of
// the GNU General Public License as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/* $Header: /CounterStrike/GADGET.CPP 1 3/03/97 10:24a Joe_bostic $ */
/***********************************************************************************************
*** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
***********************************************************************************************
* *
* Project Name : Command & Conquer *
* *
* File Name : GADGET.CPP *
* *
* Programmer : Maria del Mar McCready Legg *
* Joe L. Bostic *
* *
* Start Date : 01/03/95 *
* *
* Last Update : August 1, 1996 [JLB] *
* *
*---------------------------------------------------------------------------------------------*
* Functions: *
* GadgetClass::Action -- Base action for gadget. *
* GadgetClass::Clear_Focus -- Clears the focus if this gadget has it. *
* GadgetClass::Delete_List -- Deletes all gadget objects in list. *
* GadgetClass::Disable -- Disables the gadget from input processing. *
* GadgetClass::Draw_All -- Forces all gadgets in list to be redrawn. *
* GadgetClass::Draw_Me -- Gadget redraw action (flag control). *
* GadgetClass::Enable -- Enables the gadget. *
* GadgetClass::Extract_Gadget -- Sweeps through the gadget chain to find gadget specified. *
* GadgetClass::Flag_To_Redraw -- Flags this gadget to be redrawn. *
* GadgetClass::GadgetClass -- Constructor for gadget object. *
* GadgetClass::GadgetClass -- Default constructor for a gadget class object. *
* GadgetClass::Get_Next -- Returns a pointer to the next gadget in the chain. *
* GadgetClass::Get_Prev -- Fetches a pointer to the previous gadget. *
* GadgetClass::Has_Focus -- Checks if this object currently has the keyboard focus. *
* GadgetClass::Remove -- Removes the specified gadget from the list. *
* GadgetClass::Set_Focus -- Sets focus to this gadget. *
* GadgetClass::Sticky_Process -- Handles the sticky flag processing. *
* GadgetClass::~GadgetClass -- Destructor for gadget object. *
* GadgetClass::Is_List_To_Redraw -- tells if any gadget in the list needs redrawing *
* GadgetClass::GadgetClass -- Constructor for the gadget object. *
* GadgetClass::Set_Position -- Set the coordinate position of this gadget. *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#include "function.h"
#include <SDL.h>
/*
** This records the current gadget the the gadget system is "stuck on". Such a
** gadget will be processed to the exclusion of all others until the mouse button
** is no longer pressed.
*/
GadgetClass * GadgetClass::StuckOn = 0;
/*
** This is a copy of a pointer to the last list used by the gadget input system.
** If a change of list is detected, then all gadgets are forced to be redrawn.
*/
GadgetClass * GadgetClass::LastList = 0;
/*
** This points to the gadget that is intercepting all keyboard events.
*/
GadgetClass * GadgetClass::Focused = 0;
/*
** This points to the current color scheme for drawing all gadgets.
*/
static RemapControlType _GreyScheme = {15};
RemapControlType * GadgetClass::ColorScheme = &_GreyScheme;
/***********************************************************************************************
* GadgetClass::GadgetClass -- Constructor for gadget object. *
* *
* This is the normal constructor for gadget objects. A gadget object is only concerned *
* with the region on the screen to considered "its own" as well as the flags that tell *
* what mouse action should be recognized when the mouse is over this screen area. *
* *
* INPUT: x,y -- Coordinates (in pixels) of the upper left hand corner of the region that *
* will be "owned" by this gadget. *
* *
* w,h -- Width and height (in pixels) of this gadget's region. *
* *
* flags -- The flags (mouse conditions) that will cause this gadget's action *
* function to be called. *
* *
* OUTPUT: none *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 01/03/1995 MML : Created. *
*=============================================================================================*/
GadgetClass::GadgetClass(int x, int y, int w, int h, unsigned flags, int sticky) :
X(x), Y(y), Width(w), Height(h), IsToRepaint(false), IsSticky(sticky), IsDisabled(false), Flags(flags)
{
if (IsSticky) {
Flags |= LEFTPRESS|LEFTRELEASE;
}
}
/***********************************************************************************************
* GadgetClass::GadgetClass -- Constructor for the gadget object. *
* *
* This is the copy constructor for the gadget object. It will try to duplicate the *
* righthand gadget. *
* *
* INPUT: gadget -- Reference to the initilization gadget. *
* *
* OUTPUT: none *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 08/01/1996 JLB : Created. *
*=============================================================================================*/
GadgetClass::GadgetClass(GadgetClass const & gadget) :
X(gadget.X),
Y(gadget.Y),
Width(gadget.Width),
Height(gadget.Height),
IsToRepaint(gadget.IsToRepaint),
IsSticky(gadget.IsSticky),
IsDisabled(gadget.IsDisabled),
Flags(gadget.Flags)
{
}
/***********************************************************************************************
* GadgetClass::~GadgetClass -- Destructor for gadget object. *
* *
* This is the destructor for the gadget object. It will clear the focus from this gadget *
* if this gadget currently has the focus. *
* *
* INPUT: none *
* *
* OUTPUT: none *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 07/08/1995 JLB : Created. *
*=============================================================================================*/
GadgetClass::~GadgetClass(void)
{
if (Has_Focus()) {
Clear_Focus();
}
if (this == StuckOn) {
StuckOn = NULL;
}
if (this == LastList) {
LastList = NULL;
}
if (this == Focused) {
Focused = NULL;
}
}
/***************************************************************************
* GADGETCLASS::CLICKEDON -- If a mouse click is detected within gadget's *
* area and the appropriate flag is set, then call Action(). *
* *
* INPUT: int key, int mousex, int mousey *
* *
* OUTPUT: true or false *
* *
* WARNINGS: none. *
* *
* HISTORY: 01/03/1995 MML : Created. *
*=========================================================================*/
int GadgetClass::Clicked_On(KeyNumType & key, unsigned flags, int mousex, int mousey)
{
/*
** Set flags to match only those events that occur AND are being looked for. If
** the result is NULL, then we know that this button should be ignored.
*/
flags &= Flags;
if (mousex - X < 0 || mousey - Y < 0)
return false;
/*
** If keyboard input should be processed by this "gadget" and keyboard input is
** detected, then always call the action function. It is up to the action function
** in this case to either ignore the keyboard input or not.
**
** For mouse actions, check to see if the mouse is in the region of the button
** before calling the associated action function. This is the typical action for
** buttons.
*/
if (this == StuckOn ||
(flags & KEYBOARD) ||
(flags && (mousex - X) < Width && (mousey - Y) < Height)) {
return(Action(flags, key));
}
return(false);
}
/***********************************************************************************************
* GadgetClass::Enable -- Enables the gadget. *
* *
* This function enables the gadget. An enabled gadget will be processed for input *
* purposes. *
* *
* INPUT: none *
* *
* OUTPUT: none *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 01/15/1995 JLB : Created. *
*=============================================================================================*/
void GadgetClass::Enable(void)
{
IsDisabled = false;
IsToRepaint = true;
Clear_Focus();
}
/***********************************************************************************************
* GadgetClass::Disable -- Disables the gadget from input processing. *
* *
* This routine will disable the gadget. A disabled gadget might be rendered, but is *
* ignored for input processing. *
* *
* INPUT: none *
* *
* OUTPUT: none *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 01/15/1995 JLB : Created. *
*=============================================================================================*/
void GadgetClass::Disable(void)
{
IsDisabled = true;
IsToRepaint = true;
Clear_Focus();
}
/***********************************************************************************************
* GadgetClass::Remove -- Removes the specified gadget from the list. *
* *
* Use this routine if an individual gadget needs to be removed from the list of gadgets. *
* *
* INPUT: none *
* *
* OUTPUT: bool; Was the specified gadget found and removed? A false indicates that the *
* gadget wasn't in the list. *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 01/15/1995 JLB : Created. *
*=============================================================================================*/
GadgetClass * GadgetClass::Remove(void)
{
Clear_Focus();
return(GadgetClass *)LinkClass::Remove();
}
/***********************************************************************************************
* GadgetClass::Get_Next -- Returns a pointer to the next gadget in the chain. *
* *
* This returns with the next gadget's pointer. It is identical to the base Get_Next() *
* function, but returns a pointer to a GadgetClass object. *
* *
* INPUT: none *
* *
* OUTPUT: Returns with a pointer to the next gadget in the list. *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 01/15/1995 JLB : Created. *
*=============================================================================================*/
GadgetClass * GadgetClass::Get_Next(void) const
{
return(GadgetClass*)LinkClass::Get_Next();
}
/***********************************************************************************************
* GadgetClass::Get_Prev -- Fetches a pointer to the previous gadget. *
* *
* This routine will return the previous gadget in the list. It is identical to the base *
* function Get_Prev, but returns a pointer to a GadgetClass object. *
* *
* INPUT: none *
* *
* OUTPUT: Returns with a pointer to the previous gadget in the list. *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 01/15/1995 JLB : Created. *
*=============================================================================================*/
GadgetClass * GadgetClass::Get_Prev(void) const
{
return(GadgetClass*)LinkClass::Get_Prev();
}
/***********************************************************************************************
* GadgetClass::Delete_List -- Deletes all gadget objects in list. *
* *
* This function will delete all gadgets in the list. It is the counterpart to the *
* Create_One_Of functions. *
* *
* INPUT: none *
* *
* OUTPUT: none *
* *
* WARNINGS: Any references to these gadget become invalidated by this routine. *
* *
* HISTORY: *
* 01/15/1995 JLB : Created. *
*=============================================================================================*/
void GadgetClass::Delete_List(void)
{
GadgetClass * g = this;
/*
** Move to head of the list.
*/
while (g->Get_Prev()) {
g = g->Get_Prev();
}
/*
** First delete all the gadgets following the first one. The reason the first one
** is kept around is that sometimes deleting one gadget will result in related gadgets
** in the same list also being deleted. The first gadget will always contain the
** correct gadget pointer.
*/
while (g) {
g->Clear_Focus();
GadgetClass * temp = g;
g = g->Get_Next();
delete temp;
}
}
/***********************************************************************************************
* GadgetClass::Action -- Base action for gadget. *
* *
* This handles the base level action that a gadget performs when a qualifying input event *
* is detected. This sets the redraw flag and returns true (to stop further processing). *
* If no qualifying input event was detected, but this routine was called anyway, then *
* don't perform any action. The call to this routine, in that case, must have been forced *
* for some other reason. *
* *
* INPUT: flag -- The input event bits that qualify for this gadget. A NULL indicates that *
* no qualifying event occurred. *
* *
* OUTPUT: bool; Should further gadget list processing be aborted? *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 01/15/1995 JLB : Created. *
*=============================================================================================*/
int GadgetClass::Action(unsigned flags, KeyNumType &)
{
/*
** If any of the event flags are active, then this indicates that something probably
** has changed the gadget. Flag the gadget to be redrawn. Also, make sure that
** any sticky flags are cleared up.
*/
if (flags) {
IsToRepaint = true;
Sticky_Process(flags);
return(true);
}
return(false);
}
/***********************************************************************************************
* GadgetClass::Draw_Me -- Gadget redraw action (flag control). *
* *
* At this level, there is no actual rendering taking place with the call to Draw_Me, but *
* the IsToRepaint flag must be cleared. Derived objects will call this routine and if it *
* returns true, they will perform their custom rendering. *
* *
* INPUT: forced -- Is this redraw forced by outside circumstances? *
* *
* OUTPUT: bool; Should the gadget imagery be redrawn? *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 01/14/1995 JLB : Created. *
*=============================================================================================*/
int GadgetClass::Draw_Me(int forced)
{
if (forced || IsToRepaint) {
IsToRepaint = false;
return(true);
}
return(false);
}
/***********************************************************************************************
* GadgetClass::Draw_All -- Forces all gadgets in list to be redrawn. *
* *
* Use this function to cause all gadget in the list to be redrawn regardless of the state *
* of the IsToRepaint flag. *
* *
* INPUT: none *
* *
* OUTPUT: none *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 01/03/1995 MML : Created. *
*=============================================================================================*/
void GadgetClass::Draw_All(bool forced)
{
GadgetClass * gadget = this;
while (gadget != NULL) {
gadget->Draw_Me(forced);
gadget = gadget->Get_Next();
}
}
/***************************************************************************
* GADGETCLASS::PROCESSLIST -- Check list for a mouse click within a gadget*
* *
* INPUT: none. *
* *
* OUTPUT: key pressed. *
* *
* WARNINGS: none. *
* *
* HISTORY: 01/03/1995 MML : Created. *
*=========================================================================*/
KeyNumType GadgetClass::Input(void)
{
EventMessage eventMessage;
KeyNumType key = KN_NONE;
int flags = 0;
int forced = false;
/*
** Record this list so that a forced redraw only occurs the FIRST time the
** gadget list is passed to this routine.
*/
if (LastList != this) {
LastList = this;
forced = true;
StuckOn = NULL;
Focused = NULL;
}
/*
** Fetch any pending keyboard input.
*/
UserInput.Process_Input(key, flags);
if ( EventQueue.Check() ) {
eventMessage = EventQueue.Get();
eventMessage.Key_Flags( key, flags );
}
/*
** If "sticky" processing is active, then only process the stuck gadget.
*/
if (StuckOn) {
StuckOn->Draw_Me(false);
GadgetClass * oldstuck = StuckOn;
StuckOn->Clicked_On(key, flags, UserInput.Mouse.X, UserInput.Mouse.Y);
if (StuckOn)
{
StuckOn->Draw_Me(false);
} else {
oldstuck->Draw_Me(false);
}
}
else
{
/*
** If there is a gadget that has the keyboard focus, then route all keyboard
** events to it.
*/
if ( Focused && eventMessage.EventType == EventMessageType::EVENT_KEYBOARD ) {
Focused->Draw_Me(false);
Focused->Clicked_On(key, flags, UserInput.Mouse.X, UserInput.Mouse.Y);
if (Focused) {
Focused->Draw_Me(false);
}
} else {
/*
** Sweep through all the buttons in the chain and pass the current button state
** and keyboard input data to them. These routines will detect whether they should
** perform some action and return a flag to this effect. They also have the option
** of changing the key value so that an appropriate return value is used for this
** processing routine.
*/
GadgetClass * next_button = this;
while (next_button != NULL) {
/*
** Maybe redraw the button if it needs to or is being forced to redraw.
*/
next_button->Draw_Me(forced);
if (!next_button->IsDisabled) {
/*
** Process this button. If the button was recognized and action was
** performed, then bail from further processing (speed reasons?).
*/
if (next_button->Clicked_On(key, flags, UserInput.Mouse.X, UserInput.Mouse.Y)) {
/*
** Some buttons will require repainting when they perform some action.
** Do so at this time.
*/
next_button->Draw_Me(false);
break;
}
}
next_button = next_button->Get_Next();
}
}
}
return(key);
}
/***********************************************************************************************
* GadgetClass::Extract_Gadget -- Sweeps through the gadget chain to find gadget specified. *
* *
* This examines the gadget list looking for on that has the same ID as specified. If that *
* gadget was found, then a pointer to it is returned. Since only ControlClass gadgets *
* or ones derived from it can have an ID value, we know that the returned pointer is at *
* least of the ControlClass type. *
* *
* INPUT: id -- The ID number to scan for. Zero is not a legal ID number and if passed in, *
* a NULL will always be returned. *
* *
* OUTPUT: Returns with a pointer to the ControlClass gadget that has the matching ID number. *
* If no matching gadget was found, then NULL is returned. *
* *
* WARNINGS: If there happens to be more than one gadget with a matching ID, this routine *
* will return a pointer to the first one only. *
* *
* HISTORY: *
* 01/16/1995 JLB : Created. *
*=============================================================================================*/
ControlClass * GadgetClass::Extract_Gadget(unsigned id)
{
GadgetClass * g = this;
if (id != 0) {
while (g != NULL) {
if (g->Get_ID() == id) {
return((ControlClass *)g);
}
g = g->Get_Next();
}
}
return(0);
}
/***********************************************************************************************
* GadgetClass::Flag_To_Redraw -- Flags this gadget to be redrawn. *
* *
* Use this routine to flag the gadget to be redrawn. A gadget so flagged will have its *
* Draw_Me function called at the next available opportunity. Usually, this is the next *
* time the Input() function is called. *
* *
* INPUT: none *
* *
* OUTPUT: none *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 01/16/1995 JLB : Created. *
*=============================================================================================*/
void GadgetClass::Flag_To_Redraw(void)
{
IsToRepaint = true;
}
/***********************************************************************************************
* GadgetClass::Sticky_Process -- Handles the sticky flag processing. *
* *
* This function examines the event flags and handles any "sticky" processing required. *
* Sticky processing is when the button is flagged with the "IsSticky" bit and it will *
* be processed to the exclusion of all other gadgets while the mouse button is held *
* down. *
* *
* INPUT: flags -- The event flags that triggered the call to this routine. *
* *
* OUTPUT: none *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 01/16/1995 JLB : Created. *
*=============================================================================================*/
void GadgetClass::Sticky_Process(unsigned flags)
{
if (IsSticky && (flags & LEFTPRESS)) {
StuckOn = this;
}
if (StuckOn == this && (flags & LEFTRELEASE)) {
StuckOn = 0;
}
}
/***********************************************************************************************
* GadgetClass::Set_Focus -- Sets focus to this gadget. *
* *
* This will set the focus to this gadget regardless of any current focus setting. If there *
* is another gadget that has focus, it will have its focus cleared before this gadget will *
* get the focus. A focused gadget is one that has all keyboard input routed to it. *
* *
* INPUT: none *
* *
* OUTPUT: none *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 01/25/1995 JLB : Created. *
*=============================================================================================*/
void GadgetClass::Set_Focus(void)
{
if (Focused) {
Focused->Flag_To_Redraw();
Focused->Clear_Focus();
}
Flags |= KEYBOARD;
Focused = this;
}
/***********************************************************************************************
* GadgetClass::Clear_Focus -- Clears the focus if this gadget has it. *
* *
* Use this function to clear the focus for the gadget. If the gadget doesn't currently *
* have focus, then this routine will do nothing. For added functionality, overload this *
* virtual function so that gadget specific actions may be take when focus is lost. *
* *
* INPUT: none *
* *
* OUTPUT: none *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 01/25/1995 JLB : Created. *
*=============================================================================================*/
void GadgetClass::Clear_Focus(void)
{
if (Focused == this) {
Flags &= ~KEYBOARD;
Focused = 0;
}
}
/***********************************************************************************************
* GadgetClass::Has_Focus -- Checks if this object currently has the keyboard focus. *
* *
* If this object has the keyboard focus, then this routine will return true. When the *
* gadget has keyboard focus, all keyboard events get routed to the gadget. *
* *
* INPUT: none *
* *
* OUTPUT: bool; Does this gadget have the keyboard focus? *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 01/21/1995 JLB : Created. *
*=============================================================================================*/
bool GadgetClass::Has_Focus(void)
{
return(this == Focused);
}
/***********************************************************************************************
* GadgetClass::Is_List_To_Redraw -- tells if any gadget in the list needs redrawing *
* *
* This function is mostly for supporting HidPage drawing. If it returns true, it means *
* the application needs to re-blit the HidPage forward, after calling the list's Input(). *
* *
* INPUT: none *
* *
* OUTPUT: true = an item needs redrawing, false = no items need redrawing *
* *
* WARNINGS: It is assumed 'this' is the head of the list. *
* *
* HISTORY: *
* 01/03/1995 MML : Created. *
*=============================================================================================*/
int GadgetClass::Is_List_To_Redraw(void)
{
GadgetClass * gadget = this;
while (gadget != NULL) {
if (gadget->IsToRepaint) {
return (true);
}
gadget = gadget->Get_Next();
}
return (false);
}
/***********************************************************************************************
* GadgetClass::Set_Position -- Set the coordinate position of this gadget. *
* *
* This routine helps with moving a gadget's location. It will set the gadgets upper *
* left corner to the pixel location specified. *
* *
* INPUT: x,y -- The X and Y position to put the gadget's upper left corner to. *
* *
* OUTPUT: none *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 08/01/1996 JLB : Created. *
*=============================================================================================*/
void GadgetClass::Set_Position(int x, int y)
{
X = x;
Y = y;
}
+236
View File
@@ -0,0 +1,236 @@
#include "../FUNCTION.H"
#include "UserInput.h"
extern KeyboardClass * Keyboard;
std::map<KeyNumType, SDL_KeyCode> sdl_keyMapping_reverse;
UserInputClass::UserInputClass()
{
LastAction = InputAction::INPUT_ACTION_NONE;
// generate reverse keymapping
for ( auto it = sdl_keyMapping.begin(); it != sdl_keyMapping.end(); it++ )
{
sdl_keyMapping_reverse[it->second] = it->first;
}
}
bool UserInputClass::KeyboardState::Key_Down(KeyNumType key) const
{
auto sdl_Key = sdl_keyMapping_reverse.find( key );
if ( sdl_Key != sdl_keyMapping_reverse.end() )
{
const SDL_Scancode scanCode = SDL_GetScancodeFromKey(sdl_Key->second);
const Uint8* keyState = SDL_GetKeyboardState(NULL);
return ( keyState[scanCode] );
}
return false;
}
bool UserInputClass::MouseState::Mouse_Down(KeyNumType key) const
{
// get mouse state, we are only interested in the buttons
const Uint32 MouseState = SDL_GetMouseState(NULL,NULL);
switch (key)
{
case KN_LMOUSE:
return MouseState & SDL_BUTTON(SDL_BUTTON_LEFT);
break;
case KN_RMOUSE:
return MouseState & SDL_BUTTON(SDL_BUTTON_RIGHT);
break;
}
}
void UserInputClass::Process_Input(KeyNumType& key, int& flags)
{
bool leftMouseProcessed = false;
const Uint32 MouseState = SDL_GetMouseState(&Mouse.X, &Mouse.Y);
flags = 0;
Keyboard->MouseQX = Mouse.X;
Keyboard->MouseQY = Mouse.Y;
static SDL_Event event;
memset(&event, 0, sizeof(SDL_Event));
while (SDL_PollEvent(&event)) {
const Uint8* state = SDL_GetKeyboardState(NULL);
switch (event.type)
{
case SDL_SYSWMEVENT:
if (event.syswm.msg->msg.win.msg == WM_DESTROY)
{
Invalidate_Cached_Icons();
VisiblePage.Un_Init();
HiddenPage.Un_Init();
AllSurfaces.Release();
if (!InDebugger) Reset_Video_Mode();
PostQuitMessage(0);
switch (ReadyToQuit) {
case 1:
ReadyToQuit = 2;
break;
case 0:
ExitProcess(0);
break;
}
}
break;
/* Mouse is moving */
case SDL_MOUSEMOTION:
if ( !( MouseState & SDL_BUTTON(SDL_BUTTON_LEFT) ) )
{
flags |= GadgetClass::LEFTUP;
}
break;
case SDL_MOUSEBUTTONDOWN:
if (event.button.button == SDL_BUTTON_LEFT) {
Mouse.Button_Left == MouseButtonState::MOUSE_BUTTON_DOWN;
key = KN_LMOUSE;
flags |= GadgetClass::LEFTPRESS;
EventQueue.Put( EventMessage( Mouse.X, Mouse.Y, KN_LMOUSE ) );
Keyboard->Put_Element(KN_LMOUSE);
leftMouseProcessed = true;
numFramesLMouse++;
// after first left-mouse down, abort handling any other SDL events
// because game might first need to switch into rubber band mode
if (numFramesLMouse == 1) return;
}
else if (event.button.button == SDL_BUTTON_RIGHT) {
Mouse.Button_Right == MouseButtonState::MOUSE_BUTTON_DOWN;
EventQueue.Put( EventMessage( Mouse.X, Mouse.Y, KN_RMOUSE ) );
Keyboard->Put_Element(KN_RMOUSE);
key = KN_RMOUSE;
flags |= GadgetClass::RIGHTPRESS;
numFramesLMouse = 0;
}
break;
case SDL_MOUSEBUTTONUP:
if (event.button.button == SDL_BUTTON_LEFT) {
Mouse.Button_Left == MouseButtonState::MOUSE_BUTTON_RELEASE;
EventQueue.Put( EventMessage(Mouse.X, Mouse.Y, KN_LMOUSE, MouseButtonState::MOUSE_BUTTON_RELEASE) );
flags |= GadgetClass::LEFTRELEASE;
numFramesLMouse = 0;
}
else if (event.button.button == SDL_BUTTON_RIGHT) {
Mouse.Button_Right == MouseButtonState::MOUSE_BUTTON_RELEASE;
EventQueue.Put( EventMessage(Mouse.X, Mouse.Y, KN_RMOUSE, MouseButtonState::MOUSE_BUTTON_RELEASE) );
flags |= GadgetClass::RIGHTRELEASE;
numFramesLMouse = 0;
}
break;
// Keyboard key lifted up
case SDL_KEYUP:
flags |= GadgetClass::KEYBOARD;
break;
// Keyboard key pressed down
case SDL_KEYDOWN:
{
if (event.key.keysym.scancode == SDL_SCANCODE_GRAVE) {
renderConsole = !renderConsole;
if (renderConsole) {
ShowCursor(TRUE);
Hide_Mouse();
}
else {
ShowCursor(FALSE);
Show_Mouse();
}
break;
}
flags |= GadgetClass::KEYBOARD;
int keyFlags = 0x00;
KeyB.Shift = false;
KeyB.Alt = false;
KeyB.Control = false;
KeyB.CapsLock = false;
if (state[SDL_SCANCODE_RSHIFT] || state[SDL_SCANCODE_LSHIFT]) {
KeyB.Shift = true;
keyFlags |= KN_SHIFT_BIT;
}
if (state[SDL_SCANCODE_RALT] || state[SDL_SCANCODE_LALT]) {
keyFlags |= KN_ALT_BIT;
KeyB.Alt = true;
}
if (state[SDL_SCANCODE_RCTRL] || state[SDL_SCANCODE_LCTRL]) {
keyFlags |= KN_CTRL_BIT;
KeyB.Control = true;
}
if (state[SDL_SCANCODE_CAPSLOCK]) {
keyFlags |= KN_CAPSLOCK_BIT;
KeyB.CapsLock = true;
}
// handle match between SDL and internals ( non-text keys )
auto element = sdl_keyMapping.find((SDL_KeyCode)event.key.keysym.sym);
if (element != sdl_keyMapping.end())
{
//EventQueue.Put( element->second | keyFlags );
EventQueue.Put( EventMessage( (KeyNumType)element->second, element->second, KeyB.Shift, KeyB.Alt, KeyB.Control, KeyB.CapsLock ) );
Keyboard->Put_Element( element->second | keyFlags);
KeyB.LastKey = element->first;
if (event.text.text[0] == (event.text.text[0] & 0xFF))
{
KeyB.ASCII = element->second;
}
}
break;
}
case SDL_TEXTINPUT:
// limit to range 0-255
if (event.text.text[0] == ( event.text.text[0] & 0xFF ) )
{
KeyB.ASCII = (char)event.text.text[0];
}
}
if (Debug_Map || renderConsole)
{
ImGui_ImplSDL2_ProcessEvent(&event);
}
}
if (!leftMouseProcessed && numFramesLMouse != 0)
{
Mouse.Button_Left == MouseButtonState::MOUSE_BUTTON_HOLD;
flags |= GadgetClass::LEFTHELD;
EventQueue.Put( EventMessage(Mouse.X, Mouse.Y, KN_LMOUSE, MouseButtonState::MOUSE_BUTTON_HOLD) );
}
}
+166
View File
@@ -0,0 +1,166 @@
#pragma once
#include <SDL.h>
#include <SDL_syswm.h>
#include <map>
#include <queue>
#include "examples/imgui_impl_sdl.h"
extern KeyNumType g_globalKeyNumType;
extern int g_globalKeyFlags;
// Mapping of SDL KeyCode values to internal KeyNumType
std::map<SDL_KeyCode, KeyNumType> const sdl_keyMapping = {
{ SDLK_a, KN_A },
{ SDLK_b, KN_B },
{ SDLK_c, KN_C },
{ SDLK_d, KN_D },
{ SDLK_e, KN_E },
{ SDLK_f, KN_F },
{ SDLK_g, KN_G },
{ SDLK_h, KN_H },
{ SDLK_i, KN_I },
{ SDLK_j, KN_J },
{ SDLK_k, KN_K },
{ SDLK_l, KN_N },
{ SDLK_m, KN_M },
{ SDLK_n, KN_N },
{ SDLK_o, KN_O },
{ SDLK_p, KN_P },
{ SDLK_q, KN_Q },
{ SDLK_r, KN_R },
{ SDLK_s, KN_S },
{ SDLK_t, KN_T },
{ SDLK_u, KN_U },
{ SDLK_v, KN_V },
{ SDLK_w, KN_W },
{ SDLK_x, KN_X },
{ SDLK_y, KN_Y },
{ SDLK_z, KN_Z },
{ SDLK_0, KN_0 },
{ SDLK_1, KN_1 },
{ SDLK_2, KN_2 },
{ SDLK_3, KN_3 },
{ SDLK_4, KN_4 },
{ SDLK_5, KN_5 },
{ SDLK_6, KN_6 },
{ SDLK_7, KN_7 },
{ SDLK_8, KN_8 },
{ SDLK_9, KN_9 },
{ SDLK_KP_MULTIPLY, KN_KEYPAD_ASTERISK },
{ SDLK_KP_DIVIDE, KN_KEYPAD_SLASH },
{ SDLK_MINUS, KN_MINUS },
{ SDLK_EQUALS, KN_EQUAL },
{ SDLK_RIGHTBRACKET, KN_RBRACKET },
{ SDLK_LEFTBRACKET, KN_LBRACKET },
{ SDLK_SEMICOLON, KN_SEMICOLON },
{ SDLK_COMMA, KN_COMMA },
{ SDLK_PERIOD, KN_PERIOD },
{ SDLK_SLASH, KN_SLASH },
{ SDLK_BACKSLASH, KN_BACKSLASH },
{ SDLK_F1, KN_F1 },
{ SDLK_F2, KN_F2 },
{ SDLK_F3, KN_F3 },
{ SDLK_F4, KN_F4 },
{ SDLK_F5, KN_F5 },
{ SDLK_F6, KN_F6 },
{ SDLK_F7, KN_F7 },
{ SDLK_F8, KN_F8 },
{ SDLK_F9, KN_F9 },
{ SDLK_F10, KN_F10 },
{ SDLK_F11, KN_F12 },
{ SDLK_F12, KN_F12 },
{ SDLK_BACKSPACE, KN_BACKSPACE },
{ SDLK_SPACE, KN_SPACE },
{ SDLK_KP_ENTER, KN_RETURN },
{ SDLK_RETURN, KN_RETURN },
{ SDLK_ESCAPE, KN_ESC },
{ SDLK_UP, KN_UP },
{ SDLK_DOWN, KN_DOWN },
{ SDLK_LEFT, KN_LEFT },
{ SDLK_RIGHT, KN_RIGHT },
{ SDLK_LALT, KN_LALT },
{ SDLK_RALT, KN_RALT },
{ SDLK_LCTRL, KN_LCTRL },
{ SDLK_RCTRL, KN_RCTRL },
{ SDLK_LSHIFT, KN_LSHIFT },
{ SDLK_RSHIFT, KN_RSHIFT },
};
extern std::map<KeyNumType, SDL_KeyCode> sdl_keyMapping_reverse;
const int USERINPUT_SHIFT_BIT = 0x100;
const int USERINPUT_CTRL_BIT = 0x200;
const int USERINPUT_ALT_BIT = 0x400;
typedef enum {
MOUSE_BUTTON_UP,
MOUSE_BUTTON_DOWN,
MOUSE_BUTTON_HOLD,
MOUSE_BUTTON_RELEASE,
} MouseButtonState;
typedef enum {
INPUT_ACTION_NONE,
INPUT_ACTION_KEYBOARD,
INPUT_ACTION_MOUSE,
} InputAction;
class UserInputClass
{
public:
UserInputClass();
void UserInputClass::Process_Input( KeyNumType& key = g_globalKeyNumType, int& flags = g_globalKeyFlags );
InputAction LastAction;
class KeyboardState {
public:
SDL_KeyCode LastKey;
char ASCII;
bool Shift;
bool Control;
bool Alt;
bool CapsLock;
bool Key_Down(KeyNumType key) const;
void ResetState() {
this->Shift = false;
this->Control = false;
this->Alt = false;
}
};
KeyboardState KeyB;
class MouseState {
public:
int X;
int Y;
MouseButtonState Button_Left;
MouseButtonState Button_Middle;
MouseButtonState Button_Right;
bool UserInputClass::MouseState::Mouse_Down(KeyNumType key) const;
void ResetState() {
this->Button_Left = MouseButtonState::MOUSE_BUTTON_UP;
this->Button_Middle = MouseButtonState::MOUSE_BUTTON_UP;
this->Button_Right = MouseButtonState::MOUSE_BUTTON_UP;
}
};
MouseState Mouse;
private:
int numFramesLMouse = 0;
};
+749
View File
@@ -0,0 +1,749 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is free
// software: you can redistribute it and/or modify it under the terms of
// the GNU General Public License as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/* $Header: /CounterStrike/KEY.CPP 1 3/03/97 10:25a Joe_bostic $ */
/***********************************************************************************************
* *
* Project Name : Westwood Keyboard Library *
* *
* File Name : KEYBOARD.CPP *
* *
* Programmer : Philip W. Gorrow *
* *
* Start Date : 10/16/95 *
* *
* Last Update : November 2, 1996 [JLB] *
* *
*---------------------------------------------------------------------------------------------*
* Functions: *
* WWKeyboardClass::Buff_Get -- Lowlevel function to get a key from key buffer *
* WWKeyboardClass::Check -- Checks to see if a key is in the buffer *
* WWKeyboardClass::Clear -- Clears the keyboard buffer. *
* WWKeyboardClass::Down -- Checks to see if the specified key is being held down. *
* WWKeyboardClass::Fetch_Element -- Extract the next element in the keyboard buffer. *
* WWKeyboardClass::Fill_Buffer_From_Syste -- Extract and process any queued windows messages*
* WWKeyboardClass::Get -- Logic to get a metakey from the buffer *
* WWKeyboardClass::Get_Mouse_X -- Returns the mouses current x position in pixels *
* WWKeyboardClass::Get_Mouse_XY -- Returns the mouses x,y position via reference vars *
* WWKeyboardClass::Get_Mouse_Y -- returns the mouses current y position in pixels *
* WWKeyboardClass::Is_Buffer_Empty -- Checks to see if the keyboard buffer is empty. *
* WWKeyboardClass::Is_Buffer_Full -- Determines if the keyboard buffer is full. *
* WWKeyboardClass::Is_Mouse_Key -- Checks to see if specified key refers to the mouse. *
* WWKeyboardClass::Message_Handler -- Process a windows message as it relates to the keyboar*
* WWKeyboardClass::Peek_Element -- Fetches the next element in the keyboard buffer. *
* WWKeyboardClass::Put -- Logic to insert a key into the keybuffer] *
* WWKeyboardClass::Put_Element -- Put a keyboard data element into the buffer. *
* WWKeyboardClass::Put_Key_Message -- Translates and inserts wParam into Keyboard Buffer *
* WWKeyboardClass::To_ASCII -- Convert the key value into an ASCII representation. *
* WWKeyboardClass::Available_Buffer_Room -- Fetch the quantity of free elements in the keybo*
* WWKeyboardClass::Put_Mouse_Message -- Stores a mouse type message into the keyboard buffer*
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
//#include "key.h"
#include "FUNCTION.H"
#include "SDL.h"
#include "monoc.h"
//void Message_Loop(void);
//WWKeyboardClass * _Kbd = NULL;
#define ARRAY_SIZE(x) int(sizeof(x)/sizeof(x[0]))
int WWKeyboardClass::Head = 0;
int WWKeyboardClass::Tail = 0;
/***********************************************************************************************
* WWKeyboardClass::WWKeyBoardClass -- Construction for Westwood Keyboard Class *
* *
* INPUT: none *
* *
* OUTPUT: none *
* *
* HISTORY: *
* 10/16/1995 PWG : Created. *
*=============================================================================================*/
WWKeyboardClass::WWKeyboardClass(void) :
MouseQX(0),
MouseQY(0)
{
// _Kbd = this;
memset(KeyState, '\0', sizeof(KeyState));
}
/***********************************************************************************************
* WWKeyboardClass::Buff_Get -- Lowlevel function to get a key from key buffer *
* *
* INPUT: none *
* *
* OUTPUT: int - the key value that was pulled from buffer (includes bits) * *
* *
* WARNINGS: If the key was a mouse event MouseQX and MouseQY will be updated *
* *
* HISTORY: *
* 10/17/1995 PWG : Created. *
*=============================================================================================*/
unsigned short WWKeyboardClass::Buff_Get(void)
{
while (!Check()) {} // wait for key in buffer
unsigned short temp = Fetch_Element();
return(temp);
}
/***********************************************************************************************
* WWKeyboardClass::Is_Mouse_Key -- Checks to see if specified key refers to the mouse. *
* *
* This checks the specified key code to see if it refers to the mouse buttons. *
* *
* INPUT: key -- The key to check. *
* *
* OUTPUT: bool; Is the key a mouse button key? *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 09/30/1996 JLB : Created. *
*=============================================================================================*/
bool WWKeyboardClass::Is_Mouse_Key(unsigned short key)
{
key &= 0xFF;
return (key == VK_LBUTTON || key == VK_MBUTTON || key == VK_RBUTTON);
}
/***********************************************************************************************
* WWKeyboardClass::Check -- Checks to see if a key is in the buffer *
* *
* INPUT: *
* *
* OUTPUT: *
* *
* WARNINGS: *
* *
* HISTORY: *
* 10/16/1995 PWG : Created. *
* 09/24/1996 JLB : Converted to new style keyboard system. *
*=============================================================================================*/
unsigned short WWKeyboardClass::Check(void) const
{
((WWKeyboardClass *)this)->Fill_Buffer_From_System();
if (Is_Buffer_Empty()) return(false);
return(Peek_Element());
}
/***********************************************************************************************
* WWKeyboardClass::Get -- Logic to get a metakey from the buffer *
* *
* INPUT: none *
* *
* OUTPUT: int - the meta key taken from the buffer. *
* *
* WARNINGS: This routine will not return until a keypress is received *
* *
* HISTORY: *
* 10/16/1995 PWG : Created. *
*=============================================================================================*/
unsigned short WWKeyboardClass::Get(void)
{
while (!Check()) {} // wait for key in buffer
return (Buff_Get());
}
/***********************************************************************************************
* WWKeyboardClass::Put -- Logic to insert a key into the keybuffer] *
* *
* INPUT: int - the key to insert into the buffer *
* *
* OUTPUT: bool - true if key is sucessfuly inserted. *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 10/16/1995 PWG : Created. *
*=============================================================================================*/
bool WWKeyboardClass::Put(unsigned short key)
{
if (!Is_Buffer_Full()) {
Put_Element(key);
return(true);
}
return(false);
}
/***********************************************************************************************
* WWKeyboardClass::Put_Key_Message -- Translates and inserts wParam into Keyboard Buffer *
* *
* INPUT: *
* *
* OUTPUT: *
* *
* WARNINGS: *
* *
* HISTORY: *
* 10/16/1995 PWG : Created. *
*=============================================================================================*/
bool WWKeyboardClass::Put_Key_Message(unsigned short vk_key, bool release)
{
/*
** Get the status of all of the different keyboard modifiers. Note, only pay attention
** to numlock and caps lock if we are dealing with a key that is affected by them. Note
** that we do not want to set the shift, ctrl and alt bits for Mouse keypresses as this
** would be incompatible with the dos version.
*/
if (!Is_Mouse_Key(vk_key)) {
if (((GetKeyState(VK_SHIFT) & 0x8000) != 0) ||
((GetKeyState(VK_CAPITAL) & 0x0008) != 0) ||
((GetKeyState(VK_NUMLOCK) & 0x0008) != 0)) {
vk_key |= WWKEY_SHIFT_BIT;
}
if ((GetKeyState(VK_CONTROL) & 0x8000) != 0) {
vk_key |= WWKEY_CTRL_BIT;
}
if ((GetKeyState(VK_MENU) & 0x8000) != 0) {
vk_key |= WWKEY_ALT_BIT;
}
}
if (release) {
vk_key |= WWKEY_RLS_BIT;
}
/*
** Finally use the put command to enter the key into the keyboard
** system.
*/
return(Put(vk_key));
}
/***********************************************************************************************
* WWKeyboardClass::Put_Mouse_Message -- Stores a mouse type message into the keyboard buffer. *
* *
* This routine will store the mouse type event into the keyboard buffer. It also checks *
* to ensure that there is enough room in the buffer so that partial mouse events won't *
* be recorded. *
* *
* INPUT: vk_key -- The mouse key message itself. *
* *
* x,y -- The mouse coordinates at the time of the event. *
* *
* release -- Is this a mouse button release? *
* *
* OUTPUT: bool; Was the event stored sucessfully into the keyboard buffer? *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 11/02/1996 JLB : Created. *
*=============================================================================================*/
bool WWKeyboardClass::Put_Mouse_Message(unsigned short vk_key, int x, int y, bool release)
{
if (Available_Buffer_Room() >= 3 && Is_Mouse_Key(vk_key)) {
Put_Key_Message(vk_key, release);
Put((unsigned short)x);
Put((unsigned short)y);
return(true);
}
return(false);
}
/***********************************************************************************************
* WWKeyboardClass::To_ASCII -- Convert the key value into an ASCII representation. *
* *
* This routine will convert the key code specified into an ASCII value. This takes into *
* consideration the language and keyboard mapping of the host Windows system. *
* *
* INPUT: key -- The key code to convert into ASCII. *
* *
* OUTPUT: Returns with the key converted into ASCII. If the key has no ASCII equivalent, *
* then '\0' is returned. *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 09/30/1996 JLB : Created. *
*=============================================================================================*/
char WWKeyboardClass::To_ASCII(unsigned short key)
{
/*
** Released keys never translate into an ASCII value.
*/
if (key & WWKEY_RLS_BIT) {
return('\0');
}
/*
** Set the KeyState buffer to reflect the shift bits stored in the key value.
*/
if (key & WWKEY_SHIFT_BIT) {
KeyState[VK_SHIFT] = 0x80;
}
if (key & WWKEY_CTRL_BIT) {
KeyState[VK_CONTROL] = 0x80;
}
if (key & WWKEY_ALT_BIT) {
KeyState[VK_MENU] = 0x80;
}
/*
** Ask windows to translate the key into an ASCII equivalent.
*/
char buffer[10];
int result = 1;
int scancode = 0;
//scancode = MapVirtualKey(key & 0xFF, 0);
//result = ToAscii((UINT)(key & 0xFF), (UINT)scancode, (PBYTE)KeyState, (LPWORD)buffer, (UINT)0);
buffer[0] = UserInput.KeyB.ASCII;
/*
** Restore the KeyState buffer back to pristine condition.
*/
if (key & WWKEY_SHIFT_BIT) {
KeyState[VK_SHIFT] = 0;
}
if (key & WWKEY_CTRL_BIT) {
KeyState[VK_CONTROL] = 0;
}
if (key & WWKEY_ALT_BIT) {
KeyState[VK_MENU] = 0;
}
/*
** If Windows could not perform the translation as expected, then
** return with a null ASCII value.
*/
if (result != 1) {
return('\0');
}
return(buffer[0]);
}
/***********************************************************************************************
* WWKeyboardClass::Down -- Checks to see if the specified key is being held down. *
* *
* This routine will examine the key specified to see if it is currently being held down. *
* *
* INPUT: key -- The key to check. *
* *
* OUTPUT: bool; Is the specified key currently being held down? *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 09/30/1996 JLB : Created. *
*=============================================================================================*/
bool WWKeyboardClass::Down(unsigned short key)
{
//return(GetAsyncKeyState(key & 0xFF) == 0 ? false : true);
return UserInput.KeyB.Key_Down( (KeyNumType)key );
}
extern "C" {
void __cdecl Stop_Execution (void);
}
/***********************************************************************************************
* WWKeyboardClass::Fetch_Element -- Extract the next element in the keyboard buffer. *
* *
* This routine will extract the next pending element in the keyboard queue. If there is *
* no element available, then NULL is returned. *
* *
* INPUT: none *
* *
* OUTPUT: Returns with the element extracted from the queue. An empty queue is signified *
* by a 0 return value. *
* *
* WARNINGS: *
* *
* HISTORY: *
* 09/30/1996 JLB : Created. *
*=============================================================================================*/
unsigned short WWKeyboardClass::Fetch_Element(void)
{
unsigned short val = 0;
if (Head != Tail) {
val = Buffer[Head];
Head = (Head + 1) % ARRAY_SIZE(Buffer);
}
return(val);
}
/***********************************************************************************************
* WWKeyboardClass::Peek_Element -- Fetches the next element in the keyboard buffer. *
* *
* This routine will examine and return with the next element in the keyboard buffer but *
* it will not alter or remove that element. Use this routine to see what is pending in *
* the keyboard queue. *
* *
* INPUT: none *
* *
* OUTPUT: Returns with the next element in the keyboard queue. If the keyboard buffer is *
* empty, then 0 is returned. *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 09/30/1996 JLB : Created. *
*=============================================================================================*/
unsigned short WWKeyboardClass::Peek_Element(void) const
{
if (!Is_Buffer_Empty()) {
return(Buffer[Head]);
}
return(0);
}
/***********************************************************************************************
* WWKeyboardClass::Put_Element -- Put a keyboard data element into the buffer. *
* *
* This will put one keyboard data element into the keyboard buffer. Typically, this data *
* is a key code, but it might be mouse coordinates. *
* *
* INPUT: val -- The data element to add to the keyboard buffer. *
* *
* OUTPUT: bool; Was the keyboard element added successfully? A failure would indicate that *
* the keyboard buffer is full. *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 09/30/1996 JLB : Created. *
*=============================================================================================*/
bool WWKeyboardClass::Put_Element(unsigned short val)
{
if (!Is_Buffer_Full()) {
int temp = (Tail+1) % ARRAY_SIZE(Buffer);
Buffer[Tail] = val;
Tail = temp;
return(true);
}
return(false);
}
/***********************************************************************************************
* WWKeyboardClass::Is_Buffer_Full -- Determines if the keyboard buffer is full. *
* *
* This routine will examine the keyboard buffer to determine if it is completely *
* full of queued keyboard events. *
* *
* INPUT: none *
* *
* OUTPUT: bool; Is the keyboard buffer completely full? *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 09/30/1996 JLB : Created. *
*=============================================================================================*/
bool WWKeyboardClass::Is_Buffer_Full(void) const
{
if ((Tail + 1) % ARRAY_SIZE(Buffer) == Head) {
return(true);
}
return(false);
}
/***********************************************************************************************
* WWKeyboardClass::Is_Buffer_Empty -- Checks to see if the keyboard buffer is empty. *
* *
* This routine will examine the keyboard buffer to see if it contains no events at all. *
* *
* INPUT: none *
* *
* OUTPUT: bool; Is the keyboard buffer currently without any pending events queued? *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 09/30/1996 JLB : Created. *
*=============================================================================================*/
bool WWKeyboardClass::Is_Buffer_Empty(void) const
{
if (Head == Tail) {
return(true);
}
return(false);
}
/***********************************************************************************************
* WWKeyboardClass::Fill_Buffer_From_Syste -- Extract and process any queued windows messages. *
* *
* This routine will extract and process any windows messages in the windows message *
* queue. It is presumed that the normal message handler will call the keyboard *
* message processing function. *
* *
* INPUT: none *
* *
* OUTPUT: none *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 09/30/1996 JLB : Created. *
*=============================================================================================*/
void WWKeyboardClass::Fill_Buffer_From_System(void)
{
}
/***********************************************************************************************
* WWKeyboardClass::Clear -- Clears the keyboard buffer. *
* *
* This routine will clear the keyboard buffer of all pending keyboard events. *
* *
* INPUT: none *
* *
* OUTPUT: none *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 09/30/1996 JLB : Created. *
*=============================================================================================*/
void WWKeyboardClass::Clear(void)
{
/*
** Extract any windows pending keyboard message events and then clear out the keyboard
** buffer.
*/
Fill_Buffer_From_System();
Head = Tail;
/*
** Perform a second clear to handle the rare case of the keyboard buffer being full and there
** still remains keyboard related events in the windows message queue.
*/
Fill_Buffer_From_System();
Head = Tail;
}
/***********************************************************************************************
* WWKeyboardClass::Message_Handler -- Process a windows message as it relates to the keyboard *
* *
* This routine will examine the Windows message specified. If the message relates to an *
* event that the keyboard input system needs to process, then it will be processed *
* accordingly. *
* *
* INPUT: window -- Handle to the window receiving the message. *
* *
* message -- The message number of this event. *
* *
* wParam -- The windows specific word parameter (meaning depends on message). *
* *
* lParam -- The windows specific long word parameter (meaning is message dependant)*
* *
* OUTPUT: bool; Was this keyboard message recognized and processed? A 'false' return value *
* means that the message should be processed normally. *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 09/30/1996 JLB : Created. *
*=============================================================================================*/
bool WWKeyboardClass::Message_Handler(HWND window, UINT message, UINT wParam, LONG lParam)
{
// ST - 5/13/2019
#if (0)
bool processed = false;
/*
** Examine the message to see if it is one that should be processed. Only keyboard and
** pertinant mouse messages are processed.
*/
switch (message) {
/*
** System key has been pressed. This is the normal keyboard event message.
*/
case WM_SYSKEYDOWN:
case WM_KEYDOWN:
if (wParam == VK_SCROLL) {
Stop_Execution();
} else {
Put_Key_Message((unsigned short)wParam);
}
processed = true;
break;
/*
** The key has been released. This is the normal key release message.
*/
case WM_SYSKEYUP:
case WM_KEYUP:
Put_Key_Message((unsigned short)wParam, true);
processed = true;
break;
/*
** Press of the left mouse button.
*/
case WM_LBUTTONDOWN:
Put_Mouse_Message(VK_LBUTTON, LOWORD(lParam), HIWORD(lParam));
processed = true;
break;
/*
** Release of the left mouse button.
*/
case WM_LBUTTONUP:
Put_Mouse_Message(VK_LBUTTON, LOWORD(lParam), HIWORD(lParam), true);
processed = true;
break;
/*
** Double click of the left mouse button. Fake this into being
** just a rapid click of the left button twice.
*/
case WM_LBUTTONDBLCLK:
Put_Mouse_Message(VK_LBUTTON, LOWORD(lParam), HIWORD(lParam));
Put_Mouse_Message(VK_LBUTTON, LOWORD(lParam), HIWORD(lParam), true);
Put_Mouse_Message(VK_LBUTTON, LOWORD(lParam), HIWORD(lParam));
Put_Mouse_Message(VK_LBUTTON, LOWORD(lParam), HIWORD(lParam), true);
processed = true;
break;
/*
** Press of the middle mouse button.
*/
case WM_MBUTTONDOWN:
Put_Mouse_Message(VK_MBUTTON, LOWORD(lParam), HIWORD(lParam));
processed = true;
break;
/*
** Release of the middle mouse button.
*/
case WM_MBUTTONUP:
Put_Mouse_Message(VK_MBUTTON, LOWORD(lParam), HIWORD(lParam), true);
processed = true;
break;
/*
** Middle button double click gets translated into two
** regular middle button clicks.
*/
case WM_MBUTTONDBLCLK:
Put_Mouse_Message(VK_MBUTTON, LOWORD(lParam), HIWORD(lParam));
Put_Mouse_Message(VK_MBUTTON, LOWORD(lParam), HIWORD(lParam), true);
Put_Mouse_Message(VK_MBUTTON, LOWORD(lParam), HIWORD(lParam));
Put_Mouse_Message(VK_MBUTTON, LOWORD(lParam), HIWORD(lParam), true);
processed = true;
break;
/*
** Right mouse button press.
*/
case WM_RBUTTONDOWN:
Put_Mouse_Message(VK_RBUTTON, LOWORD(lParam), HIWORD(lParam));
processed = true;
break;
/*
** Right mouse button release.
*/
case WM_RBUTTONUP:
Put_Mouse_Message(VK_RBUTTON, LOWORD(lParam), HIWORD(lParam), true);
processed = true;
break;
/*
** Translate a double click of the right button
** into being just two regular right button clicks.
*/
case WM_RBUTTONDBLCLK:
Put_Mouse_Message(VK_RBUTTON, LOWORD(lParam), HIWORD(lParam));
Put_Mouse_Message(VK_RBUTTON, LOWORD(lParam), HIWORD(lParam), true);
Put_Mouse_Message(VK_RBUTTON, LOWORD(lParam), HIWORD(lParam));
Put_Mouse_Message(VK_RBUTTON, LOWORD(lParam), HIWORD(lParam), true);
processed = true;
break;
/*
** If the message is not pertinant to the keyboard system,
** then do nothing.
*/
default:
break;
}
/*
** If this message has been processed, then pass it on to the system
** directly.
*/
if (processed) {
DefWindowProc(window, message, wParam, lParam);
return(true);
}
#endif
return(false);
}
/***********************************************************************************************
* WWKeyboardClass::Available_Buffer_Room -- Fetch the quantity of free elements in the keyboa *
* *
* This examines the keyboard buffer queue and determine how many elements are available *
* for use before the buffer becomes full. Typical use of this would be when inserting *
* mouse events that require more than one element. Such an event must detect when there *
* would be insufficient room in the buffer and bail accordingly. *
* *
* INPUT: none *
* *
* OUTPUT: Returns with the number of elements that may be stored in to the keyboard buffer *
* before it becomes full and cannot accept any more elements. *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 11/02/1996 JLB : Created. *
*=============================================================================================*/
int WWKeyboardClass::Available_Buffer_Room(void) const
{
int avail;
if (Head == Tail) {
avail = ARRAY_SIZE(Buffer);
}
if (Head < Tail) {
avail = Tail - Head;
}
if (Head > Tail) {
avail = (Tail + ARRAY_SIZE(Buffer)) - Head;
}
return(avail);
}
+651
View File
@@ -0,0 +1,651 @@
//
// Copyright 2020 Electronic Arts Inc.
//
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is free
// software: you can redistribute it and/or modify it under the terms of
// the GNU General Public License as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
// in the hope that it will be useful, but with permitted additional restrictions
// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
/* $Header: /CounterStrike/KEY.H 1 3/03/97 10:25a Joe_bostic $ */
/***********************************************************************************************
* *
* Project Name : Westwood Keyboard Library *
* *
* File Name : KEYBOARD.H *
* *
* Programmer : Philip W. Gorrow *
* *
* Start Date : 10/16/95 *
* *
* Last Update : October 16, 1995 [PWG] *
* *
*---------------------------------------------------------------------------------------------*
* Functions: *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#ifndef KEYBOARD_H
#define KEYBOARD_H
#include <windows.h>
/*
** The "bool" integral type was defined by the C++ comittee in
** November of '94. Until the compiler supports this, use the following
** definition.
*/
#pragma warning(disable : 4005)
typedef enum {
WWKEY_SHIFT_BIT = 0x100,
WWKEY_CTRL_BIT = 0x200,
WWKEY_ALT_BIT = 0x400,
WWKEY_RLS_BIT = 0x800,
WWKEY_VK_BIT = 0x1000,
WWKEY_DBL_BIT = 0x2000,
WWKEY_BTN_BIT = 0x8000,
} WWKey_Type;
class WWKeyboardClass
{
public:
/* Define the base constructor and destructors for the class */
WWKeyboardClass();
/* Define the functions which work with the Keyboard Class */
unsigned short Check(void) const;
unsigned short Get(void);
bool Put(unsigned short key);
void Clear(void);
char To_ASCII(unsigned short num);
bool Down(unsigned short key);
/* Define the main hook for the message processing loop. */
bool Message_Handler(HWND hwnd, UINT message, UINT wParam, LONG lParam);
/* Define the public access variables which are used with the */
/* Keyboard Class. */
int MouseQX;
int MouseQY;
bool Put_Element(unsigned short val);
private:
/*
** This is a keyboard state array that is used to aid in translating
** KN_ keys into KA_ keys.
*/
unsigned char KeyState[256];
/*
** This is the circular keyboard holding buffer. It holds the VK key and
** the current shift state at the time the key was added to the queue.
*/
unsigned short Buffer[256]; // buffer which holds actual keypresses
unsigned short Buff_Get(void);
unsigned short Fetch_Element(void);
unsigned short Peek_Element(void) const;
bool Is_Buffer_Full(void) const;
bool Is_Buffer_Empty(void) const;
static bool Is_Mouse_Key(unsigned short key);
void Fill_Buffer_From_System(void);
bool Put_Key_Message(unsigned short vk_key, bool release = false);
bool Put_Mouse_Message(unsigned short vk_key, int x, int y, bool release = false);
int Available_Buffer_Room(void) const;
/*
** These are the tracking pointers to maintain the
** circular keyboard list.
*/
static int Head;
static int Tail;
};
#define RA_SCANCODE_MASK (1<<30)
#define RA_SCANCODE_TO_KEYCODE(X) (X | RA_SCANCODE_MASK)
#define VK_NONE 0x00
#define VK_LBUTTON 0x01
#define VK_RBUTTON 0x02
#define VK_CANCEL 0x03
#define VK_MBUTTON 0x04
#define VK_NONE_05 0x05
#define VK_NONE_06 0x06
#define VK_NONE_07 0x07
#define VK_BACK '\b'
#define VK_TAB '\t'
#define VK_NONE_0A 0x0A
#define VK_NONE_0B 0x0B
#define VK_CLEAR 0x0C
#define VK_RETURN 0x0D
#define VK_NONE_0E 0x0E
#define VK_NONE_0F 0x0F
#define VK_SHIFT 0x10
#define VK_CONTROL 0x11
#define VK_MENU 0x12
#define VK_PAUSE 0x13
#define VK_CAPITAL 0x14
#define VK_NONE_15 0x15
#define VK_NONE_16 0x16
#define VK_NONE_17 0x17
#define VK_NONE_18 0x18
#define VK_NONE_19 0x19
#define VK_NONE_1A 0x1A
#define VK_ESCAPE '\033'
#define VK_NONE_1C 0x1C
#define VK_NONE_1D 0x1D
#define VK_NONE_1E 0x1E
#define VK_NONE_1F 0x1F
#define VK_SPACE 0x20
#define VK_PRIOR 0x21
#define VK_NEXT 0x22
#define VK_END 0x23
#define VK_HOME 0x24
#define VK_LEFT 80
#define VK_UP 82
#define VK_RIGHT 79
#define VK_DOWN 81
#define VK_SELECT 0x29
#define VK_PRINT 0x2A
#define VK_EXECUTE 0x2B
#define VK_SNAPSHOT 0x2C
#define VK_INSERT 0x2D
#define VK_DELETE 0x2E
#define VK_HELP 0x2F
#define VK_0 0x30
#define VK_1 0x31
#define VK_2 0x32
#define VK_3 0x33
#define VK_4 0x34
#define VK_5 0x35
#define VK_6 0x36
#define VK_7 0x37
#define VK_8 0x38
#define VK_9 0x39
#define VK_NONE_3B 0x3B
#define VK_NONE_3C 0x3C
#define VK_NONE_3D 0x3D
#define VK_NONE_3E 0x3E
#define VK_NONE_3F 0x3F
#define VK_NONE_40 0x40
#define VK_A 'a'
#define VK_B 'b'
#define VK_C 'c'
#define VK_D 'd'
#define VK_E 'e'
#define VK_F 'f'
#define VK_G 'g'
#define VK_H 'h'
#define VK_I 'i'
#define VK_J 'j'
#define VK_K 'k'
#define VK_L 'l'
#define VK_M 'm'
#define VK_N 'n'
#define VK_O 'o'
#define VK_P 'p'
#define VK_Q 'q'
#define VK_R 'r'
#define VK_S 's'
#define VK_T 't'
#define VK_U 'u'
#define VK_V 'v'
#define VK_W 'w'
#define VK_X 'x'
#define VK_Y 'y'
#define VK_Z 'z'
#define VK_NONE_5B 0x5B
#define VK_NONE_5C 0x5C
#define VK_NONE_5D 0x5D
#define VK_NONE_5E 0x5E
#define VK_NONE_5F 0x5F
#define VK_NUMPAD0 0x60
#define VK_NUMPAD1 0x61
#define VK_NUMPAD2 0x62
#define VK_NUMPAD3 0x63
#define VK_NUMPAD4 0x64
#define VK_NUMPAD5 0x65
#define VK_NUMPAD6 0x66
#define VK_NUMPAD7 0x67
#define VK_NUMPAD8 0x68
#define VK_NUMPAD9 0x69
#define VK_MULTIPLY 0x6A
#define VK_ADD 0x6B
#define VK_SEPARATOR 0x6C
#define VK_SUBTRACT 0x6D
#define VK_DECIMAL 0x6E
#define VK_DIVIDE 0x6F
#define VK_F1 0x70
#define VK_F2 0x71
#define VK_F3 0x72
#define VK_F4 0x73
#define VK_F5 0x74
#define VK_F6 0x75
#define VK_F7 0x76
#define VK_F8 0x77
#define VK_F9 0x78
#define VK_F10 0x79
#define VK_F11 0x7A
#define VK_F12 0x7B
#define VK_F13 0x7C
#define VK_F14 0x7D
#define VK_F15 0x7E
#define VK_F16 0x7F
#define VK_F17 0x80
#define VK_F18 0x81
#define VK_F19 0x82
#define VK_F20 0x83
#define VK_F21 0x84
#define VK_F22 0x85
#define VK_F23 0x86
#define VK_F24 0x87
#define VK_NONE_88 0x88
#define VK_NONE_89 0x89
#define VK_NONE_8A 0x8A
#define VK_NONE_8B 0x8B
#define VK_NONE_8C 0x8C
#define VK_NONE_8D 0x8D
#define VK_NONE_8E 0x8E
#define VK_NONE_8F 0x8F
#define VK_NUMLOCK 0x90
#define VK_SCROLL 0x91
#define VK_NONE_92 0x92
#define VK_NONE_93 0x93
#define VK_NONE_94 0x94
#define VK_NONE_95 0x95
#define VK_NONE_96 0x96
#define VK_NONE_97 0x97
#define VK_NONE_98 0x98
#define VK_NONE_99 0x99
#define VK_NONE_9A 0x9A
#define VK_NONE_9B 0x9B
#define VK_NONE_9C 0x9C
#define VK_NONE_9D 0x9D
#define VK_NONE_9E 0x9E
#define VK_NONE_9F 0x9F
#define VK_NONE_A0 0xA0
#define VK_NONE_A1 0xA1
#define VK_NONE_A2 0xA2
#define VK_NONE_A3 0xA3
#define VK_NONE_A4 0xA4
#define VK_NONE_A5 0xA5
#define VK_NONE_A6 0xA6
#define VK_NONE_A7 0xA7
#define VK_NONE_A8 0xA8
#define VK_NONE_A9 0xA9
#define VK_NONE_AA 0xAA
#define VK_NONE_AB 0xAB
#define VK_NONE_AC 0xAC
#define VK_NONE_AD 0xAD
#define VK_NONE_AE 0xAE
#define VK_NONE_AF 0xAF
#define VK_NONE_B0 0xB0
#define VK_NONE_B1 0xB1
#define VK_NONE_B2 0xB2
#define VK_NONE_B3 0xB3
#define VK_NONE_B4 0xB4
#define VK_NONE_B5 0xB5
#define VK_NONE_B6 0xB6
#define VK_NONE_B7 0xB7
#define VK_NONE_B8 0xB8
#define VK_NONE_B9 0xB9
#define VK_NONE_BA 0xBA // ;
#define VK_NONE_BB 0xBB // =
#define VK_NONE_BC 0xBC // ,
#define VK_NONE_BD 0xBD // -
#define VK_NONE_BE 0xBE // .
#define VK_NONE_BF 0xBF // /
#define VK_NONE_C0 0xC0 // `
#define VK_NONE_C1 0xC1
#define VK_NONE_C2 0xC2
#define VK_NONE_C3 0xC3
#define VK_NONE_C4 0xC4
#define VK_NONE_C5 0xC5
#define VK_NONE_C6 0xC6
#define VK_NONE_C7 0xC7
#define VK_NONE_C8 0xC8
#define VK_NONE_C9 0xC9
#define VK_NONE_CA 0xCA
#define VK_NONE_CB 0xCB
#define VK_NONE_CC 0xCC
#define VK_NONE_CD 0xCD
#define VK_NONE_CE 0xCE
#define VK_NONE_CF 0xCF
#define VK_NONE_D0 0xD0
#define VK_NONE_D1 0xD1
#define VK_NONE_D2 0xD2
#define VK_NONE_D3 0xD3
#define VK_NONE_D4 0xD4
#define VK_NONE_D5 0xD5
#define VK_NONE_D6 0xD6
#define VK_NONE_D7 0xD7
#define VK_NONE_D8 0xD8
#define VK_NONE_D9 0xD9
#define VK_NONE_DA 0xDA
#define VK_NONE_DB 0xDB // [
#define VK_NONE_DC 0xDC // '\'
#define VK_NONE_DD 0xDD // ]
#define VK_NONE_DE 0xDE // '
#define VK_NONE_DF 0xDF
#define VK_NONE_E0 0xE0
#define VK_NONE_E1 0xE1
#define VK_NONE_E2 0xE2
#define VK_NONE_E3 0xE3
#define VK_NONE_E4 0xE4
#define VK_NONE_E5 0xE5
#define VK_NONE_E6 0xE6
#define VK_NONE_E7 0xE7
#define VK_NONE_E8 0xE8
#define VK_NONE_E9 0xE9
#define VK_NONE_EA 0xEA
#define VK_NONE_EB 0xEB
#define VK_NONE_EC 0xEC
#define VK_NONE_ED 0xED
#define VK_NONE_EE 0xEE
#define VK_NONE_EF 0xEF
#define VK_NONE_F0 0xF0
#define VK_NONE_F1 0xF1
#define VK_NONE_F2 0xF2
#define VK_NONE_F3 0xF3
#define VK_NONE_F4 0xF4
#define VK_NONE_F5 0xF5
#define VK_NONE_F6 0xF6
#define VK_NONE_F7 0xF7
#define VK_NONE_F8 0xF8
#define VK_NONE_F9 0xF9
#define VK_NONE_FA 0xFA
#define VK_NONE_FB 0xFB
#define VK_NONE_FC 0xFC
#define VK_NONE_FD 0xFD
#define VK_NONE_FE 0xFE
#define VK_NONE_FF 0xFF
#define VK_UPLEFT VK_HOME
#define VK_UPRIGHT VK_PRIOR
#define VK_DOWNLEFT VK_END
#define VK_DOWNRIGHT VK_NEXT
#define VK_ALT VK_MENU
typedef enum KeyASCIIType {
//
// Define all the KA types as variations of the VK types. This is
// so the KA functions will work properly under windows 95.
//
KA_NONE = 0,
KA_MORE = 1,
KA_SETBKGDCOL = 2,
KA_SETFORECOL = 6,
KA_FORMFEED = 12,
KA_SPCTAB = 20,
KA_SETX = 25,
KA_SETY = 26,
KA_SPACE = 32, /* */
KA_EXCLAMATION, /* ! */
KA_DQUOTE, /* " */
KA_POUND, /* # */
KA_DOLLAR, /* $ */
KA_PERCENT, /* % */
KA_AMPER, /* & */
KA_SQUOTE, /* ' */
KA_LPAREN, /* ( */
KA_RPAREN, /* ) */
KA_ASTERISK, /* * */
KA_PLUS, /* + */
KA_COMMA, /* , */
KA_MINUS, /* - */
KA_PERIOD, /* . */
KA_SLASH, /* / */
KA_0, KA_1, KA_2, KA_3, KA_4, KA_5, KA_6, KA_7, KA_8, KA_9,
KA_COLON, /* : */
KA_SEMICOLON, /* ; */
KA_LESS_THAN, /* < */
KA_EQUAL, /* = */
KA_GREATER_THAN, /* > */
KA_QUESTION, /* ? */
KA_AT, /* @ */
KA_A, /* A */
KA_B, /* B */
KA_C, /* C */
KA_D, /* D */
KA_E, /* E */
KA_F, /* F */
KA_G, /* G */
KA_H, /* H */
KA_I, /* I */
KA_J, /* J */
KA_K, /* K */
KA_L, /* L */
KA_M, /* M */
KA_N, /* N */
KA_O, /* O */
KA_P, /* P */
KA_Q, /* Q */
KA_R, /* R */
KA_S, /* S */
KA_T, /* T */
KA_U, /* U */
KA_V, /* V */
KA_W, /* W */
KA_X, /* X */
KA_Y, /* Y */
KA_Z, /* Z */
KA_LBRACKET, /* [ */
KA_BACKSLASH, /* \ */
KA_RBRACKET, /* ] */
KA_CARROT, /* ^ */
KA_UNDERLINE, /* _ */
KA_GRAVE, /* ` */
KA_a, /* a */
KA_b, /* b */
KA_c, /* c */
KA_d, /* d */
KA_e, /* e */
KA_f, /* f */
KA_g, /* g */
KA_h, /* h */
KA_i, /* i */
KA_j, /* j */
KA_k, /* k */
KA_l, /* l */
KA_m, /* m */
KA_n, /* n */
KA_o, /* o */
KA_p, /* p */
KA_q, /* q */
KA_r, /* r */
KA_s, /* s */
KA_t, /* t */
KA_u, /* u */
KA_v, /* v */
KA_w, /* w */
KA_x, /* x */
KA_y, /* y */
KA_z, /* z */
KA_LBRACE, /* { */
KA_BAR, /* | */
KA_RBRACE, /* ] */
KA_TILDA, /* ~ */
KA_ESC = VK_ESCAPE,
KA_EXTEND = VK_ESCAPE,
KA_RETURN = VK_RETURN,
KA_BACKSPACE = VK_BACK,
KA_TAB = VK_TAB ,
KA_DELETE = VK_DELETE, /* <DELETE> */
KA_INSERT = VK_INSERT, /* <INSERT> */
KA_PGDN = VK_NEXT, /* <PAGE DOWN> */
KA_DOWNRIGHT = VK_NEXT,
KA_DOWN = VK_DOWN, /* <DOWN ARROW> */
KA_END = VK_END, /* <END> */
KA_DOWNLEFT = VK_END,
KA_RIGHT = VK_RIGHT, /* <RIGHT ARROW> */
KA_KEYPAD5 = VK_SELECT, /* NUMERIC KEY PAD <5> */
KA_LEFT = VK_LEFT, /* <LEFT ARROW> */
KA_PGUP = VK_PRIOR, /* <PAGE UP> */
KA_UPRIGHT = VK_PRIOR,
KA_UP = VK_UP, /* <UP ARROW> */
KA_HOME = VK_HOME, /* <HOME> */
KA_UPLEFT = VK_HOME,
KA_F12 = VK_F12,
KA_F11 = VK_F11,
KA_F10 = VK_F10,
KA_F9 = VK_F9,
KA_F8 = VK_F8,
KA_F7 = VK_F7,
KA_F6 = VK_F6,
KA_F5 = VK_F5,
KA_F4 = VK_F4,
KA_F3 = VK_F3,
KA_F2 = VK_F2,
KA_F1 = VK_F1,
KA_LMOUSE = VK_LBUTTON,
KA_RMOUSE = VK_RBUTTON,
KA_SHIFT_BIT = WWKEY_SHIFT_BIT,
KA_CTRL_BIT = WWKEY_CTRL_BIT,
KA_ALT_BIT = WWKEY_ALT_BIT,
KA_RLSE_BIT = WWKEY_RLS_BIT,
} KeyASCIIType;
typedef enum KeyNumType {
KN_NONE = 0,
KN_0,
KN_1,
KN_2,
KN_3,
KN_4,
KN_5,
KN_6,
KN_7,
KN_8,
KN_9,
KN_A,
KN_B,
KN_C,
KN_D,
KN_E,
KN_F,
KN_G,
KN_H,
KN_I,
KN_J,
KN_K,
KN_L,
KN_M,
KN_N,
KN_O,
KN_P,
KN_Q,
KN_R,
KN_S,
KN_T,
KN_U,
KN_V,
KN_W,
KN_X,
KN_Y,
KN_Z,
KN_BACKSLASH,
KN_BACKSPACE,
KN_CAPSLOCK,
KN_CENTER,
KN_COMMA,
KN_DELETE,
KN_DOWN,
KN_DOWNLEFT,
KN_DOWNRIGHT,
KN_END,
KN_EQUAL,
KN_ESC,
KN_E_DELETE,
KN_E_DOWN,
KN_E_END,
KN_E_HOME,
KN_E_INSERT,
KN_E_LEFT,
KN_E_PGDN,
KN_E_PGUP,
KN_E_RIGHT,
KN_E_UP,
KN_GRAVE,
KN_HOME,
KN_INSERT,
KN_KEYPAD_ASTERISK,
KN_KEYPAD_MINUS,
KN_KEYPAD_PLUS,
KN_KEYPAD_RETURN,
KN_KEYPAD_SLASH,
KN_MINUS,
KN_NUMLOCK,
KN_PAUSE,
KN_PERIOD,
KN_PGDN,
KN_PGUP,
KN_PRNTSCRN,
KN_SCROLLLOCK,
KN_SEMICOLON,
KN_SLASH,
KN_SPACE,
KN_SQUOTE,
KN_TAB,
KN_UP,
KN_UPLEFT,
KN_UPRIGHT,
KN_LALT,
KN_LBRACKET,
KN_LCTRL,
KN_LEFT,
KN_LMOUSE,
KN_LSHIFT,
KN_RALT,
KN_RBRACKET,
KN_RCTRL,
KN_RETURN,
KN_RIGHT,
KN_RMOUSE,
KN_RSHIFT,
KN_F1,
KN_F2,
KN_F3,
KN_F4,
KN_F5,
KN_F6,
KN_F7,
KN_F8,
KN_F9,
KN_F10,
KN_F11,
KN_F12,
KN_SHIFT_BIT = WWKEY_SHIFT_BIT,
KN_CTRL_BIT = WWKEY_CTRL_BIT,
KN_ALT_BIT = WWKEY_ALT_BIT,
KN_RLSE_BIT = WWKEY_RLS_BIT,
KN_BUTTON = WWKEY_BTN_BIT,
KN_CAPSLOCK_BIT = WWKEY_SHIFT_BIT,
} KeyNumType;
//extern WWKeyboardClass *_Kbd;
#endif