flipbip_scene_2.c 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. // #include "../flipbip.h"
  2. // #include <furi.h>
  3. // #include <furi_hal.h>
  4. // #include <input/input.h>
  5. // #include <gui/elements.h>
  6. // #include <dolphin/dolphin.h>
  7. // #include "../helpers/flipbip_haptic.h"
  8. // //#include "../helpers/flipbip_speaker.h"
  9. // #include "../helpers/flipbip_led.h"
  10. // struct FlipBipScene2 {
  11. // View* view;
  12. // FlipBipScene2Callback callback;
  13. // void* context;
  14. // };
  15. // typedef struct {
  16. // int screen_text;
  17. // } FlipBipScene2Model;
  18. // char buttonText[11][14] = {
  19. // "",
  20. // "Press Up",
  21. // "Press Down",
  22. // "Press Left",
  23. // "Press Right",
  24. // "Press Ok",
  25. // "Release Up",
  26. // "Release Down",
  27. // "Release Left",
  28. // "Release Right",
  29. // "Release Ok",
  30. // };
  31. // void flipbip_scene_2_set_callback(
  32. // FlipBipScene2* instance,
  33. // FlipBipScene2Callback callback,
  34. // void* context) {
  35. // furi_assert(instance);
  36. // furi_assert(callback);
  37. // instance->callback = callback;
  38. // instance->context = context;
  39. // }
  40. // void flipbip_scene_2_draw(Canvas* canvas, FlipBipScene2Model* model) {
  41. // canvas_clear(canvas);
  42. // canvas_set_color(canvas, ColorBlack);
  43. // canvas_set_font(canvas, FontPrimary);
  44. // canvas_draw_str_aligned(canvas, 0, 10, AlignLeft, AlignTop, "Scene 2: Input Examples");
  45. // canvas_set_font(canvas, FontSecondary);
  46. // char *strInput = malloc(15);
  47. // strcpy(strInput, buttonText[model->screen_text]);
  48. // canvas_draw_str_aligned(canvas, 0, 22, AlignLeft, AlignTop, strInput);
  49. // free(strInput);
  50. // }
  51. // static void flipbip_scene_2_model_init(FlipBipScene2Model* const model) {
  52. // model->screen_text = 0;
  53. // }
  54. // bool flipbip_scene_2_input(InputEvent* event, void* context) {
  55. // furi_assert(context);
  56. // FlipBipScene2* instance = context;
  57. // if (event->type == InputTypeRelease) {
  58. // switch(event->key) {
  59. // case InputKeyBack:
  60. // with_view_model(
  61. // instance->view,
  62. // FlipBipScene2Model * model,
  63. // {
  64. // UNUSED(model);
  65. // //flipbip_stop_all_sound(instance->context);
  66. // instance->callback(FlipBipCustomEventScene2Back, instance->context);
  67. // flipbip_play_long_bump(instance->context);
  68. // },
  69. // true);
  70. // break;
  71. // case InputKeyUp:
  72. // with_view_model(
  73. // instance->view,
  74. // FlipBipScene2Model * model,
  75. // {
  76. // model->screen_text = 6;
  77. // flipbip_play_bad_bump(instance->context);
  78. // //flipbip_stop_all_sound(instance->context);
  79. // flipbip_led_set_rgb(instance->context, 255, 0, 255);
  80. // },
  81. // true);
  82. // break;
  83. // case InputKeyDown:
  84. // with_view_model(
  85. // instance->view,
  86. // FlipBipScene2Model * model,
  87. // {
  88. // model->screen_text = 7;
  89. // flipbip_play_bad_bump(instance->context);
  90. // //flipbip_stop_all_sound(instance->context);
  91. // flipbip_led_set_rgb(instance->context, 255, 255, 0);
  92. // },
  93. // true);
  94. // break;
  95. // case InputKeyLeft:
  96. // with_view_model(
  97. // instance->view,
  98. // FlipBipScene2Model * model,
  99. // {
  100. // model->screen_text = 8;
  101. // flipbip_play_bad_bump(instance->context);
  102. // //flipbip_stop_all_sound(instance->context);
  103. // flipbip_led_set_rgb(instance->context, 0, 255, 255);
  104. // },
  105. // true);
  106. // break;
  107. // case InputKeyRight:
  108. // with_view_model(
  109. // instance->view,
  110. // FlipBipScene2Model * model,
  111. // {
  112. // model->screen_text = 9;
  113. // flipbip_play_bad_bump(instance->context);
  114. // //flipbip_stop_all_sound(instance->context);
  115. // flipbip_led_set_rgb(instance->context, 255, 0, 0);
  116. // },
  117. // true);
  118. // break;
  119. // case InputKeyOk:
  120. // with_view_model(
  121. // instance->view,
  122. // FlipBipScene2Model * model,
  123. // {
  124. // model->screen_text = 10;
  125. // flipbip_play_bad_bump(instance->context);
  126. // //flipbip_stop_all_sound(instance->context);
  127. // flipbip_led_set_rgb(instance->context, 255, 255, 255);
  128. // },
  129. // true);
  130. // break;
  131. // case InputKeyMAX:
  132. // break;
  133. // }
  134. // } else if (event->type == InputTypePress) {
  135. // switch(event->key) {
  136. // case InputKeyUp:
  137. // with_view_model(
  138. // instance->view,
  139. // FlipBipScene2Model * model,
  140. // {
  141. // model->screen_text = 1;
  142. // flipbip_play_happy_bump(instance->context);
  143. // //flipbip_play_input_sound(instance->context);
  144. // },
  145. // true);
  146. // break;
  147. // case InputKeyDown:
  148. // with_view_model(
  149. // instance->view,
  150. // FlipBipScene2Model * model,
  151. // {
  152. // model->screen_text = 2;
  153. // flipbip_play_happy_bump(instance->context);
  154. // //flipbip_play_input_sound(instance->context);
  155. // },
  156. // true);
  157. // break;
  158. // case InputKeyLeft:
  159. // with_view_model(
  160. // instance->view,
  161. // FlipBipScene2Model * model,
  162. // {
  163. // model->screen_text = 3;
  164. // flipbip_play_happy_bump(instance->context);
  165. // //flipbip_play_input_sound(instance->context);
  166. // },
  167. // true);
  168. // break;
  169. // case InputKeyRight:
  170. // with_view_model(
  171. // instance->view,
  172. // FlipBipScene2Model * model,
  173. // {
  174. // model->screen_text = 4;
  175. // flipbip_play_happy_bump(instance->context);
  176. // //flipbip_play_input_sound(instance->context);
  177. // },
  178. // true);
  179. // break;
  180. // case InputKeyOk:
  181. // with_view_model(
  182. // instance->view,
  183. // FlipBipScene2Model * model,
  184. // {
  185. // model->screen_text = 5;
  186. // flipbip_play_happy_bump(instance->context);
  187. // //flipbip_play_input_sound(instance->context);
  188. // },
  189. // true);
  190. // break;
  191. // case InputKeyBack:
  192. // case InputKeyMAX:
  193. // break;
  194. // }
  195. // }
  196. // return true;
  197. // }
  198. // void flipbip_scene_2_exit(void* context) {
  199. // furi_assert(context);
  200. // //FlipBip* app = context;
  201. // //flipbip_stop_all_sound(app);
  202. // //flipbip_led_reset(app);
  203. // }
  204. // void flipbip_scene_2_enter(void* context) {
  205. // furi_assert(context);
  206. // DOLPHIN_DEED(DolphinDeedPluginStart);
  207. // }
  208. // FlipBipScene2* flipbip_scene_2_alloc() {
  209. // FlipBipScene2* instance = malloc(sizeof(FlipBipScene2));
  210. // instance->view = view_alloc();
  211. // view_allocate_model(instance->view, ViewModelTypeLocking, sizeof(FlipBipScene2Model));
  212. // view_set_context(instance->view, instance);
  213. // view_set_draw_callback(instance->view, (ViewDrawCallback)flipbip_scene_2_draw);
  214. // view_set_input_callback(instance->view, flipbip_scene_2_input);
  215. // //view_set_enter_callback(instance->view, flipbip_scene_2_enter);
  216. // view_set_exit_callback(instance->view, flipbip_scene_2_exit);
  217. // with_view_model(
  218. // instance->view,
  219. // FlipBipScene2Model * model,
  220. // {
  221. // flipbip_scene_2_model_init(model);
  222. // },
  223. // true);
  224. // return instance;
  225. // }
  226. // void flipbip_scene_2_free(FlipBipScene2* instance) {
  227. // furi_assert(instance);
  228. // view_free(instance->view);
  229. // free(instance);
  230. // }
  231. // View* flipbip_scene_2_get_view(FlipBipScene2* instance) {
  232. // furi_assert(instance);
  233. // return instance->view;
  234. // }