Author Topic: Alternative Controller for HHKB  (Read 199574 times)

0 Members and 2 Guests are viewing this topic.

Offline hasu

  • Thread Starter
  • Posts: 2420
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: Alternative Controller for HHKB
« Reply #200 on: Wed, 30 April 2014, 22:00:32 »
egdmitry, nice work! and thanks for nice scope capture :D

And yes, test framework on PC host will be very useful. At this time I have to test code on real keyboard with sadly primitive method :) and I can't test all test cases to be performed. Especially common/action* codes can be tested on host effectively and we can write many test cases for actions. This is really helpful for refactoring and bug fix.
⚠ My Engrish is broken.  !!!FC980C Alt GB!!! HHKB Alt  ⌨ConvertersAlps64FC660C Alt

Offline egdmitry

  • Posts: 15
Re: Alternative Controller for HHKB
« Reply #201 on: Sun, 04 May 2014, 23:37:26 »
And yes, test framework on PC host will be very useful. At this time I have to test code on real keyboard with sadly primitive method :) and I can't test all test cases to be performed. Especially common/action* codes can be tested on host effectively and we can write many test cases for actions. This is really helpful for refactoring and bug fix.

What's your main OS on the PC, hasu?

Offline hasu

  • Thread Starter
  • Posts: 2420
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: Alternative Controller for HHKB
« Reply #202 on: Mon, 05 May 2014, 01:16:31 »
Linux, ubuntu 12.04 at this time mainly and Cygwin on Windows 7 sometimes.
⚠ My Engrish is broken.  !!!FC980C Alt GB!!! HHKB Alt  ⌨ConvertersAlps64FC660C Alt

Offline PixelScript

  • Posts: 57
  • Location: UK
Re: Alternative Controller for HHKB
« Reply #203 on: Mon, 05 May 2014, 15:29:18 »
I wish i had the balls to open up my expensive HHKB like that!

Offline Smasher816

  • HHKB Master
  • Posts: 538
  • Location: return STATE_MISSOURI;
Re: Alternative Controller for HHKB
« Reply #204 on: Mon, 05 May 2014, 16:49:45 »
I wish i had the balls to open up my expensive HHKB like that!

It's actually surprisingly easy. http://geekhack.org/index.php?topic=57008.msg1293238#msg1293238

Offline jmolino

  • Posts: 44
  • Some folks look for answers,others look for fights
Re: Alternative Controller for HHKB
« Reply #205 on: Sat, 21 June 2014, 00:26:52 »
Hi,

I'm having a little problem... I ordered the Teensy 2.0 controller, but for some unknown reason they sent me the Teensy ++ 2.0 controller!  (the one with the angled chip and additional pin outs).  I was trying to follow Smasher's great guide here:  http://geekhack.org/index.php?topic=57008.0  but now the pins dont match the ++ controller.... can anybody help me figure out which pins I need to solder?

Thanks alot for any help or guidance.....

Offline jmolino

  • Posts: 44
  • Some folks look for answers,others look for fights
Re: Alternative Controller for HHKB
« Reply #206 on: Sat, 21 June 2014, 01:25:19 »
Think I found it....https://www.pjrc.com/teensy/pinout.html .... the pin names are a bit different, but still can be determined.....

Offline hasu

  • Thread Starter
  • Posts: 2420
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: Alternative Controller for HHKB
« Reply #207 on: Sat, 21 June 2014, 03:48:12 »
Only concern is how Teensy++ can be installed in Pro2.
Teensy++ is perfectly fit for Pro1 but not for Pro2. See these photos. In Pro2 a standoff prevents Teensy from being installed.


⚠ My Engrish is broken.  !!!FC980C Alt GB!!! HHKB Alt  ⌨ConvertersAlps64FC660C Alt

Offline jmolino

  • Posts: 44
  • Some folks look for answers,others look for fights
Re: Alternative Controller for HHKB
« Reply #208 on: Sat, 21 June 2014, 22:57:07 »
Perhaps one could just bring in the cable through the 2nd USB Hub port since it is no longer being used.  It wouldn't be "pretty" but it would work.  The only thing I'm wondering is how to secure it to the case - that would seem most important.. I'll have to look around this thread and others for ideas.

Only concern is how Teensy++ can be installed in Pro2.
Teensy++ is perfectly fit for Pro1 but not for Pro2. See these photos. In Pro2 a standoff prevents Teensy from being installed.

