Click Here
home features news forums classifieds faqs links search
6071 members 
Amiga Q&A /  Free for All /  Emulation /  Gaming / (Latest Posts)
Login

Nickname

Password

Lost Password?

Don't have an account yet?
Register now!

Support Amigaworld.net
Your support is needed and is appreciated as Amigaworld.net is primarily dependent upon the support of its users.
Donate

Menu
Main sections
» Home
» Features
» News
» Forums
» Classifieds
» Links
» Downloads
Extras
» OS4 Zone
» IRC Network
» AmigaWorld Radio
» Newsfeed
» Top Members
» Amiga Dealers
Information
» About Us
» FAQs
» Advertise
» Polls
» Terms of Service
» Search

IRC Channel
Server: irc.amigaworld.net
Ports: 1024,5555, 6665-6669
SSL port: 6697
Channel: #Amigaworld
Channel Policy and Guidelines

Who's Online
17 crawler(s) on-line.
 114 guest(s) on-line.
 1 member(s) on-line.


 Gunnar

You are an anonymous user.
Register Now!
 Gunnar:  1 min ago
 Rob:  6 mins ago
 zipper:  29 mins ago
 amigakit:  1 hr 26 mins ago
 OneTimer1:  1 hr 31 mins ago
 NutsAboutAmiga:  1 hr 35 mins ago
 kolla:  1 hr 47 mins ago
 Comi:  2 hrs 17 mins ago
 vox:  3 hrs 2 mins ago
 BigD:  4 hrs 9 mins ago

/  Forum Index
   /  Amiga Development
      /  Input.device / Hotkey Question
Register To Post

PosterThread
Yogi27 
Input.device / Hotkey Question
Posted on 19-Feb-2021 21:09:33
#1 ]
Regular Member
Joined: 11-Dec-2002
Posts: 357
From: Chicago, Illinois

Hi Everyone,

I have a question. I am working on updating my talking clock program and I would like to add a feature where if the user hits a key sequence, say Alt t, it will trigger the program to say the time. I have looked into the input.device and the exchange hotkey setup. Problem, is I cannot seem to understand either of them, not sure which is better, and all the example programs are old and ancient and will not compile.

Which one should I use and can someone point me to a modern example of it or show me a quick example of it being used.

Thanks,

Yogi

 Status: Offline
Profile     Report this post  
NutsAboutAmiga 
Re: Input.device / Hotkey Question
Posted on 19-Feb-2021 21:45:32
#2 ]
Elite Member
Joined: 9-Jun-2004
Posts: 12795
From: Norway

@Yogi27

You don't need to code.

The “Fkey” commodity can start programs, I have never actually used it, but it is actually pretty useful tool. Just add it to WBStartup.

You find FKey in Exchange GUI, select “FKey” and press the show interface button.

_________________
http://lifeofliveforit.blogspot.no/
Facebook::LiveForIt Software for AmigaOS

 Status: Offline
Profile     Report this post  
simplex 
Re: Input.device / Hotkey Question
Posted on 20-Feb-2021 2:20:47
#3 ]
Cult Member
Joined: 5-Oct-2003
Posts: 896
From: Hattiesburg, MS

@Yogi27

According to Commodore, back in the 90s, the Commodities library was the way to go. Going directly to input.device is more easily abused.

I wrote such a program once. I'm afraid I don't have any copies of my old Amiga source code anymore, but if you dig hard enough on aminet, you should be able to find some Commodities programs that include source code, and from them you should be able to make some sense of the mechanisms.

You might also make use of RKMs, either online or via eBay. I found those helpful. For instance, the Commodities library appears in Chapter 31 of the link, which you can find by scrolling to "Page" 672. It's worth reading at least the first page to understand the motivation of the Commodities library.

Last edited by simplex on 20-Feb-2021 at 02:24 AM.

_________________
I've decided to follow an awful lot of people I respect and leave AmigaWorld. If for some reason you want to talk to me, it shouldn't take much effort to find me.

 Status: Offline
Profile     Report this post  
broadblues 
Re: Input.device / Hotkey Question
Posted on 20-Feb-2021 14:42:54
#4 ]
Amiga Developer Team
Joined: 20-Jul-2004
Posts: 4446
From: Portsmouth England

@Yogi27

From my AOrganiser diary app. First wo functions are amiga_lib replacements. (prob borrowsed from clib2) as I started with clib2 and then switched to newlib which doesn't have a libamiga replacement.


