Two real joysticks cause problem
Alexander Lazarević
Alexander at lazarevic.de
Tue Feb 15 19:37:34 UTC 2005
Compatibility? Bah! ;)
Just download the new VM from [1] and file in attached ChangeSet. Hope
this works for you, because I only had a single joystick at hand to test.
Alex
[1] http://www.lazarevic.de/stick.html
> Thank you! Seems like not only the VM, but the Squeak code needs to
> be modified. Can you think of a smaller change to the Squeak code
> that is just good enough to support (and keep the compatibility of)
> the JoystickMorph and eToys? That would be really helpful.
-------------- next part --------------
'From Squeak3.7 of ''4 September 2004'' [latest update: #5989] on 15 February 2005 at 7:25:07 pm'!
!InputSensor methodsFor: 'joystick' stamp: 'laza 2/15/2005 19:03'!
joystickXY: index
| inputWord x y |
inputWord _ self primReadJoystick: index.
x _ (inputWord bitAnd: 16r7FF) - 16r3FF.
y _ ((inputWord bitShift: -11) bitAnd: 16r7FF) - 16r3FF.
^ x at y
! !
!InputSensor methodsFor: 'private' stamp: 'laza 2/15/2005 19:04'!
primReadJoystick: index
"Return the joystick input word for the joystick with the given index in the range [1..10]. Returns zero if the index does not correspond to a currently installed joystick."
<primitive: 'primitiveReadJoystick' module: 'StickPlugin'>
^ 0
! !
!JoystickMorph methodsFor: 'stepping and presenter' stamp: 'laza 2/15/2005 19:19'!
step
"Track the real joystick whose index is realJoystickIndex."
"Details:
a. if realJoystickIndex is nil we're not tracking a joystick
b. [-joyMax..joyMax] is nominal range of joystick in both X and Y"
| joyMax joyPt m mCenter r scaledPt |
super step. "Run ticking user-written scripts if any"
realJoystickIndex ifNil: [^ self].
joyMax _ 1024.
joyPt _ Sensor joystickXY: realJoystickIndex.
lastRealJoystickValue = joyPt ifTrue: [^ self].
lastRealJoystickValue _ joyPt.
m _ handleMorph.
mCenter _ m center.
r _ m owner innerBounds insetBy:
((mCenter - m fullBounds origin) corner: (m fullBounds corner - mCenter)).
scaledPt _ r center + ((r extent * joyPt) / (joyMax * 2)) truncated.
m position: (scaledPt adhereTo: r) - (m extent // 2).
! !
!JoystickMorph reorganize!
('accessing' amount angle leftRight upDown)
('event handling' handlesMouseDown: mouseMove: mouseUp:)
('initialization' initialize)
('menu' addCustomMenuItems:hand: setXRange setYRange stopTrackingJoystick toggleAutoCenter trackRealJoystick)
('other' moveHandleToCenter)
('parts bin' initializeToStandAlone)
('stepping and presenter' step stepTime)
!
More information about the Squeak-dev
mailing list
|