Show Image

Show Image



Offline Smasher816

  • HHKB Master
  • Posts: 538
  • Location: return STATE_MISSOURI;
Re: Alternative Controller for HHKB
« Reply #209 on: Sun, 22 June 2014, 19:25:55 »
Sticky foam tape works wellfor mounting and doesn't leave much residue. Something like this http://www.radioshack.com/product/index.jsp?productId=2103341.

Maybe you can talk to PJRC and see if you can get your teensy switched out. It should go ok, especially if it was their fault.

Offline jmolino

  • Posts: 44
  • Some folks look for answers,others look for fights
Re: Alternative Controller for HHKB
« Reply #210 on: Mon, 23 June 2014, 08:51:38 »
Yep - actually they did send me the correct model.. I should have it today....pretty good customer service to fix up an error like that so fast!

Sticky foam tape works wellfor mounting and doesn't leave much residue. Something like this http://www.radioshack.com/product/index.jsp?productId=2103341.

Maybe you can talk to PJRC and see if you can get your teensy switched out. It should go ok, especially if it was their fault.


Offline jdcarpe

  • Literally geekhack
  • * Curator
  • Posts: 8572
  • Location: Odessa, TX
  • God mode active
Re: Alternative Controller for HHKB
« Reply #211 on: Mon, 23 June 2014, 09:23:55 »
Yep - actually they did send me the correct model.. I should have it today....pretty good customer service to fix up an error like that so fast!

Sticky foam tape works wellfor mounting and doesn't leave much residue. Something like this http://www.radioshack.com/product/index.jsp?productId=2103341.

Maybe you can talk to PJRC and see if you can get your teensy switched out. It should go ok, especially if it was their fault.



This is a bit OT here, but Paul and Robin at PJRC are good people. That's another reason I support using the Teensy myself, and I want to encourage everyone to use Teensys over those Pro Micro or other Arduino (clone) boards.

Offline hasu

  • Thread Starter
  • Posts: 2420
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: Alternative Controller for HHKB
« Reply #212 on: Thu, 10 July 2014, 03:18:11 »
HHKB JP is supported now!

⚠ My Engrish is broken.  !!!FC980C Alt GB!!! HHKB Alt  ⌨ConvertersAlps64FC660C Alt

Offline BB__

  • Posts: 18
Re: Alternative Controller for HHKB
« Reply #213 on: Thu, 10 July 2014, 04:38:03 »
Oh nice.
Thank you hasu for your work. :thumb:

I have JP and Pro2.
When will you start selling it?
I'm in waiting list.

Offline hasu

  • Thread Starter
  • Posts: 2420
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: Alternative Controller for HHKB
« Reply #214 on: Thu, 10 July 2014, 13:09:44 »
These days I'am working on Bluetooth part of my controller and got it worked somewhat and found some defects on the PCB. I will order new PCB in a month or two to fix the fefects after some more firmware work. Next batch of PCB order will be 10.

In next revision and up of "TMK Alt Controller" PCB will support HHKB Pro2, JP and Type-S.
⚠ My Engrish is broken.  !!!FC980C Alt GB!!! HHKB Alt  ⌨ConvertersAlps64FC660C Alt

Offline Vitaly

  • Posts: 146
  • Location: Russia
Re: Alternative Controller for HHKB
« Reply #215 on: Wed, 23 July 2014, 06:23:11 »
Yep - actually they did send me the correct model.. I should have it today....pretty good customer service to fix up an error like that so fast!

Sticky foam tape works wellfor mounting and doesn't leave much residue. Something like this http://www.radioshack.com/product/index.jsp?productId=2103341.

Maybe you can talk to PJRC and see if you can get your teensy switched out. It should go ok, especially if it was their fault.



This is a bit OT here, but Paul and Robin at PJRC are good people. That's another reason I support using the Teensy myself, and I want to encourage everyone to use Teensys over those Pro Micro or other Arduino (clone) boards.
Is any difference between teensy and arduino micro clone for usage in keyboard (or joystick)? Micro I can get for $5 with free shipping and teensy about 26 (16 + 10 shipping), 5 times higher.

Offline Smasher816

  • HHKB Master
  • Posts: 538
  • Location: return STATE_MISSOURI;
