Jump to content
Korean Random
adjgam

Gamesense

Recommended Posts

Мод для изменения цвета подсветки у гарнитур Steeleries в зависимости хп своего танка

 

установка:

копируем wot.lsp в C:\ProgramData\SteelSeries\SteelSeries Engine 3\hax0rBindings\

"res_mods" в каталог с игрой.

 

Что при желании можно сделать: натанкованый урон(глупо), засвет, урон, wn8, фраги

gamesense.zip

  • Upvote 3

Share this post


Link to post

Short link
Share on other sites

Can you add M800 ("rgb-per-key-zones") keyboard support? Even better is to add mod settings into WoT to allow choose your configurations (keyboards, mouse, headsets).

 

BTW excellent work, will test this and maybe add some extra features (for sure try to do this)

Edited by lazik
  • Upvote 1

Share this post


Link to post

Short link
Share on other sites

Can you add M800 ("rgb-per-key-zones") keyboard support? Even better is to add mod settings into WoT to allow choose your configurations (keyboards, mouse, headsets).

 

BTW excellent work, will test this and maybe add some extra features (for sure try to do this)

I have only headset, I cannt test if it work on other devices

headsets have one zone, keyboards and mouse more, which zone to add?

  • Upvote 1

Share this post


Link to post

Short link
Share on other sites

@adjgam: M800 have per key zones. When I started to play with gamesense (without success) I prepared settings. In file you can find all mouses and keyboards with settings. Maybe will be helpful.

I can't find now mod settings.

https://dl.dropboxusercontent.com/u/29707635/WoT/mod_SteelSeriesRGB.py

class MouseRival100:
DEVICE_TYPE = "rgb-1-zone"
ZONES = ["one"]
class MouseRival300:
DEVICE_TYPE = "rgb-2-zone"
ZONES = ["one", "two"]
class MouseRival700:
DEVICE_TYPE = "rgb-2-zone"
ZONES = ["one", "two"]
class SenseiMouse:
DEVICE_TYPE = "rgb-3-zone"
ZONES = ["one", "two", "three"]
class SenseiWirelessMouse:
DEVICE_TYPE = "rgb-3-zone"
ZONES = ["one", "two", "three"]
class MSIGE62Keyboard:
DEVICE_TYPE = "rgb-3-zone"
ZONES = ["one", "two", "three"]
class MSIGE72Keyboard:
DEVICE_TYPE = "rgb-3-zone"
ZONES = ["one", "two", "three"]
class APEX350:
DEVICE_TYPE = "rgb-5-zone"
ZONES = ["one", "two", "three", "four", "five"]
class APEXM800:
DEVICE_TYPE = "rgb-per-key-zones"
ZONES = ["one", "two", "three", "four", "five", "logo", "q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "a", "s", "d", "f", "g", "h", "j", "k", "l", "z", "x", "c", "v", "b", "n", "m", "keyboard-1", "keyboard-2", "keyboard-3", "keyboard-4", "keyboard-5", "keyboard-6", "keyboard-7", "keyboard-8", "keyboard-9", "keyboard-0", "return", "escape", "backspace", "tab", "spacebar", "caps", "dash", "equal", "l-bracket", "r-bracket", "backslash", "pound", "semicolon", "quote", "backquote", "comma", "period", "slash", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9", "f10", "f11", "f12", "printscreen", "scrolllock", "pause", "insert", "home", "pageup", "delete", "end", "pagedown", "rightarrow", "leftarrow", "downarrow", "uparrow", "keypad-num-lock", "keypad-divide", "keypad-times", "keypad-minus", "keypad-plus", "keypad-enter", "keypad-period", "keypad-1", "keypad-2", "keypad-3", "keypad-4", "keypad-5", "keypad-6", "keypad-7", "keypad-8", "keypad-9", "keypad-0", "l-ctrl", "l-shift", "l-alt", "l-win", "r-ctrl", "r-shift", "r-alt", "r-win", "ss-key", "win-menu", "m0", "m1", "m2", "m3", "m4", "m5", "function-keys", "number-keys", "q-row", "a-row", "z-row", "macro-keys", "all-macro-keys", "main-keyboard", "nav-cluster", "arrows", "keypad", "keypad-nums", "all"]

