Troubles in Commodity-land

A forum for general AmigaOS 4.x support questions that are not platform-specific
Post Reply
User avatar
OldFart
Posts: 100
Joined: Tue Jul 12, 2011 2:56 pm
Location: Groningen, Netherlands

Troubles in Commodity-land

Post by OldFart »

Hi

As the title is not very informative, I'll try and make it more clear.
Use of ICommodities->CxFilter("rawmouse leftbutton"); generates a BADFILTER errorcode. I tried to fathom the severity of the error and wrote the following little proggy:

Code: Select all

#include <proto/exec.h>
#include <proto/dos.h>
#include <proto/commodities.h>

CONST_STRPTR FD[] = {"rawmouse leftbutton"
                    ,"rawmouse rightbutton"
                    ,"rawmouse midbutton"
                    ,"rawmouse relativemouse"
                    ,"shift -alt -control a"
                    ,"rawkey lshift alt f2"
                    ,"rawkey control esc"
                    , NULL
                    };

int main(int argc, char *argv[])
{
  int RetVal = 9;

  CxObj *CO;
  int32 CxErr;
  uint16 i = 0;

  while (FD[i] != NULL)
   {
    CO = CxFilter(FD[i]);

    if (CO != NULL)
     {
      CxErr = ICommodities->CxObjError(CO);
      IDOS->Printf("Error : %ld -- %s\n", CxErr, FD[i]);
      ICommodities->ClearCxObjError(CO);

      CxErr = 0;

      ICommodities->DeleteCxObj(CO);
     }

    i++;
   }

  return RetVal;
}
It produces this output:

Code: Select all

Error : 4 -- rawmouse leftbutton
Error : 4 -- rawmouse rightbutton
Error : 4 -- rawmouse midbutton
Error : 4 -- rawmouse relativemouse
Error : 0 -- shift -alt -control a
Error : 0 -- rawkey lshift alt f2
Error : 0 -- rawkey control esc
Am I doing something wrong and, if so, what should I have done?

Btw: commodities.library has version 53.7

OldFart
X5000, appears to be sick. Dismantled jan 1, 2024.
Dead MicroA1
A1200 in ElBox, c/w Blizzard '040 @ 50MHz + SCSI module, ZIV-board c/w (o.a.) cv64/3d + flickerdoubler + FastATA-ZIV + Lots of SCSI gear, sitting idle.
RaspBerry Pi 2B, 3B, 4B/4Gb, 4B/8Gb
OrangePi 5+ 8Gb
ACER Windows 10
User avatar
Petrol
Beta Tester
Beta Tester
Posts: 175
Joined: Mon Dec 20, 2010 6:19 pm
Location: France

Re: Troubles in Commodity-land

Post by Petrol »

Hello,

Don't you have to open commodity.library somewhere in your code?
Did you had a look in the AmigaOS wiki?
http://wiki.amigaos.net/wiki/Commoditie ... ge_Library

Regards,
Xavier.
User avatar
OldFart
Posts: 100
Joined: Tue Jul 12, 2011 2:56 pm
Location: Groningen, Netherlands

Re: Troubles in Commodity-land

Post by OldFart »

@xavier

For sake of simplicity -lauto was used when compiling.
And yes, I did look at that page. But still.

OldFart
X5000, appears to be sick. Dismantled jan 1, 2024.
Dead MicroA1
A1200 in ElBox, c/w Blizzard '040 @ 50MHz + SCSI module, ZIV-board c/w (o.a.) cv64/3d + flickerdoubler + FastATA-ZIV + Lots of SCSI gear, sitting idle.
RaspBerry Pi 2B, 3B, 4B/4Gb, 4B/8Gb
OrangePi 5+ 8Gb
ACER Windows 10
xenic
Posts: 1185
Joined: Sun Jun 19, 2011 12:06 am

Re: Troubles in Commodity-land

Post by xenic »

OldFart wrote:@xavier

For sake of simplicity -lauto was used when compiling.
And yes, I did look at that page. But still.

OldFart
I think the program would fail to compile or just crash if commodities library were not in -lauto. In fact, when I checked libauto.a in the Dopus4 Hex reader it looks like commodities library is there. I altered your example program to just try one key combination per run and experimented with numerous key combinations. I checked the keywords that Commodities library recognizes by examining it in the Dopus4 Hex reader. I discovered that the keyword combination that didn't produce an error was: "RAWMOUSE MOUSE_LEFTPRESS". You might try that yourself and see if you actually get a commodities message when the left mouse button is pressed. I can only conclude that "leftbutton" is only intended to be used in combination with some other keyword.
AmigaOne X1000 with 2GB memory - OS4.1 FE
User avatar
OldFart
Posts: 100
Joined: Tue Jul 12, 2011 2:56 pm
Location: Groningen, Netherlands

Re: Troubles in Commodity-land

Post by OldFart »

@xenic

You're the man, xenic! The documentation about CxFilters is wrong with this one issue. Now I still am curious about the "relativemouse" keyword. With which should that have to be replaced?

Btw, here's the results of the addition of the correct keywords:

Code: Select all

Error : 4 -- rawmouse leftbutton
Error : 0 -- rawmouse mouse_rightpress
Error : 4 -- rawmouse rightbutton
Error : 0 -- rawmouse mouse_leftpress
Error : 4 -- rawmouse midbutton
Error : 0 -- rawmouse mouse_middlepress
Error : 4 -- rawmouse relativemouse
Error : 0 -- shift -alt -control a
Error : 0 -- rawkey lshift alt f2
Error : 0 -- rawkey control esc
Thank you, you saved my day.

OldFart
X5000, appears to be sick. Dismantled jan 1, 2024.
Dead MicroA1
A1200 in ElBox, c/w Blizzard '040 @ 50MHz + SCSI module, ZIV-board c/w (o.a.) cv64/3d + flickerdoubler + FastATA-ZIV + Lots of SCSI gear, sitting idle.
RaspBerry Pi 2B, 3B, 4B/4Gb, 4B/8Gb
OrangePi 5+ 8Gb
ACER Windows 10
xenic
Posts: 1185
Joined: Sun Jun 19, 2011 12:06 am

Re: Troubles in Commodity-land

Post by xenic »

OldFart wrote:Thank you, you saved my day.
Thank you for your example code. I released a small commodity named "UsbSound" at OS4Depot back in October. I incorrectly assumed that a non-null return by CxFilter() meant that the key combination was correct. Your example code makes it clear that the error code needs to be checked even if CxFilter() returns a non-null value.

I'm not sure if filtering multiple hotkeys is a good idea. If you read the topic "Commodities CX_POPKEY bug" in "General AmigaOS" you'll see that thomasrapp states that a commodity should 'eat' it's hotkey which makes it unavailable to other commodities. However, I'm not sure if that's correct. I read the Commodities library WIKI and it's unclear to me what constitutes 'eating' a hotkey and what doesn't.

The WIKI states that the 'ArgArray' support functions are obsolete but the 'PopShell.c' example uses those support functions. I'd say the WIKI is in bad need of an update and some explanation about some keywords that are producing errors should be explained.
AmigaOne X1000 with 2GB memory - OS4.1 FE
User avatar
salass00
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 530
Joined: Sat Jun 18, 2011 3:12 pm
Location: Finland
Contact:

Re: Troubles in Commodity-land

Post by salass00 »

xenic wrote: I'm not sure if filtering multiple hotkeys is a good idea. If you read the topic "Commodities CX_POPKEY bug" in "General AmigaOS" you'll see that thomasrapp states that a commodity should 'eat' it's hotkey which makes it unavailable to other commodities. However, I'm not sure if that's correct. I read the Commodities library WIKI and it's unclear to me what constitutes 'eating' a hotkey and what doesn't.
To eat an event you just attach a CxTranslate(NULL) to your filter object.
xenic
Posts: 1185
Joined: Sun Jun 19, 2011 12:06 am

Re: Troubles in Commodity-land

Post by xenic »

salass00 wrote:To eat an event you just attach a CxTranslate(NULL) to your filter object.
O.K. I'm not sure the WIKI is clear on that point. Since OldFart's code is requesting mouse events, I wonder if eating those messages (CxTranslate()) will remove those events from the input stream and cripple other programs?

The Commodities library WIKI states: "Any CxMessages that exit the network are returned to the input.device's input stream as input events." That makes it sound like mouse events won't be passed to input.device if a commodity like OldFart's eats those events (CxTranslate(NULL)), which doesn't seem like a good idea.
AmigaOne X1000 with 2GB memory - OS4.1 FE
User avatar
salass00
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 530
Joined: Sat Jun 18, 2011 3:12 pm
Location: Finland
Contact:

Re: Troubles in Commodity-land

Post by salass00 »

The point of eating an event is that it doesn't get passed back into the input event stream.

For instance if your commodity X has "ctrl alt x" as CX_POPKEY and the user presses this key combination to bring up your commodity's GUI you don't want the key combination to also produce output in whatever window the user happened to have active at the time so you set up a CxTranslate(NULL) so this doesn't happen.

IMO tying anything to just regular mouse button clicks seems like a nasty thing to do no matter whether you eat the event or not.
User avatar
broadblues
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 600
Joined: Sat Jun 18, 2011 2:40 am
Location: Portsmouth, UK
Contact:

Re: Troubles in Commodity-land

Post by broadblues »

eats those events (CxTranslate(NULL)), which doesn't seem like a good idea.
This is really commdity specific, in my MKShare networked mouse it 's exactly what I need to do when I move the mouse pointer "off screen" . I 'eat' the events on the host machine and send them via the net to the client where I insert them into the client event stream.

I'm using a custom broker rather than a filter, but the concept is the same.

In another case you might simple want to translate the event to a different type, andother might want to act but pass through.

A "commodity" that is just a normal app with a popup key is arguably not a true commodity.
Post Reply