Mouse button events [logic.mouse.inputs script]

hello,

here is a test file about mouse button events (mouse sensor for mouse left > python script)
mouse_button_test_upbge025.blend (441.2 KB)

this makes use of logic.mouse.inputs
I did not find anything updated about how to use it so this file could help I guess,
maybe also useful for old folks like me that switch from bge to upbge (since getButtonStatus() is deprecated and buggy in upbge)

the script below (same than in the .blend) can be attached to a mouse sensor with left button event:

import bge
from bge import logic as l

sen_sta = ['negative','positive']
evbt_sta = [[0, 2],[2],[2,0],[0]]
bt_sta = ['activated', 'active', 'released', 'inactive']

def mouseLeft():

    cont = bge.logic.getCurrentController()
    own = cont.owner

    sens = cont.sensors['mouseleft']
    
    print(f'\nmouseleft sensor is {sen_sta[sens.positive]}')
    
    # deprecated/buggy in upbge 0.2.5 (just activated signal is now missing)
    getbtsta = sens.getButtonStatus(l.KX_MOUSE_BUT_LEFT)
    print(f' ButtonStatus : {getbtsta}')
    # deprecated but nice/working / + a new 'just deactivated' signal here
    mouseev = l.mouse.events[l.KX_MOUSE_BUT_LEFT]
    print(f' leftmouse.events : {mouseev}')
    ev = l.mouse.inputs[l.KX_MOUSE_BUT_LEFT]
    
    for atrnm in ['activated', 'active', 'inactive', 'invalid', 'queue', 'released', 'status', 'type', 'values']:
        atr = getattr(ev,atrnm)
        print(f' {atrnm} : {atr}')
    sta = bt_sta[evbt_sta.index(list(ev.status))] # ev.status type is EXP_ListWrapper
    print(f' sta : {sta}')

mouseLeft()

'''
lmouse.events   ev names                    ev.status   ev.values
1               activated,active,inactive   [0, 2]      [0, 1]
2               active                      [2]         [1]
3               active,inactive,released    [2, 0]      [1, 0]
0               inactive                    [0]         [0]
'''

please note its a first test, looks fine, but I guess there’s a greater way to obtain a simple sta string at the end. mouse.inputs looks great and very detailed. but could need a complete documentation.