fork/m-overlay
git clone https://git.julia.blue/fork/m-overlay
2bc742e
settings-overhaul
1local core ={} 2 3function core . loadGenericControllerMap ( addr , game ) 4local controllers ={ 5[ 1 ] =addr + 0xC * 0 , 6[ 2 ] =addr + 0xC * 1 , 7[ 3 ] =addr + 0xC * 2 , 8[ 4 ] =addr + 0xC * 3 , 9} 10 11local controller_struct ={ 12[ 0x0 ] ={ type ="short" , name ="controller.%d.buttons.pressed" } , 13[ 0x2 ] ={ type ="sbyte" , name ="controller.%d.joystick.x" } , 14[ 0x3 ] ={ type ="sbyte" , name ="controller.%d.joystick.y" } , 15[ 0x4 ] ={ type ="sbyte" , name ="controller.%d.cstick.x" } , 16[ 0x5 ] ={ type ="sbyte" , name ="controller.%d.cstick.y" } , 17[ 0x6 ] ={ type ="byte" , name ="controller.%d.analog.l" } , 18[ 0x7 ] ={ type ="byte" , name ="controller.%d.analog.r" } , 19[ 0xA ] ={ type ="byte" , name ="controller.%d.plugged" } , 20} 21 22for port , address in ipairs ( controllers ) do 23for offset , info in pairs ( controller_struct ) do 24game . memorymap [ address + offset ] ={ 25type =info . type , 26debug =info . debug , 27name =info . name : format ( port ), 28} 29end 30end 31 32game . translateAxis =core . translateAxis 33game . translateTriggers =core . translateTriggers 34end 35 36local abs =math . abs 37 38-- These functions seem to apply to many games 39 40function core . translateAxis ( x , y ) 41x =x / 72 42y =y / 72 43 44local near =1 - ( abs ( abs ( x ) - abs ( y ))) * 0.72 45 46local angle =math . atan2 ( x , y ) 47local mag =math . sqrt ( x * x + y * y ) 48 49-- Amplify the magnitute when x,y values are headed towards a diagonal 50return x + math . sin ( angle ) * mag * near * 0.28 , y + math . cos ( angle ) * mag * near * 0.28 51end 52 53local min =math . min 54 55function core . translateTriggers ( l , r ) 56return min ( 1 , l / 125 ), min ( 1 , r / 125 ) 57end 58 59return core