#include <iostream>

#include <unistd.h>


#include <sys/ioctl.h>

#include <sys/mouse.h>


// file open close using 

#include <fcntl.h>

// error printing using

#include <errno.h>


#define PSM_LEVEL_NATIVE    2

void checking(int number)

{

   printf(" error="" :%d\n",errno);<="" p="">

}


int main()

{

    int fd;

        // file descripter 

    int ret ;

    int level = PSM_LEVEL_NATIVE;    

    mousehw_t mhw;

      fd = open("/dev/sysmouse",O_RDWR);

      std::cout<<"FD :    "<<fd<<std::endl; 

      

      if(fd==-1)

       {

            std::cout<<"Open Error -> ErrorNumber : -> ";

            checking(1);

            std::cout<<""<<std::endl;

        }

// ret = ioctl(fd,MOUSE_SETLEVEL,&level);


 //    if(ret!=0)

  //   {

   //             checking(0);

    // }

    ret = ioctl(fd,MOUSE_GETHWINFO,&mhw);

    if(ret!=0)

    {

            checking(1);

    }


    

       std::cout<<"hw -> Type " <<mhw.type <<std::endl;

       std::cout<<"hw -> buttons " <<mhw.buttons <<std::endl;

       std::cout<<"hw -> model " <<mhw.model <<std::endl;

       std::cout<<"hw -> iftype " << mhw.iftype<<std::endl;

       std::cout<<"hw -> hwid "  <<mhw.hwid<<std::endl;    

    

    

    

    std::cout<<"closed fd"<<std::endl;




    return 0;

}


ioctl(int fd, Request 메시지, 파라미터)


Request 메시지중 MOUSE_GETHWINFO 를 보낼떄 받을 파라미터로 mousehw_t 를 보내게 된다. 물론 * 로

ioctl(fd,MOUSE_GETHWINFO,&mhw)를 보내게 되면

해당 구조체에 내용이 채워져서 나타나게 된다.

  typedef struct mousehw {
		int buttons;	/* number of buttons */
		int iftype;	/* I/F type */
		int type;	/* mouse/track ball/pad... */
		int model;	/* I/F dependent model ID */
		int hwid;	/* I/F dependent hardware ID */
	    } mousehw_t;
iftype 은 항상 MOUSE_IF_SYSMOUSE.

hwid 은 항상 0

model은 항상 MOUSE_MODEL_GENERIC Operation Level 0일때 더 높은 레벨의 경우에 MOUSE_MODEL_XXX

type 은 장치 타입이다. :  MOUSE_MOUSE, MOUSE_TRACKBALL, MOUSE_STICK, MOUSE_PAD, or MOUSE_UNKNOWN.


일단 마우스의 정보 정돈 가져올수 있게 된다. 



'GNU > FreeBSD' 카테고리의 다른 글

Mouse_Control - 5 번째(Consio.h)  (0) 2016.07.06
Mouse_Control - 4 번째(Consio.h)  (0) 2016.07.04
COMMAND - top  (0) 2016.07.04
Unix Errno 표기  (0) 2016.07.04
Mouse_Control - 3 일차  (0) 2016.07.01

+ Recent posts