libgem - evnt_multi undeclared

C and PASCAL (or any other high-level languages) in here please

Moderators: simonsunnyboy, Mug UK, Zorro 2, Moderator Team

MegatronUK
Atariator
Atariator
Posts: 23
Joined: Fri Jan 04, 2019 11:11 am

libgem - evnt_multi undeclared

Postby MegatronUK » Thu Jan 31, 2019 3:32 pm

I'm adding some GEM native event handling to my application and according to the documentation here, here and here, I need to listen for input events using evnt_multi().

This seems to be defined in /usr/m68k-atari-mint/sys-root/usr/include/gem.h

Code: Select all

$ grep evnt_multi /usr/m68k-atari-mint/sys-root/usr/include/gem.h
/** single-thread version of mt_evnt_multi() */
#define evnt_multi(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v) \
                              mt_evnt_multi(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,aes_global)
/** single-thread version of mt_evnt_multi_fast() */
#define evnt_multi_fast(a,b,c)         mt_evnt_multi_fast(a,b,c,aes_global)


The symbols are also present in in /usr/m68k-atari-mint/sys-root/usr/lib/libgem.a:

Code: Select all

m68k-atari-mint-nm /usr/m68k-atari-mint/sys-root/usr/lib/libgem.a  | grep evnt
...
...
00000000 T _mt_evnt_multi
a_evnt_multi_fast.o:
00000000 T _mt_evnt_multi_fast
a_evnt_timer.o:
00000000 T _mt_evnt_timer
00000164 T _evnt_button
00000198 T _evnt_dclick
000001b6 T _evnt_keybd
000001c8 T _evnt_mesag
000001dc T _evnt_mouse
0000021c T _evnt_multi
000002a2 T _evnt_multi_fast
000002c0 T _evnt_timer
         U _mt_evnt_button
         U _mt_evnt_dclick
         U _mt_evnt_keybd
         U _mt_evnt_mesag
         U _mt_evnt_mouse
         U _mt_evnt_multi
         U _mt_evnt_multi_fast
         U _mt_evnt_timer
        ...
        ...


I have a basic piece of code that I will eventually turn in to my event handler:

Code: Select all

#include <gem.h>

// Poll the input event queue
int inputPollEvent(struct agnostic_event *event){
   int r;
   event->event = evnt_multi(ev_flags,
      btn_clicks, btn_mask, btn_state,
      r1_flags, r1_x, r1_y, r1_w, r1_h,
      r2_flags, r2_x, r2_y, r2_w, r2_h,
      &msg_buff,
      time_hi, time_lo,
      &mx, &my, &btn, &kbd, &c, &clicks
   );
   return r;
}


The problem is that gcc reports that evnt_multi() has the wrong number of arguments:

Code: Select all

/usr/m68k-atari-mint/bin/gcc -Wall -Wno-unused-function -Wno-unused-variable -Os -I/usr/m68k-atari-mint/sys-root/usr/include -DTOS -DDIR_SEP=\"/\" -DGAMEDIR=\"./GAMES\" -DCSV_FILE=\"MENU.CSV\" -DLOGGING -DUSE_GEM   -c -o src/logging.o src/logging.c
/usr/m68k-atari-mint/bin/gcc -Wall -Wno-unused-function -Wno-unused-variable -Os -I/usr/m68k-atari-mint/sys-root/usr/include -DTOS -DDIR_SEP=\"/\" -DGAMEDIR=\"./GAMES\" -DCSV_FILE=\"MENU.CSV\" -DLOGGING -DUSE_GEM   -c -o src/input.o src/input.c
In file included from src/input.c:28:0:
src/input_gem.h: In function 'inputPollEvent':
src/input_gem.h:14:2: error: macro "evnt_multi" passed 23 arguments, but takes just 22
src/input_gem.h:7:17: error: 'evnt_multi' undeclared (first use in this function)
src/input_gem.h:7:17: note: each undeclared identifier is reported only once for each function it appears in
<builtin>: recipe for target 'src/input.o' failed
make: *** [src/input.o] Error 1


