Ticket #16691: watch.cpp

File watch.cpp, 571 bytes (added by madmax, 3 years ago)

Simple watcher program

Line 
1#include <Application.h>
2#include <USBKit.h>
3
4#include <stdio.h>
5
6
7class Watcher : public BUSBRoster {
8public:
9
10 ~Watcher() {}
11
12 status_t DeviceAdded(BUSBDevice *device) {
13 printf("ADD\n");
14 //return !B_OK; // This is no problem
15 return B_OK;
16 }
17
18 void DeviceRemoved(BUSBDevice *device) {
19 printf("REMOVE\n");
20 return;
21 }
22
23};
24
25class WatcherApp : public BApplication {
26public:
27
28 WatcherApp() : BApplication("application/x-vnd.MCR.test.USBwatch") {
29 }
30
31 void ReadyToRun() {
32 w.Start();
33 }
34
35private:
36
37 Watcher w;
38};
39
40main() {
41 WatcherApp app;
42 app.Run();
43 return 0;
44}