Git Product home page Git Product logo

neatinput's Introduction

Hi there I'm Daniel - aka LegendaryB ๐Ÿ‘‹

StandWithUkraine

  • ๐Ÿ‡ฉ๐Ÿ‡ช Made in Germany
  • ๐Ÿข I'm currently working as a software developer
  • ๐ŸŒฑ I'm currently learning Go
  • ๐ŸŽฎ I'm in love with playing games like Genshin Impact, Counter-Strike Global Offensive, Legends of Runeterra
  • ๐Ÿ—ป I'm in love with Japan - including but not limited to manga and anime

โ€œI never would have given you to them. Not for anything. Donโ€™t cry. Youโ€™re perfect.โ€
Silco to Jinx (Arcane)

โšก Tech Stack

.NET C# Xamarin Visual Studio JavaScript NodeJS TypeScript Visual Studio Code Docker Go Git GitHub GitLab Gitea Raspberry Pi

๐Ÿ’ฌ Connect with me


Click for GitHub Stats


Top Language

neatinput's People

Contributors

legendaryb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

neatinput's Issues

InputSource.Dispose() throws unexpected NullReferenceException

Here is a minor issue I stumbled upon. Do with it as you see fit. ๐Ÿ˜„

I only encountered this because I don't need to observe mouse input.

Current Behavior

InputSource.Dispose() throws NullReferenceException if one of the passed constructor parameter values (IKeyboardEventReceiver or IMouseEventReceiver) is null.

This happens on a Windows 10 (build 19041.264) environment with both latest stable v2.0.0 NeatInput.Windows package from NuGet and latest development branch code. Let me know if more details are needed in case the issue cannot be reproduced.

Expected Behavior

InputSource.Dispose() completes without throwing an exception if one of the constructor parameters is null. Or user/dev is informed earlier (during constructor call) about invalid parameters.

The constructor signature public InputSource(IKeyboardEventReceiver keyboardEventReceiver = null, IMouseEventReceiver mouseEventReceiver = null) suggests that neither of the parameters are required due to the = null optional parameter syntax. This conflicts with the fact that the constructor throws InvalidOperationException when no parameters are passed to the constructor but that is a separate issue.

Workaround

Pass a dummy implementation of the unused event receiver to the InputSource constructor.

Possible Solution(s)

  • Improve InputSource.Dispose() to handle the null references. ๐Ÿฆ‰ <(O RLY?)
  • Require passing valid event receiver instances to the InputSource constructor. E.g., remove the optional parameter syntax and throw ArgumentNullException for null parameters.
  • Internally replace the null constructor parameter values with dummy event receiver implementations.

Steps to Reproduce

.NET Core 3.1 console application that demonstrates current behaviour:

using System;
using NeatInput.Windows;
using NeatInput.Windows.Events;

namespace ReproduceException
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputSourceWithOnlyKeyboard = new InputSource(new KeyboardEventReceiver());
            inputSourceWithOnlyKeyboard.Listen();
            try
            {
                inputSourceWithOnlyKeyboard.Dispose();
                Console.WriteLine($"{nameof(inputSourceWithOnlyKeyboard)} disposed as expected");
            }
            catch (NullReferenceException ex)
            {
                Console.WriteLine($"{nameof(inputSourceWithOnlyKeyboard)} threw {ex.GetType().Name} while disposing");
            }

            var inputSourceWithOnlyMouse = new InputSource(null, new MouseEventReceiver());
            inputSourceWithOnlyMouse.Listen();
            try
            {
                inputSourceWithOnlyMouse.Dispose();
                Console.WriteLine($"{nameof(inputSourceWithOnlyMouse)} disposed as expected");
            }
            catch (NullReferenceException ex)
            {
                Console.WriteLine($"{nameof(inputSourceWithOnlyMouse)} threw {ex.GetType().Name} while disposing");
            }

            var inputSourceWithBothKeyboardAndMouse = new InputSource(new KeyboardEventReceiver(), new MouseEventReceiver());
            inputSourceWithBothKeyboardAndMouse.Listen();
            try
            {
                inputSourceWithBothKeyboardAndMouse.Dispose();
                Console.WriteLine($"{nameof(inputSourceWithBothKeyboardAndMouse)} disposed as expected");
            }
            catch (NullReferenceException ex)
            {
                Console.WriteLine($"{nameof(inputSourceWithBothKeyboardAndMouse)} threw {ex.GetType().Name} while disposing");
            }

            Console.ReadKey();
        }
    }

    public class KeyboardEventReceiver : IKeyboardEventReceiver
    {
        public void Receive(KeyboardEvent @event) { }
    }

    public class MouseEventReceiver : IMouseEventReceiver
    {
        public void Receive(MouseEvent @event) { }
    }
}

Console output after running the example application:

inputSourceWithOnlyKeyboard threw NullReferenceException while disposing
inputSourceWithOnlyMouse threw NullReferenceException while disposing
inputSourceWithBothKeyboardAndMouse disposed as expected

Bug with MouseEvent.Y

Hi, I'm tracking down the movement of the mouse by subtracting the previous Y position from the current Y position, and I get the number of pixels the mouse has moved down. But when the mouse reaches the end of the screen (1440 for me), it shows strange values โ€‹โ€‹like 1440, 1441, 1442 and 1443, which does not correspond at all to the number of pixels that the mouse passes, I can move the mouse constantly by 10 pixels, but I will only see these numbers from the list are replacing each other (everything would be fine if I constantly saw 1450, then I would simply subtract 1440). I track my mouse in an FPS game, so there is always this problem. Is there any way I can fix this?

Clarify that Linux is currently not supported

Right now, the about section states that NeatInput is

A .NET standard project which aims to make keyboard and mouse input monitoring easy on Windows and Linux.

But Linux is currently not supported. I suggest we change the about section to

A .NET standard project which aims to make keyboard and mouse input monitoring easy on Windows and eventually Linux.

To clarify that Linux support is planned, but currently not implemented

Uninstall hook automatically when the WeakReference is dead

The library uses a weak reference for the IKeyboardEventReceiver and IMouseEventReceiver fields. When the weak reference targets are not alive anymore we should automatically remove the hook because we don't have a target anymore to populate the results to.

Just need a little help understanding :)

Hi there, was wondering if there was an easy way to use our keyboard receiver or input source, to check the current state of a defined key?
Such as if( xxxx.isKeyDown(Key.W) ) { ... }

Thank you in advance!

Not usable with .NET Framework

As seen here the .NET Framework will not support .NET Standard 2.1 and above.

This is problematic for existing applications which can't be migrated to .NET Core etc. and want to use this library. It should be considered to rollback to .NET Standard 2.0 because this is the last supported .NET Standard version of the .NET Framework.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.