예제 #1
0
파일: dmouse.c 프로젝트: Yurand/tw-light
/* mick_handler:
 *  Movement callback for mickey-mode driver.
 */
static void mick_handler(__dpmi_regs *r)
{
   int x = (signed short)r->x.si;
   int y = (signed short)r->x.di;

   _mouse_b = r->x.bx;

   mymickey_x += x - mymickey_ox;
   mymickey_y += y - mymickey_oy;

   mymickey_ox = x;
   mymickey_oy = y;

   _mouse_x = MICKEY_TO_COORD_X(mouse_mx + x);
   _mouse_y = MICKEY_TO_COORD_Y(mouse_my + y);

   if ((_mouse_x < mouse_minx) || (_mouse_x > mouse_maxx) ||
       (_mouse_y < mouse_miny) || (_mouse_y > mouse_maxy)) {

      _mouse_x = CLAMP(mouse_minx, _mouse_x, mouse_maxx);
      _mouse_y = CLAMP(mouse_miny, _mouse_y, mouse_maxy);

      mouse_mx = COORD_TO_MICKEY_X(_mouse_x);
      mouse_my = COORD_TO_MICKEY_Y(_mouse_y);

      CLEAR_MICKEYS();
   }

   _handle_mouse_input();
}
예제 #2
0
void _al_win_mouse_handle_button(HWND hwnd, int button, BOOL down, int x, int y, BOOL abs)
{
  int last_mouse_b;

   _enter_critical();

   if (down)
      _mouse_b |= (1 << (button-1));
   else
      _mouse_b &= ~(1 << (button-1));

   last_mouse_b = _mouse_b;

   _exit_critical();

#if 0 /* Aseprite: We handle mouse capture in the she and ui layers */

   /* If there is a mouse button pressed we capture the mouse, in any
      other cases we release it. */
   if (last_mouse_b) {
     if (GetCapture() != hwnd)
       SetCapture(hwnd);
   }
   else {
     if (GetCapture() == hwnd)
       ReleaseCapture();
   }

#endif

   _handle_mouse_input();
}
예제 #3
0
파일: madb.c 프로젝트: Yurand/tw-light
static pascal void mouse_adb_interrupt(Ptr buffer, TempADBServiceRoutineUPP completionProc, Ptr refCon, long command)
{
   signed char tmp;
   tmp=buffer[1];
   _mouse_b = tmp&0x80?0:(_mouse2nd?2:1);
   if(tmp & 0x40)
      tmp |= 0xC0;
   else
      tmp &= 0x3F;
   _mouse_y += tmp;
   mickey_y += tmp;
   _mouse_y = CLAMP(mouse_y_min,mouse_y_max,_mouse_y);

   tmp=buffer[2];
   _mouse_b |= tmp&0x80?0:2;
   if(tmp & 0x40)
      tmp |= 0xC0;
   else
      tmp &= 0x3F;
   _mouse_x += tmp;
   mickey_x += tmp;
   _mouse_x = CLAMP(mouse_x_min,mouse_x_max,_mouse_x);
   
   _handle_mouse_input();
}
예제 #4
0
/* processor:
 *  Processes the first packet in the buffer, if any, returning the number
 *  of bytes eaten.
 */
static int processor (unsigned char *buf, int buf_size)
{
   struct input_event *event;

   if (buf_size < (int)sizeof(struct input_event))
      return 0; /* not enough data */

   event = (struct input_event*)buf;
   switch (event->type) {
      case EV_KEY:
         process_key(event);
         break;
      case EV_REL:
         process_rel(event);
         break;
      case EV_ABS:
         process_abs(event);
         break;
   }

   if (current_tool!=no_tool) {
      x_axis.out_abs = CLAMP(x_axis.out_min, x_axis.out_abs, x_axis.out_max);
      y_axis.out_abs = CLAMP(y_axis.out_min, y_axis.out_abs, y_axis.out_max);
      /* There's no range for z */

      _mouse_x = x_axis.out_abs;
      _mouse_y = y_axis.out_abs;
      _mouse_z = z_axis.out_abs;
      _mouse_b = button_left + (button_right<<1) + (button_middle<<2);
      _handle_mouse_input();
   }
   /* Returns the size of the data used */
   return sizeof(struct input_event);
}
예제 #5
0
파일: dmouse.c 프로젝트: Yurand/tw-light
/* int33_handler:
 *  Movement callback for the int 0x33 driver.
 */
