Visionaire Studio 4.2.5 Released

  • #120, by sebastianSunday, 28. August 2016, 03:17 8 years ago
    any idea what i am doing wrong here?

    Thread Captain

    2346 Posts


  • #121, by afrlmeSunday, 28. August 2016, 12:13 8 years ago
    I believe you have to do a key down, then key up to make it work correctly. What are the x,y coordinates for & the 0 at the end?

    Imperator

    7278 Posts

  • #122, by sebastianSunday, 28. August 2016, 14:38 8 years ago
    hehe...i dont know why these are there. you posted me a code with these in on page 12 wink
    I guess the coordinates are important if you create a mouse event and need to define the coordinates.
    The code above works great for keys like eKeyEsc or eKeySpace

    Thread Captain

    2346 Posts

  • #123, by afrlmeSunday, 28. August 2016, 14:48 8 years ago
    I think there's a bug with F5 key event actions. On my windows laptop anything I assign to F5 key or F5 (released) doesn't seem to execute with VS. I know the F5 key on my keyboard works though as I often use it to quickly refresh website pages.

    As for the code, I must have gotten it from Simon or a script that he or David shared. It seems that key events seem to need those input variables for some reason, whereas mouse events can be triggered with a single input variable, for example...
    createEvent('eEvtMouseLeftButtonDown'); createEvent('eEvtMouseLeftButtonUp') -- simulate left mouse button click
    

    P.S: try swapping the F5 (released) to F12 (released) or C (released) or something else & see if the screenshot thing works.

    P.S.S: screenshot requires the folder you are saving the screenshots to already exist otherwise VS won't generate the screenshot.

    Imperator

    7278 Posts

  • #124, by sebastianSunday, 28. August 2016, 16:02 8 years ago
    really? I chose the only F-Key which has problems? shock

    P.S: Yes, screenshot folder exists. It works fine if i press F5 manually.

    Thread Captain

    2346 Posts

  • #125, by afrlmeSunday, 28. August 2016, 16:40 8 years ago
    Hmm, maybe it's not eKeyF5?

    Do you have a key event handler script? If you do then try printing out the character, keycode, modifiers. It should print to log each time you press a key & let you know which key you have pressed.

    function keyboardHandler(eventType, character, keycode, modifiers)
      print(keycode, character, modifiers) -- print currently pressed keys character name, keycode name, modifier name
      return false -- key event will also be handled by engine
    end
     
    registerEventHandler("keyEvent", "keyboardHandler")
    

    Imperator

    7278 Posts

  • #126, by sebastianSunday, 28. August 2016, 18:03 8 years ago
    Eventtype: 1
    character: F5
    keycode: 10737418860
    modifier:

    I used the ascii code table for keys (I hope this is correct):

    [code]
    KeyCode Key ASCII code
    eKeyCtrlA Ctrl+A 1
    eKeyCtrlB Ctrl+B 2
    eKeyCtrlC Ctrl+C 3
    eKeyCtrlD Ctrl+D 4
    eKeyCtrlE Ctrl+E 5
    eKeyCtrlF Ctrl+F 6
    eKeyCtrlG Ctrl+G 7
    eKeyCtrlH Ctrl+H 8
    eKeyCtrlI Ctrl+I 9
    eKeyCtrlJ Ctrl+J 10
    eKeyCtrlK Ctrl+K 11
    eKeyCtrlL Ctrl+L 12
    eKeyCtrlM Ctrl+M 13
    eKeyCtrlN Ctrl+N 14
    eKeyCtrlO Ctrl+O 15
    eKeyCtrlP Ctrl+P 16
    eKeyCtrlQ Ctrl+Q 17
    eKeyCtrlR Ctrl+R 18
    eKeyCtrlS Ctrl+S 19
    eKeyCtrlT Ctrl+T 20
    eKeyCtrlU Ctrl+U 21
    eKeyCtrlV Ctrl+V 22
    eKeyCtrlW Ctrl+W 23
    eKeyCtrlX Ctrl+X 24
    eKeyCtrlY Ctrl+Y 25
    eKeyCtrlZ Ctrl+Z 26
    eKey0 0 48
    eKey1 1 49
    eKey2 2 50
    eKey3 3 51
    eKey4 4 52
    eKey5 5 53
    eKey6 6 54
    eKey7 7 55
    eKey8 8 56
    eKey9 9 57
    eKeyA A 65
    eKeyB B 66
    eKeyC C 67
    eKeyD D 68
    eKeyE E 69
    eKeyF F 70
    eKeyG G 71
    eKeyH H 72
    eKeyI I 73
    eKeyJ J 74
    eKeyK K 75
    eKeyL L 76
    eKeyM M 77
    eKeyN N 78
    eKeyO O 79
    eKeyP P 80
    eKeyQ Q 81
    eKeyR R 82
    eKeyS S 83
    eKeyT T 84
    eKeyU U 85
    eKeyV V 86
    eKeyW W 87
    eKeyX X 88
    eKeyY Y 89
    eKeyZ Z 90
    eKeyAmpersand & 38
    eKeyAsterisk * 42
    eKeyAt @ 64
    eKeyBackSlash \ 92
    eKeyBackspace Backspace 8
    eKeyCloseBracket ] 93
    eKeyCloseParenthesis ) 41
    eKeyColon : 58
    eKeyComma , 44
    eKeyDelete Delete 383
    eKeyDollar $ 36
    eKeyDoubleQuote " 34
    eKeyEquals = 61
    eKeyEscape ESC 27
    eKeyExclamationMark ! 33
    eKeyForwardSlash / 47
    eKeyGreaterThan > 62
    eKeyHash # 35
    eKeyHyphen - 45
    eKeyInsert Insert 382
    eKeyLessThan < 60
    eKeyOpenBracket [ 91
    eKeyOpenParenthesis ( 40
    eKeyPercent % 37
    eKeyPeriod . 46
    eKeyPlus + 43
    eKeyQuestionMark ! 33
    eKeyReturn RETURN 13
    eKeySemiColon ; 59
    eKeySingleQuote ' 39
    eKeySpace SPACE 32
    eKeyTab TAB 9
    eKeyUnderscore _ 95
    eKeyF1 F1 359
    eKeyF2 F2 360
    eKeyF3 F3 361
    eKeyF4 F4 362
    eKeyF5 F5 363
    eKeyF6 F6 364
    eKeyF7 F7 365
    eKeyF8 F8 366
    eKeyF9 F9 367
    eKeyF10 F10 368
    eKeyF11 F11 433
    eKeyF12 F12 434
    eKeyHome Home 371
    eKeyUpArrow UpArrow 372
    eKeyPageUp PageUp 373
    eKeyLeftArrow LeftArrow 375
    eKeyNumPad5 NumPad 5 376
    eKeyRightArrow RightArrow 377
    eKeyEnd End 379
    eKeyDownArrow DownArrow 380
    eKeyPageDown PageDown 381
    [/code]

    Thread Captain

    2346 Posts

  • #127, by afrlmeSunday, 28. August 2016, 18:06 8 years ago
    I think ascii is correct. Could try googling for them on the official sdl2 lib website. I think most key names are listed on it.

    Imperator

    7278 Posts

  • #128, by sebastianSunday, 28. August 2016, 18:11 8 years ago
    every F-Key doesnt work for me.
    when executing the createEvent to simulate the Key this appears in the console:
    8:08:39: key up: 4 ? 10000050
    18:08:39: key up: 5 ? 10000050
    18:08:39: Error: Wrong argument type for Argument #3 (expected int)
    18:08:39: Error: Failed to execute hook function 'keyboardHandler': [string "mouse_keyboard_handling"]:67: Invalid syntax for command createEvent
    

    Third argument is the Key:
    createEvent('eEvtKeyUp', {x=0,y=0}, eKeyF5, 0)
    


    Any idea what "int" i can use? maybe the keycode instead of eKeyF5?

    Thread Captain

    2346 Posts

  • #129, by afrlmeSunday, 28. August 2016, 18:19 8 years ago
    Yeah, probably the keycode. eKeyF5 should technically return a keycode as it's actually a variable already defined by VS, though it's possible eKeyF5 is the incorrect name for the variable / key.

    * edit: swapping eKeyF5 with 1073741886 seems to work for getting the create event to work, however it doesn't seem to bother triggering the actions listed under the F5 (released) actions for some reason.

    Quick question: why are you trying to create an F5 event? Why not simply add the screenshot code to whatever it is that you are wanting to use to trigger it?

    Imperator

    7278 Posts

  • #130, by sebastianSunday, 28. August 2016, 18:43 8 years ago
    because of preventing redundant code.
    The workaround i am doing now is using a "call action" action part under F5 and call the function which does the screenshot (so moving it somewhere else) and also call this function via Lua when pressing "select".

    Thread Captain

    2346 Posts