Advertisement
Guest User

kmcable usb code

a guest
Jul 3rd, 2018
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define MAX_SENSE_LENGTH 24
  2. #define MAX_CDB_LENGTH 16
  3. #define MAX_TRANSFER_BUFFER_LENGTH 1 << 16
  4.  
  5. #define HID_MOUSE_NO_BUTTON         0x00
  6. #define HID_MOUSE_RIGHT_BUTTON      0x01
  7. #define HID_MOUSE_LEFT_BUTTON       0x02
  8.  
  9. #define HID_KEY_MOD_LEFT_CTRL       0x01
  10. #define HID_KEY_MOD_LEFT_SHIFT      0x02
  11. #define HID_KEY_MOD_LEFT_ALT        0x04
  12. #define HID_KEY_MOD_LEFT_META       0x08
  13. #define HID_KEY_MOD_RIGHT_CTRL      0x10
  14. #define HID_KEY_MOD_RIGHT_SHIFT     0x20
  15. #define HID_KEY_MOD_RIGHT_ALT       0x40
  16. #define HID_KEY_MOD_RIGHT_META      0x80
  17.  
  18. #define HID_KEY_NONE                0x00
  19. #define HID_KEY_ERROR_ROLLOVER      0x01
  20. #define HID_KEY_ERROR_POSTFAIL      0x02
  21. #define HID_KEY_ERROR_UNDEFINED     0x03
  22.  
  23. #define HID_KEY_A                   0x04
  24. #define HID_KEY_B                   0x05
  25. #define HID_KEY_C                   0x06
  26. #define HID_KEY_D                   0x07
  27. #define HID_KEY_E                   0x08
  28. #define HID_KEY_F                   0x09
  29. #define HID_KEY_G                   0x0a
  30. #define HID_KEY_H                   0x0b
  31. #define HID_KEY_I                   0x0c
  32. #define HID_KEY_J                   0x0d
  33. #define HID_KEY_K                   0x0e
  34. #define HID_KEY_L                   0x0f
  35. #define HID_KEY_M                   0x10
  36. #define HID_KEY_N                   0x11
  37. #define HID_KEY_O                   0x12
  38. #define HID_KEY_P                   0x13
  39. #define HID_KEY_Q                   0x14
  40. #define HID_KEY_R                   0x15
  41. #define HID_KEY_S                   0x16
  42. #define HID_KEY_T                   0x17
  43. #define HID_KEY_U                   0x18
  44. #define HID_KEY_V                   0x19
  45. #define HID_KEY_W                   0x1a
  46. #define HID_KEY_X                   0x1b
  47. #define HID_KEY_Y                   0x1c
  48. #define HID_KEY_Z                   0x1d
  49.  
  50. #define HID_KEY_1                   0x1e // 1 and !
  51. #define HID_KEY_2                   0x1f // 2 and @
  52. #define HID_KEY_3                   0x20 // 3 and #
  53. #define HID_KEY_4                   0x21 // 4 and $
  54. #define HID_KEY_5                   0x22 // 5 and %
  55. #define HID_KEY_6                   0x23 // 6 and ^
  56. #define HID_KEY_7                   0x24 // 7 and &
  57. #define HID_KEY_8                   0x25 // 8 and *
  58. #define HID_KEY_9                   0x26 // 9 and (
  59. #define HID_KEY_0                   0x27 // 0 and )
  60.  
  61. #define HID_KEY_EXCLAMATION         0x1e // 1 and !
  62. #define HID_KEY_AT                  0x1f // 2 and @
  63. #define HID_KEY_HASH                0x20 // 3 and #
  64. #define HID_KEY_DOLLAR              0x21 // 4 and $
  65. #define HID_KEY_PERCENT             0x22 // 5 and %
  66. #define HID_KEY_CIRCUMFLEX          0x23 // 6 and ^
  67. #define HID_KEY_AMPERSAND           0x24 // 7 and &
  68. #define HID_KEY_ASTERISK            0x25 // 8 and *
  69. #define HID_KEY_LEFTPARENTTHESIS    0x26 // 9 and (
  70. #define HID_KEY_RIGHTPARENTTHESIS   0x27 // 0 and )
  71.  
  72. #define HID_KEY_RETURN              0x28 // RETURN
  73. #define HID_KEY_ESC                 0x29 // ESCAPE
  74. #define HID_KEY_BACKSPACE           0x2a // Backspace
  75. #define HID_KEY_TAB                 0x2b // Tab
  76. #define HID_KEY_SPACE               0x2c // Spacebar
  77. #define HID_KEY_MINUS               0x2d // - and _
  78. #define HID_KEY_UNDERSCORE          0x2d // - and _
  79. #define HID_KEY_EQUAL               0x2e // = and +
  80. #define HID_KEY_PLUS                0x2e // = and +
  81. #define HID_KEY_LEFTBRACE           0x2f // [ and {
  82. #define HID_KEY_RIGHTBRACE          0x30 // ] and }
  83.  
  84. #define HID_KEY_BACKSLASH           0x31 // \ and |
  85. #define HID_KEY_PIPE                0x31 // \ and |
  86. #define HID_KEY_HASHTILDE           0x32 // Non-US # and ~
  87. #define HID_KEY_SEMICOLON           0x33 // ; and :
  88. #define HID_KEY_COLON               0x33 // ; and :
  89. #define HID_KEY_QUOTE               0x34 // ' and "
  90. #define HID_KEY_DOUBLE_QUOTE        0x34 // ' and "
  91. #define HID_KEY_GRAVE               0x35 // ` and ~
  92. #define HID_KEY_TILDE               0x35 // ` and ~
  93.  
  94. #define HID_KEY_COMMA               0x36 // , and <
  95. #define HID_KEY_LESSTHAN            0x36 // , and <
  96. #define HID_KEY_DOT                 0x37 // . and >
  97. #define HID_KEY_GREATETHAN          0x37 // . and >
  98. #define HID_KEY_SLASH               0x38 // / and ?
  99. #define HID_KEY_QUESTIONMARK        0x38 // / and ?
  100. #define HID_KEY_CAPSLOCK            0x39 // Caps Lock
  101.  
  102. #define HID_KEY_F1                  0x3a // F1
  103. #define HID_KEY_F2                  0x3b // F2
  104. #define HID_KEY_F3                  0x3c // F3
  105. #define HID_KEY_F4                  0x3d // F4
  106. #define HID_KEY_F5                  0x3e // F5
  107. #define HID_KEY_F6                  0x3f // F6
  108. #define HID_KEY_F7                  0x40 // F7
  109. #define HID_KEY_F8                  0x41 // F8
  110. #define HID_KEY_F9                  0x42 // F9
  111. #define HID_KEY_F10                 0x43 // F10
  112. #define HID_KEY_F11                 0x44 // F11
  113. #define HID_KEY_F12                 0x45 // F12
  114.  
  115. #define HID_KEY_PRINT               0x46 // Print Screen
  116. #define HID_KEY_SCROLLLOCK          0x47 // Scroll Lock
  117. #define HID_KEY_PAUSE               0x48 // Pause
  118. #define HID_KEY_INSERT              0x49 // Insert
  119. #define HID_KEY_HOME                0x4a // Home
  120. #define HID_KEY_PAGEUP              0x4b // Page Up
  121. #define HID_KEY_DELETE              0x4c // Delete Forward
  122. #define HID_KEY_END                 0x4d // End
  123. #define HID_KEY_PAGEDOWN            0x4e // Page Down
  124. #define HID_KEY_RIGHT               0x4f // Right Arrow
  125. #define HID_KEY_LEFT                0x50 // Left Arrow
  126. #define HID_KEY_DOWN                0x51 // Down Arrow
  127. #define HID_KEY_UP                  0x52 // Up Arrow
  128.  
  129. #define HID_KEY_NUMLOCK             0x53 // Num Lock and Clear
  130. #define HID_KEY_KEYPAD_SLASH        0x54 // Keypad /
  131. #define HID_KEY_KEYPAD_ASTERISK     0x55 // Keypad *
  132. #define HID_KEY_KEYPAD_MINUS        0x56 // Keypad -
  133. #define HID_KEY_KEYPAD_PLUS         0x57 // Keypad +
  134. #define HID_KEY_KEYPAD_ENTER        0x58 // Keypad ENTER
  135. #define HID_KEY_KEYPAD_1            0x59 // Keypad 1 and End
  136. #define HID_KEY_KEYPAD_2            0x5a // Keypad 2 and Down Arrow
  137. #define HID_KEY_KEYPAD_3            0x5b // Keypad 3 and PageDn
  138. #define HID_KEY_KEYPAD_4            0x5c // Keypad 4 and Left Arrow
  139. #define HID_KEY_KEYPAD_5            0x5d // Keypad 5
  140. #define HID_KEY_KEYPAD_6            0x5e // Keypad 6 and Right Arrow
  141. #define HID_KEY_KEYPAD_7            0x5f // Keypad 7 and Home
  142. #define HID_KEY_KEYPAD_8            0x60 // Keypad 8 and Up Arrow
  143. #define HID_KEY_KEYPAD_9            0x61 // Keypad 9 and Page Up
  144. #define HID_KEY_KEYPAD_0            0x62 // Keypad 0 and Insert
  145. #define HID_KEY_KEYPAD_DOT          0x63 // Keypad ./, and Delete
  146.  
  147. #define USB_HOST_TO_HOST_TIMEOUT 5
  148.  
  149. #ifdef MS_WINDOWS
  150. #include <windows.h>
  151. #include <ntddscsi.h>
  152.  
  153. #else
  154. #include <stdlib.h>
  155. #include <stdio.h>
  156. #include <errno.h>
  157. #include <string.h>
  158. #include <stdarg.h>
  159. #include <fcntl.h>
  160. #include <sys/stat.h>
  161. #include <sys/types.h>
  162.  
  163. #include <scsi/sg.h>
  164. #include <sys/ioctl.h>
  165.  
  166. #define INTERFACE_ID (int)'S'    
  167. typedef int HANDLE;
  168. #define INVALID_HANDLE_VALUE -1
  169.  
  170. #define TRUE 1
  171. #define FALSE 0
  172.  
  173. typedef struct
  174. {
  175.     sg_io_hdr_t io_hdr;
  176.     unsigned char cdb[MAX_CDB_LENGTH];
  177.     unsigned char sense_buffer[MAX_SENSE_LENGTH];
  178. } SCSI_PASS_THROUGH_DIRECT;
  179. #endif
  180.  
  181. unsigned char usb_h2h_cdb_read[MAX_CDB_LENGTH]     = {217,40,100,0,0,0,0,0,0,0,0,0,0,0,79,84};
  182. unsigned char usb_h2h_cdb_write[MAX_CDB_LENGTH]    = {217,42,255,0,0,0,0,0,0,0,0,0,0,0,79,84};
  183. unsigned char usb_h2h_cdb_keyboard[MAX_CDB_LENGTH] = {217,52,0,0,0,0,0,0,0,0,0,0,0,0,79,84};
  184. unsigned char usb_h2h_cdb_mouse[MAX_CDB_LENGTH]    = {217,51,0,0,0,0,0,0,0,0,0,0,0,0,79,84};
  185.  
  186. typedef struct
  187. {
  188.     SCSI_PASS_THROUGH_DIRECT scsi_op;
  189.     HANDLE handle_dev
  190.     unsigned char* buffer;
  191.     unsigned int buffer_size;
  192.     unsigned char read_count;
  193. } USB_HOST_TO_HOST_TRANSFER;
  194.  
  195. int __is_invalid_device_handle(HANDLE handle)
  196. {
  197.     #ifdef MS_WINDOWS
  198.     return (INVALID_HANDLE_VALUE == handle);
  199.     #else
  200.     return (handle < 0);
  201.     #endif
  202. }
  203.  
  204. void __close_device_handle(HANDLE handle)
  205. {
  206.     if (__is_invalid_device_handle(handle))
  207.     {
  208.         // handle is invalid
  209.     }
  210.     else
  211.     {
  212.         #ifdef MS_WINDOWS
  213.         CloseHandle(handle);
  214.         #else
  215.         close(handle);
  216.         #endif
  217.     }
  218. }
  219.  
  220. int __is_valid_device_name(const char *dev_path)
  221. {
  222.     #ifdef MS_WINDOWS  
  223.     char tmp[] = {'\\', '\\', '.', '\\', 'X' , ':' , 0};
  224.    
  225.     if (strlen(dev_path) = strlen(tmp))
  226.     {
  227.         char drive = dev_path[4];
  228.         tmp[4] = drive;
  229.        
  230.         if ( (drive >= 'a' && drive <= 'z') || (drive >= 'A' && drive <= 'Z') )
  231.         {  
  232.             if (strncmp(dev_path, tmp, strlen(tmp)) == 0)
  233.             {
  234.                 return TRUE;
  235.             }
  236.         }
  237.     }
  238.     #else
  239.     char tmp[] = {'/', 'd', 'e', 'v', '/' , 's', 'g', 0};
  240.    
  241.     if (strlen(dev_path) > strlen(tmp))
  242.     {
  243.         if (strncmp(dev_path, tmp, strlen(tmp)) == 0)
  244.         {
  245.             return TRUE;
  246.         }
  247.     }  
  248.     #endif
  249.     return FALSE;
  250. }
  251.  
  252. int __scsi_io(USB_HOST_TO_HOST_TRANSFER *transfer)
  253. {
  254.     int result = FALSE;
  255.     int status;
  256.     if (transfer != NULL)
  257.     {
  258.     #ifdef MS_WINDOWS
  259.         int bytesReturned = 0;
  260.         DeviceIoControl(transfer->handle_dev, IOCTL_SCSI_PASS_THROUGH_DIRECT, transfer->scsi_op, sizeof(SCSI_PASS_THROUGH_DIRECT), transfer->scsi_op, 80, &bytesReturned, NULL);
  261.         if (status != 0)
  262.         {
  263.             //success
  264.             result = TRUE;
  265.         }
  266.     #else
  267.         status = ioctl(transfer->handle_dev, SG_IO, &transfer->scsi_op);   
  268.         if (status == 0)
  269.         {
  270.             //success
  271.             result = TRUE;
  272.         }
  273.         //printf("driver status: %i\n",io_hdr_write.driver_status);
  274.         //printf("host status: %i\n",io_hdr_write.host_status);    
  275.     #endif 
  276.     }
  277. }
  278.  
  279. int __fill_SCSI_PASS_THROUGH_DIRECT(SCSI_PASS_THROUGH_DIRECT *op, int direction_read, unsigned int timeout, unsigned char *cdb, unsigned int cdb_size, void *buffer, unsigned int buffer_size)
  280. {
  281.     if (op)
  282.     {
  283.         if ( ( (buffer == NULL) && (buffer_size == 0) )  || ( (buffer && (buffer_size > 0) && (buffer_size <= MAX_TRANSFER_BUFFER_LENGTH) ) ) )
  284.         {
  285.             if ((cdb_size > 0) && (cdb_size <= MAX_CDB_LENGTH))
  286.             {
  287.                 //ok
  288.             }
  289.             else
  290.             {
  291.                 return FALSE;
  292.             }
  293.         }      
  294.         else
  295.         {
  296.             return FALSE;  
  297.         }  
  298.     }
  299.     else
  300.     {
  301.         return FALSE;
  302.     }  
  303.     #ifdef MS_WINDOWS
  304.     memset(op, 0, sizeof(SCSI_PASS_THROUGH_DIRECT));
  305.    
  306.     op->ScsiStatus = -1;
  307.     op->PathId = -1;
  308.     op->TargetId = -1;
  309.     op->Lun = -1;
  310.        
  311.     op->Length = sizeof(SCSI_PASS_THROUGH_DIRECT);
  312.  
  313.     op->DataIn = direction;
  314.     op->TimeOutValue = timeout;
  315.    
  316.     op->DataBuffer = buffer;
  317.     op->DataTransferLength = buffer_size;
  318.    
  319.     memcpy(op->scsi_op.Cdb, cdb, cdb_size);
  320.     op->CdbLength = cdb_size;
  321.  
  322.     op->SenseInfoLength = MAX_SENSE_LENGTH;
  323.     op->SenseInfoOffset = 48;
  324.    
  325.     #else
  326.    
  327.     memset(&op->io_hdr, 0, sizeof(sg_io_hdr_t));
  328.     memset(&op->sense_buffer, 0, MAX_SENSE_LENGTH);
  329.     op->io_hdr.interface_id = INTERFACE_ID;
  330.     op->io_hdr.mx_sb_len = MAX_SENSE_LENGTH;
  331.     op->io_hdr.sbp = op->sense_buffer;
  332.     op->io_hdr.timeout = timeout;
  333.    
  334.     op->io_hdr.cmdp = op->cdb;
  335.     op->io_hdr.cmd_len = cdb_size;
  336.     memcpy(op->cdb, cdb, cdb_size);
  337.    
  338.     if (direction_read)
  339.     {
  340.         op->io_hdr.dxfer_direction = SG_DXFER_FROM_DEV;
  341.     }
  342.     else
  343.     {
  344.         op->io_hdr.dxfer_direction = SG_DXFER_TO_DEV;  
  345.     }
  346.     op->io_hdr.dxferp = buffer;
  347.     op->io_hdr.dxfer_len = buffer_size;
  348.    
  349.     #endif
  350.     return TRUE;
  351. }
  352.  
  353. void usb_kmcable_free_device(USB_HOST_TO_HOST_TRANSFER *transfer)
  354. {
  355.     if (transfer == NULL)
  356.     {
  357.         if (transfer->buffer)
  358.             free(transfer->buffer);
  359.         __close_device_handle(transfer->handle_dev);       
  360.     }
  361. }
  362.  
  363. void* usb_kmcable_get_device_memory(USB_HOST_TO_HOST_TRANSFER *transfer)
  364. {
  365.     if (transfer)
  366.     {  
  367.         return transfer->buffer;
  368.     }
  369.     return NULL;
  370. }
  371.  
  372.  
  373. int usb_kmcable_send_keyboard(USB_HOST_TO_HOST_TRANSFER *transfer, int usb_key_mod, int usb_key)
  374. {
  375.     unsigned char cdb[MAX_CDB_LENGTH];
  376.     memcpy(&cdb[0], &usb_h2h_cdb_keyboard[0], sizeof(usb_h2h_cdb_keyboard));
  377.     cdb[2] = (usb_key_mod & 255);
  378.     cdb[4] = (usb_key & 255);
  379.     __fill_SCSI_PASS_THROUGH_DIRECT(&transfer->scsi_op, TRUE, USB_HOST_TO_HOST_TIMEOUT, cdb, MAX_CDB_LENGTH, NULL, 0);
  380.     return __scsi_io(transfer);
  381. }
  382.  
  383. int usb_kmcable_send_mouse(USB_HOST_TO_HOST_TRANSFER *transfer, int usb_mouse_keys, int usb_mouse_dx, int usb_mouse_dy)
  384. {
  385.     unsigned char cdb[MAX_CDB_LENGTH];
  386.     int result = FALSE;
  387.     if (transfer != NULL)
  388.     {  
  389.         memcpy(&cdb[0], &usb_h2h_cdb_mouse[0], sizeof(usb_h2h_cdb_mouse));
  390.        
  391.         if (usb_mouse_dx < - 127)
  392.             usb_mouse_dx = -127;
  393.         if (usb_mouse_dy < - 127)
  394.             usb_mouse_dy = -127;   
  395.        
  396.         if (usb_mouse_dx > 127)
  397.             usb_mouse_dx = 127;
  398.         if (usb_mouse_dy > 127)
  399.             usb_mouse_dy = 127;
  400.        
  401.         cdb[2] = (usb_mouse_keys & 255);
  402.         cdb[3] = (usb_mouse_dx & 255);
  403.         cdb[4] = (usb_mouse_dy & 255);
  404.         __fill_SCSI_PASS_THROUGH_DIRECT(&transfer->scsi_op, TRUE, USB_HOST_TO_HOST_TIMEOUT, cdb, MAX_CDB_LENGTH, NULL, 0)
  405.         result = __scsi_io(transfer);  
  406.     }
  407.     return result;     
  408. }
  409.  
  410. int usb_kmcable_send_data(USB_HOST_TO_HOST_TRANSFER *transfer)
  411. {
  412.     int result = FALSE;
  413.     if (transfer != NULL)
  414.     {
  415.         __fill_SCSI_PASS_THROUGH_DIRECT(&transfer->scsi_op, FALSE, USB_HOST_TO_HOST_TIMEOUT, usb_h2h_cdb_write, MAX_CDB_LENGTH, transfer->buffer, transfer->buffer_size);  
  416.         result = __scsi_io(transfer);  
  417.     }
  418.     return result;     
  419. }
  420.  
  421. int usb_kmcable_read_data(USB_HOST_TO_HOST_TRANSFER *transfer)
  422. {
  423.     int result = FALSE;
  424.     if (transfer != NULL)
  425.     {  
  426.         __fill_SCSI_PASS_THROUGH_DIRECT(&transfer->scsi_op, TRUE, USB_HOST_TO_HOST_TIMEOUT, usb_h2h_cdb_read, MAX_CDB_LENGTH, transfer->buffer, transfer->buffer_size);
  427.         #ifdef MS_WINDOWS
  428.             transfer->scsi_op.Cdb[8] = transfer->read_count;
  429.         #else
  430.             transfer->scsi_op.cdb[8] = transfer->read_count;
  431.         #endif 
  432.         result = __scsi_io(transfer);  
  433.         transfer->read_count++;
  434.     }
  435.     return result;
  436. }
  437.  
  438. int usb_kmcable_open_device(USB_HOST_TO_HOST_TRANSFER *transfer, char *dev_path)
  439. {
  440.     HANDLE handle = INVALID_HANDLE_VALUE;
  441.     char *buffer = NULL;
  442.     int ok = TRUE;
  443.     int vers;  
  444.    
  445.     if (transfer == NULL)
  446.     {
  447.         ok = FALSE;
  448.     }
  449.    
  450.     if (dev_path == NULL)
  451.     {
  452.         ok = FALSE;
  453.     }
  454.    
  455.     if (ok)
  456.     {      
  457.         if (!__is_valid_device_name(dev_path))
  458.         {
  459.             fprintf(stderr,"invalid device path '%s'!\n", dev_path);
  460.             ok = FALSE;
  461.         }
  462.     }
  463.    
  464.     if (ok)
  465.     {          
  466.         #ifdef MS_WINDOWS
  467.         handle = CreateFile(dev_path, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, FILE_FLAG_NO_BUFFERING, 0);
  468.         #else
  469.         handle = open(dev_path, O_RDWR);
  470.         #endif
  471.        
  472.         if (__is_invalid_device_handle(handle))
  473.         {
  474.             fprintf(stderr,"open device '%s' failed!\n", dev_path);
  475.             ok = FALSE;
  476.         }
  477.     }
  478.    
  479.     if (ok)
  480.     {      
  481.         #ifdef MS_WINDOWS
  482.         if (GetDriveType(dev_path + strlen("\\\\.\\")) != DRIVE_CDROM)
  483.         {
  484.             fprintf(stderr, "Device '%s' is not detected as CDROM drive", dev_path);
  485.             CloseHandle(handle);
  486.         }
  487.         #else
  488.         if ((ioctl(handle, SG_GET_VERSION_NUM, &vers) < 0) || (vers < 30000)) {
  489.             fprintf(stderr, "Device '%s' is not an sg device, or old sg driver\n", dev_path);
  490.            
  491.         }    
  492.         #endif
  493.     }
  494.  
  495.     if (ok)
  496.     {  
  497.         buffer = malloc(MAX_TRANSFER_BUFFER_LENGTH);
  498.         if (buffer == NULL)
  499.         {
  500.             fprintf(stderr, "Cannot allocate memory\n", dev_path);
  501.             ok = FALSE;
  502.         }
  503.     }
  504.    
  505.     if (ok)
  506.     {
  507.         transfer->handle_dev = handle;
  508.         transfer->read_count = 0;
  509.         transfer->buffer = buffer;
  510.         transfer->buffer_size = MAX_TRANSFER_BUFFER_LENGTH;    
  511.     }
  512.     else
  513.     {
  514.         if (buffer)
  515.             free(buffer);
  516.         __close_device_handle(handle);
  517.     }
  518.     return ok;
  519. }
  520.  
  521.  
  522.  
  523. void main()
  524. {
  525.     USB_HOST_TO_HOST_TRANSFER t;
  526.  
  527.     usb_kmcable_open_device(&t, "/dev/sg5");
  528.    
  529.     char *data_write = usb_kmcable_get_device_memory(&t);
  530.     memset(data_write,0, 65536);
  531.    
  532.     data_write[0] = 'H';
  533.     data_write[1] = 'a';    
  534.     data_write[2] = 'l';
  535.     data_write[3] = 'l';
  536.     data_write[4] = 'o';
  537.     data_write[5] = ' ';
  538.     data_write[6] = 'W';
  539.     data_write[7] = 'o';
  540.     data_write[8] = 'r';
  541.     data_write[9] = 'l';
  542.     data_write[10] = 'd';
  543.     data_write[11] = '1';
  544.     data_write[12] = '2';
  545.                                                
  546.     while(1)
  547.     {
  548.         printf("send\n");
  549.         usb_kmcable_send_mouse(&t, 0, 1, 1);
  550.         usb_kmcable_send_keyboard(&t,0,HID_KEY_A);
  551.         sleep(1);
  552.         usb_kmcable_send_keyboard(&t,0,0);
  553.         sleep(1);
  554.         //sendDevice(&t);
  555.        
  556.     }
  557.     return;
  558. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement