mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-22 06:41:17 +00:00
added WiiMote OpenGL demo as example - will be modified soon to use Cocoa Inquiry from BTstackCocoa
This commit is contained in:
parent
09f92ef2fe
commit
776c142709
111
example/WiiMoteOpenGLDemo/BTWiiMote.c
Normal file
111
example/WiiMoteOpenGLDemo/BTWiiMote.c
Normal file
@ -0,0 +1,111 @@
|
||||
/*
|
||||
* test.c
|
||||
*
|
||||
* Created by Matthias Ringwald on 7/14/09.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <strings.h>
|
||||
|
||||
#include <btstack/btstack.h>
|
||||
#include <btstack/run_loop.h>
|
||||
#include <btstack/hci_cmds.h>
|
||||
|
||||
// bd_addr_t addr = {0x00, 0x03, 0xc9, 0x3d, 0x77, 0x43 }; // Think Outside Keyboard
|
||||
bd_addr_t addr = {0x00, 0x19, 0x1d, 0x90, 0x44, 0x68 }; // WiiMote
|
||||
// bd_addr_t addr = {0x00, 0x19, 0x1d, 0x94, 0x7a, 0xff }; // WiiMote - iPhoneBlog.de
|
||||
|
||||
static void (*data_cb)(uint8_t x, uint8_t y, uint8_t z);
|
||||
static void (*state_cb)(char *text);
|
||||
|
||||
void packet_handler(uint8_t packet_type, uint8_t *packet, uint16_t size){
|
||||
bd_addr_t event_addr;
|
||||
|
||||
switch (packet_type) {
|
||||
|
||||
case L2CAP_DATA_PACKET:
|
||||
// just dump data for now
|
||||
// hexdump( packet, size );
|
||||
if (packet[8] == 0xa1 && packet[9] == 0x31){
|
||||
(*data_cb)(packet[12], packet[13], packet[14]);
|
||||
}
|
||||
break;
|
||||
|
||||
case HCI_EVENT_PACKET:
|
||||
|
||||
switch (packet[0]){
|
||||
|
||||
case BTSTACK_EVENT_STATE:
|
||||
// bt stack activated, get started - set local name
|
||||
if (packet[2] == HCI_STATE_WORKING) {
|
||||
bt_send_cmd(&hci_write_local_name, "BTstack-Test");
|
||||
(*state_cb)("BT running");
|
||||
}
|
||||
break;
|
||||
|
||||
case HCI_EVENT_PIN_CODE_REQUEST:
|
||||
// inform about pin code request
|
||||
printf("Please enter PIN 1234 on remote device\n");
|
||||
break;
|
||||
|
||||
case L2CAP_EVENT_CHANNEL_OPENED:
|
||||
// inform about new l2cap connection
|
||||
bt_flip_addr(event_addr, &packet[2]);
|
||||
uint16_t psm = READ_BT_16(packet, 10);
|
||||
uint16_t source_cid = READ_BT_16(packet, 12);
|
||||
printf("Channel successfully opened: ");
|
||||
print_bd_addr(event_addr);
|
||||
printf(", handle 0x%02x, psm 0x%02x, source cid 0x%02x, dest cid 0x%02x\n",
|
||||
READ_BT_16(packet, 8), psm, source_cid, READ_BT_16(packet, 14));
|
||||
|
||||
if (psm == 0x13) {
|
||||
// interupt channel openedn succesfully, now open control channel, too.
|
||||
bt_send_cmd(&l2cap_create_channel, event_addr, 0x11);
|
||||
} else {
|
||||
// request acceleration data.. probably has to be sent to control channel 0x11 instead of 0x13
|
||||
uint8_t setMode31[] = { 0x52, 0x12, 0x00, 0x31 };
|
||||
bt_send_l2cap( source_cid, setMode31, sizeof(setMode31));
|
||||
uint8_t setLEDs[] = { 0x52, 0x11, 0x10 };
|
||||
bt_send_l2cap( source_cid, setLEDs, sizeof(setLEDs));
|
||||
(*state_cb)("WiiMote connected");
|
||||
}
|
||||
|
||||
case HCI_EVENT_COMMAND_COMPLETE:
|
||||
// use pairing yes/no
|
||||
if ( COMMAND_COMPLETE_EVENT(packet, hci_write_local_name) ) {
|
||||
bt_send_cmd(&hci_write_authentication_enable, 0);
|
||||
}
|
||||
|
||||
// connect to HID device (PSM 0x13) at addr
|
||||
if ( COMMAND_COMPLETE_EVENT(packet, hci_write_authentication_enable) ) {
|
||||
(*state_cb)("Connecting to WiiMote");
|
||||
bt_send_cmd(&l2cap_create_channel, addr, 0x13);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void set_bt_state_cb(void (*cb)(char *text)){
|
||||
state_cb = cb;
|
||||
}
|
||||
|
||||
void set_data_cb(void (*handler)(uint8_t x, uint8_t y, uint8_t z)){
|
||||
data_cb = handler;
|
||||
}
|
||||
|
||||
void start_bt(){
|
||||
run_loop_init(RUN_LOOP_COCOA);
|
||||
bt_open();
|
||||
bt_register_packet_handler(packet_handler);
|
||||
(*state_cb)("BT started");
|
||||
bt_send_cmd(&btstack_set_power_mode, HCI_POWER_ON );
|
||||
}
|
13
example/WiiMoteOpenGLDemo/BTWiiMote.h
Normal file
13
example/WiiMoteOpenGLDemo/BTWiiMote.h
Normal file
@ -0,0 +1,13 @@
|
||||
/*
|
||||
* BTWiiMote.h
|
||||
*
|
||||
* Created by Matthias Ringwald on 8/2/09.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
void start_bt();
|
||||
void hci_register_event_packet_handler(void (*handler)(uint8_t *packet, uint16_t size));
|
||||
|
||||
void set_bt_state_cb(void (*cb)(char *text));
|
||||
void set_data_cb(void (*handler)(uint8_t x, uint8_t y, uint8_t z));
|
58
example/WiiMoteOpenGLDemo/Classes/EAGLView.h
Normal file
58
example/WiiMoteOpenGLDemo/Classes/EAGLView.h
Normal file
@ -0,0 +1,58 @@
|
||||
//
|
||||
// EAGLView.h
|
||||
// AppleCoder-OpenGLES-00
|
||||
//
|
||||
// Created by Simon Maurice on 18/03/09.
|
||||
// Copyright Simon Maurice 2009. All rights reserved.
|
||||
//
|
||||
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <OpenGLES/EAGL.h>
|
||||
#import <OpenGLES/ES1/gl.h>
|
||||
#import <OpenGLES/ES1/glext.h>
|
||||
|
||||
/*
|
||||
This class wraps the CAEAGLLayer from CoreAnimation into a convenient UIView subclass.
|
||||
The view content is basically an EAGL surface you render your OpenGL scene into.
|
||||
Note that setting the view non-opaque will only work if the EAGL surface has an alpha channel.
|
||||
*/
|
||||
@interface EAGLView : UIView {
|
||||
|
||||
@private
|
||||
/* The pixel dimensions of the backbuffer */
|
||||
GLint backingWidth;
|
||||
GLint backingHeight;
|
||||
|
||||
EAGLContext *context;
|
||||
|
||||
/* OpenGL names for the renderbuffer and framebuffers used to render to this view */
|
||||
GLuint viewRenderbuffer, viewFramebuffer;
|
||||
|
||||
/* OpenGL name for the depth buffer that is attached to viewFramebuffer, if it exists (0 if it does not exist) */
|
||||
GLuint depthRenderbuffer;
|
||||
|
||||
NSTimer *animationTimer;
|
||||
NSTimeInterval animationInterval;
|
||||
|
||||
GLuint textures[1];
|
||||
GLfloat rota;
|
||||
|
||||
int rotateX;
|
||||
int rotateY;
|
||||
int rotateZ;
|
||||
}
|
||||
|
||||
@property NSTimeInterval animationInterval;
|
||||
|
||||
- (void)startAnimation;
|
||||
- (void)stopAnimation;
|
||||
- (void)drawView;
|
||||
|
||||
- (void)setupView;
|
||||
- (void)checkGLError:(BOOL)visibleCheck;
|
||||
|
||||
- (void)setRotationX:(int)X Y:(int)Y Z:(int)Z;
|
||||
- (void)loadTexture;
|
||||
|
||||
@end
|
381
example/WiiMoteOpenGLDemo/Classes/EAGLView.m
Normal file
381
example/WiiMoteOpenGLDemo/Classes/EAGLView.m
Normal file
@ -0,0 +1,381 @@
|
||||
//
|
||||
// EAGLView.m
|
||||
// AppleCoder-OpenGLES-00
|
||||
//
|
||||
// Created by Simon Maurice on 18/03/09.
|
||||
// Copyright Simon Maurice 2009. All rights reserved.
|
||||
//
|
||||
|
||||
|
||||
|
||||
#import <QuartzCore/QuartzCore.h>
|
||||
#import <OpenGLES/EAGLDrawable.h>
|
||||
|
||||
#import "EAGLView.h"
|
||||
#import "WiiMoteOpenGLDemoAppDelegate.h"
|
||||
|
||||
#define USE_DEPTH_BUFFER 1
|
||||
#define DEGREES_TO_RADIANS(__ANGLE) ((__ANGLE) / 180.0 * M_PI)
|
||||
|
||||
// A class extension to declare private methods
|
||||
@interface EAGLView ()
|
||||
|
||||
@property (nonatomic, retain) EAGLContext *context;
|
||||
@property (nonatomic, assign) NSTimer *animationTimer;
|
||||
|
||||
- (BOOL) createFramebuffer;
|
||||
- (void) destroyFramebuffer;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation EAGLView
|
||||
|
||||
@synthesize context;
|
||||
@synthesize animationTimer;
|
||||
@synthesize animationInterval;
|
||||
|
||||
|
||||
// You must implement this method
|
||||
+ (Class)layerClass {
|
||||
return [CAEAGLLayer class];
|
||||
}
|
||||
|
||||
|
||||
//The GL view is stored in the nib file. When it's unarchived it's sent -initWithCoder:
|
||||
- (id)initWithCoder:(NSCoder*)coder {
|
||||
|
||||
if ((self = [super initWithCoder:coder])) {
|
||||
// Get the layer
|
||||
CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer;
|
||||
|
||||
eaglLayer.opaque = YES;
|
||||
eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
[NSNumber numberWithBool:NO], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGBA8,
|
||||
kEAGLDrawablePropertyColorFormat, nil];
|
||||
|
||||
context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1];
|
||||
|
||||
if (!context || ![EAGLContext setCurrentContext:context]) {
|
||||
[self release];
|
||||
return nil;
|
||||
}
|
||||
|
||||
animationInterval = 1.0 / 60.0;
|
||||
rota = 0.0;
|
||||
|
||||
[self setupView];
|
||||
[self loadTexture];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
- (void)drawView {
|
||||
|
||||
// Our new object definition code goes here
|
||||
const GLfloat cubeVertices[] = {
|
||||
|
||||
// Define the front face
|
||||
-0.24415584, 1.0, 0.207792208, // top left
|
||||
-0.24415584, -1.0, 0.207792208, // bottom left
|
||||
0.24415584, -1.0, 0.207792208, // bottom right
|
||||
0.24415584, 1.0, 0.207792208, // top right
|
||||
|
||||
// Top face
|
||||
-0.24415584, 1.0, -0.207792208, // top left (at rear)
|
||||
-0.24415584, 1.0, 0.207792208, // bottom left (at front)
|
||||
0.24415584, 1.0, 0.207792208, // bottom right (at front)
|
||||
0.24415584, 1.0, -0.207792208, // top right (at rear)
|
||||
|
||||
// Rear face
|
||||
0.24415584, 1.0, -0.207792208, // top right (when viewed from front)
|
||||
0.24415584, -1.0, -0.207792208, // bottom right
|
||||
-0.24415584, -1.0, -0.207792208, // bottom left
|
||||
-0.24415584, 1.0, -0.207792208, // top left
|
||||
|
||||
// bottom face
|
||||
-0.24415584, -1.0, 0.207792208,
|
||||
-0.24415584, -1.0, -0.207792208,
|
||||
0.24415584, -1.0, -0.207792208,
|
||||
0.24415584, -1.0, 0.207792208,
|
||||
|
||||
// left face
|
||||
-0.24415584, 1.0, -0.207792208,
|
||||
-0.24415584, 1.0, 0.207792208,
|
||||
-0.24415584, -1.0, 0.207792208,
|
||||
-0.24415584, -1.0, -0.207792208,
|
||||
|
||||
// right face
|
||||
0.24415584, 1.0, 0.207792208,
|
||||
0.24415584, 1.0, -0.207792208,
|
||||
0.24415584, -1.0, -0.207792208,
|
||||
0.24415584, -1.0, 0.207792208
|
||||
};
|
||||
|
||||
const GLfloat squareTextureCoords[] = {
|
||||
|
||||
// Front face - WiiTop
|
||||
0, 0, // top left
|
||||
0, 0.749023438, // bottom left
|
||||
0.18359375, 0.749023438, // bottom right
|
||||
0.18359375, 0, // top right
|
||||
|
||||
// Top face - WiiRear
|
||||
0.25, 1, // top left
|
||||
0.25, 0.844726563, // bottom left
|
||||
0.43359375, 0.844726563, // bottom right
|
||||
0.43359375, 1, // top right
|
||||
|
||||
// Rear face
|
||||
0.25, 0, // bottom right
|
||||
0.25, 0.751953125, // top right
|
||||
0.43359375, 0.751953125, // top left
|
||||
0.43359375, 0, // bottom left
|
||||
|
||||
// Bottom face
|
||||
0, 0.84375, // top left
|
||||
0, 1, // bottom left
|
||||
0.18359375, 1, // bottom right
|
||||
0.18359375, 0.84375, // top right
|
||||
|
||||
// Left face
|
||||
0.5, 0, // bottom left
|
||||
0.6640625, 0, // bottom right
|
||||
0.6640625, 0.751953125, // top right
|
||||
0.5, 0.751953125, // top left
|
||||
|
||||
// Right face
|
||||
0.75, 0, // bottom left
|
||||
0.9140625, 0, // bottom right
|
||||
0.9140625, 0.751953125, // top right
|
||||
0.75, 0.751953125, // top left
|
||||
};
|
||||
|
||||
[EAGLContext setCurrentContext:context];
|
||||
glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);
|
||||
glViewport(0, 0, backingWidth, backingHeight);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
|
||||
// Our new drawing code goes here
|
||||
glLoadIdentity();
|
||||
glTranslatef(0.0, 0.0, -2.0);
|
||||
|
||||
#ifdef USE_BLUETOOTH
|
||||
glRotatef(rotateX, 1.0f, 0.0f, 0.0f);
|
||||
glRotatef(rotateY, 0.0f, 1.0f, 0.0f);
|
||||
glRotatef(rotateZ, 0.0f, 0.0f, 1.0f);
|
||||
#else
|
||||
rota += 1;
|
||||
glRotatef(rota, 0.0, 0.5, 0.0);
|
||||
glRotatef(rota, 0.0, 0.0, 1.0);
|
||||
#endif
|
||||
glVertexPointer(3, GL_FLOAT, 0, cubeVertices);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
glTexCoordPointer(2, GL_FLOAT, 0, squareTextureCoords);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
|
||||
glColor4f(1.0, 1.0, 1.0, 1.0);
|
||||
|
||||
// Draw the front face in Red
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
|
||||
// Draw the top face in green
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 4, 4);
|
||||
|
||||
// Draw the rear face in Blue
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 8, 4);
|
||||
|
||||
// Draw the bottom face
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 12, 4);
|
||||
|
||||
// Draw the left face
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 16, 4);
|
||||
|
||||
// Draw the right face
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 20, 4);
|
||||
|
||||
|
||||
glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
|
||||
[context presentRenderbuffer:GL_RENDERBUFFER_OES];
|
||||
[self checkGLError:NO];
|
||||
}
|
||||
|
||||
- (void)layoutSubviews {
|
||||
[EAGLContext setCurrentContext:context];
|
||||
[self destroyFramebuffer];
|
||||
[self createFramebuffer];
|
||||
[self drawView];
|
||||
}
|
||||
|
||||
|
||||
- (BOOL)createFramebuffer {
|
||||
|
||||
glGenFramebuffersOES(1, &viewFramebuffer);
|
||||
glGenRenderbuffersOES(1, &viewRenderbuffer);
|
||||
|
||||
glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);
|
||||
glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
|
||||
[context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(CAEAGLLayer*)self.layer];
|
||||
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, viewRenderbuffer);
|
||||
|
||||
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth);
|
||||
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight);
|
||||
|
||||
if (USE_DEPTH_BUFFER) {
|
||||
glGenRenderbuffersOES(1, &depthRenderbuffer);
|
||||
glBindRenderbufferOES(GL_RENDERBUFFER_OES, depthRenderbuffer);
|
||||
glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_DEPTH_COMPONENT16_OES, backingWidth, backingHeight);
|
||||
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, depthRenderbuffer);
|
||||
}
|
||||
|
||||
if(glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) {
|
||||
NSLog(@"failed to make complete framebuffer object %x", glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES));
|
||||
return NO;
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)setupView {
|
||||
|
||||
const GLfloat zNear = 0.1, zFar = 1000.0, fieldOfView = 60.0;
|
||||
GLfloat size;
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
size = zNear * tanf(DEGREES_TO_RADIANS(fieldOfView) / 2.0);
|
||||
|
||||
// This give us the size of the iPhone display
|
||||
CGRect rect = self.bounds;
|
||||
glFrustumf(-size, size, -size / (rect.size.width / rect.size.height), size / (rect.size.width / rect.size.height), zNear, zFar);
|
||||
glViewport(0, 0, rect.size.width, rect.size.height);
|
||||
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
- (void)loadTexture {
|
||||
CGImageRef textureImage = [UIImage imageNamed:@"wiimote_texture.png"].CGImage;
|
||||
if (textureImage == nil) {
|
||||
NSLog(@"Failed to load texture image");
|
||||
return;
|
||||
}
|
||||
|
||||
NSInteger texWidth = CGImageGetWidth(textureImage);
|
||||
NSInteger texHeight = CGImageGetHeight(textureImage);
|
||||
|
||||
GLubyte *textureData = (GLubyte *)malloc(texWidth * texHeight * 4);
|
||||
|
||||
CGContextRef textureContext = CGBitmapContextCreate(textureData,
|
||||
texWidth, texHeight,
|
||||
8, texWidth * 4,
|
||||
CGImageGetColorSpace(textureImage),
|
||||
kCGImageAlphaPremultipliedLast);
|
||||
CGContextDrawImage(textureContext, CGRectMake(0.0, 0.0, (float)texWidth, (float)texHeight), textureImage);
|
||||
CGContextRelease(textureContext);
|
||||
|
||||
glGenTextures(1, &textures[0]);
|
||||
glBindTexture(GL_TEXTURE_2D, textures[0]);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureData);
|
||||
|
||||
free(textureData);
|
||||
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
- (void)destroyFramebuffer {
|
||||
|
||||
glDeleteFramebuffersOES(1, &viewFramebuffer);
|
||||
viewFramebuffer = 0;
|
||||
glDeleteRenderbuffersOES(1, &viewRenderbuffer);
|
||||
viewRenderbuffer = 0;
|
||||
|
||||
if(depthRenderbuffer) {
|
||||
glDeleteRenderbuffersOES(1, &depthRenderbuffer);
|
||||
depthRenderbuffer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (void)startAnimation {
|
||||
self.animationTimer = [NSTimer scheduledTimerWithTimeInterval:animationInterval target:self selector:@selector(drawView) userInfo:nil repeats:YES];
|
||||
}
|
||||
|
||||
|
||||
- (void)stopAnimation {
|
||||
self.animationTimer = nil;
|
||||
}
|
||||
|
||||
|
||||
- (void)setAnimationTimer:(NSTimer *)newTimer {
|
||||
[animationTimer invalidate];
|
||||
animationTimer = newTimer;
|
||||
}
|
||||
|
||||
|
||||
- (void)setAnimationInterval:(NSTimeInterval)interval {
|
||||
|
||||
animationInterval = interval;
|
||||
if (animationTimer) {
|
||||
[self stopAnimation];
|
||||
[self startAnimation];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)checkGLError:(BOOL)visibleCheck {
|
||||
GLenum error = glGetError();
|
||||
|
||||
switch (error) {
|
||||
case GL_INVALID_ENUM:
|
||||
NSLog(@"GL Error: Enum argument is out of range");
|
||||
break;
|
||||
case GL_INVALID_VALUE:
|
||||
NSLog(@"GL Error: Numeric value is out of range");
|
||||
break;
|
||||
case GL_INVALID_OPERATION:
|
||||
NSLog(@"GL Error: Operation illegal in current state");
|
||||
break;
|
||||
case GL_STACK_OVERFLOW:
|
||||
NSLog(@"GL Error: Command would cause a stack overflow");
|
||||
break;
|
||||
case GL_STACK_UNDERFLOW:
|
||||
NSLog(@"GL Error: Command would cause a stack underflow");
|
||||
break;
|
||||
case GL_OUT_OF_MEMORY:
|
||||
NSLog(@"GL Error: Not enough memory to execute command");
|
||||
break;
|
||||
case GL_NO_ERROR:
|
||||
if (visibleCheck) {
|
||||
NSLog(@"No GL Error");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
NSLog(@"Unknown GL Error");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (void)setRotationX:(int)x Y:(int)y Z:(int)z{
|
||||
// NSLog(@"BT data: %u %u %u", x , y ,z);
|
||||
rotateX = x;
|
||||
rotateY = y;
|
||||
rotateZ = z;
|
||||
}
|
||||
- (void)dealloc {
|
||||
|
||||
[self stopAnimation];
|
||||
|
||||
if ([EAGLContext currentContext] == context) {
|
||||
[EAGLContext setCurrentContext:nil];
|
||||
}
|
||||
|
||||
[context release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
@end
|
@ -0,0 +1,24 @@
|
||||
//
|
||||
// WiiMoteOpenGLDemoAppDelegate.h
|
||||
//
|
||||
// Created by Matthias Ringwald on 8/2/09.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#define USE_BLUETOOTH
|
||||
|
||||
@class EAGLView;
|
||||
|
||||
@interface WiiMoteOpenGLDemoAppDelegate : NSObject <UIApplicationDelegate> {
|
||||
UIWindow *window;
|
||||
EAGLView *glView;
|
||||
UILabel *status;
|
||||
}
|
||||
|
||||
@property (nonatomic, retain) IBOutlet UIWindow *window;
|
||||
@property (nonatomic, retain) IBOutlet EAGLView *glView;
|
||||
@property (nonatomic, retain) IBOutlet UILabel *status;
|
||||
|
||||
@end
|
||||
|
@ -0,0 +1,93 @@
|
||||
//
|
||||
// WiiMoteOpenGLDemoAppDelegate.m
|
||||
//
|
||||
// Created by Matthias Ringwald on 8/2/09.
|
||||
//
|
||||
|
||||
#import "WiiMoteOpenGLDemoAppDelegate.h"
|
||||
#import "EAGLView.h"
|
||||
#include "../BTWiiMote.h"
|
||||
|
||||
WiiMoteOpenGLDemoAppDelegate * theMainApp;
|
||||
|
||||
@implementation WiiMoteOpenGLDemoAppDelegate
|
||||
|
||||
@synthesize window;
|
||||
@synthesize glView;
|
||||
@synthesize status;
|
||||
|
||||
static void bt_state_cb(char *text){
|
||||
NSLog(@"BT state: %s", text);
|
||||
NSString *stringFromUTFString = [[NSString alloc] initWithUTF8String:text];
|
||||
[[theMainApp status] setText:stringFromUTFString];
|
||||
}
|
||||
|
||||
static void bt_data_cb(uint8_t x, uint8_t y, uint8_t z){
|
||||
// NSLog(@"BT data: %u %u %u", x , y ,z);
|
||||
// [[theMainApp status] setText:[NSString stringWithFormat:@"X:%03u Y:%03u Z:%03u", x, y, z]];
|
||||
float ax = x - 128;
|
||||
float ay = y - 128;
|
||||
float az = z - 128;
|
||||
int roll = atan2(ax, sqrt(ay*ay+az*az)) * 180 / M_PI;
|
||||
int pitch = atan2(ay, sqrt(ax*ax+az*az)) * 180 / M_PI;
|
||||
|
||||
|
||||
#if 1
|
||||
// moving average of size SIZE
|
||||
#define SIZE 5
|
||||
static int pos = 0;
|
||||
static int historyRoll[SIZE];
|
||||
static int historyPitch[SIZE];
|
||||
|
||||
historyRoll[pos] = roll;
|
||||
historyPitch[pos] = pitch;
|
||||
pos++;
|
||||
if (pos==SIZE) pos = 0;
|
||||
|
||||
pitch = roll = 0;
|
||||
int i;
|
||||
for (i=0;i<SIZE;i++){
|
||||
roll += historyRoll[i];
|
||||
pitch += historyPitch[i];
|
||||
}
|
||||
roll = roll / SIZE;
|
||||
pitch = pitch / SIZE;
|
||||
#endif
|
||||
// pitch += 90;
|
||||
[[theMainApp glView] setRotationX:-pitch Y:roll Z:0];
|
||||
}
|
||||
|
||||
- (void)applicationDidFinishLaunching:(UIApplication *)application {
|
||||
|
||||
[status setText:@"This is my text"];
|
||||
|
||||
theMainApp = self;
|
||||
|
||||
#ifdef USE_BLUETOOTH
|
||||
set_bt_state_cb(bt_state_cb);
|
||||
set_data_cb(bt_data_cb);
|
||||
start_bt();
|
||||
#endif
|
||||
|
||||
glView.animationInterval = 1.0 / 60.0;
|
||||
[glView startAnimation];
|
||||
}
|
||||
|
||||
|
||||
- (void)applicationWillResignActive:(UIApplication *)application {
|
||||
glView.animationInterval = 1.0 / 5.0;
|
||||
}
|
||||
|
||||
|
||||
- (void)applicationDidBecomeActive:(UIApplication *)application {
|
||||
glView.animationInterval = 1.0 / 60.0;
|
||||
}
|
||||
|
||||
|
||||
- (void)dealloc {
|
||||
[window release];
|
||||
[glView release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
@end
|
30
example/WiiMoteOpenGLDemo/Info.plist
Normal file
30
example/WiiMoteOpenGLDemo/Info.plist
Normal file
@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>${PRODUCT_NAME}</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${EXECUTABLE_NAME}</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string></string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.yourcompany.${PRODUCT_NAME:identifier}</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>${PRODUCT_NAME}</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.0</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>NSMainNibFile</key>
|
||||
<string>MainWindow</string>
|
||||
</dict>
|
||||
</plist>
|
267
example/WiiMoteOpenGLDemo/MainWindow.xib
Normal file
267
example/WiiMoteOpenGLDemo/MainWindow.xib
Normal file
@ -0,0 +1,267 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="7.03">
|
||||
<data>
|
||||
<int key="IBDocument.SystemTarget">528</int>
|
||||
<string key="IBDocument.SystemVersion">9J61</string>
|
||||
<string key="IBDocument.InterfaceBuilderVersion">677</string>
|
||||
<string key="IBDocument.AppKitVersion">949.46</string>
|
||||
<string key="IBDocument.HIToolboxVersion">353.00</string>
|
||||
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<integer value="2"/>
|
||||
</object>
|
||||
<object class="NSArray" key="IBDocument.PluginDependencies">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
</object>
|
||||
<object class="NSMutableDictionary" key="IBDocument.Metadata">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="NSArray" key="dict.sortedKeys">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
</object>
|
||||
<object class="NSMutableArray" key="dict.values">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
</object>
|
||||
</object>
|
||||
<object class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="IBProxyObject" id="841351856">
|
||||
<string key="IBProxiedObjectIdentifier">IBFilesOwner</string>
|
||||
</object>
|
||||
<object class="IBProxyObject" id="191355593">
|
||||
<string key="IBProxiedObjectIdentifier">IBFirstResponder</string>
|
||||
</object>
|
||||
<object class="IBUICustomObject" id="664661524"/>
|
||||
<object class="IBUIWindow" id="380026005">
|
||||
<reference key="NSNextResponder"/>
|
||||
<int key="NSvFlags">1316</int>
|
||||
<object class="NSMutableArray" key="NSSubviews">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="IBUIView" id="773737154">
|
||||
<reference key="NSNextResponder" ref="380026005"/>
|
||||
<int key="NSvFlags">1298</int>
|
||||
<string key="NSFrameSize">{320, 450}</string>
|
||||
<reference key="NSSuperview" ref="380026005"/>
|
||||
<object class="NSColor" key="IBUIBackgroundColor">
|
||||
<int key="NSColorSpace">3</int>
|
||||
<bytes key="NSWhite">MQA</bytes>
|
||||
<object class="NSColorSpace" key="NSCustomColorSpace">
|
||||
<int key="NSID">2</int>
|
||||
</object>
|
||||
</object>
|
||||
<bool key="IBUIClearsContextBeforeDrawing">NO</bool>
|
||||
</object>
|
||||
<object class="IBUILabel" id="1044936219">
|
||||
<reference key="NSNextResponder" ref="380026005"/>
|
||||
<int key="NSvFlags">1316</int>
|
||||
<string key="NSFrame">{{20, 453}, {300, 21}}</string>
|
||||
<reference key="NSSuperview" ref="380026005"/>
|
||||
<bool key="IBUIOpaque">NO</bool>
|
||||
<bool key="IBUIClipsSubviews">YES</bool>
|
||||
<bool key="IBUIUserInteractionEnabled">NO</bool>
|
||||
<string key="IBUIText">Bluetooth starting up</string>
|
||||
<object class="NSColor" key="IBUITextColor">
|
||||
<int key="NSColorSpace">1</int>
|
||||
<bytes key="NSRGB">MC45OTQ1NjUxOSAwLjk5NDU2NTE5IDAuOTk0NTY1MTkAA</bytes>
|
||||
</object>
|
||||
<nil key="IBUIHighlightedColor"/>
|
||||
<int key="IBUIBaselineAdjustment">1</int>
|
||||
<float key="IBUIMinimumFontSize">1.000000e+01</float>
|
||||
</object>
|
||||
</object>
|
||||
<object class="NSPSMatrix" key="NSFrameMatrix"/>
|
||||
<string key="NSFrameSize">{320, 480}</string>
|
||||
<reference key="NSSuperview"/>
|
||||
<object class="NSColor" key="IBUIBackgroundColor">
|
||||
<int key="NSColorSpace">1</int>
|
||||
<bytes key="NSRGB">MCAwIDAAA</bytes>
|
||||
</object>
|
||||
<bool key="IBUIClearsContextBeforeDrawing">NO</bool>
|
||||
<bool key="IBUIVisibleAtLaunch">YES</bool>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBObjectContainer" key="IBDocument.Objects">
|
||||
<object class="NSMutableArray" key="connectionRecords">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBCocoaTouchOutletConnection" key="connection">
|
||||
<string key="label">delegate</string>
|
||||
<reference key="source" ref="841351856"/>
|
||||
<reference key="destination" ref="664661524"/>
|
||||
</object>
|
||||
<int key="connectionID">4</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBCocoaTouchOutletConnection" key="connection">
|
||||
<string key="label">window</string>
|
||||
<reference key="source" ref="664661524"/>
|
||||
<reference key="destination" ref="380026005"/>
|
||||
</object>
|
||||
<int key="connectionID">5</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBCocoaTouchOutletConnection" key="connection">
|
||||
<string key="label">glView</string>
|
||||
<reference key="source" ref="664661524"/>
|
||||
<reference key="destination" ref="773737154"/>
|
||||
</object>
|
||||
<int key="connectionID">9</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBCocoaTouchOutletConnection" key="connection">
|
||||
<string key="label">status</string>
|
||||
<reference key="source" ref="664661524"/>
|
||||
<reference key="destination" ref="1044936219"/>
|
||||
</object>
|
||||
<int key="connectionID">11</int>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBMutableOrderedSet" key="objectRecords">
|
||||
<object class="NSArray" key="orderedObjects">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">0</int>
|
||||
<object class="NSArray" key="object" id="957960031">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
</object>
|
||||
<reference key="children" ref="1000"/>
|
||||
<nil key="parent"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">2</int>
|
||||
<reference key="object" ref="380026005"/>
|
||||
<object class="NSMutableArray" key="children">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<reference ref="773737154"/>
|
||||
<reference ref="1044936219"/>
|
||||
</object>
|
||||
<reference key="parent" ref="957960031"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">-1</int>
|
||||
<reference key="object" ref="841351856"/>
|
||||
<reference key="parent" ref="957960031"/>
|
||||
<string type="base64-UTF8" key="objectName">RmlsZSdzIE93bmVyA</string>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">3</int>
|
||||
<reference key="object" ref="664661524"/>
|
||||
<reference key="parent" ref="957960031"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">8</int>
|
||||
<reference key="object" ref="773737154"/>
|
||||
<reference key="parent" ref="380026005"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">-2</int>
|
||||
<reference key="object" ref="191355593"/>
|
||||
<reference key="parent" ref="957960031"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">10</int>
|
||||
<reference key="object" ref="1044936219"/>
|
||||
<reference key="parent" ref="380026005"/>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<object class="NSMutableDictionary" key="flattenedProperties">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="NSMutableArray" key="dict.sortedKeys">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>-1.CustomClassName</string>
|
||||
<string>-2.CustomClassName</string>
|
||||
<string>10.IBPluginDependency</string>
|
||||
<string>2.IBAttributePlaceholdersKey</string>
|
||||
<string>2.IBEditorWindowLastContentRect</string>
|
||||
<string>2.IBPluginDependency</string>
|
||||
<string>3.CustomClassName</string>
|
||||
<string>3.IBPluginDependency</string>
|
||||
<string>8.CustomClassName</string>
|
||||
<string>8.IBPluginDependency</string>
|
||||
</object>
|
||||
<object class="NSMutableArray" key="dict.values">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>UIApplication</string>
|
||||
<string>UIResponder</string>
|
||||
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<object class="NSMutableDictionary">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="NSArray" key="dict.sortedKeys">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
</object>
|
||||
<object class="NSMutableArray" key="dict.values">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
</object>
|
||||
</object>
|
||||
<string>{{85, 244}, {320, 480}}</string>
|
||||
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string>WiiMoteOpenGLDemoAppDelegate</string>
|
||||
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string>EAGLView</string>
|
||||
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
</object>
|
||||
</object>
|
||||
<object class="NSMutableDictionary" key="unlocalizedProperties">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="NSArray" key="dict.sortedKeys">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
</object>
|
||||
<object class="NSMutableArray" key="dict.values">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
</object>
|
||||
</object>
|
||||
<nil key="activeLocalization"/>
|
||||
<object class="NSMutableDictionary" key="localizations">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="NSArray" key="dict.sortedKeys">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
</object>
|
||||
<object class="NSMutableArray" key="dict.values">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
</object>
|
||||
</object>
|
||||
<nil key="sourceID"/>
|
||||
<int key="maxID">11</int>
|
||||
</object>
|
||||
<object class="IBClassDescriber" key="IBDocument.Classes">
|
||||
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="IBPartialClassDescription">
|
||||
<string key="className">EAGLView</string>
|
||||
<string key="superclassName">UIView</string>
|
||||
<object class="IBClassDescriptionSource" key="sourceIdentifier">
|
||||
<string key="majorKey">IBProjectSource</string>
|
||||
<string key="minorKey">Classes/EAGLView.h</string>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBPartialClassDescription">
|
||||
<string key="className">WiiMoteOpenGLDemoAppDelegate</string>
|
||||
<string key="superclassName">NSObject</string>
|
||||
<object class="NSMutableDictionary" key="outlets">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="NSMutableArray" key="dict.sortedKeys">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>glView</string>
|
||||
<string>status</string>
|
||||
<string>window</string>
|
||||
</object>
|
||||
<object class="NSMutableArray" key="dict.values">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>EAGLView</string>
|
||||
<string>UILabel</string>
|
||||
<string>UIWindow</string>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBClassDescriptionSource" key="sourceIdentifier">
|
||||
<string key="majorKey">IBProjectSource</string>
|
||||
<string key="minorKey">Classes/WiiMoteOpenGLDemoAppDelegate.h</string>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<int key="IBDocument.localizationMode">0</int>
|
||||
<string key="IBDocument.LastKnownRelativeProjectPath">WiiMoteOpenGLDemo.xcodeproj</string>
|
||||
<int key="IBDocument.defaultPropertyAccessControl">3</int>
|
||||
</data>
|
||||
</archive>
|
319
example/WiiMoteOpenGLDemo/WiiMoteOpenGLDemo.xcodeproj/project.pbxproj
Executable file
319
example/WiiMoteOpenGLDemo/WiiMoteOpenGLDemo.xcodeproj/project.pbxproj
Executable file
@ -0,0 +1,319 @@
|
||||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 45;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
1D3623260D0F684500981E51 /* WiiMoteOpenGLDemoAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D3623250D0F684500981E51 /* WiiMoteOpenGLDemoAppDelegate.m */; };
|
||||
1D60589B0D05DD56006BFB54 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; };
|
||||
1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; };
|
||||
1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; };
|
||||
28AD733F0D9D9553002E5188 /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 28AD733E0D9D9553002E5188 /* MainWindow.xib */; };
|
||||
28FD15000DC6FC520079059D /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 28FD14FF0DC6FC520079059D /* OpenGLES.framework */; };
|
||||
28FD15080DC6FC5B0079059D /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 28FD15070DC6FC5B0079059D /* QuartzCore.framework */; };
|
||||
9C180042108B95B000824BE7 /* libBTstack.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 9C180041108B95B000824BE7 /* libBTstack.dylib */; };
|
||||
9C6BB62E1027911E00A0BCB0 /* wiimote_texture.png in Resources */ = {isa = PBXBuildFile; fileRef = 9C6BB62D1027911E00A0BCB0 /* wiimote_texture.png */; };
|
||||
9CB96E9810278945002663D0 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9CB96E9710278945002663D0 /* CoreGraphics.framework */; };
|
||||
9CB96EEF10278D8D002663D0 /* EAGLView.m in Sources */ = {isa = PBXBuildFile; fileRef = 28FD14FD0DC6FC130079059D /* EAGLView.m */; };
|
||||
9CCE6DDA1025E18700FCE9F4 /* BTWiiMote.c in Sources */ = {isa = PBXBuildFile; fileRef = 9CCE6DD91025E18700FCE9F4 /* BTWiiMote.c */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
1D30AB110D05D00D00671497 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
|
||||
1D3623240D0F684500981E51 /* WiiMoteOpenGLDemoAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WiiMoteOpenGLDemoAppDelegate.h; sourceTree = "<group>"; };
|
||||
1D3623250D0F684500981E51 /* WiiMoteOpenGLDemoAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WiiMoteOpenGLDemoAppDelegate.m; sourceTree = "<group>"; };
|
||||
1D6058910D05DD3D006BFB54 /* WiiMoteOpenGLDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = WiiMoteOpenGLDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
1DF5F4DF0D08C38300B7A737 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
|
||||
28AD733E0D9D9553002E5188 /* MainWindow.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MainWindow.xib; sourceTree = "<group>"; };
|
||||
28FD14FC0DC6FC130079059D /* EAGLView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EAGLView.h; sourceTree = "<group>"; };
|
||||
28FD14FD0DC6FC130079059D /* EAGLView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EAGLView.m; sourceTree = "<group>"; };
|
||||
28FD14FF0DC6FC520079059D /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; };
|
||||
28FD15070DC6FC5B0079059D /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
|
||||
29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
|
||||
32CA4F630368D1EE00C91783 /* WiiMoteOpenGLDemo_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WiiMoteOpenGLDemo_Prefix.pch; sourceTree = "<group>"; };
|
||||
8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
9C18001B108B94FB00824BE7 /* btstack.h */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.h; path = btstack.h; sourceTree = "<group>"; };
|
||||
9C18001C108B94FB00824BE7 /* hci_cmds.h */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.h; path = hci_cmds.h; sourceTree = "<group>"; };
|
||||
9C18001D108B94FB00824BE7 /* linked_list.h */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.h; path = linked_list.h; sourceTree = "<group>"; };
|
||||
9C18001E108B94FB00824BE7 /* run_loop.h */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.h; path = run_loop.h; sourceTree = "<group>"; };
|
||||
9C18001F108B94FB00824BE7 /* utils.h */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.h; path = utils.h; sourceTree = "<group>"; };
|
||||
9C180041108B95B000824BE7 /* libBTstack.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libBTstack.dylib; path = ../../src/libBTstack.dylib; sourceTree = SOURCE_ROOT; };
|
||||
9C6BB62D1027911E00A0BCB0 /* wiimote_texture.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = wiimote_texture.png; sourceTree = "<group>"; };
|
||||
9CB96E9710278945002663D0 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
|
||||
9CCE6DD91025E18700FCE9F4 /* BTWiiMote.c */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.c; path = BTWiiMote.c; sourceTree = "<group>"; };
|
||||
9CCE6DDB1025E19600FCE9F4 /* BTWiiMote.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BTWiiMote.h; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
1D60588F0D05DD3D006BFB54 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */,
|
||||
1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */,
|
||||
28FD15000DC6FC520079059D /* OpenGLES.framework in Frameworks */,
|
||||
28FD15080DC6FC5B0079059D /* QuartzCore.framework in Frameworks */,
|
||||
9CB96E9810278945002663D0 /* CoreGraphics.framework in Frameworks */,
|
||||
9C180042108B95B000824BE7 /* libBTstack.dylib in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
080E96DDFE201D6D7F000001 /* Classes */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
28FD14FC0DC6FC130079059D /* EAGLView.h */,
|
||||
28FD14FD0DC6FC130079059D /* EAGLView.m */,
|
||||
1D3623240D0F684500981E51 /* WiiMoteOpenGLDemoAppDelegate.h */,
|
||||
1D3623250D0F684500981E51 /* WiiMoteOpenGLDemoAppDelegate.m */,
|
||||
);
|
||||
path = Classes;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
19C28FACFE9D520D11CA2CBB /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
1D6058910D05DD3D006BFB54 /* WiiMoteOpenGLDemo.app */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
29B97314FDCFA39411CA2CEA /* CustomTemplate */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
9C180041108B95B000824BE7 /* libBTstack.dylib */,
|
||||
9C18001A108B94FB00824BE7 /* btstack */,
|
||||
9CCE6DC71025E0A600FCE9F4 /* BTstack */,
|
||||
080E96DDFE201D6D7F000001 /* Classes */,
|
||||
29B97315FDCFA39411CA2CEA /* Other Sources */,
|
||||
29B97317FDCFA39411CA2CEA /* Resources */,
|
||||
29B97323FDCFA39411CA2CEA /* Frameworks */,
|
||||
19C28FACFE9D520D11CA2CBB /* Products */,
|
||||
);
|
||||
name = CustomTemplate;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
29B97315FDCFA39411CA2CEA /* Other Sources */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
32CA4F630368D1EE00C91783 /* WiiMoteOpenGLDemo_Prefix.pch */,
|
||||
29B97316FDCFA39411CA2CEA /* main.m */,
|
||||
);
|
||||
name = "Other Sources";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
29B97317FDCFA39411CA2CEA /* Resources */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
9C6BB62D1027911E00A0BCB0 /* wiimote_texture.png */,
|
||||
28AD733E0D9D9553002E5188 /* MainWindow.xib */,
|
||||
8D1107310486CEB800E47090 /* Info.plist */,
|
||||
);
|
||||
name = Resources;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
29B97323FDCFA39411CA2CEA /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
9CB96E9710278945002663D0 /* CoreGraphics.framework */,
|
||||
28FD15070DC6FC5B0079059D /* QuartzCore.framework */,
|
||||
28FD14FF0DC6FC520079059D /* OpenGLES.framework */,
|
||||
1DF5F4DF0D08C38300B7A737 /* UIKit.framework */,
|
||||
1D30AB110D05D00D00671497 /* Foundation.framework */,
|
||||
);
|
||||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
9C18001A108B94FB00824BE7 /* btstack */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
9C18001B108B94FB00824BE7 /* btstack.h */,
|
||||
9C18001C108B94FB00824BE7 /* hci_cmds.h */,
|
||||
9C18001D108B94FB00824BE7 /* linked_list.h */,
|
||||
9C18001E108B94FB00824BE7 /* run_loop.h */,
|
||||
9C18001F108B94FB00824BE7 /* utils.h */,
|
||||
);
|
||||
name = btstack;
|
||||
path = ../../include/btstack;
|
||||
sourceTree = SOURCE_ROOT;
|
||||
};
|
||||
9CCE6DC71025E0A600FCE9F4 /* BTstack */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
9CCE6DD91025E18700FCE9F4 /* BTWiiMote.c */,
|
||||
9CCE6DDB1025E19600FCE9F4 /* BTWiiMote.h */,
|
||||
);
|
||||
name = BTstack;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
1D6058900D05DD3D006BFB54 /* WiiMoteOpenGLDemo */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "WiiMoteOpenGLDemo" */;
|
||||
buildPhases = (
|
||||
1D60588D0D05DD3D006BFB54 /* Resources */,
|
||||
1D60588E0D05DD3D006BFB54 /* Sources */,
|
||||
1D60588F0D05DD3D006BFB54 /* Frameworks */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = WiiMoteOpenGLDemo;
|
||||
productName = WiiMoteOpenGLDemo;
|
||||
productReference = 1D6058910D05DD3D006BFB54 /* WiiMoteOpenGLDemo.app */;
|
||||
productType = "com.apple.product-type.application";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
29B97313FDCFA39411CA2CEA /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "WiiMoteOpenGLDemo" */;
|
||||
compatibilityVersion = "Xcode 3.1";
|
||||
hasScannedForEncodings = 1;
|
||||
mainGroup = 29B97314FDCFA39411CA2CEA /* CustomTemplate */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
1D6058900D05DD3D006BFB54 /* WiiMoteOpenGLDemo */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXResourcesBuildPhase section */
|
||||
1D60588D0D05DD3D006BFB54 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
28AD733F0D9D9553002E5188 /* MainWindow.xib in Resources */,
|
||||
9C6BB62E1027911E00A0BCB0 /* wiimote_texture.png in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
1D60588E0D05DD3D006BFB54 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
1D60589B0D05DD56006BFB54 /* main.m in Sources */,
|
||||
1D3623260D0F684500981E51 /* WiiMoteOpenGLDemoAppDelegate.m in Sources */,
|
||||
9CCE6DDA1025E18700FCE9F4 /* BTWiiMote.c in Sources */,
|
||||
9CB96EEF10278D8D002663D0 /* EAGLView.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
1D6058940D05DD3E006BFB54 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"\"$(DEVELOPER_DIR)-SDK3.0-final/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.2.1.sdk/System/Library/Frameworks\"",
|
||||
);
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = WiiMoteOpenGLDemo_Prefix.pch;
|
||||
INFOPLIST_FILE = Info.plist;
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"\"$(SRCROOT)/../btstack/src\"",
|
||||
"\"$(SRCROOT)/../../src\"",
|
||||
);
|
||||
PRODUCT_NAME = WiiMoteOpenGLDemo;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
1D6058950D05DD3E006BFB54 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
COPY_PHASE_STRIP = YES;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"\"$(DEVELOPER_DIR)-SDK3.0-final/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.2.1.sdk/System/Library/Frameworks\"",
|
||||
);
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = WiiMoteOpenGLDemo_Prefix.pch;
|
||||
INFOPLIST_FILE = Info.plist;
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"\"$(SRCROOT)/../btstack/src\"",
|
||||
"\"$(SRCROOT)/../../src\"",
|
||||
);
|
||||
PRODUCT_NAME = WiiMoteOpenGLDemo;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
C01FCF4F08A954540054247B /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "Don't Code Sign";
|
||||
GCC_C_LANGUAGE_STANDARD = c99;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
OTHER_CFLAGS = "-I/Projects/iPhone/btstack/include";
|
||||
OTHER_CPLUSPLUSFLAGS = "";
|
||||
PREBINDING = NO;
|
||||
SDKROOT = iphoneos2.0;
|
||||
USER_HEADER_SEARCH_PATHS = "";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
C01FCF5008A954540054247B /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "Don't Code Sign";
|
||||
GCC_C_LANGUAGE_STANDARD = c99;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
OTHER_CFLAGS = "-I/Projects/iPhone/btstack/include";
|
||||
OTHER_CPLUSPLUSFLAGS = "";
|
||||
PREBINDING = NO;
|
||||
SDKROOT = iphoneos2.0;
|
||||
USER_HEADER_SEARCH_PATHS = "";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "WiiMoteOpenGLDemo" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
1D6058940D05DD3E006BFB54 /* Debug */,
|
||||
1D6058950D05DD3E006BFB54 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
C01FCF4E08A954540054247B /* Build configuration list for PBXProject "WiiMoteOpenGLDemo" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
C01FCF4F08A954540054247B /* Debug */,
|
||||
C01FCF5008A954540054247B /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = 29B97313FDCFA39411CA2CEA /* Project object */;
|
||||
}
|
8
example/WiiMoteOpenGLDemo/WiiMoteOpenGLDemo_Prefix.pch
Normal file
8
example/WiiMoteOpenGLDemo/WiiMoteOpenGLDemo_Prefix.pch
Normal file
@ -0,0 +1,8 @@
|
||||
//
|
||||
// Prefix header for all source files of the 'WiiMoteOpenGLDemo' target in the 'WiiMoteOpenGLDemo' project
|
||||
//
|
||||
|
||||
#ifdef __OBJC__
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
#endif
|
16
example/WiiMoteOpenGLDemo/main.m
Normal file
16
example/WiiMoteOpenGLDemo/main.m
Normal file
@ -0,0 +1,16 @@
|
||||
//
|
||||
// main.m
|
||||
// WiiMoteOpenGLDemo
|
||||
//
|
||||
// Created by Matthias Ringwald on 8/2/09.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
|
||||
int retVal = UIApplicationMain(argc, argv, nil, nil);
|
||||
[pool release];
|
||||
return retVal;
|
||||
}
|
7
example/WiiMoteOpenGLDemo/wiimote_coords.txt
Normal file
7
example/WiiMoteOpenGLDemo/wiimote_coords.txt
Normal file
@ -0,0 +1,7 @@
|
||||
Top 0 0 188 767
|
||||
Bottom 256 0 444 770
|
||||
Left 512 0 680 770
|
||||
Rigth 768 0 936 770
|
||||
Front 0 864 188 1024
|
||||
Rear 256 865 444 1024
|
||||
|
BIN
example/WiiMoteOpenGLDemo/wiimote_texture.png
Normal file
BIN
example/WiiMoteOpenGLDemo/wiimote_texture.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 188 KiB |
Loading…
x
Reference in New Issue
Block a user