Add support for Controller Keys, inspired by similar code by CtrlAltStudio Viewer
Dear Alpha Users who are curious about this: A = Alt B = Shift X = Ctrl Y = Escape Back = Toggle Flycam mode (Use this, it's fun!!!) Start = Toggle Cursor mode Right Stick Click = Toggle Mouselook Left Stick Click = Jump/Fly Enjoy, I know I do!
This commit is contained in:
@@ -113,6 +113,12 @@ public:
|
||||
F32 getKeyElapsedTime( KEY key ); // Returns time in seconds since key was pressed.
|
||||
S32 getKeyElapsedFrameCount( KEY key ); // Returns time in frames since key was pressed.
|
||||
|
||||
void setControllerKey(KEY key, bool level)
|
||||
{
|
||||
mControllerKeys[key] = mKeyLevel[key] = level;
|
||||
(level ? mKeyDown[key] : mKeyUp[key]) = true;
|
||||
}
|
||||
|
||||
protected:
|
||||
void addKeyName(KEY key, const std::string& name);
|
||||
|
||||
@@ -127,6 +133,7 @@ protected:
|
||||
BOOL mKeyRepeated[KEY_COUNT]; // Key was repeated
|
||||
BOOL mKeyUp[KEY_COUNT]; // Up edge
|
||||
BOOL mKeyDown[KEY_COUNT]; // Down edge
|
||||
BOOL mControllerKeys[KEY_COUNT]; // Keys held in controller
|
||||
KEY mCurTranslatedKey;
|
||||
KEY mCurScanKey; // Used during the scanKeyboard()
|
||||
|
||||
|
||||
@@ -267,7 +267,7 @@ void LLKeyboardWin32::scanKeyboard()
|
||||
// ...translate back to windows key
|
||||
U16 virtual_key = inverseTranslateExtendedKey(key);
|
||||
// keydown in highest bit
|
||||
if (!pending_key_events && !(GetAsyncKeyState(virtual_key) & 0x8000))
|
||||
if (!mControllerKeys[key] && !pending_key_events && !(GetAsyncKeyState(virtual_key) & 0x8000))
|
||||
{
|
||||
//llinfos << "Key up event missed, resetting" << llendl;
|
||||
mKeyLevel[key] = FALSE;
|
||||
|
||||
@@ -1202,6 +1202,27 @@ void LLViewerJoystick::scanJoystick()
|
||||
(gKeyboard->*(esc_down ? &LLKeyboard::handleTranslatedKeyDown : &LLKeyboard::handleTranslatedKeyDown))(KEY_ESCAPE, mask);
|
||||
}
|
||||
|
||||
// Alt
|
||||
static bool alt_down = false;
|
||||
if (!!mBtn[XBOX_A_KEY] != alt_down)
|
||||
{
|
||||
gKeyboard->setControllerKey(KEY_ALT, alt_down = mBtn[XBOX_A_KEY]);
|
||||
}
|
||||
|
||||
// Ctrl
|
||||
static bool ctrl_down = false;
|
||||
if (!!mBtn[XBOX_X_KEY] != ctrl_down)
|
||||
{
|
||||
gKeyboard->setControllerKey(KEY_CONTROL, ctrl_down = mBtn[XBOX_X_KEY]);
|
||||
}
|
||||
|
||||
// Shift
|
||||
static bool shift_down = false;
|
||||
if (!!mBtn[XBOX_B_KEY] != shift_down)
|
||||
{
|
||||
gKeyboard->setControllerKey(KEY_SHIFT, shift_down = mBtn[XBOX_B_KEY]);
|
||||
}
|
||||
|
||||
// Mouse clicks ...
|
||||
LLCoordGL coord;
|
||||
LLUI::getMousePositionScreen(&coord.mX, &coord.mY);
|
||||
|
||||
Reference in New Issue
Block a user