RailWorks_Joystick_API/RailWorks_Joystick_API/Globals.cs
2015-06-18 16:44:44 +00:00

62 lines
1.9 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace RailWorks_Joystick_API {
class Globals {
public static Joystick JoyDevices;
public static List<String> DeviceNames;
public static InputHandler IHandler;
public static TextBox DevStatus;
public static int DevStatusID = -1;
public static frmManageControls ControlManager = new frmManageControls();
public static frmControls ControlsWindow = new frmControls();
public static frmSpeedo SpeedoWindow = new frmSpeedo();
public delegate void UpdateDeviceDebugDelegate(int DeviceID);
public static float Clamp(float Value, float MinValue, float MaxValue) {
return Math.Max(MinValue, Math.Min(MaxValue, Value));
}
public static int Clamp(int Value, int MinValue, int MaxValue) {
return Math.Max(MinValue, Math.Min(MaxValue, Value));
}
public static void AxisChanged(string DeviceName, int DeviceID, string AxisName, int NewValue, int Delta) {
IHandler.UpdateAxis(DeviceID, AxisName, NewValue, Delta);
UpdateDeviceDebugDelegate Del = (zahl) => UpdateDeviceDebug(DeviceID);
DevStatus.Invoke(Del, DeviceID);
}
public static void ButtonChanged(string DeviceName, int DeviceID, string ButtonName, int NewValue, int Delta) {
IHandler.UpdateButton(DeviceID, ButtonName, NewValue, Delta);
UpdateDeviceDebugDelegate Del = (zahl) => UpdateDeviceDebug(DeviceID);
DevStatus.Invoke(Del, DeviceID);
}
public static void UpdateDeviceDebug(int DeviceID) {
if((DevStatusID == -1)) {
DevStatus.Text = IHandler.Devices[DeviceID].ToString();
} else if((DevStatusID == DeviceID)) {
DevStatus.Text = IHandler.Devices[DeviceID].ToString();
}
}
public static string IntToStr(int Int) {
return Int.ToString();
}
}
}