예제 #1
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;
}
예제 #2
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 */
void main()
{
int rc;
HMOU msHandle;
MOUEVENTINFO msEventInfo;
USHORT ReadType = 0;

rc = MouOpen( NULL, &msHandle );
if( rc )
{
		printf("MouOpen error, rc = %d\n", rc);
		return;
}

rc = MouDrawPtr( msHandle );
while(1)
{
	rc = MouReadEventQue( &msEventInfo, &ReadType, msHandle );
	if( rc )
	{
		printf("MouReadEventQue error, rc = %d\n", rc);
		return;
	}
	if( msEventInfo.time )
	printf( "mousestate = %d\n",
		msEventInfo.fs
		);
	
	DosSleep( 100 );
}

}
//static void APIENTRY thMouse(ULONG data)
static void CC thMouse(void* data)
{
    MOUEVENTINFO Event;
    //USHORT MouHandle = 0;
    USHORT ReadType = 1;
    APIRET rc;

    ppMou = new PMObj;

    EditBoxCollection* pEdit = (EditBoxCollection*) data;

    rc = MouOpen( 0L, &pEdit->MouHandle);

    if(rc)
        return;

    rc = MouDrawPtr(pEdit->MouHandle);

    while(!pEdit->isDown())
    {
        rc = MouReadEventQue(&Event, &ReadType, pEdit->MouHandle);

        if(Event.fs & iMouseMask)
        {
            pEdit->lock();

            if(pEdit->current())
            {
                pEdit->track_beg();

                if(iSenseShift)
                {
                    if(kiLastKey.skey & shShift)
                        pEdit->current()->mark();
                    else
                        pEdit->current()->unmark();
                }

                if(iUpperStatus)
                    pEdit->SetMouse(Event.row - 1, Event.col);
                else
                    pEdit->SetMouse(Event.row, Event.col);

                pEdit->track_end();

                pEdit->draw();
            }
            pEdit->unlock();
        }
    }

    MouClose(pEdit->MouHandle);
}
예제 #5
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;
	}
}
예제 #6
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 */
}
예제 #7
0
파일: mouse.c 프로젝트: OS2World/LIB-libfly
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);
}
예제 #8
0
void TThreads::resume() {
   //  cerr << "TThreads::resume\n";
   shutDownFlag=0;
   assert(! DosAllocMem((void **)&tiled,sizeof(TiledStruct),fALLOC | OBJ_TILE));
   tiled->modeInfo.cb = (unsigned short) sizeof(VIOMODEINFO);
#if 0
   printf("tiled=%lx\n", tiled);
   char line[5];
   gets(line);
#endif

   if (MouOpen((PSZ) 0, &tiled->mouseHandle) != 0) tiled->mouseHandle = 0xFFFF;

   assert(! DosCreateEventSem(NULL, &hevMouse1, 0, 0));
   assert(! DosCreateEventSem(NULL, &hevMouse2, 0, 0));
   assert(! DosCreateEventSem(NULL, &hevKeyboard1, 0, 0));
   assert(! DosCreateEventSem(NULL, &hevKeyboard2, 0, 0));
   assert(! DosCreateMutexSem(NULL, &hmtxMouse1, 0, 0));

   evCombined[0].ulUser=0;
   evCombined[0].hsemCur=(HSEM)hevMouse1;
   evCombined[1].ulUser=1;
   evCombined[1].hsemCur=(HSEM)hevKeyboard1;

   assert(!DosCreateMuxWaitSem(NULL,&hmuxMaster,2,evCombined,DCMW_WAIT_ANY));

   mouseThreadID = 0xFFFF;
   if (tiled->mouseHandle != 0xFFFF) {
#ifdef __BORLANDC__
      mouseThreadID = _beginthread(mouseThread,16384,NULL);
#else
      mouseThreadID = _beginthread(mouseThread,NULL,16384,NULL);
#endif
   }
   DosSetPriority(PRTYS_THREAD,PRTYC_REGULAR,31,mouseThreadID);
   DosPostEventSem(TThreads::hevMouse2);
#ifdef __BORLANDC__
   keyboardThreadID = _beginthread(keyboardThread,16384,NULL);
#else
   keyboardThreadID = _beginthread(keyboardThread,NULL,16384,NULL);
#endif
   DosSetPriority(PRTYS_THREAD,PRTYC_REGULAR,31,keyboardThreadID);
}
예제 #9
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;
}
예제 #10
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);
}