:-). 我是通过手机putty wifi连接到自己笔记本实现的. 代码如下 今天晚上写出来个大概 测试了一下 可以使用 嘿嘿
#include <stdio.h> #include <termios.h> #include <stdlib.h> #include <sys/time.h> #include <sys/types.h> #include <string.h> #include <unistd.h> #include <xdo.h> #define POS_PLUS 5 #define D_POS_PLUS 50 /** !@description Nokia Symbian S60 V3 Arrow key UP ----> 27 91 65 Arrow key LEFT ----> 27 91 68 Down ----> 27 91 66 Right ---> 27 91 67 Confirm key----> 10 (simulate pressing enter) * * * * * */ int setTTY() { int ttyDevice = STDOUT_FILENO; printf("%s\n","Noncanonical terminal mode is enabled"); /* [-]icanon enable erase, kill, werase, and rprnt special characters*/ /*min N with -icanon, set N characters minimum for a completed read */ system("stty -icanon"); printf(">"); /* Make sure file descriptor is for a TTY device. */ if ( ! isatty(ttyDevice) ) { printf("Not a TTY device.n"); return(EXIT_FAILURE); } /* Flush both the input and output queues. */ else { if (tcflush(ttyDevice, TCIOFLUSH) == 0) ; //printf("The input and output queues have been flushed\n"); else perror("tcflush error"); } } int nonCanonical(int sign) { struct termios ttystate; //get the terminal state tcgetattr(STDIN_FILENO, &ttystate); if (sign==1) { /*turn off canonical mode*/ ttystate.c_lflag &= ~ICANON; /* To diable canonical input*/ ttystate.c_lflag &= ~ECHO; // To disable user see what he types /*ttystate.c_lflag &= ~ISIG; To disable Control signals using control Keys minimum of number input read.*/ ttystate.c_cc[VMIN] = 1; } else { /*turn on canonical mode*/ ttystate.c_lflag |= ICANON; /*To enable Canonical mode*/ ttystate.c_lflag |= ECHO; /*To enable user see what he pressed*/ } /*set the terminal attributes.*/ tcsetattr(STDIN_FILENO, TCSANOW, &ttystate); return 1; } int handlerKeyPress(char *display) { static fd_set rfds; struct timeval tv; char a,b,c; char str[20]; xdo_t *p_xt=xdo_new(display); while (1==1) { // Set up stdin buffer probe FD_ZERO(&rfds); FD_SET(0, &rfds); tv.tv_sec = 0; tv.tv_usec = 0; if (!select(1, &rfds, NULL, NULL, &tv)) { // No input available //skips++; } else { // Input available immediately a = getchar(); //printf("%d\n",c); switch(a) { /**< */ case 27: b=getchar(); c=getchar(); switch(c) { /**< Arrow Up */ case 65: xdo_mousemove_relative(p_xt,0,-POS_PLUS); break; /**< Arrow Down */ case 66: xdo_mousemove_relative(p_xt,0,POS_PLUS); break; /**< Arrow Right */ case 67: xdo_mousemove_relative(p_xt,POS_PLUS,0); break; /**< Arrow Left */ case 68: xdo_mousemove_relative(p_xt,-POS_PLUS,0); break; }; break; /**< left click */ case 'q': xdo_click(p_xt,CURRENTWINDOW,1); break; case 'p': /**< right click */ xdo_click(p_xt,CURRENTWINDOW,3); break; /**< mouse left button down */ case 'w': xdo_mousedown(p_xt,CURRENTWINDOW,1); break; /**< mouse left button up */ case 'e': xdo_mouseup(p_xt,CURRENTWINDOW,1); break; /**< for longer distance mouse move */ case 'y': xdo_mousemove_relative(p_xt,0,-D_POS_PLUS); break; case 'n': xdo_mousemove_relative(p_xt,0,D_POS_PLUS); break; case 'g': xdo_mousemove_relative(p_xt,-D_POS_PLUS,0); break; case 'j': xdo_mousemove_relative(p_xt,D_POS_PLUS,0); break; /**< Delete key */ case 127: xdo_keysequence(p_xt,CURRENTWINDOW,"BackSpace",12000); break; /**< copy paste and cancel */ case 'c': xdo_keysequence(p_xt,CURRENTWINDOW,"Control_L+c",12000); break; case 'v': xdo_keysequence(p_xt,CURRENTWINDOW,"Control_L+v",12000); break; case 'z': xdo_keysequence(p_xt,CURRENTWINDOW,"Control_L+z",12000); } } } xdo_free(p_xt); } int main(int argc, char **argv) { if(argc<=1) { printf("rmctool needs a DISPLAY argument\n"); } setTTY(); nonCanonical(1); handlerKeyPress(argv[1]); return EXIT_SUCCESS; } 2011/5/6 RLP <rhyslpr...@yahoo.com.cn>: > On 2011-05-06 Guannan Ma <myth...@gmail.com> wrote: > >>蓝牙方向键? >> >>不明白.... >>能给出个程序名称么 或者驱动名称 >> >>我的手机是nokia e5-00 >>就是symbian s60 v3 >> >>我没有蓝牙方向键相关的程序控制 >>我的笔记本和手机倒是都支持蓝牙. >> >> > > 嘿嘿, 蓝牙, (手机)方向键, 是我的错误, 中间没有断字. 我是老手机, 爱立信自带的软件, 不知道s60上有没有类似的软件. > 再说了, 这只是手机这一端的, 笔记本那里就是普通的ubuntu默认的什么东西, 我是通过那个蓝牙applet控制的, 也没有什么特别的对话框, set > up new device就搞定了. > > -- > ubuntu-zh mailing list > ubuntu-zh@lists.ubuntu.com > https://lists.ubuntu.com/mailman/listinfo/ubuntu-zh > -- ubuntu-zh mailing list ubuntu-zh@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/ubuntu-zh