The define for evnt_multi in gem.h lists 22 parameters:

Code: Select all

#define evnt_multi(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v)


The gemlib library definitions matches the above (naturally), but the sample calls in all of the other documentation list 23 parameters (as well as a 24th, the aes_global[] global variable, that is passed to the backend mt_evnt_multi() call.).

So the documentation lists 23 parameters, the header file 22. It appears that gemlib has a combined timer parameter, but all of the other documentation lists seperate high and low byte values for the timer.

Can anyone who has used gemlib confirm that this is the case and that I should just ignore the documentation which lists seperate timer values?

mikro
Hardware Guru
Hardware Guru
Posts: 2034
Joined: Sat Sep 10, 2005 11:11 am
Location: Kosice, Slovakia
Contact:

Re: libgem - evnt_multi undeclared

Postby mikro » Thu Jan 31, 2019 4:09 pm

Yeah, that's OK. It would be pretty annoying to enter lo/hi word of the timer value, especially when we use 32-bit integers, wouldn't it. :)

ThorstenOtto
Atari Super Hero
Atari Super Hero
Posts: 811
Joined: Sun Aug 03, 2014 5:54 pm

Re: libgem - evnt_multi undeclared

Postby ThorstenOtto » Thu Jan 31, 2019 4:35 pm

It appears that gemlib has a combined timer parameter, but all of the other documentation lists seperate high and low byte values for the timer.


Yes, in gemlib, that was unfortunately combined into a long value instead of 2 separate values like e.g in Pure-C, and most other bindings. Same is true for the evnt_timer() function. The documentation lists the actual binding that is used by AES.
Note that, mostly because of the vast amount of parameters to the evnt_multi() call, there are also several other bindings available, which use structures instead. "Several" because unluckily different authors invented their own strategy to work around it. Also, some of those structures are used by the WDIALOG functions, or their callbacks.

Mikro wrote:especially when we use 32-bit integers, wouldn't it. :)


Actually, i think this was a bad decision. Not only that it makes gemlib incompatible to most other libraries, but it also does not help much, because in the actual binding, the 32-bit value has to be swapped again.

MegatronUK
Atariator
Atariator
Posts: 23
Joined: Fri Jan 04, 2019 11:11 am

Re: libgem - evnt_multi undeclared

Postby MegatronUK » Thu Jan 31, 2019 8:46 pm

Cheers folks - it took an hour or so to work out the correct masks for the events I wanted, but it's working now!

I'm only looking at keyboard input at present, but will probably look at adding mouse and joystick in the future.

ThorstenOtto
Atari Super Hero
Atari Super Hero
Posts: 811
Joined: Sun Aug 03, 2014 5:54 pm

Re: libgem - evnt_multi undeclared

Postby ThorstenOtto » Fri Feb 01, 2019 1:25 am

MegatronUK wrote:but will probably look at adding mouse and joystick in the future.


Mouse events are no problem, but joystick events are not reported by evnt_multi(). I don't have much experience with querying joysticks, but i would think you have to add MU_TIMER to the flags, and then check the joystick in the timer handling code.

mikro
Hardware Guru
Hardware Guru
Posts: 2034
Joined: Sat Sep 10, 2005 11:11 am
Location: Kosice, Slovakia
Contact:

Re: libgem - evnt_multi undeclared

Postby mikro » Fri Feb 01, 2019 6:55 am

ThorstenOtto wrote:
Mikro wrote:especially when we use 32-bit integers, wouldn't it. :)


Actually, i think this was a bad decision. Not only that it makes gemlib incompatible to most other libraries, but it also does not help much, because in the actual binding, the 32-bit value has to be swapped again.

I meant it purely from a programmer point of view - it took me a moment to realise that too but as soon as I knew, I was pretty relieved that I don't have to pollute my code with the shifts.


Social Media

     

Return to “C / PASCAL etc.”

Who is online

Users browsing this forum: No registered users and 3 guests