| [9780] | 1 | /* |
|---|
| 2 | * io_mac.h |
|---|
| 3 | * |
|---|
| 4 | * Written By: |
|---|
| 5 | * Gabriele Randelli |
|---|
| 6 | * Email: < randelli (--AT--) dis [--DOT--] uniroma1 [--DOT--] it > |
|---|
| 7 | * |
|---|
| 8 | * Copyright 2010 |
|---|
| 9 | * |
|---|
| 10 | * This file is part of wiiC. |
|---|
| 11 | * |
|---|
| 12 | * This program is free software; you can redistribute it and/or modify |
|---|
| 13 | * it under the terms of the GNU General Public License as published by |
|---|
| 14 | * the Free Software Foundation; either version 3 of the License, or |
|---|
| 15 | * (at your option) any later version. |
|---|
| 16 | * |
|---|
| 17 | * This program is distributed in the hope that it will be useful, |
|---|
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 20 | * GNU General Public License for more details. |
|---|
| 21 | * |
|---|
| 22 | * You should have received a copy of the GNU General Public License |
|---|
| 23 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
|---|
| 24 | * |
|---|
| 25 | * $Header$ |
|---|
| 26 | * |
|---|
| 27 | */ |
|---|
| 28 | |
|---|
| 29 | /** |
|---|
| 30 | * @file |
|---|
| 31 | * @brief I/O header file for MacOS. |
|---|
| 32 | */ |
|---|
| 33 | #ifndef IO_MAC_H |
|---|
| 34 | #define IO_MAC_H |
|---|
| 35 | |
|---|
| 36 | #import <stdio.h> |
|---|
| 37 | #import <stdlib.h> |
|---|
| 38 | #import <unistd.h> |
|---|
| 39 | |
|---|
| 40 | #define BLUETOOTH_VERSION_USE_CURRENT |
|---|
| 41 | |
|---|
| 42 | #import <arpa/inet.h> /* htons() */ |
|---|
| 43 | #import <IOBluetooth/IOBluetoothUtilities.h> |
|---|
| 44 | #import <IOBluetooth/objc/IOBluetoothDevice.h> |
|---|
| 45 | #import <IOBluetooth/objc/IOBluetoothHostController.h> |
|---|
| 46 | #import <IOBluetooth/objc/IOBluetoothDeviceInquiry.h> |
|---|
| 47 | #import <IOBluetooth/objc/IOBluetoothL2CAPChannel.h> |
|---|
| 48 | |
|---|
| 49 | #import "wiic_internal.h" |
|---|
| 50 | #import "io.h" |
|---|
| 51 | |
|---|
| 52 | @interface WiiSearch : NSObject |
|---|
| 53 | { |
|---|
| 54 | IOBluetoothDeviceInquiry* inquiry; |
|---|
| 55 | BOOL isDiscovering; |
|---|
| 56 | // Number of found wiimotes |
|---|
| 57 | int foundWiimotes; |
|---|
| 58 | // Maximum number of wiimotes to be searched |
|---|
| 59 | int maxWiimotes; |
|---|
| 60 | // The Wiimotes structure |
|---|
| 61 | wiimote** wiimotes; |
|---|
| 62 | } |
|---|
| 63 | |
|---|
| 64 | - (BOOL) isDiscovering; |
|---|
| 65 | - (void) setDiscovering:(BOOL) flag; |
|---|
| 66 | - (void) setWiimoteStruct:(wiimote**) wiimote_struct; |
|---|
| 67 | - (int) getFoundWiimotes; |
|---|
| 68 | - (IOReturn) start:(unsigned int) timeout maxWiimotes:(unsigned int) wiimotesNum; |
|---|
| 69 | - (IOReturn) stop; |
|---|
| 70 | - (IOReturn) close; |
|---|
| 71 | - (void) retrieveWiimoteInfo:(IOBluetoothDevice*) device; |
|---|
| 72 | - (void) deviceInquiryStarted:(IOBluetoothDeviceInquiry*) sender; |
|---|
| 73 | - (void) deviceInquiryDeviceFound:(IOBluetoothDeviceInquiry *) sender device:(IOBluetoothDevice *) device; |
|---|
| 74 | - (void) deviceInquiryComplete:(IOBluetoothDeviceInquiry*) sender error:(IOReturn) error aborted:(BOOL) aborted; |
|---|
| 75 | |
|---|
| 76 | @end |
|---|
| 77 | |
|---|
| 78 | @interface WiiConnect : NSObject |
|---|
| 79 | { |
|---|
| 80 | // Buffer to store incoming data from the Wiimote |
|---|
| 81 | NSData* receivedMsg; |
|---|
| 82 | unsigned int msgLength; |
|---|
| 83 | |
|---|
| 84 | // Reference to the relative wiimote struct (used only to complete handshaking) |
|---|
| 85 | wiimote* _wm; |
|---|
| 86 | BOOL isReading; |
|---|
| 87 | BOOL timeout; |
|---|
| 88 | BOOL disconnecting; |
|---|
| 89 | } |
|---|
| 90 | |
|---|
| 91 | - (IOBluetoothL2CAPChannel *) openL2CAPChannelWithPSM:(BluetoothL2CAPPSM) psm device:(IOBluetoothDevice*) device delegate:(id) delegate; |
|---|
| 92 | - (IOReturn) connectToWiimote:(wiimote*) wm; |
|---|
| 93 | - (void) l2capChannelData:(IOBluetoothL2CAPChannel*) channel data:(byte *) data length:(NSUInteger) length; |
|---|
| 94 | - (byte*) getNextMsg; |
|---|
| 95 | - (unsigned int) getMsgLength; |
|---|
| 96 | - (void) deleteMsg; |
|---|
| 97 | - (void) disconnected:(IOBluetoothUserNotification*) notification fromDevice:(IOBluetoothDevice*) device; |
|---|
| 98 | - (BOOL) isReading; |
|---|
| 99 | - (void) setReading:(BOOL) flag; |
|---|
| 100 | - (BOOL) isTimeout; |
|---|
| 101 | - (void) setTimeout:(BOOL) flag; |
|---|
| 102 | - (void) startTimerThread; |
|---|
| 103 | - (void) wakeUpMainThreadRunloop:(id)arg; |
|---|
| 104 | - (BOOL) isDisconnecting; |
|---|
| 105 | @end |
|---|
| 106 | |
|---|
| 107 | #endif /* IO_MAC_H */ |
|---|