CxObj *
HotKey(CONST_STRPTR descr,struct MsgPort * port,LONG ID)
{
CxObj * result = NULL;
CxObj * filter = NULL;

if(CxBase == NULL)
goto out;

filter = CxFilter(descr);
if(filter == NULL)
goto out;

ICommodities->AttachCxObj(filter,CxSender(port,ID));
ICommodities->AttachCxObj(filter,CxTranslate(NULL));

if(ICommodities->CxObjError(filter))
goto out;

result = filter;

out:

if(result == NULL && filter != NULL)
ICommodities->DeleteCxObjAll(filter);

return(result);
}

STRPTR
ArgString(CONST_STRPTR *tt,CONST_STRPTR entry,CONST_STRPTR default_string)
{
STRPTR result;

if(tt != NULL && IconBase != NULL && ((result = (STRPTR)IIcon->FindToolType((STRPTR *)tt,(STRPTR)entry))) != NULL)
return(result);
else
return((STRPTR)default_string);
}

/*
Comodities support
*/

#include

#include

#include
#include


#include
#include

#include "window.h"
#include "protos.h"


CxObj *CXBroker = NULL; /* Our broker */

#define POPKEY_ID 20

struct MsgPort *CXport = NULL; /* commodities messages here */
ULONG CXsigflag = 0; /* signal for above */



/* a little global for showing the user the hotkey */
char hotkeybuf[257];


struct NewBroker mynb = {
NB_VERSION, /* Library needs to know version */
"diary", /* broker internal name */
"Diary (c) Andy Broad 2006-2017", /* commodity title */
"Organise\nYour Life!", /* description */
NBU_NOTIFY | NBU_UNIQUE, /* We want to be the only broker */
/* with this name and we want to */
/* be notified of any attempts */
/* to add a commodity with the */
/* same name */
0, /* flags */
0, /* default priority */
NULL, /* port, will fill in */
0 /* channel (reserved) */
};


BOOL SetupCX(STRPTR *ttypes)
{
LONG error;
STRPTR str;

ShutdownCX(); /* shutdown previous and restart from scratch */

if(!(CXport=IExec->AllocSysObjectTags(ASOT_PORT,TAG_DONE)))
{
return FALSE;
}
CXsigflag = 1L mp_SigBit;

mynb.nb_Pri = ArgInt((CONST_STRPTR *)ttypes, "CX_PRIORITY", 0);
mynb.nb_Port = CXport;

mynb.nb_Flags |= COF_SHOW_HIDE;

if(!(CXBroker = ICommodities->CxBroker(&mynb, &error)))
{
ShutdownCX();
return FALSE;
}

ICommodities->AttachCxObj(CXBroker,
HotKey(str=ArgString((CONST_STRPTR *)ttypes,"CX_POPKEY","ctrl alt d"),
CXport,
POPKEY_ID));
strncpy(hotkeybuf,str,(sizeof(hotkeybuf)-1));


if((error = ICommodities->CxObjError(CXBroker)))
{
ShutdownCX();
return (FALSE);
}
ICommodities->ActivateCxObj(CXBroker,1);
return TRUE;
}

void ShutdownCX()
{
struct Message *msg;
if (CXport)
{
ICommodities->DeleteCxObjAll(CXBroker); /* safe, even if NULL */

/* now that messages are shut off, clear port */
while((msg=IExec->GetMsg(CXport))) IExec->ReplyMsg(msg);
IExec->FreeSysObject(ASOT_PORT,CXport);

CXport = NULL;
CXsigflag = 0;
CXBroker = NULL;

}
}


BOOL HandleCXmsg(struct Message *msg)
{
ULONG msgid;
ULONG msgtype;

BOOL result = TRUE;

msgid = ICommodities->CxMsgID((const CxMsg *)msg);
msgtype = ICommodities->CxMsgType((const CxMsg *)msg);

IExec->ReplyMsg(msg);

switch(msgtype)
{
case CXM_IEVENT:
switch(msgid)
{
case POPKEY_ID:
Openwindow();
break;

default:
break;
}
break;
case CXM_COMMAND:
switch(msgid)
{
case CXCMD_DISABLE:
ICommodities->ActivateCxObj(CXBroker,0L);
break;
case CXCMD_ENABLE:
ICommodities->ActivateCxObj(CXBroker,1L);
break;
case CXCMD_APPEAR: /* Time to pop up the window */
case CXCMD_UNIQUE: /* Someone has tried to run us again */

Openwindow();
break; /* the window */
case CXCMD_DISAPPEAR:
if(Asksave(ASK_CLOSE))
{
Closewindow();
}
break;
case CXCMD_KILL:
if(Asksave(ASK_QUIT))
{
result = FALSE;
}
break;
default:
break;
}
break;
}
return result;
}

