1
0
mirror of https://github.com/raphnet/gc_n64_usb-v3 synced 2025-01-30 23:00:11 -05:00
This commit is contained in:
Raphael Assenat 2015-11-03 21:28:15 -05:00
parent 2e95867469
commit 9c43932abe
4 changed files with 99 additions and 62 deletions

View File

@ -91,6 +91,9 @@ Author: Raphaël Assénat
<patterns> <patterns>
<pattern>*.mpk</pattern> <pattern>*.mpk</pattern>
<pattern>*.n64</pattern> <pattern>*.n64</pattern>
<pattern>*.N64</pattern>
<pattern>*.MPK</pattern>
<pattern>*.Mpk</pattern>
</patterns> </patterns>
</object> </object>
<object class="GtkFileFilter" id="n64_note_filter"> <object class="GtkFileFilter" id="n64_note_filter">
@ -106,6 +109,8 @@ Author: Raphaël Assénat
<column type="gchararray"/> <column type="gchararray"/>
<!-- column-name Pages --> <!-- column-name Pages -->
<column type="gint"/> <column type="gint"/>
<!-- column-name Comments -->
<column type="gchararray"/>
</columns> </columns>
</object> </object>
<object class="GtkAdjustment" id="pollrate_adjustment"> <object class="GtkAdjustment" id="pollrate_adjustment">
@ -979,52 +984,77 @@ Author: Raphaël Assénat
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkTreeView" id="n64_notes_treeview"> <object class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="vexpand">True</property> <property name="shadow_type">in</property>
<property name="model">n64_notes</property> <property name="min_content_width">600</property>
<property name="enable_search">False</property> <property name="min_content_height">300</property>
<property name="enable_grid_lines">both</property>
<property name="enable_tree_lines">True</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection1"/>
</child>
<child> <child>
<object class="GtkTreeViewColumn" id="treeviewcolumn1"> <object class="GtkTreeView" id="n64_notes_treeview">
<property name="resizable">True</property> <property name="visible">True</property>
<property name="title" translatable="yes">Note ID</property> <property name="can_focus">True</property>
<child> <property name="vexpand">True</property>
<object class="GtkCellRendererText" id="cellrenderertext3"/> <property name="vscroll_policy">natural</property>
<attributes> <property name="model">n64_notes</property>
<attribute name="text">0</attribute> <property name="enable_search">False</property>
</attributes> <property name="enable_grid_lines">both</property>
<property name="enable_tree_lines">True</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection1"/>
</child> </child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn2">
<property name="resizable">True</property>
<property name="title" translatable="yes">Game Data</property>
<property name="expand">True</property>
<child> <child>
<object class="GtkCellRendererText" id="cellrenderertext4"/> <object class="GtkTreeViewColumn" id="treeviewcolumn1">
<attributes> <property name="resizable">True</property>
<attribute name="text">1</attribute> <property name="title" translatable="yes">Note ID</property>
</attributes> <child>
<object class="GtkCellRendererText" id="cellrenderertext3"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
</child> </child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn3">
<property name="resizable">True</property>
<property name="title" translatable="yes">Pages</property>
<property name="sort_order">descending</property>
<child> <child>
<object class="GtkCellRendererText" id="cellrenderertext5"/> <object class="GtkTreeViewColumn" id="treeviewcolumn2">
<attributes> <property name="resizable">True</property>
<attribute name="text">2</attribute> <property name="title" translatable="yes">Game Data</property>
</attributes> <child>
<object class="GtkCellRendererText" id="cellrenderertext4"/>
<attributes>
<attribute name="text">1</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn3">
<property name="resizable">True</property>
<property name="title" translatable="yes">Pages</property>
<property name="sort_order">descending</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext5"/>
<attributes>
<attribute name="text">2</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn4">
<property name="resizable">True</property>
<property name="title" translatable="yes">Comments</property>
<property name="expand">True</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext6">
<property name="ellipsize">end</property>
<property name="wrap_mode">word</property>
</object>
<attributes>
<attribute name="text">3</attribute>
</attributes>
</child>
</object>
</child> </child>
</object> </object>
</child> </child>

View File

