-
Notifications
You must be signed in to change notification settings - Fork 10
Accomodate new pan event changes #56
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -717,17 +717,37 @@ CAMLprim value Val_SDL_Event(SDL_Event *event) { | |
case SDL_PANEVENT: | ||
v = caml_alloc(1, 24); | ||
|
||
vInner = caml_alloc(9, 0); | ||
vInner = caml_alloc(5 * 8, 0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 5 * 8 ???? why. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. me being dumb, was adjusting number of fields and forgot to change to constant thanks for the catch |
||
Store_field(vInner, 0, Val_int(event->window.windowID)); | ||
Store_field(vInner, 1, Val_int(event->pan.x)); | ||
Store_field(vInner, 2, Val_int(event->pan.y)); | ||
Store_field(vInner, 3, Val_bool(event->pan.contains_x)); | ||
Store_field(vInner, 4, Val_bool(event->pan.contains_y)); | ||
Store_field(vInner, 5, Val_bool(event->pan.fling)); | ||
Store_field(vInner, 6, Val_bool(event->pan.interrupt)); | ||
// verify this is the correct way of representing a ref to some WheelType.t | ||
Store_field(vInner, 7, Val_int(event->pan.source_type)); | ||
Store_field(vInner, 8, Val_int(event->pan.timestamp)); | ||
Store_field(vInner, 1, Val_int(event->pan.timestamp)); | ||
|
||
Store_field(vInner, 2, Val_int(event->pan.source)); | ||
int axis; | ||
if( event->pan.axis == SDL_PAN_AXIS_VERTICAL ) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would suggest: switch in case we add diagonal pan. And we could get exhaustivity checking with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thankfully I think a diagonal pan is always sum of vertical and horizontal, though agree a switch is more semantically clear here |
||
axis = 0; | ||
} else { | ||
axis = 1; | ||
} | ||
|
||
Store_field(vInner, 3, Val_int(axis)); | ||
|
||
if( event->pan.pantype == SDL_PANEVENTTYPE_PAN ) { | ||
// tagged 0 for only non-constant constructor Pan(float) | ||
CAMLlocal2(panElement, floatElement); | ||
panElement = caml_alloc(1, 0); | ||
|
||
floatElement = caml_copy_double(event->pan.contents.pan.delta); | ||
|
||
Store_field(panElement, 0, floatElement); | ||
|
||
Store_field(vInner, 4, panElement); | ||
} else { | ||
if( event->pan.pantype == SDL_PANEVENTTYPE_INTERRUPT ) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here again a switch is better: reduce nesting. Don't omit break; |
||
Store_field(vInner, 4, Val_int(0)); | ||
} else if( event->pan.pantype == SDL_PANEVENTTYPE_FLING ) { | ||
Store_field(vInner, 4, Val_int(1)); | ||
} | ||
} | ||
|
||
Store_field(v, 0, vInner); | ||
break; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is mousePan still used ?