Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
New Desktop API - test — Gideros Forum

New Desktop API - test

tkhnomantkhnoman Member
edited September 2015 in Roadmap
Hi guys,
Lately i tried things with Windows Desktop Export, and realized that it can have so many API.
I tried to minimize the API so it won't bother other device when updating it, and here is what i get:

application:set(what,...)
application:get(what)

--------------------------------------------------------------------

You can print all available API by doing :
application:set("help")
application:get("help")

This is also applied on type of each API, for example :
application:set("cursor","help")

--------------------------------------------------------------------

Currently available API :

- application:set("cursor",type)
arrow
upArrow
cross
wait
IBeam
sizeVer
sizeHor
sizeBDiag
sizeFDiag
sizeAll
blank
splitV
splitH
pointingHand
forbidden
openHand
closedHand
whatsThis
busy
dragMove
dragCopy
dragLink

- application:set("windowModel",type)
reset
stayOnTop --- can stack with other
stayOnBottom --- can stack with other
frameless --- can stack with other
noTitleBar
noWindowButton
onlyMinimize
onlyMaximize
onlyClose
noMinimize
noMaximize
noClose
helpButton

Stack example :
application:set("windowModel","closeOnly")
application:set("windowModel","stayOnTop")

- application:set("windowTitle",title)

- application:set("windowPosition",x,y)

- application:set("windowSize",w,h)

- application:set("minimumSize",w,h) -- for scaling

- application:set("maximumSize",w,h) -- for scaling

- application:set("windowColor",red,green,blue)

- application:set("cursorPosition",x,y)

--------------------------------------

- application:get("windowPosition") return x,y of window

- application:get("screenSize") return screen size w,h

- application:get("windowSize") return window size w,h

- application:get("cursorPosition") return window size x,y

--------------------------------------


As i mainly operate on Windows, i would not build Mac OSX for testing.
Also, feel free to request any new things regarding Desktop. \:D/

Likes: pie, SinisterSoft

+1 -1 (+2 / -0 )Share on Facebook
«1

