How to get pixel-per-inch value of the screen in XNA? - xna

Does anybody know the answer to the question above?

I do not think you can get this value. You have no idea what monitor is connected and while there might be drivers that actually know this type it might be a default driver. Either way, this information is not accessible to you.
Also, there might be duplicated displays, TV-output, an overhead projector and whatnot. So, the situation is more complex than the normal situation of a known monitor connected to your rendering window or fullscreen window

Related

How can I detect when error correction corrects something or turn off error correction in wireless communication

I'm working on a project in which I basically want to test how many errors happen in wireless communication.
My first thought was to use ESP8266 chips, but then I came to the realization that wifi has ways of correcting errors before they reach the other device. So I was wondering if there's a way to either stop this correction from happening or detect it.
I also thought of making use of the Micro:Bits' radio feature, since they're easily available to me and they don't use wifi. The problem here is that I can't find anywhere that says whether Micro:Bits have error correction codes or not.
If there's another possibility that I'm not seeing, that would definitely let errors through, I would very much like to know.
If all else fails, I could still use antennae, but that would bring a lot of other problems with it for what I'm trying to do.

Getting started on custom gamepad handling

Since I find the default gamepad handling of Windows to be lacking, I'd like to write a custom interface for that purpose. Basically, I want to add a layer between the plugged in gamepads and the Windows gamecontroller management. While I'm not sure how to tackle this problem, these are the steps I was thinking off so far:
Disconnect any plugged in gamepads from Windows' gamecontroller management
Create virtual gamecontroller (perhaps with vJoy/pyvjoy)
Read inputs from the plugged in gamepads and apply them to the virtual gamecontrollers
However, apart from the second bullet point I don't know whether (and how) these are doable. Are there any APIs that can interact with devices the way that I need to? Do I need to get into driver programming and rewrite gamepad drivers?
I know this is a broad question to a very narrow topic, but I'm kind of at a loss where to get started. Any help would be much appreciated.
HIDGuardian covers your first bullet point:
https://github.com/nefarius/ViGEm/tree/master/Sys/HidGuardian
HIDGuardian is used by InputMapper to hide the physical gamepad when a virtual gamepad has been created for the device. This prevents applications from seeing input from the same gamepad twice.

Dynamically change print data

I am looking into a way to manipulate the data sent to a printer (inkjet for now. Probably an HP 2460).
I want to change the data dynamically each time the printer tries to print.
Ie. at point 1, the print will be of the page kept normally, but the paper might change its position, so I am looking for a way to rotate the input image to counter the rotation of the paper.
I think I am looking for a way to specify the data to be printed pixel by pixel in real time.
Data input available :
rotation
position of the print head with respect to the corner of the page at
each instant provided in real time
What I have so far:
I have seen one instance where a particular HP inkjet was modified to work directly off an arduino but I would like to do it directly from the computer for now for 2 reasons:
I need to submit a proof of concept system as soon as possible
I don't have much easy access to logic analyser/scope to reverse
engineer the communication protocol (nor probably the expertise).
I am looking into PostScript, GhostScript but from what I understand so far, I wont be able to modify the data dynamically (Still trying to figure it out, so pardon me if I'm wrong). Would this approach work? Or do I need to look into drivers or something else?
I am aware of the restrictions of asking questions and how ill-researched questions are frowned upon. I am still trying to figure out how to get this done and have been looking into all the things that came up in my mind and I am coming across while looking through. But, so far, whatever I've seen doesn't seem to be capable of doing what I want (or I'm missing it). I'm asking this question in the hope of getting some pointers as to what to look into.
if you mean to manipulate each page, ie this page landscape next page portrait, etc then i would work on the postscript input, and not even think about the specific hardware communications.
On the other hand you want to grab the print head and manipulate things real time after printing has started then the approach will obviously depend on the specific printer.
I would try to do this at a higher level if possible. Best would be if you take control of how the postscript is being generated, then you can insert <<...>> setpagedevice to change printer parameters.
One problem is that most printer manufacturers have stopped distributing documentation on the printer command language.
Another problems is ghostscript output devices are hopelessly out of date, like dot matrix printers. (see problem one).
For a screen printing output application, I reverse engineered the epson 1400 print command language and wrote a program to output a bitmap to the printer. Then I wrote a ghostscript printdriver based on a .bmp driver which created bitmaps and converted the bitmap to epson commands. Since you want to use an HP, this code unfortunately won't help.
Having gone down that road, I can tell you it isn't easy. Inkjet's don't allow rotation, so you'd need to rasterize the inkjet, then re-create a rotated image. Ghostscript is itself tricky to get running to a printer using gsprint and redmon, but if you already have postscript job that prints upright, then the image can be rotated and shifted with postscript commands.
I don't understand what you are trying to accomplish. Can you use a pc with a webcam to preview the orientation, then generate a bitmap and print it to the printer or do you need to wait till the paper is in position before generating the print data?

Binding a trackball to NPAPI

I want to use a second pointing device (the trackball) as a control for a specific function on a program. This means I would NOT want any mouse functionality from the trackball, I just want to get the movement data and somehow use the NPAPI to get that into our web app. Is there a way to bind a mouse/trackball to a specific program that it doesn't act as a mouse/trackball for the computer?
Thanks in advance!
UPDATED: actually ask a question
To the best of my knowledge and my understanding of how HID devices work, there is no way to do what you want to do. If you could do it at all, you could probably do it from an NPAPI plugin, but there is no way to tell the operating system not to take control of one specific pointing device as opposed to any others.
Now, if you had a special HID trackball that didn't show up as being a regular pointing device then you could possibly do it with that, but I have never heard of any way to take control of just one of potentially many HID pointing devices on windows, linux, or mac.
There may be a way to hack something together in Linux by changing the way the drivers work, etc, but I don't know of any.

What is the most efficent way to screen capture? Screen capturing using DirectX?

I've known about screen capture using Device Contexts and GDI, since windows XP. Is there a better way (i.e. DirectX?) now that the desktop is mostly Direct3D.
How can I screen capture using DirectX?
I want to know the most efficent way to user-mode screen capture. For a tech support program that needs frequent screen scrapes.
UPDATE: I don't want to resort to using kernel mode drivers.
I am unsure this will actually be faster than the algorithms you have in mind, but one way to do it would be to copy your buffer out using GetRenderTargetData.
GetRenderTargetData
Based upon vcsjones answer (above). See CodeProject http://www.codeproject.com/KB/dialog/screencap.aspx#And%20The%20DirectX%20way%20of%20doing%20it%20
An alternative method is using Spazzarama's application, which uses DirectX (based on SlimDx) and Easyhook to inject your capture dll into a running application's DirextX pipeline.

Resources