_________________
BroadBlues On Blues BroadBlues On Amiga Walker Broad

 Status: Offline
Profile     Report this post  
Yogi27 
Re: Input.device / Hotkey Question
Posted on 20-Feb-2021 17:25:08
#5 ]
Regular Member
Joined: 11-Dec-2002
Posts: 357
From: Chicago, Illinois

@broadblues

Thanks broadblues for the example clip from your program. I will take a close look at it, and I really appreciate the help.

I was wondering if you had an example of using CreateNewProc function? I am thinking about adding an AREXX port to the program as well, and I need to have the Arexx port listening and processing function as a seperate process from my main program using CreateNewProc. I tried using CreateTask, but the output from my program was not desirable with CreateTask to say the least LOL.

Thanks again,

Yogi

 Status: Offline
Profile     Report this post  
kolla 
Re: Input.device / Hotkey Question
Posted on 21-Feb-2021 16:45:27
#6 ]
Elite Member
Joined: 20-Aug-2003
Posts: 2859
From: Trondheim, Norway

@broadblues

Better to use pastebin or something like that instead of posting large portions of code here, and avoid mangling by web server browser formatting...

_________________
B5D6A1D019D5D45BCC56F4782AC220D8B3E2A6CC

 Status: Offline
Profile     Report this post  
jabirulo 
Re: Input.device / Hotkey Question
Posted on 21-Feb-2021 21:29:45
#7 ]
Regular Member
Joined: 20-Jun-2004
Posts: 370
From: Donosti (GUIPUZCOA)

@Yogi27

http://os4depot.net/?function=showcontent&file=utility/docky/keymapswitcher_docky.lha

uses commodity as hotkey (hotkey.c), so maybe it helps too.

 Status: Offline
Profile     Report this post  
bison 
Re: Input.device / Hotkey Question
Posted on 21-Feb-2021 22:51:36
#8 ]
Elite Member
Joined: 18-Dec-2007
Posts: 2112
From: N-Space

@kolla

Easier for certain, but nothing enhances a forum post more than a bit of source code.

AW doesn't make it easy. One has to escape < and > and skip the preview step to make it work.

_________________
"Unix is supposed to fix that." -- Jay Miner

 Status: Offline
Profile     Report this post  
Deniil715 
Re: Input.device / Hotkey Question
Posted on 22-Feb-2021 10:10:24
#9 ]
Elite Member
Joined: 14-May-2003
Posts: 4236
From: Sweden

@Yogi27

As people say, assigning an arexx port and use FKey (or AllKeys) to send an arexx command to your clock would be the easiest solution.

Otherwise I recommend using commodities.library. Your clock should probably be a commodity anyway

_________________
- Don't get fooled by my avatar, I'm not like that (anymore, mostly... maybe only sometimes)
> Amiga Classic and OS4 developer for OnyxSoft.

 Status: Offline
Profile     Report this post  
Yogi27 
Re: Input.device / Hotkey Question
Posted on 24-Feb-2021 13:59:23
#10 ]
Regular Member
Joined: 11-Dec-2002
Posts: 357
From: Chicago, Illinois

Hi Everyone,

After many hours of pulling my hair out after work, I figured out how to use createnewproctags for starting a new process to my clock program and I added an Arexx port, that takes a command that triggers the talking clock.

I find that alot of the examples on the internet are outdated and contain alot of depreciated functions in them. I have a whole bunch of examples I did myself, I should probably release to help people like me who are not programming experts, but want to learn from easy examples that compile. I might do that in the future.

Now on too the commodity hotkey stuff !

Thanks for all the help,

Yogi

Last edited by Yogi27 on 24-Feb-2021 at 02:02 PM.

 Status: Offline
Profile     Report this post  

[ home ][ about us ][ privacy ] [ forums ][ classifieds ] [ links ][ news archive ] [ link to us ][ user account ]
Copyright (C) 2000 - 2019 Amigaworld.net.
Amigaworld.net was originally founded by David Doyle