dolphin/Source/Core/wiiuse/Src/wiiuse_internal.h

164 lines
4.8 KiB
C
Raw Normal View History

/*
* wiiuse
*
* Written By:
* Michael Laforest < para >
* Email: < thepara (--AT--) g m a i l [--DOT--] com >
*
* Copyright 2006-2007
*
* This file is part of wiiuse.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* $Header$
*
*/
/**
* @file
* @brief General internal wiiuse stuff.
*
* Since Wiiuse is a library, wiiuse.h is a duplicate
* of the API header.
*
* The code that would normally go in that file, but
* which is not needed by third party developers,
* is put here.
*
* So wiiuse_internal.h is included by other files
* internally, wiiuse.h is included only here.
*/
#ifndef WIIUSE_INTERNAL_H_INCLUDED
#define WIIUSE_INTERNAL_H_INCLUDED
/* wiiuse version */
#define WIIUSE_VERSION "0.12"
/********************
*
* Wiimote internal codes
*
********************/
/* Communication channels */
#define WM_OUTPUT_CHANNEL 0x11
#define WM_INPUT_CHANNEL 0x13
#define WM_SET_REPORT 0x50
/* commands */
#define WM_CMD_LED 0x11
#define WM_CMD_REPORT_TYPE 0x12
#define WM_CMD_RUMBLE 0x13
#define WM_CMD_IR 0x13
#define WM_CMD_CTRL_STATUS 0x15
#define WM_CMD_SPEAKER_ENABLE 0x14// Size 1
#define WM_CMD_WRITE_DATA 0x16
#define WM_CMD_READ_DATA 0x17
#define WM_CMD_SPEAKER_DATA 0x18// Size 21
#define WM_CMD_SPEAKER_MUTE 0x19// Size 1
#define WM_CMD_IR_2 0x1A
#define WM_BT_INPUT 0x01
#define WM_BT_OUTPUT 0x02
/* Identify the wiimote device by its class */
#define WM_DEV_CLASS_0 0x04
#define WM_DEV_CLASS_1 0x25
#define WM_DEV_CLASS_2 0x00
#define WM_VENDOR_ID 0x057E
#define WM_PRODUCT_ID 0x0306
External/wiiuse clean up, part 2. - More removal of unnecessary code - Windows: Modification of Wiiuse_Find under windows, instead of always deleting and recreating the whole wiimote_t struct, we do maintain the old one, adding/removing new wiimotes to/from it - some wiimote bugfixes, see below for details Windows related stuff: Fixed most of the disconnection issues (single and mulitple real wiimotes, both wiimote plugins) (I haven't had a disconnect msg in hours anymore(ms stack)). Rumble bug should be fixed now(both plugins,pls verify). Fixed some pair up issues( sometimes you had to press the pair up button up to 3 times, till it paired up your wiimote). More dongles might be now supported via ms stack, pls try and report back! Fixed a problem where multiple wiimotes would swap slots on pair-up/addition of a real wiimote (2-4 real wiimotes) (both plugins, but not integrated into new plugin). Improved ingame auto-pairup for real wiimotes(thx to the new wiiuse_find routine). Fixed a bug on setting wiimote timeouts, which means changing the timeout was just a dummy earlier. Most of the stuff concerns stuff in the old wiimote plugin, dont worry, in the end it's important for both plugins. It will get ported to the new plugin sooner or later.:') Some minor stuff. This might break osx/linux build and maybe the new plugin realwiimote-wise only. Thx to glennrics to pointing me to some breakings on linux, I didn't fix them all. PS I hope i haven't forgotten anything, enjoy. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5940 8ced0084-cf51-0410-be5f-012b33b47a6e
2010-07-22 04:31:36 +00:00
/* offsets in wiimote memory */
#define WM_MEM_OFFSET_CALIBRATION 0x16
#define WM_REG_IR_BLOCK1 0x04B00000
#define WM_REG_IR_BLOCK2 0x04B0001A
MAJOR and long ago overdue wiiuse and real wiimote sourcecode cleanup. Removed "recording" in old wiimote plugin and other not necessary functions(EEPROM reading, we 'll just do a reconnect instead to use default accel calibration data etc). Recording is not needed anymore(playback of recorded moves should be still working). Everything the recording feature offered, the new wiimote plugin does as well and even more. The cleanup will ease the port of the real wiimote feature into new wiimote plugin, which is still only offering emulated wiimote support. Billiard said he's now on it.:) Wiimotes are now slighty more responsive and multiple wiimotes should harmonize now slighty better. This clean up was requested/inevitable and should have be done way more earlier. This "might" break osx/linux builds, so please test. If your aware of any "real wiimote" issues please post it in the comments as well(dont forget to state your OS). Known wiimote issues: 1.) Possible wiimote disconnect on pressing the home button 2.) 1-2 Possible wiimote disconnects directly after starting a game 3.) Rumble causes lag. I don't think this is a wiimote plugin issue itself, I'm not sure tho. It would be interesting to know whether the lag still happens on emulated wiimotes as well, when the game tries to rumble. 4.) Connecting(pairing up and refreshing) a 2nd/3rd/4th real wiimote while having a game running/paused, might swap player slots and cause disconnects at that moment. If u have more issues, feel free to post them, to have them all here collected once more to get a brief overview. Apart from that, increase the wiimote read timeout @settings(20-200). If your expecting frequent disconnects, restart dolphin, and don't open the wiimote gui before playing instead directly start games. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5788 8ced0084-cf51-0410-be5f-012b33b47a6e
2010-06-26 02:08:30 +00:00
/* ir block data */
#define WM_IR_BLOCK1_LEVEL1 "\x02\x00\x00\x71\x01\x00\x64\x00\xfe"
#define WM_IR_BLOCK2_LEVEL1 "\xfd\x05"
#define WM_IR_BLOCK1_LEVEL2 "\x02\x00\x00\x71\x01\x00\x96\x00\xb4"
#define WM_IR_BLOCK2_LEVEL2 "\xb3\x04"
#define WM_IR_BLOCK1_LEVEL3 "\x02\x00\x00\x71\x01\x00\xaa\x00\x64"
#define WM_IR_BLOCK2_LEVEL3 "\x63\x03"
#define WM_IR_BLOCK1_LEVEL4 "\x02\x00\x00\x71\x01\x00\xc8\x00\x36"
#define WM_IR_BLOCK2_LEVEL4 "\x35\x03"
#define WM_IR_BLOCK1_LEVEL5 "\x07\x00\x00\x71\x01\x00\x72\x00\x20"
#define WM_IR_BLOCK2_LEVEL5 "\x1f\x03"
#define WM_IR_TYPE_BASIC 0x01
#define WM_IR_TYPE_EXTENDED 0x03
#define WM_IR_TYPE_FULL 0x05
/********************
*
* End Wiimote internal codes
*
********************/
/* wiimote state flags - (some duplicated in wiiuse.h)*/
#define WIIMOTE_STATE_DEV_FOUND 0x0001
#define WIIMOTE_STATE_HANDSHAKE 0x0002 /* actual connection exists but no handshake yet */
#define WIIMOTE_STATE_HANDSHAKE_COMPLETE 0x0004 /* actual connection exists but no handshake yet */
#define WIIMOTE_STATE_CONNECTED 0x0008
#define WIIMOTE_STATE_RUMBLE 0x0010
#define WIIMOTE_STATE_ACC 0x0020
#define WIIMOTE_STATE_EXP 0x0040
#define WIIMOTE_STATE_IR 0x0080
#define WIIMOTE_STATE_SPEAKER 0x0100
#define WIIMOTE_STATE_IR_SENS_LVL1 0x0200
#define WIIMOTE_STATE_IR_SENS_LVL2 0x0400
#define WIIMOTE_STATE_IR_SENS_LVL3 0x0800
#define WIIMOTE_STATE_IR_SENS_LVL4 0x1000
#define WIIMOTE_STATE_IR_SENS_LVL5 0x2000
#define WIIMOTE_INIT_STATES (WIIMOTE_STATE_IR_SENS_LVL3)
/* macro to manage states */
#define WIIMOTE_IS_SET(wm, s) ((wm->state & (s)) == (s))
#define WIIMOTE_ENABLE_STATE(wm, s) (wm->state |= (s))
#define WIIMOTE_DISABLE_STATE(wm, s) (wm->state &= ~(s))
#define WIIMOTE_TOGGLE_STATE(wm, s) ((wm->state & (s)) ? WIIMOTE_DISABLE_STATE(wm, s) : WIIMOTE_ENABLE_STATE(wm, s))
#define WIIMOTE_IS_FLAG_SET(wm, s) ((wm->flags & (s)) == (s))
#define WIIMOTE_ENABLE_FLAG(wm, s) (wm->flags |= (s))
#define WIIMOTE_DISABLE_FLAG(wm, s) (wm->flags &= ~(s))
#define WIIMOTE_TOGGLE_FLAG(wm, s) ((wm->flags & (s)) ? WIIMOTE_DISABLE_FLAG(wm, s) : WIIMOTE_ENABLE_FLAG(wm, s))
#define NUNCHUK_IS_FLAG_SET(wm, s) ((*(wm->flags) & (s)) == (s))
/* misc macros */
#define WIIMOTE_ID(wm) (wm->unid)
#define WIIMOTE_IS_CONNECTED(wm) (WIIMOTE_IS_SET(wm, WIIMOTE_STATE_CONNECTED))
#include "wiiuse.h"
/* not part of the api */
int wiiuse_set_report_type(struct wiimote_t* wm);
int wiiuse_send(struct wiimote_t* wm, byte report_type, byte* msg, int len);
#endif /* WIIUSE_INTERNAL_H_INCLUDED */