1
1
/****************************************************************************
2
- * examplex /nunchuck/nunchuck_main.c
2
+ * apps/examples /nunchuck/nunchuck_main.c
3
3
*
4
4
* Licensed to the Apache Software Foundation (ASF) under one or more
5
5
* contributor license agreements. See the NOTICE file distributed with
37
37
/****************************************************************************
38
38
* Pre-processor Definitions
39
39
****************************************************************************/
40
+
40
41
/* Configuration ************************************************************/
41
42
42
43
#ifndef CONFIG_INPUT_NUNCHUCK
52
53
/* Helpers ******************************************************************/
53
54
54
55
#ifndef MIN
55
- # define MIN (a ,b ) (a < b ? a : b )
56
+ # define MIN (a ,b ) ((a) < (b) ? (a) : (b) )
56
57
#endif
57
58
#ifndef MAX
58
- # define MAX (a ,b ) (a > b ? a : b )
59
+ # define MAX (a ,b ) ((a) > (b) ? (a) : (b) )
59
60
#endif
60
61
61
62
/****************************************************************************
62
63
* Private Function Prototypes
63
64
****************************************************************************/
64
65
65
- static void show_buttons (nunchuck_buttonset_t oldset , nunchuck_buttonset_t newset );
66
+ static void show_buttons (nunchuck_buttonset_t oldset ,
67
+ nunchuck_buttonset_t newset );
66
68
static void show_joystick (FAR const struct nunchuck_sample_s * sample );
67
69
static int nunchuck_read (int fd , FAR struct nunchuck_sample_s * sample );
68
70
static int nunchuck_calibrate (int fd );
69
71
70
72
/****************************************************************************
71
73
* Private Data
72
74
****************************************************************************/
75
+
73
76
/* The set of supported joystick buttons */
74
77
75
78
static nunchuck_buttonset_t g_nunchucksupported ;
@@ -101,7 +104,8 @@ static const char *g_nunchucknames[NUNCHUCK_NBUTTONS] =
101
104
* Private Functions
102
105
****************************************************************************/
103
106
104
- static void show_buttons (nunchuck_buttonset_t oldset , nunchuck_buttonset_t newset )
107
+ static void show_buttons (nunchuck_buttonset_t oldset ,
108
+ nunchuck_buttonset_t newset )
105
109
{
106
110
nunchuck_buttonset_t chgset = oldset ^ newset ;
107
111
int i ;
@@ -194,8 +198,9 @@ static int nunchuck_read(int fd, FAR struct nunchuck_sample_s *sample)
194
198
}
195
199
196
200
#ifdef CONFIG_DEBUG_INPUT
197
- /* Show the joystick position and set buttons accompanying the signal */
198
- /* Show the set of joystick buttons that we just read */
201
+ /* Show the joystick position and set buttons accompanying the signal.
202
+ * Show the set of joystick buttons that we just read
203
+ */
199
204
200
205
printf ("Read position and button set\n" );
201
206
show_joystick (sample );
@@ -390,7 +395,8 @@ int main(int argc, FAR char *argv[])
390
395
ret = ioctl (fd , NUNCHUCKIOC_SUPPORTED , (unsigned long )((uintptr_t )& tmp ));
391
396
if (ret < 0 )
392
397
{
393
- fprintf (stderr , "ERROR: ioctl(NUNCHUCKIOC_SUPPORTED) failed: %d\n" , errno );
398
+ fprintf (stderr , "ERROR: ioctl(NUNCHUCKIOC_SUPPORTED) failed: %d\n" ,
399
+ errno );
394
400
goto errout_with_fd ;
395
401
}
396
402
@@ -402,7 +408,7 @@ int main(int argc, FAR char *argv[])
402
408
403
409
nunchuck_calibrate (fd );
404
410
405
- for (;; )
411
+ for (; ; )
406
412
{
407
413
struct nunchuck_sample_s sample ;
408
414
0 commit comments