-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding other people's code as found on the internet and my own stuff.
- Loading branch information
0 parents
commit e1f0f3d
Showing
46 changed files
with
20,266 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* main.cpp | ||
* | ||
* Created on: Feb 11, 2011 | ||
* Author: ams | ||
* | ||
* Uses the object-oriented control program for controlling the Dream Cheeky | ||
* Missile Launcher to move the launcher and fire the missiles. | ||
* | ||
*/ | ||
|
||
#include <iostream> | ||
#include "missile_launcher.h" | ||
|
||
using namespace std; | ||
|
||
int main(int argc, char** argv) | ||
{ | ||
MissileLauncher mc; | ||
if(mc.init() == 0){ | ||
mc.fire(); | ||
}else{ | ||
cerr << "Failed to initialize missile launcher" << endl; | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Makes the missile launcher | ||
all: missileCommand | ||
|
||
missileCommand: | ||
g++ main.cpp missile_launcher.cpp -lusb -L/usr/lib -o missileCommand |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* missile_launcher.cpp | ||
* | ||
* Created on: Feb 11, 2011 | ||
* Author: ams | ||
* | ||
* Creates and maintains info about a Dream Cheeky Missile Launcher. | ||
* | ||
*/ | ||
|
||
#include "missile_launcher.h" | ||
|
||
void MissileLauncher::fire() | ||
{ | ||
|
||
} | ||
|
||
int MissileLauncher::init() | ||
{ | ||
struct usb_bus *busses; | ||
|
||
usb_init(); | ||
if (usb_find_busses() != 0) | ||
{ | ||
cerr << "Failed to find USB buses" << endl; | ||
return 1; | ||
} | ||
|
||
if (usb_find_devices() != 0) | ||
{ | ||
cerr << "Failed to find USB devices" << endl; | ||
return 1; | ||
} | ||
|
||
busses = usb_get_busses(); | ||
|
||
struct usb_bus *bus; | ||
|
||
//Iterate through buses and devices, looking for a missile launcher | ||
for (bus = busses; bus; bus = bus->next) | ||
{ | ||
struct usb_device *dev; | ||
|
||
for (dev = bus->devices; dev; dev = dev->next) | ||
{ | ||
/* Check if this device is a missile launcher */ | ||
if (dev->descriptor.idVendor == 6465) | ||
{ | ||
launcher = usb_open(dev); | ||
|
||
int claimed = usb_claim_interface(launcher, 0); | ||
if (claimed == 0) | ||
{ | ||
//Rock on, we have a handle on it. | ||
return 0; | ||
} | ||
else | ||
{ | ||
cerr << "Could not claim Missile Launcher" << endl; | ||
return 1; | ||
} | ||
} | ||
} | ||
} | ||
|
||
cerr << "Did not find Missile Launcher. Is it plugged in?" << endl; | ||
return 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* missile_launcher.h | ||
* | ||
* Created on: Feb 11, 2011 | ||
* Author: ams | ||
*/ | ||
|
||
#ifndef MISSILE_LAUNCHER_H_ | ||
#define MISSILE_LAUNCHER_H_ | ||
|
||
#include <usb.h> | ||
#include <iostream> | ||
|
||
using namespace std; | ||
|
||
class MissileLauncher | ||
{ | ||
public: | ||
int init(); | ||
void fire(); | ||
private: | ||
usb_dev_handle* launcher; | ||
}; | ||
|
||
#endif /* MISSILE_LAUNCHER_H_ */ |
Binary file not shown.
Empty file.
Oops, something went wrong.