c - adapting xbox controller to simple ncurses game -


libusb_device_handle *h;                                                                                       int transferred , r;                           r = libusb_init(null);                 libusb_set_debug(null, 3);  //open device                                                h = libusb_open_device_with_vid_pid(null, 0x045e, 0x028e); if (h == null) {     fprintf(stderr, "failed open device\n");     return (1); }   r = libusb_kernel_driver_active(h,0);  if(r>0)     r = libusb_detach_kernel_driver(h,0);  r = libusb_claim_interface(h,0);  if(r!=0) {     fprintf(stderr, "interface failed: %d\n",r);     return (1); }  

this part of handling device , after in moving section have these piece of codes.

unsigned char buffer[20];     libusb_interrupt_transfer(h, 0x81, buffer, sizeof (buffer),  &transferred, 0); char direction = 'l';      if (((buffer[3] >> 6)&0x01)) {     if (direction != 'r')         direction = 'l'; } if (((buffer[3] >> 7)&0x01)) {     if (direction != 'd')         direction = 'u'; } if (((buffer[3] >> 4)&0x01)) {     if (direction != 'u')         direction = 'd'; } if (((buffer[3] >> 5)&0x01)) {     if (direction != 'l')         direction = 'r'; } 

but these piece of code not able move snake.what wrong it.


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -