Page 1 of 7
Troubles in Commodity-land
Posted: Tue Dec 01, 2015 3:32 pm
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
Re: Troubles in Commodity-land
Posted: Tue Dec 01, 2015 5:24 pm
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.
Re: Troubles in Commodity-land
Posted: Tue Dec 01, 2015 5:36 pm
by OldFart
@xavier
For sake of simplicity -lauto was used when compiling.
And yes, I did look at that page. But still.
OldFart
Re: Troubles in Commodity-land
Posted: Wed Dec 02, 2015 6:41 pm
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.
Re: Troubles in Commodity-land
Posted: Wed Dec 02, 2015 8:08 pm
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
Re: Troubles in Commodity-land
Posted: Thu Dec 03, 2015 4:28 pm
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.
Re: Troubles in Commodity-land
Posted: Thu Dec 03, 2015 5:06 pm
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.
Re: Troubles in Commodity-land
Posted: Thu Dec 03, 2015 10:01 pm
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.
Re: Troubles in Commodity-land
Posted: Thu Dec 03, 2015 11:25 pm
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.
Re: Troubles in Commodity-land
Posted: Fri Dec 04, 2015 2:31 am
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.