MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / buildEvent

Method buildEvent

Engine/source/platformWin32/winDInputDevice.cpp:860–1042  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

858
859//------------------------------------------------------------------------------
860bool DInputDevice::buildEvent( DWORD offset, S32 newData, S32 oldData )
861{
862 ObjInfo &objInfo = mObjInfo[offset];
863
864 if ( objInfo.mType == SI_UNKNOWN )
865 return false;
866
867 InputEventInfo newEvent;
868 newEvent.deviceType = (InputDeviceTypes)mDeviceType;
869 newEvent.deviceInst = mDeviceID;
870 newEvent.objType = objInfo.mType;
871 newEvent.objInst = objInfo.mInst;
872 newEvent.modifier = (InputModifiers)0;
873
874 switch ( newEvent.objType )
875 {
876 case SI_AXIS:
877 newEvent.action = SI_MOVE;
878 if ( newEvent.deviceType == MouseDeviceType )
879 {
880 newEvent.fValue = float( newData );
881
882#ifdef LOG_INPUT
883#ifdef LOG_MOUSEMOVE
884 if ( newEvent.objInst == SI_XAXIS )
885 Input::log( "EVENT (DInput): %s move (%.1f, 0.0).\n", mName, newEvent.fValue );
886 else if ( newEvent.objInst == SI_YAXIS )
887 Input::log( "EVENT (DInput): %s move (0.0, %.1f).\n", mName, newEvent.fValue );
888 else
889#endif
890 if ( newEvent.objInst == SI_ZAXIS )
891 Input::log( "EVENT (DInput): %s wheel move %.1f.\n", mName, newEvent.fValue );
892#endif
893 }
894 else // Joystick or other device:
895 {
896 // Scale to the range -1.0 to 1.0:
897 if ( objInfo.mMin != DIPROPRANGE_NOMIN && objInfo.mMax != DIPROPRANGE_NOMAX )
898 {
899 F32 range = F32( objInfo.mMax - objInfo.mMin );
900 newEvent.fValue = F32( ( 2 * newData ) - objInfo.mMax - objInfo.mMin ) / range;
901 }
902 else
903 newEvent.fValue = (F32)newData;
904
905#ifdef LOG_INPUT
906 // Keep this commented unless you REALLY want these messages for something--
907 // they come once per each iteration of the main game loop.
908 //switch ( newEvent.objType )
909 //{
910 //case SI_XAXIS:
911 //if ( newEvent.fValue < -0.01f || newEvent.fValue > 0.01f )
912 //Input::log( "EVENT (DInput): %s X-axis move %.2f.\n", mName, newEvent.fValue );
913 //break;
914 //case SI_YAXIS:
915 //if ( newEvent.fValue < -0.01f || newEvent.fValue > 0.01f )
916 //Input::log( "EVENT (DInput): %s Y-axis move %.2f.\n", mName, newEvent.fValue );
917 //break;

Callers

nothing calls this directly

Calls 4

_Win32GetPOVDirsFunction · 0.85
_Win32LogPOVInputFunction · 0.85
postToSignalMethod · 0.80
logFunction · 0.50

Tested by

no test coverage detected