Can I write a Windows filter driver for an HID device to invert vertical scrolling? - windows

I would like to emulate OS X Lion's inverted vertical scrolling using a trackpad on Windows. I wonder if it would be possible to create a filter driver for a target HID device, intercept ... something ... and then reverse the values in the WM_VSCROLL message? e.g., send TB_PAGEDOWN instead of TB_PAGEUP, TB_LINEDOWN instead of TB_LINEUP, etc.
I have some familiarity with the Windows DDK and HID devices, but I've never attempted a filter driver before. Is something like this possible? If so, does anyone have some specific advice on how to proceed?
I believe I need to write an upper device filter driver.
I found the moufiltr driver sample in the DDK. The MouFilter_ServiceCallback looks like the right place to hook into. I'm hoping to be able to loop through the MOUSE_INPUT_DATA structs passed to this function and then tweak the ButtonData field when ButtonFlags has MOUSE_WHEEL set.

Related

Use RS232 (scales) as keyboard input on Mac

I have a set of scales which use RS232 to input weights to shipping software.
I am looking to use this data in Excel on Mac, basically using the device as a keyboard or in a similar way to a barcode scanner, in that the weight it sent over RS232 only when a button is pressed, with a line return at the end.
I have searched high and low and can't find an equivalent of 232key for Mac!
Using Screen in terminal, I am able to see the data I need, so I am basically looking for a way for macOS to recognise this device as a keyboard in the same way a barcode scanner does.
Thanks!

Do device drivers communicate with each other, or are they asynchronously called?

I will paint an example of what I am asking in crystal clear detail.
Say we are in a typical userland app, like painting software or text editing, and we decide to hover the mouse or click a combo box. From this input alone the mice's trackball will need to be fetched from the device driver on the low-level, but the video driver will also need to update the position of the pointer on the screen accordingly at the (seemingly) same time as follows:
As the picture illustrates, not moving the mouse, but calling the driver/updating the screen constantly works. However, what if we choose to both click the menu combo box/drop down list, and update the framebuffer feed constantly? Are both drivers called almost at the same time, and what calls them (the GUI desktop, the app directly, etc.). Because the mouse works ANYWHERE, on an app or not ... that makes me question if the mouse input is indefinitely system called, however, video output depends more on what the app is(like below, texpad).
The mouse driver has nothing to do with the video driver. You're getting the distinction wrong between what happens in the kernel space and user space.
The kernel has no idea of a concept of a 'mouse pointer'. It only exports an interface saying, "I have a input device that gives X and Y coordinates". Likewise with the video driver, it only exports an interface saying, "I have a device where you can output pictures" - it doesn't know what a mouse pointer is.
The GUI is all handled in user space and that's where you get the concept of drop down boxes, mouse pointers etc... Whatever program handles your GUI takes the kernel interfaces and does stuff with it, such as associating the input device with a mouse pointer and outputting video to the screen.
How the contents of the screen is actually pushed to the hardware will be driver dependent and doesn't involve user space. The GUI just tells the kernel, "I want the screen to look like this" and the kernel handles the rest.
Both drivers can certainly run in parallel if you have a multi-core CPU but, unless you're implementing the driver or scheduler, you don't need to know the details.

Is it possible to programmatically turn on the Macbook Pro's keyboard backlight for individual keys?

Although I have a feeling that this isn't technically possible, it's worth asking anyways. Is it possible to turn on the Macbook Pro's keyboard backlights for individual keys? I am working on a piece of grid-based software which allows the user to navigate around by pressing any key on the keyboard to position the cursor at that point in the grid. It would be very cool if I could somehow just turn on the backlight for certain keys to give the user an easy way to see the current position of the cursor.
Is it even possible for an application to control the keyboard backlighting at all, let alone for individual keys?
Yes, on programs controlling the backlight.
iTunes visualizer that pusles keyboard backlighting to music:
http://www.youtube.com/watch?v=LUXLkwlF9e8
How to manually adjust (via plugin):
http://osxdaily.com/2006/11/30/how-to-manually-adjust-the-macbook-pro-keyboard-backlight/
Not sure on programs controlling individual keys, but as that would require additional hardware to be installed on Mac's part, i doubt it.
Well after trawling the webs, it looks like the answer to that is no. But I'd like to point out that each key does have its own key- a tiny little LED (same kind they use under phone keypad buttons). Also, I've seen some people saying that flashing these lights on and off repeatedly is bad for them. Bullshit- all digital electronics control light output from LED's by flashing on and off many many times a second. Read up on PWM on wikipedia or something..
Anyways just had to get that out there :)
Thanks,
Nic

Multiple mouse/mice/cursor?

How can I show another cursor for multiple mice?
I have two TMemos, two keyboards which can type into their respective TMemo, 2 mice and I need 2 cursors those.
If hypothetically, I can already detect which mouse is which. How can I make my own cursor to go along with it. (using Delphi)
Possibly along the lines of Multipoint
as an alternative, is there any software which can render more that one cursor. Like CPNMouse?
EDIT:
I found that I can use the mouse_event Function in windows, but I still don't have the visual representation of the cursor.
Cursors are just resources. Here is a good list of the standard cursors that can be used. TControl Defines a cursor property that can be set to the cursor that should be used when over a given control. You can also use Screen.Cursor to control the entire application cursor.
To define a custom cursor you use the following code.
{$R MyCustomCursors.RES}
const
crCustom1 = 1;
crCustom2 = 2;
...
Screen.Cursors[crCustom1] := LoadCursor(hInstance, 'CUSTOM1');
Screen.Cursors[crCustom2] := LoadCursor(hInstance, 'CUSTOM2');
...
Delphi was not designed by default to deal with multiple mouse pointers, but the I suspect most environments are not. The SDK you mention is the only source of information I have seen on using multiple mice at the same time in a single application. It however is .NET only, so using it would require Delphi Prism.
If you want to roll your own support for multiple mice the same trick of using WM_INPUT can can be used. Windows will treat both mice as the same. You will have to do custom painting of the mouse cursor by hand for the second mouse.
Windows doesn't support multiple mouse or keyboards. Since each process have only 1 input queue, Windows treats all similar input devices as the same single device. This can't be changed. End of story. Period.
But even if you can't do this on system wide scale - you still can do this in one particular application. You need to write a special driver and install it for the second mouse only. This driver should not pass mouse movements to usual consumer (input queue), but rather redirect input directly to your application.
You can use a already written drivers - for example, this one or the one, that you've already mentioned.
It can be simulated its action virtually from the original cursor by doing something seamingly fast

In writing games that deal with scancodes, what do I need to know to support international keyboards on Mac and PC?

I am writing an input system for a game that needs to be able to handle keyboard schemes that are not just qwerty. In designing the system, I must take into consideration:
Two types of input: standard shooter controls (lots of buttons being pressed and raw samples collected) and flight sim controls (the button's label is what the user presses to toggle something)
Alternative software keyboard layouts (dvorak, azerty, etc) as supplied by the OS
Alternative hardware keyboard layouts that supply Unicode characters
My initial inclination is to sample the USB HID unicode scancodes. Interested on thoughts on what I need to do to be compatible with the world's input devices and recommendation of input APIs on both platforms.
Simple solution is to allow customization of input. In the control customization, record what key the OS tells you has been pressed. In game, when you get a key press, check it against your list of bound keys and do the appropriate action.
It looks You need a cross platform library for games. You can look at SDL:
http://www.libsdl.org/
It is quite popular in game development.
http://en.wikipedia.org/wiki/List_of_games_using_SDL
The library is quite modular. You can only use part that control input.

Resources