Blame view

build3/apps/hardware_test/keyboard_test_controller.cpp 1.06 KB
6663b6c9   adorian   projet complet av...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
  #include "keyboard_test_controller.h"
  extern "C" {
  #include <assert.h>
  }
  #include <poincare.h>
  
  using namespace Poincare;
  
  namespace HardwareTest {
  
  KeyboardTestController::KeyboardTestController(Responder * parentResponder) :
    ViewController(parentResponder),
    m_keyboardView(),
    m_screenTestController(nullptr)
  {
  }
  
  View * KeyboardTestController::view() {
    return &m_keyboardView;
  }
  
  bool KeyboardTestController::handleEvent(Ion::Events::Event event) {
    Ion::Keyboard::State state = Ion::Keyboard::scan();
    Ion::Keyboard::State onlyKeyDown = Ion::Keyboard::State(Ion::Keyboard::ValidKeys[m_keyboardView.testedKeyIndex()]);
    if (state == onlyKeyDown) {
      m_keyboardView.setTestedKeyIndex(m_keyboardView.testedKeyIndex()+1);
      if (m_keyboardView.testedKeyIndex() == Ion::Keyboard::NumberOfValidKeys) {
        ModalViewController * modal = (ModalViewController *)parentResponder();
        modal->displayModalViewController(&m_screenTestController, 0.0f, 0.0f);
      }
    }
    return true;
  }
  
  void KeyboardTestController::viewWillAppear() {
    m_keyboardView.setTestedKeyIndex(0);
  }
  
  }