-
-
Notifications
You must be signed in to change notification settings - Fork 83
Add wireless controller syncing functionality to WPAD/LWBT #197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
2b918cd
60df481
b1b84fd
ccfe267
e096919
d0d0191
57f2921
3cb9d09
4d5665a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ distribution. | |
#include <stdio.h> | ||
#include <string.h> | ||
#include <malloc.h> | ||
#include <gcbool.h> | ||
#include "ipc.h" | ||
#include "asm.h" | ||
#include "processor.h" | ||
|
@@ -40,6 +41,7 @@ distribution. | |
static int __conf_inited = 0; | ||
static u8 __conf_buffer[0x4000] ATTRIBUTE_ALIGN(32); | ||
static char __conf_txt_buffer[0x101] ATTRIBUTE_ALIGN(32); | ||
static int __conf_buffer_dirty = FALSE; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use actual |
||
|
||
static const char __conf_file[] ATTRIBUTE_ALIGN(32) = "/shared2/sys/SYSCONF"; | ||
static const char __conf_txt_file[] ATTRIBUTE_ALIGN(32) = "/title/00000001/00000002/data/setting.txt"; | ||
|
@@ -207,6 +209,78 @@ s32 CONF_Get(const char *name, void *buffer, u32 length) | |
return len; | ||
} | ||
|
||
s32 CONF_Set(const char *name, const void *buffer, u32 length) | ||
{ | ||
u8 *entry; | ||
s32 len; | ||
if(!__conf_inited) return CONF_ENOTINIT; | ||
|
||
entry = __CONF_Find(name); | ||
if(!entry) return CONF_ENOENT; | ||
|
||
len = CONF_GetLength(name); | ||
if(len<0) return len; | ||
if(len!=length) return CONF_EBADVALUE; | ||
|
||
switch(*entry>>5) { | ||
case CONF_BIGARRAY: | ||
memcpy(&entry[strlen(name)+3], buffer, len); | ||
break; | ||
case CONF_SMALLARRAY: | ||
memcpy(&entry[strlen(name)+2], buffer, len); | ||
break; | ||
case CONF_BYTE: | ||
case CONF_SHORT: | ||
case CONF_LONG: | ||
case CONF_BOOL: | ||
memcpy(&entry[strlen(name)+1], buffer, len); | ||
break; | ||
default: | ||
return CONF_ENOTIMPL; | ||
} | ||
__conf_buffer_dirty = TRUE; | ||
return len; | ||
} | ||
|
||
int __CONF_WriteBuffer(void) | ||
{ | ||
int ret, fd; | ||
|
||
if (!__conf_inited) | ||
return CONF_ENOTINIT; | ||
|
||
if (!__conf_buffer_dirty) | ||
return 0; | ||
|
||
fd = IOS_Open(__conf_file, 2); | ||
if (fd < 0) | ||
return fd; | ||
|
||
ret = IOS_Write(fd, __conf_buffer, 0x4000); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i would add a define with the value of |
||
IOS_Close(fd); | ||
if (ret != 0x4000) | ||
return CONF_EBADFILE; | ||
|
||
__conf_buffer_dirty = FALSE; | ||
return 0; | ||
} | ||
|
||
s32 CONF_SaveChanges(void) | ||
{ | ||
s32 ret; | ||
if (!__conf_inited) | ||
return CONF_ENOTINIT; | ||
ret = __CONF_WriteBuffer(); | ||
if (ret < 0) | ||
return ret; | ||
|
||
/*ret = __CONF_WriteTxtBuffer(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in comments and not implemented, can be removed :) |
||
if (ret < 0) | ||
return ret;*/ | ||
|
||
return CONF_ERR_OK; | ||
} | ||
|
||
s32 CONF_GetShutdownMode(void) | ||
{ | ||
u8 idleconf[2] = {0,0}; | ||
|
@@ -346,6 +420,36 @@ s32 CONF_GetPadDevices(conf_pads *pads) | |
return 0; | ||
} | ||
|
||
s32 CONF_SetPadDevices(const conf_pads *pads) | ||
{ | ||
u8 count; | ||
|
||
if (!pads) return CONF_EBADVALUE; | ||
count = pads->num_registered; | ||
if (count > CONF_PAD_MAX_REGISTERED) return CONF_EBADVALUE; | ||
return CONF_Set("BT.DINF", pads, sizeof(conf_pads)); | ||
} | ||
|
||
s32 CONF_GetPadGuestDevices(conf_pad_guests *pads) | ||
{ | ||
int res; | ||
|
||
res = CONF_Get("BT.CDIF", pads, sizeof(conf_pad_guests)); | ||
if(res < 0) return res; | ||
if(res < sizeof(conf_pad_guests)) return CONF_EBADVALUE; | ||
return 0; | ||
} | ||
|
||
s32 CONF_SetPadGuestDevices(const conf_pad_guests *pads) | ||
{ | ||
u8 count; | ||
|
||
if (!pads) return CONF_EBADVALUE; | ||
count = pads->num_guests; | ||
if (count > CONF_PAD_MAX_ACTIVE) return CONF_EBADVALUE; | ||
return CONF_Set("BT.CDIF", pads, sizeof(conf_pad_guests)); | ||
} | ||
|
||
s32 CONF_GetNickName(u8 *nickname) | ||
{ | ||
int i, res; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stupid minor change, but i'd put the Get & Set's together :)