Re: Alternative Controller for HHKB
« Reply #216 on: Wed, 23 July 2014, 09:07:32 »
Afaik, they both have the same chip controlling it, and the should have plenty of pins. The big differences are the slightly different layout, and the bootloader. You should be able to compile TMK for it fine (though don't quote me on that).

Offline argcargv

  • tempting the banhammer
  • Posts: 186
  • Location: michigan
  • PERSONAL TEXT NUKED BY STATIONARY WARHEAD
Re: Alternative Controller for HHKB
« Reply #217 on: Sat, 02 August 2014, 21:54:39 »
I finally have time to use put Hasu's controller inside the hhkb.

Now the problem is I don't know how to use it. I see the repo here https://github.com/tmk/tmk_keyboard

But how do I install all the software on a Mac? I don't have a windows computer.

Any help would be greatly appreciated! Thanks in advance!

MOD EDIT -- NUKED FROM ORBIT

Offline Smasher816

  • HHKB Master
  • Posts: 538
  • Location: return STATE_MISSOURI;
Re: Alternative Controller for HHKB
« Reply #218 on: Sat, 02 August 2014, 22:08:51 »
You will need to install crosspack. Then download the code from github, go to the correct keyboard/protocol folder and run make to compile everything, then use dfu-programmer to flash the generated hex to the microcontroller. It might be confusing so someone can help, or maybe they could just compile it for you.

See here: https://github.com/tmk/tmk_keyboard/blob/master/doc/build.md

Offline argcargv

  • tempting the banhammer
  • Posts: 186
  • Location: michigan
  • PERSONAL TEXT NUKED BY STATIONARY WARHEAD
Re: Alternative Controller for HHKB
« Reply #219 on: Sat, 02 August 2014, 23:27:02 »
You will need to install crosspack. Then download the code from github, go to the correct keyboard/protocol folder and run make to compile everything, then use dfu-programmer to flash the generated hex to the microcontroller. It might be confusing so someone can help, or maybe they could just compile it for you.

See here: https://github.com/tmk/tmk_keyboard/blob/master/doc/build.md

Thanks! Got it figured out.

For people having trouble installing dfu-programmer (I was on a new mac and missing some needed library files), use this link http://www.uriahbaalke.com/?p=106

One important thing that took me a few minutes to figure out was: when you are ready to build to the TMK alt controller with dfu. do this:

make KEYMAP=[keymap_name] dfu

DO NOT do this:
make KEYMAP=[keymap_name]
make dfu

this second make dfu overwrites the previous keymap you made with the default hhkb one. I was just dumb : P, I think I misunderstood the readme on git hub.
MOD EDIT -- NUKED FROM ORBIT

Offline dustinhxc

  • * Exalted Elder
  • Posts: 6219
  • Location: MN
  • IV
    • Gray Designs
Re: Alternative Controller for HHKB
« Reply #220 on: Sat, 20 September 2014, 02:16:02 »
HHKB JP is supported now!

Show Image


Yay.. I gotta get one someday.. Good job man.

Offline hasu

  • Thread Starter
  • Posts: 2420
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: Alternative Controller for HHKB
« Reply #221 on: Fri, 03 October 2014, 17:43:16 »
For someone who is interested in HHKB Bluetooth,

You can access files under development here.
https://github.com/tmk/HHKB_controller/ [PCB]
https://github.com/tmk/tmk_keyboard/tree/rn42/keyboard/hhkb_rn42 [Firmware]

⚠ My Engrish is broken.  !!!FC980C Alt GB!!! HHKB Alt  ⌨ConvertersAlps64FC660C Alt

Offline esoomenona

  • Gnillort?
  • Posts: 5307
.
« Reply #222 on: Fri, 03 October 2014, 20:52:43 »
.
« Last Edit: Fri, 11 September 2015, 14:42:57 by esoomenona »

Offline Latin00032

  • * Destiny Supporter
  • Posts: 1520
Re: Alternative Controller for HHKB
« Reply #223 on: Fri, 03 October 2014, 21:02:26 »
For someone who is interested in HHKB Bluetooth,

You can access files under development here.
https://github.com/tmk/HHKB_controller/ [PCB]
https://github.com/tmk/tmk_keyboard/tree/rn42/keyboard/hhkb_rn42 [Firmware]

Show Image

This makes me want to get a hhkb.

I wish there was an alternate controller that was compatible with the fc660c.

Offline epicepee

  • Posts: 35
Re: Alternative Controller for HHKB
« Reply #224 on: Mon, 06 October 2014, 22:56:12 »
Would this work with an atmega2560 via v-usb?

Offline hasu

  • Thread Starter
  • Posts: 2420
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: Alternative Controller for HHKB
« Reply #225 on: Tue, 07 October 2014, 00:21:51 »
Does VUSB support that MCU?
If yes it'll work probably.
⚠ My Engrish is broken.  !!!FC980C Alt GB!!! HHKB Alt  ⌨ConvertersAlps64FC660C Alt

Offline Smasher816

  • HHKB Master
  • Posts: 538
  • Location: return STATE_MISSOURI;
Re: Alternative Controller for HHKB
« Reply #226 on: Tue, 07 October 2014, 00:23:48 »
For someone who is interested in HHKB Bluetooth,

You can access files under development here.
https://github.com/tmk/HHKB_controller/ [PCB]
https://github.com/tmk/tmk_keyboard/tree/rn42/keyboard/hhkb_rn42 [Firmware]

Show Image


Does this mean you finally got the bluetooth part working and are now looking for other people to test it?

Offline hasu

  • Thread Starter
  • Posts: 2420
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: Alternative Controller for HHKB
« Reply #227 on: Tue, 07 October 2014, 01:07:29 »
Yes, I hope selftaught DIY people will be able to use my those files and give me feedbacks and suggestions.
The project is not finished and will be revised in next few months but I think it not much far from my goal, 80% maybe?
I'm doing rest of the works like fixing PCB design, power saving and LED indicators now. Hopefully I'll finish them in this year.
⚠ My Engrish is broken.  !!!FC980C Alt GB!!! HHKB Alt  ⌨ConvertersAlps64FC660C Alt

Offline Matt3o

  • -[_]-
  • ** Robot Emeritus
  • Posts: 3500
  • Location: Italy
Re: Alternative Controller for HHKB
« Reply #228 on: Tue, 07 October 2014, 02:58:35 »
Yes, I hope selftaught DIY people will be able to use my those files and give me feedbacks and suggestions.
The project is not finished and will be revised in next few months but I think it not much far from my goal, 80% maybe?
I'm doing rest of the works like fixing PCB design, power saving and LED indicators now. Hopefully I'll finish them in this year.

You are unstoppable, hasu! :) you know I'm in line for a BT version as soon as you get it! If you need advance funding just let me know, I'm more than happy to contribute.

