Permalink
Browse files

Add new flag to EventServer for correct handling of Unicode. Fixes #1…

  • Loading branch information...
Tolriq Jonathan Marshall
Tolriq authored and Jonathan Marshall committed Oct 13, 2012
1 parent 75b86a1 commit 4a54dd0f09db203c91b5cba39a904e2a9f1e3305
@@ -3163,7 +3163,7 @@ bool CApplication::ProcessEventServer(float frameTime)
es = CEventServer::GetInstance();
if (!es || !es->Running() || es->GetNumberOfClients()==0)
return false;
WORD wKeyID = es->GetButtonCode(joystickName, isAxis, fAmount);
unsigned int wKeyID = es->GetButtonCode(joystickName, isAxis, fAmount);
if (wKeyID)
{
@@ -3182,6 +3182,12 @@ bool CApplication::ProcessEventServer(float frameTime)
else
{
CKey key;
if (wKeyID & ES_FLAG_UNICODE)
{
key = CKey((uint8_t)0, wKeyID & ~ES_FLAG_UNICODE, 0, 0, 0);
return OnKey(key);
}
if(wKeyID == KEY_BUTTON_LEFT_ANALOG_TRIGGER)
key = CKey(wKeyID, (BYTE)(255*fAmount), 0, 0.0, 0.0, 0.0, 0.0, frameTime);
else if(wKeyID == KEY_BUTTON_RIGHT_ANALOG_TRIGGER)
@@ -392,11 +392,13 @@ bool CEventClient::OnPacketBUTTON(CEventPacket *packet)
return false;
}
unsigned short keycode;
unsigned int keycode;
if(flags & PTB_USE_NAME)
keycode = 0;
else if(flags & PTB_VKEY)
keycode = bcode|KEY_VKEY;
else if(flags & PTB_UNICODE)
keycode = bcode|ES_FLAG_UNICODE;
else
keycode = bcode;
@@ -733,10 +735,10 @@ void CEventClient::FreePacketQueues()
m_seqPackets.clear();
}
unsigned short CEventClient::GetButtonCode(string& joystickName, bool& isAxis, float& amount)
unsigned int CEventClient::GetButtonCode(string& joystickName, bool& isAxis, float& amount)
{
CSingleLock lock(m_critSection);
unsigned short bcode = 0;
unsigned int bcode = 0;
if ( m_currentButton.Active() )
{
@@ -34,6 +34,8 @@
namespace EVENTCLIENT
{
#define ES_FLAG_UNICODE 0x80000000 // new 16bit key flag to support real unicode over EventServer
class CEventAction
{
public:
@@ -68,7 +70,7 @@ namespace EVENTCLIENT
m_iNextRepeat = 0;
}
CEventButtonState(unsigned short iKeyCode,
CEventButtonState(unsigned int iKeyCode,
std::string mapName,
std::string buttonName,
float fAmount,
@@ -96,13 +98,13 @@ namespace EVENTCLIENT
bool Repeat() const { return m_bRepeat; }
int ControllerNumber() const { return m_iControllerNumber; }
bool Axis() const { return m_bAxis; }
unsigned short KeyCode() const { return m_iKeyCode; }
unsigned int KeyCode() const { return m_iKeyCode; }
float Amount() const { return m_fAmount; }
void Load();
const std::string& JoystickName() const { return m_joystickName; }
// data
unsigned short m_iKeyCode;
unsigned int m_iKeyCode;
unsigned short m_iControllerNumber;
std::string m_buttonName;
std::string m_mapName;
@@ -189,7 +191,7 @@ namespace EVENTCLIENT
void FreePacketQueues();
// return event states
unsigned short GetButtonCode(std::string& strMapName, bool& isAxis, float& amount);
unsigned int GetButtonCode(std::string& strMapName, bool& isAxis, float& amount);
// update mouse position
bool GetMousePos(float& x, float& y);
@@ -87,7 +87,8 @@ namespace EVENTPACKET
PTB_NO_REPEAT = 0x20,
PTB_VKEY = 0x40,
PTB_AXIS = 0x80,
PTB_AXISSINGLE = 0x100
PTB_AXISSINGLE = 0x100,
PTB_UNICODE = 0x200
};
enum MouseFlags
@@ -363,11 +363,11 @@ bool CEventServer::ExecuteNextAction()
return false;
}
unsigned short CEventServer::GetButtonCode(std::string& strMapName, bool& isAxis, float& fAmount)
unsigned int CEventServer::GetButtonCode(std::string& strMapName, bool& isAxis, float& fAmount)
{
CSingleLock lock(m_critSection);
map<unsigned long, CEventClient*>::iterator iter = m_clients.begin();
unsigned short bcode = 0;
unsigned int bcode = 0;
while (iter != m_clients.end())
{
@@ -63,7 +63,7 @@ namespace EVENTSERVER
void StopServer(bool bWait);
// get events
unsigned short GetButtonCode(std::string& strMapName, bool& isAxis, float& amount);
unsigned int GetButtonCode(std::string& strMapName, bool& isAxis, float& amount);
bool ExecuteNextAction();
bool GetMousePos(float &x, float &y);
int GetNumberOfClients();

0 comments on commit 4a54dd0

Please sign in to comment.