Skip to content

Commit

Permalink
Key Handling Improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
d3agle committed Jul 29, 2015
1 parent 439777c commit e19b39e
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion Server/Forms/FrmRemoteDesktop.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
using xServer.Core.Helper;
using xServer.Core.Networking;
using xServer.Core.Utilities;
Expand All @@ -9,14 +10,15 @@

namespace xServer.Forms
{
//TODO: Register Hotkeys for WIN - and ALT-key combinations
//TODO: Fix Alt + Tab
public partial class FrmRemoteDesktop : Form
{
public bool IsStarted { get; private set; }
private readonly Client _connectClient;
private bool _enableMouseInput;
private bool _enableKeyboardInput;
private IKeyboardMouseEvents _mEvents;
private List<Keys> _keysPressed;

public FrmRemoteDesktop(Client c)
{
Expand All @@ -38,6 +40,7 @@ private void FrmRemoteDesktop_Load(object sender, EventArgs e)
btnShow.Left = (this.Width / 2) - (btnShow.Width / 2);

_enableKeyboardInput = false;
_keysPressed = new List<Keys>();

if (_connectClient.Value != null)
new Core.Packets.ServerPackets.GetMonitors().Execute(_connectClient);
Expand Down Expand Up @@ -303,6 +306,13 @@ private void OnKeyDown(object sender, KeyEventArgs e)
{
if (picDesktop.Image != null && _enableKeyboardInput && IsStarted && this.ContainsFocus)
{
e.Handled = true;

if (_keysPressed.Contains(e.KeyCode))
return;

_keysPressed.Add(e.KeyCode);

if (_connectClient != null)
new Core.Packets.ServerPackets.DoKeyboardEvent((byte)e.KeyCode, true).Execute(_connectClient);
}
Expand All @@ -312,6 +322,10 @@ private void OnKeyUp(object sender, KeyEventArgs e)
{
if (picDesktop.Image != null && _enableKeyboardInput && IsStarted && this.ContainsFocus)
{
e.Handled = true;

_keysPressed.Remove(e.KeyCode);

if (_connectClient != null)
new Core.Packets.ServerPackets.DoKeyboardEvent((byte)e.KeyCode, false).Execute(_connectClient);
}
Expand Down

0 comments on commit e19b39e

Please sign in to comment.