PS: what BT module are you using again?

Offline Smasher816

  • HHKB Master
  • Posts: 538
  • Location: return STATE_MISSOURI;
Re: Alternative Controller for HHKB
« Reply #229 on: Tue, 07 October 2014, 11:51:21 »
He is using the RN-42 HID (smd) from sparkfun.

Offline Latin00032

  • * Destiny Supporter
  • Posts: 1520
Re: Alternative Controller for HHKB
« Reply #230 on: Tue, 07 October 2014, 20:14:14 »
Does it support bt 4.0 or higher?

Offline hasu

  • Thread Starter
  • Posts: 2420
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: Alternative Controller for HHKB
« Reply #231 on: Tue, 07 October 2014, 20:38:57 »
Matt3o, thank you for the encouragement :D Yes, you are on the third of my list!

As Smasher816 said my controller uses Roving Network RN-42(ver6.15) which supports only legacy BT.
⚠ My Engrish is broken.  !!!FC980C Alt GB!!! HHKB Alt  ⌨ConvertersAlps64FC660C Alt

Offline aliceinwire

  • Posts: 10
  • Location: Tokyo, Japan
Re: Alternative Controller for HHKB
« Reply #232 on: Sun, 12 October 2014, 02:05:55 »
I wish i had the balls to open up my expensive HHKB like that!

just simply opening and closing hhkb pro 2
is really straightforward


i would like to make the mod with the teensy 3.1 and bluetooth module
https://www.sparkfun.com/products/12646
https://www.sparkfun.com/products/12819
i was thinking if i need also the 5V step breakout for changing the 3.3V teensy 3.1 output to 5V
https://www.sparkfun.com/products/10968
and the lipo battery maybe...
https://www.sparkfun.com/products/8483
« Last Edit: Sun, 12 October 2014, 04:48:10 by aliceinwire »