BTW latest version wan't register events in gamesense:

thumb_16160582016-08-23_10-52-12.png

Edited by lazik

Share this post


Link to post

Short link
Share on other sites

(handler "HP" (lambda (data)
    (let* ((v (value: data))
           (c (color-between red-color green-color v)))
( on-device 'headset show: c )
(on-device  show-percent-on-zone: c v function-keys:))
))

(add-event-per-key-zone-use "HP" "function-keys")

Edited by lazik

Share this post


Link to post

Short link
Share on other sites

(handler "HP" (lambda (data)

    (let* ((v (value: data))

           (c (color-between red-color green-color v)))

( on-device 'headset show: c )

(on-device  show-percent-on-zone: c v function-keys:))

))

(add-event-per-key-zone-use "HP" "function-keys")

(handler "SETRGB" (lambda (data)
    (let* (
         	(r (r: data))
			(g (g: data))
			(b (b: data))		
	(n(list r g b)))

	( on-device 'rgb-per-key-zones show-on-zone: n function-keys: )	
	)
))


(handler "HP" (lambda (data)
    (let* ((v (value: data))
           (c (color-between red-color green-color v)))
	
	
	( on-device 'rgb-per-key-zones show-on-zone: c function-keys: )
	
	
	)
))

or

(handler "SETRGB" (lambda (data)
    (let* (
         	(r (r: data))
			(g (g: data))
			(b (b: data))		
	(n(list r g b)))
	
	( on-device 'keyboard show-on-zone: n function-keys: )	
	)
))



(handler "HP" (lambda (data)
    (let* ((v (value: data))
           (c (color-between red-color green-color v)))
	
		
	( on-device 'keyboard show-on-zone: c function-keys: )
	
	
	)
))

after any changes in handler you must restart steelseries engine

Edited by adjgam

Share this post


Link to post

Short link
Share on other sites

Your examples isn't working.

 

From https://github.com/SteelSeries/gamesense-sdk/blob/master/doc/api/writing-handlers-in-golisp.md

(handler "HEALTH"
  (lambda (data)
    (let* ((v (value: data))
           (c (color-between red-color green-color v))
      (on-device 'rgb-per-key-zones show-percent-on-zone: c v function-keys:)
      (on-device 'rgb-2-zone show-on-zone: c two:)
      (on-device 'rgb-1-zone show-on-zone: c one:)))))
(add-event-per-key-zone-use "HEALTH" "function-keys")
5.The last line of this example declares that the HEALTH event utilizes the function-keys zone on per-key-illuminated devices. This is necessary for initialization of the proper keys on the Apex M800 (and other future per-key-illuminated devices). 

So IMVHO should be

(handler "SETRGB"
(lambda (data)
  (let* (
          (r (r: data))
   (g (g: data))
   (b (b: data))
    (n(list r g b))
     ( on-device 'headset show: n )
     ( on-device 'rgb-per-key-zones show-on-zone: n function-keys: )
     (on-device 'rgb-2-zone show-on-zone: c two:)
     (on-device 'rgb-1-zone show-on-zone: c one:))
  )
)
)
(handler "HP"
(lambda (data)
  (let* ((v (value: data))
   (c (color-between red-color green-color v))
    ( on-device 'headset show: c )
    (on-device  'rgb-per-key-zones show-percent-on-zone: c v function-keys:)
    (on-device 'rgb-2-zone show-on-zone: c two:)
    (on-device 'rgb-1-zone show-on-zone: c one:))
  )
)
)
(add-event-per-key-zone-use "HP" "function-keys")

and this I think looks good but not receive HP value and keys ara not illuminated.

 

BTW after changes in lsp file must be Steelseries Engine restarted and also WoT. Every engine restart port in coreProps.json is changed.

Edited by lazik

Share this post


Link to post

Short link
Share on other sites

Hmmm, tested with your app and all keys isn't iluminated and nothing changes after sending geme_event data. There is no errors. hmmm....?

 

Tested all variants on this lsp

(handler "SETRGB"
(lambda (data)
  (let* (
          (r (r: data))
   (g (g: data))
   (b (b: data))
    (n(list r g b))
     (on-device 'headset show: n )
     (on-device 'rgb-per-key-zones show-on-zone: n keypad: )
     (on-device 'rgb-2-zone show-on-zone: n two:)
     (on-device 'rgb-1-zone show-on-zone: n one:))
  )
)
)
(handler "HP"
(lambda (data)
  (let* ((v (value: data))
   (c (color-between red-color green-color v))
    (on-device 'headset show: c )
    (on-device 'rgb-per-key-zones show-percent-on-zone: c v function-keys:)
    (on-device 'rgb-2-zone show-on-zone: c two:)
    (on-device 'rgb-1-zone show-on-zone: c one:))
  )
)
)
(handler "HEALTH" (lambda (data)
  (on-device 'rgb-per-key-zones show-percent-on-zone: red-color (value: data) "logo")
  ;; Other on-device calls for other device types, other code, etc.
  ))
;; Required to initialize this zone on the M800
(add-event-per-key-zone-use "HEALTH" "logo")
(add-event-per-key-zone-use "SETRGB" "keypad")
(add-event-per-key-zone-use "HP" "function-keys")

Share this post


Link to post

Short link
Share on other sites

app work

I dont have keyboard, I cannt test handler for mouse and keyboard

 

you can see answer in app (sending data is not json, cannt connect)

logs C:\ProgramData\SteelSeries\SteelSeries Engine 3\Logs

handler can write log to see if hanler started and if function call

(write-string "handler start\n")

Share this post


Link to post

Short link
Share on other sites

I manualy registred event in gamesense, configured zone to display HP event and now everything works just fine.

 

Problem is in mod - you register all for headset and for other devices should be this changed. Without configuration this cant be flexible mod.

Edited by lazik

Share this post


Link to post

Short link
Share on other sites

I manualy registred event in gamesense, configured zone to display HP event and now everything works just fine.

 

Problem is in mod - you register all for headset and for other devices should be this changed. Without configuration this cant be flexible mod.

for keyboard we need correct handler, I cannt register event for wn8 with json request

Share this post


Link to post

Short link
Share on other sites

OK, I edited all and for M800 is working all.

 

WOT.lsp:

;
;-------------------------------------------------------------------------
;  Author adjgam
;-------------------------------------------------------------------------
;
;
;  Usage:
;
;  POST http://127.0.0.1:<port>/game_event
;  ContentType:= 'application/json';
;
;     {"game":"WOT","event":"SETRGB","data":
;         {
;             "r": 255,
;             "g": 0,
;             "b": 0,
;         }
;   }
;
(handler "SETRGB"
(lambda (data)
  (let* (
          (r (r: data))
   (g (g: data))
   (b (b: data))
    (n(list r g b))
     (on-device 'headset show: n )
     (on-device 'rgb-per-key-zones show-on-zone: n keypad: )
     (on-device 'rgb-2-zone show-on-zone: n two:)
     (on-device 'rgb-1-zone show-on-zone: n one:))
  )
)
)
(handler "HP"
(lambda (data)
  (let* ((v (value: data))
   (c (color-between red-color green-color v))
    (on-device 'headset show: c )
    (on-device 'rgb-per-key-zones show-percent-on-zone: c v function-keys:)
    (on-device 'rgb-2-zone show-on-zone: c two:)
    (on-device 'rgb-1-zone show-on-zone: c one:))
  )
)
)
;(handler "HEALTH" (lambda (data)
;  (on-device 'rgb-per-key-zones show-percent-on-zone: red-color (value: data) "logo")
  ;; Other on-device calls for other device types, other code, etc.
;  ))
;; Required to initialize this zone on the M800
;(add-event-per-key-zone-use "HEALTH" "logo")
;(add-event-per-key-zone-use "SETRGB" "keypad")
(add-event-per-key-zone-use "HP" "function-keys")

mod_gamesense.pyc:

import BigWorld
import os
import os.path
import json
import httplib, urllib2
from Avatar import PlayerAvatar
from items import vehicles
from Vehicle import Vehicle
from Account import PlayerAccount
import Math
import math
import threading
print "[MOD] Gamesense loaded"
Autor = 'adjgam'
url = ''
LastHP = 0
def threadDecorate(object):
    def decorate(*args, **kwargs):
        th = threading.Thread(target=object, args=args, kwargs=kwargs)
        th.setName = object.func_name
        th.setDaemon = True
        th.start()
    return decorate
# read GameSense url
def Gamesense_ReadUrl():
    with open(os.getenv('PROGRAMDATA')+'/SteelSeries/SteelSeries Engine 3/coreProps.json', 'r') as f:
        data = json.load(f)
    global url
    url = 'http://' + data['address']
# register game
@threadDecorate
def Gamesense_RegisterGame():
    data = {"game":"WOT","game_display_name":"World Of Tanks","icon_color_id":11}
    req = urllib2.Request(url+'/game_metadata')
    req.add_header('Content-Type', 'application/json')
    response = urllib2.urlopen(req, json.dumps(data), timeout = 10)
# delete game
@threadDecorate
def Gamesense_DeleteGame():
    data = {"game":"WOT"}
    req = urllib2.Request(url+'/remove_game')
    req.add_header('Content-Type', 'application/json')
    response = urllib2.urlopen(req, json.dumps(data), timeout = 10)
# register HP event
@threadDecorate
def Gamesense_RegisterHpEvent():
    data = { "game":"WOT", "event":"HP", "min_value":1, "max_value":100, "icon_id":1, "handlers": [{"device-type":"rgb-per-key-zones", "zone":"function-keys", "mode":"percent", "color": {"gradient":{ "zero": {"red":255,"green":0,"blue":0}, "hundred": {"red":0,"green":255,"blue":0}}}, "rate": {"frequency": [{"low": 0, "high": 10, "frequency": 10},{"low": 11, "high": 20, "frequency": 5}, {"low": 21, "high": 100, "frequency": 2}], "repeat_limit": [{"low": 11, "high": 20, "repeat_limit": 10},{"low": 21, "high": 40, "repeat_limit": 10},{"low": 41, "high": 70, "repeat_limit": 5}]}}]}
    req = urllib2.Request(url+'/bind_game_event')
    req.add_header('Content-Type', 'application/json')
    response = urllib2.urlopen(req, json.dumps(data), timeout = 10)
   
# delete game event
@threadDecorate
def Gamesense_DeleteEvent(EventName):
    data = {"game":"WOT","event": EventName}
    req = urllib2.Request(url+'/remove_game_event')
    req.add_header('Content-Type', 'application/json')
    response = urllib2.urlopen(req, json.dumps(data), timeout = 10)
# post HP change event 0..100
@threadDecorate
def HpChange(n):
    data = {"game":"WOT","event":"HP","data":{"value": n}}
    req = urllib2.Request(url+'/game_event')
    req.add_header('Content-Type', 'application/json')
    response = urllib2.urlopen(req, json.dumps(data), timeout = 10)
# change color
@threadDecorate
def Gamesense_SetRgb(r, g, b):
    data = {"game":"WOT","event":"SETRGB","data":{"r": r, "g": g, "b": b}}
    req = urllib2.Request(url+'/game_event')
    req.add_header('Content-Type', 'application/json')
    response = urllib2.urlopen(req, json.dumps(data), timeout = 10)
# post Keepalive Event
@threadDecorate
def Gamesense_PostHearBeat():
    data = {"game":"WOT"}
    req = urllib2.Request(url+'/game_heartbeat')
    req.add_header('Content-Type', 'application/json')
    response = urllib2.urlopen(req, json.dumps(data), timeout = 10)
# gamesense hearbeat     15s = set default
@threadDecorate
def _loop():
    Gamesense_PostHearBeat()
    BigWorld.callback(10, _loop)
   
# on battle loaded set green   
def _onInitStepCompleted(self):
    orig_onInitStepCompleted(self)
    CheckHp()
# on hp change
@threadDecorate
def CheckHp():
    playerVehicle = BigWorld.entity(BigWorld.player().playerVehicleID)     
    global LastHP  
    if playerVehicle is not None and playerVehicle.isStarted and playerVehicle.isPlayerVehicle:
        HP = playerVehicle.health
        MaxHP = playerVehicle.typeDescriptor.maxHealth
        if LastHP == HP:
            return
        LastHP = HP
        if HP>0 and playerVehicle.isAlive():
            HPPercent = math.trunc(HP*100/MaxHP)
            HpChange(HPPercent)            
        else:
            Gamesense_SetRgb(0 ,0, 0)
            return   
    return

def _onHealthChanged(self, newHealth, attackerID, attackReasonID):
    orig_onHealthChanged(self, newHealth, attackerID, attackReasonID)
    CheckHp()
   
def _onLeaveWorld(self):
    orig_onLeaveWorld(self)
    Gamesense_SetRgb(0,0,0)  
def _PlayerAccount_onBecomePlayer(self):
    orig_PlayerAccount_onBecomePlayer(self)
    Gamesense_SetRgb(0,0,0)
   
# check file exists
if os.path.isfile(os.getenv('PROGRAMDATA')+'/SteelSeries/SteelSeries Engine 3/coreProps.json'):   
    # PlayerAvatar.onLeaveWorld
    orig_onLeaveWorld = PlayerAvatar.onLeaveWorld
    PlayerAvatar.onLeaveWorld = _onLeaveWorld      
   
    # Vehicle.onHealthChanged
    orig_onHealthChanged = Vehicle.onHealthChanged
    Vehicle.onHealthChanged = _onHealthChanged   
   
    # PlayerAvatar._PlayerAvatar__onInitStepCompleted
    orig_onInitStepCompleted = PlayerAvatar._PlayerAvatar__onInitStepCompleted
    PlayerAvatar._PlayerAvatar__onInitStepCompleted = _onInitStepCompleted       
   
    # on login
    orig_PlayerAccount_onBecomePlayer = PlayerAccount.onBecomePlayer
    PlayerAccount.onBecomePlayer = _PlayerAccount_onBecomePlayer
        
    Gamesense_ReadUrl()
    Gamesense_RegisterGame()
    Gamesense_SetRgb(0, 0, 0)  # set color (0,0,0)  on game init   
    _loop()   
else:
    print "[mod] Gamesense: file /SteelSeries/SteelSeries Engine 3/coreProps.json not found"

In pyc file I ended 54 line to have proper zone and device. This must be in config to have flexible mod.

 

Now other questions:

- can we add frags counter and change colors or keys ilumination (like in CS:GO plugin)?

- is there chance to add event for using consumables (example: if used key 4 is turend off etc.)

- its possible to recognize that shells on 1, 2, 3 key are active?

- can you add fire event? (if tank is on fire for example keyboard is blinks red)

- wn8 rating on zone?

...


I think if we change in line 54

"device-type":"rgb-per-key-zones"

to 

"device-type":"keyboard"

 

"zone":"function-keys" will work also for other keyboards (excluding MSI GE62 and GE72)

Share this post


Link to post

Short link
Share on other sites

- can we add frags counter and change colors or keys ilumination (like in CS:GO plugin)?

event from game with count > hange colors keys 1,2,3 and other color if <10 frags

 

- wn8 rating on zone?  

I wont to show it on headset but i dont have wn8 mod

 

- can you add fire event? (if tank is on fire for example keyboard is blinks red)

i can add event in .py and send something

Share this post


Link to post

Short link
Share on other sites

hi adjgam. is it possible to build a mod for world of warships for my keyboard ? I have a gt72 Notebook with steelseries Keyboard where 3 iluminating color changing zones are on the keyboard, 1 for the mousepad and 1 for the front lites. maybe you can help me with that. best regards, rip

Share this post


Link to post

Short link
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...