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
g19.LGLCD_PRIORITY_IDLE_NO_SHOW, g19.LGLCD_PRIORITY_BACKGROUND, g19.LGLCD_PRIORITY_NORMAL, g19.LGLCD_PRIORITY_ALERT – For setting the priority
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
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: http://svn.doridian.de/gmdlls/gmcl_g19/ User: guest, Password: guest
To run this module you need the Visual C++ 2010 Redistributable downloadable from Microsoft here: http://www.microsoft.com/downloads/details.aspx?FamilyID=a7b7a05e-6de6-4d3a-a423-37bf0912db84&displaylang=en
(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
https://github.com/signal11/hidapi - For being able to use it for direct access to the keyboard