NanoyMaster Posted May 2, 2010 Share Posted May 2, 2010 hi, I was wondering if anyone knew how to change the keyboard layout on the teensy? heres the problem: supposed to print: cmd /c for /F %i in ('WMIC logicaldisk where \"DriveType=2\" list brief ^| find \"LABEL\"') do %i\\whatever.txt but instead prints: cmd /c for /F %i in ('WMIC logicaldisk where @DriveType=2@ list brief ^~ find @LABEL@') do %i#whatever.txt I have tryed various things to get it to work. mainly making it fail compiling. anyone have any ideas/tutorials etc.? I am totally lost! Quote Link to comment Share on other sites More sharing options...
magic_smoke Posted May 2, 2010 Share Posted May 2, 2010 (edited) Have you tried sending the special characters like this Keyboard.set_key1(KEY_TILDE); Keyboard.send_now(); Keyboard.set_key1(0); // reset key state Keyboard.send_now(); Other keycodes here http://www.pjrc.com/teensy/td_keyboard.html Short of this, you could poke around in path\hardware\teensy\cores\teensy_hid Edited May 2, 2010 by magic_smoke Quote Link to comment Share on other sites More sharing options...
NanoyMaster Posted May 2, 2010 Author Share Posted May 2, 2010 cheers, yea I thought about doing it that way... but uses too much code, have email'd Paul Stoffregen who said: Look inside your Arduino folder for a file named usb.c... the one in the "teensy_hid" area, not the serial one. Inside, you'll find all the descriptor data which the PC reads when it detects the USB device. You'll find this: // HID interface descriptor, HID 1.11 spec, section 6.2.1 9, // bLength 0x21, // bDescriptorType 0x11, 0x01, // bcdHID 0, // bCountryCode 1, // bNumDescriptors 0x22, // bDescriptorType sizeof(keyboard_hid_report_desc), // wDescriptorLength You might try changing the bCountryCode line.... I found the codes here http://www.usb.org/developers/devclass_docs/HID1_11.pdf page 33 and I changed: C:\Program Files\arduino-0018\hardware\teensy\cores\teensy_hid\usb.c line 195 line 222 line 249 I have tried 33 (usa), 32 (uk) & 13 (international ISO) However none of them changed the output? I have re-emailed him and were trying to work it out, if you or anyone else out there has any ideas it would be loads of help :D Quote Link to comment Share on other sites More sharing options...
Sl45h3R Posted May 2, 2010 Share Posted May 2, 2010 If you change it, im pretty sure you have to recompile the library? Quote Link to comment Share on other sites More sharing options...
NanoyMaster Posted May 2, 2010 Author Share Posted May 2, 2010 ok, that makes sence. but how? just usb.c or everything in that directory. and where would it be compiled to? arduino doesn't seem to have many .exe's anywhere?!?! /me gets to google Quote Link to comment Share on other sites More sharing options...
Sl45h3R Posted May 2, 2010 Share Posted May 2, 2010 Arduino's library's aren't exe files, as it runs cross platform. Im not sure, maybe reply to the email and ask Paul. Quote Link to comment Share on other sites More sharing options...
NanoyMaster Posted May 2, 2010 Author Share Posted May 2, 2010 Those numbers are compile-time constants, which are placed into arrays of bytes stored in read-only flash memory so there automaticaly compiled when you "verify" you code in arduino ref. http://www.hak5.org/forums/index.php?showt...=16258&st=0 that means you should just be able to save them, also have tryed 0x<no> aswell as just <no> makes no difference :S Quote Link to comment Share on other sites More sharing options...
unrealdude Posted May 2, 2010 Share Posted May 2, 2010 i would like to suggest that a goal be added that intends to result in the ability to switch keyboard layouts at runtime based upon DIP switch settings Quote Link to comment Share on other sites More sharing options...
NanoyMaster Posted May 2, 2010 Author Share Posted May 2, 2010 woa there cowboy... lets just see if we can actually change it first :D but yea that would be an awesome idea! I think it's one of them "easier said than done" things tho :( Quote Link to comment Share on other sites More sharing options...
unrealdude Posted May 2, 2010 Share Posted May 2, 2010 (edited) i think it would be easier that it seems, just figure out what code u must send to reach the end result and write a func that translates it (quick and dirty method) i shall be working on this during the coming week (slowly) as i use a customized dvorak layout Edited May 2, 2010 by unrealdude Quote Link to comment Share on other sites More sharing options...
NanoyMaster Posted May 3, 2010 Author Share Posted May 3, 2010 OK, I have discovered that by changing usb_api.cpp line 38 - 166 you can change the layout now it's just a case of trial and error until it's right -.-' *sigh* Quote Link to comment Share on other sites More sharing options...
NanoyMaster Posted May 3, 2010 Author Share Posted May 3, 2010 (edited) OK so I have got this far and am now stuck a-z,A-Z,0-9 work fine symbols should come out like !"£$%^&*()_,+-=: @#~<>{}?|¬`'\/.; but come out like !"£$%^&*()_,+-=:@#~~<>{}?`'#/.; need to fix (space, the extra ~, | (pipe?) and ¬ (no idea what ¬ is¬)) heres my usb_api.cpp so far.. yes I know it's messy! static const uint16_t PROGMEM keycodes[] = { 0, // 0 KEY_A + CTRL, // 1 KEY_B + CTRL, // 2 KEY_C + CTRL, // 3 KEY_D + CTRL, // 4 KEY_E + CTRL, // 5 KEY_F + CTRL, // 6 KEY_G + CTRL, // 7 KEY_H + CTRL, // 8 KEY_TAB, // 9 KEY_J + CTRL, // 10 KEY_K + CTRL, // 11 KEY_L + CTRL, // 12 KEY_ENTER, // 13 KEY_N + CTRL, // 14 KEY_O + CTRL, // 15 KEY_P + CTRL, // 16 KEY_Q + CTRL, // 17 KEY_R + CTRL, // 18 KEY_S + CTRL, // 19 KEY_T + CTRL, // 20 KEY_U + CTRL, // 21 KEY_V + CTRL, // 22 KEY_W + CTRL, // 23 KEY_X + CTRL, // 24 KEY_Y + CTRL, // 25 KEY_Z + CTRL, // 26 KEY_ESC, // 27 KEY_BACKSLASH + CTRL, // 28 KEY_RIGHT_BRACE + CTRL, // 29 KEY_6 + CTRL + SHIFT, // 30 KEY_MINUS + CTRL + SHIFT, // 31 KEY_SEMICOLON + SHIFT, // 58 : <-- moved for UK KEY_1 + SHIFT, // 33 ! KEY_2 + SHIFT, // 34 " KEY_NUMBER, // # <-- changed for the UK KEY_3 + SHIFT, // 35 <-- changed for UK -- £ KEY_4 + SHIFT, // 36 <-- changed for UK -- $ KEY_6 + SHIFT, // 38 ^ <-- added for UK KEY_QUOTE, // 39 ' KEY_8 + SHIFT, // 42 * KEY_9 + SHIFT, // 40 ( KEY_7 + SHIFT, // 37 & KEY_COMMA, // 44 , <-- moved for UK KEY_MINUS + SHIFT, // 41 ) <-- changed for UK -- _ KEY_EQUAL + SHIFT, // 43 + <-- moved for UK KEY_PERIOD, // 46 . KEY_SLASH, // 47 / KEY_0, // 48 0 KEY_1, // 49 1 KEY_2, // 50 2 KEY_3, // 51 3 KEY_4, // 52 4 KEY_5, // 53 5 KEY_6, // 54 6 KEY_7, // 55 7 KEY_8, // 55 8 KEY_9, // 57 9 KEY_EQUAL, // 61 = <-- moved for UK KEY_SEMICOLON, // 59 ; <-- moved for UK //KEY_SPACE, // 32 <--- moved for UK KEY_NUMBER + SHIFT, // 126 ~ <-- moved for UK KEY_MINUS, // 45 - <-- moved for UK KEY_COMMA + SHIFT, // 60 < KEY_RIGHT_BRACE + SHIFT,// 125 } // <-- moved for UK KEY_QUOTE + SHIFT, // 64 @ <-- changed for UK -- @ KEY_A + SHIFT, // 65 A KEY_B + SHIFT, // 66 A KEY_C + SHIFT, // 67 A KEY_D + SHIFT, // 68 A KEY_E + SHIFT, // 69 A KEY_F + SHIFT, // 70 A KEY_G + SHIFT, // 71 A KEY_H + SHIFT, // 72 A KEY_I + SHIFT, // 73 A KEY_J + SHIFT, // 74 A KEY_K + SHIFT, // 75 A KEY_L + SHIFT, // 76 A KEY_M + SHIFT, // 77 A KEY_N + SHIFT, // 78 A KEY_O + SHIFT, // 79 A KEY_P + SHIFT, // 80 A KEY_Q + SHIFT, // 81 A KEY_R + SHIFT, // 82 A KEY_S + SHIFT, // 83 A KEY_T + SHIFT, // 84 A KEY_U + SHIFT, // 85 A KEY_V + SHIFT, // 86 A KEY_W + SHIFT, // 87 A KEY_X + SHIFT, // 88 A KEY_Y + SHIFT, // 89 A KEY_Z + SHIFT, // 90 A KEY_LEFT_BRACE, // 91 [ KEY_BACKSLASH, // 92 KEY_RIGHT_BRACE, // 93 ] KEY_5 + SHIFT, // 94 ^ <-- changed for UK -- % KEY_0 + SHIFT, // 95 _ <-- changed for UK --) KEY_TILDE, // 96 ` KEY_A, // 97 KEY_B, // 98 KEY_C, // 99 KEY_D, // 100 KEY_E, // 101 KEY_F, // 102 KEY_G, // 103 KEY_H, // 104 KEY_I, // 105 KEY_J, // 106 KEY_K, // 107 KEY_L, // 108 KEY_M, // 109 KEY_N, // 110 KEY_O, // 111 KEY_P, // 112 KEY_Q, // 113 KEY_R, // 114 KEY_S, // 115 KEY_T, // 116 KEY_U, // 117 KEY_V, // 118 KEY_W, // 119 KEY_X, // 120 KEY_Y, // 121 KEY_Z, // 122 KEY_PERIOD + SHIFT, // 62 > <-- moved for UK KEY_SLASH + SHIFT, // ? <-- moved for UK KEY_LEFT_BRACE + SHIFT, // 123 { KEY_BACKSLASH + SHIFT, // 124 | KEY_SEMICOLON, // 59 ; <-- moved for UK KEY_BACKSPACE, // 127 }; Edited May 3, 2010 by NanoyMaster Quote Link to comment Share on other sites More sharing options...
NanoyMaster Posted May 5, 2010 Author Share Posted May 5, 2010 (edited) --UPDATE-- after that not working I decided to take another route: I have discovered by using: for (x = 47; x <= 50; x++){ //Psychosis's idea... and a good one at that! Keyboard.print(x);Keyboard.print(": "); Keyboard.set_key1(x); Keyboard.send_now(); Keyboard.set_key1(0); Keyboard.send_now(); Keyboard.print("\r"); delay(100); } that instead of \ it's putting # I managed to change " with @ by changing usb_api.cpp also when it tries to do KEY_BACKSLASH it does # no matter what the country code is in usb.c I am totally lost any help you could give would be greatly appreciated Edited May 5, 2010 by NanoyMaster Quote Link to comment Share on other sites More sharing options...
Deevd Posted May 28, 2010 Share Posted May 28, 2010 Hi I am belgian, so keyboard layout is verry different. Did you find a solution or not? Thx in advance Quote Link to comment Share on other sites More sharing options...
NanoyMaster Posted May 29, 2010 Author Share Posted May 29, 2010 No I still havn't gotten it to work :( gave up with the teensy for now as this is way beyond my capabilities (and it was driving me insane) I don't think there is an easy way to get it to work in different layouts. and the bcountrycode vars just doesn't do anything. If you have any more luck than me it would be great :D or any ideas that I might have missed? I don't think it's just a case of swapping them around since some times 2 chars produce the same output and a load of other weird things happen :( Quote Link to comment Share on other sites More sharing options...
Deevd Posted May 29, 2010 Share Posted May 29, 2010 yeah found out swapping them was no good solution... instead i tried working on a sort of adaptor... that would read the string with my normal BE layout, and gives back a modified string back which replaces the symbols by those needed to make a good output... But for the moment i'm in a little struggle, will let you know if I finally get it to work... Quote Link to comment Share on other sites More sharing options...
IOSys Posted May 29, 2010 Share Posted May 29, 2010 just a thought .. couldn't you type ASCII-codes on the num-pad ? Quote Link to comment Share on other sites More sharing options...
NanoyMaster Posted May 29, 2010 Author Share Posted May 29, 2010 you could with alt+<no.s> but it would be nice if the usb HID device (usb keyboard) could actually type keyboard chars in out layouts plus that makes more code than nessicary eg. to print alt+123 you would have to: 1) press alt 2) set 1 3) send 1 4) release 1 5) set 2 6) send 2 7) release 2 8) set 3 9) send 3 10) release 3 11) release alt seems a bit overkill for sending an "@" for example Quote Link to comment Share on other sites More sharing options...
Deevd Posted May 29, 2010 Share Posted May 29, 2010 (edited) I had the perfect plan, was coding a test in MinGW, just to test out... had it working nicely with Strings and stuff like that... but when i tried to use strings inside the Teensy libraries it kept saying that string is not a known name type ... EDIT: Ok so had some trouble, but found another way to be able to type the code and text between " " with my belgian layout, and still getting the right text printed out... I wrote some code into the usb_api.cpp I added a method called convert(const char c[]) so it takes a const char[] like println() does, in this method convert, i read the whole char array and for each charachter it will make the right Keyboard.set_Key1(...) Keyboard.send_now().... Till now that's the only sollution I found :) Had to find out what every key printed out and stuff like that, but finally it's a success !! NanoyMaster if you need help, send PM ... Edited May 29, 2010 by Deevd Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.