Online admiralvorian

  • Posts: 321
  • Location: United States
  • DIY
Re: Alternative Controller for HHKB
« Reply #233 on: Mon, 13 October 2014, 13:32:39 »
Yes, I hope selftaught DIY people will be able to use my those files and give me feedbacks and suggestions.
The project is not finished and will be revised in next few months but I think it not much far from my goal, 80% maybe?
I'm doing rest of the works like fixing PCB design, power saving and LED indicators now. Hopefully I'll finish them in this year.

keep up the great work hasu! I can't wait to replace my teensy with a BT controller!
Darude Status:
☐ Not Sandstorm
☑ Sandstorm                                               wts wtt wtb

Offline hasu

  • Thread Starter
  • Posts: 2420
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: Alternative Controller for HHKB
« Reply #234 on: Mon, 13 October 2014, 19:26:03 »
I wish i had the balls to open up my expensive HHKB like that!

just simply opening and closing hhkb pro 2
is really straightforward

Nice video.
Yes, the case is no problem, I needed more balls when pull out its connector and lines. You will be scared of damaging them unless you know correct method.

Read these instruction. And you better unscrew PCB before remove the connector.
http://www.hirose.co.jp/cataloge_hp/en_DF14_20130411.pdf
http://www.jst-mfg.com/product/pdf/eng/handling_e.pdf
⚠ My Engrish is broken.  !!!FC980C Alt GB!!! HHKB Alt  ⌨ConvertersAlps64FC660C Alt

Offline Smasher816

  • HHKB Master
  • Posts: 538
  • Location: return STATE_MISSOURI;
Re: Alternative Controller for HHKB
« Reply #235 on: Mon, 13 October 2014, 23:48:22 »
I wish i had the balls to open up my expensive HHKB like that!

just simply opening and closing hhkb pro 2
is really straightforward

Nice video.
Yes, the case is no problem, I needed more balls when pull out its connector and lines. You will be scared of damaging them unless you know correct method.

Read these instruction. And you better unscrew PCB before remove the connector.
http://www.hirose.co.jp/cataloge_hp/en_DF14_20130411.pdf
http://www.jst-mfg.com/product/pdf/eng/handling_e.pdf

Don't pull on the cables because you don't want any of the wires getting yanked out. I just grabbed the plastic "nibs" on the sides and alternated between wiggling the left and right side while pulling. It took a little bit of force to come out but worked fine.

Offline BB__

  • Posts: 18
Re: Alternative Controller for HHKB
« Reply #236 on: Thu, 16 October 2014, 15:10:06 »
Thank you. Hasu.
Received the package. JP controller working properly.  ;D

I'm using muhenkan key as fn layer. When fn activated, I want to use 'm' and ',' keys as parentheses.
Currently I assigned 'm'=9 and ','=0, with shift key it can send parentheses.
FN+Shift+m = (
FN+Shift+, = )
But how can I send without pressing shift key?

Offline hasu

  • Thread Starter
  • Posts: 2420
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: Alternative Controller for HHKB
« Reply #237 on: Fri, 17 October 2014, 02:02:57 »
Very quick delivery :)

I think you can use this action like,
ACTION_MODS_KEY(MOD_LSFT, KC_9)

https://github.com/tmk/tmk_keyboard/blob/master/doc/keymap.md#212-modified-key
⚠ My Engrish is broken.  !!!FC980C Alt GB!!! HHKB Alt  ⌨ConvertersAlps64FC660C Alt

Offline Xe0n0

  • Posts: 11
Re: Alternative Controller for HHKB
« Reply #238 on: Mon, 20 October 2014, 08:43:26 »
For someone who is interested in HHKB Bluetooth,

You can access files under development here.
https://github.com/tmk/HHKB_controller/ [PCB]
https://github.com/tmk/tmk_keyboard/tree/rn42/keyboard/hhkb_rn42 [Firmware]

Show Image


Oh god! That's fascinating! I can't wait to order mine!

By the way hasu, how about the battery life in bluetooth battery mode? And does this design work with iOS devices?

Offline Sygaldry

  • Edema Ruh
  • * Esteemed Elder
  • Posts: 1246
  • Location: Chicago
  • All the truth in the world is held in stories.
