Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New clueboard keymap that is a tetris game #1574

Merged
merged 1 commit into from
Aug 30, 2017
Merged

Conversation

danamlund
Copy link
Contributor

It works by outputting key-presses to make ascii-art in a regular text editor. It reads key presses to rotate and move the bricks like a regular tetris game.

See gif for an example.

It is not fast nor responsive, but it is silly.

It also serve as an example on how to use process_record_user(..), matrix_scan_user(..), and how to send a keycodes. however, I do not know know if it is an example of correct usage or disastrous usage.

@jackhumbert
Copy link
Member

Haha, this is awesome :) is there a PCB/kit available for purchase? We try to keep projects in the keyboards folder ones that are commercially available. I'd love to see this added as a feature for other boards to use though!

@danamlund
Copy link
Contributor Author

This is a strictly home-built keyboard.
I will make another pull request where I add tetris as an option to an existing board.

Can you recommend a board that is commonly used, and already have compile-time dependency switches to make it easier to add another?

@danamlund
Copy link
Contributor Author

Rather than adding a whole new keyboard. I have added a keymap to the clueboard keyboard.

However, I do not have a clueboard keyboard, so I cannot verify if it works.

@danamlund
Copy link
Contributor Author

Thank you for trying it, sorry it does not work.

As you found out, tetris_text.c should be included due to the 'SRC = .." line in Makefile. It compiles on my system with a 'git clone ...; cd qmk-keyboard; make clueboard-tetris'.

While tetris is running, it catches arrow key presses to move the block. However, it should also constantly be sending a bunch of fake keypresses to draw the game. You can quit the game by pressing escape, that should give you back control of your arrow keys.

Since it stole your arrow keys, that means that F(1) and process_record_user(..) works.

So maybe matrix_scan_user(..) does not get called. But clueboard/keymaps/magicmonty also use it.
Or maybe matrix_scan_user(..) gets called with a weird interval on the clueboard microprocessor compared to the ATmega32U4 arduino-clone I tested with.

I cannot debug it further without getting a qmk-supported keyboard.

It works on my hand-wired keyboard meckb_da64.

@evyd13
Copy link
Contributor

evyd13 commented Aug 14, 2017

I don't have a clueboard but copied the code over to my tada68 (atmega32u4). It's here if you want to take a look at it. Thank you for your contribution to QMK!

@danamlund danamlund changed the title New keyboard that is a tetris game New clueboard keymap that is a tetris game Aug 14, 2017
@danamlund
Copy link
Contributor Author

I have changed this pull request to add a tetris keymap to the clueboard keyboard rather than adding a new homemade keyboard.

Note: do not accept this pull request until someone tests if it actually works.

If someone have any qmk-supported keyboard and some spare time, I will happily change this pull request to add a keymap to a different keyboard that can be tested.

@skullydazed
Copy link
Member

I just gave it a try on my board and it seems to work as advertised, but maybe only on windows? On my mac it draws the play field twice, the second time not quite correctly, and then the blocks are screwed up. I think it's relying on keystrokes that don't work on TextEdit.

@evyd13
Copy link
Contributor

evyd13 commented Aug 17, 2017

@skullydazed You're not the only one, mine does the same on Windows 10 in Notepad++.

@danamlund danamlund force-pushed the master branch 2 times, most recently from e5ebb8a to 455dfb7 Compare August 17, 2017 15:07
@danamlund
Copy link
Contributor Author

It seems that macs think that home/end means go to top/bottom of document without moving the cursor. So I have changed the code so it no longer sends HOME and END.

The game was only sending HOME and END events when building the board and the game over screen, so there will no performance penalty.

Now the game only sends: left, right, up, down, delete, backspace, qwerty, shift (for upper-case), and numbers.

The game should work on macs now.

I tested notepad++ on a windows machine. That broke for me because notepad++ popped up auto-completing helper dialogs that stole arrow key presses.
Fixing this issue for notepad++ will likely break it for other fancy text editors.
So I say we only support dumb text editors.

Note: I rebased my diffs to simplify merging, so there is only 1 commit.

Thanks for all the great feedback.

@danamlund
Copy link
Contributor Author

I think I fixed the drawing-board-twice bug. I now only draw the board on a key down event.

@jackhumbert
Copy link
Member

Looks like this is ready - awesome! Thanks :D

@jackhumbert jackhumbert merged commit a729d85 into qmk:master Aug 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants