gmcl_g19 - G19 support for GMod

After GMod already supports the Logitech G15 using I hacked together a nice module which adds a rendertarget for your Logitech G19 keyboard.
g19.StartDraw() – Begins rendering to the G19 rendertarget
g19.EndDraw() – Finishes rendering to the G19 rendertarget
g19.Update() – Makes the G19 display redraw

g19.SetForceForeground(true/false) – Forces your applet to be in foreground (or disables the forcing again)
g19.SetPriority(priority) – Sets the priority of your applet. For use with the LGLCD_PRIOTIY_ constants.

g19.SetColor(R,G,B) – Sets the color of the LCD backlight
g19.SetMLEDs(M1,M2,M3,MR) – Sets the state of the M-Keys (each is a bool)

g19.GetButtonState() – Gets the G19 buttons state (use bitmask operations to get the states of the individual buttons)

g19.BUTTON_LEFT, g19.BUTTON_RIGHT, g19.BUTTON_UP, g19.BUTTON_DOWN, g19.BUTTON_OK, g19.BUTTON_CANCEL. g19.BUTTON_MENU – For usage with GetButtonState or the hook

G19ButtonChanged – Called when a button gets changed, see usage in example Lua

Example Usage: (adds a hook for button changes and renders the view of the RTCam to the G19)
require(“g19”) – Initialzes the module

local rtTexture = surface.GetTextureID( “pp/rt” )

g19.StartDraw() --Begins rendering to the G19 rendertarget
surface.SetTexture( rtTexture )
surface.SetDrawColor( 255, 255, 255, 255 )
surface.DrawTexturedRect( 0,0,320,240 )
g19.EndDraw() --Finishes rendering to the G19 rendertarget

g19.Update() --Makes the G19 display redraw

if button == g19.BUTTON_LEFT and pressed then
print(“Left pressed!”)

function G19IsButtonPressed(button)
return ((g19.GetButtonState() & button) ~= 0)

Rendering to the G19 RT has been tested to work in the hooks “PostRenderVGUI” and “HUDPaint” so far.
It is not advised to call g19.Update() each frame since it will severely drain your framerate. My timer (as you see) runs at 15 times a sec which causes no noticeable FPS drop.

Source: User: guest, Password: guest
To run this module you need the Visual C++ 2010 Redistributable downloadable from Microsoft here:
(To compile the source you need the lglcd.h and lglcd.lib from the Logitech SDK, which is included with the G19 driver)

Demo: (filmed by my iPhone, so not best quality)

Jinto - Ideas on how to do things which I took from gm_image (renderContext->ReadPixels)
Wizard of Ass - Motivation / Testing - For being able to use it for direct access to the keyboard

Now I’m totally gonna get a G19. Awesome!

Anything useful for non-developers yet? I have a Logitech G19.

The module just has been released yet, what do you exspect?

I’m already coding on a HUD extension but I’m not sure if I gonna release it.

Sometimes when a module is released the guy who made it has some small example that uses the module in some way.
I was more thinking about that.

Well, my example up there works. It renders the view of the current RTCam to your G19 LCD In case that’s any use for you. :wink:

Awesome, screen shot would be nice too :stuck_out_tongue:

Surely a photo/video would be better here? :stuck_out_tongue:

Haha, yes, them things.

Added a little demo video to the OP.

finally a reason to buy a G19 :wink:

Awesome, but why the hill do you need a keyboard with a screen? :lol:

I would buy one but 150 euro’s for a keyboard is just a little to much.

By making this module, you increased Logitech’s sales count for the G19 by at least one.

Why the hell would you need a computer? Why the hell would you need a car? Why the hell would you need a house? Why the hell do you need laws?

Why the hell would you want laws? Why the hell would you want a house? Why the hell would you want a car? Why the hell would you want a(n awesome) computer? Why the hell would you want a keyboard with a screen?

Suddenly all of the Lua section buys G19s.

Ebay has them for 129$, woot.


But don’t use surface.GetTextureID in HUDPaint.

Fix’d in OP.

I’m taking parts of derma and recode them to work on the derma and make the buttons work with the g19 buttons.

Works pretty good for now but its alot of work :frowning:

In germany you can get the G19 for 109€ and ZERO Euro shipping :wink:

error loading module ‘g19’ from file ‘c:\program files (x86)\steam\steamapps\xxx\garrysmod\garrysmod\lua\includes\modules\gmcl_g19.dll’:
The Module couldn’t be found.

A friend of me keeps getting that error, if you enter the path manual within windows explorer it opens the file… (so it exists)
What’s going wrong?