static void int33_handler(__dpmi_regs *r)
{
   _mouse_x = r->x.cx / 8;
   _mouse_y = r->x.dx / 8;
   _mouse_b = r->x.bx;

   _handle_mouse_input();
}
예제 #6
0
void _al_win_mouse_handle_wheel(HWND hwnd, int z, BOOL abs)
{
   _enter_critical();

   _mouse_z += z;

   _exit_critical();

   _handle_mouse_input();
}
예제 #7
0
/* qnx_mouse_handler:
 *  Mouse "interrupt" handler for mickey-mode driver.
 */
void qnx_mouse_handler(int x, int y, int z, int buttons)
{
   _mouse_b = buttons;
   
   mymickey_x += x;
   mymickey_y += y;

   _mouse_x += x;
   _mouse_y += y;
   _mouse_z += z;
   
   if ((_mouse_x < mouse_minx) || (_mouse_x > mouse_maxx)
       || (_mouse_y < mouse_miny) || (_mouse_y > mouse_maxy)) {
      _mouse_x = MID(mouse_minx, _mouse_x, mouse_maxx);
      _mouse_y = MID(mouse_miny, _mouse_y, mouse_maxy);
   }

   _handle_mouse_input();
}
예제 #8
0
/* mouse_set_sysmenu: [window thread]
 *  Changes the state of the mouse when going to/from sysmenu mode.
 */
int mouse_set_sysmenu(int state)
{
   POINT p;

   if (mouse_dinput_device) {
      if (state == TRUE) {
         if (_mouse_on) {
            _mouse_on = FALSE;
            mouse_set_syscursor();
         }
      }
      else {
         READ_CURSOR_POS(p);
      }

      _handle_mouse_input();
   }

   return 0;
}
예제 #9
0
void _al_win_mouse_handle_move(HWND hwnd, int x, int y)
{
   _enter_critical();

   /* Try to restore the primary surface as soon as possible if we
      have lost it and were not able to recreate it */
   if (gfx_directx_primary_surface && gfx_directx_primary_surface->id == 0) {
     restore_all_ddraw_surfaces();
   }

   _mouse_x = CLAMP(mouse_minx, x, mouse_maxx);
   _mouse_y = CLAMP(mouse_miny, y, mouse_maxy);

   mymickey_x += x - mymickey_ox;
   mymickey_y += y - mymickey_oy;

   mymickey_ox = x;
   mymickey_oy = y;

   _exit_critical();

   _handle_mouse_input();
}
예제 #10
0
int32 mouse_thread(void *mouse_started)
{
   BPoint cursor(0, 0);
   uint32 buttons;

   if (!_be_mouse_window_mode) {
      set_mouse_position(320, 240);
   }

   release_sem(*(sem_id *)mouse_started);

   for (;;) {
      acquire_sem(_be_mouse_view_attached);

      if (mouse_thread_running == false) {
         release_sem(_be_mouse_view_attached);
         /* XXX commented out due to conflicting TRACE in Haiku
         TRACE(PREFIX_I "mouse thread exited\n");
         */

         return 0;
      }

      if ((_be_focus_count > 0) && _be_mouse_window->Lock()) {
         _be_mouse_view->GetMouse(&cursor, &buttons);
	 if (!_be_mouse_window_mode) {
	    int dx = (int)cursor.x - 320;
	    int dy = (int)cursor.y - 240;

	    if (be_mouse_warped) {
	       dx = 0;
	       dy = 0;
	       be_mouse_warped = false;
	    }
	    be_mickey_x = dx;
	    be_mickey_y = dy;
	    be_mouse_x += dx;
	    be_mouse_y += dy;
	    
	    if (dx != 0 || dy != 0) {
	       set_mouse_position(320, 240);
	    }
	 }
	 else {
	    BRect bounds = _be_mouse_window->Bounds();
	    
	    if (bounds.Contains(cursor)) {
	       int old_x = be_mouse_x;
	       int old_y = be_mouse_y;
	       
	       _mouse_on = TRUE;
	       if (!be_app->IsCursorHidden()) {
	          be_app->HideCursor();
	       }

	       be_mouse_x = (int)(cursor.x - bounds.left);
	       be_mouse_y = (int)(cursor.y - bounds.top);
	       if (!be_mouse_warped) {
	          be_mickey_x += (be_mouse_x - old_x);
	          be_mickey_y += (be_mouse_y - old_y);
	       }
	       else {
	          be_mouse_warped = false;
	          be_mickey_x = 0;
	          be_mickey_y = 0;
	       }
	    }
	    else {
	       buttons = 0;
	       _mouse_on = FALSE;
	       if (be_app->IsCursorHidden()) {
	          be_app->ShowCursor();
	       }
	    }
	 }

	 _be_mouse_window->Unlock();
	    
	 be_mouse_x = CLAMP(limit_left, be_mouse_x, limit_right);
	 be_mouse_y = CLAMP(limit_up,   be_mouse_y, limit_down);
	 
	 be_mouse_b = 0;
	 be_mouse_b |= (buttons & B_PRIMARY_MOUSE_BUTTON)   ? 1 : 0;
	 be_mouse_b |= (buttons & B_SECONDARY_MOUSE_BUTTON) ? 2 : 0;
	 be_mouse_b |= (buttons & B_TERTIARY_MOUSE_BUTTON)  ? 4 : 0;

	 _mouse_x = be_mouse_x;
	 _mouse_y = be_mouse_y;
	 _mouse_z = _be_mouse_z;
	 _mouse_b = be_mouse_b;
	 _handle_mouse_input();
      }

      release_sem(_be_mouse_view_attached);

      snooze(MOUSE_THREAD_PERIOD);
   }
}
예제 #11
0
/* mouse_dinput_handle: [input thread]
 *  Handles queued mouse input.
 */
