Compile error with orxSYSTEM_EVENT_PAYLOAD

edited August 2012 in Help request
Hi Iarwain / lydesik ,

I'm converting my mouse inputs to touch events all is working well with the touch begin, end and move events.

But I am trying to get the touch position from the orxSYSTEM_EVENT_PAYLOAD payload.

It appears on svn that the properties of fX and fY are not known. Codelite's code completion recognises them ok.

My code is:
if (_pstEvent->eType == orxEVENT_TYPE_SYSTEM){
			
	orxSYSTEM_EVENT_PAYLOAD *payload;
	payload = (orxSYSTEM_EVENT_PAYLOAD *) _pstEvent->pstPayload;

	orxLOG("Location %f x %f", payload.fX, payload.fY);

I realise acksys has a similar problem here: https://forum.orx-project.org/discussion/4432#Comment_4473 but my code is also sitting under the right conditional.

Codelite says:
error: request for member 'fX' in 'payload', which is of non-class type 'orxSYSTEM_EVENT_PAYLOAD*'
error: request for member 'fY' in 'payload', which is of non-class type 'orxSYSTEM_EVENT_PAYLOAD*'

I am probably doing something very simple to cause the issue but it's late and I'm getting fuzzy :)

Can I just stick to using getting mouse positions for now? Do these map under Android and iOS?

Comments

  • edited August 2012
    Hi,

    According to the docs orxSYSTEM_EVENT_PAYLOAD contains an union:
    union {
       struct {
          orxDOUBLE   dTime;
          orxVECTOR   vAcceleration;
       }   stAccelerometer;
       struct {
          orxDOUBLE   dTime;
          orxFLOAT   fPressure;
          orxFLOAT   fX;
          orxFLOAT   fY;
          orxU32   u32ID;
       }   stTouch;
       orxU32   u32FrameCounter;
    }; 
    
    So shouldn't it work as in the thread by acksys:
    payload.stTouch.fX instead of payload.fX
    and shouldn't you check that this is indeed touch event not accelerometer event which is missing from your example.

    I haven't really tried myself so I could be wrong ;).

    Cheers,
    Graag
  • edited August 2012
    Also, small detail that has its importance: your "payload" variable is a pointer so: payload->stTouch.fX/payload->stTouch.fY! ;)
  • edited August 2012
    Guys, many thanks! It works!

    The codelite compile error has to do with me not going through the stTouch property first.

    Thanks graag for the bit on the union. So these are not properties unless the payload is of a type system, and is to do with touch.

    My working example is now:
    if (_pstEvent->eType == orxEVENT_TYPE_SYSTEM){
        if(_pstEvent->eID == orxSYSTEM_EVENT_TOUCH_BEGIN){
            orxSYSTEM_EVENT_PAYLOAD *payload; 
            payload = (orxSYSTEM_EVENT_PAYLOAD *) _pstEvent->pstPayload; 
    			
            orxLOG("X Pos is %f", payload->stTouch.fX);
        }
    }
    

    Now the interesting thing is that Codelite is code completing the fX property directly under the payload, eg:

    payload->fX

    ... but it will not code complete fX under stTouch.

    The compiler will get upset, of course, about payload->fX and not about payload->stTouch.fX.

    So I get the impression there is something wrong in the includes that Codelite uses to generate it's tags for this struct.
  • edited August 2012
    You can try to rebuild the symbol/tag database in codelite, but it might just be a bug about unions that you can report to the author of CodeLite, Eran Ifrah, via its sourceforge project page.
  • edited August 2012
    Hi Iarwain, I've reported that at: https://sourceforge.net/tracker/?func=detail&aid=3563069&group_id=202033&atid=979960

    I noticed you reported a similar thing a couple of times in 2008. Perhaps it's a bug that crept back in.
  • edited August 2012
    Nice. It might have been, I've been asking for a bunch of features/fixes a few years ago when CodeLite was still early in development and Eran was always very reactive back then.

    Haven't been using CodeLite much lately, there's a few things I don't like and I've been focusing on visual studio instead (often using Sublime Text 2 as the main editor and compiling under VS).
  • edited August 2012
    Sublime Text 2 looks very nice.

    I've gone the other way, I'm moving more to CodeLite rather than VS due to it being easier for me to configure etc, and not so heavy. Also can move from OS to OS.

    Nice to have the choice.
  • edited August 2012
    Definitely!

    I'm using Sublime Text 2 on all 3 OSes and will probably use Acksys' work with premake when it's ready to generate makefiles for all platforms and build directly from within it.
Sign In or Register to comment.