Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
Some unused changes here
  • Loading branch information
XK9274 committed Apr 1, 2024
1 parent ed83425 commit 2caea47
Show file tree
Hide file tree
Showing 7 changed files with 425 additions and 222 deletions.
96 changes: 81 additions & 15 deletions src/cfg/SDL_picocfg_mmiyoo.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,9 @@ int cfgReadRes(struct json_object *jfile) {

int cfgReadMouse(struct json_object *jfile) {
struct json_object *jval = NULL;
struct json_object *jScaleFactor = NULL;
struct json_object *jAcceleration = NULL;
struct json_object *jAccelerationRate = NULL;
struct json_object *jMaxAcceleration = NULL;
struct json_object *jIncrementModifier = NULL;
struct json_object *jScaleFactor = NULL, *jAcceleration = NULL, *jAccelerationRate = NULL;
struct json_object *jMaxAcceleration = NULL, *jIncrementModifier = NULL, *jDisableMouseHotkey = NULL, *jDisableMouseIcon = NULL;
struct json_object *jMinX = NULL, *jMinY = NULL, *jMaxX = NULL, *jMaxY = NULL;

json_object_object_get_ex(jfile, "mouse", &jval);

Expand Down Expand Up @@ -160,23 +158,85 @@ int cfgReadMouse(struct json_object *jfile) {
pico.mouse.incrementModifier = MMIYOO_DEFAULT_INCREMENT_MODIFIER;
printf("incrementModifier not found in json file. Using default: %f.\n", MMIYOO_DEFAULT_INCREMENT_MODIFIER);
}
} else {
printf("Mouse settings not found in json file. Using defaults.\n");
pico.mouse.scaleFactor = MMIYOO_DEFAULT_SCALE_FACTOR;
pico.mouse.acceleration = MMIYOO_DEFAULT_ACCELERATION;
pico.mouse.accelerationRate = MMIYOO_DEFAULT_ACCELERATION_RATE;
pico.mouse.maxAcceleration = MMIYOO_DEFAULT_MAX_ACCELERATION;
pico.mouse.incrementModifier = MMIYOO_DEFAULT_INCREMENT_MODIFIER;

json_object_object_get_ex(jval, "disableMouseHotkey", &jDisableMouseHotkey);
if (jDisableMouseHotkey) {
pico.mouse.disableMouseHotkey = json_object_get_int(jDisableMouseHotkey);
printf("[json] pico.mouse.disableMouseHotkey: %d\n", pico.mouse.disableMouseHotkey);
} else {
pico.mouse.disableMouseHotkey = MMIYOO_DEFAULT_MOUSE_HOTKEY;
printf("disableMouseHotkey not found in json file. Using default: %d.\n", MMIYOO_DEFAULT_MOUSE_HOTKEY);
}

json_object_object_get_ex(jval, "disableMouseIcon", &jDisableMouseIcon);
if (jDisableMouseIcon) {
pico.mouse.disableMouseIcon = json_object_get_int(jDisableMouseIcon);
printf("[json] pico.mouse.disableMouseIcon: %d\n", pico.mouse.disableMouseIcon);
} else {
pico.mouse.disableMouseIcon = MMIYOO_DEFAULT_MOUSE_ICON;
printf("disableMouseIcon not found in json file. Using default: %d.\n", MMIYOO_DEFAULT_MOUSE_ICON);
}

json_object_object_get_ex(jval, "minx", &jMinX);
if (jMinX) {
pico.mouse.minx = json_object_get_int(jMinX);
printf("[json] pico.mouse.minx: %d\n", pico.mouse.minx);
} else {
pico.mouse.minx = MMIYOO_DEFAULT_MOUSE_MINX;
printf("minx not found in json file. Using default: %d.\n", MMIYOO_DEFAULT_MOUSE_MINX);
}

json_object_object_get_ex(jval, "miny", &jMinY);
if (jMinY) {
pico.mouse.miny = json_object_get_int(jMinY);
printf("[json] pico.mouse.miny: %d\n", pico.mouse.miny);
} else {
pico.mouse.miny = MMIYOO_DEFAULT_MOUSE_MINY;
printf("miny not found in json file. Using default: %d.\n", MMIYOO_DEFAULT_MOUSE_MINY);
}

json_object_object_get_ex(jval, "maxx", &jMaxX);
if (jMaxX) {
pico.mouse.maxx = json_object_get_int(jMaxX);
printf("[json] pico.mouse.maxx: %d\n", pico.mouse.maxx);
} else {
pico.mouse.maxx = MMIYOO_DEFAULT_MOUSE_MAXX;
printf("maxx not found in json file. Using default: %d.\n", MMIYOO_DEFAULT_MOUSE_MAXX);
}

json_object_object_get_ex(jval, "maxy", &jMaxY);
if (jMaxY) {
pico.mouse.maxy = json_object_get_int(jMaxY);
printf("[json] pico.mouse.maxy: %d\n", pico.mouse.maxy);
} else {
pico.mouse.maxy = MMIYOO_DEFAULT_MOUSE_MAXY;
printf("maxy not found in json file. Using default: %d.\n", MMIYOO_DEFAULT_MOUSE_MAXY);
}

if (!jval) {
printf("Mouse settings not found in json file. Using defaults.\n");
pico.mouse.scaleFactor = MMIYOO_DEFAULT_SCALE_FACTOR;
pico.mouse.acceleration = MMIYOO_DEFAULT_ACCELERATION;
pico.mouse.accelerationRate = MMIYOO_DEFAULT_ACCELERATION_RATE;
pico.mouse.maxAcceleration = MMIYOO_DEFAULT_MAX_ACCELERATION;
pico.mouse.incrementModifier = MMIYOO_DEFAULT_INCREMENT_MODIFIER;
pico.mouse.minx = MMIYOO_DEFAULT_MOUSE_MINX;
pico.mouse.miny = MMIYOO_DEFAULT_MOUSE_MINY;
pico.mouse.maxx = MMIYOO_DEFAULT_MOUSE_MAXX;
pico.mouse.maxy = MMIYOO_DEFAULT_MOUSE_MAXY;
printf("Defaults applied: minx=%d, miny=%d, maxx=%d, maxy=%d.\n",
pico.mouse.minx, pico.mouse.miny, pico.mouse.maxx, pico.mouse.maxy);
}
}

return 0;
}

