?? helio.c
字號(hào):
else { *pb = 0; return 3; }#endif#ifndef _TP_HELIO /* did we lose any data? */ if ( (data[0] & 0x2000) ) fprintf(stderr, "Lost touch panel data\n"); /* do we only have contact state data (no position data)? */ if ( (data[0] & 0x8000) == 0 ) { /* is it a pen-release? */ if ( (data[0] & 0x4000) == 0 ) { /* reset the limiter */ have_last_data = 0; /* reset the filter */ iir_count = 0; iir_accum_x = 0; iir_accum_y = 0; iir_accum_z = 0; /* return the pen (button) state only, */ /* indicating that the pen is up (no buttons are down)*/ *pb = 0; return 3; } /* ignore pen-up since we don't know where it is */ return 0; }#endif /* we have position data */#ifdef _TP_HELIO data_x = data[1]; data_y = data[2]; data_z = data[0] ? 2000 : 0;#else /* * Combine the complementary panel readings into one value (except z) * This effectively doubles the sampling freqency, reducing noise * by approx 3db. * Again, please don't quote the 3db figure. I think it also * cancels out changes in the overall resistance of the panel * such as may be caused by changes in panel temperature. */ data_x = data[2] - data[1]; data_y = data[4] - data[3]; data_z = data[5]; /* isn't z big enough for valid position data? */ if ( data_z <= low_z_limit ) { return 0; } /* has the position changed more than we will allow? */ if ( have_last_data ) { if ( (abs(data_x - last_data_x) > data_change_limit) || ( abs(data_y - last_data_y) > data_change_limit ) ) { return 0; } }#endif /* save last position */ last_data_x = data_x; last_data_y = data_y; have_last_data = 1;#ifdef _TP_HELIO if (enable_coor_transf) { POINT transformed = {data_x, data_y}; transformed = DeviceToScreen(transformed); *px = transformed.x >> 2; *py = transformed.y >> 2; } else { *px = data_x; *py = data_y; } *pb = data[0] ? BUTTON_L : 0; return 2;#else /* is filter ready? */ if ( iir_count == iir_sample_depth ) { /* make room for new sample */ iir_accum_x -= iir_accum_x >> iir_shift_bits; iir_accum_y -= iir_accum_y >> iir_shift_bits; iir_accum_z -= iir_accum_z >> iir_shift_bits; /* feed new sample to filter */ iir_accum_x += data_x; iir_accum_y += data_y; iir_accum_z += data_z; /* transformation enabled? */ if (enable_coor_transf) { /* transform x,y to screen coords */ POINT transformed = {iir_accum_x, iir_accum_y}; transformed = DeviceToScreen(transformed); /* * HACK: move this from quarter pixels to whole * pixels for now at least until I decide on the * right interface to get the quarter-pixel data * up to the next layer. */ *px = transformed.x >> 2; *py = transformed.y >> 2; } else { /* return untransformed coords (for calibration) */ *px = iir_accum_x; *py = iir_accum_y; } *pb = BUTTON_L; /* return filtered pressure */ *pz = iir_accum_z; return 2; }#endif /* prime the filter */ iir_accum_x += data_x; iir_accum_y += data_y; iir_accum_z += data_z; iir_count += 1; return 0;}/************************ Low Level Input Operations **********************//* * Mouse operations -- Event */static int mouse_update (void){ return 1;}static void mouse_getxy (int* x, int* y){ *x = tp_px; *y = tp_py;}static int mouse_getbutton(void){ return tp_pb;}static int keyboard_update(void){ switch (btn_state) { case (char)0x55: //left up-down state[SCANCODE_CURSORBLOCKUP] = 1; break; case (char)0xd5: //left up-up state[SCANCODE_CURSORBLOCKUP] = 0; break; case (char)0x44: //left down-down state[SCANCODE_CURSORBLOCKDOWN] = 1; break; case (char)0xc4: //left down-up state[SCANCODE_CURSORBLOCKDOWN] = 0; break; case (char)0x31: //down 2-down state[SCANCODE_LEFTALT] = 1; break; case (char)0xb1: //down 2-up state[SCANCODE_LEFTALT] = 0; break; case (char)0x32: //down 3-down state[SCANCODE_RIGHTALT] = 1; break; case (char)0xb2: //down 3-up state[SCANCODE_RIGHTALT] = 0; break; case (char)0x33: //down4-down state[SCANCODE_RIGHTCONTROL] = 1; break; case (char)0xb3: //down4-up state[SCANCODE_RIGHTCONTROL] = 0; break; } return NR_KEYS;}static const char* keyboard_getstate(void){ return (char *)state;}#ifdef _LITE_VERSIONstatic int wait_event (int which, int maxfd, fd_set *in, fd_set *out, fd_set *except, struct timeval *timeout)#elsestatic int wait_event (int which, fd_set *in, fd_set *out, fd_set *except, struct timeval *timeout)#endif{ fd_set rfds; int e; int retvalue = 0; int result; if (!in) { in = &rfds; FD_ZERO (in); } if (which & IAL_MOUSEEVENT) { FD_SET (tp_fd, in); if (tp_fd > maxfd) maxfd = tp_fd; }#ifdef _HELIO_BUTTONS if (which & IAL_KEYEVENT){ FD_SET (btn_fd, in); if(btn_fd > maxfd) maxfd = btn_fd; }#endif e = select (maxfd + 1, in, out, except, timeout) ; if (e > 0) { if (tp_fd >= 0 && FD_ISSET (tp_fd, in)) { FD_CLR (tp_fd, in); result = PD_Read(&tp_px, &tp_py, &tp_pz, &tp_pb); if (result > 0) { retvalue |= IAL_MOUSEEVENT; } }#ifdef _HELIO_BUTTONS if (btn_fd >= 0 && FD_ISSET(btn_fd, in)) { char data; FD_CLR(btn_fd, in); result = read(btn_fd, &data, sizeof(data)); btn_state = data; retvalue |= IAL_KEYEVENT; }#endif } else if (e < 0) { return -1; } return retvalue;}BOOL InitHelioInput (INPUT* input, const char* mdev, const char* mtype){ if (PD_Open() < 0 ) { fprintf (stderr, "IAL Helio Engine: Can not open touch panel!\n"); return FALSE; }#ifdef _HELIO_BUTTONS btn_fd = open (BTN_DEV_FILE, O_RDONLY); if (btn_fd < 0) { return FALSE; }#endif input->update_mouse = mouse_update; input->get_mouse_xy = mouse_getxy; input->set_mouse_xy = NULL; input->get_mouse_button = mouse_getbutton; input->set_mouse_range = NULL; input->update_keyboard = keyboard_update; input->get_keyboard_state = keyboard_getstate; input->set_leds = NULL; input->wait_event = wait_event; return TRUE;}void TermHelioInput (void){ PD_Close();}#endif /* _HELIO_IAL */
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -