<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>ble_app_hids_keyboard - can the HID keyboard peripheral turn on Caps lock by itself?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/96984/ble_app_hids_keyboard---can-the-hid-keyboard-peripheral-turn-on-caps-lock-by-itself</link><description>Hi guys. May I ask one firmware code question for ble_app_hids_keyboard_pca10056_s113 project from 17.1.0 nRF5 SDK: 
 https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/ble_sdk_app_hids_keyboard.html 
 
 First, as the infocenter says, if the BLE</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 01 Mar 2023 10:26:27 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/96984/ble_app_hids_keyboard---can-the-hid-keyboard-peripheral-turn-on-caps-lock-by-itself" /><item><title>RE: ble_app_hids_keyboard - can the HID keyboard peripheral turn on Caps lock by itself?</title><link>https://devzone.nordicsemi.com/thread/412704?ContentTypeID=1</link><pubDate>Wed, 01 Mar 2023 10:26:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9cbcebb0-d951-4905-b698-ac616982cfce</guid><dc:creator>Matthew K</dc:creator><description>&lt;p&gt;Thank you so much! I tested your code and it works.&lt;/p&gt;
&lt;p&gt;I was using the modifier and that didn&amp;#39;t work.&lt;/p&gt;
&lt;p&gt;Let&amp;#39;s close this ticket.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ble_app_hids_keyboard - can the HID keyboard peripheral turn on Caps lock by itself?</title><link>https://devzone.nordicsemi.com/thread/412655?ContentTypeID=1</link><pubDate>Wed, 01 Mar 2023 08:41:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ebecb077-fadf-4cc4-abb7-cf1544ec4347</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Did you test any of them? I think that would be quicker than waiting for me to see your message and reply.&lt;/p&gt;
&lt;p&gt;I tried replacing line 241 -&amp;gt; 249 in main.c with this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static uint8_t m_sample_key_press_scan_str[] = /**&amp;lt; Key pattern to be sent when the key press button has been pushed. */
{
    0x0b,       /* Key h */
    0x08,       /* Key e */
    0x0f,       /* Key l */
    0x0f,       /* Key l */
    0x12,       /* Key o */
    0x39        /* Caps Lock */
    //0x28        /* Key Return */
};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;So pressing the button a bunch of time will output this:&lt;/p&gt;
&lt;p&gt;helloCAPSONHELLOcapsofhelloCAPSONHELLOcapsof&lt;/p&gt;
&lt;p&gt;So I guess that answers the question. It should be sent as Key1, or:&lt;/p&gt;
[quote user="MatthewKYEO"]&lt;p&gt;Or did you mean to send&lt;/p&gt;
&lt;p&gt;00 00 39 00 00 00 00 00&lt;/p&gt;
&lt;p&gt;and&lt;/p&gt;
&lt;p&gt;00 00 00 00 00 00 00 00&lt;/p&gt;
&lt;p&gt;meaning the Key1 is 0x39 (57 caps lock)?&lt;/p&gt;[/quote]
&lt;p&gt;BR,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ble_app_hids_keyboard - can the HID keyboard peripheral turn on Caps lock by itself?</title><link>https://devzone.nordicsemi.com/thread/412577?ContentTypeID=1</link><pubDate>Tue, 28 Feb 2023 16:01:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:80b0d103-1349-4da5-bb3f-d92e7c9d9ed9</guid><dc:creator>Matthew K</dc:creator><description>&lt;p&gt;Yes, I pressed button 1 multiple times for sending &amp;quot;hello&amp;quot;. Since the data format was&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;[modifier, reserved, Key1, Key2, Key3, Key4, Key6, Key7]&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I saw&lt;/p&gt;
&lt;p&gt;00 00 0B 00 00 00 00 00&lt;/p&gt;
&lt;p&gt;when pressed button 1, sending &amp;#39;h&amp;#39;.&lt;/p&gt;
&lt;p&gt;and&lt;/p&gt;
&lt;p&gt;00 00 00 00 00 00 00 00&lt;/p&gt;
&lt;p&gt;when released. Hakon and I summarized the API flow here:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/96983/ble_app_hids_keyboard-why-send_key_scan_press_release-has-to-loop"&gt;ble_app_hids_keyboard: why send_key_scan_press_release has to loop?&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;While holding button 2 for the Shift Key, the data are&lt;/p&gt;
&lt;p&gt;02 00 0B 00 00 00 00 00&lt;/p&gt;
&lt;p&gt;The BLE central device received &amp;#39;H&amp;#39; and&lt;/p&gt;
&lt;p&gt;02 00 00 00 00 00 00 00&lt;/p&gt;
&lt;p&gt;was sent after releasing button 1. Back to the Caps Lock 57, did you mean to send (0x39 == 57)&lt;/p&gt;
&lt;p&gt;39 00 00 00 00 00 00 00&lt;/p&gt;
&lt;p&gt;and&lt;/p&gt;
&lt;p&gt;00 00 00 00 00 00 00 00&lt;/p&gt;
&lt;p&gt;meaning set the modifier to 0x39 (57 caps lock)?&lt;/p&gt;
&lt;p&gt;Or did you mean to send&lt;/p&gt;
&lt;p&gt;00 00 39 00 00 00 00 00&lt;/p&gt;
&lt;p&gt;and&lt;/p&gt;
&lt;p&gt;00 00 00 00 00 00 00 00&lt;/p&gt;
&lt;p&gt;meaning the Key1 is 0x39 (57 caps lock)?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ble_app_hids_keyboard - can the HID keyboard peripheral turn on Caps lock by itself?</title><link>https://devzone.nordicsemi.com/thread/412519?ContentTypeID=1</link><pubDate>Tue, 28 Feb 2023 13:21:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:92a9f251-32cd-418c-b7ef-4740d54addf7</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Did you test? How about testing the same API that is used for sending the &amp;quot;hello&amp;quot; messages? Or look at how the shift key implementation is used in the &amp;quot;caps lock on&amp;quot; and &amp;quot;caps lock off&amp;quot; messages?&lt;/p&gt;
&lt;p&gt;BR;&lt;br /&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ble_app_hids_keyboard - can the HID keyboard peripheral turn on Caps lock by itself?</title><link>https://devzone.nordicsemi.com/thread/412417?ContentTypeID=1</link><pubDate>Tue, 28 Feb 2023 08:19:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2314e774-4f69-406b-a7db-65d71600773d</guid><dc:creator>Matthew K</dc:creator><description>&lt;p&gt;Hi Edvin. Thanks for clarifying the write part. Back to your original answer,&lt;/p&gt;
[quote userid="26071" url="~/f/nordic-q-a/96984/ble_app_hids_keyboard---can-the-hid-keyboard-peripheral-turn-on-caps-lock-by-itself/411943"]So if you send a key press (and release) with this value, it will toggle the caps lock.[/quote]
&lt;p&gt;About sending &lt;em&gt;APP_USBD_HID_KBD_CAPS_LOCK = 57&lt;/em&gt;, the Nordic Infocenter says&lt;/p&gt;
&lt;p&gt;&lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v17.1.0%2Fble_sdk_app_hids_keyboard.html"&gt;https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v17.1.0%2Fble_sdk_app_hids_keyboard.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;quot;The format used for keyboard reports is the following byte array:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;[modifier, reserved, Key1, Key2, Key3, Key4, Key6, Key7]&lt;/strong&gt;&lt;/em&gt;&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Should I set that caps lock 57 in the modifier or Key1?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ble_app_hids_keyboard - can the HID keyboard peripheral turn on Caps lock by itself?</title><link>https://devzone.nordicsemi.com/thread/412206?ContentTypeID=1</link><pubDate>Mon, 27 Feb 2023 09:51:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ac06e8c9-c34d-4783-84bf-4cc66670eb25</guid><dc:creator>Edvin</dc:creator><description>[quote user="MatthewKYEO"]When doing this, was this a &amp;quot;write with response&amp;quot; or &amp;quot;write without response&amp;quot;?[/quote]
&lt;p&gt;Does it really matter? It is the central (computer/phone) that connects to the peripheral that has to decide whether it uses &amp;quot;write without response&amp;quot; or &amp;quot;write&amp;quot;.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;However, putting a breakpoint in on_write() in ble_hids.c I see that it triggers when I write 0x02, simulating caps on, and the p_ble_evt has evt_id 0x50 =&amp;nbsp;BLE_GATTS_EVT_WRITE. This event covers both write with and without response (because the difference is handled in the softdevice, so you don&amp;#39;t need to worry about the difference).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The p_ble_evt-&amp;gt;gatts_evt.write.op = 0x02, which is BLE_GATTS_OP_WRITE_CMD, which means a write without response, as opposed to 0x01 = BLE_GATTS_OP_WRITE_REQ.&lt;/p&gt;
&lt;p&gt;So it is a write without response.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;But the real question, which I interpreted from your original question was how you can toggle caps lock from the nRF52 DK running the ble_gap_hids_keyboard example, right?&lt;/p&gt;
&lt;p&gt;This is usually not triggered from the computer itself, but from the keyboard (your DK). The use of simulating this caps lock on by typing 0x02 is the same as turning on caps lock from a different computer.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ble_app_hids_keyboard - can the HID keyboard peripheral turn on Caps lock by itself?</title><link>https://devzone.nordicsemi.com/thread/412044?ContentTypeID=1</link><pubDate>Fri, 24 Feb 2023 16:02:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:67c015f1-e149-4123-b6ff-f8b4aab4af0a</guid><dc:creator>Matthew K</dc:creator><description>&lt;p&gt;Thank you for your answer Edvin.&lt;/p&gt;
[quote userid="26071" url="~/f/nordic-q-a/96984/ble_app_hids_keyboard---can-the-hid-keyboard-peripheral-turn-on-caps-lock-by-itself/411943"]d_ble_gatts_hvx(), so it is neither &amp;quot;write with response&amp;quot; nor &amp;quot;write without response&amp;quot;. It is a notification, since the peripheral is the server, not the client.[/quote]
&lt;p&gt;Sorry, but I was mentioning the HID output report: From the &lt;strong&gt;INFO CENTER,&lt;/strong&gt; &lt;strong&gt;6. Simulate Caps Lock ON,&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v17.1.0%2Fble_sdk_app_hids_keyboard.html"&gt;https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v17.1.0%2Fble_sdk_app_hids_keyboard.html&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Setting the modifier bit to 02 will simulate Caps Lock ON.&lt;/em&gt;&lt;br /&gt;&lt;em&gt; In nRF Connect, select the HID Report, which has the properties Read, WriteWithoutResponse, and Write (the Output Report) and UUID: 0x2A4D.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;As explained here, I used two nRF52 boards and the nRF Connect for Desktop for &amp;quot;writing&amp;quot; that output report data to 02.&lt;/p&gt;
&lt;p&gt;When doing this, was this a &amp;quot;write with response&amp;quot; or &amp;quot;write without response&amp;quot;?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ble_app_hids_keyboard - can the HID keyboard peripheral turn on Caps lock by itself?</title><link>https://devzone.nordicsemi.com/thread/411943?ContentTypeID=1</link><pubDate>Fri, 24 Feb 2023 11:47:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f5c1e987-1f16-4b5b-a998-6ce163bd135f</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;All HID reports are sent using the function send_key_scan_press_release() -&amp;gt;&amp;nbsp;ble_hids_inp_rep_send() -&amp;gt;&amp;nbsp;sd_ble_gatts_hvx(), so it is neither &amp;quot;write with response&amp;quot; nor &amp;quot;write without response&amp;quot;. It is a notification, since the peripheral is the server, not the client.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regarding your caps lock question. The example is by default set up to use the shift on button 2. This is why the letters are big if you hold button 2 and press button 1.&lt;/p&gt;
&lt;p&gt;If you want to use caps lock, however, this is a different type of key. It is an on/off key. Most keys in a hid report is just reporting whether they are pressed or released (which is the case for the caps lock as well), but the caps lock will toggle an internal state in whatever it is connected to. So the next time you send a character, it is the computer that knows that it should be an uppercase letter. What I am trying to say is that the keyboard doesn&amp;#39;t send a different signal on &amp;quot;A&amp;quot; and &amp;quot;a&amp;quot;. It is just the caps lock that has been toggled.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You may be confused by looking at this example, if you look at on_hid_rep_char_write. This means that the computer has turned on caps lock (from another keyboard connected). This state is reported to HID devices, so that they can turn on the Caps Lock LED (if it has one). The same goes for num lock and scroll lock.&lt;/p&gt;
&lt;p&gt;The way this handles key presses is, in my opinion overly complicated. Please see my colleagues reply in this ticket:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/4375/how-are-keyboard-key-release-events-sent-in-example-code"&gt;how are keyboard key release events sent in example code?&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;However, you can still use it. Just know that whenever you send a button press, it will also send a release report for that same button immediately after (If it didn&amp;#39;t, it would act as if you held down that button on the keyboard).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Also, the example should have used a file similar to SDK\components\libraries\usbd\class\hid\kbd\app_usbd_hid_kbd.h to show all the possible button presses. Instead it just uses hardcoded values for the letters that it is using. So I suggest you copy the content from this file (or include it in your project), so that you have more letters to pick from.&lt;/p&gt;
&lt;p&gt;In that list, you can see that the value for caps lock is:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;APP_USBD_HID_KBD_CAPS_LOCK       = 57, /**&amp;lt;KBD_CAPS_LOCK       code*/&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;So if you send a key press (and release) with this value, it will toggle the caps lock.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>