allowing emulators to change method flags
This commit is contained in:
@@ -480,7 +480,7 @@ int main(int argc, char **argv) {
|
||||
nn_mountComponent(c, screen, -1, false);
|
||||
nn_mountComponent(c, ocelotCard, -1, false);
|
||||
//nn_mountComponent(c, tmpfs, -1, false);
|
||||
nn_mountComponent(c, keyboard, -1, false);
|
||||
nn_mountComponent(c, keyboard, -1, false);
|
||||
nn_mountComponent(c, eepromCard, 0, false);
|
||||
nn_mountComponent(c, managedfs, 1, false);
|
||||
nn_mountComponent(c, gpuCard, 2, false);
|
||||
@@ -619,6 +619,11 @@ skipDrawScreen:;
|
||||
printf("error: %s\n", nn_getError(c));
|
||||
goto cleanup;
|
||||
}
|
||||
e = nn_tickSynchronized(c);
|
||||
if(e != NN_OK) {
|
||||
printf("sync method error: %s\n", nn_getError(c));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
nn_ComputerState state = nn_getComputerState(c);
|
||||
if(state == NN_POWEROFF) break;
|
||||
|
||||
@@ -1779,6 +1779,34 @@ nn_Exit nn_setComponentTypeID(nn_Component *c, const char *internalTypeID) {
|
||||
return NN_OK;
|
||||
}
|
||||
|
||||
static nn_MethodEntry *nn_getComponentMethodEntry(nn_Component *c, const char *method) {
|
||||
nn_MethodEntry ent = {
|
||||
.name = method,
|
||||
};
|
||||
return nn_hashGet(&c->methodsMap, &ent);
|
||||
}
|
||||
|
||||
// Sets the method flags
|
||||
void nn_setComponentMethodFlags(nn_Component *c, const char *method, nn_MethodFlags flags) {
|
||||
nn_MethodEntry *ent = nn_getComponentMethodEntry(c, method);
|
||||
if(ent == NULL) return;
|
||||
ent->flags = flags;
|
||||
}
|
||||
|
||||
// combines method flags
|
||||
void nn_addComponentMethodFlags(nn_Component *c, const char *method, nn_MethodFlags flags) {
|
||||
nn_MethodEntry *ent = nn_getComponentMethodEntry(c, method);
|
||||
if(ent == NULL) return;
|
||||
ent->flags |= flags;
|
||||
}
|
||||
|
||||
// removes method flags
|
||||
void nn_removeComponentMethodFlags(nn_Component *c, const char *method, nn_MethodFlags flags) {
|
||||
nn_MethodEntry *ent = nn_getComponentMethodEntry(c, method);
|
||||
if(ent == NULL) return;
|
||||
ent->flags &= ~flags;
|
||||
}
|
||||
|
||||
void *nn_getComponentState(nn_Component *c) {
|
||||
return c->state;
|
||||
}
|
||||
@@ -1792,13 +1820,6 @@ size_t nn_countComponentMethods(nn_Component *c) {
|
||||
return c->methodCount;
|
||||
}
|
||||
|
||||
static nn_MethodEntry *nn_getComponentMethodEntry(nn_Component *c, const char *method) {
|
||||
nn_MethodEntry ent = {
|
||||
.name = method,
|
||||
};
|
||||
return nn_hashGet(&c->methodsMap, &ent);
|
||||
}
|
||||
|
||||
// will fill the methodnames array with the names of the *enabled* methods.
|
||||
// Will set *len to the amount of methods.
|
||||
void nn_getComponentMethods(nn_Component *c, const char **methodnames, size_t *len) {
|
||||
|
||||
@@ -678,6 +678,13 @@ nn_Exit nn_setComponentMethodsArray(nn_Component *c, const nn_Method *methods, s
|
||||
// so the GPU can confirm it is being bound to a screen it knows how to use.
|
||||
nn_Exit nn_setComponentTypeID(nn_Component *c, const char *internalTypeID);
|
||||
|
||||
// Sets the method flags
|
||||
void nn_setComponentMethodFlags(nn_Component *c, const char *method, nn_MethodFlags flags);
|
||||
// combines method flags
|
||||
void nn_addComponentMethodFlags(nn_Component *c, const char *method, nn_MethodFlags flags);
|
||||
// removes method flags
|
||||
void nn_removeComponentMethodFlags(nn_Component *c, const char *method, nn_MethodFlags flags);
|
||||
|
||||
// get component state
|
||||
void *nn_getComponentState(nn_Component *c);
|
||||
// get component class state
|
||||
|
||||
Reference in New Issue
Block a user