mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-14 10:37:41 -04:00
Use unicode for key events despite the fact that our current Plasma20 fonts only support latin-1
This commit is contained in:
@ -519,7 +519,8 @@ hsBool pfConsole::MsgReceive( plMessage *msg )
|
||||
|
||||
void pfConsole::IHandleKey( plKeyEventMsg *msg )
|
||||
{
|
||||
char *c, key;
|
||||
char *c;
|
||||
wchar_t key;
|
||||
int i,eol;
|
||||
static hsBool findAgain = false;
|
||||
static UInt32 findCounter = 0;
|
||||
@ -831,13 +832,13 @@ void pfConsole::IHandleKey( plKeyEventMsg *msg )
|
||||
{
|
||||
key = plKeyboardDevice::KeyEventToChar( msg );
|
||||
// do they want to go into help mode?
|
||||
if( !fPythonMode && key == '?' && fWorkingCursor == 0 )
|
||||
if( !fPythonMode && key == L'?' && fWorkingCursor == 0 )
|
||||
{
|
||||
/// Go into help mode
|
||||
fHelpMode = true;
|
||||
}
|
||||
// do they want to go into Python mode?
|
||||
else if( !fHelpMode && key == '\\' && fWorkingCursor == 0 )
|
||||
else if( !fHelpMode && key == L'\\' && fWorkingCursor == 0 )
|
||||
{
|
||||
// toggle Python mode
|
||||
fPythonMode = fPythonMode ? false:true;
|
||||
|
@ -879,7 +879,7 @@ void pfGUIControlMod::Write( hsStream *s, hsResMgr *mgr )
|
||||
|
||||
//// HandleKeyPress/Event ////////////////////////////////////////////////////
|
||||
|
||||
hsBool pfGUIControlMod::HandleKeyPress( char key, UInt8 modifiers )
|
||||
hsBool pfGUIControlMod::HandleKeyPress( wchar_t key, UInt8 modifiers )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -193,7 +193,7 @@ class pfGUIControlMod : public plSingleModifier
|
||||
virtual void HandleMouseHover( hsPoint3 &mousePt, UInt8 modifiers ) {;}
|
||||
virtual void HandleMouseDblClick( hsPoint3 &mousePt, UInt8 modifiers ) {;}
|
||||
|
||||
virtual hsBool HandleKeyPress( char key, UInt8 modifiers );
|
||||
virtual hsBool HandleKeyPress( wchar_t key, UInt8 modifiers );
|
||||
virtual hsBool HandleKeyEvent( pfGameGUIMgr::EventType event, plKeyDef key, UInt8 modifiers );
|
||||
|
||||
void SetHandler( pfGUICtrlProcObject *h ) { ISetHandler( h, true ); }
|
||||
|
@ -551,7 +551,7 @@ hsBool pfGUIDialogMod::HandleKeyEvent( pfGameGUIMgr::EventType event, plKey
|
||||
|
||||
//// HandleKeyPress //////////////////////////////////////////////////////////
|
||||
|
||||
hsBool pfGUIDialogMod::HandleKeyPress( char key, UInt8 modifiers )
|
||||
hsBool pfGUIDialogMod::HandleKeyPress( wchar_t key, UInt8 modifiers )
|
||||
{
|
||||
// Same deal as HandleKeyPress. Only problem is, we needed the msg to translate
|
||||
// to a char, so it had to be done up at the mgr level (sadly)
|
||||
|
@ -119,7 +119,7 @@ class pfGUIDialogMod : public plSingleModifier
|
||||
|
||||
virtual hsBool HandleMouseEvent( pfGameGUIMgr::EventType event, hsScalar mouseX, hsScalar mouseY, UInt8 modifiers );
|
||||
hsBool HandleKeyEvent( pfGameGUIMgr::EventType event, plKeyDef key, UInt8 modifiers );
|
||||
hsBool HandleKeyPress( char key, UInt8 modifiers );
|
||||
hsBool HandleKeyPress( wchar_t key, UInt8 modifiers );
|
||||
void UpdateInterestingThings( hsScalar mouseX, hsScalar mouseY, UInt8 modifiers, hsBool modalPreset );
|
||||
|
||||
void SetControlOfInterest( pfGUIControlMod *c );
|
||||
|
@ -277,10 +277,8 @@ void pfGUIEditBoxMod::HandleMouseDrag( hsPoint3 &mousePt, UInt8 modifiers )
|
||||
{
|
||||
}
|
||||
|
||||
hsBool pfGUIEditBoxMod::HandleKeyPress( char inKey, UInt8 modifiers )
|
||||
hsBool pfGUIEditBoxMod::HandleKeyPress( wchar_t key, UInt8 modifiers )
|
||||
{
|
||||
wchar_t key = (wchar_t)inKey;
|
||||
|
||||
if( fBuffer == nil )
|
||||
return false;
|
||||
|
||||
|
@ -90,7 +90,7 @@ class pfGUIEditBoxMod : public pfGUIControlMod
|
||||
virtual void HandleMouseUp( hsPoint3 &mousePt, UInt8 modifiers );
|
||||
virtual void HandleMouseDrag( hsPoint3 &mousePt, UInt8 modifiers );
|
||||
|
||||
virtual hsBool HandleKeyPress( char key, UInt8 modifiers );
|
||||
virtual hsBool HandleKeyPress( wchar_t key, UInt8 modifiers );
|
||||
virtual hsBool HandleKeyEvent( pfGameGUIMgr::EventType event, plKeyDef key, UInt8 modifiers );
|
||||
|
||||
virtual void PurgeDynaTextMapImage();
|
||||
|
@ -905,7 +905,7 @@ void pfGUIListBoxMod::AddSelection( Int32 item )
|
||||
|
||||
//// HandleKeyPress //////////////////////////////////////////////////////////
|
||||
|
||||
hsBool pfGUIListBoxMod::HandleKeyPress( char key, UInt8 modifiers )
|
||||
hsBool pfGUIListBoxMod::HandleKeyPress( wchar_t key, UInt8 modifiers )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ class pfGUIListBoxMod : public pfGUIControlMod
|
||||
virtual void HandleMouseHover( hsPoint3 &mousePt, UInt8 modifiers );
|
||||
virtual void HandleMouseDblClick( hsPoint3 &mousePt, UInt8 modifiers );
|
||||
|
||||
virtual hsBool HandleKeyPress( char key, UInt8 modifiers );
|
||||
virtual hsBool HandleKeyPress( wchar_t key, UInt8 modifiers );
|
||||
virtual hsBool HandleKeyEvent( pfGameGUIMgr::EventType event, plKeyDef key, UInt8 modifiers );
|
||||
|
||||
virtual hsBool FilterMousePosition( hsPoint3 &mousePt );
|
||||
|
@ -1072,10 +1072,8 @@ void pfGUIMultiLineEditCtrl::HandleMouseDrag( hsPoint3 &mousePt, UInt8 modifi
|
||||
IMoveCursorTo( IPointToPosition( (Int16)(mousePt.fX), (Int16)(mousePt.fY) ) );
|
||||
}
|
||||
|
||||
hsBool pfGUIMultiLineEditCtrl::HandleKeyPress( char keyIn, UInt8 modifiers )
|
||||
hsBool pfGUIMultiLineEditCtrl::HandleKeyPress( wchar_t key, UInt8 modifiers )
|
||||
{
|
||||
wchar_t key = (wchar_t)keyIn;
|
||||
|
||||
if ((fPrevCtrl || fNextCtrl) && (fLineStarts.GetCount() <= GetFirstVisibleLine()))
|
||||
return true; // we're ignoring if we can't actually edit our visible frame (and we're linked)
|
||||
|
||||
|
@ -195,7 +195,7 @@ class pfGUIMultiLineEditCtrl : public pfGUIControlMod
|
||||
virtual void HandleMouseUp( hsPoint3 &mousePt, UInt8 modifiers );
|
||||
virtual void HandleMouseDrag( hsPoint3 &mousePt, UInt8 modifiers );
|
||||
|
||||
virtual hsBool HandleKeyPress( char key, UInt8 modifiers );
|
||||
virtual hsBool HandleKeyPress( wchar_t key, UInt8 modifiers );
|
||||
virtual hsBool HandleKeyEvent( pfGameGUIMgr::EventType event, plKeyDef key, UInt8 modifiers );
|
||||
|
||||
virtual void PurgeDynaTextMapImage();
|
||||
|
@ -594,10 +594,13 @@ hsBool pfGameGUIMgr::IHandleKeyEvt( EventType event, plKeyDef key, UInt8 modifi
|
||||
// Like IHandleKeyPress, but takes in a char for distributing actual
|
||||
// characters typed.
|
||||
|
||||
hsBool pfGameGUIMgr::IHandleKeyPress( char key, UInt8 modifiers )
|
||||
hsBool pfGameGUIMgr::IHandleKeyPress( wchar_t key, UInt8 modifiers )
|
||||
{
|
||||
pfGUIDialogMod *dlg;
|
||||
|
||||
// Really... Don't handle any nil keypresses
|
||||
if (key == nil)
|
||||
return false;
|
||||
|
||||
for( dlg = fActiveDialogs; dlg != nil; dlg = dlg->GetNext() )
|
||||
{
|
||||
|
@ -153,7 +153,7 @@ class pfGameGUIMgr : public hsKeyedObject
|
||||
|
||||
hsBool IHandleMouse( EventType event, hsScalar mouseX, hsScalar mouseY, UInt8 modifiers, UInt32 *desiredCursor );
|
||||
hsBool IHandleKeyEvt( EventType event, plKeyDef key, UInt8 modifiers );
|
||||
hsBool IHandleKeyPress( char key, UInt8 modifiers );
|
||||
hsBool IHandleKeyPress( wchar_t key, UInt8 modifiers );
|
||||
|
||||
hsBool IModalBlocking( void );
|
||||
|
||||
|
@ -890,7 +890,7 @@ void plPythonFileMod::RemoveTarget(plSceneObject* so)
|
||||
void plPythonFileMod::HandleDiscardedKey( plKeyEventMsg *msg )
|
||||
{
|
||||
// So OnDefaultKeyCaught takes two parameters: the key character pressed and a boolean saying up or down
|
||||
char keyChar = plKeyboardDevice::KeyEventToChar( msg );
|
||||
wchar_t keyChar = plKeyboardDevice::KeyEventToChar( msg );
|
||||
|
||||
// if the caps lock is down then reverse upper and lowercase
|
||||
if ( msg->GetCapsLockKeyDown() )
|
||||
|
@ -204,120 +204,43 @@ void plKeyboardDevice::HandleWindowActivate(bool bActive, HWND hWnd)
|
||||
|
||||
//// KeyEventToChar //////////////////////////////////////////////////////////
|
||||
// Translate a Plasma key event to an actual char
|
||||
char plKeyboardDevice::KeyEventToChar( plKeyEventMsg *msg )
|
||||
wchar_t plKeyboardDevice::KeyEventToChar( plKeyEventMsg *msg )
|
||||
{
|
||||
short code = msg->GetKeyCode();
|
||||
char c = 0;
|
||||
unsigned int code = msg->GetKeyCode();
|
||||
wchar_t c = 0;
|
||||
unsigned char kbState[256];
|
||||
unsigned char buffer[256];
|
||||
UINT scanCode;
|
||||
wchar_t buffer[256];
|
||||
unsigned int scanCode;
|
||||
int retVal;
|
||||
|
||||
buffer[0] = 0;
|
||||
|
||||
switch( code )
|
||||
// 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)
|
||||
{
|
||||
case KEY_A:
|
||||
case KEY_B:
|
||||
case KEY_C:
|
||||
case KEY_D:
|
||||
case KEY_E:
|
||||
case KEY_F:
|
||||
case KEY_G:
|
||||
case KEY_H:
|
||||
case KEY_I:
|
||||
case KEY_J:
|
||||
case KEY_K:
|
||||
case KEY_L:
|
||||
case KEY_M:
|
||||
case KEY_N:
|
||||
case KEY_O:
|
||||
case KEY_P:
|
||||
case KEY_Q:
|
||||
case KEY_R:
|
||||
case KEY_S:
|
||||
case KEY_T:
|
||||
case KEY_U:
|
||||
case KEY_V:
|
||||
case KEY_W:
|
||||
case KEY_X:
|
||||
case KEY_Y:
|
||||
case KEY_Z:
|
||||
case KEY_1:
|
||||
case KEY_2:
|
||||
case KEY_3:
|
||||
case KEY_4:
|
||||
case KEY_5:
|
||||
case KEY_6:
|
||||
case KEY_7:
|
||||
case KEY_8:
|
||||
case KEY_9:
|
||||
case KEY_0:
|
||||
case KEY_TILDE:
|
||||
case KEY_COMMA:
|
||||
case KEY_PERIOD:
|
||||
case KEY_LBRACKET:
|
||||
case KEY_RBRACKET:
|
||||
case KEY_BACKSLASH:
|
||||
case KEY_SLASH:
|
||||
case KEY_DASH:
|
||||
case KEY_EQUAL:
|
||||
case KEY_SEMICOLON:
|
||||
case KEY_QUOTE:
|
||||
// let windows translate everything for us!
|
||||
scanCode = MapVirtualKeyEx(code,0,GetKeyboardLayout(0));
|
||||
GetKeyboardState(kbState);
|
||||
if (fIgnoreCapsLock)
|
||||
kbState[KEY_CAPSLOCK] = 0; // clear the caps lock key
|
||||
retVal = ToAsciiEx(code,scanCode,kbState,(unsigned short*)buffer,0,GetKeyboardLayout(0));
|
||||
if (retVal == 2)
|
||||
{
|
||||
if ((buffer[0] == buffer[1]) && (!fKeyIsDeadKey))
|
||||
{
|
||||
// it's actually a dead key, since the previous key wasn't a dead key
|
||||
c = (char)buffer[0];
|
||||
fKeyIsDeadKey = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
c = (char)buffer[1]; // it was an untranslated dead key, so copy the unconverted key
|
||||
fKeyIsDeadKey = false;
|
||||
}
|
||||
}
|
||||
else if (retVal == 0)
|
||||
c = 0; // it's invalid
|
||||
else
|
||||
{
|
||||
c = (char)buffer[0];
|
||||
if (retVal < 0) // the key was a dead key
|
||||
fKeyIsDeadKey = true;
|
||||
else
|
||||
fKeyIsDeadKey = false;
|
||||
}
|
||||
break;
|
||||
|
||||
case KEY_ESCAPE: c = 27; break;
|
||||
case KEY_TAB: c = '\t'; break;
|
||||
case KEY_BACKSPACE: c = 8; break;
|
||||
case KEY_ENTER: c = '\n'; break;
|
||||
case KEY_SPACE: c = ' '; break;
|
||||
|
||||
// numlock on numbers
|
||||
case KEY_NUMPAD0: c = '0'; break;
|
||||
case KEY_NUMPAD1: c = '1'; break;
|
||||
case KEY_NUMPAD2: c = '2'; break;
|
||||
case KEY_NUMPAD3: c = '3'; break;
|
||||
case KEY_NUMPAD4: c = '4'; break;
|
||||
case KEY_NUMPAD5: c = '5'; break;
|
||||
case KEY_NUMPAD6: c = '6'; break;
|
||||
case KEY_NUMPAD7: c = '7'; break;
|
||||
case KEY_NUMPAD8: c = '8'; break;
|
||||
case KEY_NUMPAD9: c = '9'; break;
|
||||
|
||||
// everything else
|
||||
default:
|
||||
c = 0;
|
||||
break;
|
||||
// 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;
|
||||
|
@ -113,7 +113,7 @@ public:
|
||||
|
||||
static plKeyboardDevice* GetInstance() { return fInstance; }
|
||||
|
||||
static char KeyEventToChar( plKeyEventMsg *msg );
|
||||
static wchar_t KeyEventToChar( plKeyEventMsg *msg );
|
||||
};
|
||||
|
||||
class plPlate;
|
||||
|
Reference in New Issue
Block a user