Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include <iostream>
00011
00012 #include "gamepad/manager.h"
00013 #include "perf/perf.h"
00014
00015
00016
00017
00018
00019
00020
00021
00022 int
00023 main
00024 (
00025 IN int argc,
00026 IN const char * argv[]
00027 )
00028 {
00029 ASSERT(2 == argc,
00030 "Usage: %s <gamepad-data-directory>", argv[0]);
00031
00032 const char * dataDir = argv[1];
00033 DPRINTF("Using gamepad data directory: '%s'", dataDir);
00034
00035 int retval = 0;
00036
00037 try {
00038 smart_ptr<nstream::Manager> fsMgr =
00039 nstream::getFilesystemManager(dataDir);
00040 ASSERT(fsMgr, "failed to acquire filesystem manager");
00041
00042 smart_ptr<nstream::Folder> folder = fsMgr->getRoot();
00043 ASSERT(folder, "null root folder?");
00044
00045 smart_ptr<gamepad::Manager> gameMgr =
00046 gamepad::Manager::create(folder);
00047 ASSERT(gameMgr, "failed to create gamepad manager");
00048
00049 gameMgr->rediscover();
00050 gameMgr->update();
00051
00052 int N = gameMgr->getSourceDeviceCount();
00053 DPRINTF("");
00054 DPRINTF("Found %d source devices.", N);
00055
00056 for (int i = 0; i < N; ++i) {
00057 smart_ptr<gamepad::SourceDevice> device =
00058 gameMgr->getSourceDevice(i);
00059 ASSERT(device, "null source device?");
00060
00061 const char * name = device->getPublicName();
00062 DPRINTF(" device[%d]: %s", i, name);
00063 }
00064
00065 N = gameMgr->getTypeCount();
00066 DPRINTF("");
00067 DPRINTF("Found %d known gamepad types.", N);
00068 for (int i = 0; i < N; ++i) {
00069 smart_ptr<gamepad::Type> type =
00070 gameMgr->getType(i);
00071 ASSERT(type, "null type?");
00072
00073 const char * name = type->getName();
00074 DPRINTF(" type[%d]: %s", i, name);
00075 }
00076
00077 } catch(std::exception& e) {
00078 DPRINTF("EXCEPTION: %s", e.what());
00079 retval = 1;
00080 }
00081
00082 perf::dumpTimingSummary(std::cerr);
00083
00084 return retval;
00085 }
00086