[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Tips and tricks
. . -> [Subject]  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] Refresh page


Pages: 1  2  3 

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #30 on Mon 16 Apr 2007 01:31 AM (UTC)
Message
According to the source:


* RETURN VALUE
* The method returns the S_OK if it can connect to the LCD Manager
* library, or returns E_FAIL if it can not.


Also, the destructor, which should be called when you delete the object, calls:


m_output.Shutdown();


I presume this is the correct way to close it down. There doesn't seem to be a "close" call in the SDK.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Worstje   Netherlands  (899 posts)  [Biography] bio
Date Reply #31 on Mon 16 Apr 2007 01:40 AM (UTC)
Message
Yeah, I found that too just now. It's really odd. Are you able to reproduce this or is it just my configuration somehow?
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #32 on Tue 17 Apr 2007 12:10 AM (UTC)

Amended on Tue 17 Apr 2007 12:11 AM (UTC) by Nick Gammon

Message
Yes it seems to do it to me too. I made a few changes to at least eliminate the error message. This is the current plugin that works reasonably well:


<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Tuesday, April 17, 2007, 9:38 AM -->
<!-- MuClient version 3.85 -->

<!-- Plugin "g15_keyboard_test" generated by Plugin Wizard -->

<!--
Set prompt in SMAUG like this:

prompt <%h/%Hhp %m/%Mm %v/%Vmv %x/%Xxp> 

-->

<muclient>
<plugin
   name="g15_keyboard_test"
   author="Nick Gammon"
   id="cf2fb62495f34eb887d7edaa"
   language="Lua"
   purpose="Shows using the Logitech G15 keyboard"
   date_written="2007-04-17 09:37:23"
   requires="3.80"
   version="1.0"
   >

</plugin>


<!--  Triggers  -->

<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.IsOpen () or 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>
  <trigger
   enabled="y"
   match="Exits: *"
   send_to="12"
   sequence="100"
  >
  <send>
if not g15.IsOpen () or 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 ((string.gsub ("%0", "%a+", exits_subs)))

</send>
  </trigger>
</triggers>

<!--  Script  -->


<script>
<![CDATA[
function OnPluginInstall ()
  assert (package.loadlib ("G15_Display.dll", "luaopen_g15")) ()

  if g15 and g15.IsOpen () then
    g15.SetAsForeground (true)
  end -- if opened ok

-- exits substitutions table

  exits_subs = {
    north = "n",
    south = "s",
    east = "e",
    west = "w",
    northeast = "ne",
    northwest = "nw",
    southeast = "se",
    southwest = "sw",
    up = "u",
    down = "d",
  
   -- add more here
  
    }

end -- OnPluginInstall

function OnPluginClose ()
  if g15 and g15.IsOpen () then
    g15.Close ()
  end -- initialized
end -- OnPluginClose 

]]>
</script>


</muclient>



All I can suggest is to do what I did when developing, and not use a plugin. That way the keyboard driver can stay initialized, while you test modifications to your trigger routines.

I found that restarting MUSHclient did it - this is a relatively quick operation. The plugin will just reload automatically if it is in the plugin list, so the only real time waster will be reconnecting to the MUD.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Shadowfyr   USA  (1,786 posts)  [Biography] bio
Date Reply #33 on Tue 17 Apr 2007 03:40 AM (UTC)
Message
Hmm. I would think this represents a rather serious problem. Wouldn't more than one plugin using the features of the keyboard (or trying to) cause the whole thing to get messed up? We are talking about an issue where the dll is a single entry kind of thing, I would guess. I.e., only one application at a time can "talk" to the keyboard through it. That would invariably be the case with multiple plugins. Or am I wrong?

We might need a wrapper or redesign of the offending dll to fix this. Something like an activex dll or application that can sit between the client and the existing interface, and let more than one thing at least "attempt" to talk to it/receive information from it. It wouldn't prevent comflicts, like two plugins trying to send data to it at the same time, but it would fix the issue of two plugins not being able to deal with its other features. And, a clever design could buffer data, with a delay, or even loop it, so that if plugin A wants to send a compass, but plugin B wants to display a name, then the wrapper could loop them, so that the compass will show up for X seconds, then the name, then the compass again, etc. Like a billboard.

