mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-14 02:27:40 -04:00
Separate KeyEvents and KeyPresses
This commit is contained in:
@ -365,6 +365,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
gClient->SetQuitIntro(true);
|
gClient->SetQuitIntro(true);
|
||||||
}
|
}
|
||||||
// Fall through to other events
|
// Fall through to other events
|
||||||
|
case WM_CHAR:
|
||||||
case WM_KEYUP :
|
case WM_KEYUP :
|
||||||
case WM_LBUTTONUP :
|
case WM_LBUTTONUP :
|
||||||
case WM_RBUTTONUP :
|
case WM_RBUTTONUP :
|
||||||
|
@ -828,9 +828,9 @@ void pfConsole::IHandleKey( plKeyEventMsg *msg )
|
|||||||
{
|
{
|
||||||
fWorkingCursor = 0;
|
fWorkingCursor = 0;
|
||||||
}
|
}
|
||||||
else
|
else if (msg->GetKeyChar() != nil)
|
||||||
{
|
{
|
||||||
key = plKeyboardDevice::KeyEventToChar( msg );
|
key = msg->GetKeyChar();
|
||||||
// do they want to go into help mode?
|
// do they want to go into help mode?
|
||||||
if( !fPythonMode && key == L'?' && fWorkingCursor == 0 )
|
if( !fPythonMode && key == L'?' && fWorkingCursor == 0 )
|
||||||
{
|
{
|
||||||
|
@ -95,7 +95,6 @@ class pfConsole : public hsKeyedObject
|
|||||||
pfConsoleEngine *fEngine;
|
pfConsoleEngine *fEngine;
|
||||||
|
|
||||||
void IHandleKey( plKeyEventMsg *msg );
|
void IHandleKey( plKeyEventMsg *msg );
|
||||||
char IKeyEventToChar( plKeyEventMsg *msg );
|
|
||||||
|
|
||||||
static UInt32 fConsoleTextColor;
|
static UInt32 fConsoleTextColor;
|
||||||
static pfConsole *fTheConsole;
|
static pfConsole *fTheConsole;
|
||||||
|
@ -60,10 +60,7 @@ pfGUIEditBoxMod::pfGUIEditBoxMod()
|
|||||||
fFirstHalfExitKeyPushed = false;
|
fFirstHalfExitKeyPushed = false;
|
||||||
fSpecialCaptureKeyEventMode = false;
|
fSpecialCaptureKeyEventMode = false;
|
||||||
fBuffer = 0;
|
fBuffer = 0;
|
||||||
fLastDeadKey = 0;
|
|
||||||
SetBufferSize( 128 );
|
SetBufferSize( 128 );
|
||||||
|
|
||||||
SetupDeadKeyConverter();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pfGUIEditBoxMod::~pfGUIEditBoxMod()
|
pfGUIEditBoxMod::~pfGUIEditBoxMod()
|
||||||
@ -71,61 +68,6 @@ pfGUIEditBoxMod::~pfGUIEditBoxMod()
|
|||||||
delete [] fBuffer;
|
delete [] fBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pfGUIEditBoxMod::SetupDeadKeyConverter()
|
|
||||||
{
|
|
||||||
int i,j;
|
|
||||||
for (i=0; i<255; i++)
|
|
||||||
for (j=0; j<255; j++)
|
|
||||||
fDeadKeyConverter[i][j] = 0L;
|
|
||||||
|
|
||||||
// we are adding 100 to the indexes because some of these chars have a negative index for some reason
|
|
||||||
fDeadKeyConverter['^'+100]['a'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['^'+100]['e'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['^'+100]['i'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['^'+100]['o'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['^'+100]['u'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['^'+100]['A'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['^'+100]['E'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['^'+100]['I'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['^'+100]['O'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['^'+100]['U'] = L'<EFBFBD>';
|
|
||||||
|
|
||||||
fDeadKeyConverter['<EFBFBD>'+100]['a'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['<EFBFBD>'+100]['e'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['<EFBFBD>'+100]['i'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['<EFBFBD>'+100]['o'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['<EFBFBD>'+100]['u'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['<EFBFBD>'+100]['A'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['<EFBFBD>'+100]['E'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['<EFBFBD>'+100]['I'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['<EFBFBD>'+100]['O'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['<EFBFBD>'+100]['U'] = L'<EFBFBD>';
|
|
||||||
|
|
||||||
fDeadKeyConverter['<EFBFBD>'+100]['a'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['<EFBFBD>'+100]['e'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['<EFBFBD>'+100]['i'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['<EFBFBD>'+100]['o'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['<EFBFBD>'+100]['u'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['<EFBFBD>'+100]['y'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['<EFBFBD>'+100]['A'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['<EFBFBD>'+100]['E'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['<EFBFBD>'+100]['I'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['<EFBFBD>'+100]['O'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['<EFBFBD>'+100]['U'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['<EFBFBD>'+100]['Y'] = L'<EFBFBD>';
|
|
||||||
|
|
||||||
fDeadKeyConverter['`'+100]['a'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['`'+100]['e'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['`'+100]['i'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['`'+100]['o'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['`'+100]['u'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['`'+100]['A'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['`'+100]['E'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['`'+100]['I'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['`'+100]['O'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['`'+100]['U'] = L'<EFBFBD>';
|
|
||||||
}
|
|
||||||
|
|
||||||
//// IEval ///////////////////////////////////////////////////////////////////
|
//// IEval ///////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
hsBool pfGUIEditBoxMod::IEval( double secs, hsScalar del, UInt32 dirty )
|
hsBool pfGUIEditBoxMod::IEval( double secs, hsScalar del, UInt32 dirty )
|
||||||
@ -288,62 +230,8 @@ hsBool pfGUIEditBoxMod::HandleKeyPress( wchar_t key, UInt8 modifiers )
|
|||||||
fIgnoreNextKey = false;
|
fIgnoreNextKey = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plKeyboardDevice::KeyIsDeadKey())
|
|
||||||
{
|
|
||||||
if (fLastDeadKey != 0)
|
|
||||||
{
|
|
||||||
wchar_t temp = key; // we have two dead keys in a row, print out the old one and store the new one
|
|
||||||
key = fLastDeadKey;
|
|
||||||
fLastDeadKey = temp;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fLastDeadKey = key; // store the dead key and don't print it until we get the next char
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int i = wcslen( fBuffer );
|
int i = wcslen( fBuffer );
|
||||||
if (fLastDeadKey != 0) // we have a dead key that needs to be added in
|
|
||||||
{
|
|
||||||
wchar_t translatedKey = fDeadKeyConverter[(char)fLastDeadKey+100][(char)key];
|
|
||||||
if (translatedKey == 0) // no translation possible?
|
|
||||||
{
|
|
||||||
// so we need to print the dead key, followed by the typed key
|
|
||||||
// unless key is a space, then we just type the dead key
|
|
||||||
if (key == L' ')
|
|
||||||
{
|
|
||||||
if (i<fBufferSize - 1)
|
|
||||||
{
|
|
||||||
memmove(fBuffer+fCursorPos+1, fBuffer+fCursorPos, (i - fCursorPos + 1) * sizeof(wchar_t));
|
|
||||||
fBuffer[fCursorPos] = fLastDeadKey;
|
|
||||||
fCursorPos++;
|
|
||||||
HandleExtendedEvent(kValueChanging);
|
|
||||||
}
|
|
||||||
fLastDeadKey = 0L;
|
|
||||||
IUpdate();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
// print two chars now
|
|
||||||
if (i<fBufferSize - 2 && key != 0L)
|
|
||||||
{
|
|
||||||
memmove(fBuffer+fCursorPos+2, fBuffer+fCursorPos, (i - fCursorPos + 2) * sizeof(wchar_t));
|
|
||||||
fBuffer[fCursorPos] = fLastDeadKey;
|
|
||||||
fCursorPos++;
|
|
||||||
fBuffer[fCursorPos] = key;
|
|
||||||
fCursorPos++;
|
|
||||||
|
|
||||||
HandleExtendedEvent( kValueChanging );
|
|
||||||
}
|
|
||||||
fLastDeadKey = 0L;
|
|
||||||
IUpdate();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
// ok, so we have a translated key now, so assign it to our key and print it normally
|
|
||||||
key = translatedKey;
|
|
||||||
fLastDeadKey = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Insert character at the current cursor position, then inc the cursor by one
|
// Insert character at the current cursor position, then inc the cursor by one
|
||||||
if( i < fBufferSize - 1 && key != 0 )
|
if( i < fBufferSize - 1 && key != 0 )
|
||||||
|
@ -57,17 +57,12 @@ class pfGUIEditBoxMod : public pfGUIControlMod
|
|||||||
|
|
||||||
plKeyDef fSavedKey;
|
plKeyDef fSavedKey;
|
||||||
UInt8 fSavedModifiers;
|
UInt8 fSavedModifiers;
|
||||||
|
|
||||||
wchar_t fLastDeadKey; // if the previous key was a dead key, its value goes here
|
|
||||||
wchar_t fDeadKeyConverter[256][256]; // first index is the dead key, second index is the char to combine it with
|
|
||||||
|
|
||||||
virtual hsBool IEval( double secs, hsScalar del, UInt32 dirty ); // called only by owner object's Eval()
|
virtual hsBool IEval( double secs, hsScalar del, UInt32 dirty ); // called only by owner object's Eval()
|
||||||
|
|
||||||
virtual void IPostSetUpDynTextMap( void );
|
virtual void IPostSetUpDynTextMap( void );
|
||||||
virtual void IUpdate( void );
|
virtual void IUpdate( void );
|
||||||
|
|
||||||
void SetupDeadKeyConverter();
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
@ -145,9 +145,6 @@ pfGUIMultiLineEditCtrl::pfGUIMultiLineEditCtrl()
|
|||||||
fLastKeyPressed = 0;
|
fLastKeyPressed = 0;
|
||||||
fLockCount = 0;
|
fLockCount = 0;
|
||||||
|
|
||||||
fLastDeadKey = 0;
|
|
||||||
SetupDeadKeyConverter();
|
|
||||||
|
|
||||||
fNextCtrl = nil;
|
fNextCtrl = nil;
|
||||||
fPrevCtrl = nil;
|
fPrevCtrl = nil;
|
||||||
|
|
||||||
@ -174,61 +171,6 @@ pfGUIMultiLineEditCtrl::~pfGUIMultiLineEditCtrl()
|
|||||||
delete fEventProc;
|
delete fEventProc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pfGUIMultiLineEditCtrl::SetupDeadKeyConverter()
|
|
||||||
{
|
|
||||||
int i,j;
|
|
||||||
for (i=0; i<255; i++)
|
|
||||||
for (j=0; j<255; j++)
|
|
||||||
fDeadKeyConverter[i][j] = 0L;
|
|
||||||
|
|
||||||
// we are adding 100 to the indexes because some of these chars have a negative index for some reason
|
|
||||||
fDeadKeyConverter['^'+100]['a'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['^'+100]['e'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['^'+100]['i'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['^'+100]['o'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['^'+100]['u'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['^'+100]['A'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['^'+100]['E'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['^'+100]['I'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['^'+100]['O'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['^'+100]['U'] = L'<EFBFBD>';
|
|
||||||
|
|
||||||
fDeadKeyConverter['<EFBFBD>'+100]['a'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['<EFBFBD>'+100]['e'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['<EFBFBD>'+100]['i'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['<EFBFBD>'+100]['o'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['<EFBFBD>'+100]['u'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['<EFBFBD>'+100]['A'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['<EFBFBD>'+100]['E'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['<EFBFBD>'+100]['I'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['<EFBFBD>'+100]['O'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['<EFBFBD>'+100]['U'] = L'<EFBFBD>';
|
|
||||||
|
|
||||||
fDeadKeyConverter['<EFBFBD>'+100]['a'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['<EFBFBD>'+100]['e'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['<EFBFBD>'+100]['i'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['<EFBFBD>'+100]['o'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['<EFBFBD>'+100]['u'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['<EFBFBD>'+100]['y'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['<EFBFBD>'+100]['A'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['<EFBFBD>'+100]['E'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['<EFBFBD>'+100]['I'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['<EFBFBD>'+100]['O'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['<EFBFBD>'+100]['U'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['<EFBFBD>'+100]['Y'] = L'<EFBFBD>';
|
|
||||||
|
|
||||||
fDeadKeyConverter['`'+100]['a'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['`'+100]['e'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['`'+100]['i'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['`'+100]['o'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['`'+100]['u'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['`'+100]['A'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['`'+100]['E'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['`'+100]['I'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['`'+100]['O'] = L'<EFBFBD>';
|
|
||||||
fDeadKeyConverter['`'+100]['U'] = L'<EFBFBD>';
|
|
||||||
}
|
|
||||||
|
|
||||||
//// IEval ///////////////////////////////////////////////////////////////////
|
//// IEval ///////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
hsBool pfGUIMultiLineEditCtrl::IEval( double secs, hsScalar del, UInt32 dirty )
|
hsBool pfGUIMultiLineEditCtrl::IEval( double secs, hsScalar del, UInt32 dirty )
|
||||||
@ -1098,48 +1040,6 @@ hsBool pfGUIMultiLineEditCtrl::HandleKeyPress( wchar_t key, UInt8 modifiers )
|
|||||||
if( IsLocked() )
|
if( IsLocked() )
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (plKeyboardDevice::KeyIsDeadKey())
|
|
||||||
{
|
|
||||||
if (fLastDeadKey != 0)
|
|
||||||
{
|
|
||||||
wchar_t temp = key; // we have two dead keys in a row, print out the old one and store the new one
|
|
||||||
key = fLastDeadKey;
|
|
||||||
fLastDeadKey = temp;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fLastDeadKey = key; // store the dead key and don't print it until we get the next char
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fLastDeadKey != 0) // we have a dead key that needs to be added in
|
|
||||||
{
|
|
||||||
wchar_t translatedKey = fDeadKeyConverter[(char)fLastDeadKey+100][(char)key];
|
|
||||||
if (translatedKey == 0) // no translation possible?
|
|
||||||
{
|
|
||||||
// so we need to print the dead key, followed by the typed key
|
|
||||||
// unless key is a space, then we just type the dead key
|
|
||||||
if (key == ' ')
|
|
||||||
{
|
|
||||||
// Insert character at the current cursor position, then inc the cursor by one
|
|
||||||
// Note: we always want selection mode off when we're typing
|
|
||||||
InsertChar( fLastDeadKey );
|
|
||||||
fLastDeadKey = 0;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
// Insert characters at the current cursor position, then inc the cursor by one
|
|
||||||
// Note: we always want selection mode off when we're typing
|
|
||||||
InsertChar( fLastDeadKey );
|
|
||||||
InsertChar( key );
|
|
||||||
fLastDeadKey = 0;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
// ok, so we have a translated key now, so assign it to our key and print it normally
|
|
||||||
key = translatedKey;
|
|
||||||
fLastDeadKey = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Insert character at the current cursor position, then inc the cursor by one
|
// Insert character at the current cursor position, then inc the cursor by one
|
||||||
// Note: we always want selection mode off when we're typing
|
// Note: we always want selection mode off when we're typing
|
||||||
InsertChar( key );
|
InsertChar( key );
|
||||||
|
@ -94,11 +94,6 @@ class pfGUIMultiLineEditCtrl : public pfGUIControlMod
|
|||||||
|
|
||||||
static wchar_t fColorCodeChar, fStyleCodeChar;
|
static wchar_t fColorCodeChar, fStyleCodeChar;
|
||||||
static UInt32 fColorCodeSize, fStyleCodeSize;
|
static UInt32 fColorCodeSize, fStyleCodeSize;
|
||||||
|
|
||||||
wchar_t fLastDeadKey; // if the previous key was a dead key, its value goes here
|
|
||||||
wchar_t fDeadKeyConverter[256][256]; // first index is the dead key, second index is the char to combine it with
|
|
||||||
|
|
||||||
void SetupDeadKeyConverter();
|
|
||||||
|
|
||||||
virtual hsBool IEval( double secs, hsScalar del, UInt32 dirty ); // called only by owner object's Eval()
|
virtual hsBool IEval( double secs, hsScalar del, UInt32 dirty ); // called only by owner object's Eval()
|
||||||
|
|
||||||
|
@ -751,7 +751,8 @@ hsBool pfGameUIInputInterface::InterpretInputEvent( plInputEventMsg *pMsg )
|
|||||||
else
|
else
|
||||||
handled = fGUIManager->IHandleKeyEvt( pfGameGUIMgr::kKeyRepeat, pKeyMsg->GetKeyCode(), fModifiers );
|
handled = fGUIManager->IHandleKeyEvt( pfGameGUIMgr::kKeyRepeat, pKeyMsg->GetKeyCode(), fModifiers );
|
||||||
|
|
||||||
handled |= fGUIManager->IHandleKeyPress( plKeyboardDevice::KeyEventToChar( pKeyMsg ), fModifiers );
|
if (pKeyMsg->GetKeyChar())
|
||||||
|
handled |= fGUIManager->IHandleKeyPress( pKeyMsg->GetKeyChar(), fModifiers );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
handled = fGUIManager->IHandleKeyEvt( pfGameGUIMgr::kKeyUp, pKeyMsg->GetKeyCode(), fModifiers );
|
handled = fGUIManager->IHandleKeyEvt( pfGameGUIMgr::kKeyUp, pKeyMsg->GetKeyCode(), fModifiers );
|
||||||
@ -765,7 +766,7 @@ hsBool pfGameUIInputInterface::InterpretInputEvent( plInputEventMsg *pMsg )
|
|||||||
// also trigger on key-down and we don't want to be taking screen shots when
|
// also trigger on key-down and we don't want to be taking screen shots when
|
||||||
// the user re-binds the screenshot command.
|
// the user re-binds the screenshot command.
|
||||||
// HACK HACK HACK
|
// HACK HACK HACK
|
||||||
if ((!handled) && (pKeyMsg->GetKeyDown()))
|
if ((!handled) && (pKeyMsg->GetKeyDown()) && !pKeyMsg->GetKeyChar())
|
||||||
{
|
{
|
||||||
const plKeyBinding* keymap = plInputInterfaceMgr::GetInstance()->FindBindingByConsoleCmd("Game.KITakePicture");
|
const plKeyBinding* keymap = plInputInterfaceMgr::GetInstance()->FindBindingByConsoleCmd("Game.KITakePicture");
|
||||||
if (keymap)
|
if (keymap)
|
||||||
|
@ -889,18 +889,6 @@ void plPythonFileMod::RemoveTarget(plSceneObject* so)
|
|||||||
|
|
||||||
void plPythonFileMod::HandleDiscardedKey( plKeyEventMsg *msg )
|
void plPythonFileMod::HandleDiscardedKey( plKeyEventMsg *msg )
|
||||||
{
|
{
|
||||||
// So OnDefaultKeyCaught takes two parameters: the key character pressed and a boolean saying up or down
|
|
||||||
wchar_t keyChar = plKeyboardDevice::KeyEventToChar( msg );
|
|
||||||
|
|
||||||
// if the caps lock is down then reverse upper and lowercase
|
|
||||||
if ( msg->GetCapsLockKeyDown() )
|
|
||||||
{
|
|
||||||
if ( std::islower(keyChar,std::locale()) )
|
|
||||||
keyChar = std::toupper(keyChar,std::locale());
|
|
||||||
else
|
|
||||||
keyChar = std::tolower(keyChar,std::locale());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!fPyFunctionInstances[kfunc_OnDefaultKeyCaught])
|
if (!fPyFunctionInstances[kfunc_OnDefaultKeyCaught])
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -909,7 +897,7 @@ void plPythonFileMod::HandleDiscardedKey( plKeyEventMsg *msg )
|
|||||||
PyObject* retVal = PyObject_CallMethod( fPyFunctionInstances[ kfunc_OnDefaultKeyCaught ],
|
PyObject* retVal = PyObject_CallMethod( fPyFunctionInstances[ kfunc_OnDefaultKeyCaught ],
|
||||||
fFunctionNames[ kfunc_OnDefaultKeyCaught ],
|
fFunctionNames[ kfunc_OnDefaultKeyCaught ],
|
||||||
"ciiiii",
|
"ciiiii",
|
||||||
keyChar,
|
msg->GetKeyChar(),
|
||||||
(int)msg->GetKeyDown(),
|
(int)msg->GetKeyDown(),
|
||||||
(int)msg->GetRepeat(),
|
(int)msg->GetRepeat(),
|
||||||
(int)msg->GetShiftKeyDown(),
|
(int)msg->GetShiftKeyDown(),
|
||||||
|
@ -52,6 +52,7 @@ enum plOSMsg
|
|||||||
SYSKEYUP = WM_SYSKEYUP,
|
SYSKEYUP = WM_SYSKEYUP,
|
||||||
M_BUTTONDN = WM_MBUTTONDOWN,
|
M_BUTTONDN = WM_MBUTTONDOWN,
|
||||||
M_BUTTONUP = WM_MBUTTONUP,
|
M_BUTTONUP = WM_MBUTTONUP,
|
||||||
|
CHAR_MSG = WM_CHAR,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -52,7 +52,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
|||||||
plKeyboardDevice* plKeyboardDevice::fInstance = nil;
|
plKeyboardDevice* plKeyboardDevice::fInstance = nil;
|
||||||
bool plKeyboardDevice::fKeyboardState[256];
|
bool plKeyboardDevice::fKeyboardState[256];
|
||||||
hsBool plKeyboardDevice::fIgnoreCapsLock = false;
|
hsBool plKeyboardDevice::fIgnoreCapsLock = false;
|
||||||
hsBool plKeyboardDevice::fKeyIsDeadKey = false;
|
|
||||||
|
|
||||||
plKeyboardDevice::plKeyboardDevice() :
|
plKeyboardDevice::plKeyboardDevice() :
|
||||||
fShiftKeyDown(false),
|
fShiftKeyDown(false),
|
||||||
@ -148,7 +147,7 @@ void plKeyboardDevice::Shutdown()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void plKeyboardDevice::HandleKeyEvent(plOSMsg message, plKeyDef key, bool bKeyDown, hsBool bKeyRepeat)
|
void plKeyboardDevice::HandleKeyEvent(plOSMsg message, plKeyDef key, bool bKeyDown, hsBool bKeyRepeat, wchar_t c)
|
||||||
{
|
{
|
||||||
// update the internal keyboard state
|
// update the internal keyboard state
|
||||||
unsigned int keyCode = (unsigned int)key;
|
unsigned int keyCode = (unsigned int)key;
|
||||||
@ -177,6 +176,7 @@ void plKeyboardDevice::HandleKeyEvent(plOSMsg message, plKeyDef key, bool bKeyDo
|
|||||||
|
|
||||||
// send a key event...
|
// send a key event...
|
||||||
plKeyEventMsg* pMsg = TRACKED_NEW plKeyEventMsg;
|
plKeyEventMsg* pMsg = TRACKED_NEW plKeyEventMsg;
|
||||||
|
pMsg->SetKeyChar( c );
|
||||||
pMsg->SetKeyCode( key );
|
pMsg->SetKeyCode( key );
|
||||||
pMsg->SetKeyDown( bKeyDown );
|
pMsg->SetKeyDown( bKeyDown );
|
||||||
pMsg->SetShiftKeyDown( fShiftKeyDown );
|
pMsg->SetShiftKeyDown( fShiftKeyDown );
|
||||||
@ -199,50 +199,6 @@ void plKeyboardDevice::HandleWindowActivate(bool bActive, HWND hWnd)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//// KeyEventToChar //////////////////////////////////////////////////////////
|
|
||||||
// Translate a Plasma key event to an actual char
|
|
||||||
wchar_t plKeyboardDevice::KeyEventToChar( plKeyEventMsg *msg )
|
|
||||||
{
|
|
||||||
unsigned int code = msg->GetKeyCode();
|
|
||||||
wchar_t c = 0;
|
|
||||||
unsigned char kbState[256];
|
|
||||||
wchar_t buffer[256];
|
|
||||||
unsigned int scanCode;
|
|
||||||
int retVal;
|
|
||||||
|
|
||||||
buffer[0] = 0;
|
|
||||||
|
|
||||||
// let windows translate everything for us!
|
|
||||||
scanCode = MapVirtualKeyW(code, 0);
|
|
||||||
GetKeyboardState(kbState);
|
|
||||||
if (fIgnoreCapsLock)
|
|
||||||
kbState[KEY_CAPSLOCK] = 0; // clear the caps lock key
|
|
||||||
retVal = ToUnicode(code, scanCode, kbState, (wchar_t*)buffer, 256, 0);
|
|
||||||
if (retVal == -1)
|
|
||||||
{
|
|
||||||
// It's a stored dead key.
|
|
||||||
c = 0;
|
|
||||||
fKeyIsDeadKey = true;
|
|
||||||
}
|
|
||||||
else if (retVal == 0)
|
|
||||||
// Invalid crap
|
|
||||||
c = 0;
|
|
||||||
else if (retVal == 1)
|
|
||||||
{
|
|
||||||
// Exactly one good character
|
|
||||||
fKeyIsDeadKey = false;
|
|
||||||
c = buffer[0];
|
|
||||||
}
|
|
||||||
else if (retVal >= 2)
|
|
||||||
{
|
|
||||||
fKeyIsDeadKey = !fKeyIsDeadKey;
|
|
||||||
if (!fKeyIsDeadKey)
|
|
||||||
c = buffer[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
@ -57,7 +57,7 @@ public:
|
|||||||
|
|
||||||
UInt32 GetFlags() { return fFlags; }
|
UInt32 GetFlags() { return fFlags; }
|
||||||
void SetFlags(UInt32 f) { fFlags = f; }
|
void SetFlags(UInt32 f) { fFlags = f; }
|
||||||
virtual void HandleKeyEvent(plOSMsg message, plKeyDef key, bool bKeyDown, hsBool bKeyRepeat) {;}
|
virtual void HandleKeyEvent(plOSMsg message, plKeyDef key, bool bKeyDown, hsBool bKeyRepeat, wchar_t c = nil) {;}
|
||||||
virtual void HandleMouseEvent(plOSMsg message, plMouseState state) {;}
|
virtual void HandleMouseEvent(plOSMsg message, plMouseState state) {;}
|
||||||
virtual void HandleWindowActivate(bool bActive, HWND hWnd) {;}
|
virtual void HandleWindowActivate(bool bActive, HWND hWnd) {;}
|
||||||
virtual hsBool MsgReceive(plMessage* msg) {return false;}
|
virtual hsBool MsgReceive(plMessage* msg) {return false;}
|
||||||
@ -79,7 +79,6 @@ class plKeyboardDevice : public plInputDevice
|
|||||||
|
|
||||||
static bool fKeyboardState[256]; // virtual key code is the index, bool is whether it is down or not
|
static bool fKeyboardState[256]; // virtual key code is the index, bool is whether it is down or not
|
||||||
static hsBool fIgnoreCapsLock; // set if we want it to ignore this key when translating characters (i.e. for chatting)
|
static hsBool fIgnoreCapsLock; // set if we want it to ignore this key when translating characters (i.e. for chatting)
|
||||||
static hsBool fKeyIsDeadKey; // the key we just got was a dead key, store the value if you're a text input object
|
|
||||||
|
|
||||||
static plKeyboardDevice* fInstance;
|
static plKeyboardDevice* fInstance;
|
||||||
void InitKeyboardMaps();
|
void InitKeyboardMaps();
|
||||||
@ -100,19 +99,15 @@ public:
|
|||||||
void SetControlMode(int i) { fControlMode = i; }
|
void SetControlMode(int i) { fControlMode = i; }
|
||||||
|
|
||||||
const char* GetInputName() { return "keyboard"; }
|
const char* GetInputName() { return "keyboard"; }
|
||||||
void HandleKeyEvent(plOSMsg message, plKeyDef key, bool bKeyDown, hsBool bKeyRepeat);
|
void HandleKeyEvent(plOSMsg message, plKeyDef key, bool bKeyDown, hsBool bKeyRepeat, wchar_t c = nil);
|
||||||
virtual void HandleWindowActivate(bool bActive, HWND hWnd);
|
virtual void HandleWindowActivate(bool bActive, HWND hWnd);
|
||||||
virtual hsBool IsCapsLockKeyOn();
|
virtual hsBool IsCapsLockKeyOn();
|
||||||
virtual void Shutdown();
|
virtual void Shutdown();
|
||||||
|
|
||||||
static hsBool IgnoreCapsLock() { return fIgnoreCapsLock; }
|
static hsBool IgnoreCapsLock() { return fIgnoreCapsLock; }
|
||||||
static void IgnoreCapsLock(hsBool ignore) { fIgnoreCapsLock = ignore; }
|
static void IgnoreCapsLock(hsBool ignore) { fIgnoreCapsLock = ignore; }
|
||||||
|
|
||||||
static hsBool KeyIsDeadKey() { return fKeyIsDeadKey; }
|
|
||||||
|
|
||||||
static plKeyboardDevice* GetInstance() { return fInstance; }
|
static plKeyboardDevice* GetInstance() { return fInstance; }
|
||||||
|
|
||||||
static wchar_t KeyEventToChar( plKeyEventMsg *msg );
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class plPlate;
|
class plPlate;
|
||||||
|
@ -132,6 +132,8 @@ hsBool plInputInterface::ProcessKeyBindings( plInputEventMsg *msg )
|
|||||||
plKeyEventMsg *keyMsg = plKeyEventMsg::ConvertNoRef( msg );
|
plKeyEventMsg *keyMsg = plKeyEventMsg::ConvertNoRef( msg );
|
||||||
if( keyMsg == nil )
|
if( keyMsg == nil )
|
||||||
return false;
|
return false;
|
||||||
|
if ( keyMsg->GetKeyChar())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
|
||||||
/// We might have controls that are currently enabled that are triggered in part by
|
/// We might have controls that are currently enabled that are triggered in part by
|
||||||
|
@ -273,6 +273,21 @@ void plInputManager::HandleWin32ControlEvent(UINT message, WPARAM Wparam, LPARAM
|
|||||||
fInputDevices[i]->HandleKeyEvent( KEYUP, UntranslateKey((plKeyDef)Wparam, bExtended), false, false );
|
fInputDevices[i]->HandleKeyEvent( KEYUP, UntranslateKey((plKeyDef)Wparam, bExtended), false, false );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case CHAR_MSG:
|
||||||
|
{
|
||||||
|
// These are handled by KEYUP/KEYDOWN and should not be sent
|
||||||
|
// We don't like garbage getting in string fields
|
||||||
|
if (Wparam == KEY_BACKSPACE || Wparam == 0x0A || Wparam == KEY_ESCAPE ||
|
||||||
|
Wparam == KEY_TAB || Wparam == 0x0D)
|
||||||
|
break;
|
||||||
|
|
||||||
|
bExtended = Lparam >> 24 & 1;
|
||||||
|
hsBool bRepeat = ((Lparam >> 29) & 0xf) != 0;
|
||||||
|
bool down = !(Lparam >> 31);
|
||||||
|
for (int i=0; i<fInputDevices.Count(); i++)
|
||||||
|
fInputDevices[i]->HandleKeyEvent( CHAR_MSG, (plKeyDef)-1, down, bRepeat, (wchar_t)Wparam );
|
||||||
|
}
|
||||||
|
break;
|
||||||
case MOUSEWHEEL:
|
case MOUSEWHEEL:
|
||||||
{
|
{
|
||||||
plMouseEventMsg* pMsg = TRACKED_NEW plMouseEventMsg;
|
plMouseEventMsg* pMsg = TRACKED_NEW plMouseEventMsg;
|
||||||
|
@ -109,6 +109,7 @@ public:
|
|||||||
class plKeyEventMsg : public plInputEventMsg
|
class plKeyEventMsg : public plInputEventMsg
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
wchar_t fKeyChar;
|
||||||
plKeyDef fKeyCode;
|
plKeyDef fKeyCode;
|
||||||
hsBool fKeyDown;
|
hsBool fKeyDown;
|
||||||
hsBool fCapsLockKeyDown;
|
hsBool fCapsLockKeyDown;
|
||||||
@ -128,6 +129,7 @@ public:
|
|||||||
CLASSNAME_REGISTER( plKeyEventMsg );
|
CLASSNAME_REGISTER( plKeyEventMsg );
|
||||||
GETINTERFACE_ANY( plKeyEventMsg, plInputEventMsg );
|
GETINTERFACE_ANY( plKeyEventMsg, plInputEventMsg );
|
||||||
|
|
||||||
|
void SetKeyChar(wchar_t key) { fKeyChar = key; }
|
||||||
void SetKeyCode(plKeyDef w) { fKeyCode = w; }
|
void SetKeyCode(plKeyDef w) { fKeyCode = w; }
|
||||||
void SetKeyDown(hsBool b) { fKeyDown = b; }
|
void SetKeyDown(hsBool b) { fKeyDown = b; }
|
||||||
void SetShiftKeyDown(hsBool b) { fShiftKeyDown = b; }
|
void SetShiftKeyDown(hsBool b) { fShiftKeyDown = b; }
|
||||||
@ -135,6 +137,7 @@ public:
|
|||||||
void SetCapsLockKeyDown(hsBool b) { fCapsLockKeyDown = b; }
|
void SetCapsLockKeyDown(hsBool b) { fCapsLockKeyDown = b; }
|
||||||
void SetRepeat(hsBool b) { fRepeat = b; }
|
void SetRepeat(hsBool b) { fRepeat = b; }
|
||||||
|
|
||||||
|
wchar_t GetKeyChar() { return fKeyChar; }
|
||||||
plKeyDef GetKeyCode() { return fKeyCode; }
|
plKeyDef GetKeyCode() { return fKeyCode; }
|
||||||
hsBool GetKeyDown() { return fKeyDown; }
|
hsBool GetKeyDown() { return fKeyDown; }
|
||||||
hsBool GetShiftKeyDown() { return fShiftKeyDown; }
|
hsBool GetShiftKeyDown() { return fShiftKeyDown; }
|
||||||
|
Reference in New Issue
Block a user