mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2025-01-11 19:39:09 +01:00
-replaced wiilight by something better from libprojectM because
its open source and we can modify it as we want, that should fix the problem that the wii light sometimes did not disable properly ;)
This commit is contained in:
parent
7e453d5b97
commit
4c300161e1
2
Makefile
2
Makefile
@ -78,7 +78,7 @@ LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map,--section-start,.init=0x80A00
|
||||
#---------------------------------------------------------------------------------
|
||||
# any extra libraries we wish to link with the project
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBS := -lcustomfat -lcustomntfs -lcustomext2fs -lpng -lm -lz -lwiiuse -lbte -lasnd -logc -lfreetype -lvorbisidec -lmad -ljpeg -lwiilight -lmodplay
|
||||
LIBS := -lcustomfat -lcustomntfs -lcustomext2fs -lpng -lm -lz -lwiiuse -lbte -lasnd -logc -lfreetype -lvorbisidec -lmad -ljpeg -lmodplay
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
|
@ -1,21 +0,0 @@
|
||||
#ifndef _WIILIGHT_H_
|
||||
#define _WIILIGHT_H_
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void WIILIGHT_Init();
|
||||
void WIILIGHT_TurnOn();
|
||||
int WIILIGHT_GetLevel();
|
||||
int WIILIGHT_SetLevel(int level);
|
||||
|
||||
void WIILIGHT_Toggle();
|
||||
void WIILIGHT_TurnOff();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
Binary file not shown.
100
source/gui/Gekko.c
Normal file
100
source/gui/Gekko.c
Normal file
@ -0,0 +1,100 @@
|
||||
/**
|
||||
* Gekko.h - Additional rendering routines for the Gekko platform.
|
||||
*
|
||||
* Copyright (c) 2009 Rhys "Shareese" Koedijk
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
* See 'LICENSE' included within this release
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <ogcsys.h>
|
||||
#include <gctypes.h>
|
||||
#include <gccore.h>
|
||||
|
||||
#include "Gekko.h"
|
||||
|
||||
#define HW_GPIO 0xCD0000C0;
|
||||
#define DISC_SLOT_LED 0x20
|
||||
|
||||
lwp_t light_thread = LWP_THREAD_NULL;
|
||||
|
||||
void *light_loop();
|
||||
vu32 *light_reg = (u32*) HW_GPIO;
|
||||
bool light_on = false;
|
||||
u8 light_level = 0;
|
||||
|
||||
struct timespec light_timeon;
|
||||
struct timespec light_timeoff;
|
||||
|
||||
void wiiLightOn()
|
||||
{
|
||||
light_on = true;
|
||||
|
||||
if(light_thread == LWP_THREAD_NULL)
|
||||
LWP_CreateThread(&light_thread, light_loop, NULL, NULL, 0, LWP_PRIO_HIGHEST);
|
||||
}
|
||||
|
||||
void wiiLightOff()
|
||||
{
|
||||
light_on = false;
|
||||
|
||||
LWP_JoinThread(light_thread, NULL);
|
||||
light_thread = LWP_THREAD_NULL;
|
||||
*light_reg &= ~DISC_SLOT_LED;
|
||||
}
|
||||
|
||||
void wiiLightSetLevel(int level)
|
||||
{
|
||||
light_level = MIN(MAX(level, 0), 100);
|
||||
|
||||
// Calculate the new on/off times for this light intensity
|
||||
u32 level_on;
|
||||
u32 level_off;
|
||||
level_on = (light_level * 2.55) * 40000;
|
||||
level_off = 10200000 - level_on;
|
||||
light_timeon.tv_nsec = level_on;
|
||||
light_timeoff.tv_nsec = level_off;
|
||||
}
|
||||
|
||||
/**
|
||||
* Since you can only turn the disc slot light either completely on
|
||||
* or completely off, this thread simulates different light intensity
|
||||
* levels by turning the light on and off very quickly at a specific
|
||||
* interval defined by the current light intensity level.
|
||||
*
|
||||
* Its all an eye trick ;)
|
||||
*
|
||||
*/
|
||||
void *light_loop()
|
||||
{
|
||||
struct timespec timeon;
|
||||
struct timespec timeoff;
|
||||
|
||||
// Loop whilst the light is still 'on'
|
||||
while(light_on)
|
||||
{
|
||||
timeon = light_timeon;
|
||||
timeoff = light_timeoff;
|
||||
// Turn on the light and sleep for a bit
|
||||
*light_reg |= DISC_SLOT_LED;
|
||||
nanosleep(&timeon);
|
||||
// Turn off the light (if required) and sleep for a bit
|
||||
if (timeoff.tv_nsec > 0)
|
||||
*light_reg &= ~DISC_SLOT_LED;
|
||||
nanosleep(&timeoff);
|
||||
}
|
||||
return NULL;
|
||||
}
|
38
source/gui/Gekko.h
Normal file
38
source/gui/Gekko.h
Normal file
@ -0,0 +1,38 @@
|
||||
/**
|
||||
* Gekko.h - Additional rendering routines for the Gekko platform.
|
||||
*
|
||||
* Copyright (c) 2009 Rhys "Shareese" Koedijk
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
* See 'LICENSE' included within this release
|
||||
*/
|
||||
|
||||
#ifndef _GEKKO_H_
|
||||
#define _GEKKO_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Wii disc slot light routines
|
||||
void wiiLightOn();
|
||||
void wiiLightOff();
|
||||
void wiiLightSetLevel(int level);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _GEKKO_H_ */
|
@ -1,7 +1,7 @@
|
||||
#include "pngu.h"
|
||||
#include "video.hpp"
|
||||
#include <string.h>
|
||||
#include <wiilight.h>
|
||||
#include "gekko.h"
|
||||
#include "gecko.h"
|
||||
|
||||
#define DEFAULT_FIFO_SIZE (256 * 1024)
|
||||
@ -457,8 +457,8 @@ void CVideo::_showWaitMessages(CVideo *m)
|
||||
|
||||
if (m->m_useWiiLight)
|
||||
{
|
||||
WIILIGHT_SetLevel(0);
|
||||
WIILIGHT_TurnOn();
|
||||
wiiLightSetLevel(0);
|
||||
wiiLightOn();
|
||||
}
|
||||
|
||||
while (m->m_showWaitMessage)
|
||||
@ -476,7 +476,7 @@ void CVideo::_showWaitMessages(CVideo *m)
|
||||
currentLightLevel = 0;
|
||||
fadeDirection = 1;
|
||||
}
|
||||
WIILIGHT_SetLevel(currentLightLevel);
|
||||
wiiLightSetLevel(currentLightLevel);
|
||||
}
|
||||
|
||||
if (waitFrames == 0)
|
||||
@ -494,8 +494,8 @@ void CVideo::_showWaitMessages(CVideo *m)
|
||||
}
|
||||
if (m->m_useWiiLight)
|
||||
{
|
||||
WIILIGHT_SetLevel(0);
|
||||
WIILIGHT_TurnOff();
|
||||
wiiLightSetLevel(0);
|
||||
wiiLightOff();
|
||||
}
|
||||
m->m_waitMessages.clear();
|
||||
m->m_showingWaitMessages = false;
|
||||
@ -508,8 +508,8 @@ void CVideo::hideWaitMessage()
|
||||
m_showWaitMessage = false;
|
||||
CheckWaitThread();
|
||||
|
||||
WIILIGHT_SetLevel(0);
|
||||
WIILIGHT_TurnOff();
|
||||
wiiLightSetLevel(0);
|
||||
wiiLightOff();
|
||||
}
|
||||
|
||||
void CVideo::CheckWaitThread()
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include "text.hpp"
|
||||
#include <ogc/system.h>
|
||||
#include <unistd.h>
|
||||
#include <wiilight.h>
|
||||
#include "DeviceHandler.hpp"
|
||||
#include "homebrew.h"
|
||||
#include "gecko.h"
|
||||
@ -46,7 +45,6 @@ int main(int argc, char **argv)
|
||||
// Init video
|
||||
CVideo vid;
|
||||
vid.init();
|
||||
WIILIGHT_Init();
|
||||
vid.waitMessage(0.2f);
|
||||
|
||||
char *gameid = NULL;
|
||||
|
@ -12,7 +12,6 @@
|
||||
#include <wchar.h>
|
||||
#include <network.h>
|
||||
#include <errno.h>
|
||||
#include <wiilight.h>
|
||||
|
||||
#include "gecko.h"
|
||||
#include "defines.h"
|
||||
@ -24,6 +23,7 @@
|
||||
#include "cios.hpp"
|
||||
#include "loader/playlog.h"
|
||||
#include "gc/fileOps.h"
|
||||
#include "Gekko.h"
|
||||
|
||||
// Sounds
|
||||
extern const u8 click_wav[];
|
||||
@ -495,8 +495,10 @@ void CMenu::cleanup(bool ios_reload)
|
||||
if (!ios_reload || (!m_use_wifi_gecko && ios_reload))
|
||||
_deinitNetwork();
|
||||
|
||||
WIILIGHT_SetLevel(0);
|
||||
WIILIGHT_TurnOff();
|
||||
wiiLightSetLevel(0);
|
||||
wiiLightOff();
|
||||
|
||||
gprintf(" \nMemory cleaned up\n");
|
||||
}
|
||||
|
||||
void CMenu::_reload_wifi_gecko(void)
|
||||
|
Loading…
x
Reference in New Issue
Block a user