This assumes I understand what the problem that everyone is having with this thing actually is.
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #34 on Tue 17 Apr 2007 05:11 AM (UTC)
Message
The DLL registers itself with the Logitech software (ie. name "MUSHclient") - other applications can still talk to it.

I can't see a huge amount of use for multiple plugins all talking to a tiny screen on the keyboard.

It is a nifty feature for keeping track of what you are doing, in one session.

I didn't write the Logitech API, I don't know why it isn't releasing correctly.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Edoren   (31 posts)  [Biography] bio
Date Reply #35 on Tue 17 Apr 2007 11:36 PM (UTC)
Message
For some reason the new plugin keeps giving me an error about performing an arithmetic on a nil value
[Go to top] top

Posted by Edoren   (31 posts)  [Biography] bio
Date Reply #36 on Tue 17 Apr 2007 11:38 PM (UTC)
Message
The only thing that doesn't work are my exits and the only arithmetic performed is here.


hp_text:set ("hp: %1")
hp_bar:percent ( "%1" / GetVariable ("health") * 100)

mana_text:set ("m: %2")
mana_bar:percent ( "%2" / GetVariable ("mana") * 100)
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #37 on Wed 18 Apr 2007 12:32 AM (UTC)
Message
You've modified it haven't you? Mine didn't have GetVariable ("health") in it, and that looks like the part that is failing.

I was pulling health from the wildcard. That is, the match was (in part):


(?P<health>\d+)


That puts the health amount into the named wildcard "health".

Then in the calculation I used:


hp_bar:percent (%<health> / %<maxhealth> * 100)


That is using that named wildcard. No variables were used.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Edoren   (31 posts)  [Biography] bio
Date Reply #38 on Wed 18 Apr 2007 12:35 AM (UTC)
Message
I modified it to pick up my score max health since my prompt doesnt have that. Didn't have any problems with that. I actually tested if it could read that variable by getting it and sending it back to the world which worked just fine. Just don't know why its getting stuck around here.
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #39 on Wed 18 Apr 2007 02:45 AM (UTC)
Message
Quote:

hp_bar:percent ( "%1" / GetVariable ("health") * 100)


First, I wouldn't quote "%1" because it is a number, not a string.

Second, I would check that GetVariable ("health") is doing what you expect. For example, put in:


print ("health = ", GetVariable ("health"))


You know that variables in plugins are different to world variables? If "health" is a world variable, and not specific to this plugin, you need:


GetPluginVariable ("", "health")


That will get the world's variable.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Edoren   (31 posts)  [Biography] bio
Date Reply #40 on Wed 18 Apr 2007 04:10 AM (UTC)
Message
Alright, i created the plugin again from your previous examples and updated it with the new stuff you added. Apparently i must have messed up somewhere with the code because it works just fine now.
[Go to top] top

Posted by Worstje   Netherlands  (899 posts)  [Biography] bio
Date Reply #41 on Thu 19 Apr 2007 05:06 AM (UTC)
Message
I had noticed that shutting down MUSHclient fixed it, but since I tend to script while roleplaying at the same time it's quite an unfortunate problem.

Also.. I wondered.. if you were to write a normal application, used that EzLCD class (or whatever it is called) that is provided by the Logitech api, and simulated the creation of a keyboard, the releasing it and the recreating of the exact same registration with the Logitech software.. shouldn't it be able to determine whether it is some kind of Lua<>Logitech API conflict or whether it is really a bug in the API?

/me really needs to get a C++ compiler (and books) some day.
[Go to top] top

Posted by SamComeau   (1 post)  [Biography] bio
Date Reply #42 on Thu 10 Jun 2010 10:25 PM (UTC)
Message
After some tinkering and learning a bit of lua, I finally got this to work! Good news, it even works with the G-13 gamepad I bought. This is awesome, Nick you are my favorite.
[Go to top] 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.


158,268 views.

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

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]