Merge pull request #219 from DavidWyand-GG/InputEventManager

Input event changes
This commit is contained in:
David Wyand 2013-01-22 15:22:34 -08:00
commit c7769f0de6
43 changed files with 923 additions and 316 deletions

View file

@ -23,10 +23,6 @@
#ifndef _AUTH_H_
#define _AUTH_H_
#ifndef _EVENT_H_
#include "platform/event.h"
#endif
/// Formerly contained a certificate, showing that something was valid.
class Auth2Certificate
{

View file

@ -291,6 +291,9 @@ void StandardMainLoop::init()
tm = new TimeManager;
tm->timeEvent.notify(&::processTimeEvent);
// Start up the Input Event Manager
INPUTMGR->start();
Sampler::init();
// Hook in for UDP notification
@ -307,6 +310,9 @@ void StandardMainLoop::init()
void StandardMainLoop::shutdown()
{
// Stop the Input Event Manager
INPUTMGR->stop();
delete tm;
preShutdown();

View file

@ -23,7 +23,6 @@
#include "app/net/httpObject.h"
#include "platform/platform.h"
#include "platform/event.h"
#include "core/stream/fileStream.h"
#include "console/simBase.h"
#include "console/consoleInternal.h"

View file

@ -22,7 +22,6 @@
#include "platform/platform.h"
#include "console/simBase.h"
#include "platform/event.h"
#include "sim/netConnection.h"
#include "core/stream/bitStream.h"
#include "sim/netObject.h"

View file

@ -96,7 +96,6 @@
#include "app/net/serverQuery.h"
#include "platform/platform.h"
#include "platform/event.h"
#include "core/dnet.h"
#include "core/util/tVector.h"
#include "core/stream/bitStream.h"

View file

@ -26,9 +26,6 @@
#ifndef _PLATFORM_H_
#include "platform/platform.h"
#endif
#ifndef _EVENT_H_
#include "platform/event.h"
#endif
#ifndef _BITSET_H_
#include "core/bitSet.h"
#endif

View file

@ -23,7 +23,6 @@
#include "app/net/tcpObject.h"
#include "platform/platform.h"
#include "platform/event.h"
#include "console/simBase.h"
#include "console/consoleInternal.h"
#include "core/strings/stringUnit.h"

View file

@ -23,7 +23,6 @@
#include "platform/platform.h"
#include "console/console.h"
#include "console/telnetDebugger.h"
#include "platform/event.h"
#include "console/ast.h"
#include "core/tAlgorithm.h"

View file

@ -23,7 +23,6 @@
#include "platform/platform.h"
#include "console/console.h"
#include "console/telnetDebugger.h"
#include "platform/event.h"
#include "console/ast.h"
#include "core/tAlgorithm.h"

View file

@ -30,7 +30,6 @@
#include "core/strings/unicode.h"
#include "core/stream/fileStream.h"
#include "console/compiler.h"
#include "platform/event.h"
#include "platform/platformInput.h"
#include "core/util/journal/journal.h"
#include "core/util/uuid.h"

View file

@ -27,7 +27,6 @@
#include "console/ast.h"
#include "core/stream/fileStream.h"
#include "console/compiler.h"
#include "platform/event.h"
#include "platform/platformInput.h"
#include "torqueConfig.h"
#include "core/frameAllocator.h"

View file

@ -25,7 +25,6 @@
#include "console/engineAPI.h"
#include "core/strings/stringFunctions.h"
#include "platform/event.h"
#include "core/util/journal/process.h"
#include "core/module.h"

View file

@ -26,9 +26,6 @@
#ifndef _CONSOLE_H_
#include "console/console.h"
#endif
#ifndef _EVENT_H_
#include "platform/event.h"
#endif
#include "platform/platformNet.h"
/// Telnet admin console.

View file

@ -25,7 +25,6 @@
#include "core/frameAllocator.h"
#include "console/console.h"
#include "platform/event.h"
#include "core/stringTable.h"
#include "console/consoleInternal.h"
#include "console/ast.h"

View file

@ -26,9 +26,6 @@
#ifndef _PLATFORM_H_
#include "platform/platform.h"
#endif
#ifndef _EVENT_H_
#include "platform/event.h"
#endif
#include "platform/platformNet.h"

View file

@ -394,8 +394,8 @@ typedef JournaledSignal<void(WindowId, S32, S32)> ResizeEvent;
/// void event(S32 timeDelta)
typedef JournaledSignal<void(S32)> TimeManagerEvent;
// void event(U32 deviceInst,F32 fValue, U16 deviceType, U16 objType, U16 ascii, U16 objInst, U8 action, U8 modifier)
typedef JournaledSignal<void(U32,F32,U16,U16,U16,U16,U8,U8)> InputEvent;
// void event(U32 deviceInst, F32 fValue, F32 fValue2, F32 fValue3, F32 fValue4, S32 iValue, U16 deviceType, U16 objType, U16 ascii, U16 objInst, U8 action, U8 modifier)
typedef JournaledSignal<void(U32,F32,F32,F32,F32,S32,U16,U16,U16,U16,U8,U8)> InputEvent;
/// void event(U32 popupGUID, U32 commandID, bool& returnValue)
typedef JournaledSignal<void(U32, U32)> PopupMenuEvent;

View file

@ -26,7 +26,6 @@
#include "console/engineAPI.h"
#include "console/console.h"
#include "gfx/bitmap/gBitmap.h"
#include "platform/event.h"
#include "gui/core/guiDefaultControlRender.h"
#include "gfx/gfxDevice.h"
#include "gfx/gfxDrawUtil.h"

View file

@ -24,7 +24,6 @@
#include "gui/containers/guiScrollCtrl.h"
#include "gui/core/guiCanvas.h"
#include "console/consoleTypes.h"
#include "platform/event.h"
#include "core/frameAllocator.h"
#include "core/stringBuffer.h"
#include "gfx/gfxDrawUtil.h"

View file

@ -26,7 +26,6 @@
#include "gfx/gfxTextureManager.h"
#include "gui/controls/guiSliderCtrl.h"
#include "gui/core/guiDefaultControlRender.h"
#include "platform/event.h"
#include "gfx/primBuilder.h"
#include "gfx/gfxDrawUtil.h"
#include "sfx/sfxSystem.h"

View file

@ -30,7 +30,6 @@
#include "console/consoleTypes.h"
#include "console/console.h"
#include "gui/core/guiTypes.h"
#include "platform/event.h"
#include "gfx/gfxDrawUtil.h"
#include "gui/controls/guiTextEditCtrl.h"
#ifdef TORQUE_TOOLS

View file

@ -25,7 +25,6 @@
#include "console/console.h"
#include "console/engineAPI.h"
#include "platform/event.h"
#include "gui/containers/guiScrollCtrl.h"
#include "gfx/gfxDrawUtil.h"
#include "gui/core/guiDefaultControlRender.h"

View file

@ -26,7 +26,6 @@
#include "console/console.h"
#include "console/engineAPI.h"
#include "platform/profiler.h"
#include "platform/event.h"
#include "gfx/gfxDevice.h"
#include "gfx/gfxDrawUtil.h"
#include "gui/core/guiTypes.h"

View file

@ -26,9 +26,6 @@
#ifndef _SIMBASE_H_
#include "console/simBase.h"
#endif
#ifndef _EVENT_H_
#include "platform/event.h"
#endif
#ifndef _GUICONTROL_H_
#include "gui/core/guiControl.h"
#endif

View file

@ -28,7 +28,6 @@
#include "console/consoleInternal.h"
#include "console/engineAPI.h"
#include "console/codeBlock.h"
#include "platform/event.h"
#include "gfx/bitmap/gBitmap.h"
#include "sim/actionMap.h"
#include "gui/core/guiCanvas.h"

View file

@ -38,9 +38,6 @@
#ifndef _GUITYPES_H_
#include "gui/core/guiTypes.h"
#endif
#ifndef _EVENT_H_
#include "platform/event.h"
#endif
#ifndef _UTIL_DELEGATE_H_
#include "core/util/delegate.h"
#endif

View file

@ -26,9 +26,6 @@
#ifndef _GUIMOUSEEVENTCTRL_H_
#include "gui/utility/guiMouseEventCtrl.h"
#endif
#ifndef _EVENT_H_
#include "platform/event.h"
#endif
/// A control that locks the mouse and reports all keyboard input events

View file

@ -26,9 +26,6 @@
#ifndef _GUICONTROL_H_
#include "gui/core/guiControl.h"
#endif
#ifndef _EVENT_H_
#include "platform/event.h"
#endif
class GuiMouseEventCtrl : public GuiControl

View file

@ -0,0 +1,59 @@
//-----------------------------------------------------------------------------
// 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 _IINPUTDEVICE_H_
#define _IINPUTDEVICE_H_
#include "console/consoleTypes.h"
class IInputDevice
{
protected:
/// Device name
char mName[30];
/// Device type
U32 mDeviceType;
/// Is the device enabled
bool mEnabled;
public:
inline const char* getDeviceName() const
{
return mName;
}
inline U32 getDeviceType() const
{
return mDeviceType;
}
inline bool isEnabled()
{
return mEnabled;
}
virtual bool process() = 0;
};
#endif

View file

@ -0,0 +1,548 @@
//-----------------------------------------------------------------------------
// 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.
//-----------------------------------------------------------------------------
#include "platform/event.h"
#include "core/module.h"
#include "core/util/journal/process.h"
#include "core/strings/stringFunctions.h"
#include "core/stringTable.h"
#include "platform/platformInput.h"
#include "math/mQuat.h"
MODULE_BEGIN( InputEventManager )
MODULE_INIT_BEFORE( SIM )
MODULE_SHUTDOWN_AFTER( SIM )
MODULE_INIT
{
ManagedSingleton< InputEventManager >::createSingleton();
}
MODULE_SHUTDOWN
{
ManagedSingleton< InputEventManager >::deleteSingleton();
}
MODULE_END;
InputEventManager::InputEventManager()
{
mNextDeviceTypeCode = INPUT_DEVICE_PLUGIN_DEVICES_START;
mNextDeviceCode = INPUT_DEVICE_PLUGIN_CODES_START;
buildVirtualMap();
}
InputEventManager::~InputEventManager()
{
}
U32 InputEventManager::getNextDeviceType()
{
U32 code = mNextDeviceTypeCode;
++mNextDeviceTypeCode;
return code;
}
U32 InputEventManager::getNextDeviceCode()
{
U32 code = mNextDeviceCode;
++mNextDeviceCode;
return code;
}
void InputEventManager::registerDevice(IInputDevice* device)
{
// Make sure the device is not already registered
for(U32 i=0; i<mDeviceList.size(); ++i)
{
if(mDeviceList[i] == device)
return;
}
// Add the new device to the list
mDeviceList.push_back(device);
}
void InputEventManager::unregisterDevice(IInputDevice* device)
{
// Remove the device from the list
for(U32 i=0; i<mDeviceList.size(); ++i)
{
if(mDeviceList[i] == device)
{
mDeviceList.erase(i);
return;
}
}
}
bool InputEventManager::isRegisteredDevice(const char* name)
{
for(Vector<IInputDevice*>::iterator itr = mDeviceList.begin(); itr != mDeviceList.end(); ++itr)
{
if((*itr)->isEnabled())
{
const char* deviceName = (*itr)->getDeviceName();
if(dStrnicmp(name, deviceName, dStrlen(deviceName)) == 0)
{
return true;
}
}
}
return false;
}
bool InputEventManager::isRegisteredDevice(U32 type)
{
for(Vector<IInputDevice*>::iterator itr = mDeviceList.begin(); itr != mDeviceList.end(); ++itr)
{
if((*itr)->isEnabled())
{
U32 deviceType = (*itr)->getDeviceType();
if(deviceType == type)
{
return true;
}
}
}
return false;
}
bool InputEventManager::isRegisteredDeviceWithAttributes(const char* name, U32& deviceType, U32&nameLen)
{
for(Vector<IInputDevice*>::iterator itr = mDeviceList.begin(); itr != mDeviceList.end(); ++itr)
{
if((*itr)->isEnabled())
{
const char* deviceName = (*itr)->getDeviceName();
S32 length = dStrlen(deviceName);
if(dStrnicmp(name, deviceName, length) == 0)
{
deviceType = (*itr)->getDeviceType();
nameLen = length;
return true;
}
}
}
return false;
}
const char* InputEventManager::getRegisteredDeviceName(U32 type)
{
for(Vector<IInputDevice*>::iterator itr = mDeviceList.begin(); itr != mDeviceList.end(); ++itr)
{
if((*itr)->isEnabled())
{
U32 deviceType = (*itr)->getDeviceType();
if(deviceType == type)
{
return (*itr)->getDeviceName();
}
}
}
return NULL;
}
void InputEventManager::start()
{
Process::notify(this, &InputEventManager::process, PROCESS_INPUT_ORDER);
}
void InputEventManager::stop()
{
Process::remove(this, &InputEventManager::process);
}
void InputEventManager::process()
{
// Process each device
for(Vector<IInputDevice*>::iterator itr = mDeviceList.begin(); itr != mDeviceList.end(); ++itr)
{
if((*itr)->isEnabled())
{
(*itr)->process();
}
}
}
// Used for the old virtual map table that was originally in actionMap.cpp
struct CodeMapping
{
const char* pDescription;
InputEventType type;
InputObjectInstances code;
};
CodeMapping gVirtualMap[] =
{
//-------------------------------------- KEYBOARD EVENTS
//
{ "backspace", SI_KEY, KEY_BACKSPACE },
{ "tab", SI_KEY, KEY_TAB },
{ "return", SI_KEY, KEY_RETURN },
{ "enter", SI_KEY, KEY_RETURN },
{ "shift", SI_KEY, KEY_SHIFT },
{ "ctrl", SI_KEY, KEY_CONTROL },
{ "alt", SI_KEY, KEY_ALT },
{ "pause", SI_KEY, KEY_PAUSE },
{ "capslock", SI_KEY, KEY_CAPSLOCK },
{ "escape", SI_KEY, KEY_ESCAPE },
{ "space", SI_KEY, KEY_SPACE },
{ "pagedown", SI_KEY, KEY_PAGE_DOWN },
{ "pageup", SI_KEY, KEY_PAGE_UP },
{ "end", SI_KEY, KEY_END },
{ "home", SI_KEY, KEY_HOME },
{ "left", SI_KEY, KEY_LEFT },
{ "up", SI_KEY, KEY_UP },
{ "right", SI_KEY, KEY_RIGHT },
{ "down", SI_KEY, KEY_DOWN },
{ "print", SI_KEY, KEY_PRINT },
{ "insert", SI_KEY, KEY_INSERT },
{ "delete", SI_KEY, KEY_DELETE },
{ "help", SI_KEY, KEY_HELP },
{ "win_lwindow", SI_KEY, KEY_WIN_LWINDOW },
{ "win_rwindow", SI_KEY, KEY_WIN_RWINDOW },
{ "win_apps", SI_KEY, KEY_WIN_APPS },
{ "cmd", SI_KEY, KEY_ALT },
{ "opt", SI_KEY, KEY_MAC_OPT },
{ "lopt", SI_KEY, KEY_MAC_LOPT },
{ "ropt", SI_KEY, KEY_MAC_ROPT },
{ "numpad0", SI_KEY, KEY_NUMPAD0 },
{ "numpad1", SI_KEY, KEY_NUMPAD1 },
{ "numpad2", SI_KEY, KEY_NUMPAD2 },
{ "numpad3", SI_KEY, KEY_NUMPAD3 },
{ "numpad4", SI_KEY, KEY_NUMPAD4 },
{ "numpad5", SI_KEY, KEY_NUMPAD5 },
{ "numpad6", SI_KEY, KEY_NUMPAD6 },
{ "numpad7", SI_KEY, KEY_NUMPAD7 },
{ "numpad8", SI_KEY, KEY_NUMPAD8 },
{ "numpad9", SI_KEY, KEY_NUMPAD9 },
{ "numpadmult", SI_KEY, KEY_MULTIPLY },
{ "numpadadd", SI_KEY, KEY_ADD },
{ "numpadsep", SI_KEY, KEY_SEPARATOR },
{ "numpadminus", SI_KEY, KEY_SUBTRACT },
{ "numpaddecimal", SI_KEY, KEY_DECIMAL },
{ "numpaddivide", SI_KEY, KEY_DIVIDE },
{ "numpadenter", SI_KEY, KEY_NUMPADENTER },
{ "f1", SI_KEY, KEY_F1 },
{ "f2", SI_KEY, KEY_F2 },
{ "f3", SI_KEY, KEY_F3 },
{ "f4", SI_KEY, KEY_F4 },
{ "f5", SI_KEY, KEY_F5 },
{ "f6", SI_KEY, KEY_F6 },
{ "f7", SI_KEY, KEY_F7 },
{ "f8", SI_KEY, KEY_F8 },
{ "f9", SI_KEY, KEY_F9 },
{ "f10", SI_KEY, KEY_F10 },
{ "f11", SI_KEY, KEY_F11 },
{ "f12", SI_KEY, KEY_F12 },
{ "f13", SI_KEY, KEY_F13 },
{ "f14", SI_KEY, KEY_F14 },
{ "f15", SI_KEY, KEY_F15 },
{ "f16", SI_KEY, KEY_F16 },
{ "f17", SI_KEY, KEY_F17 },
{ "f18", SI_KEY, KEY_F18 },
{ "f19", SI_KEY, KEY_F19 },
{ "f20", SI_KEY, KEY_F20 },
{ "f21", SI_KEY, KEY_F21 },
{ "f22", SI_KEY, KEY_F22 },
{ "f23", SI_KEY, KEY_F23 },
{ "f24", SI_KEY, KEY_F24 },
{ "numlock", SI_KEY, KEY_NUMLOCK },
{ "scrolllock", SI_KEY, KEY_SCROLLLOCK },
{ "lshift", SI_KEY, KEY_LSHIFT },
{ "rshift", SI_KEY, KEY_RSHIFT },
{ "lcontrol", SI_KEY, KEY_LCONTROL },
{ "rcontrol", SI_KEY, KEY_RCONTROL },
{ "lalt", SI_KEY, KEY_LALT },
{ "ralt", SI_KEY, KEY_RALT },
{ "tilde", SI_KEY, KEY_TILDE },
{ "minus", SI_KEY, KEY_MINUS },
{ "equals", SI_KEY, KEY_EQUALS },
{ "lbracket", SI_KEY, KEY_LBRACKET },
{ "rbracket", SI_KEY, KEY_RBRACKET },
{ "backslash", SI_KEY, KEY_BACKSLASH },
{ "semicolon", SI_KEY, KEY_SEMICOLON },
{ "apostrophe", SI_KEY, KEY_APOSTROPHE },
{ "comma", SI_KEY, KEY_COMMA },
{ "period", SI_KEY, KEY_PERIOD },
{ "slash", SI_KEY, KEY_SLASH },
{ "lessthan", SI_KEY, KEY_OEM_102 },
//-------------------------------------- BUTTON EVENTS
// Joystick/Mouse buttons
{ "button0", SI_BUTTON, KEY_BUTTON0 },
{ "button1", SI_BUTTON, KEY_BUTTON1 },
{ "button2", SI_BUTTON, KEY_BUTTON2 },
{ "button3", SI_BUTTON, KEY_BUTTON3 },
{ "button4", SI_BUTTON, KEY_BUTTON4 },
{ "button5", SI_BUTTON, KEY_BUTTON5 },
{ "button6", SI_BUTTON, KEY_BUTTON6 },
{ "button7", SI_BUTTON, KEY_BUTTON7 },
{ "button8", SI_BUTTON, KEY_BUTTON8 },
{ "button9", SI_BUTTON, KEY_BUTTON9 },
{ "button10", SI_BUTTON, KEY_BUTTON10 },
{ "button11", SI_BUTTON, KEY_BUTTON11 },
{ "button12", SI_BUTTON, KEY_BUTTON12 },
{ "button13", SI_BUTTON, KEY_BUTTON13 },
{ "button14", SI_BUTTON, KEY_BUTTON14 },
{ "button15", SI_BUTTON, KEY_BUTTON15 },
{ "button16", SI_BUTTON, KEY_BUTTON16 },
{ "button17", SI_BUTTON, KEY_BUTTON17 },
{ "button18", SI_BUTTON, KEY_BUTTON18 },
{ "button19", SI_BUTTON, KEY_BUTTON19 },
{ "button20", SI_BUTTON, KEY_BUTTON20 },
{ "button21", SI_BUTTON, KEY_BUTTON21 },
{ "button22", SI_BUTTON, KEY_BUTTON22 },
{ "button23", SI_BUTTON, KEY_BUTTON23 },
{ "button24", SI_BUTTON, KEY_BUTTON24 },
{ "button25", SI_BUTTON, KEY_BUTTON25 },
{ "button26", SI_BUTTON, KEY_BUTTON26 },
{ "button27", SI_BUTTON, KEY_BUTTON27 },
{ "button28", SI_BUTTON, KEY_BUTTON28 },
{ "button29", SI_BUTTON, KEY_BUTTON29 },
{ "button30", SI_BUTTON, KEY_BUTTON30 },
{ "button31", SI_BUTTON, KEY_BUTTON31 },
{ "button32", SI_BUTTON, KEY_BUTTON32 },
{ "button33", SI_BUTTON, KEY_BUTTON33 },
{ "button34", SI_BUTTON, KEY_BUTTON34 },
{ "button35", SI_BUTTON, KEY_BUTTON35 },
{ "button36", SI_BUTTON, KEY_BUTTON36 },
{ "button37", SI_BUTTON, KEY_BUTTON37 },
{ "button38", SI_BUTTON, KEY_BUTTON38 },
{ "button39", SI_BUTTON, KEY_BUTTON39 },
{ "button40", SI_BUTTON, KEY_BUTTON40 },
{ "button41", SI_BUTTON, KEY_BUTTON41 },
{ "button42", SI_BUTTON, KEY_BUTTON42 },
{ "button43", SI_BUTTON, KEY_BUTTON43 },
{ "button44", SI_BUTTON, KEY_BUTTON44 },
{ "button45", SI_BUTTON, KEY_BUTTON45 },
{ "button46", SI_BUTTON, KEY_BUTTON46 },
{ "button47", SI_BUTTON, KEY_BUTTON47 },
//-------------------------------------- MOVE EVENTS
// Mouse/Joystick axes:
{ "xaxis", SI_AXIS, SI_XAXIS },
{ "yaxis", SI_AXIS, SI_YAXIS },
{ "zaxis", SI_AXIS, SI_ZAXIS },
{ "rxaxis", SI_AXIS, SI_RXAXIS },
{ "ryaxis", SI_AXIS, SI_RYAXIS },
{ "rzaxis", SI_AXIS, SI_RZAXIS },
{ "slider", SI_AXIS, SI_SLIDER },
//-------------------------------------- POV EVENTS
// Joystick POV:
{ "xpov", SI_POV, SI_XPOV },
{ "ypov", SI_POV, SI_YPOV },
{ "upov", SI_POV, SI_UPOV },
{ "dpov", SI_POV, SI_DPOV },
{ "lpov", SI_POV, SI_LPOV },
{ "rpov", SI_POV, SI_RPOV },
{ "xpov2", SI_POV, SI_XPOV2 },
{ "ypov2", SI_POV, SI_YPOV2 },
{ "upov2", SI_POV, SI_UPOV2 },
{ "dpov2", SI_POV, SI_DPOV2 },
{ "lpov2", SI_POV, SI_LPOV2 },
{ "rpov2", SI_POV, SI_RPOV2 },
#if defined( TORQUE_OS_WIN32 ) || defined( TORQUE_OS_XENON )
//-------------------------------------- XINPUT EVENTS
// Controller connect / disconnect:
{ "connect", SI_BUTTON, XI_CONNECT },
// L & R Thumbsticks:
{ "thumblx", SI_AXIS, XI_THUMBLX },
{ "thumbly", SI_AXIS, XI_THUMBLY },
{ "thumbrx", SI_AXIS, XI_THUMBRX },
{ "thumbry", SI_AXIS, XI_THUMBRY },
// L & R Triggers:
{ "triggerl", SI_AXIS, XI_LEFT_TRIGGER },
{ "triggerr", SI_AXIS, XI_RIGHT_TRIGGER },
// DPAD Buttons:
{ "dpadu", SI_BUTTON, SI_UPOV },
{ "dpadd", SI_BUTTON, SI_DPOV },
{ "dpadl", SI_BUTTON, SI_LPOV },
{ "dpadr", SI_BUTTON, SI_RPOV },
// START & BACK Buttons:
{ "btn_start", SI_BUTTON, XI_START },
{ "btn_back", SI_BUTTON, XI_BACK },
// L & R Thumbstick Buttons:
{ "btn_lt", SI_BUTTON, XI_LEFT_THUMB },
{ "btn_rt", SI_BUTTON, XI_RIGHT_THUMB },
// L & R Shoulder Buttons:
{ "btn_l", SI_BUTTON, XI_LEFT_SHOULDER },
{ "btn_r", SI_BUTTON, XI_RIGHT_SHOULDER },
// Primary buttons:
{ "btn_a", SI_BUTTON, XI_A },
{ "btn_b", SI_BUTTON, XI_B },
{ "btn_x", SI_BUTTON, XI_X },
{ "btn_y", SI_BUTTON, XI_Y },
#endif
//-------------------------------------- MISCELLANEOUS EVENTS
//
{ "anykey", SI_KEY, KEY_ANYKEY },
{ "nomatch", SI_UNKNOWN, (InputObjectInstances)0xFFFFFFFF }
};
void InputEventManager::buildVirtualMap()
{
char desc[256];
VirtualMapData* data;
for (U32 j = 0; gVirtualMap[j].code != 0xFFFFFFFF; j++)
{
// Make sure the description is lower case
desc[0] = 0;
dStrncpy(desc, gVirtualMap[j].pDescription, 255);
dStrlwr(desc);
data = new VirtualMapData();
data->type = gVirtualMap[j].type;
data->code = gVirtualMap[j].code;
data->desc = StringTable->insert(desc);
mVirtualMap.insert(data, desc);
mActionCodeMap.insertUnique(data->code, *data);
}
}
void InputEventManager::addVirtualMap(const char* description, InputEventType type, InputObjectInstances code)
{
// Make sure the description is lower case
char desc[256];
desc[0] = 0;
dStrncpy(desc, description, 255);
dStrlwr(desc);
VirtualMapData* data = new VirtualMapData();
data->type = type;
data->code = code;
data->desc = StringTable->insert(desc);
mVirtualMap.insert(data, desc);
mActionCodeMap.insertUnique(data->code, *data);
}
InputEventManager::VirtualMapData* InputEventManager::findVirtualMap(const char* description)
{
char desc[256];
desc[0] = 0;
dStrncpy(desc, description, 255);
dStrlwr(desc);
return mVirtualMap.retreive(desc);
}
const char* InputEventManager::findVirtualMapDescFromCode(U32 code)
{
HashTable<U32, VirtualMapData>::Iterator itr = mActionCodeMap.find(code);
if(itr != mActionCodeMap.end())
return itr->value.desc;
return NULL;
}
void InputEventManager::buildInputEvent(U32 deviceType, U32 deviceInst, InputEventType objType, InputObjectInstances objInst, InputActionType action, S32 iValue)
{
InputEventInfo newEvent;
newEvent.deviceType = deviceType;
newEvent.deviceInst = deviceInst;
newEvent.objType = objType;
newEvent.objInst = objInst;
newEvent.action = action;
newEvent.iValue = iValue;
newEvent.postToSignal(Input::smInputEvent);
}
void InputEventManager::buildInputEvent(U32 deviceType, U32 deviceInst, InputEventType objType, InputObjectInstances objInst, InputActionType action, float fValue)
{
InputEventInfo newEvent;
newEvent.deviceType = deviceType;
newEvent.deviceInst = deviceInst;
newEvent.objType = objType;
newEvent.objInst = objInst;
newEvent.action = action;
newEvent.fValue = fValue;
newEvent.postToSignal(Input::smInputEvent);
}
void InputEventManager::buildInputEvent(U32 deviceType, U32 deviceInst, InputEventType objType, InputObjectInstances objInst, InputActionType action, Point3F& pValue)
{
InputEventInfo newEvent;
newEvent.deviceType = deviceType;
newEvent.deviceInst = deviceInst;
newEvent.objType = objType;
newEvent.objInst = objInst;
newEvent.action = action;
newEvent.fValue = pValue.x;
newEvent.fValue2 = pValue.y;
newEvent.fValue3 = pValue.z;
newEvent.postToSignal(Input::smInputEvent);
}
void InputEventManager::buildInputEvent(U32 deviceType, U32 deviceInst, InputEventType objType, InputObjectInstances objInst, InputActionType action, QuatF& qValue)
{
InputEventInfo newEvent;
newEvent.deviceType = deviceType;
newEvent.deviceInst = deviceInst;
newEvent.objType = objType;
newEvent.objInst = objInst;
newEvent.action = action;
newEvent.fValue = qValue.x;
newEvent.fValue2 = qValue.y;
newEvent.fValue3 = qValue.z;
newEvent.fValue4 = qValue.w;
newEvent.postToSignal(Input::smInputEvent);
}

View file

@ -30,13 +30,21 @@
#define _EVENT_H_
#include "platform/types.h"
#include "platform/IInputDevice.h"
#include "core/util/journal/journaledSignal.h"
#include "core/util/tSingleton.h"
#include "core/util/tDictionary.h"
#include "core/tSimpleHashTable.h"
#define AddInputVirtualMap( description, type, code ) \
INPUTMGR->addVirtualMap( #description, type, code );
/// @defgroup input_constants Input system constants
/// @{
/// Input event constants:
enum InputObjectInstances
typedef U32 InputObjectInstances;
enum InputObjectInstancesEnum
{
KEY_NULL = 0x000, ///< Invalid KeyCode
KEY_BACKSPACE = 0x001,
@ -203,6 +211,22 @@ enum InputObjectInstances
KEY_BUTTON29 = 0x011D,
KEY_BUTTON30 = 0x011E,
KEY_BUTTON31 = 0x011F,
KEY_BUTTON32 = 0x0120,
KEY_BUTTON33 = 0x0121,
KEY_BUTTON34 = 0x0122,
KEY_BUTTON35 = 0x0123,
KEY_BUTTON36 = 0x0124,
KEY_BUTTON37 = 0x0125,
KEY_BUTTON38 = 0x0126,
KEY_BUTTON39 = 0x0127,
KEY_BUTTON40 = 0x0128,
KEY_BUTTON41 = 0x0129,
KEY_BUTTON42 = 0x012A,
KEY_BUTTON43 = 0x012B,
KEY_BUTTON44 = 0x012C,
KEY_BUTTON45 = 0x012D,
KEY_BUTTON46 = 0x012E,
KEY_BUTTON47 = 0x012F,
KEY_ANYKEY = 0xfffe,
/// Joystick event codes.
@ -250,10 +274,13 @@ enum InputObjectInstances
XI_B = 0x318,
XI_X = 0x319,
XI_Y = 0x320,
INPUT_DEVICE_PLUGIN_CODES_START = 0x400,
};
/// Input device types
enum InputDeviceTypes
typedef U32 InputDeviceTypes;
enum InputDeviceTypesEnum
{
UnknownDeviceType,
MouseDeviceType,
@ -262,7 +289,9 @@ enum InputDeviceTypes
GamepadDeviceType,
XInputDeviceType,
NUM_INPUT_DEVICE_TYPES
NUM_INPUT_DEVICE_TYPES,
INPUT_DEVICE_PLUGIN_DEVICES_START = NUM_INPUT_DEVICE_TYPES,
};
/// Device Event Action Types
@ -278,17 +307,24 @@ enum InputActionType
SI_MOVE = 0x03,
/// A key repeat occurred. Happens in between a SI_MAKE and SI_BREAK.
SI_REPEAT = 0x04,
SI_REPEAT = 0x04,
/// A value of some type. Matched with SI_FLOAT or SI_INT.
SI_VALUE = 0x05,
};
///Device Event Types
enum InputEventType
{
SI_UNKNOWN = 0x01,
SI_BUTTON = 0x02,
SI_POV = 0x03,
SI_AXIS = 0x04,
SI_KEY = 0x0A,
SI_BUTTON = 0x02, // Button press/release
SI_POV = 0x03, // Point of View hat
SI_AXIS = 0x04, // Axis in range -1.0..1.0
SI_POS = 0x05, // Absolute position value (Point3F)
SI_ROT = 0x06, // Absolute rotation value (QuatF)
SI_INT = 0x07, // Integer value (S32)
SI_FLOAT = 0x08, // Float value (F32)
SI_KEY = 0x0A, // Keyboard key
};
/// Wildcard match used by the input system.
@ -356,6 +392,10 @@ struct InputEventInfo
{
deviceInst = 0;
fValue = 0.f;
fValue2 = 0.f;
fValue3 = 0.f;
fValue4 = 0.f;
iValue = 0;
deviceType = (InputDeviceTypes)0;
objType = (InputEventType)0;
ascii = 0;
@ -367,9 +407,18 @@ struct InputEventInfo
/// Device instance: joystick0, joystick1, etc
U32 deviceInst;
/// Value ranges from -1.0 to 1.0
/// Value typically ranges from -1.0 to 1.0, but doesn't have to.
/// It depends on the context.
F32 fValue;
/// Extended float values (often used for absolute rotation Quat)
F32 fValue2;
F32 fValue3;
F32 fValue4;
/// Signed integer value
S32 iValue;
/// What was the action? (MAKE/BREAK/MOVE)
InputActionType action;
InputDeviceTypes deviceType;
@ -384,9 +433,99 @@ struct InputEventInfo
inline void postToSignal(InputEvent &ie)
{
ie.trigger(deviceInst, fValue, deviceType, objType, ascii, objInst, action, modifier);
ie.trigger(deviceInst, fValue, fValue2, fValue3, fValue4, iValue, deviceType, objType, ascii, objInst, action, modifier);
}
};
class Point3F;
class QuatF;
/// Handles input device plug-ins
class InputEventManager
{
public:
struct VirtualMapData
{
StringTableEntry desc;
InputEventType type;
InputObjectInstances code;
};
public:
InputEventManager();
virtual ~InputEventManager();
/// Get the next device type code
U32 getNextDeviceType();
/// Get the next device action code
U32 getNextDeviceCode();
void registerDevice(IInputDevice* device);
void unregisterDevice(IInputDevice* device);
/// Check if the given device name is a registered device.
/// The given name can optionally include an instance number on the end.
bool isRegisteredDevice(const char* name);
/// Check if the given device type is a registered device.
bool isRegisteredDevice(U32 type);
/// Same as above but also provides the found device type and actual
// device name length. Used by ActionMap::getDeviceTypeAndInstance()
bool isRegisteredDeviceWithAttributes(const char* name, U32& deviceType, U32&nameLen);
/// Returns the name of a registered device given its type
const char* getRegisteredDeviceName(U32 type);
void start();
void stop();
void process();
// Add to the virtual map table
void addVirtualMap(const char* description, InputEventType type, InputObjectInstances code);
// Find a virtual map entry based on the text description
VirtualMapData* findVirtualMap(const char* description);
// Find a virtual map entry's description based on the action code
const char* findVirtualMapDescFromCode(U32 code);
/// Build an input event based on a single iValue
void buildInputEvent(U32 deviceType, U32 deviceInst, InputEventType objType, InputObjectInstances objInst, InputActionType action, S32 iValue);
/// Build an input event based on a single fValue
void buildInputEvent(U32 deviceType, U32 deviceInst, InputEventType objType, InputObjectInstances objInst, InputActionType action, float fValue);
/// Build an input event based on a Point3F
void buildInputEvent(U32 deviceType, U32 deviceInst, InputEventType objType, InputObjectInstances objInst, InputActionType action, Point3F& pValue);
/// Build an input event based on a QuatF
void buildInputEvent(U32 deviceType, U32 deviceInst, InputEventType objType, InputObjectInstances objInst, InputActionType action, QuatF& qValue);
protected:
U32 mNextDeviceTypeCode;
U32 mNextDeviceCode;
Vector<IInputDevice*> mDeviceList;
// Holds description to VirtualMapData struct
SimpleHashTable<VirtualMapData> mVirtualMap;
// Used to look up a description based on a VirtualMapData.code
HashTable<U32, VirtualMapData> mActionCodeMap;
protected:
void buildVirtualMap();
public:
// For ManagedSingleton.
static const char* getSingletonName() { return "InputEventManager"; }
};
/// Returns the InputEventManager singleton.
#define INPUTMGR ManagedSingleton<InputEventManager>::instance()
#endif

View file

@ -21,7 +21,6 @@
//-----------------------------------------------------------------------------
#include "platform/platformNet.h"
#include "platform/event.h"
#include "core/strings/stringFunctions.h"
#if defined (TORQUE_OS_WIN32)

View file

@ -27,9 +27,6 @@
#ifndef _CONSOLE_H_
#include "console/console.h"
#endif
#ifndef _EVENT_H_
#include "platform/event.h"
#endif
class WinConsole
{

View file

@ -29,9 +29,6 @@
#ifndef _PLATFORMINPUT_H_
#include "platform/platformInput.h"
#endif
#ifndef _EVENT_H_
#include "platform/event.h"
#endif
#define DIRECTINPUT_VERSION 0x0800
#include <dinput.h>

View file

@ -23,7 +23,6 @@
#include "platformWin32/platformWin32.h"
#include "platformWin32/winDirectInput.h"
#include "platformWin32/winDInputDevice.h"
#include "platform/event.h"
#include "console/console.h"
#include "console/consoleTypes.h"
#include "sim/actionMap.h"

View file

@ -24,7 +24,6 @@
#include "platform/platformInput.h"
#include "platformWin32/winDirectInput.h"
#include "platform/event.h"
#include "console/console.h"
#include "core/util/journal/process.h"
#include "windowManager/platformWindowMgr.h"

View file

@ -21,7 +21,6 @@
//-----------------------------------------------------------------------------
#include "platform/platform.h"
#include "platform/event.h"
#include "platformWin32/platformWin32.h"
#include "platformWin32/winConsole.h"
#include "platformWin32/winDirectInput.h"

View file

@ -21,7 +21,6 @@
//-----------------------------------------------------------------------------
#include "sim/actionMap.h"
#include "platform/event.h"
#include "console/console.h"
#include "platform/platform.h"
#include "platform/platformInput.h"
@ -29,6 +28,8 @@
#include "core/stream/fileStream.h"
#include "math/mMathFn.h"
#include "console/engineAPI.h"
#include "math/mQuat.h"
#include "math/mAngAxis.h"
#define CONST_E 2.7182818284590452353602874f
@ -175,20 +176,12 @@ static inline bool dIsDecentChar(U8 c)
return ((U8(0xa0) <= c) || (( U8(0x21) <= c) && (c <= U8(0x7e))) || ((U8(0x91) <= c) && (c <= U8(0x92))));
}
struct CodeMapping
{
const char* pDescription;
InputEventType type;
InputObjectInstances code;
};
struct AsciiMapping
{
const char* pDescription;
U16 asciiCode;
};
extern CodeMapping gVirtualMap[];
extern AsciiMapping gAsciiMap[];
//------------------------------------------------------------------------------
@ -521,14 +514,21 @@ bool ActionMap::createEventDescriptor(const char* pEventString, EventDescriptor*
}
}
// Didn't find an ascii match. Check the virtual map table
for (U32 j = 0; gVirtualMap[j].code != 0xFFFFFFFF; j++)
//for (U32 j = 0; gVirtualMap[j].code != 0xFFFFFFFF; j++)
//{
// if (dStricmp(pObjectString, gVirtualMap[j].pDescription) == 0)
// {
// pDescriptor->eventType = gVirtualMap[j].type;
// pDescriptor->eventCode = gVirtualMap[j].code;
// return true;
// }
//}
InputEventManager::VirtualMapData* data = INPUTMGR->findVirtualMap(pObjectString);
if(data)
{
if (dStricmp(pObjectString, gVirtualMap[j].pDescription) == 0)
{
pDescriptor->eventType = gVirtualMap[j].type;
pDescriptor->eventCode = gVirtualMap[j].code;
return true;
}
pDescriptor->eventType = data->type;
pDescriptor->eventCode = data->code;
return true;
}
}
return false;
@ -900,7 +900,8 @@ const char* ActionMap::buildActionString( const InputEventInfo* event )
bool ActionMap::getDeviceTypeAndInstance(const char *pDeviceName, U32 &deviceType, U32 &deviceInstance)
{
U32 offset = 0;
U32 inputMgrDeviceType = 0;
if (dStrnicmp(pDeviceName, "keyboard", dStrlen("keyboard")) == 0)
{
deviceType = KeyboardDeviceType;
@ -921,6 +922,10 @@ bool ActionMap::getDeviceTypeAndInstance(const char *pDeviceName, U32 &deviceTyp
deviceType = GamepadDeviceType;
offset = dStrlen("gamepad");
}
else if(INPUTMGR->isRegisteredDeviceWithAttributes(pDeviceName, inputMgrDeviceType, offset))
{
deviceType = inputMgrDeviceType;
}
else
{
return false;
@ -964,9 +969,18 @@ bool ActionMap::getDeviceName(const U32 deviceType, const U32 deviceInstance, ch
dSprintf(buffer, 16, "gamepad%d", deviceInstance);
break;
default:
Con::errorf( "ActionMap::getDeviceName: unknown device type specified, %d (inst: %d)", deviceType, deviceInstance);
return false;
default:
{
const char* name = INPUTMGR->getRegisteredDeviceName(deviceType);
if(!name)
{
Con::errorf( "ActionMap::getDeviceName: unknown device type specified, %d (inst: %d)", deviceType, deviceInstance);
return false;
}
dSprintf(buffer, 16, "%s%d", name, deviceInstance);
break;
}
}
return true;
@ -1102,11 +1116,17 @@ bool ActionMap::getKeyString(const U32 action, char* buffer)
buffer[1] = '\0';
return true;
}
for (U32 i = 0; gVirtualMap[i].code != 0xFFFFFFFF; i++) {
if (gVirtualMap[i].code == action) {
dStrcpy(buffer, gVirtualMap[i].pDescription);
return true;
}
//for (U32 i = 0; gVirtualMap[i].code != 0xFFFFFFFF; i++) {
// if (gVirtualMap[i].code == action) {
// dStrcpy(buffer, gVirtualMap[i].pDescription);
// return true;
// }
//}
const char* desc = INPUTMGR->findVirtualMapDescFromCode(action);
if(desc)
{
dStrcpy(buffer, desc);
return true;
}
}
@ -1297,7 +1317,7 @@ bool ActionMap::processAction(const InputEventInfo* pEvent)
if(Platform::checkKeyboardInputExclusion(pEvent))
return false;
static const char *argv[2];
static const char *argv[5];
if (pEvent->action == SI_MAKE) {
const Node* pNode = findNode(pEvent->deviceType, pEvent->deviceInst,
pEvent->modifier, pEvent->objInst);
@ -1390,9 +1410,72 @@ bool ActionMap::processAction(const InputEventInfo* pEvent)
Con::execute(2, argv);
return true;
}
}
else if ( (pEvent->objType == SI_POS || pEvent->objType == SI_FLOAT || pEvent->objType == SI_ROT || pEvent->objType == SI_INT)
&& INPUTMGR->isRegisteredDevice(pEvent->deviceType)
)
{
const Node* pNode = findNode(pEvent->deviceType, pEvent->deviceInst,
pEvent->modifier, pEvent->objInst);
if( pNode == NULL )
return false;
// Ok, we're all set up, call the function.
argv[0] = pNode->consoleFunction;
S32 argc = 1;
if (pEvent->objType == SI_INT)
{
// Handle the integer as some sort of motion such as a
// single component to an absolute position
argv[1] = Con::getIntArg( pEvent->iValue );
argc += 1;
}
else if (pEvent->objType == SI_FLOAT)
{
// Handle float as some sort of motion such as a
// single component to an absolute position
argv[1] = Con::getFloatArg( pEvent->fValue );
argc += 1;
}
else if (pEvent->objType == SI_POS)
{
// Handle Point3F type position
argv[1] = Con::getFloatArg( pEvent->fValue );
argv[2] = Con::getFloatArg( pEvent->fValue2 );
argv[3] = Con::getFloatArg( pEvent->fValue3 );
argc += 3;
}
else
{
// Handle rotation (QuatF)
QuatF quat(pEvent->fValue, pEvent->fValue2, pEvent->fValue3, pEvent->fValue4);
AngAxisF aa(quat);
aa.axis.normalize();
argv[1] = Con::getFloatArg( aa.axis.x );
argv[2] = Con::getFloatArg( aa.axis.y );
argv[3] = Con::getFloatArg( aa.axis.z );
argv[4] = Con::getFloatArg( mRadToDeg(aa.angle) );
argc += 4;
}
if (pNode->object)
{
Con::execute(pNode->object, argc, argv);
}
else
{
Con::execute(argc, argv);
}
return true;
}
else if ( pEvent->deviceType == JoystickDeviceType
|| pEvent->deviceType == GamepadDeviceType
|| INPUTMGR->isRegisteredDevice(pEvent->deviceType)
)
{
// Joystick events...
@ -1449,6 +1532,49 @@ bool ActionMap::processAction(const InputEventInfo* pEvent)
{
return checkBreakTable(pEvent);
}
else if (pEvent->action == SI_VALUE)
{
if ( (pEvent->objType == SI_FLOAT || pEvent->objType == SI_INT)
&& INPUTMGR->isRegisteredDevice(pEvent->deviceType)
)
{
const Node* pNode = findNode(pEvent->deviceType, pEvent->deviceInst,
pEvent->modifier, pEvent->objInst);
if( pNode == NULL )
return false;
// Ok, we're all set up, call the function.
argv[0] = pNode->consoleFunction;
S32 argc = 1;
if (pEvent->objType == SI_INT)
{
// Handle the integer as some sort of motion such as a
// single component to an absolute position
argv[1] = Con::getIntArg( pEvent->iValue );
argc += 1;
}
else if (pEvent->objType == SI_FLOAT)
{
// Handle float as some sort of motion such as a
// single component to an absolute position
argv[1] = Con::getFloatArg( pEvent->fValue );
argc += 1;
}
if (pNode->object)
{
Con::execute(pNode->object, argc, argv);
}
else
{
Con::execute(argc, argv);
}
return true;
}
}
return false;
}
@ -1998,223 +2124,6 @@ DefineEngineMethod( ActionMap, getDeadZone, const char*, ( const char* device, c
}
//------------------------------------------------------------------------------
//-------------------------------------- Key code to string mapping
// TODO: Add most obvious aliases...
//
CodeMapping gVirtualMap[] =
{
//-------------------------------------- KEYBOARD EVENTS
//
{ "backspace", SI_KEY, KEY_BACKSPACE },
{ "tab", SI_KEY, KEY_TAB },
{ "return", SI_KEY, KEY_RETURN },
{ "enter", SI_KEY, KEY_RETURN },
{ "shift", SI_KEY, KEY_SHIFT },
{ "ctrl", SI_KEY, KEY_CONTROL },
{ "alt", SI_KEY, KEY_ALT },
{ "pause", SI_KEY, KEY_PAUSE },
{ "capslock", SI_KEY, KEY_CAPSLOCK },
{ "escape", SI_KEY, KEY_ESCAPE },
{ "space", SI_KEY, KEY_SPACE },
{ "pagedown", SI_KEY, KEY_PAGE_DOWN },
{ "pageup", SI_KEY, KEY_PAGE_UP },
{ "end", SI_KEY, KEY_END },
{ "home", SI_KEY, KEY_HOME },
{ "left", SI_KEY, KEY_LEFT },
{ "up", SI_KEY, KEY_UP },
{ "right", SI_KEY, KEY_RIGHT },
{ "down", SI_KEY, KEY_DOWN },
{ "print", SI_KEY, KEY_PRINT },
{ "insert", SI_KEY, KEY_INSERT },
{ "delete", SI_KEY, KEY_DELETE },
{ "help", SI_KEY, KEY_HELP },
{ "win_lwindow", SI_KEY, KEY_WIN_LWINDOW },
{ "win_rwindow", SI_KEY, KEY_WIN_RWINDOW },
{ "win_apps", SI_KEY, KEY_WIN_APPS },
{ "cmd", SI_KEY, KEY_ALT },
{ "opt", SI_KEY, KEY_MAC_OPT },
{ "lopt", SI_KEY, KEY_MAC_LOPT },
{ "ropt", SI_KEY, KEY_MAC_ROPT },
{ "numpad0", SI_KEY, KEY_NUMPAD0 },
{ "numpad1", SI_KEY, KEY_NUMPAD1 },
{ "numpad2", SI_KEY, KEY_NUMPAD2 },
{ "numpad3", SI_KEY, KEY_NUMPAD3 },
{ "numpad4", SI_KEY, KEY_NUMPAD4 },
{ "numpad5", SI_KEY, KEY_NUMPAD5 },
{ "numpad6", SI_KEY, KEY_NUMPAD6 },
{ "numpad7", SI_KEY, KEY_NUMPAD7 },
{ "numpad8", SI_KEY, KEY_NUMPAD8 },
{ "numpad9", SI_KEY, KEY_NUMPAD9 },
{ "numpadmult", SI_KEY, KEY_MULTIPLY },
{ "numpadadd", SI_KEY, KEY_ADD },
{ "numpadsep", SI_KEY, KEY_SEPARATOR },
{ "numpadminus", SI_KEY, KEY_SUBTRACT },
{ "numpaddecimal", SI_KEY, KEY_DECIMAL },
{ "numpaddivide", SI_KEY, KEY_DIVIDE },
{ "numpadenter", SI_KEY, KEY_NUMPADENTER },
{ "f1", SI_KEY, KEY_F1 },
{ "f2", SI_KEY, KEY_F2 },
{ "f3", SI_KEY, KEY_F3 },
{ "f4", SI_KEY, KEY_F4 },
{ "f5", SI_KEY, KEY_F5 },
{ "f6", SI_KEY, KEY_F6 },
{ "f7", SI_KEY, KEY_F7 },
{ "f8", SI_KEY, KEY_F8 },
{ "f9", SI_KEY, KEY_F9 },
{ "f10", SI_KEY, KEY_F10 },
{ "f11", SI_KEY, KEY_F11 },
{ "f12", SI_KEY, KEY_F12 },
{ "f13", SI_KEY, KEY_F13 },
{ "f14", SI_KEY, KEY_F14 },
{ "f15", SI_KEY, KEY_F15 },
{ "f16", SI_KEY, KEY_F16 },
{ "f17", SI_KEY, KEY_F17 },
{ "f18", SI_KEY, KEY_F18 },
{ "f19", SI_KEY, KEY_F19 },
{ "f20", SI_KEY, KEY_F20 },
{ "f21", SI_KEY, KEY_F21 },
{ "f22", SI_KEY, KEY_F22 },
{ "f23", SI_KEY, KEY_F23 },
{ "f24", SI_KEY, KEY_F24 },
{ "numlock", SI_KEY, KEY_NUMLOCK },
{ "scrolllock", SI_KEY, KEY_SCROLLLOCK },
{ "lshift", SI_KEY, KEY_LSHIFT },
{ "rshift", SI_KEY, KEY_RSHIFT },
{ "lcontrol", SI_KEY, KEY_LCONTROL },
{ "rcontrol", SI_KEY, KEY_RCONTROL },
{ "lalt", SI_KEY, KEY_LALT },
{ "ralt", SI_KEY, KEY_RALT },
{ "tilde", SI_KEY, KEY_TILDE },
{ "minus", SI_KEY, KEY_MINUS },
{ "equals", SI_KEY, KEY_EQUALS },
{ "lbracket", SI_KEY, KEY_LBRACKET },
{ "rbracket", SI_KEY, KEY_RBRACKET },
{ "backslash", SI_KEY, KEY_BACKSLASH },
{ "semicolon", SI_KEY, KEY_SEMICOLON },
{ "apostrophe", SI_KEY, KEY_APOSTROPHE },
{ "comma", SI_KEY, KEY_COMMA },
{ "period", SI_KEY, KEY_PERIOD },
{ "slash", SI_KEY, KEY_SLASH },
{ "lessthan", SI_KEY, KEY_OEM_102 },
//-------------------------------------- BUTTON EVENTS
// Joystick/Mouse buttons
{ "button0", SI_BUTTON, KEY_BUTTON0 },
{ "button1", SI_BUTTON, KEY_BUTTON1 },
{ "button2", SI_BUTTON, KEY_BUTTON2 },
{ "button3", SI_BUTTON, KEY_BUTTON3 },
{ "button4", SI_BUTTON, KEY_BUTTON4 },
{ "button5", SI_BUTTON, KEY_BUTTON5 },
{ "button6", SI_BUTTON, KEY_BUTTON6 },
{ "button7", SI_BUTTON, KEY_BUTTON7 },
{ "button8", SI_BUTTON, KEY_BUTTON8 },
{ "button9", SI_BUTTON, KEY_BUTTON9 },
{ "button10", SI_BUTTON, KEY_BUTTON10 },
{ "button11", SI_BUTTON, KEY_BUTTON11 },
{ "button12", SI_BUTTON, KEY_BUTTON12 },
{ "button13", SI_BUTTON, KEY_BUTTON13 },
{ "button14", SI_BUTTON, KEY_BUTTON14 },
{ "button15", SI_BUTTON, KEY_BUTTON15 },
{ "button16", SI_BUTTON, KEY_BUTTON16 },
{ "button17", SI_BUTTON, KEY_BUTTON17 },
{ "button18", SI_BUTTON, KEY_BUTTON18 },
{ "button19", SI_BUTTON, KEY_BUTTON19 },
{ "button20", SI_BUTTON, KEY_BUTTON20 },
{ "button21", SI_BUTTON, KEY_BUTTON21 },
{ "button22", SI_BUTTON, KEY_BUTTON22 },
{ "button23", SI_BUTTON, KEY_BUTTON23 },
{ "button24", SI_BUTTON, KEY_BUTTON24 },
{ "button25", SI_BUTTON, KEY_BUTTON25 },
{ "button26", SI_BUTTON, KEY_BUTTON26 },
{ "button27", SI_BUTTON, KEY_BUTTON27 },
{ "button28", SI_BUTTON, KEY_BUTTON28 },
{ "button29", SI_BUTTON, KEY_BUTTON29 },
{ "button30", SI_BUTTON, KEY_BUTTON30 },
{ "button31", SI_BUTTON, KEY_BUTTON31 },
//-------------------------------------- MOVE EVENTS
// Mouse/Joystick axes:
{ "xaxis", SI_AXIS, SI_XAXIS },
{ "yaxis", SI_AXIS, SI_YAXIS },
{ "zaxis", SI_AXIS, SI_ZAXIS },
{ "rxaxis", SI_AXIS, SI_RXAXIS },
{ "ryaxis", SI_AXIS, SI_RYAXIS },
{ "rzaxis", SI_AXIS, SI_RZAXIS },
{ "slider", SI_AXIS, SI_SLIDER },
//-------------------------------------- POV EVENTS
// Joystick POV:
{ "xpov", SI_POV, SI_XPOV },
{ "ypov", SI_POV, SI_YPOV },
{ "upov", SI_POV, SI_UPOV },
{ "dpov", SI_POV, SI_DPOV },
{ "lpov", SI_POV, SI_LPOV },
{ "rpov", SI_POV, SI_RPOV },
{ "xpov2", SI_POV, SI_XPOV2 },
{ "ypov2", SI_POV, SI_YPOV2 },
{ "upov2", SI_POV, SI_UPOV2 },
{ "dpov2", SI_POV, SI_DPOV2 },
{ "lpov2", SI_POV, SI_LPOV2 },
{ "rpov2", SI_POV, SI_RPOV2 },
#if defined( TORQUE_OS_WIN32 ) || defined( TORQUE_OS_XENON )
//-------------------------------------- XINPUT EVENTS
// Controller connect / disconnect:
{ "connect", SI_BUTTON, XI_CONNECT },
// L & R Thumbsticks:
{ "thumblx", SI_AXIS, XI_THUMBLX },
{ "thumbly", SI_AXIS, XI_THUMBLY },
{ "thumbrx", SI_AXIS, XI_THUMBRX },
{ "thumbry", SI_AXIS, XI_THUMBRY },
// L & R Triggers:
{ "triggerl", SI_AXIS, XI_LEFT_TRIGGER },
{ "triggerr", SI_AXIS, XI_RIGHT_TRIGGER },
// DPAD Buttons:
{ "dpadu", SI_BUTTON, SI_UPOV },
{ "dpadd", SI_BUTTON, SI_DPOV },
{ "dpadl", SI_BUTTON, SI_LPOV },
{ "dpadr", SI_BUTTON, SI_RPOV },
// START & BACK Buttons:
{ "btn_start", SI_BUTTON, XI_START },
{ "btn_back", SI_BUTTON, XI_BACK },
// L & R Thumbstick Buttons:
{ "btn_lt", SI_BUTTON, XI_LEFT_THUMB },
{ "btn_rt", SI_BUTTON, XI_RIGHT_THUMB },
// L & R Shoulder Buttons:
{ "btn_l", SI_BUTTON, XI_LEFT_SHOULDER },
{ "btn_r", SI_BUTTON, XI_RIGHT_SHOULDER },
// Primary buttons:
{ "btn_a", SI_BUTTON, XI_A },
{ "btn_b", SI_BUTTON, XI_B },
{ "btn_x", SI_BUTTON, XI_X },
{ "btn_y", SI_BUTTON, XI_Y },
#endif
//-------------------------------------- MISCELLANEOUS EVENTS
//
{ "anykey", SI_KEY, KEY_ANYKEY },
{ "nomatch", SI_UNKNOWN, (InputObjectInstances)0xFFFFFFFF }
};
AsciiMapping gAsciiMap[] =
{
//--- KEYBOARD EVENTS

View file

@ -32,9 +32,6 @@
#ifndef _NETSTRINGTABLE_H_
#include "sim/netStringTable.h"
#endif
#ifndef _EVENT_H_
#include "platform/event.h"
#endif
#ifndef _DNET_H_
#include "core/dnet.h"
#endif

View file

@ -21,7 +21,6 @@
//-----------------------------------------------------------------------------
#include "platform/platform.h"
#include "platform/event.h"
#include "sim/netConnection.h"
#include "sim/netInterface.h"
#include "core/stream/bitStream.h"

View file

@ -21,7 +21,6 @@
//-----------------------------------------------------------------------------
#include "platform/platform.h"
#include "platform/event.h"
#include "windowManager/platformWindowMgr.h"
#include "gfx/gfxInit.h"
#include "gfx/gfxDevice.h"

View file

@ -31,7 +31,6 @@
#include <windows.h>
#include "platform/event.h"
#include "platform/platformInput.h"
#include "windowManager/win32/winDispatch.h"
#include "windowManager/win32/win32Window.h"

View file

@ -310,7 +310,7 @@ void WindowInputGenerator::handleKeyboard( WindowId did, U32 modifier, U32 actio
//-----------------------------------------------------------------------------
// Raw input
//-----------------------------------------------------------------------------
void WindowInputGenerator::handleInputEvent( U32 deviceInst,F32 fValue, U16 deviceType, U16 objType, U16 ascii, U16 objInst, U8 action, U8 modifier )
void WindowInputGenerator::handleInputEvent( U32 deviceInst, F32 fValue, F32 fValue2, F32 fValue3, F32 fValue4, S32 iValue, U16 deviceType, U16 objType, U16 ascii, U16 objInst, U8 action, U8 modifier )
{
// Skip it if we don't have focus.
if(!mInputController || !mFocused)
@ -320,6 +320,10 @@ void WindowInputGenerator::handleInputEvent( U32 deviceInst,F32 fValue, U16 devi
InputEventInfo event;
event.deviceInst = deviceInst;
event.fValue = fValue;
event.fValue2 = fValue2;
event.fValue3 = fValue3;
event.fValue4 = fValue4;
event.iValue = iValue;
event.deviceType = (InputDeviceTypes)deviceType;
event.objType = (InputEventType)objType;
event.ascii = ascii;

View file

@ -58,7 +58,7 @@ class WindowInputGenerator
void handleKeyboard (WindowId did, U32 modifier, U32 action, U16 key);
void handleCharInput (WindowId did, U32 modifier, U16 key);
void handleAppEvent (WindowId did, S32 event);
void handleInputEvent (U32 deviceInst,F32 fValue, U16 deviceType, U16 objType, U16 ascii, U16 objInst, U8 action, U8 modifier);
void handleInputEvent (U32 deviceInst, F32 fValue, F32 fValue2, F32 fValue3, F32 fValue4, S32 iValue, U16 deviceType, U16 objType, U16 ascii, U16 objInst, U8 action, U8 modifier);
void generateInputEvent( InputEventInfo &inputEvent );