Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to "verify" your details, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.
 Entire forum ➜ MUSHclient ➜ Tips and tricks ➜ How to use the Logitech G15 gamers keyboard with MUSHclient

How to use the Logitech G15 gamers keyboard with MUSHclient

It is now over 60 days since the last post. This thread is closed.     Refresh page


Pages: 1 2  3  

Posted by Nick Gammon   Australia  (23,070 posts)  Bio   Forum Administrator
Date Fri 16 Jun 2006 05:39 AM (UTC)
Message

Recently I purchased a Logitech G15 "gamers" keyboard. This is what it looks like:

One of the interesting things about it is the set of additional 18 "soft keys" on the left-hand side of the keyboard, plus the keys M1/M2/M3 which let you select the 18 soft-keys into one of 3 "banks". This effectively gives you 54 additional keys that you can program.

You can program the keys to either emulate an existing key (eg. Shift+Ctrl+Alt+T) which would be handy for binding functions to some obscure keystroke combination (using the Accelerator function in MUSHclient) and then call that up with a single keypress.

You can also record a sequence of presses using either the MR (macro record) key, or the supplied software. The sequence can include emulated mouse clicks, and delays, the duration of which you can customize.

The final point of interest is the fold-up LCD screen. This can be programmed from the PC. There are some supplied apps that show things like the time of day, or the CPU usage. However the challenging part is to make the display show game-based information, as in the screenshot below:

(My photo doesn't do it full justice, it is hard to photograph LCD screens properly).

The follow-up posts describe how you can interface the keyboard with MUSHclient and customize the display to show whatever you want.


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,070 posts)  Bio   Forum Administrator
Date Reply #1 on Fri 16 Jun 2006 05:48 AM (UTC)

Amended on Tue 06 Mar 2007 06:46 AM (UTC) by Nick Gammon

Message
To connect to the LCD screen I used the SDK (software development kit) that Logitech conveniently supplied on the CD that came with the keyboard. However, I upgraded the keyboard software from their web site and also get an upgraded SDK.

To interface with MUSHclient I wrote a "wrapper" DLL that lets you use most of its functionality from Lua script calls.

First, download the DLL from here (66 Kb):

http://www.gammon.com.au/files/mushclient/G15_Display.zip

If you are using MUSHclient version 3.80 onwards, use this version instead:

http://www.gammon.com.au/files/mushclient/lua5.1_extras/G15_Display.zip

Then, extract it and place the G15_Display.dll into the same directory as the MUSHclient.exe program.

Then you need to install the DLL. I did it as part of a trigger:


if not g15 then
  assert (loadlib ("G15_Display.dll", "luaopen_g15")) ()
  g15.SetAsForeground (true)
end -- if


This effectively installs it on-the-fly the first time it is needed.

If you are using MUSHclient 3.80 onwards you need to change loadlib to package.loadlib.

Then I made a trigger that captures the prompt line and sends the information in it to the LCD screen as both numbers and a progress bar:


<triggers>
  <trigger
   enabled="y"

match="^\&lt;(?P&lt;health&gt;\d+)\/(?P&lt;maxhealth&gt;\d+)hp (?P&lt;mana&gt;\d+)\/(?P&lt;maxmana&gt;\d+)m (?P&lt;move&gt;\d+)\/(?P&lt;maxmove&gt;\d+)mv (?P&lt;xp&gt;\d+)\/(?P&lt;xptolevel&gt;\d+)xp\&gt;"


   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>if not g15 then
  assert (loadlib ("G15_Display.dll", "luaopen_g15")) ()
  g15.SetAsForeground (true)
end -- if

if not g15.IsConnected () then
  return
end -- if

if not hp_text then
  hp_text = g15.AddText ("static", "small", "right", 40, 0, 0)
  hp_bar  = g15.AddProgressBar ("filled", 100, 8, 50, 0) 
  mana_text = g15.AddText ("static", "small", "right", 40, 0, 10)
  mana_bar  = g15.AddProgressBar ("filled", 100, 8, 50, 10) 
  move_text = g15.AddText ("static", "small", "right", 40, 0, 20)
  move_bar  = g15.AddProgressBar ("filled", 100, 8, 50, 20) 
