Exemple #1
0
        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);
        }
Exemple #2
0
        private void _SetStatuses()
        {
            //Determine if PS3 tablet exists
            if (PS3InputDevice.IsDetected())
            {
                grpPS3.Enabled         = true;
                lblPS3Tablet.ForeColor = Color.Green;
            }
            else
            {
                grpPS3.Enabled = false;
            }

            flpWiiTablets.Controls.Clear();
            if (WiiInputDevice.IsDetected())
            {
                foreach (var tablet in MouseInterface.Tablets)
                {
                    var wiiTablet = tablet.Tablet as WiiInputDevice;
                    if (wiiTablet != null)
                    {
                        var ctl = new WiiTabletDevice(wiiTablet.Index.GetValueOrDefault());
                        flpWiiTablets.Controls.Add(ctl);
                        ctl.Anchor         = AnchorStyles.Left | AnchorStyles.Right;
                        ctl.ButtonClicked += btnSlotSettings_Click;
                    }
                }
            }

            //Determine if 360 wireless receiver is connected
            if (MouseInterface.Receiver != null && MouseInterface.Receiver.IsReceiverConnected)
            {
                grp360.Enabled           = true;
                lbl360Receiver.ForeColor = Color.Green;

                foreach (var slot in _slots)
                {
                    if (MouseInterface.Receiver.IsDeviceConnected(slot.Index))
                    {
                        var description = "N/A";
                        var info        = MouseInterface.Receiver.GetDeviceInformation(slot.Index);
                        if (info != null)
                        {
                            switch (info.Subtype)
                            {
                            case Xbox360USB.WirelessReceiver.DeviceSubtype.Controller:
                            {
                                description = "Controller: " + info.ToString();
                                break;
                            }

                            case Xbox360USB.WirelessReceiver.DeviceSubtype.uDrawTablet:
                            {
                                description = "uDraw GameTablet: " + info.ToString();
                                break;
                            }

                            default:
                                description = "Unknown Device";
                                break;
                            }
                        }

                        slot.Label.ForeColor = Color.Green;
                        slot.Label.Text      = String.Format("Slot {0}: {1}", slot.Index, description);
                        slot.Button.Enabled  = true;
                    }
                    else
                    {
                        slot.Label.ForeColor = Color.Red;
                        slot.Label.Text      = String.Format("Slot {0}: N/A", slot.Index);
                        slot.Button.Enabled  = false;
                    }
                }
            }
            else
            {
                grp360.Enabled = false;
            }
        }