Mercurial > repos > blastem
comparison io.c @ 913:a5a51465f8b0
Allow IO device config to be overriden by ROM DB
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Tue, 08 Dec 2015 19:33:58 -0800 |
parents | 599e2861f484 |
children | 28ec32e720b2 |
comparison
equal
deleted
inserted
replaced
912:599e2861f484 | 913:a5a51465f8b0 |
---|---|
643 static void cleanup_sockfile() | 643 static void cleanup_sockfile() |
644 { | 644 { |
645 unlink(sockfile_name); | 645 unlink(sockfile_name); |
646 } | 646 } |
647 | 647 |
648 void setup_io_devices(tern_node * config, io_port * ports) | 648 void setup_io_devices(tern_node * config, rom_info *rom, io_port * ports) |
649 { | 649 { |
650 tern_node *io_nodes = tern_get_node(tern_find_path(config, "io\0devices\0")); | 650 tern_node *io_nodes = tern_get_node(tern_find_path(config, "io\0devices\0")); |
651 char * io_1 = tern_find_ptr(io_nodes, "1"); | 651 char * io_1 = rom->port1_override ? rom->port1_override : tern_find_ptr(io_nodes, "1"); |
652 char * io_2 = tern_find_ptr(io_nodes, "2"); | 652 char * io_2 = rom->port2_override ? rom->port2_override : tern_find_ptr(io_nodes, "2"); |
653 char * io_ext = tern_find_ptr(io_nodes, "ext"); | 653 char * io_ext = rom->ext_override ? rom->ext_override : tern_find_ptr(io_nodes, "ext"); |
654 | 654 |
655 process_device(io_1, ports); | 655 process_device(io_1, ports); |
656 process_device(io_2, ports+1); | 656 process_device(io_2, ports+1); |
657 process_device(io_ext, ports+2); | 657 process_device(io_ext, ports+2); |
658 | 658 |
799 } | 799 } |
800 if (bindtype != BIND_UI) { | 800 if (bindtype != BIND_UI) { |
801 bindtype += devicenum-1; | 801 bindtype += devicenum-1; |
802 } | 802 } |
803 mice[state->mouseidx].buttons[buttonnum].bind_type = bindtype; | 803 mice[state->mouseidx].buttons[buttonnum].bind_type = bindtype; |
804 | 804 |
805 } | 805 } |
806 | 806 |
807 void process_mouse(char *mousenum, tern_val value, void *data) | 807 void process_mouse(char *mousenum, tern_val value, void *data) |
808 { | 808 { |
809 tern_node **buttonmaps = data; | 809 tern_node **buttonmaps = data; |
810 tern_node *mousedef = tern_get_node(value); | 810 tern_node *mousedef = tern_get_node(value); |
811 tern_node *padbuttons = buttonmaps[0]; | 811 tern_node *padbuttons = buttonmaps[0]; |
812 tern_node *mousebuttons = buttonmaps[1]; | 812 tern_node *mousebuttons = buttonmaps[1]; |
813 | 813 |
814 if (!mousedef) { | 814 if (!mousedef) { |
815 warning("Binding for mouse %s is a scalar!\n", mousenum); | 815 warning("Binding for mouse %s is a scalar!\n", mousenum); |
816 return; | 816 return; |
817 } | 817 } |
818 int mouseidx = atoi(mousenum); | 818 int mouseidx = atoi(mousenum); |
865 padbuttons = tern_insert_int(padbuttons, ".x", BUTTON_X); | 865 padbuttons = tern_insert_int(padbuttons, ".x", BUTTON_X); |
866 padbuttons = tern_insert_int(padbuttons, ".y", BUTTON_Y); | 866 padbuttons = tern_insert_int(padbuttons, ".y", BUTTON_Y); |
867 padbuttons = tern_insert_int(padbuttons, ".z", BUTTON_Z); | 867 padbuttons = tern_insert_int(padbuttons, ".z", BUTTON_Z); |
868 padbuttons = tern_insert_int(padbuttons, ".start", BUTTON_START); | 868 padbuttons = tern_insert_int(padbuttons, ".start", BUTTON_START); |
869 padbuttons = tern_insert_int(padbuttons, ".mode", BUTTON_MODE); | 869 padbuttons = tern_insert_int(padbuttons, ".mode", BUTTON_MODE); |
870 | 870 |
871 tern_node *mousebuttons = tern_insert_int(NULL, ".left", MOUSE_LEFT); | 871 tern_node *mousebuttons = tern_insert_int(NULL, ".left", MOUSE_LEFT); |
872 mousebuttons = tern_insert_int(mousebuttons, ".middle", MOUSE_MIDDLE); | 872 mousebuttons = tern_insert_int(mousebuttons, ".middle", MOUSE_MIDDLE); |
873 mousebuttons = tern_insert_int(mousebuttons, ".right", MOUSE_RIGHT); | 873 mousebuttons = tern_insert_int(mousebuttons, ".right", MOUSE_RIGHT); |
874 mousebuttons = tern_insert_int(mousebuttons, ".start", MOUSE_START); | 874 mousebuttons = tern_insert_int(mousebuttons, ".start", MOUSE_START); |
875 mousebuttons = tern_insert_int(mousebuttons, ".motion", PSEUDO_BUTTON_MOTION); | 875 mousebuttons = tern_insert_int(mousebuttons, ".motion", PSEUDO_BUTTON_MOTION); |
1244 input = 0x10; | 1244 input = 0x10; |
1245 } else { | 1245 } else { |
1246 input = 0; | 1246 input = 0; |
1247 } | 1247 } |
1248 } else { | 1248 } else { |
1249 | 1249 |
1250 int16_t delta_x = port->device.mouse.latched_x - port->device.mouse.last_read_x; | 1250 int16_t delta_x = port->device.mouse.latched_x - port->device.mouse.last_read_x; |
1251 int16_t delta_y = port->device.mouse.last_read_y - port->device.mouse.latched_y; | 1251 int16_t delta_y = port->device.mouse.last_read_y - port->device.mouse.latched_y; |
1252 switch (port->device.mouse.tr_counter) | 1252 switch (port->device.mouse.tr_counter) |
1253 { | 1253 { |
1254 case 0: | 1254 case 0: |