@ -210,7 +210,7 @@ void deselect_adapter(struct application *app)
gtk_combo_box_set_active_iter(cb_adapter_list, NULL); gtk_combo_box_set_active_iter(cb_adapter_list, NULL);
} }
void infoPopop(struct application *app, const char *message) void infoPopup(struct application *app, const char *message)
{ {
GtkWidget *dialog; GtkWidget *dialog;
@ -225,7 +225,7 @@ void infoPopop(struct application *app, const char *message)
} }
void errorPopop(struct application *app, const char *message) void errorPopup(struct application *app, const char *message)
{ {
GtkWidget *dialog; GtkWidget *dialog;
@ -282,7 +282,7 @@ G_MODULE_EXPORT void update_usbadapter_firmware(GtkWidget *w, gpointer data)
return; return;
} }
if (pclose(dfu_fp)) { if (pclose(dfu_fp)) {
errorPopop(app, "dfu-programmmer not found. Cannot perform update."); errorPopup(app, "dfu-programmmer not found. Cannot perform update.");
return; return;
} }
@ -309,7 +309,7 @@ G_MODULE_EXPORT void update_usbadapter_firmware(GtkWidget *w, gpointer data)
app->updateHexFile = filename; app->updateHexFile = filename;
if (!check_ihex_for_signature(filename, "9c3ea8b8-753f-11e5-a0dc-001bfca3c593")) { if (!check_ihex_for_signature(filename, "9c3ea8b8-753f-11e5-a0dc-001bfca3c593")) {
errorPopop(app, "Signature not found - This file is invalid or not meant for this adapter"); errorPopup(app, "Signature not found - This file is invalid or not meant for this adapter");
} }
/* Prepare the update dialog widgets... */ /* Prepare the update dialog widgets... */
@ -322,9 +322,9 @@ G_MODULE_EXPORT void update_usbadapter_firmware(GtkWidget *w, gpointer data)
gtk_widget_hide( GTK_WIDGET(firmware_update_dialog)); gtk_widget_hide( GTK_WIDGET(firmware_update_dialog));
if (res == GTK_RESPONSE_OK) { if (res == GTK_RESPONSE_OK) {
infoPopop(app, "Update succeeded."); infoPopup(app, "Update succeeded.");
} else if (res == GTK_RESPONSE_REJECT) { } else if (res == GTK_RESPONSE_REJECT) {
errorPopop(app, "Update failed. Suggestion: Do not disconnect the adapter and retry right away!"); errorPopup(app, "Update failed. Suggestion: Do not disconnect the adapter and retry right away!");
} }
printf("Update dialog done\n"); printf("Update dialog done\n");
@ -414,7 +414,7 @@ G_MODULE_EXPORT void pollIntervalChanged(GtkWidget *win, gpointer data)
n = gcn64lib_setConfig(app->current_adapter_handle, CFG_PARAM_POLL_INTERVAL0, &buf, 1); n = gcn64lib_setConfig(app->current_adapter_handle, CFG_PARAM_POLL_INTERVAL0, &buf, 1);
if (n != 0) { if (n != 0) {
errorPopop(app, "Error setting configuration"); errorPopup(app, "Error setting configuration");
deselect_adapter(app); deselect_adapter(app);
rebuild_device_list_store(data); rebuild_device_list_store(data);
} }
@ -442,7 +442,7 @@ G_MODULE_EXPORT void config_checkbox_changed(GtkWidget *win, gpointer data)
buf = gtk_toggle_button_get_active(configurable_bits[i].chkbtn); buf = gtk_toggle_button_get_active(configurable_bits[i].chkbtn);
n = gcn64lib_setConfig(app->current_adapter_handle, configurable_bits[i].cfg_param, &buf, 1); n = gcn64lib_setConfig(app->current_adapter_handle, configurable_bits[i].cfg_param, &buf, 1);
if (n != 0) { if (n != 0) {
errorPopop(app, "Error setting configuration"); errorPopup(app, "Error setting configuration");
deselect_adapter(app); deselect_adapter(app);
rebuild_device_list_store(app); rebuild_device_list_store(app);
break; break;
@ -532,7 +532,7 @@ G_MODULE_EXPORT void adapterSelected(GtkComboBox *cb, gpointer data)
app->current_adapter_handle = gcn64_openDevice(info); app->current_adapter_handle = gcn64_openDevice(info);
if (!app->current_adapter_handle) { if (!app->current_adapter_handle) {
errorPopop(app, "Failed to open adapter"); errorPopup(app, "Failed to open adapter");
deselect_adapter(app); deselect_adapter(app);
return; return;
} }
@ -568,19 +568,23 @@ G_MODULE_EXPORT void onFileRescan(GtkWidget *wid, gpointer data)
rebuild_device_list_store(data); rebuild_device_list_store(data);
} }
static void mempak_io_progress_cb(int progress, void *ctx) static int mempak_io_progress_cb(int progress, void *ctx)
{ {
struct application *app = ctx; struct application *app = ctx;
GET_UI_ELEMENT(GtkProgressBar, mempak_io_progress); GET_UI_ELEMENT(GtkProgressBar, mempak_io_progress);
gdouble fract;
fract = progress/MEMPAK_BLOCK_SIZE;
gtk_progress_bar_set_fraction(mempak_io_progress, progress/((gdouble)MEMPAK_MEM_SIZE)); gtk_progress_bar_set_fraction(mempak_io_progress, progress/((gdouble)MEMPAK_MEM_SIZE));
while (gtk_events_pending()) { while (gtk_events_pending()) {
gtk_main_iteration_do(FALSE); gtk_main_iteration_do(FALSE);
} }
return app->stop_reading_mempak;
}
G_MODULE_EXPORT void mempak_io_stop(GtkWidget *wid, gpointer data)
{
struct application *app = data;
app->stop_reading_mempak = 1;
} }
G_MODULE_EXPORT void read_n64_pak(GtkWidget *wid, gpointer data) G_MODULE_EXPORT void read_n64_pak(GtkWidget *wid, gpointer data)
@ -599,16 +603,18 @@ G_MODULE_EXPORT void read_n64_pak(GtkWidget *wid, gpointer data)
gtk_widget_show(GTK_WIDGET(mempak_io_dialog)); gtk_widget_show(GTK_WIDGET(mempak_io_dialog));
gtk_label_set_text(mempak_op_label, "Reading memory pack..."); gtk_label_set_text(mempak_op_label, "Reading memory pack...");
app->stop_reading_mempak = 0;
res = gcn64lib_mempak_download(app->current_adapter_handle, 0, &mpk, mempak_io_progress_cb, app); res = gcn64lib_mempak_download(app->current_adapter_handle, 0, &mpk, mempak_io_progress_cb, app);
gtk_widget_hide(GTK_WIDGET(mempak_io_dialog)); gtk_widget_hide(GTK_WIDGET(mempak_io_dialog));
if (res != 0) { if (res != 0) {
switch(res) switch(res)
{ {
case -1: errorPopop(app, "No mempak detected"); break; case -1: errorPopup(app, "No mempak detected"); break;
case -2: errorPopop(app, "I/O error reading mempak"); break; case -2: errorPopup(app, "I/O error reading mempak"); break;
case -4: errorPopup(app, "Read aborted"); break;
default: default:
case -3: errorPopop(app, "Error reading mempak"); break; case -3: errorPopup(app, "Error reading mempak"); break;
} }
} }
else { else {

View File

@ -8,7 +8,7 @@
#define GET_ELEMENT(TYPE, ELEMENT) (TYPE *)gtk_builder_get_object(app->builder, #ELEMENT) #define GET_ELEMENT(TYPE, ELEMENT) (TYPE *)gtk_builder_get_object(app->builder, #ELEMENT)
#define GET_UI_ELEMENT(TYPE, ELEMENT) TYPE *ELEMENT = GET_ELEMENT(TYPE, ELEMENT) #define GET_UI_ELEMENT(TYPE, ELEMENT) TYPE *ELEMENT = GET_ELEMENT(TYPE, ELEMENT)
void errorPopop(struct application *app, const char *message); void errorPopup(struct application *app, const char *message);
struct application { struct application {
GtkBuilder *builder; GtkBuilder *builder;
@ -24,6 +24,7 @@ struct application {
int update_dialog_response; int update_dialog_response;
struct mpkedit_data *mpke; struct mpkedit_data *mpke;
int stop_reading_mempak;
}; };

View File

@ -175,7 +175,7 @@ G_MODULE_EXPORT void mpke_export_note(GtkWidget *win, gpointer data)
if (0==get_mempak_entry(app->mpke->mpk, selection, &entry)) { if (0==get_mempak_entry(app->mpke->mpk, selection, &entry)) {
char namebuf[64]; char namebuf[64];
if (!entry.valid) { if (!entry.valid) {
errorPopop(app, "Please select a non-empty note"); errorPopup(app, "Please select a non-empty note");
return; return;
} }
@ -198,7 +198,7 @@ G_MODULE_EXPORT void mpke_export_note(GtkWidget *win, gpointer data)
filename = gtk_file_chooser_get_filename(chooser); filename = gtk_file_chooser_get_filename(chooser);
if (mempak_exportNote(app->mpke->mpk, selection, filename)) { if (mempak_exportNote(app->mpke->mpk, selection, filename)) {
errorPopop(app, "Could not export note"); errorPopup(app, "Could not export note");
} else { } else {
printf("Note saved to %s\n", filename); printf("Note saved to %s\n", filename);
} }
@ -255,8 +255,8 @@ G_MODULE_EXPORT void mpke_insert_note(GtkWidget *win, gpointer data)
switch(res) switch(res)
{ {
default: default:
case -1: errorPopop(app, "Error loading file or inserting note\n"); break; case -1: errorPopup(app, "Error loading file or inserting note\n"); break;
case -2: errorPopop(app, "Not enough free blocks to insert note\n"); break; case -2: errorPopup(app, "Not enough free blocks to insert note\n"); break;
} }
} else { } else {
// Success // Success
@ -309,7 +309,7 @@ G_MODULE_EXPORT void mpke_open(GtkWidget *win, gpointer data)
app->mpke->modified = 0; app->mpke->modified = 0;
mpke_replaceMpk(app, mpk, filename); mpke_replaceMpk(app, mpk, filename);
} else { } else {
errorPopop(app, "Failed to load mempak"); errorPopup(app, "Failed to load mempak");
} }
} }
@ -361,7 +361,7 @@ G_MODULE_EXPORT void mpke_saveas(GtkWidget *win, gpointer data)
app->mpke->modified = 0; app->mpke->modified = 0;
mpke_updateFilename(app,filename); mpke_updateFilename(app,filename);
} else { } else {
errorPopop(app, "Unknown file format specified"); errorPopup(app, "Unknown file format specified");
} }
} }