static void mouse_dinput_handle(void)
{
   static DIDEVICEOBJECTDATA message_buffer[DINPUT_BUFFERSIZE];
   long int waiting_messages;
   HRESULT hr;
   int i;

   /* the whole buffer is free */
   waiting_messages = DINPUT_BUFFERSIZE;

   /* fill the buffer */
   hr = IDirectInputDevice_GetDeviceData(mouse_dinput_device,
                                         sizeof(DIDEVICEOBJECTDATA),
                                         message_buffer,
                                         &waiting_messages,
                                         0);

   /* was device lost ? */
   if ((hr == DIERR_NOTACQUIRED) || (hr == DIERR_INPUTLOST)) {
      /* reacquire device */
      _TRACE(PREFIX_W "mouse device not acquired or lost\n");
      wnd_schedule_proc(mouse_dinput_acquire);
   }
   else if (FAILED(hr)) {  /* other error? */
      _TRACE(PREFIX_E "unexpected error while filling mouse message buffer\n");
   }
   else {
      /* normally only this case should happen */
      for (i = 0; i < waiting_messages; i++) {
         mouse_dinput_handle_event(message_buffer[i].dwOfs,
                                   message_buffer[i].dwData);
      }

      if (gfx_driver && gfx_driver->windowed) {
         /* windowed input mode */
         if (!wnd_sysmenu) {
            POINT p;

            READ_CURSOR_POS(p);

            mymickey_x += p.x - mymickey_ox;
            mymickey_y += p.y - mymickey_oy;

            mymickey_ox = p.x;
            mymickey_oy = p.y;

            _handle_mouse_input();
         }
      }
      else {
         /* fullscreen input mode */
         mymickey_x += dinput_x - mymickey_ox;
         mymickey_y += dinput_y - mymickey_oy;

         mymickey_ox = dinput_x;
         mymickey_oy = dinput_y;

         _mouse_x = MICKEY_TO_COORD_X(mouse_mx + dinput_x);
         _mouse_y = MICKEY_TO_COORD_Y(mouse_my + dinput_y);

         if ((_mouse_x < mouse_minx) || (_mouse_x > mouse_maxx) ||
             (_mouse_y < mouse_miny) || (_mouse_y > mouse_maxy)) {

            _mouse_x = MID(mouse_minx, _mouse_x, mouse_maxx);
            _mouse_y = MID(mouse_miny, _mouse_y, mouse_maxy);

            mouse_mx = COORD_TO_MICKEY_X(_mouse_x);
            mouse_my = COORD_TO_MICKEY_Y(_mouse_y);

            CLEAR_MICKEYS();
         }

         if (!_mouse_on) {
            _mouse_on = TRUE;
            wnd_schedule_proc(mouse_set_syscursor);
         }

         _handle_mouse_input();
      }
   }
}