Use a Wii classic controller with Pokitto
Fork of HelloWorld by
Revision 8:4f86dcba69b9, committed 2018-03-21
- Comitter:
- spinal
- Date:
- Wed Mar 21 16:00:24 2018 +0000
- Parent:
- 7:c51ef06c4585
- Commit message:
- Using a Wii classic controller with Pokitto
Changed in this revision
gfx.h | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r c51ef06c4585 -r 4f86dcba69b9 gfx.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gfx.h Wed Mar 21 16:00:24 2018 +0000 @@ -0,0 +1,1956 @@ +#include <stdint.h> + + +// circle +const uint8_t sprite_circle[] = +{ +16,16, +0,26,164,0, +2,159,246,128, +11,255,255,224, +47,255,255,248, +47,255,255,248, +95,255,255,245, +191,255,255,254, +191,255,255,254, +191,255,255,254, +191,255,255,254, +95,255,255,245, +47,255,255,248, +47,255,255,248, +11,255,255,224, +2,159,246,128, +0,26,164,0, +}; + + +// map +const uint8_t sprite_map[] = { +1,1,1,1,2,3,4,4,4,5,6,7,8,9,6,10,4,4,4,11,12,1,1,1,1, +1,1,13,14,15,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,18,19,1,1, +1,20,21,16,22,23,16,16,16,16,16,16,16,16,16,16,16,16,16,24,25,16,26,27,1, +1,28,16,16,29,30,16,16,16,16,16,16,16,16,16,16,16,31,32,33,34,31,32,35,1, +36,37,16,38,39,40,41,16,16,16,42,43,44,43,45,43,16,46,47,16,16,48,49,50,51, +52,16,16,53,54,55,56,16,16,16,57,16,57,16,57,16,16,58,59,60,61,58,59,16,62, +52,16,16,16,63,64,16,65,66,67,68,16,16,16,65,66,67,68,16,69,70,16,16,16,62, +71,72,16,16,16,16,16,73,16,16,74,16,16,16,73,16,16,74,16,16,16,16,16,75,76, +1,77,16,16,16,16,16,78,16,16,79,16,16,16,78,16,16,79,16,16,16,16,16,80,1, +1,81,82,16,16,16,16,83,84,85,86,16,16,16,83,84,85,86,16,16,16,16,87,88,1, +1,1,89,90,91,16,16,16,16,16,16,16,92,16,16,16,16,16,16,16,93,94,95,1,1, +1,1,1,1,96,97,98,98,98,99,100,100,1,100,100,101,98,98,98,102,103,1,1,1,1 +}; + +//Total colors 3 +const uint16_t sprite_pal[] = { +0,50712,65535,0 +}; + +//Sprite sheet:10x11 +const uint8_t sprites [][18] ={ +//[0] cell:0x0 +{ +8,8, +0,0, +0,0, +0,0, +0,0, +0,0, +0,0, +0,0, +0,0, +}, +//[1] cell:1x0 +{ +8,8, +0,0, +0,0, +0,0, +0,0, +0,0, +0,0, +0,0, +0,0, +}, +//[2] cell:2x0 +{ +8,8, +0,0, +0,0, +0,0, +0,0, +0,0, +0,0, +0,42, +10,191, +}, +//[3] cell:3x0 +{ +8,8, +0,0, +0,0, +0,0, +0,0, +0,0, +42,170, +191,255, +255,255, +}, +//[4] cell:4x0 +{ +8,8, +0,0, +0,0, +0,0, +0,0, +0,0, +170,170, +255,255, +255,255, +}, +//[5] cell:5x0 +{ +8,8, +0,0, +0,0, +0,2, +0,11, +0,47, +170,175, +255,250, +255,255, +}, +//[6] cell:6x0 +{ +8,8, +0,0, +0,0, +170,170, +255,255, +255,255, +255,255, +170,170, +255,255, +}, +//[7] cell:7x0 +{ +8,8, +0,0, +0,0, +0,0, +128,0, +224,0, +224,0, +168,0, +254,170, +}, +//[8] cell:8x0 +{ +8,8, +0,0, +0,0, +0,0, +0,0, +0,0, +0,0, +0,0, +170,170, +}, +//[9] cell:9x0 +{ +8,8, +0,0, +0,0, +0,0, +0,2, +0,11, +0,11, +0,42, +170,191, +}, +//[10] cell:10x0 +{ +8,8, +0,0, +0,0, +128,0, +224,0, +248,0, +250,170, +175,255, +255,255, +}, +//[11] cell:11x0 +{ +8,8, +0,0, +0,0, +0,0, +0,0, +0,0, +170,168, +255,254, +255,255, +}, +//[12] cell:12x0 +{ +8,8, +0,0, +0,0, +0,0, +0,0, +0,0, +0,0, +168,0, +254,160, +}, +//[13] cell:13x0 +{ +8,8, +0,0, +0,0, +0,0, +0,0, +0,0, +0,2, +0,43, +0,191, +}, +//[14] cell:14x0 +{ +8,8, +0,2, +0,43, +2,191, +11,255, +175,255, +255,255, +255,255, +255,255, +}, +//[15] cell:15x0 +{ +8,8, +175,255, +255,255, +255,255, +255,255, +255,255, +255,255, +255,255, +255,255, +}, +//[16] cell:0x1 +{ +8,8, +255,255, +255,255, +255,255, +255,255, +255,255, +255,255, +255,255, +255,255, +}, +//[17] cell:1x1 +{ +8,8, +255,250, +255,255, +255,255, +255,255, +255,255, +255,255, +255,255, +255,255, +}, +//[18] cell:2x1 +{ +8,8, +128,0, +232,0, +254,128, +255,224, +255,250, +255,255, +255,255, +255,255, +}, +//[19] cell:3x1 +{ +8,8, +0,0, +0,0, +0,0, +0,0, +0,0, +128,0, +232,0, +254,0, +}, +//[20] cell:4x1 +{ +8,8, +0,0, +0,0, +0,0, +0,0, +0,2, +0,2, +0,11, +0,47, +}, +//[21] cell:5x1 +{ +8,8, +2,255, +11,255, +47,255, +191,255, +255,255, +255,255, +255,255, +255,255, +}, +//[22] cell:6x1 +{ +8,8, +255,255, +255,255, +255,255, +255,255, +255,255, +255,255, +255,255, +255,106, +}, +//[23] cell:7x1 +{ +8,8, +255,255, +255,255, +255,255, +255,255, +255,255, +255,255, +255,255, +170,127, +}, +//[24] cell:8x1 +{ +8,8, +255,218, +253,159, +249,255, +215,255, +239,255, +95,255, +191,251, +191,253, +}, +//[25] cell:9x1 +{ +8,8, +167,255, +246,127, +255,111, +255,215, +255,251, +255,245, +239,254, +127,254, +}, +//[26] cell:10x1 +{ +8,8, +255,128, +255,224, +255,248, +255,254, +255,255, +255,255, +255,255, +255,255, +}, +//[27] cell:11x1 +{ +8,8, +0,0, +0,0, +0,0, +0,0, +128,0, +128,0, +224,0, +248,0, +}, +//[28] cell:12x1 +{ +8,8, +0,191, +0,191, +2,255, +2,255, +11,255, +11,255, +47,255, +47,255, +}, +//[29] cell:13x1 +{ +8,8, +255,159, +255,191, +255,191, +255,191, +255,191, +255,191, +255,191, +255,191, +}, +//[30] cell:14x1 +{ +8,8, +253,191, +255,191, +191,191, +191,191, +191,191, +191,191, +255,191, +255,191, +}, +//[31] cell:15x1 +{ +8,8, +255,255, +255,255, +255,255, +255,255, +255,218, +253,159, +249,255, +215,255, +}, +//[32] cell:0x2 +{ +8,8, +255,255, +255,255, +255,255, +255,255, +167,255, +246,127, +255,111, +255,215, +}, +//[33] cell:1x2 +{ +8,8, +191,253, +191,251, +95,255, +239,255, +215,255, +249,255, +253,159, +255,218, +}, +//[34] cell:2x2 +{ +8,8, +127,254, +239,254, +255,245, +255,251, +255,215, +255,111, +246,127, +167,255, +}, +//[35] cell:3x2 +{ +8,8, +254,0, +254,0, +255,128, +255,128, +255,224, +255,224, +255,248, +255,248, +}, +//[36] cell:4x2 +{ +8,8, +0,0, +0,0, +0,0, +0,2, +0,2, +0,2, +0,2, +0,11, +}, +//[37] cell:5x2 +{ +8,8, +191,255, +191,255, +191,255, +255,255, +255,255, +255,255, +255,255, +255,255, +}, +//[38] cell:6x2 +{ +8,8, +253,170, +254,127, +254,255, +254,255, +254,250, +254,255, +254,255, +254,127, +}, +//[39] cell:7x2 +{ +8,8, +170,127, +255,255, +255,255, +255,255, +175,255, +255,255, +255,255, +255,255, +}, +//[40] cell:8x2 +{ +8,8, +255,106, +255,255, +255,255, +255,255, +255,250, +255,255, +255,255, +255,255, +}, +//[41] cell:9x2 +{ +8,8, +170,159, +255,111, +255,239, +255,239, +171,239, +255,239, +255,239, +255,111, +}, +//[42] cell:10x2 +{ +8,8, +246,167, +235,250, +95,253, +191,255, +190,175, +191,255, +95,253, +235,250, +}, +//[43] cell:11x2 +{ +8,8, +255,255, +255,255, +127,255, +191,255, +191,255, +191,255, +127,255, +255,255, +}, +//[44] cell:12x2 +{ +8,8, +246,167, +235,250, +95,189, +190,175, +186,171, +190,239, +94,173, +235,250, +}, +//[45] cell:13x2 +{ +8,8, +246,167, +235,250, +95,253, +191,191, +190,175, +191,191, +95,253, +235,250, +}, +//[46] cell:14x2 +{ +8,8, +239,255, +95,255, +191,251, +191,253, +191,255, +191,249, +95,255, +239,255, +}, +//[47] cell:15x2 +{ +8,8, +255,251, +255,245, +239,254, +191,254, +127,254, +255,254, +255,245, +255,251, +}, +//[48] cell:0x3 +{ +8,8, +239,255, +95,255, +191,246, +191,255, +191,246, +191,251, +95,246, +239,255, +}, +//[49] cell:1x3 +{ +8,8, +255,251, +255,245, +159,254, +239,254, +175,254, +239,254, +175,245, +255,251, +}, +//[50] cell:2x3 +{ +8,8, +255,254, +255,254, +255,254, +255,255, +255,255, +255,255, +255,255, +255,255, +}, +//[51] cell:3x3 +{ +8,8, +0,0, +0,0, +0,0, +128,0, +128,0, +128,0, +128,0, +224,0, +}, +//[52] cell:4x3 +{ +8,8, +0,11, +0,11, +0,11, +0,11, +0,11, +0,11, +0,11, +0,11, +}, +//[53] cell:5x3 +{ +8,8, +253,170, +255,255, +255,255, +255,255, +255,255, +255,255, +255,255, +255,255, +}, +//[54] cell:6x3 +{ +8,8, +170,127, +255,191, +255,191, +255,191, +255,191, +255,191, +255,191, +255,191, +}, +//[55] cell:7x3 +{ +8,8, +255,106, +255,191, +255,191, +191,191, +191,191, +191,191, +191,191, +255,191, +}, +//[56] cell:8x3 +{ +8,8, +170,159, +255,255, +255,255, +255,255, +255,255, +255,255, +255,255, +255,255, +}, +//[57] cell:9x3 +{ +8,8, +246,167, +255,255, +255,255, +255,255, +255,255, +255,255, +255,255, +255,255, +}, +//[58] cell:10x3 +{ +8,8, +215,255, +249,255, +253,159, +255,218, +255,255, +255,255, +255,255, +255,255, +}, +//[59] cell:11x3 +{ +8,8, +255,215, +255,111, +246,127, +167,255, +255,255, +255,255, +255,255, +255,255, +}, +//[60] cell:12x3 +{ +8,8, +255,218, +253,159, +249,255, +215,255, +239,255, +95,255, +191,247, +191,251, +}, +//[61] cell:13x3 +{ +8,8, +167,255, +246,127, +255,111, +255,215, +255,251, +255,245, +255,254, +255,254, +}, +//[62] cell:14x3 +{ +8,8, +224,0, +224,0, +224,0, +224,0, +224,0, +224,0, +224,0, +224,0, +}, +//[63] cell:15x3 +{ +8,8, +255,159, +255,106, +255,255, +255,255, +255,255, +255,255, +255,255, +255,255, +}, +//[64] cell:0x4 +{ +8,8, +253,191, +170,127, +255,255, +255,255, +255,255, +255,255, +255,255, +255,255, +}, +//[65] cell:1x4 +{ +8,8, +255,255, +255,255, +255,255, +255,250, +255,175, +255,191, +254,255, +254,255, +}, +//[66] cell:2x4 +{ +8,8, +255,250, +254,175, +235,255, +191,255, +255,255, +255,255, +255,255, +255,255, +}, +//[67] cell:3x4 +{ +8,8, +175,255, +250,191, +255,235, +255,254, +255,255, +255,255, +255,255, +255,255, +}, +//[68] cell:4x4 +{ +8,8, +255,255, +255,255, +255,255, +175,255, +250,255, +254,255, +255,191, +255,191, +}, +//[69] cell:5x4 +{ +8,8, +191,250, +191,248, +95,246, +239,255, +215,255, +249,255, +253,159, +255,218, +}, +//[70] cell:6x4 +{ +8,8, +159,254, +47,254, +159,245, +255,251, +255,215, +255,111, +246,127, +167,255, +}, +//[71] cell:7x4 +{ +8,8, +0,2, +0,2, +0,2, +0,2, +0,0, +0,0, +0,0, +0,0, +}, +//[72] cell:8x4 +{ +8,8, +255,255, +255,255, +255,255, +255,255, +191,255, +191,255, +191,255, +47,255, +}, +//[73] cell:9x4 +{ +8,8, +254,255, +251,255, +251,255, +239,255, +239,255, +239,255, +191,255, +191,255, +}, +//[74] cell:10x4 +{ +8,8, +255,191, +255,239, +255,239, +255,251, +255,251, +255,251, +255,254, +255,254, +}, +//[75] cell:11x4 +{ +8,8, +255,255, +255,255, +255,255, +255,255, +255,254, +255,254, +255,254, +255,248, +}, +//[76] cell:12x4 +{ +8,8, +128,0, +128,0, +128,0, +128,0, +0,0, +0,0, +0,0, +0,0, +}, +//[77] cell:13x4 +{ +8,8, +47,255, +11,255, +11,255, +2,255, +2,255, +0,191, +0,191, +0,47, +}, +//[78] cell:14x4 +{ +8,8, +191,255, +191,255, +239,255, +239,255, +239,255, +251,255, +251,255, +254,255, +}, +//[79] cell:15x4 +{ +8,8, +255,254, +255,254, +255,251, +255,251, +255,251, +255,239, +255,239, +255,191, +}, +//[80] cell:0x5 +{ +8,8, +255,248, +255,224, +255,224, +255,128, +255,128, +254,0, +254,0, +248,0, +}, +//[81] cell:1x5 +{ +8,8, +0,11, +0,2, +0,2, +0,0, +0,0, +0,0, +0,0, +0,0, +}, +//[82] cell:2x5 +{ +8,8, +255,255, +255,255, +255,255, +191,255, +47,255, +11,255, +2,255, +0,191, +}, +//[83] cell:3x5 +{ +8,8, +254,255, +254,255, +255,191, +255,175, +255,250, +255,255, +255,255, +255,255, +}, +//[84] cell:4x5 +{ +8,8, +255,255, +255,255, +255,255, +255,255, +191,255, +235,255, +254,175, +255,250, +}, +//[85] cell:5x5 +{ +8,8, +255,255, +255,255, +255,255, +255,255, +255,254, +255,235, +250,191, +175,255, +}, +//[86] cell:6x5 +{ +8,8, +255,191, +255,191, +254,255, +250,255, +175,255, +255,255, +255,255, +255,255, +}, +//[87] cell:7x5 +{ +8,8, +255,255, +255,255, +255,255, +255,254, +255,248, +255,224, +255,128, +254,0, +}, +//[88] cell:8x5 +{ +8,8, +224,0, +128,0, +128,0, +0,0, +0,0, +0,0, +0,0, +0,0, +}, +//[89] cell:9x5 +{ +8,8, +0,43, +0,2, +0,0, +0,0, +0,0, +0,0, +0,0, +0,0, +}, +//[90] cell:10x5 +{ +8,8, +255,255, +255,255, +175,255, +11,255, +2,191, +0,43, +0,2, +0,0, +}, +//[91] cell:11x5 +{ +8,8, +255,255, +255,255, +255,255, +255,255, +255,255, +255,255, +175,255, +10,191, +}, +//[92] cell:12x5 +{ +8,8, +255,255, +255,255, +255,255, +255,255, +255,255, +255,255, +255,255, +170,170, +}, +//[93] cell:13x5 +{ +8,8, +255,255, +255,255, +255,255, +255,255, +255,255, +255,255, +255,250, +254,160, +}, +//[94] cell:14x5 +{ +8,8, +255,255, +255,255, +255,250, +255,224, +254,128, +232,0, +128,0, +0,0, +}, +//[95] cell:15x5 +{ +8,8, +232,0, +128,0, +0,0, +0,0, +0,0, +0,0, +0,0, +0,0, +}, +//[96] cell:0x6 +{ +8,8, +0,42, +0,0, +0,0, +0,0, +0,0, +0,0, +0,0, +0,0, +}, +//[97] cell:1x6 +{ +8,8, +191,255, +42,170, +0,0, +0,0, +0,0, +0,0, +0,0, +0,0, +}, +//[98] cell:2x6 +{ +8,8, +255,255, +170,170, +0,0, +0,0, +0,0, +0,0, +0,0, +0,0, +}, +//[99] cell:3x6 +{ +8,8, +234,170, +128,0, +0,0, +0,0, +0,0, +0,0, +0,0, +0,0, +}, +//[100] cell:4x6 +{ +8,8, +170,170, +0,0, +0,0, +0,0, +0,0, +0,0, +0,0, +0,0, +}, +//[101] cell:5x6 +{ +8,8, +170,171, +0,2, +0,0, +0,0, +0,0, +0,0, +0,0, +0,0, +}, +//[102] cell:6x6 +{ +8,8, +255,254, +170,168, +0,0, +0,0, +0,0, +0,0, +0,0, +0,0, +}, +//[103] cell:7x6 +{ +8,8, +168,0, +0,0, +0,0, +0,0, +0,0, +0,0, +0,0, +0,0, +}, +//[104] cell:8x6 +{ +8,8, +170,170, +170,170, +170,170, +170,170, +170,170, +170,170, +170,170, +170,170, +}, +//[105] cell:9x6 +{ +8,8, +170,170, +170,170, +170,170, +170,170, +170,170, +170,170, +170,170, +170,170, +}, +//[106] cell:10x6 +{ +8,8, +170,170, +170,170, +170,170, +170,170, +170,170, +170,170, +170,170, +170,170, +}, +//[107] cell:11x6 +{ +8,8, +170,170, +170,170, +170,170, +170,170, +170,170, +170,170, +170,170, +170,170, +}, +//[108] cell:12x6 +{ +8,8, +170,170, +170,170, +170,170, +170,170, +170,170, +170,170, +170,170, +170,170, +}, +//[109] cell:13x6 +{ +8,8, +170,170, +170,170, +170,170, +170,170, +170,170, +170,170, +170,170, +170,170, +}, +//[110] cell:14x6 +{ +8,8, +170,170, +170,170, +170,170, +170,170, +170,170, +170,170, +170,170, +170,170, +}, +//[111] cell:15x6 +{ +8,8, +170,170, +170,170, +170,170, +170,170, +170,170, +170,170, +170,170, +170,170, +}, +};//Sprite sheet:4x5 +const uint8_t sprite_buttons [][66] ={ +//[0] cell:0x0 +{ +16,16, +0,26,164,0, +1,149,86,64, +9,85,85,96, +21,85,85,84, +37,85,85,88, +85,85,85,85, +149,93,117,86, +149,87,213,86, +149,87,213,86, +149,93,117,86, +85,85,85,85, +37,85,85,88, +21,85,85,84, +9,85,85,96, +1,149,86,64, +0,26,164,0, +}, +//[1] cell:1x0 +{ +16,16, +0,26,164,0, +1,149,86,64, +9,85,85,96, +21,85,85,84, +37,85,85,88, +85,85,85,85, +149,93,117,86, +149,87,213,86, +149,85,213,86, +149,95,85,86, +85,85,85,85, +37,85,85,88, +21,85,85,84, +9,85,85,96, +1,149,86,64, +0,26,164,0, +}, +//[2] cell:2x0 +{ +16,16, +0,26,164,0, +1,149,86,64, +9,85,85,96, +21,85,85,84, +37,85,85,88, +85,85,85,85, +149,87,213,86, +149,85,117,86, +149,87,245,86, +149,93,117,86, +85,87,245,85, +37,85,85,88, +21,85,85,84, +9,85,85,96, +1,149,86,64, +0,26,164,0, +}, +//[3] cell:3x0 +{ +16,16, +0,26,164,0, +1,149,86,64, +9,85,85,96, +21,85,85,84, +37,85,85,88, +85,85,85,85, +149,85,85,86, +149,93,85,86, +149,95,213,86, +149,93,117,86, +85,87,213,85, +37,85,85,88, +21,85,85,84, +9,85,85,96, +1,149,86,64, +0,26,164,0, +}, +//[4] cell:0x1 +{ +16,16, +6,164,0,0, +41,90,0,0, +85,85,64,0, +149,85,128,0, +151,245,128,0, +149,85,128,0, +85,85,64,0, +41,90,0,0, +6,164,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +}, +//[5] cell:1x1 +{ +16,16, +6,164,0,0, +41,90,0,0, +85,213,64,0, +151,245,128,0, +159,253,128,0, +151,117,128,0, +87,245,64,0, +41,90,0,0, +6,164,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +}, +//[6] cell:2x1 +{ +16,16, +6,164,0,0, +41,90,0,0, +85,85,64,0, +149,213,128,0, +151,245,128,0, +149,213,128,0, +85,85,64,0, +41,90,0,0, +6,164,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +}, +//[7] cell:3x1 +{ +16,16, +10,170,168,0, +37,85,86,0, +149,85,85,128, +149,85,85,128, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +}, +//[8] cell:0x2 +{ +16,16, +106,170,64,0, +149,85,128,0, +149,85,128,0, +149,213,128,0, +149,213,128,0, +149,213,128,0, +149,213,128,0, +149,85,128,0, +149,85,128,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +}, +//[9] cell:1x2 +{ +16,16, +149,85,128,0, +149,85,128,0, +149,213,128,0, +149,213,128,0, +149,213,128,0, +149,213,128,0, +149,85,128,0, +149,85,128,0, +106,170,64,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +}, +//[10] cell:2x2 +{ +16,16, +106,170,128,0, +149,85,64,0, +149,85,64,0, +149,85,64,0, +151,253,64,0, +149,85,64,0, +149,85,64,0, +149,85,64,0, +106,170,128,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +}, +//[11] cell:3x2 +{ +16,16, +170,170,64,0, +85,85,128,0, +85,85,128,0, +85,85,128,0, +127,245,128,0, +85,85,128,0, +85,85,128,0, +85,85,128,0, +170,170,64,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +}, +//[12] cell:0x3 +{ +16,16, +0,0,0,0, +0,0,0,170, +0,0,42,255, +0,2,191,255, +0,43,255,255, +0,191,255,255, +2,255,255,234, +2,255,250,128, +11,254,160,0, +11,232,0,0, +10,128,0,0, +8,0,0,0, +160,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +}, +//[13] cell:1x3 +{ +16,16, +42,170,170,170, +191,255,255,255, +255,255,255,255, +255,255,255,255, +255,255,255,255, +234,170,170,170, +128,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +}, +//[14] cell:2x3 +{ +16,16, +170,160,0,0, +255,248,0,0, +255,248,0,0, +255,248,0,0, +255,248,0,0, +170,170,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +}, +//[15] cell:3x3 +{ +16,16, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +}, +//[16] cell:0x4 +{ +16,16, +10,170,170,170, +47,255,255,255, +47,255,255,255, +47,255,255,255, +47,255,255,255, +170,170,170,170, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +}, +//[17] cell:1x4 +{ +16,16, +170,168,0,0, +255,254,170,0, +255,255,255,168, +255,255,255,254, +255,255,255,255, +170,171,255,255, +0,2,171,255, +0,0,2,175, +0,0,0,10, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +}, +//[18] cell:2x4 +{ +16,16, +0,0,0,0, +0,0,0,0, +0,0,0,0, +128,0,0,0, +232,0,0,0, +254,0,0,0, +255,128,0,0, +255,128,0,0, +191,224,0,0, +43,224,0,0, +2,160,0,0, +0,32,0,0, +0,10,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +}, +//[19] cell:3x4 +{ +16,16, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +}, +//[20] cell:0x5 +{ +16,16, +0,0,0,0, +0,0,0,170, +0,0,42,85, +0,2,149,85, +0,41,85,85, +0,149,85,85, +2,85,85,106, +2,85,90,128, +9,86,160,0, +9,104,0,0, +10,128,0,0, +8,0,0,0, +160,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +}, +//[21] cell:1x5 +{ +16,16, +42,170,170,170, +149,85,85,85, +85,85,85,85, +85,85,85,85, +85,85,85,85, +106,170,170,170, +128,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +}, +//[22] cell:2x5 +{ +16,16, +170,160,0,0, +85,88,0,0, +85,88,0,0, +85,88,0,0, +85,88,0,0, +170,170,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +}, +//[23] cell:3x5 +{ +16,16, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +}, +//[24] cell:0x6 +{ +16,16, +10,170,170,170, +37,85,85,85, +37,85,85,85, +37,85,85,85, +37,85,85,85, +170,170,170,170, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +}, +//[25] cell:1x6 +{ +16,16, +170,168,0,0, +85,86,170,0, +85,85,85,168, +85,85,85,86, +85,85,85,85, +170,169,85,85, +0,2,169,85, +0,0,2,165, +0,0,0,10, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +}, +//[26] cell:2x6 +{ +16,16, +0,0,0,0, +0,0,0,0, +0,0,0,0, +128,0,0,0, +104,0,0,0, +86,0,0,0, +85,128,0,0, +85,128,0,0, +149,96,0,0, +41,96,0,0, +2,160,0,0, +0,32,0,0, +0,10,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +}, +//[27] cell:3x6 +{ +16,16, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +0,0,0,0, +}, +};
diff -r c51ef06c4585 -r 4f86dcba69b9 main.cpp --- a/main.cpp Sun Oct 22 19:13:22 2017 +0000 +++ b/main.cpp Wed Mar 21 16:00:24 2018 +0000 @@ -1,12 +1,219 @@ #include "Pokitto.h" +#include "gfx.h" + +#define ADDRESS 0xA4 // 0x52 << 1 + +Pokitto::Core game; +I2C i2c(P0_5, P0_4); // sda, scl + + +unsigned char dataFormat; +unsigned char controllerType[6]; +bool connected, old_connected; +uint8_t _data[21]; +int w_LX, w_RX, w_LY, w_RY, w_LT, w_RT, w_AX, w_AY, w_AZ; +bool w_RIGHT, w_DOWN, w_L, w_MINUS, w_HOME, w_PLUS, w_R, w_LZ, w_B, w_Y, w_A, w_X, w_RZ, w_LEFT, w_UP; +int wiiError,oldError; +int controlType=-1; + +unsigned char conTypes[3][6]={ + {0x00,0x00,0xA4,0x20,0x00,0x00}, // 0 = Nunchuck + {0x00,0x00,0xA4,0x20,0x01,0x01}, // 1 = Classic controller + {0x01,0x00,0xA4,0x20,0x01,0x01}, // 2 = Classic controller pro +}; +char *controller[3] = {"Nunchuck","Classic controller","Classic controller pro"}; +void init_classic(); + + + + +void checkController(){ + //game.display.clear(); + char tempText[20]; + game.display.setCursor(0,77); + controlType=-1; + for(char s=0; s<3; s++){ + unsigned char tempCount=0; + for(char t=0; t<6; t++){ + // check controller against known models. 5th byte ignored, as it is changed by init process + if(t!=4){ if(controllerType[t] == conTypes[s][t]){ tempCount++; } } + } + if(tempCount==5){controlType=s;} + } + //Serial.print("Controller:"); + if(controlType<0){ + game.display.print("Not Connected"); + // Serial.println("Not Connected"); + }else{ + // Serial.println(controller[controlType]); + sprintf(tempText,"%s\n",controller[controlType]); + game.display.print(tempText); + } + + sprintf(tempText,"DataFormat = %d\n",dataFormat); + game.display.print(tempText); + +} + +void updateClassic() +{ + i2c.write(ADDRESS, (const char*)0x00, 1); + // wait + wait_ms(10); + if(i2c.read(ADDRESS, (char*)_data, 8)){ + connected = 0; + }else{ + connected = 1; -Pokitto::Core mygame; + if(controlType == 0){ + // nunchuck + // nunchuck only does format 1 + w_LX = _data[0]; + w_LY = _data[1]; + w_AX = (_data[2] << 2) | ((_data[5] >> 2) & 3); + w_AY = (_data[3] << 2) | ((_data[5] >> 4) & 3); + w_AZ = (_data[4] << 2) | ((_data[5] >> 6) & 3); + w_LZ = !((_data[5] >> 0) & 1); + w_L = !((_data[5] >> 1) & 1); + } + if(controlType == 1 || controlType == 2){ + // classic controller or classic controller pro + w_LX = _data[0]; + w_RX = _data[1]; + w_LY = _data[2]; + w_RY = _data[3]; + w_LT = _data[4]; + w_RT = _data[5]; + w_RIGHT = _data[6]&B10000000 ? 0:1; + w_DOWN = _data[6]&B01000000 ? 0:1; + w_L = _data[6]&B00100000 ? 0:1; + w_MINUS = _data[6]&B00010000 ? 0:1; + w_HOME = _data[6]&B00001000 ? 0:1; + w_PLUS = _data[6]&B00000100 ? 0:1; + w_R = _data[6]&B00000010 ? 0:1; + w_LZ = _data[7]&B10000000 ? 0:1; + w_B = _data[7]&B01000000 ? 0:1; + w_Y = _data[7]&B00100000 ? 0:1; + w_A = _data[7]&B00010000 ? 0:1; + w_X = _data[7]&B00001000 ? 0:1; + w_RZ = _data[7]&B00000100 ? 0:1; + w_LEFT = _data[7]&B00000010 ? 0:1; + w_UP = _data[7]&B00000001 ? 0:1; + } + } + + if(old_connected == 0 && connected == 1){ + wait_ms(10); + init_classic(); + } + old_connected = connected; +} + +void init_classic() +{ + i2c.frequency(100000); + for(char t=0; t<6; t++){ + controllerType[t] = 0x00; + } + + //if(!i2c.write(ADDRESS, NULL, 0)){ + + char dat[] = {0xF0,0x55,0xFB,0x00,0xFE,0x03}; + i2c.write(ADDRESS, &dat[0], 2); + i2c.stop(); + wait_ms(1); + i2c.write(ADDRESS, &dat[2], 2); + i2c.stop(); + wait_ms(1); + i2c.write(ADDRESS, &dat[4], 2); + i2c.stop(); + wait_ms(1); + + + char cmd[] = {0xFA}; + i2c.write(ADDRESS, cmd, sizeof(cmd)); + wait_ms(1); + if(i2c.read(ADDRESS, (char*)controllerType, 6)){ + connected = 0; + }else{ + connected = 1; + } + i2c.stop(); + + dataFormat = controllerType[4]; + checkController(); + + /* + Known data types + 1. Standard Wii Classic controller + 2. ? + 3. Classic controller, easier to read, not universally supported by 3rd part controllers + 4. Wii Motion Plus + */ + //update_classic(); + // } +} + int main () { - mygame.begin(); - while (mygame.isRunning()) { - if (mygame.update()) { - mygame.display.print("Hello World!"); + game.begin(); + + game.display.setFont(font3x5); + game.display.setInvisibleColor(0); + + game.display.load565Palette(sprite_pal); + + while (game.isRunning()) { + if (game.update()) { + + + updateClassic(); + + + //game.display.clear(); + char tempText[40]; + + sprintf(tempText,"%03d\n%03d\n%03d\n%03d\n%03d\n%03d\n%03d\n%03d\n%03d\n \n%03d\n", connected, _data[0],_data[1],_data[2],_data[3],_data[4],_data[5],_data[6],_data[7],controllerType[4]); + game.display.setCursor(0,0); + game.display.print(tempText); + sprintf(tempText,"%s\n",controller[controlType]); + game.display.setCursor(0,120); + game.display.print(tempText); + + + char ox=8, oy=16; + // draw background! + for(char t=0; t<3; t++){ + game.display.drawBitmap(ox+24+t*16,oy+w_LT/60,sprite_buttons[12+t+(w_L*8)]); + game.display.drawBitmap(ox+136+t*16,oy+w_RT/60,sprite_buttons[16+t+(w_R*8)]); + } + + for(uint8_t y=0; y<12; y++){ + for(uint8_t x=0; x<25; x++){ + game.display.drawBitmap(ox+x*8,oy+y*8,sprites[sprite_map[x+25*y]]); + } + } + + game.display.drawBitmap(ox+64+(w_LX-127)/10,oy+56+(127-w_LY)/10,sprite_circle); + game.display.drawBitmap(ox+120+(w_RX-127)/10,oy+56+(127-w_RY)/10,sprite_circle); + if(w_RIGHT)game.display.drawBitmap(ox+45,oy+32, sprite_buttons[11]); + if(w_DOWN)game.display.drawBitmap(ox+36,oy+41, sprite_buttons[9]); + if(w_LEFT)game.display.drawBitmap(ox+27,oy+32, sprite_buttons[10]); + if(w_UP)game.display.drawBitmap(ox+36,oy+23, sprite_buttons[8]); + if(w_MINUS)game.display.drawBitmap(ox+80,oy+32,sprite_buttons[6]); + if(w_HOME)game.display.drawBitmap(ox+96,oy+32,sprite_buttons[5]); + if(w_PLUS)game.display.drawBitmap(ox+112,oy+32,sprite_buttons[6]); + if(w_X)game.display.drawBitmap(ox+152,oy+16,sprite_buttons[0]); + if(w_Y)game.display.drawBitmap(ox+136,oy+28,sprite_buttons[1]); + if(w_A)game.display.drawBitmap(ox+168,oy+28,sprite_buttons[2]); + if(w_B)game.display.drawBitmap(ox+152,oy+40,sprite_buttons[3]); + if(w_LZ)game.display.drawBitmap(ox+77,oy+2,sprite_buttons[7]); + if(w_RZ)game.display.drawBitmap(ox+110,oy+2,sprite_buttons[7]); + + + + + } }