end -- if

hp_text:set ("hp: %&lt;health&gt;")
hp_bar:percent (%&lt;health&gt; / %&lt;maxhealth&gt; * 100)

mana_text:set ("m: %&lt;mana&gt;")
mana_bar:percent (%&lt;mana&gt; / %&lt;maxmana&gt; * 100)

move_text:set ("mv: %&lt;move&gt;")
move_bar:percent (%&lt;move&gt; / %&lt;maxmove&gt; * 100)
</send>
  </trigger>
</triggers>


This trigger adds 6 things to the LCD (spaced 10 pixels apart vertically for hp/mana/movement). There are 3 text boxes for the text display, and 3 progress bars for a visual progress indication.

Then this trigger handles exits when they appear:


<triggers>
  <trigger
   enabled="y"
   match="Exits: *"
   send_to="12"
   sequence="100"
  >
  <send>if not g15 then
  assert (loadlib ("G15_Display.dll", "luaopen_g15")) ()
  g15.SetAsForeground (true)
end -- if

if not g15.IsConnected () then
  return
end -- if

if not exits_text then
  exits_text = g15.AddText ("static", "small", "left", 160, 0, 30)
end -- if

exits_text:set ("%0")
</send>
  </trigger>
</triggers>


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,070 posts)  Bio   Forum Administrator
Date Reply #2 on Fri 16 Jun 2006 05:56 AM (UTC)

Amended on Sun 15 Apr 2007 10:47 PM (UTC) by Nick Gammon

Message
Full documentation

Load DLL

You need to load the DLL from inside MUSHclient, within a Lua scripting environment (main program or plugin):


  assert (loadlib ("G15_Display.dll", "luaopen_g15")) ()  -- install
  g15.SetAsForeground (true)  -- bring to foreground


For Lua 5.1 onwards (MUSHclient 3.80 onwards) you need to use package.loadlib, like this:


  assert (package.loadlib ("G15_Display.dll", "luaopen_g15")) ()  -- install





Once installed, the g15 table has the following functions:

IsOpen - check if the keyboard interface loaded OK.


  assert (g15.IsOpen ())


IsConnected - check if the keyboard is connected OK. If not, other functions will raise an error.

  
  assert (g15.IsConnected ())


Update - force an update of the LCD screen - done automatically after setting text but you can do it manually if you are using scrolling text, say every second or so.


  g15.Update ()


AddText - adds a new "text" object, returning a userdata which can be used to change the text in it.

All arguments have defaults.

Syntax:


  tud = g15.addtext (type, size, align, pixels, x, y)



  • type = one of: static/scrolling (default: static)
  • size = one of: small/medium/big (default: small)
  • align = one of: left/center/right (default: left)
  • pixels = maximum width in pixels (eg. up to 160) (default: 80)
  • x = X-position (0 = left) (default: 0)
  • y = Y-position (0 = top) (default: 0)


eg.

  hp_text = g15.AddText ("static", "small", "right", 40, 0, 0)


Small text is 7 point, medium is 8 point, big is 12 point.

AddProgressBar - adds a new "progress bar" object, returning a userdata which can be used to change the progress amount in it.

All arguments have defaults.

Syntax:


  pud = g15.AddProgressBar (type, sizeX, sizeY, x, y)




  • type = one of: cursor/filled/dot (default: cursor)
  • sizeX = width in pixels (default: 120)
  • sizeY = height in pixels (default: 5)
  • x = X-position (0 = left) (default: 0)
  • y = Y-position (0 = top) (default: 0)


eg.


  hp_bar  = g15.AddProgressBar ("filled", 100, 8, 50, 0) 


SetAsForeground - brings that page on the LCD screen to the front or back.


  g15.SetAsForeground (true)  -- make foreground


ButtonTriggered - returns true if the corresponding button is triggered

  
  print (g15.ButtonTriggered (2))


ButtonReleased - returns true if the corresponding button is released


  print (g15.ButtonReleased (3))


ButtonIsPressed - returns true if the corresponding button is pressed right now


  print (g15.ButtonIsPressed (4))


Close - closes the G15 library, releasing the LCD device


  g15.Close ()


The Close function was released on 16 April 2007 in the Lua 5.1 version, and is intended to be used in OnPluginClose to properly release the device.




Text Methods

Once you have created a text object with g15.AddText you can do the following things to it:

set - set the text

eg.


  hp_text:set ("Your health is low")


Note the colon after the userdata, which makes it supply the userdata itself as the first argument (the "self" parameter).

visible - make visible or invisible

eg.


  hp_text:visible (true)  -- make visible




Progress Bar Methods

Once you have created a progress bar object with g15.AddProgressBar you can do the following things to it:

percent - set the percentage filled

eg.


  hp_bar:percent (45)  -- make 45% filled


Note the colon after the userdata, which makes it supply the userdata itself as the first argument (the "self" parameter).

If the argument is outside the range 0 to 100 it is forced into that range.

visible - make visible or invisible

eg.

  hp_bar:visible (false)  -- make invisible





Notes



  • The LCD screen size currently is 160 x 43 pixels.

  • Personally I couldn't get ButtonTriggered and ButtonReleased to do anything. However ButtonIsPressed seemed to correctly return true if the button was held down when the call is made.

  • I seem to be having problems with the display disconnecting if the computer goes to sleep. Perhaps this wouldn't happen in practice, but I have released an updated DLL recently that removes the test for whether or not the display is connected. You can still test it yourself with IsConnected, but the other functions will now complete, whether or not the display is connected (I think).

  • I wasn't able to work out how to reliably remove things (other than making it crash <groan>), however I thought you probably would have a standard setup that doesn't need changing much. The SDK implements some sort of "pages" concept that I couldn't see a great use for. If you wanted to have two (or more) pages of information you can probably use the "visible" property to do this. Make two sets of things, one visible and the other invisible, and toggle back and forth between them.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,070 posts)  Bio   Forum Administrator
Date Reply #3 on Fri 16 Jun 2006 05:59 AM (UTC)

Amended on Fri 16 Jun 2006 06:00 AM (UTC) by Nick Gammon

Message
Source code

The source code is in the same file you can download:

http://www.gammon.com.au/files/mushclient/G15_Display.zip

I haven't included the Logitech SDK, you would need to obtain that from Logitech as part of the purchase of the keyboard, or subsequent upgrade.

You are welcome to adapt it to your own purposes.

Please let me know if you find problems or make significant improvements.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #4 on Fri 16 Jun 2006 07:07 AM (UTC)
Message
Nick, this is really, really cool. Three thumbs up. Makes me want to get one of these keyboards. :-) Extra information display is something I've been thinking about for a long time. It would be nifty to have things like the time, temperature, cpu usage all "right at your fingertips", literally.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Ked   Russia  (524 posts)  Bio
Date Reply #5 on Fri 16 Jun 2006 07:58 AM (UTC)
Message
This must be the coolest use of a keyboard I've ever heard about! Health, mana gauges and exits on the keyboard's display... How much does that thing cost, by the way?
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #6 on Fri 16 Jun 2006 02:08 PM (UTC)
Message
Hmm, I have a Logitech MX 5000 keyboard that has a LCD screen. Any idea if this'll work on mine?

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by Conner   USA  (381 posts)  Bio
Date Reply #7 on Fri 16 Jun 2006 05:00 PM (UTC)
Message
No idea, Zeno...

Nick, that is one very cool looking keyboard, I'm going to have to start saving up for one. :)

-=Conner=-
--
Come test your mettle in the Land of Legends at telnet://tcdbbs.zapto.org:4000
or, for a little family oriented medieval fun, come join us at The Castle's Dungeon BBS at telnet://tcdbbs.zapto.org
or, if you just want information about either, check our web page at http://tcdbbs.zapto.org
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #8 on Fri 16 Jun 2006 05:24 PM (UTC)
Message
http://www.pricegrabber.com/search_getprod.php?masterid=11165862&search=logitech+g15

