Example #1
0
//=================================================================================================
void Controls::SelectCell(int item, int column, int button)
{
	if(button == 0)
	{
		Key.SetState(VK_LBUTTON, IS_UP);
		picked = item;
		picked_n = column-1;
		cursor_tick = 0.f;
		game->key_callback = KeyDownCallback(this, &Controls::OnKey);
		game->cursor_allow_move = false;
	}
	else
		GKey[item][column-1] = VK_NONE;
}
Example #2
0
void doEvents(int __display_width, int __display_height,
	      void (*KeyDownCallback)(unsigned char,int,int),
	      void (*KeyUpCallback)(unsigned char,int,int)) {

  if (__key_fd==0) {
    char buf[1];
    int res;

    res = read(__key_fd, &buf[0], 1);
    while (res >= 0) {
      //printf("keyboard %i\n",buf[0]);
      if (buf[0] & 0x80) {
	printf("key %i released\n",(buf[0]&~0x80));
	KeyUpCallback(buf[0]&~0x80,0,0);
      } else {
	printf("key %i pressed\n",(buf[0]&~0x80));
	KeyDownCallback(buf[0]&~0x80,0,0);
      }
      res = read(__key_fd, &buf[0], 1);
    }

  } else {

    struct input_event ev;
    int res;
    res = read(__key_fd, &ev,sizeof(struct input_event));
    while (res>=0) {
      //printf(" %i %i %i\n",ev.type,ev.code,ev.value);
      // should probably handle MSC and SYN as well - meh
      if (ev.type==EV_KEY) {

	if (ev.value==1) {
	  //printf("%d\n",lc_map[ev.code]);
	  KeyDownCallback(lc_map[ev.code&0xff],0,0);
	} else if (ev.value==0) {
	  KeyUpCallback(lc_map[ev.code&0xff],0,0);
	}
      }
      res = read(__key_fd, &ev,sizeof(struct input_event));
    }


  }

  if (__rel_mouse) {
    __mouse[0]=0;
    __mouse[1]=0;
  }

  if(__mouse_fd>0) {
    signed char mbuf[3];
    int mres;
    mres=read(__mouse_fd,&mbuf[0],3);
    while(mres>=0) {
      //printf("%i %i %i\n",mbuf[0]&7,mbuf[1],mbuf[2]);
      __mouse[2]=mbuf[0]&7;
      if (__rel_mouse) {
	__mouse[0]=mbuf[1];
	__mouse[1]=-mbuf[2];
      } else {
	__mouse[0]=__mouse[0]+mbuf[1];
	__mouse[1]=__mouse[1]-mbuf[2];
	if (__mouse[0]<0) __mouse[0]=0;
	if (__mouse[1]<0) __mouse[1]=0;
	if (__mouse[0]>__display_width) __mouse[0]=__display_width;
	if (__mouse[1]>__display_height) __mouse[1]=__display_height;
      }

      mres=read(__mouse_fd,&mbuf[0],3);
    }

  }

}