Merge branch 'Preview4_0' of https://github.com/Areloch/Torque3D into Preview4_0

This commit is contained in:
Areloch 2020-03-21 00:54:30 -05:00
commit 8b4d4633bc
8 changed files with 1027 additions and 1 deletions

View file

@ -704,7 +704,7 @@ void ConvexShape::prepRenderImage( SceneRenderState *state )
// Set our Material
ri->matInst = matInst;
if (matInst->getMaterial()->isTranslucent())
if (matInst->getMaterial()->isTranslucent() && (!(matInst->getMaterial()->isAlphatest() && state->isShadowPass())))
{
ri->translucentSort = true;
ri->type = RenderPassManager::RIT_Translucent;

View file

@ -0,0 +1,106 @@
//-----------------------------------------------------------------------------
// Module creation functions.
//-----------------------------------------------------------------------------
function inputTest::create( %this )
{
}
function inputTest::destroy( %this )
{
}
function inputTest::initClient( %this )
{
exec("./scripts/customProfiles.cs");
exec("./scripts/inputMonitor.cs");
exec("./scripts/gui/inputMonitor.gui");
exec("./scripts/joystickSettings.cs");
exec("./scripts/gui/joystickSettings.gui");
if (isObject(MainMenuGui))
{
%testBtn = new GuiButtonCtrl() {
text = "Input Event Monitor";
groupNum = "-1";
buttonType = "PushButton";
useMouseEvents = "0";
position = "0 0";
extent = "200 40";
minExtent = "8 8";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiBlankMenuButtonProfile";
visible = "1";
active = "1";
command = "Canvas.pushDialog(InputMonitorDlg);";
tooltipProfile = "GuiToolTipProfile";
isContainer = "0";
canSave = "0";
canSaveDynamicFields = "0";
};
if (!isObject(MMTestContainer))
{
new GuiDynamicCtrlArrayControl(MMTestContainer) {
colCount = "0";
colSize = "200";
rowCount = "0";
rowSize = "40";
rowSpacing = "2";
colSpacing = "0";
frozen = "0";
autoCellSize = "0";
fillRowFirst = "1";
dynamicSize = "1";
padding = "0 0 0 0";
position = "0 0";
extent = "200 40";
minExtent = "8 2";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiDefaultProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
canSave = "0";
canSaveDynamicFields = "0";
};
MainMenuGui.add(MMTestContainer);
}
MMTestContainer.add(%testBtn);
}
}
function onSDLDeviceConnected(%sdlIndex, %deviceName, %deviceType)
{
echo("onSDLDeviceConnected(" @ %sdlIndex @ ", \"" @ %deviceName @ "\", \"" @ %deviceType @ "\") - Called");
// Note: This is called before the device is automatically processed to allow
// overrides, so refreshing the gui needs to happen after the device has been opened
if (JoystickSettingsDlg.isAwake())
JoystickSettingsDlg.schedule(250, "updateDevices");
if (InputMonitorDlg.isAwake())
InputMonitorDlg.schedule(250, "updateDevicesLine");
}
function onSDLDeviceDisconnected(%sdlIndex)
{
echo("onSDLDeviceDisconnected(" @ %sdlIndex @ ") - Called");
if (JoystickSettingsDlg.isAwake())
JoystickSettingsDlg.schedule(250, "updateDevices");
if (InputMonitorDlg.isAwake())
InputMonitorDlg.schedule(250, "updateDevicesLine");
}
function listAllGCMappings()
{ // Lists all game controller device mappings that are currently installed
%numMappings = SDLInputManager::GameControllerNumMappings();
for (%i = 0; %i < %numMappings; %i++)
echo(SDLInputManager::GameControllerMappingForIndex(%i));
}

View file

@ -0,0 +1,10 @@
<ModuleDefinition
ModuleId="inputTest"
VersionId="1"
Description="Input Monitor Module."
ScriptFile="inputTest.cs"
CreateFunction="create"
DestroyFunction="destroy"
Group="Game"
Dependencies="UI=1">
</ModuleDefinition>

View file

@ -0,0 +1,30 @@
new GuiControlProfile (GuiEventBackgroundProfile)
{
justify = "left";
fontSize = 18;
fontColor = "225 225 225 255";
opaque = true;
fillColor = "20 20 20 225";
};
new GuiControlProfile (GuiEventBorderProfile)
{
opaque = false;
border = 1;
borderColor = "225 225 225 255";
};
new GuiControlProfile (GuiEventTextProfile)
{
justify = "left";
fontSize = 18;
fontColor = "225 225 225 255";
};
new GuiControlProfile (GuiEventCheckboxProfile : GuiCheckBoxProfile)
{
fontSize = 18;
fontColor = "225 225 225 255";
fontColorHL ="141 204 249 255";
};

View file

@ -0,0 +1,196 @@
//--- OBJECT WRITE BEGIN ---
%guiContent = new GuiControl(InputMonitorDlg) {
position = "0 0";
extent = "1024 768";
minExtent = "8 8";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiModelessDialogProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
canSave = "1";
canSaveDynamicFields = "1";
new GuiContainer() {
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "162 149";
extent = "334 608";
minExtent = "8 2";
horizSizing = "center";
vertSizing = "center";
profile = "GuiEventBackgroundProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
canSave = "1";
canSaveDynamicFields = "0";
new GuiInputCtrl(InputMonitorCtrl) {
sendAxisEvents = "1";
sendBreakEvents = "1";
sendModifierEvents = "1";
lockMouse = "0";
position = "0 0";
extent = "8 8";
minExtent = "8 8";
horizSizing = "width";
vertSizing = "height";
profile = "GuiInputCtrlProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "0";
canSave = "1";
canSaveDynamicFields = "0";
};
new GuiChunkedBitmapCtrl() {
bitmap = "data/ui/art/hudfill.png";
useVariable = "0";
tile = "0";
position = "0 0";
extent = "334 608";
minExtent = "8 2";
horizSizing = "width";
vertSizing = "height";
profile = "GuiDefaultProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "0";
canSave = "1";
canSaveDynamicFields = "0";
};
new GuiTextCtrl() {
text = "0 of 0 Joystick devices open";
maxLength = "255";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "12 4";
extent = "312 20";
minExtent = "8 8";
horizSizing = "width";
vertSizing = "bottom";
profile = "GuiMenuButtonProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
internalName = "devicesLine";
canSave = "1";
canSaveDynamicFields = "0";
};
new GuiTextCtrl() {
text = "Press f2 for settings";
maxLength = "255";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "12 28";
extent = "312 20";
minExtent = "8 8";
horizSizing = "width";
vertSizing = "bottom";
profile = "GuiMenuButtonProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
canSave = "1";
canSaveDynamicFields = "0";
};
new GuiTextCtrl() {
text = "Press escape to close input monitor";
maxLength = "255";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "12 52";
extent = "312 20";
minExtent = "8 8";
horizSizing = "width";
vertSizing = "bottom";
profile = "GuiMenuButtonProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
canSave = "1";
canSaveDynamicFields = "0";
};
new GuiScrollCtrl() {
willFirstRespond = "1";
hScrollBar = "alwaysOff";
vScrollBar = "dynamic";
lockHorizScroll = "1";
lockVertScroll = "0";
constantThumbHeight = "0";
childMargin = "0 0";
mouseWheelScrollSpeed = "-1";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "12 76";
extent = "312 520";
minExtent = "8 8";
horizSizing = "width";
vertSizing = "height";
profile = "ConsoleScrollProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
canSave = "1";
canSaveDynamicFields = "0";
new GuiMessageVectorCtrl(EventVectorCtrl) {
lineSpacing = "2";
lineContinuedIndex = "10";
matchColor = "0 0 255 255";
maxColorIndex = "5";
position = "1 1";
extent = "310 54";
minExtent = "8 8";
horizSizing = "width";
vertSizing = "height";
profile = "GuiEventTextProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "0";
canSave = "1";
canSaveDynamicFields = "0";
};
};
};
};
//--- OBJECT WRITE END ---

View file

@ -0,0 +1,496 @@
//--- OBJECT WRITE BEGIN ---
%guiContent = new GuiControl(JoystickSettingsDlg) {
position = "0 0";
extent = "1024 768";
minExtent = "8 8";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiModelessDialogProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
canSave = "1";
canSaveDynamicFields = "1";
axisDeadzone = "0.1";
maxLines = "500";
new GuiContainer() {
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "212 184";
extent = "600 404";
minExtent = "8 2";
horizSizing = "center";
vertSizing = "center";
profile = "GuiEventBackgroundProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
canSave = "1";
canSaveDynamicFields = "0";
new GuiTextCtrl() {
text = "Input Monitor Settings/Joystick Devices";
maxLength = "255";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "12 4";
extent = "578 20";
minExtent = "8 8";
horizSizing = "width";
vertSizing = "bottom";
profile = "GuiMenuButtonProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
canSave = "1";
canSaveDynamicFields = "0";
};
new GuiCheckBoxCtrl() {
text = "pref::Input::JoystickEnabled";
groupNum = "-1";
buttonType = "ToggleButton";
useMouseEvents = "0";
position = "40 28";
extent = "250 20";
minExtent = "8 2";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiEventCheckboxProfile";
visible = "1";
active = "1";
variable = "$pref::Input::JoystickEnabled";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "0";
canSave = "1";
canSaveDynamicFields = "0";
};
new GuiCheckBoxCtrl() {
text = "pref::Input::sdlControllerEnabled";
groupNum = "-1";
buttonType = "ToggleButton";
useMouseEvents = "0";
position = "326 28";
extent = "250 20";
minExtent = "8 2";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiEventCheckboxProfile";
visible = "1";
active = "1";
variable = "$pref::Input::sdlControllerEnabled";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "0";
canSave = "1";
canSaveDynamicFields = "0";
};
new GuiCheckBoxCtrl() {
text = "4 Axis Joystick Split L/R";
groupNum = "-1";
buttonType = "ToggleButton";
useMouseEvents = "0";
position = "40 52";
extent = "206 20";
minExtent = "8 2";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiEventCheckboxProfile";
visible = "1";
active = "1";
variable = "$pref::Input::JoystickSplitAxesLR";
tooltipProfile = "GuiToolTipProfile";
tooltip = "Split axis inputs on 4 axis joysticks. This has no effect on any other device.\n4 Axis joysticks use IDs 0-3 which get mapped to xaxis, yaxis, zaxis and rxaxis. When true, this will increment IDs 2 and 3 so the inputs map to xaxis, yaxis, rxaxis and ryaxis.";
hovertime = "1000";
isContainer = "0";
canSave = "1";
canSaveDynamicFields = "0";
};
new GuiCheckBoxCtrl() {
text = "POV Button Events";
groupNum = "-1";
buttonType = "ToggleButton";
useMouseEvents = "0";
position = "252 52";
extent = "155 20";
minExtent = "8 2";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiEventCheckboxProfile";
visible = "1";
active = "1";
variable = "$pref::Input::JoystickPOVButtons";
tooltipProfile = "GuiToolTipProfile";
tooltip = "(Joystick only) If true, the pov hat will be treated as 4 buttons and make/break events will be generated for upov, dpov, lpov and rpov.";
hovertime = "1000";
isContainer = "0";
canSave = "1";
canSaveDynamicFields = "0";
};
new GuiCheckBoxCtrl() {
text = "POV Mask Events";
groupNum = "-1";
buttonType = "ToggleButton";
useMouseEvents = "0";
position = "420 52";
extent = "156 20";
minExtent = "8 2";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiEventCheckboxProfile";
visible = "1";
active = "1";
variable = "$pref::Input::JoystickPOVMask";
tooltipProfile = "GuiToolTipProfile";
tooltip = "(Joystick only) If true, the pov hat will be treated as a single input with a 4 bit mask value. The povmask event will be generated with the current mask every time the mask value changes.";
hovertime = "1000";
isContainer = "0";
canSave = "1";
canSaveDynamicFields = "0";
};
new GuiTextCtrl() {
text = "Input Monitor Axis Deadzone";
maxLength = "255";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "40 76";
extent = "208 20";
minExtent = "8 8";
horizSizing = "width";
vertSizing = "bottom";
profile = "GuiEventCheckboxProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
canSave = "1";
canSaveDynamicFields = "0";
};
new GuiSliderCtrl() {
range = "0 1";
ticks = "0";
snap = "0";
value = "0";
position = "256 80";
extent = "215 20";
minExtent = "8 2";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiSliderProfile";
visible = "1";
active = "1";
variable = "InputMonitorDlg.axisDeadzone";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "0";
canSave = "1";
canSaveDynamicFields = "0";
};
new GuiTextCtrl() {
text = "0";
maxLength = "255";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "476 76";
extent = "100 20";
minExtent = "8 8";
horizSizing = "width";
vertSizing = "bottom";
profile = "GuiEventCheckboxProfile";
visible = "1";
active = "1";
variable = "InputMonitorDlg.axisDeadzone";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
canSave = "1";
canSaveDynamicFields = "0";
};
new GuiScrollCtrl(IEMDeviceScroll) {
willFirstRespond = "1";
hScrollBar = "alwaysOff";
vScrollBar = "dynamic";
lockHorizScroll = "0";
lockVertScroll = "0";
constantThumbHeight = "0";
childMargin = "0 0";
mouseWheelScrollSpeed = "-1";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "12 100";
extent = "578 268";
minExtent = "8 2";
horizSizing = "right";
vertSizing = "bottom";
profile = "ConsoleScrollProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
canSave = "1";
canSaveDynamicFields = "0";
new GuiDynamicCtrlArrayControl() {
colCount = "0";
colSize = "562";
rowCount = "0";
rowSize = "132";
rowSpacing = "2";
colSpacing = "0";
frozen = "0";
autoCellSize = "0";
fillRowFirst = "1";
dynamicSize = "1";
padding = "0 0 0 0";
position = "1 1";
extent = "566 189";
minExtent = "8 2";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiDefaultProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
internalName = "deviceArray";
canSave = "1";
canSaveDynamicFields = "0";
};
};
new GuiContainer(DevicePrototype) {
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "0 0";
extent = "562 132";
minExtent = "8 2";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiEventBorderProfile";
visible = "0";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
hidden = "1";
canSave = "1";
canSaveDynamicFields = "0";
new GuiTextCtrl() {
text = "";
maxLength = "255";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "8 8";
extent = "386 20";
minExtent = "8 8";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiEventCheckboxProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
internalName = "DeviceName";
canSave = "1";
canSaveDynamicFields = "0";
};
new GuiTextCtrl() {
text = "";
maxLength = "255";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "384 8";
extent = "166 20";
minExtent = "8 8";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiEventTextProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
internalName = "DeviceOpen";
canSave = "1";
canSaveDynamicFields = "0";
};
new GuiTextCtrl() {
text = "";
maxLength = "255";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "24 32";
extent = "530 20";
minExtent = "8 8";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiEventTextProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
internalName = "DeviceGUID";
canSave = "1";
canSaveDynamicFields = "0";
};
new GuiTextCtrl() {
text = "";
maxLength = "255";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "24 56";
extent = "530 20";
minExtent = "8 8";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiEventTextProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
internalName = "DeviceSpecs";
canSave = "1";
canSaveDynamicFields = "0";
};
new GuiTextCtrl() {
text = "";
maxLength = "255";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "24 80";
extent = "530 20";
minExtent = "8 8";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiEventTextProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
internalName = "DeviceDetails";
canSave = "1";
canSaveDynamicFields = "0";
};
new GuiButtonCtrl() {
text = "Open as Joystick";
groupNum = "-1";
buttonType = "PushButton";
useMouseEvents = "0";
position = "30 104";
extent = "240 24";
minExtent = "8 8";
horizSizing = "right";
vertSizing = "top";
profile = "GuiMenuButtonProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "0";
internalName = "button1";
canSave = "1";
canSaveDynamicFields = "0";
};
new GuiButtonCtrl() {
text = "Open as Game Controller";
groupNum = "-1";
buttonType = "PushButton";
useMouseEvents = "0";
position = "292 104";
extent = "240 24";
minExtent = "8 8";
horizSizing = "left";
vertSizing = "top";
profile = "GuiMenuButtonProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "0";
internalName = "button2";
canSave = "1";
canSaveDynamicFields = "0";
};
};
new GuiButtonCtrl() {
text = "Done";
groupNum = "-1";
buttonType = "PushButton";
useMouseEvents = "0";
position = "260 376";
extent = "80 24";
minExtent = "8 8";
horizSizing = "center";
vertSizing = "top";
profile = "GuiMenuButtonProfile";
visible = "1";
active = "1";
command = "JoystickSettingsDlg.closeSettings();";
accelerator = "escape";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "0";
canSave = "1";
canSaveDynamicFields = "0";
};
};
};
//--- OBJECT WRITE END ---

View file

@ -0,0 +1,82 @@
function InputMonitorDlg::onWake(%this)
{
if ((%this.maxLines $= "") || (%this.maxLines < 10))
%this.maxLines = 500;
if (%this.axisDeadzone $= "")
%this.axisDeadzone = 0.1;
if (!isObject(InputEventVector))
new MessageVector(InputEventVector);
InputEventVector.clear();
EventVectorCtrl.attach(InputEventVector);
%this.updateDevicesLine();
}
function InputMonitorDlg::updateDevicesLine(%this)
{
%sdlDevices = 0;
if (isMethod("SDLInputManager", "numJoysticks"))
%sdlDevices = SDLInputManager::numJoysticks();
%openDevices = 0;
for (%i = 0; %i < %sdlDevices; %i++)
{
%openState = SDLInputManager::getDeviceOpenState(%i);
if (%openState > 0)
%openDevices++;
}
%this.setDevicesLine(%openDevices, %sdlDevices);
}
function InputMonitorDlg::setDevicesLine(%this, %openDevices, %sdlDevices)
{
%text = %openDevices @ " of " @ %sdlDevices @ " Joystick devices opened";
%this-->devicesLine.setText(%text);
}
function InputMonitorCtrl::onInputEvent(%this, %device, %action, %state)
{
%text = %device @ ", " @ %action @ (%state ? " Make" : " Break");
if (InputEventVector.getNumLines() > InputMonitorDlg.maxLines)
InputEventVector.popFrontLine();
InputEventVector.pushBackLine(%text, 0);
// Test for the reserved keystrokes:
if (%device $= "keyboard")
{
// Cancel...
if (%action $= "escape")
{
Canvas.popDialog(InputMonitorDlg);
return;
}
// Settings...
if ((%action $= "f2") && %state)
{
Canvas.popDialog(InputMonitorDlg);
Canvas.pushDialog(JoystickSettingsDlg);
}
}
}
function InputMonitorCtrl::onAxisEvent(%this, %device, %action, %axisValue)
{
if (mAbs(%axisValue) < InputMonitorDlg.axisDeadzone)
{
if (%this.lastZero[%device@%action])
return;
%this.lastZero[%device@%action] = true;
%axisValue = 0;
}
else
%this.lastZero[%device@%action] = false;
%text = %device @ ", " @ %action SPC %axisValue;
if (InputEventVector.getNumLines() > InputMonitorDlg.maxLines)
InputEventVector.popFrontLine();
InputEventVector.pushBackLine(%text, 0);
}

View file

@ -0,0 +1,106 @@
function JoystickSettingsDlg::onWake(%this)
{
%this.updateDevices();
}
function JoystickSettingsDlg::closeSettings(%this)
{
Canvas.popDialog(%this);
Canvas.pushDialog(InputMonitorDlg);
}
function JoystickSettingsDlg::updateDevices(%this)
{
%this-->deviceArray.deleteAllObjects();
%sdlDevices = 0;
if (isMethod("SDLInputManager", "numJoysticks"))
%sdlDevices = SDLInputManager::numJoysticks();
for (%i = 0; %i < %sdlDevices; %i++)
{
%guiCtrl = DevicePrototype.deepClone();
%this-->deviceArray.addGuiControl(%guiCtrl);
%guiCtrl.visible = true;
%guiCtrl.canSave = false;
%openState = SDLInputManager::getDeviceOpenState(%i);
if (%openState > 0)
{
%torqueInst = SDLInputManager::getTorqueInstFromDevice(%i);
%stateStr = "Opened as " @ %torqueInst;
}
else
%stateStr = "Closed";
%guiCtrl->DeviceOpen.setText(%stateStr);
if (%openState == 2)
%deviceName = SDLInputManager::ControllerNameForIndex(%i);
else
%deviceName = SDLInputManager::JoystickNameForIndex(%i);
%guiCtrl->DeviceName.setText(%deviceName);
%guidStr = SDLInputManager::JoystickGetGUID(%i);
%guiCtrl->DeviceGUID.setText("GUID: " @ %guidStr);
// Note: all of the device values could be retrieved individually with:
// SDLInputManager::JoystickNumAxes(%i), SDLInputManager::JoystickNumButtons(%i),
// SDLInputManager::JoystickNumHats(%i), SDLInputManager::JoystickNumBalls(%i),
// SDLInputManager::JoystickIsHaptic(%i), SDLInputManager::JoystickPowerLevel(%i)
//
%deviceSpecs = SDLInputManager::JoystickGetSpecs(%i);
%vendorId = SDLInputManager::GetVendor(%i);
%productId = SDLInputManager::GetProduct(%i);
%productVersion = SDLInputManager::GetProductVersion(%i);
%specStr = getField(%deviceSpecs,0) @ " Axes, " @ getField(%deviceSpecs, 1) @ " Buttons, ";
%specStr = %specStr @ getField(%deviceSpecs, 2) @ " POV Hats, " @ getField(%deviceSpecs, 3) @ " Trackballs, ";
if (getField(%deviceSpecs, 5))
%specStr = %specStr @ "Haptic, ";
%powerLevel = getField(%deviceSpecs, 6);
if (%powerLevel $= "Wired")
%specStr = %specStr @ "Wired";
else
%specStr = %specStr @ "Battery: " @ %powerLevel;
%guiCtrl->DeviceSpecs.setText(%specStr);
%isController = getField(%deviceSpecs, 4);
%deviceType = getField(%deviceSpecs, 7);
%details = "Type: " @ %deviceType @ ", Vendor ID: " @ %vendorId;
%details = %details @ ", Product ID: " @ %productId @ ", Version: " @ %productVersion;
%guiCtrl->DeviceDetails.setText(%details);
// Setup Buttons
if (%openState > 0)
{
%guiCtrl->button2.setText("Close Device");
%guiCtrl->button2.visible = true;
%guiCtrl->button2.command = "SDLInputManager::closeDevice(" @ %i @ ");";
if (%openState == 2)
{
%guiCtrl->button1.setText("Open as Joystick");
%guiCtrl->button1.visible = true;
%guiCtrl->button1.command = "SDLInputManager::openAsJoystick(" @ %i @ ");";
}
else
{
%guiCtrl->button1.setText("Open as Game Controller");
%guiCtrl->button1.visible = true;
%guiCtrl->button1.command = "SDLInputManager::openAsController(" @ %i @ ");";
}
}
else
{
%guiCtrl->button1.setText("Open as Joystick");
%guiCtrl->button1.visible = true;
%guiCtrl->button1.command = "SDLInputManager::openAsJoystick(" @ %i @ ");";
%guiCtrl->button2.setText("Open as Game Controller");
%guiCtrl->button2.visible = true;
%guiCtrl->button2.command = "SDLInputManager::openAsController(" @ %i @ ");";
}
// After the command executes, refresh this device list
%guiCtrl->button1.command = %guiCtrl->button1.command @ "JoystickSettingsDlg.updateDevices();";
%guiCtrl->button2.command = %guiCtrl->button2.command @ "JoystickSettingsDlg.updateDevices();";
}
}