C

Qt Quick Ultralite Automotive Cluster Demo

/****************************************************************************** ** ** Copyright (C) 2019 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Quick Ultralite module. ** ** $QT_BEGIN_LICENSE:COMM$ ** ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms ** and conditions see http://www.qt.io/terms-conditions. For further ** information use the contact form at http://www.qt.io/contact-us. ** ** $QT_END_LICENSE$ ** ******************************************************************************/
#include "hmi_input.h" #include "r_typedefs.h" #include "r_bsp_hmi_api.h" template<HMIInputEvent::Type type, HMIInputEvent::Key keyCode> static void keyEventHandler() { HMIInput::instance().postEvent(HMIInputEvent(keyCode, type)); } static void hmiInputInit() { R_BSP_HMI_Init(); R_BSP_SetButtonCallback(BSP_BTN_UP_PRESS, keyEventHandler<HMIInputEvent::KeyPress, HMIInputEvent::HMI_BTN_UP>); R_BSP_SetButtonCallback(BSP_BTN_UP_RELEASE, keyEventHandler<HMIInputEvent::KeyRelease, HMIInputEvent::HMI_BTN_UP>); R_BSP_SetButtonCallback(BSP_BTN_DOWN_PRESS, keyEventHandler<HMIInputEvent::KeyPress, HMIInputEvent::HMI_BTN_DOWN>); R_BSP_SetButtonCallback(BSP_BTN_DOWN_RELEASE, keyEventHandler<HMIInputEvent::KeyRelease, HMIInputEvent::HMI_BTN_DOWN>); R_BSP_SetButtonCallback(BSP_BTN_LEFT_PRESS, keyEventHandler<HMIInputEvent::KeyPress, HMIInputEvent::HMI_BTN_LEFT>); R_BSP_SetButtonCallback(BSP_BTN_LEFT_RELEASE, keyEventHandler<HMIInputEvent::KeyRelease, HMIInputEvent::HMI_BTN_LEFT>); R_BSP_SetButtonCallback(BSP_BTN_RIGHT_PRESS, keyEventHandler<HMIInputEvent::KeyPress, HMIInputEvent::HMI_BTN_RIGHT>); R_BSP_SetButtonCallback(BSP_BTN_RIGHT_RELEASE, keyEventHandler<HMIInputEvent::KeyRelease, HMIInputEvent::HMI_BTN_RIGHT>); R_BSP_SetButtonCallback(BSP_BTN_CENTER_PRESS, keyEventHandler<HMIInputEvent::KeyPress, HMIInputEvent::HMI_BTN_CENTER>); R_BSP_SetButtonCallback(BSP_BTN_CENTER_RELEASE, keyEventHandler<HMIInputEvent::KeyRelease, HMIInputEvent::HMI_BTN_CENTER>); // The knob alternates between sending left and right turn events // no matter which way you turn it, so let's just send BTN_LEFT_TURN events // to make it sort of useful. R_BSP_SetButtonCallback(BSP_BTN_LEFT_TURN, keyEventHandler<HMIInputEvent::KeyRelease, HMIInputEvent::HMI_KNOB_TURN_RIGHT>); R_BSP_SetButtonCallback(BSP_BTN_RIGHT_TURN, keyEventHandler<HMIInputEvent::KeyRelease, HMIInputEvent::HMI_KNOB_TURN_RIGHT>); R_BSP_SetButtonCallback(BSP_BTN_OK_PRESS, keyEventHandler<HMIInputEvent::KeyPress, HMIInputEvent::HMI_KNOB_CENTER>); R_BSP_SetButtonCallback(BSP_BTN_OK_RELEASE, keyEventHandler<HMIInputEvent::KeyRelease, HMIInputEvent::HMI_KNOB_CENTER>); } extern void (*hmiInputInitRoutine)(); static struct Init { Init() { hmiInputInitRoutine = hmiInputInit; } } init;