Re: Alternative Controller for HHKB
« Reply #239 on: Tue, 28 October 2014, 21:41:10 »
I will be placing an order for a Type-S soon.
Looking forward to ordering the controller with BT as well!
 :thumb: :thumb: :thumb:

Offline rdev5

  • Posts: 11
Re: Alternative Controller for HHKB
« Reply #240 on: Wed, 29 October 2014, 15:00:07 »
Hasu (or anyone else),

How can I MACRO( T(N), ...) each (int) element in digits array in reverse order?

See https://gist.github.com/anonymous/cb0bc4419f83d66ae890

Offline bazh

  • * Exquisite Elder
  • Posts: 970
  • Location: Finland
Re: Alternative Controller for HHKB
« Reply #241 on: Wed, 29 October 2014, 16:25:36 »
got mine today, definitely will have a fun time figure it out for my Pro 2 :p


and save me a spot when the final BT controller is ready also! :D

Offline hasu

  • Thread Starter
  • Posts: 2420
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: Alternative Controller for HHKB
« Reply #242 on: Wed, 29 October 2014, 19:32:45 »
Not sure what you want to do with this. Can you describe more?

What does that C code and what is contents of digits[] array in the end?


Hasu (or anyone else),

How can I MACRO( T(N), ...) each (int) element in digits array in reverse order?

See https://gist.github.com/anonymous/cb0bc4419f83d66ae890

⚠ My Engrish is broken.  !!!FC980C Alt GB!!! HHKB Alt  ⌨ConvertersAlps64FC660C Alt

Offline rdev5

  • Posts: 11
Re: Alternative Controller for HHKB
« Reply #243 on: Thu, 30 October 2014, 10:15:53 »
Hi hasu,

Ultimately what I'd like to do is be able to programatically send keys using a MACRO based on a string of characters I provide, vs. hard coding it statically.

In the case of the gist I linked to, the use case would be to 1) generate a random number and then 2) send each digit in that string or array of digits.

So if my number was 1234, currently I would have to statically bind an Fn key as: MACRO( I(0), T(1), T(2), T(3), T(4), END )

In psuedo-code, what I'm asking is if there is a way to do the following:

Code: [Select]
int digits[] = {1, 2, 3, 4}; // Or random number regnerator

MACRO( I(0) );
for (int i = 0; i < sizeof(digits); i++) {
  MACRO( T( digits[i] ) );
}
MACRO( END );

Integer constants of course are easy since you have definitions for those. However, I'm also looking to do something like the following:

Code: [Select]
char seq[] = {'a', 'b', 'c', '1', '2', '3'}; // Or random number regnerator

MACRO( I(0) );
for (int i = 0; i < sizeof(seq); i++) {
  MACRO( T( seq[i] ) );
}
MACRO( END );

Thanks!

Not sure what you want to do with this. Can you describe more?

What does that C code and what is contents of digits[] array in the end?


Hasu (or anyone else),

How can I MACRO( T(N), ...) each (int) element in digits array in reverse order?

See https://gist.github.com/anonymous/cb0bc4419f83d66ae890

Offline byker

  • Literally Canada
  • * Global Moderator
  • Posts: 3068
  • Location: West Coast - Canada
Re: Alternative Controller for HHKB
« Reply #244 on: Thu, 30 October 2014, 13:16:11 »
Anyone else see this? Pretty interesting! http://www.kbdmania.net/xe/review/8598580

Offline hasu

  • Thread Starter
  • Posts: 2420
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: Alternative Controller for HHKB
« Reply #245 on: Thu, 30 October 2014, 13:57:47 »
MACRO is basically static, all keys used in it should be fixed when compiled. You cannot calculate anything presented in MACRO dynamically at runtime.

You can define 'function action' in keymap instead, in this action you can write most of things freely in C. This is not well documented yet, but you can find some examples in keymap files under keyboard/ or converter/ directories.
https://github.com/tmk/tmk_keyboard/blob/master/doc/keymap.md#24-function-action

This is an example. To send keycodes to host use functions like register_code() and unregister_code() instead of T().
https://github.com/tmk/tmk_keyboard/blob/master/keyboard/hhkb/keymap_hasu.c#L244




Hi hasu,

Ultimately what I'd like to do is be able to programatically send keys using a MACRO based on a string of characters I provide, vs. hard coding it statically.

In the case of the gist I linked to, the use case would be to 1) generate a random number and then 2) send each digit in that string or array of digits.

