티스토리 뷰
고객사의 요청에 따라 자사의 X Module Driver를 껐다 켰다 하는 프로그램을 작성했다.
#include <X11/extensions/XInput.h>
#include <STDIO.H>
#include <STDLIB.H>
#include <STRING.H>
int main()
{
int loop, num_devices;
XDevice *device;
char **extensions;
Display *dpy;
XDeviceInfo *devices;
int digi_id;
int onoff; //1 : on 2 : off
XDeviceEnableControl xDeviceEnableControl;
dpy = XOpenDisplay(NULL);
devices = XListInputDevices(dpy, &num_devices);
for(loop = 0;loop < num_devices;loop++)
{
printf("%d: \"%s\" [", devices[loop].id, devices[loop].name ? devices[loop].name : "<NONAME>");
if(!strcmp(devices[loop].name,"DriverName")) //if same
digi_id = devices[loop].id;
}
printf("\n\nMyDriver id : %d\n",digi_id);
printf("**************************************************\n");
printf("1. on 2.off\n");
printf("input>");
scanf("%d",&onoff);
device = XOpenDevice(dpy,digi_id);
if(device)
{
if(onoff == 1) //on
xDeviceEnableControl.enable = 1;
else if(onoff == 2) //off
xDeviceEnableControl.enable = 0;
}
xDeviceEnableControl.length = sizeof(xDeviceEnableControl);
xDeviceEnableControl.control = DEVICE_ENABLE;
XChangeDeviceControl(dpy, device, DEVICE_ENABLE,(XDeviceControl*)&xDeviceEnableControl);
printf("device %s\n",(onoff==1)?"on":"off");
device = XCloseDevice(dpy,device);
return 0;
}
소스코드는 별거 없고 컴파일 시에 Xi와 X11 라이브러리를 포함시켜 줘야 한다. (gcc -lX11 -lXi)
너무 간단해서 따로 설명이 필요 없을 것 같다.. XListInputDevice로 XDeviceInfo의 정보를 얻어와서 장치들을 열거 한 후
제어하기 원하는 장치의 이름을 매핑 시켜 id를 얻어와서 XOpenDevice로 장치를 open하여 제어하는게 전부이다.
간단한 소스코드지만 무에서 유를 창조했다는 것이 기쁠 따름~~!
도움이 된 페이지 : http://www.opensource.apple.com/source/X11apps/X11apps-30/xsetpointer/xsetpointer-1.0.1/xsetpointer.c
'Development > Driver' 카테고리의 다른 글
| USB Setup transaction format (0) | 2010.06.09 |
|---|---|
| IHV 세미나(20100520) 요약 (0) | 2010.05.31 |
| WinDbg와 VMWare 환경설정하기 (0) | 2010.04.27 |
| ClassGUID (0) | 2010.04.27 |
| 레지스트리 SERVICE에 있는 변수 설명 (0) | 2010.04.27 |
| Vista에서 드라이버 배포하는 방법 (2) | 2010.04.22 |
| Windows Vista 응용프로그램, 드라이버에 코드 사이닝 하기 (1) | 2010.04.20 |
| Code Signing(Authenticode) 해야하는 이유 (0) | 2010.04.15 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- 음악
- it
- db
- Cloud
- 리눅스
- source
- AWS
- C++
- gcc
- driver
- android
- 안드로이드
- Python
- kering
- winapi
- C
- algorithm
- java
- Troubleshooting
- NDK
- 드라이버
- MFC
- linux
- jni
- API
- Quiz
- jni강좌
- Visual C++
- 프로그래밍
- database
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | |||
| 5 | 6 | 7 | 8 | 9 | 10 | 11 |
| 12 | 13 | 14 | 15 | 16 | 17 | 18 |
| 19 | 20 | 21 | 22 | 23 | 24 | 25 |
| 26 | 27 | 28 | 29 | 30 | 31 |
글 보관함
OnOffModule.zip