Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 22:50 15 Sep 2026 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : CMM2 Check for Nunchuk Controller

Author Message
Archimedes5000
Newbie

Joined: 21/01/2021
Location: Germany
Posts: 6
Posted: 09:48am 07 Apr 2021
Copy link to clipboard 
Print this post

Hello,

CMM2 V5.06 - is it possible to check the presence of a nunchuck controller without the program ending with an error?

Greetings Axel
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 9131
Posted: 10:11am 07 Apr 2021
Copy link to clipboard 
Print this post

I've not used a nunchuck, but I'd attempt it by setting up a ON ERROR SKIP [nn] before a nunchuck command to read something, then check to see if the returned value is zero. If it is then there's no nunchuck.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
 
Archimedes5000
Newbie

Joined: 21/01/2021
Location: Germany
Posts: 6
Posted: 10:29am 07 Apr 2021
Copy link to clipboard 
Print this post

Hi, thank you!
By searching for "On Error skip" I found this
https://www.thebackshed.com/Forum/ViewTopic_mobile.php?TID=13475&P=1

Will try and be back later.

Greetings Axel
 
twofingers

Guru

Joined: 02/06/2014
Location: Germany
Posts: 1769
Posted: 10:41am 07 Apr 2021
Copy link to clipboard 
Print this post

Please take a look at this example:
'Mandelbrot Explorer V1.3 for Color Maximite 2  9/20/2020
'By the Sasquatch
'[...]
'Check for Wii Nunchuk
 On Error Skip 1
   Wii Nunchuk Open
 If MM.ERRNO = 0 Then
  If Nunchuk(T) = &HA4200000 Then  'Check for original style nunchuk
    HaveChuk = True
  Else
    Wii Nunchuk Close
  End If
 End If

 If Not HaveChuk Then
   'Check for Wii Classic Controller
   On Error Skip 1
     Wii Classic Open
   If MM.ERRNO = 0 Then
    If Classic(T) = &HA4200101 Then  'Check for Classic
      HaveClassic = True
    Else
      Wii Classic Close
    End If
   End If
 End If


I used this for a short test:
TRUE=1
FALSE=Not TRUE

 On Error Skip 1
   Wii Nunchuk Open
 If MM.ERRNO = 0 Then HaveChuk = True

? HaveChuk


PRINT HEX$(NUNCHUK(T, 3))



do

PRINT "X-Joystick:"NUNCHUK(JX, 3)
PRINT "Y-Joystick:"NUNCHUK(JY, 3)

PRINT "Z-BUTTON   :"NUNCHUK(Z, 3)
PRINT "C-BUTTON   :"NUNCHUK(C, 3)


PRINT "X"NUNCHUK(AX, 3)-512
PRINT "Y"NUNCHUK(AY, 3)-512
PRINT "Z"NUNCHUK(AZ, 3)-512

PRINT NUNCHUK(AX0, 3)-512
PRINT NUNCHUK(AX1, 3)-684
PRINT NUNCHUK(AY0, 3)-512
PRINT NUNCHUK(AY1, 3)-684
PRINT NUNCHUK(AZ0, 3)-512
PRINT NUNCHUK(AZ1, 3)-684

pause 1000
loop


Michael
‚My name is Ozymandias, king of kings
Look on my works, ye Mighty, and despair!‘
Nothing beside remains. Round the decay
Of that colossal wreck, boundless and bare
The lone and ...
 
Archimedes5000
Newbie

Joined: 21/01/2021
Location: Germany
Posts: 6
Posted: 03:52pm 10 Apr 2021
Copy link to clipboard 
Print this post

Please take a look at this great product. It has 3 nunchuk ports.
https://www.thebackshed.com/forum/ViewTopic.php?FID=16&TID=13673

So I have to find out whether and to which port a nunchuk is connected.

I will be back...

Greetings Axel
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2026