示例#1
0
/*
 * InitMouse - initialize the mouse
 */
void InitMouse( void )
{
    USHORT          events;

    if( !EditFlags.UseMouse ) {
        return;
    }

    if( MouOpen( 0L, &mouseHandle ) != 0 ) {
        EditFlags.UseMouse = FALSE;
        return;
    }
    events = 0x007f;
    if( MouSetEventMask( &events, mouseHandle ) != 0 ) {
        events = 0x001f;
        if( MouSetEventMask( &events, mouseHandle ) == 0 ) {
            mouseHasTwoButtons = TRUE;
        }
    }

    SetMousePosition( WindMaxWidth / 2 - 1, WindMaxHeight / 2 - 1 );
    SetMouseSpeed( MouseSpeed );
    PollMouse( &MouseStatus, &MouseRow, &MouseCol );

} /* InitMouse */
示例#2
0
void RW_IN_Init (in_state_t *in_state_p)
{
	USHORT m_mask = MOUSE_MOTION_WITH_BN1_DOWN | MOUSE_BN1_DOWN |
			MOUSE_MOTION_WITH_BN2_DOWN | MOUSE_BN2_DOWN |
			MOUSE_MOTION_WITH_BN3_DOWN | MOUSE_BN3_DOWN |
			MOUSE_MOTION;
	USHORT m_flags = MOUSE_DISABLED | MOUSE_MICKEYS;
	if (mouse_works) return;

	in_state = in_state_p;

	// mouse variables
	freelook = ri.Cvar_Get( "freelook", "0", 0 );
	lookstrafe = ri.Cvar_Get ("lookstrafe", "0", 0);
	sensitivity = ri.Cvar_Get ("sensitivity", "3", 0);
	m_pitch = ri.Cvar_Get ("m_pitch", "0.022", 0);
	m_yaw = ri.Cvar_Get ("m_yaw", "0.022", 0);
	m_forward = ri.Cvar_Get ("m_forward", "1", 0);
	m_side = ri.Cvar_Get ("m_side", "0.8", 0);

	ri.Cmd_AddCommand ("+mlook", RW_IN_MLookDown);
	ri.Cmd_AddCommand ("-mlook", RW_IN_MLookUp);

	ri.Cmd_AddCommand ("force_centerview", Force_CenterView_f);

	if (MouOpen(NULL, &mh)) return;
	ev = _THUNK_PTR_STRUCT_OK(ev_a) ? ev_a : ev_a + 1;
	//scale = _THUNK_PTR_STRUCT_OK(scale_a) ? scale_a : scale_a + 1;
	mouse_works = 1;
	//scale->rowScale = 1;
	//scale->colScale = 1;
	//if (MouSetScaleFact(scale, mh)) Sys_Error("MouSetScaleFact");
	if (MouSetDevStatus(&m_flags, mh)) Sys_Error("MouSetDevStatus");
	MouSetEventMask(&m_mask, mh);
	{
		//THRESHOLD t;
		USHORT status = -1;
		MouGetNumButtons(&status, mh);
		//Con_Printf("os/2 mouse: %d buttons\n", (int)status);
		/*
		t.Length = sizeof t;
		MouGetThreshold(&t, mh);
		Con_Printf("t: %d %d %d %d %d\n", t.Length, t.Level1, t.Lev1Mult, t.Level2, t.lev2Mult);
		*/
	}
	_fmutex_create(&sem, 0);
	xpos = ypos = 0;
	if (_beginthread(mouse_thread, NULL, 65536, NULL) == -1) {
		MouClose(mh);
		mouse_works = 0;
	}
}
示例#3
0
static void hb_gt_os2_mouse_Init( PHB_GT pGT )
{
   USHORT fsEvents = MOUSE_MOTION_WITH_BN1_DOWN | MOUSE_BN1_DOWN |
                     MOUSE_MOTION_WITH_BN2_DOWN | MOUSE_BN2_DOWN |
                     MOUSE_MOTION_WITH_BN3_DOWN | MOUSE_BN3_DOWN;

   HB_SYMBOL_UNUSED( pGT );

   if( MouOpen( 0L, &s_uMouHandle ) )              /* try to open mouse */
      s_uMouHandle = 0;                            /* no mouse found */
   else
      MouSetEventMask( &fsEvents, s_uMouHandle );  /* mask some events */
}
示例#4
0
static int os2_init(aa_context * c, int mode) {
  USHORT mask = 0x7F;
  USHORT status = 0x0;

  if (MouOpen(NULL,&hMou) && MouOpen("POINTER$", &hMou)) {
    hMou = -1;
    return 0;
  }
  MouDrawPtr(hMou);
  MouSetDevStatus(&status, hMou);
  MouSetEventMask(&mask, hMou);

  return 1;
}
示例#5
0
void main (void)
{
    MOUEVENTINFO  event;
    HMOU          MouHandle;
    USHORT        NButtons, wait = MOU_NOWAIT, eventmask;
    char          ev_name[1024];
    int           rc;

    rc = MouOpen (NULL, &MouHandle);
    printf ("rc = %d from MouOpen\n", rc);
    if (rc) return;

    MouGetNumButtons (&NButtons, MouHandle);
    printf ("%d buttons\n", NButtons);

    rc = MouGetEventMask (&eventmask, MouHandle);
    printf ("rc = %d from MouGetEventMask\n", rc);
    eventmask = (MOUSE_MOTION | MOUSE_BN1_DOWN | MOUSE_BN2_DOWN | MOUSE_BN3_DOWN);
    eventmask |= (MOUSE_MOTION_WITH_BN1_DOWN |
                  MOUSE_MOTION_WITH_BN2_DOWN | MOUSE_MOTION_WITH_BN3_DOWN);
    rc = MouSetEventMask (&eventmask, MouHandle);
    printf ("rc = %d from MouSetEventMask\n", rc);
    rc = MouDrawPtr (MouHandle);
    printf ("rc = %d from MouDrawPtr\n", rc);
    
    while (1)
    {
        rc = MouReadEventQue (&event, &wait, MouHandle);
        if (rc) printf ("rc = %d from MouReadEventQue\n", rc);
        if (rc) continue;
        if (event.time == 0) continue;
        
        ev_name[0] = '\0';
        if (event.fs & MOUSE_BN1_DOWN)             strcat (ev_name, "B1 down     | ");
        if (event.fs & MOUSE_BN2_DOWN)             strcat (ev_name, "B2 down     | ");
        if (event.fs & MOUSE_BN3_DOWN)             strcat (ev_name, "B3 down     | ");
        if (event.fs & MOUSE_MOTION)               strcat (ev_name, "Movement    | ");
        if (event.fs & MOUSE_MOTION_WITH_BN1_DOWN) strcat (ev_name, "B1 movement | ");
        if (event.fs & MOUSE_MOTION_WITH_BN2_DOWN) strcat (ev_name, "B2 movement | ");
        if (event.fs & MOUSE_MOTION_WITH_BN3_DOWN) strcat (ev_name, "B3 movement | ");
        if (ev_name[0] == '\0')                    strcat (ev_name, "release     | ");
        
        printf ("%s row = %3d, col = %3d, flags = %x\n", ev_name, event.row, event.col, event.fs);
    }

    MouClose (MouHandle);
}
示例#6
0
int ConInit(int XSize, int YSize) {
  USHORT MevMask = 127;

  if (Initialized) return 0;

  EventBuf.What = evNone;
  MousePresent  = (MouOpen(NULL, &MouseHandle) == 0) ? 1 : 0;

  if (MousePresent) MouSetEventMask(&MevMask, MouseHandle);

  memset(&SaveKbdState, 0, sizeof(SaveKbdState));
  SaveKbdState.cb = sizeof(SaveKbdState);
  APIRET16 s = KbdGetStatus(&SaveKbdState, 0);
  assert(s == 0);
  ConContinue();

  Initialized = 1;

  return 0;
}
示例#7
0
static void
mouse_server(unsigned long ignored GCC_UNUSED)
{
    unsigned short fWait = MOU_WAIT;
    /* NOPTRRECT mourt = { 0,0,24,79 }; */
    MOUEVENTINFO mouev;
    HMOU hmou;
    unsigned short mask = MOUSE_BN1_DOWN | MOUSE_BN2_DOWN | MOUSE_BN3_DOWN;
    int nbuttons = 3;
    int oldstate = 0;
    char err[80];
    unsigned long rc;

    /* open the handle for the mouse */
    if (MouOpen(NULL, &hmou) == 0) {
	rc = MouSetEventMask(&mask, hmou);
	if (rc) {		/* retry with 2 buttons */
	    mask = MOUSE_BN1_DOWN | MOUSE_BN2_DOWN;
	    rc = MouSetEventMask(&mask, hmou);
	    nbuttons = 2;
	}
	if (rc == 0 && MouDrawPtr(hmou) == 0) {
	    for (;;) {
		/* sit and wait on the event queue */
		rc = MouReadEventQue(&mouev, &fWait, hmou);
		if (rc) {
		    snprintf(err, sizeof(err),
			     "Error reading mouse queue, rc=%lu.\r\n", rc);
		    break;
		}
		if (!mouse_activated)
		    goto finish;

		/*
		 * OS/2 numbers a 3-button mouse inconsistently from other
		 * platforms:
		 *      1 = left
		 *      2 = right
		 *      3 = middle.
		 */
		if ((mouev.fs ^ oldstate) & MOUSE_BN1_DOWN)
		    write_event(mouev.fs & MOUSE_BN1_DOWN,
				mouse_buttons[1], mouev.col, mouev.row);
		if ((mouev.fs ^ oldstate) & MOUSE_BN2_DOWN)
		    write_event(mouev.fs & MOUSE_BN2_DOWN,
				mouse_buttons[3], mouev.col, mouev.row);
		if ((mouev.fs ^ oldstate) & MOUSE_BN3_DOWN)
		    write_event(mouev.fs & MOUSE_BN3_DOWN,
				mouse_buttons[2], mouev.col, mouev.row);

	      finish:
		oldstate = mouev.fs;
	    }
	} else
	    snprintf(err, sizeof(err),
		     "Error setting event mask, buttons=%d, rc=%lu.\r\n",
		     nbuttons, rc);

	DosWrite(2, err, strlen(err), &rc);
	MouClose(hmou);
    }
    DosExit(EXIT_THREAD, 0L);
}