完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
您好,我使用的是PIC18F25K50,用MPLAB X IDE。我的项目要求我用USB连接到我的PC上是一个有效的小型定制键盘。我用以下的MLA项目为起点:“C: Microchip M201V2016Y04Y227 ApvsUSB设备HIDKEngult固件PicdMyfsUsByK50.x“这一切都很好。提供的演示代码有一个变量的输入报告。文件AppIdEclipse中的KEYBORAD.CITS中的KEY(0)允许值从4到39,对应于26个小写字母A到Z,以及10个数字0到9。这样,我就可以在我的“键盘”上按按钮将这些36个字符发送到主机PC;它们出现了。作为键入的字符,例如,文本编辑器。我的问题是:我如何发送其他字符,尤其是修改键,例如& lt;Stand & gt;and lt;ctrl& gt;我不是C的专家,无法确定代码是在哪里发送给主机的。我还看了应用笔记AN1212A,但发现这更令人困惑。我想知道是否有人能帮我快速获得我需要的密钥信息。我意识到我试图绕过我应该获得的详细理解,但生命短暂,我只需要继续进行这个项目。非常感谢你能提供的任何帮助。肯。
以上来自于百度翻译 以下为原文 Hello, I am using a PIC18F25K50, with MPLAB X IDE. My project requires me to make what is effectively a small custom keyboard with USB connection to my PC. I have used the following MLA project as a starting point: "C:Microchipmlav2016_04_27appsu***devicehid_keyboardfirmwarepicdem_fs_u***_k50.x" This works fine as far as it goes. The demo code supplied has a variable inputReport.keys[0] in file app_device_keyborad.c This is allowed to have values from 4 to 39, corresponding to 26 lower case a to z, and 10 digits 0 to 9. Thus I can make button presses on my "keyboard" send any of these 36 characters to the host PC; they appear as typed characters as expected in, for example, a text editor. My question is: How do I send the other characters, and in particular the modifier keys like I am no expert in C, and cannot work out where the code specifies what is actually sent to the host. I have also had a look at application note AN1212a, but find this even more confusing. I wonder if anyone can help me to speedily get to the key information I require. I realize I'm trying to by-pass the detailed understanding which I should acquire, but life is short, and I just need to get on with the project. Many thanks for any help you can provide. Ken. |
|
相关推荐
7个回答
|
|
生命是短暂的,谷歌是Fasthtp://StaskOfFult.COM/Quass/7073328/List-Heal-KeBest-SCAN -CODES-和UB-HID-键盘记录文档搜索,例如:Windows HID键盘代码
以上来自于百度翻译 以下为原文 Life is short, and Google is fast http://stackoverflow.com/questions/27075328/list-of-hex-keyboard-scan-codes-and-u***-hid-keyboard-documentation search e.g. for: windows hid keyboard codes |
|
|
|
您好,感谢您的回复和链接到网站;我现在有所有的键盘代码,这是伟大的。虽然我现在有了Shift KEY(0xE1)的代码,但是我仍然不能让它工作,因为修改键必须以一种特殊的方式使用,而且C代码对于我来说还远远不够。但是,不管怎样,我可以继续进行这个项目,因为我需要大约50个不同的密钥,并且不关心W。它们是帽子。所以我现在所有的代码都不需要使用Shift键,再次感谢你们的帮助。肯。
以上来自于百度翻译 以下为原文 Hello, Thanks for reply and link to websites; I now have all the keboard codes, which is great. But although I now have the code for Shift key (0xE1) I still cannot get it to work, because the modifier keys have to be used in a special way, and the C code for this is still beyond my grasp. However, no matter, I can get on with the project because I need approx 50 different keys, and don't care what they are. So all the codes I now have will be plenty without using the Shift key. Thanks again for your help. Ken. |
|
|
|
修饰符进入包的第一字节,这是6(或8)个键的位字段。键入3…8字节。
以上来自于百度翻译 以下为原文 Modifiers go into the 1st byte of the packet, which is a bitfield for 6 (or 8) keys. Keys go into 3..8 bytes. |
|
|
|
您忽略了引用:在链接到的第一页。
以上来自于百度翻译 以下为原文 You ignored the reference to: Byte 0: Keyboard modifier bits (SHIFT, ALT, CTRL etc) in the first page linked to. |
|
|
|
您好,谢谢您的进一步回复。我知道修改器必须在包中的一个特殊位置,但不能弄清楚这是如何从MLA中得到的代码中实现的。它似乎把普通的关键数据放在数组索引0中,例如在这行中:输入报告。键[0 ] = sEndoKIKE;/ /设置关键字PRESI认为上面涉及到什么叫做结构?我只掌握C的基本知识,不理解结构是如何工作的,所以也许我应该把它放在这里,继续我的项目,也许以后我会抽出时间去学习一些更高级的C。
以上来自于百度翻译 以下为原文 Hello, Thanks for further replies. I was aware that modifiers have to go in a special place in the packet, but cannot work out how this is implemented in the code I have got from MLA. It seems to put the normal key data in array index 0, eg as in this line: inputReport.keys[0] = send_key; // Set the key press I think the above relates to what is called a structure ? I have only a basic knowledge of C, and do not understand how structures work. So perhaps I should just leave it at that, press on with my project, and maybe later I will find time to learn some more advanced C. Thanks again. |
|
|
|
代码不适合C初学者,我同意。我没有跳进那个样本,我不能测试任何东西。但是,如果你想继续:这是从你的AppIdEclipse键盘。C和我在AppHyKeBoad任务中间添加了一条线,这应该是添加修饰符的方法(如左撇子)。请注意,在“联合修饰符”中可以看到其他修饰符。当然,您不希望为所有键设置修改器,这只是语法的一个例子。它将重置结构为零,从而重置先前设置在这个全局变量中的任何位。
以上来自于百度翻译 以下为原文 The code is not well suited for C beginners, I agree. I did not dive into that sample and I cannot test anything. But if you want to continue: This is from your app_device_keyboard.c and I added a line in the middle of APP_KeyboardTasks which should be the way to add the modifiers (leftAlt as example) here. See the other modifiers in the union 'modifiers'. Note that of course you do not want to set the modifier for all keys, it's only an example for the syntax. union __attribute__((packed)) { uint8_t value; struct __attribute__((packed)) { unsigned leftControl :1; unsigned leftShift :1; unsigned leftAlt :1; unsigned leftGUI :1; unsigned rightControl :1; unsigned rightShift :1; unsigned rightAlt :1; unsigned rightGUI :1; } bits; } modifiers; memset(&inputReport, 0, sizeof(inputReport)); if(BUTTON_IsPressed(BUTTON_USB_DEVICE_HID_KEYBOARD_KEY) == true) { if(keyboard.waitingForRelease == false) { keyboard.waitingForRelease = true; /* Set the only important data, the key press data. */ inputReport.keys[0] = keyboard.key++; inputReport.modifiers.bits.leftAlt = 1; // added by rodims for test //In this simulated keyboard, if the last key pressed exceeds the a-z + 0-9, //then wrap back around so we send 'a' again. if(keyboard.key == 40) { keyboard.key = 4; } } } memset(&inputReport, 0, sizeof(inputReport)); |
|
|
|
你好,我刚才试过你的建议,罗迪姆斯,用左移而不是左撇子,效果不错!当设置为0时,它给出小写,当设置为1时,大写字母。同样地,对于其他所有的钥匙,我怀疑是否有任何办法能为我自己解决这个问题。多谢,肯。
以上来自于百度翻译 以下为原文 Hello again, I have just tried your suggestion, rodims, using leftShift rather than leftAlt, and it works! When set to 0 it gives lower case, and when set to 1, upper case. Similarly for all the other keys. I doubt if there is any way I could have worked this out for myself. Many thanks, Ken. |
|
|
|
只有小组成员才能发言,加入小组>>
5160 浏览 9 评论
1998 浏览 8 评论
1927 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3170 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2225 浏览 5 评论
730浏览 1评论
613浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
503浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
628浏览 0评论
526浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-22 16:32 , Processed in 1.690946 second(s), Total 91, Slave 74 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号