示例#1
0
static int _glfwTranslateChar( struct IntuiMessage *msg )
{
    struct InputEvent event;
    unsigned char     buffer[ 4 ];
    int               character;

    // Create input event
    event.ie_Class        = IECLASS_RAWKEY;
    event.ie_Code         = msg->Code;
    event.ie_Qualifier    = msg->Qualifier;
    event.ie_EventAddress = msg->IAddress;

    // Map key event to text string
    if( MapRawKey( &event, buffer, 4, NULL ) > 0 )
    {
        // Valid Unicode character?
        character = (int) buffer[ 0 ];
        if( (character >= 32  && character <= 126) ||
            (character >= 160 && character <= 255) )
        {
            return character;
        }
    }

    return -1;
}
示例#2
0
/*******************
**  HandleEvents  **
*******************/
VOID HandleEvents(struct Window *win, UBYTE *buffer, LONG bufsize)
{
    struct IntuiMessage *imsg;
    struct MsgPort *port = win->UserPort;
    BOOL terminated = FALSE;
    WORD written;
    struct InputEvent ie ={0,};
    
    ie.ie_Class = IECLASS_RAWKEY;
    
    while (!terminated)
    {
        if ((imsg = (struct IntuiMessage *)GetMsg(port)) != NULL)
        {
            
            switch (imsg->Class)
            {
            
            case IDCMP_REFRESHWINDOW:
                BeginRefresh(win);
                EndRefresh(win, TRUE);
                break;
                
            case IDCMP_RAWKEY:
                ie.ie_Code     = imsg->Code;
                ie.ie_Qualifier    = imsg->Qualifier;
                printf("rawkey: code=$%04x, qual=$%04x\n",
                    ie.ie_Code, ie.ie_Qualifier);
                
                ie.ie_EventAddress =  imsg->IAddress;
                
                written = MapRawKey(&ie, buffer, bufsize, NULL);
                if (written == -1)
                    printf("Buffer owerflow !!\n");
                else if (written)
                {
                    printf("Map:");
                    Write(Output(), buffer, written);
                    printf("\n");
                }
                if (ie.ie_Code == 197)
                    terminated = TRUE;
                break;
                                    
            } /* switch (imsg->Class) */
            ReplyMsg((struct Message *)imsg);
            
                        
        } /* if ((imsg = GetMsg(port)) != NULL) */
        else
        {
            Wait(1L << port->mp_SigBit);
        }
    } /* while (!terminated) */
    
    return;
} /* HandleEvents() */
示例#3
0
/* Converts a Rawkey to a vanillakey */
ULONG ConvertKey(struct IntuiMessage *imsg)
{
   struct InputEvent event;
   UBYTE code = 0;
   event.ie_NextEvent    = NULL;
   event.ie_Class        = IECLASS_RAWKEY;
   event.ie_SubClass     = 0;
   event.ie_Code         = imsg->Code;
   event.ie_Qualifier    = imsg->Qualifier;
   event.ie_EventAddress = (APTR *) *((ULONG *)imsg->IAddress);
   MapRawKey(&event, (STRPTR)&code, 1, NULL);
   return code;
}
示例#4
0
void IN_SendKeyEvents (void)
{
	struct IntuiMessage *intuimsg;
	struct InputEvent *inputev;
	int sym, state, code;

	if (!window) return;/* dedicated server? */

	while ((intuimsg = (struct IntuiMessage *) GetMsg(window->UserPort)))
	{
		switch (intuimsg->Class)
		{
		case IDCMP_ACTIVEWINDOW:
			S_UnblockSound();
			break;
		case IDCMP_INACTIVEWINDOW:
			S_BlockSound();
			break;
		case IDCMP_CLOSEWINDOW:
			CL_Disconnect ();
			Sys_Quit ();
			break;
		}

		ReplyMsg((struct Message *)intuimsg);
	}

	while ((inputev = IN_GetNextEvent()))
	{
		sym = 0;

		code = inputev->ie_Code & ~IECODE_UP_PREFIX;
		state = !(inputev->ie_Code & IECODE_UP_PREFIX);

		if (inputev->ie_Class == IECLASS_RAWKEY)
		{
			if (!Key_IsGameKey())
			{
				UBYTE bufascii;
				if (KeymapBase && MapRawKey(inputev, (STRPTR) &bufascii, sizeof(bufascii), NULL) > 0)
				{
					//Con_Printf("%d\n", bufascii);
					sym = (bufascii == 8) ? K_BACKSPACE	: bufascii;
				}
			}

			if (!sym && code < MAX_KEYCONV)
				sym = keyconv[code];

			//Con_Printf("rawkey code %d sym %d state %d\n", code, sym, state);
		}
		else if (inputev->ie_Class == IECLASS_RAWMOUSE)
		{
			switch (code)
			{
			case IECODE_LBUTTON:
				sym = K_MOUSE1;
				break;
			case IECODE_RBUTTON:
				sym = K_MOUSE2;
				break;
			case IECODE_MBUTTON:
				sym = K_MOUSE3;
				break;
			}
			//Con_Printf("rawmouse code %d sym %d state %d\n", code, sym, state);
		}
		else if (inputev->ie_Class == IECLASS_NEWMOUSE)
		{
			switch (code)
			{
			case NM_WHEEL_UP:
				sym = K_MWHEELUP;
				break;
			case NM_WHEEL_DOWN:
				sym = K_MWHEELDOWN;
				break;
			case NM_BUTTON_FOURTH:
				sym = K_MOUSE4;
				break;
			}
			//Con_Printf("newmouse code %d sym %d state %d\n", code, sym, state);
		}

		if (sym)
		{
			if (sym == K_MWHEELUP || sym == K_MWHEELDOWN)
			{
				/* the mouse wheel doesn't generate a key up event */
				Key_Event(sym, true);
				Key_Event(sym, false);
			}
			else
			{
				Key_Event(sym, state);
			}
		}
	}

	IN_HandleJoystick();
}
示例#5
0
ULONG HandleStrInput(   struct Gadget       *gad,
                      struct GadgetInfo *ginfo,
                      struct InputEvent *ievent,
                      UWORD         *imsgcode,
                      struct IntuitionBase  *IntuitionBase)
{
    struct SGWork   	 sgw;
    struct StringInfo   *strinfo = (struct StringInfo *)gad->SpecialInfo;
    struct StringExtend *strext = NULL;
    ULONG           	 command = 0;