Comments

  • tkhnomantkhnoman Member
    edited July 2015
    [2] Fixed some of cursor tipe displacement, and change set "position" to "windowPosition"


    --- Also for just testing purpose, probably would add later on as real event ---
    function printPressure(event)
    	print(event.touch.id)
    end
     
    stage:addEventListener(Event.TOUCHES_BEGIN, printPressure)
    stage:addEventListener(Event.TOUCHES_MOVE, printPressure)
    stage:addEventListener(Event.TOUCHES_END, printPressure)
    This is generate pressure at "id" variable for Pen Tablet (such wacom),

    Make sure at Project Properties, you don't tick "Touch events generate mouse events" for this test.


    zip
    zip
    gideros-2015.07.15 Custom[2].zip
    1M

    Likes: pie

    +1 -1 (+1 / -0 )Share on Facebook
  • @tkhnoman, it works!!!! (on my wacom intuos 3) a value between 1-10000 i got depending on how much i press.

    so please implement it so that it's received on say event.touch.pressure.
    and will the same work on mac? i don't have any to test but my friends would use it on mac too, so it would be good to have it.

    last, it would be nice if pressure on android would use the same api and i would not need to use plugin anymore and also it would work across platforms.
    in android it's a very simple thing, event.getPressure() can get pressure info called inside onTouch function, see my plugin doing this here:
    http://giderosmobile.com/forum/discussion/1557/get-stylus-pressure-information/p1
    but it's basically this one line and the rest is additional work so that it works as a plugin.

    again: thanks a lot, this is awesome, this progress is way beyond my expectations.
  • Hmm. I don't know about Android. I also won't test on another platform beside Windows.
    But the event itself is global, i will try to manage it more as a real event and try to ask a pull request

  • [3] removed tablet from touches, and added as real event.

    Now the app can receive :
    function printPressure(event)
    	print(event.pressure)
    	-- for k,v in pairs( event ) do
    		-- print(k,v)
    	-- end
    end
     
    stage:addEventListener(Event.PENTABLET_PRESS, printPressure)
    stage:addEventListener(Event.PENTABLET_MOVE, printPressure)
    stage:addEventListener(Event.PENTABLET_RELEASE, printPressure)

    If you activated encryption for export, you need to copy it to template folder, and do non-asset only export.

    It will take some time to add it to pull request, so i don't think i will do it this week, since i need to prepare for my game.

    @keszegh Did your wacom have tilt, can you test it for me?
    zip
    zip
    gideros.2015.07.15 Custom[3].zip
    2M
  • i can test tilt.

    with this version i got errors, running your example (or anything else) in player it's:
    main.lua:2: unexpected symbol near '�'

    while win export error is:
    memory allocation error: block too big
  • Hmm... That is weird error, but i experienced that unexpected symbol error when building iOS, which i still don't know why, lol. 8-}

    Anyway, i tried to change things, probably works, probably not.
    @keszegh Can you try it again?
    zip
    zip
    gideros-2015.07.15[4].zip
    2M
  • now it's good (player and win export too), nice!
    let me know how can i test tilt.
    also i would be grateful if at some point the same would work for mac export too.
  • @keszegh ,
    	-- for k,v in pairs( event ) do
    		-- print(k,v)
    	-- end
    By uncommenting that you can know what is inside the table, and here is the component:
    pressure, x, y, tiltX, tiltY, pointerType (can indicate whether it is pen or eraser), tangentialPressure (this is rare i think, only for airbrush type)

    Actually there is still z & rotation, but i don't think i it is needed, so i removed them.

    I believe it would work on Mac, because this is native in the Qt engine.

    For Android/iOS, i think it would be "event.touch.pressure", because when i read about touch event, actually there is data to know whether it is finger or pen (different from this pentablet).

  • @tkhnoman, all these work perfectly on my intuos:
    pressure, x, y, tiltX, tiltY, pointerType
    tangentialPressure is always zero but i don't have an airbrush pen for my tablet, so i tested only with my normal wacom pen.

    why don't you add z and rotation if it's there anyway?

    so far so (very) good.


  • btw the latest exe is reported by the antivirus of a friend of mine. i guess and hope it's false, what do you think? (and how to avoid false alarm?)
  • z and rotation is for 4D mouse and Rotation Stylus, i think...
    There is also "device", which will indicate what kind of device that send the input.

    http://doc.qt.io/qt-4.8/qtabletevent.html

    There are actually 2 more event, enter_proximity and leave_proximity, which i still don't know how to handle them. Those events are the one who usually handle z.
    It's incomplete for those, but complete for just penTablet.
    So yeah, let's just leave it at that... \m/ \m/


    Regarding the virus...
    Well, i'm not sure whether it is false alarm or not, but my PC have no problem so far. :-?
    To avoid it, you can add the exception at the antivirus.
  • it's more than good enough like that in this case.
    enter and leave proximity could be another event, then hovering could be noticed by the app, but that's also not crucial.
  • ar2rsawseenar2rsawseen Maintainer
    edited July 2015
    so after some discussions, here is what I would propose
    people feel free to agree/disagree :)

    instead of setDesktopProperty/getDesktopProperty let's make it simply set/get methods
    so the values could also be tweened if needed.

    also there might be some mobile or platform specific properties we can make changeable. So in docs we could list what platforms support what properties.

    Let's make property name camelCase and let's not create property constants, as it will pollute the scope, but simply use string directly (as with Sprite:set/get methods)

    Also in that case, if you set/get value that is not for these platform, it should ignore/return nil, but not crash


    About Touches, let's make additional property pressure which returns pressure if such is available and 0 if not.

    It might be hard to add new property for touch because of the need to go through many internals, so I can change the core and you can simply add pressure for platforms you can :)

    makes sense? :)

    Likes: keszegh, pie

    +1 -1 (+2 / -0 )Share on Facebook
  • ar2rsawseenar2rsawseen Maintainer
    @tkhnoman so if we all agree, let me know if you need any help from me :)
  • @ar2rsawseen
    Great, i also love that idea.
    This make our job to add API so much easier. \m/
    (I think i will also try to give print of available method & value when it doesn't fit, that way people won't need to look at API too much)

    Well, for PenTablet, i already experienced going through many internals, and it is indeed tiring. I guess i probably can manage to add pressure for touches event. \:D/

    Likes: ar2rsawseen

    +1 -1 (+1 / -0 )Share on Facebook
  • ar2rsawseenar2rsawseen Maintainer
    great, and no worries, I will review the changes ;)
  • This one should detect pressure for touch, as event.touch.pressure
    function printPressure(event)
    	print(event.type, event.touch.pressure)
    end
     
    stage:addEventListener(Event.TOUCHES_BEGIN, printPressure)
    stage:addEventListener(Event.TOUCHES_MOVE, printPressure)
    stage:addEventListener(Event.TOUCHES_END, printPressure)
    @SinisterSoft : Could you test it for me?
    zip
    zip
    gideros-2015.07.15[5].zip
    2M
  • @keszegh
    I taken down the pen tablet pull request.
    After second thought, it might have a little impact for performance, so better not use it as standard one.
    I would try to create plugin for it.
  • ar2rsawseenar2rsawseen Maintainer
    edited July 2015
    But on Android devices you can also get pressure of touch input

    That's why I wanted to put it to touch events, so we could use it on other platforms too :)

    But that's totally up to you.

    Either way it is better to take things step by step, yes :)
  • event.touch.pressure would be more logical, @tkhnoman, is the impact on performance significant? did you test it?
    @ar2rsawseen, @tkhnoman, as a compromise isn't it possible to have something like an application:registerPressure(true)
    which would turn on pressure registering in which case event.touch.pressure has the pressure info (both on android and on desktop) while if it's
    application:registerPressure(false) , which could be the standard behaviour if there is that impact on performance, no pressure would be handled and event.touch.pressure could simply return nil.
    what do you think about this?
  • ar2rsawseenar2rsawseen Maintainer
    I don't think there is any significant performance penalty, but did not test it :)
  • if any of you make a simple test program to test the penalty, i'm willing to test it.
  • SinisterSoftSinisterSoft Maintainer
    I vote for it on touch messages - this will be on laptop touch screens soon. Windows also can tell betweek palm, finger and pen inputs - maybe something in touch to say what type of input the touch is?
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • about the test app, i meant a test app that anybody can run to test speed difference when getting only touch event vs using pen with pressure event.
  • @SinisterSoft , for now, can you test my last exe that i posted here. It contain pressure detection for touch (and not for pen tablet like the one before)

    Before people got weirder tought about this. Pen tablet and touch is two different device. They do both have pressure, but pen tablet won't create pressure on touch and vice versa.
    It's like that there is button on keyboard and controller, but they are different.

    As for the performance, it did drop but very very little and untoticable, like that if you use multiplier instead of divider, so i decide not to.

    I can manipulate pen tablet pressure to enter touch pressure, but let's try for plug in first, because there is stil tilt and other components for pen tablet.
  • [6] This is manipulated event.
    I think let's settle with this, since creating plugin is kind of hard to do. This also won't affect performance at all.

    It detect pen tablet event, but called touch event for it.
    But be aware, since pen tablet is considered mouse at Desktop, it would also generate addition touch event if "Mouse Events generate touch events" on project properties ticked.
    Luckily, it still possible for user to deal with it, because now touchEvent would also produce type. It would generate "mouse" on generated-touch-event from mouse.
    function printPressure(event)
    	print(event.type, event.touch.pressure, event.touch.type)
    end
     
    stage:addEventListener(Event.TOUCHES_BEGIN, printPressure)
    stage:addEventListener(Event.TOUCHES_MOVE, printPressure)
    stage:addEventListener(Event.TOUCHES_END, printPressure)
    Not forget to mention, there are 4 type : "finger" "pen" "mouse" "penTablet"
    pen and penTablet are different device. Haven't test whether that pen device would generate penTablet or not, because i don't have touch device that can be switched to pen.

    Once @SinisterSoft finished checking whether it works or not, i would ask for pull request for this, but would only work for Desktop.
    All pressure would be 0 and all type would be "finger" on another platform, because i won't develop on them.
    zip
    zip
    gideros-2015.07.15 - Custom[6].zip
    2M
  • SinisterSoftSinisterSoft Maintainer
    I'm sending my laptop back to Intel today (it's all packed up to go), but it's replacement is also arriving today.

    So I can't test out right now, but I will before tomorrow. I'll test it on Windows 8.1 (what it arrives with) and also on Windows 10 (what I'll be updating it to asap).

    :)
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
Sign In or Register to comment.