Jump to content

[Version 1] American To Uk


Recommended Posts

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!

Link to comment
Share on other sites

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 by magic_smoke
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 by unrealdude
Link to comment
Share on other sites

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 : &lt;-- moved for UK
	KEY_1 + SHIFT, 		// 33 !
	KEY_2 + SHIFT,		// 34 "
	KEY_NUMBER, 		// # &lt;-- changed for the UK
	KEY_3 + SHIFT,		// 35  &lt;-- changed for UK -- £ 
	KEY_4 + SHIFT,		// 36 &lt;-- changed for UK -- $
	KEY_6 + SHIFT,		// 38 ^ &lt;-- added for UK
	KEY_QUOTE,		// 39 '  
	KEY_8 + SHIFT,		// 42 *
	KEY_9 + SHIFT,		// 40 ( 
	KEY_7 + SHIFT,		// 37 &amp;
	KEY_COMMA,		// 44 , &lt;-- moved for UK
	KEY_MINUS + SHIFT,	// 41 ) &lt;-- changed for UK -- _
	KEY_EQUAL + SHIFT,	// 43 + &lt;-- 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 = &lt;-- moved for UK
	KEY_SEMICOLON,		// 59 ; &lt;-- moved for UK	
	//KEY_SPACE,		// 32  &lt;--- moved for UK
	KEY_NUMBER + SHIFT,	// 126 ~ &lt;-- moved for UK
	KEY_MINUS,		// 45 - &lt;-- moved for UK
	KEY_COMMA + SHIFT,	// 60 &lt;
	KEY_RIGHT_BRACE + SHIFT,// 125 } // &lt;-- moved for UK
	KEY_QUOTE + SHIFT,	// 64 @ &lt;-- 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 ^ &lt;-- changed for UK -- %
	KEY_0 + SHIFT,	// 95 _ &lt;-- 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 &gt; &lt;-- moved for UK 
	KEY_SLASH + SHIFT, // ? &lt;-- moved for UK
	KEY_LEFT_BRACE + SHIFT,	// 123 {
	KEY_BACKSLASH + SHIFT,	// 124 |
	KEY_SEMICOLON,		// 59 ; &lt;-- moved for UK	
	KEY_BACKSPACE,		// 127

};

Edited by NanoyMaster
Link to comment
Share on other sites

--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 by NanoyMaster
Link to comment
Share on other sites

  • 4 weeks later...

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 :(

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 by Deevd
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...