public TabletConnection(IInputDevice tablet, WirelessReceiver receiver, int index) { Tablet = tablet; Receiver = receiver; ReceiverIndex = index; Settings = new TabletSettings(); }
public static void ReloadSettings() { foreach (var t in Tablets) { t.Settings = TabletSettings.LoadSettings(GetSettingsFileName( t.Tablet as PS3InputDevice != null, t.ReceiverIndex)); } }
public TabletOptions(bool isController, string iniFileName, TabletSettings settings) { InitializeComponent(); _isController = isController; _iniFileName = iniFileName; _settings = settings; _Init(); }
public static void Start(Options options) { Stop(); _frmOptions = options; _keyCounters = new Dictionary <TabletOptionButton.TabletButton, Dictionary <int, int> >(); foreach (TabletOptionButton.TabletButton button in Enum.GetValues(typeof(TabletOptionButton.TabletButton))) { _keyCounters.Add(button, new Dictionary <int, int>()); } _modifierCounters = new Dictionary <Keypress.ModifierKeyCode, int>(); foreach (Keypress.ModifierKeyCode code in Enum.GetValues(typeof(Keypress.ModifierKeyCode))) { _modifierCounters.Add(code, 0); } //Set up Xbox 360 USB wireless receiver if (Receiver == null || !Receiver.IsReceiverConnected) { Receiver = new Xbox360USB.WirelessReceiver(); Receiver.DeviceConnected += Receiver_DeviceConnected; Receiver.DeviceDisconnected += Receiver_DeviceDisconnected; Receiver.Start(); } //Set up the PS3 tablet dongle var conn = new TabletConnection((new PS3InputDevice()) as IInputDevice); conn.ButtonStateChanged += _ButtonStateChanged; conn.DPadStateChanged += _DPadStateChanged; conn.Settings = TabletSettings.LoadSettings(GetSettingsFileName(false, true, null)); Tablets.Add(conn); //Set up the Wii tablet(s) var devices = WiiInputDevice.GetAllDevices(); int i = 0; foreach (var dev in devices) { conn = new TabletConnection((new WiiInputDevice(dev, i))); conn.ButtonStateChanged += _ButtonStateChanged; conn.DPadStateChanged += _DPadStateChanged; conn.Settings = TabletSettings.LoadSettings(GetSettingsFileName(true, false, null)); Tablets.Add(conn); i++; } //Set up the event timer _timer = new System.Threading.Timer(new TimerCallback(_HandleTabletEvents), null, 0, 1); }
private static void _Handle360TabletConnect(int index) { _Handle360TabletDisconnect(index); var connection = new TabletConnection((new Xbox360InputDevice(Receiver, index, Receiver.GetDeviceInformation(index))) as IInputDevice, Receiver, index); connection.ButtonStateChanged += _ButtonStateChanged; connection.DPadStateChanged += _DPadStateChanged; connection.ChatpadKeyStateChanged += _ChatpadKeyStateChanged; connection.ShiftPressed += _ShiftPressed; connection.PeoplePressed += _PeoplePressed; Tablets.Add(connection); connection.Settings = TabletSettings.LoadSettings(GetSettingsFileName(false, index)); }
private void btnSlotSettings_Click(object sender, EventArgs e) { //Find out which one we're dealing with bool isPS3 = (sender == btnPS3Settings); bool isController = false; int? index = null; if (!isPS3) { //Find which 360 slot foreach (var slot in _slots) { if (sender == slot.Button) { index = slot.Index; break; } } if (MouseInterface.Receiver != null) { var info = MouseInterface.Receiver.GetDeviceInformation(index.Value); if (info != null) { isController = (info.Subtype == Xbox360USB.WirelessReceiver.DeviceSubtype.Controller); } } } string fileName = MouseInterface.GetSettingsFileName(isPS3, index); if (!String.IsNullOrEmpty(fileName)) { var frm = new TabletOptions(isController, fileName, TabletSettings.LoadSettings(fileName)); frm.ShowDialog(); frm.Dispose(); MouseInterface.ReloadSettings(); } }
public TabletConnection(IInputDevice tablet) { Tablet = tablet; Settings = new TabletSettings(); }
public static TabletSettings LoadSettings(string iniFileName) { var ret = new TabletSettings(); //Pen pressure threshold var sb = new StringBuilder(255); GetPrivateProfileString(_DEFAULT_SECTION, _KEY_PEN_THRESHOLD, ret.PenPressureThreshold.ToString(), sb, sb.Capacity, Path.Combine(Directory.GetCurrentDirectory(), iniFileName)); int threshold = ret.PenPressureThreshold; int.TryParse(sb.ToString(), out threshold); ret.PenPressureThreshold = threshold; //Allow finger movement sb = new StringBuilder(255); GetPrivateProfileString(_DEFAULT_SECTION, _KEY_ALLOW_FINGER_MOVEMENT, ret.AllowFingerMovement.ToString(), sb, sb.Capacity, Path.Combine(Directory.GetCurrentDirectory(), iniFileName)); bool allowFingerMovement = ret.AllowFingerMovement; bool.TryParse(sb.ToString(), out allowFingerMovement); ret.AllowFingerMovement = allowFingerMovement; //Movement type sb = new StringBuilder(255); GetPrivateProfileString(_DEFAULT_SECTION, _KEY_MOVEMENT_TYPE, ret.MovementType.ToString(), sb, sb.Capacity, Path.Combine(Directory.GetCurrentDirectory(), iniFileName)); var type = ret.MovementType; type = (TabletMovementType)Enum.Parse(typeof(TabletMovementType), sb.ToString()); ret.MovementType = type; //Movement speed sb = new StringBuilder(255); GetPrivateProfileString(_DEFAULT_SECTION, _KEY_MOVEMENT_SPEED, ret.MovementSpeed.ToString(), sb, sb.Capacity, Path.Combine(Directory.GetCurrentDirectory(), iniFileName)); int speed = ret.MovementSpeed; int.TryParse(sb.ToString(), out speed); ret.MovementSpeed = speed; //Movement precision sb = new StringBuilder(255); GetPrivateProfileString(_DEFAULT_SECTION, _KEY_PRECISION, ret.Precision.ToString(), sb, sb.Capacity, Path.Combine(Directory.GetCurrentDirectory(), iniFileName)); int precision = ret.Precision; int.TryParse(sb.ToString(), out precision); ret.Precision = precision; //Actions ret.AAction = _GetAction(iniFileName, _KEY_A_ACTION, _DEFAULT_A_ACTION); ret.AFile = _GetString(iniFileName, _KEY_A_FILE); ret.BAction = _GetAction(iniFileName, _KEY_B_ACTION, _DEFAULT_B_ACTION); ret.BFile = _GetString(iniFileName, _KEY_B_FILE); ret.XAction = _GetAction(iniFileName, _KEY_X_ACTION, _DEFAULT_X_ACTION); ret.XFile = _GetString(iniFileName, _KEY_X_FILE); ret.YAction = _GetAction(iniFileName, _KEY_Y_ACTION, _DEFAULT_Y_ACTION); ret.YFile = _GetString(iniFileName, _KEY_Y_FILE); ret.UpAction = _GetAction(iniFileName, _KEY_UP_ACTION, _DEFAULT_UP_ACTION); ret.UpFile = _GetString(iniFileName, _KEY_UP_FILE); ret.DownAction = _GetAction(iniFileName, _KEY_DOWN_ACTION, _DEFAULT_DOWN_ACTION); ret.DownFile = _GetString(iniFileName, _KEY_DOWN_FILE); ret.LeftAction = _GetAction(iniFileName, _KEY_LEFT_ACTION, _DEFAULT_LEFT_ACTION); ret.LeftFile = _GetString(iniFileName, _KEY_LEFT_FILE); ret.RightAction = _GetAction(iniFileName, _KEY_RIGHT_ACTION, _DEFAULT_RIGHT_ACTION); ret.RightFile = _GetString(iniFileName, _KEY_RIGHT_FILE); ret.StartAction = _GetAction(iniFileName, _KEY_START_ACTION, _DEFAULT_START_ACTION); ret.StartFile = _GetString(iniFileName, _KEY_START_FILE); ret.BackAction = _GetAction(iniFileName, _KEY_BACK_ACTION, _DEFAULT_BACK_ACTION); ret.BackFile = _GetString(iniFileName, _KEY_BACK_FILE); ret.GuideAction = _GetAction(iniFileName, _KEY_GUIDE_ACTION, _DEFAULT_GUIDE_ACTION); ret.GuideFile = _GetString(iniFileName, _KEY_GUIDE_FILE); ret.ClickAction = _GetAction(iniFileName, _KEY_CLICK_ACTION, _DEFAULT_CLICK_ACTION); ret.ClickFile = _GetString(iniFileName, _KEY_CLICK_FILE); ret.PeopleAction = _GetAction(iniFileName, _KEY_PEOPLE_ACTION, _DEFAULT_PEOPLE_ACTION); ret.PeopleFile = _GetString(iniFileName, _KEY_PEOPLE_FILE); //Display name sb = new StringBuilder(255); GetPrivateProfileString(_DEFAULT_SECTION, _KEY_CURRENT_DISPLAY, ret.CurrentDisplay.ToString(), sb, sb.Capacity, Path.Combine(Directory.GetCurrentDirectory(), iniFileName)); ret.CurrentDisplay = sb.ToString(); //Allow all displays sb = new StringBuilder(255); GetPrivateProfileString(_DEFAULT_SECTION, _KEY_ALLOW_ALL_DISPLAYS, ret.AllowAllDisplays.ToString(), sb, sb.Capacity, Path.Combine(Directory.GetCurrentDirectory(), iniFileName)); bool allowAllDisplays = ret.AllowAllDisplays; bool.TryParse(sb.ToString(), out allowAllDisplays); ret.AllowAllDisplays = allowAllDisplays; //Maintain aspect ratio sb = new StringBuilder(255); GetPrivateProfileString(_DEFAULT_SECTION, _KEY_MAINTAIN_ASPECT_RATIO, ret.MaintainAspectRatio.ToString(), sb, sb.Capacity, Path.Combine(Directory.GetCurrentDirectory(), iniFileName)); bool maintainAspectRatio = ret.MaintainAspectRatio; bool.TryParse(sb.ToString(), out maintainAspectRatio); ret.MaintainAspectRatio = maintainAspectRatio; //Restrict to current window sb = new StringBuilder(255); GetPrivateProfileString(_DEFAULT_SECTION, _KEY_RESTRICT_TO_CURRENT_WINDOW, ret.RestrictToCurrentWindow.ToString(), sb, sb.Capacity, Path.Combine(Directory.GetCurrentDirectory(), iniFileName)); bool restrictToCurrentWindow = ret.RestrictToCurrentWindow; bool.TryParse(sb.ToString(), out restrictToCurrentWindow); ret.RestrictToCurrentWindow = restrictToCurrentWindow; //Horizontal dock sb = new StringBuilder(255); GetPrivateProfileString(_DEFAULT_SECTION, _KEY_HORIZONTAL_DOCK, ret.HorizontalDock.ToString(), sb, sb.Capacity, Path.Combine(Directory.GetCurrentDirectory(), iniFileName)); var hdock = ret.HorizontalDock; hdock = (DockOption.DockOptionValue)Enum.Parse(typeof(DockOption.DockOptionValue), sb.ToString()); ret.HorizontalDock = hdock; //Vertical dock sb = new StringBuilder(255); GetPrivateProfileString(_DEFAULT_SECTION, _KEY_VERTICAL_DOCK, ret.VerticalDock.ToString(), sb, sb.Capacity, Path.Combine(Directory.GetCurrentDirectory(), iniFileName)); var vdock = ret.VerticalDock; vdock = (DockOption.DockOptionValue)Enum.Parse(typeof(DockOption.DockOptionValue), sb.ToString()); ret.VerticalDock = vdock; //PPJoy virtual joystick number sb = new StringBuilder(255); GetPrivateProfileString(_DEFAULT_SECTION, _KEY_PPJOY_NUMBER, ret.PPJoyNumber.ToString(), sb, sb.Capacity, Path.Combine(Directory.GetCurrentDirectory(), iniFileName)); int joyNumber = ret.PPJoyNumber; int.TryParse(sb.ToString(), out joyNumber); ret.PPJoyNumber = joyNumber; return(ret); }
public static TabletSettings LoadSettings(string iniFileName) { var ret = new TabletSettings(); //Pen pressure threshold var sb = new StringBuilder(255); GetPrivateProfileString(_DEFAULT_SECTION, _KEY_PEN_THRESHOLD, ret.PenPressureThreshold.ToString(), sb, sb.Capacity, Path.Combine(Directory.GetCurrentDirectory(), iniFileName)); int threshold = ret.PenPressureThreshold; int.TryParse(sb.ToString(), out threshold); ret.PenPressureThreshold = threshold; //Allow finger movement sb = new StringBuilder(255); GetPrivateProfileString(_DEFAULT_SECTION, _KEY_ALLOW_FINGER_MOVEMENT, ret.AllowFingerMovement.ToString(), sb, sb.Capacity, Path.Combine(Directory.GetCurrentDirectory(), iniFileName)); bool allowFingerMovement = ret.AllowFingerMovement; bool.TryParse(sb.ToString(), out allowFingerMovement); ret.AllowFingerMovement = allowFingerMovement; //Movement type sb = new StringBuilder(255); GetPrivateProfileString(_DEFAULT_SECTION, _KEY_MOVEMENT_TYPE, ret.MovementType.ToString(), sb, sb.Capacity, Path.Combine(Directory.GetCurrentDirectory(), iniFileName)); var type = ret.MovementType; type = (TabletMovementType)Enum.Parse(typeof(TabletMovementType), sb.ToString()); ret.MovementType = type; //Movement speed sb = new StringBuilder(255); GetPrivateProfileString(_DEFAULT_SECTION, _KEY_MOVEMENT_SPEED, ret.MovementSpeed.ToString(), sb, sb.Capacity, Path.Combine(Directory.GetCurrentDirectory(), iniFileName)); int speed = ret.MovementSpeed; int.TryParse(sb.ToString(), out speed); ret.MovementSpeed = speed; //Movement precision sb = new StringBuilder(255); GetPrivateProfileString(_DEFAULT_SECTION, _KEY_PRECISION, ret.Precision.ToString(), sb, sb.Capacity, Path.Combine(Directory.GetCurrentDirectory(), iniFileName)); int precision = ret.Precision; int.TryParse(sb.ToString(), out precision); ret.Precision = precision; //Actions ret.AAction = _GetAction(iniFileName, _KEY_A_ACTION, _DEFAULT_A_ACTION); ret.AFile = _GetString(iniFileName, _KEY_A_FILE); ret.BAction = _GetAction(iniFileName, _KEY_B_ACTION, _DEFAULT_B_ACTION); ret.BFile = _GetString(iniFileName, _KEY_B_FILE); ret.XAction = _GetAction(iniFileName, _KEY_X_ACTION, _DEFAULT_X_ACTION); ret.XFile = _GetString(iniFileName, _KEY_X_FILE); ret.YAction = _GetAction(iniFileName, _KEY_Y_ACTION, _DEFAULT_Y_ACTION); ret.YFile = _GetString(iniFileName, _KEY_Y_FILE); ret.UpAction = _GetAction(iniFileName, _KEY_UP_ACTION, _DEFAULT_UP_ACTION); ret.UpFile = _GetString(iniFileName, _KEY_UP_FILE); ret.DownAction = _GetAction(iniFileName, _KEY_DOWN_ACTION, _DEFAULT_DOWN_ACTION); ret.DownFile = _GetString(iniFileName, _KEY_DOWN_FILE); ret.LeftAction = _GetAction(iniFileName, _KEY_LEFT_ACTION, _DEFAULT_LEFT_ACTION); ret.LeftFile = _GetString(iniFileName, _KEY_LEFT_FILE); ret.RightAction = _GetAction(iniFileName, _KEY_RIGHT_ACTION, _DEFAULT_RIGHT_ACTION); ret.RightFile = _GetString(iniFileName, _KEY_RIGHT_FILE); ret.StartAction = _GetAction(iniFileName, _KEY_START_ACTION, _DEFAULT_START_ACTION); ret.StartFile = _GetString(iniFileName, _KEY_START_FILE); ret.BackAction = _GetAction(iniFileName, _KEY_BACK_ACTION, _DEFAULT_BACK_ACTION); ret.BackFile = _GetString(iniFileName, _KEY_BACK_FILE); ret.GuideAction = _GetAction(iniFileName, _KEY_GUIDE_ACTION, _DEFAULT_GUIDE_ACTION); ret.GuideFile = _GetString(iniFileName, _KEY_GUIDE_FILE); ret.ClickAction = _GetAction(iniFileName, _KEY_CLICK_ACTION, _DEFAULT_CLICK_ACTION); ret.ClickFile = _GetString(iniFileName, _KEY_CLICK_FILE); ret.PeopleAction = _GetAction(iniFileName, _KEY_PEOPLE_ACTION, _DEFAULT_PEOPLE_ACTION); ret.PeopleFile = _GetString(iniFileName, _KEY_PEOPLE_FILE); //Display name sb = new StringBuilder(255); GetPrivateProfileString(_DEFAULT_SECTION, _KEY_CURRENT_DISPLAY, ret.CurrentDisplay.ToString(), sb, sb.Capacity, Path.Combine(Directory.GetCurrentDirectory(), iniFileName)); ret.CurrentDisplay = sb.ToString(); //Allow all displays sb = new StringBuilder(255); GetPrivateProfileString(_DEFAULT_SECTION, _KEY_ALLOW_ALL_DISPLAYS, ret.AllowAllDisplays.ToString(), sb, sb.Capacity, Path.Combine(Directory.GetCurrentDirectory(), iniFileName)); bool allowAllDisplays = ret.AllowAllDisplays; bool.TryParse(sb.ToString(), out allowAllDisplays); ret.AllowAllDisplays = allowAllDisplays; //Maintain aspect ratio sb = new StringBuilder(255); GetPrivateProfileString(_DEFAULT_SECTION, _KEY_MAINTAIN_ASPECT_RATIO, ret.MaintainAspectRatio.ToString(), sb, sb.Capacity, Path.Combine(Directory.GetCurrentDirectory(), iniFileName)); bool maintainAspectRatio = ret.MaintainAspectRatio; bool.TryParse(sb.ToString(), out maintainAspectRatio); ret.MaintainAspectRatio = maintainAspectRatio; //Restrict to current window sb = new StringBuilder(255); GetPrivateProfileString(_DEFAULT_SECTION, _KEY_RESTRICT_TO_CURRENT_WINDOW, ret.RestrictToCurrentWindow.ToString(), sb, sb.Capacity, Path.Combine(Directory.GetCurrentDirectory(), iniFileName)); bool restrictToCurrentWindow = ret.RestrictToCurrentWindow; bool.TryParse(sb.ToString(), out restrictToCurrentWindow); ret.RestrictToCurrentWindow = restrictToCurrentWindow; //Horizontal dock sb = new StringBuilder(255); GetPrivateProfileString(_DEFAULT_SECTION, _KEY_HORIZONTAL_DOCK, ret.HorizontalDock.ToString(), sb, sb.Capacity, Path.Combine(Directory.GetCurrentDirectory(), iniFileName)); var hdock = ret.HorizontalDock; hdock = (DockOption.DockOptionValue)Enum.Parse(typeof(DockOption.DockOptionValue), sb.ToString()); ret.HorizontalDock = hdock; //Vertical dock sb = new StringBuilder(255); GetPrivateProfileString(_DEFAULT_SECTION, _KEY_VERTICAL_DOCK, ret.VerticalDock.ToString(), sb, sb.Capacity, Path.Combine(Directory.GetCurrentDirectory(), iniFileName)); var vdock = ret.VerticalDock; vdock = (DockOption.DockOptionValue)Enum.Parse(typeof(DockOption.DockOptionValue), sb.ToString()); ret.VerticalDock = vdock; //PPJoy virtual joystick number sb = new StringBuilder(255); GetPrivateProfileString(_DEFAULT_SECTION, _KEY_PPJOY_NUMBER, ret.PPJoyNumber.ToString(), sb, sb.Capacity, Path.Combine(Directory.GetCurrentDirectory(), iniFileName)); int joyNumber = ret.PPJoyNumber; int.TryParse(sb.ToString(), out joyNumber); ret.PPJoyNumber = joyNumber; return ret; }