Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Binding for some common Gui operations #2117

Merged
merged 10 commits into from Aug 16, 2023
Merged

Conversation

pgrawehr
Copy link
Contributor

@pgrawehr pgrawehr commented Aug 5, 2023

Add two virtual devices:

  • Take screenshots
  • Simulate a mouse
Microsoft Reviewers: Open in CodeFlow

@pgrawehr pgrawehr self-assigned this Aug 5, 2023
@ghost ghost added the area-device-bindings Device Bindings for audio, sensor, motor, and display hardware that can used with System.Device.Gpio label Aug 5, 2023
@pgrawehr pgrawehr removed their assignment Aug 6, 2023
@pgrawehr pgrawehr marked this pull request as ready for review August 6, 2023 13:54
@Ellerbach
Copy link
Member

I have a question: what is different from the excellent https://github.com/gui-cs/Terminal.Gui?
I've been using Terminal.Gui and it does all this, works on all platforms and OS.

@pgrawehr
Copy link
Contributor Author

pgrawehr commented Aug 7, 2023

I have a question: what is different from the excellent gui-cs/Terminal.Gui? I've been using Terminal.Gui and it does all this, works on all platforms and OS.

I didn't know that library, but I don't see it doing any of this (or I couldn't find it).

My binding is for

  • a) creating a virtual mouse, not to read the mouse. So the purpose is to be able to create an Iot App that takes some sensors (e.g. a joystick, or an accelerometer) and use it to control the desktop OS.
  • b) take a graphical screenshot of the desktop OS that can be forwarded to a Iot screen.

Together, these two allow running a desktop OS on something like an Ili934x (on SPI) and a touchscreen or to create custom input devices for a kiosk application. And with "desktop OS" I really mean the full GUI (of either Windows or Unix)

@Ellerbach
Copy link
Member

OK, so it's quite complementary and both can be used at the same time. I'm a big fan of Terminal.Gui. Really works nicely. I'm using it a lot in personal projects. So you can get a gui in a command line with support of mouse as well. So integration of both can be nice.

Copy link
Member

@Ellerbach Ellerbach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few comments but all up, it looks really good and interesting scenario, definitely something that can bring a lot of value!

src/devices/Gui/IPointingDevice.cs Outdated Show resolved Hide resolved
// Definitions for this file come from X.h and Xlib.h from the Raspberry Pi (32 Bit Raspberry Pi OS)
// Some structures may have different alignment on 64 bit systems, so that it may be required to replace
// some field types with nint/nuint
internal static UInt32 AllPlanes = 0xFFFF_FFFF;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why using UInt32 and not just uint?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For values used in interop calls, I prefer to be explicit about the size. I know that in c#, uint is defined to be 32 bits, but this is not the case in the C world.

src/devices/Gui/Interop/Interop.X11.cs Show resolved Hide resolved
internal static extern unsafe Window XDefaultRootWindow(IntPtr display);

[DllImport(X11)]
internal static extern int XGetWindowAttributes(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe add as well the missing intellisense comments? There are few places where it's not present. For maintainability, it can help for the internal ones especially for the dllimport ones?

src/devices/Gui/Interop/Interop.uinput.cs Show resolved Hide resolved
src/devices/Gui/ScreenCapture.Windows.cs Show resolved Hide resolved
@pgrawehr pgrawehr merged commit a5f29d1 into dotnet:main Aug 16, 2023
9 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Dec 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-device-bindings Device Bindings for audio, sensor, motor, and display hardware that can used with System.Device.Gpio
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants