Integrate button tester
@ -14,7 +14,6 @@
|
||||
|
||||
C3D_RenderTarget *RENDER_TOP, *RENDER_BOTTOM;
|
||||
C2D_TextBuf staticBuf, dynamicBuf, sizeBuf;
|
||||
C2D_Image banner, drive_icon;
|
||||
|
||||
typedef u32 Colour;
|
||||
|
||||
@ -26,5 +25,7 @@ float Draw_GetTextWidth(float size, const char *text);
|
||||
float Draw_GetTextHeight(float size, const char *text);
|
||||
bool Draw_Rect(float x, float y, float w, float h, Colour colour);
|
||||
bool Draw_Image(C2D_Image image, float x, float y);
|
||||
bool Draw_ImageScale(C2D_Image image, float x, float y, float scaleX, float scaleY);
|
||||
bool Draw_Image_Blend(C2D_Image image, float x, float y, Colour colour);
|
||||
|
||||
#endif
|
8
gui/include/menu_control.h
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef _3DSIDENT_MENU_CONTROL_H_
|
||||
#define _3DSIDENT_MENU_CONTROL_H_
|
||||
|
||||
extern bool MENU_STATE_CONTROLS;
|
||||
|
||||
void Menu_Controls(void);
|
||||
|
||||
#endif
|
12
gui/include/textures.h
Normal file
@ -0,0 +1,12 @@
|
||||
#ifndef _3DSIDENT_TEXTURES_H_
|
||||
#define _3DSIDENT_TEXTURES_H_
|
||||
|
||||
#include <citro2d.h>
|
||||
|
||||
C2D_Image banner, drive_icon;
|
||||
C2D_Image btn_A, btn_B, btn_X, btn_Y, btn_Start_Select, btn_L, btn_R, btn_ZL, btn_ZR, btn_Dpad, btn_Cpad, btn_Cstick, btn_home, cursor, volumeIcon;
|
||||
|
||||
void Textures_Load(void);
|
||||
void Textures_Free(void);
|
||||
|
||||
#endif
|
BIN
gui/res/drawable/A.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
gui/res/drawable/B.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
gui/res/drawable/C_stick.png
Normal file
After Width: | Height: | Size: 3.5 KiB |
BIN
gui/res/drawable/Circle_pad.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
gui/res/drawable/D_pad.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
gui/res/drawable/Home.png
Normal file
After Width: | Height: | Size: 3.5 KiB |
BIN
gui/res/drawable/L.png
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
gui/res/drawable/R.png
Normal file
After Width: | Height: | Size: 3.5 KiB |
BIN
gui/res/drawable/Start_select.png
Normal file
After Width: | Height: | Size: 3.3 KiB |
BIN
gui/res/drawable/X.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
gui/res/drawable/Y.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
gui/res/drawable/ZL.png
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
gui/res/drawable/ZR.png
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
gui/res/drawable/cursor.png
Normal file
After Width: | Height: | Size: 764 B |
@ -1,3 +1,18 @@
|
||||
--atlas -f rgba8888 -z auto
|
||||
A.png
|
||||
B.png
|
||||
C_stick.png
|
||||
Circle_pad.png
|
||||
cursor.png
|
||||
D_pad.png
|
||||
drive.png
|
||||
Home.png
|
||||
icon.png
|
||||
L.png
|
||||
R.png
|
||||
Start_select.png
|
||||
volume.png
|
||||
X.png
|
||||
Y.png
|
||||
ZL.png
|
||||
ZR.png
|
BIN
gui/res/drawable/volume.png
Normal file
After Width: | Height: | Size: 15 KiB |
@ -58,3 +58,15 @@ bool Draw_Image(C2D_Image image, float x, float y)
|
||||
{
|
||||
return C2D_DrawImageAt(image, x, y, 0.5f, NULL, 1.0f, 1.0f);
|
||||
}
|
||||
|
||||
bool Draw_ImageScale(C2D_Image image, float x, float y, float scaleX, float scaleY)
|
||||
{
|
||||
return C2D_DrawImageAt(image, x, y, 0.5f, NULL, scaleX, scaleY);
|
||||
}
|
||||
|
||||
bool Draw_Image_Blend(C2D_Image image, float x, float y, Colour colour)
|
||||
{
|
||||
C2D_ImageTint tint;
|
||||
C2D_PlainImageTint(&tint, colour, 0.50f);
|
||||
return C2D_DrawImageAt(image, x, y, 0.5f, &tint, 1.0f, 1.0f);
|
||||
}
|
||||
|
@ -8,10 +8,10 @@
|
||||
#include "fs.h"
|
||||
#include "menus.h"
|
||||
#include "sprites.h"
|
||||
#include "textures.h"
|
||||
#include "utils.h"
|
||||
|
||||
static u32 cpu_time_limit = 0;
|
||||
static C2D_SpriteSheet spritesheet;
|
||||
|
||||
static void Init_Services(void)
|
||||
{
|
||||
@ -52,14 +52,12 @@ static void Init_Services(void)
|
||||
RENDER_TOP = C2D_CreateScreenTarget(GFX_TOP, GFX_LEFT);
|
||||
RENDER_BOTTOM = C2D_CreateScreenTarget(GFX_BOTTOM, GFX_LEFT);
|
||||
|
||||
spritesheet = C2D_SpriteSheetLoad("romfs:/res/drawable/sprites.t3x");
|
||||
banner = C2D_SpriteSheetGetImage(spritesheet, sprites_icon_idx);
|
||||
drive_icon = C2D_SpriteSheetGetImage(spritesheet, sprites_drive_idx);
|
||||
Textures_Load();
|
||||
}
|
||||
|
||||
static void Term_Services(void)
|
||||
{
|
||||
C2D_SpriteSheetFree(spritesheet);
|
||||
Textures_Free();
|
||||
|
||||
C2D_TextBufDelete(sizeBuf);
|
||||
C2D_TextBufDelete(dynamicBuf);
|
||||
|
158
gui/source/menu_control.c
Normal file
@ -0,0 +1,158 @@
|
||||
#include <3ds.h>
|
||||
|
||||
#include "C2D_helper.h"
|
||||
#include "menu_control.h"
|
||||
#include "textures.h"
|
||||
|
||||
bool MENU_STATE_CONTROLS = false;
|
||||
|
||||
void Menu_Controls(void)
|
||||
{
|
||||
circlePosition cPad, cStick;
|
||||
touchPosition touch;
|
||||
|
||||
u16 touch_x = 0, touch_y = 0;
|
||||
|
||||
u8 volume;
|
||||
|
||||
int i = 0;
|
||||
|
||||
while (MENU_STATE_CONTROLS)
|
||||
{
|
||||
hidScanInput();
|
||||
hidCircleRead(&cPad);
|
||||
hidCstickRead(&cStick);
|
||||
u32 kDown = hidKeysDown();
|
||||
u32 kHeld = hidKeysHeld();
|
||||
HIDUSER_GetSoundVolume(&volume);
|
||||
|
||||
if (((kHeld & KEY_START) && (kDown & KEY_SELECT)) || ((kHeld & KEY_SELECT) && (kDown & KEY_START)))
|
||||
MENU_STATE_CONTROLS = false;
|
||||
|
||||
if (kHeld & KEY_TOUCH)
|
||||
{
|
||||
hidTouchRead(&touch);
|
||||
touch_x = touch.px;
|
||||
touch_y = touch.py;
|
||||
}
|
||||
|
||||
C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
|
||||
C2D_TargetClear(RENDER_TOP, C2D_Color32(60, 61, 63, 255));
|
||||
C2D_TargetClear(RENDER_BOTTOM, C2D_Color32(94, 39, 80, 255));
|
||||
C2D_SceneBegin(RENDER_TOP);
|
||||
|
||||
Draw_Rect(75, 30, 250, 210, C2D_Color32(97, 101, 104, 255));
|
||||
Draw_Rect(85, 40, 230, 175, C2D_Color32(242, 241, 239, 255));
|
||||
Draw_Rect(85, 40, 230, 15, C2D_Color32(66, 65, 61, 255));
|
||||
|
||||
Draw_Textf(90, 40, 0.45f, C2D_Color32(230, 232, 214, 255), "3DSident Button Test");
|
||||
|
||||
Draw_Textf(90, 56, 0.45f, C2D_Color32(77, 76, 74, 255), "Circle pad: %04d, %04d", cPad.dx, cPad.dy);
|
||||
Draw_Textf(90, 70, 0.45f, C2D_Color32(77, 76, 74, 255), "C stick: %04d, %04d", cStick.dx, cStick.dy);
|
||||
Draw_Textf(90, 84, 0.45f, C2D_Color32(77, 76, 74, 255), "Touch position: %03d, %03d", touch.px, touch.py);
|
||||
Draw_Textf(90, 84, 0.45f, C2D_Color32(77, 76, 74, 255), "Touch position: %03d, %03d", touch.px, touch.py);
|
||||
|
||||
Draw_Image(volumeIcon, 90, 98);
|
||||
double volPercent = (volume * 1.5873015873);
|
||||
Draw_Rect(115, 104, 190, 5, C2D_Color32(219, 219, 219, 255));
|
||||
Draw_Rect(115, 104, ((volPercent / 100) * 190), 5, C2D_Color32(241, 122, 74, 255));
|
||||
|
||||
Draw_Textf(90, 118, 0.45f, C2D_Color32(77, 76, 74, 255), "3D");
|
||||
double _3dSliderPercent = (osGet3DSliderState() * 100.0);
|
||||
Draw_Rect(115, 122, 190, 5, C2D_Color32(219, 219, 219, 255));
|
||||
Draw_Rect(115, 122, ((_3dSliderPercent / 100) * 190), 5, C2D_Color32(241, 122, 74, 255));
|
||||
|
||||
Draw_Textf(90, 138, 0.45f, C2D_Color32(77, 76, 74, 255), "Use home button to exit.");
|
||||
|
||||
Draw_Image(btn_home, 180, 215);
|
||||
|
||||
if (kHeld & KEY_L)
|
||||
Draw_Image_Blend(btn_L, 0, 0, MENU_SELECTOR_COLOUR);
|
||||
else
|
||||
Draw_Image(btn_L, 0, 0);
|
||||
|
||||
if (kHeld & KEY_R)
|
||||
Draw_Image_Blend(btn_R, 345, 0, MENU_SELECTOR_COLOUR);
|
||||
else
|
||||
Draw_Image(btn_R, 345, 0);
|
||||
|
||||
if (kHeld & KEY_ZL)
|
||||
Draw_Image_Blend(btn_ZL, 60, 0, MENU_SELECTOR_COLOUR);
|
||||
else
|
||||
Draw_Image(btn_ZL, 60, 0);
|
||||
|
||||
if (kHeld & KEY_ZR)
|
||||
Draw_Image_Blend(btn_ZR, 300, 0, MENU_SELECTOR_COLOUR);
|
||||
else
|
||||
Draw_Image(btn_ZR, 300, 0);
|
||||
|
||||
if (kHeld & KEY_A)
|
||||
Draw_Image_Blend(btn_A, 370, 80, MENU_SELECTOR_COLOUR);
|
||||
else
|
||||
Draw_Image(btn_A, 370, 80);
|
||||
|
||||
if (kHeld & KEY_B)
|
||||
Draw_Image_Blend(btn_B, 350, 100, MENU_SELECTOR_COLOUR);
|
||||
else
|
||||
Draw_Image(btn_B, 350, 100);
|
||||
|
||||
if (kHeld & KEY_X)
|
||||
Draw_Image_Blend(btn_X, 350, 60, MENU_SELECTOR_COLOUR);
|
||||
else
|
||||
Draw_Image(btn_X, 350, 60);
|
||||
|
||||
if (kHeld & KEY_Y)
|
||||
Draw_Image_Blend(btn_Y, 330, 80, MENU_SELECTOR_COLOUR);
|
||||
else
|
||||
Draw_Image(btn_Y, 330, 80);
|
||||
|
||||
if (kHeld & KEY_START)
|
||||
Draw_Image_Blend(btn_Start_Select, 330, 140, MENU_SELECTOR_COLOUR);
|
||||
else
|
||||
Draw_Image(btn_Start_Select, 330, 140);
|
||||
|
||||
if (kHeld & KEY_SELECT)
|
||||
Draw_Image_Blend(btn_Start_Select, 330, 165, MENU_SELECTOR_COLOUR);
|
||||
else
|
||||
Draw_Image(btn_Start_Select, 330, 165);
|
||||
|
||||
if (kHeld & KEY_CPAD_LEFT)
|
||||
Draw_Image_Blend(btn_Cpad, 3, 55, MENU_SELECTOR_COLOUR);
|
||||
else if (kHeld & KEY_CPAD_RIGHT)
|
||||
Draw_Image_Blend(btn_Cpad, 13, 55, MENU_SELECTOR_COLOUR);
|
||||
else if (kHeld & KEY_CPAD_UP)
|
||||
Draw_Image_Blend(btn_Cpad, 8, 50, MENU_SELECTOR_COLOUR);
|
||||
else if (kHeld & KEY_CPAD_DOWN)
|
||||
Draw_Image_Blend(btn_Cpad, 8, 60, MENU_SELECTOR_COLOUR);
|
||||
else
|
||||
Draw_Image(btn_Cpad, 8, 55);
|
||||
|
||||
if (kHeld & KEY_DLEFT)
|
||||
Draw_Image_Blend(btn_Dpad, 0, 110, MENU_SELECTOR_COLOUR);
|
||||
else if (kHeld & KEY_DRIGHT)
|
||||
Draw_Image_Blend(btn_Dpad, 10, 110, MENU_SELECTOR_COLOUR);
|
||||
else if (kHeld & KEY_DUP)
|
||||
Draw_Image_Blend(btn_Dpad, 5, 105, MENU_SELECTOR_COLOUR);
|
||||
else if (kHeld & KEY_DDOWN)
|
||||
Draw_Image_Blend(btn_Dpad, 5, 115, MENU_SELECTOR_COLOUR);
|
||||
else
|
||||
Draw_Image(btn_Dpad, 5, 110);
|
||||
|
||||
if (kHeld & KEY_CSTICK_LEFT)
|
||||
Draw_Image_Blend(btn_Cstick, 325, 35, MENU_SELECTOR_COLOUR);
|
||||
else if (kHeld & KEY_CSTICK_RIGHT)
|
||||
Draw_Image_Blend(btn_Cstick, 335, 35, MENU_SELECTOR_COLOUR);
|
||||
else if (kHeld & KEY_CSTICK_UP)
|
||||
Draw_Image_Blend(btn_Cstick, 330, 30, MENU_SELECTOR_COLOUR);
|
||||
else if (kHeld & KEY_CSTICK_DOWN)
|
||||
Draw_Image_Blend(btn_Cstick, 330, 40, MENU_SELECTOR_COLOUR);
|
||||
else
|
||||
Draw_Image(btn_Cstick, 330, 35);
|
||||
|
||||
C2D_SceneBegin(RENDER_BOTTOM);
|
||||
|
||||
Draw_Image(cursor, touch_x, touch_y);
|
||||
|
||||
Draw_EndFrame();
|
||||
}
|
||||
}
|
@ -10,10 +10,12 @@
|
||||
#include "config.h"
|
||||
#include "hardware.h"
|
||||
#include "kernel.h"
|
||||
#include "menu_control.h"
|
||||
#include "misc.h"
|
||||
#include "screenshot.h"
|
||||
#include "storage.h"
|
||||
#include "system.h"
|
||||
#include "textures.h"
|
||||
#include "utils.h"
|
||||
#include "wifi.h"
|
||||
|
||||
@ -389,6 +391,7 @@ void Menu_Main(void)
|
||||
case 9:
|
||||
Draw_Text((400 - instr_width) / 2, (240 - instr_height) / 2, 0.5f, MENU_INFO_TITLE_COLOUR, "Press select to hide user-specific info");
|
||||
Draw_Text((400 - instr_width) / 2, ((240 - instr_height) / 2) + 18, 0.5f, MENU_INFO_TITLE_COLOUR, " Press L + R to capture a screenshot ");
|
||||
Draw_Text((400 - instr_width) / 2, ((240 - instr_height) / 2) + 36, 0.5f, MENU_INFO_TITLE_COLOUR, "Press START + SELECT to use button test");
|
||||
break;
|
||||
}
|
||||
|
||||
@ -433,7 +436,9 @@ void Menu_Main(void)
|
||||
if (((kHeld & KEY_L) && (kDown & KEY_R)) || ((kHeld & KEY_R) && (kDown & KEY_L)))
|
||||
Screenshot_Capture();
|
||||
|
||||
if (kDown & KEY_START)
|
||||
longjmp(exitJmp, 1);
|
||||
if (((kHeld & KEY_START) && (kDown & KEY_SELECT)) || ((kHeld & KEY_SELECT) && (kDown & KEY_START)))
|
||||
MENU_STATE_CONTROLS = true;
|
||||
|
||||
Menu_Controls();
|
||||
}
|
||||
}
|
||||
|
32
gui/source/textures.c
Normal file
@ -0,0 +1,32 @@
|
||||
#include "sprites.h"
|
||||
#include "textures.h"
|
||||
|
||||
static C2D_SpriteSheet spritesheet;
|
||||
|
||||
void Textures_Load(void)
|
||||
{
|
||||
spritesheet = C2D_SpriteSheetLoad("romfs:/res/drawable/sprites.t3x");
|
||||
|
||||
banner = C2D_SpriteSheetGetImage(spritesheet, sprites_icon_idx);
|
||||
drive_icon = C2D_SpriteSheetGetImage(spritesheet, sprites_drive_idx);
|
||||
btn_A = C2D_SpriteSheetGetImage(spritesheet, sprites_A_idx);
|
||||
btn_B = C2D_SpriteSheetGetImage(spritesheet, sprites_B_idx);
|
||||
btn_X = C2D_SpriteSheetGetImage(spritesheet, sprites_X_idx);
|
||||
btn_Y = C2D_SpriteSheetGetImage(spritesheet, sprites_Y_idx);
|
||||
btn_Start_Select = C2D_SpriteSheetGetImage(spritesheet, sprites_Start_select_idx);
|
||||
btn_L = C2D_SpriteSheetGetImage(spritesheet, sprites_L_idx);
|
||||
btn_R = C2D_SpriteSheetGetImage(spritesheet, sprites_R_idx);
|
||||
btn_ZL = C2D_SpriteSheetGetImage(spritesheet, sprites_ZL_idx);
|
||||
btn_ZR = C2D_SpriteSheetGetImage(spritesheet, sprites_ZR_idx);
|
||||
btn_Dpad = C2D_SpriteSheetGetImage(spritesheet, sprites_D_pad_idx);
|
||||
btn_Cpad = C2D_SpriteSheetGetImage(spritesheet, sprites_Circle_pad_idx);
|
||||
btn_Cstick = C2D_SpriteSheetGetImage(spritesheet, sprites_C_stick_idx);
|
||||
btn_home = C2D_SpriteSheetGetImage(spritesheet, sprites_Home_idx);
|
||||
cursor = C2D_SpriteSheetGetImage(spritesheet, sprites_cursor_idx);
|
||||
volumeIcon = C2D_SpriteSheetGetImage(spritesheet, sprites_volume_idx);
|
||||
}
|
||||
|
||||
void Textures_Free(void)
|
||||
{
|
||||
C2D_SpriteSheetFree(spritesheet);
|
||||
}
|