int cfgReadClock(struct json_object *jfile) {

struct json_object *jperf = NULL;
struct json_object *jval = NULL;



if (!json_object_object_get_ex(jfile, "performance", &jperf) || !jperf) {
printf("Performance settings not found in json file. Using defaults.\n");
pico.perf.cpuclock = MMIYOO_DEFAULT_CPU_CLOCK;
Expand Down Expand Up @@ -433,8 +493,14 @@ int picoConfigWrite(void) {
json_object_object_add(jmouse, "accelerationRate", json_object_new_double(pico.mouse.accelerationRate));
json_object_object_add(jmouse, "maxAcceleration", json_object_new_double(pico.mouse.maxAcceleration));
json_object_object_add(jmouse, "incrementModifier", json_object_new_double(pico.mouse.incrementModifier));
json_object_object_add(jmouse, "disableMouseHotkey", json_object_new_int(pico.mouse.disableMouseHotkey));
json_object_object_add(jmouse, "disableMouseIcon", json_object_new_int(pico.mouse.disableMouseIcon));
json_object_object_add(jmouse, "minx", json_object_new_int(pico.mouse.minx));
json_object_object_add(jmouse, "miny", json_object_new_int(pico.mouse.miny));
json_object_object_add(jmouse, "maxx", json_object_new_int(pico.mouse.maxx));
json_object_object_add(jmouse, "maxy", json_object_new_int(pico.mouse.maxy));
json_object_object_add(jfile, "mouse", jmouse);

// performance
jperformance = json_object_new_object();
json_object_object_add(jperformance, "cpuclock", json_object_new_int(pico.perf.cpuclock));
Expand Down
81 changes: 47 additions & 34 deletions src/cfg/SDL_picocfg_mmiyoo.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,40 +9,47 @@
#define MAX_PATH 255
#endif

#define PICO_CFG_PATH "cfg/onioncfg.json"
#define BUFFER_SIZE PATH_MAX + 20
#define MMIYOO_DEFAULT_KEY_L2 SDLK_d
#define MMIYOO_DEFAULT_KEY_L1 SDLK_d
#define MMIYOO_DEFAULT_KEY_UpDpad SDLK_UP
#define MMIYOO_DEFAULT_KEY_DownDpad SDLK_DOWN
#define MMIYOO_DEFAULT_KEY_LeftDpad SDLK_LEFT
#define MMIYOO_DEFAULT_KEY_RightDpad SDLK_RIGHT
#define MMIYOO_DEFAULT_KEY_R2 SDLK_d
#define MMIYOO_DEFAULT_KEY_R1 SDLK_d
#define MMIYOO_DEFAULT_KEY_A SDLK_z
#define MMIYOO_DEFAULT_KEY_B SDLK_x
#define MMIYOO_DEFAULT_KEY_X SDLK_ESCAPE
#define MMIYOO_DEFAULT_KEY_Y SDLK_d
#define MMIYOO_DEFAULT_KEY_Select SDLK_m
#define MMIYOO_DEFAULT_KEY_Start SDLK_RETURN
#define MMIYOO_DEFAULT_KEY_MENU SDLK_ESCAPE
#define MMIYOO_DEFAULT_CPU_CLOCK 1300
#define MMIYOO_MAX_CPU_CLOCK 1700
#define MMIYOO_MIN_CPU_CLOCK 600
#define MMIYOO_DEFAULT_CPU_CLOCK_INCREMENT 25
#define MMIYOO_MAX_CPU_CLOCK_INCREMENT 100
#define MMIYOO_DEFAULT_SCALE_FACTOR 2
#define MMIYOO_DEFAULT_ACCELERATION 2.0
#define MMIYOO_DEFAULT_ACCELERATION_RATE 1.5
#define MMIYOO_DEFAULT_MAX_ACCELERATION 5
#define MMIYOO_DEFAULT_INCREMENT_MODIFIER 0.1
#define DEFAULT_DIGIT_PATH "res/digit"
#define DEFAULT_BEZEL_PATH "res/bezel/standard/"
#define DEFAULT_INTEGER_BEZEL_PATH "res/bezel/integer_scaled/"
#define DEFAULT_BEZEL_ID 0
#define DEFAULT_INTEGER_BEZEL_ID 0
#define MAX_BEZELS 256
#define DEFAULT_MOUSE_ICON "res/icon/mouse.png"
#define PICO_CFG_PATH "cfg/onioncfg.json"
#define BUFFER_SIZE PATH_MAX + 20
#define MMIYOO_DEFAULT_KEY_L2 SDLK_d
#define MMIYOO_DEFAULT_KEY_L1 SDLK_d
#define MMIYOO_DEFAULT_KEY_UpDpad SDLK_UP
#define MMIYOO_DEFAULT_KEY_DownDpad SDLK_DOWN
#define MMIYOO_DEFAULT_KEY_LeftDpad SDLK_LEFT
#define MMIYOO_DEFAULT_KEY_RightDpad SDLK_RIGHT
#define MMIYOO_DEFAULT_KEY_R2 SDLK_d
#define MMIYOO_DEFAULT_KEY_R1 SDLK_d
#define MMIYOO_DEFAULT_KEY_A SDLK_z
#define MMIYOO_DEFAULT_KEY_B SDLK_x
#define MMIYOO_DEFAULT_KEY_X SDLK_ESCAPE
#define MMIYOO_DEFAULT_KEY_Y SDLK_d
#define MMIYOO_DEFAULT_KEY_Select SDLK_m
#define MMIYOO_DEFAULT_KEY_Start SDLK_RETURN
#define MMIYOO_DEFAULT_KEY_MENU SDLK_ESCAPE
#define MMIYOO_DEFAULT_CPU_CLOCK 1300
#define MMIYOO_MAX_CPU_CLOCK 1800
#define MMIYOO_MIN_CPU_CLOCK 600
#define MMIYOO_DEFAULT_CPU_CLOCK_INCREMENT 25
#define MMIYOO_MAX_CPU_CLOCK_INCREMENT 100
#define MMIYOO_DEFAULT_SCALE_FACTOR 2
#define MMIYOO_DEFAULT_ACCELERATION 2.0
#define MMIYOO_DEFAULT_ACCELERATION_RATE 1.5
#define MMIYOO_DEFAULT_MAX_ACCELERATION 5
#define MMIYOO_DEFAULT_INCREMENT_MODIFIER 0.1
#define MMIYOO_DEFAULT_MOUSE_HOTKEY 0
#define MMIYOO_DEFAULT_MOUSE_ICON 0
#define MMIYOO_DEFAULT_MOUSE_MINX 40
#define MMIYOO_DEFAULT_MOUSE_MINY 0
#define MMIYOO_DEFAULT_MOUSE_MAXX 280
#define MMIYOO_DEFAULT_MOUSE_MAXY 236

#define DEFAULT_DIGIT_PATH "res/digit"
#define DEFAULT_BEZEL_PATH "res/bezel/standard/"
#define DEFAULT_INTEGER_BEZEL_PATH "res/bezel/integer_scaled/"
#define DEFAULT_BEZEL_ID 0
#define DEFAULT_INTEGER_BEZEL_ID 0
#define MAX_BEZELS 256
#define DEFAULT_MOUSE_ICON "res/icon/mouse.png"

SDL_Keycode stringToKeycode(const char *keyString);
int picoConfigRead(void);
Expand All @@ -58,6 +65,12 @@ typedef struct _MOUSE {
float accelerationRate;
float maxAcceleration;
float incrementModifier;
int disableMouseHotkey;
int disableMouseIcon;
int minx;
int miny;
int maxx;
int maxy;
} MOUSE;

typedef struct _STATE {
Expand Down
2 changes: 1 addition & 1 deletion src/joystick/mmiyoo/SDL_joystick_mmiyoo.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ static SDL_JoystickID MMIYOO_JoystickGetDeviceInstanceID(int device_index)

static int MMIYOO_JoystickOpen(SDL_Joystick *joystick, int device_index)
{
joystick->nbuttons = 28; // tis a lie = FIXMARKER
joystick->nbuttons = 28; // tis a lie
joystick->naxes = 2;
joystick->nhats = 0;
return 0;
Expand Down
40 changes: 28 additions & 12 deletions src/render/mmiyoo/SDL_render_mmiyoo.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,24 +58,36 @@ struct _PICO_TEXTURE {

extern MMIYOO_EventInfo MMiyooEventInfo;
extern PICO pico;
extern int FB_W;
extern int FB_H;

static struct _PICO_TEXTURE ptex[MAX_TEXTURE] = {0};

static int update_texture(void *chk, void *new, const void *pixels, int pitch)
{
int cc = 0;
static int lastIndex = -1;

if (lastIndex != -1 && ptex[lastIndex].texture == chk) {
ptex[lastIndex].texture = new;
ptex[lastIndex].pixels = pixels;
ptex[lastIndex].pitch = pitch;
return lastIndex;
}

for (cc=0; cc<MAX_TEXTURE; cc++) {
for (int cc = 0; cc < MAX_TEXTURE; ++cc) {
if (ptex[cc].texture == chk) {
ptex[cc].texture = new;
ptex[cc].pixels = pixels;
ptex[cc].pitch = pitch;
lastIndex = cc;
return cc;
}
}

return -1;
}


static const void* get_pixels(void *chk)
{
int cc = 0;
Expand Down Expand Up @@ -205,18 +217,22 @@ static int MMIYOO_QueueFillRects(SDL_Renderer *renderer, SDL_RenderCommand *cmd,

static int MMIYOO_QueueCopy(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture, const SDL_Rect *srcrect, const SDL_FRect *dstrect)
{
int pitch = 0;
static int lastPitch = 0;
static const void *lastPixels = NULL;
static void *lastTexture = NULL;
SDL_Rect dst = {0};
const void *pixels = NULL;
static int show_digit_val = 0;
static int show_digit_num = 0;

float m = (640.0 / srcrect->w < 480.0 / srcrect->h) ? 640.0 / srcrect->w : 480.0 / srcrect->h;

pitch = get_pitch(texture);
pixels = get_pixels(texture);

if ((pitch == 0) || (pixels == NULL)) {
if (texture != lastTexture) {
lastPitch = get_pitch(texture);
lastPixels = get_pixels(texture);
lastTexture = texture;
}

if ((lastPitch == 0) || (lastPixels == NULL)) {
return 0;
}

Expand Down Expand Up @@ -270,11 +286,11 @@ static int MMIYOO_QueueCopy(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_
}

if (pico.state.screen_scaling != 1) {
dst.x = (640 - dst.w) / 2;
dst.y = (480 - dst.h) / 2;
dst.x = (FB_W - dst.w) / 2;
dst.y = (FB_H - dst.h) / 2;
}

GFX_Copy(pixels, *srcrect, dst, pitch, 0, E_MI_GFX_ROTATE_180);
GFX_Copy(lastPixels, *srcrect, dst, lastPitch, 0, 0);

return 0;
}
Expand Down
Loading

0 comments on commit 2caea47

Please sign in to comment.