Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8093

General • Re: Using Raspberry Pi Pico as HID bridge for Pi 5 - Feasibility check

$
0
0
Here are modifications to the current keymouse.c/txt that change the mouse to absolute, using MATSOBdev2's report map which works as advertised.

keymouse.txt

Code:

  PRIMARY_SERVICE = 1812    LECHAR=Protocol Mode   SIZE=1  Permit=06  UUID=2A4E      LECHAR=HID Info        SIZE=4  Permit=02  UUID=2A4A      LECHAR=HID Ctl Point   SIZE=8  Permit=04  UUID=2A4C       LECHAR=Report Map      SIZE=100 Permit=02  UUID=2A4B      LECHAR=Key report      SIZE=8  Permit=92  UUID=2A4D      LECHAR=Mouse report    SIZE=5  Permit=92  UUID=2A4D  
keymouse.c

Code:

unsigned char reportmap[100] = {0x05,0x01,0x09,0x06,0xA1,0x01,0x85,0x01,0x05,0x07,0x19,0xE0,0x29,0xE7,0x15,0x00,                               0x25,0x01,0x75,0x01,0x95,0x08,0x81,0x02,0x95,0x01,0x75,0x08,0x81,0x01,0x95,0x06,                               0x75,0x08,0x15,0x00,0x25,0x65,0x05,0x07,0x19,0x00,0x29,0x65,0x81,0x00,0xC0,                               0x05,0x01,0x09,0x02,0xA1,0x01,0x85,0x02,0x09,0x01,0xA1,0x00,0x05,0x09,0x19,0x01,                               0x29,0x03,0x15,0x00,0x25,0x01,0x95,0x03,0x75,0x01,0x81,0x02,0x95,0x01,0x75,0x05,                               0x81,0x03,0x05,0x01,0x09,0x30,0x09,0x31,0x15,0x01,0x26,0xFF,0x75,0x75,0x10,0x95,0x02,                               0x81,0x02,0xC0,0xC0};/*********** SEND MOUSE *********absx,absy = absolute mouse positionbut  1 = Left button click     2 = Right button click     4 = Middle button click    For a single click these button presses should be followed  by a buf[0]=0 send to indicate button up.      ********************************/int send_mouse(unsigned short absx,unsigned short absy,char but)  {  unsigned char buf[5];  static int reportindex = -1;      if(reportindex < 0)    {  // look up Report 1 index    buf[0] = 0x2A;    buf[1] = 0x4D;    reportindex = find_ctic_index(localnode(),UUID_2,buf);    if(reportindex < 0)      {      printf("Failed to find Report characteristic\n");      return(0);      }    ++reportindex;  // Mouse is Report 2    }        buf[0] = but;  buf[1] = absx & 0xFF;  buf[2] = (absx >> 8) & 0xFF;  buf[3] = absy & 0xFF;  buf[4] = (absy >> 8) & 0xFF;  // send to Report2  write_ctic(localnode(),reportindex,buf,0);  return(1);  }

Statistics: Posted by petzval — Sat Mar 29, 2025 1:26 pm



Viewing all articles
Browse latest Browse all 8093

Trending Articles