    EnterFunc(bug("HandleStrInput(gad=%p, ginfo=%p, ievent=%p)\n",
                  gad, ginfo, ievent));

    if ((ievent->ie_Class == IECLASS_TIMER)) return 0;

    D(bug("Gadget text: %s\n", strinfo->Buffer));

    if (!ginfo)
        ReturnInt("HandleStrInput", ULONG, 0UL);

    UpdateStringInfo(gad);

    /* Initialize SGWork */
    sgw.Gadget  = gad;
    sgw.StringInfo  = strinfo;
    sgw.WorkBuffer  = strinfo->Buffer; /* default */
    sgw.PrevBuffer  = strinfo->Buffer;
    sgw.Modes   = 0;
    sgw.IEvent  = ievent;
    sgw.Code    = 0;
    sgw.BufferPos   = strinfo->BufferPos;
    sgw.NumChars    = strinfo->NumChars;
    sgw.Actions = 0;
    sgw.LongInt = strinfo->LongInt;
    sgw.GadgetInfo  = ginfo;
    sgw.EditOp  = EO_NOOP;

    if (gad->Flags & GFLG_STRINGEXTEND)
    {
        D(bug("HandleStrInput: Extended gadget\n"));
        strext = strinfo->Extension;
        if (strext->WorkBuffer)
        {
            sgw.WorkBuffer = strext->WorkBuffer;
            /* The edit hook gets *copy* of the current buffer contents */
            strcpy(sgw.WorkBuffer, strinfo->Buffer);
        }
        sgw.Modes = strext->InitialModes;
    }

    switch (ievent->ie_Class)
    {
	case IECLASS_RAWMOUSE:
            if (ievent->ie_Code == SELECTDOWN)
            {
        	command = SGH_CLICK;
        	sgw.Actions = SGA_USE | SGA_REDISPLAY;
        	D(bug("HandleStrInput: RAWMOUSE event\n"));
            }
            break;

	case IECLASS_RAWKEY:
        {
            UBYTE buf;

            D(bug("HandleStrInput: RAWKEY event\n"));
            if (ievent->ie_Code & IECODE_UP_PREFIX)
            {
                D(bug("HandleStrInput: filter UP event\n"));
            }
            else
            {
                command = SGH_KEY;
                sgw.Actions = SGA_USE;
                if (1 == MapRawKey(sgw.IEvent, &buf, 1, strinfo->AltKeyMap))
                {
                    D(bug("HandleStrInput: sgw.Code 0x%lx\n",buf));
                    sgw.Code = (UWORD)buf;
                }
            }
	    break;
        }

    }

    if (!command)
        ReturnInt("HandleStrInput", ULONG , 0UL);

    /* Call the global editing hook */

    D(bug("calling global hook, Buffer=%s, WorkBuffer=%s\n",
          strinfo->Buffer, sgw.WorkBuffer));
    CallHookPkt(GetPrivIBase(IntuitionBase)->GlobalEditHook, &sgw, &command);

    /* If there is a local edit hook, run it */
    if (strext)
    {
        if (strext->EditHook)
        {
            D(bug("calling local edit hook\n"));
            CallHookPkt(strext->EditHook, &sgw, &command);
        }
    }

    /* Copy possibly changed stuff into stringgad */
    if (sgw.Actions & SGA_USE)
    {
        if (strext)
        {
            if (strext->WorkBuffer)
                strcpy(strinfo->Buffer, strext->WorkBuffer);
        }

        strinfo->BufferPos = sgw.BufferPos;
        strinfo->NumChars  = sgw.NumChars;
        strinfo->LongInt   = sgw.LongInt;

#if 0
        if (gad->Activation & GACT_LONGINT)
        {
            kprintf("strinfo->LongInt = %d\n",strinfo->LongInt);
            */
        }
        else
        {