Looks like prices are around $65-$70 from respectable vendors.

Zeno: you'd probably have to download the SDK for your model, and make a few adjustments to the Lua library. Shouldn't be too hard; maybe the SDKs are even more or less the same.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Nick Gammon   Australia  (23,070 posts)  Bio   Forum Administrator
Date Reply #9 on Fri 16 Jun 2006 10:25 PM (UTC)
Message
Quote:

I have a Logitech MX 5000 keyboard that has a LCD screen. Any idea if this'll work on mine?


Don't know, they probably have a slightly different interface, perhaps just a different "service number" or something.

You could try and see. :)

If you want to compile yourself grab the SDK that comes with the keyboard. All I did was take their demo program (written in C++) and replace the "main file" (with WinMain in it) with the source file supplied in the download. I changed the type from .exe to .dll and compiled. You need to grab the Lua include files as well from the Lua download (lua.h and so on).

I linked it against the supplied .lib file (lgLcd.lib) and all went well. You can probably compile under gcc but I haven't tried it.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,070 posts)  Bio   Forum Administrator
Date Reply #10 on Fri 16 Jun 2006 10:31 PM (UTC)
Message
The other points of interest about this particular keyboard is that the keys are backlit (you can sort of see that in the photos as a blue light). This is customizable from off/low/high. This is useful if you are playing at night in the semi-dark, you can still read the letters.

There is also a mute button for the sound, and another switch which lets you put it into "game" mode, which disables the Windows key and the Properties key, which if you accidentally press can tend to throw into another application when you least want it.

Plus, just below the LCD screen some sort of "multimedia" center that lets you do play, pause, fast forward, rewind and a volume control, that I haven't done much with yet.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,070 posts)  Bio   Forum Administrator
Date Reply #11 on Sat 17 Jun 2006 07:00 AM (UTC)
Message
Quote:

How much does that thing cost, by the way?


Well, if you live in Australia, I bought mine for $AUD 139.94.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #12 on Sat 17 Jun 2006 07:30 AM (UTC)
Message
Is that tax and shipping and everything included? There's a seller here that's offering it for USD 68 before tax and shipping; it would turn be USD 73.60 after tax, and probably about USD 80 after shipping. According to xe.com, AUD 139.94 is USD 103.64; I guess that's inline with the general difference in electronics costs.

I was shocked when I went to the UK over Christmas that electronics cost the same numeric value as in the USA, but in pounds! So a 1GB flash card would cost about USD 65 here, but also GBP 65. But, GBP 65 = USD 120.25... so it's almost twice as much!

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Nick Gammon   Australia  (23,070 posts)  Bio   Forum Administrator
Date Reply #13 on Sat 17 Jun 2006 07:37 AM (UTC)
Message
That price included the 10% GST tax that our government saw fit to impose on us. I picked it up in person so shipping would have been extra.

I suppose you could expect to pay a bit more for shipping to Australia, but if it is made in China or somewhere like that, that should have been about the same as shipping it to the USA.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #14 on Sat 17 Jun 2006 07:44 AM (UTC)
Message
Sales tax here (in California) is 8.25%. (It's different in other states, in fact, some states don't have sales tax at all...) But the catch is that it's almost never included in the price; you have to mentally juggle with prices, always adding the sales tax. It's actually pretty annoying. :/ I think it's a marketing trick: they want to make the price appear smaller, in order to encourage consumption. And it works: some people tried including the tax in the price, and people went to competitors even if the competitors' after-tax price was more expensive!! Pretty crazy how human psychology works, sometimes...

And the shipping is always calculated relative to retailer, not origin. (I.e., shipping from a NY retailer to a CA address is more expensive than from CA to CA, but CA to CA is usually fairly cheap.) I guess the costs of shipping from factory to retailer is reflected in the price, not in the shipping mark-up you pay when ordering online.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


171,078 views.

This is page 1, subject is 3 pages long: 1 2  3  [Next page]

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.