Welcome to mirror list, hosted at ThFree Co, Russian Federation.

hids_mouse_menu.c « menu « ble « STM32_WPAN « ST « Middlewares - github.com/Flipper-Zero/STM32CubeWB.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 84ae004c77d865d05200b5b8a23a87b204a3a19e (plain)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/**
 ******************************************************************************
 * @file    hids_mouse_menu.c
 * @author  MCD Application Team
 * @brief   Human Interface Device Mouse Server Menu Application
 ******************************************************************************
 * @attention
 *
 * Copyright (c) 2018-2021 STMicroelectronics.
 * All rights reserved.
 *
 * This software is licensed under terms that can be found in the LICENSE file
 * in the root directory of this software component.
 * If no LICENSE file comes with this software, it is provided AS-IS.
 *
 ******************************************************************************
 */


/* Includes ------------------------------------------------------------------*/
#include "DispTools.h"
#include "hids_menu.h"
#include "app_conf.h"

/* Private typedef -----------------------------------------------------------*/


/* Private defines -----------------------------------------------------------*/
#define ESCAPE              254


/* Private macros ------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
static char *cMenuTitle = "HUMAN INTERFACE DEVICE SERVER";
static char *cSoftwareVersion = "1.0";

/***************************************
*    M E N U   D E F I N I T I O N S   *
***************************************/
static const char * cButtonState[] = 
{
  "Released", 
  "Pressed ",
  "" 
};
static uint16_t Button1, Button2, Button3;
static int32_t XPosVal, XPosMin, XPosMax;
static int32_t YPosVal, YPosMin, YPosMax;
static int32_t WIndVal, WIndMin, WIndMax;
STRUCTCAPTUREVAL_T XPos =
{ &XPosVal, 
  &XPosMin, 
  &XPosMax
};
STRUCTCAPTUREVAL_T YPos =
{ &YPosVal, 
  &YPosMin, 
  &YPosMax 
};
STRUCTCAPTUREVAL_T WInd =
{ 
  &WIndVal, 
  &WIndMin, 
  &WIndMax 
};
static STRUCTMENU_T HID_Set_Report_Menu[] =
{
  {  "Button 1",            &Button1, TOGGLE, cButtonState },
  {  "Button 2",            &Button2, TOGGLE, cButtonState },
  {  "Button 3",            &Button3, TOGGLE, cButtonState },
  {  "Horizontal Position", &XPos,    NUM32,  "%04d"       },
  {  "Vertical Position",   &YPos,    NUM32,  "%04d"       },
  {  "Wheel Indentation",   &WInd,    NUM32,  "%04d"       },
  {  " ",                   NULL,     TITLE,  " "          },
  {  "Save & Quit  ",       NULL,     ACTION, " "          },
  {  ""                                                    }
};

enum _HID_Set_Report_Menu_Enum
{
  HID_B1 = 0,
  HID_B2,
  HID_B3,
  HID_HP,
  HID_VP,
  HID_WI,
  HID_SRNULL,
  HID_SRQUIT
};

/* Global variables ----------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Functions Definition ------------------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
/* Public functions ----------------------------------------------------------*/
/**
 **********************************************************************************************************************
 * \fn:     void HIDS_Menu(uint8_t * action_type)
 * \author:  -
 * \brief:  Human Interface Device action Menu.
 * \param:  *action_type pointer on action type
 * \return: None
 **********************************************************************************************************************
**/
void HIDS_Menu (uint8_t * action_type, uint8_t * report)
{
  uint16_t wItem = 0;
  uint8_t Handle;
  
  ClearScreen ();

  XPosVal = 0;
  XPosMin = (int8_t)(-127);
  XPosMax = (int8_t)127;
  YPosVal = 0;
  YPosMin = (int8_t)(-127);
  YPosMax = (int8_t)127;
  WIndVal = 0;
  WIndMin = (int8_t)(-127);
  WIndMax = (int8_t)127;

  Handle = CreateMenu(HID_Set_Report_Menu, 
                      6, 
                      12, 
                      0, 
                      0);

  do
  {
    DisplayTitle (1, cMenuTitle, cSoftwareVersion);
    DisplaySubTitle (10, "Report Setting Menu", FALSE);
    wItem = RunMenu(Handle, 
                    wItem, 
                    6, 
                    12, 
                    CAPTURE+DISPLAY); 
    switch (wItem)
    {
      case HID_SRQUIT:
        {
          *action_type = 1;
          report[0] = Button1;
          report[0] |= Button2 << 1;
          report[0] |= Button3 << 2;
          report[1] = XPosVal;
          report[2] = YPosVal;
          report[3] = WIndVal;
          wItem = HOME;
        }
        break;

      case ESCAPE:
        {
          *action_type = 0;
          wItem = HOME;
        }
        break;

      default:
        break;
    }
  }
  while (wItem != HOME);

  ClearScreen ();
  DeleteMenu(Handle);
}