12 Replies Latest reply on May 29, 2018 7:49 AM by epr_1639216

    BLE Keyboard and Mouse HID on the same device

      Using CYBLE-212019 and starting from the 'BLE Hid Keyboard' design example of 'PSoC Creator' I have developed a Bluetooth PC keyboard. Now I have to implement a Bluetooth mouse on the same device.


      I've checked the 'BLE Hid Mouse' example and it works and I've tried to merge the two projects copying the mouse service inside the keyboard project and the BLE mouse event management in the code.


      Currently it does not work neither the keyboard nor the mouse but may be I've forgotten to copy something.


      What I like to know if it's possible to have mouse and keyboard profiles implemented on the same device and, if possible, some info about how to do it.


      Many thanks.



        • 1. Re: BLE Keyboard and Mouse HID on the same device

          Yes it is possible. Here is a thread with similar questions, and links to example projects that should be enough to answer your questions/get you started:


          HID BLE Mouse and Keyboard Link

          • 3. Re: BLE Keyboard and Mouse HID on the same device

            As attachment I've added a simple project derived from 'PSoC Creator' HID_Keyboard example where I've tried to add mouse function. I've added two new reports (Mouse Report and Boot Mouse Input Report) and the relative software to send data. Using Wireshark to log info sent by the device (CYBLE-212019 evaluation board on Pioneer Kit) I see that the mouse data are sent but the PC ignores them. I suppose I've to tell to the PC that the device is also a mouse but I don't know how. May be adding some infos to Report Map?


            Many thanks.



            • 4. Re: BLE Keyboard and Mouse HID on the same device

              I've only dabbled in HID reports, and it's been some time, but I would suspect that you need to have info for both the mouse and keyboard in the report map in order for the PC to recognize them as such. 


              Under the BLE component, looking at the Report Map, I'm thinking there is a report map per HID device, and as far as the PC is concerned, both the mouse/keyboard are separate HID devices?


              Hence, I would create a separate Human Interface Device service, and rewrite all of the attributes to be appropriate for an HID mouse.


              You would then need to write and handle a second HID service callback handler to handle the Mouse events just as the keyboard events are currently being handled in hids.c


              Depending on the implementation of the receiving side, this could simply work, or it may be wrong. I'm not sure how the HID over BLE protocol is setup, but I suspect if it is trying to stay true to HID, then each of the mouse and keyboard would need their own HID service and attributes.

              1 of 1 people found this helpful
              • 5. Re: BLE Keyboard and Mouse HID on the same device

                According to the included PDF file with the example project, you will need windows 8 or higher to get it setup and running, and when you do so it requires installing a BLE keyboard through use of the control panel. You will probably need to do something similar for a BLE mouse device?

                • 6. Re: BLE Keyboard and Mouse HID on the same device

                  Many thanks for your answers.


                  Now mouse and keyboard are working. As in the application linked in the thread you told me about it's necessary to add the mouse reports and the report map to the keyboard HID device. I've tried many times to modify the report map using the graphic user interface but I wasn't able to do it. So I've saved on file the report map of your thread application, of the HID keyboard and HID mouse applications and then using a text editor I've merged the last two looking at the thread one and finally I loaded it in the HID keyboard application report map. I hope and I'm sure there is a better mode to do it.


                  I've attached the working project.

                  1 of 1 people found this helpful
                  • 7. Re: BLE Keyboard and Mouse HID on the same device

                    Hmmm, I don't have much time to look into it, but if you got it working then kudos to you :D


                    To modify the BLE profile: When you select the Report Map service in the profile, it will show a green plus in the right side of the component window, and if you mouse over that the tool tip shows "Add HID item", which then adds a "Usage_Page_ item to the report map. You can then select the mouse Usage and Collection items from that drop-down selection to add the Mouse HID report to the report map. (Although editing it with a text-file editor is perfectly valid).


                    It seems to work just fine for me to use it, perhaps you misunderstood how to use the gui, which is understandable (it is rather confusing at times).


                    It displays the profile services and attributes as if they were files in a file-system. But, that is a false notion, and thus if you just use the "Add HID Item" button, you should be able to add and modify HID values within the Report Map to add the HID mouse to the profile.


                    Nicely done on getting it working Paolo;


                    I've attached a screenshot showing the button and Report Map fields that get added as a result/

                    • 8. Re: BLE Keyboard and Mouse HID on the same device

                      Yes I know it isn't the right way to do it but the user interface is not so friendly and is not simple to know what insert. I haven't found any documentation about that. It would be useful to add a complete service from a predefined list. Anyway I think Cypress have done a good job because Bluetooth is complex and they give a lot a examples of applications. The problems arise when you have to do something that different.


                      Thank you for your help.

                      • 9. Re: BLE Keyboard and Mouse HID on the same device

                        Hi! For the BLE to act both as an HID keyboard and mouse, how does a single HID service with "combined" Report Map differ in performance with 2 HID services (one for keyboard, one for mouse)?@e.pratt_1639216

                        • 10. Re: BLE Keyboard and Mouse HID on the same device

                          grcac_2279656 The Report Map is the defined use according to the USB/HID report descriptor. If you are implementing both sides of the BLE, then you can tweak it to work in both scenarios. The separate HID services for the BLE profile is related to how the BLE profile is interacted with. It depends on how you want to package the data, and how consumers will utilize it on their receiving BLE devices connected with the computer.

                          I would liken it to just organization of which way you want it. I suspect that having both HID performances within the same report map (if you have both mouse and keyboard) would be the better approach if all of your data is coming from the same hardware device, but if you are reading your sensor/data values from separate devices, or want to be able to use only the keyboard or only the mouse, then it would make more sense separate the two HID reports into two separate services.



                          Most likely the data/latency performance of your device will be bottlenecked by the BLE transmissions, so combining the data into the same report map if you use both device-data streams would be the best approach.

                          1 of 1 people found this helpful
                          • 11. Re: BLE Keyboard and Mouse HID on the same device

                            In my case, the PSoC BLE is interacting with devices such as PC, laptop and phone, and thus, I cannot tweak the other side. Moreover, I believe I really have to sacrifice the latency performance and have separate Services for keyboard and mouse since this is what a phone accepts for a certain application to work.


                            Thank you, epr_1639216, for this good explanation regarding my query.

                            • 12. Re: BLE Keyboard and Mouse HID on the same device


                              Good to know that separate services is the compatible approach

                              God bless,