Sending the right HID Keycode? - keyboard
I'm currently developing a very smal and specific HID Keyboard with a atmega microcontroller. The biggest problem i have is that a keycode is very specific for the locale that is currently set on the host pc.
All normal chars like a-z are working very well but some special chars are producing bad results when the key is pressed.
For example the + Key, which is 0xE1 & 0x2E (LeftShift & KeyboardEqualSign) does only work on a US Keyboard. But i use a German Layout, so i get a ß instead.
How can i now get the right keycodes for the German Layout? I cant find any document that describes such keys... I think the HID Keycodes are really bad designed to support multiple keyboard layouts :(
Do i need to lookup my keys on a german layout what they would be in us? So for the + Sign its probably the ] key? But why the heck its a so stupid design? Is there any wrapper for that?
had the same problem. I took a picture of an en_us keyboard and compared it to my german keyboard and then I transfered that on the keycodes... Its not yet finished because its a suprisingly lot of work and I do not need other characters right now. Most important characters should be there. Its sorted after Iso8859, I let the iso codes stay maybe that helps someone.
Here you go:
iso8859 hex code, modifier, usb hid keycode, character
0x22, shift,0x1F , "
0x23, 0,0x31 , #
0x24, shift,0x21 , $
0x25, shift,0x22 , %
0x26, shift,0x23 , &
0x27, shift,0x31 , '
0x28, shift,0x25 , (
0x29, shift,0x26 ,
0x2A, shift,0x30 , *
0x2B, 0,0x30 , +
0x2C, 0,0x36 , ,
0x2D, 0,0x38 , -
0x2E, 0,0x37 , .
0x2F, shift,0x24 , /
0x30 to 0x39 are the numbers, no changes here to en_us
0x3A, shift,0x37 , :
0x3B, shift,0x36 , ;
0x3C, 0,0x64 , <
0x3D, shift,0x27 , =
0x3E, shift,0x64 , >
0x3F, shift,0x2D , ?
0x40, altgr,0x14 , #
*Upper case letter, no changes here to en_us
0x59, shift,0x1D ,switch Z,Y
0x5A, shift,0x1C;
0x5B, altgr,0x25 , [
0x5C, altgr,0x2D , "\"
0x5D, altgr,0x26 , ]
0x5E, 0,0x35 , ^
0x5F, shift,0x38 , _
0x60, shift,0x2E , `
*lower case letters, no changes here to en_us
0x79, 0,0x1D ,switch z,y
0x7A, 0,0x1C
0x7B, altgr,0x24 , {
0x7C, altgr,0x64 , |
0x7D, altgr,0x27 , }
0x7E, altgr,0x30 , ~
*0x80 to 0x9F not in use
0xA0 Not existing "nonbreaking space"
havent done yet
0xC4, shift,0x34 ,Ä
havent done yet
0xD6, shift,0x33 ,Ö
havent done yet
0xDC, shift,0x2F ,Ü
havent done yet
0xE4, 0,0x34 , ä
havent done yet
0xF5, 0,0x33 ,ö
havent done yet
0xFC, 0,0x2F ,ü
havent done yet
Hope that helps you or the next stumbling upon that problem :)
Best regards
Related
Node ESCPOS printer text alignments are not working for STAR printer
I am using ESCPOS library for printing menu items using SP700 star printer. Data is coming properly in print but align and style properties are not working. My code snippet: var network = new escpos.Network(printerData.IpAddress); const options = { encoding: "GB18030" /* default */ } // encoding is optional printer = new escpos.Printer(network, options); network.open(function (error, device) { printer .font('A') .align('ct') .style('NORMAL') .size(1, 1) ; printer.align('ct') printer.print("property- align: 'ct'"); printer.align('CT') printer.print("property- align: 'CT'"); printer.align('CENTER') printer.style('bu'); printer.print("property- align: 'CENTER' & style: 'bu'"); printer.style('B'); printer.print("style: 'B'"); printer.print("Date: "); printer.style('normal'); printer.print("property- style: 'NORMAL'"); printer.style('NORMAL'); printer.println(printDataHolder.printData.date); }); Here I have added some dummy text to check with different property values like 'ct', 'CT', 'CENTER' for center alignment and 'bu', 'B' for bold style but all text are getting printed in left alignment and normal text. Below is the print: Any help on this will be appreciated. Thanks!
I overlooked your written printer model information. Star Micronics' Dot Impact Printer has many unique ESC/POS commands, one of which is alignment settings. ESC a n is for standard ESC/POS, but ESC GS a n for Star Micronics Dot Impact Printer. EPSON ESC a [Name] Select justification [Format] ASCII ESC a n Hex 1B 61 n Decimal 27 97 n Please refer to this specification and define your own bytes array data according to the command supported by the printer. Dot Impact Printer STAR Command Specifications Rev. 1.91 Page 3-32 ESC GS a n [Name] Specify position alignment [Code] ASCII ESC GS a n Hexadecimal 1B 1D 61 n Decimal 27 29 97 n
please try chaining code like : const SerialPort = require("serialport"); const escpos = require("escpos"); escpos.SerialPort = require("escpos-serialport"); ... const options = { encoding: "your language encoding" }; const device = new escpos.SerialPort('COM1', { baudRate: 9600 }); // example 'COM1', 9600 const printer = new escpos.Printer(device, options); device.open(function (err: any) { printer .align("CT") // align center .style("B") // font weight bold .size(0.1, 0.1) // text size .text("Your big test text") .size(0.01, 0.01) .text("Your small test text") .cut() .close(); } Or, if you re-declare it, try re-declaring "CT" and "encoding" in the first part, and I think it might work. printer .align("CT") // align center .style("B") // font weight bold .size(0.1, 0.1) // text size .text("Your big test text"); printer .encode("your language encoding") .align("CT") // align center .style("NORMAL") .size(0.01, 0.01) .text("Your small test text") .cut() .close(); It may be helpful to check the path below. node_modules > escpos > index.js node_modules > escpos > commands.js
How can I retrieve wLength of a hid device in linux?
I want to retrieve wLength (that can be specified by a hid device). The clear answer maybe is to send a ctrl signal to device. But I tried it by the following code: struct usbfs_ctrltransfer ctrl = { .bmRequestType = LIBUSB_ENDPOINT_IN, .bRequest = LIBUSB_REQUEST_GET_CONFIGURATION, .wValue = 0, .wIndex = 0, .wLength = 1, ... } .... r = ioctl(fd, 0, &ctrl); .... The result of this code was just an error value (I think that was -1!). I reloaded the hid module (kernel module) in debug mode(modprobe hid debug=100 --> don't panic for this large debug level!). In this case the hid print out the true value of the wLength. /build/buildd/linux-3.13.0/drivers/hid/usbhid/hid-core.c: submitting ctrl urb: Get_Report wValue=0x0100 wIndex=0x0001 wLength=64 I track it in Linux kernel source code and I found that this information are printed in usb_get_intfdata. In summary I wonder to know if there is an equal function in userland or not?
The answer to this question is using udev. By reading special attribute, called bmAttributes, you can find the I/O's actual length. Using below code to read it: .... udev_device_get_sysattr_value(dev, "bmAttributes") ....
HID reports/scan codes for RN 42 HID's gamepad profile
i'm creating a bluetooth HID gamepad with a arduino leonardo and the RN 42 HID module. I can actually use the module to iterate a keyboard or a mouse but i didn't understand how to send the right scan codes to iterate a gamepad or a joystick. In the user's guide of the module they said that the raw report had to be sent like that: 0xFD,0x06,Buttons 0-7,Buttons 8-15,X1,Y1,X2,Y2 Any idea on how to set the report?
First, you have to init a SoftwareSerial instance. Then you have to enter Command Mode of the RN-42 module with a sequence of $$$, set up the HID joystick mode (SH, 0240) and name the device (SN, ...), set the baud rate (SU, ...), etc. After the successful initialization of the module, you can send HID joystick reports as follows: SoftwareSerial bluetooth(bluetoothRX, bluetoothTX); //... // Command Mode // -------------- bluetooth.begin(9600); delay(50); bluetooth.print("$$$"); delay(50); bluetooth.print("SN,HIDJoystick\r\n"); delay(50); bluetooth.print(" SU,57\r\n"); delay(50); bluetooth.print("S~,6\r\n"); delay(600); bluetooth.print("SH,0240\r\n"); delay(200); bluetooth.print("R,1\r\n"); delay(400); // HID Joystick Report // -------------- bluetooth.write((byte)0xFD); //Start HID Report bluetooth.write((byte)0x6); //Length byte // 1. X/Y-Axis bluetooth.write(45); //First X coordinate bluetooth.write(-33); //First Y coordinate // 2. X/Y-Axis bluetooth.write(45); //Second X coordinate bluetooth.write(-33); //Second Y coordinate // Buttons bluetooth.write(B10000001); // Second Byte (Buttons 1-8) bluetooth.write(B10000000); // Second Byte (Buttons 9-16) Please note that the buttons are controlled via binary values.
Autohotkey remapping alt+j to left but alt+shift+j doesn't select left nor do alt+ctr+j move a caret , if getKeyState does not work
Basically, It's inspired by Vim I want to use a key(e.g Alt, F1) combination(+I J K L) to map to Arrow Keys What is already done in Autohotkey Ralt & j::send{Left} Ralt & k::send{Right} ... Now I take Alt+I as up etc,which is pretty fine for me But the problem comes when you press Ralt+Shift+j (Suppose to select the last charater) Ralt+Ctrl+j (Suppose to move a caramel text) These kind of combination would not work and it just get overrided to basic move cursor to left Even if I use if/while statement with GetKeyState, it doesn't gonna work if GetKeyState("Shift","P") Ralt+j::send +{Left} This kind of stuff didn't work Any Ideas on that ?It would make coding very efficient without having to move the right hand. Thanks in advance.
You are missing 2 things: Must use a # symbol when doing a context sensitive hotkey The bottom section of code is using a + instead of the & you used previously. See the below modification: RAlt & j:: Send {Left} RAlt & k:: Send {Right} #If GetKeyState("Shift","P") RAlt & j:: Send +{Left} RAlt & k:: Send +{Right} ; Close with #If to remove the context or simply start another '#If GetKeystate ....'
Are there standard 8-bit color palettes?
I'm attempting to reverse engineer a file format from a logging program. It seems to use a 1-2 byte field which may be used for label colors, as it seems to be the only thing that's unexplained. Short of iterating through other label colors and generating new output files (which is a pain in the ass, hence me trying to reverse-engineer the format in the first place), are there any standard 8-bit color palettes they may line up with? I've found some (e.g. the only 216 colors that are allowed on the web), but they're not enumerated in any particular way. I believe 0x32 is light green (e.g. 0,255,0), 0x0A is teal cyan (0, 255, 255), and 0x28 is red. Each field may also include a trailing 0x00. Or I could be totally wrong.
Well, it could be one of the old standard VGA palettes. This is the one for mode 13h: However, the numbers you posted seem to be off-by-one from the index into the usual ordering. EDIT: Here are the 24-bit RGB values for the color components in a python formatted array. It is a bit long so be warned! [0x000000, 0x0000a8, 0x00a800, 0x00a8a8, 0xa80000, 0xa800a8, 0xa85400, 0xa8a8a8, 0x545454, 0x5454fc, 0x54fc54, 0x54fcfc, 0xfc5454, 0xfc54fc, 0xfcfc54, 0xfcfcfc, 0x000000, 0x141414, 0x202020, 0x2c2c2c, 0x383838, 0x444444, 0x505050, 0x606060, 0x707070, 0x808080, 0x909090, 0xa0a0a0, 0xb4b4b4, 0xc8c8c8, 0xe0e0e0, 0xfcfcfc, 0x0000fc, 0x4000fc, 0x7c00fc, 0xbc00fc, 0xfc00fc, 0xfc00bc, 0xfc007c, 0xfc0040, 0xfc0000, 0xfc4000, 0xfc7c00, 0xfcbc00, 0xfcfc00, 0xbcfc00, 0x7cfc00, 0x40fc00, 0x00fc00, 0x00fc40, 0x00fc7c, 0x00fcbc, 0x00fcfc, 0x00bcfc, 0x007cfc, 0x0040fc, 0x7c7cfc, 0x9c7cfc, 0xbc7cfc, 0xdc7cfc, 0xfc7cfc, 0xfc7cdc, 0xfc7cbc, 0xfc7c9c, 0xfc7c7c, 0xfc9c7c, 0xfcbc7c, 0xfcdc7c, 0xfcfc7c, 0xdcfc7c, 0xbcfc7c, 0x9cfc7c, 0x7cfc7c, 0x7cfc9c, 0x7cfcbc, 0x7cfcdc, 0x7cfcfc, 0x7cdcfc, 0x7cbcfc, 0x7c9cfc, 0xb4b4fc, 0xc4b4fc, 0xd8b4fc, 0xe8b4fc, 0xfcb4fc, 0xfcb4e8, 0xfcb4d8, 0xfcb4c4, 0xfcb4b4, 0xfcc4b4, 0xfcd8b4, 0xfce8b4, 0xfcfcb4, 0xe8fcb4, 0xd8fcb4, 0xc4fcb4, 0xb4fcb4, 0xb4fcc4, 0xb4fcd8, 0xb4fce8, 0xb4fcfc, 0xb4e8fc, 0xb4d8fc, 0xb4c4fc, 0x000070, 0x1c0070, 0x380070, 0x540070, 0x700070, 0x700054, 0x700038, 0x70001c, 0x700000, 0x701c00, 0x703800, 0x705400, 0x707000, 0x547000, 0x387000, 0x1c7000, 0x007000, 0x00701c, 0x007038, 0x007054, 0x007070, 0x005470, 0x003870, 0x001c70, 0x383870, 0x443870, 0x543870, 0x603870, 0x703870, 0x703860, 0x703854, 0x703844, 0x703838, 0x704438, 0x705438, 0x706038, 0x707038, 0x607038, 0x547038, 0x447038, 0x387038, 0x387044, 0x387054, 0x387060, 0x387070, 0x386070, 0x385470, 0x384470, 0x505070, 0x585070, 0x605070, 0x685070, 0x705070, 0x705068, 0x705060, 0x705058, 0x705050, 0x705850, 0x706050, 0x706850, 0x707050, 0x687050, 0x607050, 0x587050, 0x507050, 0x507058, 0x507060, 0x507068, 0x507070, 0x506870, 0x506070, 0x505870, 0x000040, 0x100040, 0x200040, 0x300040, 0x400040, 0x400030, 0x400020, 0x400010, 0x400000, 0x401000, 0x402000, 0x403000, 0x404000, 0x304000, 0x204000, 0x104000, 0x004000, 0x004010, 0x004020, 0x004030, 0x004040, 0x003040, 0x002040, 0x001040, 0x202040, 0x282040, 0x302040, 0x382040, 0x402040, 0x402038, 0x402030, 0x402028, 0x402020, 0x402820, 0x403020, 0x403820, 0x404020, 0x384020, 0x304020, 0x284020, 0x204020, 0x204028, 0x204030, 0x204038, 0x204040, 0x203840, 0x203040, 0x202840, 0x2c2c40, 0x302c40, 0x342c40, 0x3c2c40, 0x402c40, 0x402c3c, 0x402c34, 0x402c30, 0x402c2c, 0x40302c, 0x40342c, 0x403c2c, 0x40402c, 0x3c402c, 0x34402c, 0x30402c, 0x2c402c, 0x2c4030, 0x2c4034, 0x2c403c, 0x2c4040, 0x2c3c40, 0x2c3440, 0x2c3040, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000]
There is no standard palette for 8-bit but Teletext uses true 8-bit color palette It's based on hardwares http://en.wikipedia.org/wiki/List_of_8-bit_computer_hardware_palettes Edit : Some devices able to show different shades of color by adjusting brightness but true 8-bit is this palette ( Teletext )