LcdInit() private method

private LcdInit ( ) : uint
return uint
Ejemplo n.º 1
0
        public LCDForm()
        {
            InitializeComponent();
            if (File.Exists("DMcLgLCD.dll"))
            {
                _LCDUpdateTimer          = new Timer();
                _LCDUpdateTimer.Interval = 34;
                _LCDUpdateTimer.Tick    += _OnLCDUpdate;

                _LCDButtonPressTimer          = new Timer();
                _LCDButtonPressTimer.Interval = 100;
                _LCDButtonPressTimer.Tick    += _OnLCDButtonPressTimer;

                DMcLgLCD.LcdInit();
                var Connection = DMcLgLCD.LcdConnectEx(_appletname, 0, 0);
                if (Connection != DMcLgLCD.LGLCD_INVALID_CONNECTION)
                {
                    _device = DMcLgLCD.LcdOpenByType(Connection, DMcLgLCD.LGLCD_DEVICE_QVGA);
                    if (_device != DMcLgLCD.LGLCD_INVALID_DEVICE)
                    {
                        DMcLgLCD.LcdSetAsLCDForegroundApp(_device, DMcLgLCD.LGLCD_FORE_YES);
                        _LCDUpdateTimer.Start();
                        _LCDButtonPressTimer.Start();
                    }
                }
            }
        }
        private void Kodi_Applet_Load(object sender, EventArgs e)
        {
            if (DMcLgLCD.ERROR_SUCCESS == DMcLgLCD.LcdInit())
            {
                connection = DMcLgLCD.LcdConnectEx("Kodi Media Keys", 0, 0); // Initializes the display with a useful name to identify the application

                if (DMcLgLCD.LGLCD_INVALID_CONNECTION != connection)
                {
                    device = DMcLgLCD.LcdOpenByType(connection, DMcLgLCD.LGLCD_DEVICE_QVGA);

                    if (DMcLgLCD.LGLCD_INVALID_DEVICE == device) // Determines whether or not the keyboard is a G15 or G19 (currently the application is only tested on a G15)
                    {
                        device = DMcLgLCD.LcdOpenByType(connection, DMcLgLCD.LGLCD_DEVICE_BW);
                        if (DMcLgLCD.LGLCD_INVALID_DEVICE != device)
                        {
                            deviceType = DMcLgLCD.LGLCD_DEVICE_BW;
                        }
                    }
                    else
                    {
                        deviceType = DMcLgLCD.LGLCD_DEVICE_QVGA;
                    }

                    if (DMcLgLCD.LGLCD_DEVICE_BW == deviceType)
                    {
                        LCD = new Bitmap(160, 43); // Sets the screen size of the keyboard display
                        Graphics g = Graphics.FromImage(LCD);
                        g.Clear(Color.White);
                        g.Dispose();

                        DMcLgLCD.LcdUpdateBitmap(device, LCD.GetHbitmap(), DMcLgLCD.LGLCD_DEVICE_BW);
                        DMcLgLCD.LcdSetAsLCDForegroundApp(device, DMcLgLCD.LGLCD_FORE_YES);

                        pbLCD.Width  = 160; // Sets the picture box display (that is shown when the user double clicks the icon).
                        pbLCD.Height = 43;
                    }

                    if (deviceType > 0) // Only update the screen if there is a screen to update.
                    {
                        DMcLgLCD.LcdSetConfigCallback(cfgCallback);

                        updateTimer = new System.Timers.Timer(100);

                        updateTimer.Elapsed += new System.Timers.ElapsedEventHandler(OnTimedEvent);

                        updateTimer.Interval = 100; // Wil. update the display every 100ms. Likely only required to use a value of 1000. This is required to update the current song time.
                        updateTimer.Enabled  = true;
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private void Main_Load(object sender, EventArgs e)
        {
            this.LoadConfig();

            if (DMcLgLCD.LcdInit() == DMcLgLCD.ERROR_SUCCESS)
            {
                this.connection = DMcLgLCD.LcdConnectEx("League Of Legends Info", 0, 0);

                if (this.connection != DMcLgLCD.LGLCD_INVALID_CONNECTION)
                {
                    this.device = DMcLgLCD.LcdOpenByType(this.connection, DMcLgLCD.LGLCD_DEVICE_QVGA);

                    if (this.device == DMcLgLCD.LGLCD_INVALID_DEVICE)
                    {
                        this.device = DMcLgLCD.LcdOpenByType(this.connection, DMcLgLCD.LGLCD_DEVICE_BW);
                        if (this.device != DMcLgLCD.LGLCD_INVALID_DEVICE)
                        {
                            this.deviceType = DMcLgLCD.LGLCD_DEVICE_BW;
                        }
                    }
                    else
                    {
                        this.deviceType = DMcLgLCD.LGLCD_DEVICE_QVGA;
                    }

                    if (this.deviceType == DMcLgLCD.LGLCD_DEVICE_QVGA)
                    {
                        this.Screens[LCD_SCREEN_LOADING] = getImage(@"images\splash.jpg");
                        Graphics g = Graphics.FromImage(this.Screens[LCD_SCREEN_LOADING]);
                        g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
                        g.DrawString("Awaiting game launch...", new Font("Arial", 12, FontStyle.Regular, GraphicsUnit.Pixel), Brushes.White, 92, 220);
                        g.Dispose();

                        this.Render();
                    }

                    if (this.deviceType > 0)
                    {
                        this.MainLoopTask(this.tokenSource1.Token);
                    }
                }
            }
        }
        private void frmMain_Load(object sender, EventArgs e)
        {
            if (DMcLgLCD.ERROR_SUCCESS == DMcLgLCD.LcdInit())
            {
                Instance = this;
                LetterMgr.Instance.Init();

                SettingsMgr.Instance.Load();
                if (SettingsMgr.Instance.IsFirstRun)
                {
                    SettingsMgr.Instance.IsFirstRun = false;
                    SettingsMgr.Instance.Save();
                    try
                    {
                        AutoStart.SetAutoStart();
                    }
                    catch
                    {}
                }

                LCDShotFolder = string.Format("{0}/LCD Shots/", Application.StartupPath);
                if (!Directory.Exists(LCDShotFolder))
                {
                    Directory.CreateDirectory(LCDShotFolder);
                }

                Visible       = false;
                ShowInTaskbar = false;

                #region Tray
                if (SettingsMgr.Instance.UseTrayIcon)
                {
                    TrayMenu = new ContextMenu();
                    TrayMenu.MenuItems.Add("Take LCD &Shot", OnLCDShot);
                    TrayMenu.MenuItems.Add("&Config", OnConfig);
                    TrayMenu.MenuItems.Add("-");
                    TrayMenu.MenuItems.Add("&Exit", OnExit);
                    TrayIcon      = new NotifyIcon();
                    TrayIcon.Text = "Learn Japanese";

                    TrayIcon.Icon = new Icon(Application.StartupPath + "/Icon.ico", 32, 32);

                    // Add menu to tray icon and show it.
                    TrayIcon.ContextMenu = TrayMenu;
                    TrayIcon.Visible     = true;
                }
                #endregion

                #region Font

                if (DMcLgLCD.LGLCD_DEVICE_BW == deviceType)
                {
                    GFont = new Font("Arial", 5, FontStyle.Regular);
                }
                else
                {
                    GFont = new Font("Arial", 12, FontStyle.Regular);
                }
                #endregion

                connection = DMcLgLCD.LcdConnectEx("Learn Japanese", 0, 0);

                if (DMcLgLCD.LGLCD_INVALID_CONNECTION != connection)
                {
                    device = DMcLgLCD.LcdOpenByType(connection, DMcLgLCD.LGLCD_DEVICE_QVGA);

                    if (DMcLgLCD.LGLCD_INVALID_DEVICE == device)
                    {
                        device = DMcLgLCD.LcdOpenByType(connection, DMcLgLCD.LGLCD_DEVICE_BW);
                        if (DMcLgLCD.LGLCD_INVALID_DEVICE != device)
                        {
                            deviceType = DMcLgLCD.LGLCD_DEVICE_BW;
                        }
                    }
                    else
                    {
                        deviceType = DMcLgLCD.LGLCD_DEVICE_QVGA;
                    }

                    if (DMcLgLCD.LGLCD_DEVICE_BW == deviceType)
                    {
                        LCD = new Bitmap(160, 43);
                        Graphics g = Graphics.FromImage(LCD);
                        g.Clear(Color.White);
                        g.Dispose();

                        DMcLgLCD.LcdUpdateBitmap(device, LCD.GetHbitmap(), DMcLgLCD.LGLCD_DEVICE_BW);
                        DMcLgLCD.LcdSetAsLCDForegroundApp(device, DMcLgLCD.LGLCD_FORE_YES);
                    }
                    else
                    {
                        LCD = new Bitmap(320, 240);
                        Graphics g = Graphics.FromImage(LCD);
                        g.Clear(Color.White);
                        g.Dispose();

                        DMcLgLCD.LcdUpdateBitmap(device, LCD.GetHbitmap(), DMcLgLCD.LGLCD_DEVICE_QVGA);
                        DMcLgLCD.LcdSetAsLCDForegroundApp(device, DMcLgLCD.LGLCD_FORE_YES);
                    }

                    if (deviceType > 0)
                    {
                        //commented out in favor of polling routine.
                        //DMcLgLCD.LcdSetButtonCallback(btnCallback);
                        DMcLgLCD.LcdSetConfigCallback(cfgCallback);
                        //The fastest you should send updates to the LCD is around 30fps or 34ms.  100ms is probably a good typical update speed.
                        timInput.Enabled = true;
                    }
                    timWorkaround.Enabled = true; // sometimes the LCD just shows a white screen for some reason on startup. this 100ms delay fixes that.
                }
            }
            else
            {
                MessageBox.Show("Error: The G-keyboard was not detected. The application will not close.",
                                "Hardware not found.",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                Close();
            }
        }
Ejemplo n.º 5
0
        public void Awake()
        {
            if (GHudmain != null)
            {
                return;
            }
            GHudmain = this;
            UnityEngine.Object.DontDestroyOnLoad(GHudmain);

            if (!lcd_initialized)
            {
                DMcLgLCD.LcdInit();
                lcd_initialized = true;
            }

            Device bw_dev    = new DeviceBW();
            Device color_dev = new DeviceQVGA();

            if (bw_dev != null && bw_dev.isValid())
            {
                devices.Add(bw_dev);
                OrbitInfo initialbw = new OrbitInfo(bw_dev, "✈", System.Drawing.Color.Black, System.Drawing.Color.Black);
                initialbw.Activate();
                bw_dev.modules.Add(initialbw);


                OrbitInfo targetinfo = new OrbitInfo(bw_dev, "+", System.Drawing.Color.Black, System.Drawing.Color.Black);
                targetinfo.is_target_type_module = true;
                bw_dev.modules.Add(targetinfo);

                bw_dev.modules.Add(new OrbitGraph(bw_dev, System.Drawing.Color.Yellow, "✈"));
                OrbitGraph tgt_orbitgraph = new OrbitGraph(bw_dev, System.Drawing.Color.Yellow, "+");
                tgt_orbitgraph.is_target_type_module = true;
                bw_dev.modules.Add(tgt_orbitgraph);
            }

            if (color_dev != null && color_dev.isValid())
            {
                devices.Add(color_dev);
                VesselInfo initialcolor = new VesselInfo(color_dev);
                initialcolor.Activate();
                color_dev.modules.Add(initialcolor);
                //color_dev.modules.Add(new OrbitInfo(color_dev, "✈", System.Drawing.Color.FromArgb(0xee, 0xee, 0x00), System.Drawing.Color.FromArgb(0xaa, 0xaa, 0x44)));

                /*
                 * OrbitInfo col_targetinfo = new OrbitInfo(color_dev, "⊹", System.Drawing.Color.LightBlue, System.Drawing.Color.MediumPurple);
                 * col_targetinfo.is_target_type_module = true;
                 * color_dev.modules.Add(col_targetinfo);
                 */
                color_dev.modules.Add(new OrbitGraph(color_dev, System.Drawing.Color.Yellow, "✈"));
                OrbitGraph tgt_orbitgraph = new OrbitGraph(color_dev, System.Drawing.Color.LightBlue, "+");
                tgt_orbitgraph.is_target_type_module = true;
                color_dev.modules.Add(tgt_orbitgraph);
            }

            foreach (Device dev in devices)
            {
                dev.ButtonUP     += new Device.ButtonHandler(ButtonUp);
                dev.ButtonDOWN   += new Device.ButtonHandler(ButtonDown);
                dev.ButtonLEFT   += new Device.ButtonHandler(ButtonLeft);
                dev.ButtonRIGHT  += new Device.ButtonHandler(ButtonRight);
                dev.ButtonOK     += new Device.ButtonHandler(ButtonOk);
                dev.ButtonCANCEL += new Device.ButtonHandler(ButtonCancel);
                dev.ButtonMENU   += new Device.ButtonHandler(ButtonMenu);

                dev.DisplayFrame();
            }
        }