[Fuse-for-macosx-commits] SF.net SVN: fuse-for-macosx:[832] trunk/fuse
Brought to you by:
fredm
From: <fr...@us...> - 2016-10-28 11:30:27
|
Revision: 832 http://sourceforge.net/p/fuse-for-macosx/code/832 Author: fredm Date: 2016-10-28 11:30:23 +0000 (Fri, 28 Oct 2016) Log Message: ----------- Fix for Recreated Spectrum bottom key row handling See [bugs:#23] Modified Paths: -------------- trunk/fuse/fusepb/models/Emulator.h trunk/fuse/fusepb/models/Emulator.m trunk/fuse/ui/cocoa/keysyms.m Modified: trunk/fuse/fusepb/models/Emulator.h =================================================================== --- trunk/fuse/fusepb/models/Emulator.h 2016-10-21 11:27:17 UTC (rev 831) +++ trunk/fuse/fusepb/models/Emulator.h 2016-10-28 11:30:23 UTC (rev 832) @@ -40,6 +40,7 @@ float timerInterval; GHashTable *unicode_keysyms_hash; + GHashTable *recreated_keysyms_hash; BOOL optDown; BOOL ctrlDown; Modified: trunk/fuse/fusepb/models/Emulator.m =================================================================== --- trunk/fuse/fusepb/models/Emulator.m 2016-10-21 11:27:17 UTC (rev 831) +++ trunk/fuse/fusepb/models/Emulator.m 2016-10-28 11:30:23 UTC (rev 832) @@ -57,6 +57,7 @@ #include "zxcf.h" extern keysyms_map_t unicode_keysyms_map[]; +extern keysyms_map_t recreated_keysyms_map[]; #include "sound/sfifo.h" @@ -629,17 +630,23 @@ ui_mouse_button( 2, 0 ); } --(void) initKeyboard +-(GHashTable*) initKeySymsHash:(keysyms_map_t *)keysyms_map { keysyms_map_t *ptr3; + GHashTable* keysyms_hash = g_hash_table_new( g_int_hash, g_int_equal ); - unicode_keysyms_hash = g_hash_table_new( g_int_hash, g_int_equal ); + for( ptr3 = keysyms_map; ptr3->ui; ptr3++ ) + g_hash_table_insert( keysyms_hash, &( ptr3->ui ), &( ptr3->fuse ) ); - for( ptr3 = (keysyms_map_t *)unicode_keysyms_map; ptr3->ui; ptr3++ ) - g_hash_table_insert( unicode_keysyms_hash, &( ptr3->ui ), - &( ptr3->fuse ) ); + return keysyms_hash; } +-(void) initKeyboard +{ + unicode_keysyms_hash = [self initKeySymsHash:unicode_keysyms_map]; + recreated_keysyms_hash = [self initKeySymsHash:recreated_keysyms_map]; +} + -(void) modifierChange:(input_event_type)theType oldState:(BOOL)old newState:(BOOL)new { if( old != new ) { @@ -735,12 +742,17 @@ input_key fuse_keysym; enum events event_type; - fuse_keysym = keysyms_remap( keyCode ); - if( fuse_keysym == INPUT_KEY_NONE ) { - fuse_keysym = [self otherKeysymsRemap:[characters characterAtIndex:0] - inHash:unicode_keysyms_hash]; + // If recreated ZX spectrum is enabled, look up unshifted key in recreated_keysyms_map, + // else move on to normal path + if( !( settings_current.recreated_spectrum && + (fuse_keysym = [self otherKeysymsRemap:keyCode inHash:recreated_keysyms_hash]) != INPUT_KEY_NONE) ) { + fuse_keysym = keysyms_remap( keyCode ); + if( fuse_keysym == INPUT_KEY_NONE ) { + fuse_keysym = [self otherKeysymsRemap:[characters characterAtIndex:0] + inHash:unicode_keysyms_hash]; + } } - + if( [self isSpecial:fuse_keysym] == YES ) { event_type = type == INPUT_EVENT_KEYPRESS ? PRESS_SPECIAL : RELEASE_SPECIAL; Modified: trunk/fuse/ui/cocoa/keysyms.m =================================================================== --- trunk/fuse/ui/cocoa/keysyms.m 2016-10-21 11:27:17 UTC (rev 831) +++ trunk/fuse/ui/cocoa/keysyms.m 2016-10-28 11:30:23 UTC (rev 832) @@ -49,7 +49,7 @@ { 82, INPUT_KEY_0 }, { 65, INPUT_KEY_period }, { 75, INPUT_KEY_slash }, - { 67, INPUT_KEY_asterisk }, + { 67, INPUT_KEY_asterisk }, { 78, INPUT_KEY_minus }, { 69, INPUT_KEY_plus }, { 76, INPUT_KEY_Return }, @@ -97,6 +97,21 @@ }; +/* Map ADC keyboard scancode to Fuse input layer keysym for Recreated + ZX Spectrum keyboard */ +keysyms_map_t recreated_keysyms_map[] = { + + { 44, INPUT_KEY_slash }, + { 41, INPUT_KEY_semicolon }, + { 43, INPUT_KEY_comma }, + { 47, INPUT_KEY_period }, + { 33, INPUT_KEY_bracketleft }, + { 30, INPUT_KEY_bracketright }, + + { 0, 0 } /* End marker: DO NOT MOVE! */ + +}; + /* Map UCS-2(?) Unicode to Fuse input layer keysym for non-extended mode Spectrum symbols present on keyboards */ keysyms_map_t unicode_keysyms_map[] = { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |