Welcome, Guest. Please login or register.

Author Topic: Intuition Loops  (Read 3136 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline Thomas

Re: Intuition Loops
« on: January 25, 2017, 11:52:03 AM »
1. yes

2. Wait() takes a signal mask. This means you wait for each signal whose bit is set in the mask. This way you can wait for multiple signals at once. The mp_SigBit field contains the signal number, so you have to shift 1 by that number to get the right bit set in the mask.

There are a few signals which are reserved for the system. The most popular is the signal you receive when the user hits Ctrl-C: it has the signal number 12 (SIGBREAKB_CTRL_F) and the signal mask is 1 << 12 a.k.a. 0x1000 (SIGBREAKF_CTRL_C).

Offline Thomas

Re: Intuition Loops
« Reply #1 on: January 25, 2017, 09:15:24 PM »
Exactly. But you need to add more brackets because | is stronger than <<.

Code: [Select]

Wait( (1 << mywin->UserPort->mp_SigBit) | SIGBREAKF_CTRL_C);



Normally you would do something like this:

Code: [Select]

window_signal = 1 << mywin->UserPort->mp_SigBit;

signals_received = Wait(window_signal | SIGBREAKF_CTRL_C);

if (signals_received & window_signal)
{
/* handle window input a.k.a. IDCMP */
}

if (signals_received & SIGBREAKF_CTRL_C)
{
/* handle Ctrl-C */
}