Not a bug fix, per se, but a change in the way the dll handles the hBitmap passed to it. I had made the incorrect assumption that the host language would have a good way to deal with the .GetHbitmap method. Apparently, you need to define a Win32 DeleteObject command to remove the resources created with that function.
It's not too big a deal in the .net languages, but VB6 could get ugly. Instead, I'm now automatically deleting the object sent to the LcdUpdateBitmap function. The download is on the DMcLgLCD page and contains updated example code.
Thanks to TimoHollwedel, I've found a couple of bugs in the DMcLgLCD dll. The bugs have been removed and I went ahead and added in some new functions as well. All of the examples have been updated to reflect all of the changes.
Here's the quick lowdown on what's changed:
- Fixed a small memory leak.
- Added LcdReadSoftButtons. Stable way of polling the soft button status. Meant to replace the LcdSetButtonCallback function.
- Added LcdSetConfigCallback. Allows a headless app to have a config screen that can be called by Logitech's LCD Manager.
- Added LcdConnectEx. Necessary for reading the G-19 extended soft buttons. With LcdConnect, you can only read the direction keys as G-15 buttons.
- Updated examples. C# Example is now more graphical in nature, showing the button presses on the LCD screen itself.
Download available on the DMcLgLCD page.
I'm pretty close to being finished with my DMcLgLCD Logitech Keyboard wrapper. I've got the callback routines for the keyboard buttons working now. I originally just passed a function address along directly to Logitech's DLL, but it tended to crash if someone clicked the buttons too fast. I read up on threading and I now have a thread that can buffer the input a little so the Logitech callbacks aren't held up waiting. It works a lot better, but it still crashes if you really hammer the buttons and your callback takes too long to address them :). I'm going to leave it like that for now and write a warning in the documentation and samples. If I keep the routines simple, it doesn't get hung up.
At this point, I've pretty much finished all of the functionality and I just need to refine the functions a little. Currently, I have functions that pretty much mirror the original Logitech functions. I'll keep those intact, but also write some simpler functions that work for what 99% of people will want to use it for.
I've currently got a small skeleton app written, but I need to split it up into two or three different examples. Maybe an "easy" example using the new simplified functions and a more advanced example that uses the full wrapper. I'll also need something to show how to handle color VS black and white. After that, I'll try doing a quick C# example and if I can get that to work, a VB.NET example as well.
The DLL really started coming along last night. I got color working, got VB talking to the DLL by just passing a Picturebox.Image to it. I then went on to test using a graphics library in VB that returned an HBITMAP and proceeded to throw different types of images at the LCD. As a result, I got 1-Bit, 8-Bit, 24-Bit and 32-Bit images working both for the standard 160x43 screen as well as the 320x240 color screen.
I was pretty excited to have everything working on my dev machine, so I took the newly minted DLL and my updated Manga Reader downstairs to my gaming machine with the G19 keyboard... and it failed miserably. It would have helped if the error made any sense, but Manga Reader kept insisting that it couldn't find the DLL at all.
Quick lesson for all you Visual C++ newbies (like me): By default, VC++ requires that a runtime is installed. Not so bad for a standalone program, but fatal to a distributable DLL. After a whole lot of tail chasing, I finally came across the proper tidbit of information and set my project to compile the libraries statically. Viola! Working DLL.
I'll still need to test on XP as well as machines without a keyboard, but I should be able to get a new version of Manga Reader out fairly soon. As a bonus, it no longer registers itself to start up when Windows starts :) As for the DLL, I'll make a stab at creating a callback function for the soft buttons (I have no idea where to begin on this) and if I'm successful, I'll start writing a couple of sample apps and package it up. I'll definitely make a VB6 sample, but I'll also try to create VB.NET and C# samples as well.
It's been slow going, but I've been working on my own dll Wrapper the Logitech G15 and G19 keyboards. It should work with other languages, but I'm mostly targeting VB6 at the moment. So far, I've managed to wrangle up something that can display the contents of a picturebox to a Black and White display. It's been tough, but I did learn a lot more than I expected to while putting it together.
Next step is to try sending bitmaps in memory and seeing how well my code handles 8-bit, 24-bit and 32-bit images. I'll have to write some new code for 1-bit images, but it shouldn't be too hard. After that is color for the G19 (which should be easy) and then maybe soft button handling.
I'll make up a sample app and create a new page for it when it's ready to distribute. It was really frustrating just trying to find a good VB6 DLL that works only with the G15. I haven't seen anything for the G19.