mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-20 03:45:26 +00:00
Merge branch 'gg-development' into SQLiteConsoleRefactor
This commit is contained in:
commit
5e478291fb
16 changed files with 2355 additions and 142 deletions
|
|
@ -151,6 +151,12 @@ void afxRenderHighlightMgr::render( SceneRenderState *state )
|
|||
matrixSet.setProjection(*passRI->projection);
|
||||
mat->setTransforms(matrixSet, state);
|
||||
|
||||
// Setup HW skinning transforms if applicable
|
||||
if (mat->usesHardwareSkinning())
|
||||
{
|
||||
mat->setNodeTransforms(passRI->mNodeTransforms, passRI->mNodeTransformCount);
|
||||
}
|
||||
|
||||
mat->setSceneInfo(state, sgData);
|
||||
mat->setBuffers(passRI->vertBuff, passRI->primBuff);
|
||||
|
||||
|
|
@ -173,4 +179,4 @@ void afxRenderHighlightMgr::render( SceneRenderState *state )
|
|||
|
||||
// Make sure the effect is gonna render.
|
||||
getSelectionEffect()->setSkip( false );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,9 +58,25 @@ ConsoleDocClass( GuiInputCtrl,
|
|||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
GuiInputCtrl::GuiInputCtrl()
|
||||
: mSendAxisEvents(false),
|
||||
mSendBreakEvents(false),
|
||||
mSendModifierEvents(false)
|
||||
{
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
void GuiInputCtrl::initPersistFields()
|
||||
{
|
||||
|
||||
addGroup("GuiInputCtrl");
|
||||
addField("sendAxisEvents", TypeBool, Offset(mSendAxisEvents, GuiInputCtrl),
|
||||
"If true, onAxisEvent callbacks will be sent for SI_AXIS Move events (Default false).");
|
||||
addField("sendBreakEvents", TypeBool, Offset(mSendBreakEvents, GuiInputCtrl),
|
||||
"If true, break events for all devices will generate callbacks (Default false).");
|
||||
addField("sendModifierEvents", TypeBool, Offset(mSendModifierEvents, GuiInputCtrl),
|
||||
"If true, Make events will be sent for modifier keys (Default false).");
|
||||
endGroup("GuiInputCtrl");
|
||||
|
||||
Parent::initPersistFields();
|
||||
}
|
||||
|
|
@ -110,6 +126,8 @@ static bool isModifierKey( U16 keyCode )
|
|||
case KEY_RALT:
|
||||
case KEY_LSHIFT:
|
||||
case KEY_RSHIFT:
|
||||
case KEY_MAC_LOPT:
|
||||
case KEY_MAC_ROPT:
|
||||
return( true );
|
||||
}
|
||||
|
||||
|
|
@ -117,33 +135,49 @@ static bool isModifierKey( U16 keyCode )
|
|||
}
|
||||
|
||||
IMPLEMENT_CALLBACK( GuiInputCtrl, onInputEvent, void, (const char* device, const char* action, bool state ),
|
||||
( device, action, state),
|
||||
"@brief Callback that occurs when an input is triggered on this control\n\n"
|
||||
"@param device The device type triggering the input, such as keyboard, mouse, etc\n"
|
||||
"@param action The actual event occuring, such as a key or button\n"
|
||||
"@param state True if the action is being pressed, false if it is being release\n\n"
|
||||
);
|
||||
( device, action, state),
|
||||
"@brief Callback that occurs when an input is triggered on this control\n\n"
|
||||
"@param device The device type triggering the input, such as keyboard, mouse, etc\n"
|
||||
"@param action The actual event occuring, such as a key or button\n"
|
||||
"@param state True if the action is being pressed, false if it is being release\n\n");
|
||||
|
||||
IMPLEMENT_CALLBACK(GuiInputCtrl, onAxisEvent, void, (const char* device, const char* action, F32 axisValue),
|
||||
(device, action, axisValue),
|
||||
"@brief Callback that occurs when an axis event is triggered on this control\n\n"
|
||||
"@param device The device type triggering the input, such as mouse, joystick, gamepad, etc\n"
|
||||
"@param action The ActionMap code for the axis\n"
|
||||
"@param axisValue The current value of the axis\n\n");
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool GuiInputCtrl::onInputEvent( const InputEventInfo &event )
|
||||
{
|
||||
// TODO - add POV support...
|
||||
char deviceString[32];
|
||||
if ( event.action == SI_MAKE )
|
||||
{
|
||||
if ( event.objType == SI_BUTTON
|
||||
|| event.objType == SI_POV
|
||||
|| ( ( event.objType == SI_KEY ) && !isModifierKey( event.objInst ) ) )
|
||||
|| event.objType == SI_KEY )
|
||||
{
|
||||
char deviceString[32];
|
||||
if ( !ActionMap::getDeviceName( event.deviceType, event.deviceInst, deviceString ) )
|
||||
return( false );
|
||||
return false;
|
||||
|
||||
const char* actionString = ActionMap::buildActionString( &event );
|
||||
if ((event.objType == SI_KEY) && isModifierKey(event.objInst))
|
||||
{
|
||||
if (!mSendModifierEvents)
|
||||
return false;
|
||||
|
||||
//Con::executef( this, "onInputEvent", deviceString, actionString, "1" );
|
||||
onInputEvent_callback(deviceString, actionString, 1);
|
||||
char keyString[32];
|
||||
if (!ActionMap::getKeyString(event.objInst, keyString))
|
||||
return false;
|
||||
|
||||
return( true );
|
||||
onInputEvent_callback(deviceString, keyString, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
const char* actionString = ActionMap::buildActionString(&event);
|
||||
onInputEvent_callback(deviceString, actionString, 1);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if ( event.action == SI_BREAK )
|
||||
|
|
@ -152,14 +186,36 @@ bool GuiInputCtrl::onInputEvent( const InputEventInfo &event )
|
|||
{
|
||||
char keyString[32];
|
||||
if ( !ActionMap::getKeyString( event.objInst, keyString ) )
|
||||
return( false );
|
||||
return false;
|
||||
|
||||
//Con::executef( this, "onInputEvent", "keyboard", keyString, "0" );
|
||||
onInputEvent_callback("keyboard", keyString, 0);
|
||||
onInputEvent_callback("keyboard", keyString, 0);
|
||||
return true;
|
||||
}
|
||||
else if (mSendBreakEvents)
|
||||
{
|
||||
if (!ActionMap::getDeviceName(event.deviceType, event.deviceInst, deviceString))
|
||||
return false;
|
||||
|
||||
return( true );
|
||||
const char* actionString = ActionMap::buildActionString(&event);
|
||||
|
||||
onInputEvent_callback(deviceString, actionString, 0);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (mSendAxisEvents && ((event.objType == SI_AXIS) || (event.objType == SI_INT) || (event.objType == SI_FLOAT)))
|
||||
{
|
||||
F32 fValue = event.fValue;
|
||||
if (event.objType == SI_INT)
|
||||
fValue = (F32)event.iValue;
|
||||
|
||||
return( false );
|
||||
if (!ActionMap::getDeviceName(event.deviceType, event.deviceInst, deviceString))
|
||||
return false;
|
||||
|
||||
const char* actionString = ActionMap::buildActionString(&event);
|
||||
|
||||
onAxisEvent_callback(deviceString, actionString, fValue);
|
||||
return (event.deviceType != MouseDeviceType); // Don't consume mouse move events
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,23 +32,31 @@
|
|||
/// to script. This is useful for implementing custom keyboard handling code.
|
||||
class GuiInputCtrl : public GuiMouseEventCtrl
|
||||
{
|
||||
public:
|
||||
protected:
|
||||
bool mSendAxisEvents;
|
||||
bool mSendBreakEvents;
|
||||
bool mSendModifierEvents;
|
||||
|
||||
typedef GuiMouseEventCtrl Parent;
|
||||
|
||||
// GuiControl.
|
||||
virtual bool onWake();
|
||||
virtual void onSleep();
|
||||
public:
|
||||
|
||||
virtual bool onInputEvent( const InputEventInfo &event );
|
||||
|
||||
static void initPersistFields();
|
||||
typedef GuiMouseEventCtrl Parent;
|
||||
|
||||
DECLARE_CONOBJECT(GuiInputCtrl);
|
||||
DECLARE_CATEGORY( "Gui Other Script" );
|
||||
DECLARE_DESCRIPTION( "A control that locks the mouse and reports all keyboard input events to script." );
|
||||
GuiInputCtrl();
|
||||
|
||||
DECLARE_CALLBACK( void, onInputEvent, ( const char* device, const char* action, bool state ));
|
||||
// GuiControl.
|
||||
virtual bool onWake();
|
||||
virtual void onSleep();
|
||||
|
||||
virtual bool onInputEvent( const InputEventInfo &event );
|
||||
|
||||
static void initPersistFields();
|
||||
|
||||
DECLARE_CONOBJECT(GuiInputCtrl);
|
||||
DECLARE_CATEGORY( "Gui Other Script" );
|
||||
DECLARE_DESCRIPTION( "A control that locks the mouse and reports all input events to script." );
|
||||
|
||||
DECLARE_CALLBACK( void, onInputEvent, ( const char* device, const char* action, bool state ));
|
||||
DECLARE_CALLBACK(void, onAxisEvent, (const char* device, const char* action, F32 axisValue));
|
||||
};
|
||||
|
||||
#endif // _GUI_INPUTCTRL_H
|
||||
|
|
|
|||
|
|
@ -249,6 +249,14 @@ enum InputObjectInstancesEnum
|
|||
SI_DPOV2 = 0x215,
|
||||
SI_LPOV2 = 0x216,
|
||||
SI_RPOV2 = 0x217,
|
||||
SI_POVMASK = 0x218,
|
||||
SI_POVMASK2 = 0x219,
|
||||
|
||||
/// Trackball event codes.
|
||||
SI_XBALL = 0x21A,
|
||||
SI_YBALL = 0x21B,
|
||||
SI_XBALL2 = 0x21C,
|
||||
SI_YBALL2 = 0x21D,
|
||||
|
||||
XI_CONNECT = 0x300,
|
||||
XI_THUMBLX = 0x301,
|
||||
|
|
@ -262,7 +270,7 @@ enum InputObjectInstancesEnum
|
|||
XI_DPAD_DOWN = 0x308,
|
||||
XI_DPAD_LEFT = 0x309,
|
||||
XI_DPAD_RIGHT = 0x310,*/
|
||||
|
||||
|
||||
XI_START = 0x311,
|
||||
XI_BACK = 0x312,
|
||||
XI_LEFT_THUMB = 0x313,
|
||||
|
|
@ -273,7 +281,8 @@ enum InputObjectInstancesEnum
|
|||
XI_A = 0x317,
|
||||
XI_B = 0x318,
|
||||
XI_X = 0x319,
|
||||
XI_Y = 0x320,
|
||||
XI_Y = 0x31A,
|
||||
XI_GUIDE = 0x31B,
|
||||
|
||||
INPUT_DEVICE_PLUGIN_CODES_START = 0x400,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -27,15 +27,11 @@
|
|||
|
||||
#include "sdlInput.h"
|
||||
#include "platform/platformInput.h"
|
||||
#include "sdlInputManager.h"
|
||||
#include "SDL.h"
|
||||
|
||||
#ifdef LOG_INPUT
|
||||
#include <time.h>
|
||||
#include <stdarg.h>
|
||||
#endif
|
||||
|
||||
// Static class variables:
|
||||
InputManager* Input::smManager;
|
||||
InputManager* Input::smManager = NULL;
|
||||
bool Input::smActive;
|
||||
U8 Input::smModifierKeys;
|
||||
bool Input::smLastKeyboardActivated;
|
||||
|
|
@ -43,10 +39,6 @@ bool Input::smLastMouseActivated;
|
|||
bool Input::smLastJoystickActivated;
|
||||
InputEvent Input::smInputEvent;
|
||||
|
||||
#ifdef LOG_INPUT
|
||||
static HANDLE gInputLog;
|
||||
#endif
|
||||
|
||||
static void fillAsciiTable() {}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
|
@ -91,24 +83,17 @@ void Input::init()
|
|||
fillAsciiTable();
|
||||
Con::printf( "" );
|
||||
|
||||
smManager = new SDLInputManager;
|
||||
if (smManager)
|
||||
{
|
||||
SDLInputManager::init();
|
||||
}
|
||||
|
||||
// Set ourselves to participate in per-frame processing.
|
||||
Process::notify(Input::process, PROCESS_INPUT_ORDER);
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
DefineEngineFunction(isJoystickDetected, bool, (),, "")
|
||||
{
|
||||
return(SDL_NumJoysticks() > 0);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
DefineEngineFunction(getJoystickAxes, const char*, (const char* instance), , "")
|
||||
{
|
||||
// TODO SDL
|
||||
return("");
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
U16 Input::getKeyCode( U16 asciiCode )
|
||||
{
|
||||
|
|
@ -118,7 +103,7 @@ U16 Input::getKeyCode( U16 asciiCode )
|
|||
char c[2];
|
||||
c[0]= asciiCode;
|
||||
c[1] = NULL;
|
||||
return KeyMapSDL::getTorqueScanCodeFromSDL( SDL_GetScancodeFromName( c ) );
|
||||
return KeyMapSDL::getTorqueScanCodeFromSDL( SDL_GetScancodeFromKey( SDL_GetKeyFromName(c) ) );
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
|
@ -159,6 +144,13 @@ void Input::destroy()
|
|||
|
||||
SDL_QuitSubSystem( SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | SDL_INIT_GAMECONTROLLER );
|
||||
|
||||
if (smManager)
|
||||
{
|
||||
if (smManager->isEnabled())
|
||||
smManager->disable();
|
||||
delete smManager;
|
||||
smManager = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
|
@ -186,8 +178,8 @@ void Input::activate()
|
|||
//ImmReleaseContext( getWin32WindowHandle(), winState.imeHandle );
|
||||
#endif
|
||||
|
||||
if ( !Con::getBoolVariable( "$enableDirectInput" ) )
|
||||
return;
|
||||
if (smManager && !smManager->isEnabled())
|
||||
smManager->enable();
|
||||
|
||||
if ( smManager && smManager->isEnabled() && !smActive )
|
||||
{
|
||||
|
|
@ -199,7 +191,10 @@ void Input::activate()
|
|||
//------------------------------------------------------------------------------
|
||||
void Input::deactivate()
|
||||
{
|
||||
if ( smManager && smManager->isEnabled() && smActive )
|
||||
if (smManager && smManager->isEnabled())
|
||||
smManager->disable();
|
||||
|
||||
if (smActive)
|
||||
{
|
||||
smActive = false;
|
||||
Con::printf( "Input deactivated." );
|
||||
|
|
@ -435,4 +430,4 @@ U32 KeyMapSDL::getSDLScanCodeFromTorque(U32 torque)
|
|||
buildScanCodeArray();
|
||||
|
||||
return T3D_SDL[torque];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
1381
Engine/source/platformSDL/sdlInputManager.cpp
Normal file
1381
Engine/source/platformSDL/sdlInputManager.cpp
Normal file
File diff suppressed because it is too large
Load diff
114
Engine/source/platformSDL/sdlInputManager.h
Normal file
114
Engine/source/platformSDL/sdlInputManager.h
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef _SDLINPUTMANAGER_H_
|
||||
#define _SDLINPUTMANAGER_H_
|
||||
|
||||
#ifndef _PLATFORMINPUT_H_
|
||||
#include "platform/platformInput.h"
|
||||
#endif
|
||||
#include "SDL.h"
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
class SDLInputManager : public InputManager
|
||||
{
|
||||
enum Constants {
|
||||
MaxJoysticks = 4, // Up to 4 simultaneous joysticks
|
||||
MaxControllers = 4, // Up to 4 simultaneous controllers
|
||||
MaxHats = 2, // Maximum 2 hats per device
|
||||
MaxBalls = 2, // Maximum 2 trackballs per device
|
||||
MaxControllerAxes = 7, // From map_StringForControllerAxis[] in SDL_gamecontroller.c
|
||||
MaxControllerButtons = 16 // From map_StringForControllerButton[] in SDL_gamecontroller.c
|
||||
};
|
||||
|
||||
struct controllerState
|
||||
{
|
||||
S32 sdlInstID; // SDL device instance id
|
||||
U32 torqueInstID; // Torque device instance id
|
||||
SDL_GameController *inputDevice;
|
||||
};
|
||||
|
||||
struct joystickState
|
||||
{
|
||||
S32 sdlInstID; // SDL device instance id
|
||||
U32 torqueInstID; // Torque device instance id
|
||||
SDL_Joystick *inputDevice;
|
||||
U32 numAxes;
|
||||
U8 lastHatState[MaxHats];
|
||||
|
||||
void reset();
|
||||
};
|
||||
|
||||
private:
|
||||
typedef InputManager Parent;
|
||||
|
||||
static S32 map_EventForControllerAxis[MaxControllerAxes];
|
||||
static S32 map_EventForControllerButton[MaxControllerButtons];
|
||||
|
||||
static bool smJoystickEnabled;
|
||||
static bool smJoystickSplitAxesLR;
|
||||
static bool smControllerEnabled;
|
||||
static bool smPOVButtonEvents;
|
||||
static bool smPOVMaskEvents;
|
||||
|
||||
joystickState mJoysticks[MaxJoysticks];
|
||||
controllerState mControllers[MaxControllers];
|
||||
|
||||
// Used to look up a torque instance based on a device inst
|
||||
HashTable<S32, joystickState*> mJoystickMap;
|
||||
HashTable<S32, controllerState*> mControllerMap;
|
||||
|
||||
bool mJoystickActive;
|
||||
|
||||
void deviceConnectedCallback(S32 index);
|
||||
bool closeControllerByIndex(S32 index);
|
||||
void closeController(SDL_JoystickID sdlId);
|
||||
bool closeJoystickByIndex(S32 index);
|
||||
void closeJoystick(SDL_JoystickID sdlId);
|
||||
|
||||
void buildInputEvent(U32 deviceType, U32 deviceInst, InputEventType objType, InputObjectInstances objInst, InputActionType action, S32 iValue);
|
||||
void buildInputEvent(U32 deviceType, U32 deviceInst, InputEventType objType, InputObjectInstances objInst, InputActionType action, F32 fValue);
|
||||
void buildHatEvents(U32 deviceType, U32 deviceInst, U8 lastState, U8 currentState, S32 hatIndex);
|
||||
|
||||
public:
|
||||
DECLARE_STATIC_CLASS(SDLInputManager);
|
||||
|
||||
public:
|
||||
SDLInputManager();
|
||||
|
||||
bool enable();
|
||||
void disable();
|
||||
void process();
|
||||
|
||||
void processEvent(SDL_Event &evt);
|
||||
|
||||
static void init();
|
||||
|
||||
// Console interface:
|
||||
S32 openJoystick(S32 sdlIndex, S32 requestedTID);
|
||||
S32 openController(S32 sdlIndex, S32 requestedTID);
|
||||
void closeDevice(S32 sdlIndex);
|
||||
S32 getJoystickOpenState(S32 sdlIndex);
|
||||
void getJoystickTorqueInst(S32 sdlIndex, char* instBuffer);
|
||||
};
|
||||
|
||||
#endif // _SDLINPUTMANAGER_H_
|
||||
|
|
@ -21,6 +21,7 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "windowManager/sdl/sdlWindowMgr.h"
|
||||
#include "platformSDL/sdlInputManager.h"
|
||||
#include "gfx/gfxDevice.h"
|
||||
#include "core/util/journal/process.h"
|
||||
#include "core/strings/unicode.h"
|
||||
|
|
@ -269,6 +270,13 @@ void PlatformWindowManagerSDL::_process()
|
|||
SDL_Event evt;
|
||||
while( SDL_PollEvent(&evt) )
|
||||
{
|
||||
if (evt.type >= SDL_JOYAXISMOTION && evt.type <= SDL_CONTROLLERDEVICEREMAPPED)
|
||||
{
|
||||
SDLInputManager* mgr = static_cast<SDLInputManager*>(Input::getManager());
|
||||
if (mgr)
|
||||
mgr->processEvent(evt);
|
||||
continue;
|
||||
}
|
||||
switch(evt.type)
|
||||
{
|
||||
case SDL_QUIT:
|
||||
|
|
@ -356,15 +364,16 @@ void PlatformWindowManagerSDL::_process()
|
|||
|
||||
case(SDL_DROPCOMPLETE):
|
||||
{
|
||||
if (!Con::isFunction("onDropEnd"))
|
||||
break;
|
||||
|
||||
Con::executef("onDropEnd");
|
||||
if (Con::isFunction("onDropEnd"))
|
||||
Con::executef("onDropEnd");
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
//Con::printf("Event: %d", evt.type);
|
||||
#ifdef TORQUE_DEBUG
|
||||
Con::warnf("Unhandled SDL input event: 0x%04x", evt.type);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue