AndunHH / spacemouse

Repository for the space mouse based on four joysticks and keys
Other
42 stars 9 forks source link

Compilation error when `NUMKEYS` is set to something else than 4 #21

Closed coliss86 closed 2 weeks ago

coliss86 commented 2 weeks ago

Hi,

when setting NUMKEYSto 0 for example, the code doesn't compile :

/Users/coliss86/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_1.8.6 -DUSB_VID=0x046d -DUSB_PID=0xc62b "-DUSB_MANUFACTURER=\"3Dconnexion\"" "-DUSB_PRODUCT=\"SpaceMouse Pro Wireless\"" -I/Users/coliss86/Documents/Arduino/hardware/avr/1.8.6/cores/arduino -I/Users/coliss86/Documents/Arduino/hardware/avr/1.8.6/variants/leonardo -I/Users/coliss86/Documents/Arduino/hardware/avr/1.8.6/libraries/HID/src /private/var/folders/_v/3mbgv__n4ps26g46195spmy40000gn/T/arduino/sketches/1B39D9A13F5C2808FC99DE8A9AEA0721/sketch/spacemouse-keys.ino.cpp -o /private/var/folders/_v/3mbgv__n4ps26g46195spmy40000gn/T/arduino/sketches/1B39D9A13F5C2808FC99DE8A9AEA0721/sketch/spacemouse-keys.ino.cpp.o
Using previously compiled file: /private/var/folders/_v/3mbgv__n4ps26g46195spmy40000gn/T/arduino/sketches/1B39D9A13F5C2808FC99DE8A9AEA0721/sketch/calibration.cpp.o
/Users/coliss86/Documents/Arduino/temp/spacemouse/spacemouse-keys/spacemouse-keys.ino:75:39: error: too many initializers for 'int [0]'
 int keyList[NUMKEYS] = {K0, K1, K2, K3};
                                       ^

Using library HID at version 1.0 in folder: /Users/coliss86/Documents/Arduino/hardware/avr/1.8.6/libraries/HID 
exit status 1

Compilation error: too many initializers for 'int [0]'

This is due to int keyList[NUMKEYS] = {K0, K1, K2, K3}; being hard coded in spacemouse-keys.ino. What do you think of moving it to config.h like PINLIST?

AndunHH commented 2 weeks ago

You are absolutely right. I changed this behavior with commit 5469856.

To have an easier conversation about errors in the code, I created a Release called 0.5 today, before I merged the platformio support.

I have only soldered four buttons to my mouse, therefore I have not tested, if the 3cdonnexion driver is accepting more buttons than four. But the arduino code should now work with more.

Can you check with the new version?

AndunHH commented 2 weeks ago

Despite the coding problem discussed above, the key support is not very advanced now. I try to get some answer how the usb protocoll is working by asking the spacenavd project, which has an 3dconnexion driver: https://github.com/FreeSpacenav/spacenavd/discussions/106

coliss86 commented 2 weeks ago

This is perfect, the compilation is fixed, thx :)