I hacked a bit on the headphoned code adding another watch for the file /sys/devices/platform/nokia-av/detect but it doesn't detect any change Then I've tried with inotifywait for both files /sys/devices/platform/nokia-av/detect and /sys/devices/platform/gpio-switch/headphone/state I've been surprised to see that a change is detected only for the latter. So I think there's no other way than polling the file.
Making a replacement /usr/lib/ohm/libohm_accessories.so that would register the headset in the first place as a headset wouldn't be hard work (riiiight...) thanks to IDA Pro and the examples of plugins found in the OHM package but there's no point when you can just modify nokia-av.ko to not disable the button, which is what I will be doing soon. **** you, Nokia, and your stupid decisions.