pikeyd165 – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 /**** pikeyd.c *****************************/
2 /* M. Moller 2013-01-16 */
3 /* Universal RPi GPIO keyboard daemon */
4 /*******************************************/
5  
6 /*
7 Copyright (C) 2013 Michael Moller.
8 This file is part of the Universal Raspberry Pi GPIO keyboard daemon.
9  
10 This is free software; you can redistribute it and/or
11 modify it under the terms of the GNU Lesser General Public
12 License as published by the Free Software Foundation; either
13 version 2.1 of the License, or (at your option) any later version.
14  
15 The software is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
19  
20 You should have received a copy of the GNU Lesser General Public
21 License along with the GNU C Library; if not, write to the Free
22 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
23 02111-1307 USA.
24 */
25  
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include <string.h>
29 #include <unistd.h>
30 #include <stdbool.h>
31  
32 #include "joy_RPi.h"
33  
34  
35 #include <bcm2835.h>
36 #include "gpio_joystick.h"
37  
38 #define HC165JOY 1
39  
40  
41 static void showHelp(void);
42 static void showVersion(void);
43  
44 bool no_key_debounce = false;
45 bool skip_mouse_init = false;
46  
47 int main(int argc, char *argv[])
48 {
49  
50  
51 int i;
52  
53 if(argc>1){
54  
55 for (i = 1; i < argc; i++) {
56 if(!strcmp(argv[i], "-d")){
57 daemonize("/tmp", "/tmp/pikeyd.pid");
58 }
59 else if(!strcmp(argv[i], "-k")){
60 daemonKill("/tmp/pikeyd.pid");
61 exit(0);
62 }
63 else if(!strcmp(argv[i], "-v")){
64 showVersion();
65 exit(0);
66 }
67 else if(!strcmp(argv[i], "-h")){
68 showHelp();
69 exit(0);
70 }
71 else if(!strcmp(argv[i], "-smi")){
72 printf("mouse disabled\n");
73 skip_mouse_init = true;
74 }
75 else if(!strcmp(argv[i], "-ndb")){
76 printf("no key debounce\n");
77 no_key_debounce = true;
78 }
79  
80 }
81 }
82  
83  
84  
85  
86  
87  
88  
89 init_config();
90 //test_config(); exit(0);
91  
92 printf("init uinput\n");
93  
94 if(init_uinput(skip_mouse_init) == 0){
95 sleep(1);
96 //test_uinput();
97  
98  
99 if(joy_RPi_init()>=0){
100  
101 for(;;){
102 joy_RPi_poll();
103 usleep(4000);
104 }
105  
106 joy_RPi_exit();
107 }
108  
109 close_uinput(skip_mouse_init);
110 }
111  
112 return 0;
113 }
114  
115 static void showHelp(void)
116 {
117 printf("Usage: pikeyd [option]\n");
118  
119 printf("Options:\n");
120 printf(" -d run as daemon\n");
121 printf(" -k try to terminate running daemon\n");
122 printf(" -v version\n");
123 printf(" -smi skip mouse initialisation, no mouse/trackball devices are created\n");
124 printf(" -ndb no key debounce \n");
125 printf(" -h this help\n");
126 }
127  
128 static void showVersion(void)
129 {
130 printf("\npikeyd - 2017 \n");
131 printf("The Universal Raspberry Pi GPIO keyboard daemon.\n");
132 printf("Copyright (C) 2013 Michael Moller.\n");
133 printf("This is free software; see the source for copying conditions. There is NO\n");
134 printf("warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n");
135  
136 printf("This version of pikeyd is heavily modified for use with the pi2jamma hardware. \n");
137 printf("Input is read via gpio bitstream, it supports 24 buttons, 2 Trackballs and 4 analog channels \n\n");
138 printf("Buildinfo:\n",BDATE);
139 printf("build directory: %s\n",BVERSION);
140 printf("build date: %s\n\n",BDATE);
141 }