So if my number was 1234, currently I would have to statically bind an Fn key as: MACRO( I(0), T(1), T(2), T(3), T(4), END )
⚠ My Engrish is broken.  !!!FC980C Alt GB!!! HHKB Alt  ⌨ConvertersAlps64FC660C Alt

Offline rdev5

  • Posts: 11
Re: Alternative Controller for HHKB
« Reply #246 on: Thu, 30 October 2014, 14:55:30 »
Getting this now (after previous failed attempt to flash with error about bootloader overlap):

Code: [Select]
Creating load file for Flash: hhkb_lufa.hex
avr-objcopy -O ihex -R .eeprom -R .fuse -R .lock -R .signature hhkb_lufa.elf hhkb_lufa.hex
dfu-programmer atmega32u4 erase
Checking memory from 0x0 to 0x6FFF...  Empty.
Chip already blank, to force erase use --force.
dfu-programmer atmega32u4 flash hhkb_lufa.hex
Checking memory from 0x0 to 0x6CFF...  Empty.
0%                            100%  Programming 0x6D00 bytes...
[ X  ERROR
Memory write error, use debug for more info.
make: *** [dfu] Error 1

Offline rdev5

  • Posts: 11
Re: Alternative Controller for HHKB
« Reply #247 on: Thu, 30 October 2014, 14:57:25 »
Nevermind, did a force erase, and manually ran
Code: [Select]
dfu-programmer atmega32u4 flash hhkb_lufa.hex and it came back. Now to find a way to compress my code:

Code: [Select]
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
{
  switch (id) {
    case MY_FUNC:
      if (!record->event.pressed && record->tap.count > 0 && !(record->tap.interrupted)) {

        int seed_size = 1000000;
        int seed_array[seed_size];

        // Seed rand from memory+time and generate random number
        int seed = 0; for (int i = 0 ; i < seed_size; i++) seed ^= abs(seed_array[i]);
        seed = abs(seed);

        srand(seed);
        int number = rand();

        // Print
        // printf("Seed: %d\n", seed);
        // printf("Number: %d\n", number);

        // Count digits
        int c = 0, n = number;
        while (n != 0) {n /= 10; c++; }

        // Extract each digit
        int numberArray[c]; c = 0; n = number;
        while (n != 0) {numberArray[c] = n % 10; n /= 10; c++; }

        // Print
        // printf("Verify: ");
        for (int i = c - 1 ; i >= 0; i--) {
          // // printf("%d", numberArray[i]);

          uint8_t k;
          switch(numberArray[i]) {
            case 0: k = 0x27; break;
            case 1: k = 0x18; break;
            case 2: k = 0x19; break;
            case 3: k = 0x20; break;
            case 4: k = 0x21; break;
            case 5: k = 0x22; break;
            case 6: k = 0x23; break;
            case 7: k = 0x24; break;
            case 8: k = 0x25; break;
            case 9: k = 0x26; break;
          }

          register_code(k);
          unregister_code(k);

          // printf("%d(%x) ", numberArray[i], k);
        }

        send_keyboard_report();
        record->tap.count = 0;  // ad hoc: cancel tap
      }
      break;
  }
}

Offline hasu

  • Thread Starter
  • Posts: 2420
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: Alternative Controller for HHKB
« Reply #248 on: Thu, 30 October 2014, 15:22:02 »
My smaple code use a bit complex 'if' statement to handle delicate 'dual role key' things. I think you can use just this simple clause to execut your function when the key is released.
Code: [Select]
if (!record->event.pressed) {

And these codes are not needed.
Code: [Select]
        send_keyboard_report();
        record->tap.count = 0;  // ad hoc: cancel tap


Size of int is 16 bit, and ATMega32u4 has only 2.5KB memory(SRAM). This code won't work on the MCU. And you better use uint8_t, uint16_t, int8_t or int16_t in MCU programing instead of int.
Code: [Select]
        int seed_size = 1000000;
        int seed_array[seed_size];
⚠ My Engrish is broken.  !!!FC980C Alt GB!!! HHKB Alt  ⌨ConvertersAlps64FC660C Alt

Offline rdev5

  • Posts: 11
Re: Alternative Controller for HHKB
« Reply #249 on: Thu, 30 October 2014, 15:53:28 »
Is there a way I can seed rand() or random() from this board (analog signal perhaps)?